2007-08-20 01:20:48 +00:00
|
|
|
/********************************************/
|
|
|
|
/* Definitions for the EESchema program: */
|
|
|
|
/********************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#ifndef CLASS_SCREEN_H
|
|
|
|
#define CLASS_SCREEN_H
|
|
|
|
|
|
|
|
#ifndef eda_global
|
|
|
|
#define eda_global extern
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "macros.h"
|
|
|
|
#include "base_struct.h"
|
|
|
|
|
|
|
|
/* Max number of sheets in a hierarchy project: */
|
|
|
|
#define NB_MAX_SHEET 500
|
|
|
|
|
|
|
|
|
|
|
|
/* Forward declarations */
|
|
|
|
class DrawSheetStruct;
|
2008-02-26 19:19:54 +00:00
|
|
|
extern DrawSheetStruct* g_RootSheet;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
class SCH_SCREEN : public BASE_SCREEN
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2008-02-26 19:19:54 +00:00
|
|
|
int m_RefCount; //how many sheets reference this screen?
|
|
|
|
//delete when it goes to zero.
|
|
|
|
int m_ScreenNumber;
|
|
|
|
int m_NumberOfScreen;
|
2007-09-01 12:00:30 +00:00
|
|
|
SCH_SCREEN( int idtype, KICAD_T aType = SCREEN_STRUCT_TYPE );
|
2007-08-20 01:20:48 +00:00
|
|
|
~SCH_SCREEN();
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
2008-02-26 19:19:54 +00:00
|
|
|
return wxT( "SCH_SCREEN" );
|
2007-09-13 11:28:58 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
void FreeDrawList(); // Free EESchema drawing list (does not delete the sub hierarchies)
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
void Place( WinEDA_DrawFrame* frame, wxDC* DC ) { };
|
2008-02-26 19:19:54 +00:00
|
|
|
void RemoveFromDrawList( EDA_BaseStruct* DrawStruct ); /* remove DrawStruct from EEDrawList. */
|
|
|
|
bool CheckIfOnDrawList( EDA_BaseStruct* st );
|
|
|
|
void AddToDrawList( EDA_BaseStruct* DrawStruct );
|
2007-08-20 01:20:48 +00:00
|
|
|
void ClearUndoORRedoList( EDA_BaseStruct* List );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
bool SchematicCleanUp( wxDC* DC = NULL );
|
|
|
|
EDA_BaseStruct* ExtractWires( bool CreateCopy );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
/* full undo redo management : */
|
2007-09-01 12:00:30 +00:00
|
|
|
virtual void ClearUndoRedoList();
|
2007-08-20 01:20:48 +00:00
|
|
|
virtual void AddItemToUndoList( EDA_BaseStruct* item );
|
|
|
|
virtual void AddItemToRedoList( EDA_BaseStruct* item );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-02-28 19:27:25 +00:00
|
|
|
class DrawSheetLabelStruct : public EDA_BaseStruct,
|
|
|
|
public EDA_TextStruct
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-08-23 04:28:46 +00:00
|
|
|
int m_Layer;
|
2007-08-20 01:20:48 +00:00
|
|
|
int m_Edge, m_Shape;
|
2008-02-26 19:19:54 +00:00
|
|
|
bool m_IsDangling; // TRUE non connected
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
public:
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawSheetLabelStruct( DrawSheetStruct* parent,
|
2008-02-26 19:19:54 +00:00
|
|
|
const wxPoint& pos = wxPoint( 0, 0 ),
|
|
|
|
const wxString& text = wxEmptyString );
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
~DrawSheetLabelStruct() { }
|
2007-09-13 11:28:58 +00:00
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
2008-02-26 19:19:54 +00:00
|
|
|
return wxT( "DrawSheetLabelStruct" );
|
2007-09-13 11:28:58 +00:00
|
|
|
}
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
DrawSheetLabelStruct* GenCopy();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
DrawSheetLabelStruct* Next()
|
2007-08-20 01:20:48 +00:00
|
|
|
{ return (DrawSheetLabelStruct*) Pnext; }
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
void Place( WinEDA_DrawFrame* frame, wxDC* DC );
|
|
|
|
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
|
|
|
|
int draw_mode, int Color = -1 );
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
/* class DrawSheetStruct
|
2008-02-28 19:27:25 +00:00
|
|
|
* This class is the sheet symbol placed in a schematic, and is the entry point for a sub schematic
|
|
|
|
*/
|
2008-02-26 19:19:54 +00:00
|
|
|
WX_DEFINE_ARRAY( DrawSheetStruct *, SheetGrowArray );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
class DrawSheetStruct : public EDA_BaseStruct /*public SCH_SCREEN*/ /* Gestion de la hierarchie */
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2008-02-26 19:19:54 +00:00
|
|
|
wxString m_SheetName; //this is equivalent to C101 for components:
|
|
|
|
// it is stored in F0 ... of the file.
|
2008-02-28 19:27:25 +00:00
|
|
|
private:
|
2008-02-26 19:19:54 +00:00
|
|
|
wxString m_FileName; //also in SCH_SCREEN (redundant),
|
|
|
|
//but need it here for loading after
|
|
|
|
//reading the sheet description from file.
|
2008-02-28 19:27:25 +00:00
|
|
|
public:
|
|
|
|
int m_SheetNameSize; // Size (height) of the text, used to draw the name
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2008-02-28 19:27:25 +00:00
|
|
|
int m_FileNameSize; // Size (height) of the text, used to draw the name
|
2008-02-26 19:19:54 +00:00
|
|
|
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 */
|
2008-02-28 19:27:25 +00:00
|
|
|
SCH_SCREEN* m_AssociatedScreen; /* Associated Screen which handle the physical data
|
|
|
|
* In complex hierarchies we can have many DrawSheetStruct using the same data
|
|
|
|
*/
|
2008-02-26 19:19:54 +00:00
|
|
|
int m_SheetNumber; // sheet number (used for info)
|
|
|
|
int m_NumberOfSheets; // Sheets count in the whole schematic (used for info)
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
public:
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawSheetStruct( const wxPoint& pos = wxPoint( 0, 0 ) );
|
2007-09-01 12:00:30 +00:00
|
|
|
~DrawSheetStruct();
|
2007-09-13 11:28:58 +00:00
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
2008-02-26 19:19:54 +00:00
|
|
|
return wxT( "DrawSheetStruct" );
|
2007-09-13 11:28:58 +00:00
|
|
|
}
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
void Place( WinEDA_DrawFrame* frame, wxDC* DC );
|
2007-09-01 12:00:30 +00:00
|
|
|
DrawSheetStruct* GenCopy();
|
2007-08-20 01:20:48 +00:00
|
|
|
void Display_Infos( WinEDA_DrawFrame* frame );
|
|
|
|
void CleanupSheet( WinEDA_SchematicFrame* frame, wxDC* DC );
|
|
|
|
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
|
|
|
|
int draw_mode, int Color = -1 );
|
2008-02-26 19:19:54 +00:00
|
|
|
void SwapData( DrawSheetStruct* copyitem );
|
|
|
|
void DeleteAnnotation( bool recurse );
|
|
|
|
int ComponentCount();
|
|
|
|
bool Load( WinEDA_SchematicFrame* frame );
|
|
|
|
bool SearchHierarchy( wxString filename, SCH_SCREEN** screen );
|
2008-02-28 19:27:25 +00:00
|
|
|
bool LocatePathOfScreen( SCH_SCREEN* screen, DrawSheetPath* list );
|
2008-02-26 19:19:54 +00:00
|
|
|
int CountSheets();
|
2008-02-28 19:27:25 +00:00
|
|
|
wxString GetFileName(void);
|
2008-02-29 12:33:07 +00:00
|
|
|
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
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
//void RemoveSheet(DrawSheetStruct* sheet);
|
|
|
|
//to remove a sheet, just delete it
|
|
|
|
//-- the destructor should take care of everything else.
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
/**********************************************/
|
|
|
|
/* class to handle a series of sheets *********/
|
|
|
|
/* a 'path' so to speak.. *********************/
|
|
|
|
/**********************************************/
|
2008-02-12 21:12:46 +00:00
|
|
|
#define DSLSZ 32
|
2008-02-28 19:27:25 +00:00
|
|
|
class DrawSheetPath
|
2008-02-12 21:12:46 +00:00
|
|
|
{
|
|
|
|
public:
|
2008-02-26 19:19:54 +00:00
|
|
|
int m_numSheets;
|
|
|
|
DrawSheetStruct* m_sheets[DSLSZ];
|
|
|
|
|
2008-02-28 19:27:25 +00:00
|
|
|
DrawSheetPath();
|
|
|
|
~DrawSheetPath() { };
|
2008-02-26 19:19:54 +00:00
|
|
|
void Clear() { m_numSheets = 0; }
|
2008-02-28 19:27:25 +00:00
|
|
|
int Cmp( DrawSheetPath& d );
|
2008-02-26 19:19:54 +00:00
|
|
|
DrawSheetStruct* Last();
|
|
|
|
SCH_SCREEN* LastScreen();
|
|
|
|
EDA_BaseStruct* LastDrawList();
|
|
|
|
void Push( DrawSheetStruct* sheet );
|
|
|
|
DrawSheetStruct* Pop();
|
|
|
|
wxString Path();
|
|
|
|
wxString PathHumanReadable();
|
|
|
|
void UpdateAllScreenReferences();
|
|
|
|
|
2008-02-28 19:27:25 +00:00
|
|
|
bool operator =( const DrawSheetPath& d1 );
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2008-02-28 19:27:25 +00:00
|
|
|
bool operator ==( const DrawSheetPath& d1 );
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2008-02-28 19:27:25 +00:00
|
|
|
bool operator !=( const DrawSheetPath& d1 );
|
2008-02-26 19:19:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************/
|
2008-02-12 21:12:46 +00:00
|
|
|
/* Class to handle the list of *Sheets* in a hierarchy */
|
2008-02-26 19:19:54 +00:00
|
|
|
/*******************************************************/
|
|
|
|
|
|
|
|
// sheets are not unique - can have many sheets with the same
|
2008-02-28 19:27:25 +00:00
|
|
|
// filename and the same SCH_SCREEN reference.
|
2008-02-12 21:12:46 +00:00
|
|
|
class EDA_SheetList
|
|
|
|
{
|
2008-02-26 19:19:54 +00:00
|
|
|
private:
|
2008-02-28 19:27:25 +00:00
|
|
|
DrawSheetPath* m_List;
|
|
|
|
int m_count; /* Number of sheets included in hierarchy,
|
|
|
|
* starting at the given sheet in constructor . the given sheet is counted
|
|
|
|
*/
|
2008-02-26 19:19:54 +00:00
|
|
|
int m_index;
|
2008-02-28 19:27:25 +00:00
|
|
|
DrawSheetPath m_currList;
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
EDA_SheetList( DrawSheetStruct* sheet )
|
|
|
|
{
|
|
|
|
m_index = 0;
|
|
|
|
m_count = 0;
|
|
|
|
m_List = NULL;
|
|
|
|
if( sheet == NULL )
|
|
|
|
sheet = g_RootSheet;
|
|
|
|
BuildSheetList( sheet );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
~EDA_SheetList()
|
|
|
|
{
|
|
|
|
if( m_List )
|
|
|
|
{
|
|
|
|
free( m_List );
|
|
|
|
}
|
|
|
|
m_List = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GetCount() { return m_count; }
|
2008-02-28 19:27:25 +00:00
|
|
|
DrawSheetPath* GetFirst();
|
|
|
|
DrawSheetPath* GetNext();
|
|
|
|
DrawSheetPath* GetSheet( int index );
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void BuildSheetList( DrawSheetStruct* sheet );
|
2008-02-12 21:12:46 +00:00
|
|
|
};
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
/********************************************************/
|
2008-02-12 21:12:46 +00:00
|
|
|
/* Class to handle the list of *screens* in a hierarchy */
|
2008-02-26 19:19:54 +00:00
|
|
|
/********************************************************/
|
|
|
|
|
|
|
|
// screens are unique, and correspond to .sch files.
|
|
|
|
WX_DEFINE_ARRAY( SCH_SCREEN *, ScreenGrowArray );
|
2007-06-05 12:10:51 +00:00
|
|
|
class EDA_ScreenList
|
|
|
|
{
|
|
|
|
private:
|
2008-02-12 21:12:46 +00:00
|
|
|
ScreenGrowArray m_List;
|
2008-02-26 19:19:54 +00:00
|
|
|
unsigned int m_Index;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
public:
|
2008-02-26 19:19:54 +00:00
|
|
|
EDA_ScreenList()
|
|
|
|
{
|
|
|
|
m_Index = 0;
|
|
|
|
BuildScreenList( g_RootSheet );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
~EDA_ScreenList() { }
|
|
|
|
int GetCount() { return m_List.GetCount(); }
|
2008-02-28 19:27:25 +00:00
|
|
|
SCH_SCREEN* GetFirst();
|
|
|
|
SCH_SCREEN* GetNext();
|
|
|
|
SCH_SCREEN* GetScreen( unsigned int index );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
private:
|
2008-02-26 19:19:54 +00:00
|
|
|
void AddScreenToList( SCH_SCREEN* testscreen );
|
|
|
|
void BuildScreenList( EDA_BaseStruct* sheet );
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* CLASS_SCREEN_H */
|