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.
This commit is contained in:
lifekidyeaa 2008-02-15 23:21:33 +00:00
parent 87f4916afb
commit c7ec524fc7
6 changed files with 30 additions and 13 deletions

View File

@ -62,6 +62,7 @@ static inline int USCALE( us arg, us num, us den )
static int inline ZoomValue( int value_to_zoom ) {
int zoom = GET_ZOOM;
if( !zoom ) return 0;
if( value_to_zoom >= 0 )
return ( value_to_zoom + (zoom >> 1 ) ) / zoom;

View File

@ -353,9 +353,9 @@ bool DrawSheetStruct::Load(WinEDA_SchematicFrame* frame)
//do not need to load the sub-sheets - this has already been done.
}else{
m_s = new SCH_SCREEN(SCHEMATIC_FRAME);
m_s->m_RefCount++;
if(!frame->LoadOneEEFile(m_s, m_FileName))
return false;
m_s->m_RefCount++;
EDA_BaseStruct* bs = m_s->EEDrawList;
while(bs){
if(bs->Type() == DRAW_SHEET_STRUCT_TYPE){

View File

@ -112,6 +112,15 @@ const wxString EDA_SchComponentStruct::GetRef( DrawSheetList* sheet )
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;
}
@ -143,6 +152,8 @@ void EDA_SchComponentStruct::SetRef( DrawSheetList* sheet, wxString ref )
abs(m_Field[REFERENCE].m_Pos.y - m_Pos.y) > 1000)) {
//move it to a reasonable position..
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.
}

View File

@ -201,6 +201,8 @@ EDA_SchComponentStruct* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
if( msg.IsEmpty() )
msg = wxT( "U" );
msg += wxT( "?" );
//update the reference -- just the prefix for now.
DrawLibItem->SetRef(GetSheet(), msg );
/* Init champ Reference */
DrawLibItem->m_Field[REFERENCE].m_Pos.x =

View File

@ -160,12 +160,11 @@ void WinEDA_SchematicFrame::ReCreateMenuBar()
//TODO: Unify the ID names!
wxMenu* placeMenu = new wxMenu;
item = new wxMenuItem(
placeMenu,
ID_COMPONENT_BUTT,
_( "&Component" ),
_( "Place the component" )
);
item = new wxMenuItem(
placeMenu,
ID_COMPONENT_BUTT,
_("&Component"),
_("Place a component") );
item->SetBitmap( add_component_xpm );
placeMenu->Append( item );

View File

@ -159,7 +159,7 @@ void WinEDA_SheetPropertiesFrame::CreateControls()
itemBoxSizer3->Add( itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _(
"Filename:" ), wxDefaultPosition,
"Filename (will be created upon save if it does not already exist):" ), wxDefaultPosition,
wxDefaultSize, 0 );
itemBoxSizer4->Add( itemStaticText5,
0,
@ -294,12 +294,9 @@ void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event )
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 ) )
{
//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 ){
m_CurrentSheet->m_s->m_RefCount--;
if( m_CurrentSheet->m_s->m_RefCount == 0)
@ -308,7 +305,14 @@ void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event )
m_CurrentSheet->m_s = NULL; //so that we reload..
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();