File indexing completed on 2024-05-12 15:27:36
0001 /*************************************************************************** 0002 File : DatapickerImageView.h 0003 Project : LabPlot 0004 Description : DatapickerImage view for datapicker 0005 -------------------------------------------------------------------- 0006 Copyright : (C) 2015 by Ankit Wagadre (wagadre.ankit@gmail.com) 0007 0008 ***************************************************************************/ 0009 /*************************************************************************** 0010 * * 0011 * This program is free software; you can redistribute it and/or modify * 0012 * it under the terms of the GNU General Public License as published by * 0013 * the Free Software Foundation; either version 2 of the License, or * 0014 * (at your option) any later version. * 0015 * * 0016 * This program is distributed in the hope that it will be useful, * 0017 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0019 * GNU General Public License for more details. * 0020 * * 0021 * You should have received a copy of the GNU General Public License * 0022 * along with this program; if not, write to the Free Software * 0023 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 0024 * Boston, MA 02110-1301 USA * 0025 * * 0026 ***************************************************************************/ 0027 0028 #ifndef DATAPICKERIMAGEVIEW_H 0029 #define DATAPICKERIMAGEVIEW_H 0030 0031 #include "commonfrontend/worksheet/WorksheetView.h" 0032 0033 class AbstractAspect; 0034 class DatapickerImage; 0035 class Datapicker; 0036 class Transform; 0037 0038 class QActionGroup; 0039 class QMenu; 0040 class QPrinter; 0041 class QToolBar; 0042 class QToolButton; 0043 class QWheelEvent; 0044 0045 class DatapickerImageView : public QGraphicsView { 0046 Q_OBJECT 0047 0048 public: 0049 explicit DatapickerImageView(DatapickerImage*); 0050 ~DatapickerImageView() override; 0051 0052 void setScene(QGraphicsScene*); 0053 void exportToFile(const QString&, const WorksheetView::ExportFormat, const int); 0054 0055 private: 0056 enum class MouseMode {Navigation, ZoomSelection, 0057 ReferencePointsEntry, CurvePointsEntry, CurveSegmentsEntry}; 0058 0059 void initActions(); 0060 void initMenus(); 0061 void drawForeground(QPainter*, const QRectF&) override; 0062 void drawBackground(QPainter*, const QRectF&) override; 0063 void exportPaint(QPainter*, const QRectF& targetRect, const QRectF& sourceRect); 0064 void updateMagnificationWindow(); 0065 0066 //events 0067 void contextMenuEvent(QContextMenuEvent*) override; 0068 void wheelEvent(QWheelEvent*) override; 0069 void mousePressEvent(QMouseEvent*) override; 0070 void mouseReleaseEvent(QMouseEvent*) override; 0071 void mouseMoveEvent(QMouseEvent*) override; 0072 0073 DatapickerImage* m_image; 0074 Datapicker* m_datapicker; 0075 Transform* m_transform; 0076 MouseMode m_mouseMode{MouseMode::ReferencePointsEntry}; 0077 bool m_selectionBandIsShown{false}; 0078 QPoint m_selectionStart; 0079 QPoint m_selectionEnd; 0080 int magnificationFactor{0}; 0081 float m_rotationAngle{0.0}; 0082 int m_numScheduledScalings{0}; 0083 0084 //Menus 0085 QMenu* m_zoomMenu; 0086 QMenu* m_viewMouseModeMenu; 0087 QMenu* m_viewImageMenu; 0088 QMenu* m_navigationMenu; 0089 QMenu* m_magnificationMenu; 0090 0091 QToolButton* tbZoom{nullptr}; 0092 QToolButton* tbMagnification{nullptr}; 0093 QAction* currentZoomAction{nullptr}; 0094 QAction* currentMagnificationAction{nullptr}; 0095 QAction* currentPlotPointsTypeAction{nullptr}; 0096 0097 //Actions 0098 QAction* zoomInViewAction; 0099 QAction* zoomOutViewAction; 0100 QAction* zoomOriginAction; 0101 QAction* zoomFitPageHeightAction; 0102 QAction* zoomFitPageWidthAction; 0103 0104 QAction* setAxisPointsAction; 0105 QAction* setCurvePointsAction; 0106 QAction* selectSegmentAction; 0107 0108 QAction* addCurveAction; 0109 0110 QAction* navigationModeAction; 0111 QAction* zoomSelectionModeAction; 0112 0113 QActionGroup* navigationActionGroup; 0114 QAction* shiftLeftAction; 0115 QAction* shiftRightAction; 0116 QAction* shiftDownAction; 0117 QAction* shiftUpAction; 0118 0119 QActionGroup* magnificationActionGroup; 0120 QAction* noMagnificationAction; 0121 QAction* twoTimesMagnificationAction; 0122 QAction* threeTimesMagnificationAction; 0123 QAction* fourTimesMagnificationAction; 0124 QAction* fiveTimesMagnificationAction; 0125 0126 public slots: 0127 void createContextMenu(QMenu*) const; 0128 void fillToolBar(QToolBar*); 0129 void print(QPrinter*); 0130 0131 private slots: 0132 void mouseModeChanged(QAction*); 0133 void magnificationChanged(QAction*); 0134 void changeZoom(QAction*); 0135 void changeSelectedItemsPosition(QAction*); 0136 void handleImageActions(); 0137 void updateBackground(); 0138 void addCurve(); 0139 void changeRotationAngle(); 0140 0141 void zoom(int); 0142 void scalingTime(); 0143 void animFinished(); 0144 0145 signals: 0146 void statusInfo(const QString&); 0147 }; 0148 0149 #endif