diff --git a/common/origin_viewitem.cpp b/common/origin_viewitem.cpp index d7b23ff3b3..59dc9c35c4 100644 --- a/common/origin_viewitem.cpp +++ b/common/origin_viewitem.cpp @@ -83,7 +83,7 @@ void ORIGIN_VIEWITEM::ViewDraw( int, VIEW* aView ) const VECTOR2D scaledSize = aView->ToWorld( VECTOR2D( m_size, m_size ), false ); // Draw a circle around the marker's center point if the style demands it - if( ( m_style == CIRCLE_CROSS ) || ( m_style == CIRCLE_DOT ) || ( m_style == CIRCLE_X ) ) + if( m_style == CIRCLE_CROSS || m_style == CIRCLE_X ) gal->DrawCircle( m_position, fabs( scaledSize.x ) ); switch( m_style ) @@ -99,49 +99,10 @@ void ORIGIN_VIEWITEM::ViewDraw( int, VIEW* aView ) const m_position + VECTOR2D( 0, scaledSize.y ) ); break; - case DASH_LINE: - { - gal->DrawCircle( m_position, scaledSize.x / 4 ); - - VECTOR2D start( m_position ); - VECTOR2D end( m_end ); - BOX2I clip( VECTOR2I( start ), VECTOR2I( end.x - start.x, end.y - start.y ) ); - clip.Normalize(); - - double theta = atan2( end.y - start.y, end.x - start.x ); - std::array strokes = { scaledSize.x, scaledSize.x / 2 }; - - for( size_t i = 0; i < 10000; ++i ) - { - VECTOR2D next( start.x + strokes[ i % 2 ] * cos( theta ), - start.y + strokes[ i % 2 ] * sin( theta ) ); - - // Drawing each segment can be done rounded to ints. - VECTOR2I segStart( KiROUND( start.x ), KiROUND( start.y ) ); - VECTOR2I segEnd( KiROUND( next.x ), KiROUND( next.y ) ); - - if( ClipLine( &clip, segStart.x, segStart.y, segEnd.x, segEnd.y ) ) - break; - else if( i % 2 == 0 ) - gal->DrawLine( segStart, segEnd ); - - start = next; - } - - gal->DrawCircle( m_end, scaledSize.x / 4 ); - break; - } - - case X: case CIRCLE_X: gal->DrawLine( m_position - scaledSize, m_position + scaledSize ); scaledSize.y = -scaledSize.y; gal->DrawLine( m_position - scaledSize, m_position + scaledSize ); break; - - case DOT: - case CIRCLE_DOT: - gal->DrawCircle( m_position, scaledSize.x / 4 ); - break; } } diff --git a/include/origin_viewitem.h b/include/origin_viewitem.h index 2b2a71518b..b9923bba5e 100644 --- a/include/origin_viewitem.h +++ b/include/origin_viewitem.h @@ -24,8 +24,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef __ORIGIN_VIEWITEM_H -#define __ORIGIN_VIEWITEM_H +#pragma once #include #include @@ -44,7 +43,7 @@ public: /// Marker symbol styles. enum MARKER_STYLE { - NO_GRAPHIC, CROSS, X, DOT, CIRCLE_CROSS, CIRCLE_X, CIRCLE_DOT, DASH_LINE + NO_GRAPHIC, CROSS, CIRCLE_CROSS, CIRCLE_X }; ORIGIN_VIEWITEM( const COLOR4D& aColor = COLOR4D( 1.0, 1.0, 1.0, 1.0 ), @@ -103,16 +102,6 @@ public: return VECTOR2I( m_position.x, m_position.y ); } - inline void SetEndPosition( const VECTOR2D& aPosition ) - { - m_end = aPosition; - } - - inline const VECTOR2I GetEndPosition() const - { - return VECTOR2I( m_end.x, m_end.y ); - } - inline void SetSize( int aSize ) { m_size = aSize; @@ -128,41 +117,17 @@ public: m_color = aColor; } - inline const KIGFX::COLOR4D& GetColor() const - { - return m_color; - } - inline void SetStyle( MARKER_STYLE aStyle ) { m_style = aStyle; } - inline MARKER_STYLE GetStyle() const - { - return m_style; - } - protected: - /// Marker coordinates. VECTOR2D m_position; - - /// Marker end position for markers that stretch between points. - VECTOR2D m_end; - - /// Marker size (in pixels). - int m_size; - - /// Marker color. + int m_size; /// (in pixels) COLOR4D m_color; - - /// Marker symbol. MARKER_STYLE m_style; - - /// If set, the marker will be drawn even if its position is 0,0. - bool m_drawAtZero; + bool m_drawAtZero; /// If set, the marker will be drawn even if its position is 0,0. }; } // namespace KIGFX - -#endif diff --git a/pcbnew/tools/pcb_control.cpp b/pcbnew/tools/pcb_control.cpp index 972e7afd92..bf9f359026 100644 --- a/pcbnew/tools/pcb_control.cpp +++ b/pcbnew/tools/pcb_control.cpp @@ -106,7 +106,17 @@ void PCB_CONTROL::Reset( RESET_REASON aReason ) if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH || aReason == REDRAW ) { m_gridOrigin->SetPosition( board()->GetDesignSettings().GetGridOrigin() ); - m_gridOrigin->SetColor( m_frame->GetGridColor() ); + + double backgroundBrightness = m_frame->GetCanvas()->GetGAL()->GetClearColor().GetBrightness(); + COLOR4D color = m_frame->GetGridColor(); + + if( backgroundBrightness > 0.5 ) + color.Darken( 0.25 ); + else + color.Brighten( 0.25 ); + + m_gridOrigin->SetColor( color ); + getView()->Remove( m_gridOrigin.get() ); getView()->Add( m_gridOrigin.get() ); }