Loading change_log.txt +17 −0 Original line number Original line Diff line number Diff line Loading @@ -5,6 +5,23 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with email address. email address. 2008-Feb-26 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> ================================================================================ +eeschema changed in class DrawSheetStruct m_s member name to m_AssociatedScreen some others minor problems solved. some files "uncrustified" Major problem in undo/redo when a sheet is deleted not yet solved Only for a complex hierarchy, could lost data. When a sheet is deleted by block delete. it is put in undo list. It is really deleted after 10 changes (when the undo list is full). At this time, the associated data is also deleted. If an other (not deleted) sheet shares the same data, this data is lost. Need work to solve this problem and keep the undo/redo feature. 2008-Feb-25 UPDATE Wayne Stambaugh <stambaughw{at}verizon{dot}net> 2008-Feb-25 UPDATE Wayne Stambaugh <stambaughw{at}verizon{dot}net> ================================================================================ ================================================================================ +eeschema +eeschema Loading eeschema/annotate.cpp +5 −7 Original line number Original line Diff line number Diff line Loading @@ -34,9 +34,6 @@ void ReAnnotatePowerSymbolsOnly( void ) /* Build the screen list (screen, not sheet) */ /* Build the screen list (screen, not sheet) */ EDA_SheetList SheetList( NULL ); EDA_SheetList SheetList( NULL ); /* Update the screen number, sheet count and date */ //ScreenList.UpdateScreenNumberAndDate(); DrawSheetList* sheet; DrawSheetList* sheet; int CmpNumber = 1; int CmpNumber = 1; Loading Loading @@ -161,7 +158,7 @@ void DeleteAnnotation( WinEDA_SchematicFrame* parent, bool annotateSchematic ) sheet->DeleteAnnotation( annotateSchematic ); sheet->DeleteAnnotation( annotateSchematic ); g_RootSheet->m_s->SetModify(); g_RootSheet->m_AssociatedScreen->SetModify(); parent->DrawPanel->Refresh( true ); parent->DrawPanel->Refresh( true ); } } Loading Loading @@ -192,10 +189,11 @@ void AnnotateComponents( WinEDA_SchematicFrame* parent, /* Build the sheet list */ /* Build the sheet list */ EDA_SheetList SheetList( g_RootSheet ); EDA_SheetList SheetList( g_RootSheet ); /* Update the sheet number */ /* Update the screen number, sheet count and date */ ii = 0; SheetList.UpdateSheetNumberAndDate(); /* First pass: Component counting */ /* First pass: Component counting */ ii = 0; sheet = parent->GetSheet(); sheet = parent->GetSheet(); if( annotateSchematic ) if( annotateSchematic ) { { Loading Loading @@ -595,7 +593,7 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool oneSheetOnly ) /* build the screen list */ /* build the screen list */ EDA_SheetList SheetList( NULL ); EDA_SheetList SheetList( NULL ); g_RootSheet->m_s->SetModify(); g_RootSheet->m_AssociatedScreen->SetModify(); ii = 0; ii = 0; /* first pass : count composents */ /* first pass : count composents */ Loading eeschema/annotate_dialog.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -258,7 +258,7 @@ void WinEDA_AnnotateFrame::OnClear( wxCommandEvent& event ) message += _( "\n\nThis operation will clear the existing annotation " \ message += _( "\n\nThis operation will clear the existing annotation " \ "and cannot be undone." ); "and cannot be undone." ); response = wxMessageBox( message, _( "" ), response = wxMessageBox( message, wxT( "" ), wxICON_EXCLAMATION | wxOK | wxCANCEL ); wxICON_EXCLAMATION | wxOK | wxCANCEL ); if (response == wxCANCEL) if (response == wxCANCEL) return; return; Loading @@ -283,7 +283,7 @@ void WinEDA_AnnotateFrame::OnApply( wxCommandEvent& event ) message += _( "\n\nThis operation will change the current annotation and " \ message += _( "\n\nThis operation will change the current annotation and " \ "cannot be undone." ); "cannot be undone." ); response = wxMessageBox( message, _( "" ), response = wxMessageBox( message, wxT( "" ), wxICON_EXCLAMATION | wxOK | wxCANCEL ); wxICON_EXCLAMATION | wxOK | wxCANCEL ); if (response == wxCANCEL) if (response == wxCANCEL) return; return; Loading eeschema/block.cpp +4 −4 Original line number Original line Diff line number Diff line Loading @@ -832,12 +832,12 @@ static EDA_BaseStruct* CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREE case DRAW_SHEET_STRUCT_TYPE: case DRAW_SHEET_STRUCT_TYPE: { { //DuplicateStruct calls GenCopy, which should handle //DuplicateStruct calls GenCopy, which should handle //m_s and m_sRefCount properly. //m_AssociatedScreen and m_sRefCount properly. DrawSheetStruct* sheet = (DrawSheetStruct*) Struct; DrawSheetStruct* sheet = (DrawSheetStruct*) Struct; sheet->m_TimeStamp = GetTimeStamp(); sheet->m_TimeStamp = GetTimeStamp(); //sheet->m_s->m_UndoList = NULL; //sheet->m_AssociatedScreen->m_UndoList = NULL; //sheet->m_s->m_RedoList = NULL; //sheet->m_AssociatedScreen->m_RedoList = NULL; //keep m_s pointer & associated. //keep m_AssociatedScreen pointer & associated. //sheet->m_Son = NULL; m_son is involved in undo and redo. //sheet->m_Son = NULL; m_son is involved in undo and redo. break; break; } } Loading eeschema/class_drawsheet.cpp +395 −277 Original line number Original line Diff line number Diff line Loading @@ -43,9 +43,12 @@ DrawSheetStruct::DrawSheetStruct( const wxPoint& pos ) : m_Layer = LAYER_SHEET; m_Layer = LAYER_SHEET; m_Pos = pos; m_Pos = pos; m_SheetNameSize = m_FileNameSize = 60; m_SheetNameSize = m_FileNameSize = 60; m_s = NULL; m_AssociatedScreen = NULL; m_SheetName = wxT( "Root" ); m_SheetName = wxT( "Root" ); m_FileName = wxT( " " ); m_FileName = wxT( " " ); m_SheetNumber = 1; m_NumberOfSheets = 1; } } Loading @@ -54,7 +57,9 @@ DrawSheetStruct::~DrawSheetStruct() /**************************************/ /**************************************/ { { DrawSheetLabelStruct* label = m_Label, * next_label; DrawSheetLabelStruct* label = m_Label, * next_label; while( label ){ while( label ) { next_label = (DrawSheetLabelStruct*) label->Pnext; next_label = (DrawSheetLabelStruct*) label->Pnext; delete label; delete label; label = next_label; label = next_label; Loading @@ -62,13 +67,15 @@ DrawSheetStruct::~DrawSheetStruct() //also, look at the associated sheet & its reference count //also, look at the associated sheet & its reference count //perhaps it should be deleted also. //perhaps it should be deleted also. if(m_s){ if( m_AssociatedScreen ) m_s->m_RefCount--; { if(m_s->m_RefCount == 0) m_AssociatedScreen->m_RefCount--; delete m_s; if( m_AssociatedScreen->m_RefCount == 0 ) delete m_AssociatedScreen; } } } } /***********************************************/ /***********************************************/ DrawSheetStruct* DrawSheetStruct::GenCopy() DrawSheetStruct* DrawSheetStruct::GenCopy() /***********************************************/ /***********************************************/ Loading Loading @@ -109,9 +116,9 @@ DrawSheetStruct* DrawSheetStruct::GenCopy() } } /* don't copy screen data - just reference it. */ /* don't copy screen data - just reference it. */ newitem->m_s = m_s; newitem->m_AssociatedScreen = m_AssociatedScreen; if(m_s) if( m_AssociatedScreen ) m_s->m_RefCount++; m_AssociatedScreen->m_RefCount++; return newitem; return newitem; } } Loading @@ -120,6 +127,7 @@ DrawSheetStruct* DrawSheetStruct::GenCopy() /**********************************************************/ /**********************************************************/ void DrawSheetStruct::SwapData( DrawSheetStruct* copyitem ) void DrawSheetStruct::SwapData( DrawSheetStruct* copyitem ) /**********************************************************/ /**********************************************************/ /* Used if undo / redo command: /* Used if undo / redo command: * swap data between this and copyitem * swap data between this and copyitem */ */ Loading @@ -132,6 +140,8 @@ void DrawSheetStruct::SwapData( DrawSheetStruct* copyitem ) EXCHG( m_Label, copyitem->m_Label ); EXCHG( m_Label, copyitem->m_Label ); EXCHG( m_NbLabel, copyitem->m_NbLabel ); EXCHG( m_NbLabel, copyitem->m_NbLabel ); } } /****************************************************************/ /****************************************************************/ void DrawSheetStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) void DrawSheetStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) /****************************************************************/ /****************************************************************/ Loading @@ -152,9 +162,12 @@ void DrawSheetStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) EDA_BaseStruct::Place( frame, DC ); //puts it on the EEDrawList. EDA_BaseStruct::Place( frame, DC ); //puts it on the EEDrawList. } } /********************************************************************/ /********************************************************************/ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* frame, wxDC* DC ) void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* frame, wxDC* DC ) /********************************************************************/ /********************************************************************/ /* Delete pinsheets which are not corresponding to a hierarchal label /* Delete pinsheets which are not corresponding to a hierarchal label * if DC != NULL, redraw Sheet * if DC != NULL, redraw Sheet */ */ Loading @@ -169,7 +182,7 @@ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* frame, wxDC* DC ) { { /* Search Hlabel corresponding to this Pinsheet */ /* Search Hlabel corresponding to this Pinsheet */ EDA_BaseStruct* DrawStruct = m_s->EEDrawList; EDA_BaseStruct* DrawStruct = m_AssociatedScreen->EEDrawList; DrawHierLabelStruct* HLabel = NULL; DrawHierLabelStruct* HLabel = NULL; for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) { { Loading @@ -191,6 +204,7 @@ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* frame, wxDC* DC ) } } } } /**************************************************************************************/ /**************************************************************************************/ void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int DrawMode, int Color ) int DrawMode, int Color ) Loading Loading @@ -247,43 +261,57 @@ void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& of } } } } /**************************************************************************************/ /**************************************************************************************/ void DrawSheetStruct::DeleteAnnotation( bool recurse ) void DrawSheetStruct::DeleteAnnotation( bool recurse ) /**************************************************************************************/ /**************************************************************************************/ { { if(recurse && m_s){ if( recurse && m_AssociatedScreen ) EDA_BaseStruct* strct = m_s->EEDrawList; { for(; strct; strct = strct->Pnext){ EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList; if(strct->Type() == DRAW_SHEET_STRUCT_TYPE){ for( ; strct; strct = strct->Pnext ) { if( strct->Type() == DRAW_SHEET_STRUCT_TYPE ) { DrawSheetStruct* sheet = (DrawSheetStruct*) strct; DrawSheetStruct* sheet = (DrawSheetStruct*) strct; sheet->DeleteAnnotation( recurse ); sheet->DeleteAnnotation( recurse ); } } } } } } EDA_BaseStruct* comp = m_s->EEDrawList; EDA_BaseStruct* comp = m_AssociatedScreen->EEDrawList; for( ; comp ; comp = comp->Pnext ){ for( ; comp; comp = comp->Pnext ) if(comp->Type() == DRAW_LIB_ITEM_STRUCT_TYPE ){ { if( comp->Type() == DRAW_LIB_ITEM_STRUCT_TYPE ) { ( (EDA_SchComponentStruct*) comp )->ClearAnnotation(); ( (EDA_SchComponentStruct*) comp )->ClearAnnotation(); } } } } } } /*******************************************************************/ /*******************************************************************/ int DrawSheetStruct::ComponentCount() int DrawSheetStruct::ComponentCount() /*******************************************************************/ /*******************************************************************/ { { //count our own components, without the power components. //count our own components, without the power components. /* Routine retournant le nombre de composants dans le schema, /* Routine retournant le nombre de composants dans le schema, * powers non comprises */ * powers non comprises */ int n = 0; int n = 0; if(m_s){ if( m_AssociatedScreen ) { EDA_BaseStruct* bs; EDA_BaseStruct* bs; for( bs = m_s->EEDrawList; bs != NULL; bs = bs->Pnext ){ for( bs = m_AssociatedScreen->EEDrawList; bs != NULL; bs = bs->Pnext ) if( bs->Type() == DRAW_LIB_ITEM_STRUCT_TYPE ){ { if( bs->Type() == DRAW_LIB_ITEM_STRUCT_TYPE ) { DrawPartStruct* Cmp = (DrawPartStruct*) bs; DrawPartStruct* Cmp = (DrawPartStruct*) bs; if( Cmp->m_Field[VALUE].m_Text.GetChar( 0 ) != '#' ) if( Cmp->m_Field[VALUE].m_Text.GetChar( 0 ) != '#' ) n++; n++; } } if(bs->Type() == DRAW_SHEET_STRUCT_TYPE){ if( bs->Type() == DRAW_SHEET_STRUCT_TYPE ) { DrawSheetStruct* sheet = (DrawSheetStruct*) bs; DrawSheetStruct* sheet = (DrawSheetStruct*) bs; n += sheet->ComponentCount(); n += sheet->ComponentCount(); } } Loading @@ -291,18 +319,24 @@ int DrawSheetStruct::ComponentCount( ) } } return n; return n; } } /*******************************************************************************/ /*******************************************************************************/ bool DrawSheetStruct::SearchHierarchy( wxString filename, SCH_SCREEN** screen ) bool DrawSheetStruct::SearchHierarchy( wxString filename, SCH_SCREEN** screen ) /*******************************************************************************/ /*******************************************************************************/ { { //search the existing hierarchy for an instance of screen "FileName". //search the existing hierarchy for an instance of screen "FileName". if(m_s){ if( m_AssociatedScreen ) EDA_BaseStruct* strct = m_s->EEDrawList; { while(strct){ EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList; if(strct->Type() == DRAW_SHEET_STRUCT_TYPE){ while( strct ) { if( strct->Type() == DRAW_SHEET_STRUCT_TYPE ) { DrawSheetStruct* ss = (DrawSheetStruct*) strct; DrawSheetStruct* ss = (DrawSheetStruct*) strct; if(ss->m_s && ss->m_s->m_FileName.CmpNoCase(filename) == 0){ if( ss->m_AssociatedScreen && ss->m_AssociatedScreen->m_FileName.CmpNoCase( filename ) == 0 ) *screen = ss->m_s; { *screen = ss->m_AssociatedScreen; return true; return true; } } if( ss->SearchHierarchy( filename, screen ) ) if( ss->SearchHierarchy( filename, screen ) ) Loading @@ -313,6 +347,8 @@ bool DrawSheetStruct::SearchHierarchy(wxString filename, SCH_SCREEN **screen) } } return false; return false; } } /*******************************************************************************/ /*******************************************************************************/ bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* screen, DrawSheetList* list ) bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* screen, DrawSheetList* list ) /*******************************************************************************/ /*******************************************************************************/ Loading @@ -322,43 +358,55 @@ bool DrawSheetStruct::LocatePathOfScreen(SCH_SCREEN *screen, DrawSheetList* list //no other references to its m_s otherwise there would be loops //no other references to its m_s otherwise there would be loops //in the heirarchy. //in the heirarchy. //search the existing hierarchy for an instance of screen "FileName". //search the existing hierarchy for an instance of screen "FileName". if(m_s){ if( m_AssociatedScreen ) { list->Push( this ); list->Push( this ); if(m_s == screen) if( m_AssociatedScreen == screen ) return true; return true; EDA_BaseStruct* strct = m_s->EEDrawList; EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList; while(strct){ while( strct ) if(strct->Type() == DRAW_SHEET_STRUCT_TYPE){ { if( strct->Type() == DRAW_SHEET_STRUCT_TYPE ) { DrawSheetStruct* ss = (DrawSheetStruct*) strct; DrawSheetStruct* ss = (DrawSheetStruct*) strct; if( ss->LocatePathOfScreen( screen, list ) ) if( ss->LocatePathOfScreen( screen, list ) ) return true; return true; } } strct = strct->Pnext; strct = strct->Pnext; } } list->Pop(); list->Pop(); } } return false; return false; } } /*******************************************************************************/ /*******************************************************************************/ bool DrawSheetStruct::Load( WinEDA_SchematicFrame* frame ) bool DrawSheetStruct::Load( WinEDA_SchematicFrame* frame ) /*******************************************************************************/ /*******************************************************************************/ { { if(!m_s){ if( !m_AssociatedScreen ) { SCH_SCREEN* screen = NULL; SCH_SCREEN* screen = NULL; g_RootSheet->SearchHierarchy( m_FileName, &screen ); g_RootSheet->SearchHierarchy( m_FileName, &screen ); if(screen){ if( screen ) m_s = screen; { m_s->m_RefCount++; m_AssociatedScreen = screen; m_AssociatedScreen->m_RefCount++; //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{ } m_s = new SCH_SCREEN(SCHEMATIC_FRAME); else m_s->m_RefCount++; { if(!frame->LoadOneEEFile(m_s, m_FileName)) m_AssociatedScreen = new SCH_SCREEN( SCHEMATIC_FRAME ); m_AssociatedScreen->m_RefCount++; if( !frame->LoadOneEEFile( m_AssociatedScreen, m_FileName ) ) return false; return false; EDA_BaseStruct* bs = m_s->EEDrawList; EDA_BaseStruct* bs = m_AssociatedScreen->EEDrawList; while(bs){ while( bs ) if(bs->Type() == DRAW_SHEET_STRUCT_TYPE){ { if( bs->Type() == DRAW_SHEET_STRUCT_TYPE ) { DrawSheetStruct* ss = (DrawSheetStruct*) bs; DrawSheetStruct* ss = (DrawSheetStruct*) bs; if( !ss->Load( frame ) ) if( !ss->Load( frame ) ) return false; return false; Loading @@ -369,15 +417,21 @@ bool DrawSheetStruct::Load(WinEDA_SchematicFrame* frame) } } return true; return true; } } /*******************************************************************************/ /*******************************************************************************/ int DrawSheetStruct::CountSheets() int DrawSheetStruct::CountSheets() /*******************************************************************************/ /*******************************************************************************/ { { int count = 1; //1 = this!! int count = 1; //1 = this!! if(m_s){ EDA_BaseStruct* strct = m_s->EEDrawList; if( m_AssociatedScreen ) for(; strct; strct = strct->Pnext){ { if(strct->Type() == DRAW_SHEET_STRUCT_TYPE){ EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList; for( ; strct; strct = strct->Pnext ) { if( strct->Type() == DRAW_SHEET_STRUCT_TYPE ) { DrawSheetStruct* ss = (DrawSheetStruct*) strct; DrawSheetStruct* ss = (DrawSheetStruct*) strct; count += ss->CountSheets(); count += ss->CountSheets(); } } Loading @@ -394,8 +448,8 @@ int DrawSheetStruct::CountSheets() /*******************************************************************/ /*******************************************************************/ DrawSheetLabelStruct::DrawSheetLabelStruct( DrawSheetStruct* parent, DrawSheetLabelStruct::DrawSheetLabelStruct( DrawSheetStruct* parent, const wxPoint& pos, const wxString& text ) : const wxPoint& pos, const wxString& text ) : EDA_BaseStruct( DRAW_SHEETLABEL_STRUCT_TYPE ), EDA_BaseStruct( DRAW_SHEETLABEL_STRUCT_TYPE ) EDA_TextStruct( text ) , EDA_TextStruct( text ) /*******************************************************************/ /*******************************************************************/ { { m_Layer = LAYER_SHEETLABEL; m_Layer = LAYER_SHEETLABEL; Loading Loading @@ -511,115 +565,179 @@ void DrawSheetLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoin GRPoly( &panel->m_ClipBox, DC, NbSegm, coord, FillShape, LineWidth, txtcolor, txtcolor ); /* Poly Non rempli */ GRPoly( &panel->m_ClipBox, DC, NbSegm, coord, FillShape, LineWidth, txtcolor, txtcolor ); /* Poly Non rempli */ } } /**********************************************/ /**********************************************/ /* class to handle a series of sheets *********/ /* class to handle a series of sheets *********/ /* a 'path' so to speak.. *********************/ /* a 'path' so to speak.. *********************/ /**********************************************/ /**********************************************/ DrawSheetList::DrawSheetList(){ DrawSheetList::DrawSheetList() { for( int i = 0; i<DSLSZ; i++ ) for( int i = 0; i<DSLSZ; i++ ) m_sheets[i] = NULL; m_sheets[i] = NULL; m_numSheets = 0; m_numSheets = 0; } } int DrawSheetList::Cmp(DrawSheetList& d){ int DrawSheetList::Cmp( DrawSheetList& d ) { if( m_numSheets > d.m_numSheets ) if( m_numSheets > d.m_numSheets ) return 1; return 1; if( m_numSheets < d.m_numSheets ) if( m_numSheets < d.m_numSheets ) return -1; return -1; //otherwise, same number of sheets. //otherwise, same number of sheets. for(int i=0; i<m_numSheets; i++){ for( int i = 0; i<m_numSheets; i++ ) { if( m_sheets[i]->m_TimeStamp > d.m_sheets[i]->m_TimeStamp ) if( m_sheets[i]->m_TimeStamp > d.m_sheets[i]->m_TimeStamp ) return 1; return 1; if( m_sheets[i]->m_TimeStamp < d.m_sheets[i]->m_TimeStamp ) if( m_sheets[i]->m_TimeStamp < d.m_sheets[i]->m_TimeStamp ) return -1; return -1; } } return 0; return 0; } } DrawSheetStruct* DrawSheetList::Last(){ DrawSheetStruct* DrawSheetList::Last() { if( m_numSheets ) if( m_numSheets ) return m_sheets[m_numSheets - 1]; return m_sheets[m_numSheets - 1]; return NULL; return NULL; } } SCH_SCREEN* DrawSheetList::LastScreen(){ SCH_SCREEN* DrawSheetList::LastScreen() { if( m_numSheets ) if( m_numSheets ) return m_sheets[m_numSheets-1]->m_s; return m_sheets[m_numSheets - 1]->m_AssociatedScreen; return NULL; return NULL; } } EDA_BaseStruct* DrawSheetList::LastDrawList(){ if(m_numSheets && m_sheets[m_numSheets-1]->m_s) return m_sheets[m_numSheets-1]->m_s->EEDrawList; EDA_BaseStruct* DrawSheetList::LastDrawList() { if( m_numSheets && m_sheets[m_numSheets - 1]->m_AssociatedScreen ) return m_sheets[m_numSheets - 1]->m_AssociatedScreen->EEDrawList; return NULL; return NULL; } } void DrawSheetList::Push(DrawSheetStruct* sheet){ if(m_numSheets < DSLSZ){ void DrawSheetList::Push( DrawSheetStruct* sheet ) { if( m_numSheets < DSLSZ ) { m_sheets[m_numSheets] = sheet; m_sheets[m_numSheets] = sheet; m_numSheets++; m_numSheets++; } } } } DrawSheetStruct* DrawSheetList::Pop(){ if(m_numSheets > 0){ DrawSheetStruct* DrawSheetList::Pop() { if( m_numSheets > 0 ) { m_numSheets--; m_numSheets--; return m_sheets[m_numSheets]; return m_sheets[m_numSheets]; } } return NULL; return NULL; } } wxString DrawSheetList::Path(){ wxString DrawSheetList::Path() { wxString s, t; wxString s, t; s = wxT( "/" ); s = wxT( "/" ); //start at 1 to avoid the root sheet, //start at 1 to avoid the root sheet, //which does not need to be added to the path //which does not need to be added to the path //it's timestamp changes anyway. //it's timestamp changes anyway. for(int i=1; i< m_numSheets; i++){ for( int i = 1; i< m_numSheets; i++ ) { t.Printf( _( "%8.8lX/" ), m_sheets[i]->m_TimeStamp ); t.Printf( _( "%8.8lX/" ), m_sheets[i]->m_TimeStamp ); s = s + t; s = s + t; } } return s; return s; } } wxString DrawSheetList::PathHumanReadable(){ wxString DrawSheetList::PathHumanReadable() { wxString s, t; wxString s, t; s = wxT( "/" ); s = wxT( "/" ); //start at 1 to avoid the root sheet, as above. //start at 1 to avoid the root sheet, as above. for(int i=1; i< m_numSheets; i++){ for( int i = 1; i< m_numSheets; i++ ) { s = s + m_sheets[i]->m_SheetName + wxT( "/" ); s = s + m_sheets[i]->m_SheetName + wxT( "/" ); } } return s; return s; } } void DrawSheetList::UpdateAllScreenReferences(){ void DrawSheetList::UpdateAllScreenReferences() { EDA_BaseStruct* t = LastDrawList(); EDA_BaseStruct* t = LastDrawList(); while(t){ if(t->Type() == DRAW_LIB_ITEM_STRUCT_TYPE){ while( t ) { if( t->Type() == DRAW_LIB_ITEM_STRUCT_TYPE ) { EDA_SchComponentStruct* d = (EDA_SchComponentStruct*) t; EDA_SchComponentStruct* d = (EDA_SchComponentStruct*) t; d->m_Field[REFERENCE].m_Text = d->GetRef( this ); d->m_Field[REFERENCE].m_Text = d->GetRef( this ); } } t = t->Pnext; t = t->Pnext; } } printf( "on sheet: %s \n", CONV_TO_UTF8( PathHumanReadable() ) ); printf( "on sheet: %s \n", CONV_TO_UTF8( PathHumanReadable() ) ); } } bool DrawSheetList::operator= (const DrawSheetList& d1){ bool DrawSheetList::operator=( const DrawSheetList& d1 ) { m_numSheets = d1.m_numSheets; m_numSheets = d1.m_numSheets; int i; int i; for(i=0; i<m_numSheets; i++){ for( i = 0; i<m_numSheets; i++ ) { m_sheets[i] = d1.m_sheets[i]; m_sheets[i] = d1.m_sheets[i]; } } for(; i<DSLSZ; i++){ for( ; i<DSLSZ; i++ ) { m_sheets[i] = 0; m_sheets[i] = 0; } } return true; return true; } } bool DrawSheetList::operator==(const DrawSheetList &d1){ bool DrawSheetList::operator==( const DrawSheetList& d1 ) { if( m_numSheets != d1.m_numSheets ) if( m_numSheets != d1.m_numSheets ) return false; return false; for(int i=0; i<m_numSheets; i++){ for( int i = 0; i<m_numSheets; i++ ) { if( m_sheets[i] != d1.m_sheets[i] ) if( m_sheets[i] != d1.m_sheets[i] ) return false; return false; } } return true; return true; } } bool DrawSheetList::operator!=(const DrawSheetList &d1){ bool DrawSheetList::operator!=( const DrawSheetList& d1 ) { if( m_numSheets != d1.m_numSheets ) if( m_numSheets != d1.m_numSheets ) return true; return true; for(int i=0; i<m_numSheets; i++){ for( int i = 0; i<m_numSheets; i++ ) { if( m_sheets[i] != d1.m_sheets[i] ) if( m_sheets[i] != d1.m_sheets[i] ) return true; return true; } } return false; return false; } } Loading
change_log.txt +17 −0 Original line number Original line Diff line number Diff line Loading @@ -5,6 +5,23 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with email address. email address. 2008-Feb-26 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> ================================================================================ +eeschema changed in class DrawSheetStruct m_s member name to m_AssociatedScreen some others minor problems solved. some files "uncrustified" Major problem in undo/redo when a sheet is deleted not yet solved Only for a complex hierarchy, could lost data. When a sheet is deleted by block delete. it is put in undo list. It is really deleted after 10 changes (when the undo list is full). At this time, the associated data is also deleted. If an other (not deleted) sheet shares the same data, this data is lost. Need work to solve this problem and keep the undo/redo feature. 2008-Feb-25 UPDATE Wayne Stambaugh <stambaughw{at}verizon{dot}net> 2008-Feb-25 UPDATE Wayne Stambaugh <stambaughw{at}verizon{dot}net> ================================================================================ ================================================================================ +eeschema +eeschema Loading
eeschema/annotate.cpp +5 −7 Original line number Original line Diff line number Diff line Loading @@ -34,9 +34,6 @@ void ReAnnotatePowerSymbolsOnly( void ) /* Build the screen list (screen, not sheet) */ /* Build the screen list (screen, not sheet) */ EDA_SheetList SheetList( NULL ); EDA_SheetList SheetList( NULL ); /* Update the screen number, sheet count and date */ //ScreenList.UpdateScreenNumberAndDate(); DrawSheetList* sheet; DrawSheetList* sheet; int CmpNumber = 1; int CmpNumber = 1; Loading Loading @@ -161,7 +158,7 @@ void DeleteAnnotation( WinEDA_SchematicFrame* parent, bool annotateSchematic ) sheet->DeleteAnnotation( annotateSchematic ); sheet->DeleteAnnotation( annotateSchematic ); g_RootSheet->m_s->SetModify(); g_RootSheet->m_AssociatedScreen->SetModify(); parent->DrawPanel->Refresh( true ); parent->DrawPanel->Refresh( true ); } } Loading Loading @@ -192,10 +189,11 @@ void AnnotateComponents( WinEDA_SchematicFrame* parent, /* Build the sheet list */ /* Build the sheet list */ EDA_SheetList SheetList( g_RootSheet ); EDA_SheetList SheetList( g_RootSheet ); /* Update the sheet number */ /* Update the screen number, sheet count and date */ ii = 0; SheetList.UpdateSheetNumberAndDate(); /* First pass: Component counting */ /* First pass: Component counting */ ii = 0; sheet = parent->GetSheet(); sheet = parent->GetSheet(); if( annotateSchematic ) if( annotateSchematic ) { { Loading Loading @@ -595,7 +593,7 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool oneSheetOnly ) /* build the screen list */ /* build the screen list */ EDA_SheetList SheetList( NULL ); EDA_SheetList SheetList( NULL ); g_RootSheet->m_s->SetModify(); g_RootSheet->m_AssociatedScreen->SetModify(); ii = 0; ii = 0; /* first pass : count composents */ /* first pass : count composents */ Loading
eeschema/annotate_dialog.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -258,7 +258,7 @@ void WinEDA_AnnotateFrame::OnClear( wxCommandEvent& event ) message += _( "\n\nThis operation will clear the existing annotation " \ message += _( "\n\nThis operation will clear the existing annotation " \ "and cannot be undone." ); "and cannot be undone." ); response = wxMessageBox( message, _( "" ), response = wxMessageBox( message, wxT( "" ), wxICON_EXCLAMATION | wxOK | wxCANCEL ); wxICON_EXCLAMATION | wxOK | wxCANCEL ); if (response == wxCANCEL) if (response == wxCANCEL) return; return; Loading @@ -283,7 +283,7 @@ void WinEDA_AnnotateFrame::OnApply( wxCommandEvent& event ) message += _( "\n\nThis operation will change the current annotation and " \ message += _( "\n\nThis operation will change the current annotation and " \ "cannot be undone." ); "cannot be undone." ); response = wxMessageBox( message, _( "" ), response = wxMessageBox( message, wxT( "" ), wxICON_EXCLAMATION | wxOK | wxCANCEL ); wxICON_EXCLAMATION | wxOK | wxCANCEL ); if (response == wxCANCEL) if (response == wxCANCEL) return; return; Loading
eeschema/block.cpp +4 −4 Original line number Original line Diff line number Diff line Loading @@ -832,12 +832,12 @@ static EDA_BaseStruct* CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREE case DRAW_SHEET_STRUCT_TYPE: case DRAW_SHEET_STRUCT_TYPE: { { //DuplicateStruct calls GenCopy, which should handle //DuplicateStruct calls GenCopy, which should handle //m_s and m_sRefCount properly. //m_AssociatedScreen and m_sRefCount properly. DrawSheetStruct* sheet = (DrawSheetStruct*) Struct; DrawSheetStruct* sheet = (DrawSheetStruct*) Struct; sheet->m_TimeStamp = GetTimeStamp(); sheet->m_TimeStamp = GetTimeStamp(); //sheet->m_s->m_UndoList = NULL; //sheet->m_AssociatedScreen->m_UndoList = NULL; //sheet->m_s->m_RedoList = NULL; //sheet->m_AssociatedScreen->m_RedoList = NULL; //keep m_s pointer & associated. //keep m_AssociatedScreen pointer & associated. //sheet->m_Son = NULL; m_son is involved in undo and redo. //sheet->m_Son = NULL; m_son is involved in undo and redo. break; break; } } Loading
eeschema/class_drawsheet.cpp +395 −277 Original line number Original line Diff line number Diff line Loading @@ -43,9 +43,12 @@ DrawSheetStruct::DrawSheetStruct( const wxPoint& pos ) : m_Layer = LAYER_SHEET; m_Layer = LAYER_SHEET; m_Pos = pos; m_Pos = pos; m_SheetNameSize = m_FileNameSize = 60; m_SheetNameSize = m_FileNameSize = 60; m_s = NULL; m_AssociatedScreen = NULL; m_SheetName = wxT( "Root" ); m_SheetName = wxT( "Root" ); m_FileName = wxT( " " ); m_FileName = wxT( " " ); m_SheetNumber = 1; m_NumberOfSheets = 1; } } Loading @@ -54,7 +57,9 @@ DrawSheetStruct::~DrawSheetStruct() /**************************************/ /**************************************/ { { DrawSheetLabelStruct* label = m_Label, * next_label; DrawSheetLabelStruct* label = m_Label, * next_label; while( label ){ while( label ) { next_label = (DrawSheetLabelStruct*) label->Pnext; next_label = (DrawSheetLabelStruct*) label->Pnext; delete label; delete label; label = next_label; label = next_label; Loading @@ -62,13 +67,15 @@ DrawSheetStruct::~DrawSheetStruct() //also, look at the associated sheet & its reference count //also, look at the associated sheet & its reference count //perhaps it should be deleted also. //perhaps it should be deleted also. if(m_s){ if( m_AssociatedScreen ) m_s->m_RefCount--; { if(m_s->m_RefCount == 0) m_AssociatedScreen->m_RefCount--; delete m_s; if( m_AssociatedScreen->m_RefCount == 0 ) delete m_AssociatedScreen; } } } } /***********************************************/ /***********************************************/ DrawSheetStruct* DrawSheetStruct::GenCopy() DrawSheetStruct* DrawSheetStruct::GenCopy() /***********************************************/ /***********************************************/ Loading Loading @@ -109,9 +116,9 @@ DrawSheetStruct* DrawSheetStruct::GenCopy() } } /* don't copy screen data - just reference it. */ /* don't copy screen data - just reference it. */ newitem->m_s = m_s; newitem->m_AssociatedScreen = m_AssociatedScreen; if(m_s) if( m_AssociatedScreen ) m_s->m_RefCount++; m_AssociatedScreen->m_RefCount++; return newitem; return newitem; } } Loading @@ -120,6 +127,7 @@ DrawSheetStruct* DrawSheetStruct::GenCopy() /**********************************************************/ /**********************************************************/ void DrawSheetStruct::SwapData( DrawSheetStruct* copyitem ) void DrawSheetStruct::SwapData( DrawSheetStruct* copyitem ) /**********************************************************/ /**********************************************************/ /* Used if undo / redo command: /* Used if undo / redo command: * swap data between this and copyitem * swap data between this and copyitem */ */ Loading @@ -132,6 +140,8 @@ void DrawSheetStruct::SwapData( DrawSheetStruct* copyitem ) EXCHG( m_Label, copyitem->m_Label ); EXCHG( m_Label, copyitem->m_Label ); EXCHG( m_NbLabel, copyitem->m_NbLabel ); EXCHG( m_NbLabel, copyitem->m_NbLabel ); } } /****************************************************************/ /****************************************************************/ void DrawSheetStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) void DrawSheetStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) /****************************************************************/ /****************************************************************/ Loading @@ -152,9 +162,12 @@ void DrawSheetStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) EDA_BaseStruct::Place( frame, DC ); //puts it on the EEDrawList. EDA_BaseStruct::Place( frame, DC ); //puts it on the EEDrawList. } } /********************************************************************/ /********************************************************************/ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* frame, wxDC* DC ) void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* frame, wxDC* DC ) /********************************************************************/ /********************************************************************/ /* Delete pinsheets which are not corresponding to a hierarchal label /* Delete pinsheets which are not corresponding to a hierarchal label * if DC != NULL, redraw Sheet * if DC != NULL, redraw Sheet */ */ Loading @@ -169,7 +182,7 @@ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* frame, wxDC* DC ) { { /* Search Hlabel corresponding to this Pinsheet */ /* Search Hlabel corresponding to this Pinsheet */ EDA_BaseStruct* DrawStruct = m_s->EEDrawList; EDA_BaseStruct* DrawStruct = m_AssociatedScreen->EEDrawList; DrawHierLabelStruct* HLabel = NULL; DrawHierLabelStruct* HLabel = NULL; for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) { { Loading @@ -191,6 +204,7 @@ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* frame, wxDC* DC ) } } } } /**************************************************************************************/ /**************************************************************************************/ void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int DrawMode, int Color ) int DrawMode, int Color ) Loading Loading @@ -247,43 +261,57 @@ void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& of } } } } /**************************************************************************************/ /**************************************************************************************/ void DrawSheetStruct::DeleteAnnotation( bool recurse ) void DrawSheetStruct::DeleteAnnotation( bool recurse ) /**************************************************************************************/ /**************************************************************************************/ { { if(recurse && m_s){ if( recurse && m_AssociatedScreen ) EDA_BaseStruct* strct = m_s->EEDrawList; { for(; strct; strct = strct->Pnext){ EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList; if(strct->Type() == DRAW_SHEET_STRUCT_TYPE){ for( ; strct; strct = strct->Pnext ) { if( strct->Type() == DRAW_SHEET_STRUCT_TYPE ) { DrawSheetStruct* sheet = (DrawSheetStruct*) strct; DrawSheetStruct* sheet = (DrawSheetStruct*) strct; sheet->DeleteAnnotation( recurse ); sheet->DeleteAnnotation( recurse ); } } } } } } EDA_BaseStruct* comp = m_s->EEDrawList; EDA_BaseStruct* comp = m_AssociatedScreen->EEDrawList; for( ; comp ; comp = comp->Pnext ){ for( ; comp; comp = comp->Pnext ) if(comp->Type() == DRAW_LIB_ITEM_STRUCT_TYPE ){ { if( comp->Type() == DRAW_LIB_ITEM_STRUCT_TYPE ) { ( (EDA_SchComponentStruct*) comp )->ClearAnnotation(); ( (EDA_SchComponentStruct*) comp )->ClearAnnotation(); } } } } } } /*******************************************************************/ /*******************************************************************/ int DrawSheetStruct::ComponentCount() int DrawSheetStruct::ComponentCount() /*******************************************************************/ /*******************************************************************/ { { //count our own components, without the power components. //count our own components, without the power components. /* Routine retournant le nombre de composants dans le schema, /* Routine retournant le nombre de composants dans le schema, * powers non comprises */ * powers non comprises */ int n = 0; int n = 0; if(m_s){ if( m_AssociatedScreen ) { EDA_BaseStruct* bs; EDA_BaseStruct* bs; for( bs = m_s->EEDrawList; bs != NULL; bs = bs->Pnext ){ for( bs = m_AssociatedScreen->EEDrawList; bs != NULL; bs = bs->Pnext ) if( bs->Type() == DRAW_LIB_ITEM_STRUCT_TYPE ){ { if( bs->Type() == DRAW_LIB_ITEM_STRUCT_TYPE ) { DrawPartStruct* Cmp = (DrawPartStruct*) bs; DrawPartStruct* Cmp = (DrawPartStruct*) bs; if( Cmp->m_Field[VALUE].m_Text.GetChar( 0 ) != '#' ) if( Cmp->m_Field[VALUE].m_Text.GetChar( 0 ) != '#' ) n++; n++; } } if(bs->Type() == DRAW_SHEET_STRUCT_TYPE){ if( bs->Type() == DRAW_SHEET_STRUCT_TYPE ) { DrawSheetStruct* sheet = (DrawSheetStruct*) bs; DrawSheetStruct* sheet = (DrawSheetStruct*) bs; n += sheet->ComponentCount(); n += sheet->ComponentCount(); } } Loading @@ -291,18 +319,24 @@ int DrawSheetStruct::ComponentCount( ) } } return n; return n; } } /*******************************************************************************/ /*******************************************************************************/ bool DrawSheetStruct::SearchHierarchy( wxString filename, SCH_SCREEN** screen ) bool DrawSheetStruct::SearchHierarchy( wxString filename, SCH_SCREEN** screen ) /*******************************************************************************/ /*******************************************************************************/ { { //search the existing hierarchy for an instance of screen "FileName". //search the existing hierarchy for an instance of screen "FileName". if(m_s){ if( m_AssociatedScreen ) EDA_BaseStruct* strct = m_s->EEDrawList; { while(strct){ EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList; if(strct->Type() == DRAW_SHEET_STRUCT_TYPE){ while( strct ) { if( strct->Type() == DRAW_SHEET_STRUCT_TYPE ) { DrawSheetStruct* ss = (DrawSheetStruct*) strct; DrawSheetStruct* ss = (DrawSheetStruct*) strct; if(ss->m_s && ss->m_s->m_FileName.CmpNoCase(filename) == 0){ if( ss->m_AssociatedScreen && ss->m_AssociatedScreen->m_FileName.CmpNoCase( filename ) == 0 ) *screen = ss->m_s; { *screen = ss->m_AssociatedScreen; return true; return true; } } if( ss->SearchHierarchy( filename, screen ) ) if( ss->SearchHierarchy( filename, screen ) ) Loading @@ -313,6 +347,8 @@ bool DrawSheetStruct::SearchHierarchy(wxString filename, SCH_SCREEN **screen) } } return false; return false; } } /*******************************************************************************/ /*******************************************************************************/ bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* screen, DrawSheetList* list ) bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* screen, DrawSheetList* list ) /*******************************************************************************/ /*******************************************************************************/ Loading @@ -322,43 +358,55 @@ bool DrawSheetStruct::LocatePathOfScreen(SCH_SCREEN *screen, DrawSheetList* list //no other references to its m_s otherwise there would be loops //no other references to its m_s otherwise there would be loops //in the heirarchy. //in the heirarchy. //search the existing hierarchy for an instance of screen "FileName". //search the existing hierarchy for an instance of screen "FileName". if(m_s){ if( m_AssociatedScreen ) { list->Push( this ); list->Push( this ); if(m_s == screen) if( m_AssociatedScreen == screen ) return true; return true; EDA_BaseStruct* strct = m_s->EEDrawList; EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList; while(strct){ while( strct ) if(strct->Type() == DRAW_SHEET_STRUCT_TYPE){ { if( strct->Type() == DRAW_SHEET_STRUCT_TYPE ) { DrawSheetStruct* ss = (DrawSheetStruct*) strct; DrawSheetStruct* ss = (DrawSheetStruct*) strct; if( ss->LocatePathOfScreen( screen, list ) ) if( ss->LocatePathOfScreen( screen, list ) ) return true; return true; } } strct = strct->Pnext; strct = strct->Pnext; } } list->Pop(); list->Pop(); } } return false; return false; } } /*******************************************************************************/ /*******************************************************************************/ bool DrawSheetStruct::Load( WinEDA_SchematicFrame* frame ) bool DrawSheetStruct::Load( WinEDA_SchematicFrame* frame ) /*******************************************************************************/ /*******************************************************************************/ { { if(!m_s){ if( !m_AssociatedScreen ) { SCH_SCREEN* screen = NULL; SCH_SCREEN* screen = NULL; g_RootSheet->SearchHierarchy( m_FileName, &screen ); g_RootSheet->SearchHierarchy( m_FileName, &screen ); if(screen){ if( screen ) m_s = screen; { m_s->m_RefCount++; m_AssociatedScreen = screen; m_AssociatedScreen->m_RefCount++; //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{ } m_s = new SCH_SCREEN(SCHEMATIC_FRAME); else m_s->m_RefCount++; { if(!frame->LoadOneEEFile(m_s, m_FileName)) m_AssociatedScreen = new SCH_SCREEN( SCHEMATIC_FRAME ); m_AssociatedScreen->m_RefCount++; if( !frame->LoadOneEEFile( m_AssociatedScreen, m_FileName ) ) return false; return false; EDA_BaseStruct* bs = m_s->EEDrawList; EDA_BaseStruct* bs = m_AssociatedScreen->EEDrawList; while(bs){ while( bs ) if(bs->Type() == DRAW_SHEET_STRUCT_TYPE){ { if( bs->Type() == DRAW_SHEET_STRUCT_TYPE ) { DrawSheetStruct* ss = (DrawSheetStruct*) bs; DrawSheetStruct* ss = (DrawSheetStruct*) bs; if( !ss->Load( frame ) ) if( !ss->Load( frame ) ) return false; return false; Loading @@ -369,15 +417,21 @@ bool DrawSheetStruct::Load(WinEDA_SchematicFrame* frame) } } return true; return true; } } /*******************************************************************************/ /*******************************************************************************/ int DrawSheetStruct::CountSheets() int DrawSheetStruct::CountSheets() /*******************************************************************************/ /*******************************************************************************/ { { int count = 1; //1 = this!! int count = 1; //1 = this!! if(m_s){ EDA_BaseStruct* strct = m_s->EEDrawList; if( m_AssociatedScreen ) for(; strct; strct = strct->Pnext){ { if(strct->Type() == DRAW_SHEET_STRUCT_TYPE){ EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList; for( ; strct; strct = strct->Pnext ) { if( strct->Type() == DRAW_SHEET_STRUCT_TYPE ) { DrawSheetStruct* ss = (DrawSheetStruct*) strct; DrawSheetStruct* ss = (DrawSheetStruct*) strct; count += ss->CountSheets(); count += ss->CountSheets(); } } Loading @@ -394,8 +448,8 @@ int DrawSheetStruct::CountSheets() /*******************************************************************/ /*******************************************************************/ DrawSheetLabelStruct::DrawSheetLabelStruct( DrawSheetStruct* parent, DrawSheetLabelStruct::DrawSheetLabelStruct( DrawSheetStruct* parent, const wxPoint& pos, const wxString& text ) : const wxPoint& pos, const wxString& text ) : EDA_BaseStruct( DRAW_SHEETLABEL_STRUCT_TYPE ), EDA_BaseStruct( DRAW_SHEETLABEL_STRUCT_TYPE ) EDA_TextStruct( text ) , EDA_TextStruct( text ) /*******************************************************************/ /*******************************************************************/ { { m_Layer = LAYER_SHEETLABEL; m_Layer = LAYER_SHEETLABEL; Loading Loading @@ -511,115 +565,179 @@ void DrawSheetLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoin GRPoly( &panel->m_ClipBox, DC, NbSegm, coord, FillShape, LineWidth, txtcolor, txtcolor ); /* Poly Non rempli */ GRPoly( &panel->m_ClipBox, DC, NbSegm, coord, FillShape, LineWidth, txtcolor, txtcolor ); /* Poly Non rempli */ } } /**********************************************/ /**********************************************/ /* class to handle a series of sheets *********/ /* class to handle a series of sheets *********/ /* a 'path' so to speak.. *********************/ /* a 'path' so to speak.. *********************/ /**********************************************/ /**********************************************/ DrawSheetList::DrawSheetList(){ DrawSheetList::DrawSheetList() { for( int i = 0; i<DSLSZ; i++ ) for( int i = 0; i<DSLSZ; i++ ) m_sheets[i] = NULL; m_sheets[i] = NULL; m_numSheets = 0; m_numSheets = 0; } } int DrawSheetList::Cmp(DrawSheetList& d){ int DrawSheetList::Cmp( DrawSheetList& d ) { if( m_numSheets > d.m_numSheets ) if( m_numSheets > d.m_numSheets ) return 1; return 1; if( m_numSheets < d.m_numSheets ) if( m_numSheets < d.m_numSheets ) return -1; return -1; //otherwise, same number of sheets. //otherwise, same number of sheets. for(int i=0; i<m_numSheets; i++){ for( int i = 0; i<m_numSheets; i++ ) { if( m_sheets[i]->m_TimeStamp > d.m_sheets[i]->m_TimeStamp ) if( m_sheets[i]->m_TimeStamp > d.m_sheets[i]->m_TimeStamp ) return 1; return 1; if( m_sheets[i]->m_TimeStamp < d.m_sheets[i]->m_TimeStamp ) if( m_sheets[i]->m_TimeStamp < d.m_sheets[i]->m_TimeStamp ) return -1; return -1; } } return 0; return 0; } } DrawSheetStruct* DrawSheetList::Last(){ DrawSheetStruct* DrawSheetList::Last() { if( m_numSheets ) if( m_numSheets ) return m_sheets[m_numSheets - 1]; return m_sheets[m_numSheets - 1]; return NULL; return NULL; } } SCH_SCREEN* DrawSheetList::LastScreen(){ SCH_SCREEN* DrawSheetList::LastScreen() { if( m_numSheets ) if( m_numSheets ) return m_sheets[m_numSheets-1]->m_s; return m_sheets[m_numSheets - 1]->m_AssociatedScreen; return NULL; return NULL; } } EDA_BaseStruct* DrawSheetList::LastDrawList(){ if(m_numSheets && m_sheets[m_numSheets-1]->m_s) return m_sheets[m_numSheets-1]->m_s->EEDrawList; EDA_BaseStruct* DrawSheetList::LastDrawList() { if( m_numSheets && m_sheets[m_numSheets - 1]->m_AssociatedScreen ) return m_sheets[m_numSheets - 1]->m_AssociatedScreen->EEDrawList; return NULL; return NULL; } } void DrawSheetList::Push(DrawSheetStruct* sheet){ if(m_numSheets < DSLSZ){ void DrawSheetList::Push( DrawSheetStruct* sheet ) { if( m_numSheets < DSLSZ ) { m_sheets[m_numSheets] = sheet; m_sheets[m_numSheets] = sheet; m_numSheets++; m_numSheets++; } } } } DrawSheetStruct* DrawSheetList::Pop(){ if(m_numSheets > 0){ DrawSheetStruct* DrawSheetList::Pop() { if( m_numSheets > 0 ) { m_numSheets--; m_numSheets--; return m_sheets[m_numSheets]; return m_sheets[m_numSheets]; } } return NULL; return NULL; } } wxString DrawSheetList::Path(){ wxString DrawSheetList::Path() { wxString s, t; wxString s, t; s = wxT( "/" ); s = wxT( "/" ); //start at 1 to avoid the root sheet, //start at 1 to avoid the root sheet, //which does not need to be added to the path //which does not need to be added to the path //it's timestamp changes anyway. //it's timestamp changes anyway. for(int i=1; i< m_numSheets; i++){ for( int i = 1; i< m_numSheets; i++ ) { t.Printf( _( "%8.8lX/" ), m_sheets[i]->m_TimeStamp ); t.Printf( _( "%8.8lX/" ), m_sheets[i]->m_TimeStamp ); s = s + t; s = s + t; } } return s; return s; } } wxString DrawSheetList::PathHumanReadable(){ wxString DrawSheetList::PathHumanReadable() { wxString s, t; wxString s, t; s = wxT( "/" ); s = wxT( "/" ); //start at 1 to avoid the root sheet, as above. //start at 1 to avoid the root sheet, as above. for(int i=1; i< m_numSheets; i++){ for( int i = 1; i< m_numSheets; i++ ) { s = s + m_sheets[i]->m_SheetName + wxT( "/" ); s = s + m_sheets[i]->m_SheetName + wxT( "/" ); } } return s; return s; } } void DrawSheetList::UpdateAllScreenReferences(){ void DrawSheetList::UpdateAllScreenReferences() { EDA_BaseStruct* t = LastDrawList(); EDA_BaseStruct* t = LastDrawList(); while(t){ if(t->Type() == DRAW_LIB_ITEM_STRUCT_TYPE){ while( t ) { if( t->Type() == DRAW_LIB_ITEM_STRUCT_TYPE ) { EDA_SchComponentStruct* d = (EDA_SchComponentStruct*) t; EDA_SchComponentStruct* d = (EDA_SchComponentStruct*) t; d->m_Field[REFERENCE].m_Text = d->GetRef( this ); d->m_Field[REFERENCE].m_Text = d->GetRef( this ); } } t = t->Pnext; t = t->Pnext; } } printf( "on sheet: %s \n", CONV_TO_UTF8( PathHumanReadable() ) ); printf( "on sheet: %s \n", CONV_TO_UTF8( PathHumanReadable() ) ); } } bool DrawSheetList::operator= (const DrawSheetList& d1){ bool DrawSheetList::operator=( const DrawSheetList& d1 ) { m_numSheets = d1.m_numSheets; m_numSheets = d1.m_numSheets; int i; int i; for(i=0; i<m_numSheets; i++){ for( i = 0; i<m_numSheets; i++ ) { m_sheets[i] = d1.m_sheets[i]; m_sheets[i] = d1.m_sheets[i]; } } for(; i<DSLSZ; i++){ for( ; i<DSLSZ; i++ ) { m_sheets[i] = 0; m_sheets[i] = 0; } } return true; return true; } } bool DrawSheetList::operator==(const DrawSheetList &d1){ bool DrawSheetList::operator==( const DrawSheetList& d1 ) { if( m_numSheets != d1.m_numSheets ) if( m_numSheets != d1.m_numSheets ) return false; return false; for(int i=0; i<m_numSheets; i++){ for( int i = 0; i<m_numSheets; i++ ) { if( m_sheets[i] != d1.m_sheets[i] ) if( m_sheets[i] != d1.m_sheets[i] ) return false; return false; } } return true; return true; } } bool DrawSheetList::operator!=(const DrawSheetList &d1){ bool DrawSheetList::operator!=( const DrawSheetList& d1 ) { if( m_numSheets != d1.m_numSheets ) if( m_numSheets != d1.m_numSheets ) return true; return true; for(int i=0; i<m_numSheets; i++){ for( int i = 0; i<m_numSheets; i++ ) { if( m_sheets[i] != d1.m_sheets[i] ) if( m_sheets[i] != d1.m_sheets[i] ) return true; return true; } } return false; return false; } }