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)  

Worksheet.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : Worksheet.h
3  Project : LabPlot
4  Description : Worksheet (2D visualization) part
5  --------------------------------------------------------------------
6  Copyright : (C) 2009 Tilman Benkert (thzs@gmx.net)
7  Copyright : (C) 2011-2019 by Alexander Semke (alexander.semke@web.de)
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  * This program is distributed in the hope that it will be useful, *
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20  * GNU General Public License for more details. *
21  * *
22  * You should have received a copy of the GNU General Public License *
23  * along with this program; if not, write to the Free Software *
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
25  * Boston, MA 02110-1301 USA *
26  * *
27  ***************************************************************************/
28 
29 #ifndef WORKSHEET_H
30 #define WORKSHEET_H
31 
35 
36 class QGraphicsItem;
37 class QGraphicsScene;
38 class QRectF;
39 
40 class WorksheetPrivate;
41 class WorksheetView;
42 class TreeModel;
43 class XYCurve;
44 class CartesianPlot;
45 
46 class Worksheet : public AbstractPart {
47  Q_OBJECT
48 
49 public:
50  explicit Worksheet(const QString& name, bool loading = false);
51  ~Worksheet() override;
52 
53  enum class Unit {Millimeter, Centimeter, Inch, Point};
56 
57  static double convertToSceneUnits(const double value, const Worksheet::Unit unit);
58  static double convertFromSceneUnits(const double value, const Worksheet::Unit unit);
59 
60  QIcon icon() const override;
61  QMenu* createContextMenu() override;
62  QWidget* view() const override;
63  QVector<AbstractAspect*> dependsOn() const override;
64 
65  bool exportView() const override;
66  bool printView() override;
67  bool printPreview() const override;
68 
69  void save(QXmlStreamWriter*) const override;
70  bool load(XmlStreamReader*, bool preview) override;
71 
72  QRectF pageRect() const;
73  void setPageRect(const QRectF&);
74  QGraphicsScene* scene() const;
75  void update();
76  void setPrinting(bool) const;
77  void setThemeName(const QString&);
78 
79  void setItemSelectedInView(const QGraphicsItem*, const bool);
80  void setSelectedInView(const bool);
81  void deleteAspectFromGraphicsItem(const QGraphicsItem*);
82  void setIsClosing();
84 
89  void setPlotsLocked(bool);
90  bool plotsLocked();
91  int getPlotCount();
92  CartesianPlot* getPlot(int index);
94 
95  void cursorModelPlotAdded(const QString& name);
96  void cursorModelPlotRemoved(const QString& name);
97 
98  BASIC_D_ACCESSOR_DECL(float, backgroundOpacity, BackgroundOpacity)
99  BASIC_D_ACCESSOR_DECL(PlotArea::BackgroundType, backgroundType, BackgroundType)
100  BASIC_D_ACCESSOR_DECL(PlotArea::BackgroundColorStyle, backgroundColorStyle, BackgroundColorStyle)
101  BASIC_D_ACCESSOR_DECL(PlotArea::BackgroundImageStyle, backgroundImageStyle, BackgroundImageStyle)
102  BASIC_D_ACCESSOR_DECL(Qt::BrushStyle, backgroundBrushStyle, BackgroundBrushStyle)
103  CLASS_D_ACCESSOR_DECL(QColor, backgroundFirstColor, BackgroundFirstColor)
104  CLASS_D_ACCESSOR_DECL(QColor, backgroundSecondColor, BackgroundSecondColor)
105  CLASS_D_ACCESSOR_DECL(QString, backgroundFileName, BackgroundFileName)
106 
107  BASIC_D_ACCESSOR_DECL(bool, scaleContent, ScaleContent)
108  BASIC_D_ACCESSOR_DECL(bool, useViewSize, UseViewSize)
110  BASIC_D_ACCESSOR_DECL(float, layoutTopMargin, LayoutTopMargin)
111  BASIC_D_ACCESSOR_DECL(float, layoutBottomMargin, LayoutBottomMargin)
112  BASIC_D_ACCESSOR_DECL(float, layoutLeftMargin, LayoutLeftMargin)
113  BASIC_D_ACCESSOR_DECL(float, layoutRightMargin, LayoutRightMargin)
114  BASIC_D_ACCESSOR_DECL(float, layoutHorizontalSpacing, LayoutHorizontalSpacing)
115  BASIC_D_ACCESSOR_DECL(float, layoutVerticalSpacing, LayoutVerticalSpacing)
116  BASIC_D_ACCESSOR_DECL(int, layoutRowCount, LayoutRowCount)
117  BASIC_D_ACCESSOR_DECL(int, layoutColumnCount, LayoutColumnCount)
118 
119  QString theme() const;
120 
121  void setSuppressLayoutUpdate(bool);
122  void updateLayout();
123 
124  void registerShortcuts() override;
125  void unregisterShortcuts() override;
126 
128 
129 public slots:
130  void setTheme(const QString&);
131  void cartesianPlotMousePressZoomSelectionMode(QPointF logicPos);
132  void cartesianPlotMousePressCursorMode(int cursorNumber, QPointF logicPos);
133  void cartesianPlotMouseMoveZoomSelectionMode(QPointF logicPos);
134  void cartesianPlotMouseMoveCursorMode(int cursorNumber, QPointF logicPos);
136  void cartesianPlotMouseHoverZoomSelectionMode(QPointF logicPos);
139 
140  // slots needed by the cursor
141  void updateCurveBackground(const QPen&, const QString& curveName);
143  void cursorPosChanged(int cursorNumber, double xPos);
144  void curveAdded(const XYCurve* curve);
145  void curveRemoved(const XYCurve* curve);
146  void curveDataChanged(const XYCurve* curve);
147 
148 private:
149  void init();
150  WorksheetElement* aspectFromGraphicsItem(const WorksheetElement*, const QGraphicsItem*) const;
151  void loadTheme(const QString&);
152 
154  mutable WorksheetView* m_view{nullptr};
155  friend class WorksheetPrivate;
156 
157 private slots:
158  void handleAspectAdded(const AbstractAspect*);
160  void handleAspectRemoved(const AbstractAspect* parent, const AbstractAspect* before, const AbstractAspect* child);
161 
162  void childSelected(const AbstractAspect*) override;
163  void childDeselected(const AbstractAspect*) override;
164 
165 signals:
167  void itemSelected(QGraphicsItem*);
168  void itemDeselected(QGraphicsItem*);
174 
178  void backgroundBrushStyleChanged(Qt::BrushStyle);
179  void backgroundFirstColorChanged(const QColor&);
180  void backgroundSecondColorChanged(const QColor&);
181  void backgroundFileNameChanged(const QString&);
184  void pageRectChanged(const QRectF&);
194  void themeChanged(const QString&);
195 };
196 
197 #endif
Base class of all persistent objects in a Project.
AbstractAspect * parent(AspectType type) const
In the parent-child hierarchy, return the first parent of type.
QString name() const
T * child(int index, ChildIndexFlags flags={}) const
Base class of Aspects with MDI windows as views (AspectParts).
Definition: AbstractPart.h:36
A xy-plot.
Definition: CartesianPlot.h:58
BackgroundColorStyle
Definition: PlotArea.h:46
BackgroundImageStyle
Definition: PlotArea.h:48
BackgroundType
Definition: PlotArea.h:45
The TreeModel class This is an abstract treemodel which can be used by a treeview.
Definition: TreeModel.h:68
Base class for all Worksheet children.
Worksheet view.
Definition: WorksheetView.h:51
Top-level container for worksheet elements like plot, labels, etc.
Definition: Worksheet.h:46
void useViewSizeRequested()
void setCartesianPlotActionMode(CartesianPlotActionMode mode)
Definition: Worksheet.cpp:461
void cartesianPlotMousePressCursorMode(int cursorNumber, QPointF logicPos)
Definition: Worksheet.cpp:760
void cartesianPlotMouseReleaseZoomSelectionMode()
Definition: Worksheet.cpp:749
void backgroundBrushStyleChanged(Qt::BrushStyle)
int getPlotCount()
Worksheet::getPlotCount.
Definition: Worksheet.cpp:417
void updateCurveBackground(const QPen &, const QString &curveName)
Definition: Worksheet.cpp:1072
void setSuppressLayoutUpdate(bool)
Definition: Worksheet.cpp:441
CartesianPlotActionMode cartesianPlotCursorMode()
Definition: Worksheet.cpp:453
QGraphicsScene * scene() const
Definition: Worksheet.cpp:299
void handleAspectAboutToBeRemoved(const AbstractAspect *)
Definition: Worksheet.cpp:280
CartesianPlotActionMode cartesianPlotActionMode()
Definition: Worksheet.cpp:449
QWidget * view() const override
Construct a primary view on me.
Definition: Worksheet.cpp:165
void layoutColumnCountChanged(int)
void layoutLeftMarginChanged(float)
void cartesianPlotMouseModeChanged(CartesianPlot::MouseMode)
void updateLayout()
Definition: Worksheet.cpp:445
~Worksheet() override
Definition: Worksheet.cpp:73
void backgroundColorStyleChanged(PlotArea::BackgroundColorStyle)
void setIsClosing()
Definition: Worksheet.cpp:403
void cartesianPlotMouseHoverZoomSelectionMode(QPointF logicPos)
Definition: Worksheet.cpp:784
void showCursorDock(TreeModel *, QVector< CartesianPlot * >)
void setThemeName(const QString &)
void backgroundOpacityChanged(float)
void cursorModelPlotRemoved(const QString &name)
Definition: Worksheet.cpp:937
QMenu * createContextMenu() override
Definition: Worksheet.cpp:153
void curveRemoved(const XYCurve *curve)
Definition: Worksheet.cpp:1040
void cartesianPlotMousePressZoomSelectionMode(QPointF logicPos)
Definition: Worksheet.cpp:738
void setSelectedInView(const bool)
Definition: Worksheet.cpp:377
void layoutChanged(Worksheet::Layout)
void setPrinting(bool) const
Definition: Worksheet.cpp:717
void itemSelected(QGraphicsItem *)
void handleAspectAdded(const AbstractAspect *)
Definition: Worksheet.cpp:228
CartesianPlot * getPlot(int index)
Worksheet::getPlot.
Definition: Worksheet.cpp:426
void backgroundTypeChanged(PlotArea::BackgroundType)
void pageRectChanged(const QRectF &)
bool load(XmlStreamReader *, bool preview) override
Load from XML.
Definition: Worksheet.cpp:1403
void layoutBottomMarginChanged(float)
static double convertFromSceneUnits(const double value, const Worksheet::Unit unit)
Definition: Worksheet.cpp:131
void cartesianPlotMouseMoveCursorMode(int cursorNumber, QPointF logicPos)
Definition: Worksheet.cpp:806
void setPlotsLocked(bool)
Definition: Worksheet.cpp:491
void save(QXmlStreamWriter *) const override
Save as XML.
Definition: Worksheet.cpp:1337
void itemDeselected(QGraphicsItem *)
void cursorModelPlotAdded(const QString &name)
Definition: Worksheet.cpp:927
void cartesianPlotMouseMoveZoomSelectionMode(QPointF logicPos)
Definition: Worksheet.cpp:773
TreeModel * cursorModel()
Definition: Worksheet.cpp:433
void backgroundFileNameChanged(const QString &)
void layoutVerticalSpacingChanged(float)
void backgroundSecondColorChanged(const QColor &)
void themeChanged(const QString &)
void childDeselected(const AbstractAspect *) override
Definition: Worksheet.cpp:323
void requestProjectContextMenu(QMenu *)
QString theme() const
void init()
Definition: Worksheet.cpp:77
void requestUpdate()
void cartesianPlotMouseModeChangedSlot(CartesianPlot::MouseMode)
Definition: Worksheet.cpp:951
QRectF pageRect() const
Definition: Worksheet.cpp:303
void curveAdded(const XYCurve *curve)
Definition: Worksheet.cpp:994
void setPageRect(const QRectF &)
Definition: Worksheet.cpp:697
void suppressSelectionChangedEvent(bool)
Definition: Worksheet.cpp:408
void deleteAspectFromGraphicsItem(const QGraphicsItem *)
Definition: Worksheet.cpp:384
void curveDataChanged(const XYCurve *curve)
Definition: Worksheet.cpp:960
WorksheetPrivate *const d
Definition: Worksheet.h:153
void layoutHorizontalSpacingChanged(float)
void setCartesianPlotCursorMode(CartesianPlotActionMode mode)
Definition: Worksheet.cpp:469
bool printPreview() const override
Definition: Worksheet.cpp:222
void setItemSelectedInView(const QGraphicsItem *, const bool)
Definition: Worksheet.cpp:335
void layoutRightMarginChanged(float)
void cursorPosChanged(int cursorNumber, double xPos)
Worksheet::cursorPosChanged Updates the cursor treemodel with the new data.
Definition: Worksheet.cpp:826
void setTheme(const QString &)
Definition: Worksheet.cpp:724
bool plotsLocked()
Definition: Worksheet.cpp:457
bool exportView() const override
Definition: Worksheet.cpp:191
void registerShortcuts() override
Definition: Worksheet.cpp:503
QIcon icon() const override
Return an icon to be used for decorating my views.
Definition: Worksheet.cpp:146
void updateCompleteCursorTreeModel()
Worksheet::updateCompleteCursorTreeModel If the plot or the curve are not available,...
Definition: Worksheet.cpp:1105
void scaleContentChanged(bool)
Worksheet(const QString &name, bool loading=false)
Definition: Worksheet.cpp:64
WorksheetView * m_view
Definition: Worksheet.h:154
void backgroundImageStyleChanged(PlotArea::BackgroundImageStyle)
void cartesianPlotMouseHoverOutsideDataRect()
Definition: Worksheet.cpp:795
void layoutRowCountChanged(int)
void propertiesExplorerRequested()
CartesianPlotActionMode
Definition: Worksheet.h:55
WorksheetElement * aspectFromGraphicsItem(const WorksheetElement *, const QGraphicsItem *) const
Definition: Worksheet.cpp:358
void unregisterShortcuts() override
Definition: Worksheet.cpp:507
static double convertToSceneUnits(const double value, const Worksheet::Unit unit)
Definition: Worksheet.cpp:113
void loadTheme(const QString &)
Definition: Worksheet.cpp:1563
bool printView() override
Definition: Worksheet.cpp:210
void layoutTopMarginChanged(float)
void backgroundFirstColorChanged(const QColor &)
void childSelected(const AbstractAspect *) override
Definition: Worksheet.cpp:312
void handleAspectRemoved(const AbstractAspect *parent, const AbstractAspect *before, const AbstractAspect *child)
Definition: Worksheet.cpp:288
QVector< AbstractAspect * > dependsOn() const override
Definition: Worksheet.cpp:180
void update()
Definition: Worksheet.cpp:437
A 2D-curve, provides an interface for editing many properties of the curve.
Definition: XYCurve.h:46
XML stream parser that supports errors as well as warnings. This class also adds line and column numb...
#define CLASS_D_ACCESSOR_DECL(type, method, Method)
Definition: macros.h:134
#define BASIC_D_ACCESSOR_DECL(type, method, Method)
Definition: macros.h:107