Commit 0ac832f0 authored by charras's avatar charras

screen number and screen count now are set

parent 39125547
......@@ -10,6 +10,7 @@ email address.
================================================================================
+eeschema:
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>
......
......@@ -22,45 +22,23 @@ static int ExistUnit( CmpListStruct* Objet, int Unit,
CmpListStruct* BaseListeCmp, int NbOfCmp );
/************************************************/
/******************************************************/
void WinEDA_SchematicFrame::UpdateSheetNumberAndDate()
/************************************************/
/******************************************************/
/* Set a sheet number, the sheet count for sheets in the whole schematic
* and update the date in all screens
*/
{
wxString date = GenDate();
int sheet_number = 1; // sheet 1 is the root sheet
DrawSheetPath* sheetpath;
EDA_ScreenList s_list;
/* Build the sheet list */
EDA_SheetList SheetList( g_RootSheet );
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;
}
}
}
// Set the date
for ( SCH_SCREEN * screen = s_list.GetFirst(); screen != NULL; screen = s_list.GetNext() )
screen->m_Date = date;
g_RootSheet->m_AssociatedScreen->m_Date = date;
g_RootSheet->m_AssociatedScreen->m_NumberOfScreen = sheet_count;
g_RootSheet->m_SheetNumber = 1;
g_RootSheet->m_NumberOfSheets = sheet_count;
// Set sheet counts
SetSheetNumberAndCount();
}
......
......@@ -47,8 +47,6 @@ DrawSheetStruct::DrawSheetStruct( const wxPoint& pos ) :
m_AssociatedScreen = NULL;
m_SheetName.Printf( wxT( "Sheet%8.8lX" ), m_TimeStamp );
m_FileName.Printf( wxT( "file%8.8lX.sch" ), m_TimeStamp );
m_SheetNumber = 1;
m_NumberOfSheets = 1;
}
......@@ -277,7 +275,7 @@ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* aFrame, bool aRedraw
}
Pinsheet = NextPinsheet;
}
if( aRedraw )
aFrame->DrawPanel->PostDirtyRect( GetBoundingBox() );
......@@ -499,9 +497,9 @@ bool DrawSheetStruct::Load( WinEDA_SchematicFrame* frame )
}
/*******************************************************************************/
/**********************************/
int DrawSheetStruct::CountSheets()
/*******************************************************************************/
/**********************************/
{
int count = 1; //1 = this!!
......
......@@ -26,7 +26,7 @@ public:
public:
Hierarchical_PIN_Sheet_Struct( DrawSheetStruct* parent,
const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString );
const wxString& text = wxEmptyString );
~Hierarchical_PIN_Sheet_Struct() { }
......@@ -36,13 +36,13 @@ public:
}
Hierarchical_PIN_Sheet_Struct* GenCopy();
Hierarchical_PIN_Sheet_Struct* GenCopy();
Hierarchical_PIN_Sheet_Struct* Next() { return (Hierarchical_PIN_Sheet_Struct*) Pnext; }
void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int draw_mode, int Color = -1 );
void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int draw_mode, int Color = -1 );
/**
* Function Save
......@@ -50,11 +50,13 @@ public:
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
bool Save( FILE* aFile ) const;
#if defined (DEBUG)
#if defined(DEBUG)
// comment inherited by Doxygen from Base_Struct
void Show( int nestLevel, std::ostream& os );
void Show( int nestLevel, std::ostream& os );
#endif
};
......@@ -64,7 +66,7 @@ public:
*/
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:
wxString m_SheetName; /*this is equivalent to C101 for components:
......@@ -75,7 +77,6 @@ private:
* reading the sheet description from file. */
public:
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 */
wxPoint m_Pos;
wxSize m_Size; /* Position and Size of sheet symbol */
......@@ -85,8 +86,6 @@ public:
SCH_SCREEN* m_AssociatedScreen; /* Associated Screen which handle the physical 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:
DrawSheetStruct( const wxPoint& pos = wxPoint( 0, 0 ) );
......@@ -103,32 +102,34 @@ public:
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
DrawSheetStruct* GenCopy();
void Display_Infos( WinEDA_DrawFrame* frame );
void CleanupSheet( WinEDA_SchematicFrame* frame, bool aRedraw );
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int draw_mode, int Color = -1 );
EDA_Rect GetBoundingBox();
void SwapData( DrawSheetStruct* copyitem );
int ComponentCount();
bool Load( WinEDA_SchematicFrame* frame );
bool SearchHierarchy( wxString filename, SCH_SCREEN** screen ); //search the existing hierarchy for an instance of screen "FileName".
bool LocatePathOfScreen( SCH_SCREEN* screen, DrawSheetPath* list );
int CountSheets();
wxString GetFileName( void );
void SetFileName( const wxString& aFilename ); // Set a new filename without changing anything else
bool ChangeFileName( WinEDA_SchematicFrame* aFrame, const wxString& aFileName ); // Set a new filename and manage data and associated screen
bool Save( FILE* aFile ) const;
void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
DrawSheetStruct* GenCopy();
void Display_Infos( WinEDA_DrawFrame* frame );
void CleanupSheet( WinEDA_SchematicFrame* frame, bool aRedraw );
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int draw_mode, int Color = -1 );
EDA_Rect GetBoundingBox();
void SwapData( DrawSheetStruct* copyitem );
int ComponentCount();
bool Load( WinEDA_SchematicFrame* frame );
bool SearchHierarchy( wxString filename, SCH_SCREEN** screen ); //search the existing hierarchy for an instance of screen "FileName".
bool LocatePathOfScreen( SCH_SCREEN* screen, DrawSheetPath* list );
int CountSheets();
wxString GetFileName( void );
void SetFileName( const wxString& aFilename ); // Set a new filename without changing anything else
bool ChangeFileName( WinEDA_SchematicFrame* aFrame, const wxString& aFileName ); // Set a new filename and manage data and associated screen
//void RemoveSheet(DrawSheetStruct* sheet);
//to remove a sheet, just delete it
//-- the destructor should take care of everything else.
#if defined(DEBUG)
#if defined (DEBUG)
// comment inherited by Doxygen from Base_Struct
void Show( int nestLevel, std::ostream& os );
void Show( int nestLevel, std::ostream& os );
#endif
};
......@@ -147,25 +148,25 @@ public:
DrawSheetPath();
~DrawSheetPath() { };
void Clear() { m_numSheets = 0; }
int Cmp( DrawSheetPath& d );
DrawSheetStruct* Last();
SCH_SCREEN* LastScreen();
EDA_BaseStruct* LastDrawList();
void Push( DrawSheetStruct* sheet );
DrawSheetStruct* Pop();
int Cmp( DrawSheetPath& d );
DrawSheetStruct* Last();
SCH_SCREEN* LastScreen();
EDA_BaseStruct* LastDrawList();
void Push( DrawSheetStruct* sheet );
DrawSheetStruct* Pop();
/** Function Path
* the path uses the time stamps which do not changes even when editing sheet parameters
* a path is something like / (root) or /34005677 or /34005677/00AE4523
*/
wxString Path();
wxString Path();
/** Function PathHumanReadable
* Return the sheet path in a readable form, i.e.
* as a path made from sheet names.
* (the "normal" path uses the time stamps which do not changes even when editing sheet parameters)
*/
wxString PathHumanReadable();
wxString PathHumanReadable();
/** Function UpdateAllScreenReferences
* Update the reference and the m_Multi parameter (part selection) for all components on a screen
......@@ -173,13 +174,13 @@ public:
* Mandatory in complex hierarchies because sheets use the same screen (basic schematic)
* but with different references and part selection according to the displayed sheet
*/
void UpdateAllScreenReferences();
void UpdateAllScreenReferences();
bool operator =( const DrawSheetPath& d1 );
bool operator =( const DrawSheetPath& d1 );
bool operator ==( const DrawSheetPath& d1 );
bool operator ==( const DrawSheetPath& d1 );
bool operator !=( const DrawSheetPath& d1 );
bool operator !=( const DrawSheetPath& d1 );
};
......@@ -222,12 +223,12 @@ public:
int GetCount() { return m_count; }
DrawSheetPath* GetFirst();
DrawSheetPath* GetNext();
DrawSheetPath* GetSheet( int index );
DrawSheetPath* GetFirst();
DrawSheetPath* GetNext();
DrawSheetPath* GetSheet( int index );
private:
void BuildSheetList( DrawSheetStruct* sheet );
void BuildSheetList( DrawSheetStruct* sheet );
};
#endif /* CLASS_DRAWSHEET_H */
......@@ -91,8 +91,6 @@ SCH_SCREEN::SCH_SCREEN( int screentype, KICAD_T aType ) :
SetGridList( g_GridList );
m_UndoRedoCountMax = 10;
m_RefCount = 0;
m_ScreenNumber = 1;
m_NumberOfScreen = 1;
}
......
......@@ -152,7 +152,6 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe
{
screen->m_CurrentSheetDesc = &g_Sheet_A4;
screen->SetZoom( 32 );
screen->m_ScreenNumber = screen->m_NumberOfScreen = 1;
screen->m_Title = wxT( "noname.sch" );
GetScreen()->m_FileName = screen->m_Title;
screen->m_Company.Empty();
......@@ -162,6 +161,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe
screen->m_Commentaire4.Empty();
Read_Config( wxEmptyString, TRUE );
Zoom_Automatique( TRUE );
SetSheetNumberAndCount();
ReDrawPanel();
return 1;
}
......@@ -226,6 +226,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe
/* Reaffichage ecran de base (ROOT) si necessaire */
ActiveScreen = GetScreen();
Zoom_Automatique( FALSE );
SetSheetNumberAndCount();
DrawPanel->Refresh( TRUE );
return diag;
}
......
......@@ -316,6 +316,7 @@ static bool UpdateScreenFromSheet(WinEDA_SchematicFrame * frame)
//update the References
frame->m_CurrentSheet->UpdateAllScreenReferences();
frame->SetSheetNumberAndCount();
frame->DrawPanel->m_CanStartBlock = -1;
ActiveScreen = frame->m_CurrentSheet->LastScreen();
if ( NewScreen->m_FirstRedraw ){
......
......@@ -66,7 +66,7 @@ bool WinEDA_SchematicFrame::SaveEEFile( SCH_SCREEN* screen, int FileSave )
this,
wxFD_SAVE,
FALSE
);
);
if( Name.IsEmpty() )
return FALSE;
......@@ -115,9 +115,9 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
* @return bool - true if success writing else false.
*/
{
const wxChar** LibNames;
wxString Name, msg;
Ki_PageDescr* PlotSheet;
const wxChar** LibNames;
wxString Name, msg;
Ki_PageDescr* PlotSheet;
LibNames = GetLibNames();
for( int ii = 0; LibNames[ii] != NULL; ii++ )
......@@ -145,7 +145,12 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
fprintf( aFile, "$Descr %s %d %d\n", CONV_TO_UTF8( PlotSheet->m_Name ),
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, "Title \"%s\"\n", CONV_TO_UTF8( m_Title ) );
fprintf( aFile, "Date \"%s\"\n", CONV_TO_UTF8( m_Date ) );
fprintf( aFile, "Rev \"%s\"\n", CONV_TO_UTF8( m_Revision ) );
......@@ -159,7 +164,7 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
/* Saving schematic items */
bool failed = FALSE;
for( SCH_ITEM* item = EEDrawList; item; item=item->Next() )
for( SCH_ITEM* item = EEDrawList; item; item = item->Next() )
{
switch( item->Type() )
{
......@@ -179,11 +184,11 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
failed = TRUE;
break;
/*
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case DRAW_PICK_ITEM_STRUCT_TYPE:
break;
*/
/*
* case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
* case DRAW_PICK_ITEM_STRUCT_TYPE:
* break;
*/
default:
break;
......
......@@ -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
{
return m_CurrentSheet->LastScreen();
......
......@@ -19,10 +19,8 @@
class SCH_SCREEN : public BASE_SCREEN
{
public:
int m_RefCount; //how many sheets reference this screen?
//delete when it goes to zero.
int m_ScreenNumber;
int m_NumberOfScreen;
int m_RefCount; /*how many sheets reference this screen?
* delete when it goes to zero. */
SCH_SCREEN( int idtype, KICAD_T aType = SCREEN_STRUCT_TYPE );
~SCH_SCREEN();
......@@ -47,29 +45,30 @@ public:
}
void FreeDrawList(); // Free EESchema drawing list (does not delete the sub hierarchies)
void FreeDrawList(); // Free EESchema drawing list (does not delete the sub hierarchies)
void Place( WinEDA_SchematicFrame* frame, wxDC* DC ) { };
void RemoveFromDrawList( SCH_ITEM* DrawStruct ); /* remove DrawStruct from EEDrawList. */
bool CheckIfOnDrawList( SCH_ITEM* st );
void AddToDrawList( SCH_ITEM* DrawStruct );
void ClearUndoORRedoList( EDA_BaseStruct* List );
void RemoveFromDrawList( SCH_ITEM* DrawStruct ); /* remove DrawStruct from EEDrawList. */
bool CheckIfOnDrawList( SCH_ITEM* st );
void AddToDrawList( SCH_ITEM* DrawStruct );
void ClearUndoORRedoList( EDA_BaseStruct* List );
bool SchematicCleanUp( wxDC* DC = NULL );
SCH_ITEM* ExtractWires( bool CreateCopy );
bool SchematicCleanUp( wxDC* DC = NULL );
SCH_ITEM* ExtractWires( bool CreateCopy );
/* full undo redo management : */
virtual void ClearUndoRedoList();
virtual void AddItemToUndoList( EDA_BaseStruct* item );
virtual void AddItemToRedoList( EDA_BaseStruct* item );
virtual void ClearUndoRedoList();
virtual void AddItemToUndoList( EDA_BaseStruct* item );
virtual void AddItemToRedoList( EDA_BaseStruct* item );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
bool Save( FILE* aFile ) const;
};
......@@ -94,8 +93,8 @@ public:
SCH_SCREEN* GetScreen( unsigned int index );
private:
void AddScreenToList( SCH_SCREEN* testscreen );
void BuildScreenList( EDA_BaseStruct* sheet );
void AddScreenToList( SCH_SCREEN* testscreen );
void BuildScreenList( EDA_BaseStruct* sheet );
};
#endif /* CLASS_SCREEN_H */
......@@ -112,10 +112,18 @@ public:
void InstallPreviousSheet();
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_HPGL( wxCommandEvent& event );
void ToPostProcess( wxCommandEvent& event );
// read and save files
void Save_File( wxCommandEvent& event );
void SaveProject();
int LoadOneEEProject( const wxString& FileName, bool IsNew );
......
......@@ -85,15 +85,4 @@ asked by: Dick Hollenbeck
loaded board. I think the number of layers should be reduced to the
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