From a9c54c10a2a66b326fc8ba52914f598fda00c9cd Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Thu, 11 Feb 2021 23:05:03 +0100 Subject: [PATCH] VIEW_OVERLAY: support for bitmap text --- common/view/view_overlay.cpp | 56 ++++++++++++++++++++++++++++++++++++ include/view/view_overlay.h | 10 ++++++- 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/common/view/view_overlay.cpp b/common/view/view_overlay.cpp index 8d2f97bb4b..484dbffb00 100644 --- a/common/view/view_overlay.cpp +++ b/common/view/view_overlay.cpp @@ -218,6 +218,38 @@ struct VIEW_OVERLAY::COMMAND_SET_WIDTH : public VIEW_OVERLAY::COMMAND }; +struct VIEW_OVERLAY::COMMAND_GLYPH_SIZE : public VIEW_OVERLAY::COMMAND +{ + COMMAND_GLYPH_SIZE( const VECTOR2D aSize ) : + m_size( aSize ) {}; + + virtual void Execute( VIEW* aView ) const override + { + aView->GetGAL()->SetGlyphSize( m_size ); + } + + VECTOR2D m_size; +}; + + +struct VIEW_OVERLAY::COMMAND_BITMAP_TEXT : public VIEW_OVERLAY::COMMAND +{ + COMMAND_BITMAP_TEXT( const wxString& aText, const VECTOR2D& aPosition, + double aRotationAngle ) : + m_text( aText ), + m_pos( aPosition ), + m_angle (aRotationAngle) {}; + + virtual void Execute( VIEW* aView ) const override + { + aView->GetGAL()->BitmapText( m_text, m_pos, m_angle ); + } + + double m_angle; + wxString m_text; + VECTOR2D m_pos; +}; + VIEW_OVERLAY::VIEW_OVERLAY() { } @@ -286,6 +318,17 @@ void VIEW_OVERLAY::Segment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoi } +void VIEW_OVERLAY::Polyline( const SHAPE_LINE_CHAIN& aPolyLine ) +{ + SetIsStroke( true ); + SetIsFill( false ); + for( int i = 0; i < aPolyLine.SegmentCount(); i++ ) + { + Line( aPolyLine.CSegment( i ) ); + } +} + + void VIEW_OVERLAY::Polygon( const SHAPE_POLY_SET& aPolySet ) { m_commands.push_back( new COMMAND_POLY_POLYGON( aPolySet ) ); @@ -329,6 +372,19 @@ void VIEW_OVERLAY::SetIsFill( bool aIsFillEnabled ) } +void VIEW_OVERLAY::SetGlyphSize( const VECTOR2D aSize ) +{ + m_commands.push_back( new COMMAND_GLYPH_SIZE( aSize ) ); +} + + +void VIEW_OVERLAY::BitmapText( const wxString& aText, const VECTOR2D& aPosition, + double aRotationAngle ) +{ + m_commands.push_back( new COMMAND_BITMAP_TEXT( aText, aPosition, aRotationAngle ) ); +} + + void VIEW_OVERLAY::SetIsStroke( bool aIsStrokeEnabled ) { m_commands.push_back( new COMMAND_SET_STROKE( aIsStrokeEnabled ) ); diff --git a/include/view/view_overlay.h b/include/view/view_overlay.h index b20f220ff7..412eb02727 100644 --- a/include/view/view_overlay.h +++ b/include/view/view_overlay.h @@ -65,6 +65,9 @@ public: struct COMMAND_POLYLINE; struct COMMAND_POINT_POLYLINE; + struct COMMAND_GLYPH_SIZE; + struct COMMAND_BITMAP_TEXT; + void Clear(); virtual const BOX2I ViewBBox() const override; @@ -83,14 +86,19 @@ public: // polygon primitives void Polygon( const std::deque& aPointList ); void Polygon( const SHAPE_POLY_SET& aPolySet ); + void Polyline( const SHAPE_LINE_CHAIN& aPolyLine ); void Polygon( const VECTOR2D aPointList[], int aListSize ); + void BitmapText( const wxString& aText, const VECTOR2D& aPosition, + double aRotationAngle ); + // Draw settings void SetIsFill( bool aIsFillEnabled ); void SetIsStroke( bool aIsStrokeEnabled ); void SetFillColor( const COLOR4D& aColor ); void SetStrokeColor( const COLOR4D& aColor ); - + void SetGlyphSize( const VECTOR2D aSize ); + void SetLineWidth( double aLineWidth ); private: