diff --git a/about/help_en b/about/help_en index 1a7fe00..f6b509c 100644 --- a/about/help_en +++ b/about/help_en @@ -153,6 +153,24 @@ file explorer programs that are in system or from file explorer to this program. In menu you can select which FITS keywords will be showed. Temporarilly disable loading FITS header or copy file paths of selected files as text.

+

Command line options

+

+Tenmon can be executed from command line. It support these command line options. +

+

+

Batch processing

This module allow to write scripts in JavaScript that process image files. Batch Processing window consist from three main parts. On top is list of input files and directories. You can add directories or individual files to this list. Directories are scanned recursively to find all files even non image files. This list of files is then passed to script in array named files. diff --git a/about/help_fr b/about/help_fr index 3665b73..acc22bd 100644 --- a/about/help_fr +++ b/about/help_fr @@ -102,6 +102,55 @@ En appuyant sur la touche Enter ou en cliquant sur le bouton Filtre, les Cet exemple filtre les fichiers où : "Bias" figure dans le nom de fichier, la propriété OBJECT est "M_42" (où le trait de soulignement peut être n'importe quel caractère) et la propriété DATE commence par "2022".

+

Plate Solving

+

This module can plate solve images and update FITS header with solution for FITS and XISF images. +Profile this set various parameters that affect star extraction and solving. +Starting point program will try to automatically determine optimal starting point which helps to speed up solving. +You can leave one or both unchecked then it will attempt to do blind solving. If the position or scale is wrong it can actually +fail to solve. +Solution this section contain resulting solution like RA,DEC coordinates center of image, image field of view, orientation as degrees E of N, +image scale in arcseconds per pixel, number of stars extracted and HFR fitting and eccentricity. Then there is log window for debug information from +solver. +

+

Then finally there are various action button. Settings button show dialog where you can set path to existing index files or auto download some. +Extract button will just extract stars from image and it will show their count, HFR and eccentricity. This action doesn't need index files. +Solve button will try to find coordinates of images. Abort button will stop extraction or solving. Update FITS header will update FITS fits keywords +with found solution.

+ +

In settings dialog you can set path to index files which is by default custom internal one. It also try to locate commonly used path from other +programs like KStars for astrometry.net index files. +

+ +

File Manager

+

+This is simple double panel file manager. It can show columns with selected FITS keywords. Each panel have tabs where it easily switch between +multiple directories. You can copy or move files and directories either inside one panel or between two panels by selecting and then dragging. +By default files are copies. To move then press Shift key before start dragging. Double click on file will open it in main window if it is image +or other file it will open default program that is associated with it this file type. You can also drag file to other programs like from default +file explorer programs that are in system or from file explorer to this program. +

+

+In menu you can select which FITS keywords will be showed. Temporarilly disable loading FITS header or copy file paths of selected files as text. +

+ +

Command line options

+

+Tenmon can be executed from command line. It support these command line options. +

+

+

Traitement par lot

Ce module permet d'écrire des scripts en JavaScript qui traitent des fichiers images. La fenêtre de traitement par lots se compose de trois parties principales. En haut se trouve la liste des fichiers et répertoires d'entrée. diff --git a/about/help_sk b/about/help_sk index f0473d2..fc47c08 100644 --- a/about/help_sk +++ b/about/help_sk @@ -133,6 +133,24 @@ file explorer programs that are in system or from file explorer to this program. In menu you can select which FITS keywords will be showed. Temporarilly disable loading FITS header or copy file paths of selected files as text.

+

Command line options

+

+Tenmon can be executed from command line. It support these command line options. +

+

+

Hromadné spracovanie

Tento modul umožnuje písanie skriptov v JavaScripte ktoré spracujú súbory obrázkov. Okno Hromadného spracovanie pozostáva z troch častí. Navrchu je zoznam vstupných súborov a adresárov. diff --git a/src/batchprocessing.cpp b/src/batchprocessing.cpp index e649ec2..caccd5d 100644 --- a/src/batchprocessing.cpp +++ b/src/batchprocessing.cpp @@ -18,7 +18,6 @@ #include "chartgraph.h" #ifdef Q_OS_LINUX -#include #include #include #endif @@ -99,12 +98,12 @@ BatchProcessing::BatchProcessing(Database *database, QWidget *parent) : QDialog( qWarning() << "Failed to get app data location"; } - connect(_ui->addFilesButton, &QPushButton::released, this, &BatchProcessing::addFiles); - connect(_ui->addDirButton, &QPushButton::released, this, &BatchProcessing::addDir); + connect(_ui->addFilesButton, &QPushButton::released, this, static_cast(&BatchProcessing::addFiles)); + connect(_ui->addDirButton, &QPushButton::released, this, static_cast(&BatchProcessing::addDir)); connect(_ui->addMarkedButton, &QPushButton::released, this, &BatchProcessing::addMarked); connect(_ui->removeButton, &QPushButton::released, this, &BatchProcessing::removePath); connect(_ui->removeAllButton, &QPushButton::released, this, &BatchProcessing::removeAllPaths); - connect(_ui->startButton, &QPushButton::released, this, &BatchProcessing::runScript); + connect(_ui->startButton, &QPushButton::released, this, static_cast(&BatchProcessing::runScript)); connect(_ui->stopButton, &QPushButton::released, this, &BatchProcessing::stopScript); connect(_ui->browseButton, &QPushButton::released, this, &BatchProcessing::browse); connect(_ui->openScriptsButton, &QPushButton::released, this, &BatchProcessing::openScriptDir); @@ -148,6 +147,17 @@ BatchProcessing::~BatchProcessing() delete _ui; } +void BatchProcessing::setOutputDir(const QString &output) +{ + _ui->outputPath->setText(output); +} + +void BatchProcessing::setPaths(const QStringList &paths) +{ + _ui->pathsList->addItems(paths); + refreshPaths(); +} + void BatchProcessing::closeEvent(QCloseEvent *event) { if(_engineThread) @@ -266,6 +276,35 @@ void BatchProcessing::runScript() else { QMessageBox::warning(this, tr("Invalid output directory"), tr("Output directory path doesn't exist or is not writable")); + delete _engineThread; + _engineThread = nullptr; + } + } +} + +void BatchProcessing::runScript(const QString &script, bool exit) +{ + _ui->log->clear(); + { + _engineThread = new Script::ScriptEngineThread(_database, this); + connect(_engineThread, &Script::ScriptEngineThread::newMessage, this, &BatchProcessing::newMessage); + connect(_engineThread, &Script::ScriptEngineThread::newMessage, this, &BatchProcessing::newMessageCli); + connect(_engineThread, &Script::ScriptEngineThread::finished, this, &BatchProcessing::scriptFinished); + if(exit)connect(_engineThread, &Script::ScriptEngineThread::finished, this, &BatchProcessing::accept); + + QFileInfo outDir(_ui->outputPath->text()); + if(outDir.exists() && outDir.isWritable()) + { + _engineThread->setParams(script, _paths, _ui->outputPath->text()); + _engineThread->start(); + _ui->startButton->setEnabled(false); + _ui->stopButton->setEnabled(true); + } + else + { + QMessageBox::warning(this, tr("Invalid output directory"), tr("Output directory path doesn't exist or is not writable")); + delete _engineThread; + _engineThread = nullptr; } } } @@ -293,6 +332,14 @@ void BatchProcessing::newMessage(const QString &message, bool error) _ui->log->append(message); } +void BatchProcessing::newMessageCli(const QString &message, bool error) +{ + if(error) + qWarning() << message; + else + qDebug() << message; +} + QJSValue BatchProcessing::getString(const QString &label, const QString &text) { bool ok = false; diff --git a/src/batchprocessing.h b/src/batchprocessing.h index 0896505..4ba7349 100644 --- a/src/batchprocessing.h +++ b/src/batchprocessing.h @@ -30,6 +30,8 @@ private slots: public: explicit BatchProcessing(Database *database, QWidget *parent = nullptr); ~BatchProcessing(); + void setOutputDir(const QString &output); + void setPaths(const QStringList &paths); protected: void closeEvent(QCloseEvent *event); void refreshPaths(); @@ -42,9 +44,11 @@ public slots: void browse(); void openScriptDir(); void runScript(); + void runScript(const QString &script, bool exit); void stopScript(); void scriptFinished(); void newMessage(const QString &message, bool error); + void newMessageCli(const QString &message, bool error); QJSValue getString(const QString &label, const QString &text); QJSValue getInt(const QString &label, int value); diff --git a/src/main.cpp b/src/main.cpp index 28bf7bd..be3c163 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -35,7 +35,10 @@ int main(int argc, char *argv[]) cmd.addOption({"gles", "Use OpenGL ES. This is default on ARM platform."}); cmd.addOption({{"thumb", "thumbnail"}, "Generate thumbnail and save it to path.", "path"}); cmd.addOption({{"s", "size"}, "Size of the thumbnails in pixels (default: 128)", "size", "128"}); - cmd.addPositionalArgument("file", "File to open"); + cmd.addPositionalArgument("file", "Files or paths to open"); + cmd.addOption({"script", "Execute script", "script"}); + cmd.addOption({"outdir", "Output dir for script (default: CWD)", "dir", "."}); + cmd.addOption({"noexit", "Do not exit application when script finish"}); cmd.addHelpOption(); QStringList cmdArgs; for(int i = 0; i < argc; i++) @@ -107,7 +110,7 @@ int main(int argc, char *argv[]) MainWindow w; w.show(); - if(!cmd.positionalArguments().isEmpty()) + if(!cmd.positionalArguments().isEmpty() && !cmd.isSet("script")) { QStringList files = cmd.positionalArguments(); QStringList paths; @@ -124,5 +127,17 @@ int main(int argc, char *argv[]) w.loadFiles(paths); } + if(cmd.isSet("script")) + { + QStringList paths = cmd.positionalArguments(); + QString script = cmd.value("script"); + QString outdir = cmd.value("outdir"); + if(!QDir::isAbsolutePath(script))script = QDir::currentPath() + "/" + script; + if(!QDir::isAbsolutePath(outdir))outdir = QDir::currentPath() + "/" + outdir; + bool noexit = cmd.isSet("noexit"); + if(!noexit)w.hide(); + w.runScript(script, outdir, paths, !noexit); + } + return a.exec(); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d85be56..542c272 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include "loadrunable.h" #include "markedfiles.h" #include "about.h" @@ -847,6 +848,20 @@ void MainWindow::openFileManager() #endif } +void MainWindow::runScript(const QString &script, const QString &outdir, const QStringList &paths, bool exit) +{ + BatchProcessing *batchProcessing = new BatchProcessing(m_database, this); + batchProcessing->setOutputDir(outdir); + batchProcessing->setPaths(paths); + if(exit)batchProcessing->hide(); + QTimer::singleShot(500, [batchProcessing, script, exit](){ + batchProcessing->runScript(script, exit); + batchProcessing->exec(); + delete batchProcessing; + if(exit)QCoreApplication::exit(); + }); +} + void MainWindow::updateWindowTitle() { ImagePtr ptr = m_ringList->currentImage();