Commit c7ec524f authored by lifekidyeaa's avatar lifekidyeaa

eeschema: fixed:

* crash when creating a sheet that does not yet have a sch file
* when loading schematic file v 1 annotations are applied to all sheets independent of path in hierarchy
* component reference is drawn by default upon placing a new libary comp. 
parent 87f4916a
...@@ -62,6 +62,7 @@ static inline int USCALE( us arg, us num, us den ) ...@@ -62,6 +62,7 @@ static inline int USCALE( us arg, us num, us den )
static int inline ZoomValue( int value_to_zoom ) { static int inline ZoomValue( int value_to_zoom ) {
int zoom = GET_ZOOM; int zoom = GET_ZOOM;
if( !zoom ) return 0;
if( value_to_zoom >= 0 ) if( value_to_zoom >= 0 )
return ( value_to_zoom + (zoom >> 1 ) ) / zoom; return ( value_to_zoom + (zoom >> 1 ) ) / zoom;
......
...@@ -353,9 +353,9 @@ bool DrawSheetStruct::Load(WinEDA_SchematicFrame* frame) ...@@ -353,9 +353,9 @@ bool DrawSheetStruct::Load(WinEDA_SchematicFrame* frame)
//do not need to load the sub-sheets - this has already been done. //do not need to load the sub-sheets - this has already been done.
}else{ }else{
m_s = new SCH_SCREEN(SCHEMATIC_FRAME); m_s = new SCH_SCREEN(SCHEMATIC_FRAME);
m_s->m_RefCount++;
if(!frame->LoadOneEEFile(m_s, m_FileName)) if(!frame->LoadOneEEFile(m_s, m_FileName))
return false; return false;
m_s->m_RefCount++;
EDA_BaseStruct* bs = m_s->EEDrawList; EDA_BaseStruct* bs = m_s->EEDrawList;
while(bs){ while(bs){
if(bs->Type() == DRAW_SHEET_STRUCT_TYPE){ if(bs->Type() == DRAW_SHEET_STRUCT_TYPE){
......
...@@ -112,6 +112,15 @@ const wxString EDA_SchComponentStruct::GetRef( DrawSheetList* sheet ) ...@@ -112,6 +112,15 @@ const wxString EDA_SchComponentStruct::GetRef( DrawSheetList* sheet )
return m_References[i]; return m_References[i];
} }
} }
//if it was not found in m_Paths array, then see if it is in
// m_Field[REFERENCE] -- if so, use this as a default for this path.
// this will happen if we load a version 1 schematic file.
// it will also mean that multiple instances of the same sheet by default
// all have the same component references, but perhaps this is best.
if( !m_Field[REFERENCE].m_Text.IsEmpty() ){
SetRef( sheet, m_Field[REFERENCE].m_Text );
return m_Field[REFERENCE].m_Text;
}
return m_PrefixString; return m_PrefixString;
} }
...@@ -143,6 +152,8 @@ void EDA_SchComponentStruct::SetRef( DrawSheetList* sheet, wxString ref ) ...@@ -143,6 +152,8 @@ void EDA_SchComponentStruct::SetRef( DrawSheetList* sheet, wxString ref )
abs(m_Field[REFERENCE].m_Pos.y - m_Pos.y) > 1000)) { abs(m_Field[REFERENCE].m_Pos.y - m_Pos.y) > 1000)) {
//move it to a reasonable position.. //move it to a reasonable position..
m_Field[REFERENCE].m_Pos = m_Pos; m_Field[REFERENCE].m_Pos = m_Pos;
m_Field[REFERENCE].m_Pos.x += 50; //a slight offset..
m_Field[REFERENCE].m_Pos.y += 50;
} }
m_Field[REFERENCE].m_Text = ref; //for drawing. m_Field[REFERENCE].m_Text = ref; //for drawing.
} }
......
...@@ -201,6 +201,8 @@ EDA_SchComponentStruct* WinEDA_SchematicFrame::Load_Component( wxDC* DC, ...@@ -201,6 +201,8 @@ EDA_SchComponentStruct* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
if( msg.IsEmpty() ) if( msg.IsEmpty() )
msg = wxT( "U" ); msg = wxT( "U" );
msg += wxT( "?" ); msg += wxT( "?" );
//update the reference -- just the prefix for now.
DrawLibItem->SetRef(GetSheet(), msg );
/* Init champ Reference */ /* Init champ Reference */
DrawLibItem->m_Field[REFERENCE].m_Pos.x = DrawLibItem->m_Field[REFERENCE].m_Pos.x =
......
...@@ -160,12 +160,11 @@ void WinEDA_SchematicFrame::ReCreateMenuBar() ...@@ -160,12 +160,11 @@ void WinEDA_SchematicFrame::ReCreateMenuBar()
//TODO: Unify the ID names! //TODO: Unify the ID names!
wxMenu* placeMenu = new wxMenu; wxMenu* placeMenu = new wxMenu;
item = new wxMenuItem( item = new wxMenuItem(
placeMenu, placeMenu,
ID_COMPONENT_BUTT, ID_COMPONENT_BUTT,
_( "&Component" ), _("&Component"),
_( "Place the component" ) _("Place a component") );
);
item->SetBitmap( add_component_xpm ); item->SetBitmap( add_component_xpm );
placeMenu->Append( item ); placeMenu->Append( item );
......
...@@ -159,7 +159,7 @@ void WinEDA_SheetPropertiesFrame::CreateControls() ...@@ -159,7 +159,7 @@ void WinEDA_SheetPropertiesFrame::CreateControls()
itemBoxSizer3->Add( itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); itemBoxSizer3->Add( itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _( wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _(
"Filename:" ), wxDefaultPosition, "Filename (will be created upon save if it does not already exist):" ), wxDefaultPosition,
wxDefaultSize, 0 ); wxDefaultSize, 0 );
itemBoxSizer4->Add( itemStaticText5, itemBoxSizer4->Add( itemStaticText5,
0, 0,
...@@ -294,12 +294,9 @@ void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event ) ...@@ -294,12 +294,9 @@ void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event )
if( wxFileExists( FileName ) )//do we reload the data from the existing file if( wxFileExists( FileName ) )//do we reload the data from the existing file
{ {
msg.Printf( _( "A file named %s exists, load it ?" ), FileName.GetData() ); msg.Printf( _( "A file named %s exists, load it (otherwise overwrite it)?" ), FileName.GetData() );
if( IsOK( this, msg ) ) if( IsOK( this, msg ) )
{ {
//LoadOneSheet clears the EEDrawList,
//we do not need to delete & recreate the SCH_SCREEN obj
m_CurrentSheet->m_FileName = FileName;
if( m_CurrentSheet->m_s ){ if( m_CurrentSheet->m_s ){
m_CurrentSheet->m_s->m_RefCount--; m_CurrentSheet->m_s->m_RefCount--;
if( m_CurrentSheet->m_s->m_RefCount == 0) if( m_CurrentSheet->m_s->m_RefCount == 0)
...@@ -308,7 +305,14 @@ void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event ) ...@@ -308,7 +305,14 @@ void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event )
m_CurrentSheet->m_s = NULL; //so that we reload.. m_CurrentSheet->m_s = NULL; //so that we reload..
m_CurrentSheet->Load(m_Parent); m_CurrentSheet->Load(m_Parent);
} }
} }else{
//just make a new screen if needed.
if( !m_CurrentSheet->m_s ){
m_CurrentSheet->m_s = new SCH_SCREEN(SCHEMATIC_FRAME);
m_CurrentSheet->m_s->m_RefCount++; //be careful with these
m_CurrentSheet->m_s->m_FileName = FileName;
}
}
} }
msg = m_FileNameSize->GetValue(); msg = m_FileNameSize->GetValue();
......
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