@@ -32,95 +32,92 @@ class uStraightLineSegment;
3232}
3333
3434
35+ // ! Graphics: Constraints
3536namespace QConstraint {
3637
3738using Uncertain::uStraightLineSegment;
3839
40+ // ! Graphics: Base class for marker depicting constraints
3941class QConstraintBase : public QGraphicsItem
4042{
4143protected:
4244 QConstraintBase ();
4345public:
46+ // ! Copy constructor
4447 QConstraintBase ( const QConstraintBase & other) = delete ;
48+
49+ // ! Copy assignment constructor
4550 QConstraintBase & operator = (const QConstraintBase&) = delete ;
4651
4752 // T qgraphicsitem_cast(QGraphicsItem *item)
4853 // To make this function work correctly with custom items, reimplement the type() function for each custom QGraphicsItem subclass.
4954 enum {Type = UserType +364 };
50- int type () const override { return Type; }
51-
52- void serialize ( QDataStream &out );
53- bool deserialize ( QDataStream &);
5455
55- virtual std::shared_ptr<QConstraintBase> create () const = 0;
56+ // ! Get graphics type (id)
57+ int type () const override { return Type; }
5658
57- void setColor ( const QColor & col) {
58- m_pen_req.setColor (col);
59- m_pen_red.setColor (col);
60- }
61- void setLineWidth ( const int w) {
62- m_pen_req.setWidth (w);
63- m_pen_red.setWidth (w);
64- }
59+ void serialize ( QDataStream &out ); // !< serialization
60+ bool deserialize ( QDataStream &); // !< deserialization
6561
66- void setLineStyle ( const int s) {
67- m_pen_req.setStyle ( Qt::PenStyle (s) );
68- m_pen_red.setStyle ( Qt::PenStyle (s) );
69- }
62+ virtual std::shared_ptr<QConstraintBase> create () const = 0; // !< Creation
7063
71- void setAltColor (const QColor &col );
64+ void setColor ( const QColor & col); // !< Set color
65+ void setLineWidth ( const int w); // !< Set line width
66+ void setLineStyle ( const int s); // !< Set line style
67+ void setAltColor ( const QColor &col ); // !< Set color for automatic colorization
7268 void setStatus ( bool isrequired,
73- bool isenforced);
69+ bool isenforced); // !< Set status
7470
71+ // ! Get status enforcment (success/failure)
7572 bool enforced () const { return m_is_enforced; }
7673
77-
78- virtual void setMarkerSize ( qreal s) = 0;
74+ virtual void setMarkerSize ( qreal s) = 0; // !< Set marker size
7975 virtual void setGeometry ( const uStraightLineSegment &s,
80- const uStraightLineSegment &t) = 0;
76+ const uStraightLineSegment &t) = 0; // !< Set geometry
8177
82- static QPen defaultPenReq () { return s_defaultPenReq; }
83- static QPen defaultPenRed () { return s_defaultPenRed; }
78+ static QPen defaultPenReq () { return s_defaultPenReq; } // !< Get default pen for required constraints
79+ static QPen defaultPenRed () { return s_defaultPenRed; } // !< Get default pen for redundant constraints
8480
85- static void setDefaultPenReq ( const QPen &p) { s_defaultPenReq = p; }
86- static void setDefaultPenRed ( const QPen &p) { s_defaultPenRed = p; }
87- static void setPenSelected ( const QPen &p) { s_penSelected = p;}
88- static void setDefaultMarkerSize ( int s) { s_defaultMarkerSize = s; }
81+ static void setDefaultPenReq ( const QPen &p) { s_defaultPenReq = p; } // !< Set default pen for required constraints
82+ static void setDefaultPenRed ( const QPen &p) { s_defaultPenRed = p; } // !< Set default pen for redundant constraints
83+ static void setPenSelected ( const QPen &p) { s_penSelected = p;} // !< Set pen for selection
84+ static void setDefaultMarkerSize ( int s) { s_defaultMarkerSize = s; } // !< Set default marker size
8985
90- static void toggleShow () { s_show = !s_show; }
91- static void toggleShowColor () { s_showColor =! s_showColor; }
92- static bool show () {return s_show;}
86+ static void toggleShow () { s_show = !s_show; } // !< Toggle visibility
87+ static void toggleShowColor () { s_showColor =! s_showColor; } // !< Toggle colorization (on/off)
88+ static bool show () {return s_show;} // !< Get status visibility
9389
9490protected:
9591 ~QConstraintBase () override = default ;
9692
97- virtual qreal markerSize () const = 0;
93+ virtual qreal markerSize () const = 0; // !< Set marker size
9894 void paint ( QPainter *painter,
9995 const QStyleOptionGraphicsItem *option,
100- QWidget *widget) override ;
96+ QWidget *widget) override ; // !< Plot marker
10197
102- void mousePressEvent (QGraphicsSceneMouseEvent *) override ;
98+ void mousePressEvent (QGraphicsSceneMouseEvent *) override ; // !< Handle mouse press event
10399
104- bool m_is_required = true ; // for painting
105- bool m_is_enforced = false ; // for painting
100+ bool m_is_required = true ; // !< Is required? ( for painting)
101+ bool m_is_enforced = false ; // !< Is enforced? ( for painting)
106102
107- static bool showColor () { return s_showColor; }
103+ static bool showColor () { return s_showColor; } // !< Get status automatic colorization (on/off)
108104
109- static int s_defaultMarkerSize;
110- static QPen s_defaultPenReq;
111- static QPen s_defaultPenRed;
112- static QPen s_penSelected;
105+ static int s_defaultMarkerSize; // !< Default marker size
106+ static QPen s_defaultPenReq; // !< Default pen for required constraints
107+ static QPen s_defaultPenRed; // !< Default pen for redundant constraints
108+ static QPen s_penSelected; // !< Pen for selection
113109
114- const double m_sc = 1000 ; // TODO(meijoc) QConstraintBase
115- QColor m_altColor;
116- QPen m_pen_req;
117- QPen m_pen_red;
110+ const double m_sc = 1000 ; // !< Scale factor coordinates screen // TODO(meijoc)
111+ QColor m_altColor; // !< Color for automatic colorization (subtasks)
112+ QPen m_pen_req; // !< Pen for required constraint
113+ QPen m_pen_red; // !< Pen for redundant constraint
118114
119115private:
120116 static bool s_showColor;
121117 static bool s_show;
122118};
123119
120+ // ! Graphics: Three copunctual straight lines (circle)
124121class QCopunctual : public QConstraintBase ,
125122 public QGraphicsEllipseItem
126123{
@@ -133,15 +130,17 @@ class QCopunctual : public QConstraintBase,
133130 qreal markerSize () const override ;
134131
135132protected:
136- QRectF boundingRect () const override ; // !< axis-aligned bounding box
133+ QRectF boundingRect () const override ; // !< Get axis-aligned bounding box
137134 void paint ( QPainter *painter,
138135 const QStyleOptionGraphicsItem *option,
139- QWidget *widget) override ;
136+ QWidget *widget) override ; // !< Plot the circle
140137
141138private:
142139 std::shared_ptr<QConstraintBase> create () const override ;
143140};
144141
142+
143+ // ! Graphics: Two orthogonal straight lines (square)
145144class QOrthogonal : public QConstraintBase ,
146145 public QGraphicsRectItem
147146{
@@ -155,14 +154,15 @@ class QOrthogonal : public QConstraintBase,
155154 qreal markerSize () const override ;
156155
157156protected:
158- QRectF boundingRect () const override ; // !< axis-aligned bounding box
157+ QRectF boundingRect () const override ; // !< get axis-aligned bounding box
159158 void paint ( QPainter *painter,
160159 const QStyleOptionGraphicsItem *option,
161- QWidget *widget) override ;
160+ QWidget *widget) override ; // !< Plot square
162161private:
163162 std::shared_ptr<QConstraintBase> create () const override ;
164163};
165164
165+ // ! Graphics: Marker for indentity
166166class QIdentical : public QConstraintBase ,
167167 public QGraphicsPolygonItem
168168{
@@ -175,16 +175,17 @@ class QIdentical : public QConstraintBase,
175175 const uStraightLineSegment &t) override ;
176176
177177protected:
178- QRectF boundingRect () const override ; // !< axis-aligned bounding box
178+ QRectF boundingRect () const override ; // !< Get axis-aligned bounding box
179179 void paint ( QPainter *painter,
180180 const QStyleOptionGraphicsItem *option,
181- QWidget *widget) override ;
181+ QWidget *widget) override ; // !< Plot marker
182182
183183private:
184184 std::shared_ptr<QConstraintBase> create () const override ;
185185};
186186
187187
188+ // ! Graphics: Marke for parallelism
188189class QParallel : public QConstraintBase
189190{
190191public:
@@ -196,10 +197,10 @@ class QParallel : public QConstraintBase
196197 qreal markerSize () const override ;
197198
198199protected:
199- QRectF boundingRect () const override ;
200+ QRectF boundingRect () const override ; // !< Get axis-aligned bounding box
200201 void paint ( QPainter *painter,
201202 const QStyleOptionGraphicsItem *option,
202- QWidget *widget) override ;
203+ QWidget *widget) override ; // !< Plot marker
203204private:
204205 std::shared_ptr<QConstraintBase> create () const override ;
205206
0 commit comments