diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index cf34a162ad..a9eea19e46 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include @@ -184,6 +184,14 @@ bool PCB_PAINTER::Draw( const EDA_ITEM* aItem, int aLayer ) draw( (ZONE_CONTAINER*) aItem ); break; + case PCB_DIMENSION_T: + draw( (DIMENSION*) aItem ); + break; + + case PCB_TARGET_T: + draw( (PCB_TARGET*) aItem ); + break; + default: // Painter does not know how to draw the object return false; @@ -376,14 +384,14 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText ) void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer ) { - COLOR4D strokeColor = getLayerColor( aLayer, 0 ); + COLOR4D strokeColor = getLayerColor( aLayer, 0 ); + VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y); + double orientation = aText->GetDrawRotation() * M_PI / 1800.0; m_gal->SetStrokeColor( strokeColor ); m_gal->SetLineWidth( aText->GetThickness() ); m_stroke_font->LoadAttributes( aText ); - m_stroke_font->Draw( std::string( aText->GetText().mb_str() ), - VECTOR2D( aText->GetTextPosition().x, aText->GetTextPosition().y), - aText->GetDrawRotation() * M_PI / 1800.0 ); + m_stroke_font->Draw( std::string( aText->GetText().mb_str() ), position, orientation ); } @@ -419,3 +427,48 @@ void PCB_PAINTER::draw( const ZONE_CONTAINER* aContainer ) } } } + + +void PCB_PAINTER::draw( const DIMENSION* aDimension ) +{ + COLOR4D strokeColor = getLayerColor( aDimension->GetLayer(), 0 ); + + m_gal->SetStrokeColor( strokeColor ); + m_gal->SetIsFill( false ); + m_gal->SetIsStroke( true ); + m_gal->SetLineWidth( aDimension->GetWidth() ); + + // Draw an arrow + m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_crossBarF ) ); + m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineGO ), VECTOR2D( aDimension->m_featureLineGF ) ); + m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineDO ), VECTOR2D( aDimension->m_featureLineDF ) ); + m_gal->DrawLine( VECTOR2D( aDimension->m_arrowD1O ), VECTOR2D( aDimension->m_arrowD1F ) ); + m_gal->DrawLine( VECTOR2D( aDimension->m_arrowD2O ), VECTOR2D( aDimension->m_arrowD2F ) ); + m_gal->DrawLine( VECTOR2D( aDimension->m_arrowG1O ), VECTOR2D( aDimension->m_arrowG1F ) ); + m_gal->DrawLine( VECTOR2D( aDimension->m_arrowG2O ), VECTOR2D( aDimension->m_arrowG2F ) ); + + // Draw text + draw( &aDimension->Text() ); +} + + +void PCB_PAINTER::draw( const PCB_TARGET* aTarget ) +{ + COLOR4D strokeColor = getLayerColor( aTarget->GetLayer(), 0 ); + double radius; + + // according to PCB_TARGET::Draw() (class_mire.cpp) + if( aTarget->GetShape() ) // shape X + { + radius = aTarget->GetSize() / 2; + } + else + { + radius = aTarget->GetSize() / 3; + } + + m_gal->SetStrokeColor( strokeColor ); + m_gal->SetIsFill( true ); + m_gal->SetIsStroke( true ); + m_gal->DrawCircle( VECTOR2D( aTarget->GetPosition() ), radius ); +} diff --git a/pcbnew/pcb_painter.h b/pcbnew/pcb_painter.h index 80e2f78694..537fae5e63 100644 --- a/pcbnew/pcb_painter.h +++ b/pcbnew/pcb_painter.h @@ -44,6 +44,8 @@ class SEGZONE; class ZONE_CONTAINER; class TEXTE_PCB; class TEXTE_MODULE; +class DIMENSION; +class PCB_TARGET; namespace KiGfx { @@ -137,6 +139,8 @@ protected: void draw( const TEXTE_PCB* ); void draw( const TEXTE_MODULE*, int ); void draw( const ZONE_CONTAINER* ); + void draw( const DIMENSION* ); + void draw( const PCB_TARGET* ); }; } // namespace KiGfx