2008-04-12 18:39:20 +00:00
|
|
|
/********************************************/
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Definitions for the EESchema program: */
|
2008-04-12 18:39:20 +00:00
|
|
|
/********************************************/
|
|
|
|
|
|
|
|
#ifndef CLASS_DRAWSHEET_H
|
|
|
|
#define CLASS_DRAWSHEET_H
|
|
|
|
|
|
|
|
#include "base_struct.h"
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
extern SCH_SHEET* g_RootSheet;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pin (label) used in sheets to create hierarchical schematics.
|
|
|
|
*
|
|
|
|
* A SCH_SHEET_PIN is used to create a hierarchical sheet in the same way a
|
2009-12-02 21:44:03 +00:00
|
|
|
* pin is used in a component. It connects the objects in the sheet object
|
|
|
|
* to the objects in the schematic page to the objects in the page that is
|
2009-11-04 20:46:53 +00:00
|
|
|
* represented by the sheet. In a sheet object, a SCH_SHEET_PIN must be
|
|
|
|
* connected to a wire, bus, or label. In the schematic page represented by
|
|
|
|
* the sheet, it corresponds to a hierarchical label.
|
2009-01-04 18:52:57 +00:00
|
|
|
*/
|
2009-11-04 20:46:53 +00:00
|
|
|
class SCH_SHEET_PIN : public SCH_ITEM, public EDA_TextStruct
|
2008-04-12 18:39:20 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
int m_Edge, m_Shape;
|
|
|
|
bool m_IsDangling; // TRUE non connected
|
2009-11-03 13:26:31 +00:00
|
|
|
int m_Number; // used to numbered labels when writing data on file .
|
|
|
|
// m_Number >= 2
|
2008-04-15 19:38:19 +00:00
|
|
|
// value 0 is for sheet name and 1 for sheet filename
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2010-03-16 18:22:59 +00:00
|
|
|
public:
|
|
|
|
SCH_SHEET_PIN( SCH_SHEET* parent,
|
|
|
|
const wxPoint& pos = wxPoint( 0, 0 ),
|
|
|
|
const wxString& text = wxEmptyString );
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
~SCH_SHEET_PIN() { }
|
2008-04-22 16:38:23 +00:00
|
|
|
|
2008-04-12 18:39:20 +00:00
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
return wxT( "SCH_SHEET_PIN" );
|
2008-04-12 18:39:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET_PIN* GenCopy();
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET_PIN* Next()
|
2009-11-03 13:26:31 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
return ( SCH_SHEET_PIN*) Pnext;
|
2009-11-03 13:26:31 +00:00
|
|
|
}
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
void Place( WinEDA_SchematicFrame* frame,
|
|
|
|
wxDC* DC );
|
|
|
|
void Draw( WinEDA_DrawPanel* panel,
|
|
|
|
wxDC* DC,
|
|
|
|
const wxPoint& offset,
|
|
|
|
int draw_mode,
|
|
|
|
int Color = -1 );
|
2008-04-15 19:38:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Save
|
2009-11-03 13:26:31 +00:00
|
|
|
* writes the data structures for this object out to a FILE in "*.sch"
|
|
|
|
* format.
|
2008-04-15 19:38:19 +00:00
|
|
|
* @param aFile The FILE to write to.
|
|
|
|
* @return bool - true if success writing else false.
|
|
|
|
*/
|
2009-11-03 13:26:31 +00:00
|
|
|
bool Save( FILE* aFile ) const;
|
2008-04-30 17:04:22 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
#if defined(DEBUG)
|
2008-04-22 16:38:23 +00:00
|
|
|
|
|
|
|
// comment inherited by Doxygen from Base_Struct
|
2009-11-03 13:26:31 +00:00
|
|
|
void Show( int nestLevel, std::ostream& os );
|
2008-04-30 17:04:22 +00:00
|
|
|
|
2008-04-22 16:38:23 +00:00
|
|
|
#endif
|
2009-05-05 18:25:47 +00:00
|
|
|
|
2009-06-30 19:21:41 +00:00
|
|
|
/** Function GetPenSize
|
|
|
|
* @return the size of the "pen" that be used to draw or plot this item
|
|
|
|
*/
|
2009-11-03 13:26:31 +00:00
|
|
|
virtual int GetPenSize();
|
2009-06-30 19:21:41 +00:00
|
|
|
|
2009-05-05 18:25:47 +00:00
|
|
|
/** function CreateGraphicShape
|
|
|
|
* Calculates the graphic shape (a polygon) associated to the text
|
|
|
|
* @param aCorner_list = list to fill with polygon corners coordinates
|
|
|
|
* @param Pos = Position of the shape
|
|
|
|
*/
|
2009-11-03 13:26:31 +00:00
|
|
|
void CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
|
|
|
|
const wxPoint& Pos );
|
2009-07-27 14:32:40 +00:00
|
|
|
|
|
|
|
// Geometric transforms (used in block operations):
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2009-07-27 14:32:40 +00:00
|
|
|
/** virtual function Move
|
|
|
|
* move item to a new position.
|
2009-11-03 13:26:31 +00:00
|
|
|
* @param aMoveVector = the displacement vector
|
2009-07-27 14:32:40 +00:00
|
|
|
*/
|
2009-11-03 13:26:31 +00:00
|
|
|
virtual void Move( const wxPoint& aMoveVector )
|
2009-07-27 14:32:40 +00:00
|
|
|
{
|
|
|
|
m_Pos += aMoveVector;
|
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2009-07-27 14:32:40 +00:00
|
|
|
/** virtual function Mirror_Y
|
|
|
|
* mirror item relative to an Y axis
|
|
|
|
* @param aYaxis_position = the y axis position
|
|
|
|
*/
|
2009-11-03 13:26:31 +00:00
|
|
|
virtual void Mirror_Y( int aYaxis_position )
|
2009-07-27 14:32:40 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
m_Edge = m_Edge ? 0 : 1;
|
2009-07-27 14:32:40 +00:00
|
|
|
m_Pos.x -= aYaxis_position;
|
|
|
|
NEGATE( m_Pos.x );
|
|
|
|
m_Pos.x += aYaxis_position;
|
|
|
|
}
|
2010-03-16 18:22:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Compare schematic sheet entry (pin?) name against search string.
|
|
|
|
*
|
|
|
|
* @param aSearchData - Criteria to search against.
|
|
|
|
* @return True if this item matches the search criteria.
|
|
|
|
*/
|
|
|
|
virtual bool Matches( wxFindReplaceData& aSearchData );
|
2008-04-12 18:39:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* class SCH_SHEET
|
2009-11-03 13:26:31 +00:00
|
|
|
* This class is the sheet symbol placed in a schematic, and is the entry point
|
|
|
|
* for a sub schematic
|
2008-04-12 18:39:20 +00:00
|
|
|
*/
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
class SCH_SHEET : public SCH_ITEM
|
2008-04-12 18:39:20 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-11-03 13:26:31 +00:00
|
|
|
wxString m_SheetName; /* this is equivalent to C101 for
|
|
|
|
* components: it is stored in F0 ...
|
|
|
|
* of the file. */
|
2008-04-12 18:39:20 +00:00
|
|
|
private:
|
2008-04-21 06:34:56 +00:00
|
|
|
wxString m_FileName; /*also in SCH_SCREEN (redundant),
|
|
|
|
* but need it here for loading after
|
2009-11-03 13:26:31 +00:00
|
|
|
* reading the sheet description from
|
|
|
|
* file. */
|
2008-04-12 18:39:20 +00:00
|
|
|
public:
|
2009-11-03 13:26:31 +00:00
|
|
|
int m_SheetNameSize; /* Size (height) of the text, used to
|
|
|
|
* draw the sheet name */
|
|
|
|
int m_FileNameSize; /* Size (height) of the text, used to
|
|
|
|
* draw the file name */
|
2008-04-21 06:34:56 +00:00
|
|
|
wxPoint m_Pos;
|
2009-11-03 13:26:31 +00:00
|
|
|
wxSize m_Size; /* Position and Size of *sheet symbol */
|
2008-04-21 06:34:56 +00:00
|
|
|
int m_Layer;
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET_PIN* m_Label; /* Points Be connection, linked
|
|
|
|
* list.*/
|
2009-11-03 13:26:31 +00:00
|
|
|
int m_NbLabel; /* Pins sheet (corresponding to
|
|
|
|
* hierarchical labels) count */
|
|
|
|
SCH_SCREEN* m_AssociatedScreen; /* Associated Screen which
|
|
|
|
* handle the physical data
|
|
|
|
* In complex hierarchies we
|
2009-11-04 20:46:53 +00:00
|
|
|
* can have many SCH_SHEET
|
2009-11-03 13:26:31 +00:00
|
|
|
* using the same data
|
|
|
|
*/
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
public:
|
|
|
|
SCH_SHEET( const wxPoint& pos = wxPoint( 0, 0 ) );
|
|
|
|
~SCH_SHEET();
|
2008-04-12 18:39:20 +00:00
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
return wxT( "SCH_SHEET" );
|
2008-04-12 18:39:20 +00:00
|
|
|
}
|
|
|
|
|
2008-04-21 06:34:56 +00:00
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
/**
|
|
|
|
* Function Save
|
2009-11-03 13:26:31 +00:00
|
|
|
* writes the data structures for this object out to a FILE in "*.sch"
|
|
|
|
* format.
|
2008-04-15 19:38:19 +00:00
|
|
|
* @param aFile The FILE to write to.
|
|
|
|
* @return bool - true if success writing else false.
|
|
|
|
*/
|
2009-11-04 20:46:53 +00:00
|
|
|
bool Save( FILE* aFile ) const;
|
2008-04-30 17:04:22 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
|
|
|
|
SCH_SHEET* GenCopy();
|
|
|
|
void DisplayInfo( WinEDA_DrawFrame* frame );
|
2008-04-30 17:04:22 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
/** Function CleanupSheet
|
2009-11-03 13:26:31 +00:00
|
|
|
* Delete pinsheets which are not corresponding to a hierarchical label
|
2009-01-04 18:52:57 +00:00
|
|
|
* @param aFrame = the schematic frame
|
2010-04-17 10:45:00 +00:00
|
|
|
* @param aRedraw = true to redraw Sheet
|
|
|
|
* @param aSaveForUndoRedo = true to put this sheet in UndoRedo list,
|
|
|
|
* if it is modified.
|
2008-04-21 06:34:56 +00:00
|
|
|
*/
|
2010-04-17 10:45:00 +00:00
|
|
|
void CleanupSheet( WinEDA_SchematicFrame* frame, bool aRedraw, bool aSaveForUndoRedo );
|
2008-04-21 06:34:56 +00:00
|
|
|
|
2009-06-30 19:21:41 +00:00
|
|
|
/** Function GetPenSize
|
|
|
|
* @return the size of the "pen" that be used to draw or plot this item
|
|
|
|
*/
|
2009-11-04 20:46:53 +00:00
|
|
|
virtual int GetPenSize();
|
2009-06-30 19:21:41 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
/** Function Draw
|
|
|
|
* Draw the hierarchical sheet shape
|
|
|
|
* @param aPanel = the current DrawPanel
|
|
|
|
* @param aDc = the current Device Context
|
|
|
|
* @param aOffset = draw offset (usually wxPoint(0,0))
|
|
|
|
* @param aDrawMode = draw mode
|
2009-11-03 13:26:31 +00:00
|
|
|
* @param aColor = color used to draw sheet. Usually -1 to use the normal
|
|
|
|
* color for sheet items
|
2008-04-21 06:34:56 +00:00
|
|
|
*/
|
2009-11-04 20:46:53 +00:00
|
|
|
void Draw( WinEDA_DrawPanel* aPanel,
|
|
|
|
wxDC* aDC,
|
|
|
|
const wxPoint& aOffset,
|
|
|
|
int aDrawMode,
|
|
|
|
int aColor = -1 );
|
2008-04-21 06:34:56 +00:00
|
|
|
|
2009-01-31 18:08:47 +00:00
|
|
|
/** Function HitTest
|
|
|
|
* @return true if the point aPosRef is within item area
|
|
|
|
* @param aPosRef = a wxPoint to test
|
|
|
|
*/
|
2009-11-03 13:26:31 +00:00
|
|
|
bool HitTest( const wxPoint& aPosRef );
|
2009-01-31 18:08:47 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
/** Function GetBoundingBox
|
2009-11-03 13:26:31 +00:00
|
|
|
* @return an EDA_Rect giving the bounding box of the sheet
|
2008-04-21 06:34:56 +00:00
|
|
|
*/
|
2009-11-03 13:26:31 +00:00
|
|
|
EDA_Rect GetBoundingBox();
|
2009-01-31 18:08:47 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
void SwapData( SCH_SHEET* copyitem );
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
/** Function ComponentCount
|
|
|
|
* count our own components, without the power components.
|
2009-01-06 20:09:32 +00:00
|
|
|
* @return the component count.
|
2009-01-04 18:52:57 +00:00
|
|
|
*/
|
2009-11-03 13:26:31 +00:00
|
|
|
int ComponentCount();
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
/** Function Load.
|
|
|
|
* for the sheet: load the file m_FileName
|
|
|
|
* if a screen already exists, the file is already read.
|
2009-11-03 13:26:31 +00:00
|
|
|
* m_AssociatedScreen point on the screen, and its m_RefCount is
|
|
|
|
* incremented
|
2009-01-04 18:52:57 +00:00
|
|
|
* else creates a new associated screen and load the data file.
|
2009-11-03 13:26:31 +00:00
|
|
|
* @param aFrame = a WinEDA_SchematicFrame pointer to the maim schematic
|
|
|
|
* frame
|
2009-01-04 18:52:57 +00:00
|
|
|
* @return true if OK
|
|
|
|
*/
|
2009-11-03 13:26:31 +00:00
|
|
|
bool Load( WinEDA_SchematicFrame* aFrame );
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
/** Function SearchHierarchy
|
|
|
|
* search the existing hierarchy for an instance of screen "FileName".
|
|
|
|
* @param aFilename = the filename to find
|
2009-11-03 13:26:31 +00:00
|
|
|
* @param aFilename = a location to return a pointer to the screen (if
|
|
|
|
* found)
|
2009-01-04 18:52:57 +00:00
|
|
|
* @return bool if found, and a pointer to the screen
|
|
|
|
*/
|
2009-11-03 13:26:31 +00:00
|
|
|
bool SearchHierarchy( wxString aFilename, SCH_SCREEN** aScreen );
|
2009-01-04 18:52:57 +00:00
|
|
|
|
|
|
|
/** Function LocatePathOfScreen
|
|
|
|
* search the existing hierarchy for an instance of screen "FileName".
|
|
|
|
* don't bother looking at the root sheet - it must be unique,
|
2009-11-03 13:26:31 +00:00
|
|
|
* no other references to its m_AssociatedScreen otherwise there would be
|
2009-12-02 21:44:03 +00:00
|
|
|
* loops
|
2009-01-04 18:52:57 +00:00
|
|
|
* in the hierarchy.
|
|
|
|
* @param aScreen = the SCH_SCREEN* screen that we search for
|
2009-12-02 21:44:03 +00:00
|
|
|
* @param aList = the SCH_SHEET_PATH* that must be used
|
2009-01-04 18:52:57 +00:00
|
|
|
* @return true if found
|
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
bool LocatePathOfScreen( SCH_SCREEN* aScreen,
|
|
|
|
SCH_SHEET_PATH* aList );
|
2009-01-06 20:09:32 +00:00
|
|
|
|
|
|
|
/** Function CountSheets
|
|
|
|
* calculates the number of sheets found in "this"
|
|
|
|
* this number includes the full subsheets count
|
|
|
|
* @return the full count of sheets+subsheets contained by "this"
|
|
|
|
*/
|
2009-11-03 13:26:31 +00:00
|
|
|
int CountSheets();
|
2009-01-06 20:09:32 +00:00
|
|
|
|
|
|
|
/** Function GetFileName
|
|
|
|
* return the filename corresponding to this sheet
|
|
|
|
* @return a wxString containing the filename
|
|
|
|
*/
|
2009-11-03 13:26:31 +00:00
|
|
|
wxString GetFileName( void );
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
// Set a new filename without changing anything else
|
|
|
|
void SetFileName( const wxString& aFilename )
|
2008-04-12 18:39:20 +00:00
|
|
|
{
|
2009-01-04 18:52:57 +00:00
|
|
|
m_FileName = aFilename;
|
2008-04-12 18:39:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
/** Function ChangeFileName
|
|
|
|
* Set a new filename and manage data and associated screen
|
|
|
|
* The main difficulty is the filename change in a complex hierarchy.
|
2009-11-03 13:26:31 +00:00
|
|
|
* - if new filename is not already used: change to the new name (and if an
|
2009-12-02 21:44:03 +00:00
|
|
|
* existing file is found, load it on request)
|
2009-11-03 13:26:31 +00:00
|
|
|
* - if new filename is already used (a complex hierarchy) : reference the
|
2009-12-02 21:44:03 +00:00
|
|
|
* sheet.
|
2009-01-04 18:52:57 +00:00
|
|
|
* @param aFileName = the new filename
|
|
|
|
* @param aFrame = the schematic frame
|
|
|
|
*/
|
2009-11-03 13:26:31 +00:00
|
|
|
bool ChangeFileName( WinEDA_SchematicFrame* aFrame,
|
|
|
|
const wxString& aFileName );
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
//void RemoveSheet(SCH_SHEET* sheet);
|
2009-01-04 18:52:57 +00:00
|
|
|
//to remove a sheet, just delete it
|
|
|
|
//-- the destructor should take care of everything else.
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2009-07-27 14:32:40 +00:00
|
|
|
// Geometric transforms (used in block operations):
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2009-07-27 14:32:40 +00:00
|
|
|
/** virtual function Move
|
|
|
|
* move item to a new position.
|
2009-11-03 13:26:31 +00:00
|
|
|
* @param aMoveVector = the displacement vector
|
2009-07-27 14:32:40 +00:00
|
|
|
*/
|
2009-11-03 13:26:31 +00:00
|
|
|
virtual void Move( const wxPoint& aMoveVector )
|
2009-07-27 14:32:40 +00:00
|
|
|
{
|
|
|
|
m_Pos += aMoveVector;
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET_PIN* label = m_Label;
|
2009-07-27 14:32:40 +00:00
|
|
|
while( label != NULL )
|
|
|
|
{
|
|
|
|
label->Move( aMoveVector );
|
|
|
|
label = label->Next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2009-07-27 14:32:40 +00:00
|
|
|
/** virtual function Mirror_Y
|
|
|
|
* mirror item relative to an Y axis
|
|
|
|
* @param aYaxis_position = the y axis position
|
|
|
|
*/
|
2009-11-03 13:26:31 +00:00
|
|
|
virtual void Mirror_Y( int aYaxis_position );
|
2009-07-27 14:32:40 +00:00
|
|
|
|
2010-03-16 18:22:59 +00:00
|
|
|
/**
|
|
|
|
* Compare schematic sheet file and sheet name against search string.
|
|
|
|
*
|
|
|
|
* @param aSearchData - Criteria to search against.
|
|
|
|
* @param aCaseSensitive - True for case sensitive search.
|
|
|
|
* @param aWholeWord - True to match whole word.
|
|
|
|
* @return True if this item matches the search criteria.
|
|
|
|
*/
|
|
|
|
virtual bool Matches( wxFindReplaceData& aSearchData );
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
#if defined(DEBUG)
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
// comment inherited by Doxygen from Base_Struct
|
2009-11-03 13:26:31 +00:00
|
|
|
void Show( int nestLevel, std::ostream& os );
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
#endif
|
2008-04-12 18:39:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* CLASS_DRAWSHEET_H */
|