Add actions for peak and star find
This commit is contained in:
@@ -8,6 +8,14 @@ typedef QVector<StringPair> ImageInfoData;
|
|||||||
|
|
||||||
Q_DECLARE_METATYPE(ImageInfoData);
|
Q_DECLARE_METATYPE(ImageInfoData);
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Statistics,
|
||||||
|
Peaks,
|
||||||
|
Stars,
|
||||||
|
}AnalyzeLevel;
|
||||||
|
|
||||||
class ImageInfo : public QTreeWidget
|
class ImageInfo : public QTreeWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
+15
-5
@@ -22,7 +22,7 @@ void Image::load()
|
|||||||
{
|
{
|
||||||
m_loading = true;
|
m_loading = true;
|
||||||
m_released = false;
|
m_released = false;
|
||||||
QThreadPool::globalInstance()->start(new LoadRunable(m_name, this, m_ringList->calculateStats()));
|
QThreadPool::globalInstance()->start(new LoadRunable(m_name, this, m_ringList->analyzeLevel()));
|
||||||
}
|
}
|
||||||
if(!m_loading && !m_pixmap.isNull())
|
if(!m_loading && !m_pixmap.isNull())
|
||||||
emit pixmapLoaded(this);
|
emit pixmapLoaded(this);
|
||||||
@@ -68,7 +68,7 @@ void Image::imageLoaded(QImage img, ImageInfoData info)
|
|||||||
|
|
||||||
ImageRingList::ImageRingList(QObject *parent) : QObject(parent)
|
ImageRingList::ImageRingList(QObject *parent) : QObject(parent)
|
||||||
, m_liveMode(false)
|
, m_liveMode(false)
|
||||||
, m_calculateStats(false)
|
, m_analyzeLevel(None)
|
||||||
{
|
{
|
||||||
connect(&m_fileSystemWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(dirChanged(QString)));
|
connect(&m_fileSystemWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(dirChanged(QString)));
|
||||||
}
|
}
|
||||||
@@ -150,12 +150,22 @@ void ImageRingList::setLiveMode(bool live)
|
|||||||
|
|
||||||
void ImageRingList::setCalculateStats(bool stats)
|
void ImageRingList::setCalculateStats(bool stats)
|
||||||
{
|
{
|
||||||
m_calculateStats = stats;
|
m_analyzeLevel = stats ? Statistics : None;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImageRingList::calculateStats() const
|
void ImageRingList::setFindPeaks(bool findPeaks)
|
||||||
{
|
{
|
||||||
return m_calculateStats;
|
m_analyzeLevel = findPeaks ? Peaks : None;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImageRingList::setFindStars(bool findStars)
|
||||||
|
{
|
||||||
|
m_analyzeLevel = findStars ? Stars : None;
|
||||||
|
}
|
||||||
|
|
||||||
|
AnalyzeLevel ImageRingList::analyzeLevel() const
|
||||||
|
{
|
||||||
|
return m_analyzeLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageRingList::setFiles(const QStringList files, const QString ¤tFile)
|
void ImageRingList::setFiles(const QStringList files, const QString ¤tFile)
|
||||||
|
|||||||
+4
-2
@@ -46,7 +46,7 @@ class ImageRingList : public QObject
|
|||||||
QList<ImagePtr>::iterator m_lastImage;
|
QList<ImagePtr>::iterator m_lastImage;
|
||||||
QFileSystemWatcher m_fileSystemWatcher;
|
QFileSystemWatcher m_fileSystemWatcher;
|
||||||
bool m_liveMode;
|
bool m_liveMode;
|
||||||
bool m_calculateStats;
|
AnalyzeLevel m_analyzeLevel;
|
||||||
public:
|
public:
|
||||||
explicit ImageRingList(QObject *parent = 0);
|
explicit ImageRingList(QObject *parent = 0);
|
||||||
~ImageRingList();
|
~ImageRingList();
|
||||||
@@ -57,7 +57,9 @@ public:
|
|||||||
void decrement();
|
void decrement();
|
||||||
void setLiveMode(bool live);
|
void setLiveMode(bool live);
|
||||||
void setCalculateStats(bool stats);
|
void setCalculateStats(bool stats);
|
||||||
bool calculateStats() const;
|
void setFindPeaks(bool findPeaks);
|
||||||
|
void setFindStars(bool findStars);
|
||||||
|
AnalyzeLevel analyzeLevel() const;
|
||||||
protected:
|
protected:
|
||||||
void setFiles(const QStringList files, const QString ¤tFile = QString());
|
void setFiles(const QStringList files, const QString ¤tFile = QString());
|
||||||
QList<ImagePtr>::iterator increment(QList<ImagePtr>::iterator iter);
|
QList<ImagePtr>::iterator increment(QList<ImagePtr>::iterator iter);
|
||||||
|
|||||||
+4
-4
@@ -7,10 +7,10 @@
|
|||||||
#include <fitsio2.h>
|
#include <fitsio2.h>
|
||||||
#include "rawimage.h"
|
#include "rawimage.h"
|
||||||
|
|
||||||
LoadRunable::LoadRunable(const QString &file, Image *receiver, bool stats) :
|
LoadRunable::LoadRunable(const QString &file, Image *receiver, AnalyzeLevel level) :
|
||||||
m_file(file),
|
m_file(file),
|
||||||
m_receiver(receiver),
|
m_receiver(receiver),
|
||||||
m_calculateStats(stats)
|
m_analyzeLevel(level)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,11 +211,11 @@ void LoadRunable::run()
|
|||||||
RawImageAbs *rawImage = nullptr;
|
RawImageAbs *rawImage = nullptr;
|
||||||
if(m_file.endsWith(".CR2", Qt::CaseInsensitive))
|
if(m_file.endsWith(".CR2", Qt::CaseInsensitive))
|
||||||
{
|
{
|
||||||
loadRAW(m_file, info, m_calculateStats ? &rawImage : nullptr, &img);
|
loadRAW(m_file, info, m_analyzeLevel != None ? &rawImage : nullptr, &img);
|
||||||
}
|
}
|
||||||
else if(m_file.endsWith(".FIT", Qt::CaseInsensitive))
|
else if(m_file.endsWith(".FIT", Qt::CaseInsensitive))
|
||||||
{
|
{
|
||||||
loadFITS(m_file, info, m_calculateStats ? &rawImage : nullptr, &img);
|
loadFITS(m_file, info, m_analyzeLevel != None ? &rawImage : nullptr, &img);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
+3
-2
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QRunnable>
|
#include <QRunnable>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include "imageinfo.h"
|
||||||
|
|
||||||
class Image;
|
class Image;
|
||||||
|
|
||||||
@@ -10,9 +11,9 @@ class LoadRunable : public QRunnable
|
|||||||
{
|
{
|
||||||
QString m_file;
|
QString m_file;
|
||||||
Image *m_receiver;
|
Image *m_receiver;
|
||||||
bool m_calculateStats;
|
AnalyzeLevel m_analyzeLevel;
|
||||||
public:
|
public:
|
||||||
LoadRunable(const QString &file, Image *receiver, bool stats);
|
LoadRunable(const QString &file, Image *receiver, AnalyzeLevel level);
|
||||||
void run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+32
-4
@@ -62,12 +62,30 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),
|
|||||||
selectMenu->addAction(tr("Unmark and next"), this, SLOT(unmarkAndNext()), Qt::Key_X);
|
selectMenu->addAction(tr("Unmark and next"), this, SLOT(unmarkAndNext()), Qt::Key_X);
|
||||||
menuBar()->addMenu(selectMenu);
|
menuBar()->addMenu(selectMenu);
|
||||||
|
|
||||||
QMenu *statsMenu = new QMenu(tr("Statistic"), this);
|
QMenu *analyzeMenu = new QMenu(tr("Analyze"), this);
|
||||||
QAction *statsAction = new QAction(tr("Image statistics"), this);
|
QActionGroup *analyzeGroup = new QActionGroup(this);
|
||||||
|
connect(analyzeGroup, &QActionGroup::triggered, [](QAction* action) {
|
||||||
|
static QAction* lastAction = nullptr;
|
||||||
|
if(action == lastAction)
|
||||||
|
{
|
||||||
|
action->setChecked(false);
|
||||||
|
lastAction = nullptr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
lastAction = action;
|
||||||
|
});
|
||||||
|
|
||||||
|
QAction *statsAction = analyzeGroup->addAction(tr("Image statistics"));
|
||||||
|
QAction *peakAction = analyzeGroup->addAction(tr("Peak finder"));
|
||||||
|
QAction *starAction = analyzeGroup->addAction("Star finder");
|
||||||
statsAction->setCheckable(true);
|
statsAction->setCheckable(true);
|
||||||
|
peakAction->setCheckable(true);
|
||||||
|
starAction->setCheckable(true);
|
||||||
connect(statsAction, SIGNAL(toggled(bool)), this, SLOT(imageStats(bool)));
|
connect(statsAction, SIGNAL(toggled(bool)), this, SLOT(imageStats(bool)));
|
||||||
statsMenu->addAction(statsAction);
|
connect(peakAction, SIGNAL(toggled(bool)), this, SLOT(peakFinder(bool)));
|
||||||
menuBar()->addMenu(statsMenu);
|
connect(starAction, SIGNAL(toggled(bool)), this, SLOT(starFinder(bool)));
|
||||||
|
analyzeMenu->addActions({statsAction, peakAction, starAction});
|
||||||
|
menuBar()->addMenu(analyzeMenu);
|
||||||
|
|
||||||
m_database = new Database(this);
|
m_database = new Database(this);
|
||||||
if(!m_database->init())
|
if(!m_database->init())
|
||||||
@@ -252,6 +270,16 @@ void MainWindow::imageStats(bool imageStats)
|
|||||||
m_ringList->setCalculateStats(imageStats);
|
m_ringList->setCalculateStats(imageStats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::peakFinder(bool findPeaks)
|
||||||
|
{
|
||||||
|
m_ringList->setFindPeaks(findPeaks);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::starFinder(bool findStars)
|
||||||
|
{
|
||||||
|
m_ringList->setFindStars(findStars);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::updateWindowTitle()
|
void MainWindow::updateWindowTitle()
|
||||||
{
|
{
|
||||||
ImagePtr ptr = m_ringList->currentImage();
|
ImagePtr ptr = m_ringList->currentImage();
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ protected slots:
|
|||||||
void copyMarked();
|
void copyMarked();
|
||||||
void liveMode(bool active);
|
void liveMode(bool active);
|
||||||
void imageStats(bool imageStats);
|
void imageStats(bool imageStats);
|
||||||
|
void peakFinder(bool findPeaks);
|
||||||
|
void starFinder(bool findStars);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user