eeschema: code cleaning, comments added, and the true number of sheets and sheets numbers in complex hierarchies

This commit is contained in:
charras 2009-01-04 18:52:57 +00:00
parent 79472a683e
commit 17cc6f4904
13 changed files with 780 additions and 594 deletions

View File

@ -1,12 +1,6 @@
/******************************************/
/* drawpanel.cpp - WinEDA_DrawPanel class */
/******************************************/
#ifdef __GNUG__
#pragma implementation
#endif
#include "fctsys.h"
#include "common.h"
@ -580,10 +574,14 @@ void WinEDA_DrawPanel::EraseScreen( wxDC* DC )
}
//#define USE_GCDC_IN_KICAD
#ifdef USE_GCDC_IN_KICAD
#include <wx/dcgraph.h>
#if wxUSE_GRAPHICS_CONTEXT
// note: wxUSE_GRAPHICS_CONTEXT must be set to 1 in wxWidgets
// see setup.h in wx Widgets.
// wxWidgets configure can need option --enable-graphics_ctx
// Currently, **only for tests**
//#define USE_GCDC_IN_KICAD // uncommment it to use wxGCDC
#endif
/***************************************************/
void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
/***************************************************/

View File

@ -15,6 +15,7 @@ set(EESCHEMA_SRCS
busentry.cpp
bus-wire-junction.cpp
class_drawsheet.cpp
class_drawsheetpath.cpp
class_hierarchical_PIN_sheet.cpp
class_libentry.cpp
class_libentry_fields.cpp

View File

@ -55,7 +55,7 @@ void WinEDA_SchematicFrame::UpdateSheetNumberAndDate()
****************************************************************************/
void ReAnnotatePowerSymbolsOnly( void )
{
/* Build the screen list (screen, not sheet) */
/* Build the sheet list (sheet, not screen) */
EDA_SheetList SheetList( NULL );
DrawSheetPath* sheet;

View File

@ -37,10 +37,10 @@ DrawSheetStruct::DrawSheetStruct( const wxPoint& pos ) :
SCH_ITEM( NULL, DRAW_SHEET_STRUCT_TYPE )
/***********************************************************/
{
m_Label = NULL;
m_NbLabel = 0;
m_Layer = LAYER_SHEET;
m_Pos = pos;
m_Label = NULL;
m_NbLabel = 0;
m_Layer = LAYER_SHEET;
m_Pos = pos;
m_TimeStamp = GetTimeStamp();
m_SheetNameSize = m_FileNameSize = 60;
m_AssociatedScreen = NULL;
@ -74,28 +74,30 @@ DrawSheetStruct::~DrawSheetStruct()
/**********************************************/
bool DrawSheetStruct::Save( FILE* f ) const
bool DrawSheetStruct::Save( FILE* aFile ) const
/***********************************************/
/* Routine utilisee dans la routine precedente.
* Assure la sauvegarde de la structure LibItemStruct
/** 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 Success = true;
Hierarchical_PIN_Sheet_Struct* SheetLabel;
fprintf( f, "$Sheet\n" );
fprintf( aFile, "$Sheet\n" );
if( fprintf( f, "S %-4d %-4d %-4d %-4d\n",
m_Pos.x, m_Pos.y,
m_Size.x, m_Size.y ) == EOF )
if( fprintf( aFile, "S %-4d %-4d %-4d %-4d\n",
m_Pos.x, m_Pos.y,
m_Size.x, m_Size.y ) == EOF )
{
Success = false;
return Success;
}
//save the unique timestamp, like other shematic parts.
if( fprintf( f, "U %8.8lX\n", m_TimeStamp ) == EOF )
if( fprintf( aFile, "U %8.8lX\n", m_TimeStamp ) == EOF )
{
Success = false; return Success;
}
@ -103,7 +105,7 @@ bool DrawSheetStruct::Save( FILE* f ) const
/* Generation de la liste des 2 textes (sheetname et filename) */
if( !m_SheetName.IsEmpty() )
{
if( fprintf( f, "F0 \"%s\" %d\n", CONV_TO_UTF8( m_SheetName ),
if( fprintf( aFile, "F0 \"%s\" %d\n", CONV_TO_UTF8( m_SheetName ),
m_SheetNameSize ) == EOF )
{
Success = false; return Success;
@ -112,7 +114,7 @@ bool DrawSheetStruct::Save( FILE* f ) const
if( !m_FileName.IsEmpty() )
{
if( fprintf( f, "F1 \"%s\" %d\n", CONV_TO_UTF8( m_FileName ),
if( fprintf( aFile, "F1 \"%s\" %d\n", CONV_TO_UTF8( m_FileName ),
m_FileNameSize ) == EOF )
{
Success = false; return Success;
@ -125,12 +127,12 @@ bool DrawSheetStruct::Save( FILE* f ) const
while( SheetLabel != NULL )
{
SheetLabel->m_Number = l_id;
SheetLabel->Save( f );
SheetLabel->Save( aFile );
l_id++;
SheetLabel = SheetLabel->Next();
}
fprintf( f, "$EndSheet\n" );
fprintf( aFile, "$EndSheet\n" );
return Success;
}
@ -146,7 +148,7 @@ DrawSheetStruct* DrawSheetStruct::GenCopy()
DrawSheetStruct* newitem = new DrawSheetStruct( m_Pos );
newitem->m_Size = m_Size;
newitem->m_Size = m_Size;
newitem->SetParent( m_Parent );
newitem->m_TimeStamp = GetTimeStamp();
@ -242,8 +244,10 @@ void DrawSheetStruct::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* aFrame, bool aRedraw )
/********************************************************************/
/* Delete pinsheets which are not corresponding to a hierarchal label
* if aRedraw != NULL, redraw Sheet
/** Function CleanupSheet
* Delete pinsheets which are not corresponding to a hierarchal label
* @param aRedraw = true to redraw Sheet
* @param aFrame = the schematic frame
*/
{
Hierarchical_PIN_Sheet_Struct* Pinsheet, * NextPinsheet;
@ -257,7 +261,7 @@ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* aFrame, bool aRedraw
/* Search Hlabel corresponding to this Pinsheet */
EDA_BaseStruct* DrawStruct = m_AssociatedScreen->EEDrawList;
SCH_HIERLABEL* HLabel = NULL;
SCH_HIERLABEL* HLabel = NULL;
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
{
if( DrawStruct->Type() != TYPE_SCH_HIERLABEL )
@ -279,58 +283,65 @@ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* aFrame, bool aRedraw
Pinsheet = NextPinsheet;
}
if( aRedraw )
aFrame->DrawPanel->PostDirtyRect( GetBoundingBox() );
if( aRedraw )
aFrame->DrawPanel->PostDirtyRect( GetBoundingBox() );
}
/**************************************************************************************/
void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset,
int DrawMode, int Color )
void DrawSheetStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
const wxPoint& aOffset,
int aDrawMode, int aColor )
/**************************************************************************************/
/* Draw the hierarchical sheet shape */
/** 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
* @param aColor = color used to draw sheet. Usually -1 to use the normal color for sheet items
*/
{
Hierarchical_PIN_Sheet_Struct* SheetLabelStruct;
int txtcolor;
wxString Text;
int color;
wxPoint pos = m_Pos + offset;
wxPoint pos = m_Pos + aOffset;
int LineWidth = g_DrawMinimunLineWidth;
if( Color >= 0 )
color = Color;
if( aColor >= 0 )
color = aColor;
else
color = ReturnLayerColor( m_Layer );
GRSetDrawMode( DC, DrawMode );
GRSetDrawMode( aDC, aDrawMode );
GRRect( &panel->m_ClipBox, DC, pos.x, pos.y,
pos.x + m_Size.x, pos.y + m_Size.y, LineWidth, color );
GRRect( &aPanel->m_ClipBox, aDC, pos.x, pos.y,
pos.x + m_Size.x, pos.y + m_Size.y, LineWidth, color );
/* Draw text : SheetName */
if( Color > 0 )
txtcolor = Color;
if( aColor > 0 )
txtcolor = aColor;
else
txtcolor = ReturnLayerColor( LAYER_SHEETNAME );
Text = wxT( "Sheet: " ) + m_SheetName;
DrawGraphicText( panel, DC,
wxPoint( pos.x, pos.y - 8 ), (EDA_Colors) txtcolor,
Text, TEXT_ORIENT_HORIZ, wxSize( m_SheetNameSize, m_SheetNameSize ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
DrawGraphicText( aPanel, aDC,
wxPoint( pos.x, pos.y - 8 ), (EDA_Colors) txtcolor,
Text, TEXT_ORIENT_HORIZ, wxSize( m_SheetNameSize, m_SheetNameSize ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
/* Draw text : FileName */
if( Color >= 0 )
txtcolor = Color;
if( aColor >= 0 )
txtcolor = aColor;
else
txtcolor = ReturnLayerColor( LAYER_SHEETFILENAME );
Text = wxT( "File: " ) + m_FileName;
DrawGraphicText( panel, DC,
wxPoint( pos.x, pos.y + m_Size.y + 4 ),
(EDA_Colors) txtcolor,
Text, TEXT_ORIENT_HORIZ, wxSize( m_FileNameSize, m_FileNameSize ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, LineWidth );
DrawGraphicText( aPanel, aDC,
wxPoint( pos.x, pos.y + m_Size.y + 4 ),
(EDA_Colors) txtcolor,
Text, TEXT_ORIENT_HORIZ, wxSize( m_FileNameSize, m_FileNameSize ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, LineWidth );
/* Draw text : SheetLabel */
@ -338,7 +349,7 @@ void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
while( SheetLabelStruct != NULL )
{
if( !( SheetLabelStruct->m_Flags & IS_MOVED ) )
SheetLabelStruct->Draw( panel, DC, offset, DrawMode, Color );
SheetLabelStruct->Draw( aPanel, aDC, aOffset, aDrawMode, aColor );
SheetLabelStruct = SheetLabelStruct->Next();
}
}
@ -347,6 +358,10 @@ void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
/*****************************************/
EDA_Rect DrawSheetStruct::GetBoundingBox()
/*****************************************/
/** Function GetBoundingBox
* @return an EDA_Rect giving the bouding box of the sheet
*/
{
int dx, dy;
@ -365,12 +380,15 @@ EDA_Rect DrawSheetStruct::GetBoundingBox()
}
/*******************************************************************/
/************************************/
int DrawSheetStruct::ComponentCount()
/*******************************************************************/
/************************************/
/** Function ComponentCount
* count our own components, without the power components.
* @return the copponent count.
*/
{
//count our own components, without the power components.
int n = 0;
if( m_AssociatedScreen )
@ -381,7 +399,7 @@ int DrawSheetStruct::ComponentCount()
if( bs->Type() == TYPE_SCH_COMPONENT )
{
SCH_COMPONENT* Cmp = (SCH_COMPONENT*) bs;
if( Cmp->GetField(VALUE)->m_Text.GetChar( 0 ) != '#' )
if( Cmp->GetField( VALUE )->m_Text.GetChar( 0 ) != '#' )
n++;
}
if( bs->Type() == DRAW_SHEET_STRUCT_TYPE )
@ -396,10 +414,16 @@ int DrawSheetStruct::ComponentCount()
/*******************************************************************************/
bool DrawSheetStruct::SearchHierarchy( wxString filename, SCH_SCREEN** screen )
bool DrawSheetStruct::SearchHierarchy( wxString aFilename, SCH_SCREEN** aScreen )
/*******************************************************************************/
/** Function SearchHierarchy
* search the existing hierarchy for an instance of screen "FileName".
* @param aFilename = the filename to find
* @param aFilename = a location to return a pointer to the screen (if found)
* @return bool if found, and a pointer to the screen
*/
{
//search the existing hierarchy for an instance of screen "FileName".
if( m_AssociatedScreen )
{
EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList;
@ -409,12 +433,12 @@ bool DrawSheetStruct::SearchHierarchy( wxString filename, SCH_SCREEN** screen )
{
DrawSheetStruct* ss = (DrawSheetStruct*) strct;
if( ss->m_AssociatedScreen
&& ss->m_AssociatedScreen->m_FileName.CmpNoCase( filename ) == 0 )
&& ss->m_AssociatedScreen->m_FileName.CmpNoCase( aFilename ) == 0 )
{
*screen = ss->m_AssociatedScreen;
*aScreen = ss->m_AssociatedScreen;
return true;
}
if( ss->SearchHierarchy( filename, screen ) )
if( ss->SearchHierarchy( aFilename, aScreen ) )
return true;
}
strct = strct->Next();
@ -425,19 +449,24 @@ bool DrawSheetStruct::SearchHierarchy( wxString filename, SCH_SCREEN** screen )
/*******************************************************************************/
bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* screen,
DrawSheetPath* list )
bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* aScreen,
DrawSheetPath* aList )
/*******************************************************************************/
/** Function LocatePathOfScreen
* search the existing hierarchy for an instance of screen "FileName".
* don't bother looking at the root sheet - it must be unique,
* no other references to its m_AssociatedScreen otherwise there would be loops
* in the hierarchy.
* @param aScreen = the SCH_SCREEN* screen that we search for
* @param aList = the DrawSheetPath* that must be used
* @return true if found
*/
{
//search the existing hierarchy for an instance of screen "FileName".
//don't bother looking at the root sheet - it must be unique,
//no other references to its m_AssociatedScreen otherwise there would be loops
//in the hierarchy.
//search the existing hierarchy for an instance of screen "FileName".
if( m_AssociatedScreen )
{
list->Push( this );
if( m_AssociatedScreen == screen )
aList->Push( this );
if( m_AssociatedScreen == aScreen )
return true;
EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList;
while( strct )
@ -445,21 +474,30 @@ bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* screen,
if( strct->Type() == DRAW_SHEET_STRUCT_TYPE )
{
DrawSheetStruct* ss = (DrawSheetStruct*) strct;
if( ss->LocatePathOfScreen( screen, list ) )
if( ss->LocatePathOfScreen( aScreen, aList ) )
return true;
}
strct = strct->Next();
}
list->Pop();
aList->Pop();
}
return false;
}
/*******************************************************************************/
bool DrawSheetStruct::Load( WinEDA_SchematicFrame* frame )
/*******************************************************************************/
/**********************************************************/
bool DrawSheetStruct::Load( WinEDA_SchematicFrame* aFrame )
/***********************************************************/
/** Function Load.
* for the sheet: load the file m_FileName
* if a screen already exists, the file is already read.
* m_AssociatedScreen point on the screen, and its m_RefCount is incremented
* else creates a new associated screen and load the data file.
* @param aFrame = a WinEDA_SchematicFrame pointer to the maim schematic frame
* @return true if OK
*/
{
bool success = true;
@ -478,7 +516,7 @@ bool DrawSheetStruct::Load( WinEDA_SchematicFrame* frame )
{
m_AssociatedScreen = new SCH_SCREEN();
m_AssociatedScreen->m_RefCount++;
success = frame->LoadOneEEFile( m_AssociatedScreen, m_FileName );
success = aFrame->LoadOneEEFile( m_AssociatedScreen, m_FileName );
if( success )
{
EDA_BaseStruct* bs = m_AssociatedScreen->EEDrawList;
@ -487,7 +525,7 @@ bool DrawSheetStruct::Load( WinEDA_SchematicFrame* frame )
if( bs->Type() == DRAW_SHEET_STRUCT_TYPE )
{
DrawSheetStruct* sheetstruct = (DrawSheetStruct*) bs;
if( !sheetstruct->Load( frame ) )
if( !sheetstruct->Load( aFrame ) )
success = false;
}
bs = bs->Next();
@ -529,23 +567,18 @@ wxString DrawSheetStruct::GetFileName( void )
}
/************************************************************/
void DrawSheetStruct::SetFileName( const wxString& aFilename )
/************************************************************/
{
m_FileName = aFilename;
}
/************************************************************************/
bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame,
const wxString& aFileName )
/************************************************************************/
/** Function ChangeFileName
* Set a new filename and manage data and associated screen
* The main difficulty is the filename change in a complex hierarchy.
* - if new filename is not already used: change to the new name (and if an existing file is found, load it on request)
* - if new filename is already used (a complex hierarchy) : reference the sheet.
* @param aFileName = the new filename
* @param aFrame = the schematic frame
*/
bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame,
const wxString& aFileName )
{
if( (GetFileName() == aFileName) && m_AssociatedScreen )
return true;
@ -560,8 +593,8 @@ bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame,
if( m_AssociatedScreen ) //upon initial load, this will be null.
{
msg.Printf( _(
"A Sub Hierarchy named %s exists, Use it (The data in this sheet will be replaced)?" ),
aFileName.GetData() );
"A Sub Hierarchy named %s exists, Use it (The data in this sheet will be replaced)?" ),
aFileName.GetData() );
if( !IsOK( NULL, msg ) )
{
DisplayInfo( NULL, _( "Sheet Filename Renaming Aborted" ) );
@ -572,14 +605,14 @@ bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame,
else if( wxFileExists( aFileName ) ) //do we reload the data from an existing file
{
msg.Printf( _(
"A file named %s exists, load it (otherwise keep current sheet data if possible)?" ),
aFileName.GetData() );
"A file named %s exists, load it (otherwise keep current sheet data if possible)?" ),
aFileName.GetData() );
if( IsOK( NULL, msg ) )
{
LoadFromFile = true;
if ( m_AssociatedScreen ) // Can be NULL if loading a file when creating a new sheet
if( m_AssociatedScreen ) // Can be NULL if loading a file when creating a new sheet
{
m_AssociatedScreen->m_RefCount--; //be careful with these
m_AssociatedScreen->m_RefCount--; //be careful with these
if( m_AssociatedScreen->m_RefCount == 0 )
SAFE_DELETE( m_AssociatedScreen );
m_AssociatedScreen = NULL; //will be created later
@ -646,197 +679,19 @@ void DrawSheetStruct::Show( int nestLevel, std::ostream& os )
wxString s = GetClass();
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">"
<< " sheet_name=\"" << CONV_TO_UTF8( m_SheetName) << '"'
<< ">\n";
<< " sheet_name=\"" << CONV_TO_UTF8( m_SheetName ) << '"'
<< ">\n";
// show all the pins, and check the linked list integrity
Hierarchical_PIN_Sheet_Struct* label;
for( label = m_Label; label; label=label->Next() )
for( label = m_Label; label; label = label->Next() )
{
label->Show( nestLevel+1, os );
label->Show( nestLevel + 1, os );
}
NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n"
<< std::flush;
<< std::flush;
}
#endif
/**********************************************/
/* class to handle a series of sheets *********/
/* a 'path' so to speak.. *********************/
/**********************************************/
DrawSheetPath::DrawSheetPath()
{
for( int i = 0; i<DSLSZ; i++ )
m_sheets[i] = NULL;
m_numSheets = 0;
}
int DrawSheetPath::Cmp( const DrawSheetPath& d ) const
{
if( m_numSheets > d.m_numSheets )
return 1;
if( m_numSheets < d.m_numSheets )
return -1;
//otherwise, same number of sheets.
for( int i = 0; i<m_numSheets; i++ )
{
if( m_sheets[i]->m_TimeStamp > d.m_sheets[i]->m_TimeStamp )
return 1;
if( m_sheets[i]->m_TimeStamp < d.m_sheets[i]->m_TimeStamp )
return -1;
}
return 0;
}
DrawSheetStruct* DrawSheetPath::Last()
{
if( m_numSheets )
return m_sheets[m_numSheets - 1];
return NULL;
}
SCH_SCREEN* DrawSheetPath::LastScreen()
{
if( m_numSheets )
return m_sheets[m_numSheets - 1]->m_AssociatedScreen;
return NULL;
}
EDA_BaseStruct* DrawSheetPath::LastDrawList()
{
if( m_numSheets && m_sheets[m_numSheets - 1]->m_AssociatedScreen )
return m_sheets[m_numSheets - 1]->m_AssociatedScreen->EEDrawList;
return NULL;
}
void DrawSheetPath::Push( DrawSheetStruct* sheet )
{
wxASSERT( m_numSheets <= DSLSZ );
if( m_numSheets < DSLSZ )
{
m_sheets[m_numSheets] = sheet;
m_numSheets++;
}
}
DrawSheetStruct* DrawSheetPath::Pop()
{
if( m_numSheets > 0 )
{
m_numSheets--;
return m_sheets[m_numSheets];
}
return NULL;
}
wxString DrawSheetPath::Path()
{
wxString s, t;
s = wxT( "/" );
//start at 1 to avoid the root sheet,
//which does not need to be added to the path
//it's timestamp changes anyway.
for( int i = 1; i< m_numSheets; i++ )
{
t.Printf( _( "%8.8lX/" ), m_sheets[i]->m_TimeStamp );
s = s + t;
}
return s;
}
wxString DrawSheetPath::PathHumanReadable()
{
wxString s, t;
s = wxT( "/" );
//start at 1 to avoid the root sheet, as above.
for( int i = 1; i< m_numSheets; i++ )
{
s = s + m_sheets[i]->m_SheetName + wxT( "/" );
}
return s;
}
/***********************************************/
void DrawSheetPath::UpdateAllScreenReferences()
/***********************************************/
{
EDA_BaseStruct* t = LastDrawList();
while( t )
{
if( t->Type() == TYPE_SCH_COMPONENT )
{
SCH_COMPONENT* component = (SCH_COMPONENT*) t;
component->GetField(REFERENCE)->m_Text = component->GetRef( this );
component->m_Multi = component->GetUnitSelection( this );
}
t = t->Next();
}
}
bool DrawSheetPath::operator=( const DrawSheetPath& d1 )
{
m_numSheets = d1.m_numSheets;
int i;
for( i = 0; i<m_numSheets; i++ )
{
m_sheets[i] = d1.m_sheets[i];
}
for( ; i<DSLSZ; i++ )
{
m_sheets[i] = 0;
}
return true;
}
bool DrawSheetPath::operator==( const DrawSheetPath& d1 )
{
if( m_numSheets != d1.m_numSheets )
return false;
for( int i = 0; i<m_numSheets; i++ )
{
if( m_sheets[i] != d1.m_sheets[i] )
return false;
}
return true;
}
bool DrawSheetPath::operator!=( const DrawSheetPath& d1 )
{
if( m_numSheets != d1.m_numSheets )
return true;
for( int i = 0; i<m_numSheets; i++ )
{
if( m_sheets[i] != d1.m_sheets[i] )
return true;
}
return false;
}

View File

@ -13,7 +13,11 @@
extern DrawSheetStruct* g_RootSheet;
/* class Hierarchical_PIN_Sheet_Struct
* a Hierarchical_PIN_Sheet_Struct is for a hierarchical sheet like a pin for a component
* At root level, a Hierarchical_PIN_Sheet_Struct must be connected to a wire, bus or label
* A sheet level it corresponds to a hierarchical label.
*/
class Hierarchical_PIN_Sheet_Struct : public SCH_ITEM,
public EDA_TextStruct
{
@ -26,7 +30,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() { }
@ -64,7 +68,6 @@ public:
/* class DrawSheetStruct
* 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 SCH_ITEM
{
@ -107,21 +110,86 @@ public:
void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
DrawSheetStruct* GenCopy();
void Display_Infos( WinEDA_DrawFrame* frame );
/** Function CleanupSheet
* Delete pinsheets which are not corresponding to a hierarchal label
* @param aRedraw = true to redraw Sheet
* @param aFrame = the schematic 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 );
/** 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
* @param aColor = color used to draw sheet. Usually -1 to use the normal color for sheet items
*/
void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aDrawMode, int aColor = -1 );
/** Function GetBoundingBox
* @return an EDA_Rect giving the bouding box of the sheet
*/
EDA_Rect GetBoundingBox();
void SwapData( DrawSheetStruct* copyitem );
/** Function ComponentCount
* count our own components, without the power components.
* @return the copponent count.
*/
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 );
/** Function Load.
* for the sheet: load the file m_FileName
* if a screen already exists, the file is already read.
* m_AssociatedScreen point on the screen, and its m_RefCount is incremented
* else creates a new associated screen and load the data file.
* @param aFrame = a WinEDA_SchematicFrame pointer to the maim schematic frame
* @return true if OK
*/
bool Load( WinEDA_SchematicFrame* aFrame );
/** Function SearchHierarchy
* search the existing hierarchy for an instance of screen "FileName".
* @param aFilename = the filename to find
* @param aFilename = a location to return a pointer to the screen (if found)
* @return bool if found, and a pointer to the screen
*/
bool SearchHierarchy( wxString aFilename, SCH_SCREEN** aScreen );
/** Function LocatePathOfScreen
* search the existing hierarchy for an instance of screen "FileName".
* don't bother looking at the root sheet - it must be unique,
* no other references to its m_AssociatedScreen otherwise there would be loops
* in the hierarchy.
* @param aScreen = the SCH_SCREEN* screen that we search for
* @param aList = the DrawSheetPath* that must be used
* @return true if found
*/
bool LocatePathOfScreen( SCH_SCREEN* aScreen, DrawSheetPath* aList );
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);
// Set a new filename without changing anything else
void SetFileName( const wxString& aFilename )
{
m_FileName = aFilename;
}
/** Function ChangeFileName
* Set a new filename and manage data and associated screen
* The main difficulty is the filename change in a complex hierarchy.
* - if new filename is not already used: change to the new name (and if an existing file is found, load it on request)
* - if new filename is already used (a complex hierarchy) : reference the sheet.
* @param aFileName = the new filename
* @param aFrame = the schematic frame
*/
bool ChangeFileName( WinEDA_SchematicFrame* aFrame, const wxString& aFileName );
//void RemoveSheet(DrawSheetStruct* sheet);
//to remove a sheet, just delete it
//-- the destructor should take care of everything else.
@ -133,104 +201,4 @@ public:
#endif
};
/**********************************************/
/* class to handle a series of sheets *********/
/* a 'path' so to speak.. *********************/
/**********************************************/
class DrawSheetPath
{
public:
int m_numSheets;
#define DSLSZ 32 // Max number of levels for a sheet path
DrawSheetStruct* m_sheets[DSLSZ];
DrawSheetPath();
~DrawSheetPath() { };
void Clear() { m_numSheets = 0; }
int Cmp( const DrawSheetPath& d ) const;
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();
/** 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();
/**
* Function UpdateAllScreenReferences
* updates the reference and the m_Multi parameter (part selection) for all
* components on a screen depending on the actual sheet path.
* 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();
bool operator =( const DrawSheetPath& d1 );
bool operator ==( const DrawSheetPath& d1 );
bool operator !=( const DrawSheetPath& d1 );
};
/*******************************************************/
/* Class to handle the list of *Sheets* in a hierarchy */
/*******************************************************/
// sheets are not unique - can have many sheets with the same
// filename and the same SCH_SCREEN reference.
class EDA_SheetList
{
private:
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;
DrawSheetPath m_currList;
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; }
DrawSheetPath* GetFirst();
DrawSheetPath* GetNext();
DrawSheetPath* GetSheet( int index );
private:
void BuildSheetList( DrawSheetStruct* sheet );
};
#endif /* CLASS_DRAWSHEET_H */

View File

@ -0,0 +1,281 @@
/////////////////////////////////////////////////////////////////////////////
// Name: class_drawsheet.cpp
// Purpose: member functions for DrawSheetStruct
// header = class_drawsheet.h
// Author: jean-pierre Charras
// Modified by:
// Created: 08/02/2006 18:37:02
// RCS-ID:
// Copyright:
// Licence: License GNU
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "fctsys.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
/**********************************************/
/* class to handle a series of sheets *********/
/* a 'path' so to speak.. *********************/
/**********************************************/
DrawSheetPath::DrawSheetPath()
{
for( int i = 0; i<DSLSZ; i++ )
m_sheets[i] = NULL;
m_numSheets = 0;
}
int DrawSheetPath::Cmp( const DrawSheetPath& d ) const
{
if( m_numSheets > d.m_numSheets )
return 1;
if( m_numSheets < d.m_numSheets )
return -1;
//otherwise, same number of sheets.
for( int i = 0; i<m_numSheets; i++ )
{
if( m_sheets[i]->m_TimeStamp > d.m_sheets[i]->m_TimeStamp )
return 1;
if( m_sheets[i]->m_TimeStamp < d.m_sheets[i]->m_TimeStamp )
return -1;
}
return 0;
}
DrawSheetStruct* DrawSheetPath::Last()
{
if( m_numSheets )
return m_sheets[m_numSheets - 1];
return NULL;
}
SCH_SCREEN* DrawSheetPath::LastScreen()
{
if( m_numSheets )
return m_sheets[m_numSheets - 1]->m_AssociatedScreen;
return NULL;
}
EDA_BaseStruct* DrawSheetPath::LastDrawList()
{
if( m_numSheets && m_sheets[m_numSheets - 1]->m_AssociatedScreen )
return m_sheets[m_numSheets - 1]->m_AssociatedScreen->EEDrawList;
return NULL;
}
void DrawSheetPath::Push( DrawSheetStruct* sheet )
{
wxASSERT( m_numSheets <= DSLSZ );
if( m_numSheets < DSLSZ )
{
m_sheets[m_numSheets] = sheet;
m_numSheets++;
}
}
DrawSheetStruct* DrawSheetPath::Pop()
{
if( m_numSheets > 0 )
{
m_numSheets--;
return m_sheets[m_numSheets];
}
return NULL;
}
wxString DrawSheetPath::Path()
{
wxString s, t;
s = wxT( "/" );
//start at 1 to avoid the root sheet,
//which does not need to be added to the path
//it's timestamp changes anyway.
for( int i = 1; i< m_numSheets; i++ )
{
t.Printf( _( "%8.8lX/" ), m_sheets[i]->m_TimeStamp );
s = s + t;
}
return s;
}
wxString DrawSheetPath::PathHumanReadable()
{
wxString s, t;
s = wxT( "/" );
//start at 1 to avoid the root sheet, as above.
for( int i = 1; i< m_numSheets; i++ )
{
s = s + m_sheets[i]->m_SheetName + wxT( "/" );
}
return s;
}
/***********************************************/
void DrawSheetPath::UpdateAllScreenReferences()
/***********************************************/
{
EDA_BaseStruct* t = LastDrawList();
while( t )
{
if( t->Type() == TYPE_SCH_COMPONENT )
{
SCH_COMPONENT* component = (SCH_COMPONENT*) t;
component->GetField(REFERENCE)->m_Text = component->GetRef( this );
component->m_Multi = component->GetUnitSelection( this );
}
t = t->Next();
}
}
bool DrawSheetPath::operator=( const DrawSheetPath& d1 )
{
m_numSheets = d1.m_numSheets;
int i;
for( i = 0; i<m_numSheets; i++ )
{
m_sheets[i] = d1.m_sheets[i];
}
for( ; i<DSLSZ; i++ )
{
m_sheets[i] = 0;
}
return true;
}
bool DrawSheetPath::operator==( const DrawSheetPath& d1 )
{
if( m_numSheets != d1.m_numSheets )
return false;
for( int i = 0; i<m_numSheets; i++ )
{
if( m_sheets[i] != d1.m_sheets[i] )
return false;
}
return true;
}
bool DrawSheetPath::operator!=( const DrawSheetPath& d1 )
{
if( m_numSheets != d1.m_numSheets )
return true;
for( int i = 0; i<m_numSheets; i++ )
{
if( m_sheets[i] != d1.m_sheets[i] )
return true;
}
return false;
}
/*********************************************************************/
/* Class EDA_SheetList to handle the list of Sheets in a hierarchy */
/*********************************************************************/
/*****************************************/
DrawSheetPath* EDA_SheetList::GetFirst()
/*****************************************/
{
m_index = 0;
if( m_count > 0 )
return &( m_List[0] );
return NULL;
}
/*****************************************/
DrawSheetPath* EDA_SheetList::GetNext()
/*****************************************/
{
if( m_index < m_count )
m_index++;
return GetSheet( m_index );
}
/************************************************/
DrawSheetPath* EDA_SheetList::GetSheet( int index )
/************************************************/
/* return the m_List[index] item
*/
{
if( index < m_count )
return &(m_List[index]);
return NULL;
}
/************************************************************************/
void EDA_SheetList::BuildSheetList( DrawSheetStruct* sheet )
/************************************************************************/
{
if( m_List == NULL )
{
int count = sheet->CountSheets();
m_count = count;
m_index = 0;
count *= sizeof(DrawSheetPath);
m_List = (DrawSheetPath*) MyZMalloc( count );
m_currList.Clear();
}
m_currList.Push( sheet );
m_List[m_index] = m_currList;
m_index++;
if( sheet->m_AssociatedScreen != NULL )
{
EDA_BaseStruct* strct = m_currList.LastDrawList();
while( strct )
{
if( strct->Type() == DRAW_SHEET_STRUCT_TYPE )
{
DrawSheetStruct* sht = (DrawSheetStruct*) strct;
BuildSheetList( sht );
}
strct = strct->Next();
}
}
m_currList.Pop();
}

View File

@ -0,0 +1,118 @@
/********************************************/
/* Definitions for the EESchema program: */
/********************************************/
#ifndef CLASS_DRAWSHEET_PATH_H
#define CLASS_DRAWSHEET_PATH_H
#ifndef eda_global
#define eda_global extern
#endif
#include "base_struct.h"
/**********************************************/
/* class to handle a series of sheets *********/
/* a 'path' so to speak.. *********************/
/**********************************************/
class DrawSheetPath
{
public:
int m_numSheets;
#define DSLSZ 32 // Max number of levels for a sheet path
DrawSheetStruct* m_sheets[DSLSZ];
DrawSheetPath();
~DrawSheetPath() { };
void Clear() { m_numSheets = 0; }
int Cmp( const DrawSheetPath& d ) const;
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();
/** 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();
/**
* Function UpdateAllScreenReferences
* updates the reference and the m_Multi parameter (part selection) for all
* components on a screen depending on the actual sheet path.
* 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();
bool operator =( const DrawSheetPath& d1 );
bool operator ==( const DrawSheetPath& d1 );
bool operator !=( const DrawSheetPath& d1 );
};
/*******************************************************/
/* Class to handle the list of *Sheets* in a hierarchy */
/*******************************************************/
/* sheets are not unique - can have many sheets with the same
* filename and the same SCH_SCREEN reference.
* the schematic (SCH_SCREEN) is shared between these sheets,
* and component references are specific to a sheet path.
* When a sheet is entered, component references and sheet number are updated
*/
class EDA_SheetList
{
private:
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;
DrawSheetPath m_currList;
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; }
DrawSheetPath* GetFirst();
DrawSheetPath* GetNext();
DrawSheetPath* GetSheet( int index );
private:
void BuildSheetList( DrawSheetStruct* sheet );
};
#endif /* CLASS_DRAWSHEET_PATH_H */

View File

@ -107,8 +107,8 @@ SCH_SCREEN::SCH_SCREEN( KICAD_T type ) : BASE_SCREEN( type )
for( i = 0; i < SCHEMATIC_GRID_LIST_CNT; i++ )
AddGrid( SchematicGridList[i] );
SetGrid( wxSize( 50, 50 ) ); /* pas de la grille */
m_UndoRedoCountMax = 10;
SetGrid( wxSize( 50, 50 ) ); /* usual grid size */
m_UndoRedoCountMax = 10; // Undo/redo levels count. 10 is a reasonnable value
m_RefCount = 0;
m_Center = false; // Suitable for schematic only. for libedit and viewlib, must be set to true
InitDatas();
@ -286,77 +286,3 @@ void EDA_ScreenList::BuildScreenList( EDA_BaseStruct* s )
}
}
/*********************************************************************/
/* Class EDA_SheetList to handle the list of Sheets in a hierarchy */
/*********************************************************************/
/*****************************************/
DrawSheetPath* EDA_SheetList::GetFirst()
/*****************************************/
{
m_index = 0;
if( m_count > 0 )
return &( m_List[0] );
return NULL;
}
/*****************************************/
DrawSheetPath* EDA_SheetList::GetNext()
/*****************************************/
{
if( m_index < m_count )
m_index++;
return GetSheet( m_index );
}
/************************************************/
DrawSheetPath* EDA_SheetList::GetSheet( int index )
/************************************************/
/* return the m_List[index] item
*/
{
if( index < m_count )
return &(m_List[index]);
return NULL;
}
/************************************************************************/
void EDA_SheetList::BuildSheetList( DrawSheetStruct* sheet )
/************************************************************************/
{
if( m_List == NULL )
{
int count = sheet->CountSheets();
m_count = count;
m_index = 0;
if( m_List )
free( m_List );
m_List = NULL;
count *= sizeof(DrawSheetPath);
m_List = (DrawSheetPath*) MyZMalloc( count );
memset( (void*) m_List, 0, count );
m_currList.Clear();
}
m_currList.Push( sheet );
m_List[m_index] = m_currList;
m_index++;
if( sheet->m_AssociatedScreen != NULL )
{
EDA_BaseStruct* strct = m_currList.LastDrawList();
while( strct )
{
if( strct->Type() == DRAW_SHEET_STRUCT_TYPE )
{
DrawSheetStruct* sht = (DrawSheetStruct*) strct;
BuildSheetList( sht );
}
strct = strct->Next();
}
}
m_currList.Pop();
}

View File

@ -89,7 +89,7 @@ private:
public:
WinEDA_HierFrame( WinEDA_SchematicFrame* parent, wxDC* DC, const wxPoint& pos );
void BuildSheetList( DrawSheetPath* list, wxTreeItemId* previousmenu );
void BuildSheetsTree( DrawSheetPath* list, wxTreeItemId* previousmenu );
~WinEDA_HierFrame();
@ -150,7 +150,7 @@ WinEDA_HierFrame::WinEDA_HierFrame( WinEDA_SchematicFrame* parent, wxDC* DC,
m_Tree->SelectItem( cellule ); //root.
maxposx = 15;
BuildSheetList( &list, &cellule );
BuildSheetsTree( &list, &cellule );
if( m_nbsheets > 1 )
{
@ -180,7 +180,7 @@ void WinEDA_HierFrame::OnQuit( wxCommandEvent& WXUNUSED (event) )
/********************************************************************/
void WinEDA_HierFrame::BuildSheetList( DrawSheetPath* list,
void WinEDA_HierFrame::BuildSheetsTree( DrawSheetPath* list,
wxTreeItemId* previousmenu )
/********************************************************************/
@ -196,7 +196,7 @@ void WinEDA_HierFrame::BuildSheetList( DrawSheetPath* list,
if( m_nbsheets == (NB_MAX_SHEET + 1) )
{
wxString msg;
msg << wxT( "BuildSheetList: Error: nbsheets > " ) << NB_MAX_SHEET;
msg << wxT( "BuildSheetsTree: Error: nbsheets > " ) << NB_MAX_SHEET;
DisplayError( this, msg );
m_nbsheets++;
}
@ -229,7 +229,7 @@ void WinEDA_HierFrame::BuildSheetList( DrawSheetPath* list,
m_Tree->EnsureVisible( menu );
m_Tree->SelectItem( menu );
}
BuildSheetList( list, &menu );
BuildSheetsTree( list, &menu );
m_Tree->Expand( menu );
list->Pop();
}

View File

@ -25,6 +25,7 @@ OBJECTS = eeschema.o\
class_sch_cmp_field.o\
classes_body_items.o\
class_drawsheet.o\
class_drawsheetpath.o\
class_pin.o\
class_hierarchical_PIN_sheet.o\
class_text-label.o\

View File

@ -17,6 +17,7 @@
#include "component_class.h"
#include "class_screen.h"
#include "class_drawsheet.h"
#include "class_drawsheetpath.h"
#include "class_text-label.h"
#include "class_schematic_items.h"

View File

@ -30,96 +30,97 @@
/*******************************/
BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, wxFrame )
COMMON_EVENTS_DRAWFRAME
EVT_SOCKET( ID_EDA_SOCKET_EVENT_SERV,
WinEDA_DrawFrame::OnSockRequestServer )
EVT_SOCKET( ID_EDA_SOCKET_EVENT, WinEDA_DrawFrame::OnSockRequest )
COMMON_EVENTS_DRAWFRAME EVT_SOCKET(
ID_EDA_SOCKET_EVENT_SERV,
WinEDA_DrawFrame::
OnSockRequestServer )
EVT_SOCKET( ID_EDA_SOCKET_EVENT, WinEDA_DrawFrame::OnSockRequest )
EVT_CLOSE( WinEDA_SchematicFrame::OnCloseWindow )
EVT_SIZE( WinEDA_SchematicFrame::OnSize )
EVT_CLOSE( WinEDA_SchematicFrame::OnCloseWindow )
EVT_SIZE( WinEDA_SchematicFrame::OnSize )
EVT_MENU( ID_NEW_PROJECT, WinEDA_SchematicFrame::OnNewProject )
EVT_MENU( ID_LOAD_PROJECT, WinEDA_SchematicFrame::OnLoadProject )
EVT_MENU( ID_NEW_PROJECT, WinEDA_SchematicFrame::OnNewProject )
EVT_MENU( ID_LOAD_PROJECT, WinEDA_SchematicFrame::OnLoadProject )
EVT_MENU_RANGE( ID_LOAD_FILE_1, ID_LOAD_FILE_10,
WinEDA_SchematicFrame::OnLoadFile )
EVT_MENU_RANGE( ID_LOAD_FILE_1, ID_LOAD_FILE_10,
WinEDA_SchematicFrame::OnLoadFile )
EVT_TOOL( ID_NEW_PROJECT, WinEDA_SchematicFrame::OnNewProject )
EVT_TOOL( ID_LOAD_PROJECT, WinEDA_SchematicFrame::OnLoadProject )
EVT_TOOL( ID_NEW_PROJECT, WinEDA_SchematicFrame::OnNewProject )
EVT_TOOL( ID_LOAD_PROJECT, WinEDA_SchematicFrame::OnLoadProject )
EVT_TOOL_RANGE( ID_SCHEMATIC_MAIN_TOOLBAR_START,
ID_SCHEMATIC_MAIN_TOOLBAR_END,
WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL_RANGE( ID_SCHEMATIC_MAIN_TOOLBAR_START,
ID_SCHEMATIC_MAIN_TOOLBAR_END,
WinEDA_SchematicFrame::Process_Special_Functions )
EVT_MENU_RANGE( ID_PREFERENCES_FONT_INFOSCREEN, ID_PREFERENCES_FONT_END,
WinEDA_DrawFrame::ProcessFontPreferences )
EVT_MENU_RANGE( ID_PREFERENCES_FONT_INFOSCREEN, ID_PREFERENCES_FONT_END,
WinEDA_DrawFrame::ProcessFontPreferences )
EVT_MENU( ID_SAVE_PROJECT, WinEDA_SchematicFrame::Save_File )
EVT_MENU( ID_SAVE_ONE_SHEET, WinEDA_SchematicFrame::Save_File )
EVT_MENU( ID_SAVE_ONE_SHEET_AS, WinEDA_SchematicFrame::Save_File )
EVT_TOOL( ID_SAVE_PROJECT, WinEDA_SchematicFrame::Save_File )
EVT_MENU( ID_GEN_PRINT, WinEDA_SchematicFrame::ToPrinter )
EVT_MENU( ID_GEN_PLOT_PS, WinEDA_SchematicFrame::ToPlot_PS )
EVT_MENU( ID_GEN_PLOT_HPGL, WinEDA_SchematicFrame::ToPlot_HPGL )
EVT_MENU( ID_GEN_PLOT_SVG, WinEDA_DrawFrame::SVG_Print )
EVT_MENU( ID_GEN_COPY_SHEET_TO_CLIPBOARD, WinEDA_DrawFrame::CopyToClipboard )
EVT_MENU( ID_GEN_COPY_BLOCK_TO_CLIPBOARD, WinEDA_DrawFrame::CopyToClipboard )
EVT_MENU( ID_EXIT, WinEDA_SchematicFrame::OnExit )
EVT_MENU( ID_SAVE_PROJECT, WinEDA_SchematicFrame::Save_File )
EVT_MENU( ID_SAVE_ONE_SHEET, WinEDA_SchematicFrame::Save_File )
EVT_MENU( ID_SAVE_ONE_SHEET_AS, WinEDA_SchematicFrame::Save_File )
EVT_TOOL( ID_SAVE_PROJECT, WinEDA_SchematicFrame::Save_File )
EVT_MENU( ID_GEN_PRINT, WinEDA_SchematicFrame::ToPrinter )
EVT_MENU( ID_GEN_PLOT_PS, WinEDA_SchematicFrame::ToPlot_PS )
EVT_MENU( ID_GEN_PLOT_HPGL, WinEDA_SchematicFrame::ToPlot_HPGL )
EVT_MENU( ID_GEN_PLOT_SVG, WinEDA_DrawFrame::SVG_Print )
EVT_MENU( ID_GEN_COPY_SHEET_TO_CLIPBOARD, WinEDA_DrawFrame::CopyToClipboard )
EVT_MENU( ID_GEN_COPY_BLOCK_TO_CLIPBOARD, WinEDA_DrawFrame::CopyToClipboard )
EVT_MENU( ID_EXIT, WinEDA_SchematicFrame::OnExit )
EVT_MENU_RANGE( ID_CONFIG_AND_PREFERENCES_START,
ID_CONFIG_AND_PREFERENCES_END,
WinEDA_SchematicFrame::Process_Config )
EVT_TOOL( ID_COLORS_SETUP, WinEDA_SchematicFrame::Process_Config )
EVT_TOOL( ID_OPTIONS_SETUP, WinEDA_SchematicFrame::Process_Config )
EVT_MENU_RANGE( ID_CONFIG_AND_PREFERENCES_START,
ID_CONFIG_AND_PREFERENCES_END,
WinEDA_SchematicFrame::Process_Config )
EVT_TOOL( ID_COLORS_SETUP, WinEDA_SchematicFrame::Process_Config )
EVT_TOOL( ID_OPTIONS_SETUP, WinEDA_SchematicFrame::Process_Config )
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END,
WinEDA_DrawFrame::SetLanguage )
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END,
WinEDA_DrawFrame::SetLanguage )
EVT_TOOL_RANGE( ID_ZOOM_IN_BUTT, ID_ZOOM_PAGE_BUTT,
WinEDA_SchematicFrame::Process_Zoom )
EVT_TOOL_RANGE( ID_ZOOM_IN_BUTT, ID_ZOOM_PAGE_BUTT,
WinEDA_SchematicFrame::Process_Zoom )
EVT_TOOL( ID_TO_LIBRARY, WinEDA_SchematicFrame::OnOpenLibraryEditor )
EVT_TOOL( ID_TO_LIBVIEW, WinEDA_SchematicFrame::OnOpenLibraryViewer )
EVT_TOOL( ID_TO_LIBRARY, WinEDA_SchematicFrame::OnOpenLibraryEditor )
EVT_TOOL( ID_TO_LIBVIEW, WinEDA_SchematicFrame::OnOpenLibraryViewer )
EVT_TOOL( ID_TO_PCB, WinEDA_SchematicFrame::OnOpenPcbnew )
EVT_TOOL( ID_TO_CVPCB, WinEDA_SchematicFrame::OnOpenCvpcb )
EVT_TOOL( ID_TO_PCB, WinEDA_SchematicFrame::OnOpenPcbnew )
EVT_TOOL( ID_TO_CVPCB, WinEDA_SchematicFrame::OnOpenCvpcb )
EVT_TOOL( ID_SHEET_SET, WinEDA_DrawFrame::Process_PageSettings )
EVT_TOOL( ID_HIERARCHY, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( wxID_CUT, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( wxID_COPY, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( wxID_PASTE, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( ID_UNDO_BUTT, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( ID_GET_ANNOTATE, WinEDA_SchematicFrame::OnAnnotate )
EVT_TOOL( ID_GEN_PRINT, WinEDA_SchematicFrame::ToPrinter )
EVT_TOOL( ID_GET_ERC, WinEDA_SchematicFrame::OnErc )
EVT_TOOL( ID_GET_NETLIST, WinEDA_SchematicFrame::OnCreateNetlist )
EVT_TOOL( ID_GET_TOOLS, WinEDA_SchematicFrame::OnCreateBillOfMaterials )
EVT_TOOL( ID_FIND_ITEMS, WinEDA_SchematicFrame::OnFindItems )
EVT_TOOL( ID_BACKANNO_ITEMS, WinEDA_SchematicFrame::OnLoadStuffFile )
EVT_TOOL( ID_SHEET_SET, WinEDA_DrawFrame::Process_PageSettings )
EVT_TOOL( ID_HIERARCHY, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( wxID_CUT, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( wxID_COPY, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( wxID_PASTE, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( ID_UNDO_BUTT, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( ID_GET_ANNOTATE, WinEDA_SchematicFrame::OnAnnotate )
EVT_TOOL( ID_GEN_PRINT, WinEDA_SchematicFrame::ToPrinter )
EVT_TOOL( ID_GET_ERC, WinEDA_SchematicFrame::OnErc )
EVT_TOOL( ID_GET_NETLIST, WinEDA_SchematicFrame::OnCreateNetlist )
EVT_TOOL( ID_GET_TOOLS, WinEDA_SchematicFrame::OnCreateBillOfMaterials )
EVT_TOOL( ID_FIND_ITEMS, WinEDA_SchematicFrame::OnFindItems )
EVT_TOOL( ID_BACKANNO_ITEMS, WinEDA_SchematicFrame::OnLoadStuffFile )
EVT_MENU( ID_GENERAL_HELP, WinEDA_DrawFrame::GetKicadHelp )
EVT_MENU( ID_KICAD_ABOUT, WinEDA_DrawFrame::GetKicadAbout )
EVT_MENU( ID_GENERAL_HELP, WinEDA_DrawFrame::GetKicadHelp )
EVT_MENU( ID_KICAD_ABOUT, WinEDA_DrawFrame::GetKicadAbout )
// Tools et boutons de Schematique, Vertical toolbar:
EVT_TOOL_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START,
ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
WinEDA_SchematicFrame::Process_Special_Functions )
// Tools et boutons de Schematique, Vertical toolbar:
EVT_TOOL_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START,
ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL_RCLICKED( ID_LABEL_BUTT, WinEDA_SchematicFrame::ToolOnRightClick )
EVT_TOOL_RCLICKED( ID_GLABEL_BUTT, WinEDA_SchematicFrame::ToolOnRightClick )
EVT_TOOL_RCLICKED( ID_HIERLABEL_BUTT,
WinEDA_SchematicFrame::ToolOnRightClick )
EVT_TOOL_RCLICKED( ID_LABEL_BUTT, WinEDA_SchematicFrame::ToolOnRightClick )
EVT_TOOL_RCLICKED( ID_GLABEL_BUTT, WinEDA_SchematicFrame::ToolOnRightClick )
EVT_TOOL_RCLICKED( ID_HIERLABEL_BUTT,
WinEDA_SchematicFrame::ToolOnRightClick )
EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE,
WinEDA_SchematicFrame::Process_Special_Functions )
EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE,
WinEDA_SchematicFrame::Process_Special_Functions )
// Tools et boutons de Schematique, Options toolbar:
EVT_TOOL_RANGE( ID_TB_OPTIONS_START, ID_TB_OPTIONS_END,
WinEDA_SchematicFrame::OnSelectOptionToolbar )
// Tools et boutons de Schematique, Options toolbar:
EVT_TOOL_RANGE( ID_TB_OPTIONS_START, ID_TB_OPTIONS_END,
WinEDA_SchematicFrame::OnSelectOptionToolbar )
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
WinEDA_SchematicFrame::Process_Special_Functions )
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
WinEDA_SchematicFrame::Process_Special_Functions )
END_EVENT_TABLE()
@ -128,25 +129,25 @@ END_EVENT_TABLE()
/* Constructor */
/****************/
WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father,
WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style ) :
const wxPoint& pos,
const wxSize& size,
long style ) :
WinEDA_DrawFrame( father, SCHEMATIC_FRAME, title, pos, size, style )
{
wxConfig* config = wxGetApp().m_EDA_Config;
m_FrameName = wxT( "SchematicFrame" );
m_Draw_Axis = FALSE; // TRUE to show axis
m_Draw_Grid = g_ShowGrid; // TRUE to show a grid
m_FrameName = wxT( "SchematicFrame" );
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 DrawSheetPath();
m_CurrentField = NULL;
m_Multiflag = 0;
m_TextFieldSize = DEFAULT_SIZE_TEXT;
m_LibeditFrame = NULL; // Component editor frame.
m_ViewlibFrame = NULL; // Frame for browsing component libraries
m_Multiflag = 0;
m_TextFieldSize = DEFAULT_SIZE_TEXT;
m_LibeditFrame = NULL; // Component editor frame.
m_ViewlibFrame = NULL; // Frame for browsing component libraries
CreateScreens();
@ -212,27 +213,41 @@ 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
* must be called after a delete or add sheet command, and when entering a sheet
*/
{
SCH_SCREEN* screen = GetScreen();
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();
}
}
/* Set the sheet count, and the sheet number (1 for root sheet)
*/
int sheet_count = g_RootSheet->CountSheets();
int SheetNumber = 1;
wxString current_sheetpath = m_CurrentSheet->Path();
EDA_SheetList SheetList( NULL );
// Examine all sheets path to find the current sheets path,
// and count them from root to the current scheet path:
DrawSheetPath* sheet;
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
{
wxString sheetpath = sheet->Path();
if( sheetpath == current_sheetpath ) // Current sheet path found
break;
SheetNumber++; // not found, increment sheet number before this current path
}
for( screen = s_list.GetFirst(); screen != NULL; screen = s_list.GetNext() )
{
screen->m_NumberOfScreen = sheet_count;
}
GetScreen()->m_ScreenNumber = SheetNumber;
}
SCH_SCREEN* WinEDA_SchematicFrame::GetScreen() const
@ -278,7 +293,7 @@ void WinEDA_SchematicFrame::CreateScreens()
g_RootSheet->m_AssociatedScreen->m_RefCount++;
}
g_RootSheet->m_AssociatedScreen->m_FileName = g_DefaultSchematicFileName;
g_RootSheet->m_AssociatedScreen->m_Date = GenDate();
g_RootSheet->m_AssociatedScreen->m_Date = GenDate();
m_CurrentSheet->Clear();
m_CurrentSheet->Push( g_RootSheet );
@ -302,7 +317,7 @@ void WinEDA_SchematicFrame::OnCloseWindow( wxCloseEvent& Event )
return;
}
EDA_SheetList sheets( g_RootSheet );
EDA_SheetList sheets( g_RootSheet );
for( sheet = sheets.GetFirst(); sheet != NULL; sheet = sheets.GetNext() )
{
@ -343,8 +358,8 @@ void WinEDA_SchematicFrame::OnCloseWindow( wxCloseEvent& Event )
}
}
if( !g_RootSheet->m_AssociatedScreen->m_FileName.IsEmpty() &&
(g_RootSheet->m_AssociatedScreen->EEDrawList != NULL) )
if( !g_RootSheet->m_AssociatedScreen->m_FileName.IsEmpty()
&& (g_RootSheet->m_AssociatedScreen->EEDrawList != NULL) )
SetLastProject( g_RootSheet->m_AssociatedScreen->m_FileName );
ClearProjectDrawList( g_RootSheet->m_AssociatedScreen, TRUE );
@ -366,8 +381,8 @@ void WinEDA_SchematicFrame::OnCloseWindow( wxCloseEvent& Event )
/*****************************************************************************
* Enable or disable some tools according to current conditions
*****************************************************************************/
* Enable or disable some tools according to current conditions
*****************************************************************************/
void WinEDA_SchematicFrame::SetToolbars()
{
if( m_HToolBar )
@ -415,23 +430,26 @@ void WinEDA_SchematicFrame::SetToolbars()
{
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_GRID, m_Draw_Grid );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_GRID,
m_Draw_Grid ? _( "Grid not show" ) : _( "Show Grid" ) );
m_Draw_Grid ? _( "Grid not show" ) : _( "Show Grid" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_MM,
g_UnitMetric == MILLIMETRE ? TRUE : FALSE );
g_UnitMetric == MILLIMETRE ? TRUE : FALSE );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH,
g_UnitMetric == INCHES ? TRUE : FALSE );
g_UnitMetric == INCHES ? TRUE : FALSE );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR,
g_CursorShape );
g_CursorShape );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_HIDDEN_PINS, g_ShowAllPins );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_HIDDEN_PINS,
g_ShowAllPins ? _( "No show Hidden Pins" ) : _( "Show Hidden Pins" ) );
g_ShowAllPins ? _( "No show Hidden Pins" ) : _(
"Show Hidden Pins" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_BUS_WIRES_ORIENT,
g_HVLines );
g_HVLines );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_BUS_WIRES_ORIENT,
g_HVLines ? _( "Allows any direction for wires and busses" ) :
_( "Allows horizontal and vertical wires and busses only" ) );
g_HVLines ? _(
"Allows any direction for wires and busses" ) :
_(
"Allows horizontal and vertical wires and busses only" ) );
}
DisplayUnitsMsg();
@ -459,31 +477,36 @@ int WinEDA_SchematicFrame::BestZoom()
return bestzoom;
}
/**************************************************************/
void WinEDA_SchematicFrame::OnAnnotate( wxCommandEvent& event )
/**************************************************************/
{
WinEDA_AnnotateFrame* dlg = new WinEDA_AnnotateFrame( this );
dlg->ShowModal();
dlg->Destroy();
}
/*********************************************************/
void WinEDA_SchematicFrame::OnErc( wxCommandEvent& event )
/*********************************************************/
{
WinEDA_ErcFrame* dlg = new WinEDA_ErcFrame( this );
dlg->ShowModal();
dlg->Destroy();
}
/*******************************************************************/
void WinEDA_SchematicFrame::OnCreateNetlist( wxCommandEvent& event )
/*******************************************************************/
{
int i;
if ( g_NetFormat < NET_TYPE_PCBNEW )
if( g_NetFormat < NET_TYPE_PCBNEW )
g_NetFormat = NET_TYPE_PCBNEW;
do
@ -492,18 +515,22 @@ void WinEDA_SchematicFrame::OnCreateNetlist( wxCommandEvent& event )
i = dlg->ShowModal();
dlg->Destroy();
} while( i == NET_PLUGIN_CHANGE );
// If a plugin is removed or added, rebuild and reopen the new dialog
}
/**********************************************************************/
void WinEDA_SchematicFrame::OnCreateBillOfMaterials( wxCommandEvent & )
void WinEDA_SchematicFrame::OnCreateBillOfMaterials( wxCommandEvent& )
/**********************************************************************/
{
WinEDA_Build_BOM_Frame* dlg = new WinEDA_Build_BOM_Frame( this );
dlg->ShowModal();
dlg->Destroy();
}
/*******************************************************************/
void WinEDA_SchematicFrame::OnFindItems( wxCommandEvent& event )
/*******************************************************************/
@ -515,24 +542,27 @@ void WinEDA_SchematicFrame::OnFindItems( wxCommandEvent& event )
this->DrawPanel->m_IgnoreMouseEvents = FALSE;
}
/***************************************************************/
void WinEDA_SchematicFrame::OnLoadFile( wxCommandEvent& event )
/***************************************************************/
{
int i = event.GetId() - ID_LOAD_FILE_1;
LoadOneEEProject( GetLastProject( i ).GetData( ), false );
LoadOneEEProject( GetLastProject( i ).GetData(), false );
SetToolbars();
}
/*******************************************************************/
void WinEDA_SchematicFrame::OnLoadStuffFile( wxCommandEvent& event )
/*******************************************************************/
{
ReadInputStuffFile( );
ReadInputStuffFile();
DrawPanel->Refresh();
}
/****************************************************************/
void WinEDA_SchematicFrame::OnNewProject( wxCommandEvent& event )
/****************************************************************/
@ -540,6 +570,7 @@ void WinEDA_SchematicFrame::OnNewProject( wxCommandEvent& event )
LoadOneEEProject( wxEmptyString, true );
}
/*****************************************************************/
void WinEDA_SchematicFrame::OnLoadProject( wxCommandEvent& event )
/*****************************************************************/
@ -547,6 +578,7 @@ void WinEDA_SchematicFrame::OnLoadProject( wxCommandEvent& event )
LoadOneEEProject( wxEmptyString, false );
}
/****************************************************************/
void WinEDA_SchematicFrame::OnOpenPcbnew( wxCommandEvent& event )
/****************************************************************/
@ -563,6 +595,7 @@ void WinEDA_SchematicFrame::OnOpenPcbnew( wxCommandEvent& event )
ExecuteFile( this, PCBNEW_EXE );
}
/***************************************************************/
void WinEDA_SchematicFrame::OnOpenCvpcb( wxCommandEvent& event )
/***************************************************************/
@ -579,6 +612,7 @@ void WinEDA_SchematicFrame::OnOpenCvpcb( wxCommandEvent& event )
ExecuteFile( this, CVPCB_EXE );
}
/*************************************************************************/
void WinEDA_SchematicFrame::OnOpenLibraryViewer( wxCommandEvent& event )
/*************************************************************************/
@ -594,6 +628,7 @@ void WinEDA_SchematicFrame::OnOpenLibraryViewer( wxCommandEvent& event )
}
}
/*************************************************************************/
void WinEDA_SchematicFrame::OnOpenLibraryEditor( wxCommandEvent& event )
/*************************************************************************/
@ -605,14 +640,15 @@ void WinEDA_SchematicFrame::OnOpenLibraryEditor( wxCommandEvent& event )
else
{
m_LibeditFrame = new WinEDA_LibeditFrame( this,
wxT( "Library Editor" ),
wxPoint( -1, -1 ),
wxSize( 600, 400 ) );
wxT( "Library Editor" ),
wxPoint( -1, -1 ),
wxSize( 600, 400 ) );
ActiveScreen = g_ScreenLib;
m_LibeditFrame->AdjustScrollBars();
}
}
void WinEDA_SchematicFrame::OnExit( wxCommandEvent& event )
{
Close( true );

View File

@ -62,6 +62,7 @@ endif
SYSWXLIB = `$(WXWIN)/wx-config --libs gl`\
-lwxpng-$(LIBVERSION) -lwxjpeg-$(LIBVERSION) -lwxzlib-$(LIBVERSION) $(PYLIBS)
CC = gcc
.cpp.o: