7#include "printingwizard.h"
9#include <QStackedWidget>
11#include <QStandardPaths>
13#include "finderchart.h"
14#include "loggingform.h"
15#include "detailstable.h"
16#include "pwizobjectselection.h"
17#include "pwizchartconfig.h"
18#include "pwizfovbrowse.h"
19#include "pwizfovconfig.h"
20#include "pwizfovtypeselection.h"
21#include "pwizfovmanual.h"
23#include "pwizchartcontents.h"
25#include "projections/projector.h"
27#include "kstarsdata.h"
30#include "shfovexporter.h"
40 :
QDialog(
parent), m_KStars(
KStars::Instance()), m_FinderChart(nullptr), m_SkyObject(nullptr), m_FovType(FT_UNDEFINED),
41 m_FovImageSize(
QSize(500, 500)), m_ShBeginObject(nullptr), m_PointingShBegin(false), m_SwitchColors(false),
42 m_RecapturingFov(false), m_RecaptureIdx(-1)
61 qDeleteAll(m_FovSnapshots);
66 switch (m_WizardStack->currentIndex())
68 case PW_OBJECT_SELECTION:
70 nextB->setEnabled(m_SkyObject !=
nullptr);
81 m_KStars->map()->setClickedObject(m_SkyObject);
82 m_KStars->map()->slotCenter();
85 m_KStars->map()->setObjectPointingMode(
true);
91 m_PointingShBegin =
true;
95 m_KStars->map()->setClickedObject(m_SkyObject);
96 m_KStars->map()->slotCenter();
99 m_KStars->map()->setObjectPointingMode(
true);
105 if (m_PointingShBegin)
107 m_ShBeginObject = obj;
108 m_WizFovShUI->setBeginObject(obj);
109 m_PointingShBegin =
false;
114 m_WizObjectSelectionUI->setSkyObject(obj);
124 slewAndBeginCapture(m_SkyObject);
130 slewAndBeginCapture(center, fov);
135 if (m_KStars->data()->getVisibleFOVs().isEmpty())
140 QPixmap pixmap(m_FovImageSize);
141 m_SimpleFovExporter.exportFov(m_KStars->data()->getVisibleFOVs().first(), &pixmap);
142 if (m_WizFovConfigUI->isLegendEnabled())
145 Legend legend(m_WizFovConfigUI->getLegendOrientation(), m_WizFovConfigUI->getLegendPosition());
146 legend.setType(m_WizFovConfigUI->getLegendType());
149 if (m_WizFovConfigUI->isAlphaBlendingEnabled())
151 QColor bgColor = legend.getBgColor();
153 legend.setBgColor(bgColor);
157 legend.paintLegend(&pixmap);
160 m_KStars->map()->getCenterPoint());
162 if (m_RecapturingFov)
164 delete m_FovSnapshots.at(m_RecaptureIdx);
165 m_FovSnapshots.replace(m_RecaptureIdx, snapshot);
166 m_KStars->map()->setFovCaptureMode(
false);
167 m_RecapturingFov =
false;
173 m_FovSnapshots.append(snapshot);
183 m_KStars->loadColorScheme(m_PrevSchemeName);
184 m_KStars->map()->forceUpdate();
187 if (m_RecapturingFov)
189 m_RecapturingFov =
false;
198 if (!m_ShBeginObject)
207 foreach (
FOV *fov, KStarsData::Instance()->getAvailableFOVs())
209 if (fov->name() == m_WizFovShUI->getFovName())
211 fovArcmin = qMin(fov->sizeX(), fov->sizeY());
217 if (!exporter.
calculatePath(*m_SkyObject, *m_ShBeginObject, fovArcmin / 60, m_WizFovShUI->getMaglim()))
220 i18n(
"Star hopper returned empty path. We advise you to change star hopping settings "
221 "or use manual capture mode."),
222 i18n(
"Star hopper failed to find path"));
227 m_SimpleFovExporter.setFovShapeOverriden(m_WizFovConfigUI->isFovShapeOverriden());
228 m_SimpleFovExporter.setFovSymbolDrawn(m_WizFovConfigUI->isFovShapeOverriden());
231 m_SwitchColors = m_WizFovConfigUI->isSwitchColorsEnabled();
232 m_PrevSchemeName = m_KStars->data()->colorScheme()->fileName();
235 m_KStars->loadColorScheme(
"chart.colors");
240 Options::setFOVNames(
QStringList(m_WizFovShUI->getFovName()));
241 KStarsData::Instance()->syncFOV();
242 if (KStarsData::Instance()->getVisibleFOVs().isEmpty())
256 m_KStars->loadColorScheme(m_PrevSchemeName);
257 m_KStars->map()->forceUpdate();
261 m_KStars->map()->forceUpdate(
true);
264 Options::setFOVNames(prevFovNames);
265 KStarsData::Instance()->syncFOV();
274 m_RecapturingFov =
true;
275 m_RecaptureIdx = idx;
278 SkyPoint p = m_FovSnapshots.at(m_RecaptureIdx)->getCentralPoint();
279 slewAndBeginCapture(&p, m_FovSnapshots.at(m_RecaptureIdx)->getFov());
282void PrintingWizard::slotPrevPage()
299 m_WizardStack->setCurrentIndex(PW_FOV_SH);
314 m_WizardStack->setCurrentIndex(PW_FOV_CONFIG);
320 m_WizardStack->setCurrentIndex(currentIdx - 1);
329void PrintingWizard::slotNextPage()
331 int currentIdx = m_WizardStack->currentIndex();
336 m_FovType = m_WizFovTypeSelectionUI->getFovExportType();
337 m_WizardStack->setCurrentIndex(PW_FOV_CONFIG);
347 m_WizardStack->setCurrentIndex(PW_FOV_MANUAL);
353 m_WizardStack->setCurrentIndex(PW_FOV_SH);
368 m_WizardStack->setCurrentIndex(PW_FOV_BROWSE);
374 m_WizChartContentsUI->entered();
375 m_WizardStack->setCurrentIndex(PW_CHART_CONTENTS);
379 case PW_CHART_CONTENTS:
382 m_WizardStack->setCurrentIndex(PW_CHART_PRINT);
388 m_WizardStack->setCurrentIndex(currentIdx + 1);
396void PrintingWizard::setupWidgets()
401 m_WizardStack =
new QStackedWidget(
this);
405 QVBoxLayout *mainLayout =
new QVBoxLayout;
413 nextB =
new QPushButton(
i18n(
"&Next >"));
414 nextB->setToolTip(
i18n(
"Go to next Wizard page"));
415 nextB->setDefault(
true);
416 backB =
new QPushButton(
i18n(
"< &Back"));
417 backB->setToolTip(
i18n(
"Go to previous Wizard page"));
418 backB->setEnabled(
false);
423 connect(nextB, SIGNAL(clicked()),
this, SLOT(slotNextPage()));
424 connect(backB, SIGNAL(clicked()),
this, SLOT(slotPrevPage()));
427 m_WizWelcomeUI =
new PWizWelcomeUI(m_WizardStack);
428 m_WizObjectSelectionUI =
new PWizObjectSelectionUI(
this, m_WizardStack);
429 m_WizChartConfigUI =
new PWizChartConfigUI(
this);
430 m_WizFovTypeSelectionUI =
new PWizFovTypeSelectionUI(
this, m_WizardStack);
431 m_WizFovConfigUI =
new PWizFovConfigUI(m_WizardStack);
432 m_WizFovManualUI =
new PWizFovManualUI(
this, m_WizardStack);
433 m_WizFovShUI =
new PWizFovShUI(
this, m_WizardStack);
434 m_WizFovBrowseUI =
new PWizFovBrowseUI(
this, m_WizardStack);
435 m_WizChartContentsUI =
new PWizChartContentsUI(
this, m_WizardStack);
436 m_WizPrintUI =
new PWizPrintUI(
this, m_WizardStack);
439 m_WizardStack->addWidget(m_WizWelcomeUI);
440 m_WizardStack->addWidget(m_WizObjectSelectionUI);
441 m_WizardStack->addWidget(m_WizChartConfigUI);
442 m_WizardStack->addWidget(m_WizFovTypeSelectionUI);
443 m_WizardStack->addWidget(m_WizFovConfigUI);
444 m_WizardStack->addWidget(m_WizFovManualUI);
445 m_WizardStack->addWidget(m_WizFovShUI);
446 m_WizardStack->addWidget(m_WizFovBrowseUI);
447 m_WizardStack->addWidget(m_WizChartContentsUI);
448 m_WizardStack->addWidget(m_WizPrintUI);
454 m_WizWelcomeUI->banner->setPixmap(bannerImg);
455 m_WizObjectSelectionUI->banner->setPixmap(bannerImg);
456 m_WizChartConfigUI->banner->setPixmap(bannerImg);
457 m_WizFovTypeSelectionUI->banner->setPixmap(bannerImg);
458 m_WizFovConfigUI->banner->setPixmap(bannerImg);
459 m_WizFovManualUI->banner->setPixmap(bannerImg);
460 m_WizFovShUI->banner->setPixmap(bannerImg);
461 m_WizFovBrowseUI->banner->setPixmap(bannerImg);
462 m_WizChartContentsUI->banner->setPixmap(bannerImg);
463 m_WizPrintUI->banner->setPixmap(bannerImg);
466 backB->setEnabled(
false);
469void PrintingWizard::updateButtons()
471 nextB->setEnabled(m_WizardStack->currentIndex() < m_WizardStack->count() - 1);
472 backB->setEnabled(m_WizardStack->currentIndex() > 0);
475void PrintingWizard::slewAndBeginCapture(
SkyPoint *center,
FOV *fov)
486 Options::setFOVNames(QStringList(fov->name()));
487 m_KStars->data()->syncFOV();
490 double zoom = m_FovImageSize.width() > m_FovImageSize.height() ?
492 SimpleFovExporter::calculateZoomLevel(m_FovImageSize.
height(), fov->sizeY());
493 m_KStars->map()->setZoomFactor(zoom);
496 m_SimpleFovExporter.setFovShapeOverriden(m_WizFovConfigUI->isFovShapeOverriden());
497 m_SimpleFovExporter.setFovSymbolDrawn(m_WizFovConfigUI->isFovShapeOverriden());
499 m_SwitchColors = m_WizFovConfigUI->isSwitchColorsEnabled();
500 m_PrevSchemeName = m_KStars->data()->colorScheme()->fileName();
503 m_KStars->loadColorScheme(
"chart.colors");
506 m_KStars->hideAllFovExceptFirst();
507 m_KStars->map()->setClickedPoint(center);
508 m_KStars->map()->slotCenter();
509 m_KStars->map()->setFovCaptureMode(
true);
513void PrintingWizard::createFinderChart()
518 delete m_FinderChart;
520 m_FinderChart =
new FinderChart;
523 m_FinderChart->insertTitleSubtitle(m_WizChartConfigUI->titleEdit->text(), m_WizChartConfigUI->subtitleEdit->text());
526 if (!m_WizChartConfigUI->descriptionTextEdit->toPlainText().isEmpty())
528 m_FinderChart->insertDescription(m_WizChartConfigUI->descriptionTextEdit->toPlainText());
532 if (m_WizChartContentsUI->isLoggingFormChecked())
534 LoggingForm chartLogger;
536 m_FinderChart->insertSectionTitle(
i18n(
"Logging Form"));
537 m_FinderChart->insertLoggingForm(&chartLogger);
540 m_FinderChart->insertSectionTitle(
i18n(
"Field of View Snapshots"));
543 for (
int i = 0; i < m_FovSnapshots.size(); i++)
545 FOV *fov = m_FovSnapshots.at(i)->getFov();
546 QString fovDescription =
547 i18nc(
"%1 = FOV index, %2 = FOV count, %3 = FOV name, %4 = FOV X size, %5 = FOV Y size",
551 m_FinderChart->insertImage(m_FovSnapshots.at(i)->getPixmap().toImage(),
552 fovDescription + m_FovSnapshots.at(i)->getDescription(),
true);
555 if (m_WizChartContentsUI->isGeneralTableChecked() || m_WizChartContentsUI->isPositionTableChecked() ||
556 m_WizChartContentsUI->isRSTTableChecked() || m_WizChartContentsUI->isAstComTableChecked())
558 m_FinderChart->insertSectionTitle(
i18n(
"Details About Object"));
559 m_FinderChart->insertGeoTimeInfo(KStarsData::Instance()->ut(), KStarsData::Instance()->
geo());
563 DetailsTable detTable;
564 if (m_WizChartContentsUI->isGeneralTableChecked())
567 m_FinderChart->insertDetailsTable(&detTable);
571 if (m_WizChartContentsUI->isPositionTableChecked())
574 m_FinderChart->insertDetailsTable(&detTable);
578 if (m_WizChartContentsUI->isRSTTableChecked())
580 detTable.
createRSTTAble(m_SkyObject, m_KStars->data()->ut(), m_KStars->data()->geo());
581 m_FinderChart->insertDetailsTable(&detTable);
585 if (m_WizChartContentsUI->isAstComTableChecked())
588 m_FinderChart->insertDetailsTable(&detTable);
void createRSTTAble(SkyObject *obj, const KStarsDateTime &ut, GeoLocation *geo)
Create Rise/Set/Transit details table.
void createAsteroidCometTable(SkyObject *obj)
Create Asteroid/Comet details table.
void createGeneralTable(SkyObject *obj)
Create general details table.
void createCoordinatesTable(SkyObject *obj, const KStarsDateTime &ut, GeoLocation *geo)
Create coordinates details table.
A simple class encapsulating a Field-of-View symbol.
Class that represents single field of view snapshot.
This is the main window for KStars.
static KStars * Instance()
PWizWelcomeUI(QWidget *parent=nullptr)
Constructor.
PrintingWizard(QWidget *parent=nullptr)
Constructor.
void fovCaptureDone()
Disable FOV capture mode.
void recaptureFov(int idx)
Recapture FOV snapshot of passed index.
void beginFovCapture()
Hide Printing Wizard and put SkyMap in FOV capture mode.
void beginPointing()
Set SkyMap to pointing mode and hide Printing Wizard.
~PrintingWizard() override
Destructor.
void updateStepButtons()
Update Next/Previous step buttons.
void beginShBeginPointing()
Enter star hopping begin pointing mode.
void pointingDone(SkyObject *obj)
Quit object pointing mode and set the pointed object.
void captureFov()
Capture current contents of FOV symbol.
void beginShFovCapture()
Capture FOV snapshots using star hopper-based method.
Helper class used as a wrapper for StarHopper when capturing FOV snapshots.
bool calculatePath(const SkyPoint &src, const SkyPoint &dest, double fov, double maglim)
Calculate path between source and destination SkyPoints.
bool exportPath()
Export FOV snapshots across calculated path.
static double calculateZoomLevel(int pixelSize, float degrees)
Calculate zoom level at which given angular length will occupy given length in pixels.
Provides all necessary information about an object in the sky: its coordinates, name(s),...
The sky coordinates of a point in the sky.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
GeoCoordinates geo(const QVariant &location)
void information(QWidget *parent, const QString &text, const QString &title=QString(), const QString &dontShowAgainName=QString(), Options options=Notify)
QAction * zoom(const QObject *recvr, const char *slot, QObject *parent)
QDialog(QWidget *parent, Qt::WindowFlags f)
QFrame(QWidget *parent, Qt::WindowFlags f)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const
bool load(const QString &fileName, const char *format, Qt::ImageConversionFlags flags)
QString number(double n, char format, int precision)