Loading eeschema/class_sch_cmp_field.cpp +92 −110 Original line number Diff line number Diff line Loading @@ -58,11 +58,13 @@ int SCH_CMP_FIELD::GetPenSize( ) else pensize = g_DrawDefaultLineThickness; } // Clip pen size for small texts: pensize = Clamp_Text_PenSize( pensize, m_Size, m_Bold ); return pensize; } /** * Routine de trace des textes type Field du composant. * entree: Loading @@ -73,10 +75,8 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, { int orient; EDA_Colors color; wxPoint pos; /* Position des textes */ SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) m_Parent; GRTextHorizJustifyType hjustify; GRTextVertJustifyType vjustify; wxPoint textpos; SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent; int LineWidth = m_Width; if( LineWidth == 0 ) // Use default values for pen size Loading @@ -96,79 +96,31 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, GRSetDrawMode( DC, DrawMode ); /* Calcul de la position des textes, selon orientation du composant */ /* Calculate the text orientation, according to the component orientation/mirror */ orient = m_Orient; hjustify = m_HJustify; vjustify = m_VJustify; pos = m_Pos - DrawLibItem->m_Pos; pos = DrawLibItem->GetScreenCoord( pos ); pos += DrawLibItem->m_Pos; /* Y a t-il rotation (pour l'orientation, la justification)*/ if( DrawLibItem->m_Transform[0][1] ) // Rotation du composant de 90deg if( parentComponent->m_Transform[0][1] ) // Rotation du composant de 90deg { if( orient == TEXT_ORIENT_HORIZ ) orient = TEXT_ORIENT_VERT; else orient = TEXT_ORIENT_HORIZ; /* Y a t-il rotation, miroir (pour les justifications)*/ GRTextHorizJustifyType tmp = hjustify; hjustify = (GRTextHorizJustifyType) vjustify; vjustify = (GRTextVertJustifyType) tmp; if( DrawLibItem->m_Transform[1][0] < 0 ) switch ( vjustify ) { case GR_TEXT_VJUSTIFY_BOTTOM: vjustify = GR_TEXT_VJUSTIFY_TOP; break; case GR_TEXT_VJUSTIFY_TOP: vjustify = GR_TEXT_VJUSTIFY_BOTTOM; break; default: break; } if( DrawLibItem->m_Transform[1][0] > 0 ) switch ( hjustify ) { case GR_TEXT_HJUSTIFY_LEFT: hjustify = GR_TEXT_HJUSTIFY_RIGHT; break; case GR_TEXT_HJUSTIFY_RIGHT: hjustify = GR_TEXT_HJUSTIFY_LEFT; break; default: break; } } else { /* Texte horizontal: Y a t-il miroir (pour les justifications)*/ if( DrawLibItem->m_Transform[0][0] < 0 ) switch ( hjustify ) { case GR_TEXT_HJUSTIFY_LEFT: hjustify = GR_TEXT_HJUSTIFY_RIGHT; break; case GR_TEXT_HJUSTIFY_RIGHT: hjustify = GR_TEXT_HJUSTIFY_LEFT; break; default: break; } if( DrawLibItem->m_Transform[1][1] > 0 ) switch ( vjustify ) { case GR_TEXT_VJUSTIFY_BOTTOM: vjustify = GR_TEXT_VJUSTIFY_TOP; break; case GR_TEXT_VJUSTIFY_TOP: vjustify = GR_TEXT_VJUSTIFY_BOTTOM; break; default: break; } } /* 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 vustifications * according to the text orienation. * - 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 = GetBoundaryBox(); GRTextHorizJustifyType hjustify = GR_TEXT_HJUSTIFY_CENTER; GRTextVertJustifyType vjustify = GR_TEXT_VJUSTIFY_CENTER; textpos = BoundaryBox.Centre(); if( m_FieldId == REFERENCE ) color = ReturnLayerColor( LAYER_REFERENCEPART ); else if( m_FieldId == VALUE ) Loading @@ -178,9 +130,10 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, if( !m_AddExtraText || (m_FieldId != REFERENCE) ) { DrawGraphicText( panel, DC, pos, color, m_Text, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, m_Size, hjustify, vjustify, LineWidth, m_Italic, m_Bold ); DrawGraphicText( panel, DC, textpos, color, m_Text, orient, m_Size, hjustify, vjustify, LineWidth, m_Italic, m_Bold ); } else { Loading @@ -190,17 +143,40 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, char part_id; #if defined(KICAD_GOST) fulltext.Append( '.' ); part_id = '1' - 1 + DrawLibItem->m_Multi; part_id = '1' - 1 + parentComponent->m_Multi; #else part_id = 'A' - 1 + DrawLibItem->m_Multi; part_id = 'A' - 1 + parentComponent->m_Multi; #endif fulltext.Append( part_id ); DrawGraphicText( panel, DC, pos, color, fulltext, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, m_Size, hjustify, vjustify, LineWidth, m_Italic, DrawGraphicText( panel, DC, textpos, color, fulltext, orient, m_Size, hjustify, vjustify, LineWidth, m_Italic, m_Bold, false ); } /* Enable this to draw the bounding box around the text field to validate * the bounding box calculations. */ #if 0 // Draw boundary box: int x1 = BoundaryBox.GetX(); int y1 = BoundaryBox.GetY(); int x2 = BoundaryBox.GetRight(); int y2 = BoundaryBox.GetBottom(); GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN ); // Draw the text anchor point /* Calculate the text position, according to the component orientation/mirror */ textpos = m_Pos - parentComponent->m_Pos; textpos = parentComponent->GetScreenCoord( textpos ); textpos += parentComponent->m_Pos; x1 = textpos.x; y1 = textpos.y; int len = 10; GRLine( &panel->m_ClipBox, DC, x1 - len, y1, x1 + len, y1, 0, BLUE ); GRLine( &panel->m_ClipBox, DC, x1, y1 - len, x1, y1 +len, 0, BLUE ); #endif } Loading @@ -224,6 +200,7 @@ void SCH_CMP_FIELD::ImportValues( const LIB_FIELD& aSource ) m_Mirror = aSource.m_Mirror; } /** * Used if undo / redo command: * swap data between this and copyitem Loading Loading @@ -270,10 +247,10 @@ EDA_Rect SCH_CMP_FIELD::GetBoundaryBox() const int orient; int dx, dy, x1, y1, x2, y2; SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) m_Parent; SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent; orient = m_Orient; wxPoint pos = DrawLibItem->m_Pos; wxPoint pos = parentComponent->m_Pos; x1 = m_Pos.x - pos.x; y1 = m_Pos.y - pos.y; Loading @@ -282,32 +259,36 @@ EDA_Rect SCH_CMP_FIELD::GetBoundaryBox() const hjustify = m_HJustify; vjustify = m_VJustify; x2 = pos.x + (DrawLibItem->m_Transform[0][0] * x1) + (DrawLibItem->m_Transform[0][1] * y1); y2 = pos.y + (DrawLibItem->m_Transform[1][0] * x1) + (DrawLibItem->m_Transform[1][1] * y1); x2 = pos.x + (parentComponent->m_Transform[0][0] *x1) + (parentComponent->m_Transform[0][1] *y1); y2 = pos.y + (parentComponent->m_Transform[1][0] *x1) + (parentComponent->m_Transform[1][1] *y1); /* If the component orientation is +/- 90 deg, the text orientation must * be changed */ if( DrawLibItem->m_Transform[0][1] ) /* Calculate the text orientation, according to the component orientation/mirror */ if( parentComponent->m_Transform[0][1] ) { if( orient == TEXT_ORIENT_HORIZ ) orient = TEXT_ORIENT_VERT; else orient = TEXT_ORIENT_HORIZ; } /* Calculate the text justification, according to the component orientation/mirror */ if( parentComponent->m_Transform[0][1] ) { /* is it mirrored (for text justify)*/ EXCHG( hjustify, vjustify ); if( DrawLibItem->m_Transform[1][0] < 0 ) vjustify = -vjustify; if( DrawLibItem->m_Transform[0][1] > 0 ) hjustify = -hjustify; if( parentComponent->m_Transform[1][0] < 0 ) NEGATE( vjustify ); if( parentComponent->m_Transform[0][1] > 0 ) NEGATE( hjustify ); } else /* component horizontal: is it mirrored (for text justify)*/ { if( DrawLibItem->m_Transform[0][0] < 0 ) hjustify = -hjustify; if( DrawLibItem->m_Transform[1][1] > 0 ) vjustify = -vjustify; if( parentComponent->m_Transform[0][0] < 0 ) NEGATE( hjustify ); if( parentComponent->m_Transform[1][1] > 0 ) NEGATE( vjustify ); } if( orient == TEXT_ORIENT_VERT ) Loading Loading @@ -359,6 +340,7 @@ EDA_Rect SCH_CMP_FIELD::GetBoundaryBox() const bool SCH_CMP_FIELD::Save( FILE* aFile ) const { char hjustify = 'C'; if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) hjustify = 'L'; else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) Loading eeschema/plot.cpp +19 −82 Original line number Diff line number Diff line Loading @@ -85,9 +85,7 @@ static void PlotTextField( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem, */ { wxPoint textpos; /* Position des textes */ SCH_CMP_FIELD* field = DrawLibItem->GetField( FieldNumber ); int orient; EDA_Colors color = UNSPECIFIED_COLOR; color = ReturnLayerColor( field->GetLayer() ); Loading @@ -98,98 +96,37 @@ static void PlotTextField( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem, if( field->IsVoid() ) return; /* Calcul de la position des textes, selon orientation du composant */ orient = field->m_Orient; GRTextHorizJustifyType hjustify = field->m_HJustify; GRTextVertJustifyType vjustify = field->m_VJustify; textpos = field->m_Pos - DrawLibItem->m_Pos; // textpos is the text position relative to the component anchor textpos = TransformCoordinate( DrawLibItem->m_Transform, textpos ) + DrawLibItem->m_Pos; /* Y a t-il rotation */ if( DrawLibItem->m_Transform[0][1] ) /* Calculate the text orientation, according to the component orientation/mirror */ int orient = field->m_Orient; if( DrawLibItem->m_Transform[0][1] ) // Rotation du composant de 90deg { if( orient == TEXT_ORIENT_HORIZ ) orient = TEXT_ORIENT_VERT; else orient = TEXT_ORIENT_HORIZ; /* Y a t-il rotation, miroir (pour les justifications)*/ GRTextHorizJustifyType tmp = hjustify; hjustify = (GRTextHorizJustifyType) vjustify; vjustify = (GRTextVertJustifyType) tmp; if( DrawLibItem->m_Transform[1][0] < 0 ) switch( vjustify ) { case GR_TEXT_VJUSTIFY_BOTTOM: vjustify = GR_TEXT_VJUSTIFY_TOP; break; case GR_TEXT_VJUSTIFY_TOP: vjustify = GR_TEXT_VJUSTIFY_BOTTOM; break; default: break; } if( DrawLibItem->m_Transform[1][0] > 0 ) switch( hjustify ) { case GR_TEXT_HJUSTIFY_LEFT: hjustify = GR_TEXT_HJUSTIFY_RIGHT; break; case GR_TEXT_HJUSTIFY_RIGHT: hjustify = GR_TEXT_HJUSTIFY_LEFT; break; default: break; } } else { /* Texte horizontal: Y a t-il miroir (pour les justifications)*/ if( DrawLibItem->m_Transform[0][0] < 0 ) switch( hjustify ) { case GR_TEXT_HJUSTIFY_LEFT: hjustify = GR_TEXT_HJUSTIFY_RIGHT; break; case GR_TEXT_HJUSTIFY_RIGHT: hjustify = GR_TEXT_HJUSTIFY_LEFT; break; default: break; } if( DrawLibItem->m_Transform[1][1] > 0 ) switch( vjustify ) { case GR_TEXT_VJUSTIFY_BOTTOM: vjustify = GR_TEXT_VJUSTIFY_TOP; break; case GR_TEXT_VJUSTIFY_TOP: vjustify = GR_TEXT_VJUSTIFY_BOTTOM; break; default: break; } } /* 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 vustifications * according to the text orienation. * - 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 = field->GetBoundaryBox(); GRTextHorizJustifyType hjustify = GR_TEXT_HJUSTIFY_CENTER; GRTextVertJustifyType vjustify = GR_TEXT_VJUSTIFY_CENTER; wxPoint textpos = BoundaryBox.Centre(); int thickness = field->GetPenSize(); if( !IsMulti || (FieldNumber != REFERENCE) ) { plotter->text( textpos, color, field->m_Text, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, orient, field->m_Size, hjustify, vjustify, thickness, field->m_Italic, field->m_Bold ); Loading @@ -208,7 +145,7 @@ static void PlotTextField( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem, #endif Text.Append( unit_id ); plotter->text( textpos, color, Text, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, orient, field->m_Size, hjustify, vjustify, thickness, field->m_Italic, field->m_Bold ); } Loading Loading
eeschema/class_sch_cmp_field.cpp +92 −110 Original line number Diff line number Diff line Loading @@ -58,11 +58,13 @@ int SCH_CMP_FIELD::GetPenSize( ) else pensize = g_DrawDefaultLineThickness; } // Clip pen size for small texts: pensize = Clamp_Text_PenSize( pensize, m_Size, m_Bold ); return pensize; } /** * Routine de trace des textes type Field du composant. * entree: Loading @@ -73,10 +75,8 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, { int orient; EDA_Colors color; wxPoint pos; /* Position des textes */ SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) m_Parent; GRTextHorizJustifyType hjustify; GRTextVertJustifyType vjustify; wxPoint textpos; SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent; int LineWidth = m_Width; if( LineWidth == 0 ) // Use default values for pen size Loading @@ -96,79 +96,31 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, GRSetDrawMode( DC, DrawMode ); /* Calcul de la position des textes, selon orientation du composant */ /* Calculate the text orientation, according to the component orientation/mirror */ orient = m_Orient; hjustify = m_HJustify; vjustify = m_VJustify; pos = m_Pos - DrawLibItem->m_Pos; pos = DrawLibItem->GetScreenCoord( pos ); pos += DrawLibItem->m_Pos; /* Y a t-il rotation (pour l'orientation, la justification)*/ if( DrawLibItem->m_Transform[0][1] ) // Rotation du composant de 90deg if( parentComponent->m_Transform[0][1] ) // Rotation du composant de 90deg { if( orient == TEXT_ORIENT_HORIZ ) orient = TEXT_ORIENT_VERT; else orient = TEXT_ORIENT_HORIZ; /* Y a t-il rotation, miroir (pour les justifications)*/ GRTextHorizJustifyType tmp = hjustify; hjustify = (GRTextHorizJustifyType) vjustify; vjustify = (GRTextVertJustifyType) tmp; if( DrawLibItem->m_Transform[1][0] < 0 ) switch ( vjustify ) { case GR_TEXT_VJUSTIFY_BOTTOM: vjustify = GR_TEXT_VJUSTIFY_TOP; break; case GR_TEXT_VJUSTIFY_TOP: vjustify = GR_TEXT_VJUSTIFY_BOTTOM; break; default: break; } if( DrawLibItem->m_Transform[1][0] > 0 ) switch ( hjustify ) { case GR_TEXT_HJUSTIFY_LEFT: hjustify = GR_TEXT_HJUSTIFY_RIGHT; break; case GR_TEXT_HJUSTIFY_RIGHT: hjustify = GR_TEXT_HJUSTIFY_LEFT; break; default: break; } } else { /* Texte horizontal: Y a t-il miroir (pour les justifications)*/ if( DrawLibItem->m_Transform[0][0] < 0 ) switch ( hjustify ) { case GR_TEXT_HJUSTIFY_LEFT: hjustify = GR_TEXT_HJUSTIFY_RIGHT; break; case GR_TEXT_HJUSTIFY_RIGHT: hjustify = GR_TEXT_HJUSTIFY_LEFT; break; default: break; } if( DrawLibItem->m_Transform[1][1] > 0 ) switch ( vjustify ) { case GR_TEXT_VJUSTIFY_BOTTOM: vjustify = GR_TEXT_VJUSTIFY_TOP; break; case GR_TEXT_VJUSTIFY_TOP: vjustify = GR_TEXT_VJUSTIFY_BOTTOM; break; default: break; } } /* 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 vustifications * according to the text orienation. * - 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 = GetBoundaryBox(); GRTextHorizJustifyType hjustify = GR_TEXT_HJUSTIFY_CENTER; GRTextVertJustifyType vjustify = GR_TEXT_VJUSTIFY_CENTER; textpos = BoundaryBox.Centre(); if( m_FieldId == REFERENCE ) color = ReturnLayerColor( LAYER_REFERENCEPART ); else if( m_FieldId == VALUE ) Loading @@ -178,9 +130,10 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, if( !m_AddExtraText || (m_FieldId != REFERENCE) ) { DrawGraphicText( panel, DC, pos, color, m_Text, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, m_Size, hjustify, vjustify, LineWidth, m_Italic, m_Bold ); DrawGraphicText( panel, DC, textpos, color, m_Text, orient, m_Size, hjustify, vjustify, LineWidth, m_Italic, m_Bold ); } else { Loading @@ -190,17 +143,40 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, char part_id; #if defined(KICAD_GOST) fulltext.Append( '.' ); part_id = '1' - 1 + DrawLibItem->m_Multi; part_id = '1' - 1 + parentComponent->m_Multi; #else part_id = 'A' - 1 + DrawLibItem->m_Multi; part_id = 'A' - 1 + parentComponent->m_Multi; #endif fulltext.Append( part_id ); DrawGraphicText( panel, DC, pos, color, fulltext, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, m_Size, hjustify, vjustify, LineWidth, m_Italic, DrawGraphicText( panel, DC, textpos, color, fulltext, orient, m_Size, hjustify, vjustify, LineWidth, m_Italic, m_Bold, false ); } /* Enable this to draw the bounding box around the text field to validate * the bounding box calculations. */ #if 0 // Draw boundary box: int x1 = BoundaryBox.GetX(); int y1 = BoundaryBox.GetY(); int x2 = BoundaryBox.GetRight(); int y2 = BoundaryBox.GetBottom(); GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN ); // Draw the text anchor point /* Calculate the text position, according to the component orientation/mirror */ textpos = m_Pos - parentComponent->m_Pos; textpos = parentComponent->GetScreenCoord( textpos ); textpos += parentComponent->m_Pos; x1 = textpos.x; y1 = textpos.y; int len = 10; GRLine( &panel->m_ClipBox, DC, x1 - len, y1, x1 + len, y1, 0, BLUE ); GRLine( &panel->m_ClipBox, DC, x1, y1 - len, x1, y1 +len, 0, BLUE ); #endif } Loading @@ -224,6 +200,7 @@ void SCH_CMP_FIELD::ImportValues( const LIB_FIELD& aSource ) m_Mirror = aSource.m_Mirror; } /** * Used if undo / redo command: * swap data between this and copyitem Loading Loading @@ -270,10 +247,10 @@ EDA_Rect SCH_CMP_FIELD::GetBoundaryBox() const int orient; int dx, dy, x1, y1, x2, y2; SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) m_Parent; SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent; orient = m_Orient; wxPoint pos = DrawLibItem->m_Pos; wxPoint pos = parentComponent->m_Pos; x1 = m_Pos.x - pos.x; y1 = m_Pos.y - pos.y; Loading @@ -282,32 +259,36 @@ EDA_Rect SCH_CMP_FIELD::GetBoundaryBox() const hjustify = m_HJustify; vjustify = m_VJustify; x2 = pos.x + (DrawLibItem->m_Transform[0][0] * x1) + (DrawLibItem->m_Transform[0][1] * y1); y2 = pos.y + (DrawLibItem->m_Transform[1][0] * x1) + (DrawLibItem->m_Transform[1][1] * y1); x2 = pos.x + (parentComponent->m_Transform[0][0] *x1) + (parentComponent->m_Transform[0][1] *y1); y2 = pos.y + (parentComponent->m_Transform[1][0] *x1) + (parentComponent->m_Transform[1][1] *y1); /* If the component orientation is +/- 90 deg, the text orientation must * be changed */ if( DrawLibItem->m_Transform[0][1] ) /* Calculate the text orientation, according to the component orientation/mirror */ if( parentComponent->m_Transform[0][1] ) { if( orient == TEXT_ORIENT_HORIZ ) orient = TEXT_ORIENT_VERT; else orient = TEXT_ORIENT_HORIZ; } /* Calculate the text justification, according to the component orientation/mirror */ if( parentComponent->m_Transform[0][1] ) { /* is it mirrored (for text justify)*/ EXCHG( hjustify, vjustify ); if( DrawLibItem->m_Transform[1][0] < 0 ) vjustify = -vjustify; if( DrawLibItem->m_Transform[0][1] > 0 ) hjustify = -hjustify; if( parentComponent->m_Transform[1][0] < 0 ) NEGATE( vjustify ); if( parentComponent->m_Transform[0][1] > 0 ) NEGATE( hjustify ); } else /* component horizontal: is it mirrored (for text justify)*/ { if( DrawLibItem->m_Transform[0][0] < 0 ) hjustify = -hjustify; if( DrawLibItem->m_Transform[1][1] > 0 ) vjustify = -vjustify; if( parentComponent->m_Transform[0][0] < 0 ) NEGATE( hjustify ); if( parentComponent->m_Transform[1][1] > 0 ) NEGATE( vjustify ); } if( orient == TEXT_ORIENT_VERT ) Loading Loading @@ -359,6 +340,7 @@ EDA_Rect SCH_CMP_FIELD::GetBoundaryBox() const bool SCH_CMP_FIELD::Save( FILE* aFile ) const { char hjustify = 'C'; if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) hjustify = 'L'; else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) Loading
eeschema/plot.cpp +19 −82 Original line number Diff line number Diff line Loading @@ -85,9 +85,7 @@ static void PlotTextField( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem, */ { wxPoint textpos; /* Position des textes */ SCH_CMP_FIELD* field = DrawLibItem->GetField( FieldNumber ); int orient; EDA_Colors color = UNSPECIFIED_COLOR; color = ReturnLayerColor( field->GetLayer() ); Loading @@ -98,98 +96,37 @@ static void PlotTextField( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem, if( field->IsVoid() ) return; /* Calcul de la position des textes, selon orientation du composant */ orient = field->m_Orient; GRTextHorizJustifyType hjustify = field->m_HJustify; GRTextVertJustifyType vjustify = field->m_VJustify; textpos = field->m_Pos - DrawLibItem->m_Pos; // textpos is the text position relative to the component anchor textpos = TransformCoordinate( DrawLibItem->m_Transform, textpos ) + DrawLibItem->m_Pos; /* Y a t-il rotation */ if( DrawLibItem->m_Transform[0][1] ) /* Calculate the text orientation, according to the component orientation/mirror */ int orient = field->m_Orient; if( DrawLibItem->m_Transform[0][1] ) // Rotation du composant de 90deg { if( orient == TEXT_ORIENT_HORIZ ) orient = TEXT_ORIENT_VERT; else orient = TEXT_ORIENT_HORIZ; /* Y a t-il rotation, miroir (pour les justifications)*/ GRTextHorizJustifyType tmp = hjustify; hjustify = (GRTextHorizJustifyType) vjustify; vjustify = (GRTextVertJustifyType) tmp; if( DrawLibItem->m_Transform[1][0] < 0 ) switch( vjustify ) { case GR_TEXT_VJUSTIFY_BOTTOM: vjustify = GR_TEXT_VJUSTIFY_TOP; break; case GR_TEXT_VJUSTIFY_TOP: vjustify = GR_TEXT_VJUSTIFY_BOTTOM; break; default: break; } if( DrawLibItem->m_Transform[1][0] > 0 ) switch( hjustify ) { case GR_TEXT_HJUSTIFY_LEFT: hjustify = GR_TEXT_HJUSTIFY_RIGHT; break; case GR_TEXT_HJUSTIFY_RIGHT: hjustify = GR_TEXT_HJUSTIFY_LEFT; break; default: break; } } else { /* Texte horizontal: Y a t-il miroir (pour les justifications)*/ if( DrawLibItem->m_Transform[0][0] < 0 ) switch( hjustify ) { case GR_TEXT_HJUSTIFY_LEFT: hjustify = GR_TEXT_HJUSTIFY_RIGHT; break; case GR_TEXT_HJUSTIFY_RIGHT: hjustify = GR_TEXT_HJUSTIFY_LEFT; break; default: break; } if( DrawLibItem->m_Transform[1][1] > 0 ) switch( vjustify ) { case GR_TEXT_VJUSTIFY_BOTTOM: vjustify = GR_TEXT_VJUSTIFY_TOP; break; case GR_TEXT_VJUSTIFY_TOP: vjustify = GR_TEXT_VJUSTIFY_BOTTOM; break; default: break; } } /* 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 vustifications * according to the text orienation. * - 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 = field->GetBoundaryBox(); GRTextHorizJustifyType hjustify = GR_TEXT_HJUSTIFY_CENTER; GRTextVertJustifyType vjustify = GR_TEXT_VJUSTIFY_CENTER; wxPoint textpos = BoundaryBox.Centre(); int thickness = field->GetPenSize(); if( !IsMulti || (FieldNumber != REFERENCE) ) { plotter->text( textpos, color, field->m_Text, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, orient, field->m_Size, hjustify, vjustify, thickness, field->m_Italic, field->m_Bold ); Loading @@ -208,7 +145,7 @@ static void PlotTextField( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem, #endif Text.Append( unit_id ); plotter->text( textpos, color, Text, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, orient, field->m_Size, hjustify, vjustify, thickness, field->m_Italic, field->m_Bold ); } Loading