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
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();
5654QPen QConstraintBase::s_penSelected = QPen();
5755
5856QConstraintBase::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
7270QConstraintBase::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
135133void 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
141139void 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
148146void 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,
195193QRectF 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
285283QRectF 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
441439QRectF 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
449448std::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
528527std::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 () );
0 commit comments