void DIALOG_FOOTPRINT_WIZARD_LIST::onShowTrace( wxCommandEvent& event ) { wxString trace; pcbnewGetWizardsBackTrace( trace ); // Filter message before displaying them // a trace starts by "Traceback" and is followed by 2 useless lines // for our purpose wxArrayString traces; wxStringSplit( trace, traces, '\n' ); // Build the filtered message (remove useless lines) trace.Clear(); for( unsigned ii = 0; ii < traces.Count(); ++ii ) { if( traces[ii].Contains( "Traceback" ) ) { ii += 2; // Skip this line and next lines which are related to pcbnew.py module if( !trace.IsEmpty() ) // Add separator for the next trace block trace << "\n**********************************\n"; } else trace += traces[ii] + "\n"; } // Now display the filtered trace in our dialog // (a simple wxMessageBox is really not suitable for long messages) DIALOG_FOOTPRINT_WIZARD_LOG logWindow( this ); logWindow.m_Message->SetValue( trace ); logWindow.ShowModal(); }
void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode, EDA_COLOR_T aAnchor_color ) { if( m_MultilineAllowed ) { std::vector<wxPoint> positions; wxArrayString strings; wxStringSplit( GetShownText(), strings, '\n' ); positions.reserve( strings.Count() ); GetPositionsOfLinesOfMultilineText(positions, strings.Count() ); for( unsigned ii = 0; ii < strings.Count(); ii++ ) { wxString& txt = strings.Item( ii ); drawOneLineOfText( aClipBox, aDC, aOffset, aColor, aDrawMode, aFillMode, txt, positions[ii] ); } } else drawOneLineOfText( aClipBox, aDC, aOffset, aColor, aDrawMode, aFillMode, GetShownText(), m_Pos ); // Draw text anchor, if requested if( aAnchor_color != UNSPECIFIED_COLOR ) { GRDrawAnchor( aClipBox, aDC, m_Pos.x + aOffset.x, m_Pos.y + aOffset.y, DIM_ANCRE_TEXTE, aAnchor_color ); } }
// Plot a PCB Text, i;e. a text found on a copper or technical layer void BRDITEMS_PLOTTER::PlotTextePcb( TEXTE_PCB* pt_texte ) { double orient; int thickness; wxPoint pos; wxSize size; wxString shownText( pt_texte->GetShownText() ); if( shownText.IsEmpty() ) return; if( !m_layerMask[pt_texte->GetLayer()] ) return; m_plotter->SetColor( getColor( pt_texte->GetLayer() ) ); size = pt_texte->GetSize(); pos = pt_texte->GetTextPosition(); orient = pt_texte->GetOrientation(); thickness = ( GetMode() == LINE ) ? -1 : pt_texte->GetThickness(); if( pt_texte->IsMirrored() ) size.x = -size.x; // Non bold texts thickness is clamped at 1/6 char size by the low level draw function. // but in Pcbnew we do not manage bold texts and thickness up to 1/4 char size // (like bold text) and we manage the thickness. // So we set bold flag to true bool allow_bold = pt_texte->IsBold() || thickness; if( pt_texte->IsMultilineAllowed() ) { std::vector<wxPoint> positions; wxArrayString* list = wxStringSplit( shownText, '\n' ); positions.reserve( list->Count() ); pt_texte->GetPositionsOfLinesOfMultilineText( positions, list->Count() ); for( unsigned ii = 0; ii < list->Count(); ii++ ) { wxString& txt = list->Item( ii ); m_plotter->Text( positions[ii], UNSPECIFIED_COLOR, txt, orient, size, pt_texte->GetHorizJustify(), pt_texte->GetVertJustify(), thickness, pt_texte->IsItalic(), allow_bold ); } delete list; } else { m_plotter->Text( pos, UNSPECIFIED_COLOR, shownText, orient, size, pt_texte->GetHorizJustify(), pt_texte->GetVertJustify(), thickness, pt_texte->IsItalic(), allow_bold ); } }
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 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 ); }
static void export_vrml_pcbtext( TEXTE_PCB* text ) { // Coupling by globals! Ewwww... s_text_layer = text->GetLayer(); s_text_width = text->m_Thickness; wxSize size = text->m_Size; if( text->m_Mirror ) NEGATE( size.x ); if( text->m_MultilineAllowed ) { wxPoint pos = text->m_Pos; wxArrayString* list = wxStringSplit( text->m_Text, '\n' ); wxPoint offset; offset.y = text->GetInterline(); RotatePoint( &offset, text->GetOrientation() ); for( unsigned i = 0; i<list->Count(); i++ ) { wxString txt = list->Item( i ); DrawGraphicText( NULL, NULL, pos, BLACK, txt, text->GetOrientation(), size, text->m_HJustify, text->m_VJustify, text->m_Thickness, text->m_Italic, true, vrml_text_callback ); pos += offset; } delete (list); } else { DrawGraphicText( NULL, NULL, text->m_Pos, BLACK, text->m_Text, text->GetOrientation(), size, text->m_HJustify, text->m_VJustify, text->m_Thickness, text->m_Italic, true, vrml_text_callback ); } }
void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet( SHAPE_POLY_SET& aCornerBuffer, int aClearanceValue, int aCircleToSegmentsCount, double aCorrectionFactor ) const { wxSize size = GetSize(); if( IsMirrored() ) size.x = -size.x; s_cornerBuffer = &aCornerBuffer; s_textWidth = GetThickness() + ( 2 * aClearanceValue ); s_textCircle2SegmentCount = aCircleToSegmentsCount; EDA_COLOR_T color = BLACK; // not actually used, but needed by DrawGraphicText if( IsMultilineAllowed() ) { wxArrayString strings_list; wxStringSplit( GetShownText(), strings_list, '\n' ); std::vector<wxPoint> positions; 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 ); DrawGraphicText( NULL, NULL, positions[ii], color, txt, GetOrientation(), size, GetHorizJustify(), GetVertJustify(), GetThickness(), IsItalic(), true, addTextSegmToPoly ); } } else { DrawGraphicText( NULL, NULL, GetTextPosition(), color, GetShownText(), GetOrientation(), size, GetHorizJustify(), GetVertJustify(), GetThickness(), IsItalic(), true, addTextSegmToPoly ); } }
static void export_vrml_pcbtext( MODEL_VRML& aModel, TEXTE_PCB* text ) { model_vrml->s_text_layer = text->GetLayer(); model_vrml->s_text_width = text->GetThickness(); wxSize size = text->GetSize(); if( text->IsMirrored() ) NEGATE( size.x ); EDA_COLOR_T color = BLACK; // not actually used, but needed by DrawGraphicText if( text->IsMultilineAllowed() ) { wxArrayString* list = wxStringSplit( text->GetShownText(), '\n' ); std::vector<wxPoint> positions; positions.reserve( list->Count() ); text->GetPositionsOfLinesOfMultilineText( positions, list->Count() ); for( unsigned ii = 0; ii < list->Count(); ii++ ) { wxString txt = list->Item( ii ); DrawGraphicText( NULL, NULL, positions[ii], color, txt, text->GetOrientation(), size, text->GetHorizJustify(), text->GetVertJustify(), text->GetThickness(), text->IsItalic(), true, vrml_text_callback ); } delete (list); } else { DrawGraphicText( NULL, NULL, text->GetTextPosition(), color, text->GetShownText(), text->GetOrientation(), size, text->GetHorizJustify(), text->GetVertJustify(), text->GetThickness(), text->IsItalic(), true, vrml_text_callback ); } }
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 ); }
void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& aCornerBuffer ) const { wxSize size = GetSize(); if( IsMirrored() ) NEGATE( size.x ); s_cornerBuffer = &aCornerBuffer; EDA_COLOR_T color = BLACK; // not actually used, but needed by DrawGraphicText if( IsMultilineAllowed() ) { wxArrayString* list = wxStringSplit( GetText(), '\n' ); std::vector<wxPoint> positions; positions.reserve( list->Count() ); GetPositionsOfLinesOfMultilineText( positions, list->Count() ); for( unsigned ii = 0; ii < list->Count(); ii++ ) { wxString txt = list->Item( ii ); DrawGraphicText( NULL, NULL, positions[ii], color, txt, GetOrientation(), size, GetHorizJustify(), GetVertJustify(), GetThickness(), IsItalic(), true, addTextSegmToBuffer ); } delete list; } else { DrawGraphicText( NULL, NULL, GetTextPosition(), color, GetText(), GetOrientation(), size, GetHorizJustify(), GetVertJustify(), GetThickness(), IsItalic(), true, addTextSegmToBuffer ); } }
EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const { EDA_RECT rect; wxPoint pos; wxArrayString strings; wxString text = GetShownText(); int thickness = ( aThickness < 0 ) ? m_Thickness : aThickness; int linecount = 1; if( m_MultilineAllowed ) { wxStringSplit( text, strings, '\n' ); if ( strings.GetCount() ) // GetCount() == 0 for void strings { if( aLine >= 0 && (aLine < (int)strings.GetCount()) ) text = strings.Item( aLine ); else text = strings.Item( 0 ); linecount = strings.GetCount(); } } // calculate the H and V size int dx = LenSize( text ); int dy = GetInterline( aThickness ); // Creates bounding box (rectangle) for an horizontal text wxSize textsize = wxSize( dx, dy ); if( aInvertY ) rect.SetOrigin( m_Pos.x, -m_Pos.y ); else rect.SetOrigin( m_Pos ); // extra dy interval for letters like j and y and ] int extra_dy = dy - m_Size.y; rect.Move( wxPoint( 0, -extra_dy / 2 ) ); // move origin by the half extra interval // for multiline texts and aLine < 0, merge all rectangles if( m_MultilineAllowed && aLine < 0 ) { for( unsigned ii = 1; ii < strings.GetCount(); ii++ ) { text = strings.Item( ii ); dx = LenSize( text ); textsize.x = std::max( textsize.x, dx ); textsize.y += dy; } } rect.SetSize( textsize ); /* Now, calculate the rect origin, according to text justification * At this point the rectangle origin is the text origin (m_Pos). * This is true only for left and top text justified texts (using top to bottom Y axis * orientation). and must be recalculated for others justifications * also, note the V justification is relative to the first line */ switch( m_HJustify ) { case GR_TEXT_HJUSTIFY_LEFT: if( m_Mirror ) rect.SetX( rect.GetX() - rect.GetWidth() ); break; case GR_TEXT_HJUSTIFY_CENTER: rect.SetX( rect.GetX() - (rect.GetWidth() / 2) ); break; case GR_TEXT_HJUSTIFY_RIGHT: if( !m_Mirror ) rect.SetX( rect.GetX() - rect.GetWidth() ); break; } dy = m_Size.y + thickness; switch( m_VJustify ) { case GR_TEXT_VJUSTIFY_TOP: break; case GR_TEXT_VJUSTIFY_CENTER: rect.SetY( rect.GetY() - ( dy / 2) ); break; case GR_TEXT_VJUSTIFY_BOTTOM: rect.SetY( rect.GetY() - dy ); break; } if( linecount > 1 ) { int yoffset; linecount -= 1; switch( m_VJustify ) { case GR_TEXT_VJUSTIFY_TOP: break; case GR_TEXT_VJUSTIFY_CENTER: yoffset = linecount * GetInterline() / 2; rect.SetY( rect.GetY() - yoffset ); break; case GR_TEXT_VJUSTIFY_BOTTOM: yoffset = linecount * GetInterline( aThickness ); rect.SetY( rect.GetY() - yoffset ); break; } } rect.Inflate( thickness / 2 ); rect.Normalize(); // Make h and v sizes always >= 0 return rect; }
/** * Function PlotGraphicText * same as DrawGraphicText, but plot graphic text insteed of draw it * @param aPos = text position (according to aH_justify, aV_justify) * @param aColor (enum EDA_COLOR_T) = text color * @param aText = text to draw * @param aOrient = angle in 0.1 degree * @param aSize = text size (size.x or size.y can be < 0 for mirrored texts) * @param aH_justify = horizontal justification (Left, center, right) * @param aV_justify = vertical justification (bottom, center, top) * @param aWidth = line width (pen width) (default = 0) * if width < 0 : draw segments in sketch mode, width = abs(width) * Use a value min(aSize.x, aSize.y) / 5 for a bold text * @param aItalic = true to simulate an italic font * @param aBold = true to use a bold font Useful only with default width value (aWidth = 0) * @param aMultilineAllowed = true to plot text as multiline, otherwise single line */ void PLOTTER::Text( const wxPoint& aPos, enum EDA_COLOR_T aColor, const wxString& aText, double aOrient, const wxSize& aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed ) { int textPensize = aWidth; if( textPensize == 0 && aBold ) // Use default values if aWidth == 0 textPensize = GetPenSizeForBold( std::min( aSize.x, aSize.y ) ); if( textPensize >= 0 ) textPensize = Clamp_Text_PenSize( aWidth, aSize, aBold ); else textPensize = -Clamp_Text_PenSize( -aWidth, aSize, aBold ); SetCurrentLineWidth( textPensize ); if( aColor >= 0 ) SetColor( aColor ); if( aMultilineAllowed ) { // EDA_TEXT needs for calculations of the position of every // line according to orientation and justifications wxArrayString strings; EDA_TEXT* multilineText = new EDA_TEXT( aText ); multilineText->SetSize( aSize ); multilineText->SetTextPosition( aPos ); multilineText->SetOrientation( aOrient ); multilineText->SetHorizJustify( aH_justify ); multilineText->SetVertJustify( aV_justify ); multilineText->SetThickness( aWidth ); multilineText->SetMultilineAllowed( aMultilineAllowed ); std::vector<wxPoint> positions; wxStringSplit( aText, strings, '\n' ); positions.reserve( strings.Count() ); multilineText->GetPositionsOfLinesOfMultilineText( positions, strings.Count() ); for( unsigned ii = 0; ii < strings.Count(); ii++ ) { wxString& txt = strings.Item( ii ); DrawGraphicText( NULL, NULL, positions[ii], aColor, txt, aOrient, aSize, aH_justify, aV_justify, textPensize, aItalic, aBold, NULL, this ); } delete multilineText; } else { DrawGraphicText( NULL, NULL, aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, textPensize, aItalic, aBold, NULL, this ); } if( aWidth != textPensize ) SetCurrentLineWidth( aWidth ); }