Skip to content

Commit 46338d0

Browse files
committed
protected members made private
1 parent 254ecfa commit 46338d0

File tree

2 files changed

+48
-49
lines changed

2 files changed

+48
-49
lines changed

src/qconstraints.cpp

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file is part of the GreasePad distribution (https://github.com/FraunhoferIOSB/GreasePad).
3-
* Copyright (c) 2022-2025 Jochen Meidow, Fraunhofer IOSB
3+
* Copyright (c) 2022-2026 Jochen Meidow, Fraunhofer IOSB
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -20,20 +20,18 @@
2020
#include "qconstraints.h"
2121
#include "uncertain/usegment.h"
2222

23-
#include <QColor>
2423
#include <QGraphicsItem>
2524
#include <QGraphicsSceneMouseEvent>
26-
#include <QMenu>
2725
#include <QPainter>
2826
#include <QtPreprocessorSupport>
2927

3028
#include "qcontainerfwd.h"
3129
#include "qnamespace.h"
32-
#include "qsharedpointer.h"
3330
#include "qstyleoption.h"
3431
#include "qtypes.h"
3532

3633
#include <Eigen/Core>
34+
#include <Eigen/Dense>
3735

3836
#include <cassert>
3937
#include <cmath>
@@ -56,9 +54,9 @@ QPen QConstraintBase::s_defaultPenRed = QPen();
5654
QPen QConstraintBase::s_penSelected = QPen();
5755

5856
QConstraintBase::QConstraintBase()
59-
: m_pen_req(s_defaultPenReq)
60-
, m_pen_red(s_defaultPenRed)
61-
, m_is_required(false)
57+
: m_is_required(false)
58+
, m_penReq(s_defaultPenReq)
59+
, m_penRed(s_defaultPenRed)
6260
{
6361
// qDebug() << Q_FUNC_INFO;
6462
setVisible(s_show);
@@ -70,11 +68,11 @@ QConstraintBase::QConstraintBase()
7068
}
7169

7270
QConstraintBase::QConstraintBase(const QConstraintBase &other)
73-
: m_pen_req(other.m_pen_req)
74-
, m_pen_red(other.m_pen_red)
75-
, m_is_required(other.m_is_required)
71+
: m_is_required(other.m_is_required)
7672
, m_is_enforced(other.m_is_enforced)
7773
, m_altColor(other.m_altColor)
74+
, m_penReq(other.m_penReq)
75+
, m_penRed(other.m_penRed)
7876
{
7977
setVisible( s_show);
8078

@@ -98,8 +96,8 @@ void QConstraintBase::serialize( QDataStream &out )
9896
out << m_is_required;
9997
out << m_is_enforced;
10098

101-
out << m_pen_req;
102-
out << m_pen_red;
99+
out << m_penReq;
100+
out << m_penRed;
103101
out << m_altColor;
104102

105103
out << markerSize();
@@ -114,8 +112,8 @@ bool QConstraintBase::deserialize( QDataStream &in )
114112
in >> m_is_required;
115113
in >> m_is_enforced;
116114

117-
in >> m_pen_req;
118-
in >> m_pen_red;
115+
in >> m_penReq;
116+
in >> m_penRed;
119117

120118
in >> m_altColor;
121119
qreal s = NAN;
@@ -134,21 +132,21 @@ bool QConstraintBase::deserialize( QDataStream &in )
134132

135133
void QConstraintBase::setColor( const QColor & col)
136134
{
137-
m_pen_req.setColor(col);
138-
m_pen_red.setColor(col);
135+
m_penReq.setColor(col);
136+
m_penRed.setColor(col);
139137
}
140138

141139
void QConstraintBase::setLineWidth( const int w)
142140
{
143-
m_pen_req.setWidth(w);
144-
m_pen_red.setWidth(w);
141+
m_penReq.setWidth(w);
142+
m_penRed.setWidth(w);
145143
}
146144

147145

148146
void QConstraintBase::setLineStyle( const int s)
149147
{
150-
m_pen_req.setStyle( Qt::PenStyle(s) );
151-
m_pen_red.setStyle( Qt::PenStyle(s) );
148+
m_penReq.setStyle( Qt::PenStyle(s) );
149+
m_penRed.setStyle( Qt::PenStyle(s) );
152150
}
153151

154152

@@ -195,9 +193,9 @@ void QConstraintBase::setStatus( bool isrequired,
195193
QRectF QAligned::boundingRect() const
196194
{
197195
return a.boundingRect().adjusted(
198-
-2*m_pen_req.width(), -2*m_pen_req.width(),
199-
+2*m_pen_req.width(), +2*m_pen_req.width()
200-
);
196+
-2*penRequiredConstraint().width(), -2*penRequiredConstraint().width(),
197+
+2*penRequiredConstraint().width(), +2*penRequiredConstraint().width()
198+
);
201199
}
202200

203201

@@ -206,7 +204,7 @@ void QAligned::paint( QPainter *painter,
206204
const QStyleOptionGraphicsItem * option,
207205
QWidget * widget)
208206
{
209-
QPen pen = QPen( required() ? m_pen_req : m_pen_red);
207+
QPen pen = QPen( required() ? penRequiredConstraint() : penRedundantConstraint());
210208
if ( !enforced() ) {
211209
pen.setColor( Qt::red );
212210
}
@@ -284,10 +282,10 @@ std::shared_ptr<QConstraintBase> QAligned::create()
284282

285283
QRectF QOrthogonal::boundingRect() const
286284
{
287-
return rect().adjusted(-2*m_pen_req.widthF(),
288-
-2*m_pen_req.widthF(),
289-
2*m_pen_req.widthF(),
290-
2*m_pen_req.widthF());
285+
return rect().adjusted(-2*penRequiredConstraint().widthF(),
286+
-2*penRequiredConstraint().widthF(),
287+
2*penRequiredConstraint().widthF(),
288+
2*penRequiredConstraint().widthF());
291289
}
292290

293291

@@ -297,7 +295,7 @@ void QOrthogonal::paint( QPainter *painter,
297295
const QStyleOptionGraphicsItem * option,
298296
QWidget * widget)
299297
{
300-
QPen pen = QPen( required() ? m_pen_req : m_pen_red);
298+
QPen pen = QPen( required() ? penRequiredConstraint() : penRedundantConstraint());
301299
if ( !enforced() ) {
302300
pen.setColor( Qt::cyan );
303301
}
@@ -416,7 +414,7 @@ void QCopunctual::paint( QPainter *painter,
416414
const QStyleOptionGraphicsItem * option,
417415
QWidget * widget)
418416
{
419-
QPen pen = QPen( required() ? m_pen_req : m_pen_red);
417+
QPen pen = QPen( required() ? penRequiredConstraint() : penRedundantConstraint());
420418

421419
if ( showColor()) {
422420
pen.setColor( altColor() );
@@ -430,8 +428,8 @@ void QCopunctual::paint( QPainter *painter,
430428
QRectF R = rect();
431429
if ( !required() ) {
432430
// enlarge
433-
R.adjust( -m_pen_req.widthF(), -m_pen_req.widthF(),
434-
m_pen_req.widthF(), m_pen_req.widthF());
431+
R.adjust( -penRequiredConstraint().widthF(), -penRequiredConstraint().widthF(),
432+
penRequiredConstraint().widthF(), penRequiredConstraint().widthF());
435433
}
436434
painter->drawEllipse( R );
437435

@@ -440,10 +438,11 @@ void QCopunctual::paint( QPainter *painter,
440438

441439
QRectF QCopunctual::boundingRect() const
442440
{
443-
return rect().adjusted( -m_pen_req.width(),
444-
-m_pen_req.width(),
445-
+m_pen_req.width(),
446-
+m_pen_req.width());
441+
return rect().adjusted(
442+
-penRequiredConstraint().width(),
443+
-penRequiredConstraint().width(),
444+
+penRequiredConstraint().width(),
445+
+penRequiredConstraint().width());
447446
}
448447

449448
std::shared_ptr<QConstraintBase> QCopunctual::doClone() const
@@ -519,10 +518,10 @@ QRectF QParallel::boundingRect() const
519518
{
520519
QRectF const R = a.boundingRect().united(b.boundingRect());
521520
return R.adjusted(
522-
-2*m_pen_req.width(),
523-
-2*m_pen_req.width(),
524-
+2*m_pen_req.width(),
525-
+2*m_pen_req.width());
521+
-2*penRequiredConstraint().width(),
522+
-2*penRequiredConstraint().width(),
523+
+2*penRequiredConstraint().width(),
524+
+2*penRequiredConstraint().width());
526525
}
527526

528527
std::shared_ptr<QConstraintBase> QParallel::create()
@@ -535,7 +534,7 @@ void QParallel::paint( QPainter *painter,
535534
const QStyleOptionGraphicsItem * option,
536535
QWidget * widget)
537536
{
538-
QPen pen = QPen( required() ? m_pen_req : m_pen_red);
537+
QPen pen = QPen( required() ? penRequiredConstraint() : penRedundantConstraint());
539538

540539
if ( showColor() ) {
541540
pen.setColor( altColor() );

src/qconstraints.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,28 @@
1919
#ifndef QCONSTRAINTS_H
2020
#define QCONSTRAINTS_H
2121

22-
#include <QDebug>
2322
#include <QGraphicsItem>
2423
#include <QPen>
25-
#include <QWidget>
2624

2725
#include "qcontainerfwd.h"
28-
#include "qsharedpointer.h"
2926
#include "qtypes.h"
3027

3128
#include <Eigen/Core>
32-
#include <Eigen/Dense>
3329

3430
#include <functional>
3531
#include <map>
3632
#include <memory>
3733
#include <string>
3834

3935

40-
4136
namespace Uncertain {
4237
class uStraightLineSegment;
4338
} // namespace Uncertain
4439

40+
class QColor;
41+
class QDataStream;
42+
class QWidget;
43+
4544

4645
//! Graphics: Constraints
4746
namespace QConstraint {
@@ -75,6 +74,8 @@ class QConstraintBase : public QGraphicsItem
7574
void setAltColor( const QColor &col ); //!< Set color for automatic colorization
7675
[[nodiscard]] QColor altColor() const {return m_altColor;}
7776
void setStatus( bool isrequired, bool isenforced); //!< Set status
77+
[[nodiscard]] QPen penRequiredConstraint() const {return m_penReq;} //!< get pen for required constraint
78+
[[nodiscard]] QPen penRedundantConstraint() const {return m_penRed;} //!< get pen for redundant constraint
7879

7980
virtual void setMarkerSize ( qreal s) = 0; //!< Set marker size
8081
virtual void setGeometry( QVector<std::shared_ptr< const uStraightLineSegment>> &,
@@ -112,9 +113,6 @@ class QConstraintBase : public QGraphicsItem
112113
static QPen s_defaultPenRed; //!< Default pen for redundant constraints
113114
static QPen s_penSelected; //!< Pen for selection
114115

115-
QPen m_pen_req; //!< Pen for required constraint
116-
QPen m_pen_red; //!< Pen for redundant constraint
117-
118116
[[nodiscard]] bool enforced() const { return m_is_enforced; } //!< Get status enforcment (success/failure)
119117
[[nodiscard]] bool required() const {return m_is_required;}
120118

@@ -127,6 +125,8 @@ class QConstraintBase : public QGraphicsItem
127125
bool m_is_enforced = false; //!< Constraint is enforced? (for painting)
128126

129127
QColor m_altColor; //!< Color for automatic colorization of subtasks
128+
QPen m_penReq; //!< Pen for required constraint
129+
QPen m_penRed; //!< Pen for redundant constraint
130130

131131
static bool s_showColor;
132132
static bool s_show;

0 commit comments

Comments
 (0)