Engauge Digitizer  2
GraphicsScene.h
Go to the documentation of this file.
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #ifndef GRAPHICS_SCENE_H
8 #define GRAPHICS_SCENE_H
9 
10 #include "CmdMediator.h"
11 #include "GraphicsLinesForCurves.h"
12 #include <QGraphicsScene>
13 #include <QObject>
14 #include <QStringList>
15 
16 class CmdMediator;
17 class Curve;
18 class CurvesGraphs;
19 class CurveStyles;
20 class GeometryWindow;
21 class GraphicsPoint;
22 class LineStyle;
23 class MainWindow;
24 class PointStyle;
25 class QGraphicsPathItem;
26 class QTextStream;
27 class ScaleBar;
28 class Transformation;
29 
36 class GraphicsScene : public QGraphicsScene
37 {
38  // We use Q_OBJECT so translations work
39  Q_OBJECT;
40 
41 public:
43  GraphicsScene(MainWindow *mainWindow);
44 
46  virtual ~GraphicsScene();
47 
49  void addTemporaryPoint (const QString &identifier,
50  GraphicsPoint *point);
51 
54  void addTemporaryScaleBar (GraphicsPoint *point0,
55  GraphicsPoint *point1,
56  const QString &pointIdentifier0,
57  const QString &pointIdentifier1);
58 
60  GraphicsPoint *createPoint (const QString &identifier,
61  const PointStyle &pointStyle,
62  const QPointF &posScreen,
63  GeometryWindow *geometryWindow);
64 
67 
69  QStringList positionHasChangedPointIdentifiers () const;
70 
72  void printStream (QString indentation,
73  QTextStream &str);
74 
76  void removePoint (const QString &identifier);
77 
81 
84 
86  void resetOnLoad();
87 
90 
92  void showCurves (bool show,
93  bool showAll = false,
94  const QString &curveName = "");
95 
98  void updateAfterCommand (CmdMediator &cmdMediator,
99  double highlightOpacity,
100  GeometryWindow *geometryWindow,
101  const Transformation &transformation);
102 
104  void updateCurveStyles(const CurveStyles &modelCurveStyles);
105 
108  void updateGraphicsLinesToMatchGraphicsPoints (const CurveStyles &modelCurveStyles,
109  const Transformation &transformation);
110 
111 private:
112 
114  QString dumpCursors () const;
115 
116  const QGraphicsPixmapItem *image () const;
117 
119  void updateCurves (CmdMediator &cmdMediator);
120 
122  void updatePathItemMultiValued (const QPainterPath &pathMultiValued,
123  const LineStyle &lineMultiValued);
124 
126  void updatePointMembership (CmdMediator &cmdMediator,
127  GeometryWindow *geometryWindow,
128  const Transformation &transformation);
129 
131  GraphicsLinesForCurves m_graphicsLinesForCurves;
132 
137  QGraphicsPathItem *m_pathItemMultiValued;
138 };
139 
140 #endif // GRAPHICS_SCENE_H
GraphicsScene::GraphicsScene
GraphicsScene(MainWindow *mainWindow)
Single constructor.
Definition: GraphicsScene.cpp:28
GraphicsScene::resetOnLoad
void resetOnLoad()
Reset, when loading a document after the first, to same state that first document was at when loaded.
Definition: GraphicsScene.cpp:204
GraphicsScene::createPoint
GraphicsPoint * createPoint(const QString &identifier, const PointStyle &pointStyle, const QPointF &posScreen, GeometryWindow *geometryWindow)
Create one QGraphicsItem-based object that represents one Point. It is NOT added to m_graphicsLinesFo...
Definition: GraphicsScene.cpp:69
GraphicsLinesForCurves
This class stores the GraphicsLinesForCurves objects, one per Curve.
Definition: GraphicsLinesForCurves.h:28
GraphicsScene::removeTemporaryPointIfExists
void removeTemporaryPointIfExists()
Remove temporary point if it exists.
Definition: GraphicsScene.cpp:192
GraphicsScene::~GraphicsScene
virtual ~GraphicsScene()
Virtual destructor needed since using Q_OBJECT.
Definition: GraphicsScene.cpp:34
CmdMediator.h
GraphicsScene::showCurves
void showCurves(bool show, bool showAll=false, const QString &curveName="")
Show or hide all Curves (if showAll is true) or just the selected Curve (if showAll is false);.
Definition: GraphicsScene.cpp:232
GraphicsScene::resetPositionHasChangedFlags
void resetPositionHasChangedFlags()
Reset positionHasChanged flag for all items. Typically this is done as part of mousePressEvent.
Definition: GraphicsScene.cpp:219
Transformation
Affine transformation between screen and graph coordinates, based on digitized axis points.
Definition: Transformation.h:30
GraphicsScene::addTemporaryPoint
void addTemporaryPoint(const QString &identifier, GraphicsPoint *point)
Add one temporary point to m_graphicsLinesForCurves. Non-temporary points are handled by the updateLi...
Definition: GraphicsScene.cpp:38
Curve
Container for one set of digitized Points.
Definition: Curve.h:32
GraphicsScene::addTemporaryScaleBar
void addTemporaryScaleBar(GraphicsPoint *point0, GraphicsPoint *point1, const QString &pointIdentifier0, const QString &pointIdentifier1)
Add temporary scale bar to scene.
Definition: GraphicsScene.cpp:50
GraphicsScene::printStream
void printStream(QString indentation, QTextStream &str)
Debugging method that supports print method of this class and printStream method of some other class(...
Definition: GraphicsScene.cpp:178
GraphicsLinesForCurves.h
MainWindow
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:90
LineStyle
Details for a specific Line.
Definition: LineStyle.h:18
GraphicsScene
Add point and line handling to generic QGraphicsScene.
Definition: GraphicsScene.h:35
GraphicsScene::hideAllItemsExceptImage
void hideAllItemsExceptImage()
Hide all graphics items, except background image, in preparation for preview during IMPORT_TYPE_ADVAN...
Definition: GraphicsScene.cpp:107
GraphicsScene::removePoint
void removePoint(const QString &identifier)
Remove specified point. This aborts if the point does not exist.
Definition: GraphicsScene.cpp:185
CurvesGraphs
Container for all graph curves. The axes point curve is external to this class.
Definition: CurvesGraphs.h:23
CmdMediator
Command queue stack.
Definition: CmdMediator.h:22
PointStyle
Details for a specific Point.
Definition: PointStyle.h:19
GraphicsPoint
Graphics item for drawing a circular or polygonal Point.
Definition: GraphicsPoint.h:42
GraphicsScene::positionHasChangedPointIdentifiers
QStringList positionHasChangedPointIdentifiers() const
Return a list of identifiers for the points that have moved since the last call to resetPositionHasCh...
Definition: GraphicsScene.cpp:143
GeometryWindow
Window that displays the geometry information, as a table, for the current curve.
Definition: GeometryWindow.h:27
CurveStyles
Model for DlgSettingsCurveProperties and CmdSettingsCurveProperties.
Definition: CurveStyles.h:21
GraphicsScene::updateAfterCommand
void updateAfterCommand(CmdMediator &cmdMediator, double highlightOpacity, GeometryWindow *geometryWindow, const Transformation &transformation)
Update the Points and their Curves after executing a command.
Definition: GraphicsScene.cpp:275
GraphicsScene::updateGraphicsLinesToMatchGraphicsPoints
void updateGraphicsLinesToMatchGraphicsPoints(const CurveStyles &modelCurveStyles, const Transformation &transformation)
A mouse move has just occurred so move the selected points, since they were dragged.
Definition: GraphicsScene.cpp:312
GraphicsScene::removeTemporaryScaleBarIfExists
void removeTemporaryScaleBarIfExists()
Remove temporary scale bar, composed of two points and the line between them.
Definition: GraphicsScene.cpp:199
GraphicsScene::updateCurveStyles
void updateCurveStyles(const CurveStyles &modelCurveStyles)
Update curve styles after settings changed.
Definition: GraphicsScene.cpp:305