Commit a6232e2c authored by Wayne Stambaugh's avatar Wayne Stambaugh

Fix field text position access bug in Eeschema. (fixes lp:1160214)

parent f824c838
...@@ -233,7 +233,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event ...@@ -233,7 +233,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event
// change all field positions from relative to absolute // change all field positions from relative to absolute
for( unsigned i = 0; i<m_FieldsBuf.size(); ++i ) for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
{ {
m_FieldsBuf[i].SetPosition( m_FieldsBuf[i].GetPosition() + m_Cmp->m_Pos ); m_FieldsBuf[i].SetTextPosition( m_FieldsBuf[i].GetTextPosition() + m_Cmp->m_Pos );
} }
// Delete any fields with no name before we copy all of m_FieldsBuf back into the component. // Delete any fields with no name before we copy all of m_FieldsBuf back into the component.
...@@ -458,7 +458,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent ...@@ -458,7 +458,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
m_FieldsBuf.push_back( aComponent->m_Fields[i] ); m_FieldsBuf.push_back( aComponent->m_Fields[i] );
// make the editable field position relative to the component // make the editable field position relative to the component
m_FieldsBuf[i].SetPosition( m_FieldsBuf[i].GetPosition() - m_Cmp->m_Pos ); m_FieldsBuf[i].SetTextPosition( m_FieldsBuf[i].GetTextPosition() - m_Cmp->m_Pos );
} }
// Add template fieldnames: // Add template fieldnames:
...@@ -491,7 +491,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent ...@@ -491,7 +491,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
fld = *schField; fld = *schField;
// make the editable field position relative to the component // make the editable field position relative to the component
fld.SetPosition( fld.GetPosition() - m_Cmp->m_Pos ); fld.SetTextPosition( fld.GetTextPosition() - m_Cmp->m_Pos );
} }
m_FieldsBuf.push_back( fld ); m_FieldsBuf.push_back( fld );
...@@ -510,7 +510,8 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent ...@@ -510,7 +510,8 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
m_FieldsBuf.push_back( *cmp ); m_FieldsBuf.push_back( *cmp );
// make the editable field position relative to the component // make the editable field position relative to the component
m_FieldsBuf[newNdx].SetPosition( m_FieldsBuf[newNdx].GetPosition() - m_Cmp->m_Pos ); m_FieldsBuf[newNdx].SetTextPosition( m_FieldsBuf[newNdx].GetTextPosition() -
m_Cmp->m_Pos );
} }
} }
...@@ -644,7 +645,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel() ...@@ -644,7 +645,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetSize().x ) ); textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetSize().x ) );
wxPoint coord = field.GetPosition(); wxPoint coord = field.GetTextPosition();
wxPoint zero = -m_Cmp->m_Pos; // relative zero wxPoint zero = -m_Cmp->m_Pos; // relative zero
// If the field value is empty and the position is at relative zero, we // If the field value is empty and the position is at relative zero, we
...@@ -655,10 +656,10 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel() ...@@ -655,10 +656,10 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
{ {
rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetOrientation() == TEXT_ORIENT_VERT ); rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetOrientation() == TEXT_ORIENT_VERT );
coord.x = m_FieldsBuf[REFERENCE].GetPosition().x coord.x = m_FieldsBuf[REFERENCE].GetTextPosition().x
+ ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100; + ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100;
coord.y = m_FieldsBuf[REFERENCE].GetPosition().y coord.y = m_FieldsBuf[REFERENCE].GetTextPosition().y
+ ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100; + ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100;
// coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT. // coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT.
...@@ -844,11 +845,11 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event ) ...@@ -844,11 +845,11 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
// Perhaps the FOOTPRINT field should also be considered, // Perhaps the FOOTPRINT field should also be considered,
// but for most of components it is not set in library // but for most of components it is not set in library
LIB_FIELD& refField = entry->GetReferenceField(); LIB_FIELD& refField = entry->GetReferenceField();
m_Cmp->GetField( REFERENCE )->SetPosition( refField.GetPosition() + m_Cmp->m_Pos ); m_Cmp->GetField( REFERENCE )->SetTextPosition( refField.GetTextPosition() + m_Cmp->m_Pos );
m_Cmp->GetField( REFERENCE )->ImportValues( refField ); m_Cmp->GetField( REFERENCE )->ImportValues( refField );
LIB_FIELD& valField = entry->GetValueField(); LIB_FIELD& valField = entry->GetValueField();
m_Cmp->GetField( VALUE )->SetPosition( valField.GetPosition() + m_Cmp->m_Pos ); m_Cmp->GetField( VALUE )->SetTextPosition( valField.GetTextPosition() + m_Cmp->m_Pos );
m_Cmp->GetField( VALUE )->ImportValues( valField ); m_Cmp->GetField( VALUE )->ImportValues( valField );
m_Cmp->SetOrientation( CMP_NORMAL ); m_Cmp->SetOrientation( CMP_NORMAL );
......
...@@ -661,7 +661,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel() ...@@ -661,7 +661,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetSize().x ) ); textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetSize().x ) );
wxPoint coord = field.GetPosition(); wxPoint coord = field.GetTextPosition();
wxPoint zero; wxPoint zero;
// If the field value is empty and the position is at relative zero, we set the // If the field value is empty and the position is at relative zero, we set the
...@@ -672,8 +672,10 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel() ...@@ -672,8 +672,10 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
{ {
rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetOrientation() == TEXT_ORIENT_VERT ); rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetOrientation() == TEXT_ORIENT_VERT );
coord.x = m_FieldsBuf[REFERENCE].GetPosition().x + (fieldNdx - MANDATORY_FIELDS + 1) * 100; coord.x = m_FieldsBuf[REFERENCE].GetTextPosition().x +
coord.y = m_FieldsBuf[REFERENCE].GetPosition().y + (fieldNdx - MANDATORY_FIELDS + 1) * 100; (fieldNdx - MANDATORY_FIELDS + 1) * 100;
coord.y = m_FieldsBuf[REFERENCE].GetTextPosition().y +
(fieldNdx - MANDATORY_FIELDS + 1) * 100;
// coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT. // coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT.
// That is ok, we basically don't want all the new empty fields on // That is ok, we basically don't want all the new empty fields on
...@@ -761,7 +763,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField() ...@@ -761,7 +763,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
// and the screen axis is top to bottom: we must change the y coord sign for editing // and the screen axis is top to bottom: we must change the y coord sign for editing
NEGATE( pos.y ); NEGATE( pos.y );
field.SetPosition( pos ); field.SetTextPosition( pos );
return true; return true;
} }
...@@ -157,7 +157,7 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_COMPONENT& libComponent, SCH_SHEET_PATH* sheet ...@@ -157,7 +157,7 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_COMPONENT& libComponent, SCH_SHEET_PATH* sheet
schField = AddField( fld ); schField = AddField( fld );
} }
schField->SetPosition( m_Pos + it->GetPosition() ); schField->SetTextPosition( m_Pos + it->GetTextPosition() );
schField->ImportValues( *it ); schField->ImportValues( *it );
...@@ -490,11 +490,11 @@ void SCH_COMPONENT::SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref ) ...@@ -490,11 +490,11 @@ void SCH_COMPONENT::SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref )
SCH_FIELD* rf = GetField( REFERENCE ); SCH_FIELD* rf = GetField( REFERENCE );
if( rf->GetText().IsEmpty() if( rf->GetText().IsEmpty()
|| ( abs( rf->GetPosition().x - m_Pos.x ) + || ( abs( rf->GetTextPosition().x - m_Pos.x ) +
abs( rf->GetPosition().y - m_Pos.y ) > 10000 ) ) abs( rf->GetTextPosition().y - m_Pos.y ) > 10000 ) )
{ {
// move it to a reasonable position // move it to a reasonable position
rf->SetPosition( m_Pos + wxPoint( 50, 50 ) ); rf->SetTextPosition( m_Pos + wxPoint( 50, 50 ) );
} }
rf->SetText( ref ); // for drawing. rf->SetText( ref ); // for drawing.
...@@ -1206,7 +1206,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg ) ...@@ -1206,7 +1206,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
for( int i = 0; i<GetFieldCount(); i++ ) for( int i = 0; i<GetFieldCount(); i++ )
{ {
if( GetField( i )->GetText().IsEmpty() ) if( GetField( i )->GetText().IsEmpty() )
GetField( i )->SetPosition( m_Pos ); GetField( i )->SetTextPosition( m_Pos );
} }
} }
else if( line[0] == 'A' && line[1] == 'R' ) else if( line[0] == 'A' && line[1] == 'R' )
...@@ -1511,9 +1511,9 @@ void SCH_COMPONENT::MirrorY( int aYaxis_position ) ...@@ -1511,9 +1511,9 @@ void SCH_COMPONENT::MirrorY( int aYaxis_position )
for( int ii = 0; ii < GetFieldCount(); ii++ ) for( int ii = 0; ii < GetFieldCount(); ii++ )
{ {
// Move the fields to the new position because the component itself has moved. // Move the fields to the new position because the component itself has moved.
wxPoint pos = GetField( ii )->GetPosition(); wxPoint pos = GetField( ii )->GetTextPosition();
pos.x -= dx; pos.x -= dx;
GetField( ii )->SetPosition( pos ); GetField( ii )->SetTextPosition( pos );
} }
} }
...@@ -1531,9 +1531,9 @@ void SCH_COMPONENT::MirrorX( int aXaxis_position ) ...@@ -1531,9 +1531,9 @@ void SCH_COMPONENT::MirrorX( int aXaxis_position )
for( int ii = 0; ii < GetFieldCount(); ii++ ) for( int ii = 0; ii < GetFieldCount(); ii++ )
{ {
// Move the fields to the new position because the component itself has moved. // Move the fields to the new position because the component itself has moved.
wxPoint pos = GetField( ii )->GetPosition(); wxPoint pos = GetField( ii )->GetTextPosition();
pos.y -= dy; pos.y -= dy;
GetField( ii )->SetPosition( pos ); GetField( ii )->SetTextPosition( pos );
} }
} }
...@@ -1550,10 +1550,10 @@ void SCH_COMPONENT::Rotate( wxPoint aPosition ) ...@@ -1550,10 +1550,10 @@ void SCH_COMPONENT::Rotate( wxPoint aPosition )
for( int ii = 0; ii < GetFieldCount(); ii++ ) for( int ii = 0; ii < GetFieldCount(); ii++ )
{ {
// Move the fields to the new position because the component itself has moved. // Move the fields to the new position because the component itself has moved.
wxPoint pos = GetField( ii )->GetPosition(); wxPoint pos = GetField( ii )->GetTextPosition();
pos.x -= prev.x - m_Pos.x; pos.x -= prev.x - m_Pos.x;
pos.y -= prev.y - m_Pos.y; pos.y -= prev.y - m_Pos.y;
GetField( ii )->SetPosition( pos ); GetField( ii )->SetTextPosition( pos );
} }
} }
......
...@@ -1084,10 +1084,10 @@ bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxStri ...@@ -1084,10 +1084,10 @@ bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxStri
*/ */
SCH_FIELD * fpfield = component->GetField( FOOTPRINT ); SCH_FIELD * fpfield = component->GetField( FOOTPRINT );
if( fpfield->GetText().IsEmpty() if( fpfield->GetText().IsEmpty()
&& ( fpfield->GetPosition() == component->GetPosition() ) ) && ( fpfield->GetTextPosition() == component->GetPosition() ) )
{ {
fpfield->SetOrientation( component->GetField( VALUE )->GetOrientation() ); fpfield->SetOrientation( component->GetField( VALUE )->GetOrientation() );
fpfield->SetPosition( component->GetField( VALUE )->GetPosition() ); fpfield->SetTextPosition( component->GetField( VALUE )->GetTextPosition() );
fpfield->SetSize( component->GetField( VALUE )->GetSize() ); fpfield->SetSize( component->GetField( VALUE )->GetSize() );
if( fpfield->GetOrientation() == 0 ) if( fpfield->GetOrientation() == 0 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment