Commit 0ac832f0 authored by charras's avatar charras

screen number and screen count now are set

parent 39125547
...@@ -10,6 +10,7 @@ email address. ...@@ -10,6 +10,7 @@ email address.
================================================================================ ================================================================================
+eeschema: +eeschema:
made in some dialogs the ESC key working (linux version, already working under windows) made in some dialogs the ESC key working (linux version, already working under windows)
screen number and screen count now are set
2008-Apr-29 UPDATE Dick Hollenbeck <dick@softplc.com> 2008-Apr-29 UPDATE Dick Hollenbeck <dick@softplc.com>
......
...@@ -22,45 +22,23 @@ static int ExistUnit( CmpListStruct* Objet, int Unit, ...@@ -22,45 +22,23 @@ static int ExistUnit( CmpListStruct* Objet, int Unit,
CmpListStruct* BaseListeCmp, int NbOfCmp ); CmpListStruct* BaseListeCmp, int NbOfCmp );
/************************************************/ /******************************************************/
void WinEDA_SchematicFrame::UpdateSheetNumberAndDate() void WinEDA_SchematicFrame::UpdateSheetNumberAndDate()
/************************************************/ /******************************************************/
/* Set a sheet number, the sheet count for sheets in the whole schematic /* Set a sheet number, the sheet count for sheets in the whole schematic
* and update the date in all screens * and update the date in all screens
*/ */
{ {
wxString date = GenDate(); wxString date = GenDate();
int sheet_number = 1; // sheet 1 is the root sheet EDA_ScreenList s_list;
DrawSheetPath* sheetpath;
/* Build the sheet list */ // Set the date
EDA_SheetList SheetList( g_RootSheet ); for ( SCH_SCREEN * screen = s_list.GetFirst(); screen != NULL; screen = s_list.GetNext() )
int sheet_count = SheetList.GetCount();
for( sheetpath = SheetList.GetFirst();
sheetpath != NULL;
sheetpath = SheetList.GetNext() )
{
// Read all sheets in path, but not the root sheet (jj = 1)
for( int jj = 1; jj < sheetpath->m_numSheets; jj++ )
{
DrawSheetStruct* sheet = sheetpath->m_sheets[jj];
sheet->m_SheetNumber = sheet_number++;
sheet->m_NumberOfSheets = sheet_count;
SCH_SCREEN* screen = sheet->m_AssociatedScreen;
if( screen != NULL )
{
screen->m_NumberOfScreen = sheet_count;
screen->m_Date = date; screen->m_Date = date;
}
}
}
g_RootSheet->m_AssociatedScreen->m_Date = date; // Set sheet counts
g_RootSheet->m_AssociatedScreen->m_NumberOfScreen = sheet_count; SetSheetNumberAndCount();
g_RootSheet->m_SheetNumber = 1;
g_RootSheet->m_NumberOfSheets = sheet_count;
} }
......
...@@ -47,8 +47,6 @@ DrawSheetStruct::DrawSheetStruct( const wxPoint& pos ) : ...@@ -47,8 +47,6 @@ DrawSheetStruct::DrawSheetStruct( const wxPoint& pos ) :
m_AssociatedScreen = NULL; m_AssociatedScreen = NULL;
m_SheetName.Printf( wxT( "Sheet%8.8lX" ), m_TimeStamp ); m_SheetName.Printf( wxT( "Sheet%8.8lX" ), m_TimeStamp );
m_FileName.Printf( wxT( "file%8.8lX.sch" ), m_TimeStamp ); m_FileName.Printf( wxT( "file%8.8lX.sch" ), m_TimeStamp );
m_SheetNumber = 1;
m_NumberOfSheets = 1;
} }
...@@ -499,9 +497,9 @@ bool DrawSheetStruct::Load( WinEDA_SchematicFrame* frame ) ...@@ -499,9 +497,9 @@ bool DrawSheetStruct::Load( WinEDA_SchematicFrame* frame )
} }
/*******************************************************************************/ /**********************************/
int DrawSheetStruct::CountSheets() int DrawSheetStruct::CountSheets()
/*******************************************************************************/ /**********************************/
{ {
int count = 1; //1 = this!! int count = 1; //1 = this!!
......
...@@ -52,9 +52,11 @@ public: ...@@ -52,9 +52,11 @@ public:
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
#if defined(DEBUG) #if defined (DEBUG)
// comment inherited by Doxygen from Base_Struct // comment inherited by Doxygen from Base_Struct
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
#endif #endif
}; };
...@@ -64,7 +66,7 @@ public: ...@@ -64,7 +66,7 @@ public:
*/ */
WX_DEFINE_ARRAY( DrawSheetStruct *, SheetGrowArray ); WX_DEFINE_ARRAY( DrawSheetStruct *, SheetGrowArray );
class DrawSheetStruct : public SCH_ITEM /*public SCH_SCREEN*/ /* Gestion de la hierarchie */ class DrawSheetStruct : public SCH_ITEM /* Gestion de la hierarchie */
{ {
public: public:
wxString m_SheetName; /*this is equivalent to C101 for components: wxString m_SheetName; /*this is equivalent to C101 for components:
...@@ -75,7 +77,6 @@ private: ...@@ -75,7 +77,6 @@ private:
* reading the sheet description from file. */ * reading the sheet description from file. */
public: public:
int m_SheetNameSize; /* Size (height) of the text, used to draw the name */ int m_SheetNameSize; /* Size (height) of the text, used to draw the name */
int m_FileNameSize; /* Size (height) of the text, used to draw the name */ int m_FileNameSize; /* Size (height) of the text, used to draw the name */
wxPoint m_Pos; wxPoint m_Pos;
wxSize m_Size; /* Position and Size of sheet symbol */ wxSize m_Size; /* Position and Size of sheet symbol */
...@@ -85,8 +86,6 @@ public: ...@@ -85,8 +86,6 @@ public:
SCH_SCREEN* m_AssociatedScreen; /* Associated Screen which handle the physical data SCH_SCREEN* m_AssociatedScreen; /* Associated Screen which handle the physical data
* In complex hierarchies we can have many DrawSheetStruct using the same data * In complex hierarchies we can have many DrawSheetStruct using the same data
*/ */
int m_SheetNumber; // sheet number (used for info)
int m_NumberOfSheets; // Sheets count in the whole schematic (used for info)
public: public:
DrawSheetStruct( const wxPoint& pos = wxPoint( 0, 0 ) ); DrawSheetStruct( const wxPoint& pos = wxPoint( 0, 0 ) );
...@@ -126,9 +125,11 @@ public: ...@@ -126,9 +125,11 @@ public:
//to remove a sheet, just delete it //to remove a sheet, just delete it
//-- the destructor should take care of everything else. //-- the destructor should take care of everything else.
#if defined(DEBUG) #if defined (DEBUG)
// comment inherited by Doxygen from Base_Struct // comment inherited by Doxygen from Base_Struct
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
#endif #endif
}; };
......
...@@ -91,8 +91,6 @@ SCH_SCREEN::SCH_SCREEN( int screentype, KICAD_T aType ) : ...@@ -91,8 +91,6 @@ SCH_SCREEN::SCH_SCREEN( int screentype, KICAD_T aType ) :
SetGridList( g_GridList ); SetGridList( g_GridList );
m_UndoRedoCountMax = 10; m_UndoRedoCountMax = 10;
m_RefCount = 0; m_RefCount = 0;
m_ScreenNumber = 1;
m_NumberOfScreen = 1;
} }
......
...@@ -152,7 +152,6 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe ...@@ -152,7 +152,6 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe
{ {
screen->m_CurrentSheetDesc = &g_Sheet_A4; screen->m_CurrentSheetDesc = &g_Sheet_A4;
screen->SetZoom( 32 ); screen->SetZoom( 32 );
screen->m_ScreenNumber = screen->m_NumberOfScreen = 1;
screen->m_Title = wxT( "noname.sch" ); screen->m_Title = wxT( "noname.sch" );
GetScreen()->m_FileName = screen->m_Title; GetScreen()->m_FileName = screen->m_Title;
screen->m_Company.Empty(); screen->m_Company.Empty();
...@@ -162,6 +161,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe ...@@ -162,6 +161,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe
screen->m_Commentaire4.Empty(); screen->m_Commentaire4.Empty();
Read_Config( wxEmptyString, TRUE ); Read_Config( wxEmptyString, TRUE );
Zoom_Automatique( TRUE ); Zoom_Automatique( TRUE );
SetSheetNumberAndCount();
ReDrawPanel(); ReDrawPanel();
return 1; return 1;
} }
...@@ -226,6 +226,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe ...@@ -226,6 +226,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe
/* Reaffichage ecran de base (ROOT) si necessaire */ /* Reaffichage ecran de base (ROOT) si necessaire */
ActiveScreen = GetScreen(); ActiveScreen = GetScreen();
Zoom_Automatique( FALSE ); Zoom_Automatique( FALSE );
SetSheetNumberAndCount();
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
return diag; return diag;
} }
......
...@@ -316,6 +316,7 @@ static bool UpdateScreenFromSheet(WinEDA_SchematicFrame * frame) ...@@ -316,6 +316,7 @@ static bool UpdateScreenFromSheet(WinEDA_SchematicFrame * frame)
//update the References //update the References
frame->m_CurrentSheet->UpdateAllScreenReferences(); frame->m_CurrentSheet->UpdateAllScreenReferences();
frame->SetSheetNumberAndCount();
frame->DrawPanel->m_CanStartBlock = -1; frame->DrawPanel->m_CanStartBlock = -1;
ActiveScreen = frame->m_CurrentSheet->LastScreen(); ActiveScreen = frame->m_CurrentSheet->LastScreen();
if ( NewScreen->m_FirstRedraw ){ if ( NewScreen->m_FirstRedraw ){
......
...@@ -145,7 +145,12 @@ bool SCH_SCREEN::Save( FILE* aFile ) const ...@@ -145,7 +145,12 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
fprintf( aFile, "$Descr %s %d %d\n", CONV_TO_UTF8( PlotSheet->m_Name ), fprintf( aFile, "$Descr %s %d %d\n", CONV_TO_UTF8( PlotSheet->m_Name ),
PlotSheet->m_Size.x, PlotSheet->m_Size.y ); PlotSheet->m_Size.x, PlotSheet->m_Size.y );
/* Write ScreenNumber and NumberOfScreen; not very meaningfull for SheetNumber and Sheet Count
* in a complex hierarchy, but usefull in simple hierarchy and flat hierarchy
* Used also to serach the root sheet ( ScreenNumber = 1 ) withing the files
*/
fprintf( aFile, "Sheet %d %d\n", m_ScreenNumber, m_NumberOfScreen ); fprintf( aFile, "Sheet %d %d\n", m_ScreenNumber, m_NumberOfScreen );
fprintf( aFile, "Title \"%s\"\n", CONV_TO_UTF8( m_Title ) ); fprintf( aFile, "Title \"%s\"\n", CONV_TO_UTF8( m_Title ) );
fprintf( aFile, "Date \"%s\"\n", CONV_TO_UTF8( m_Date ) ); fprintf( aFile, "Date \"%s\"\n", CONV_TO_UTF8( m_Date ) );
fprintf( aFile, "Rev \"%s\"\n", CONV_TO_UTF8( m_Revision ) ); fprintf( aFile, "Rev \"%s\"\n", CONV_TO_UTF8( m_Revision ) );
...@@ -159,7 +164,7 @@ bool SCH_SCREEN::Save( FILE* aFile ) const ...@@ -159,7 +164,7 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
/* Saving schematic items */ /* Saving schematic items */
bool failed = FALSE; bool failed = FALSE;
for( SCH_ITEM* item = EEDrawList; item; item=item->Next() ) for( SCH_ITEM* item = EEDrawList; item; item = item->Next() )
{ {
switch( item->Type() ) switch( item->Type() )
{ {
...@@ -180,9 +185,9 @@ bool SCH_SCREEN::Save( FILE* aFile ) const ...@@ -180,9 +185,9 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
break; break;
/* /*
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE: * case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case DRAW_PICK_ITEM_STRUCT_TYPE: * case DRAW_PICK_ITEM_STRUCT_TYPE:
break; * break;
*/ */
default: default:
......
...@@ -201,6 +201,32 @@ DrawSheetPath* WinEDA_SchematicFrame::GetSheet() ...@@ -201,6 +201,32 @@ DrawSheetPath* WinEDA_SchematicFrame::GetSheet()
} }
/****************************************************/
void WinEDA_SchematicFrame::SetSheetNumberAndCount()
/****************************************************/
/** Function SetSheetNumberAndCount
* Set the m_ScreenNumber and m_NumberOfScreen members for screens
* must be called after a delete or add sheet command, ans when entering a sheet
*/
{
SCH_SCREEN* screen = GetScreen();
EDA_ScreenList s_list;
/* Set the screen count, and the screen number (1 for root sheet)
*/
int screen_num = 2;
for ( screen = s_list.GetFirst(); screen != NULL; screen = s_list.GetNext() )
{
if ( screen == g_RootSheet->m_AssociatedScreen )
screen->m_ScreenNumber = 1;
else
screen->m_ScreenNumber = screen_num++;
screen->m_NumberOfScreen = s_list.GetCount();
}
}
SCH_SCREEN* WinEDA_SchematicFrame::GetScreen() const SCH_SCREEN* WinEDA_SchematicFrame::GetScreen() const
{ {
return m_CurrentSheet->LastScreen(); return m_CurrentSheet->LastScreen();
......
...@@ -19,10 +19,8 @@ ...@@ -19,10 +19,8 @@
class SCH_SCREEN : public BASE_SCREEN class SCH_SCREEN : public BASE_SCREEN
{ {
public: public:
int m_RefCount; //how many sheets reference this screen? int m_RefCount; /*how many sheets reference this screen?
//delete when it goes to zero. * delete when it goes to zero. */
int m_ScreenNumber;
int m_NumberOfScreen;
SCH_SCREEN( int idtype, KICAD_T aType = SCREEN_STRUCT_TYPE ); SCH_SCREEN( int idtype, KICAD_T aType = SCREEN_STRUCT_TYPE );
~SCH_SCREEN(); ~SCH_SCREEN();
...@@ -63,6 +61,7 @@ public: ...@@ -63,6 +61,7 @@ public:
virtual void ClearUndoRedoList(); virtual void ClearUndoRedoList();
virtual void AddItemToUndoList( EDA_BaseStruct* item ); virtual void AddItemToUndoList( EDA_BaseStruct* item );
virtual void AddItemToRedoList( EDA_BaseStruct* item ); virtual void AddItemToRedoList( EDA_BaseStruct* item );
/** /**
* Function Save * Function Save
* writes the data structures for this object out to a FILE in "*.brd" format. * writes the data structures for this object out to a FILE in "*.brd" format.
......
...@@ -112,10 +112,18 @@ public: ...@@ -112,10 +112,18 @@ public:
void InstallPreviousSheet(); void InstallPreviousSheet();
void InstallNextScreen( DrawSheetStruct* Sheet ); void InstallNextScreen( DrawSheetStruct* Sheet );
/** Function SetSheetNumberAndCount
* Set the m_ScreenNumber and m_NumberOfScreen members for screens
* must be called after a delete or add sheet command, and when entering a sheet
*/
void SetSheetNumberAndCount();
// Plot functions:
void ToPlot_PS( wxCommandEvent& event ); void ToPlot_PS( wxCommandEvent& event );
void ToPlot_HPGL( wxCommandEvent& event ); void ToPlot_HPGL( wxCommandEvent& event );
void ToPostProcess( wxCommandEvent& event ); void ToPostProcess( wxCommandEvent& event );
// read and save files
void Save_File( wxCommandEvent& event ); void Save_File( wxCommandEvent& event );
void SaveProject(); void SaveProject();
int LoadOneEEProject( const wxString& FileName, bool IsNew ); int LoadOneEEProject( const wxString& FileName, bool IsNew );
......
...@@ -85,15 +85,4 @@ asked by: Dick Hollenbeck ...@@ -85,15 +85,4 @@ asked by: Dick Hollenbeck
loaded board. I think the number of layers should be reduced to the loaded board. I think the number of layers should be reduced to the
default and the default layer names should be used. default and the default layer names should be used.
2008-Apr-30 Assigned To:
asked by: Dick Hollenbeck
================================================================================
+eeschema
This line in eeschema/save_schemas.cpp is using m_ScreenNumber == 1
regardless.
fprintf( aFile, "Sheet %d %d\n", m_ScreenNumber, m_NumberOfScreen );
The field m_ScreenNumber needs to be updated based on where
the sheet is in the hierarchy. Until this is fixed, the code which checks
for "Sheet 1 " in kicad/treeprj_frame.cpp is broken and the project manager
is showing all *.sch files, not just the top most *.sch files.
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