File indexing completed on 2024-04-14 03:43:00

0001 /*
0002     SPDX-FileCopyrightText: 2011 Rafał Kułaga <rl.kulaga@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef PRINTINGWIZARD_H
0008 #define PRINTINGWIZARD_H
0009 
0010 #include "ui_pwizwelcome.h"
0011 
0012 #include "QDialog"
0013 #include "simplefovexporter.h"
0014 #include "fovsnapshot.h"
0015 #include "QSize"
0016 
0017 class KStars;
0018 class PWizObjectSelectionUI;
0019 class PWizFovBrowseUI;
0020 class PWizFovTypeSelectionUI;
0021 class PWizFovConfigUI;
0022 class PWizFovManualUI;
0023 class PWizFovShUI;
0024 class PWizChartConfigUI;
0025 class PWizChartContentsUI;
0026 class PWizPrintUI;
0027 class FinderChart;
0028 class SkyObject;
0029 class QStackedWidget;
0030 class QPrinter;
0031 
0032 /**
0033   * \class PWizWelcomeUI
0034   * \brief User interface for the first step of the Printing Wizard.
0035   * \author Rafał Kułaga
0036   */
0037 class PWizWelcomeUI : public QFrame, public Ui::PWizWelcome
0038 {
0039     Q_OBJECT
0040   public:
0041     /**
0042           * \brief Constructor.
0043           */
0044     explicit PWizWelcomeUI(QWidget *parent = nullptr);
0045 };
0046 
0047 /**
0048   * \class PrintingWizard
0049   * \brief Class representing Printing Wizard for KStars printed documents (currently only finder charts).
0050   * \author Rafał Kułaga
0051   */
0052 class PrintingWizard : public QDialog
0053 {
0054     Q_OBJECT
0055   public:
0056     /**
0057           * \brief Wizard steps enumeration.
0058           */
0059     enum WIZARD_STEPS
0060     {
0061         PW_WELCOME          = 0,
0062         PW_OBJECT_SELECTION = 1,
0063         PW_CHART_CONFIG     = 2,
0064         PW_FOV_TYPE         = 3,
0065         PW_FOV_CONFIG       = 4,
0066         PW_FOV_MANUAL       = 5,
0067         PW_FOV_SH           = 6,
0068         PW_FOV_BROWSE       = 7,
0069         PW_CHART_CONTENTS   = 8,
0070         PW_CHART_PRINT      = 9
0071     };
0072 
0073     /**
0074           * \brief FOV export method type enumeration.
0075           */
0076     enum FOV_TYPE
0077     {
0078         FT_MANUAL,
0079         FT_STARHOPPER,
0080         FT_UNDEFINED
0081     };
0082 
0083     /**
0084           * \brief Constructor.
0085           */
0086     explicit PrintingWizard(QWidget *parent = nullptr);
0087 
0088     /**
0089           * \brief Destructor.
0090           */
0091     ~PrintingWizard() override;
0092 
0093     /**
0094           * \brief Get used FOV export method.
0095           * \return Selected FOV export method.
0096           */
0097     FOV_TYPE getFovType() { return m_FovType; }
0098 
0099     /**
0100           * \brief Get printer used by Printing Wizard.
0101           * \return Used printer.
0102           */
0103     QPrinter *getPrinter() { return m_Printer; }
0104 
0105     /**
0106           * \brief Get used FinderChart document.
0107           * \return Used FinderChart document.
0108           */
0109     FinderChart *getFinderChart() { return m_FinderChart; }
0110 
0111     /**
0112           * \brief Get selected SkyObject, for which FinderChart is created.
0113           * \return Selected SkyObject.
0114           */
0115     SkyObject *getSkyObject() { return m_SkyObject; }
0116 
0117     /**
0118           * \brief Get FovSnapshot list.
0119           * \return Used FovSnapshot list.
0120           */
0121     QList<FovSnapshot *> *getFovSnapshotList() { return &m_FovSnapshots; }
0122 
0123     /**
0124           * \brief Get FOV snapshot image size.
0125           * \return Size of the FOV snapshot image.
0126           */
0127     QSize getFovImageSize() { return m_FovImageSize; }
0128 
0129     /**
0130           * \brief Get pointer to the SimpleFovExporter class instance.
0131           * \return Pointer to the SimpleFovExporter instance used by Printing Wizard.
0132           */
0133     SimpleFovExporter *getFovExporter() { return &m_SimpleFovExporter; }
0134 
0135     /**
0136           * \brief Get object at which star hopping will begin.
0137           * \return Source object for star hopper.
0138           */
0139     SkyObject *getShBeginObject() { return m_ShBeginObject; }
0140 
0141     /**
0142           * \brief Set SkyObject for which FinderChart is created.
0143           * \return SkyObject for which finder chart is created.
0144           */
0145     void setSkyObject(SkyObject *obj) { m_SkyObject = obj; }
0146 
0147     /**
0148           * \brief Set SkyObject at which star hopper will begin.
0149           * \return SkyObject at which star hopper will begin.
0150           */
0151     void setShBeginObject(SkyObject *obj) { m_ShBeginObject = obj; }
0152 
0153     /**
0154           * \brief Update Next/Previous step buttons.
0155           */
0156     void updateStepButtons();
0157 
0158     /**
0159           * \brief Set SkyMap to pointing mode and hide Printing Wizard.
0160           */
0161     void beginPointing();
0162 
0163     /**
0164           * \brief Enter star hopping begin pointing mode.
0165           */
0166     void beginShBeginPointing();
0167 
0168     /**
0169           * \brief Quit object pointing mode and set the pointed object.
0170           * \param obj Pointer to the SkyObject that was pointed on SkyMap.
0171           */
0172     void pointingDone(SkyObject *obj);
0173 
0174     /**
0175           * \brief Hide Printing Wizard and put SkyMap in FOV capture mode.
0176           */
0177     void beginFovCapture();
0178 
0179     /**
0180           * \brief Hide Printing Wizard and put SkyMap in FOV capture mode.
0181           * \param center Point at which SkyMap should be centered.
0182           * \param fov Field of view symbol, used to calculate zoom factor.
0183           */
0184     void beginFovCapture(SkyPoint *center, FOV *fov = nullptr);
0185 
0186     /**
0187           * \brief Capture current contents of FOV symbol.
0188           */
0189     void captureFov();
0190 
0191     /**
0192           * \brief Disable FOV capture mode.
0193           */
0194     void fovCaptureDone();
0195 
0196     /**
0197           * \brief Capture FOV snapshots using star hopper-based method.
0198           */
0199     void beginShFovCapture();
0200 
0201     /**
0202           * \brief Recapture FOV snapshot of passed index.
0203           * \param idx Index of the element to be recaptured.
0204           */
0205     void recaptureFov(int idx);
0206 
0207   private slots:
0208     /**
0209           * \brief Slot: go to the previous page of Printing Wizard.
0210           */
0211     void slotPrevPage();
0212 
0213     /**
0214           * \brief Slot: go to the next page of Printing Wizard.
0215           */
0216     void slotNextPage();
0217 
0218   private:
0219     /**
0220           * \brief Setup widget properties.
0221           */
0222     void setupWidgets();
0223 
0224     /**
0225           * \brief Update Previous/Next buttons.
0226           */
0227     void updateButtons();
0228 
0229     /**
0230           * \brief Private method, used to center SkyMap around passed SkyPoint, and enter FOV capture mode.
0231           * \param center Point at which SkyMap should be centered.
0232           * \param fov Field of view symbol, used to calculate zoom factor.
0233           */
0234     void slewAndBeginCapture(SkyPoint *center, FOV *fov = nullptr);
0235 
0236     /**
0237           * \brief Create finder chart using settings from all steps.
0238           */
0239     void createFinderChart();
0240 
0241     KStars *m_KStars;
0242     FinderChart *m_FinderChart;
0243     SkyObject *m_SkyObject;
0244     QStackedWidget *m_WizardStack;
0245     QPrinter *m_Printer;
0246 
0247     FOV_TYPE m_FovType;
0248     QSize m_FovImageSize;
0249     SimpleFovExporter m_SimpleFovExporter;
0250 
0251     QList<FovSnapshot *> m_FovSnapshots;
0252 
0253     SkyObject *m_ShBeginObject;
0254     bool m_PointingShBegin;
0255 
0256     bool m_SwitchColors;
0257     QString m_PrevSchemeName;
0258 
0259     bool m_RecapturingFov;
0260     int m_RecaptureIdx;
0261 
0262     QPushButton *nextB, *backB;
0263 
0264     PWizWelcomeUI *m_WizWelcomeUI;
0265     PWizObjectSelectionUI *m_WizObjectSelectionUI;
0266     PWizFovTypeSelectionUI *m_WizFovTypeSelectionUI;
0267     PWizFovConfigUI *m_WizFovConfigUI;
0268     PWizFovManualUI *m_WizFovManualUI;
0269     PWizFovShUI *m_WizFovShUI;
0270     PWizFovBrowseUI *m_WizFovBrowseUI;
0271     PWizChartConfigUI *m_WizChartConfigUI;
0272     PWizChartContentsUI *m_WizChartContentsUI;
0273     PWizPrintUI *m_WizPrintUI;
0274 };
0275 
0276 #endif // PRINTINGWIZARD_H