Compare commits

..

5 Commits

Author SHA1 Message Date
nou 9746f8f653 Add option to show hidden files 2022-08-29 18:37:51 +02:00
nou b51a305c63 Remove unused method 2022-08-29 18:29:00 +02:00
nou 39775b5e98 Scale float images to 0,1 range on load 2022-07-22 11:36:10 +02:00
nou 93b56e2966 Workaround for QTBUG-87332 2022-07-03 13:40:54 +02:00
nou 2e41464ff4 Update build instructions 2022-06-27 10:26:27 +02:00
12 changed files with 69 additions and 13 deletions
+16 -3
View File
@@ -2,10 +2,23 @@ FITS/XISF image viewer with multithreaded image loading
To get all dependencies install these packages To get all dependencies install these packages
sudo apt install qtbase5-dev libraw-dev libexif-dev libcfitsio-dev libgsl-dev cmake sudo apt install qtbase5-dev libraw-dev libexif-dev libcfitsio-dev libgsl-dev wcslib-dev libopencv-dev cmake
on OpenSUSE
sudo zypper install opencv-devel gsl-devel exif-devel libraw-devel wcslib-devel libqt5-qtbase-devel
MacOS X
To compile on MacOS install XCode first. Then install homebrew in x86_64 mode
with "arch -i x86_64". Building on native ARM is not supported.
homebrew install qt5 libraw cfitsio libexif libgsl wcslib opencv
You may need to set CMAKE_PREFIX_PATH for Qt5 and OpenCV so CMake can find them.
Then to build run standard cmake Then to build run standard cmake
cmake -B build -S . cmake -B build -S .
make cmake --build build
./tenmon ./build/tenmon
+13 -6
View File
@@ -20,12 +20,6 @@ FilesystemWidget::FilesystemWidget(QAbstractItemModel *model, QWidget *parent) :
connect(m_listView->selectionModel(), &QItemSelectionModel::currentChanged, this, &FilesystemWidget::fileClicked); connect(m_listView->selectionModel(), &QItemSelectionModel::currentChanged, this, &FilesystemWidget::fileClicked);
} }
void FilesystemWidget::setDir(const QString &dir)
{
//m_model->setRootPath(dir);
//m_treeView->setRootIndex(m_model->index(m_model->rootPath()));
}
void FilesystemWidget::selectFile(int row) void FilesystemWidget::selectFile(int row)
{ {
QModelIndex index = m_model->index(row, 0); QModelIndex index = m_model->index(row, 0);
@@ -47,6 +41,9 @@ Filetree::Filetree(QWidget *parent) : QTreeView(parent)
m_fileSystemModel->setRootPath(m_rootDir); m_fileSystemModel->setRootPath(m_rootDir);
m_fileSystemModel->setNameFilters({"*.fits", "*.fit", "*.xisf", "*.jpg", "*.jpeg", "*.png", "*.cr2", "*.nef", "*.dng"}); m_fileSystemModel->setNameFilters({"*.fits", "*.fit", "*.xisf", "*.jpg", "*.jpeg", "*.png", "*.cr2", "*.nef", "*.dng"});
m_fileSystemModel->setNameFilterDisables(false); m_fileSystemModel->setNameFilterDisables(false);
if(settings.value("filetree/showHidden", false).toBool())
m_fileSystemModel->setFilter(m_fileSystemModel->filter() | QDir::Hidden);
setModel(m_fileSystemModel); setModel(m_fileSystemModel);
setRootIndex(m_fileSystemModel->index(m_rootDir)); setRootIndex(m_fileSystemModel->index(m_rootDir));
header()->restoreState(settings.value("filetree/header").toByteArray()); header()->restoreState(settings.value("filetree/header").toByteArray());
@@ -57,6 +54,7 @@ Filetree::~Filetree()
QSettings settings; QSettings settings;
settings.setValue("filetree/rootDir", m_rootDir); settings.setValue("filetree/rootDir", m_rootDir);
settings.setValue("filetree/header", header()->saveState()); settings.setValue("filetree/header", header()->saveState());
settings.setValue("filetree/showHidden", (bool)(m_fileSystemModel->filter() & QDir::Hidden));
} }
void Filetree::contextMenuEvent(QContextMenuEvent *event) void Filetree::contextMenuEvent(QContextMenuEvent *event)
@@ -85,6 +83,9 @@ void Filetree::contextMenuEvent(QContextMenuEvent *event)
QAction *resetRoot = menu.addAction(tr("Reset root")); QAction *resetRoot = menu.addAction(tr("Reset root"));
QAction *goUp = menu.addAction(tr("Go up")); QAction *goUp = menu.addAction(tr("Go up"));
QAction *showHidden = menu.addAction(tr("Show hidden files"));
showHidden->setCheckable(true);
showHidden->setChecked(m_fileSystemModel->filter() & QDir::Hidden);
QAction *a = menu.exec(event->globalPos()); QAction *a = menu.exec(event->globalPos());
if(a == nullptr) if(a == nullptr)
@@ -121,6 +122,12 @@ void Filetree::contextMenuEvent(QContextMenuEvent *event)
{ {
emit indexDirectory(m_fileSystemModel->filePath(index)); emit indexDirectory(m_fileSystemModel->filePath(index));
} }
else if(a == showHidden)
{
auto filter = m_fileSystemModel->filter();
filter ^= QDir::Hidden;
m_fileSystemModel->setFilter(filter);
}
} }
void Filetree::mouseDoubleClickEvent(QMouseEvent *event) void Filetree::mouseDoubleClickEvent(QMouseEvent *event)
-1
View File
@@ -13,7 +13,6 @@ class FilesystemWidget : public QWidget
QAbstractItemModel *m_model; QAbstractItemModel *m_model;
public: public:
explicit FilesystemWidget(QAbstractItemModel *model, QWidget *parent = nullptr); explicit FilesystemWidget(QAbstractItemModel *model, QWidget *parent = nullptr);
void setDir(const QString &dir);
private slots: private slots:
void selectFile(int row); void selectFile(int row);
void fileClicked(const QModelIndex &index, const QModelIndex &); void fileClicked(const QModelIndex &index, const QModelIndex &);
+11 -3
View File
@@ -13,7 +13,7 @@
#include <signal.h> #include <signal.h>
#include <unistd.h> #include <unistd.h>
#include <QSettings> #include <QSettings>
#include <QCoreApplication> #include <QGuiApplication>
#include <QThreadPool> #include <QThreadPool>
#include <QStatusBar> #include <QStatusBar>
#include "loadrunable.h" #include "loadrunable.h"
@@ -190,7 +190,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
_lastDir = standardLocations.first(); _lastDir = standardLocations.first();
_lastDir = settings.value("mainwindow/lastdir", _lastDir).toString(); _lastDir = settings.value("mainwindow/lastdir", _lastDir).toString();
m_filesystem->setDir(_lastDir);
QStringList args = QCoreApplication::arguments(); QStringList args = QCoreApplication::arguments();
args.removeFirst(); args.removeFirst();
@@ -208,6 +207,16 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
} }
m_imageGL->setFocus(); m_imageGL->setFocus();
// workaround for nasty wayland backend bug https://bugreports.qt.io/browse/QTBUG-87332
if(static_cast<QGuiApplication*>(QCoreApplication::instance())->platformName() == "wayland")
{
infoDock->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
filesystemDock->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
databaseViewDock->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
filetreeDock->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
m_stretchPanel->setFloatable(false);
}
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@@ -367,7 +376,6 @@ void MainWindow::loadFile(const QString &path)
_lastDir = info.canonicalPath(); _lastDir = info.canonicalPath();
QSettings settings; QSettings settings;
settings.setValue("mainwindow/lastdir", _lastDir); settings.setValue("mainwindow/lastdir", _lastDir);
m_filesystem->setDir(_lastDir);
} }
} }
+16
View File
@@ -67,6 +67,7 @@ RawImage::RawImage(cv::Mat &img)
{ {
m_img = img; m_img = img;
m_stats = false; m_stats = false;
scaleToUnit();
} }
RawImage::RawImage(const RawImage &d) RawImage::RawImage(const RawImage &d)
@@ -378,3 +379,18 @@ bool RawImage::pixel(int x, int y, QVector3D &rgb) const
} }
return true; return true;
} }
void RawImage::scaleToUnit()
{
if(CV_MAT_DEPTH(m_img.type()) == CV_32F)
{
double min, max;
cv::minMaxIdx(m_img, &min, &max);
if(min < 0 || max > 1)
{
float scale = 1.0 / (max - min);
float zero = min * scale;
m_img = m_img * scale - zero;
}
}
}
+1
View File
@@ -84,6 +84,7 @@ public:
float thumbAspect() const; float thumbAspect() const;
const cv::Mat& mat() const; const cv::Mat& mat() const;
bool pixel(int x, int y, QVector3D &rgb) const; bool pixel(int x, int y, QVector3D &rgb) const;
void scaleToUnit();
}; };
#endif // RAWIMAGE_H #endif // RAWIMAGE_H
Binary file not shown.
+4
View File
@@ -71,6 +71,10 @@
<source>Go up</source> <source>Go up</source>
<translation>Go up</translation> <translation>Go up</translation>
</message> </message>
<message>
<source>Show hidden files</source>
<translation>Show hidden files</translation>
</message>
</context> </context>
<context> <context>
<name>HelpDialog</name> <name>HelpDialog</name>
Binary file not shown.
+4
View File
@@ -71,6 +71,10 @@
<source>Go up</source> <source>Go up</source>
<translation>Monter</translation> <translation>Monter</translation>
</message> </message>
<message>
<source>Show hidden files</source>
<translation>Afficher les fichiers cachés</translation>
</message>
</context> </context>
<context> <context>
<name>HelpDialog</name> <name>HelpDialog</name>
Binary file not shown.
+4
View File
@@ -72,6 +72,10 @@
<source>Go up</source> <source>Go up</source>
<translation>O úroveň vyššie</translation> <translation>O úroveň vyššie</translation>
</message> </message>
<message>
<source>Show hidden files</source>
<translation>Zobraz skryté súbory</translation>
</message>
</context> </context>
<context> <context>
<name>HelpDialog</name> <name>HelpDialog</name>