Loading common/drawpanel.cpp +7 −9 Original line number Original line Diff line number Diff line /******************************************/ /******************************************/ /* drawpanel.cpp - WinEDA_DrawPanel class */ /* drawpanel.cpp - WinEDA_DrawPanel class */ /******************************************/ /******************************************/ #ifdef __GNUG__ #pragma implementation #endif #include "fctsys.h" #include "fctsys.h" #include "common.h" #include "common.h" Loading Loading @@ -580,10 +574,14 @@ void WinEDA_DrawPanel::EraseScreen( wxDC* DC ) } } //#define USE_GCDC_IN_KICAD #if wxUSE_GRAPHICS_CONTEXT #ifdef USE_GCDC_IN_KICAD // note: wxUSE_GRAPHICS_CONTEXT must be set to 1 in wxWidgets #include <wx/dcgraph.h> // 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 #endif /***************************************************/ /***************************************************/ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) /***************************************************/ /***************************************************/ Loading eeschema/CMakeLists.txt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -15,6 +15,7 @@ set(EESCHEMA_SRCS busentry.cpp busentry.cpp bus-wire-junction.cpp bus-wire-junction.cpp class_drawsheet.cpp class_drawsheet.cpp class_drawsheetpath.cpp class_hierarchical_PIN_sheet.cpp class_hierarchical_PIN_sheet.cpp class_libentry.cpp class_libentry.cpp class_libentry_fields.cpp class_libentry_fields.cpp Loading eeschema/annotate.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -55,7 +55,7 @@ void WinEDA_SchematicFrame::UpdateSheetNumberAndDate() ****************************************************************************/ ****************************************************************************/ void ReAnnotatePowerSymbolsOnly( void ) void ReAnnotatePowerSymbolsOnly( void ) { { /* Build the screen list (screen, not sheet) */ /* Build the sheet list (sheet, not screen) */ EDA_SheetList SheetList( NULL ); EDA_SheetList SheetList( NULL ); DrawSheetPath* sheet; DrawSheetPath* sheet; Loading eeschema/class_drawsheet.cpp +129 −274 Original line number Original line Diff line number Diff line Loading @@ -74,19 +74,21 @@ DrawSheetStruct::~DrawSheetStruct() /**********************************************/ /**********************************************/ bool DrawSheetStruct::Save( FILE* f ) const bool DrawSheetStruct::Save( FILE* aFile ) const /***********************************************/ /***********************************************/ /* Routine utilisee dans la routine precedente. /** Function Save * Assure la sauvegarde de la structure LibItemStruct * 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; bool Success = true; Hierarchical_PIN_Sheet_Struct* SheetLabel; Hierarchical_PIN_Sheet_Struct* SheetLabel; fprintf( f, "$Sheet\n" ); fprintf( aFile, "$Sheet\n" ); if( fprintf( f, "S %-4d %-4d %-4d %-4d\n", if( fprintf( aFile, "S %-4d %-4d %-4d %-4d\n", m_Pos.x, m_Pos.y, m_Pos.x, m_Pos.y, m_Size.x, m_Size.y ) == EOF ) m_Size.x, m_Size.y ) == EOF ) { { Loading @@ -95,7 +97,7 @@ bool DrawSheetStruct::Save( FILE* f ) const } } //save the unique timestamp, like other shematic parts. //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; Success = false; return Success; } } Loading @@ -103,7 +105,7 @@ bool DrawSheetStruct::Save( FILE* f ) const /* Generation de la liste des 2 textes (sheetname et filename) */ /* Generation de la liste des 2 textes (sheetname et filename) */ if( !m_SheetName.IsEmpty() ) 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 ) m_SheetNameSize ) == EOF ) { { Success = false; return Success; Success = false; return Success; Loading @@ -112,7 +114,7 @@ bool DrawSheetStruct::Save( FILE* f ) const if( !m_FileName.IsEmpty() ) 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 ) m_FileNameSize ) == EOF ) { { Success = false; return Success; Success = false; return Success; Loading @@ -125,12 +127,12 @@ bool DrawSheetStruct::Save( FILE* f ) const while( SheetLabel != NULL ) while( SheetLabel != NULL ) { { SheetLabel->m_Number = l_id; SheetLabel->m_Number = l_id; SheetLabel->Save( f ); SheetLabel->Save( aFile ); l_id++; l_id++; SheetLabel = SheetLabel->Next(); SheetLabel = SheetLabel->Next(); } } fprintf( f, "$EndSheet\n" ); fprintf( aFile, "$EndSheet\n" ); return Success; return Success; } } Loading Loading @@ -242,8 +244,10 @@ void DrawSheetStruct::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* aFrame, bool aRedraw ) void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* aFrame, bool aRedraw ) /********************************************************************/ /********************************************************************/ /* Delete pinsheets which are not corresponding to a hierarchal label /** Function CleanupSheet * if aRedraw != NULL, redraw Sheet * 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; Hierarchical_PIN_Sheet_Struct* Pinsheet, * NextPinsheet; Loading Loading @@ -281,52 +285,59 @@ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* aFrame, bool aRedraw if( aRedraw ) if( aRedraw ) aFrame->DrawPanel->PostDirtyRect( GetBoundingBox() ); aFrame->DrawPanel->PostDirtyRect( GetBoundingBox() ); } } /**************************************************************************************/ /**************************************************************************************/ void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, void DrawSheetStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& offset, const wxPoint& aOffset, int DrawMode, int Color ) 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; Hierarchical_PIN_Sheet_Struct* SheetLabelStruct; int txtcolor; int txtcolor; wxString Text; wxString Text; int color; int color; wxPoint pos = m_Pos + offset; wxPoint pos = m_Pos + aOffset; int LineWidth = g_DrawMinimunLineWidth; int LineWidth = g_DrawMinimunLineWidth; if( Color >= 0 ) if( aColor >= 0 ) color = Color; color = aColor; else else color = ReturnLayerColor( m_Layer ); color = ReturnLayerColor( m_Layer ); GRSetDrawMode( DC, DrawMode ); GRSetDrawMode( aDC, aDrawMode ); GRRect( &panel->m_ClipBox, DC, pos.x, pos.y, GRRect( &aPanel->m_ClipBox, aDC, pos.x, pos.y, pos.x + m_Size.x, pos.y + m_Size.y, LineWidth, color ); pos.x + m_Size.x, pos.y + m_Size.y, LineWidth, color ); /* Draw text : SheetName */ /* Draw text : SheetName */ if( Color > 0 ) if( aColor > 0 ) txtcolor = Color; txtcolor = aColor; else else txtcolor = ReturnLayerColor( LAYER_SHEETNAME ); txtcolor = ReturnLayerColor( LAYER_SHEETNAME ); Text = wxT( "Sheet: " ) + m_SheetName; Text = wxT( "Sheet: " ) + m_SheetName; DrawGraphicText( panel, DC, DrawGraphicText( aPanel, aDC, wxPoint( pos.x, pos.y - 8 ), (EDA_Colors) txtcolor, wxPoint( pos.x, pos.y - 8 ), (EDA_Colors) txtcolor, Text, TEXT_ORIENT_HORIZ, wxSize( m_SheetNameSize, m_SheetNameSize ), Text, TEXT_ORIENT_HORIZ, wxSize( m_SheetNameSize, m_SheetNameSize ), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth ); GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth ); /* Draw text : FileName */ /* Draw text : FileName */ if( Color >= 0 ) if( aColor >= 0 ) txtcolor = Color; txtcolor = aColor; else else txtcolor = ReturnLayerColor( LAYER_SHEETFILENAME ); txtcolor = ReturnLayerColor( LAYER_SHEETFILENAME ); Text = wxT( "File: " ) + m_FileName; Text = wxT( "File: " ) + m_FileName; DrawGraphicText( panel, DC, DrawGraphicText( aPanel, aDC, wxPoint( pos.x, pos.y + m_Size.y + 4 ), wxPoint( pos.x, pos.y + m_Size.y + 4 ), (EDA_Colors) txtcolor, (EDA_Colors) txtcolor, Text, TEXT_ORIENT_HORIZ, wxSize( m_FileNameSize, m_FileNameSize ), Text, TEXT_ORIENT_HORIZ, wxSize( m_FileNameSize, m_FileNameSize ), Loading @@ -338,7 +349,7 @@ void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, while( SheetLabelStruct != NULL ) while( SheetLabelStruct != NULL ) { { if( !( SheetLabelStruct->m_Flags & IS_MOVED ) ) if( !( SheetLabelStruct->m_Flags & IS_MOVED ) ) SheetLabelStruct->Draw( panel, DC, offset, DrawMode, Color ); SheetLabelStruct->Draw( aPanel, aDC, aOffset, aDrawMode, aColor ); SheetLabelStruct = SheetLabelStruct->Next(); SheetLabelStruct = SheetLabelStruct->Next(); } } } } Loading @@ -347,6 +358,10 @@ void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, /*****************************************/ /*****************************************/ EDA_Rect DrawSheetStruct::GetBoundingBox() EDA_Rect DrawSheetStruct::GetBoundingBox() /*****************************************/ /*****************************************/ /** Function GetBoundingBox * @return an EDA_Rect giving the bouding box of the sheet */ { { int dx, dy; int dx, dy; Loading @@ -365,12 +380,15 @@ EDA_Rect DrawSheetStruct::GetBoundingBox() } } /************************************/ /*******************************************************************/ int DrawSheetStruct::ComponentCount() 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; int n = 0; if( m_AssociatedScreen ) if( m_AssociatedScreen ) Loading @@ -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 ) if( m_AssociatedScreen ) { { EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList; EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList; Loading @@ -409,12 +433,12 @@ bool DrawSheetStruct::SearchHierarchy( wxString filename, SCH_SCREEN** screen ) { { DrawSheetStruct* ss = (DrawSheetStruct*) strct; DrawSheetStruct* ss = (DrawSheetStruct*) strct; if( ss->m_AssociatedScreen 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; return true; } } if( ss->SearchHierarchy( filename, screen ) ) if( ss->SearchHierarchy( aFilename, aScreen ) ) return true; return true; } } strct = strct->Next(); strct = strct->Next(); Loading @@ -425,19 +449,24 @@ bool DrawSheetStruct::SearchHierarchy( wxString filename, SCH_SCREEN** screen ) /*******************************************************************************/ /*******************************************************************************/ bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* screen, bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* aScreen, DrawSheetPath* list ) 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 ) if( m_AssociatedScreen ) { { list->Push( this ); aList->Push( this ); if( m_AssociatedScreen == screen ) if( m_AssociatedScreen == aScreen ) return true; return true; EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList; EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList; while( strct ) while( strct ) Loading @@ -445,21 +474,30 @@ bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* screen, if( strct->Type() == DRAW_SHEET_STRUCT_TYPE ) if( strct->Type() == DRAW_SHEET_STRUCT_TYPE ) { { DrawSheetStruct* ss = (DrawSheetStruct*) strct; DrawSheetStruct* ss = (DrawSheetStruct*) strct; if( ss->LocatePathOfScreen( screen, list ) ) if( ss->LocatePathOfScreen( aScreen, aList ) ) return true; return true; } } strct = strct->Next(); strct = strct->Next(); } } list->Pop(); aList->Pop(); } } return false; 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; bool success = true; Loading @@ -478,7 +516,7 @@ bool DrawSheetStruct::Load( WinEDA_SchematicFrame* frame ) { { m_AssociatedScreen = new SCH_SCREEN(); m_AssociatedScreen = new SCH_SCREEN(); m_AssociatedScreen->m_RefCount++; m_AssociatedScreen->m_RefCount++; success = frame->LoadOneEEFile( m_AssociatedScreen, m_FileName ); success = aFrame->LoadOneEEFile( m_AssociatedScreen, m_FileName ); if( success ) if( success ) { { EDA_BaseStruct* bs = m_AssociatedScreen->EEDrawList; EDA_BaseStruct* bs = m_AssociatedScreen->EEDrawList; Loading @@ -487,7 +525,7 @@ bool DrawSheetStruct::Load( WinEDA_SchematicFrame* frame ) if( bs->Type() == DRAW_SHEET_STRUCT_TYPE ) if( bs->Type() == DRAW_SHEET_STRUCT_TYPE ) { { DrawSheetStruct* sheetstruct = (DrawSheetStruct*) bs; DrawSheetStruct* sheetstruct = (DrawSheetStruct*) bs; if( !sheetstruct->Load( frame ) ) if( !sheetstruct->Load( aFrame ) ) success = false; success = false; } } bs = bs->Next(); bs = bs->Next(); Loading Loading @@ -529,23 +567,18 @@ wxString DrawSheetStruct::GetFileName( void ) } } /************************************************************/ /************************************************************************/ void DrawSheetStruct::SetFileName( const wxString& aFilename ) bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame, /************************************************************/ const wxString& aFileName ) { /************************************************************************/ m_FileName = aFilename; } /** Function ChangeFileName /** Function ChangeFileName * Set a new filename and manage data and associated screen * Set a new filename and manage data and associated screen * The main difficulty is the filename change in a complex hierarchy. * 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 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. * - 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 ) if( (GetFileName() == aFileName) && m_AssociatedScreen ) return true; return true; Loading Loading @@ -659,184 +692,6 @@ void DrawSheetStruct::Show( int nestLevel, std::ostream& os ) NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n" 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() #endif { 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; } Loading
common/drawpanel.cpp +7 −9 Original line number Original line Diff line number Diff line /******************************************/ /******************************************/ /* drawpanel.cpp - WinEDA_DrawPanel class */ /* drawpanel.cpp - WinEDA_DrawPanel class */ /******************************************/ /******************************************/ #ifdef __GNUG__ #pragma implementation #endif #include "fctsys.h" #include "fctsys.h" #include "common.h" #include "common.h" Loading Loading @@ -580,10 +574,14 @@ void WinEDA_DrawPanel::EraseScreen( wxDC* DC ) } } //#define USE_GCDC_IN_KICAD #if wxUSE_GRAPHICS_CONTEXT #ifdef USE_GCDC_IN_KICAD // note: wxUSE_GRAPHICS_CONTEXT must be set to 1 in wxWidgets #include <wx/dcgraph.h> // 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 #endif /***************************************************/ /***************************************************/ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) /***************************************************/ /***************************************************/ Loading
eeschema/CMakeLists.txt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -15,6 +15,7 @@ set(EESCHEMA_SRCS busentry.cpp busentry.cpp bus-wire-junction.cpp bus-wire-junction.cpp class_drawsheet.cpp class_drawsheet.cpp class_drawsheetpath.cpp class_hierarchical_PIN_sheet.cpp class_hierarchical_PIN_sheet.cpp class_libentry.cpp class_libentry.cpp class_libentry_fields.cpp class_libentry_fields.cpp Loading
eeschema/annotate.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -55,7 +55,7 @@ void WinEDA_SchematicFrame::UpdateSheetNumberAndDate() ****************************************************************************/ ****************************************************************************/ void ReAnnotatePowerSymbolsOnly( void ) void ReAnnotatePowerSymbolsOnly( void ) { { /* Build the screen list (screen, not sheet) */ /* Build the sheet list (sheet, not screen) */ EDA_SheetList SheetList( NULL ); EDA_SheetList SheetList( NULL ); DrawSheetPath* sheet; DrawSheetPath* sheet; Loading
eeschema/class_drawsheet.cpp +129 −274 Original line number Original line Diff line number Diff line Loading @@ -74,19 +74,21 @@ DrawSheetStruct::~DrawSheetStruct() /**********************************************/ /**********************************************/ bool DrawSheetStruct::Save( FILE* f ) const bool DrawSheetStruct::Save( FILE* aFile ) const /***********************************************/ /***********************************************/ /* Routine utilisee dans la routine precedente. /** Function Save * Assure la sauvegarde de la structure LibItemStruct * 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; bool Success = true; Hierarchical_PIN_Sheet_Struct* SheetLabel; Hierarchical_PIN_Sheet_Struct* SheetLabel; fprintf( f, "$Sheet\n" ); fprintf( aFile, "$Sheet\n" ); if( fprintf( f, "S %-4d %-4d %-4d %-4d\n", if( fprintf( aFile, "S %-4d %-4d %-4d %-4d\n", m_Pos.x, m_Pos.y, m_Pos.x, m_Pos.y, m_Size.x, m_Size.y ) == EOF ) m_Size.x, m_Size.y ) == EOF ) { { Loading @@ -95,7 +97,7 @@ bool DrawSheetStruct::Save( FILE* f ) const } } //save the unique timestamp, like other shematic parts. //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; Success = false; return Success; } } Loading @@ -103,7 +105,7 @@ bool DrawSheetStruct::Save( FILE* f ) const /* Generation de la liste des 2 textes (sheetname et filename) */ /* Generation de la liste des 2 textes (sheetname et filename) */ if( !m_SheetName.IsEmpty() ) 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 ) m_SheetNameSize ) == EOF ) { { Success = false; return Success; Success = false; return Success; Loading @@ -112,7 +114,7 @@ bool DrawSheetStruct::Save( FILE* f ) const if( !m_FileName.IsEmpty() ) 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 ) m_FileNameSize ) == EOF ) { { Success = false; return Success; Success = false; return Success; Loading @@ -125,12 +127,12 @@ bool DrawSheetStruct::Save( FILE* f ) const while( SheetLabel != NULL ) while( SheetLabel != NULL ) { { SheetLabel->m_Number = l_id; SheetLabel->m_Number = l_id; SheetLabel->Save( f ); SheetLabel->Save( aFile ); l_id++; l_id++; SheetLabel = SheetLabel->Next(); SheetLabel = SheetLabel->Next(); } } fprintf( f, "$EndSheet\n" ); fprintf( aFile, "$EndSheet\n" ); return Success; return Success; } } Loading Loading @@ -242,8 +244,10 @@ void DrawSheetStruct::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* aFrame, bool aRedraw ) void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* aFrame, bool aRedraw ) /********************************************************************/ /********************************************************************/ /* Delete pinsheets which are not corresponding to a hierarchal label /** Function CleanupSheet * if aRedraw != NULL, redraw Sheet * 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; Hierarchical_PIN_Sheet_Struct* Pinsheet, * NextPinsheet; Loading Loading @@ -281,52 +285,59 @@ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* aFrame, bool aRedraw if( aRedraw ) if( aRedraw ) aFrame->DrawPanel->PostDirtyRect( GetBoundingBox() ); aFrame->DrawPanel->PostDirtyRect( GetBoundingBox() ); } } /**************************************************************************************/ /**************************************************************************************/ void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, void DrawSheetStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& offset, const wxPoint& aOffset, int DrawMode, int Color ) 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; Hierarchical_PIN_Sheet_Struct* SheetLabelStruct; int txtcolor; int txtcolor; wxString Text; wxString Text; int color; int color; wxPoint pos = m_Pos + offset; wxPoint pos = m_Pos + aOffset; int LineWidth = g_DrawMinimunLineWidth; int LineWidth = g_DrawMinimunLineWidth; if( Color >= 0 ) if( aColor >= 0 ) color = Color; color = aColor; else else color = ReturnLayerColor( m_Layer ); color = ReturnLayerColor( m_Layer ); GRSetDrawMode( DC, DrawMode ); GRSetDrawMode( aDC, aDrawMode ); GRRect( &panel->m_ClipBox, DC, pos.x, pos.y, GRRect( &aPanel->m_ClipBox, aDC, pos.x, pos.y, pos.x + m_Size.x, pos.y + m_Size.y, LineWidth, color ); pos.x + m_Size.x, pos.y + m_Size.y, LineWidth, color ); /* Draw text : SheetName */ /* Draw text : SheetName */ if( Color > 0 ) if( aColor > 0 ) txtcolor = Color; txtcolor = aColor; else else txtcolor = ReturnLayerColor( LAYER_SHEETNAME ); txtcolor = ReturnLayerColor( LAYER_SHEETNAME ); Text = wxT( "Sheet: " ) + m_SheetName; Text = wxT( "Sheet: " ) + m_SheetName; DrawGraphicText( panel, DC, DrawGraphicText( aPanel, aDC, wxPoint( pos.x, pos.y - 8 ), (EDA_Colors) txtcolor, wxPoint( pos.x, pos.y - 8 ), (EDA_Colors) txtcolor, Text, TEXT_ORIENT_HORIZ, wxSize( m_SheetNameSize, m_SheetNameSize ), Text, TEXT_ORIENT_HORIZ, wxSize( m_SheetNameSize, m_SheetNameSize ), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth ); GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth ); /* Draw text : FileName */ /* Draw text : FileName */ if( Color >= 0 ) if( aColor >= 0 ) txtcolor = Color; txtcolor = aColor; else else txtcolor = ReturnLayerColor( LAYER_SHEETFILENAME ); txtcolor = ReturnLayerColor( LAYER_SHEETFILENAME ); Text = wxT( "File: " ) + m_FileName; Text = wxT( "File: " ) + m_FileName; DrawGraphicText( panel, DC, DrawGraphicText( aPanel, aDC, wxPoint( pos.x, pos.y + m_Size.y + 4 ), wxPoint( pos.x, pos.y + m_Size.y + 4 ), (EDA_Colors) txtcolor, (EDA_Colors) txtcolor, Text, TEXT_ORIENT_HORIZ, wxSize( m_FileNameSize, m_FileNameSize ), Text, TEXT_ORIENT_HORIZ, wxSize( m_FileNameSize, m_FileNameSize ), Loading @@ -338,7 +349,7 @@ void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, while( SheetLabelStruct != NULL ) while( SheetLabelStruct != NULL ) { { if( !( SheetLabelStruct->m_Flags & IS_MOVED ) ) if( !( SheetLabelStruct->m_Flags & IS_MOVED ) ) SheetLabelStruct->Draw( panel, DC, offset, DrawMode, Color ); SheetLabelStruct->Draw( aPanel, aDC, aOffset, aDrawMode, aColor ); SheetLabelStruct = SheetLabelStruct->Next(); SheetLabelStruct = SheetLabelStruct->Next(); } } } } Loading @@ -347,6 +358,10 @@ void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, /*****************************************/ /*****************************************/ EDA_Rect DrawSheetStruct::GetBoundingBox() EDA_Rect DrawSheetStruct::GetBoundingBox() /*****************************************/ /*****************************************/ /** Function GetBoundingBox * @return an EDA_Rect giving the bouding box of the sheet */ { { int dx, dy; int dx, dy; Loading @@ -365,12 +380,15 @@ EDA_Rect DrawSheetStruct::GetBoundingBox() } } /************************************/ /*******************************************************************/ int DrawSheetStruct::ComponentCount() 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; int n = 0; if( m_AssociatedScreen ) if( m_AssociatedScreen ) Loading @@ -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 ) if( m_AssociatedScreen ) { { EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList; EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList; Loading @@ -409,12 +433,12 @@ bool DrawSheetStruct::SearchHierarchy( wxString filename, SCH_SCREEN** screen ) { { DrawSheetStruct* ss = (DrawSheetStruct*) strct; DrawSheetStruct* ss = (DrawSheetStruct*) strct; if( ss->m_AssociatedScreen 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; return true; } } if( ss->SearchHierarchy( filename, screen ) ) if( ss->SearchHierarchy( aFilename, aScreen ) ) return true; return true; } } strct = strct->Next(); strct = strct->Next(); Loading @@ -425,19 +449,24 @@ bool DrawSheetStruct::SearchHierarchy( wxString filename, SCH_SCREEN** screen ) /*******************************************************************************/ /*******************************************************************************/ bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* screen, bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* aScreen, DrawSheetPath* list ) 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 ) if( m_AssociatedScreen ) { { list->Push( this ); aList->Push( this ); if( m_AssociatedScreen == screen ) if( m_AssociatedScreen == aScreen ) return true; return true; EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList; EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList; while( strct ) while( strct ) Loading @@ -445,21 +474,30 @@ bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* screen, if( strct->Type() == DRAW_SHEET_STRUCT_TYPE ) if( strct->Type() == DRAW_SHEET_STRUCT_TYPE ) { { DrawSheetStruct* ss = (DrawSheetStruct*) strct; DrawSheetStruct* ss = (DrawSheetStruct*) strct; if( ss->LocatePathOfScreen( screen, list ) ) if( ss->LocatePathOfScreen( aScreen, aList ) ) return true; return true; } } strct = strct->Next(); strct = strct->Next(); } } list->Pop(); aList->Pop(); } } return false; 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; bool success = true; Loading @@ -478,7 +516,7 @@ bool DrawSheetStruct::Load( WinEDA_SchematicFrame* frame ) { { m_AssociatedScreen = new SCH_SCREEN(); m_AssociatedScreen = new SCH_SCREEN(); m_AssociatedScreen->m_RefCount++; m_AssociatedScreen->m_RefCount++; success = frame->LoadOneEEFile( m_AssociatedScreen, m_FileName ); success = aFrame->LoadOneEEFile( m_AssociatedScreen, m_FileName ); if( success ) if( success ) { { EDA_BaseStruct* bs = m_AssociatedScreen->EEDrawList; EDA_BaseStruct* bs = m_AssociatedScreen->EEDrawList; Loading @@ -487,7 +525,7 @@ bool DrawSheetStruct::Load( WinEDA_SchematicFrame* frame ) if( bs->Type() == DRAW_SHEET_STRUCT_TYPE ) if( bs->Type() == DRAW_SHEET_STRUCT_TYPE ) { { DrawSheetStruct* sheetstruct = (DrawSheetStruct*) bs; DrawSheetStruct* sheetstruct = (DrawSheetStruct*) bs; if( !sheetstruct->Load( frame ) ) if( !sheetstruct->Load( aFrame ) ) success = false; success = false; } } bs = bs->Next(); bs = bs->Next(); Loading Loading @@ -529,23 +567,18 @@ wxString DrawSheetStruct::GetFileName( void ) } } /************************************************************/ /************************************************************************/ void DrawSheetStruct::SetFileName( const wxString& aFilename ) bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame, /************************************************************/ const wxString& aFileName ) { /************************************************************************/ m_FileName = aFilename; } /** Function ChangeFileName /** Function ChangeFileName * Set a new filename and manage data and associated screen * Set a new filename and manage data and associated screen * The main difficulty is the filename change in a complex hierarchy. * 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 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. * - 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 ) if( (GetFileName() == aFileName) && m_AssociatedScreen ) return true; return true; Loading Loading @@ -659,184 +692,6 @@ void DrawSheetStruct::Show( int nestLevel, std::ostream& os ) NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n" 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() #endif { 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; }