Engauge Digitizer 2
Loading...
Searching...
No Matches
Guidelines.h
Go to the documentation of this file.
1/******************************************************************************************************
2 * (C) 2019 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 GUIDELINES_H
8#define GUIDELINES_H
9
10#include "ColorPalette.h"
11#include "CoordsType.h"
12#include "GuidelineState.h"
13#include <QList>
14#include <QString>
15#include "Transformation.h"
16
18class GraphicsScene;
21class MainWindow;
22class QGraphicsScene;
23
24typedef QList<GuidelineAbstract*> GuidelineContainerPrivate;
25
28{
30 friend class TestGuidelines;
31
32public:
34 Guidelines(MainWindow &mainWindow);
36
38 void clear ();
39
41 ColorPalette color () const;
42
44 CoordsType coordsType () const;
45
47 GuidelineAbstract *createGuideline (const QString &identifier,
48 GuidelineState stateInitial);
49
51 void createGuidelineR (const QString &identifier,
52 double r);
53
55 void createGuidelineR (const QString &identifier,
56 const QPointF &posScreen);
57
59 void createGuidelineT (const QString &identifier,
60 double t);
61
63 void createGuidelineT (const QString &identifier,
64 const QPointF &posScreen);
65
67 void createGuidelineX (const QString &identifier,
68 double x);
69
71 void createGuidelineX (const QString &identifier,
72 const QPointF &posScreen);
73
75 void createGuidelineY (const QString &identifier,
76 double y);
77
79 void createGuidelineY (const QString &identifier,
80 const QPointF &posScreen);
81
84 void createReplacementGuideline (const QString &identifierReplaced,
85 double newValue,
86 GuidelineState guidelineStateForReplacement);
87
89 void handleActiveChange (bool active);
90
92 void handleGuidelineMode (bool visible,
93 bool locked);
94
96 void initialize (GraphicsScene &scene);
97
99 void moveGuidelineXT (const QString &identifier,
100 double valueAfter);
101
103 void moveGuidelineYR (const QString &identifier,
104 double valueAfter);
105
108 void removeGuideline (const QString &identifier);
109
112 const DocumentModelGuideline &modelGuideline);
113
115 QString stateDump () const;
116
119
121 void updateColor ();
122
124 DocumentModelGuideline updateValues (const DocumentModelGuideline &modelGuidelineOld) const;
125
128
129private:
130 Guidelines();
131
132 GuidelineContainerPrivate::iterator findIdentifierXT (const QString &identifier);
133 GuidelineContainerPrivate::iterator findIdentifierYR (const QString &identifier);
134
136 const GuidelineContainerPrivate &guidelineContainerPrivateXT () const;
137 const GuidelineContainerPrivate &guidelineContainerPrivateYR () const;
138
140 void registerGuidelineXT (GuidelineAbstract *guideline);
141 void registerGuidelineYR (GuidelineAbstract *guideline);
142
143 GuidelineAbstract *unregisterGuideline (const QString &identifier);
144
145 // Save for easy removal later
146 GuidelineContainerPrivate m_guidelineContainerXT;
147 GuidelineContainerPrivate m_guidelineContainerYR;
148
149 MainWindow &m_mainWindow;
150
151 GuidelineFactory *m_guidelineFactory;
152};
153
154#endif // GUIDELINES_H
ColorPalette
CoordsType
Definition CoordsType.h:12
GuidelineState
Set of possible Guideline states. See class Guideline for more information.
QList< GuidelineAbstract * > GuidelineContainerPrivate
Definition Guidelines.h:24
Model for managing the coordinate values corresponding Guidelines.
Add point and line handling to generic QGraphicsScene.
This class is a special case of the standard QGraphicsLineItem for guidelines, and serves as the base...
Factory for generating Guideline objects.
void setModelGuideline(CoordsType coordsType, const DocumentModelGuideline &modelGuideline)
Load Guidelines from Document.
void createGuidelineY(const QString &identifier, double y)
Factory method for creating a new GUIDELINE_STATE_DEPLOYED_CONSTANT_Y_ACTIVE.
void createGuidelineR(const QString &identifier, double r)
Factory method for creating a new GUIDELINE_STATE_DEPLOYED_CONSTANT_R_ACTIVE.
void createReplacementGuideline(const QString &identifierReplaced, double newValue, GuidelineState guidelineStateForReplacement)
Factory method for creating a new replacement Guideline, which replaces one handle and one visible Gu...
void clear()
Remove guidelines since the current Document is about to be closed.
CoordsType coordsType() const
Return cartesian or polar.
void createGuidelineT(const QString &identifier, double t)
Factory method for creating a new GUIDELINE_STATE_DEPLOYED_CONSTANT_T_ACTIVE.
GuidelineAbstract * createGuideline(const QString &identifier, GuidelineState stateInitial)
Factory method for creating a new Guideline.
void moveGuidelineYR(const QString &identifier, double valueAfter)
Move an Y/R guideline from one value to another. Closest value wins.
ColorPalette color() const
Color to be used for guidelines.
Transformation transformation() const
Return copy of transformation owned by MainWindow.
DocumentModelGuideline updateValues(const DocumentModelGuideline &modelGuidelineOld) const
Updates the guideline values for later storing in Document. Only the values are updated.
Guidelines(MainWindow &mainWindow)
Single constructor.
friend class TestGuidelines
For unit testing.
Definition Guidelines.h:30
void handleGuidelineMode(bool visible, bool locked)
User toggled guideline mode.
void removeGuideline(const QString &identifier)
Remove an X/T or Y/R guideline.
void updateWithLatestTransformation()
Update transformation. This is called after a command has been executed.
void moveGuidelineXT(const QString &identifier, double valueAfter)
Move an X/T guideline from one value to another. Closest value wins.
void initialize(GraphicsScene &scene)
Initialize Guideline factory.
void createGuidelineX(const QString &identifier, double x)
Factory method for creating a new GUIDELINE_STATE_DEPLOYED_CONSTANT_X_ACTIVE.
void handleActiveChange(bool active)
DigitizeState change so active status may (or may not) be toggled.
QString stateDump() const
States listed as a string for debugging only.
void updateColor()
Force a color update.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition MainWindow.h:95
Affine transformation between screen and graph coordinates, based on digitized axis points.