diff --git a/common/tool/edit_points.cpp b/common/tool/edit_points.cpp index e62f670a52..5f45057904 100644 --- a/common/tool/edit_points.cpp +++ b/common/tool/edit_points.cpp @@ -315,7 +315,19 @@ void EDIT_POINTS::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const drawPoint( point ); for( const EDIT_LINE& line : m_lines ) - drawPoint( line, true ); + { + if( line.HasCenterPoint() ) + { + drawPoint( line.GetPosition(), true ); + } + + if( line.DrawLine() ) + { + gal->SetLineWidth( borderSize ); + gal->SetStrokeColor( borderColor ); + gal->DrawLine( line.GetOrigin().GetPosition(), line.GetEnd().GetPosition() ); + } + } gal->PopDepth(); } diff --git a/eeschema/tools/ee_point_editor.cpp b/eeschema/tools/ee_point_editor.cpp index 66ee6eb359..8a391cc94f 100644 --- a/eeschema/tools/ee_point_editor.cpp +++ b/eeschema/tools/ee_point_editor.cpp @@ -118,6 +118,9 @@ public: points->AddPoint( shape->GetStart() ); points->AddPoint( shape->GetEnd() ); points->AddPoint( shape->GetPosition() ); + + points->AddIndicatorLine( points->Point( ARC_CENTER ), points->Point( ARC_START ) ); + points->AddIndicatorLine( points->Point( ARC_CENTER ), points->Point( ARC_END ) ); break; case SHAPE_T::CIRCLE: @@ -160,6 +163,11 @@ public: points->AddPoint( shape->GetBezierC1() ); points->AddPoint( shape->GetBezierC2() ); points->AddPoint( shape->GetEnd() ); + + points->AddIndicatorLine( points->Point( BEZIER_START ), + points->Point( BEZIER_CTRL_PT1 ) ); + points->AddIndicatorLine( points->Point( BEZIER_END ), + points->Point( BEZIER_CTRL_PT2 ) ); break; default: diff --git a/include/tool/edit_points.h b/include/tool/edit_points.h index b36c4dd5bc..66929b80e2 100644 --- a/include/tool/edit_points.h +++ b/include/tool/edit_points.h @@ -304,6 +304,26 @@ public: return m_end; } + /** + * Is the center-point of the line useful to be shown? + */ + bool HasCenterPoint() const { return m_hasCenterPoint; } + + /** + * Set if the center-point of the line should be shown. + */ + void SetHasCenterPoint( bool aHasCenterPoint ) { m_hasCenterPoint = aHasCenterPoint; } + + /** + * Should the line itself be drawn, or just the end and/or center points? + */ + bool DrawLine() const { return m_showLine; } + + /** + * Set if the line itself should be drawn. + */ + void SetDrawLine( bool aShowLine ) { m_showLine = aShowLine; } + bool operator==( const EDIT_POINT& aOther ) const { return GetPosition() == aOther.GetPosition(); @@ -318,6 +338,9 @@ private: EDIT_POINT& m_origin; ///< Origin point for a line EDIT_POINT& m_end; ///< End point for a line + bool m_hasCenterPoint = true; ///< True if the line has a (useful) center point + bool m_showLine = false; ///< True if the line itself should be drawn + ///< Constraint for the point, NULL if none std::shared_ptr<EDIT_CONSTRAINT<EDIT_LINE> > m_constraint; }; @@ -390,6 +413,22 @@ public: m_lines.emplace_back( aOrigin, aEnd ); } + /** + * Adds an EDIT_LINE that is shown as an indicator, + * rather than an editable line (no center point drag, + * show the line itself). + * + * @param aOrigin is the origin for a new line. + * @param aEnd is the end for a new line. + */ + void AddIndicatorLine( EDIT_POINT& aOrigin, EDIT_POINT& aEnd ) + { + EDIT_LINE& line = m_lines.emplace_back( aOrigin, aEnd ); + line.SetHasCenterPoint( false ); + line.SetDrawLine( true ); + } + + /** * Adds a break, indicating the end of a contour. */ diff --git a/pcbnew/tools/pcb_point_editor.cpp b/pcbnew/tools/pcb_point_editor.cpp index 66cde3ba4a..55f7e42077 100644 --- a/pcbnew/tools/pcb_point_editor.cpp +++ b/pcbnew/tools/pcb_point_editor.cpp @@ -267,6 +267,9 @@ std::shared_ptr<EDIT_POINTS> PCB_POINT_EDITOR::makePoints( EDA_ITEM* aItem ) points->AddPoint( shape->GetArcMid() ); points->AddPoint( shape->GetEnd() ); points->AddPoint( shape->GetCenter() ); + + points->AddIndicatorLine( points->Point( ARC_CENTER ), points->Point( ARC_START ) ); + points->AddIndicatorLine( points->Point( ARC_CENTER ), points->Point( ARC_END ) ); break; case SHAPE_T::CIRCLE: @@ -283,6 +286,11 @@ std::shared_ptr<EDIT_POINTS> PCB_POINT_EDITOR::makePoints( EDA_ITEM* aItem ) points->AddPoint( shape->GetBezierC1() ); points->AddPoint( shape->GetBezierC2() ); points->AddPoint( shape->GetEnd() ); + + points->AddIndicatorLine( points->Point( BEZIER_START ), + points->Point( BEZIER_CTRL_PT1 ) ); + points->AddIndicatorLine( points->Point( BEZIER_CTRL_PT2 ), + points->Point( BEZIER_END ) ); break; default: // suppress warnings