Compare commits

...

6 Commits

Author SHA1 Message Date
nou 85f9822b96 Fix prevSubImage 2025-03-25 18:26:08 +01:00
nou 7fc6c64fd7 Make help windows non modal 2025-03-24 22:09:18 +01:00
nou 4488c2e6af Always make 4 channels 2025-03-24 22:08:54 +01:00
nou 0047607c1d Add loading sub images 2025-03-23 13:33:34 +01:00
nou 45c368bbbb Remove usage of SLOT() and SIGNAL() 2025-03-19 13:50:39 +01:00
nou c96cb86a29 Show relative path in title bar for when browsing dir recursive 2025-03-19 13:14:04 +01:00
17 changed files with 159 additions and 70 deletions
+2
View File
@@ -32,6 +32,8 @@ HelpDialog::HelpDialog(QWidget *parent) : QDialog(parent)
{ {
setWindowTitle(tr("Help")); setWindowTitle(tr("Help"));
resize(1000, 600); resize(1000, 600);
setModal(false);
setAttribute(Qt::WA_DeleteOnClose, true);
QVBoxLayout *layout = new QVBoxLayout(this); QVBoxLayout *layout = new QVBoxLayout(this);
QTextEdit *helpText = new QTextEdit(this); QTextEdit *helpText = new QTextEdit(this);
+1 -1
View File
@@ -308,7 +308,7 @@ DataBaseView::DataBaseView(Database *database, QWidget *parent) : QWidget(parent
} }
QPushButton *filterButton = new QPushButton(tr("Filter"), this); QPushButton *filterButton = new QPushButton(tr("Filter"), this);
connect(filterButton, SIGNAL(pressed()), this, SLOT(applyFilter())); connect(filterButton, &QPushButton::pressed, this, &DataBaseView::applyFilter);
hlayout->addWidget(filterButton); hlayout->addWidget(filterButton);
connect(m_database, &Database::databaseChanged, [this, &addFilterItems](){ connect(m_database, &Database::databaseChanged, [this, &addFilterItems](){
+2
View File
@@ -76,6 +76,8 @@ struct ImageInfoData
QVector<QPair<QString, QString>> info; QVector<QPair<QString, QString>> info;
std::shared_ptr<WCSDataT> wcs; std::shared_ptr<WCSDataT> wcs;
SkyPointScale getCenterRaDec() const; SkyPointScale getCenterRaDec() const;
int index = 0;
int num = 1;
}; };
typedef enum typedef enum
+55 -18
View File
@@ -23,13 +23,16 @@ Image::Image(const QString name, int number, ImageRingList *ringList) :
{ {
} }
void Image::load(QThreadPool *pool) void Image::load(int index, QThreadPool *pool)
{ {
if(index != m_info.index && !m_loading)
m_rawImage.reset();
if(!m_rawImage && !m_loading) if(!m_rawImage && !m_loading)
{ {
m_loading = true; m_loading = true;
m_released = false; m_released = false;
pool->start(new LoadRunable(m_name, this, m_ringList->analyzeLevel())); pool->start(new LoadRunable(m_name, this, m_ringList->analyzeLevel(), index));
} }
if(!m_loading && m_rawImage) if(!m_loading && m_rawImage)
emit pixmapLoaded(this); emit pixmapLoaded(this);
@@ -38,7 +41,7 @@ void Image::load(QThreadPool *pool)
void Image::loadThumbnail(QThreadPool *pool) void Image::loadThumbnail(QThreadPool *pool)
{ {
if(!m_thumbnail) if(!m_thumbnail)
pool->start(new LoadRunable(m_name, this, AnalyzeLevel::None, true)); pool->start(new LoadRunable(m_name, this, AnalyzeLevel::None, 0, true));
else else
emit thumbnailLoaded(this); emit thumbnailLoaded(this);
} }
@@ -115,7 +118,7 @@ ImageRingList::ImageRingList(Database *database, const QStringList &nameFilter,
, m_nameFilter(nameFilter) , m_nameFilter(nameFilter)
, m_fileSuffix(nameFilter) , m_fileSuffix(nameFilter)
{ {
connect(&m_fileSystemWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(dirChanged(QString))); connect(&m_fileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, &ImageRingList::dirChanged);
m_nameFilter.replaceInStrings(QRegularExpression("^"), "*."); m_nameFilter.replaceInStrings(QRegularExpression("^"), "*.");
m_loadPool = new QThreadPool(this); m_loadPool = new QThreadPool(this);
m_loadPool->setThreadPriority(QThread::LowPriority); m_loadPool->setThreadPriority(QThread::LowPriority);
@@ -146,6 +149,7 @@ bool ImageRingList::setDir(const QString path, const QString &currentFile, bool
if(dir.exists()) if(dir.exists())
{ {
m_currentDir = path;
QStringList scannedDirs; QStringList scannedDirs;
QStringList absolutePaths; QStringList absolutePaths;
std::function<void(const QString&)> scanDir = [&](const QString &path) std::function<void(const QString&)> scanDir = [&](const QString &path)
@@ -174,7 +178,8 @@ bool ImageRingList::setDir(const QString path, const QString &currentFile, bool
//qDebug() << absolutePaths.size(); //qDebug() << absolutePaths.size();
setFilesPrivate(absolutePaths, m_liveMode ? absolutePaths.first() : currentFile); setFilesPrivate(absolutePaths, m_liveMode ? absolutePaths.first() : currentFile);
m_fileSystemWatcher.removePaths(m_fileSystemWatcher.directories()); if(m_fileSystemWatcher.directories().size())
m_fileSystemWatcher.removePaths(m_fileSystemWatcher.directories());
m_fileSystemWatcher.addPath(path); m_fileSystemWatcher.addPath(path);
return true; return true;
} }
@@ -212,6 +217,11 @@ ImagePtr ImageRingList::currentImage()
return 0; return 0;
} }
QString ImageRingList::currentDir() const
{
return m_currentDir;
}
void ImageRingList::increment() void ImageRingList::increment()
{ {
if(m_images.size()) if(m_images.size())
@@ -223,9 +233,9 @@ void ImageRingList::increment()
(*m_firstImage)->release(); (*m_firstImage)->release();
m_firstImage = increment(m_firstImage); m_firstImage = increment(m_firstImage);
m_currImage = increment(m_currImage); m_currImage = increment(m_currImage);
(*m_currImage)->load(m_loadPool); (*m_currImage)->load(0, m_loadPool);
m_lastImage = increment(m_lastImage); m_lastImage = increment(m_lastImage);
(*m_lastImage)->load(m_loadPool); (*m_lastImage)->load(0, m_loadPool);
} }
} }
@@ -240,9 +250,37 @@ void ImageRingList::decrement()
(*m_lastImage)->release(); (*m_lastImage)->release();
m_firstImage = decrement(m_firstImage); m_firstImage = decrement(m_firstImage);
m_currImage = decrement(m_currImage); m_currImage = decrement(m_currImage);
(*m_currImage)->load(m_loadPool); (*m_currImage)->load(0, m_loadPool);
m_lastImage = decrement(m_lastImage); m_lastImage = decrement(m_lastImage);
(*m_firstImage)->load(m_loadPool); (*m_firstImage)->load(0, m_loadPool);
}
}
void ImageRingList::prevSubImage()
{
if(m_images.size())
{
if((*m_currImage)->isLoading())
return;
int index = (*m_currImage)->info().index;
int num = (*m_currImage)->info().num;
if(num > 1)
(*m_currImage)->load(index == 0 ? num - 1 : index - 1, m_loadPool);
}
}
void ImageRingList::nextSubImage()
{
if(m_images.size())
{
if((*m_currImage)->isLoading())
return;
int index = (*m_currImage)->info().index;
int num = (*m_currImage)->info().num;
if(num > 1)
(*m_currImage)->load((index + 1) % num, m_loadPool);
} }
} }
@@ -296,7 +334,7 @@ void ImageRingList::loadFile(int row)
if(m_images.empty()) if(m_images.empty())
return; return;
(*m_currImage)->load(m_loadPool); (*m_currImage)->load(0, m_loadPool);
m_width = DEFAULT_WIDTH<m_images.size()/2 ? DEFAULT_WIDTH : m_images.size()/2; m_width = DEFAULT_WIDTH<m_images.size()/2 ? DEFAULT_WIDTH : m_images.size()/2;
if(m_liveMode) if(m_liveMode)
@@ -305,9 +343,9 @@ void ImageRingList::loadFile(int row)
for(int i=0; i<m_width; i++) for(int i=0; i<m_width; i++)
{ {
m_firstImage = decrement(m_firstImage); m_firstImage = decrement(m_firstImage);
(*m_firstImage)->load(m_loadPool); (*m_firstImage)->load(0, m_loadPool);
m_lastImage = increment(m_lastImage); m_lastImage = increment(m_lastImage);
(*m_lastImage)->load(m_loadPool); (*m_lastImage)->load(0, m_loadPool);
} }
if(m_lastImage != m_firstImage) if(m_lastImage != m_firstImage)
{ {
@@ -431,9 +469,9 @@ void ImageRingList::setPreload(int width)
for(int i = newWidth - m_width; i>0; i--) for(int i = newWidth - m_width; i>0; i--)
{ {
m_firstImage = decrement(m_firstImage); m_firstImage = decrement(m_firstImage);
(*m_firstImage)->load(m_loadPool); (*m_firstImage)->load(0, m_loadPool);
m_lastImage = increment(m_lastImage); m_lastImage = increment(m_lastImage);
(*m_lastImage)->load(m_loadPool); (*m_lastImage)->load(0, m_loadPool);
} }
} }
if(newWidth < m_width) if(newWidth < m_width)
@@ -498,8 +536,8 @@ void ImageRingList::setFilesPrivate(const QStringList files, const QString &curr
for(const QString &file : files) for(const QString &file : files)
{ {
ImagePtr ptr = make_shared<Image>(file, i++, this); ImagePtr ptr = make_shared<Image>(file, i++, this);
connect(ptr.get(), SIGNAL(pixmapLoaded(Image*)), this, SLOT(imageLoaded(Image*))); connect(ptr.get(), &Image::pixmapLoaded, this, &ImageRingList::imageLoaded);
connect(ptr.get(), SIGNAL(thumbnailLoaded(Image*)), this, SIGNAL(thumbnailLoaded(Image*))); connect(ptr.get(), &Image::thumbnailLoaded, this, &ImageRingList::thumbnailLoaded);
m_images.append(ptr); m_images.append(ptr);
} }
@@ -538,9 +576,8 @@ void ImageRingList::imageLoaded(Image *image)
} }
} }
void ImageRingList::dirChanged(QString dir) void ImageRingList::dirChanged(QString)
{ {
m_currentDir = dir;
if(m_liveMode) if(m_liveMode)
reloadDir(); reloadDir();
else else
+5 -2
View File
@@ -28,7 +28,7 @@ class Image : public QObject
ImageRingList *m_ringList; ImageRingList *m_ringList;
public: public:
explicit Image(const QString name, int number, ImageRingList *ringList); explicit Image(const QString name, int number, ImageRingList *ringList);
void load(QThreadPool *pool); void load(int index, QThreadPool *pool);
void loadThumbnail(QThreadPool *pool); void loadThumbnail(QThreadPool *pool);
void release(); void release();
QString name() const; QString name() const;
@@ -79,6 +79,7 @@ public:
void setFile(const QString &file); void setFile(const QString &file);
void setFiles(QStringList files); void setFiles(QStringList files);
ImagePtr currentImage(); ImagePtr currentImage();
QString currentDir() const;
void setLiveMode(bool live); void setLiveMode(bool live);
void setCalculateStats(bool stats); void setCalculateStats(bool stats);
void setFindPeaks(bool findPeaks); void setFindPeaks(bool findPeaks);
@@ -105,6 +106,8 @@ public slots:
void toggleSlideshow(bool start); void toggleSlideshow(bool start);
void increment(); void increment();
void decrement(); void decrement();
void prevSubImage();
void nextSubImage();
void setMarked(); void setMarked();
protected: protected:
void setFilesPrivate(const QStringList files, const QString &currentFile = QString()); void setFilesPrivate(const QStringList files, const QString &currentFile = QString());
@@ -117,7 +120,7 @@ signals:
void currentImageChanged(int index); void currentImageChanged(int index);
protected slots: protected slots:
void imageLoaded(Image *image); void imageLoaded(Image *image);
void dirChanged(QString dir); void dirChanged(QString);
void reloadDir(); void reloadDir();
}; };
+2 -2
View File
@@ -27,8 +27,8 @@ ImageScrollArea::ImageScrollArea(Database *database, QWidget *parent) : QWidget(
layout->addWidget(m_verticalScrollBar, 0, 1); layout->addWidget(m_verticalScrollBar, 0, 1);
layout->addWidget(m_horizontalScrollBar, 1, 0); layout->addWidget(m_horizontalScrollBar, 1, 0);
connect(m_verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(scrollEvent())); connect(m_verticalScrollBar, &QScrollBar::valueChanged, this, &ImageScrollArea::scrollEvent);
connect(m_horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(scrollEvent())); connect(m_horizontalScrollBar, &QScrollBar::valueChanged, this, &ImageScrollArea::scrollEvent);
if(imageWidgetGL) if(imageWidgetGL)
{ {
+1 -1
View File
@@ -79,7 +79,7 @@ ImageWidgetGL::ImageWidgetGL(Database *database, QWidget *parent) : QOpenGLWidge
m_updateTimer = new QTimer(this); m_updateTimer = new QTimer(this);
m_updateTimer->setInterval(500); m_updateTimer->setInterval(500);
m_updateTimer->setSingleShot(true); m_updateTimer->setSingleShot(true);
connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(update())); connect(m_updateTimer, &QTimer::timeout, this, static_cast<void (QOpenGLWidget::*)()>(&ImageWidgetGL::update));
setAcceptDrops(true); setAcceptDrops(true);
QTimer::singleShot(1000, [this](){ QTimer::singleShot(1000, [this](){
if(!isValid()) if(!isValid())
+40 -13
View File
@@ -83,11 +83,10 @@ int loadFITSHeader(fitsfile *file, ImageInfoData &info)
return status; return status;
} }
bool loadFITS(const QString path, ImageInfoData &info, std::shared_ptr<RawImage> &image, bool planar) bool loadFITS(const QString path, ImageInfoData &info, std::shared_ptr<RawImage> &image, bool planar, uint32_t index)
{ {
fitsfile *file; fitsfile *file;
int status = 0; int status = 0;
int type = -1;
int num = 0; int num = 0;
long naxes[3] = {0}; long naxes[3] = {0};
@@ -105,16 +104,32 @@ bool loadFITS(const QString path, ImageInfoData &info, std::shared_ptr<RawImage>
fits_get_num_hdus(file, &num, &status); fits_get_num_hdus(file, &num, &status);
if(status)return checkError(); if(status)return checkError();
int hdutype;
int imgtype; int imgtype;
int naxis; int naxis;
for(int i=1; i <= num; i++) std::vector<int> imageIdxs;
for(int i = 1; i <= num; i++)
{ {
fits_movabs_hdu(file, i, IMAGE_HDU, &status);if(status)return checkError(); fits_movabs_hdu(file, i, &hdutype, &status);if(status)return checkError();
fits_get_hdu_type(file, &type, &status);if(status)return checkError(); if(hdutype == IMAGE_HDU)
{
fits_get_img_param(file, 3, &imgtype, &naxis, naxes, &status);if(status)return checkError();
if(naxis >= 2 && naxis <= 3)imageIdxs.push_back(i);
}
}
info.num = imageIdxs.size();
info.index = index;
if(index >= imageIdxs.size())return false;
fits_movabs_hdu(file, imageIdxs[index], &hdutype, &status);if(status)return checkError();
if(hdutype == IMAGE_HDU)
{
naxes[0] = naxes[1] = naxes[2] = 0;
fits_get_img_param(file, 3, &imgtype, &naxis, naxes, &status);if(status)return checkError(); fits_get_img_param(file, 3, &imgtype, &naxis, naxes, &status);if(status)return checkError();
fits_get_img_equivtype(file, &imgtype, &status);if(status)return checkError(); fits_get_img_equivtype(file, &imgtype, &status);if(status)return checkError();
if(type == IMAGE_HDU && naxis >= 2 && naxis <= 3 && status == 0) if(hdutype == IMAGE_HDU && naxis >= 2 && naxis <= 3 && status == 0)
{ {
RawImage::DataType type; RawImage::DataType type;
int fitstype; int fitstype;
@@ -133,6 +148,10 @@ bool loadFITS(const QString path, ImageInfoData &info, std::shared_ptr<RawImage>
type = RawImage::UINT16; type = RawImage::UINT16;
fitstype = TUSHORT; fitstype = TUSHORT;
break; break;
case LONG_IMG:
type = RawImage::UINT32;
fitstype = TINT;
break;
case ULONG_IMG: case ULONG_IMG:
type = RawImage::UINT32; type = RawImage::UINT32;
fitstype = TUINT; fitstype = TUINT;
@@ -173,13 +192,18 @@ bool loadFITS(const QString path, ImageInfoData &info, std::shared_ptr<RawImage>
for(size_t i=0; i<size; i++) for(size_t i=0; i<size; i++)
s[i] -= INT16_MIN; s[i] -= INT16_MIN;
} }
else if(fitstype == TINT)
{
uint32_t *s = static_cast<uint32_t*>(img.data());
size_t size = img.size() * img.channels();
for(size_t i=0; i<size; i++)
s[i] -= INT32_MIN;
}
if(img.channels() == 1 || planar) if(img.channels() == 1 || planar)
image = std::make_shared<RawImage>(std::move(img)); image = std::make_shared<RawImage>(std::move(img));
else else
image = RawImage::fromPlanar(img); image = RawImage::fromPlanar(img);
break;
} }
} }
noload: noload:
@@ -202,14 +226,15 @@ noload:
return true; return true;
} }
bool loadXISF(const QString &path, ImageInfoData &info, std::shared_ptr<RawImage> &image, bool planar) bool loadXISF(const QString &path, ImageInfoData &info, std::shared_ptr<RawImage> &image, bool planar, uint32_t index)
{ {
try try
{ {
LibXISF::XISFReader xisf; LibXISF::XISFReader xisf;
xisf.open(path.toLocal8Bit().data()); xisf.open(path.toLocal8Bit().data());
const LibXISF::Image &xisfImage = xisf.getImage(0); if(index >= (uint32_t)xisf.imagesCount())return false;
const LibXISF::Image &xisfImage = xisf.getImage(index);
auto fitskeywords = xisfImage.fitsKeywords(); auto fitskeywords = xisfImage.fitsKeywords();
for(auto fits : fitskeywords) for(auto fits : fitskeywords)
@@ -222,6 +247,8 @@ bool loadXISF(const QString &path, ImageInfoData &info, std::shared_ptr<RawImage
info.fitsHeader.append(prop); info.fitsHeader.append(prop);
} }
info.num = xisf.imagesCount();
info.index = index + 1;
info.wcs = std::make_shared<WCSDataT>(xisfImage.width(), xisfImage.height(), info.fitsHeader); info.wcs = std::make_shared<WCSDataT>(xisfImage.width(), xisfImage.height(), info.fitsHeader);
info.info.append({QObject::tr("Width"), QString::number(xisfImage.width())}); info.info.append({QObject::tr("Width"), QString::number(xisfImage.width())});
info.info.append({QObject::tr("Height"), QString::number(xisfImage.height())}); info.info.append({QObject::tr("Height"), QString::number(xisfImage.height())});
@@ -378,7 +405,7 @@ bool loadRAW(const QString path, ImageInfoData &info, std::shared_ptr<RawImage>
return true; return true;
} }
bool loadImage(const QString &path, ImageInfoData &info, std::shared_ptr<RawImage> &rawImage, bool planar) bool loadImage(const QString &path, ImageInfoData &info, std::shared_ptr<RawImage> &rawImage, int index, bool planar)
{ {
bool ret = false; bool ret = false;
QElapsedTimer timer; QElapsedTimer timer;
@@ -390,12 +417,12 @@ bool loadImage(const QString &path, ImageInfoData &info, std::shared_ptr<RawImag
} }
else if(path.endsWith(".FIT", Qt::CaseInsensitive) || path.endsWith(".FITS", Qt::CaseInsensitive) || path.endsWith(".FZ", Qt::CaseInsensitive) || path.endsWith(".FTS", Qt::CaseInsensitive)) else if(path.endsWith(".FIT", Qt::CaseInsensitive) || path.endsWith(".FITS", Qt::CaseInsensitive) || path.endsWith(".FZ", Qt::CaseInsensitive) || path.endsWith(".FTS", Qt::CaseInsensitive))
{ {
ret = loadFITS(path, info, rawImage, planar); ret = loadFITS(path, info, rawImage, planar, index);
qDebug() << "LoadFITS" << timer.elapsed(); qDebug() << "LoadFITS" << timer.elapsed();
} }
else if(path.endsWith(".XISF", Qt::CaseInsensitive)) else if(path.endsWith(".XISF", Qt::CaseInsensitive))
{ {
ret = loadXISF(path, info, rawImage, planar); ret = loadXISF(path, info, rawImage, planar, index);
qDebug() << "LoadXISF" << timer.elapsed(); qDebug() << "LoadXISF" << timer.elapsed();
} }
else else
+1 -1
View File
@@ -9,6 +9,6 @@ class RawImage;
QString makeUNCPath(const QString &path); QString makeUNCPath(const QString &path);
bool readFITSHeader(const QString &path, ImageInfoData &info); bool readFITSHeader(const QString &path, ImageInfoData &info);
bool readXISFHeader(const QString &path, ImageInfoData &info); bool readXISFHeader(const QString &path, ImageInfoData &info);
bool loadImage(const QString &path, ImageInfoData &info, std::shared_ptr<RawImage> &rawImage, bool planar = false); bool loadImage(const QString &path, ImageInfoData &info, std::shared_ptr<RawImage> &rawImage, int index, bool planar = false);
#endif // LOADIMAGE_H #endif // LOADIMAGE_H
+5 -4
View File
@@ -10,11 +10,12 @@
#include "loadimage.h" #include "loadimage.h"
#include <lcms2.h> #include <lcms2.h>
LoadRunable::LoadRunable(const QString &file, Image *receiver, AnalyzeLevel level, bool thumbnail) : LoadRunable::LoadRunable(const QString &file, Image *receiver, AnalyzeLevel level, int index, bool thumbnail) :
m_file(makeUNCPath(file)), m_file(makeUNCPath(file)),
m_receiver(receiver), m_receiver(receiver),
m_analyzeLevel(level), m_analyzeLevel(level),
m_thumbnail(thumbnail) m_thumbnail(thumbnail),
m_index(index)
{ {
} }
@@ -32,7 +33,7 @@ void LoadRunable::run()
info.info.append({QObject::tr("Filename"), finfo.fileName()}); info.info.append({QObject::tr("Filename"), finfo.fileName()});
std::shared_ptr<RawImage> rawImage; std::shared_ptr<RawImage> rawImage;
if(!loadImage(m_file, info, rawImage)) if(!loadImage(m_file, info, rawImage, m_index))
info.info.append({QObject::tr("Error"), QObject::tr("Failed to load image")}); info.info.append({QObject::tr("Error"), QObject::tr("Failed to load image")});
@@ -187,7 +188,7 @@ void ConvertRunable::run()
ImageInfoData imageinfo; ImageInfoData imageinfo;
std::shared_ptr<RawImage> rawimage; std::shared_ptr<RawImage> rawimage;
loadImage(m_infile, imageinfo, rawimage); loadImage(m_infile, imageinfo, rawimage, 0);
QFileInfo info(m_outfile); QFileInfo info(m_outfile);
info.dir().mkpath("."); info.dir().mkpath(".");
+2 -1
View File
@@ -15,8 +15,9 @@ class LoadRunable : public QRunnable
Image *m_receiver; Image *m_receiver;
AnalyzeLevel m_analyzeLevel; AnalyzeLevel m_analyzeLevel;
bool m_thumbnail; bool m_thumbnail;
int m_index = 0;
public: public:
LoadRunable(const QString &file, Image *receiver, AnalyzeLevel level, bool thumbnail = false); LoadRunable(const QString &file, Image *receiver, AnalyzeLevel level, int index, bool thumbnail = false);
void run() override; void run() override;
}; };
+34 -18
View File
@@ -95,7 +95,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
m_ringList = new ImageRingList(m_database, nameFilter, this); m_ringList = new ImageRingList(m_database, nameFilter, this);
m_filesystem = new FilesystemWidget(m_ringList, this); m_filesystem = new FilesystemWidget(m_ringList, this);
connect(m_filesystem, SIGNAL(fileSelected(int)), this, SLOT(loadFile(int))); connect(m_filesystem, &FilesystemWidget::fileSelected, this, static_cast<void (MainWindow::*)(int)>(&MainWindow::loadFile));
connect(m_filesystem, &FilesystemWidget::sortChanged, m_ringList, &ImageRingList::setSort); connect(m_filesystem, &FilesystemWidget::sortChanged, m_ringList, &ImageRingList::setSort);
connect(m_filesystem, &FilesystemWidget::reverseSort, m_ringList, &ImageRingList::reverseSort); connect(m_filesystem, &FilesystemWidget::reverseSort, m_ringList, &ImageRingList::reverseSort);
@@ -106,7 +106,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
connect(m_filetree, &Filetree::indexDirectory, this, static_cast<void (MainWindow::*)(const QString &)>(&MainWindow::indexDir)); connect(m_filetree, &Filetree::indexDirectory, this, static_cast<void (MainWindow::*)(const QString &)>(&MainWindow::indexDir));
m_databaseView = new DataBaseView(m_database, this); m_databaseView = new DataBaseView(m_database, this);
connect(m_databaseView, SIGNAL(loadFile(QString)), this, SLOT(loadFile(QString))); connect(m_databaseView, &DataBaseView::loadFile, this, static_cast<void (MainWindow::*)(const QString &)>(&MainWindow::loadFile));
#ifdef PLATESOLVER #ifdef PLATESOLVER
_plateSolving = new PlateSolving(this); _plateSolving = new PlateSolving(this);
@@ -114,6 +114,19 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
_plateSolving->hide(); _plateSolving->hide();
#endif #endif
QToolBar *navigationToolbar = new QToolBar(tr("Navigation toolbar"), this);
navigationToolbar->setObjectName("navigationtoolbar");
navigationToolbar->hide();
QAction *prevAction = navigationToolbar->addAction(style()->standardIcon(QStyle::SP_ArrowLeft), tr("Previous image"));
QAction *nextAction = navigationToolbar->addAction(style()->standardIcon(QStyle::SP_ArrowRight), tr("Next image"));
QAction *prevSubAction = navigationToolbar->addAction(style()->standardIcon(QStyle::SP_ArrowUp), tr("Prev sub image"));
QAction *nextSubAction = navigationToolbar->addAction(style()->standardIcon(QStyle::SP_ArrowDown), tr("Next sub image"));
connect(prevAction, &QAction::triggered, m_ringList, static_cast<void (ImageRingList::*)()>(&ImageRingList::decrement));
connect(nextAction, &QAction::triggered, m_ringList, static_cast<void (ImageRingList::*)()>(&ImageRingList::increment));
connect(prevSubAction, &QAction::triggered, m_ringList, static_cast<void (ImageRingList::*)()>(&ImageRingList::prevSubImage));
connect(nextSubAction, &QAction::triggered, m_ringList, static_cast<void (ImageRingList::*)()>(&ImageRingList::nextSubImage));
addToolBar(Qt::TopToolBarArea, navigationToolbar);
addToolBar(Qt::TopToolBarArea, m_stretchPanel); addToolBar(Qt::TopToolBarArea, m_stretchPanel);
QDockWidget *filesystemDock = new QDockWidget(tr("Filesystem"), this); QDockWidget *filesystemDock = new QDockWidget(tr("Filesystem"), this);
@@ -155,16 +168,16 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
connect(m_image, &ImageScrollArea::fileDropped, this, static_cast<void (MainWindow::*)(const QString &)>(&MainWindow::loadFile)); connect(m_image, &ImageScrollArea::fileDropped, this, static_cast<void (MainWindow::*)(const QString &)>(&MainWindow::loadFile));
QMenu *fileMenu = new QMenu(tr("File"), this); QMenu *fileMenu = new QMenu(tr("File"), this);
fileMenu->addAction(tr("Open"), QKeySequence::Open, this, SLOT(loadFile())); fileMenu->addAction(tr("Open"), QKeySequence::Open, this, static_cast<void (MainWindow::*)()>(&MainWindow::loadFile));
fileMenu->addAction(tr("Open directory recursively"), this, &MainWindow::loadDir); fileMenu->addAction(tr("Open directory recursively"), this, &MainWindow::loadDir);
QAction *saveAs = fileMenu->addAction(tr("Save as"), QKeySequence::Save, this, SLOT(saveAs())); QAction *saveAs = fileMenu->addAction(tr("Save as"), QKeySequence::Save, this, &MainWindow::saveAs);
fileMenu->addSeparator(); fileMenu->addSeparator();
fileMenu->addAction(tr("Copy marked files"), Qt::Key_F5, this, SLOT(copyMarked())); fileMenu->addAction(tr("Copy marked files"), Qt::Key_F5, this, &MainWindow::copyMarked);
fileMenu->addAction(tr("Move marked files"), Qt::Key_F6, this, SLOT(moveMarked())); fileMenu->addAction(tr("Move marked files"), Qt::Key_F6, this, &MainWindow::moveMarked);
fileMenu->addAction(tr("Move marked files to trash"), QKeySequence::Delete, this, &MainWindow::deleteMarked); fileMenu->addAction(tr("Move marked files to trash"), QKeySequence::Delete, this, &MainWindow::deleteMarked);
fileMenu->addSeparator(); fileMenu->addSeparator();
fileMenu->addAction(tr("Index directory"), this, SLOT(indexDir())); fileMenu->addAction(tr("Index directory"), this, static_cast<void (MainWindow::*)()>(&MainWindow::indexDir));
fileMenu->addAction(tr("Reindex files"), this, SLOT(reindex())); fileMenu->addAction(tr("Reindex files"), this, &MainWindow::reindex);
fileMenu->addAction(tr("Export database to CSV"), this, &MainWindow::exportCSV); fileMenu->addAction(tr("Export database to CSV"), this, &MainWindow::exportCSV);
fileMenu->addAction(tr("Batch processing"), Qt::Key_B | Qt::CTRL, [this](){ fileMenu->addAction(tr("Batch processing"), Qt::Key_B | Qt::CTRL, [this](){
BatchProcessing *batchProcessing = new BatchProcessing(m_database, this); BatchProcessing *batchProcessing = new BatchProcessing(m_database, this);
@@ -172,9 +185,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
delete batchProcessing; delete batchProcessing;
}); });
fileMenu->addSeparator(); fileMenu->addSeparator();
QAction *liveModeAction = fileMenu->addAction(tr("Live mode"), this, SLOT(liveMode(bool))); QAction *liveModeAction = fileMenu->addAction(tr("Live mode"), this, &MainWindow::liveMode);
liveModeAction->setCheckable(true); liveModeAction->setCheckable(true);
QAction *exitAction = fileMenu->addAction(tr("Exit"), this, SLOT(close())); QAction *exitAction = fileMenu->addAction(tr("Exit"), this, &MainWindow::close);
exitAction->setShortcut(QKeySequence::Quit); exitAction->setShortcut(QKeySequence::Quit);
menuBar()->addMenu(fileMenu); menuBar()->addMenu(fileMenu);
@@ -243,11 +256,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
menuBar()->addMenu(viewMenu); menuBar()->addMenu(viewMenu);
QMenu *selectMenu = new QMenu(tr("Select"), this); QMenu *selectMenu = new QMenu(tr("Select"), this);
selectMenu->addAction(tr("Mark"), Qt::Key_F7, this, SLOT(markImage())); selectMenu->addAction(tr("Mark"), Qt::Key_F7, this, &MainWindow::markImage);
selectMenu->addAction(tr("Unmark"), Qt::Key_F8, this, SLOT(unmarkImage())); selectMenu->addAction(tr("Unmark"), Qt::Key_F8, this, &MainWindow::unmarkImage);
selectMenu->addSeparator(); selectMenu->addSeparator();
selectMenu->addAction(tr("Mark and next"), Qt::Key_M, this, SLOT(markAndNext())); selectMenu->addAction(tr("Mark and next"), Qt::Key_M, this, &MainWindow::markAndNext);
selectMenu->addAction(tr("Unmark and next"), Qt::Key_X, this, SLOT(unmarkAndNext())); selectMenu->addAction(tr("Unmark and next"), Qt::Key_X, this, &MainWindow::unmarkAndNext);
selectMenu->addSeparator(); selectMenu->addSeparator();
selectMenu->addAction(tr("Show marked list"), this, &MainWindow::showMarkFilesDialog); selectMenu->addAction(tr("Show marked list"), this, &MainWindow::showMarkFilesDialog);
QAction *openMarked = selectMenu->addAction(tr("Open marked"), m_ringList, &ImageRingList::setMarked); QAction *openMarked = selectMenu->addAction(tr("Open marked"), m_ringList, &ImageRingList::setMarked);
@@ -282,6 +295,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
QMenu *dockMenu = new QMenu(tr("Docks"), this); QMenu *dockMenu = new QMenu(tr("Docks"), this);
dockMenu->addAction(infoDock->toggleViewAction()); dockMenu->addAction(infoDock->toggleViewAction());
dockMenu->addAction(m_stretchPanel->toggleViewAction()); dockMenu->addAction(m_stretchPanel->toggleViewAction());
dockMenu->addAction(navigationToolbar->toggleViewAction());
dockMenu->addAction(filesystemDock->toggleViewAction()); dockMenu->addAction(filesystemDock->toggleViewAction());
dockMenu->addAction(databaseViewDock->toggleViewAction()); dockMenu->addAction(databaseViewDock->toggleViewAction());
dockMenu->addAction(filetreeDock->toggleViewAction()); dockMenu->addAction(filetreeDock->toggleViewAction());
@@ -292,7 +306,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
menuBar()->addMenu(dockMenu); menuBar()->addMenu(dockMenu);
QMenu *helpMenu = menuBar()->addMenu(tr("Help")); QMenu *helpMenu = menuBar()->addMenu(tr("Help"));
helpMenu->addAction(tr("Help"), QKeySequence::HelpContents, [this]{ HelpDialog help(this); help.exec(); }); helpMenu->addAction(tr("Help"), QKeySequence::HelpContents, [this]{ HelpDialog *help = new HelpDialog(this); help->show(); });
helpMenu->addAction(tr("About Tenmon"), [this]{ About about(this); about.exec(); }); helpMenu->addAction(tr("About Tenmon"), [this]{ About about(this); about.exec(); });
helpMenu->addAction(tr("About Qt"), [this](){ QMessageBox::aboutQt(this); }); helpMenu->addAction(tr("About Qt"), [this](){ QMessageBox::aboutQt(this); });
helpMenu->addAction(tr("Check for update"), this, &MainWindow::checkNewVersion); helpMenu->addAction(tr("Check for update"), this, &MainWindow::checkNewVersion);
@@ -387,7 +401,7 @@ void MainWindow::setupSigterm()
::socketpair(AF_UNIX, SOCK_STREAM, 0, socketPair); ::socketpair(AF_UNIX, SOCK_STREAM, 0, socketPair);
socketNotifier = new QSocketNotifier(socketPair[1], QSocketNotifier::Read, this); socketNotifier = new QSocketNotifier(socketPair[1], QSocketNotifier::Read, this);
connect(socketNotifier, SIGNAL(activated(int)), this, SLOT(socketNotify())); connect(socketNotifier, &QSocketNotifier::activated, this, &MainWindow::socketNotify);
#endif #endif
} }
@@ -811,8 +825,10 @@ void MainWindow::updateWindowTitle()
ImagePtr ptr = m_ringList->currentImage(); ImagePtr ptr = m_ringList->currentImage();
if(ptr) if(ptr)
{ {
QFileInfo info(ptr->name()); QDir dir(m_ringList->currentDir());
QString title = info.fileName(); QString title = dir.relativeFilePath(ptr->name());
if(ptr->info().num > 1)
title += QString(" [%1/%2]").arg(ptr->info().index + 1).arg(ptr->info().num);
if(m_database->isMarked(ptr->name())) if(m_database->isMarked(ptr->name()))
title += " *"; title += " *";
setWindowTitle(title); setWindowTitle(title);
+3 -3
View File
@@ -1,8 +1,8 @@
#include "rawimage.h" #include "rawimage.h"
#include <cstring> #include <cstring>
#include <lcms2.h>
#include <algorithm> #include <algorithm>
#ifndef NO_QT #ifndef NO_QT
#include <lcms2.h>
#include <QDebug> #include <QDebug>
#include <QElapsedTimer> #include <QElapsedTimer>
#include <QFloat16> #include <QFloat16>
@@ -55,7 +55,7 @@ void RawImage::allocate(uint32_t w, uint32_t h, uint32_t ch, DataType type)
m_width = w; m_width = w;
m_height = h; m_height = h;
m_channels = ch; m_channels = ch;
m_ch = ch == 3 ? 4 : ch; m_ch = ch > 1 ? 4 : ch;
m_origType = m_type = type; m_origType = m_type = type;
m_pixels = std::make_unique<PixelType[]>((size_t)m_width * m_height * m_ch * typeSize(type)); m_pixels = std::make_unique<PixelType[]>((size_t)m_width * m_height * m_ch * typeSize(type));
} }
@@ -1071,7 +1071,6 @@ void RawImage::setICCProfile(const QByteArray &icc)
if(icc.size()) if(icc.size())
m_iccProfile = std::vector<uint8_t>(icc.begin(), icc.end()); m_iccProfile = std::vector<uint8_t>(icc.begin(), icc.end());
} }
#endif
void RawImage::setICCProfile(const LibXISF::ByteArray &icc) void RawImage::setICCProfile(const LibXISF::ByteArray &icc)
{ {
@@ -1180,6 +1179,7 @@ void RawImage::generateLUT()
cmsCloseProfile(inProfile); cmsCloseProfile(inProfile);
cmsCloseProfile(outProfile); cmsCloseProfile(outProfile);
} }
#endif
void RawImage::applySTF(const MTFParam &mtfParams) void RawImage::applySTF(const MTFParam &mtfParams)
{ {
+1 -1
View File
@@ -125,10 +125,10 @@ public:
bool valid() const; bool valid() const;
#ifndef NO_QT #ifndef NO_QT
void setICCProfile(const QByteArray &icc); void setICCProfile(const QByteArray &icc);
#endif
void setICCProfile(const LibXISF::ByteArray &icc); void setICCProfile(const LibXISF::ByteArray &icc);
void convertTosRGB(); void convertTosRGB();
void generateLUT(); void generateLUT();
#endif
void applySTF(const MTFParam &mtfParams); void applySTF(const MTFParam &mtfParams);
MTFParam calcMTFParams(bool linked = false, bool debayer = false) const; MTFParam calcMTFParams(bool linked = false, bool debayer = false) const;
const std::vector<uint16_t>& getLUT() const; const std::vector<uint16_t>& getLUT() const;
+1 -1
View File
@@ -737,7 +737,7 @@ QJSValue File::stats()
{ {
ImageInfoData info; ImageInfoData info;
std::shared_ptr<RawImage> rawImage; std::shared_ptr<RawImage> rawImage;
loadImage(_path, info, rawImage); loadImage(_path, info, rawImage, 0);
rawImage->calcStats(); rawImage->calcStats();
RawImage::Stats stats = rawImage->imageStats(); RawImage::Stats stats = rawImage->imageStats();
_stats = _engine->newObject(); _stats = _engine->newObject();
+3 -3
View File
@@ -150,10 +150,10 @@ void SettingsDialog::installThumbnailer()
QProcess regsvr; QProcess regsvr;
int ret = regsvr.execute("regsvr32.exe", {"/s", path}); int ret = regsvr.execute("regsvr32.exe", {"/s", path});
if(ret) if(ret == 0)
{ QMessageBox::information(this, tr("Thumbnail support"), tr("Thumbnail generation support sucessufully installed."));
else
QMessageBox::critical(this, tr("Error"), tr("Failed to register thumbnailer. %1").arg(ret)); QMessageBox::critical(this, tr("Error"), tr("Failed to register thumbnailer. %1").arg(ret));
}
#endif #endif
} }
+1 -1
View File
@@ -7,7 +7,7 @@ int generateThumbnail(const QString &input, const QString &output, uint32_t size
{ {
ImageInfoData info; ImageInfoData info;
std::shared_ptr<RawImage> rawImage; std::shared_ptr<RawImage> rawImage;
if(!loadImage(input, info, rawImage)) if(!loadImage(input, info, rawImage, 0))
return 2; return 2;
if(!rawImage) if(!rawImage)