labplot  2.8.2
About: LabPlot is an application for plotting and analysis of 2D and 3D functions and data. It is a complete rewrite of LabPlot1 and lacks in the first release a lot of features available in the predecessor. On the other hand, the GUI and the usability is more superior.
  Fossies Dox: labplot-2.8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

WorksheetView.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : WorksheetView.h
3  Project : LabPlot
4  Description : Worksheet view
5  --------------------------------------------------------------------
6  Copyright : (C) 2009-2019 by Alexander Semke (alexander.semke@web.de)
7  Copyright : (C) 2018 by Stefan Gerlach (stefan.gerlach@uni.kn)
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
29 
30 #ifndef WORKSHEETVIEW_H
31 #define WORKSHEETVIEW_H
32 
33 #include <QGraphicsView>
36 
37 class QPrinter;
38 class QMenu;
39 class QToolBar;
40 class QToolButton;
41 class QWheelEvent;
42 class QTimeLine;
43 
44 class AbstractAspect;
45 class WorksheetElement;
46 
47 #ifdef Q_OS_MAC
48  class KDMacTouchBar;
49 #endif
50 
51 class WorksheetView : public QGraphicsView {
52  Q_OBJECT
53 
54 public:
55  explicit WorksheetView(Worksheet* worksheet);
56 
57  enum class ExportFormat {PDF, SVG, PNG};
58  enum class GridStyle {NoGrid, Line, Dot};
60 
61  struct GridSettings {
63  QColor color;
66  double opacity;
67  };
68 
70 
71  void setScene(QGraphicsScene*);
72  void exportToFile(const QString&, const ExportFormat, const ExportArea, const bool, const int);
73  void exportToClipboard(const ExportFormat, const ExportArea, const bool, const int);
74  void exportToClipboard();
75  void setIsClosing();
76  void setIsBeingPresented(bool presenting);
79  void setPlotLock(bool lock);
81 
83  void registerShortcuts();
84  void unregisterShortcuts();
85 
86 private:
87  void initBasicActions();
88  void initActions();
89  void initMenus();
90  void processResize();
91  void drawForeground(QPainter*, const QRectF&) override;
92  void drawBackground(QPainter*, const QRectF&) override;
93  void drawBackgroundItems(QPainter*, const QRectF&);
94  bool isPlotAtPos(QPoint) const;
95  CartesianPlot* plotAt(QPoint) const;
96  void exportPaint(QPainter* painter, const QRectF& targetRect, const QRectF& sourceRect, const bool);
97  void cartesianPlotAdd(CartesianPlot*, QAction*);
98 
99  //events
100  void resizeEvent(QResizeEvent*) override;
101  void contextMenuEvent(QContextMenuEvent*) override;
102  void wheelEvent(QWheelEvent*) override;
103  void mousePressEvent(QMouseEvent*) override;
104  void mouseDoubleClickEvent(QMouseEvent*) override;
105  void mouseReleaseEvent(QMouseEvent*) override;
106  void mouseMoveEvent(QMouseEvent*) override;
107  void keyPressEvent(QKeyEvent*) override;
108  void keyReleaseEvent(QKeyEvent*) override;
109  void dragEnterEvent(QDragEnterEvent*) override;
110  void dragMoveEvent(QDragMoveEvent*) override;
111  void dropEvent(QDropEvent*) override;
112 
120  QGraphicsPixmapItem* m_magnificationWindow{nullptr};
125  QTimeLine* m_fadeInTimeLine{nullptr};
126  QTimeLine* m_fadeOutTimeLine{nullptr};
127  bool m_isClosing{false};
128  bool m_actionsInitialized{false};
129  bool m_menusInitialized{false};
132 
133  //Menus
134  QMenu* m_addNewMenu{nullptr};
135  QMenu* m_addNewCartesianPlotMenu{nullptr};
136  QMenu* m_zoomMenu{nullptr};
137  QMenu* m_magnificationMenu{nullptr};
138  QMenu* m_layoutMenu{nullptr};
139  QMenu* m_gridMenu{nullptr};
140  QMenu* m_themeMenu{nullptr};
141  QMenu* m_viewMouseModeMenu{nullptr};
142  QMenu* m_cartesianPlotMenu{nullptr};
144  QMenu* m_cartesianPlotAddNewMenu{nullptr};
146  QMenu* m_cartesianPlotZoomMenu{nullptr};
149  QMenu* m_dataManipulationMenu{nullptr};
150 
151  QToolButton* tbNewCartesianPlot{nullptr};
152  QToolButton* tbZoom{nullptr};
153  QToolButton* tbMagnification{nullptr};
154  QAction* currentZoomAction{nullptr};
155  QAction* currentMagnificationAction{nullptr};
156 
157  //Actions
158  QAction* selectAllAction{nullptr};
159  QAction* deleteAction{nullptr};
160  QAction* backspaceAction{nullptr};
161 
162  QAction* zoomInViewAction{nullptr};
163  QAction* zoomOutViewAction{nullptr};
164  QAction* zoomOriginAction{nullptr};
165  QAction* zoomFitPageHeightAction{nullptr};
166  QAction* zoomFitPageWidthAction{nullptr};
167  QAction* zoomFitSelectionAction{nullptr};
168 
169  QAction* navigationModeAction{nullptr};
170  QAction* zoomSelectionModeAction{nullptr};
171  QAction* selectionModeAction{nullptr};
172 
173  QAction* addCartesianPlot1Action{nullptr};
174  QAction* addCartesianPlot2Action{nullptr};
175  QAction* addCartesianPlot3Action{nullptr};
176  QAction* addCartesianPlot4Action{nullptr};
177  QAction* addTextLabelAction{nullptr};
178  QAction* addImageAction{nullptr};
179  QAction* addHistogram{nullptr};
180 
181  QAction* verticalLayoutAction{nullptr};
182  QAction* horizontalLayoutAction{nullptr};
183  QAction* gridLayoutAction{nullptr};
184  QAction* breakLayoutAction{nullptr};
185 
186  QAction* noGridAction{nullptr};
187  QAction* denseLineGridAction{nullptr};
188  QAction* sparseLineGridAction{nullptr};
189  QAction* denseDotGridAction{nullptr};
190  QAction* sparseDotGridAction{nullptr};
191  QAction* customGridAction{nullptr};
192  QAction* snapToGridAction{nullptr};
193 
194  QAction* noMagnificationAction{nullptr};
195  QAction* twoTimesMagnificationAction{nullptr};
196  QAction* threeTimesMagnificationAction{nullptr};
197  QAction* fourTimesMagnificationAction{nullptr};
198  QAction* fiveTimesMagnificationAction{nullptr};
199 
200  QAction* plotsLockedAction{nullptr};
201  QAction* showPresenterMode{nullptr};
202 
203  //Actions for cartesian plots
205  QAction* cartesianPlotApplyToAllAction{nullptr};
206  QAction* cartesianPlotApplyToAllCursor{nullptr};
212  QAction* cartesianPlotCursorModeAction{nullptr};
213 
214  QAction* addCurveAction{nullptr};
215  QAction* addHistogramAction{nullptr};
216  QAction* addEquationCurveAction{nullptr};
217  QAction* addDataOperationCurveAction{nullptr};
218  QAction* addDataReductionCurveAction{nullptr};
219  QAction* addDifferentiationCurveAction{nullptr};
220  QAction* addIntegrationCurveAction{nullptr};
221  QAction* addInterpolationCurveAction{nullptr};
222  QAction* addSmoothCurveAction{nullptr};
223  QAction* addFitCurveAction{nullptr};
224  QAction* addFourierFilterCurveAction{nullptr};
226  QAction* addConvolutionCurveAction{nullptr};
227  QAction* addCorrelationCurveAction{nullptr};
228 
229  QAction* addHorizontalAxisAction{nullptr};
230  QAction* addVerticalAxisAction{nullptr};
231  QAction* addLegendAction{nullptr};
232  QAction* addPlotTextLabelAction{nullptr};
233  QAction* addPlotImageAction{nullptr};
234  QAction* addCustomPointAction{nullptr};
235 
236  QAction* scaleAutoXAction{nullptr};
237  QAction* scaleAutoYAction{nullptr};
238  QAction* scaleAutoAction{nullptr};
239  QAction* zoomInAction{nullptr};
240  QAction* zoomOutAction{nullptr};
241  QAction* zoomInXAction{nullptr};
242  QAction* zoomOutXAction{nullptr};
243  QAction* zoomInYAction{nullptr};
244  QAction* zoomOutYAction{nullptr};
245  QAction* shiftLeftXAction{nullptr};
246  QAction* shiftRightXAction{nullptr};
247  QAction* shiftUpYAction{nullptr};
248  QAction* shiftDownYAction{nullptr};
249 
250  // Analysis menu
251  QAction* addDataOperationAction{nullptr};
252  QAction* addDataReductionAction{nullptr};
253  QAction* addDifferentiationAction{nullptr};
254  QAction* addIntegrationAction{nullptr};
255  QAction* addInterpolationAction{nullptr};
256  QAction* addSmoothAction{nullptr};
257  QAction* addFitAction{nullptr};
258  QAction* addFourierFilterAction{nullptr};
259  QAction* addFourierTransformAction{nullptr};
260  QAction* addConvolutionAction{nullptr};
261  QAction* addCorrelationAction{nullptr};
262 
263 public slots:
264  void createContextMenu(QMenu*);
265  void createAnalysisMenu(QMenu*);
266  void fillToolBar(QToolBar*);
267 #ifdef Q_OS_MAC
268  void fillTouchBar(KDMacTouchBar*);
269 #endif
270  void fillCartesianPlotToolBar(QToolBar*);
271  void print(QPrinter*);
272  void selectItem(QGraphicsItem*);
273  void presenterMode();
274  void cartesianPlotMouseModeChangedSlot(CartesianPlot::MouseMode mouseMode); // from cartesian Plot
275 
276 private slots:
277  void addNew(QAction*);
279  void selectAllElements();
280  void deleteElement();
281 
282  void mouseModeChanged(QAction*);
283  void useViewSizeRequested();
284  void changeZoom(QAction*);
285  void magnificationChanged(QAction*);
286  void changeLayout(QAction*);
287  void changeGrid(QAction*);
288  void changeSnapToGrid();
289  void plotsLockedActionChanged(bool checked);
290 
291  void deselectItem(QGraphicsItem*);
292  void selectionChanged();
293  void updateBackground();
295 
296  void fadeIn(qreal);
297  void fadeOut(qreal);
298 
299  void zoom(int);
300  void scalingTime();
301  void animFinished();
302 
303  //SLOTs for cartesian plots
304  void cartesianPlotActionModeChanged(QAction*);
305  void cartesianPlotCursorModeChanged(QAction*);
306  void cartesianPlotMouseModeChanged(QAction*);
307  void cartesianPlotNavigationChanged(QAction*);
308  void cartesianPlotAddNew(QAction*);
310 
311 signals:
312  void statusInfo(const QString&);
314 };
315 
316 #endif
Base class of all persistent objects in a Project.
A xy-plot.
Definition: CartesianPlot.h:58
Base class for all Worksheet children.
Worksheet view.
Definition: WorksheetView.h:51
QAction * addDifferentiationCurveAction
void changeGrid(QAction *)
QAction * addTextLabelAction
void setPlotLock(bool lock)
QAction * scaleAutoXAction
void resizeEvent(QResizeEvent *) override
void fillCartesianPlotToolBar(QToolBar *)
Worksheet * m_worksheet
QAction * cartesianPlotApplyToAllCursor
QAction * sparseDotGridAction
void mouseMoveEvent(QMouseEvent *) override
QTimeLine * m_fadeOutTimeLine
QAction * addDataOperationCurveAction
void selectItem(QGraphicsItem *)
WorksheetView(Worksheet *worksheet)
QAction * addEquationCurveAction
QMenu * m_cartesianPlotAddNewAnalysisMenu
void statusInfo(const QString &)
void cartesianPlotNavigationChanged(QAction *)
QAction * selectionModeAction
QAction * addPlotImageAction
QAction * threeTimesMagnificationAction
GridSettings m_gridSettings
QAction * addDataReductionAction
void setIsBeingPresented(bool presenting)
Worksheet::CartesianPlotActionMode getCartesianPlotActionMode()
void print(QPrinter *)
QAction * shiftUpYAction
QMenu * m_gridMenu
void cartesianPlotAdd(CartesianPlot *, QAction *)
QAction * addImageAction
void cartesianPlotCursorModeChanged(QAction *)
QAction * noMagnificationAction
void exportToFile(const QString &, const ExportFormat, const ExportArea, const bool, const int)
QPoint m_selectionStart
void magnificationChanged(QAction *)
QAction * shiftLeftXAction
QAction * horizontalLayoutAction
QAction * fourTimesMagnificationAction
void contextMenuEvent(QContextMenuEvent *) override
void exportPaint(QPainter *painter, const QRectF &targetRect, const QRectF &sourceRect, const bool)
QAction * zoomSelectionModeAction
QMenu * m_addNewCartesianPlotMenu
QAction * zoomFitPageWidthAction
QGraphicsPixmapItem * m_magnificationWindow
QAction * zoomInAction
QMenu * m_layoutMenu
void layoutChanged(Worksheet::Layout)
void drawBackground(QPainter *, const QRectF &) override
QAction * selectAllAction
void cartesianPlotActionModeChanged(QAction *)
void keyReleaseEvent(QKeyEvent *) override
void mouseModeChanged(QAction *)
QAction * cartesianPlotApplyToAllAction
void exportToClipboard(const ExportFormat, const ExportArea, const bool, const int)
QMenu * m_cartesianPlotActionModeMenu
QMenu * m_addNewMenu
bool m_actionsInitialized
QMenu * m_viewMouseModeMenu
void cartesianPlotMouseModeChangedSlot(CartesianPlot::MouseMode mouseMode)
void fadeOut(qreal)
QAction * cartesianPlotZoomXSelectionModeAction
QAction * backspaceAction
void propertiesExplorerRequested()
void selectAllElements()
QAction * verticalLayoutAction
CartesianPlot::MouseMode m_cartesianPlotMouseMode
void initBasicActions()
QAction * cartesianPlotZoomSelectionModeAction
QAction * zoomInYAction
QAction * addConvolutionCurveAction
QMenu * m_cartesianPlotMenu
QAction * addCustomPointAction
bool m_selectionBandIsShown
QMenu * m_cartesianPlotZoomMenu
QAction * zoomOutViewAction
QAction * addCurveAction
void addNew(QAction *)
QAction * addFitCurveAction
QAction * currentMagnificationAction
QAction * addDataReductionCurveAction
QAction * showPresenterMode
void unregisterShortcuts()
QAction * zoomInViewAction
QMenu * m_themeMenu
QAction * addHorizontalAxisAction
QMenu * m_cartesianPlotCursorModeMenu
QAction * addHistogram
QAction * cartesianPlotApplyToSelectionAction
void setScene(QGraphicsScene *)
QAction * cartesianPlotCursorModeAction
QTimeLine * m_fadeInTimeLine
QPoint m_selectionEnd
QMenu * m_cartesianPlotAddNewMenu
QAction * addInterpolationAction
QMenu * m_dataManipulationMenu
QAction * addCartesianPlot1Action
QAction * addIntegrationCurveAction
QAction * shiftRightXAction
void keyPressEvent(QKeyEvent *) override
QAction * scaleAutoYAction
void cartesianPlotMouseModeChanged(QAction *)
QAction * addSmoothCurveAction
QAction * breakLayoutAction
QAction * addCartesianPlot2Action
QAction * addVerticalAxisAction
void createAnalysisMenu(QMenu *)
WorksheetElement * lastAddedWorksheetElement
QAction * addFourierFilterCurveAction
QAction * addDataOperationAction
QAction * addCorrelationAction
void fillToolBar(QToolBar *)
void dragEnterEvent(QDragEnterEvent *) override
QAction * plotsLockedAction
void createContextMenu(QMenu *)
void wheelEvent(QWheelEvent *) override
void useViewSizeRequested()
bool m_suppressSelectionChangedEvent
void cartesianPlotAddNew(QAction *)
QAction * addFourierTransformCurveAction
void registerShortcuts()
QAction * zoomInXAction
void changeLayout(QAction *)
QAction * customGridAction
void changeZoom(QAction *)
void handleCartesianPlotActions()
bool isPlotAtPos(QPoint) const
int m_numScheduledScalings
void dragMoveEvent(QDragMoveEvent *) override
QAction * currentZoomAction
QAction * addIntegrationAction
void dropEvent(QDropEvent *) override
QAction * gridLayoutAction
QAction * fiveTimesMagnificationAction
QAction * navigationModeAction
bool m_menusInitialized
QAction * cartesianPlotSelectionModeAction
QAction * denseLineGridAction
QList< QGraphicsItem * > m_selectedItems
QAction * zoomOutYAction
QToolButton * tbMagnification
QAction * cartesianPlotZoomYSelectionModeAction
void mouseReleaseEvent(QMouseEvent *) override
void setCartesianPlotActionMode(Worksheet::CartesianPlotActionMode mode)
QAction * shiftDownYAction
QAction * twoTimesMagnificationAction
void aspectAboutToBeRemoved(const AbstractAspect *)
bool m_suppressMouseModeChange
void exportToClipboard()
void mouseDoubleClickEvent(QMouseEvent *) override
QAction * noGridAction
void drawBackgroundItems(QPainter *, const QRectF &)
void setCartesianPlotCursorMode(Worksheet::CartesianPlotActionMode mode)
QAction * cartesianPlotApplyToSelectionCursor
void deselectItem(QGraphicsItem *)
QAction * addCartesianPlot4Action
CartesianPlot * plotAt(QPoint) const
QAction * denseDotGridAction
QAction * addPlotTextLabelAction
void drawForeground(QPainter *, const QRectF &) override
QAction * addDifferentiationAction
QToolButton * tbNewCartesianPlot
QAction * addConvolutionAction
QAction * zoomFitPageHeightAction
QAction * addCorrelationCurveAction
QMenu * m_cartesianPlotMouseModeMenu
QAction * addFitAction
QAction * addCartesianPlot3Action
QAction * zoomFitSelectionAction
QAction * scaleAutoAction
QMenu * m_zoomMenu
QAction * addInterpolationCurveAction
QAction * snapToGridAction
QAction * addSmoothAction
void mousePressEvent(QMouseEvent *) override
QAction * addLegendAction
QAction * zoomOutAction
QAction * addHistogramAction
QAction * zoomOutXAction
QAction * addFourierFilterAction
void plotsLockedActionChanged(bool checked)
QAction * deleteAction
void suppressSelectionChangedEvent(bool)
MouseMode m_mouseMode
QAction * zoomOriginAction
void fadeIn(qreal)
QAction * sparseLineGridAction
QToolButton * tbZoom
QMenu * m_magnificationMenu
QAction * addFourierTransformAction
Top-level container for worksheet elements like plot, labels, etc.
Definition: Worksheet.h:46
CartesianPlotActionMode
Definition: Worksheet.h:55