Commit dd9497a1 authored by CHARRAS's avatar CHARRAS

Fixed: problem which could crash eeschema when a schematic file in a hierarchy was not found

parent e92706bc
......@@ -5,6 +5,12 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.
2008-Feb-26 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+eeschema
Fixed: problem which could crash eeschema when a sub schematic file in a hierarchy was not found.
2008-Feb-27 UPDATE Wayne Stambaugh <stambaughw{at}verizon{dot}net>
================================================================================
+ eeschema
......
This diff is collapsed.
......@@ -208,7 +208,7 @@ void WinEDA_AnnotateFrame::CreateControls()
/* TODO: Check if there is any existing annotation and enable/disable
* the clear button accordingly. Probably should also enable/
* disable new components radio button if all of the components
* are already annotated. Some low level work on the DrawSheetList
* are already annotated. Some low level work on the DrawSheetPath
* class will need to be done to accomadate this.
*/
m_btnClear = new wxButton( this, wxID_CLEAR );
......
This diff is collapsed.
......@@ -43,10 +43,11 @@ DrawSheetStruct::DrawSheetStruct( const wxPoint& pos ) :
m_NbLabel = 0;
m_Layer = LAYER_SHEET;
m_Pos = pos;
m_TimeStamp = GetTimeStamp();
m_SheetNameSize = m_FileNameSize = 60;
m_AssociatedScreen = NULL;
m_SheetName = wxT( "Root" );
m_FileName = wxT( " " );
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;
......@@ -351,7 +352,7 @@ bool DrawSheetStruct::SearchHierarchy( wxString filename, SCH_SCREEN** screen )
/*******************************************************************************/
bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* screen, DrawSheetList* list )
bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* screen, DrawSheetPath* list )
/*******************************************************************************/
{
//search the existing hierarchy for an instance of screen "FileName".
......@@ -386,6 +387,8 @@ bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* screen, DrawSheetList* lis
bool DrawSheetStruct::Load( WinEDA_SchematicFrame* frame )
/*******************************************************************************/
{
bool success = true;
if( !m_AssociatedScreen )
{
SCH_SCREEN* screen = NULL;
......@@ -401,22 +404,24 @@ bool DrawSheetStruct::Load( WinEDA_SchematicFrame* frame )
{
m_AssociatedScreen = new SCH_SCREEN( SCHEMATIC_FRAME );
m_AssociatedScreen->m_RefCount++;
if( !frame->LoadOneEEFile( m_AssociatedScreen, m_FileName ) )
return false;
EDA_BaseStruct* bs = m_AssociatedScreen->EEDrawList;
while( bs )
{
if( bs->Type() == DRAW_SHEET_STRUCT_TYPE )
{
DrawSheetStruct* ss = (DrawSheetStruct*) bs;
if( !ss->Load( frame ) )
return false;
}
bs = bs->Pnext;
}
success = frame->LoadOneEEFile( m_AssociatedScreen, m_FileName);
if ( success )
{
EDA_BaseStruct* bs = m_AssociatedScreen->EEDrawList;
while( bs )
{
if( bs->Type() == DRAW_SHEET_STRUCT_TYPE )
{
DrawSheetStruct* sheetstruct = (DrawSheetStruct*) bs;
if( !sheetstruct->Load( frame ) )
success = false;
}
bs = bs->Pnext;
}
}
}
}
return true;
return success;
}
......@@ -442,6 +447,21 @@ int DrawSheetStruct::CountSheets()
}
/******************************************/
wxString DrawSheetStruct::GetFileName(void)
/******************************************/
{
return m_FileName;
}
/************************************************************/
void DrawSheetStruct::SetFileName(const wxString & aFilename)
/************************************************************/
{
m_FileName = aFilename;
}
/************************/
/* DrawSheetLabelStruct */
/************************/
......@@ -571,7 +591,7 @@ void DrawSheetLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoin
/* class to handle a series of sheets *********/
/* a 'path' so to speak.. *********************/
/**********************************************/
DrawSheetList::DrawSheetList()
DrawSheetPath::DrawSheetPath()
{
for( int i = 0; i<DSLSZ; i++ )
m_sheets[i] = NULL;
......@@ -580,7 +600,7 @@ DrawSheetList::DrawSheetList()
}
int DrawSheetList::Cmp( DrawSheetList& d )
int DrawSheetPath::Cmp( DrawSheetPath& d )
{
if( m_numSheets > d.m_numSheets )
return 1;
......@@ -600,7 +620,7 @@ int DrawSheetList::Cmp( DrawSheetList& d )
}
DrawSheetStruct* DrawSheetList::Last()
DrawSheetStruct* DrawSheetPath::Last()
{
if( m_numSheets )
return m_sheets[m_numSheets - 1];
......@@ -608,7 +628,7 @@ DrawSheetStruct* DrawSheetList::Last()
}
SCH_SCREEN* DrawSheetList::LastScreen()
SCH_SCREEN* DrawSheetPath::LastScreen()
{
if( m_numSheets )
return m_sheets[m_numSheets - 1]->m_AssociatedScreen;
......@@ -616,7 +636,7 @@ SCH_SCREEN* DrawSheetList::LastScreen()
}
EDA_BaseStruct* DrawSheetList::LastDrawList()
EDA_BaseStruct* DrawSheetPath::LastDrawList()
{
if( m_numSheets && m_sheets[m_numSheets - 1]->m_AssociatedScreen )
return m_sheets[m_numSheets - 1]->m_AssociatedScreen->EEDrawList;
......@@ -624,8 +644,9 @@ EDA_BaseStruct* DrawSheetList::LastDrawList()
}
void DrawSheetList::Push( DrawSheetStruct* sheet )
void DrawSheetPath::Push( DrawSheetStruct* sheet )
{
wxASSERT( m_numSheets <= DSLSZ );
if( m_numSheets < DSLSZ )
{
m_sheets[m_numSheets] = sheet;
......@@ -634,7 +655,7 @@ void DrawSheetList::Push( DrawSheetStruct* sheet )
}
DrawSheetStruct* DrawSheetList::Pop()
DrawSheetStruct* DrawSheetPath::Pop()
{
if( m_numSheets > 0 )
{
......@@ -645,7 +666,7 @@ DrawSheetStruct* DrawSheetList::Pop()
}
wxString DrawSheetList::Path()
wxString DrawSheetPath::Path()
{
wxString s, t;
......@@ -664,7 +685,7 @@ wxString DrawSheetList::Path()
}
wxString DrawSheetList::PathHumanReadable()
wxString DrawSheetPath::PathHumanReadable()
{
wxString s, t;
......@@ -680,7 +701,7 @@ wxString DrawSheetList::PathHumanReadable()
}
void DrawSheetList::UpdateAllScreenReferences()
void DrawSheetPath::UpdateAllScreenReferences()
{
EDA_BaseStruct* t = LastDrawList();
......@@ -698,7 +719,7 @@ void DrawSheetList::UpdateAllScreenReferences()
}
bool DrawSheetList::operator=( const DrawSheetList& d1 )
bool DrawSheetPath::operator=( const DrawSheetPath& d1 )
{
m_numSheets = d1.m_numSheets;
int i;
......@@ -716,7 +737,7 @@ bool DrawSheetList::operator=( const DrawSheetList& d1 )
}
bool DrawSheetList::operator==( const DrawSheetList& d1 )
bool DrawSheetPath::operator==( const DrawSheetPath& d1 )
{
if( m_numSheets != d1.m_numSheets )
return false;
......@@ -730,7 +751,7 @@ bool DrawSheetList::operator==( const DrawSheetList& d1 )
}
bool DrawSheetList::operator!=( const DrawSheetList& d1 )
bool DrawSheetPath::operator!=( const DrawSheetPath& d1 )
{
if( m_numSheets != d1.m_numSheets )
return true;
......
......@@ -268,7 +268,7 @@ void EDA_ScreenList::BuildScreenList( EDA_BaseStruct* s )
/*********************************************************************/
/*****************************************/
DrawSheetList* EDA_SheetList::GetFirst()
DrawSheetPath* EDA_SheetList::GetFirst()
/*****************************************/
{
m_index = 0;
......@@ -279,7 +279,7 @@ DrawSheetList* EDA_SheetList::GetFirst()
/*****************************************/
DrawSheetList* EDA_SheetList::GetNext()
DrawSheetPath* EDA_SheetList::GetNext()
/*****************************************/
{
if( m_index < m_count )
......@@ -289,7 +289,7 @@ DrawSheetList* EDA_SheetList::GetNext()
/************************************************/
DrawSheetList* EDA_SheetList::GetSheet( int index )
DrawSheetPath* EDA_SheetList::GetSheet( int index )
/************************************************/
/* return the m_List[index] item
......@@ -312,8 +312,8 @@ void EDA_SheetList::BuildSheetList( DrawSheetStruct* sheet )
m_index = 0;
if( m_List )
free( m_List );m_List = NULL;
count *= sizeof(DrawSheetList);
m_List = (DrawSheetList*) MyZMalloc( count );
count *= sizeof(DrawSheetPath);
m_List = (DrawSheetPath*) MyZMalloc( count );
memset( (void*) m_List, 0, count );
m_currList.Clear();
}
......@@ -336,44 +336,3 @@ void EDA_SheetList::BuildSheetList( DrawSheetStruct* sheet )
m_currList.Pop();
}
/************************************************/
void EDA_SheetList::UpdateSheetNumberAndDate()
/************************************************/
/* Set a sheet number, the sheet count for sheets in the whole schematic
* and update the date in all srceens
*/
{
wxString date = GenDate();
int sheet_count = 1, sheet_number = 2; // sheet 1 is the root sheet
for( int ii = 0; ii<(int) m_count; ii++ )
{
DrawSheetList* sheetlist = GetSheet( ii );
sheet_count += sheetlist->m_numSheets;
}
for( int ii = 0; ii<(int) m_count; ii++ )
{
DrawSheetList* sheetlist = GetSheet( ii );
// Read all sheets in path, but not the root sheet (jj = 1)
for( int jj = 1; jj < sheetlist->m_numSheets; jj++ )
{
DrawSheetStruct* sheet = sheetlist->m_sheets[jj];
sheet->m_SheetNumber = sheet_number++;
sheet->m_NumberOfSheets = m_count;
SCH_SCREEN* screen = sheet->m_AssociatedScreen;
if( screen != NULL )
{
screen->m_NumberOfScreen = sheet_count;
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 = m_count;
}
......@@ -55,8 +55,8 @@ public:
};
class DrawSheetLabelStruct : public EDA_BaseStruct
, public EDA_TextStruct
class DrawSheetLabelStruct : public EDA_BaseStruct,
public EDA_TextStruct
{
public:
int m_Layer;
......@@ -87,8 +87,8 @@ public:
/* class DrawSheetStruct
This class is the sheet symbol placed in a schematic, and is the entry point for a sub schematic
*/
* This class is the sheet symbol placed in a schematic, and is the entry point for a sub schematic
*/
WX_DEFINE_ARRAY( DrawSheetStruct *, SheetGrowArray );
class DrawSheetStruct : public EDA_BaseStruct /*public SCH_SCREEN*/ /* Gestion de la hierarchie */
......@@ -96,20 +96,22 @@ class DrawSheetStruct : public EDA_BaseStruct /*public SCH_SCREEN*/ /* Gestio
public:
wxString m_SheetName; //this is equivalent to C101 for components:
// it is stored in F0 ... of the file.
private:
wxString m_FileName; //also in SCH_SCREEN (redundant),
//but need it here for loading after
//reading the sheet description from file.
int m_SheetNameSize;
public:
int m_SheetNameSize; // Size (height) of the text, used to draw the name
int m_FileNameSize;
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 */
int m_Layer;
DrawSheetLabelStruct* m_Label; /* Points de connection, linked list.*/
int m_NbLabel; /* Nombre de points de connexion */
SCH_SCREEN* m_AssociatedScreen; /* Associated Screen which handle the physical data
In complex hierarchies we can have many DrawSheetStruct using the same data
*/
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)
......@@ -133,8 +135,10 @@ public:
int ComponentCount();
bool Load( WinEDA_SchematicFrame* frame );
bool SearchHierarchy( wxString filename, SCH_SCREEN** screen );
bool LocatePathOfScreen( SCH_SCREEN* screen, DrawSheetList* list );
bool LocatePathOfScreen( SCH_SCREEN* screen, DrawSheetPath* list );
int CountSheets();
wxString GetFileName(void);
void SetFileName(const wxString & aFilename);
//void RemoveSheet(DrawSheetStruct* sheet);
//to remove a sheet, just delete it
......@@ -147,16 +151,16 @@ public:
/* a 'path' so to speak.. *********************/
/**********************************************/
#define DSLSZ 32
class DrawSheetList
class DrawSheetPath
{
public:
int m_numSheets;
DrawSheetStruct* m_sheets[DSLSZ];
DrawSheetList();
~DrawSheetList() { };
DrawSheetPath();
~DrawSheetPath() { };
void Clear() { m_numSheets = 0; }
int Cmp( DrawSheetList& d );
int Cmp( DrawSheetPath& d );
DrawSheetStruct* Last();
SCH_SCREEN* LastScreen();
EDA_BaseStruct* LastDrawList();
......@@ -166,11 +170,11 @@ public:
wxString PathHumanReadable();
void UpdateAllScreenReferences();
bool operator =( const DrawSheetList& d1 );
bool operator =( const DrawSheetPath& d1 );
bool operator ==( const DrawSheetList& d1 );
bool operator ==( const DrawSheetPath& d1 );
bool operator !=( const DrawSheetList& d1 );
bool operator !=( const DrawSheetPath& d1 );
};
......@@ -179,14 +183,16 @@ public:
/*******************************************************/
// sheets are not unique - can have many sheets with the same
// filename and the same SCH_SHEET reference.
// filename and the same SCH_SCREEN reference.
class EDA_SheetList
{
private:
DrawSheetList* m_List;
int m_count;
DrawSheetPath* m_List;
int m_count; /* Number of sheets included in hierarchy,
* starting at the given sheet in constructor . the given sheet is counted
*/
int m_index;
DrawSheetList m_currList;
DrawSheetPath m_currList;
public:
EDA_SheetList( DrawSheetStruct* sheet )
......@@ -211,10 +217,9 @@ public:
int GetCount() { return m_count; }
DrawSheetList* GetFirst();
DrawSheetList* GetNext();
DrawSheetList* GetSheet( int index );
void UpdateSheetNumberAndDate(); // Update the date displayed in the sheet count
DrawSheetPath* GetFirst();
DrawSheetPath* GetNext();
DrawSheetPath* GetSheet( int index );
private:
void BuildSheetList( DrawSheetStruct* sheet );
......@@ -242,9 +247,9 @@ public:
~EDA_ScreenList() { }
int GetCount() { return m_List.GetCount(); }
SCH_SCREEN* GetFirst();
SCH_SCREEN* GetNext();
SCH_SCREEN* GetScreen( unsigned int index );
SCH_SCREEN* GetFirst();
SCH_SCREEN* GetNext();
SCH_SCREEN* GetScreen( unsigned int index );
private:
void AddScreenToList( SCH_SCREEN* testscreen );
......
......@@ -94,7 +94,7 @@ const wxString& EDA_SchComponentStruct::ReturnFieldName( int aFieldNdx ) const
/****************************************************************/
wxString EDA_SchComponentStruct::GetPath( DrawSheetList* sheet )
wxString EDA_SchComponentStruct::GetPath( DrawSheetPath* sheet )
/****************************************************************/
{
wxString str;
......@@ -105,7 +105,7 @@ wxString EDA_SchComponentStruct::GetPath( DrawSheetList* sheet )
/********************************************************************/
const wxString EDA_SchComponentStruct::GetRef( DrawSheetList* sheet )
const wxString EDA_SchComponentStruct::GetRef( DrawSheetPath* sheet )
/********************************************************************/
{
wxString path = GetPath( sheet );
......@@ -137,7 +137,7 @@ const wxString EDA_SchComponentStruct::GetRef( DrawSheetList* sheet )
/***********************************************************************/
void EDA_SchComponentStruct::SetRef( DrawSheetList* sheet, wxString ref )
void EDA_SchComponentStruct::SetRef( DrawSheetPath* sheet, wxString ref )
/***********************************************************************/
{
//check to see if it is already there before inserting it
......
......@@ -88,7 +88,7 @@ public:
}
};
WX_DECLARE_OBJARRAY( DrawSheetList, ArrayOfSheetLists );
WX_DECLARE_OBJARRAY( DrawSheetPath, ArrayOfSheetLists );
/* the class EDA_SchComponentStruct describes a real component */
class EDA_SchComponentStruct : public DrawPartStruct
{
......@@ -148,9 +148,9 @@ public:
//returns a unique ID, in the form of a path.
wxString GetPath( DrawSheetList* sheet );
const wxString GetRef( DrawSheetList* sheet );
void SetRef( DrawSheetList* sheet, wxString ref );
wxString GetPath( DrawSheetPath* sheet );
const wxString GetRef( DrawSheetPath* sheet );
void SetRef( DrawSheetPath* sheet, wxString ref );
void ClearRefs();
#if defined (DEBUG)
......
......@@ -42,7 +42,7 @@ wxString msg;
{
msg.Printf( _("Sheet %s (file %s) modified. Save it?"),
FirstSheet->m_SheetName.GetData(),
FirstSheet->m_FileName.GetData());
FirstSheet->GetFileName().GetData());
if( IsOK(NULL, msg) )
{
frame->SaveEEFile(FirstSheet->m_AssociatedScreen, FILE_SAVE_AS);
......
......@@ -772,7 +772,7 @@ int GenListeCmp( ListComponent * List )
int ItemCount = 0;
EDA_BaseStruct *DrawList;
EDA_SchComponentStruct *DrawLibItem;
DrawSheetList * sheet;
DrawSheetPath * sheet;
/* Build the sheet (not screen) list */
EDA_SheetList SheetList(NULL);
......@@ -820,7 +820,7 @@ static int GenListeGLabels( ListLabel * List )
int ItemCount = 0;
EDA_BaseStruct *DrawList;
DrawSheetLabelStruct *SheetLabel;
DrawSheetList * sheet;
DrawSheetPath * sheet;
/* Build the screen list */
EDA_SheetList SheetList(NULL);
......
......@@ -712,7 +712,7 @@ static bool WriteDiagnosticERC( const wxString& FullFileName )
DrawMarkerStruct* Marker;
char Line[256];
static FILE* OutErc;
DrawSheetList* Sheet;
DrawSheetPath* Sheet;
wxString msg;
if( ( OutErc = wxFopen( FullFileName, wxT( "wt" ) ) ) == NULL )
......
......@@ -141,7 +141,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe
wxSetWorkingDirectory( wxPathOnly( FullFileName ) );
GetScreen()->m_FileName = FullFileName;
g_RootSheet->m_FileName = FullFileName;
g_RootSheet->SetFileName(FullFileName);
Affiche_Message( wxEmptyString );
MsgPanel->EraseMsgBox();
......@@ -223,14 +223,13 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe
//load the project.
SAFE_DELETE(g_RootSheet->m_AssociatedScreen);
if(!g_RootSheet->Load(this))
return 0;
bool diag = g_RootSheet->Load(this);
/* Reaffichage ecran de base (ROOT) si necessaire */
ActiveScreen = GetScreen();
Zoom_Automatique( FALSE );
DrawPanel->Refresh( TRUE );
return 1;
return diag;
}
/**********************************************************/
SCH_SCREEN * WinEDA_SchematicFrame::CreateNewScreen(
......
......@@ -70,7 +70,7 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindComponentAndItem(
* @param mouseWarp If true, then move the mouse cursor to the item.
*/
{
DrawSheetList* sheet, * SheetWithComponentFound = NULL;
DrawSheetPath* sheet, * SheetWithComponentFound = NULL;
EDA_BaseStruct* DrawList = NULL;
EDA_SchComponentStruct* Component = NULL;
wxSize DrawAreaSize = DrawPanel->GetClientSize();
......@@ -266,7 +266,7 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindMarker( int SearchType )
* SearchType = 0: search the first marker, else search next marker
*/
{
DrawSheetList* sheet, * FirstSheet = NULL;
DrawSheetPath* sheet, * FirstSheet = NULL;
EDA_BaseStruct* DrawList, * FirstStruct = NULL, * Struct = NULL;
DrawMarkerStruct* Marker = NULL;
int StartCount;
......@@ -420,7 +420,7 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindSchematicItem(
* @param mouseWarp If true, then move the mouse cursor to the item.
*/
{
DrawSheetList* Sheet, * FirstSheet = NULL;
DrawSheetPath* Sheet, * FirstSheet = NULL;
EDA_BaseStruct* DrawList = NULL, * FirstStruct = NULL, * Struct = NULL;
int StartCount, ii, jj;
bool NotFound;
......
......@@ -23,7 +23,7 @@
#include "../bitmaps/treensel.xpm"
static void UpdateScreenFromSheet(WinEDA_SchematicFrame * frame);
static bool UpdateScreenFromSheet(WinEDA_SchematicFrame * frame);
enum {
ID_TREECTRL_HIERARCHY = 1600
......@@ -37,8 +37,8 @@ class WinEDA_HierFrame;
class TreeItemData: public wxTreeItemData
{
public:
DrawSheetList m_SheetList;
TreeItemData(DrawSheetList sheet) :wxTreeItemData()
DrawSheetPath m_SheetList;
TreeItemData(DrawSheetPath sheet) :wxTreeItemData()
{
m_SheetList = sheet;
}
......@@ -92,7 +92,7 @@ private:
public:
WinEDA_HierFrame(WinEDA_SchematicFrame *parent, wxDC * DC, const wxPoint& pos);
void BuildSheetList(DrawSheetList * list, wxTreeItemId * previousmenu);
void BuildSheetList(DrawSheetPath * list, wxTreeItemId * previousmenu);
~WinEDA_HierFrame();
void OnSelect(wxTreeEvent& event);
......@@ -133,7 +133,7 @@ WinEDA_HierFrame::WinEDA_HierFrame(WinEDA_SchematicFrame *parent, wxDC * DC,
cellule = m_Tree->AddRoot(_("Root"), 0, 1);
m_Tree->SetItemBold(cellule, TRUE);
DrawSheetList list;
DrawSheetPath list;
list.Push(g_RootSheet);
m_Tree->SetItemData( cellule, new TreeItemData(list) );
......@@ -179,7 +179,7 @@ void WinEDA_HierFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
}
/********************************************************************/
void WinEDA_HierFrame::BuildSheetList(DrawSheetList* list,
void WinEDA_HierFrame::BuildSheetList(DrawSheetPath* list,
wxTreeItemId * previousmenu)
/********************************************************************/
/* Routine de creation de l'arbre de navigation dans la hierarchy
......@@ -235,11 +235,12 @@ wxTreeItemId menu;
/***************************************************/
void WinEDA_HierFrame::OnSelect(wxTreeEvent& event)
/***************************************************/
/* appelee sur un double-click de la souris pour la selection d'un item:
Selectionne et affiche l'ecran demand�
/* Called on a double-click on a tree item:
Open the selected sheet, and display the corresponding screen
*/
{
wxTreeItemId ItemSel = m_Tree->GetSelection();
*(m_Parent->m_CurrentSheet) =
((TreeItemData*)(m_Tree->GetItemData(ItemSel)))->m_SheetList;
wxString path = m_Parent->m_CurrentSheet->PathHumanReadable();
......@@ -259,7 +260,7 @@ void WinEDA_SchematicFrame::InstallPreviousSheet()
g_ItemToRepeat = NULL;
MsgPanel->EraseMsgBox();
//make a copy for testing purposes.
DrawSheetList listtemp = *m_CurrentSheet;
DrawSheetPath listtemp = *m_CurrentSheet;
listtemp.Pop();
if ( listtemp.LastScreen() == NULL ){
DisplayError( this, wxT("InstallPreviousScreen() Error: Sheet not found"));
......@@ -290,7 +291,7 @@ void WinEDA_SchematicFrame::InstallNextScreen(DrawSheetStruct * Sheet)
}
/**************************************************************/
static void UpdateScreenFromSheet(WinEDA_SchematicFrame * frame)
static bool UpdateScreenFromSheet(WinEDA_SchematicFrame * frame)
/**************************************************************/
/* Recherche et installe de l'ecran relatif au sheet symbole Sheet.
......@@ -302,7 +303,10 @@ static void UpdateScreenFromSheet(WinEDA_SchematicFrame * frame)
NewScreen = frame->m_CurrentSheet->LastScreen();
if(!NewScreen)
NewScreen = g_RootSheet->m_AssociatedScreen;
{
DisplayError(frame, wxT("Screen not found for this sheet"));
return false;
}
// Reinit des parametres d'affichage du nouvel ecran
// assumes m_CurrentSheet has already been updated.
......@@ -325,6 +329,6 @@ static void UpdateScreenFromSheet(WinEDA_SchematicFrame * frame)
frame->DrawPanel->MouseToCursorSchema();
}
ActiveScreen = frame->m_CurrentSheet->LastScreen();
return;
return true;
}
......@@ -98,6 +98,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F
return FALSE;
screen->SetCurItem( NULL );
screen->m_FileName = FullFileName;
LineCount = 1;
if( ( f = wxFopen( FullFileName, wxT( "rt" ) ) ) == NULL )
......@@ -107,7 +108,6 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F
return FALSE;
}
screen->m_FileName = FullFileName;
MsgDiag = _( "Loading " ) + screen->m_FileName;
PrintMsg( MsgDiag );
......@@ -886,7 +886,7 @@ static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Wi
}
else
{
SheetStruct->m_FileName = CONV_FROM_UTF8( Name1 );
SheetStruct->SetFileName(CONV_FROM_UTF8( Name1 ));
//printf("in ReadSheetDescr : SheetStruct->m_FileName = %s \n", Name1);
SheetStruct->m_FileNameSize = size;
}
......
......@@ -25,9 +25,9 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f, bool use_
static void WriteGENERICListOfNets( FILE* f, ObjetNetListStruct* ObjNet );
static void AddPinToComponentPinList( EDA_SchComponentStruct* Component,
DrawSheetList* sheet,
DrawSheetPath* sheet,
LibDrawPin* PinEntry );
static void FindOthersUnits( EDA_SchComponentStruct* Component, DrawSheetList* Sheet_in);
static void FindOthersUnits( EDA_SchComponentStruct* Component, DrawSheetPath* Sheet_in);
static int SortPinsByNum( ObjetNetListStruct** Pin1, ObjetNetListStruct** Pin2 );
static void EraseDuplicatePins( ObjetNetListStruct** TabPin, int NbrPin );
......@@ -93,7 +93,7 @@ void WriteNetList( WinEDA_SchematicFrame* frame, const wxString& FileNameNL,
/****************************************************************************/
static EDA_SchComponentStruct* FindNextComponentAndCreatPinList(
EDA_BaseStruct* DrawList, DrawSheetList* sheet)
EDA_BaseStruct* DrawList, DrawSheetPath* sheet)
/****************************************************************************/
/* Find a "suitable" component from the DrawList
......@@ -245,7 +245,7 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame,
*/
{
wxString Line, FootprintName;
DrawSheetList* sheet;
DrawSheetPath* sheet;
EDA_BaseStruct* DrawList;
EDA_SchComponentStruct* Component;
wxString netname;
......@@ -392,7 +392,7 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f,
*/
{
char Line[1024];
DrawSheetList* sheet;
DrawSheetPath* sheet;
EDA_BaseStruct* DrawList;
EDA_SchComponentStruct* Component;
int ii, nbitems;
......@@ -534,7 +534,7 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with
{
wxString Line, FootprintName;
char Buf[256];
DrawSheetList* sheet;
DrawSheetPath* sheet;
EDA_BaseStruct* DrawList;
EDA_SchComponentStruct* Component;
int ii;
......@@ -676,7 +676,7 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with
/*************************************************************************************/
static void AddPinToComponentPinList( EDA_SchComponentStruct* Component,
DrawSheetList* sheetlist, LibDrawPin* Pin )
DrawSheetPath* sheetlist, LibDrawPin* Pin )
/*************************************************************************************/
/* Add a new pin description in the pin list s_SortedComponentPinList
......@@ -742,7 +742,7 @@ static void EraseDuplicatePins( ObjetNetListStruct** TabPin, int NbrPin )
/**********************************************************************/
static void FindOthersUnits( EDA_SchComponentStruct* Component_in, DrawSheetList* Sheet_in)
static void FindOthersUnits( EDA_SchComponentStruct* Component_in, DrawSheetPath* Sheet_in)
/**********************************************************************/
/* Recherche les autres parts du boitier auquel appartient la part Component,
......@@ -754,7 +754,7 @@ static void FindOthersUnits( EDA_SchComponentStruct* Component_in, DrawSheetList
EDA_SchComponentStruct* Component2;
EDA_LibComponentStruct* Entry;
LibEDA_BaseStruct* DEntry;
DrawSheetList* sheet;
DrawSheetPath* sheet;
wxString str;
EDA_SheetList SheetList( NULL );
......@@ -960,7 +960,7 @@ static void WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f )
wxString msg;
wxString FootprintName;
char Line[1024];
DrawSheetList* sheet;
DrawSheetPath* sheet;
EDA_BaseStruct* DrawList;
EDA_SchComponentStruct* Component;
wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion();
......
......@@ -20,7 +20,7 @@
static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus );
static void SheetLabelConnect( ObjetNetListStruct* SheetLabel );
static int ListeObjetConnection( WinEDA_SchematicFrame* frame,
DrawSheetList* sheetlist,
DrawSheetPath* sheetlist,
ObjetNetListStruct* ObjNet );
static int ConvertBusToMembers( ObjetNetListStruct* ObjNet );
static void PointToPointConnect( ObjetNetListStruct* Ref, int IsBus,
......@@ -154,7 +154,7 @@ void* WinEDA_SchematicFrame::BuildNetListBase()
{
int NetNumber;
int i, istart, NetCode;
DrawSheetList* sheet;
DrawSheetPath* sheet;
wxString msg;
wxBusyCursor Busy;
......@@ -435,7 +435,7 @@ static void SheetLabelConnect( ObjetNetListStruct* SheetLabel )
/*****************************************************************************/
static int ListeObjetConnection( WinEDA_SchematicFrame* frame, DrawSheetList* sheetlist,
static int ListeObjetConnection( WinEDA_SchematicFrame* frame, DrawSheetPath* sheetlist,
ObjetNetListStruct* ObjNet )
/*****************************************************************************/
......@@ -454,7 +454,7 @@ static int ListeObjetConnection( WinEDA_SchematicFrame* frame, DrawSheetList* sh
EDA_LibComponentStruct* Entry;
LibEDA_BaseStruct* DEntry;
DrawSheetLabelStruct* SheetLabel;
DrawSheetList list;
DrawSheetPath list;
DrawList = sheetlist->LastScreen()->EEDrawList;
for( ; DrawList; DrawList = DrawList->Pnext )
......
......@@ -66,7 +66,7 @@ public:
void* m_Link; /* Pour SheetLabelStruct: Pointeur sur la feuille de hierarchie
* Pour les Pins: pointeur sur le composant */
int m_Flag; /* flag pour calculs internes */
DrawSheetList m_SheetList;
DrawSheetPath m_SheetList;
NetObjetType m_Type;
int m_ElectricalType;/* Pour Pins et sheet labels: type electrique */
private:
......@@ -76,7 +76,7 @@ public:
int m_Member; /* pour les labels type BUSWIRE ( labels de bus eclate )
* numero de membre */
IsConnectType m_FlagOfConnection;
DrawSheetList m_SheetListInclude; /* sheet that the hierarchal label connects to.*/
DrawSheetPath m_SheetListInclude; /* sheet that the hierarchal label connects to.*/
long m_PinNum; /* numero de pin( 4 octets -> 4 codes ascii) */
const wxString* m_Label; /* Tous types Labels:pointeur sur la wxString definissant le label */
wxPoint m_Start, m_End;
......@@ -102,7 +102,7 @@ typedef struct ListComponent
EDA_SchComponentStruct * m_Comp;
char m_Ref[32];
//have to store it here since the object refrerences will be duplicated.
DrawSheetList m_SheetList; //composed of UIDs
DrawSheetPath m_SheetList; //composed of UIDs
} ListComponent;
/* Structure decrivant 1 composant de la schematique (pour *annotation* ) */
......@@ -113,7 +113,7 @@ public:
int m_NbParts; /* Nombre de parts par boitier */
bool m_PartsLocked; // For multi part components: True if the part cannot be changed
int m_Unit; /* Numero de part */
DrawSheetList m_SheetList;
DrawSheetPath m_SheetList;
unsigned long m_TimeStamp; /* unique identification number */
int m_IsNew; /* != 0 pour composants non annotes */
char m_TextValue[32]; /* Valeur */
......
......@@ -773,7 +773,7 @@ void PlotSheetStruct( DrawSheetStruct* Struct )
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM );
/* Trace des textes : FileName */
Text = Struct->m_FileName;
Text = Struct->GetFileName();
size = wxSize( Struct->m_FileNameSize, Struct->m_FileNameSize );
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( LAYER_SHEETFILENAME ) );
......
......@@ -495,10 +495,10 @@ DrawSheetLabelStruct * SheetLabel;
}
}
if( ! SheetStruct->m_FileName.IsEmpty())
if( ! SheetStruct->GetFileName().IsEmpty())
{
if(fprintf(f,"F1 \"%s\" %d\n",
CONV_TO_UTF8(SheetStruct->m_FileName),
CONV_TO_UTF8(SheetStruct->GetFileName()),
SheetStruct->m_FileNameSize) == EOF)
{
Failed = TRUE; return(Failed);
......
......@@ -533,8 +533,11 @@ void SCH_SCREEN::ClearUndoORRedoList( EDA_BaseStruct* List )
item = PickedList->m_PickedStruct;
if( item )
{
#if 0
if( item->Type() == DRAW_SHEET_STRUCT_TYPE )
{
printf(
"schematic undo_redo.cpp: undo_redo with a DRAW_SHEET_STRUCT_TYPE, checkme!!\n" );
DrawSheetStruct* sheet = (DrawSheetStruct*) item;
/* Delete sub hierarchy if the sheet must be deleted */
if( (sheet->m_Flags & IS_DELETED) != 0 )
......@@ -544,8 +547,6 @@ void SCH_SCREEN::ClearUndoORRedoList( EDA_BaseStruct* List )
{
if( (item->m_Flags & IS_NEW) == 0 )
{
printf(
"schematic undo_redo.cpp: undo_redo with a DRAW_SHEET_STRUCT_TYPE, checkme!!\n" );
/*
* sheet->EEDrawList = NULL;
......@@ -555,6 +556,7 @@ void SCH_SCREEN::ClearUndoORRedoList( EDA_BaseStruct* List )
}
}
}
#endif
if( (item->m_Flags & IS_NEW) == 0 )
{
SAFE_DELETE( item );
......@@ -578,6 +580,7 @@ void SCH_SCREEN::ClearUndoORRedoList( EDA_BaseStruct* List )
}
else
{
#if 0
if( FirstItem->Type() == DRAW_SHEET_STRUCT_TYPE )
{
DrawSheetStruct* sheet = (DrawSheetStruct*) FirstItem;
......@@ -599,6 +602,7 @@ void SCH_SCREEN::ClearUndoORRedoList( EDA_BaseStruct* List )
}
}
}
#endif
if( (FirstItem->m_Flags & IS_NEW) == 0 )
{
SAFE_DELETE( FirstItem );
......
......@@ -140,7 +140,7 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father,
m_Draw_Axis = FALSE; // TRUE to show axis
m_Draw_Grid = g_ShowGrid; // TRUE to show a grid
m_Draw_Sheet_Ref = TRUE; // TRUE to show sheet references
m_CurrentSheet = new DrawSheetList();
m_CurrentSheet = new DrawSheetPath();
CreateScreens();
......@@ -179,7 +179,7 @@ WinEDA_SchematicFrame::~WinEDA_SchematicFrame()
{
m_Parent->m_SchematicFrame = NULL;
SAFE_DELETE( g_RootSheet );
SAFE_DELETE( m_CurrentSheet ); //a DrawSheetList, on the heap.
SAFE_DELETE( m_CurrentSheet ); //a DrawSheetPath, on the heap.
m_CurrentSheet = NULL;
}
......@@ -187,7 +187,7 @@ WinEDA_SchematicFrame::~WinEDA_SchematicFrame()
/***************/
/* utility functions */
/***************/
DrawSheetList* WinEDA_SchematicFrame::GetSheet()
DrawSheetPath* WinEDA_SchematicFrame::GetSheet()
{
return m_CurrentSheet;
}
......@@ -205,7 +205,7 @@ void WinEDA_SchematicFrame::SetScreen( SCH_SCREEN* screen )
//there is ambiguity in this function (there may be several
//instances of a given sheet, but irregardless it is useful
//for printing etc.
DrawSheetList sheetlist;
DrawSheetPath sheetlist;
if( g_RootSheet->LocatePathOfScreen( screen, &sheetlist ) )
{
......@@ -250,7 +250,7 @@ void WinEDA_SchematicFrame::CreateScreens()
/**************************************************************/
void WinEDA_SchematicFrame::OnCloseWindow( wxCloseEvent& Event )
{
DrawSheetList* sheet;
DrawSheetPath* sheet;
if( m_Parent->m_LibeditFrame ) // Can close component editor ?
{
......@@ -400,18 +400,18 @@ int WinEDA_SchematicFrame::BestZoom()
int bestzoom;
wxSize size;
dx = GetScreen()->m_CurrentSheetDesc->m_Size.x;
dy = GetScreen()->m_CurrentSheetDesc->m_Size.y;
dx = GetScreen()->m_CurrentSheetDesc->m_Size.x;
dy = GetScreen()->m_CurrentSheetDesc->m_Size.y;
size = DrawPanel->GetClientSize();
ii = dx / size.x;
jj = dy / size.y;
bestzoom = MAX( ii, jj ) + 1;
GetScreen()->SetZoom( ii );
GetScreen()->m_Curseur.x = dx / 2;
GetScreen()->m_Curseur.y = dy / 2;
size = DrawPanel->GetClientSize();
ii = dx / size.x;
jj = dy / size.y;
bestzoom = MAX( ii, jj ) + 1;
GetScreen()->SetZoom( ii );
GetScreen()->m_Curseur.x = dx / 2;
GetScreen()->m_Curseur.y = dy / 2;
return bestzoom;
}
......
......@@ -16,7 +16,7 @@ class WinEDA_SchematicFrame : public WinEDA_DrawFrame
{
public:
WinEDAChoiceBox* m_SelPartBox;
DrawSheetList* m_CurrentSheet; //which sheet we are presently working on.
DrawSheetPath* m_CurrentSheet; //which sheet we are presently working on.
private:
wxMenu* m_FilesMenu;
......@@ -45,7 +45,7 @@ public:
int hotkey,
EDA_BaseStruct* DrawStruct );
DrawSheetList* GetSheet();
DrawSheetPath* GetSheet();
virtual BASE_SCREEN* GetScreen();
virtual void SetScreen(SCH_SCREEN* screen);
virtual wxString GetScreenDesc();
......@@ -168,6 +168,11 @@ private:
public:
bool EditSheet( DrawSheetStruct* Sheet, wxDC* DC );
/** Function UpdateSheetNumberAndDate
* Set a sheet number, the sheet count for sheets in the whole schematic
* and update the date in all screens
*/
void UpdateSheetNumberAndDate();
private:
void StartMoveSheet( DrawSheetStruct* sheet, wxDC* DC );
......
This diff is collapsed.
......@@ -39,15 +39,15 @@
////@begin control identifiers
#define ID_DIALOG 10000
#define ID_TEXTCTRL1 10002
#define ID_TEXTCTRL 10001
#define ID_TEXTCTRL2 10003
#define ID_TEXTCTRL3 10004
#define SYMBOL_WINEDA_SHEETPROPERTIESFRAME_STYLE wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX|MAYBE_RESIZE_BORDER
#define SYMBOL_WINEDA_SHEETPROPERTIESFRAME_TITLE _("Sheet properties")
#define SYMBOL_WINEDA_SHEETPROPERTIESFRAME_IDNAME ID_DIALOG
#define SYMBOL_WINEDA_SHEETPROPERTIESFRAME_SIZE wxSize(400, 300)
#define SYMBOL_WINEDA_SHEETPROPERTIESFRAME_POSITION wxDefaultPosition
#define ID_TEXTCTRL1 10002
#define ID_TEXTCTRL 10001
#define ID_TEXTCTRL2 10003
#define ID_TEXTCTRL3 10004
////@end control identifiers
/*!
......
This diff is collapsed.
......@@ -75,7 +75,7 @@ class DrawGlobalLabelStruct;
class DrawTextStruct;
class EDA_DrawLineStruct;
class DrawSheetStruct;
class DrawSheetList;
class DrawSheetPath;
class DrawSheetLabelStruct;
class EDA_SchComponentStruct;
class LibDrawField;
......
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