void TEXTE_PCB::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) { wxString msg; wxCHECK_RET( m_Parent != NULL, wxT( "TEXTE_PCB::GetMsgPanelInfo() m_Parent is NULL." ) ); if( m_Parent->Type() == PCB_DIMENSION_T ) aList.push_back( MSG_PANEL_ITEM( _( "Dimension" ), GetShownText(), DARKGREEN ) ); else aList.push_back( MSG_PANEL_ITEM( _( "PCB Text" ), GetShownText(), DARKGREEN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), BLUE ) ); if( !m_Mirror ) aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), _( "No" ), DARKGREEN ) ); else aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), _( "Yes" ), DARKGREEN ) ); msg.Printf( wxT( "%.1f" ), m_Orient / 10.0 ); aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) ); msg = ::CoordinateToString( m_Thickness ); aList.push_back( MSG_PANEL_ITEM( _( "Thickness" ), msg, MAGENTA ) ); msg = ::CoordinateToString( m_Size.x ); aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, RED ) ); msg = ::CoordinateToString( m_Size.y ); aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, RED ) ); }
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 ); } }
void TEXTE_PCB::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) { wxString msg; wxCHECK_RET( m_Parent != NULL, wxT( "TEXTE_PCB::GetMsgPanelInfo() m_Parent is NULL." ) ); if( m_Parent->Type() == PCB_DIMENSION_T ) aList.push_back( MSG_PANEL_ITEM( _( "Dimension" ), GetShownText(), DARKGREEN ) ); else aList.push_back( MSG_PANEL_ITEM( _( "PCB Text" ), GetShownText(), DARKGREEN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), BLUE ) ); if( !IsMirrored() ) aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), _( "No" ), DARKGREEN ) ); else aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), _( "Yes" ), DARKGREEN ) ); msg.Printf( wxT( "%.1f" ), GetTextAngle() / 10.0 ); aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) ); msg = MessageTextFromValue( aUnits, GetThickness() ); aList.push_back( MSG_PANEL_ITEM( _( "Thickness" ), msg, MAGENTA ) ); msg = MessageTextFromValue( aUnits, GetTextWidth() ); aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, RED ) ); msg = MessageTextFromValue( aUnits, GetTextHeight() ); aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, RED ) ); }
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_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(), GetShownText(), 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() ); }
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 ); } }
wxString EDA_TEXT::ShortenedShownText() const { wxString tmp = GetShownText(); tmp.Replace( wxT( "\n" ), wxT( " " ) ); tmp.Replace( wxT( "\r" ), wxT( " " ) ); tmp.Replace( wxT( "\t" ), wxT( " " ) ); if( tmp.Length() > 15 ) tmp = tmp.Left( 12 ) + wxT( "..." ); return tmp; }
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 ); }
// see class_text_mod.h void TEXTE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) { MODULE* module = (MODULE*) m_Parent; if( module == NULL ) // Happens in modedit, and for new texts return; wxString msg, Line; static const wxString text_type_msg[3] = { _( "Ref." ), _( "Value" ), _( "Text" ) }; Line = module->GetReference(); aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), Line, DARKCYAN ) ); Line = GetShownText(); aList.push_back( MSG_PANEL_ITEM( _( "Text" ), Line, BROWN ) ); wxASSERT( m_Type >= TEXT_is_REFERENCE && m_Type <= TEXT_is_DIVERS ); aList.push_back( MSG_PANEL_ITEM( _( "Type" ), text_type_msg[m_Type], DARKGREEN ) ); if( !IsVisible() ) msg = _( "No" ); else msg = _( "Yes" ); aList.push_back( MSG_PANEL_ITEM( _( "Display" ), msg, DARKGREEN ) ); // Display text layer aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), DARKGREEN ) ); if( IsMirrored() ) msg = _( "Yes" ); else msg = _( "No" ); aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), msg, DARKGREEN ) ); msg.Printf( wxT( "%.1f" ), GetTextAngleDegrees() ); aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) ); msg = ::CoordinateToString( GetThickness() ); aList.push_back( MSG_PANEL_ITEM( _( "Thickness" ), msg, DARKGREEN ) ); msg = ::CoordinateToString( GetTextWidth() ); aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, RED ) ); msg = ::CoordinateToString( GetTextHeight() ); aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, RED ) ); }
const EDA_RECT SCH_GLOBALLABEL::GetBoundingBox() const { int x, y, dx, dy, length, height; x = GetTextPos().x; y = GetTextPos().y; dx = dy = 0; int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); height = ( (GetTextHeight() * 15) / 10 ) + width + 2 * TXT_MARGIN; // text X size add height for triangular shapes(bidirectional) length = LenSize( GetShownText(), width ) + height + DANGLING_SYMBOL_SIZE; switch( GetLabelSpinStyle() ) // respect orientation { default: case 0: // Horiz Normal Orientation (left justified) dx = -length; dy = height; x += DANGLING_SYMBOL_SIZE; y -= height / 2; break; case 1: // Vert Orientation UP dx = height; dy = -length; x -= height / 2; y += DANGLING_SYMBOL_SIZE; break; case 2: // Horiz Orientation - Right justified dx = length; dy = height; x -= DANGLING_SYMBOL_SIZE; y -= height / 2; break; case 3: // Vert Orientation BOTTOM dx = height; dy = length; x -= height / 2; y -= DANGLING_SYMBOL_SIZE; break; } EDA_RECT box( wxPoint( x, y ), wxSize( dx, dy ) ); box.Normalize(); return box; }
const EDA_RECT SCH_HIERLABEL::GetBoundingBox() const { int x, y, dx, dy, length, height; x = m_Pos.x; y = m_Pos.y; dx = dy = 0; int width = (m_Thickness == 0) ? GetDefaultLineThickness() : m_Thickness; height = m_Size.y + width + 2 * TXTMARGE; length = LenSize( GetShownText() ) + height // add height for triangular shapes + 2 * DANGLING_SYMBOL_SIZE; switch( m_schematicOrientation ) // respect orientation { case 0: /* Horiz Normal Orientation (left justified) */ dx = -length; dy = height; x += DANGLING_SYMBOL_SIZE; y -= height / 2; break; case 1: /* Vert Orientation UP */ dx = height; dy = -length; x -= height / 2; y += DANGLING_SYMBOL_SIZE; break; case 2: /* Horiz Orientation - Right justified */ dx = length; dy = height; x -= DANGLING_SYMBOL_SIZE; y -= height / 2; break; case 3: /* Vert Orientation BOTTOM */ dx = height; dy = length; x -= height / 2; y -= DANGLING_SYMBOL_SIZE; break; } EDA_RECT box( wxPoint( x, y ), wxSize( dx, dy ) ); box.Normalize(); return box; }
const EDA_RECT SCH_LABEL::GetBoundingBox() const { int x, y, dx, dy, length, height; x = m_Pos.x; y = m_Pos.y; int width = (m_Thickness == 0) ? GetDefaultLineThickness() : m_Thickness; length = LenSize( GetShownText() ); height = m_Size.y + width; dx = dy = 0; switch( m_schematicOrientation ) { case 0: /* Horiz Normal Orientation (left justified) */ dx = 2 * DANGLING_SYMBOL_SIZE + length; dy = -2 * DANGLING_SYMBOL_SIZE - height - TXTMARGE; x -= DANGLING_SYMBOL_SIZE; y += DANGLING_SYMBOL_SIZE; break; case 1: /* Vert Orientation UP */ dx = -2 * DANGLING_SYMBOL_SIZE - height - TXTMARGE; dy = -2 * DANGLING_SYMBOL_SIZE - length; x += DANGLING_SYMBOL_SIZE; y += DANGLING_SYMBOL_SIZE; break; case 2: /* Horiz Orientation - Right justified */ dx = -2 * DANGLING_SYMBOL_SIZE - length; dy = -2 * DANGLING_SYMBOL_SIZE - height - TXTMARGE; x += DANGLING_SYMBOL_SIZE; y += DANGLING_SYMBOL_SIZE; break; case 3: /* Vert Orientation BOTTOM */ dx = -2 * DANGLING_SYMBOL_SIZE - height - TXTMARGE; dy = 2 * DANGLING_SYMBOL_SIZE + length; x += DANGLING_SYMBOL_SIZE; y -= DANGLING_SYMBOL_SIZE; break; } EDA_RECT box( wxPoint( x, y ), wxSize( dx, dy ) ); box.Normalize(); return box; }
void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill, const TRANSFORM& aTransform ) { wxASSERT( plotter != NULL ); /* The text orientation may need to be flipped if the * transformation matrix causes xy axes to be flipped. */ int t1 = ( aTransform.x1 != 0 ) ^ ( m_Orient != 0 ); wxPoint pos = aTransform.TransformCoordinate( m_Pos ) + offset; // Get color EDA_COLOR_T color; if( plotter->GetColorMode() ) // Used normal color or selected color color = IsSelected() ? GetItemSelectedColor() : GetDefaultColor(); else color = BLACK; plotter->Text( pos, color, GetShownText(), t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT, m_Size, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GetPenSize(), m_Italic, m_Bold ); }
wxString TEXTE_MODULE::GetSelectMenuText() const { wxString text; const wxChar *reference = GetChars( static_cast<MODULE*>( GetParent() )->GetReference() ); switch( m_Type ) { case TEXT_is_REFERENCE: text.Printf( _( "Reference %s" ), reference ); break; case TEXT_is_VALUE: text.Printf( _( "Value %s of %s" ), GetChars( GetShownText() ), reference ); break; default: // wrap this one in quotes: text.Printf( _( "Text \"%s\" on %s of %s" ), GetChars( ShortenedShownText() ), GetChars( GetLayerName() ), reference ); break; } return text; }
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 strings_list; wxStringSplit( GetShownText(), strings_list, wxChar('\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, addTextSegmToBuffer ); } } 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; }
void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos ) { int HalfSize = m_Size.y / 2; int linewidth = (m_Thickness == 0) ? GetDefaultLineThickness() : m_Thickness; linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); aPoints.clear(); int symb_len = LenSize( GetShownText() ) + ( TXTMARGE * 2 ); // Create outline shape : 6 points int x = symb_len + linewidth + 3; // Use negation bar Y position to calculate full vertical size #define Y_CORRECTION 1.3 // Note: this factor is due to the fact the negation bar Y position // does not give exactly the full Y size of text // and is experimentally set to this value int y = KiROUND( OverbarPositionY( HalfSize ) * Y_CORRECTION ); // add room for line thickness and space between top of text and graphic shape y += linewidth; // Starting point(anchor) aPoints.push_back( wxPoint( 0, 0 ) ); aPoints.push_back( wxPoint( 0, -y ) ); // Up aPoints.push_back( wxPoint( -x, -y ) ); // left aPoints.push_back( wxPoint( -x, 0 ) ); // Up left aPoints.push_back( wxPoint( -x, y ) ); // left down aPoints.push_back( wxPoint( 0, y ) ); // down int x_offset = 0; switch( m_shape ) { case NET_INPUT: x_offset = -HalfSize; aPoints[0].x += HalfSize; break; case NET_OUTPUT: aPoints[3].x -= HalfSize; break; case NET_BIDI: case NET_TRISTATE: x_offset = -HalfSize; aPoints[0].x += HalfSize; aPoints[3].x -= HalfSize; break; case NET_UNSPECIFIED: default: break; } int angle = 0; switch( m_schematicOrientation ) { case 0: /* Orientation horiz normal */ break; case 1: /* Orientation vert UP */ angle = -900; break; case 2: /* Orientation horiz inverse */ angle = 1800; break; case 3: /* Orientation vert BOTTOM */ angle = 900; break; } // Rotate outlines and move corners in real position for( unsigned ii = 0; ii < aPoints.size(); ii++ ) { aPoints[ii].x += x_offset; if( angle ) RotatePoint( &aPoints[ii], angle ); aPoints[ii] += Pos; } aPoints.push_back( aPoints[0] ); // closing }
void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ) { COLOR4D color = GetDefaultColor(); if( aColor == COLOR4D::UNSPECIFIED ) // Used normal color or selected color { if( IsSelected() ) color = GetItemSelectedColor(); } else { color = aColor; } GRSetDrawMode( aDC, aDrawMode ); /* Calculate the text orientation, according to the component * orientation/mirror (needed when draw text in schematic) */ int orient = GetTextAngle(); if( aTransform.y1 ) // Rotate component 90 degrees. { 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 bBox = GetBoundingBox(); // convert coordinates from draw Y axis to libedit Y axis: bBox.RevertYAxis(); wxPoint txtpos = bBox.Centre(); // Calculate pos according to mirror/rotation. txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset; EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL; DrawGraphicText( clipbox, aDC, txtpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GetPenSize(), IsItalic(), IsBold() ); /* Enable this to draw the bounding box around the text field to validate * the bounding box calculations. */ #if 0 // bBox already uses libedit Y axis. bBox = aTransform.TransformCoordinate( bBox ); bBox.Move( aOffset ); GRRect( clipbox, aDC, bBox, 0, LIGHTMAGENTA ); #endif }
void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aOffset ) { if( aPanel == NULL ) return; /* parent must *not* be NULL (a footprint text without a footprint parent has no sense) */ wxASSERT( m_Parent ); BOARD* brd = GetBoard( ); auto frame = static_cast<PCB_BASE_FRAME*> ( aPanel->GetParent() ); auto color = frame->Settings().Colors().GetLayerColor( GetLayer() ); PCB_LAYER_ID text_layer = GetLayer(); if( !brd->IsLayerVisible( m_Layer ) || ( IsFrontLayer( text_layer ) && !brd->IsElementVisible( LAYER_MOD_TEXT_FR ) ) || ( IsBackLayer( text_layer ) && !brd->IsElementVisible( LAYER_MOD_TEXT_BK ) ) ) return; if( !brd->IsElementVisible( LAYER_MOD_REFERENCES ) && GetText() == wxT( "%R" ) ) return; if( !brd->IsElementVisible( LAYER_MOD_VALUES ) && GetText() == wxT( "%V" ) ) return; // Invisible texts are still drawn (not plotted) in LAYER_MOD_TEXT_INVISIBLE // Just because we must have to edit them (at least to make them visible) if( !IsVisible() ) { if( !brd->IsElementVisible( LAYER_MOD_TEXT_INVISIBLE ) ) return; color = frame->Settings().Colors().GetItemColor( LAYER_MOD_TEXT_INVISIBLE ); } auto displ_opts = (PCB_DISPLAY_OPTIONS*)( aPanel->GetDisplayOptions() ); // shade text if high contrast mode is active if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts && displ_opts->m_ContrastModeDisplay ) { PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) aPanel->GetScreen() )->m_Active_Layer; if( !IsOnLayer( curr_layer ) ) color = COLOR4D( DARKDARKGRAY ); } // Draw mode compensation for the width int width = GetThickness(); if( displ_opts && displ_opts->m_DisplayModTextFill == SKETCH ) width = -width; GRSetDrawMode( aDC, aDrawMode ); wxPoint pos = GetTextPos() - aOffset; // Draw the text anchor point if( brd->IsElementVisible( LAYER_ANCHOR ) ) { COLOR4D anchor_color = frame->Settings().Colors().GetItemColor( LAYER_ANCHOR ); GRDrawAnchor( aPanel->GetClipBox(), aDC, pos.x, pos.y, DIM_ANCRE_TEXTE, anchor_color ); } // Draw the text proper, with the right attributes wxSize size = GetTextSize(); double orient = GetDrawRotation(); // If the text is mirrored : negate size.x (mirror / Y axis) if( IsMirrored() ) size.x = -size.x; DrawGraphicText( aPanel->GetClipBox(), aDC, pos, color, GetShownText(), orient, size, GetHorizJustify(), GetVertJustify(), width, IsItalic(), IsBold() ); // Enable these line to draw the bounding box (debug test purpose only) #if 0 { EDA_RECT BoundaryBox = GetBoundingBox(); GRRect( aPanel->GetClipBox(), aDC, BoundaryBox, 0, BROWN ); } #endif }
void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aOffset ) { if( aPanel == NULL ) return; /* parent must *not* be NULL (a footprint text without a footprint parent has no sense) */ wxASSERT( m_Parent ); BOARD* brd = GetBoard( ); EDA_COLOR_T color = brd->GetLayerColor( GetLayer() ); LAYER_ID text_layer = GetLayer(); if( !brd->IsLayerVisible( m_Layer ) || (IsFrontLayer( text_layer ) && !brd->IsElementVisible( MOD_TEXT_FR_VISIBLE )) || (IsBackLayer( text_layer ) && !brd->IsElementVisible( MOD_TEXT_BK_VISIBLE )) ) return; // Invisible texts are still drawn (not plotted) in MOD_TEXT_INVISIBLE // Just because we must have to edit them (at least to make them visible) if( m_NoShow ) { if( !brd->IsElementVisible( MOD_TEXT_INVISIBLE ) ) return; color = brd->GetVisibleElementColor( MOD_TEXT_INVISIBLE ); } DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)aPanel->GetDisplayOptions(); // shade text if high contrast mode is active if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts && displ_opts->m_ContrastModeDisplay ) { LAYER_ID curr_layer = ( (PCB_SCREEN*) aPanel->GetScreen() )->m_Active_Layer; if( !IsOnLayer( curr_layer ) ) ColorTurnToDarkDarkGray( &color ); } // Draw mode compensation for the width int width = m_Thickness; if( displ_opts && displ_opts->m_DisplayModTextFill == SKETCH ) width = -width; GRSetDrawMode( aDC, aDrawMode ); wxPoint pos = m_Pos - aOffset; // Draw the text anchor point if( brd->IsElementVisible( ANCHOR_VISIBLE ) ) { EDA_COLOR_T anchor_color = brd->GetVisibleElementColor(ANCHOR_VISIBLE); GRDrawAnchor( aPanel->GetClipBox(), aDC, pos.x, pos.y, DIM_ANCRE_TEXTE, anchor_color ); } // Draw the text proper, with the right attributes wxSize size = m_Size; double orient = GetDrawRotation(); // If the text is mirrored : negate size.x (mirror / Y axis) if( m_Mirror ) size.x = -size.x; DrawGraphicText( aPanel->GetClipBox(), aDC, pos, color, GetShownText(), orient, size, m_HJustify, m_VJustify, width, m_Italic, m_Bold ); // Enable these line to draw the bounding box (debug test purpose only) #if 0 { EDA_RECT BoundaryBox = GetBoundingBox(); GRRect( aPanel->GetClipBox(), aDC, BoundaryBox, 0, BROWN ); } #endif }
void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos ) { int halfSize = GetTextHeight() / 2; int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() ); aPoints.clear(); int symb_len = LenSize( GetShownText(), linewidth ) + ( TXT_MARGIN * 2 ); // Create outline shape : 6 points int x = symb_len + linewidth + 3; // Use negation bar Y position to calculate full vertical size // Search for overbar symbol bool hasOverBar = false; for( unsigned ii = 1; ii < m_Text.size(); ii++ ) { if( m_Text[ii-1] == '~' && m_Text[ii] != '~' ) { hasOverBar = true; break; } } #define Y_CORRECTION 1.40 // Note: this factor is due to the fact the Y size of a few letters like [ // are bigger than the y size value, and we need a margin for the graphic symbol. int y = KiROUND( halfSize * Y_CORRECTION ); // Note: this factor is due to the fact we need a margin for the graphic symbol. #define Y_OVERBAR_CORRECTION 1.2 if( hasOverBar ) y = KiROUND( KIGFX::STROKE_FONT::GetInterline( halfSize, linewidth ) * Y_OVERBAR_CORRECTION ); // Gives room for line thickess and margin y += linewidth // for line thickess + linewidth/2; // for margin // Starting point(anchor) aPoints.push_back( wxPoint( 0, 0 ) ); aPoints.push_back( wxPoint( 0, -y ) ); // Up aPoints.push_back( wxPoint( -x, -y ) ); // left aPoints.push_back( wxPoint( -x, 0 ) ); // Up left aPoints.push_back( wxPoint( -x, y ) ); // left down aPoints.push_back( wxPoint( 0, y ) ); // down int x_offset = 0; switch( m_shape ) { case NET_INPUT: x_offset = -halfSize; aPoints[0].x += halfSize; break; case NET_OUTPUT: aPoints[3].x -= halfSize; break; case NET_BIDI: case NET_TRISTATE: x_offset = -halfSize; aPoints[0].x += halfSize; aPoints[3].x -= halfSize; break; case NET_UNSPECIFIED: default: break; } int angle = 0; switch( GetLabelSpinStyle() ) { default: case 0: break; // Orientation horiz normal case 1: angle = -900; break; // Orientation vert UP case 2: angle = 1800; break; // Orientation horiz inverse case 3: angle = 900; break; // Orientation vert BOTTOM } // Rotate outlines and move corners in real position for( wxPoint& aPoint : aPoints ) { aPoint.x += x_offset; if( angle ) RotatePoint( &aPoint, angle ); aPoint += Pos; } aPoints.push_back( aPoints[0] ); // closing }
void SCH_TEXT::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) { wxString msg; switch( Type() ) { case SCH_TEXT_T: msg = _( "Graphic Text" ); break; case SCH_LABEL_T: msg = _( "Label" ); break; case SCH_GLOBAL_LABEL_T: msg = _( "Global Label" ); break; case SCH_HIERARCHICAL_LABEL_T: msg = _( "Hierarchical Label" ); break; case SCH_SHEET_PIN_T: msg = _( "Hierarchical Sheet Pin" ); break; default: return; } aList.push_back( MSG_PANEL_ITEM( msg, GetShownText(), DARKCYAN ) ); switch( GetLabelSpinStyle() ) { case 0: msg = _( "Horizontal" ); break; case 1: msg = _( "Vertical up" ); break; case 2: msg = _( "Horizontal invert" ); break; case 3: msg = _( "Vertical down" ); break; default: msg = wxT( "???" ); break; } aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), msg, BROWN ) ); wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) }; int style = 0; if( IsItalic() ) style = 1; if( IsBold() ) style += 2; aList.push_back( MSG_PANEL_ITEM( _( "Style" ), textStyle[style], BROWN ) ); // Display electricat type if it is relevant if( (Type() == SCH_GLOBAL_LABEL_T) || (Type() == SCH_HIERARCHICAL_LABEL_T ) || (Type() == SCH_SHEET_PIN_T ) ) { switch( GetShape() ) { case NET_INPUT: msg = _( "Input" ); break; case NET_OUTPUT: msg = _( "Output" ); break; case NET_BIDI: msg = _( "Bidirectional" ); break; case NET_TRISTATE: msg = _( "Tri-State" ); break; case NET_UNSPECIFIED: msg = _( "Passive" ); break; default: msg = wxT( "???" ); break; } aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, BLUE ) ); } // Display text size (X or Y value, with are the same value in Eeschema) msg = MessageTextFromValue( aUnits, GetTextWidth(), true ); aList.push_back( MSG_PANEL_ITEM( _( "Size" ), msg, RED ) ); #if defined(DEBUG) if( auto conn = Connection( *g_CurrentSheet ) ) { conn->AppendDebugInfoToMsgPanel( aList ); } msg.Printf( "%p", this ); aList.push_back( MSG_PANEL_ITEM( "Object Address", msg, RED ) ); #endif }
/* * Display the type, shape, size and some other props to the Message panel */ void SCH_TEXT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) { wxString msg; switch( Type() ) { case SCH_TEXT_T: msg = _( "Graphic Text" ); break; case SCH_LABEL_T: msg = _( "Label" ); break; case SCH_GLOBAL_LABEL_T: msg = _( "Global Label" ); break; case SCH_HIERARCHICAL_LABEL_T: msg = _( "Hierarchical Label" ); break; case SCH_SHEET_PIN_T: msg = _( "Hierarchical Sheet Pin" ); break; default: return; } aList.push_back( MSG_PANEL_ITEM( msg, GetShownText(), DARKCYAN ) ); switch( GetOrientation() ) { case 0: // horizontal text msg = _( "Horizontal" ); break; case 1: // Vert Orientation UP msg = _( "Vertical up" ); break; case 2: // invert horizontal text msg = _( "Horizontal invert" ); break; case 3: // Vert Orientation Down msg = _( "Vertical down" ); break; default: msg = wxT( "???" ); break; } aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), msg, BROWN ) ); wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) }; int style = 0; if( m_Italic ) style = 1; if( m_Bold ) style += 2; aList.push_back( MSG_PANEL_ITEM( _( "Style" ), textStyle[style], BROWN ) ); // Display electricat type if it is relevant if( (Type() == SCH_GLOBAL_LABEL_T) || (Type() == SCH_HIERARCHICAL_LABEL_T ) || (Type() == SCH_SHEET_PIN_T ) ) { switch( GetShape() ) { case NET_INPUT: msg = _( "Input" ); break; case NET_OUTPUT: msg = _( "Output" ); break; case NET_BIDI: msg = _( "Bidirectional" ); break; case NET_TRISTATE: msg = _( "Tri-State" ); break; case NET_UNSPECIFIED: msg = _( "Passive" ); break; default: msg = wxT( "???" ); break; } aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, BLUE ) ); } // Display text size (X or Y value, with are the same value in Eeschema) msg = StringFromValue( g_UserUnit, m_Size.x, true ); aList.push_back( MSG_PANEL_ITEM( _( "Size" ), msg, RED ) ); }