Loading eeschema/class_sch_cmp_field.cpp +92 −110 Original line number Original line Diff line number Diff line Loading @@ -58,11 +58,13 @@ int SCH_CMP_FIELD::GetPenSize( ) else else pensize = g_DrawDefaultLineThickness; pensize = g_DrawDefaultLineThickness; } } // Clip pen size for small texts: // Clip pen size for small texts: pensize = Clamp_Text_PenSize( pensize, m_Size, m_Bold ); pensize = Clamp_Text_PenSize( pensize, m_Size, m_Bold ); return pensize; return pensize; } } /** /** * Routine de trace des textes type Field du composant. * Routine de trace des textes type Field du composant. * entree: * entree: Loading @@ -73,10 +75,8 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, { { int orient; int orient; EDA_Colors color; EDA_Colors color; wxPoint pos; /* Position des textes */ wxPoint textpos; SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) m_Parent; SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent; GRTextHorizJustifyType hjustify; GRTextVertJustifyType vjustify; int LineWidth = m_Width; int LineWidth = m_Width; if( LineWidth == 0 ) // Use default values for pen size 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 ); 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; orient = m_Orient; hjustify = m_HJustify; vjustify = m_VJustify; if( parentComponent->m_Transform[0][1] ) // Rotation du composant de 90deg 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( orient == TEXT_ORIENT_HORIZ ) if( orient == TEXT_ORIENT_HORIZ ) orient = TEXT_ORIENT_VERT; orient = TEXT_ORIENT_VERT; else else orient = TEXT_ORIENT_HORIZ; 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 ) if( m_FieldId == REFERENCE ) color = ReturnLayerColor( LAYER_REFERENCEPART ); color = ReturnLayerColor( LAYER_REFERENCEPART ); else if( m_FieldId == VALUE ) 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) ) if( !m_AddExtraText || (m_FieldId != REFERENCE) ) { { DrawGraphicText( panel, DC, pos, color, m_Text, DrawGraphicText( panel, DC, textpos, color, m_Text, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, orient, m_Size, hjustify, vjustify, LineWidth, m_Italic, m_Bold ); m_Size, hjustify, vjustify, LineWidth, m_Italic, m_Bold ); } } else else { { Loading @@ -190,17 +143,40 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, char part_id; char part_id; #if defined(KICAD_GOST) #if defined(KICAD_GOST) fulltext.Append( '.' ); fulltext.Append( '.' ); part_id = '1' - 1 + DrawLibItem->m_Multi; part_id = '1' - 1 + parentComponent->m_Multi; #else #else part_id = 'A' - 1 + DrawLibItem->m_Multi; part_id = 'A' - 1 + parentComponent->m_Multi; #endif #endif fulltext.Append( part_id ); fulltext.Append( part_id ); DrawGraphicText( panel, DC, pos, color, fulltext, DrawGraphicText( panel, DC, textpos, color, fulltext, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, orient, m_Size, hjustify, vjustify, LineWidth, m_Italic, m_Size, hjustify, vjustify, LineWidth, m_Italic, m_Bold, false ); 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; m_Mirror = aSource.m_Mirror; } } /** /** * Used if undo / redo command: * Used if undo / redo command: * swap data between this and copyitem * swap data between this and copyitem Loading Loading @@ -270,10 +247,10 @@ EDA_Rect SCH_CMP_FIELD::GetBoundaryBox() const int orient; int orient; int dx, dy, x1, y1, x2, y2; int dx, dy, x1, y1, x2, y2; SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) m_Parent; SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent; orient = m_Orient; orient = m_Orient; wxPoint pos = DrawLibItem->m_Pos; wxPoint pos = parentComponent->m_Pos; x1 = m_Pos.x - pos.x; x1 = m_Pos.x - pos.x; y1 = m_Pos.y - pos.y; y1 = m_Pos.y - pos.y; Loading @@ -282,32 +259,36 @@ EDA_Rect SCH_CMP_FIELD::GetBoundaryBox() const hjustify = m_HJustify; hjustify = m_HJustify; vjustify = m_VJustify; vjustify = m_VJustify; x2 = pos.x + (DrawLibItem->m_Transform[0][0] * x1) x2 = pos.x + (parentComponent->m_Transform[0][0] *x1) + (DrawLibItem->m_Transform[0][1] * y1); + (parentComponent->m_Transform[0][1] *y1); y2 = pos.y + (DrawLibItem->m_Transform[1][0] * x1) y2 = pos.y + (parentComponent->m_Transform[1][0] *x1) + (DrawLibItem->m_Transform[1][1] * y1); + (parentComponent->m_Transform[1][1] *y1); /* If the component orientation is +/- 90 deg, the text orientation must /* Calculate the text orientation, according to the component orientation/mirror */ * be changed */ if( parentComponent->m_Transform[0][1] ) if( DrawLibItem->m_Transform[0][1] ) { { if( orient == TEXT_ORIENT_HORIZ ) if( orient == TEXT_ORIENT_HORIZ ) orient = TEXT_ORIENT_VERT; orient = TEXT_ORIENT_VERT; else else orient = TEXT_ORIENT_HORIZ; 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)*/ /* is it mirrored (for text justify)*/ EXCHG( hjustify, vjustify ); EXCHG( hjustify, vjustify ); if( DrawLibItem->m_Transform[1][0] < 0 ) if( parentComponent->m_Transform[1][0] < 0 ) vjustify = -vjustify; NEGATE( vjustify ); if( DrawLibItem->m_Transform[0][1] > 0 ) if( parentComponent->m_Transform[0][1] > 0 ) hjustify = -hjustify; NEGATE( hjustify ); } } else /* component horizontal: is it mirrored (for text justify)*/ else /* component horizontal: is it mirrored (for text justify)*/ { { if( DrawLibItem->m_Transform[0][0] < 0 ) if( parentComponent->m_Transform[0][0] < 0 ) hjustify = -hjustify; NEGATE( hjustify ); if( DrawLibItem->m_Transform[1][1] > 0 ) if( parentComponent->m_Transform[1][1] > 0 ) vjustify = -vjustify; NEGATE( vjustify ); } } if( orient == TEXT_ORIENT_VERT ) 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 bool SCH_CMP_FIELD::Save( FILE* aFile ) const { { char hjustify = 'C'; char hjustify = 'C'; if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) hjustify = 'L'; hjustify = 'L'; else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) Loading eeschema/plot.cpp +19 −82 Original line number Original line 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 ); SCH_CMP_FIELD* field = DrawLibItem->GetField( FieldNumber ); int orient; EDA_Colors color = UNSPECIFIED_COLOR; EDA_Colors color = UNSPECIFIED_COLOR; color = ReturnLayerColor( field->GetLayer() ); color = ReturnLayerColor( field->GetLayer() ); Loading @@ -98,98 +96,37 @@ static void PlotTextField( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem, if( field->IsVoid() ) if( field->IsVoid() ) return; return; /* Calcul de la position des textes, selon orientation du composant */ /* Calculate the text orientation, according to the component orientation/mirror */ orient = field->m_Orient; int orient = field->m_Orient; GRTextHorizJustifyType hjustify = field->m_HJustify; if( DrawLibItem->m_Transform[0][1] ) // Rotation du composant de 90deg 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] ) { { if( orient == TEXT_ORIENT_HORIZ ) if( orient == TEXT_ORIENT_HORIZ ) orient = TEXT_ORIENT_VERT; orient = TEXT_ORIENT_VERT; else else orient = TEXT_ORIENT_HORIZ; 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: /* Calculate the text justification, according to the component orientation/mirror break; * this is a bit complicated due to cumulative calculations: } * - numerous cases (mirrored or not, rotation) * - the DrawGraphicText function recalculate also H and H vustifications if( DrawLibItem->m_Transform[1][1] > 0 ) * according to the text orienation. switch( vjustify ) * - When a component is mirrored, the text is not mirrored and justifications { * are complicated to calculate case GR_TEXT_VJUSTIFY_BOTTOM: * so the more easily way is to use no justifications ( Centered text ) vjustify = GR_TEXT_VJUSTIFY_TOP; * and use GetBoundaryBox to know the text coordinate considered as centered break; */ EDA_Rect BoundaryBox = field->GetBoundaryBox(); case GR_TEXT_VJUSTIFY_TOP: GRTextHorizJustifyType hjustify = GR_TEXT_HJUSTIFY_CENTER; vjustify = GR_TEXT_VJUSTIFY_BOTTOM; GRTextVertJustifyType vjustify = GR_TEXT_VJUSTIFY_CENTER; break; wxPoint textpos = BoundaryBox.Centre(); default: break; } } int thickness = field->GetPenSize(); int thickness = field->GetPenSize(); if( !IsMulti || (FieldNumber != REFERENCE) ) if( !IsMulti || (FieldNumber != REFERENCE) ) { { plotter->text( textpos, color, field->m_Text, plotter->text( textpos, color, field->m_Text, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, orient, field->m_Size, field->m_Size, hjustify, vjustify, hjustify, vjustify, thickness, field->m_Italic, field->m_Bold ); thickness, field->m_Italic, field->m_Bold ); Loading @@ -208,7 +145,7 @@ static void PlotTextField( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem, #endif #endif Text.Append( unit_id ); Text.Append( unit_id ); plotter->text( textpos, color, Text, plotter->text( textpos, color, Text, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, orient, field->m_Size, hjustify, vjustify, field->m_Size, hjustify, vjustify, thickness, field->m_Italic, field->m_Bold ); thickness, field->m_Italic, field->m_Bold ); } } Loading Loading
eeschema/class_sch_cmp_field.cpp +92 −110 Original line number Original line Diff line number Diff line Loading @@ -58,11 +58,13 @@ int SCH_CMP_FIELD::GetPenSize( ) else else pensize = g_DrawDefaultLineThickness; pensize = g_DrawDefaultLineThickness; } } // Clip pen size for small texts: // Clip pen size for small texts: pensize = Clamp_Text_PenSize( pensize, m_Size, m_Bold ); pensize = Clamp_Text_PenSize( pensize, m_Size, m_Bold ); return pensize; return pensize; } } /** /** * Routine de trace des textes type Field du composant. * Routine de trace des textes type Field du composant. * entree: * entree: Loading @@ -73,10 +75,8 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, { { int orient; int orient; EDA_Colors color; EDA_Colors color; wxPoint pos; /* Position des textes */ wxPoint textpos; SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) m_Parent; SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent; GRTextHorizJustifyType hjustify; GRTextVertJustifyType vjustify; int LineWidth = m_Width; int LineWidth = m_Width; if( LineWidth == 0 ) // Use default values for pen size 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 ); 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; orient = m_Orient; hjustify = m_HJustify; vjustify = m_VJustify; if( parentComponent->m_Transform[0][1] ) // Rotation du composant de 90deg 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( orient == TEXT_ORIENT_HORIZ ) if( orient == TEXT_ORIENT_HORIZ ) orient = TEXT_ORIENT_VERT; orient = TEXT_ORIENT_VERT; else else orient = TEXT_ORIENT_HORIZ; 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 ) if( m_FieldId == REFERENCE ) color = ReturnLayerColor( LAYER_REFERENCEPART ); color = ReturnLayerColor( LAYER_REFERENCEPART ); else if( m_FieldId == VALUE ) 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) ) if( !m_AddExtraText || (m_FieldId != REFERENCE) ) { { DrawGraphicText( panel, DC, pos, color, m_Text, DrawGraphicText( panel, DC, textpos, color, m_Text, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, orient, m_Size, hjustify, vjustify, LineWidth, m_Italic, m_Bold ); m_Size, hjustify, vjustify, LineWidth, m_Italic, m_Bold ); } } else else { { Loading @@ -190,17 +143,40 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, char part_id; char part_id; #if defined(KICAD_GOST) #if defined(KICAD_GOST) fulltext.Append( '.' ); fulltext.Append( '.' ); part_id = '1' - 1 + DrawLibItem->m_Multi; part_id = '1' - 1 + parentComponent->m_Multi; #else #else part_id = 'A' - 1 + DrawLibItem->m_Multi; part_id = 'A' - 1 + parentComponent->m_Multi; #endif #endif fulltext.Append( part_id ); fulltext.Append( part_id ); DrawGraphicText( panel, DC, pos, color, fulltext, DrawGraphicText( panel, DC, textpos, color, fulltext, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, orient, m_Size, hjustify, vjustify, LineWidth, m_Italic, m_Size, hjustify, vjustify, LineWidth, m_Italic, m_Bold, false ); 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; m_Mirror = aSource.m_Mirror; } } /** /** * Used if undo / redo command: * Used if undo / redo command: * swap data between this and copyitem * swap data between this and copyitem Loading Loading @@ -270,10 +247,10 @@ EDA_Rect SCH_CMP_FIELD::GetBoundaryBox() const int orient; int orient; int dx, dy, x1, y1, x2, y2; int dx, dy, x1, y1, x2, y2; SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) m_Parent; SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent; orient = m_Orient; orient = m_Orient; wxPoint pos = DrawLibItem->m_Pos; wxPoint pos = parentComponent->m_Pos; x1 = m_Pos.x - pos.x; x1 = m_Pos.x - pos.x; y1 = m_Pos.y - pos.y; y1 = m_Pos.y - pos.y; Loading @@ -282,32 +259,36 @@ EDA_Rect SCH_CMP_FIELD::GetBoundaryBox() const hjustify = m_HJustify; hjustify = m_HJustify; vjustify = m_VJustify; vjustify = m_VJustify; x2 = pos.x + (DrawLibItem->m_Transform[0][0] * x1) x2 = pos.x + (parentComponent->m_Transform[0][0] *x1) + (DrawLibItem->m_Transform[0][1] * y1); + (parentComponent->m_Transform[0][1] *y1); y2 = pos.y + (DrawLibItem->m_Transform[1][0] * x1) y2 = pos.y + (parentComponent->m_Transform[1][0] *x1) + (DrawLibItem->m_Transform[1][1] * y1); + (parentComponent->m_Transform[1][1] *y1); /* If the component orientation is +/- 90 deg, the text orientation must /* Calculate the text orientation, according to the component orientation/mirror */ * be changed */ if( parentComponent->m_Transform[0][1] ) if( DrawLibItem->m_Transform[0][1] ) { { if( orient == TEXT_ORIENT_HORIZ ) if( orient == TEXT_ORIENT_HORIZ ) orient = TEXT_ORIENT_VERT; orient = TEXT_ORIENT_VERT; else else orient = TEXT_ORIENT_HORIZ; 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)*/ /* is it mirrored (for text justify)*/ EXCHG( hjustify, vjustify ); EXCHG( hjustify, vjustify ); if( DrawLibItem->m_Transform[1][0] < 0 ) if( parentComponent->m_Transform[1][0] < 0 ) vjustify = -vjustify; NEGATE( vjustify ); if( DrawLibItem->m_Transform[0][1] > 0 ) if( parentComponent->m_Transform[0][1] > 0 ) hjustify = -hjustify; NEGATE( hjustify ); } } else /* component horizontal: is it mirrored (for text justify)*/ else /* component horizontal: is it mirrored (for text justify)*/ { { if( DrawLibItem->m_Transform[0][0] < 0 ) if( parentComponent->m_Transform[0][0] < 0 ) hjustify = -hjustify; NEGATE( hjustify ); if( DrawLibItem->m_Transform[1][1] > 0 ) if( parentComponent->m_Transform[1][1] > 0 ) vjustify = -vjustify; NEGATE( vjustify ); } } if( orient == TEXT_ORIENT_VERT ) 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 bool SCH_CMP_FIELD::Save( FILE* aFile ) const { { char hjustify = 'C'; char hjustify = 'C'; if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) hjustify = 'L'; hjustify = 'L'; else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) Loading
eeschema/plot.cpp +19 −82 Original line number Original line 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 ); SCH_CMP_FIELD* field = DrawLibItem->GetField( FieldNumber ); int orient; EDA_Colors color = UNSPECIFIED_COLOR; EDA_Colors color = UNSPECIFIED_COLOR; color = ReturnLayerColor( field->GetLayer() ); color = ReturnLayerColor( field->GetLayer() ); Loading @@ -98,98 +96,37 @@ static void PlotTextField( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem, if( field->IsVoid() ) if( field->IsVoid() ) return; return; /* Calcul de la position des textes, selon orientation du composant */ /* Calculate the text orientation, according to the component orientation/mirror */ orient = field->m_Orient; int orient = field->m_Orient; GRTextHorizJustifyType hjustify = field->m_HJustify; if( DrawLibItem->m_Transform[0][1] ) // Rotation du composant de 90deg 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] ) { { if( orient == TEXT_ORIENT_HORIZ ) if( orient == TEXT_ORIENT_HORIZ ) orient = TEXT_ORIENT_VERT; orient = TEXT_ORIENT_VERT; else else orient = TEXT_ORIENT_HORIZ; 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: /* Calculate the text justification, according to the component orientation/mirror break; * this is a bit complicated due to cumulative calculations: } * - numerous cases (mirrored or not, rotation) * - the DrawGraphicText function recalculate also H and H vustifications if( DrawLibItem->m_Transform[1][1] > 0 ) * according to the text orienation. switch( vjustify ) * - When a component is mirrored, the text is not mirrored and justifications { * are complicated to calculate case GR_TEXT_VJUSTIFY_BOTTOM: * so the more easily way is to use no justifications ( Centered text ) vjustify = GR_TEXT_VJUSTIFY_TOP; * and use GetBoundaryBox to know the text coordinate considered as centered break; */ EDA_Rect BoundaryBox = field->GetBoundaryBox(); case GR_TEXT_VJUSTIFY_TOP: GRTextHorizJustifyType hjustify = GR_TEXT_HJUSTIFY_CENTER; vjustify = GR_TEXT_VJUSTIFY_BOTTOM; GRTextVertJustifyType vjustify = GR_TEXT_VJUSTIFY_CENTER; break; wxPoint textpos = BoundaryBox.Centre(); default: break; } } int thickness = field->GetPenSize(); int thickness = field->GetPenSize(); if( !IsMulti || (FieldNumber != REFERENCE) ) if( !IsMulti || (FieldNumber != REFERENCE) ) { { plotter->text( textpos, color, field->m_Text, plotter->text( textpos, color, field->m_Text, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, orient, field->m_Size, field->m_Size, hjustify, vjustify, hjustify, vjustify, thickness, field->m_Italic, field->m_Bold ); thickness, field->m_Italic, field->m_Bold ); Loading @@ -208,7 +145,7 @@ static void PlotTextField( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem, #endif #endif Text.Append( unit_id ); Text.Append( unit_id ); plotter->text( textpos, color, Text, plotter->text( textpos, color, Text, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, orient, field->m_Size, hjustify, vjustify, field->m_Size, hjustify, vjustify, thickness, field->m_Italic, field->m_Bold ); thickness, field->m_Italic, field->m_Bold ); } } Loading