Skip to content

Commit 5c72efa

Browse files
committed
basic documentation
1 parent 75dbcee commit 5c72efa

File tree

4 files changed

+82
-63
lines changed

4 files changed

+82
-63
lines changed

src/conncomp.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include <Eigen/Sparse>
2323

24+
//! Sparse incidence matrix and connected components
2425
namespace Graph {
2526

2627
using Eigen::SparseMatrix;
@@ -30,17 +31,19 @@ using Eigen::Matrix;
3031
using Eigen::Dynamic;
3132
using Eigen::VectorXi;
3233

34+
//! Connected components (vector with indices/labels)
3335
class ConnComp
3436
{
3537
public:
36-
ConnComp( const SparseMatrix<int, ColMajor> & BB);
38+
ConnComp( const SparseMatrix<int, ColMajor> & BB); //!< Value constructor with sparse matrix
3739

38-
VectorXi mapHead( int cc, int n) const;
39-
VectorXi mapTail( int cc, int n) const;
40-
int label(Index i) const;
41-
VectorXi head( int n) const;
42-
VectorXi tail( int n) const;
40+
VectorXi mapHead( int cc, int n) const; //!< Get linear indices of the elements in 1...n with label 'cc'.
41+
VectorXi mapTail( int cc, int n) const; //!< Get linear indices of the elements in n-1...end with label 'cc'.
42+
int label( Index i) const; //!< Get label/index) of i-th element
43+
VectorXi head( int n) const; //!< Get labels/indices of first n elements
44+
VectorXi tail( int n) const; //!< Get labels/indices of last n elements
4345

46+
//! Get number of connected components
4447
int number() const { return m_comp.size()>0 ? m_comp.maxCoeff()+1 : 0; }
4548

4649
private:

src/mainwindow.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class QGraphicsPixmapItem;
3131
class QDoubleSpinBox;
3232
class QLabel;
3333

34-
34+
//! Graphical user interface
3535
namespace GUI {
3636

3737
class FormatTool;
@@ -43,14 +43,14 @@ class MainWindow : public QMainWindow
4343
Q_OBJECT
4444

4545
public:
46-
MainWindow( QWidget *parent = nullptr);
46+
MainWindow( QWidget *parent = nullptr); //!< standard constructor
4747
~MainWindow() override;
4848

4949
// Where required, read binary file as program argument, see main.cpp
50-
void readBinaryFile( const QString &fileName);
50+
void readBinaryFile( const QString & fileName); //!< Read binary file
5151

5252
protected:
53-
void closeEvent( QCloseEvent *) override;
53+
void closeEvent( QCloseEvent *) override; //!< Handle close event
5454

5555
private:
5656
State curr_state;

src/qconstraints.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,21 @@ bool QConstraintBase::deserialize( QDataStream &in )
106106
return true;
107107
}
108108

109+
void QConstraintBase::setColor( const QColor & col) {
110+
m_pen_req.setColor(col);
111+
m_pen_red.setColor(col);
112+
}
113+
114+
void QConstraintBase::setLineWidth( const int w) {
115+
m_pen_req.setWidth(w);
116+
m_pen_red.setWidth(w);
117+
}
118+
119+
120+
void QConstraintBase::setLineStyle( const int s) {
121+
m_pen_req.setStyle( Qt::PenStyle(s) );
122+
m_pen_red.setStyle( Qt::PenStyle(s) );
123+
}
109124

110125

111126
QRectF QOrthogonal::boundingRect() const

src/qconstraints.h

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -32,95 +32,92 @@ class uStraightLineSegment;
3232
}
3333

3434

35+
//! Graphics: Constraints
3536
namespace QConstraint {
3637

3738
using Uncertain::uStraightLineSegment;
3839

40+
//! Graphics: Base class for marker depicting constraints
3941
class QConstraintBase : public QGraphicsItem
4042
{
4143
protected:
4244
QConstraintBase();
4345
public:
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

9490
protected:
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

119115
private:
120116
static bool s_showColor;
121117
static bool s_show;
122118
};
123119

120+
//! Graphics: Three copunctual straight lines (circle)
124121
class QCopunctual : public QConstraintBase,
125122
public QGraphicsEllipseItem
126123
{
@@ -133,15 +130,17 @@ class QCopunctual : public QConstraintBase,
133130
qreal markerSize() const override;
134131

135132
protected:
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

141138
private:
142139
std::shared_ptr<QConstraintBase> create() const override;
143140
};
144141

142+
143+
//! Graphics: Two orthogonal straight lines (square)
145144
class QOrthogonal : public QConstraintBase,
146145
public QGraphicsRectItem
147146
{
@@ -155,14 +154,15 @@ class QOrthogonal : public QConstraintBase,
155154
qreal markerSize() const override;
156155

157156
protected:
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
162161
private:
163162
std::shared_ptr<QConstraintBase> create() const override;
164163
};
165164

165+
//! Graphics: Marker for indentity
166166
class QIdentical : public QConstraintBase,
167167
public QGraphicsPolygonItem
168168
{
@@ -175,16 +175,17 @@ class QIdentical : public QConstraintBase,
175175
const uStraightLineSegment &t) override;
176176

177177
protected:
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

183183
private:
184184
std::shared_ptr<QConstraintBase> create() const override;
185185
};
186186

187187

188+
//! Graphics: Marke for parallelism
188189
class QParallel : public QConstraintBase
189190
{
190191
public:
@@ -196,10 +197,10 @@ class QParallel : public QConstraintBase
196197
qreal markerSize() const override;
197198

198199
protected:
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
203204
private:
204205
std::shared_ptr<QConstraintBase> create() const override;
205206

0 commit comments

Comments
 (0)