void LIB_BEZIER::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ) { wxASSERT( aPlotter != NULL ); static std::vector< wxPoint > cornerList; cornerList.clear(); for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ ) { wxPoint pos = m_PolyPoints[ii]; pos = aTransform.TransformCoordinate( pos ) + aOffset; cornerList.push_back( pos ); } if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR ) { aPlotter->SetColor( GetLayerColor( LAYER_DEVICE_BACKGROUND ) ); aPlotter->PlotPoly( cornerList, FILLED_WITH_BG_BODYCOLOR, 0 ); } bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR; auto pen_size = GetPenSize(); if( !already_filled || pen_size > 0 ) { pen_size = std::max( 0, pen_size ); aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) ); aPlotter->PlotPoly( cornerList, already_filled ? NO_FILL : m_Fill, GetPenSize() ); } }
void LIB_POLYLINE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ) { wxPoint pos1; EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE ); wxPoint* buffer = NULL; if( aColor < 0 ) // Used normal color or selected color { if( IsSelected() ) color = GetItemSelectedColor(); } else { color = aColor; } buffer = new wxPoint[ m_PolyPoints.size() ]; for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ ) { buffer[ii] = aTransform.TransformCoordinate( m_PolyPoints[ii] ) + aOffset; } FILL_T fill = aData ? NO_FILL : m_Fill; if( aColor >= 0 ) fill = NO_FILL; GRSetDrawMode( aDC, aDrawMode ); EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL; if( fill == FILLED_WITH_BG_BODYCOLOR ) GRPoly( clipbox, aDC, m_PolyPoints.size(), buffer, 1, GetPenSize(), (m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ), GetLayerColor( LAYER_DEVICE_BACKGROUND ) ); else if( fill == FILLED_SHAPE ) GRPoly( clipbox, aDC, m_PolyPoints.size(), buffer, 1, GetPenSize(), color, color ); else GRPoly( clipbox, aDC, m_PolyPoints.size(), buffer, 0, GetPenSize(), color, color ); delete[] buffer; /* Set to one (1) to draw bounding box around polyline to validate * bounding box calculation. */ #if 0 EDA_RECT bBox = GetBoundingBox(); bBox.RevertYAxis(); bBox = aTransform.TransformCoordinate( bBox ); bBox.Move( aOffset ); GRRect( clipbox, aDC, bBox, 0, LIGHTMAGENTA ); #endif }
void SCH_TEXT::Plot( PLOTTER* aPlotter ) { static std::vector <wxPoint> Poly; COLOR4D color = GetLayerColor( GetLayer() ); int tmp = GetThickness(); int thickness = GetPenSize(); // Two thicknesses are set here: // The first is for EDA_TEXT, which controls the interline spacing based on text thickness // The second is for the output that sets the actual stroke size SetThickness( thickness ); aPlotter->SetCurrentLineWidth( thickness ); if( IsMultilineAllowed() ) { std::vector<wxPoint> positions; wxArrayString strings_list; wxStringSplit( GetShownText(), strings_list, '\n' ); positions.reserve( strings_list.Count() ); GetPositionsOfLinesOfMultilineText(positions, (int) strings_list.Count() ); for( unsigned ii = 0; ii < strings_list.Count(); ii++ ) { wxPoint textpos = positions[ii] + GetSchematicTextOffset(); wxString& txt = strings_list.Item( ii ); aPlotter->Text( textpos, color, txt, GetTextAngle(), GetTextSize(), GetHorizJustify(), GetVertJustify(), thickness, IsItalic(), IsBold() ); } } else { wxPoint textpos = GetTextPos() + GetSchematicTextOffset(); aPlotter->Text( textpos, color, GetShownText(), GetTextAngle(), GetTextSize(), GetHorizJustify(), GetVertJustify(), thickness, IsItalic(), IsBold() ); } // Draw graphic symbol for global or hierarchical labels CreateGraphicShape( Poly, GetTextPos() ); aPlotter->SetCurrentLineWidth( GetPenSize() ); if( Poly.size() ) aPlotter->PlotPoly( Poly, NO_FILL ); SetThickness( tmp ); }
void LIB_RECTANGLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ) { wxPoint pos1, pos2; EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE ); if( aColor < 0 ) // Used normal color or selected color { if( IsSelected() ) color = GetItemSelectedColor(); } else { color = aColor; } pos1 = aTransform.TransformCoordinate( m_Pos ) + aOffset; pos2 = aTransform.TransformCoordinate( m_End ) + aOffset; FILL_T fill = aData ? NO_FILL : m_Fill; if( aColor >= 0 ) fill = NO_FILL; GRSetDrawMode( aDC, aDrawMode ); EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL; if( fill == FILLED_WITH_BG_BODYCOLOR && !aData ) GRFilledRect( clipbox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, GetPenSize( ), (m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ), GetLayerColor( LAYER_DEVICE_BACKGROUND ) ); else if( m_Fill == FILLED_SHAPE && !aData ) GRFilledRect( clipbox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, GetPenSize(), color, color ); else GRRect( clipbox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, GetPenSize(), color ); /* Set to one (1) to draw bounding box around rectangle to validate * bounding box calculation. */ #if 0 EDA_RECT bBox = GetBoundingBox(); bBox.RevertYAxis(); bBox = aTransform.TransformCoordinate( bBox ); bBox.Move( aOffset ); GRRect( clipbox, aDC, bBox, 0, LIGHTMAGENTA ); #endif }
void LIB_POLYLINE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ) { wxASSERT( aPlotter != NULL ); static std::vector< wxPoint > cornerList; cornerList.clear(); for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ ) { wxPoint pos = m_PolyPoints[ii]; pos = aTransform.TransformCoordinate( pos ) + aOffset; cornerList.push_back( pos ); } if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR ) { aPlotter->SetColor( GetLayerColor( LAYER_DEVICE_BACKGROUND ) ); aPlotter->PlotPoly( cornerList, FILLED_WITH_BG_BODYCOLOR, 0 ); aFill = false; // body is now filled, do not fill it later. } bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR; aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) ); aPlotter->PlotPoly( cornerList, already_filled ? NO_FILL : m_Fill, GetPenSize() ); }
const EDA_RECT LIB_BEZIER::GetBoundingBox() const { EDA_RECT rect; int xmin, xmax, ymin, ymax; if( !GetCornerCount() ) return rect; xmin = xmax = m_PolyPoints[0].x; ymin = ymax = m_PolyPoints[0].y; for( unsigned ii = 1; ii < GetCornerCount(); ii++ ) { xmin = std::min( xmin, m_PolyPoints[ii].x ); xmax = std::max( xmax, m_PolyPoints[ii].x ); ymin = std::min( ymin, m_PolyPoints[ii].y ); ymax = std::max( ymax, m_PolyPoints[ii].y ); } rect.SetOrigin( xmin, ymin ); rect.SetEnd( xmax, ymax ); rect.Inflate( ( GetPenSize()+1 ) / 2 ); rect.RevertYAxis(); return rect; }
void LIB_FIELD::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ) { if( IsVoid() ) return; /* Calculate the text orientation, according to the component * orientation/mirror */ int orient = m_Orient; if( aTransform.y1 ) // Rotate component 90 deg. { if( orient == TEXT_ORIENT_HORIZ ) orient = TEXT_ORIENT_VERT; else orient = TEXT_ORIENT_HORIZ; } EDA_RECT BoundaryBox = GetBoundingBox(); EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER; EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER; wxPoint textpos = aTransform.TransformCoordinate( BoundaryBox.Centre() ) + aOffset; aPlotter->Text( textpos, GetDefaultColor(), m_Text, orient, m_Size, hjustify, vjustify, GetPenSize(), m_Italic, m_Bold ); }
void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill, const TRANSFORM& aTransform ) { wxASSERT( plotter != NULL ); EDA_RECT bBox = GetBoundingBox(); // convert coordinates from draw Y axis to libedit Y axis bBox.RevertYAxis(); wxPoint txtpos = bBox.Centre(); /* The text orientation may need to be flipped if the * transformation matrix causes xy axes to be flipped. */ int t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 ); wxPoint pos = aTransform.TransformCoordinate( txtpos ) + offset; // Get color COLOR4D color; if( plotter->GetColorMode() ) // Used normal color or selected color color = IsSelected() ? GetItemSelectedColor() : GetDefaultColor(); else color = COLOR4D::BLACK; plotter->Text( pos, color, GetShownText(), t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT, GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GetPenSize(), IsItalic(), IsBold() ); }
const EDA_RECT SCH_SHEET::GetBoundingBox() const { wxPoint end; EDA_RECT box( m_pos, m_size ); int lineWidth = GetPenSize(); // Determine length of texts wxString text = wxT( "Sheet: " ) + m_name; int textlen = GraphicTextWidth( text, wxSize( m_sheetNameSize, m_sheetNameSize ), false, false ); text = wxT( "File: " ) + m_fileName; int textlen2 = GraphicTextWidth( text, wxSize( m_fileNameSize, m_fileNameSize ), false, false ); // Calculate bounding box X size: textlen = std::max( textlen, textlen2 ); end.x = std::max( m_size.x, textlen ); // Calculate bounding box pos: end.y = m_size.y; end += m_pos; // Move upper and lower limits to include texts: box.SetY( box.GetY() - ( KiROUND( m_sheetNameSize * 1.3 ) + 8 ) ); end.y += KiROUND( m_fileNameSize * 1.3 ) + 8; box.SetEnd( end ); box.Inflate( lineWidth / 2 ); return box; }
void SCH_BUS_ENTRY_BASE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor ) { COLOR4D color; EDA_RECT* clipbox = aPanel->GetClipBox(); if( aColor != COLOR4D::UNSPECIFIED ) color = aColor; else color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer ); GRSetDrawMode( aDC, aDrawMode ); GRLine( clipbox, aDC, m_pos.x + aOffset.x, m_pos.y + aOffset.y, m_End().x + aOffset.x, m_End().y + aOffset.y, GetPenSize(), color ); // Draw pin targets if part is being dragged bool dragging = aPanel->GetScreen()->GetCurItem() == this && aPanel->IsMouseCaptured(); if( m_isDanglingStart || dragging ) { GRCircle( clipbox, aDC, m_pos.x + aOffset.x, m_pos.y + aOffset.y, TARGET_BUSENTRY_RADIUS, 0, color ); } if( m_isDanglingEnd || dragging ) { GRCircle( clipbox, aDC, m_End().x + aOffset.x, m_End().y + aOffset.y, TARGET_BUSENTRY_RADIUS, 0, color ); } }
void SCH_BUS_ENTRY_BASE::Plot( PLOTTER* aPlotter ) { aPlotter->SetCurrentLineWidth( GetPenSize() ); aPlotter->SetColor( GetLayerColor( GetLayer() ) ); aPlotter->MoveTo( m_pos ); aPlotter->FinishTo( m_End() ); }
void SCH_FIELD::Plot( PLOTTER* aPlotter ) { SCH_COMPONENT* parent = ( SCH_COMPONENT* ) GetParent(); wxCHECK_RET( parent != NULL && parent->Type() == SCH_COMPONENT_T, wxT( "Cannot plot field with invalid parent." ) ); EDA_COLOR_T color = ReturnLayerColor( GetLayer() ); if( m_Attributs & TEXT_NO_VISIBLE ) return; if( IsVoid() ) return; /* Calculate the text orientation, according to the component * orientation/mirror */ int orient = m_Orient; if( parent->GetTransform().y1 ) // Rotate component 90 deg. { if( orient == TEXT_ORIENT_HORIZ ) orient = TEXT_ORIENT_VERT; else orient = TEXT_ORIENT_HORIZ; } /* Calculate the text justification, according to the component * orientation/mirror * this is a bit complicated due to cumulative calculations: * - numerous cases (mirrored or not, rotation) * - the DrawGraphicText function recalculate also H and H justifications * according to the text orientation. * - When a component is mirrored, the text is not mirrored and * justifications are complicated to calculate * so the more easily way is to use no justifications ( Centered text ) * and use GetBoundaryBox to know the text coordinate considered as centered */ EDA_RECT BoundaryBox = GetBoundingBox(); EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER; EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER; wxPoint textpos = BoundaryBox.Centre(); int thickness = GetPenSize(); if( (parent->GetPartCount() <= 1) || (m_id != REFERENCE) ) { aPlotter->Text( textpos, color, m_Text, orient, m_Size, hjustify, vjustify, thickness, m_Italic, m_Bold ); } else /* We plot the reference, for a multiple parts per package */ { /* Adding A, B ... to the reference */ wxString Text = m_Text + LIB_COMPONENT::ReturnSubReference( parent->GetUnit() ); aPlotter->Text( textpos, color, Text, orient, m_Size, hjustify, vjustify, thickness, m_Italic, m_Bold ); } }
void LIB_CIRCLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform ) { wxPoint pos1 = aTransform.TransformCoordinate( m_Pos ) + aOffset; COLOR4D color = GetLayerColor( LAYER_DEVICE ); COLOR4D bgColor = GetLayerColor( LAYER_DEVICE_BACKGROUND ); FILL_T fill = aData ? NO_FILL : m_Fill; EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL; if( fill == FILLED_WITH_BG_BODYCOLOR ) GRFilledCircle( clipbox, aDC, pos1.x, pos1.y, m_Radius, GetPenSize(), bgColor, bgColor ); else if( fill == FILLED_SHAPE ) GRFilledCircle( clipbox, aDC, pos1.x, pos1.y, m_Radius, 0, color, color ); else GRCircle( clipbox, aDC, pos1.x, pos1.y, m_Radius, GetPenSize(), color ); }
void LIB_CIRCLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ) { wxPoint pos1; COLOR4D color = GetLayerColor( LAYER_DEVICE ); if( aColor == COLOR4D::UNSPECIFIED ) // Used normal color or selected color { if( IsSelected() ) color = GetItemSelectedColor(); } else { color = aColor; } pos1 = aTransform.TransformCoordinate( m_Pos ) + aOffset; GRSetDrawMode( aDC, aDrawMode ); FILL_T fill = aData ? NO_FILL : m_Fill; if( aColor != COLOR4D::UNSPECIFIED ) fill = NO_FILL; EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL; if( fill == FILLED_WITH_BG_BODYCOLOR ) GRFilledCircle( clipbox, aDC, pos1.x, pos1.y, m_Radius, GetPenSize(), (m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ), GetLayerColor( LAYER_DEVICE_BACKGROUND ) ); else if( fill == FILLED_SHAPE ) GRFilledCircle( clipbox, aDC, pos1.x, pos1.y, m_Radius, 0, color, color ); else GRCircle( clipbox, aDC, pos1.x, pos1.y, m_Radius, GetPenSize(), color ); /* Set to one (1) to draw bounding box around circle to validate bounding * box calculation. */ #if 0 EDA_RECT bBox = GetBoundingBox(); bBox.RevertYAxis(); bBox = aTransform.TransformCoordinate( bBox ); bBox.Move( aOffset ); GRRect( clipbox, aDC, bBox, 0, LIGHTMAGENTA ); #endif }
EDA_RECT LIB_RECTANGLE::GetBoundingBox() const { EDA_RECT rect; rect.SetOrigin( m_Pos.x, m_Pos.y * -1 ); rect.SetEnd( m_End.x, m_End.y * -1 ); rect.Inflate( (GetPenSize() / 2) + 1 ); return rect; }
EDA_RECT SCH_JUNCTION::GetBoundingBox() const { EDA_RECT rect; rect.SetOrigin( m_pos ); rect.Inflate( ( GetPenSize() + m_size.x ) / 2 ); return rect; }
void SCH_TEXT::Plot( PLOTTER* aPlotter ) { static std::vector <wxPoint> Poly; EDA_COLOR_T color = ReturnLayerColor( GetLayer() ); wxPoint textpos = m_Pos + GetSchematicTextOffset(); int thickness = GetPenSize(); aPlotter->SetCurrentLineWidth( thickness ); if( m_MultilineAllowed ) { wxPoint pos = textpos; wxArrayString* list = wxStringSplit( m_Text, '\n' ); wxPoint offset; offset.y = GetInterline(); RotatePoint( &offset, m_Orient ); for( unsigned i = 0; i<list->Count(); i++ ) { wxString txt = list->Item( i ); aPlotter->Text( pos, color, txt, m_Orient, m_Size, m_HJustify, m_VJustify, thickness, m_Italic, m_Bold ); pos += offset; } delete (list); } else { aPlotter->Text( textpos, color, m_Text, m_Orient, m_Size, m_HJustify, m_VJustify, thickness, m_Italic, m_Bold ); } /* Draw graphic symbol for global or hierarchical labels */ CreateGraphicShape( Poly, m_Pos ); aPlotter->SetCurrentLineWidth( GetPenSize() ); if( Poly.size() ) aPlotter->PlotPoly( Poly, NO_FILL ); }
const EDA_RECT SCH_NO_CONNECT::GetBoundingBox() const { int delta = ( GetPenSize() + m_size.x ) / 2; EDA_RECT box; box.SetOrigin( m_pos ); box.Inflate( delta ); return box; }
bool LIB_CIRCLE::HitTest( const wxPoint& aPosRef ) const { int mindist = GetPenSize() / 2; // Have a minimal tolerance for hit test if( mindist < MINIMUM_SELECTION_DISTANCE ) mindist = MINIMUM_SELECTION_DISTANCE; return HitTest( aPosRef, mindist, DefaultTransform ); }
bool LIB_RECTANGLE::HitTest( const wxPoint& aPosition ) { int mindist = ( GetPenSize() / 2 ) + 1; // Have a minimal tolerance for hit test if( mindist < MINIMUM_SELECTION_DISTANCE ) mindist = MINIMUM_SELECTION_DISTANCE; return HitTest( aPosition, mindist, DefaultTransform ); }
void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ) { wxPoint text_pos; int color; int linewidth = GetPenSize(); if( m_Bold ) linewidth = GetPenSizeForBold( m_Size.x ); else linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); if( ( m_Attributs & TEXT_NO_VISIBLE ) && ( aColor < 0 ) ) { color = GetInvisibleItemColor(); } else if( IsSelected() && ( aColor < 0 ) ) { color = GetItemSelectedColor(); } else { color = aColor; } if( color < 0 ) color = GetDefaultColor(); text_pos = aTransform.TransformCoordinate( m_Pos ) + aOffset; wxString text; if( aData ) text = *(wxString*)aData; else text = m_Text; GRSetDrawMode( aDC, aDrawMode ); EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL; DrawGraphicText( clipbox, aDC, text_pos, (EDA_COLOR_T) color, text, m_Orient, m_Size, m_HJustify, m_VJustify, linewidth, m_Italic, m_Bold ); /* Set to one (1) to draw bounding box around field text to validate * bounding box calculation. */ #if 0 EDA_RECT bBox = GetBoundingBox(); EDA_RECT grBox; grBox.SetOrigin( aTransform.TransformCoordinate( bBox.GetOrigin() ) ); grBox.SetEnd( aTransform.TransformCoordinate( bBox.GetEnd() ) ); grBox.Move( aOffset ); GRRect( clipbox, aDC, grBox, 0, LIGHTMAGENTA ); #endif }
bool LIB_CIRCLE::HitTest( const wxPoint &aPosRef, int aThreshold, const TRANSFORM& aTransform ) const { if( aThreshold < 0 ) aThreshold = GetPenSize() / 2; int dist = KiROUND( GetLineLength( aPosRef, aTransform.TransformCoordinate( m_Pos ) ) ); if( abs( dist - m_Radius ) <= aThreshold ) return true; return false; }
void LIB_CIRCLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor, int aDrawMode, void* aData, const TRANSFORM& aTransform ) { wxPoint pos1; int color = ReturnLayerColor( LAYER_DEVICE ); if( aColor < 0 ) // Used normal color or selected color { if( IsSelected() ) color = g_ItemSelectetColor; } else { color = aColor; } pos1 = aTransform.TransformCoordinate( m_Pos ) + aOffset; GRSetDrawMode( aDC, aDrawMode ); FILL_T fill = aData ? NO_FILL : m_Fill; if( aColor >= 0 ) fill = NO_FILL; if( fill == FILLED_WITH_BG_BODYCOLOR ) GRFilledCircle( aPanel->GetClipBox(), aDC, pos1.x, pos1.y, m_Radius, GetPenSize(), (m_Flags & IS_MOVED) ? color : ReturnLayerColor( LAYER_DEVICE_BACKGROUND ), ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); else if( fill == FILLED_SHAPE ) GRFilledCircle( aPanel->GetClipBox(), aDC, pos1.x, pos1.y, m_Radius, 0, color, color ); else GRCircle( aPanel->GetClipBox(), aDC, pos1.x, pos1.y, m_Radius, GetPenSize(), color ); /* Set to one (1) to draw bounding box around circle to validate bounding * box calculation. */ #if 0 EDA_RECT bBox = GetBoundingBox(); GRRect( aPanel->GetClipBox(), aDC, bBox.GetOrigin().x, bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA ); #endif }
const EDA_RECT LIB_CIRCLE::GetBoundingBox() const { EDA_RECT rect; rect.SetOrigin( m_Pos.x - m_Radius, m_Pos.y - m_Radius ); rect.SetEnd( m_Pos.x + m_Radius, m_Pos.y + m_Radius ); rect.Inflate( ( GetPenSize()+1 ) / 2 ); rect.RevertYAxis(); return rect; }
void LIB_CIRCLE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ) { wxPoint pos = aTransform.TransformCoordinate( m_Pos ) + aOffset; if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR ) { aPlotter->SetColor( GetLayerColor( LAYER_DEVICE_BACKGROUND ) ); aPlotter->Circle( pos, m_Radius * 2, FILLED_WITH_BG_BODYCOLOR, 0 ); } bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR; auto pen_size = GetPenSize(); if( !already_filled || pen_size > 0 ) { pen_size = std::max( 0, pen_size ); aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) ); aPlotter->Circle( pos, m_Radius * 2, already_filled ? NO_FILL : m_Fill, GetPenSize() ); } }
const EDA_RECT SCH_BUS_ENTRY_BASE::GetBoundingBox() const { EDA_RECT box; box.SetOrigin( m_pos ); box.SetEnd( m_End() ); box.Normalize(); box.Inflate( GetPenSize() / 2 ); return box; }
const EDA_RECT LIB_RECTANGLE::GetBoundingBox() const { EDA_RECT rect; rect.SetOrigin( m_Pos ); rect.SetEnd( m_End ); rect.Inflate( ( GetPenSize()+1 ) / 2 ); rect.RevertYAxis(); return rect; }
void SCH_TEXT::Plot( PLOTTER* aPlotter ) { static std::vector <wxPoint> Poly; EDA_COLOR_T color = GetLayerColor( GetLayer() ); wxPoint textpos = m_Pos + GetSchematicTextOffset(); int thickness = GetPenSize(); aPlotter->SetCurrentLineWidth( thickness ); if( m_MultilineAllowed ) { std::vector<wxPoint> positions; wxArrayString strings_list; wxStringSplit( GetShownText(), strings_list, '\n' ); positions.reserve( strings_list.Count() ); GetPositionsOfLinesOfMultilineText(positions, strings_list.Count() ); for( unsigned ii = 0; ii < strings_list.Count(); ii++ ) { wxString& txt = strings_list.Item( ii ); aPlotter->Text( positions[ii], color, txt, m_Orient, m_Size, m_HJustify, m_VJustify, thickness, m_Italic, m_Bold ); } } else { aPlotter->Text( textpos, color, GetShownText(), m_Orient, m_Size, m_HJustify, m_VJustify, thickness, m_Italic, m_Bold ); } /* Draw graphic symbol for global or hierarchical labels */ CreateGraphicShape( Poly, m_Pos ); aPlotter->SetCurrentLineWidth( GetPenSize() ); if( Poly.size() ) aPlotter->PlotPoly( Poly, NO_FILL ); }
bool LIB_CIRCLE::HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTransform ) { if( aThreshold < 0 ) aThreshold = GetPenSize() / 2; wxPoint relpos = aPosRef - aTransform.TransformCoordinate( m_Pos ); int dist = wxRound( sqrt( ( (double) relpos.x * relpos.x ) + ( (double) relpos.y * relpos.y ) ) ); if( abs( dist - m_Radius ) <= aThreshold ) return true; return false; }
void SCH_FIELD::Plot( PLOTTER* aPlotter ) { SCH_COMPONENT* parent = ( SCH_COMPONENT* ) GetParent(); wxCHECK_RET( parent != NULL && parent->Type() == SCH_COMPONENT_T, wxT( "Cannot plot field with invalid parent." ) ); COLOR4D color = GetLayerColor( GetLayer() ); if( !IsVisible() ) return; if( IsVoid() ) return; /* Calculate the text orientation, according to the component * orientation/mirror */ int orient = GetTextAngle(); if( parent->GetTransform().y1 ) // Rotate component 90 deg. { if( orient == TEXT_ANGLE_HORIZ ) orient = TEXT_ANGLE_VERT; else orient = TEXT_ANGLE_HORIZ; } /* Calculate the text justification, according to the component * orientation/mirror * this is a bit complicated due to cumulative calculations: * - numerous cases (mirrored or not, rotation) * - the DrawGraphicText function recalculate also H and H justifications * according to the text orientation. * - When a component is mirrored, the text is not mirrored and * justifications are complicated to calculate * so the more easily way is to use no justifications ( Centered text ) * and use GetBoundaryBox to know the text coordinate considered as centered */ EDA_RECT BoundaryBox = GetBoundingBox(); EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER; EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER; wxPoint textpos = BoundaryBox.Centre(); int thickness = GetPenSize(); aPlotter->Text( textpos, color, GetFullyQualifiedText(), orient, GetTextSize(), hjustify, vjustify, thickness, IsItalic(), IsBold() ); }