diff --git a/CMakeLists.txt b/CMakeLists.txt index c4f3547f4a..b6af39f9b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ # # CMAKE_VERBOSE_MAKEFILE ON/OFF (OPTIONAL) # Turns ON/OFF verbose build messages. +# you can also pass VERBOSE=1 to make for the same effect. # # CMAKE_INSTALL_PREFIX (OPTIONAL) # diff --git a/change_log.txt b/change_log.txt index b00984af44..80f748f83c 100644 --- a/change_log.txt +++ b/change_log.txt @@ -6,6 +6,19 @@ Please add newer entries at the top, list the date and your name with email address. +2008-Feb-12 UPDATE Tim Hanson sideskate@gmail.com +================================================================================ ++eeschema + * commiting my changes to allow multiple instances of a given schematic file within a hierarchy: + ** internally, m_currentScreen has been replaced with m_currentSheet, + which is a list or 'path' of screens. The path of screens is used to generate + a series of timestamps, which is converted to flat component reference via a look-up + table in the schematic files. + ** this means that m_currentScreen is no longer used -- use GetScreen(). + ** GetScreen is virtual, as some of the dialogs keep around a WinEDA_BaseScreen pointer. + ** all sub-sheets in a given schematic must have different names to generate a meaningful netlist. + +======= 2008-Feb-12 UPDATE Igor Plyatov ================================================================================ +eeschema @@ -13,7 +26,6 @@ email address. +all Russian translation update. - 2008-Feb-11 UPDATE Dick Hollenbeck ================================================================================ +pcbnew diff --git a/common/base_screen.cpp b/common/base_screen.cpp index 65c846287b..7f72ab3f66 100644 --- a/common/base_screen.cpp +++ b/common/base_screen.cpp @@ -49,7 +49,7 @@ BASE_SCREEN::~BASE_SCREEN() void BASE_SCREEN::InitDatas() /*******************************/ { - m_SheetNumber = m_NumberOfSheet = 1; /* gestion hierarchie: Root: SheetNumber = 1 */ + m_ScreenNumber = m_NumberOfScreen = 1; /* gestion hierarchie: Root: ScreenNumber = 1 */ m_Zoom = 32; m_Grid = wxSize( 50, 50 ); /* pas de la grille */ m_UserGrid = g_UserGrid; /* pas de la grille "utilisateur" */ @@ -63,18 +63,18 @@ void BASE_SCREEN::InitDatas() { case SCHEMATIC_FRAME: m_Center = FALSE; - m_CurrentSheet = &g_Sheet_A4; + m_CurrentSheetDesc = &g_Sheet_A4; break; default: case CVPCB_DISPLAY_FRAME: case MODULE_EDITOR_FRAME: case PCB_FRAME: - m_CurrentSheet = &g_Sheet_A4; + m_CurrentSheetDesc = &g_Sheet_A4; break; case GERBER_FRAME: - m_CurrentSheet = &g_Sheet_GERBER; + m_CurrentSheetDesc = &g_Sheet_GERBER; break; } @@ -158,15 +158,15 @@ wxSize BASE_SCREEN::ReturnPageSize() { default: case SCHEMATIC_FRAME: - PageSize = m_CurrentSheet->m_Size; + PageSize = m_CurrentSheetDesc->m_Size; break; case GERBER_FRAME: case CVPCB_DISPLAY_FRAME: case MODULE_EDITOR_FRAME: case PCB_FRAME: - PageSize.x = m_CurrentSheet->m_Size.x * (PCB_INTERNAL_UNIT / 1000); - PageSize.y = m_CurrentSheet->m_Size.y * (PCB_INTERNAL_UNIT / 1000); + PageSize.x = m_CurrentSheetDesc->m_Size.x * (PCB_INTERNAL_UNIT / 1000); + PageSize.y = m_CurrentSheetDesc->m_Size.y * (PCB_INTERNAL_UNIT / 1000); break; } diff --git a/common/base_struct.cpp b/common/base_struct.cpp index 2b942f77d9..035e4c037d 100644 --- a/common/base_struct.cpp +++ b/common/base_struct.cpp @@ -186,7 +186,9 @@ std::ostream& operator<<( std::ostream& out, const wxPoint& pt ) void EDA_BaseStruct::Show( int nestLevel, std::ostream& os ) { // for now, make it look like XML: - NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n"; + wxString s = GetClass(); + s = s + wxT(" "); + NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">\n"; /* EDA_BaseStruct* kid = m_Son; @@ -195,9 +197,9 @@ void EDA_BaseStruct::Show( int nestLevel, std::ostream& os ) kid->Show( nestLevel+1, os ); } */ - NestedSpace( nestLevel+1, os ) << "Need ::Show() override, shown class is using EDA_BaseStruct::Show()\n"; + NestedSpace( nestLevel+1, os ) << "Need ::Show() override\n"; - NestedSpace( nestLevel, os ) << "\n"; + NestedSpace( nestLevel, os ) << "\n"; } diff --git a/common/basicframe.cpp b/common/basicframe.cpp index 3a34f191e2..8acd88504a 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -122,6 +122,9 @@ void WinEDA_BasicFrame::PrintMsg(const wxString & text) /******************************************************/ { SetStatusText(text); +#ifdef DEBUG + printf("%s\n", (const char*)text.mb_str() ); +#endif } /*************************************************************************/ diff --git a/common/common_plot_functions.cpp b/common/common_plot_functions.cpp index ddd8e03d24..bf177eab2e 100644 --- a/common/common_plot_functions.cpp +++ b/common/common_plot_functions.cpp @@ -80,7 +80,7 @@ void PlotWorkSheet(int format_plot, BASE_SCREEN * screen) */ { #define WSTEXTSIZE 50 // Text size in mils -Ki_PageDescr * Sheet = screen->m_CurrentSheet; +Ki_PageDescr * Sheet = screen->m_CurrentSheetDesc; int ii, jj, xg , yg, ipas, gxpas, gypas; wxSize PageSize; wxPoint pos, ref; @@ -234,11 +234,11 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION; break; case WS_SIZESHEET: - msg += screen->m_CurrentSheet->m_Name; + msg += screen->m_CurrentSheetDesc->m_Name; break; case WS_IDENTSHEET: - msg << screen->m_SheetNumber << wxT("/") << screen->m_NumberOfSheet; + msg << screen->m_ScreenNumber << wxT("/") << screen->m_NumberOfScreen; break; case WS_COMPANY_NAME: diff --git a/common/copy_to_clipboard.cpp b/common/copy_to_clipboard.cpp index b0bbb5328f..18905f85ee 100644 --- a/common/copy_to_clipboard.cpp +++ b/common/copy_to_clipboard.cpp @@ -40,7 +40,7 @@ void WinEDA_DrawFrame::CopyToClipboard(wxCommandEvent& event) if( event.GetId() == ID_GEN_COPY_BLOCK_TO_CLIPBOARD ) { - if (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE) + if (GetScreen()->BlockLocate.m_Command != BLOCK_IDLE) DrawPanel->SetCursor(wxCursor(DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor) ); if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) diff --git a/common/gestfich.cpp b/common/gestfich.cpp index e4c1e9472d..4ba58464b4 100644 --- a/common/gestfich.cpp +++ b/common/gestfich.cpp @@ -505,7 +505,7 @@ void SetRealLibraryPath( const wxString& shortlibname ) * Sinon g_UserLibDirBuffer = /usr/share/kicad/shortlibname/ * * Remarque: - * Les \ sont remplacés par / (a la mode Unix) + * Les \ sont remplac�s par / (a la mode Unix) */ { bool PathFound = FALSE; @@ -545,7 +545,7 @@ wxString ReturnKicadDatasPath() * Sinon retourne /usr/share/kicad/ * * Remarque: - * Les \ sont remplacés par / (a la mode Unix) + * Les \ sont remplac�s par / (a la mode Unix) */ { bool PathFound = FALSE; diff --git a/common/worksheet.cpp b/common/worksheet.cpp index 27b0299bba..ba46d98339 100644 --- a/common/worksheet.cpp +++ b/common/worksheet.cpp @@ -21,7 +21,7 @@ void WinEDA_DrawFrame::TraceWorkSheet(wxDC * DC, BASE_SCREEN * screen, int line_ { if ( ! m_Draw_Sheet_Ref ) return; -Ki_PageDescr * Sheet = screen->m_CurrentSheet; +Ki_PageDescr * Sheet = screen->m_CurrentSheetDesc; int ii, jj, xg , yg, ipas, gxpas, gypas; wxPoint pos; int refx, refy,Color; @@ -179,10 +179,8 @@ int width = line_width; case WS_IDENTSHEET: if(WsItem->m_Legende) msg = WsItem->m_Legende; - msg << screen->m_SheetNumber << wxT("/") << - screen->m_NumberOfSheet; DrawGraphicText(DrawPanel, DC, pos, Color, - msg, TEXT_ORIENT_HORIZ, size, + GetScreenDesc(), TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width); break; @@ -273,3 +271,12 @@ int width = line_width; } } } +/*********************************************************************/ +wxString WinEDA_DrawFrame::GetScreenDesc() +/*********************************************************************/ +{ + wxString msg; + msg << GetScreen()->m_ScreenNumber << wxT("/") << + GetScreen()->m_NumberOfScreen; + return msg; +} diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 81b699a73e..65832c30a7 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -12,7 +12,7 @@ SET(EESCHEMA_SRCS block_libedit.cpp busentry.cpp bus-wire-junction.cpp - class_hierarchy_sheet.cpp + class_drawsheet.cpp class_screen.cpp class_text-label.cpp cleanup.cpp diff --git a/eeschema/affiche.cpp b/eeschema/affiche.cpp index 121b3bb1c2..46039cee73 100644 --- a/eeschema/affiche.cpp +++ b/eeschema/affiche.cpp @@ -35,7 +35,7 @@ void EDA_SchComponentStruct::Display_Infos( WinEDA_DrawFrame* frame ) frame->MsgPanel->EraseMsgBox(); Affiche_1_Parametre( frame, 1, _( "Ref" ), - m_Field[REFERENCE].m_Text, DARKCYAN ); + GetRef(((WinEDA_SchematicFrame*)frame)->GetSheet()), DARKCYAN ); if( Entry && Entry->m_Options == ENTRY_POWER ) msg = _( "Pwr Symb" ); diff --git a/eeschema/annotate.cpp b/eeschema/annotate.cpp index 61e7f49162..0022cb4464 100644 --- a/eeschema/annotate.cpp +++ b/eeschema/annotate.cpp @@ -12,7 +12,7 @@ static bool SortByPosition = true; #include "protos.h" /* Local Functions*/ -static int ListeComposants( CmpListStruct* BaseListeCmp, SCH_SCREEN* screen, int NumSheet ); +static int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetList* sheet ); static int AnnotTriComposant( const void* o1, const void* o2 ); static void BreakReference( CmpListStruct* BaseListeCmp, int NbOfCmp ); static void ReAnnotateComponents( CmpListStruct* BaseListeCmp, int NbOfCmp ); @@ -34,17 +34,17 @@ void ReAnnotatePowerSymbolsOnly( void ) * PWR with id 12 is named PWR12 in global annotation and PWR012 by the Power annotation */ { - /* Build the screen list */ - EDA_ScreenList ScreenList( NULL ); + /* Build the screen list (screen, not sheet) */ + EDA_SheetList SheetList( NULL ); - /* Update the sheet number, sheet count and date */ - ScreenList.UpdateSheetNumberAndDate(); + /* Update the screen number, sheet count and date */ + //ScreenList.UpdateScreenNumberAndDate(); - SCH_SCREEN* screen; + DrawSheetList* sheet; int CmpNumber = 1; - for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext()) { - EDA_BaseStruct* DrawList = screen->EEDrawList; + EDA_BaseStruct* DrawList = sheet->LastDrawList(); for( ; DrawList != NULL; DrawList = DrawList->Pnext ) { if( DrawList->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) @@ -54,15 +54,31 @@ void ReAnnotatePowerSymbolsOnly( void ) FindLibPart( DrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); if( (Entry == NULL) || (Entry->m_Options != ENTRY_POWER) ) continue; - DrawLibItem->ClearAnnotation(); - DrawLibItem->m_RefIdNumber = CmpNumber; - DrawLibItem->m_Field[REFERENCE].m_Text.RemoveLast(); // Remove the '?' - DrawLibItem->m_Field[REFERENCE].m_Text << wxT( "0" ) << CmpNumber; + //DrawLibItem->ClearAnnotation(sheet); this clears all annotation :( + wxString refstr = DrawLibItem->m_PrefixString; + //str will be "C?" or so after the ClearAnnotation call. + while(refstr.Last() == '?') + refstr.RemoveLast(); + if(!refstr.StartsWith(wxT("#"))) + refstr = wxT("#") + refstr; + refstr << wxT( "0" ) << CmpNumber; + DrawLibItem->SetRef(sheet, refstr); CmpNumber++; } } } - +/***********************************************************************/ +CmpListStruct* AllocateCmpListStrct(int numcomponents ) +/***********************************************************************/ +{ + int ii = numcomponents * sizeof(CmpListStruct); + CmpListStruct* list = (CmpListStruct*) MyZMalloc( ii ); + //fill this memory with zeros. + char* cptr = (char*)list; + for(int i=0; iSetModify(); - ScreenList.UpdateSheetNumberAndDate(); + /* Update the sheet number */ + ii = 0; /* First pass: Component counting */ - screen = (SCH_SCREEN*) m_Parent->m_CurrentScreen; - if( AnnotProject == true ) - { + sheet = m_Parent->GetSheet(); + if( AnnotProject == true ){ NbOfCmp = 0; - for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) - { - NbOfCmp += ListeComposants( NULL, screen, screen->m_SheetNumber ); - } + for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) + NbOfCmp += ListeComposants( NULL, sheet ); } else - NbOfCmp = ListeComposants( NULL, screen, screen->m_SheetNumber ); + NbOfCmp = ListeComposants( NULL, sheet ); if( NbOfCmp == 0 ) return; - ii = sizeof(CmpListStruct) * NbOfCmp; - BaseListeCmp = (CmpListStruct*) MyZMalloc( ii ); + BaseListeCmp = AllocateCmpListStrct(NbOfCmp); /* Second pass : Int data tables */ - screen = (SCH_SCREEN*) m_Parent->m_CurrentScreen; if( AnnotProject == true ) - { + { ii = 0; - for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) - { - ii += ListeComposants( BaseListeCmp + ii, - screen, screen->m_SheetNumber ); - } + for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) + ii += ListeComposants( BaseListeCmp + ii, sheet); } else - ii = ListeComposants( BaseListeCmp, screen, screen->m_SheetNumber ); + ii = ListeComposants( BaseListeCmp, sheet); if( ii != NbOfCmp ) DisplayError( this, wxT( "Internal error in AnnotateComponents()" ) ); @@ -177,33 +182,23 @@ void WinEDA_AnnotateFrame::DeleteAnnotation( wxCommandEvent& event ) * Update sheet number and number of sheets */ { - int NbSheet; - SCH_SCREEN* screen; - EDA_SchComponentStruct* DrawLibItem; - - if( !IsOK( this, _( "Previous Annotation will be deleted. Continue ?" ) ) ) - { - m_Abort = true; return; - } + DrawSheetStruct* sheet; + //EDA_SchComponentStruct* DrawLibItem; + if( !IsOK( this, _( "Previous Annotation will be deleted. Continue ?" ) ) ){ + m_Abort = true; + return; + } AnnotProject = (m_AnnotProjetCtrl->GetSelection() == 0) ? true : FALSE; m_Abort = FALSE; - /* Build the screen list */ - EDA_ScreenList ScreenList( NULL ); - - NbSheet = ScreenList.GetCount(); - - /* Update the sheet number, sheet count and date */ - ScreenList.UpdateSheetNumberAndDate(); - - ScreenSch->SetModify(); - if( AnnotProject == true ) - screen = ScreenList.GetFirst(); + sheet = g_RootSheet; else - screen = (SCH_SCREEN*) m_Parent->m_CurrentScreen; + sheet = m_Parent->GetSheet()->Last(); + sheet->DeleteAnnotation( AnnotProject ); + /* for( ; screen != NULL; screen = ScreenList.GetNext() ) { EDA_BaseStruct* DrawList = screen->EEDrawList; @@ -219,26 +214,26 @@ void WinEDA_AnnotateFrame::DeleteAnnotation( wxCommandEvent& event ) if( !AnnotProject ) break; } - +*/ + g_RootSheet->m_s->SetModify(); m_Parent->DrawPanel->Refresh( true ); - EndModal( 0 ); + //EndModal( 0 ); } /************************************************************************************/ -int ListeComposants( CmpListStruct* BaseListeCmp, SCH_SCREEN* screen, int NumSheet ) +int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetList* sheet) /***********************************************************************************/ -/* if BaseListeCmp == NULL : Components counting +/* if BaseListeCmp == NULL : count components * else update data table BaseListeCmp */ { int NbrCmp = 0; - EDA_BaseStruct* DrawList = screen->EEDrawList; + EDA_BaseStruct* DrawList = sheet->LastDrawList(); EDA_SchComponentStruct* DrawLibItem; EDA_LibComponentStruct* Entry; - DrawList = screen->EEDrawList; for( ; DrawList; DrawList = DrawList->Pnext ) { switch( DrawList->Type() ) @@ -248,6 +243,7 @@ int ListeComposants( CmpListStruct* BaseListeCmp, SCH_SCREEN* screen, int NumShe case DRAW_TEXT_STRUCT_TYPE: case DRAW_LABEL_STRUCT_TYPE: case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: break; case DRAW_LIB_ITEM_STRUCT_TYPE: @@ -266,16 +262,16 @@ int ListeComposants( CmpListStruct* BaseListeCmp, SCH_SCREEN* screen, int NumShe BaseListeCmp[NbrCmp].m_NbParts = Entry->m_UnitCount; BaseListeCmp[NbrCmp].m_Unit = DrawLibItem->m_Multi; BaseListeCmp[NbrCmp].m_PartsLocked = Entry->m_UnitSelectionLocked; - BaseListeCmp[NbrCmp].m_Sheet = NumSheet; + BaseListeCmp[NbrCmp].m_SheetList = *sheet; BaseListeCmp[NbrCmp].m_IsNew = FALSE; BaseListeCmp[NbrCmp].m_Pos = DrawLibItem->m_Pos; BaseListeCmp[NbrCmp].m_TimeStamp = DrawLibItem->m_TimeStamp; - if( DrawLibItem->m_Field[REFERENCE].m_Text.IsEmpty() ) - DrawLibItem->m_Field[REFERENCE].m_Text = wxT( "DefRef?" ); + if( DrawLibItem->GetRef(sheet).IsEmpty() ) + DrawLibItem->SetRef( sheet, wxT( "DefRef?" ) ); strncpy( BaseListeCmp[NbrCmp].m_TextRef, - CONV_TO_UTF8( DrawLibItem->m_Field[REFERENCE].m_Text ), 32 ); + CONV_TO_UTF8(DrawLibItem->GetRef(sheet)), 32 ); BaseListeCmp[NbrCmp].m_NumRef = -1; @@ -326,7 +322,7 @@ int AnnotTriComposant( const void* o1, const void* o2 ) if( SortByPosition == true ) { if( ii == 0 ) - ii = Objet1->m_Sheet - Objet2->m_Sheet; + ii = Objet1->m_SheetList.Cmp(Objet2->m_SheetList); if( ii == 0 ) ii = Objet1->m_Pos.x - Objet2->m_Pos.x; if( ii == 0 ) @@ -339,7 +335,7 @@ int AnnotTriComposant( const void* o1, const void* o2 ) if( ii == 0 ) ii = Objet1->m_Unit - Objet2->m_Unit; if( ii == 0 ) - ii = Objet1->m_Sheet - Objet2->m_Sheet; + ii = Objet1->m_SheetList.Cmp(Objet2->m_SheetList); if( ii == 0 ) ii = Objet1->m_Pos.x - Objet2->m_Pos.x; if( ii == 0 ) @@ -375,11 +371,8 @@ static void ReAnnotateComponents( CmpListStruct* BaseListeCmp, int NbOfCmp ) else sprintf( Text + strlen( Text ), "%d", BaseListeCmp[ii].m_NumRef ); - DrawLibItem->m_Field[REFERENCE].m_Text = CONV_FROM_UTF8( Text ); + DrawLibItem->SetRef(&(BaseListeCmp[ii].m_SheetList), CONV_FROM_UTF8( Text ) ); DrawLibItem->m_Multi = BaseListeCmp[ii].m_Unit; - DrawLibItem->m_RefIdNumber = BaseListeCmp[ii].m_NumRef; - if( DrawLibItem->m_RefIdNumber < 0 ) - DrawLibItem->m_RefIdNumber = 0; } } @@ -432,6 +425,9 @@ void BreakReference( CmpListStruct* BaseListeCmp, int NbOfCmp ) break; } } + /*printf("BreakReference(): %s number found: %d\n", + BaseListeCmp[ii].m_TextRef, + BaseListeCmp[ii].m_NumRef); */ } } @@ -618,33 +614,26 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly ) * false = search in whole hierarchy (usual search). */ { - int NbSheet, ii, NumSheet = 1, error, NbOfCmp; - SCH_SCREEN* screen; + int ii, error, NbOfCmp; + DrawSheetList* sheet; CmpListStruct* ListeCmp = NULL; wxString Buff; wxString msg, cmpref; /* build the screen list */ - EDA_ScreenList ScreenList( NULL ); + EDA_SheetList SheetList( NULL ); - NbSheet = ScreenList.GetCount(); - - /* Update the sheet number, sheet count and date */ - ScreenSch->SetModify(); - ScreenList.UpdateSheetNumberAndDate(); + g_RootSheet->m_s->SetModify(); + ii = 0; /* first pass : count composents */ - screen = (SCH_SCREEN*) frame->m_CurrentScreen; - if( !OneSheetOnly ) - { + if( !OneSheetOnly ){ NbOfCmp = 0; - for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) - { - NbOfCmp += ListeComposants( NULL, screen, NumSheet ); - } + for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) + NbOfCmp += ListeComposants( NULL, sheet ); } else - NbOfCmp = ListeComposants( NULL, screen, NumSheet ); + NbOfCmp = ListeComposants( NULL, frame->GetSheet() ); if( NbOfCmp == 0 ) { @@ -654,24 +643,19 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly ) /* Second pass : create the list of components */ - ii = sizeof(CmpListStruct) * NbOfCmp; - ListeCmp = (CmpListStruct*) MyZMalloc( ii ); + ListeCmp = AllocateCmpListStrct(NbOfCmp); - if( OneSheetOnly == 0 ) - { - ii = 0; - screen = ScreenSch; - for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) - { - ii += ListeComposants( ListeCmp + ii, screen, NumSheet ); - } + printf("CheckAnnotate() listing all components:\n"); + if( !OneSheetOnly ){ + ii = 0; + for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) + ii += ListeComposants( ListeCmp + ii, sheet ); } else - { - screen = (SCH_SCREEN*) frame->m_CurrentScreen; - ListeComposants( ListeCmp, screen, NumSheet ); - } - + ListeComposants( ListeCmp, frame->GetSheet() ); + + printf("CheckAnnotate() done:\n"); + qsort( ListeCmp, NbOfCmp, sizeof(CmpListStruct), AnnotTriComposant ); /* Break full components reference in name (prefix) and number: example: IC1 become IC, and 1 */ @@ -782,7 +766,7 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly ) error++; } - /* Error if values are différent between units, for the same reference */ + /* Error if values are diff�rent between units, for the same reference */ if( stricmp( ListeCmp[ii].m_TextValue, ListeCmp[ii + 1].m_TextValue ) != 0 ) { wxString nextcmpref, cmpvalue, nextcmpvalue; diff --git a/eeschema/block.cpp b/eeschema/block.cpp index 214ea0c129..82467677ae 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -201,7 +201,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) * retourne : * 0 si aucun composant selectionne * 1 sinon - * -1 si commande terminée et composants trouvés (block delete, block save) + * -1 si commande termin�e et composants trouv�s (block delete, block save) */ { int ii = 0; @@ -232,18 +232,18 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) break; case BLOCK_DRAG: /* Drag */ - BreakSegmentOnJunction( GetScreen() ); + BreakSegmentOnJunction( (SCH_SCREEN*)GetScreen() ); case BLOCK_MOVE: /* Move */ case BLOCK_COPY: /* Copy */ block->m_BlockDrawStruct = - PickStruct( GetScreen()->BlockLocate, GetScreen()->EEDrawList, SEARCHALL ); + PickStruct( GetScreen()->BlockLocate, GetScreen(), SEARCHALL ); case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ if( block->m_BlockDrawStruct != NULL ) { ii = 1; - CollectStructsToDrag( GetScreen() ); + CollectStructsToDrag( (SCH_SCREEN*)GetScreen() ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur = DrawMovingBlockOutlines; DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); @@ -260,7 +260,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) case BLOCK_DELETE: /* Delete */ block->m_BlockDrawStruct = PickStruct( GetScreen()->BlockLocate, - GetScreen()->EEDrawList, SEARCHALL ); + GetScreen(), SEARCHALL ); DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); if( block->m_BlockDrawStruct != NULL ) { @@ -275,7 +275,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) case BLOCK_SAVE: /* Save */ block->m_BlockDrawStruct = PickStruct( GetScreen()->BlockLocate, - GetScreen()->EEDrawList, SEARCHALL ); + GetScreen(), SEARCHALL ); DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); if( block->m_BlockDrawStruct != NULL ) { @@ -379,14 +379,14 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) } block->m_BlockDrawStruct = NULL; } - BreakSegmentOnJunction( GetScreen() ); + BreakSegmentOnJunction( (SCH_SCREEN*)GetScreen() ); block->m_BlockDrawStruct = PickStruct( GetScreen()->BlockLocate, - GetScreen()->EEDrawList, SEARCHALL ); + GetScreen(), SEARCHALL ); if( block->m_BlockDrawStruct != NULL ) { ii = 1; - CollectStructsToDrag( GetScreen() ); + CollectStructsToDrag( (SCH_SCREEN*)GetScreen() ); if( DrawPanel->ManageCurseur ) DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); block->m_State = STATE_BLOCK_MOVE; @@ -685,10 +685,10 @@ void MirrorOneStruct( EDA_BaseStruct* DrawStruct, wxPoint& Center ) DrawText->m_Pos.x = px.x; break; + case DRAW_HIER_LABEL_STRUCT_TYPE: case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - // Text is not really mirrored: Orientation is changed - DrawText = (DrawGlobalLabelStruct*) DrawStruct; + DrawText = (DrawLabelStruct*) DrawStruct; if( DrawText->m_Orient == 0 ) /* horizontal text */ DrawText->m_Orient = 2; else if( DrawText->m_Orient == 2 ) /* invert horizontal text*/ @@ -831,14 +831,14 @@ static EDA_BaseStruct* CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREE case DRAW_SHEET_STRUCT_TYPE: { + //DuplicateStruct calls GenCopy, which should handle + //m_s and m_sRefCount properly. DrawSheetStruct* sheet = (DrawSheetStruct*) Struct; sheet->m_TimeStamp = GetTimeStamp(); - sheet->m_UndoList = NULL; - sheet->m_RedoList = NULL; - sheet->EEDrawList = NULL; - sheet->m_Son = NULL; - sheet->m_SheetName.Printf( wxT( "%8.8lX" ), sheet->m_TimeStamp ); - sheet->m_FileName = sheet->m_SheetName + wxT( ".sch" ); + //sheet->m_s->m_UndoList = NULL; + //sheet->m_s->m_RedoList = NULL; + //keep m_s pointer & associated. + //sheet->m_Son = NULL; m_son is involved in undo and redo. break; } @@ -871,6 +871,7 @@ static EDA_BaseStruct* CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREE case DRAW_TEXT_STRUCT_TYPE: case DRAW_LABEL_STRUCT_TYPE: case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: case DRAW_SHEETLABEL_STRUCT_TYPE: case DRAW_PICK_ITEM_STRUCT_TYPE: case DRAW_MARKER_STRUCT_TYPE: @@ -882,17 +883,12 @@ static EDA_BaseStruct* CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREE { DrawSheetStruct* sheet = (DrawSheetStruct*) NewDrawStruct; sheet->m_TimeStamp = GetTimeStamp(); - sheet->m_UndoList = NULL; - sheet->m_RedoList = NULL; - sheet->EEDrawList = NULL; sheet->m_Son = NULL; - sheet->m_SheetName.Printf( wxT( "%8.8lX" ), sheet->m_TimeStamp ); - sheet->m_FileName = sheet->m_SheetName + wxT( ".sch" ); break; } case DRAW_LIB_ITEM_STRUCT_TYPE: - ( (EDA_SchComponentStruct*) NewDrawStruct )->m_TimeStamp = GetTimeStamp(); + ( (EDA_SchComponentStruct*) NewDrawStruct )->m_TimeStamp = GetTimeStamp(); ( (EDA_SchComponentStruct*) NewDrawStruct )->ClearAnnotation(); break; } @@ -964,7 +960,12 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, EDA_BaseStruct* DrawStruct RedrawOneStruct( panel, DC, DrawStruct, g_XorMode ); /* Unlink the structure */ DrawStruct->Pnext = DrawStruct->Pback = NULL; // Only one struct -> no link - frame->SaveCopyInUndoList( DrawStruct, IS_DELETED ); + if(DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE){ + SAFE_DELETE(DrawStruct); + //no undo/redo for this (for now), it is on both the EEDrawList and m_SubSheet arrays, + //hence the undo logic would have to be extended for this. + }else + frame->SaveCopyInUndoList( DrawStruct, IS_DELETED ); } } @@ -1043,7 +1044,7 @@ void WinEDA_SchematicFrame::PasteStruct( wxDC* DC ) EDA_BaseStruct* Struct = PickedList->m_PickedStruct; if( Struct->Type() == DRAW_LIB_ITEM_STRUCT_TYPE ) { - ( (EDA_SchComponentStruct*) Struct )->m_TimeStamp = GetTimeStamp(); + ( (EDA_SchComponentStruct*) Struct )->m_TimeStamp = GetTimeStamp(); ( (EDA_SchComponentStruct*) Struct )->ClearAnnotation(); SetStructFather( Struct, GetScreen() ); } @@ -1067,7 +1068,7 @@ void WinEDA_SchematicFrame::PasteStruct( wxDC* DC ) { if( DrawStruct->Type() == DRAW_LIB_ITEM_STRUCT_TYPE ) { - ( (EDA_SchComponentStruct*) DrawStruct )->m_TimeStamp = GetTimeStamp(); + ( (EDA_SchComponentStruct*) DrawStruct )->m_TimeStamp = GetTimeStamp(); ( (EDA_SchComponentStruct*) DrawStruct )->ClearAnnotation(); } SetStructFather( DrawStruct, GetScreen() ); @@ -1117,6 +1118,7 @@ bool PlaceStruct( BASE_SCREEN* screen, EDA_BaseStruct* DrawStruct ) case DRAW_TEXT_STRUCT_TYPE: case DRAW_LABEL_STRUCT_TYPE: case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: case DRAW_LIB_ITEM_STRUCT_TYPE: case DRAW_SHEET_STRUCT_TYPE: case DRAW_SHEETLABEL_STRUCT_TYPE: @@ -1219,9 +1221,10 @@ void MoveOneStruct( EDA_BaseStruct* DrawStruct, const wxPoint& move_vector ) DrawLabel->m_Pos += move_vector; break; + case DRAW_HIER_LABEL_STRUCT_TYPE: case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - #define DrawGlobalLabel ( (DrawGlobalLabelStruct*) DrawStruct ) - DrawGlobalLabel->m_Pos += move_vector; + #define DrawGHLabel ( (DrawLabelStruct*) DrawStruct ) + DrawGHLabel->m_Pos += move_vector; break; case DRAW_LIB_ITEM_STRUCT_TYPE: @@ -1310,6 +1313,10 @@ EDA_BaseStruct* DuplicateStruct( EDA_BaseStruct* DrawStruct ) NewDrawStruct = ( (DrawLabelStruct*) DrawStruct )->GenCopy(); break; + case DRAW_HIER_LABEL_STRUCT_TYPE: + NewDrawStruct = ( (DrawHierLabelStruct*) DrawStruct )->GenCopy(); + break; + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: NewDrawStruct = ( (DrawGlobalLabelStruct*) DrawStruct )->GenCopy(); break; @@ -1577,9 +1584,10 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) Struct->m_Flags |= SELECTED; break; + case DRAW_HIER_LABEL_STRUCT_TYPE: case DRAW_GLOBAL_LABEL_STRUCT_TYPE: #undef STRUCT - #define STRUCT ( (DrawGlobalLabelStruct*) Struct ) + #define STRUCT ( (DrawLabelStruct*) Struct ) if( Struct->m_Flags & SELECTED ) break; /* Already in list */ if( STRUCT->m_Pos != position ) diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index 166f734fa9..39e77cfd26 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -140,8 +140,8 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type ) if( !newsegment ) /* first point : Create first wire ou bus */ { s_ConnexionStartPoint = cursorpos; - s_OldWiresList = GetScreen()->ExtractWires( TRUE ); - GetScreen()->SchematicCleanUp( NULL ); + s_OldWiresList = ((SCH_SCREEN*)GetScreen())->ExtractWires( TRUE ); + ((SCH_SCREEN*)GetScreen())->SchematicCleanUp( NULL ); switch( type ) { @@ -191,8 +191,8 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type ) DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); - /* Creation du segment suivant ou fin de tracé si point sur pin, jonction ...*/ - if( IsTerminalPoint( GetScreen(), cursorpos, oldsegment->m_Layer ) ) + /* Creation du segment suivant ou fin de trac� si point sur pin, jonction ...*/ + if( IsTerminalPoint( (SCH_SCREEN*)GetScreen(), cursorpos, oldsegment->m_Layer ) ) { EndSegment( DC ); return; } @@ -299,7 +299,7 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC ) alt_end_point = lastsegment->m_Start; } - GetScreen()->SchematicCleanUp( NULL ); + ((SCH_SCREEN*)GetScreen())->SchematicCleanUp( NULL ); /* clear flags and find last segment entered, for repeat function */ segment = (EDA_DrawLineStruct*) GetScreen()->EEDrawList; @@ -519,7 +519,7 @@ void WinEDA_SchematicFrame::DeleteCurrentSegment( wxDC* DC ) Segment_in_Ghost( DrawPanel, DC, FALSE ); /* Effacement du trace en cours */ } - EraseStruct( GetScreen()->GetCurItem(), GetScreen() ); + EraseStruct( GetScreen()->GetCurItem(), (SCH_SCREEN*)GetScreen() ); DrawPanel->ManageCurseur = NULL; GetScreen()->SetCurItem( NULL ); } @@ -662,6 +662,16 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) break; + case DRAW_HIER_LABEL_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (DrawHierLabelStruct*) g_ItemToRepeat ) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos += g_RepeatStep; + new_pos = STRUCT->m_Pos; + /*** Increment du numero de label ***/ + IncrementLabelMember( STRUCT->m_Text ); + break; + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: #undef STRUCT #define STRUCT ( (DrawGlobalLabelStruct*) g_ItemToRepeat ) @@ -695,11 +705,11 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) // Create the duplicate component, position = mouse cursor g_ItemToRepeat = STRUCT->GenCopy(); - new_pos.x = m_CurrentScreen->m_Curseur.x - STRUCT->m_Pos.x; - new_pos.y = m_CurrentScreen->m_Curseur.y - STRUCT->m_Pos.y; - STRUCT->m_Pos = m_CurrentScreen->m_Curseur; + new_pos.x = GetScreen()->m_Curseur.x - STRUCT->m_Pos.x; + new_pos.y = GetScreen()->m_Curseur.y - STRUCT->m_Pos.y; + STRUCT->m_Pos = GetScreen()->m_Curseur; STRUCT->m_Flags = IS_NEW; - STRUCT->m_TimeStamp = GetTimeStamp(); + STRUCT->m_TimeStamp = GetTimeStamp(); for( int ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) { STRUCT->m_Field[ii].m_Pos += new_pos; @@ -770,10 +780,10 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer ) * - type WIRE, si il y a * - une jonction * - ou une pin - * - ou une extrémité unique de fil + * - ou une extr�mit� unique de fil * * - type BUS, si il y a - * - ou une extrémité unique de BUS + * - ou une extr�mit� unique de BUS */ { EDA_BaseStruct* item; @@ -785,7 +795,7 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer ) switch( layer ) { case LAYER_BUS: - item = PickStruct( pos, screen->EEDrawList, BUSITEM ); + item = PickStruct( pos, screen, BUSITEM ); if( item ) return TRUE; pinsheet = LocateAnyPinSheet( pos, screen->EEDrawList ); @@ -798,13 +808,13 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer ) break; case LAYER_NOTES: - item = PickStruct( pos, screen->EEDrawList, DRAWITEM ); + item = PickStruct( pos, screen, DRAWITEM ); if( item ) return TRUE; break; case LAYER_WIRE: - item = PickStruct( pos, screen->EEDrawList, RACCORDITEM | JUNCTIONITEM ); + item = PickStruct( pos, screen, RACCORDITEM | JUNCTIONITEM ); if( item ) return TRUE; @@ -820,17 +830,17 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer ) return TRUE; } - item = PickStruct( pos, screen->EEDrawList, WIREITEM ); + item = PickStruct( pos, screen, WIREITEM ); if( item ) return TRUE; - item = PickStruct( pos, screen->EEDrawList, LABELITEM ); + item = PickStruct( pos, screen, LABELITEM ); if( item && (item->Type() != DRAW_TEXT_STRUCT_TYPE) && ( ( (DrawGlobalLabelStruct*) item )->m_Pos.x == pos.x ) && ( ( (DrawGlobalLabelStruct*) item )->m_Pos.y == pos.y ) ) return TRUE; - pinsheet = LocateAnyPinSheet( pos, screen->EEDrawList ); + pinsheet = LocateAnyPinSheet( pos, screen ); if( pinsheet && !IsBusLabel( pinsheet->m_Text ) ) { itempos = pinsheet->m_Pos; @@ -861,14 +871,14 @@ bool IsJunctionNeeded( WinEDA_SchematicFrame* frame, wxPoint& pos ) * - a pin is on location pos */ { - if( PickStruct( pos, frame->GetScreen()->EEDrawList, JUNCTIONITEM ) ) + if( PickStruct( pos, frame->GetScreen(), JUNCTIONITEM ) ) return FALSE; - if( PickStruct( pos, frame->GetScreen()->EEDrawList, WIREITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) ) + if( PickStruct( pos, frame->GetScreen(), WIREITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) ) { - if( PickStruct( pos, frame->GetScreen()->EEDrawList, WIREITEM | WIRE_BUS_ENDPOINTS_ONLY ) ) + if( PickStruct( pos, frame->GetScreen(), WIREITEM | WIRE_BUS_ENDPOINTS_ONLY ) ) return TRUE; - if( frame->LocatePinEnd( frame->GetScreen()->EEDrawList, pos ) ) + if( frame->LocatePinEnd( frame->GetScreen(), pos ) ) return TRUE; } diff --git a/eeschema/class_drawsheet.cpp b/eeschema/class_drawsheet.cpp new file mode 100644 index 0000000000..58188a71ce --- /dev/null +++ b/eeschema/class_drawsheet.cpp @@ -0,0 +1,625 @@ +///////////////////////////////////////////////////////////////////////////// + +// Name: DrawSheet.cpp +// Purpose: member functions for DrawSheetStruct and DrawSheetLabelStruct +// header = class_screen.h +// Author: jean-pierre Charras +// Modified by: +// Created: 08/02/2006 18:37:02 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// 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 "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + + +/***********************************************************/ +DrawSheetStruct::DrawSheetStruct( const wxPoint& pos ) : + EDA_BaseStruct( DRAW_SHEET_STRUCT_TYPE ) +/***********************************************************/ +{ + m_Label = NULL; + m_NbLabel = 0; + m_Layer = LAYER_SHEET; + m_Pos = pos; + m_SheetNameSize = m_FileNameSize = 60; + m_s = NULL; + m_SheetName = wxT("Root"); + m_FileName = wxT(" "); +} + + +/**************************************/ +DrawSheetStruct::~DrawSheetStruct() +/**************************************/ +{ + DrawSheetLabelStruct* label = m_Label, * next_label; + while( label ){ + next_label = (DrawSheetLabelStruct*) label->Pnext; + delete label; + label = next_label; + } + + //also, look at the associated sheet & its reference count + //perhaps it should be deleted also. + if(m_s){ + m_s->m_RefCount--; + if(m_s->m_RefCount == 0) + delete m_s; + } +} + +/***********************************************/ +DrawSheetStruct* DrawSheetStruct::GenCopy() +/***********************************************/ + +/* creates a copy of a sheet + * The linked data itself (EEDrawList) is not duplicated + */ +{ + DrawSheetStruct* newitem = new DrawSheetStruct( m_Pos ); + + + newitem->m_Size = m_Size; + newitem->m_Parent = m_Parent; + newitem->m_TimeStamp = GetTimeStamp(); + + newitem->m_FileName = m_FileName; + newitem->m_FileNameSize = m_FileNameSize; + newitem->m_SheetName = m_SheetName; + newitem->m_SheetNameSize = m_SheetNameSize; + + newitem->m_Label = NULL; + + DrawSheetLabelStruct* Slabel = NULL, *label = m_Label; + + if( label ) + { + Slabel = newitem->m_Label = label->GenCopy(); + Slabel->m_Parent = newitem; + label = (DrawSheetLabelStruct*) label->Pnext; + } + + while( label ) + { + Slabel->Pnext = label->GenCopy(); + Slabel = (DrawSheetLabelStruct*) Slabel->Pnext; + Slabel->m_Parent = newitem; + label = (DrawSheetLabelStruct*) label->Pnext; + } + + /* don't copy screen data - just reference it. */ + newitem->m_s = m_s; + if(m_s) + m_s->m_RefCount++; + + return newitem; +} + + +/**********************************************************/ +void DrawSheetStruct::SwapData( DrawSheetStruct* copyitem ) +/**********************************************************/ +/* Used if undo / redo command: + * swap data between this and copyitem + */ +{ + EXCHG( m_Pos, copyitem->m_Pos ); + EXCHG( m_Size, copyitem->m_Size ); + EXCHG( m_SheetName, copyitem->m_SheetName ); + EXCHG( m_SheetNameSize, copyitem->m_SheetNameSize ); + EXCHG( m_FileNameSize, copyitem->m_FileNameSize ); + EXCHG( m_Label, copyitem->m_Label ); + EXCHG( m_NbLabel, copyitem->m_NbLabel ); +} +/****************************************************************/ +void DrawSheetStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) +/****************************************************************/ +{ + /* Placement en liste des structures si nouveau composant:*/ + if( m_Flags & IS_NEW ) + { + if( !( (WinEDA_SchematicFrame*) frame )->EditSheet( this, DC ) ) + { + frame->GetScreen()->SetCurItem( NULL ); + frame->DrawPanel->ManageCurseur = NULL; + frame->DrawPanel->ForceCloseManageCurseur = NULL; + RedrawOneStruct( frame->DrawPanel, DC, this, g_XorMode ); + delete this; + return; + } + } + + EDA_BaseStruct::Place( frame, DC ); //puts it on the EEDrawList. +} +/********************************************************************/ +void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* frame, wxDC* DC ) +/********************************************************************/ +/* Delete pinsheets which are not corresponding to a hierarchal label + * if DC != NULL, redraw Sheet + */ +{ + DrawSheetLabelStruct* Pinsheet, * NextPinsheet; + + if( !IsOK( frame, _( "Ok to cleanup this sheet" ) ) ) + return; + + Pinsheet = m_Label; + while( Pinsheet ) + { + /* Search Glabel corresponding to this Pinsheet */ + + EDA_BaseStruct* DrawStruct = m_s->EEDrawList; + DrawHierLabelStruct* HLabel = NULL; + for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) + { + if( DrawStruct->Type() != DRAW_HIER_LABEL_STRUCT_TYPE ) + continue; + HLabel = (DrawHierLabelStruct*) DrawStruct; + if( Pinsheet->m_Text.CmpNoCase( HLabel->m_Text ) == 0 ) + break; // Found! + HLabel = NULL; + } + + NextPinsheet = (DrawSheetLabelStruct*) Pinsheet->Pnext; + if( HLabel == NULL ) // Hlabel not found: delete pinsheet + { + frame->GetScreen()->SetModify(); + frame->DeleteSheetLabel( DC, Pinsheet ); + } + Pinsheet = NextPinsheet; + } +} + +/**************************************************************************************/ +void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, + int DrawMode, int Color ) +/**************************************************************************************/ +/* Draw the hierarchical sheet shape */ +{ + DrawSheetLabelStruct* SheetLabelStruct; + int txtcolor; + wxString Text; + int color; + wxPoint pos = m_Pos + offset; + int LineWidth = g_DrawMinimunLineWidth; + + if( Color >= 0 ) + color = Color; + else + color = ReturnLayerColor( m_Layer ); + GRSetDrawMode( DC, DrawMode ); + + GRRect( &panel->m_ClipBox, DC, pos.x, pos.y, + pos.x + m_Size.x, pos.y + m_Size.y, LineWidth, color ); + + /* Draw text : SheetName */ + if( Color > 0 ) + txtcolor = Color; + else + txtcolor = ReturnLayerColor( LAYER_SHEETNAME ); + + Text = wxT( "Sheet: " ) + m_SheetName; + DrawGraphicText( panel, DC, + wxPoint( pos.x, pos.y - 8 ), 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; + else + txtcolor = ReturnLayerColor( LAYER_SHEETFILENAME ); + Text = wxT( "File: " ) + m_FileName; + DrawGraphicText( panel, DC, + wxPoint( pos.x, pos.y + m_Size.y + 4 ), + txtcolor, + Text, TEXT_ORIENT_HORIZ, wxSize( m_FileNameSize, m_FileNameSize ), + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, LineWidth ); + + + /* Draw text : SheetLabel */ + SheetLabelStruct = m_Label; + while( SheetLabelStruct != NULL ) + { + SheetLabelStruct->Draw( panel, DC, offset, DrawMode, Color ); + SheetLabelStruct = (DrawSheetLabelStruct*) (SheetLabelStruct->Pnext); + } +} + +/**************************************************************************************/ +void DrawSheetStruct::DeleteAnnotation( bool recurse ) +/**************************************************************************************/ +{ + if(recurse && m_s){ + EDA_BaseStruct* strct = m_s->EEDrawList; + for(; strct; strct = strct->Pnext){ + if(strct->Type() == DRAW_SHEET_STRUCT_TYPE){ + DrawSheetStruct* sheet = (DrawSheetStruct*)strct; + sheet->DeleteAnnotation(recurse); + } + } + } + EDA_BaseStruct* comp = m_s->EEDrawList; + for( ; comp ; comp = comp->Pnext ){ + if(comp->Type() == DRAW_LIB_ITEM_STRUCT_TYPE ){ + ((EDA_SchComponentStruct*)comp)->ClearAnnotation(); + } + } +} +/*******************************************************************/ +int DrawSheetStruct::ComponentCount( ) +/*******************************************************************/ +{ + //count our own components, without the power components. + /* Routine retournant le nombre de composants dans le schema, + * powers non comprises */ + int n = 0; + if(m_s){ + EDA_BaseStruct* bs; + for( bs = m_s->EEDrawList; bs != NULL; bs = bs->Pnext ){ + if( bs->Type() == DRAW_LIB_ITEM_STRUCT_TYPE ){ + DrawPartStruct* Cmp = (DrawPartStruct*) bs; + if( Cmp->m_Field[VALUE].m_Text.GetChar( 0 ) != '#' ) + n++; + } + if(bs->Type() == DRAW_SHEET_STRUCT_TYPE){ + DrawSheetStruct* sheet = (DrawSheetStruct*)bs; + n += sheet->ComponentCount(); + } + } + } + return n; +} +/*******************************************************************************/ +bool DrawSheetStruct::SearchHierarchy(wxString filename, SCH_SCREEN **screen) +/*******************************************************************************/ +{ + //search the existing hierarchy for an instance of screen "FileName". + if(m_s){ + EDA_BaseStruct* strct = m_s->EEDrawList; + while(strct){ + if(strct->Type() == DRAW_SHEET_STRUCT_TYPE){ + DrawSheetStruct* ss = (DrawSheetStruct*)strct; + if(ss->m_s && ss->m_s->m_FileName.CmpNoCase(filename) == 0){ + *screen = ss->m_s; + return true; + } + if(ss->SearchHierarchy(filename, screen)) + return true; + } + strct = strct->Pnext; + } + } + return false; +} +/*******************************************************************************/ +bool DrawSheetStruct::LocatePathOfScreen(SCH_SCREEN *screen, DrawSheetList* list) +/*******************************************************************************/ +{ + //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_s otherwise there would be loops + //in the heirarchy. + //search the existing hierarchy for an instance of screen "FileName". + if(m_s){ + list->Push(this); + if(m_s == screen) + return true; + EDA_BaseStruct* strct = m_s->EEDrawList; + while(strct){ + if(strct->Type() == DRAW_SHEET_STRUCT_TYPE){ + DrawSheetStruct* ss = (DrawSheetStruct*)strct; + if(ss->LocatePathOfScreen(screen, list)) + return true; + } + strct = strct->Pnext; + } + list->Pop(); + } + return false; +} + +/*******************************************************************************/ +bool DrawSheetStruct::Load(WinEDA_SchematicFrame* frame) +/*******************************************************************************/ +{ + if(!m_s){ + SCH_SCREEN* screen = NULL; + g_RootSheet->SearchHierarchy(m_FileName, &screen); + if(screen){ + m_s = screen; + m_s->m_RefCount++; + //do not need to load the sub-sheets - this has already been done. + }else{ + m_s = new SCH_SCREEN(SCHEMATIC_FRAME); + if(!frame->LoadOneEEFile(m_s, m_FileName)) + return false; + m_s->m_RefCount++; + EDA_BaseStruct* bs = m_s->EEDrawList; + while(bs){ + if(bs->Type() == DRAW_SHEET_STRUCT_TYPE){ + DrawSheetStruct* ss = (DrawSheetStruct*)bs; + if(!ss->Load(frame)) + return false; + } + bs = bs->Pnext; + } + } + } + return true; +} +/*******************************************************************************/ +int DrawSheetStruct::CountSheets() +/*******************************************************************************/ +{ + int count = 1; //1 = this!! + if(m_s){ + EDA_BaseStruct* strct = m_s->EEDrawList; + for(; strct; strct = strct->Pnext){ + if(strct->Type() == DRAW_SHEET_STRUCT_TYPE){ + DrawSheetStruct* ss = (DrawSheetStruct*)strct; + count += ss->CountSheets(); + } + } + } + return count; +} + + +/************************/ +/* DrawSheetLabelStruct */ +/************************/ + +/*******************************************************************/ +DrawSheetLabelStruct::DrawSheetLabelStruct( DrawSheetStruct* parent, + const wxPoint& pos, const wxString& text ) : + EDA_BaseStruct( DRAW_SHEETLABEL_STRUCT_TYPE ), + EDA_TextStruct( text ) +/*******************************************************************/ +{ + m_Layer = LAYER_SHEETLABEL; + m_Parent = parent; + m_Pos = pos; + m_Edge = 0; + m_Shape = NET_INPUT; + m_IsDangling = TRUE; +} + + +/***********************************************************/ +DrawSheetLabelStruct* DrawSheetLabelStruct::GenCopy() +/***********************************************************/ +{ + DrawSheetLabelStruct* newitem = + new DrawSheetLabelStruct( (DrawSheetStruct*) m_Parent, m_Pos, m_Text ); + + newitem->m_Edge = m_Edge; + newitem->m_Shape = m_Shape; + + return newitem; +} + + +/********************************************************************************************/ +void DrawSheetLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, + int DrawMode, int Color ) +/********************************************************************************************/ +/* Routine de dessin des Labels type hierarchie */ +{ + int side, txtcolor; + int posx, tposx, posy, size2; + wxSize size; + int NbSegm, coord[20]; + int LineWidth = g_DrawMinimunLineWidth; + + if( Color >= 0 ) + txtcolor = Color; + else + txtcolor = ReturnLayerColor( m_Layer ); + GRSetDrawMode( DC, DrawMode ); + + posx = m_Pos.x + offset.x; posy = m_Pos.y + offset.y; size = m_Size; + if( !m_Text.IsEmpty() ) + { + if( m_Edge ) + { + tposx = posx - size.x; + side = GR_TEXT_HJUSTIFY_RIGHT; + } + else + { + tposx = posx + size.x + (size.x / 8); + side = GR_TEXT_HJUSTIFY_LEFT; + } + DrawGraphicText( panel, DC, wxPoint( tposx, posy ), txtcolor, + m_Text, TEXT_ORIENT_HORIZ, size, + side, GR_TEXT_VJUSTIFY_CENTER, LineWidth ); + } + /* dessin du symbole de connexion */ + + if( m_Edge ) + { + size.x = -size.x; + size.y = -size.y; + } + + coord[0] = posx; coord[1] = posy; size2 = size.x / 2; + NbSegm = 0; + + switch( m_Shape ) + { + case 0: /* input |> */ + coord[2] = posx; coord[3] = posy - size2; + coord[4] = posx + size2; coord[5] = posy - size2; + coord[6] = posx + size.x; coord[7] = posy; + coord[8] = posx + size2; coord[9] = posy + size2; + coord[10] = posx; coord[11] = posy + size2; + coord[12] = coord[0]; coord[13] = coord[1]; + NbSegm = 7; + break; + + case 1: /* output <| */ + coord[2] = posx + size2; coord[3] = posy - size2; + coord[4] = posx + size.x; coord[5] = posy - size2; + coord[6] = posx + size.x; coord[7] = posy + size2; + coord[8] = posx + size2; coord[9] = posy + size2; + coord[10] = coord[0]; coord[11] = coord[1]; + NbSegm = 6; + break; + + case 2: /* bidi <> */ + case 3: /* TriSt <> */ + coord[2] = posx + size2; coord[3] = posy - size2; + coord[4] = posx + size.x; coord[5] = posy; + coord[6] = posx + size2; coord[7] = posy + size2; + coord[8] = coord[0]; coord[9] = coord[1]; + NbSegm = 5; + break; + + default: /* unsp []*/ + coord[2] = posx; coord[3] = posy - size2; + coord[4] = posx + size.x; coord[5] = posy - size2; + coord[6] = posx + size.x; coord[7] = posy + size2; + coord[8] = posx; coord[9] = posy + size2; + coord[10] = coord[0]; coord[11] = coord[1]; + NbSegm = 6; + break; + } + + int FillShape = FALSE; + GRPoly( &panel->m_ClipBox, DC, NbSegm, coord, FillShape, LineWidth, txtcolor, txtcolor ); /* Poly Non rempli */ +} + +/**********************************************/ +/* class to handle a series of sheets *********/ +/* a 'path' so to speak.. *********************/ +/**********************************************/ +DrawSheetList::DrawSheetList(){ + for(int i=0; i d.m_numSheets) + return 1; + if(m_numSheets < d.m_numSheets) + return -1; + //otherwise, same number of sheets. + for(int i=0; im_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* DrawSheetList::Last(){ + if(m_numSheets) + return m_sheets[m_numSheets-1]; + return NULL; +} +SCH_SCREEN* DrawSheetList::LastScreen(){ + if(m_numSheets) + return m_sheets[m_numSheets-1]->m_s; + return NULL; +} +EDA_BaseStruct* DrawSheetList::LastDrawList(){ + if(m_numSheets && m_sheets[m_numSheets-1]->m_s) + return m_sheets[m_numSheets-1]->m_s->EEDrawList; + return NULL; +} +void DrawSheetList::Push(DrawSheetStruct* sheet){ + if(m_numSheets < DSLSZ){ + m_sheets[m_numSheets] = sheet; + m_numSheets++; + } +} +DrawSheetStruct* DrawSheetList::Pop(){ + if(m_numSheets > 0){ + m_numSheets --; + return m_sheets[m_numSheets]; + } + return NULL; +} +wxString DrawSheetList::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 DrawSheetList::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 DrawSheetList::UpdateAllScreenReferences(){ + EDA_BaseStruct* t = LastDrawList(); + while(t){ + if(t->Type() == DRAW_LIB_ITEM_STRUCT_TYPE){ + EDA_SchComponentStruct* d = (EDA_SchComponentStruct*)t; + d->m_Field[REFERENCE].m_Text = d->GetRef(this); + } + t = t->Pnext; + } + printf( "on sheet: %s \n", CONV_TO_UTF8(PathHumanReadable()) ); +} +bool DrawSheetList::operator= (const DrawSheetList& d1){ + m_numSheets = d1.m_numSheets; + int i; + for(i=0; iPnext; - delete label; - label = next_label; - } -} - - -/***********************************************/ -DrawSheetStruct* DrawSheetStruct::GenCopy() -/***********************************************/ - -/* creates a copy of a sheet - * The linked data itself (EEDrawList) is not duplicated - */ -{ - DrawSheetStruct* newitem = new DrawSheetStruct( m_Pos ); - - DrawSheetLabelStruct* Slabel = NULL, * label = m_Label; - - newitem->m_Size = m_Size; - newitem->m_Parent = m_Parent; - newitem->m_TimeStamp = GetTimeStamp(); - - newitem->m_FileName = m_FileName; - newitem->m_FileNameSize = m_FileNameSize; - newitem->m_SheetName = m_SheetName; - newitem->m_SheetNameSize = m_SheetNameSize; - - if( label ) - { - Slabel = newitem->m_Label = label->GenCopy(); - Slabel->m_Parent = newitem; - label = (DrawSheetLabelStruct*) label->Pnext; - } - - while( label ) - { - Slabel->Pnext = label->GenCopy(); - Slabel = (DrawSheetLabelStruct*) Slabel->Pnext; - Slabel->m_Parent = newitem; - label = (DrawSheetLabelStruct*) label->Pnext; - } - - /* copy screen data */ - newitem->m_DrawOrg = m_DrawOrg; - newitem->m_Curseur = m_Curseur; - newitem->m_MousePosition = m_MousePosition; - newitem->m_MousePositionInPixels = m_MousePositionInPixels; - newitem->m_O_Curseur = m_O_Curseur; - newitem->m_ScrollbarPos = m_ScrollbarPos; - newitem->m_ScrollbarNumber = m_ScrollbarNumber; - newitem->m_StartVisu = m_StartVisu; - newitem->m_FirstRedraw = m_FirstRedraw; - - newitem->EEDrawList = EEDrawList; /* Object list (main data) for schematic */ - newitem->m_UndoList = m_UndoList; /* Object list for the undo command (old data) */ - newitem->m_RedoList = m_RedoList; /* Object list for the redo command (old data) */ - - newitem->m_CurrentSheet = m_CurrentSheet; - newitem->m_SheetNumber = m_SheetNumber; - newitem->m_NumberOfSheet = m_NumberOfSheet; - newitem->m_FileName = m_FileName; - newitem->m_Title = m_Title; - newitem->m_Date = m_Date; - newitem->m_Revision = m_Revision; - newitem->m_Company = m_Company; - newitem->m_Commentaire1 = m_Commentaire1; - newitem->m_Commentaire2 = m_Commentaire2; - newitem->m_Commentaire3 = m_Commentaire3; - newitem->m_Commentaire4 = m_Commentaire4; - - return newitem; -} - - -/**********************************************************/ -void DrawSheetStruct::SwapData( DrawSheetStruct* copyitem ) -/**********************************************************/ - -/* Used if undo / redo command: - * swap data between this and copyitem - */ -{ - EXCHG( m_Pos, copyitem->m_Pos ); - EXCHG( m_Size, copyitem->m_Size ); - EXCHG( m_SheetName, copyitem->m_SheetName ); - EXCHG( m_SheetNameSize, copyitem->m_SheetNameSize ); - EXCHG( m_FileNameSize, copyitem->m_FileNameSize ); - EXCHG( m_Label, copyitem->m_Label ); - EXCHG( m_NbLabel, copyitem->m_NbLabel ); -} - - -/**************************************************************************************/ -void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, - int DrawMode, int Color ) -/**************************************************************************************/ -/* Draw the hierarchical sheet shape */ -{ - DrawSheetLabelStruct* SheetLabelStruct; - int txtcolor; - wxString Text; - int color; - wxPoint pos = m_Pos + offset; - int LineWidth = g_DrawMinimunLineWidth; - - if( Color >= 0 ) - color = Color; - else - color = ReturnLayerColor( m_Layer ); - GRSetDrawMode( DC, DrawMode ); - - GRRect( &panel->m_ClipBox, DC, pos.x, pos.y, - pos.x + m_Size.x, pos.y + m_Size.y, LineWidth, color ); - - /* Draw text : SheetName */ - if( Color > 0 ) - txtcolor = Color; - else - txtcolor = ReturnLayerColor( LAYER_SHEETNAME ); - - Text = wxT( "Sheet: " ) + m_SheetName; - DrawGraphicText( panel, DC, - wxPoint( pos.x, pos.y - 8 ), 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; - else - txtcolor = ReturnLayerColor( LAYER_SHEETFILENAME ); - Text = wxT( "File: " ) + m_FileName; - DrawGraphicText( panel, DC, - wxPoint( pos.x, pos.y + m_Size.y + 4 ), - txtcolor, - Text, TEXT_ORIENT_HORIZ, wxSize( m_FileNameSize, m_FileNameSize ), - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, LineWidth ); - - - /* Draw text : SheetLabel */ - SheetLabelStruct = m_Label; - while( SheetLabelStruct != NULL ) - { - SheetLabelStruct->Draw( panel, DC, offset, DrawMode, Color ); - SheetLabelStruct = (DrawSheetLabelStruct*) (SheetLabelStruct->Pnext); - } -} - - -/************************/ -/* DrawSheetLabelStruct */ -/************************/ - -/*******************************************************************/ -DrawSheetLabelStruct::DrawSheetLabelStruct( DrawSheetStruct* parent, - const wxPoint& pos, const wxString& text ) : - EDA_BaseStruct( DRAW_SHEETLABEL_STRUCT_TYPE ), - EDA_TextStruct( text ) -/*******************************************************************/ -{ - m_Layer = LAYER_SHEETLABEL; - m_Parent = parent; - m_Pos = pos; - m_Edge = 0; - m_Shape = NET_INPUT; - m_IsDangling = TRUE; -} - - -/***********************************************************/ -DrawSheetLabelStruct* DrawSheetLabelStruct::GenCopy() -/***********************************************************/ -{ - DrawSheetLabelStruct* newitem = - new DrawSheetLabelStruct( (DrawSheetStruct*) m_Parent, m_Pos, m_Text ); - - newitem->m_Edge = m_Edge; - newitem->m_Shape = m_Shape; - - return newitem; -} - - -/********************************************************************************************/ -void DrawSheetLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, - int DrawMode, int Color ) -/********************************************************************************************/ -/* Routine de dessin des Labels type hierarchie */ -{ - int side, txtcolor; - int posx, tposx, posy, size2; - wxSize size; - int NbSegm, coord[20]; - int LineWidth = g_DrawMinimunLineWidth; - - if( Color >= 0 ) - txtcolor = Color; - else - txtcolor = ReturnLayerColor( m_Layer ); - GRSetDrawMode( DC, DrawMode ); - - posx = m_Pos.x + offset.x; posy = m_Pos.y + offset.y; size = m_Size; - if( !m_Text.IsEmpty() ) - { - if( m_Edge ) - { - tposx = posx - size.x; - side = GR_TEXT_HJUSTIFY_RIGHT; - } - else - { - tposx = posx + size.x + (size.x / 8); - side = GR_TEXT_HJUSTIFY_LEFT; - } - DrawGraphicText( panel, DC, wxPoint( tposx, posy ), txtcolor, - m_Text, TEXT_ORIENT_HORIZ, size, - side, GR_TEXT_VJUSTIFY_CENTER, LineWidth ); - } - /* dessin du symbole de connexion */ - - if( m_Edge ) - { - size.x = -size.x; - size.y = -size.y; - } - - coord[0] = posx; coord[1] = posy; size2 = size.x / 2; - NbSegm = 0; - - switch( m_Shape ) - { - case 0: /* input |> */ - coord[2] = posx; coord[3] = posy - size2; - coord[4] = posx + size2; coord[5] = posy - size2; - coord[6] = posx + size.x; coord[7] = posy; - coord[8] = posx + size2; coord[9] = posy + size2; - coord[10] = posx; coord[11] = posy + size2; - coord[12] = coord[0]; coord[13] = coord[1]; - NbSegm = 7; - break; - - case 1: /* output <| */ - coord[2] = posx + size2; coord[3] = posy - size2; - coord[4] = posx + size.x; coord[5] = posy - size2; - coord[6] = posx + size.x; coord[7] = posy + size2; - coord[8] = posx + size2; coord[9] = posy + size2; - coord[10] = coord[0]; coord[11] = coord[1]; - NbSegm = 6; - break; - - case 2: /* bidi <> */ - case 3: /* TriSt <> */ - coord[2] = posx + size2; coord[3] = posy - size2; - coord[4] = posx + size.x; coord[5] = posy; - coord[6] = posx + size2; coord[7] = posy + size2; - coord[8] = coord[0]; coord[9] = coord[1]; - NbSegm = 5; - break; - - default: /* unsp []*/ - coord[2] = posx; coord[3] = posy - size2; - coord[4] = posx + size.x; coord[5] = posy - size2; - coord[6] = posx + size.x; coord[7] = posy + size2; - coord[8] = posx; coord[9] = posy + size2; - coord[10] = coord[0]; coord[11] = coord[1]; - NbSegm = 6; - break; - } - - int FillShape = FALSE; - GRPoly( &panel->m_ClipBox, DC, NbSegm, coord, FillShape, LineWidth, txtcolor, txtcolor ); /* Poly Non rempli */ -} diff --git a/eeschema/class_screen.cpp b/eeschema/class_screen.cpp index 680ea5967a..9fa2f139dd 100644 --- a/eeschema/class_screen.cpp +++ b/eeschema/class_screen.cpp @@ -1,7 +1,3 @@ -/**********************************************************/ -/* EECLASS.CPP */ -/* fonctions relatives aux classes definies dans EESCHEMA */ -/**********************************************************/ #include "fctsys.h" #include "gr_basic.h" @@ -24,6 +20,7 @@ void SetStructFather( EDA_BaseStruct* Struct, BASE_SCREEN* Screen ) case DRAW_TEXT_STRUCT_TYPE: case DRAW_LABEL_STRUCT_TYPE: case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: case DRAW_LIB_ITEM_STRUCT_TYPE: case DRAW_SEGMENT_STRUCT_TYPE: case DRAW_BUSENTRY_STRUCT_TYPE: @@ -54,8 +51,9 @@ void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) { if( m_Flags & IS_NEW ) { - Pnext = frame->m_CurrentScreen->EEDrawList; - frame->m_CurrentScreen->EEDrawList = this; + SCH_SCREEN* screen = (SCH_SCREEN*)frame->GetScreen(); + if(!screen->CheckIfOnDrawList(this)) //don't want a loop! + screen->AddToDrawList(this); g_ItemToRepeat = this; if( frame->m_Ident == SCHEMATIC_FRAME ) ( (WinEDA_SchematicFrame*) frame )->SaveCopyInUndoList( this, IS_NEW ); @@ -91,6 +89,9 @@ SCH_SCREEN::SCH_SCREEN( int screentype, KICAD_T aType ) : SetZoomList( table_zoom ); SetGridList( g_GridList ); m_UndoRedoCountMax = 10; + m_RefCount = 0; + m_ScreenNumber = 1; + m_NumberOfScreen = 1; } @@ -116,8 +117,9 @@ void SCH_SCREEN::FreeDrawList() { DrawStruct = EEDrawList; EEDrawList = EEDrawList->Pnext; - delete DrawStruct; + SAFE_DELETE(DrawStruct); } + EEDrawList = NULL; } @@ -134,7 +136,7 @@ void SCH_SCREEN::RemoveFromDrawList( EDA_BaseStruct* DrawStruct ) else { EDA_BaseStruct* DrawList = EEDrawList; - while( DrawList->Pnext ) + while( DrawList && DrawList->Pnext ) { if( DrawList->Pnext == DrawStruct ) { @@ -145,181 +147,169 @@ void SCH_SCREEN::RemoveFromDrawList( EDA_BaseStruct* DrawStruct ) } } } - +/**************************************************************/ +bool SCH_SCREEN::CheckIfOnDrawList( EDA_BaseStruct* st ) +/**************************************************************/ +{ + EDA_BaseStruct* DrawList = EEDrawList; + while( DrawList ){ + if( DrawList == st) + return true; + DrawList = DrawList->Pnext; + } + return false; +} +/**************************************************************/ +void SCH_SCREEN::AddToDrawList( EDA_BaseStruct* st ) +/**************************************************************/ +{ //simple function to add to the head of the drawlist. + st->Pnext = EEDrawList; + EEDrawList = st; +} /*********************************************************************/ /* Class EDA_ScreenList to handle the list of screens in a hierarchy */ /*********************************************************************/ -EDA_ScreenList::EDA_ScreenList( EDA_BaseStruct* DrawStruct ) - -/* create the list of screens (i.e hierarchycal sheets) found in DrawStruct - * if DrawStruct == NULL: start from root sheet and the root screen is included in list - */ -{ - m_Count = 0; - m_List = NULL; - m_Index = 0; - - /* Count the number of screens */ - BuildScreenList( NULL, DrawStruct, &m_Count ); - if( m_Count > NB_MAX_SHEET ) - { - wxString msg; - msg.Printf( wxT( "ReturnScreenList: Error: screen count > %d" ), NB_MAX_SHEET ); - DisplayError( NULL, msg ); - } - - - m_List = (SCH_SCREEN**) MyZMalloc( sizeof(SCH_SCREEN *) * (m_Count + 2) ); - /* Fill the list */ - BuildScreenList( m_List, DrawStruct, &m_Count ); -} - - -/*****************************************/ -EDA_ScreenList::~EDA_ScreenList() -/*****************************************/ -{ - if( m_List ) - free( m_List ); - m_List = NULL; -} - - /*****************************************/ SCH_SCREEN* EDA_ScreenList::GetFirst() /*****************************************/ { m_Index = 0; - if( m_List ) - return *m_List; - else - return NULL; + if(m_List.GetCount() > 0) + return m_List[0]; + return NULL; } - /*****************************************/ SCH_SCREEN* EDA_ScreenList::GetNext() /*****************************************/ { - if( m_Index < m_Count ) + if( m_Index < m_List.GetCount() ) m_Index++; - - if( (m_Index < m_Count) && m_List ) - { - return m_List[m_Index]; - } - else - return NULL; + return GetScreen(m_Index); } /************************************************/ -SCH_SCREEN* EDA_ScreenList::GetScreen( int index ) +SCH_SCREEN* EDA_ScreenList::GetScreen( unsigned int index ) /************************************************/ /* return the m_List[index] item */ { - SCH_SCREEN* screen = NULL; + if( index < m_List.GetCount() ) + return m_List[index]; + return NULL; +} +/************************************************/ +void EDA_ScreenList::AddScreenToList( SCH_SCREEN* testscreen ) +/************************************************/ +{ + if(testscreen == NULL) return; + for(unsigned int i=0; i< m_List.GetCount(); i++){ + if(m_List[i] == testscreen) + return; + } + m_List.Add(testscreen); +#ifdef DEBUG + printf("EDA_ScreenList::AddScreenToList adding %s\n", (const char*)testscreen->m_FileName.mb_str()); +#endif +} +/************************************************/ +void EDA_ScreenList::UpdateScreenNumberAndDate( ) +/************************************************/ +{ + SCH_SCREEN* screen; + + wxString date = GenDate(); + for(int i=0; i<(int)m_List.GetCount(); i++){ + screen = m_List[i]; + screen->m_ScreenNumber = i; + screen->m_NumberOfScreen = m_List.GetCount(); + screen->m_Date = date; + } +} +/************************************************************************/ +void EDA_ScreenList::BuildScreenList(EDA_BaseStruct* s) +/************************************************************************/ +{ + if(s && s->Type() == DRAW_SHEET_STRUCT_TYPE){ + DrawSheetStruct* ds = (DrawSheetStruct*)s; + s = ds->m_s; + } + if(s && s->Type() == SCREEN_STRUCT_TYPE){ + SCH_SCREEN* screen = (SCH_SCREEN*)s; + AddScreenToList(screen); + EDA_BaseStruct* strct = screen->EEDrawList; + while(strct){ + if(strct->Type() == DRAW_SHEET_STRUCT_TYPE){ + BuildScreenList(strct); + } + strct = strct->Pnext; + } + } +} +/*********************************************************************/ +/* Class EDA_SheetList to handle the list of Sheets in a hierarchy */ +/*********************************************************************/ - if( (index >= 0) && index < m_Count ) - screen = m_List[index]; - - return screen; +/*****************************************/ +DrawSheetList* EDA_SheetList::GetFirst() +/*****************************************/ +{ + m_index = 0; + if(m_count > 0) + return &( m_List[0] ); + return NULL; } +/*****************************************/ +DrawSheetList* EDA_SheetList::GetNext() +/*****************************************/ +{ + if( m_index < m_count ) + m_index++; + return GetSheet(m_index); +} -/**************************************************/ -void EDA_ScreenList::UpdateSheetNumberAndDate() -/**************************************************/ - -/* Update the sheet number, the sheet count and the date for all sheets in list +/************************************************/ +DrawSheetList* EDA_SheetList::GetSheet(int index ) +/************************************************/ +/* return the m_List[index] item */ { - int SheetNumber = 1; - SCH_SCREEN* screen; - wxString sheet_date = GenDate(); - - for( screen = GetFirst(); screen != NULL; screen = GetNext() ) - { - screen->m_SheetNumber = SheetNumber++; /* Update the sheet number */ - screen->m_NumberOfSheet = m_Count; /* Update the number of sheets */ - screen->m_Date = sheet_date; /* Update the sheet date */ - } + if( index < m_count ) + return &(m_List[index]); + return NULL; } - /************************************************************************/ -SCH_SCREEN** EDA_ScreenList::BuildScreenList( SCH_SCREEN** ScreenList, - EDA_BaseStruct* DrawStruct, int* Count ) +void EDA_SheetList::BuildSheetList(DrawSheetStruct* sheet) /************************************************************************/ - -/* Count the Hierachical sheet number (ScreenList == NULL ) - * or fill the screen pointer buffer (ScreenList != NULL ) - * If DrawStruct = NULL, search starts from Root screen, and puts root screen in list - * Recursive function ! - */ { - bool HasSubhierarchy = FALSE; - EDA_BaseStruct* CurrStruct; - - if( *Count > NB_MAX_SHEET ) - { - return ScreenList; - } - - /* Read the current list and put Screen pointers in list */ - if( DrawStruct == NULL ) - { - DrawStruct = ScreenSch->EEDrawList; - if( ScreenList ) - { - *ScreenList = ScreenSch; - ScreenList++; - } - else - (*Count)++; - } - - CurrStruct = DrawStruct; - while( CurrStruct ) - { - if( CurrStruct->Type() == DRAW_SHEET_STRUCT_TYPE ) - { - HasSubhierarchy = TRUE; - if( ScreenList ) - { - *ScreenList = (SCH_SCREEN*) CurrStruct; - ScreenList++; - } - else - (*Count)++; - } - CurrStruct = CurrStruct->Pnext; - } - - if( !HasSubhierarchy ) - return ScreenList; - - /* Read the Sub Hierarchies */ - CurrStruct = DrawStruct; - while( CurrStruct ) - { - if( CurrStruct->Type() == DRAW_SHEET_STRUCT_TYPE ) - { - SCH_SCREEN* Screen = (SCH_SCREEN*) CurrStruct; - - /* Go to Subhierachy if needed - * (warning: BuildScreenList must not called with a NULL parameter - * for DrawStruct, because BuildScreenList restart from the root screen - * when DrawStruct == NULL */ - if( Screen->EEDrawList ) - ScreenList = BuildScreenList( ScreenList, Screen->EEDrawList, Count ); - } - CurrStruct = CurrStruct->Pnext; - } - - return ScreenList; + 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(DrawSheetList); + m_List = (DrawSheetList*)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_s != NULL){ + EDA_BaseStruct* strct = m_currList.LastDrawList(); + while(strct){ + if(strct->Type() == DRAW_SHEET_STRUCT_TYPE){ + DrawSheetStruct* sht = (DrawSheetStruct*)strct; + BuildSheetList(sht); + } + strct = strct->Pnext; + } + } + m_currList.Pop(); } diff --git a/eeschema/class_screen.h b/eeschema/class_screen.h index a2a45e716f..db4476c9de 100644 --- a/eeschema/class_screen.h +++ b/eeschema/class_screen.h @@ -83,11 +83,16 @@ extern int* TemplateShape[5][4]; /* Forward declarations */ class DrawSheetStruct; +extern DrawSheetStruct* g_RootSheet; class SCH_SCREEN : public BASE_SCREEN { public: + int m_RefCount; //how many sheets reference this screen? + //delete when it goes to zero. + int m_ScreenNumber; + int m_NumberOfScreen; SCH_SCREEN( int idtype, KICAD_T aType = SCREEN_STRUCT_TYPE ); ~SCH_SCREEN(); @@ -100,6 +105,8 @@ public: void Place( WinEDA_DrawFrame* frame, wxDC* DC ) { }; void RemoveFromDrawList( EDA_BaseStruct* DrawStruct );/* remove DrawStruct from EEDrawList. */ + bool CheckIfOnDrawList( EDA_BaseStruct* st ); + void AddToDrawList( EDA_BaseStruct* DrawStruct ); void ClearUndoORRedoList( EDA_BaseStruct* List ); bool SchematicCleanUp( wxDC* DC = NULL ); @@ -117,7 +124,7 @@ class DrawSheetLabelStruct : public EDA_BaseStruct, public EDA_TextStruct public: int m_Layer; int m_Edge, m_Shape; - bool m_IsDangling; // TRUE si non connecté + bool m_IsDangling; // TRUE si non connect� public: DrawSheetLabelStruct( DrawSheetStruct* parent, @@ -140,20 +147,25 @@ public: int draw_mode, int Color = -1 ); }; +WX_DEFINE_ARRAY( DrawSheetStruct*, SheetGrowArray ); -class DrawSheetStruct : public SCH_SCREEN /* Gestion de la hierarchie */ +class DrawSheetStruct : public EDA_BaseStruct /*public SCH_SCREEN*/ /* Gestion de la hierarchie */ { public: - wxString m_SheetName; - int m_SheetNameSize; + wxString m_SheetName; //this is equivalent to C101 for components: + // it is stored in F0 ... of the file. + wxString m_FileName; //also in SCH_SCREEN (redundant), + //but need it here for loading after + //reading the sheet description from file. + int m_SheetNameSize; -// wxString m_FileName; in SCH_SCREEN - int m_FileNameSize; - wxPoint m_Pos; - wxSize m_Size; /* Position and Size of sheet symbol */ - int m_Layer; - DrawSheetLabelStruct* m_Label; /* Points de connection */ - int m_NbLabel; /* Nombre de points de connexion */ + int m_FileNameSize; + wxPoint m_Pos; + wxSize m_Size; /* Position and Size of sheet symbol */ + int m_Layer; + DrawSheetLabelStruct* m_Label; /* Points de connection, linked list.*/ + int m_NbLabel; /* Nombre de points de connexion */ + SCH_SCREEN* m_s; public: DrawSheetStruct( const wxPoint& pos = wxPoint( 0, 0 ) ); @@ -169,30 +181,95 @@ public: void CleanupSheet( WinEDA_SchematicFrame* frame, wxDC* DC ); virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode, int Color = -1 ); - void SwapData( DrawSheetStruct* copyitem ); + void SwapData( DrawSheetStruct* copyitem ); + void DeleteAnnotation( bool recurse ); + int ComponentCount(); + bool Load(WinEDA_SchematicFrame* frame); + bool SearchHierarchy(wxString filename, SCH_SCREEN **screen); + bool LocatePathOfScreen(SCH_SCREEN *screen, DrawSheetList* list); + int CountSheets(); + //void RemoveSheet(DrawSheetStruct* sheet); + //to remove a sheet, just delete it + //-- the destructor should take care of everything else. }; +#define DSLSZ 32 +class DrawSheetList +{ +public: + int m_numSheets; + DrawSheetStruct* m_sheets[DSLSZ]; + + DrawSheetList(); + ~DrawSheetList(){}; + void Clear(){m_numSheets = 0; } + int Cmp(DrawSheetList& d); + DrawSheetStruct* Last(); + SCH_SCREEN* LastScreen(); + EDA_BaseStruct* LastDrawList(); + void Push(DrawSheetStruct* sheet); + DrawSheetStruct* Pop(); + wxString Path(); + wxString PathHumanReadable(); + void UpdateAllScreenReferences(); + bool operator= (const DrawSheetList& d1); + bool operator==(const DrawSheetList &d1); + bool operator!=(const DrawSheetList &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_SHEET reference. +class EDA_SheetList +{ + private: + DrawSheetList* m_List; + int m_count; + int m_index; + DrawSheetList m_currList; -/* Class to handle the list of screens in a hierarchy */ + 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; } + DrawSheetList* GetFirst(); + DrawSheetList* GetNext(); + DrawSheetList* GetSheet(int index ); + + private: + void BuildSheetList( DrawSheetStruct* sheet ); +}; + +/* Class to handle the list of *screens* in a hierarchy */ +// screens are unique, and correspond to .sch files. +WX_DEFINE_ARRAY( SCH_SCREEN*, ScreenGrowArray ); class EDA_ScreenList { private: - int m_Count; - SCH_SCREEN** m_List; - int m_Index; + ScreenGrowArray m_List; + unsigned int m_Index; public: - EDA_ScreenList( EDA_BaseStruct* DrawStruct ); - ~EDA_ScreenList(); - int GetCount() { return m_Count; } + EDA_ScreenList(){ + m_Index = 0; + BuildScreenList(g_RootSheet); + } + ~EDA_ScreenList() {} + int GetCount() { return m_List.GetCount(); } SCH_SCREEN* GetFirst(); SCH_SCREEN* GetNext(); - SCH_SCREEN* GetScreen( int index ); - void UpdateSheetNumberAndDate(); + SCH_SCREEN* GetScreen( unsigned int index ); + void UpdateScreenNumberAndDate(); private: - SCH_SCREEN** BuildScreenList( SCH_SCREEN** ScreenList, - EDA_BaseStruct* DrawStruct, int* Count ); + void AddScreenToList( SCH_SCREEN* testscreen ); + void BuildScreenList( EDA_BaseStruct* sheet ); }; #endif /* CLASS_SCREEN_H */ diff --git a/eeschema/class_text-label.cpp b/eeschema/class_text-label.cpp index 693faa10b9..8263521a43 100644 --- a/eeschema/class_text-label.cpp +++ b/eeschema/class_text-label.cpp @@ -18,6 +18,7 @@ /* class DrawTextStruct */ /* class DrawLabelStruct */ /* class DrawGlobalLabelStruct */ +/* class DrawHierLabelStruct */ /************************/ /**************************************************************************/ @@ -47,9 +48,13 @@ DrawTextStruct* DrawTextStruct::GenCopy() break; case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - newitem = new DrawGlobalLabelStruct( m_Pos, m_Text ); + newitem = new DrawGlobalLabelStruct(m_Pos, m_Text ); break; + case DRAW_HIER_LABEL_STRUCT_TYPE: + newitem = new DrawHierLabelStruct(m_Pos, m_Text ); + break; + case DRAW_LABEL_STRUCT_TYPE: newitem = new DrawLabelStruct( m_Pos, m_Text ); break; @@ -102,8 +107,7 @@ void DrawTextStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) /* restore new values */ SwapData( (DrawTextStruct*) g_ItemToUndoCopy ); - delete g_ItemToUndoCopy; - g_ItemToUndoCopy = NULL; + SAFE_DELETE( g_ItemToUndoCopy ); } EDA_BaseStruct::Place( frame, DC ); @@ -121,15 +125,24 @@ DrawLabelStruct::DrawLabelStruct( const wxPoint& pos, const wxString& text ) : /***********************************************************************************/ -DrawGlobalLabelStruct::DrawGlobalLabelStruct( const wxPoint& pos, const wxString& text ) : +DrawGlobalLabelStruct::DrawGlobalLabelStruct(const wxPoint& pos, const wxString& text) : DrawTextStruct( pos, text, DRAW_GLOBAL_LABEL_STRUCT_TYPE ) /***********************************************************************************/ { - m_Layer = LAYER_GLOBLABEL; - m_Shape = NET_INPUT; + m_Layer = LAYER_GLOBLABEL; + m_Shape = NET_BIDI; m_IsDangling = TRUE; } +/***********************************************************************************/ +DrawHierLabelStruct::DrawHierLabelStruct(const wxPoint& pos, const wxString& text) : + DrawTextStruct( pos, text, DRAW_HIER_LABEL_STRUCT_TYPE ) +/***********************************************************************************/ +{ + m_Layer = LAYER_HIERLABEL; + m_Shape = NET_INPUT; + m_IsDangling = TRUE; +} /*******************************************************************************************/ void DrawTextStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, @@ -201,10 +214,9 @@ void DrawLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& of /*******************************************************************************************/ -void DrawGlobalLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, +void DrawHierLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int DrawMode, int Color ) /******************************************************************************************/ - /* Texts type Global Label have 4 directions, and the Text origin is the graphic icon */ { @@ -214,46 +226,45 @@ void DrawGlobalLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoi wxSize Size = m_Size; int width = MAX( m_Width, g_DrawMinimunLineWidth ); - if( Color >= 0 ) - color = Color; - else - color = ReturnLayerColor( m_Layer ); + if( Color >= 0 ) + color = Color; + else + color = ReturnLayerColor( m_Layer ); - GRSetDrawMode( DC, DrawMode ); + GRSetDrawMode( DC, DrawMode ); - HalfSize = Size.x / 2; ii = Size.x + TXTMARGE; + HalfSize = Size.x / 2; ii = Size.x + TXTMARGE; - switch( m_Orient ) - { - case 0: /* Orientation horiz normale */ - DrawGraphicText( panel, DC, - wxPoint( m_Pos.x - ii + offset.x, m_Pos.y + offset.y ), color, - m_Text, TEXT_ORIENT_HORIZ, Size, - GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, width ); - break; + switch( m_Orient ) + { + case 0: /* Orientation horiz normale */ + DrawGraphicText( panel, DC, + wxPoint( m_Pos.x - ii + offset.x, m_Pos.y + offset.y ), color, + m_Text, TEXT_ORIENT_HORIZ, Size, + GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, width ); + break; - case 1: /* Orientation vert UP */ - DrawGraphicText( panel, DC, - wxPoint( m_Pos.x + offset.x, m_Pos.y + ii + offset.y ), color, - m_Text, TEXT_ORIENT_VERT, Size, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, width ); - break; + case 1: /* Orientation vert UP */ + DrawGraphicText( panel, DC, + wxPoint( m_Pos.x + offset.x, m_Pos.y + ii + offset.y ), color, + m_Text, TEXT_ORIENT_VERT, Size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, width ); + break; - case 2: /* Orientation horiz inverse */ - DrawGraphicText( panel, DC, - wxPoint( m_Pos.x + ii + offset.x, m_Pos.y + offset.y ), color, - m_Text, TEXT_ORIENT_HORIZ, Size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); - break; - - case 3: /* Orientation vert BOTTOM */ - DrawGraphicText( panel, DC, - wxPoint( m_Pos.x + offset.x, m_Pos.y - ii + offset.y ), color, - m_Text, TEXT_ORIENT_VERT, Size, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, width ); - break; - } + case 2: /* Orientation horiz inverse */ + DrawGraphicText( panel, DC, + wxPoint( m_Pos.x + ii + offset.x, m_Pos.y + offset.y ), color, + m_Text, TEXT_ORIENT_HORIZ, Size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); + break; + case 3: /* Orientation vert BOTTOM */ + DrawGraphicText( panel, DC, + wxPoint( m_Pos.x + offset.x, m_Pos.y - ii + offset.y ), color, + m_Text, TEXT_ORIENT_VERT, Size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, width ); + break; + } Template = TemplateShape[m_Shape][m_Orient]; @@ -271,3 +282,74 @@ void DrawGlobalLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoi if( m_IsDangling ) DrawDanglingSymbol( panel, DC, m_Pos + offset, color ); } +/*******************************************************************************************/ +void DrawGlobalLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, + int DrawMode, int Color ) +/******************************************************************************************/ +/* Texts type Global Label have 4 directions, and the Text origin is the graphic icon + */ + //should reimplement this with a custom global shape?? + //it is the same as Hierarchal sheet. +{ + int* Template; + int Poly[20]; + int ii, jj, imax, color, HalfSize; + wxSize Size = m_Size; + int width = MAX( m_Width, g_DrawMinimunLineWidth ); + + if( Color >= 0 ) + color = Color; + else + color = ReturnLayerColor( m_Layer ); + + GRSetDrawMode( DC, DrawMode ); + + HalfSize = Size.x / 2; ii = Size.x + TXTMARGE; + + switch( m_Orient ) + { + case 0: /* Orientation horiz normale */ + DrawGraphicText( panel, DC, + wxPoint( m_Pos.x - ii + offset.x, m_Pos.y + offset.y ), color, + m_Text, TEXT_ORIENT_HORIZ, Size, + GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, width ); + break; + + case 1: /* Orientation vert UP */ + DrawGraphicText( panel, DC, + wxPoint( m_Pos.x + offset.x, m_Pos.y + ii + offset.y ), color, + m_Text, TEXT_ORIENT_VERT, Size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, width ); + break; + + case 2: /* Orientation horiz inverse */ + DrawGraphicText( panel, DC, + wxPoint( m_Pos.x + ii + offset.x, m_Pos.y + offset.y ), color, + m_Text, TEXT_ORIENT_HORIZ, Size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); + break; + + case 3: /* Orientation vert BOTTOM */ + DrawGraphicText( panel, DC, + wxPoint( m_Pos.x + offset.x, m_Pos.y - ii + offset.y ), color, + m_Text, TEXT_ORIENT_VERT, Size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, width ); + break; + } + + Template = TemplateShape[m_Shape][m_Orient]; + + imax = *Template; Template++; + for( ii = 0, jj = 0; ii < imax; ii++ ) + { + Poly[jj] = ( HalfSize * (*Template) ) + m_Pos.x + offset.x; + jj++; Template++; + Poly[jj] = ( HalfSize * (*Template) ) + m_Pos.y + offset.y; + jj++; Template++; + } + + GRPoly( &panel->m_ClipBox, DC, imax, Poly, 0, width, color, color ); + + if( m_IsDangling ) + DrawDanglingSymbol( panel, DC, m_Pos + offset, color ); +} diff --git a/eeschema/cleanup.cpp b/eeschema/cleanup.cpp index 3040121040..8a639a0779 100644 --- a/eeschema/cleanup.cpp +++ b/eeschema/cleanup.cpp @@ -106,6 +106,7 @@ void BreakSegmentOnJunction( SCH_SCREEN* Screen ) case DRAW_NOCONNECT_STRUCT_TYPE: case DRAW_LABEL_STRUCT_TYPE: case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: case DRAW_LIB_ITEM_STRUCT_TYPE: case DRAW_PICK_ITEM_STRUCT_TYPE: case DRAW_POLYLINE_STRUCT_TYPE: diff --git a/eeschema/component_class.cpp b/eeschema/component_class.cpp index 39c221496b..726ab61f3f 100644 --- a/eeschema/component_class.cpp +++ b/eeschema/component_class.cpp @@ -16,7 +16,8 @@ #include "macros.h" - +#include +WX_DEFINE_OBJARRAY(ArrayOfSheetLists); /***************************/ /* class DrawPartStruct */ /* class EDA_SchComponentStruct */ @@ -88,7 +89,72 @@ const wxString& EDA_SchComponentStruct::ReturnFieldName( int aFieldNdx ) const return m_Field[aFieldNdx].m_Name; } +/************************************/ +wxString EDA_SchComponentStruct::GetPath(DrawSheetList* sheet) +/************************************/ +{ + wxString str; + str.Printf(_("%8.8lX"), m_TimeStamp ); + return sheet->Path() + str; +} +/************************************/ +const wxString EDA_SchComponentStruct::GetRef( DrawSheetList* sheet ) +/************************************/ +{ + wxString path = GetPath( sheet ); + unsigned int i; + for(i=0; i 1000)) { + //move it to a reasonable position.. + m_Field[REFERENCE].m_Pos = m_Pos; + } + m_Field[REFERENCE].m_Text = ref; //for drawing. +} + +/************************************/ +void EDA_SchComponentStruct::ClearRefs() +/************************************/ +{ + m_Paths.Empty(); + m_References.Empty(); +} + const wxString& EDA_SchComponentStruct::GetFieldValue( int aFieldNdx ) const { // avoid unnecessarily copying wxStrings. @@ -109,8 +175,8 @@ EDA_SchComponentStruct::EDA_SchComponentStruct( const wxPoint& pos ) : int ii; m_Multi = 0; /* In multi unit chip - which unit to draw. */ - m_RefIdNumber = 0; - m_FlagControlMulti = 0; + //m_FlagControlMulti = 0; + m_UsedOnSheets.Clear(); m_Convert = 0; /* Gestion des mutiples representations (conversion De Morgan) */ /* The rotation/mirror transformation matrix. pos normal*/ @@ -132,6 +198,8 @@ EDA_SchComponentStruct::EDA_SchComponentStruct( const wxPoint& pos ) : m_Field[REFERENCE].m_Layer = LAYER_REFERENCEPART; m_PinIsDangling = NULL; + + m_PrefixString = wxString(_("U")); } @@ -183,8 +251,6 @@ EDA_Rect EDA_SchComponentStruct::GetBoundaryBox() BoundaryBox.Offset( m_Pos ); return BoundaryBox; } - - /**************************************************************************/ void PartTextStruct::SwapData( PartTextStruct* copyitem ) /**************************************************************************/ @@ -250,8 +316,7 @@ void EDA_SchComponentStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) /* restore new values */ SwapData( (EDA_SchComponentStruct*) g_ItemToUndoCopy ); - delete g_ItemToUndoCopy; - g_ItemToUndoCopy = NULL; + SAFE_DELETE( g_ItemToUndoCopy ); } EDA_BaseStruct::Place( frame, DC ); @@ -265,13 +330,13 @@ void EDA_SchComponentStruct::ClearAnnotation() /* Suppress annotation ( i.i IC23 changed to IC? and part reset to 1) */ { - m_RefIdNumber = 0; - - while( isdigit( m_Field[REFERENCE].m_Text.Last() ) ) - m_Field[REFERENCE].m_Text.RemoveLast(); - - if( m_Field[REFERENCE].m_Text.Last() != '?' ) - m_Field[REFERENCE].m_Text.Append( '?' ); + wxString defRef = m_PrefixString; + defRef.Append( _("?") ); + m_References.Empty(); + unsigned int i; + for(i=0; i< m_Paths.GetCount(); i++){ + m_References.Add(defRef); + } EDA_LibComponentStruct* Entry; Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); @@ -291,7 +356,8 @@ EDA_SchComponentStruct* EDA_SchComponentStruct::GenCopy() new_item->m_Multi = m_Multi; new_item->m_ChipName = m_ChipName; - new_item->m_FlagControlMulti = m_FlagControlMulti; + //new_item->m_FlagControlMulti = m_FlagControlMulti; + new_item->m_UsedOnSheets = m_UsedOnSheets; new_item->m_Convert = m_Convert; new_item->m_Transform[0][0] = m_Transform[0][0]; new_item->m_Transform[0][1] = m_Transform[0][1]; @@ -522,9 +588,9 @@ int EDA_SchComponentStruct::GetRotationMiroir() wxPoint EDA_SchComponentStruct::GetScreenCoord( const wxPoint& coord ) /***********************************************************************/ -/* Renvoie la coordonnée du point coord, en fonction de l'orientation +/* Renvoie la coordonn�e du point coord, en fonction de l'orientation * du composant (rotation, miroir). - * Les coord sont toujours relatives à l'ancre (coord 0,0) du composant + * Les coord sont toujours relatives � l'ancre (coord 0,0) du composant */ { wxPoint screenpos; @@ -548,7 +614,7 @@ void EDA_SchComponentStruct::Show( int nestLevel, std::ostream& os ) { // for now, make it look like XML: NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << - " ref=\"" << GetReference().mb_str() << '"' << + " ref=\"" << ReturnFieldName(0) << '"' << " chipName=\"" << m_ChipName.mb_str() << '"' << m_Pos << " layer=\"" << m_Layer << '"' << diff --git a/eeschema/component_class.h b/eeschema/component_class.h index 9e563d3321..63afbfba3d 100644 --- a/eeschema/component_class.h +++ b/eeschema/component_class.h @@ -11,10 +11,11 @@ #include "macros.h" #include "base_struct.h" - +#include +#include "class_screen.h" +#include /* Definition de la representation du composant */ -#define NUMBER_OF_FIELDS 12 /* Nombre de champs de texte affectes au composant */ enum NumFieldType { REFERENCE = 0, /* Champ Reference of part, i.e. "IC21" */ VALUE, /* Champ Value of part, i.e. "3.3K" */ @@ -27,7 +28,8 @@ enum NumFieldType { FIELD5, FIELD6, FIELD7, - FIELD8 + FIELD8, + NUMBER_OF_FIELDS /* Nombre de champs de texte affectes au composant */ }; @@ -64,7 +66,7 @@ public: /* the class DrawPartStruct describes a basic virtual component * Not used directly: - * used classes are EDA_SchComponentStruct (the "classic" schematic component + * used classes are EDA_SchComponentStruct (the "classic" schematic component, below) * and the Pseudo component DrawSheetStruct */ class DrawPartStruct : public EDA_BaseStruct @@ -83,27 +85,26 @@ public: { return wxT( "DrawPart" ); } - - - /** - * Function GetReference - * returns a reference to the Reference - */ - const wxString& GetReference() { return m_Field[REFERENCE].m_Text; } }; - +WX_DECLARE_OBJARRAY(DrawSheetList, ArrayOfSheetLists); /* the class EDA_SchComponentStruct describes a real component */ class EDA_SchComponentStruct : public DrawPartStruct { public: - int m_RefIdNumber; /* reference count: for U1, R2 .. it is the 1 or 2 value */ int m_Multi; /* In multi unit chip - which unit to draw. */ - int m_FlagControlMulti; - int m_Convert; /* Gestion des mutiples representations (ex: conversion De Morgan) */ + //int m_FlagControlMulti; + ArrayOfSheetLists m_UsedOnSheets; + int m_Convert; /* Gestion (management) des mutiples representations (ex: conversion De Morgan) */ int m_Transform[2][2]; /* The rotation/mirror transformation matrix. */ bool* m_PinIsDangling; // liste des indicateurs de pin non connectee + wxArrayString m_Paths; // /sheet1/C102, /sh2/sh1/U32 etc. + wxArrayString m_References; // C102, U32 etc. + wxString m_PrefixString; //C, R, U, Q etc - the first character which typically indicates what the component is. + //determined, upon placement, from the library component. + //determined, upon file load, by the first non-digits in the reference fields. + public: EDA_SchComponentStruct( const wxPoint& pos = wxPoint( 0, 0 ) ); ~EDA_SchComponentStruct( void ) { } @@ -142,7 +143,13 @@ public: void SwapData( EDA_SchComponentStruct* copyitem ); virtual void Place( WinEDA_DrawFrame* frame, wxDC* DC ); - + + + //returns a unique ID, in the form of a path. + wxString GetPath( DrawSheetList* sheet); + const wxString GetRef( DrawSheetList* sheet ); + void SetRef( DrawSheetList* sheet, wxString ref ); + void ClearRefs(); #if defined(DEBUG) /** * Function Show diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp index d66b58de49..000637bdba 100644 --- a/eeschema/controle.cpp +++ b/eeschema/controle.cpp @@ -60,7 +60,7 @@ SchematicGeneralLocateAndDisplay( bool IncludePin ) break; case DRAW_LIB_ITEM_STRUCT_TYPE: - Pin = LocateAnyPin( m_CurrentScreen->EEDrawList, GetScreen()->m_Curseur, &LibItem ); + Pin = LocateAnyPin( GetScreen()->EEDrawList, GetScreen()->m_Curseur, &LibItem ); if( Pin ) break; // Priority is probing a pin first LibItem = (EDA_SchComponentStruct*) DrawStruct; @@ -68,7 +68,7 @@ SchematicGeneralLocateAndDisplay( bool IncludePin ) break; default: - Pin = LocateAnyPin( m_CurrentScreen->EEDrawList, GetScreen()->m_Curseur, &LibItem ); + Pin = LocateAnyPin( GetScreen()->EEDrawList, GetScreen()->m_Curseur, &LibItem ); break; case COMPONENT_PIN_DRAW_TYPE: @@ -82,7 +82,7 @@ SchematicGeneralLocateAndDisplay( bool IncludePin ) Pin->Display_Infos( this ); if( LibItem ) Affiche_1_Parametre( this, 1, - LibItem->m_Field[REFERENCE].m_Text, + LibItem->GetRef(GetSheet()), LibItem->m_Field[VALUE].m_Text, CYAN ); @@ -121,7 +121,7 @@ SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, bool IncludePin ) wxString msg; int ii; - DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList, MARKERITEM ); + DrawStruct = PickStruct( refpoint, GetScreen(), MARKERITEM ); if( DrawStruct ) { DrawMarkerStruct* Marker = (DrawMarkerStruct*) DrawStruct; @@ -134,7 +134,7 @@ SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, bool IncludePin ) return DrawStruct; } - DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList, + DrawStruct = PickStruct( refpoint, GetScreen(), NOCONNECTITEM ); if( DrawStruct ) { @@ -142,7 +142,7 @@ SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, bool IncludePin ) return DrawStruct; } - DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList, + DrawStruct = PickStruct( refpoint, GetScreen(), JUNCTIONITEM ); if( DrawStruct ) { @@ -150,17 +150,17 @@ SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, bool IncludePin ) return DrawStruct; } - DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList, + DrawStruct = PickStruct( refpoint, GetScreen(), WIREITEM | BUSITEM | RACCORDITEM ); if( DrawStruct ) // Search for a pin { - Pin = LocateAnyPin( m_CurrentScreen->EEDrawList, refpoint, &LibItem ); + Pin = LocateAnyPin( m_CurrentSheet->LastDrawList(), refpoint, &LibItem ); if( Pin ) { Pin->Display_Infos( this ); if( LibItem ) Affiche_1_Parametre( this, 1, - LibItem->m_Field[REFERENCE].m_Text, + LibItem->GetRef(GetSheet()), LibItem->m_Field[VALUE].m_Text, CYAN ); } @@ -169,7 +169,7 @@ SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, bool IncludePin ) return DrawStruct; } - DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList, FIELDCMPITEM ); + DrawStruct = PickStruct( refpoint, GetScreen(), FIELDCMPITEM ); if( DrawStruct ) { PartTextStruct* Field = (PartTextStruct*) DrawStruct; @@ -180,29 +180,29 @@ SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, bool IncludePin ) } /* search for a pin */ - Pin = LocateAnyPin( m_CurrentScreen->EEDrawList, refpoint, &LibItem ); + Pin = LocateAnyPin( m_CurrentSheet->LastDrawList(), refpoint, &LibItem ); if( Pin ) { Pin->Display_Infos( this ); if( LibItem ) Affiche_1_Parametre( this, 1, - LibItem->m_Field[REFERENCE].m_Text, + LibItem->GetRef(GetSheet()), LibItem->m_Field[VALUE].m_Text, CYAN ); if( IncludePin == TRUE ) return LibItem; } - DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList, LIBITEM ); + DrawStruct = PickStruct( refpoint, GetScreen(), LIBITEM ); if( DrawStruct ) { - DrawStruct = LocateSmallestComponent( GetScreen() ); + DrawStruct = LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ); LibItem = (EDA_SchComponentStruct*) DrawStruct; LibItem->Display_Infos( this ); return DrawStruct; } - DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList, + DrawStruct = PickStruct( refpoint, GetScreen(), SHEETITEM ); if( DrawStruct ) { @@ -211,7 +211,7 @@ SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, bool IncludePin ) } // Recherche des autres elements - DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList, + DrawStruct = PickStruct( refpoint, GetScreen(), SEARCHALL ); if( DrawStruct ) { @@ -228,17 +228,16 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels /***********************************************************************/ { wxSize delta; - int zoom = m_CurrentScreen->GetZoom(); + SCH_SCREEN* screen = (SCH_SCREEN*)GetScreen(); + int zoom = screen->GetZoom(); wxPoint curpos, oldpos; int hotkey = 0; - ActiveScreen = (SCH_SCREEN*) m_CurrentScreen; + curpos = screen->m_MousePosition; + oldpos = screen->m_Curseur; - curpos = m_CurrentScreen->m_MousePosition; - oldpos = m_CurrentScreen->m_Curseur; - - delta.x = m_CurrentScreen->GetGrid().x / zoom; - delta.y = m_CurrentScreen->GetGrid().y / zoom; + delta.x = screen->GetGrid().x / zoom; + delta.y = screen->GetGrid().y / zoom; if( delta.x <= 0 ) delta.x = 1; @@ -252,37 +251,37 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels case EDA_PANNING_UP_KEY: OnZoom( ID_ZOOM_PANNING_UP ); - curpos = m_CurrentScreen->m_Curseur; + curpos = screen->m_Curseur; break; case EDA_PANNING_DOWN_KEY: OnZoom( ID_ZOOM_PANNING_DOWN ); - curpos = m_CurrentScreen->m_Curseur; + curpos = screen->m_Curseur; break; case EDA_PANNING_LEFT_KEY: OnZoom( ID_ZOOM_PANNING_LEFT ); - curpos = m_CurrentScreen->m_Curseur; + curpos = screen->m_Curseur; break; case EDA_PANNING_RIGHT_KEY: OnZoom( ID_ZOOM_PANNING_RIGHT ); - curpos = m_CurrentScreen->m_Curseur; + curpos = screen->m_Curseur; break; case EDA_ZOOM_IN_FROM_MOUSE: OnZoom( ID_ZOOM_PLUS_KEY ); - curpos = m_CurrentScreen->m_Curseur; + curpos = screen->m_Curseur; break; case EDA_ZOOM_OUT_FROM_MOUSE: OnZoom( ID_ZOOM_MOINS_KEY ); - curpos = m_CurrentScreen->m_Curseur; + curpos = screen->m_Curseur; break; case EDA_ZOOM_CENTER_FROM_MOUSE: OnZoom( ID_ZOOM_CENTER_KEY ); - curpos = m_CurrentScreen->m_Curseur; + curpos = screen->m_Curseur; break; case WXK_NUMPAD8: /* Deplacement curseur vers le haut */ @@ -315,22 +314,22 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels } /* Recalcul de la position du curseur schema */ - m_CurrentScreen->m_Curseur = curpos; + screen->m_Curseur = curpos; /* Placement sur la grille generale */ - PutOnGrid( &m_CurrentScreen->m_Curseur ); + PutOnGrid( &(screen->m_Curseur) ); - if( m_CurrentScreen->IsRefreshReq() ) + if( screen->IsRefreshReq() ) { RedrawActiveWindow( DC, TRUE ); } - if( oldpos != m_CurrentScreen->m_Curseur ) + if( oldpos != screen->m_Curseur ) { - curpos = m_CurrentScreen->m_Curseur; - m_CurrentScreen->m_Curseur = oldpos; + curpos = screen->m_Curseur; + screen->m_Curseur = oldpos; DrawPanel->CursorOff( DC ); - m_CurrentScreen->m_Curseur = curpos; + GetScreen()->m_Curseur = curpos; DrawPanel->CursorOn( DC ); if( DrawPanel->ManageCurseur ) @@ -341,9 +340,9 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels if( hotkey ) { - if( m_CurrentScreen->GetCurItem() - && m_CurrentScreen->GetCurItem()->m_Flags ) - OnHotKey( DC, hotkey, m_CurrentScreen->GetCurItem() ); + if( screen->GetCurItem() + && screen->GetCurItem()->m_Flags ) + OnHotKey( DC, hotkey, screen->GetCurItem() ); else OnHotKey( DC, hotkey, NULL ); } diff --git a/eeschema/dangling_ends.cpp b/eeschema/dangling_ends.cpp index b0a0c4abc5..b8b536144d 100644 --- a/eeschema/dangling_ends.cpp +++ b/eeschema/dangling_ends.cpp @@ -98,7 +98,7 @@ void WinEDA_SchematicFrame::TestDanglingEnds( EDA_BaseStruct* DrawList, wxDC* DC for( DanglingItem = ItemList; DanglingItem != NULL; DanglingItem = nextitem ) { nextitem = DanglingItem->m_Pnext; - delete DanglingItem; + SAFE_DELETE( DanglingItem ); } ItemList = RebuildEndList( DrawList ); @@ -109,6 +109,7 @@ void WinEDA_SchematicFrame::TestDanglingEnds( EDA_BaseStruct* DrawList, wxDC* DC switch( DrawItem->Type() ) { case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: case DRAW_LABEL_STRUCT_TYPE: #undef STRUCT #define STRUCT ( (DrawLabelStruct*) DrawItem ) @@ -146,7 +147,7 @@ LibDrawPin* WinEDA_SchematicFrame::LocatePinEnd( EDA_BaseStruct* DrawList, const wxPoint& pos ) /********************************************************************/ -/* Teste si le point de coordonnées pos est sur l'extrémité d'une PIN +/* Teste si le point de coordonn�es pos est sur l'extr�mit� d'une PIN * retourne un pointeur sur la pin * NULL sinon */ @@ -280,7 +281,7 @@ wxPoint ReturnPinPhysicalPosition( LibDrawPin* Pin, EDA_SchComponentStruct* DrawLibItem ) /****************************************************/ -/* Retourne la position physique de la pin, qui dépend de l'orientation +/* Retourne la position physique de la pin, qui d�pend de l'orientation * du composant */ { wxPoint PinPos = Pin->m_Pos; @@ -316,8 +317,9 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList ) break; case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: #undef STRUCT - #define STRUCT ( (DrawGlobalLabelStruct*) DrawItem ) + #define STRUCT ( (DrawLabelStruct*) DrawItem ) item = new DanglingEndHandle( LABEL_END ); item->m_Item = DrawItem; diff --git a/eeschema/delete.cpp b/eeschema/delete.cpp index 911392732d..78f66c96b7 100644 --- a/eeschema/delete.cpp +++ b/eeschema/delete.cpp @@ -116,24 +116,28 @@ DrawPickedStruct * PickedItem, *PickedList = NULL; for(DelStruct = GetScreen()->EEDrawList; DelStruct != NULL; DelStruct=DelStruct->Pnext) DelStruct->m_Flags = 0; - BreakSegmentOnJunction( GetScreen() ); + BreakSegmentOnJunction( (SCH_SCREEN*)GetScreen() ); DelStruct = GetScreen()->EEDrawList; /* Locate all the wires, bus or junction under the mouse cursor, and put them in a list of items to delete */ + SCH_SCREEN* screen = (SCH_SCREEN*)GetScreen(); + EDA_BaseStruct* savedEEDrawList = screen->EEDrawList; while ( DelStruct && - (DelStruct = PickStruct(GetScreen()->m_Curseur, - DelStruct, JUNCTIONITEM|WIREITEM|BUSITEM)) != NULL ) + (DelStruct = PickStruct(screen->m_Curseur, + screen, JUNCTIONITEM|WIREITEM|BUSITEM)) != NULL ) { + DelStruct->m_Flags = SELECTEDNODE|STRUCT_DELETED; /* Put this structure in the picked list: */ PickedItem = new DrawPickedStruct(DelStruct); PickedItem->Pnext = PickedList; PickedList = PickedItem; DelStruct=DelStruct->Pnext; + screen->EEDrawList = DelStruct; } - + GetScreen()->EEDrawList = savedEEDrawList; /* Mark all wires, junctions, .. connected to one of the item to delete */ if ( DeleteFullConnection ) @@ -224,7 +228,7 @@ DrawPickedStruct * PickedItem, *PickedList = NULL; if ( DelStruct->Type() != DRAW_LABEL_STRUCT_TYPE ) continue; GetScreen()->m_Curseur = ((DrawTextStruct*)DelStruct)->m_Pos; EDA_BaseStruct * TstStruct = - PickStruct(GetScreen()->m_Curseur, GetScreen()->EEDrawList,WIREITEM|BUSITEM); + PickStruct(GetScreen()->m_Curseur, GetScreen(),WIREITEM|BUSITEM); if ( TstStruct && TstStruct->m_Flags & STRUCT_DELETED ) { DelStruct->m_Flags |= STRUCT_DELETED; @@ -267,33 +271,33 @@ bool LocateAndDeleteItem(WinEDA_SchematicFrame * frame, wxDC * DC) */ { EDA_BaseStruct * DelStruct; -SCH_SCREEN * screen = frame->GetScreen(); +SCH_SCREEN * screen = (SCH_SCREEN*)(frame->GetScreen()); bool item_deleted = FALSE; DelStruct = PickStruct(screen->m_Curseur, - screen->EEDrawList, MARKERITEM); + screen, MARKERITEM); if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur, - screen->EEDrawList, JUNCTIONITEM); + screen, JUNCTIONITEM); if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur, - screen->EEDrawList, NOCONNECTITEM); + screen, NOCONNECTITEM); if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur, - screen->EEDrawList, RACCORDITEM); + screen, RACCORDITEM); if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur, - screen->EEDrawList, WIREITEM|BUSITEM); + screen, WIREITEM|BUSITEM); if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur, - screen->EEDrawList, DRAWITEM); + screen, DRAWITEM); if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur, - screen->EEDrawList, TEXTITEM|LABELITEM); + screen, TEXTITEM|LABELITEM); if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur, - screen->EEDrawList, LIBITEM); + screen, LIBITEM); if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur, - screen->EEDrawList, SHEETITEM); + screen, SHEETITEM); if (DelStruct) { g_ItemToRepeat = NULL; DeleteStruct(frame->DrawPanel, DC, DelStruct); - frame->TestDanglingEnds(frame->m_CurrentScreen->EEDrawList, DC); + frame->TestDanglingEnds(frame->GetScreen()->EEDrawList, DC); frame->GetScreen()->SetModify(); item_deleted = TRUE; } @@ -331,6 +335,7 @@ DrawSheetLabelStruct* SheetLabel, *NextLabel; if (DrawStruct->Type() == DRAW_SHEETLABEL_STRUCT_TYPE) { /* Cette stucture est rattachee a une feuille, et n'est pas accessible par la liste globale directement */ + //this structure has a sheet attached, which we must find. DrawList = Screen->EEDrawList; for ( ; DrawList != NULL; DrawList = DrawList->Pnext ) { @@ -342,7 +347,7 @@ DrawSheetLabelStruct* SheetLabel, *NextLabel; { ((DrawSheetStruct *) DrawList)->m_Label = (DrawSheetLabelStruct *)SheetLabel->Pnext; - delete DrawStruct; + SAFE_DELETE( DrawStruct ); return; } else while( SheetLabel->Pnext )/* Examen de la liste dependante */ @@ -351,7 +356,7 @@ DrawSheetLabelStruct* SheetLabel, *NextLabel; if( NextLabel == (DrawSheetLabelStruct*) DrawStruct ) { SheetLabel->Pnext = (EDA_BaseStruct *)NextLabel->Pnext; - delete DrawStruct; + SAFE_DELETE( DrawStruct ); return; } SheetLabel = NextLabel; @@ -360,7 +365,6 @@ DrawSheetLabelStruct* SheetLabel, *NextLabel; return; } - if (DrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE) { PickedList = (DrawPickedStruct *) DrawStruct; @@ -369,7 +373,7 @@ DrawSheetLabelStruct* SheetLabel, *NextLabel; if (PickedList->m_PickedStruct == Screen->EEDrawList) { Screen->EEDrawList = Screen->EEDrawList->Pnext; - delete DrawStruct; + SAFE_DELETE( DrawStruct ); } else { @@ -379,7 +383,7 @@ DrawSheetLabelStruct* SheetLabel, *NextLabel; if (DrawList->Pnext == PickedList->m_PickedStruct) { DrawList->Pnext = DrawList->Pnext->Pnext; - delete DrawStruct; + SAFE_DELETE( DrawStruct ); return; } DrawList = DrawList->Pnext; @@ -393,7 +397,7 @@ DrawSheetLabelStruct* SheetLabel, *NextLabel; if (DrawStruct == Screen->EEDrawList) { Screen->EEDrawList = DrawStruct->Pnext; - delete DrawStruct; + SAFE_DELETE( DrawStruct ); } else { @@ -403,7 +407,7 @@ DrawSheetLabelStruct* SheetLabel, *NextLabel; if (DrawList->Pnext == DrawStruct) { DrawList->Pnext = DrawStruct->Pnext; - delete DrawStruct; + SAFE_DELETE( DrawStruct ); return; } DrawList = DrawList->Pnext; @@ -423,7 +427,7 @@ SCH_SCREEN * screen; EDA_BaseStruct * DrawStruct, * NextStruct; DrawMarkerStruct * Marker; - EDA_ScreenList ScreenList(NULL); + EDA_ScreenList ScreenList; for ( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) { for ( DrawStruct = screen->EEDrawList; DrawStruct != NULL; DrawStruct = NextStruct) @@ -471,7 +475,7 @@ LibEDA_BaseStruct *PreviousDrawItem; if( LibEntry->m_Drawings == DrawItem ) { LibEntry->m_Drawings = DrawItem->Next(); - delete DrawItem; + SAFE_DELETE( DrawItem ); } else /* Cas des autres items */ @@ -480,7 +484,7 @@ LibEDA_BaseStruct *PreviousDrawItem; if(PreviousDrawItem->Pnext == DrawItem) { PreviousDrawItem->Pnext = DrawItem->Pnext; - delete DrawItem; break; + SAFE_DELETE( DrawItem ); break; } PreviousDrawItem = PreviousDrawItem->Next(); } @@ -488,7 +492,7 @@ LibEDA_BaseStruct *PreviousDrawItem; else /* Structure non reliee a un composant */ { - delete DrawItem; + SAFE_DELETE( DrawItem ); } } diff --git a/eeschema/delsheet.cpp b/eeschema/delsheet.cpp index cf076842fc..5058f12f42 100644 --- a/eeschema/delsheet.cpp +++ b/eeschema/delsheet.cpp @@ -37,37 +37,40 @@ wxString msg; } /* effacement du sous schema correspondant */ - if( FirstSheet->IsModify() && confirm_deletion ) + if( FirstSheet->m_s->IsModify() && confirm_deletion ) { msg.Printf( _("Sheet %s (file %s) modified. Save it?"), FirstSheet->m_SheetName.GetData(), FirstSheet->m_FileName.GetData()); if( IsOK(NULL, msg) ) { - frame->SaveEEFile(FirstSheet, FILE_SAVE_AS); + frame->SaveEEFile(FirstSheet->m_s, FILE_SAVE_AS); } } /* free the sub hierarchy */ - EEDrawList = FirstSheet->EEDrawList; - while (EEDrawList != NULL) - { - DrawStruct = EEDrawList; - EEDrawList = EEDrawList->Pnext; - if( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE) + if(FirstSheet->m_s){ + EEDrawList = FirstSheet->m_s->EEDrawList; + while (EEDrawList != NULL) { - DeleteSubHierarchy((DrawSheetStruct *) DrawStruct, confirm_deletion); + DrawStruct = EEDrawList; + EEDrawList = EEDrawList->Pnext; + if( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE) + { + DeleteSubHierarchy((DrawSheetStruct *) DrawStruct, confirm_deletion); + } } + /* Effacement des elements de la feuille courante */ + FirstSheet->m_s->FreeDrawList(); } - - /* Effacement des elements de la feuille courante */ - FirstSheet->FreeDrawList(); } /*********************************************************************/ -void ClearDrawList(EDA_BaseStruct *DrawList, bool confirm_deletion) +//void ClearDrawList(EDA_BaseStruct *DrawList, bool confirm_deletion) /********************************************************************/ /* free the draw list DrawList and the subhierarchies */ +//this is redundant -- use FreeDrawList, a member of SCH_SCREEN +/* { EDA_BaseStruct *DrawStruct; @@ -84,7 +87,7 @@ EDA_BaseStruct *DrawStruct; delete DrawStruct; } } - +*/ /********************************************************************/ bool ClearProjectDrawList(SCH_SCREEN * screen, bool confirm_deletion) /********************************************************************/ @@ -94,11 +97,10 @@ bool ClearProjectDrawList(SCH_SCREEN * screen, bool confirm_deletion) { if ( screen == NULL ) return(TRUE); - ClearDrawList(screen->EEDrawList, confirm_deletion); - screen->EEDrawList = NULL; + screen->FreeDrawList(); /* Clear the screen datas */ - screen->m_SheetNumber = screen->m_NumberOfSheet = 1; + screen->m_ScreenNumber = screen->m_NumberOfScreen = 1; screen->m_Title.Empty(); screen->m_Revision.Empty(); screen->m_Company.Empty(); diff --git a/eeschema/dialog_build_BOM.cpp b/eeschema/dialog_build_BOM.cpp index f337e9f662..3808094ac4 100644 --- a/eeschema/dialog_build_BOM.cpp +++ b/eeschema/dialog_build_BOM.cpp @@ -46,24 +46,16 @@ ////@end XPM images -/* Structures pour memo et liste des elements */ -typedef struct ListLabel -{ - int m_LabelType; - void * m_Label; - int m_SheetNumber; -} ListLabel; - - /* fonctions locales */ static int GenListeGLabels( ListLabel * List ); -static int ListTriComposantByRef(EDA_SchComponentStruct **Objet1, - EDA_SchComponentStruct **Objet2); -static int ListTriComposantByVal(EDA_SchComponentStruct **Objet1, - EDA_SchComponentStruct **Objet2); +int GenListeCmp( ListComponent * List ); +static int ListTriComposantByRef(ListComponent *Objet1, + ListComponent *Objet2); +static int ListTriComposantByVal(ListComponent *Objet1, + ListComponent *Objet2); static int ListTriGLabelBySheet(ListLabel *Objet1, ListLabel *Objet2); static int ListTriGLabelByVal(ListLabel *Objet1, ListLabel *Objet2); -static void DeleteSubCmp( EDA_BaseStruct ** List , int NbItems); +static void DeleteSubCmp( ListComponent * List , int NbItems); static int PrintListeGLabel( FILE *f, ListLabel *List, int NbItems); @@ -552,12 +544,14 @@ wxString mask, filename; else s_ExportSeparatorSymbol = s_ExportSeparator[0]; - m_ListFileName = ScreenSch->m_FileName; + m_ListFileName = g_RootSheet->m_s->m_FileName; ChangeFileNameExt(m_ListFileName, EXT_LIST); + //need to get rid of the path. + m_ListFileName = m_ListFileName.AfterLast('/'); mask = wxT("*"); mask += EXT_LIST; - filename = EDA_FileSelector(_("Bill of material:"), + filename = EDA_FileSelector(_("Bill of materials:"), wxEmptyString, /* Chemin par defaut (ici dir courante) */ m_ListFileName, /* nom fichier par defaut, et resultat */ EXT_LIST, /* extension par defaut */ @@ -600,7 +594,7 @@ void WinEDA_Build_BOM_Frame::CreateExportList(const wxString & FullFileName) */ { FILE *f; -EDA_BaseStruct ** List; +ListComponent * List; int NbItems; wxString msg; @@ -616,8 +610,7 @@ wxString msg; NbItems = GenListeCmp( NULL ); if( NbItems ) { - List = (EDA_BaseStruct **) - MyZMalloc( NbItems * sizeof(EDA_BaseStruct **) ); + List = (ListComponent*)MyZMalloc( NbItems * sizeof(ListComponent) ); if( List == NULL ) { fclose( f ); @@ -627,7 +620,7 @@ wxString msg; GenListeCmp( List ); /* sort component list */ - qsort( List, NbItems, sizeof( EDA_BaseStruct * ), + qsort( List, NbItems, sizeof( ListComponent ), (int(*)(const void*, const void*))ListTriComposantByRef ); // if( ! s_ListWithSubCmponents ) @@ -654,7 +647,7 @@ void WinEDA_Build_BOM_Frame::GenereListeOfItems(const wxString & FullFileName) */ { FILE *f; -EDA_BaseStruct ** List; +ListComponent * List; ListLabel * ListOfLabels; int NbItems; char Line[1024]; @@ -672,8 +665,8 @@ wxString msg; NbItems = GenListeCmp( NULL ); if( NbItems ) { - List = ( EDA_BaseStruct **) - MyZMalloc( NbItems * sizeof(EDA_BaseStruct **) ); + List = ( ListComponent *) + MyZMalloc( NbItems * sizeof(ListComponent) ); if( List == NULL ) { fclose( f ); @@ -681,6 +674,10 @@ wxString msg; } GenListeCmp( List ); + + for(int i=0; iGetValue() ) DeleteSubCmp(List, NbItems); @@ -705,7 +705,7 @@ wxString msg; // if( s_ListByValue ) if( m_ListCmpbyValItems->GetValue() ) { - qsort( List, NbItems, sizeof( EDA_BaseStruct * ), + qsort( List, NbItems, sizeof( ListComponent ), (int(*)(const void*, const void*))ListTriComposantByVal ); PrintListeCmpByVal(f, List, NbItems); } @@ -720,6 +720,7 @@ wxString msg; if( NbItems ) { ListOfLabels = (ListLabel *) MyZMalloc( NbItems * sizeof(ListLabel) ); + memset((void*)ListOfLabels, 0, NbItems * sizeof(ListLabel)); if( ListOfLabels == NULL ) { fclose( f ); @@ -761,26 +762,31 @@ wxString msg; /****************************************/ -int GenListeCmp( EDA_BaseStruct ** List ) +int GenListeCmp( ListComponent * List ) /****************************************/ /* Routine de generation de la liste des elements utiles du dessin * Si List == NULL: comptage des elements * Sinon remplissage de la liste * Initialise "FlagControlMulti" a SheetNumber pour la sortie des listes * et m_Father comme pointeur sur la sheet d'appartenance + * + * routine for generating a list of the used components. + * if List == null, just returns the count. if not, fills the list. + * goes through the sheets, not the screens, so that we account for + * multiple instances of a given screen. */ { int ItemCount = 0; EDA_BaseStruct *DrawList; EDA_SchComponentStruct *DrawLibItem; -BASE_SCREEN * screen; +DrawSheetList * sheet; - /* Build the screen list */ - EDA_ScreenList ScreenList(NULL); + /* Build the sheet (not screen) list */ + EDA_SheetList SheetList(NULL); - for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) { - DrawList = screen->EEDrawList; + DrawList = sheet->LastDrawList(); while( DrawList ) { switch( DrawList->Type() ) @@ -788,11 +794,14 @@ BASE_SCREEN * screen; case DRAW_LIB_ITEM_STRUCT_TYPE : ItemCount++; DrawLibItem = (EDA_SchComponentStruct *) DrawList; - DrawLibItem->m_FlagControlMulti = screen->m_SheetNumber; - DrawLibItem->m_Parent = screen; + DrawLibItem->m_Parent = sheet->LastScreen(); if( List ) { - *List = DrawList; + (*List).m_Comp = DrawLibItem; + (*List).m_SheetList = *sheet; + strncpy(&((*List).m_Ref[0]), + CONV_TO_UTF8(DrawLibItem->GetRef(sheet)), + sizeof((*List).m_Ref)); List++; } break; @@ -818,24 +827,27 @@ static int GenListeGLabels( ListLabel * List ) int ItemCount = 0; EDA_BaseStruct *DrawList; DrawSheetLabelStruct *SheetLabel; -BASE_SCREEN * screen; +DrawSheetList * sheet; /* Build the screen list */ - EDA_ScreenList ScreenList(NULL); + EDA_SheetList SheetList(NULL); - for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) { - DrawList = screen->EEDrawList; - while( DrawList ) + DrawList = sheet->LastDrawList(); + wxString path = sheet->Path(); + while(DrawList ) { switch( DrawList->Type() ) { + case DRAW_HIER_LABEL_STRUCT_TYPE: case DRAW_GLOBAL_LABEL_STRUCT_TYPE : ItemCount++; if( List ) { - List->m_LabelType = DRAW_GLOBAL_LABEL_STRUCT_TYPE; - List->m_SheetNumber = screen->m_SheetNumber; + List->m_LabelType = DrawList->Type(); + snprintf(List->m_SheetPath, sizeof(List->m_SheetPath), + "%s", CONV_TO_UTF8(path)); List->m_Label = DrawList; List++; } @@ -850,7 +862,8 @@ BASE_SCREEN * screen; if( List ) { List->m_LabelType = DRAW_SHEETLABEL_STRUCT_TYPE; - List->m_SheetNumber = screen->m_SheetNumber; + snprintf(List->m_SheetPath, sizeof(List->m_SheetPath), + "%s", CONV_TO_UTF8(path)); List->m_Label = SheetLabel; List++; } @@ -871,8 +884,8 @@ BASE_SCREEN * screen; /**********************************************************/ -static int ListTriComposantByVal(EDA_SchComponentStruct **Objet1, - EDA_SchComponentStruct **Objet2) +static int ListTriComposantByVal(ListComponent *Objet1, + ListComponent *Objet2) /**********************************************************/ /* Routine de comparaison pour le tri du Tableau par qsort() * Les composants sont tries @@ -884,27 +897,31 @@ static int ListTriComposantByVal(EDA_SchComponentStruct **Objet1, int ii; const wxString * Text1, *Text2; - if( ( *Objet1 == NULL ) && ( *Objet2 == NULL ) ) + if( ( Objet1 == NULL ) && ( Objet2 == NULL ) ) return( 0 ); - if( *Objet1 == NULL ) + if( Objet1 == NULL ) return( -1 ); - if( *Objet2 == NULL ) + if( Objet2 == NULL ) + return( 1 ); + if( ( Objet1->m_Comp == NULL ) && ( Objet2->m_Comp == NULL ) ) + return( 0 ); + if( Objet1->m_Comp == NULL ) + return( -1 ); + if( Objet2->m_Comp == NULL ) return( 1 ); - Text1 = &(*Objet1)->m_Field[VALUE].m_Text; - Text2 = &(*Objet2)->m_Field[VALUE].m_Text; + Text1 = &(Objet1->m_Comp->m_Field[VALUE].m_Text); + Text2 = &(Objet2->m_Comp->m_Field[VALUE].m_Text); ii = Text1->CmpNoCase(*Text2); if( ii == 0 ) { - Text1 = &(*Objet1)->m_Field[REFERENCE].m_Text; - Text2 = &(*Objet2)->m_Field[REFERENCE].m_Text; - ii = Text1->CmpNoCase(*Text2); + ii = strcmp(Objet1->m_Ref, Objet2->m_Ref); } if( ii == 0 ) { - ii = (*Objet1)->m_Multi - (*Objet2)->m_Multi; + ii = Objet1->m_Comp->m_Multi - Objet2->m_Comp->m_Multi; } return( ii ); @@ -912,8 +929,8 @@ const wxString * Text1, *Text2; /**********************************************************/ -static int ListTriComposantByRef(EDA_SchComponentStruct **Objet1, - EDA_SchComponentStruct **Objet2) +static int ListTriComposantByRef(ListComponent *Objet1, + ListComponent *Objet2) /**********************************************************/ /* Routine de comparaison pour le tri du Tableau par qsort() * Les composants sont tries @@ -925,27 +942,30 @@ static int ListTriComposantByRef(EDA_SchComponentStruct **Objet1, int ii; const wxString * Text1, *Text2; - if( ( *Objet1 == NULL ) && ( *Objet2 == NULL ) ) + if( ( Objet1 == NULL ) && ( Objet2 == NULL ) ) return( 0 ); - if( *Objet1 == NULL ) + if( Objet1 == NULL ) return( -1 ); - if( *Objet2 == NULL ) + if( Objet2 == NULL ) + return( 1 ); + + if( ( Objet1->m_Comp == NULL ) && ( Objet2->m_Comp == NULL ) ) + return( 0 ); + if( Objet1->m_Comp == NULL ) + return( -1 ); + if( Objet2->m_Comp == NULL ) return( 1 ); - Text1 = &(*Objet1)->m_Field[REFERENCE].m_Text; - Text2 = &(*Objet2)->m_Field[REFERENCE].m_Text; - ii = Text1->CmpNoCase(*Text2); + ii = strcmp(Objet1->m_Ref, Objet2->m_Ref); - if( ii == 0 ) - { - Text1 = &(*Objet1)->m_Field[VALUE].m_Text; - Text2 = &(*Objet2)->m_Field[VALUE].m_Text; + if( ii == 0 ){ + Text1 = &( Objet1->m_Comp->m_Field[VALUE].m_Text ); + Text2 = &( Objet2->m_Comp->m_Field[VALUE].m_Text ); ii = Text1->CmpNoCase(*Text2); } - if( ii == 0 ) - { - ii = (*Objet1)->m_Multi - (*Objet2)->m_Multi; + if( ii == 0 ){ + ii = Objet1->m_Comp->m_Multi - Objet2->m_Comp->m_Multi; } return( ii ); @@ -978,7 +998,7 @@ const wxString * Text1, *Text2; if( ii == 0 ) { - ii = Objet1->m_SheetNumber - Objet2->m_SheetNumber; + ii = strcmp(Objet1->m_SheetPath, Objet2->m_SheetPath); } return( ii ); @@ -997,7 +1017,8 @@ static int ListTriGLabelBySheet(ListLabel *Objet1, ListLabel *Objet2) int ii; const wxString * Text1, *Text2; - ii = Objet1->m_SheetNumber - Objet2->m_SheetNumber; + + ii = strcmp(Objet1->m_SheetPath, Objet2->m_SheetPath); if( ii == 0 ) { @@ -1019,7 +1040,7 @@ const wxString * Text1, *Text2; /**************************************************************/ -static void DeleteSubCmp( EDA_BaseStruct ** List, int NbItems ) +static void DeleteSubCmp( ListComponent * List, int NbItems ) /**************************************************************/ /* Supprime les sous-composants, c'est a dire les descriptions redonnantes des * boitiers multiples @@ -1028,21 +1049,24 @@ static void DeleteSubCmp( EDA_BaseStruct ** List, int NbItems ) { int ii; EDA_SchComponentStruct * LibItem; -const wxString * OldName = NULL; +wxString OldName; for( ii = 0; ii < NbItems; ii++ ) { - LibItem = (EDA_SchComponentStruct *) List[ii]; + LibItem = List[ii].m_Comp; if( LibItem == NULL ) continue; - if( OldName ) + if( !OldName.IsEmpty() ) { - if( OldName->CmpNoCase( LibItem->m_Field[REFERENCE].m_Text ) == 0 ) + if( strcmp(OldName.mb_str(), List[ii].m_Ref ) == 0 ) { - List[ii] = NULL; + List[ii].m_Comp = NULL; + List[ii].m_SheetList.Clear(); + List[ii].m_Ref[0] = 0; + } } - OldName = &LibItem->m_Field[REFERENCE].m_Text; + OldName.Printf(_("%s"), List[ii].m_Ref ); } } @@ -1088,7 +1112,7 @@ wxCheckBox * FieldCtrl = FieldListCtrl[0]; /*********************************************************************************************/ -int WinEDA_Build_BOM_Frame::PrintListeCmpByRef( FILE * f, EDA_BaseStruct ** List, int NbItems, +int WinEDA_Build_BOM_Frame::PrintListeCmpByRef( FILE * f, ListComponent * List, int NbItems, bool CompactForm ) /*********************************************************************************************/ /* Print the B.O.M sorted by reference @@ -1103,7 +1127,7 @@ wxString msg; if( CompactForm ) { - fprintf( f, "ref%cvalue%csheet number%csheet name%cfootprint", + fprintf( f, "ref%cvalue%csheet path%csheet name%cfootprint", s_ExportSeparatorSymbol, s_ExportSeparatorSymbol, s_ExportSeparatorSymbol, s_ExportSeparatorSymbol ); wxCheckBox * FieldListCtrl[FIELD8 - FIELD1 + 1] = { @@ -1140,7 +1164,7 @@ wxString msg; for( ii = 0; ii < NbItems; ii++ ) { - DrawList = List[ii]; + DrawList = List[ii].m_Comp; if( DrawList == NULL ) continue; @@ -1148,7 +1172,7 @@ wxString msg; continue; DrawLibItem = (EDA_SchComponentStruct *) DrawList; - if( DrawLibItem->m_Field[REFERENCE].m_Text[0] == '#' ) + if( List[ii].m_Ref[0] == '#' ) continue; Multi = 0; @@ -1160,7 +1184,7 @@ wxString msg; if( ( Multi > 1 ) && m_ListSubCmpItems->GetValue() ) Unit = DrawLibItem->m_Multi + 'A' - 1; - sprintf( NameCmp,"%s", CONV_TO_UTF8(DrawLibItem->m_Field[REFERENCE].m_Text) ); + sprintf( NameCmp,"%s", List[ii].m_Ref ); if( ! CompactForm || Unit != ' ' ) sprintf( NameCmp + strlen(NameCmp), "%c", Unit ); @@ -1174,17 +1198,19 @@ wxString msg; // if( s_ListWithSubCmponents ) if( m_ListSubCmpItems->GetValue() ) { - DrawSheetStruct * sheet = (DrawSheetStruct *)(DrawLibItem->m_Parent); + SCH_SCREEN * screen = (SCH_SCREEN *)(DrawLibItem->m_Parent); wxString sheetname; - if( sheet && sheet->Type() == DRAW_SHEET_STRUCT_TYPE ) - sheetname = sheet->m_SheetName; + if( screen && screen->Type() == SCREEN_STRUCT_TYPE ) + sheetname = screen->m_FileName; else - sheetname = _("Root"); + sheetname = _("?"); if( CompactForm ) - fprintf(f, "%c%d;%s", s_ExportSeparatorSymbol, DrawLibItem->m_FlagControlMulti, + fprintf(f, "%c%s;%s", s_ExportSeparatorSymbol, + CONV_TO_UTF8(List[ii].m_SheetList.Path()), CONV_TO_UTF8(sheetname)); else - fprintf(f, " (Sheet %.2d: \"%s\")", DrawLibItem->m_FlagControlMulti, + fprintf(f, " (Sheet %s: \"%s\")", + CONV_TO_UTF8(List[ii].m_SheetList.Path()), CONV_TO_UTF8(sheetname)); } @@ -1201,7 +1227,7 @@ wxString msg; } /*********************************************************************************************/ -int WinEDA_Build_BOM_Frame::PrintListeCmpByVal( FILE * f, EDA_BaseStruct ** List, int NbItems ) +int WinEDA_Build_BOM_Frame::PrintListeCmpByVal( FILE * f, ListComponent * List, int NbItems ) /**********************************************************************************************/ { int ii, Multi; @@ -1220,7 +1246,7 @@ wxString msg; for( ii = 0; ii < NbItems; ii++ ) { - DrawList = List[ii]; + DrawList = List[ii].m_Comp; if( DrawList == NULL ) continue; @@ -1228,7 +1254,7 @@ wxString msg; continue; DrawLibItem = (EDA_SchComponentStruct *) DrawList; - if( DrawLibItem->m_Field[REFERENCE].m_Text[0] == '#' ) + if( List[ii].m_Ref[0] == '#' ) continue; Multi = 0; @@ -1237,18 +1263,17 @@ wxString msg; if( Entry ) Multi = Entry->m_UnitCount; // if( ( Multi > 1 ) && s_ListWithSubCmponents ) - if( ( Multi > 1 ) && m_ListSubCmpItems->GetValue() ) + if( ( Multi > 1 ) && m_ListSubCmpItems->GetValue() ){ Unit = DrawLibItem->m_Multi + 'A' - 1; - msg = DrawLibItem->m_Field[REFERENCE].m_Text; - msg.Append(Unit); - - fprintf( f, "| %-12s %-10s", - CONV_TO_UTF8(DrawLibItem->m_Field[VALUE].m_Text), - CONV_TO_UTF8(msg) ); + } + fprintf( f, "| %-12s %-10s%c", + CONV_TO_UTF8(DrawLibItem->m_Field[VALUE].m_Text), + List[ii].m_Ref, Unit); + // if( s_ListWithSubCmponents ) if( m_ListSubCmpItems->GetValue() ) { - fprintf(f, " (Sheet %.2d)", DrawLibItem->m_FlagControlMulti); + fprintf(f, " (Sheet %s)", CONV_TO_UTF8(List[ii].m_SheetList.Path()) ); } PrintFieldData(f, DrawLibItem); @@ -1265,24 +1290,31 @@ wxString msg; static int PrintListeGLabel( FILE *f, ListLabel *List, int NbItems) /******************************************************************/ { -int ii, jj; -DrawGlobalLabelStruct *DrawTextItem; -DrawSheetLabelStruct * DrawSheetLabel; -ListLabel * LabelItem; -wxString msg; - + int ii, jj; + DrawLabelStruct *DrawTextItem; + DrawSheetLabelStruct * DrawSheetLabel; + ListLabel * LabelItem; + wxString msg; + char str[64]; + for( ii = 0; ii < NbItems; ii++ ) { LabelItem = & List[ii]; switch( LabelItem->m_LabelType ) { - case DRAW_GLOBAL_LABEL_STRUCT_TYPE : - DrawTextItem = (DrawGlobalLabelStruct *)(LabelItem->m_Label); + case DRAW_HIER_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + DrawTextItem = (DrawLabelStruct *)(LabelItem->m_Label); + if(LabelItem->m_LabelType == DRAW_HIER_LABEL_STRUCT_TYPE) + strncpy(str, "Hierarchal", sizeof(str)); + else + strncpy(str, "Global ", sizeof(str)); msg.Printf( - _("> %-28.28s Global (Sheet %.2d) pos: %3.3f, %3.3f\n"), + _("> %-28.28s %s (Sheet %s) pos: %3.3f, %3.3f\n"), DrawTextItem->m_Text.GetData(), - LabelItem->m_SheetNumber, + str, + LabelItem->m_SheetPath, (float)DrawTextItem->m_Pos.x / 1000, (float)DrawTextItem->m_Pos.y / 1000); @@ -1299,10 +1331,10 @@ wxString msg; jj = 4; wxString labtype = CONV_FROM_UTF8(SheetLabelType[jj]); msg.Printf( - _("> %-28.28s Sheet %-7.7s (Sheet %.2d) pos: %3.3f, %3.3f\n"), + _("> %-28.28s Sheet %-7.7s (Sheet %s) pos: %3.3f, %3.3f\n"), DrawSheetLabel->m_Text.GetData(), labtype.GetData(), - LabelItem->m_SheetNumber, + LabelItem->m_SheetPath, (float)DrawSheetLabel->m_Pos.x / 1000, (float)DrawSheetLabel->m_Pos.y / 1000); fprintf(f, CONV_TO_UTF8(msg)); diff --git a/eeschema/dialog_build_BOM.h b/eeschema/dialog_build_BOM.h index 94e3a50b33..b8a9ee2e1c 100644 --- a/eeschema/dialog_build_BOM.h +++ b/eeschema/dialog_build_BOM.h @@ -131,8 +131,8 @@ public: ////@end WinEDA_Build_BOM_Frame member function declarations void GenereListeOfItems(const wxString & FullFileName); void CreateExportList(const wxString & FullFileName); - int PrintListeCmpByRef( FILE * f, EDA_BaseStruct ** List, int NbItems, bool CompactForm = FALSE ); - int PrintListeCmpByVal( FILE *f, EDA_BaseStruct **List, int NbItems); + int PrintListeCmpByRef( FILE * f, ListComponent * List, int NbItems, bool CompactForm = FALSE ); + int PrintListeCmpByVal( FILE *f, ListComponent * List, int NbItems); void PrintFieldData(FILE * f, EDA_SchComponentStruct * DrawLibItem, bool CompactForm = FALSE); void SavePreferences(); diff --git a/eeschema/dialog_edit_label.cpp b/eeschema/dialog_edit_label.cpp index d3daee610e..db0ce11a47 100644 --- a/eeschema/dialog_edit_label.cpp +++ b/eeschema/dialog_edit_label.cpp @@ -67,6 +67,10 @@ wxString msg; case DRAW_GLOBAL_LABEL_STRUCT_TYPE: SetTitle(_("Global Label properties")); break; + + case DRAW_HIER_LABEL_STRUCT_TYPE: + SetTitle(_("Hierarchal Label properties")); + break; case DRAW_LABEL_STRUCT_TYPE: SetTitle(_("Label properties")); @@ -155,7 +159,7 @@ void WinEDA_LabelPropertiesFrame::CreateControls() m_TextShapeStrings.Add(_("Bidi")); m_TextShapeStrings.Add(_("TriState")); m_TextShapeStrings.Add(_("Passive")); - m_TextShape = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Glabel Shape:"), wxDefaultPosition, wxDefaultSize, m_TextShapeStrings, 1, wxRA_SPECIFY_COLS ); + m_TextShape = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("label Shape:"), wxDefaultPosition, wxDefaultSize, m_TextShapeStrings, 1, wxRA_SPECIFY_COLS ); m_TextShape->SetSelection(0); m_TextShape->Show(false); itemBoxSizer6->Add(m_TextShape, 0, wxALIGN_TOP|wxALL, 5); @@ -185,7 +189,8 @@ void WinEDA_LabelPropertiesFrame::CreateControls() m_TextShape->SetValidator( wxGenericValidator(& m_CurrentText->m_Shape) ); ////@end WinEDA_LabelPropertiesFrame content construction - if (m_CurrentText->Type() == DRAW_GLOBAL_LABEL_STRUCT_TYPE ) + if (m_CurrentText->Type() == DRAW_GLOBAL_LABEL_STRUCT_TYPE || + m_CurrentText->Type() == DRAW_HIER_LABEL_STRUCT_TYPE) m_TextShape->Show(true); } diff --git a/eeschema/dialog_options.cpp b/eeschema/dialog_options.cpp index ea1c37f570..c533aa008e 100644 --- a/eeschema/dialog_options.cpp +++ b/eeschema/dialog_options.cpp @@ -433,10 +433,10 @@ wxString msg; break; } - if ( m_Parent->m_CurrentScreen ) + if ( m_Parent->GetScreen() ) { - if ( setgrid ) m_Parent->m_CurrentScreen->SetGrid(grid); - m_Parent->m_CurrentScreen->SetRefreshReq(); + if ( setgrid ) m_Parent->GetScreen()->SetGrid(grid); + m_Parent->GetScreen()->SetRefreshReq(); } } diff --git a/eeschema/divers.cpp b/eeschema/divers.cpp index b761eb0268..f9b2ced6e3 100644 --- a/eeschema/divers.cpp +++ b/eeschema/divers.cpp @@ -14,28 +14,6 @@ #include "protos.h" -/**********************************************************/ -SCH_SCREEN * CreateNewScreen(WinEDA_DrawFrame * frame_source, - SCH_SCREEN * OldScreen, int TimeStamp) -/**********************************************************/ -/* Routine de creation ( par allocation memoire ) d'un nouvel ecran - cet ecran est en chainage arriere avec OldScreen - la valeur TimeStamp est attribuee au parametre NewScreen->TimeStamp -*/ -{ -SCH_SCREEN * NewScreen; - - NewScreen = new SCH_SCREEN(NULL, frame_source, SCHEMATIC_FRAME); - - NewScreen->SetRefreshReq(); - if(OldScreen) NewScreen->m_Company = OldScreen->m_Company; - NewScreen->m_TimeStamp = TimeStamp; - - NewScreen->Pback = OldScreen; - - return(NewScreen); -} - /**************************************/ void SetFlagModify(BASE_SCREEN * Window) /**************************************/ diff --git a/eeschema/edit_component_in_lib.cpp b/eeschema/edit_component_in_lib.cpp index 73fe4ffee9..66d3ca674f 100644 --- a/eeschema/edit_component_in_lib.cpp +++ b/eeschema/edit_component_in_lib.cpp @@ -29,15 +29,15 @@ enum id_libedit { /* Variables locales */ extern int CurrentUnit; -/* Classe de la frame des propriétés d'un composant en librairie */ +/* Classe de la frame des propri�t�s d'un composant en librairie */ -/* Cette classe genere une fenetre type NoteBook, pour l'edition des propriétés +/* Cette classe genere une fenetre type NoteBook, pour l'edition des propri�t�s * d'un composant le librairie. - * On peut éditer: + * On peut �diter: * Texte dimensions et justification de tous les champs (Ref, Val, et autres champs) * Documentation et mots clefs * Nombre de part par boitier - * et autres propriérés générales + * et autres propri�r�s g�n�rales */ #include "dialog_edit_component_in_lib.cpp" @@ -653,7 +653,7 @@ void WinEDA_PartPropertiesFrame::PartPropertiesAccept( wxCommandEvent& event ) Close(); return; } - m_Parent->m_CurrentScreen->SetModify(); + m_Parent->GetScreen()->SetModify(); m_Parent->SaveCopyInUndoList( CurrentLibEntry ); CopyPanelFieldToData(); @@ -761,7 +761,7 @@ void WinEDA_PartPropertiesFrame::PartPropertiesAccept( wxCommandEvent& event ) { if( ii < FIELD1 || Field->m_Name.IsEmpty() ) { - delete Field; + SAFE_DELETE( Field ); if( previousField ) previousField->Pnext = NextField; else @@ -1056,8 +1056,8 @@ bool WinEDA_PartPropertiesFrame::ChangeNbUnitsPerPackage( int MaxUnit ) bool WinEDA_PartPropertiesFrame::SetUnsetConvert() /*****************************************************/ -/* crée ou efface (selon option AsConvert) les éléments - * de la représentation convertie d'un composant +/* cr�e ou efface (selon option AsConvert) les �l�ments + * de la repr�sentation convertie d'un composant */ { int FlagDel = 0; @@ -1096,7 +1096,7 @@ bool WinEDA_PartPropertiesFrame::SetUnsetConvert() } else /* Representation convertie a supprimer */ { - /* Traitement des elements à supprimer */ + /* Traitement des elements � supprimer */ if( CurrentLibEntry ) DrawItem = CurrentLibEntry->m_Drawings; for( ; DrawItem != NULL; DrawItem = NextDrawItem ) diff --git a/eeschema/edit_component_in_schematic.cpp b/eeschema/edit_component_in_schematic.cpp index a61eb9763c..ec695ad944 100644 --- a/eeschema/edit_component_in_schematic.cpp +++ b/eeschema/edit_component_in_schematic.cpp @@ -88,7 +88,10 @@ void WinEDA_ComponentPropertiesFrame::InitBuffers() for( ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ ) { m_FieldName[ii] = m_Cmp->ReturnFieldName( ii ); - m_FieldText[ii] = m_Cmp->m_Field[ii].m_Text; + if(ii == REFERENCE) + m_FieldText[ii] = m_Cmp->GetRef(m_Parent->GetSheet()); + else + m_FieldText[ii] = m_Cmp->m_Field[ii].m_Text; m_FieldSize[ii] = m_Cmp->m_Field[ii].m_Size.x; m_FieldFlags[ii] = (m_Cmp->m_Field[ii].m_Attributs & TEXT_NO_VISIBLE) ? 0 : 1; @@ -115,8 +118,9 @@ void WinEDA_ComponentPropertiesFrame::CopyDataToPanelField() { int fieldId = m_CurrentFieldId; - for( int ii = FIELD1; ii < NUMBER_OF_FIELDS; ii++ ) + for( int ii = FIELD1; ii < NUMBER_OF_FIELDS; ii++ ){ m_FieldSelection->SetString( ii, m_FieldName[ii] ); + } if( fieldId == VALUE && m_LibEntry && m_LibEntry->m_Options == ENTRY_POWER ) m_FieldTextCtrl->Enable( FALSE ); @@ -343,7 +347,7 @@ void WinEDA_ComponentPropertiesFrame::ComponentPropertiesAccept( wxCommandEvent& (m_ConvertButt->GetValue() == TRUE) ? m_Cmp->m_Convert = 2 : m_Cmp->m_Convert = 1; - //Mise a jour de la selection de l'élément dans le boitier + //Mise a jour de la selection de l'�l�ment dans le boitier if( m_Cmp->m_Multi ) m_Cmp->m_Multi = m_SelectUnit->GetSelection() + 1; @@ -382,13 +386,13 @@ void WinEDA_ComponentPropertiesFrame::ComponentPropertiesAccept( wxCommandEvent& } - // Mise a jour des textes + // Mise a jour des textes (update the texts) for( int ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ ) { if( ii == REFERENCE ) // la reference ne peut etre vide { if( !m_FieldText[ii].IsEmpty() ) - m_Cmp->m_Field[ii].m_Text = m_FieldText[ii]; + m_Cmp->SetRef(m_Parent->GetSheet(), m_FieldText[ii]); } else if( ii == VALUE ) // la valeur ne peut etre vide et ne peut etre change sur un POWER { @@ -421,10 +425,10 @@ void WinEDA_ComponentPropertiesFrame::ComponentPropertiesAccept( wxCommandEvent& m_Cmp->m_Field[ii].m_Pos.y += cmp_pos.y; } - m_Parent->m_CurrentScreen->SetModify(); + m_Parent->GetScreen()->SetModify(); RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE ); - m_Parent->TestDanglingEnds( m_Parent->m_CurrentScreen->EEDrawList, &dc ); + m_Parent->TestDanglingEnds( m_Parent->GetScreen()->EEDrawList, &dc ); EndModal( 0 ); } @@ -454,7 +458,7 @@ void WinEDA_SchematicFrame::StartMoveCmpField( PartTextStruct* Field, wxDC* DC ) int x1, y1; EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*) CurrentField->m_Parent; - delete g_ItemToUndoCopy; + SAFE_DELETE( g_ItemToUndoCopy ); g_ItemToUndoCopy = Cmp->GenCopy(); pos = Cmp->m_Pos; @@ -476,7 +480,7 @@ void WinEDA_SchematicFrame::StartMoveCmpField( PartTextStruct* Field, wxDC* DC ) newpos.y = pos.y + Cmp->m_Transform[0][1] * x1 + Cmp->m_Transform[1][1] * y1; DrawPanel->CursorOff( DC ); - m_CurrentScreen->m_Curseur = newpos; + GetScreen()->m_Curseur = newpos; DrawPanel->MouseToCursorSchema(); OldPos = Field->m_Pos; @@ -561,6 +565,9 @@ void WinEDA_SchematicFrame::EditCmpFieldText( PartTextStruct* Field, wxDC* DC ) Field->m_Size.x = Field->m_Size.y = TextFieldSize; } Field->m_Text = newtext; + if( FieldNumber == REFERENCE ){ + Cmp->SetRef(GetSheet(), newtext); + } } else /* Nouveau texte NULL */ { @@ -580,7 +587,7 @@ void WinEDA_SchematicFrame::EditCmpFieldText( PartTextStruct* Field, wxDC* DC ) DrawTextField( DrawPanel, DC, Field, flag, g_XorMode ); Cmp->Display_Infos( this ); - m_CurrentScreen->SetModify(); + GetScreen()->SetModify(); } @@ -633,7 +640,7 @@ static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC ) DrawTextField( Panel, DC, CurrentField, Multiflag, GR_DEFAULT_DRAWMODE ); } CurrentField = NULL; - delete g_ItemToUndoCopy; g_ItemToUndoCopy = NULL; + SAFE_DELETE( g_ItemToUndoCopy ); } @@ -725,7 +732,6 @@ void WinEDA_SchematicFrame::EditComponentReference( EDA_SchComponentStruct* Cmp, /**************************************************************************************************/ /* Edit the component text reference*/ { - wxString msg; EDA_LibComponentStruct* Entry; int flag = 0; @@ -739,19 +745,18 @@ void WinEDA_SchematicFrame::EditComponentReference( EDA_SchComponentStruct* Cmp, if( Entry->m_UnitCount > 1 ) flag = 1; - PartTextStruct* TextField = &Cmp->m_Field[REFERENCE]; + wxString ref = Cmp->GetRef(GetSheet()); + Get_Message( _( "Reference" ), ref, this ); - msg = TextField->m_Text; - Get_Message( _( "Reference" ), msg, this ); - - if( !msg.IsEmpty() ) // New text entered + if( !ref.IsEmpty() ) // New text entered { /* save old cmp in undo list if not already in edit, or moving ... */ if( Cmp->m_Flags == 0 ) SaveCopyInUndoList( Cmp, IS_CHANGED ); + Cmp->SetRef(GetSheet(), ref); DrawTextField( DrawPanel, DC, &Cmp->m_Field[REFERENCE], flag, g_XorMode ); - TextField->m_Text = msg; + Cmp->SetRef(GetSheet(), ref ); DrawTextField( DrawPanel, DC, &Cmp->m_Field[REFERENCE], flag, Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE ); GetScreen()->SetModify(); @@ -794,7 +799,7 @@ void WinEDA_SchematicFrame::EditComponentValue( EDA_SchComponentStruct* Cmp, wxD TextField->m_Text = msg; DrawTextField( DrawPanel, DC, &Cmp->m_Field[VALUE], flag, Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE ); - m_CurrentScreen->SetModify(); + GetScreen()->SetModify(); } Cmp->Display_Infos( this ); @@ -848,7 +853,7 @@ void WinEDA_SchematicFrame::EditComponentFootprint( EDA_SchComponentStruct* Cmp, DrawTextField( DrawPanel, DC, &Cmp->m_Field[FOOTPRINT], flag, Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE ); - m_CurrentScreen->SetModify(); + GetScreen()->SetModify(); Cmp->Display_Infos( this ); } @@ -896,7 +901,7 @@ void WinEDA_ComponentPropertiesFrame::SetInitCmp( wxCommandEvent& event ) m_Cmp->SetRotationMiroir( CMP_NORMAL ); - m_Parent->m_CurrentScreen->SetModify(); + m_Parent->GetScreen()->SetModify(); RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE ); EndModal( 1 ); diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index dc19dadcb2..2138b20ea7 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -87,6 +87,7 @@ void WinEDA_SchematicFrame::StartMoveTexte( DrawTextStruct* TextStruct, wxDC* DC { case DRAW_LABEL_STRUCT_TYPE: case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: case DRAW_TEXT_STRUCT_TYPE: ItemInitialPosition = TextStruct->m_Pos; OldSize = TextStruct->m_Size; @@ -98,7 +99,7 @@ void WinEDA_SchematicFrame::StartMoveTexte( DrawTextStruct* TextStruct, wxDC* DC } DrawPanel->CursorOff( DC ); - m_CurrentScreen->m_Curseur = ItemInitialPosition; + GetScreen()->m_Curseur = ItemInitialPosition; DrawPanel->MouseToCursorSchema(); GetScreen()->SetModify(); @@ -142,7 +143,7 @@ void WinEDA_SchematicFrame::ChangeTextOrient( DrawTextStruct* TextStruct, wxDC* { if( TextStruct == NULL ) TextStruct = (DrawTextStruct*) PickStruct( GetScreen()->m_Curseur, - GetScreen()->EEDrawList, TEXTITEM | LABELITEM ); + GetScreen(), TEXTITEM | LABELITEM ); if( TextStruct == NULL ) return; @@ -159,6 +160,7 @@ void WinEDA_SchematicFrame::ChangeTextOrient( DrawTextStruct* TextStruct, wxDC* { case DRAW_LABEL_STRUCT_TYPE: case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: case DRAW_TEXT_STRUCT_TYPE: TextStruct->m_Orient++; TextStruct->m_Orient &= 3; @@ -190,15 +192,21 @@ EDA_BaseStruct* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type ) switch( type ) { case LAYER_NOTES: - NewText = new DrawTextStruct( m_CurrentScreen->m_Curseur ); + NewText = new DrawTextStruct( GetScreen()->m_Curseur ); break; case LAYER_LOCLABEL: - NewText = new DrawLabelStruct( m_CurrentScreen->m_Curseur ); + NewText = new DrawLabelStruct( GetScreen()->m_Curseur ); break; + case LAYER_HIERLABEL: + NewText = new DrawHierLabelStruct(GetScreen()->m_Curseur ); + NewText->m_Shape = s_DefaultShapeGLabel; + NewText->m_Orient = s_DefaultOrientGLabel; + break; + case LAYER_GLOBLABEL: - NewText = new DrawGlobalLabelStruct( m_CurrentScreen->m_Curseur ); + NewText = new DrawGlobalLabelStruct(GetScreen()->m_Curseur ); NewText->m_Shape = s_DefaultShapeGLabel; NewText->m_Orient = s_DefaultOrientGLabel; break; @@ -216,11 +224,11 @@ EDA_BaseStruct* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type ) if( NewText->m_Text.IsEmpty() ) { - delete NewText; + SAFE_DELETE( NewText ); return NULL; } - if( type == LAYER_GLOBLABEL ) + if( type == LAYER_GLOBLABEL || type == LAYER_HIERLABEL) { s_DefaultShapeGLabel = NewText->m_Shape; s_DefaultOrientGLabel = NewText->m_Orient; @@ -230,7 +238,7 @@ EDA_BaseStruct* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type ) DrawPanel->ManageCurseur = ShowWhileMoving; DrawPanel->ForceCloseManageCurseur = ExitMoveTexte; - m_CurrentScreen->SetCurItem( NewText ); + GetScreen()->SetCurItem( NewText ); return NewText; } @@ -252,6 +260,7 @@ static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) { case DRAW_LABEL_STRUCT_TYPE: case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: case DRAW_TEXT_STRUCT_TYPE: ( (DrawTextStruct*) TextStruct )->m_Pos = panel->GetScreen()->m_Curseur; break; @@ -269,7 +278,7 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC ) /*************************************************************/ /* Abort function for the command move text */ { - SCH_SCREEN* screen = (SCH_SCREEN*) Panel->m_Parent->m_CurrentScreen; + SCH_SCREEN* screen = (SCH_SCREEN*) Panel->m_Parent->GetScreen(); EDA_BaseStruct* Struct = screen->GetCurItem(); g_ItemToRepeat = NULL; @@ -286,7 +295,7 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC ) if( Struct->m_Flags & IS_NEW ) { - delete Struct; + SAFE_DELETE( Struct ); screen->SetCurItem( NULL ); } else /* this was a move command on an "old" text: restore its old settings. */ @@ -295,6 +304,7 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC ) { case DRAW_LABEL_STRUCT_TYPE: case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: case DRAW_TEXT_STRUCT_TYPE: { DrawTextStruct* Text = (DrawTextStruct*) Struct; @@ -336,9 +346,11 @@ void WinEDA_SchematicFrame::ConvertTextType( DrawTextStruct* Text, break; case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - newtext = new DrawGlobalLabelStruct( Text->m_Pos, Text->m_Text ); + newtext = new DrawGlobalLabelStruct(Text->m_Pos, Text->m_Text ); break; - + case DRAW_HIER_LABEL_STRUCT_TYPE: + newtext = new DrawHierLabelStruct(Text->m_Pos, Text->m_Text ); + break; case DRAW_TEXT_STRUCT_TYPE: newtext = new DrawTextStruct( Text->m_Pos, Text->m_Text ); break; @@ -381,13 +393,12 @@ void WinEDA_SchematicFrame::ConvertTextType( DrawTextStruct* Text, { Text->m_Flags = 0; DeleteStruct( DrawPanel, DC, Text ); - m_CurrentScreen->SetCurItem( NULL ); + GetScreen()->SetCurItem( NULL ); g_ItemToRepeat = NULL; } GetScreen()->SetCurItem( newtext ); - delete g_ItemToUndoCopy; - g_ItemToUndoCopy = NULL; + SAFE_DELETE( g_ItemToUndoCopy ); DrawPanel->CursorOff( DC ); // Erase schematic cursor diff --git a/eeschema/eeconfig.cpp b/eeschema/eeconfig.cpp index dd09d54a63..9377cce278 100644 --- a/eeschema/eeconfig.cpp +++ b/eeschema/eeconfig.cpp @@ -52,7 +52,7 @@ wxString FullFileName; case ID_CONFIG_READ: { wxString mask( wxT("*") ); mask += g_Prj_Config_Filename_ext; - FullFileName = ScreenSch->m_FileName; + FullFileName = g_RootSheet->m_s->m_FileName; ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext ); FullFileName = EDA_FileSelector(_("Read config file"), @@ -142,7 +142,7 @@ wxString FullFileName; bool IsRead = TRUE; wxArrayString liblist_tmp = g_LibName_List; - if ( CfgFileName.IsEmpty() ) FullFileName = ScreenSch->m_FileName; + if ( CfgFileName.IsEmpty() ) FullFileName = g_RootSheet->m_s->m_FileName; else FullFileName = CfgFileName; g_LibName_List.Clear(); @@ -185,7 +185,7 @@ wxString FullFileName; wxString mask( wxT("*") ); mask += g_Prj_Config_Filename_ext; - FullFileName = ScreenSch->m_FileName.AfterLast('/') /*ConfigFileName*/; + FullFileName = g_RootSheet->m_s->m_FileName.AfterLast('/') /*ConfigFileName*/; ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext ); path = wxGetCwd(); diff --git a/eeschema/eecreate.cpp b/eeschema/eecreate.cpp index 118733f691..d955aa94c3 100644 --- a/eeschema/eecreate.cpp +++ b/eeschema/eecreate.cpp @@ -27,6 +27,7 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type ) /* Routine de Trace de segments ( WIRES, BUS ) pour lesquels chaque segment * est une structure. */ +// NOT USED!!!@!@! { DrawSegmentStruct* oldsegment, * newsegment; wxPoint pos = GetScreen()->m_Curseur; @@ -84,7 +85,7 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type ) GetScreen()->ManageCurseur( DrawPanel, DC, FALSE ); oldsegment->m_EndIsDangling = FALSE; - /* Creation du segment suivant ou fin de tracé si point sur pin, jonction ...*/ + /* Creation du segment suivant ou fin de trac� si point sur pin, jonction ...*/ if( IsTerminalPoint( GetScreen(), oldsegment->m_End, oldsegment->m_Layer ) ) { EndSegment( DC ); return; @@ -385,6 +386,8 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: #undef STRUCT #define STRUCT ( (DrawLabelStruct*) g_ItemToRepeat ) g_ItemToRepeat = STRUCT->GenCopy(); @@ -396,19 +399,6 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) STRUCT->m_Text = Line; break; - - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ( (DrawGlobalLabelStruct*) g_ItemToRepeat ) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x; - STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y; - /*** Increment du numero de label ***/ - strcpy( Line, STRUCT->GetText() ); - IncrementLabelMember( Line ); - STRUCT->m_Text = Line; - break; - case DRAW_SEGMENT_STRUCT_TYPE: #undef STRUCT #define STRUCT ( (DrawSegmentStruct*) g_ItemToRepeat ) @@ -479,10 +469,10 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer ) * - type WIRE, si il y a * - une jonction * - ou une pin - * - ou une extrémité unique de fil + * - ou une extr�mit� unique de fil * * - type BUS, si il y a - * - ou une extrémité unique de BUS + * - ou une extr�mit� unique de BUS */ { EDA_BaseStruct* item; diff --git a/eeschema/eelibs_draw_components.cpp b/eeschema/eelibs_draw_components.cpp index 1734b3b6df..944a579705 100644 --- a/eeschema/eelibs_draw_components.cpp +++ b/eeschema/eelibs_draw_components.cpp @@ -193,7 +193,7 @@ void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC, Field->m_HJustify, Field->m_VJustify, LineWidth ); } - // Tracé de l'ancre + // Trac� de l'ancre int len = 3 * panel->GetZoom(); GRLine( &panel->m_ClipBox, DC, posX, posY - len, posX, posY + len, 0, color ); GRLine( &panel->m_ClipBox, DC, posX - len, posY, posX + len, posY, 0, color ); @@ -212,7 +212,7 @@ void EDA_SchComponentStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, bool dummy = FALSE; if( ( Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString, FIND_ROOT ) ) == NULL ) - { /* composant non trouvé, on affiche un composant "dummy" */ + { /* composant non trouv�, on affiche un composant "dummy" */ dummy = TRUE; if( DummyCmp == NULL ) CreateDummyCmp(); @@ -587,8 +587,8 @@ void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC, LibDrawPin* Pin = (LibDrawPin*) DEntry; if( Pin->m_Attributs & PINNOTDRAW ) { - if( (ActiveScreen->m_Type == SCHEMATIC_FRAME) - && !g_ShowAllPins ) + if( /*(GetScreen()->m_Type == SCHEMATIC_FRAME ) + &&*/ !g_ShowAllPins ) break; } diff --git a/eeschema/eelibs_read_libraryfiles.cpp b/eeschema/eelibs_read_libraryfiles.cpp index 1e887ff0d5..4f368b4b07 100644 --- a/eeschema/eelibs_read_libraryfiles.cpp +++ b/eeschema/eelibs_read_libraryfiles.cpp @@ -91,9 +91,9 @@ LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame, ChangeFileNameExt( FullFileName, DOC_EXT ); LoadDocLib( frame, FullFileName, NewLib->m_Name ); } - else - delete NewLib; - + else{ + SAFE_DELETE( NewLib ); + } fclose( f ); return NewLib; } @@ -237,7 +237,7 @@ void FreeCmpLibrary( wxWindow* frame, const wxString& LibName ) TempLib->m_Pnext = TempLib->m_Pnext->m_Pnext; } - delete Lib; + SAFE_DELETE( Lib ); /* The removed librairy can be the current library in libedit. * If so, clear the current library in libedit */ @@ -483,7 +483,7 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, char Msg.Printf( wxT( " Error at line %d of library \n\"%s\",\nlibrary not loaded" ), *LineNum, currentLibraryName.GetData() ); DisplayError( frame, Msg ); - delete LibEntry; + SAFE_DELETE( LibEntry ); return NULL; } } @@ -604,7 +604,7 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char* if( !Error ) { /* Convert '~' to spaces. */ Text->m_Text = CONV_FROM_UTF8( Buffer ); - Text->m_Text.Replace( wxT( "~" ), wxT( " " ) ); // Les espaces sont restitués + Text->m_Text.Replace( wxT( "~" ), wxT( " " ) ); // Les espaces sont restitu�s } } break; @@ -780,7 +780,7 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char* MsgLine.Printf( wxT( "Error in %c DRAW command in line %d, aborted." ), Line[0], *LineNum ); DisplayError( frame, MsgLine ); - delete New; + SAFE_DELETE( New ); /* FLush till end of draw: */ do { @@ -1119,8 +1119,8 @@ static int SortItemsFct( const void* ref, const void* item ); void EDA_LibComponentStruct::SortDrawItems() /*******************************************/ -/* Trie les éléments graphiques d'un composant lib pour améliorer - * le tracé: +/* Trie les �l�ments graphiques d'un composant lib pour am�liorer + * le trac�: * items remplis en premier, pins en dernier * En cas de superposition d'items, c'est plus lisible */ diff --git a/eeschema/eeload.cpp b/eeschema/eeload.cpp index bee28e7efc..e69de29bb2 100644 --- a/eeschema/eeload.cpp +++ b/eeschema/eeload.cpp @@ -1,222 +0,0 @@ -/****************************************/ -/* Module to load/save EESchema files. */ -/****************************************/ - -#include "fctsys.h" -#include "gr_basic.h" - -#include "common.h" -#include "program.h" -#include "libcmp.h" -#include "general.h" - -#include "protos.h" - -#include "id.h" - - -static void LoadSubHierarchy( WinEDA_SchematicFrame* frame, EDA_BaseStruct* DrawList ); - -/* Variables locales */ - - -/************************************************************************************/ -int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNew ) -/************************************************************************************/ - -/* - * Load an entire project ( shcematic root file and its subhierarchies, the configuration and the libs - * which are not already loaded) - */ -{ - SCH_SCREEN* screen; - wxString FullFileName, msg; - bool LibCacheExist = FALSE; - - EDA_ScreenList ScreenList( NULL ); - - for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) - { - if( screen->IsModify() ) - break; - } - - if( screen ) - { - if( !IsOK( this, _( "Clear Schematic Hierarchy (modified!)?" ) ) ) - return FALSE; - if( ScreenSch->m_FileName != g_DefaultSchematicFileName ) - SetLastProject( ScreenSch->m_FileName ); - } - - - screen = ScreenSch; - - FullFileName = FileName; - if( ( FullFileName.IsEmpty() ) && !IsNew ) - { - wxString mask = wxT( "*" ) + g_SchExtBuffer; - FullFileName = EDA_FileSelector( _( "Schematic files:" ), - wxEmptyString, /* Chemin par defaut */ - wxEmptyString, /* nom fichier par defaut */ - g_SchExtBuffer, /* extension par defaut */ - mask, /* Masque d'affichage */ - this, - wxFD_OPEN, - TRUE - ); - if( FullFileName.IsEmpty() ) - return FALSE; - } - - if( ClearProjectDrawList( screen, TRUE ) == FALSE ) - return 1; - - ActiveScreen = m_CurrentScreen = screen = ScreenSch; - ScreenSch->ClearUndoRedoList(); - screen->SetCurItem( NULL ); - wxSetWorkingDirectory( wxPathOnly( FullFileName ) ); - m_CurrentScreen->m_FileName = FullFileName; - Affiche_Message( wxEmptyString ); - MsgPanel->EraseMsgBox(); - - memset( &g_EESchemaVar, 0, sizeof(g_EESchemaVar) ); - - m_CurrentScreen->ClrModify(); - m_CurrentScreen->Pnext = NULL; - - if( IsNew ) - { - screen->m_CurrentSheet = &g_Sheet_A4; - screen->SetZoom( 32 ); - screen->m_SheetNumber = screen->m_NumberOfSheet = 1; - screen->m_Title = wxT( "noname.sch" ); - m_CurrentScreen->m_FileName = screen->m_Title; - screen->m_Company.Empty(); - screen->m_Commentaire1.Empty(); - screen->m_Commentaire2.Empty(); - screen->m_Commentaire3.Empty(); - screen->m_Commentaire4.Empty(); - Read_Config( wxEmptyString, TRUE ); - Zoom_Automatique( TRUE ); - ReDrawPanel(); - return 1; - } - - // Rechargement de la configuration: - msg = _( "Ready\nWorking dir: \n" ) + wxGetCwd(); - PrintMsg( msg ); - - Read_Config( wxEmptyString, FALSE ); - - // Delete old caches. - LibraryStruct* nextlib, * lib = g_LibraryList; - for( ; lib != NULL; lib = nextlib ) - { - nextlib = lib->m_Pnext; - if( lib->m_IsLibCache ) - FreeCmpLibrary( this, lib->m_Name ); - } - - if( IsNew ) - { - ReDrawPanel(); - return 1; - } - - // Loading the project library cache - wxString FullLibName; - wxString shortfilename; - wxSplitPath( ScreenSch->m_FileName, NULL, &shortfilename, NULL ); - FullLibName << wxT( "." ) << STRING_DIR_SEP << shortfilename << wxT( ".cache" ) << - g_LibExtBuffer; - if( wxFileExists( FullLibName ) ) - { - wxString libname; - libname = FullLibName; - ChangeFileNameExt( libname, wxEmptyString ); - msg = wxT( "Load " ) + FullLibName; - LibraryStruct* LibCache = LoadLibraryName( this, FullLibName, libname ); - if( LibCache ) - { - LibCache->m_IsLibCache = TRUE; - msg += wxT( " OK" ); - } - else - msg += wxT( " ->Error" ); - PrintMsg( msg ); - LibCacheExist = TRUE; - } - - if( !wxFileExists( ScreenSch->m_FileName ) && !LibCacheExist ) // Nouveau projet prpbablement - { - msg.Printf( _( "File %s not found (new project ?)" ), - ScreenSch->m_FileName.GetData() ); - DisplayInfo( this, msg, 20 ); - return -1; - } - - if( LoadOneEEFile( ScreenSch, ScreenSch->m_FileName ) == FALSE ) - return 0; - - /* load all subhierarchies fond in current list and new loaded list */ - LoadSubHierarchy( this, ScreenSch->EEDrawList ); - - /* Reaffichage ecran de base (ROOT) si necessaire */ - ActiveScreen = ScreenSch; - Zoom_Automatique( FALSE ); - - return 1; -} - - -/*******************************************************************************/ -void LoadSubHierarchy( WinEDA_SchematicFrame* frame, EDA_BaseStruct* DrawList ) -/*******************************************************************************/ - -/* load subhierarcy when sheets are found in DrawList - * recursive function. - */ -{ - EDA_BaseStruct* EEDrawList = DrawList; - - while( EEDrawList ) - { - if( EEDrawList->Type() == DRAW_SHEET_STRUCT_TYPE ) - { - #undef STRUCT - #define STRUCT ( (DrawSheetStruct*) EEDrawList ) - int timestamp = STRUCT->m_TimeStamp; - if( timestamp == 0 ) - { - timestamp = GetTimeStamp(); - STRUCT->m_TimeStamp = timestamp; - } - if( !STRUCT->m_FileName.IsEmpty() ) - { - //problem -- must check for closed loops here, or we may never exit! - //search back up the linked list tree... - EDA_BaseStruct* strct = EEDrawList; - bool noRecurse = true; - while( strct->m_Parent ){ - strct = strct->m_Parent; - if( ((DrawSheetStruct*)strct)->m_FileName == - STRUCT->m_FileName ){ - wxString msg; - msg += wxString::Format(_( "The sheet hierarchy has an infinite loop, halting recursive loads. file: ")); - msg += STRUCT->m_FileName; - DisplayError( frame, msg ); - noRecurse = false; - } - } - if( frame->LoadOneEEFile( STRUCT, STRUCT->m_FileName ) == TRUE && noRecurse) - { - LoadSubHierarchy( frame, STRUCT->EEDrawList ); - } - } - else - DisplayError( frame, _( "No FileName in SubSheet" ) ); - } - EEDrawList = EEDrawList->Pnext; - } -} diff --git a/eeschema/eeredraw.cpp b/eeschema/eeredraw.cpp index ab11fe7ffb..f09514315f 100644 --- a/eeschema/eeredraw.cpp +++ b/eeschema/eeredraw.cpp @@ -35,7 +35,7 @@ char marq_bitmap[]= char marqERC_bitmap[]= { 8, 8, 0, 0, /* Dimensions x et y , offsets x et y du bitmap de marqueurs*/ - -1, /* Color: -1 = couleur non précisée */ + -1, /* Color: -1 = couleur non pr�cis�e */ 1,1,1,1,1,0,0,0, 1,1,1,0,1,0,0,0, 1,1,1,1,0,0,0,0, @@ -129,18 +129,18 @@ wxString title; void WinEDA_DrawPanel::PrintPage(wxDC * DC, bool Print_Sheet_Ref, int PrintMask) /*******************************************************************************/ { -BASE_SCREEN * screen, * oldscreen = m_Parent->GetScreen(); +BASE_SCREEN * screen; // * oldscreen = m_Parent->GetScreen(); wxBeginBusyCursor(); - screen = m_Parent->m_CurrentScreen = ActiveScreen; + ActiveScreen = screen = m_Parent->GetScreen(); RedrawStructList(this,DC, screen->EEDrawList, GR_COPY); if ( Print_Sheet_Ref ) m_Parent->TraceWorkSheet(DC, screen, g_DrawMinimunLineWidth ); - m_Parent->m_CurrentScreen = oldscreen; + //m_Parent->m_CurrentSheet->m_s = oldscreen; wxEndBusyCursor(); } @@ -223,7 +223,7 @@ void DrawMarkerStruct::Draw(WinEDA_DrawPanel * panel,wxDC * DC, const wxPoint & int DrawMode, int Color) /****************************************************************************************/ { -#define WAR 1 // utilisé aussi dans erc.cpp +#define WAR 1 // utilis� aussi dans erc.cpp if( m_Type == MARQ_ERC ) { @@ -300,23 +300,23 @@ int width = MAX(m_Width, g_DrawMinimunLineWidth); GRSetDrawMode(DC, DrawMode); if( (m_Layer == LAYER_BUS) && (zoom <= 16) ) - { + { width *= 3; - } + } GRMoveTo(m_Points[0], m_Points[1]); if( m_Layer == LAYER_NOTES) - { + { for (i = 1; i < m_NumOfPoints; i++) GRDashedLineTo(&panel->m_ClipBox, DC, m_Points[i * 2] + offset.x, m_Points[i * 2 + 1] + offset.y, width, color); - } + } else - { + { for (i = 1; i < m_NumOfPoints; i++) GRLineTo(&panel->m_ClipBox, DC, m_Points[i * 2] + offset.x, m_Points[i * 2 + 1] + offset.y, width, color); - } + } } /***************************************************************************** @@ -420,6 +420,8 @@ int width = g_DrawMinimunLineWidth; } case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: { DrawLabelStruct * Struct; Struct = (DrawLabelStruct * ) DrawStruct; @@ -429,16 +431,6 @@ int width = g_DrawMinimunLineWidth; break; } - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - { - DrawGlobalLabelStruct * Struct; - Struct = (DrawGlobalLabelStruct * ) DrawStruct; - Struct->m_Pos.x += dx; Struct->m_Pos.y += dy; - Struct->Draw(panel, DC, wxPoint(0,0),DrawMode,g_GhostColor); - Struct->m_Pos.x -= dx; Struct->m_Pos.y -= dy; - break; - } - case DRAW_NOCONNECT_STRUCT_TYPE: { DrawNoConnectStruct * Struct; diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index 2b4e92bf2f..8ed3c35cdb 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -24,10 +24,6 @@ #include "bitmaps.h" #include "eda_dde.h" - -/* Routines locales */ -static void CreateScreens(); - // Global variables wxString g_Main_Title( wxT( "EESchema" ) ); @@ -61,8 +57,6 @@ bool WinEDA_App::OnInit() if( argc > 1 ) FFileName = argv[1]; - CreateScreens(); - /* init EESCHEMA */ GetSettings(); // read current setup SeedLayers(); @@ -106,25 +100,3 @@ bool WinEDA_App::OnInit() return TRUE; } - -/******************************/ -static void CreateScreens() -/******************************/ - -/* - * Fonction d'init des écrans utilisés dans EESchema: - */ -{ - /* creation des ecrans Sch , Lib */ - - if( ScreenSch == NULL ) - ScreenSch = new SCH_SCREEN( SCHEMATIC_FRAME ); - ScreenSch->m_FileName = g_DefaultSchematicFileName; - ScreenSch->m_Date = GenDate(); - ActiveScreen = ScreenSch; - - if( ScreenLib == NULL ) - ScreenLib = new SCH_SCREEN( LIBEDITOR_FRAME ); - ScreenLib->SetZoom( 4 ); - ScreenLib->m_UndoRedoCountMax = 10; -} diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index 16482420da..a54545bc69 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -51,7 +51,7 @@ int WriteFichierERC = FALSE; * PIN_OPENEMITTER, PIN_NC */ #define OK 0 -#define WAR 1 // utilisé aussi dans eeredraw +#define WAR 1 // utilis� aussi dans eeredraw #define ERR 2 #define UNC 3 @@ -185,7 +185,7 @@ void WinEDA_ErcFrame::ReBuildMatrixPanel() text_height = text->GetRect().GetHeight(); bitmap_size = MAX( bitmap_size, text_height ); - delete text; + SAFE_DELETE( text ); // compute the Y pos interval: BoxMatrixMinSize.y = ( bitmap_size * (PIN_NMAX + 1) ) + 5; @@ -313,7 +313,7 @@ void WinEDA_ErcFrame::TestErc( wxCommandEvent& event ) g_EESchemaVar.NbWarningErc = 0; /* Cleanup the entire hierarchy */ - EDA_ScreenList ScreenList( NULL ); + EDA_ScreenList ScreenList; for( SCH_SCREEN* Screen = ScreenList.GetFirst(); Screen != NULL; Screen = ScreenList.GetNext() ) { @@ -358,10 +358,12 @@ void WinEDA_ErcFrame::TestErc( wxCommandEvent& event ) case NET_LABEL: case NET_BUSLABELMEMBER: case NET_PINLABEL: + case NET_GLOBLABEL: //not sure how to handle global labels -- they should be treated like other nets (just global!0 + case NET_GLOBBUSLABELMEMBER: break; - case NET_GLOBLABEL: - case NET_GLOBBUSLABELMEMBER: + case NET_HIERLABEL: + case NET_HIERBUSLABELMEMBER: case NET_SHEETLABEL: case NET_SHEETBUSLABELMEMBER: TestLabel( m_Parent->DrawPanel, &dc, NetItemRef, StartNet ); @@ -398,7 +400,7 @@ void WinEDA_ErcFrame::TestErc( wxCommandEvent& event ) if( WriteFichierERC == TRUE ) { wxString ErcFullFileName; - ErcFullFileName = ScreenSch->m_FileName; + ErcFullFileName = g_RootSheet->m_s->m_FileName; ChangeFileNameExt( ErcFullFileName, wxT( ".erc" ) ); ErcFullFileName = EDA_FileSelector( _( "ERC file:" ), wxEmptyString, /* Chemin par defaut */ @@ -542,7 +544,7 @@ static void Diagnose( WinEDA_DrawPanel* panel, wxDC* DC, Marker->m_Type = MARQ_ERC; Marker->m_MarkFlags = WAR; - screen = NetItemRef->m_Screen; + screen = NetItemRef->m_SheetList.LastScreen(); Marker->Pnext = screen->EEDrawList; screen->EEDrawList = Marker; g_EESchemaVar.NbErrorErc++; @@ -550,14 +552,14 @@ static void Diagnose( WinEDA_DrawPanel* panel, wxDC* DC, if( MinConn < 0 ) // Traitement des erreurs sur labels { - if( (NetItemRef->m_Type == NET_GLOBLABEL) - || (NetItemRef->m_Type == NET_GLOBBUSLABELMEMBER) ) + if( (NetItemRef->m_Type == NET_HIERLABEL) + || (NetItemRef->m_Type == NET_HIERBUSLABELMEMBER) ) { - Marker->m_Comment.Printf( _( "Warning GLabel %s not connected to SheetLabel" ), + Marker->m_Comment.Printf( _( "Warning HLabel %s not connected to SheetLabel" ), NetItemRef->m_Label->GetData() ); } else - Marker->m_Comment.Printf( _( "Warning SheetLabel %s not connected to GLabel" ), + Marker->m_Comment.Printf( _( "Warning SheetLabel %s not connected to HLabel" ), NetItemRef->m_Label->GetData() ); if( screen == panel->GetScreen() ) @@ -656,7 +658,7 @@ static void TestOthersItems( WinEDA_DrawPanel* panel, wxDC* DC, || (NetItemRef->GetNet() != NetItemTst->GetNet()) ) // fin de net { /* Fin de netcode trouve: Tst connexion minimum */ if( (*MinConnexion < NET_NC ) - && (local_minconn < NET_NC ) ) /* pin non connectée ou non pilotee */ + && (local_minconn < NET_NC ) ) /* pin non connect�e ou non pilotee */ { Diagnose( panel, DC, NetItemRef, NULL, local_minconn, WAR ); *MinConnexion = DRV; // inhibition autres messages de ce type pour ce net @@ -670,11 +672,13 @@ static void TestOthersItems( WinEDA_DrawPanel* panel, wxDC* DC, case NET_BUS: case NET_JONCTION: case NET_LABEL: - case NET_GLOBLABEL: + case NET_HIERLABEL: case NET_BUSLABELMEMBER: - case NET_GLOBBUSLABELMEMBER: + case NET_HIERBUSLABELMEMBER: case NET_SHEETBUSLABELMEMBER: case NET_SHEETLABEL: + case NET_GLOBLABEL: + case NET_GLOBBUSLABELMEMBER: case NET_PINLABEL: break; @@ -719,7 +723,7 @@ static bool WriteDiagnosticERC( const wxString& FullFileName ) DrawMarkerStruct* Marker; char Line[256]; static FILE* OutErc; - DrawSheetStruct* Sheet; + DrawSheetList* Sheet; wxString msg; if( ( OutErc = wxFopen( FullFileName, wxT( "wt" ) ) ) == NULL ) @@ -730,19 +734,20 @@ static bool WriteDiagnosticERC( const wxString& FullFileName ) fprintf( OutErc, "%s (%s)\n", CONV_TO_UTF8( msg ), Line ); - EDA_ScreenList ScreenList( NULL ); + EDA_SheetList SheetList( NULL ); - for( SCH_SCREEN* Screen = ScreenList.GetFirst(); Screen != NULL; Screen = ScreenList.GetNext() ) + for( Sheet = SheetList.GetFirst(); Sheet != NULL; Sheet = SheetList.GetNext() ) { - Sheet = (DrawSheetStruct*) Screen; - - msg.Printf( _( "\n***** Sheet %d (%s)\n" ), - Sheet->m_SheetNumber, - Screen == ScreenSch ? _( "Root" ) : Sheet->m_SheetName.GetData() ); + if(Sheet->Last() == g_RootSheet){ + msg.Printf( _( "\n***** Sheet Root\n" ) ); + }else{ + wxString str = Sheet->Path(); + msg.Printf( _("\n***** Sheet %s\n"), str.GetData() ); + } fprintf( OutErc, "%s", CONV_TO_UTF8( msg ) ); - DrawStruct = Screen->EEDrawList; + DrawStruct = Sheet->LastDrawList(); for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) { if( DrawStruct->Type() != DRAW_MARKER_STRUCT_TYPE ) @@ -770,7 +775,18 @@ static bool WriteDiagnosticERC( const wxString& FullFileName ) return TRUE; } - +bool TestLabel_( ObjetNetListStruct* a, ObjetNetListStruct* b ) +{ + int at = a->m_Type; + int bt = b->m_Type; + if( (at == NET_HIERLABEL || at == NET_HIERBUSLABELMEMBER) + &&(bt == NET_SHEETLABEL || bt == NET_SHEETBUSLABELMEMBER) ){ + if( a->m_SheetList == b->m_SheetListInclude ){ + return true; //connected! + } + } + return false; //these two are unconnected +} /***********************************************************************/ void TestLabel( WinEDA_DrawPanel* panel, wxDC* DC, ObjetNetListStruct* NetItemRef, ObjetNetListStruct* StartNet ) @@ -799,66 +815,16 @@ void TestLabel( WinEDA_DrawPanel* panel, wxDC* DC, || ( NetItemRef->GetNet() != NetItemTst->GetNet() ) ) { /* Fin de netcode trouve */ - if( erc ) - { + if( erc ){ /* GLabel ou SheetLabel orphelin */ Diagnose( panel, DC, NetItemRef, NULL, -1, WAR ); } return; } - - if( (NetItemRef->m_Type == NET_GLOBLABEL) - || (NetItemRef->m_Type == NET_GLOBBUSLABELMEMBER) ) - { - switch( NetItemTst->m_Type ) - { - case NET_SEGMENT: - case NET_BUS: - case NET_JONCTION: - case NET_LABEL: - case NET_GLOBLABEL: - case NET_BUSLABELMEMBER: - case NET_GLOBBUSLABELMEMBER: - case NET_PINLABEL: - case NET_NOCONNECT: - case NET_PIN: - break; - - case NET_SHEETBUSLABELMEMBER: - case NET_SHEETLABEL: - /* Tst si le GLabel est bien dans la bonne sousfeuille */ - if( NetItemRef->m_SheetNumber == NetItemTst->m_NumInclude ) - { - erc = 0; - } - break; - } - } - else - { - switch( NetItemTst->m_Type ) - { - case NET_SEGMENT: - case NET_BUS: - case NET_JONCTION: - case NET_LABEL: - case NET_BUSLABELMEMBER: - case NET_SHEETBUSLABELMEMBER: - case NET_SHEETLABEL: - case NET_PINLABEL: - case NET_NOCONNECT: - case NET_PIN: - break; - - case NET_GLOBLABEL: - case NET_GLOBBUSLABELMEMBER: - /* Tst si le GLabel est bien dans la bonne sous-feuille */ - if( NetItemTst->m_SheetNumber == NetItemRef->m_NumInclude ) - { - erc = 0; - } - break; - } - } + if(TestLabel_(NetItemRef, NetItemTst)) + erc = 0; + //same thing, different order. + if(TestLabel_(NetItemTst, NetItemRef)) + erc = 0; } } diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 73273f6b49..8b1b39f57b 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -20,7 +20,7 @@ void WinEDA_SchematicFrame::Save_File( wxCommandEvent& event ) /****************************************************************/ -/* Commands to save shepatic project or the current page. +/* Commands to save project or the current page. */ { int id = event.GetId(); @@ -28,7 +28,7 @@ void WinEDA_SchematicFrame::Save_File( wxCommandEvent& event ) switch( id ) { case ID_SAVE_PROJECT: /* Update Schematic File */ - SaveProject( this ); + SaveProject( ); break; case ID_SAVE_ONE_SHEET: /* Update Schematic File */ @@ -47,26 +47,25 @@ void WinEDA_SchematicFrame::Save_File( wxCommandEvent& event ) /******************************************************************************************/ -bool WinEDA_SchematicFrame::LoadOneSheet( SCH_SCREEN* screen, const wxString& filename ) +//bool WinEDA_SchematicFrame::LoadOneSheet(DrawSheetStruct* sheet, const wxString& filename ) /******************************************************************************************/ -{ +//{ +// return FALSE; + //when is this used? and why? + /* + //this must be called with a non-null pointer screen pointer, clearly. + //also note that this is for reading in a *root* file wxString FullFileName = filename; - if( screen->EEDrawList != NULL ) - { - if( !IsOK( this, _( "Clear SubHierarchy ?" ) ) ) - return FALSE; - } - if( FullFileName.IsEmpty() ) { wxString mask; mask = wxT( "*" ) + g_SchExtBuffer; FullFileName = EDA_FileSelector( _( "Schematic files:" ), - wxEmptyString, /* default path */ - screen->m_FileName, /* default filename */ - g_SchExtBuffer, /* extension par defaut */ - mask, /* Masque d'affichage */ + wxEmptyString, //default path + sheet->m_s->m_FileName,// default filename + g_SchExtBuffer, // extension par defaut + mask, // Masque d'affichage this, wxFD_OPEN, FALSE @@ -76,52 +75,212 @@ bool WinEDA_SchematicFrame::LoadOneSheet( SCH_SCREEN* screen, const wxString& fi } ClearProjectDrawList( screen, TRUE ); - + printf("in LoadOneScreen setting screen filename: %s \n", (const char*) FullFileName.mb_str() ); screen->m_FileName = FullFileName; - LoadOneEEFile( screen, FullFileName ); + LoadDrawSheet( DrawSheetStruct * sheet, filename); screen->SetModify(); if( GetScreen() == screen ) Refresh( TRUE ); return TRUE; + */ +//} + +/************************************************************************************/ +int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNew ) +/************************************************************************************/ +{ + /* + * Load an entire project + * ( schematic root file and its subhierarchies, the configuration and the libs + * which are not already loaded) + */ + SCH_SCREEN* screen; + wxString FullFileName, msg; + bool LibCacheExist = FALSE; + + EDA_ScreenList ScreenList; + + for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + { + if( screen->IsModify() ) + break; + } + + if( screen ) + { + if( !IsOK( this, _( "Clear Schematic Hierarchy (modified!)?" ) ) ) + return FALSE; + if( g_RootSheet->m_s->m_FileName != g_DefaultSchematicFileName ) + SetLastProject( g_RootSheet->m_s->m_FileName ); + } + + FullFileName = FileName; + if( ( FullFileName.IsEmpty() ) && !IsNew ) + { + wxString mask = wxT( "*" ) + g_SchExtBuffer; + FullFileName = EDA_FileSelector( _( "Schematic files:" ), + wxEmptyString, /* Chemin par defaut */ + wxEmptyString, /* nom fichier par defaut */ + g_SchExtBuffer, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxFD_OPEN, + TRUE + ); + if( FullFileName.IsEmpty() ) + return FALSE; + } + if(g_RootSheet){ + SAFE_DELETE(g_RootSheet); + } + CreateScreens(); + screen = (SCH_SCREEN*)GetScreen(); + + wxSetWorkingDirectory( wxPathOnly( FullFileName ) ); + GetScreen()->m_FileName = FullFileName; + g_RootSheet->m_FileName = FullFileName; + Affiche_Message( wxEmptyString ); + MsgPanel->EraseMsgBox(); + + memset( &g_EESchemaVar, 0, sizeof(g_EESchemaVar) ); + + GetScreen()->ClrModify(); + //m_CurrentSheet->m_s->Pnext = NULL; should be by default + + if( IsNew ) + { + screen->m_CurrentSheetDesc = &g_Sheet_A4; + screen->SetZoom( 32 ); + screen->m_ScreenNumber = screen->m_NumberOfScreen = 1; + screen->m_Title = wxT( "noname.sch" ); + GetScreen()->m_FileName = screen->m_Title; + screen->m_Company.Empty(); + screen->m_Commentaire1.Empty(); + screen->m_Commentaire2.Empty(); + screen->m_Commentaire3.Empty(); + screen->m_Commentaire4.Empty(); + Read_Config( wxEmptyString, TRUE ); + Zoom_Automatique( TRUE ); + ReDrawPanel(); + return 1; + } + + // Rechargement de la configuration: + msg = _( "Ready\nWorking dir: \n" ) + wxGetCwd(); + PrintMsg( msg ); + + Read_Config( wxEmptyString, FALSE ); + + // Delete old caches. + LibraryStruct* nextlib, * lib = g_LibraryList; + for( ; lib != NULL; lib = nextlib ) + { + nextlib = lib->m_Pnext; + if( lib->m_IsLibCache ) + FreeCmpLibrary( this, lib->m_Name ); + } + + if( IsNew ) + { + ReDrawPanel(); + return 1; + } + + // Loading the project library cache + wxString FullLibName; + wxString shortfilename; + wxSplitPath( g_RootSheet->m_s->m_FileName, NULL, &shortfilename, NULL ); + FullLibName << wxT( "." ) << STRING_DIR_SEP << shortfilename << wxT( ".cache" ) << + g_LibExtBuffer; + if( wxFileExists( FullLibName ) ) + { + wxString libname; + libname = FullLibName; + ChangeFileNameExt( libname, wxEmptyString ); + msg = wxT( "Load " ) + FullLibName; + LibraryStruct* LibCache = LoadLibraryName( this, FullLibName, libname ); + if( LibCache ) + { + LibCache->m_IsLibCache = TRUE; + msg += wxT( " OK" ); + } + else + msg += wxT( " ->Error" ); + PrintMsg( msg ); + LibCacheExist = TRUE; + } + + if( !wxFileExists( g_RootSheet->m_s->m_FileName ) && !LibCacheExist ) // Nouveau projet prpbablement + { + msg.Printf( _( "File %s not found (new project ?)" ), + g_RootSheet->m_s->m_FileName.GetData() ); + DisplayInfo( this, msg, 20 ); + return -1; + } + + //load the project. + SAFE_DELETE(g_RootSheet->m_s); + if(!g_RootSheet->Load(this)) + return 0; + + /* Reaffichage ecran de base (ROOT) si necessaire */ + ActiveScreen = GetScreen(); + Zoom_Automatique( FALSE ); + DrawPanel->Refresh( TRUE ); + return 1; +} +/**********************************************************/ +SCH_SCREEN * WinEDA_SchematicFrame::CreateNewScreen( + SCH_SCREEN * OldScreen, int TimeStamp) +/**********************************************************/ +/* Routine de creation ( par allocation memoire ) d'un nouvel ecran + cet ecran est en chainage arriere avec OldScreen + la valeur TimeStamp est attribuee au parametre NewScreen->TimeStamp +*/ +{ + SCH_SCREEN * NewScreen; + + NewScreen = new SCH_SCREEN(SCHEMATIC_FRAME); + + NewScreen->SetRefreshReq(); + if(OldScreen) NewScreen->m_Company = OldScreen->m_Company; + NewScreen->m_TimeStamp = TimeStamp; + + NewScreen->Pback = OldScreen; + + return(NewScreen); } - /****************************************************/ -void SaveProject( WinEDA_SchematicFrame* frame ) +void WinEDA_SchematicFrame::SaveProject( ) /****************************************************/ /* Sauvegarde toutes les feuilles du projet - * et crée une librairie archive des composants, de nom .chche.lib + * et cr�e une librairie archive des composants, de nom .chche.lib */ { - SCH_SCREEN* screen_tmp; + SCH_SCREEN* screen_tmp, *screen; wxString LibArchiveFileName; - if( frame == NULL ) - return; + screen_tmp = (SCH_SCREEN*)GetScreen(); //save... - screen_tmp = frame->GetScreen(); + EDA_ScreenList ScreenList; - EDA_ScreenList ScreenList( NULL ); - - for( ActiveScreen = ScreenList.GetFirst(); - ActiveScreen != NULL; - ActiveScreen = ScreenList.GetNext() ) + for( screen = ScreenList.GetFirst(); screen != NULL; + screen = ScreenList.GetNext() ) { - frame->m_CurrentScreen = ActiveScreen; - frame->SaveEEFile( NULL, FILE_SAVE_AS ); + printf("SaveEEFile, %s\n", (const char*)screen->m_FileName.mb_str() ); + SaveEEFile( screen, FILE_SAVE_AS ); } - frame->m_CurrentScreen = ActiveScreen = screen_tmp; - /* Creation du fichier d'archivage composants en repertoire courant */ - LibArchiveFileName = MakeFileName( wxEmptyString, ScreenSch->m_FileName, wxEmptyString ); + LibArchiveFileName = MakeFileName( wxEmptyString, GetScreen()->m_FileName, wxEmptyString ); ChangeFileNameExt( LibArchiveFileName, wxEmptyString ); /* mise a jour extension */ LibArchiveFileName += wxT( ".cache" ) + g_LibExtBuffer; - LibArchive( frame, LibArchiveFileName ); + LibArchive( this, LibArchiveFileName ); } @@ -132,10 +291,14 @@ int CountCmpNumber() /* Routine retournant le nombre de composants dans le schema, * powers non comprises */ { + return g_RootSheet->ComponentCount(); + /* BASE_SCREEN* Window; EDA_BaseStruct* Phead; int Nb = 0; + + Window = ScreenSch; while( Window ) { @@ -153,4 +316,5 @@ int CountCmpNumber() } return Nb; + */ } diff --git a/eeschema/find.cpp b/eeschema/find.cpp index 8067362c9f..8b084e4281 100644 --- a/eeschema/find.cpp +++ b/eeschema/find.cpp @@ -79,7 +79,7 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindComponentAndItem( * @param mouseWarp If true, then move the mouse cursor to the item. */ { - SCH_SCREEN* Screen, * ScreenWithComponentFound = NULL; + DrawSheetList* sheet, * SheetWithComponentFound = NULL; EDA_BaseStruct* DrawList = NULL; EDA_SchComponentStruct* Component = NULL; wxSize DrawAreaSize = DrawPanel->GetClientSize(); @@ -89,25 +89,25 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindComponentAndItem( wxString msg; LibDrawPin* pin; - EDA_ScreenList ScreenList( NULL ); + EDA_SheetList SheetList( NULL ); - Screen = ScreenList.GetFirst(); + sheet = SheetList.GetFirst(); if( !Find_in_hierarchy ) - Screen = (SCH_SCREEN*) m_CurrentScreen; + sheet = m_CurrentSheet; - for( ; Screen != NULL; Screen = ScreenList.GetNext() ) + for( ; sheet != NULL; sheet = SheetList.GetNext() ) { - DrawList = Screen->EEDrawList; + DrawList = sheet->LastDrawList(); for( ; (DrawList != NULL) && (NotFound == true); DrawList = DrawList->Pnext ) { if( DrawList->Type() == DRAW_LIB_ITEM_STRUCT_TYPE ) { EDA_SchComponentStruct* pSch; pSch = (EDA_SchComponentStruct*) DrawList; - if( component_reference.CmpNoCase( pSch->m_Field[REFERENCE].m_Text ) == 0 ) + if( component_reference.CmpNoCase( pSch->GetRef(sheet) ) == 0 ) { Component = pSch; - ScreenWithComponentFound = Screen; + SheetWithComponentFound = sheet; switch( SearchType ) { @@ -149,11 +149,13 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindComponentAndItem( if( Component ) { - Screen = ScreenWithComponentFound; - if( Screen != GetScreen() ) + sheet = SheetWithComponentFound; + if( sheet != GetSheet() ) { - Screen->SetZoom( GetScreen()->GetZoom() ); - m_CurrentScreen = ActiveScreen = Screen; + sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() ); + *m_CurrentSheet = *sheet; + ActiveScreen = m_CurrentSheet->LastScreen(); + m_CurrentSheet->UpdateAllScreenReferences(); DoCenterAndRedraw = TRUE; } wxPoint delta; @@ -164,18 +166,18 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindComponentAndItem( pos = delta + Component->m_Pos; - wxPoint old_cursor_position = Screen->m_Curseur; - Screen->m_Curseur = pos; + wxPoint old_cursor_position = sheet->LastScreen()->m_Curseur; + sheet->LastScreen()->m_Curseur = pos; curpos = DrawPanel->CursorScreenPosition(); DrawPanel->GetViewStart( - &m_CurrentScreen->m_StartVisu.x, - &m_CurrentScreen->m_StartVisu.y ); + &( GetScreen()->m_StartVisu.x ), + &( GetScreen()->m_StartVisu.y )); // calcul des coord curseur avec origine = screen - curpos.x -= m_CurrentScreen->m_StartVisu.x; - curpos.y -= m_CurrentScreen->m_StartVisu.y; + curpos.x -= GetScreen()->m_StartVisu.x; + curpos.y -= GetScreen()->m_StartVisu.y; /* Il y a peut-etre necessite de recadrer le dessin: */ #define MARGIN 30 @@ -194,13 +196,13 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindComponentAndItem( DrawPanel->PrepareGraphicContext( &dc ); - EXCHG( old_cursor_position, Screen->m_Curseur ); + EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur ); DrawPanel->CursorOff( &dc ); if( mouseWarp ) GRMouseWarp( DrawPanel, curpos ); - EXCHG( old_cursor_position, Screen->m_Curseur ); + EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur ); DrawPanel->CursorOn( &dc ); } @@ -273,7 +275,7 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindMarker( int SearchType ) * SearchType = 0: search the first marker, else search next marker */ { - SCH_SCREEN* Screen, * FirstScreen = NULL; + DrawSheetList* sheet, * FirstSheet = NULL; EDA_BaseStruct* DrawList, * FirstStruct = NULL, * Struct = NULL; DrawMarkerStruct* Marker = NULL; int StartCount; @@ -289,13 +291,13 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindMarker( int SearchType ) if( SearchType == 0 ) s_MarkerCount = 0; - EDA_ScreenList ScreenList( NULL ); + EDA_SheetList SheetList( NULL ); NotFound = TRUE; StartCount = 0; /* Search for s_MarkerCount markers */ - for( Screen = ScreenList.GetFirst(); Screen != NULL; Screen = ScreenList.GetNext() ) + for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) { - DrawList = Screen->EEDrawList; + DrawList = sheet->LastDrawList(); while( DrawList && NotFound ) { if( DrawList->Type() == DRAW_MARKER_STRUCT_TYPE ) @@ -303,9 +305,9 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindMarker( int SearchType ) Marker = (DrawMarkerStruct*) DrawList; NotFound = FALSE; pos = Marker->m_Pos; - if( FirstScreen == NULL ) /* First item found */ + if( FirstSheet == NULL ) /* First item found */ { - FirstScreen = Screen; firstpos = pos; + FirstSheet = sheet; firstpos = pos; FirstStruct = DrawList; } @@ -326,31 +328,33 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindMarker( int SearchType ) break; } - if( NotFound && FirstScreen ) // markers are found, but we have reach the last marker */ + if( NotFound && FirstSheet ) // markers are found, but we have reach the last marker */ { // After the last marker, the first marker is used */ - NotFound = FALSE; Screen = FirstScreen; + NotFound = FALSE; sheet = FirstSheet; Struct = FirstStruct; pos = firstpos; s_MarkerCount = 1; } if( NotFound == FALSE ) { - if( Screen != GetScreen() ) + if( sheet != GetSheet() ) { - Screen->SetZoom( GetScreen()->GetZoom() ); - m_CurrentScreen = ActiveScreen = Screen; + sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() ); + *m_CurrentSheet = *sheet; + ActiveScreen = m_CurrentSheet->LastScreen(); + m_CurrentSheet->UpdateAllScreenReferences(); DoCenterAndRedraw = TRUE; } - old_cursor_position = Screen->m_Curseur; - Screen->m_Curseur = pos; + old_cursor_position = sheet->LastScreen()->m_Curseur; + sheet->LastScreen()->m_Curseur = pos; curpos = DrawPanel->CursorScreenPosition(); // calcul des coord curseur avec origine = screen - DrawPanel->GetViewStart( &m_CurrentScreen->m_StartVisu.x, - &m_CurrentScreen->m_StartVisu.y ); - curpos.x -= m_CurrentScreen->m_StartVisu.x; - curpos.y -= m_CurrentScreen->m_StartVisu.y; + DrawPanel->GetViewStart( &m_CurrentSheet->LastScreen()->m_StartVisu.x, + &m_CurrentSheet->LastScreen()->m_StartVisu.y ); + curpos.x -= m_CurrentSheet->LastScreen()->m_StartVisu.x; + curpos.y -= m_CurrentSheet->LastScreen()->m_StartVisu.y; // reposition the window if the chosen marker is off screen. #define MARGIN 30 @@ -368,14 +372,14 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindMarker( int SearchType ) wxClientDC dc( DrawPanel ); DrawPanel->PrepareGraphicContext( &dc ); - EXCHG( old_cursor_position, Screen->m_Curseur ); + EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur ); DrawPanel->CursorOff( &dc ); GRMouseWarp( DrawPanel, curpos ); - EXCHG( old_cursor_position, Screen->m_Curseur ); + EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur ); DrawPanel->CursorOn( &dc ); } - - msg.Printf( _( "Marker %d found in %s" ), s_MarkerCount, Screen->m_FileName.GetData() ); + wxString path = sheet->Path(); + msg.Printf( _( "Marker %d found in %s" ), s_MarkerCount, path.GetData() ); Affiche_Message( msg ); } else @@ -425,7 +429,7 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindSchematicItem( * @param mouseWarp If true, then move the mouse cursor to the item. */ { - SCH_SCREEN* Screen, * FirstScreen = NULL; + DrawSheetList* Sheet, * FirstSheet = NULL; EDA_BaseStruct* DrawList = NULL, * FirstStruct = NULL, * Struct = NULL; int StartCount, ii, jj; bool NotFound; @@ -457,15 +461,15 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindSchematicItem( NotFound = TRUE; StartCount = 0; - EDA_ScreenList ScreenList( NULL ); + EDA_SheetList SheetList( NULL ); - Screen = ScreenList.GetFirst(); + Sheet = SheetList.GetFirst(); if( !Find_in_hierarchy ) - Screen = (SCH_SCREEN*) m_CurrentScreen; + Sheet = m_CurrentSheet; - for( ; Screen != NULL; Screen = ScreenList.GetNext() ) + for( ; Sheet != NULL; Sheet = SheetList.GetNext() ) { - DrawList = Screen->EEDrawList; + DrawList = Sheet->LastDrawList(); while( DrawList ) { switch( DrawList->Type() ) @@ -473,7 +477,7 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindSchematicItem( case DRAW_LIB_ITEM_STRUCT_TYPE: EDA_SchComponentStruct * pSch; pSch = (EDA_SchComponentStruct*) DrawList; - if( WildCompareString( WildText, pSch->m_Field[REFERENCE].m_Text, FALSE ) ) + if( WildCompareString( WildText, pSch->GetRef(Sheet), FALSE ) ) { NotFound = FALSE; pos = pSch->m_Field[REFERENCE].m_Pos; @@ -488,6 +492,7 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindSchematicItem( case DRAW_LABEL_STRUCT_TYPE: case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: case DRAW_TEXT_STRUCT_TYPE: DrawTextStruct * pDraw; pDraw = (DrawTextStruct*) DrawList; @@ -504,9 +509,9 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindSchematicItem( if( NotFound == FALSE ) /* Item found ! */ { - if( FirstScreen == NULL ) /* First Item found */ + if( FirstSheet == NULL ) /* First Item found */ { - FirstScreen = Screen; + FirstSheet = Sheet; firstpos = pos; FirstStruct = DrawList; } @@ -535,10 +540,10 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindSchematicItem( break; } - if( NotFound && FirstScreen ) + if( NotFound && FirstSheet ) { NotFound = FALSE; - Screen = FirstScreen; + Sheet = FirstSheet; Struct = FirstStruct; pos = firstpos; s_ItemsCount = 1; @@ -546,10 +551,12 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindSchematicItem( if( NotFound == FALSE ) { - if( Screen != GetScreen() ) + if( Sheet != GetSheet() ) { - Screen->SetZoom( GetScreen()->GetZoom() ); - m_CurrentScreen = ActiveScreen = Screen; + Sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() ); + *m_CurrentSheet = *Sheet; + ActiveScreen = m_CurrentSheet->LastScreen(); + m_CurrentSheet->UpdateAllScreenReferences(); DoCenterAndRedraw = TRUE; } @@ -570,18 +577,18 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindSchematicItem( pos.y = jj + pSch->m_Pos.y; } - old_cursor_position = Screen->m_Curseur; - Screen->m_Curseur = pos; + old_cursor_position = Sheet->LastScreen()->m_Curseur; + Sheet->LastScreen()->m_Curseur = pos; curpos = DrawPanel->CursorScreenPosition(); DrawPanel->GetViewStart( - &m_CurrentScreen->m_StartVisu.x, - &m_CurrentScreen->m_StartVisu.y ); + &( GetScreen()->m_StartVisu.x ), + &( GetScreen()->m_StartVisu.y )); // calcul des coord curseur avec origine = screen - curpos.x -= m_CurrentScreen->m_StartVisu.x; - curpos.y -= m_CurrentScreen->m_StartVisu.y; + curpos.x -= m_CurrentSheet->LastScreen()->m_StartVisu.x; + curpos.y -= m_CurrentSheet->LastScreen()->m_StartVisu.y; /* Il y a peut-etre necessite de recadrer le dessin: */ #define MARGIN 30 @@ -599,18 +606,18 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindSchematicItem( DrawPanel->PrepareGraphicContext( &dc ); - EXCHG( old_cursor_position, Screen->m_Curseur ); + EXCHG( old_cursor_position, Sheet->LastScreen()->m_Curseur ); DrawPanel->CursorOff( &dc ); if( mouseWarp ) GRMouseWarp( DrawPanel, curpos ); - EXCHG( old_cursor_position, Screen->m_Curseur ); + EXCHG( old_cursor_position, Sheet->LastScreen()->m_Curseur ); DrawPanel->CursorOn( &dc ); } - msg = WildText + _( " Found in " ) + Screen->m_FileName; + msg = WildText + _( " Found in " ) + Sheet->Last()->m_SheetName; Affiche_Message( msg ); } else diff --git a/eeschema/general.h b/eeschema/general.h index a42bb03f5b..34c85983ad 100644 --- a/eeschema/general.h +++ b/eeschema/general.h @@ -72,6 +72,7 @@ typedef enum { LAYER_JUNCTION, LAYER_LOCLABEL, LAYER_GLOBLABEL, + LAYER_HIERLABEL, LAYER_PINFUN, LAYER_PINNUM, LAYER_PINNAM, @@ -147,7 +148,7 @@ extern int g_HVLines; eda_global int g_PlotPSColorOpt; // True = plot postcript color (see plotps.cpp) -// Gestion de diverses variables, options... devant etre mémorisées mais +// Gestion de diverses variables, options... devant etre m�moris�es mais // Remises a 0 lors d'un rechargement de projetc struct EESchemaVariables { @@ -164,7 +165,7 @@ eda_global int g_PrintFillMask; /* pour les options "FILL", eda_global wxString g_CurrentViewLibraryName; /* nom de la librairie en cours d'examen */ eda_global wxString g_CurrentViewComponentName; /* nom du le composant en cours d'examen */ eda_global int g_ViewConvert; /* Vue normal / convert */ -eda_global int g_ViewUnit; /* unité a afficher (A, B ..) */ +eda_global int g_ViewUnit; /* unit� a afficher (A, B ..) */ /* Variables globales pour Schematic Edit */ eda_global int g_DefaultTextLabelSize @@ -218,7 +219,8 @@ struct HPGL_Pen_Descr_Struct eda_global HPGL_Pen_Descr_Struct g_HPGL_Pen_Descr; /* Ecrans usuels */ -eda_global SCH_SCREEN * ScreenSch; +//eda_global SCH_SCREEN * ScreenSch; +eda_global DrawSheetStruct* g_RootSheet; eda_global SCH_SCREEN * ScreenLib; /*************************************/ @@ -253,7 +255,7 @@ eda_global wxString g_NetListerCommandLine; // ligne de commande pour l'appel au eda_global LayerStruct g_LayerDescr; /* couleurs des couches */ eda_global bool g_EditPinByPinIsOn /* bool: TRUE si edition des pins pin a pin au lieu */ -#ifdef MAIN /* de l'edition simultanée des pins de meme coordonnées */ +#ifdef MAIN /* de l'edition simultan�e des pins de meme coordonn�es */ = FALSE #endif ; diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index d5f19e9f23..8329dbcb45 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -178,11 +178,11 @@ EDA_SchComponentStruct* WinEDA_SchematicFrame::Load_Component( wxDC* DC, DrawPanel->ManageCurseur = ShowWhileMoving; DrawPanel->ForceCloseManageCurseur = ExitPlaceCmp; - DrawLibItem = new EDA_SchComponentStruct( m_CurrentScreen->m_Curseur ); + DrawLibItem = new EDA_SchComponentStruct( GetScreen()->m_Curseur ); DrawLibItem->m_Multi = 1;/* Selection de l'unite 1 dans le boitier */ DrawLibItem->m_Convert = 1; DrawLibItem->m_ChipName = Name; - DrawLibItem->m_TimeStamp = GetTimeStamp(); + DrawLibItem->m_TimeStamp = GetTimeStamp(); DrawLibItem->m_Flags = IS_NEW | IS_MOVED; /* Init champ Valeur */ @@ -209,7 +209,7 @@ EDA_SchComponentStruct* WinEDA_SchematicFrame::Load_Component( wxDC* DC, Entry->m_Prefix.m_Pos.y + DrawLibItem->m_Pos.y; DrawLibItem->m_Field[REFERENCE].m_Orient = Entry->m_Prefix.m_Orient; DrawLibItem->m_Field[REFERENCE].m_Size = Entry->m_Prefix.m_Size; - DrawLibItem->m_Field[REFERENCE].m_Text = msg; + DrawLibItem->m_PrefixString = Entry->m_Prefix.m_Text; DrawLibItem->m_Field[REFERENCE].m_Attributs = Entry->m_Prefix.m_Attributs; DrawLibItem->m_Field[REFERENCE].m_HJustify = Entry->m_Prefix.m_HJustify; DrawLibItem->m_Field[REFERENCE].m_VJustify = Entry->m_Prefix.m_VJustify; @@ -253,14 +253,14 @@ static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) wxPoint move_vector; EDA_SchComponentStruct* DrawLibItem = (EDA_SchComponentStruct*) - panel->m_Parent->m_CurrentScreen->GetCurItem(); + panel->m_Parent->GetScreen()->GetCurItem(); /* Effacement du composant */ if( erase ) DrawStructsInGhost( panel, DC, DrawLibItem, 0, 0 ); - move_vector.x = panel->m_Parent->m_CurrentScreen->m_Curseur.x - DrawLibItem->m_Pos.x; - move_vector.y = panel->m_Parent->m_CurrentScreen->m_Curseur.y - DrawLibItem->m_Pos.y; + move_vector.x = panel->m_Parent->GetScreen()->m_Curseur.x - DrawLibItem->m_Pos.x; + move_vector.y = panel->m_Parent->GetScreen()->m_Curseur.y - DrawLibItem->m_Pos.y; MoveOneStruct( DrawLibItem, move_vector ); DrawStructsInGhost( panel, DC, DrawLibItem, 0, 0 ); @@ -301,7 +301,7 @@ void WinEDA_SchematicFrame::CmpRotationMiroir( DrawPanel->CursorOn( DC ); } - TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + TestDanglingEnds( GetScreen()->EEDrawList, DC ); GetScreen()->SetModify(); } @@ -314,12 +314,12 @@ static void ExitPlaceCmp( WinEDA_DrawPanel* Panel, wxDC* DC ) */ { EDA_SchComponentStruct* DrawLibItem = (EDA_SchComponentStruct*) - Panel->m_Parent->m_CurrentScreen->GetCurItem(); + Panel->m_Parent->GetScreen()->GetCurItem(); if( DrawLibItem->m_Flags & IS_NEW ) /* Nouveau Placement en cours, on l'efface */ { DrawStructsInGhost( Panel, DC, DrawLibItem, 0, 0 ); - delete DrawLibItem; + SAFE_DELETE( DrawLibItem ); } else if( DrawLibItem ) /* Deplacement ancien composant en cours */ { @@ -338,7 +338,7 @@ static void ExitPlaceCmp( WinEDA_DrawPanel* Panel, wxDC* DC ) DrawLibItem->m_Flags = 0; Panel->ManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL; - Panel->m_Parent->m_CurrentScreen->SetCurItem( NULL ); + Panel->m_Parent->GetScreen()->SetCurItem( NULL ); } @@ -385,7 +385,7 @@ void WinEDA_SchematicFrame::SelPartUnit( EDA_SchComponentStruct* DrawComponent, else DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); - TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + TestDanglingEnds( GetScreen()->EEDrawList, DC ); GetScreen()->SetModify(); } @@ -426,7 +426,7 @@ void WinEDA_SchematicFrame::ConvertPart( EDA_SchComponentStruct* DrawComponent, else DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); - TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + TestDanglingEnds( GetScreen()->EEDrawList, DC ); GetScreen()->SetModify(); } @@ -471,18 +471,19 @@ void WinEDA_SchematicFrame::StartMovePart( EDA_SchComponentStruct* Component, if( Component->m_Flags == 0 ) { - if( g_ItemToUndoCopy ) - delete g_ItemToUndoCopy; + if( g_ItemToUndoCopy ){ + SAFE_DELETE( g_ItemToUndoCopy ); + } g_ItemToUndoCopy = Component->GenCopy(); } DrawPanel->CursorOff( DC ); - m_CurrentScreen->m_Curseur = Component->m_Pos; + GetScreen()->m_Curseur = Component->m_Pos; DrawPanel->MouseToCursorSchema(); DrawPanel->ManageCurseur = ShowWhileMoving; DrawPanel->ForceCloseManageCurseur = ExitPlaceCmp; - m_CurrentScreen->SetCurItem( Component ); + GetScreen()->SetCurItem( Component ); OldPos = Component->m_Pos; memcpy( OldTransMat, Component->m_Transform, sizeof(OldTransMat) ); diff --git a/eeschema/hierarch.cpp b/eeschema/hierarch.cpp index 41463e389d..948282d312 100644 --- a/eeschema/hierarch.cpp +++ b/eeschema/hierarch.cpp @@ -21,8 +21,7 @@ #include "../bitmaps/treensel.xpm" -static void InstallScreenFromSheet(WinEDA_SchematicFrame * frame, - DrawSheetStruct * Sheet ); +static void UpdateScreenFromSheet(WinEDA_SchematicFrame * frame); enum { ID_TREECTRL_HIERARCHY = 1600 @@ -31,16 +30,16 @@ enum { class WinEDA_HierFrame; -/* Cette classe permet de memoriser la feuille (sheet) associée a l'item +/* Cette classe permet de memoriser la feuille (sheet) associ�e a l'item pour l'arbre de hierarchie */ class TreeItemData: public wxTreeItemData { public: - DrawSheetStruct * Sheet; - TreeItemData(DrawSheetStruct * sheet) :wxTreeItemData() - { - Sheet = sheet; - } + DrawSheetList m_SheetList; + TreeItemData(DrawSheetList sheet) :wxTreeItemData() + { + m_SheetList = sheet; + } }; /* Classe de l'arbre de hierarchie */ @@ -82,7 +81,7 @@ class WinEDA_HierFrame : public wxDialog public: WinEDA_SchematicFrame * m_Parent; WinEDA_Tree * m_Tree; - int nbsheets; + int m_nbsheets; wxDC * m_DC; private: @@ -91,8 +90,7 @@ private: public: WinEDA_HierFrame(WinEDA_SchematicFrame *parent, wxDC * DC, const wxPoint& pos); - void BuildSheetList(EDA_BaseStruct * DrawStruct, - wxTreeItemId * previousmenu); + void BuildSheetList(DrawSheetList * list, wxTreeItemId * previousmenu); ~WinEDA_HierFrame(); void OnSelect(wxTreeEvent& event); @@ -123,17 +121,19 @@ WinEDA_HierFrame::WinEDA_HierFrame(WinEDA_SchematicFrame *parent, wxDC * DC, wxDialog(parent, -1, _("Navigator"), pos, wxSize(110,50), DIALOG_STYLE) { -wxTreeItemId cellule; + wxTreeItemId cellule; m_Parent = parent; m_DC = DC; m_Tree = new WinEDA_Tree(this); - nbsheets = 1; + m_nbsheets = 1; cellule = m_Tree->AddRoot(_("Root"), 0, 1); m_Tree->SetItemBold(cellule, TRUE); - m_Tree->SetItemData( cellule, new TreeItemData(NULL) ); + DrawSheetList list; + list.Push(g_RootSheet); + m_Tree->SetItemData( cellule, new TreeItemData(list) ); wxRect itemrect; #ifdef __UNIX__ @@ -145,20 +145,18 @@ wxRect itemrect; m_TreeSize.x = itemrect.GetWidth() + 10; m_TreeSize.y = 20; - if (ScreenSch == m_Parent->m_CurrentScreen ) - { - m_Tree->SelectItem(cellule); - } + if( m_Parent->GetSheet()->Last() == g_RootSheet ) + m_Tree->SelectItem(cellule); //root. maxposx = 15; - BuildSheetList(ScreenSch->EEDrawList, &cellule); + BuildSheetList(&list, &cellule); - if ( nbsheets > 1) + if ( m_nbsheets > 1) { m_Tree->Expand(cellule); // Reajustage de la taille de la frame a une valeur optimale - m_TreeSize.y += nbsheets * itemrect.GetHeight(); + m_TreeSize.y += m_nbsheets * itemrect.GetHeight(); m_TreeSize.x = MIN(m_TreeSize.x, 250); m_TreeSize.y = MIN( m_TreeSize.y, 350); SetClientSize(m_TreeSize); @@ -179,7 +177,7 @@ void WinEDA_HierFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) } /********************************************************************/ -void WinEDA_HierFrame::BuildSheetList(EDA_BaseStruct * DrawStruct, +void WinEDA_HierFrame::BuildSheetList(DrawSheetList* list, wxTreeItemId * previousmenu) /********************************************************************/ /* Routine de creation de l'arbre de navigation dans la hierarchy @@ -188,33 +186,27 @@ schematique */ { wxTreeItemId menu; -SCH_SCREEN * Screen; - if( nbsheets > NB_MAX_SHEET ) - { - if( nbsheets == (NB_MAX_SHEET + 1) ) - { + if( m_nbsheets > NB_MAX_SHEET ){ + if( m_nbsheets == (NB_MAX_SHEET + 1) ){ wxString msg; msg << wxT("BuildSheetList: Error: nbsheets > ") << NB_MAX_SHEET; DisplayError(this, msg); - nbsheets++; + m_nbsheets++; } return; } - maxposx += m_Tree->GetIndent(); - - while( DrawStruct ) - { - if(DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE ) - { - #define STRUCT ((DrawSheetStruct*)DrawStruct) - nbsheets++; + maxposx += m_Tree->GetIndent(); + EDA_BaseStruct* bs = list->LastDrawList(); + while(bs && m_nbsheets < NB_MAX_SHEET){ + if(bs->Type() == DRAW_SHEET_STRUCT_TYPE){ + DrawSheetStruct* ss = (DrawSheetStruct*)bs; + m_nbsheets++; menu = m_Tree->AppendItem(*previousmenu, - STRUCT->m_SheetName, 0 , 1 ); - m_Tree->SetItemData( menu, new TreeItemData(STRUCT) ); -// m_Tree->SetItemFont( menu, *StdFont); - + ss->m_SheetName, 0 , 1 ); + list->Push(ss); + m_Tree->SetItemData( menu, new TreeItemData(*list) ); int ll = m_Tree->GetItemText(menu).Len(); #ifdef __WINDOWS__ ll *= 9; // * char width @@ -224,27 +216,15 @@ SCH_SCREEN * Screen; ll += maxposx + 20; m_TreeSize.x = MAX(m_TreeSize.x, ll); m_TreeSize.y += 1; - - Screen = (SCH_SCREEN*) DrawStruct; - if (Screen == m_Parent->m_CurrentScreen ) - { + if ( *list == *(m_Parent->GetSheet()) ){ m_Tree->EnsureVisible(menu); m_Tree->SelectItem(menu); } - - /* Examen des sous - hierarchies */ - if(Screen) - { - int oldnbsheets = nbsheets; - BuildSheetList(Screen->EEDrawList,&menu); - if( oldnbsheets != nbsheets ) - { - m_Tree->SetItemBold(menu, TRUE); - m_Tree->Expand(menu); - } - } + BuildSheetList(list, &menu); + m_Tree->Expand(menu); + list->Pop(); } - DrawStruct = DrawStruct->Pnext; + bs = bs->Pnext; } maxposx -= m_Tree->GetIndent(); } @@ -254,63 +234,37 @@ SCH_SCREEN * Screen; void WinEDA_HierFrame::OnSelect(wxTreeEvent& event) /***************************************************/ /* appelee sur un double-click de la souris pour la selection d'un item: - Selectionne et affiche l'ecran demandé + Selectionne et affiche l'ecran demand� */ { -DrawSheetStruct * Sheet; - wxTreeItemId ItemSel = m_Tree->GetSelection(); - Sheet = ((TreeItemData*)(m_Tree->GetItemData(ItemSel)))->Sheet; - InstallScreenFromSheet(m_Parent, Sheet); + *(m_Parent->m_CurrentSheet) = + ((TreeItemData*)(m_Tree->GetItemData(ItemSel)))->m_SheetList; + wxString path = m_Parent->m_CurrentSheet->PathHumanReadable(); + printf("changing to sheet %s\n", CONV_TO_UTF8(path)); + UpdateScreenFromSheet(m_Parent); Close(TRUE); } - /******************************************************/ -void WinEDA_SchematicFrame::InstallPreviousScreen() +void WinEDA_SchematicFrame::InstallPreviousSheet() /******************************************************/ /* Set the current screen to display the parent sheet of the current displayed sheet */ { -SCH_SCREEN * Screen; -EDA_BaseStruct * DrawStruct; - - if( m_CurrentScreen == ScreenSch ) return; + if( m_CurrentSheet->Last() == g_RootSheet ) return; g_ItemToRepeat = NULL; MsgPanel->EraseMsgBox(); - - /* Build the screen list */ - EDA_ScreenList ScreenList(NULL); - - /* search the list which have the current scheet in EEDrawList */ - for ( Screen = ScreenList.GetFirst(); Screen != NULL; Screen = ScreenList.GetNext() ) - { - DrawStruct = Screen->EEDrawList; - while (DrawStruct != NULL ) - { - if ( DrawStruct == m_CurrentScreen ) break; // Found ! - DrawStruct = DrawStruct->Pnext; - } - if ( DrawStruct ) break; - } - - if ( Screen == NULL ) - { - DisplayError( this, wxT("InstallPreviousScreen() Error: Screen not found")); + //make a copy for testing purposes. + DrawSheetList listtemp = *m_CurrentSheet; + listtemp.Pop(); + if ( listtemp.LastScreen() == NULL ){ + DisplayError( this, wxT("InstallPreviousScreen() Error: Sheet not found")); return; } - m_CurrentScreen = ActiveScreen = Screen; - DrawPanel->m_CanStartBlock = -1; - DrawPanel->SetScrollbars( DrawPanel->m_Scroll_unit, - DrawPanel->m_Scroll_unit, - m_CurrentScreen->m_ScrollbarNumber.x, - m_CurrentScreen->m_ScrollbarNumber.y, - m_CurrentScreen->m_ScrollbarPos.x, - m_CurrentScreen->m_ScrollbarPos.y,TRUE); - - ReDrawPanel(); - DrawPanel->MouseToCursorSchema(); + m_CurrentSheet->Pop(); + UpdateScreenFromSheet(this); } /*********************************************************************/ @@ -318,22 +272,23 @@ void WinEDA_SchematicFrame::InstallNextScreen(DrawSheetStruct * Sheet) /*********************************************************************/ /* Routine d'installation de l'ecran correspondant au symbole Sheet pointe par la souris + have to be careful here because the DrawSheetStructs within the EEDrawList + don't actually have a valid m_s (on purpose -- you need the m_SubSheet hierarchy + to maintain path info (well, this is but one way to maintain path info..) */ { if( Sheet == NULL) { DisplayError(this,wxT("InstallNextScreen() error")); return; } + m_CurrentSheet->Push(Sheet); g_ItemToRepeat = NULL; MsgPanel->EraseMsgBox(); - InstallScreenFromSheet(this, Sheet ); + UpdateScreenFromSheet(this); } - - /**************************************************************/ -static void InstallScreenFromSheet(WinEDA_SchematicFrame * frame, - DrawSheetStruct * Sheet ) +static void UpdateScreenFromSheet(WinEDA_SchematicFrame * frame) /**************************************************************/ /* Recherche et installe de l'ecran relatif au sheet symbole Sheet. @@ -341,36 +296,34 @@ static void InstallScreenFromSheet(WinEDA_SchematicFrame * frame, */ { -SCH_SCREEN * NewScreen; -SCH_SCREEN * oldscreen = (SCH_SCREEN*) frame->m_CurrentScreen; + SCH_SCREEN * NewScreen; + //SCH_SCREEN * oldscreen = frame->GetScreen(); what is oldscreen used for? - if( Sheet == NULL ) NewScreen = ScreenSch; - else NewScreen = Sheet; + NewScreen = frame->m_CurrentSheet->LastScreen(); + if(!NewScreen) + NewScreen = g_RootSheet->m_s; + + // Reinit des parametres d'affichage du nouvel ecran + // assumes m_CurrentSheet has already been updated. + frame->MsgPanel->EraseMsgBox(); + frame->DrawPanel->SetScrollbars( frame->DrawPanel->m_Scroll_unit, + frame->DrawPanel->m_Scroll_unit, + NewScreen->m_ScrollbarNumber.x, + NewScreen->m_ScrollbarNumber.y, + NewScreen->m_ScrollbarPos.x, + NewScreen->m_ScrollbarPos.y,TRUE); - frame->m_CurrentScreen = ActiveScreen = NewScreen; - if ( oldscreen != frame->m_CurrentScreen ) - { // Reinit des parametres d'affichage du nouvel ecran - frame->MsgPanel->EraseMsgBox(); - frame->DrawPanel->SetScrollbars( frame->DrawPanel->m_Scroll_unit, - frame->DrawPanel->m_Scroll_unit, - NewScreen->m_ScrollbarNumber.x, - NewScreen->m_ScrollbarNumber.y, - NewScreen->m_ScrollbarPos.x, - NewScreen->m_ScrollbarPos.y,TRUE); - - frame->DrawPanel->m_CanStartBlock = -1; - if ( NewScreen->m_FirstRedraw ) - { - NewScreen->m_FirstRedraw = FALSE; - frame->Zoom_Automatique(TRUE); - } - else - { - frame->ReDrawPanel(); - frame->DrawPanel->MouseToCursorSchema(); - } + //update the References + frame->m_CurrentSheet->UpdateAllScreenReferences(); + frame->DrawPanel->m_CanStartBlock = -1; + if ( NewScreen->m_FirstRedraw ){ + NewScreen->m_FirstRedraw = FALSE; + frame->Zoom_Automatique(TRUE); + }else{ + frame->ReDrawPanel(); + frame->DrawPanel->MouseToCursorSchema(); } - + ActiveScreen = frame->m_CurrentSheet->LastScreen(); return; } diff --git a/eeschema/hotkeys.cpp b/eeschema/hotkeys.cpp index a0b263fe24..39ec760f5c 100644 --- a/eeschema/hotkeys.cpp +++ b/eeschema/hotkeys.cpp @@ -145,14 +145,14 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, * Commands are case insensitive */ { - bool ItemInEdit = m_CurrentScreen->GetCurItem() - && m_CurrentScreen->GetCurItem()->m_Flags; + bool ItemInEdit = GetScreen()->GetCurItem() + && GetScreen()->GetCurItem()->m_Flags; bool RefreshToolBar = FALSE; // We must refresh tool bar when the undo/redo tool state is modified if( hotkey == 0 ) return; - wxPoint MousePos = m_CurrentScreen->m_MousePosition; + wxPoint MousePos = GetScreen()->m_MousePosition; // Remap the control key Ctrl A (0x01) to GR_KB_CTRL + 'A' (easier to handle...) if( (hotkey & GR_KB_CTRL) != 0 ) @@ -179,7 +179,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, break; case HK_RESET_LOCAL_COORD: /* Reset the relative coord */ - m_CurrentScreen->m_O_Curseur = m_CurrentScreen->m_Curseur; + GetScreen()->m_O_Curseur = GetScreen()->m_Curseur; break; case HK_ZOOM_IN: @@ -217,9 +217,9 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, if( ItemInEdit ) break; RefreshToolBar = LocateAndDeleteItem( this, DC ); - m_CurrentScreen->SetModify(); - m_CurrentScreen->SetCurItem( NULL ); - TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + GetScreen()->SetModify(); + GetScreen()->SetCurItem( NULL ); + TestDanglingEnds( GetScreen()->EEDrawList, DC ); break; case HK_REPEAT_LAST: @@ -276,11 +276,11 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, if( DrawStruct == NULL ) { DrawStruct = PickStruct( GetScreen()->m_Curseur, - GetScreen()->EEDrawList, LIBITEM | TEXTITEM | LABELITEM ); + GetScreen(), LIBITEM | TEXTITEM | LABELITEM ); if( DrawStruct == NULL ) break; if( DrawStruct->Type() == DRAW_LIB_ITEM_STRUCT_TYPE ) - DrawStruct = LocateSmallestComponent( GetScreen() ); + DrawStruct = LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ); if( DrawStruct == NULL ) break; } @@ -301,6 +301,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, case DRAW_TEXT_STRUCT_TYPE: case DRAW_LABEL_STRUCT_TYPE: case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: if( DrawStruct->m_Flags == 0 ) { SaveCopyInUndoList( DrawStruct, IS_CHANGED ); @@ -317,7 +318,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, case HK_MIRROR_Y_COMPONENT: // Mirror Y (Component) if( DrawStruct == NULL ) - DrawStruct = LocateSmallestComponent( GetScreen() ); + DrawStruct = LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ); if( DrawStruct ) { if( DrawStruct->m_Flags == 0 ) @@ -332,7 +333,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, case HK_MIRROR_X_COMPONENT: // Mirror X (Component) if( DrawStruct == NULL ) - DrawStruct = LocateSmallestComponent( GetScreen() ); + DrawStruct = LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ); if( DrawStruct ) { if( DrawStruct->m_Flags == 0 ) @@ -347,7 +348,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, case HK_ORIENT_NORMAL_COMPONENT: // Orient 0, no mirror (Component) if( DrawStruct == NULL ) - DrawStruct = LocateSmallestComponent( GetScreen() ); + DrawStruct = LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ); if( DrawStruct ) { if( DrawStruct->m_Flags == 0 ) @@ -357,7 +358,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, } CmpRotationMiroir( (EDA_SchComponentStruct*) DrawStruct, DC, CMP_NORMAL ); - TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + TestDanglingEnds( (SCH_SCREEN*)GetScreen()->EEDrawList, DC ); } break; @@ -366,10 +367,10 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, if( ItemInEdit ) break; if( DrawStruct == NULL ) - DrawStruct = LocateSmallestComponent( GetScreen() ); + DrawStruct = LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ); if( DrawStruct && (DrawStruct->m_Flags ==0) ) { - m_CurrentScreen->SetCurItem( DrawStruct ); + ((SCH_SCREEN*)GetScreen())->SetCurItem( DrawStruct ); wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, HK_Descr->m_IdMenuEvent ); wxPostEvent( this, event ); @@ -379,7 +380,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, if( ItemInEdit ) break; if( DrawStruct == NULL ) - DrawStruct = LocateSmallestComponent( GetScreen() ); + DrawStruct = LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ); if(DrawStruct) { EditComponentValue( @@ -391,7 +392,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, if( ItemInEdit ) break; if( DrawStruct == NULL ) - DrawStruct = LocateSmallestComponent( GetScreen() ); + DrawStruct = LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ); if(DrawStruct) { EditComponentFootprint( @@ -414,14 +415,14 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, * Commands are case insensitive */ { - bool ItemInEdit = m_CurrentScreen->GetCurItem() - && m_CurrentScreen->GetCurItem()->m_Flags; + bool ItemInEdit = GetScreen()->GetCurItem() + && GetScreen()->GetCurItem()->m_Flags; bool RefreshToolBar = FALSE; // We must refresh tool bar when the undo/redo tool state is modified if( hotkey == 0 ) return; - wxPoint MousePos = m_CurrentScreen->m_MousePosition; + wxPoint MousePos = GetScreen()->m_MousePosition; LibEDA_BaseStruct* DrawEntry = LocateItemUsingCursor(); @@ -448,7 +449,7 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, break; case HK_RESET_LOCAL_COORD: /* Reset the relative coord */ - m_CurrentScreen->m_O_Curseur = m_CurrentScreen->m_Curseur; + GetScreen()->m_O_Curseur = GetScreen()->m_Curseur; break; case HK_ZOOM_IN: diff --git a/eeschema/libarch.cpp b/eeschema/libarch.cpp index 41080dcd1c..ecb9d18445 100644 --- a/eeschema/libarch.cpp +++ b/eeschema/libarch.cpp @@ -27,15 +27,15 @@ static int TriListEntry(EDA_LibComponentStruct **Objet1, bool LibArchive(wxWindow * frame, const wxString & ArchFullFileName) /*******************************************************************/ /* -Creation du fichier librairie contenant tous les composants utilisés dans +Creation du fichier librairie contenant tous les composants utilis�s dans le projet en cours -retourne TRUE si fichier créé +retourne TRUE si fichier cr�� */ { wxString DocFileName, msg; char Line[256]; FILE *ArchiveFile, *DocFile; -EDA_BaseStruct ** ListStruct; +ListComponent * List; EDA_LibComponentStruct ** ListEntry, *Entry; int ii, NbItems; const wxChar * Text; @@ -45,12 +45,11 @@ const wxChar * Text; NbItems = GenListeCmp(NULL ); // Comptage des composants if ( NbItems == 0 ) return FALSE; - ListStruct = (EDA_BaseStruct **) - MyZMalloc( NbItems * sizeof(EDA_BaseStruct **) ); - if (ListStruct == NULL ) return FALSE; + List = (ListComponent *) MyZMalloc( NbItems * sizeof( ListComponent ) ); + if (List == NULL ) return FALSE; /* Calcul de la liste des composants */ - GenListeCmp(ListStruct); + GenListeCmp(List); /* Calcul de la liste des Entrees de librairie et Remplacement des alias par les composants "Root" */ @@ -60,12 +59,12 @@ const wxChar * Text; for ( ii = 0; ii < NbItems; ii++ ) { - Text = ( (EDA_SchComponentStruct*)ListStruct[ii])->m_ChipName.GetData(); + Text = List[ii].m_Comp->m_ChipName.GetData(); Entry = FindLibPart(Text, wxEmptyString, FIND_ROOT); - ListEntry[ii] = Entry; // = NULL si Composant non trouvé en librairie + ListEntry[ii] = Entry; // = NULL si Composant non trouv� en librairie } - MyFree(ListStruct); + MyFree(List); qsort( ListEntry, NbItems, sizeof(EDA_LibComponentStruct *), (int(*)(const void*, const void*))TriListEntry); @@ -95,7 +94,7 @@ const wxChar * Text; /* Generation des elements */ for ( ii = 0; ii < NbItems; ii++ ) { - if ( ListEntry[ii] == NULL ) // Composant non trouvé en librairie + if ( ListEntry[ii] == NULL ) // Composant non trouv� en librairie { continue; } diff --git a/eeschema/libclass.cpp b/eeschema/libclass.cpp index a1fc4bc660..08f8d76fde 100644 --- a/eeschema/libclass.cpp +++ b/eeschema/libclass.cpp @@ -41,7 +41,7 @@ void FreeLibraryEntry( LibCmpEntry* Entry ) /* Used by PQFreeFunc() to delete all entries */ { - delete Entry; + SAFE_DELETE( Entry ); } @@ -197,7 +197,7 @@ EDA_LibComponentStruct::~EDA_LibComponentStruct() while( field ) { TempField = field; field = (LibDrawField*) field->Pnext; - delete TempField; + SAFE_DELETE( TempField ); } /* suppression des elements dependants */ @@ -205,7 +205,7 @@ EDA_LibComponentStruct::~EDA_LibComponentStruct() while( DrawItem ) { NextDrawItem = DrawItem->Next(); - delete DrawItem; + SAFE_DELETE( DrawItem ); DrawItem = NextDrawItem; } } diff --git a/eeschema/libedit.cpp b/eeschema/libedit.cpp index 479b295eab..dc05b57b0b 100644 --- a/eeschema/libedit.cpp +++ b/eeschema/libedit.cpp @@ -98,11 +98,10 @@ EDA_LibComponentStruct *LibEntry = NULL; ScreenLib->ClrModify(); CurrentDrawItem = NULL; - // Effacement ancien composant affiché + // Effacement ancien composant affich� if( CurrentLibEntry) { - delete CurrentLibEntry; - CurrentLibEntry = NULL; + SAFE_DELETE( CurrentLibEntry ) ; } /* Chargement du composant */ @@ -159,7 +158,7 @@ const wxChar * CmpName, *RootName = NULL; CurrentAliasName = CmpName; } - if( CurrentLibEntry) delete CurrentLibEntry; + if( CurrentLibEntry){ SAFE_DELETE( CurrentLibEntry ) ;} CurrentLibEntry = CopyLibEntryStruct(this, LibEntry); CurrentUnit = 1; CurrentConvert = 1; @@ -180,7 +179,7 @@ void WinEDA_LibeditFrame::RedrawActiveWindow(wxDC * DC, bool EraseBg) /*********************************************************************/ /* Routine generale d'affichage a l'ecran du "PartLib" en cours d'edition */ { - if( m_CurrentScreen == NULL ) return; + if( GetScreen() == NULL ) return; ActiveScreen = GetScreen(); @@ -209,7 +208,7 @@ void WinEDA_LibeditFrame::RedrawActiveWindow(wxDC * DC, bool EraseBg) DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); // reaffichage lie au curseur } - m_CurrentScreen->ClrRefreshReq(); + GetScreen()->ClrRefreshReq(); DisplayLibInfos(); Affiche_Status_Box(); } @@ -260,7 +259,7 @@ void WinEDA_LibeditFrame::DisplayCmpDoc(const wxString & Name) /**************************************************************/ /* Affiche la documentation du composant selectionne -Utilisée lors de l'affichage de la liste des composants en librairie +Utilis�e lors de l'affichage de la liste des composants en librairie */ { LibCmpEntry * CmpEntry; @@ -400,8 +399,8 @@ int diag; NewStruct->m_Prefix.m_Text = wxT("U"); NewStruct->m_Prefix.m_Text.MakeUpper(); - // Effacement ancien composant affiché - if( CurrentLibEntry) delete CurrentLibEntry; + // Effacement ancien composant affich� + if( CurrentLibEntry){ SAFE_DELETE( CurrentLibEntry );} CurrentLibEntry = NewStruct; CurrentUnit = 1; CurrentConvert = 1; @@ -460,7 +459,7 @@ EDA_LibCmpAliasStruct * AliasEntry; /* Effacement memoire pour cet alias */ PQDelete( &Library->m_Entries, (void*) Entry ); - delete Entry; + SAFE_DELETE( Entry ); if( Library->m_NumOfParts > 0 ) CurrentLib->m_NumOfParts --; return; } @@ -469,7 +468,7 @@ EDA_LibCmpAliasStruct * AliasEntry; if( Entry->m_AliasList.GetCount() == 0) // Trivial case: no alias, we can safety delete e=this entry { PQDelete( &Library->m_Entries, Entry ); - delete Entry; + SAFE_DELETE( Entry ); if( Library->m_NumOfParts > 0 ) Library->m_NumOfParts --; return; } diff --git a/eeschema/libedit_onleftclick.cpp b/eeschema/libedit_onleftclick.cpp index 8cbb38069f..ce18c155f2 100644 --- a/eeschema/libedit_onleftclick.cpp +++ b/eeschema/libedit_onleftclick.cpp @@ -52,21 +52,21 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) } else { - DrawEntry = LocatePin( m_CurrentScreen->m_MousePosition, CurrentLibEntry, + DrawEntry = LocatePin( GetScreen()->m_MousePosition, CurrentLibEntry, CurrentUnit, CurrentConvert ); if( DrawEntry == NULL ) { - DrawEntry = LocateDrawItem( GetScreen(), GetScreen()->m_MousePosition, + DrawEntry = LocateDrawItem( (SCH_SCREEN*)GetScreen(), GetScreen()->m_MousePosition, CurrentLibEntry, CurrentUnit, CurrentConvert, LOCATE_ALL_DRAW_ITEM ); } if( DrawEntry == NULL ) - DrawEntry = LocatePin( m_CurrentScreen->m_Curseur, CurrentLibEntry, + DrawEntry = LocatePin( GetScreen()->m_Curseur, CurrentLibEntry, CurrentUnit, CurrentConvert ); if( DrawEntry == NULL ) { - DrawEntry = LocateDrawItem( GetScreen(), GetScreen()->m_Curseur, + DrawEntry = LocateDrawItem( (SCH_SCREEN*)GetScreen(), GetScreen()->m_Curseur, CurrentLibEntry, CurrentUnit, CurrentConvert, LOCATE_ALL_DRAW_ITEM ); } @@ -124,21 +124,23 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) break; case ID_LIBEDIT_DELETE_ITEM_BUTT: - DrawEntry = LocatePin( m_CurrentScreen->m_MousePosition, CurrentLibEntry, + DrawEntry = LocatePin( GetScreen()->m_MousePosition, CurrentLibEntry, CurrentUnit, CurrentConvert ); if( DrawEntry == NULL ) { - DrawEntry = LocateDrawItem( GetScreen(), m_CurrentScreen->m_MousePosition, + DrawEntry = LocateDrawItem( (SCH_SCREEN*)GetScreen(), + GetScreen()->m_MousePosition, CurrentLibEntry, CurrentUnit, CurrentConvert, LOCATE_ALL_DRAW_ITEM ); } if( DrawEntry == NULL ) - DrawEntry = LocatePin( m_CurrentScreen->m_Curseur, CurrentLibEntry, + DrawEntry = LocatePin( GetScreen()->m_Curseur, CurrentLibEntry, CurrentUnit, CurrentConvert ); if( DrawEntry == NULL ) { - DrawEntry = LocateDrawItem( GetScreen(), m_CurrentScreen->m_Curseur, + DrawEntry = LocateDrawItem( (SCH_SCREEN*)GetScreen(), + GetScreen()->m_Curseur, CurrentLibEntry, CurrentUnit, CurrentConvert, LOCATE_ALL_DRAW_ITEM ); } @@ -154,7 +156,7 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) else DeleteOneLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, DrawEntry, TRUE ); DrawEntry = NULL; - m_CurrentScreen->SetModify(); + GetScreen()->SetModify(); break; case ID_LIBEDIT_ANCHOR_ITEM_BUTT: @@ -177,8 +179,8 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) void WinEDA_LibeditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) /*************************************************************************/ -/* Appelé sur un double click: - * pour un élément editable (textes, composant): +/* Appel� sur un double click: + * pour un �l�ment editable (textes, composant): * appel de l'editeur correspondant. * pour une connexion en cours: * termine la connexion @@ -193,23 +195,23 @@ void WinEDA_LibeditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) if( !m_ID_current_state // Simple localisation des elements || (DrawEntry == NULL) || (DrawEntry->m_Flags == 0) ) { - DrawEntry = LocatePin( m_CurrentScreen->m_MousePosition, CurrentLibEntry, + DrawEntry = LocatePin( GetScreen()->m_MousePosition, CurrentLibEntry, CurrentUnit, CurrentConvert ); if( DrawEntry == NULL ) - DrawEntry = LocatePin( m_CurrentScreen->m_Curseur, CurrentLibEntry, + DrawEntry = LocatePin( GetScreen()->m_Curseur, CurrentLibEntry, CurrentUnit, CurrentConvert ); if( DrawEntry == NULL ) { - DrawEntry = CurrentDrawItem = LocateDrawItem( (SCH_SCREEN*) m_CurrentScreen, - m_CurrentScreen->m_MousePosition, + DrawEntry = CurrentDrawItem = LocateDrawItem( (SCH_SCREEN*) GetScreen(), + GetScreen()->m_MousePosition, CurrentLibEntry, CurrentUnit, CurrentConvert, LOCATE_ALL_DRAW_ITEM ); } if( DrawEntry == NULL ) { - DrawEntry = CurrentDrawItem = LocateDrawItem( (SCH_SCREEN*) m_CurrentScreen, - m_CurrentScreen->m_Curseur, + DrawEntry = CurrentDrawItem = LocateDrawItem( (SCH_SCREEN*) GetScreen(), + GetScreen()->m_Curseur, CurrentLibEntry, CurrentUnit, CurrentConvert, LOCATE_ALL_DRAW_ITEM ); @@ -247,7 +249,7 @@ void WinEDA_LibeditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) switch( DrawEntry->Type() ) { case COMPONENT_PIN_DRAW_TYPE: - if( DrawEntry->m_Flags == 0 ) // Item localisé et non en edition: placement commande move + if( DrawEntry->m_Flags == 0 ) // Item localis� et non en edition: placement commande move { InstallPineditFrame( this, DC, pos ); } diff --git a/eeschema/libedit_onrightclick.cpp b/eeschema/libedit_onrightclick.cpp index e4dc27797d..0ca330ff94 100644 --- a/eeschema/libedit_onrightclick.cpp +++ b/eeschema/libedit_onrightclick.cpp @@ -35,7 +35,7 @@ bool WinEDA_LibeditFrame::OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu /********************************************************************************/ { LibEDA_BaseStruct* DrawEntry = LocateItemUsingCursor(); -bool BlockActive = (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE); +bool BlockActive = (GetScreen()->BlockLocate.m_Command != BLOCK_IDLE); if ( CurrentLibEntry == NULL ) return true; diff --git a/eeschema/libedit_undo_redo.cpp b/eeschema/libedit_undo_redo.cpp index 1fbf133bb8..e7b311d617 100644 --- a/eeschema/libedit_undo_redo.cpp +++ b/eeschema/libedit_undo_redo.cpp @@ -33,7 +33,7 @@ EDA_LibComponentStruct * CopyItem; while ( GetScreen()->m_RedoList ) { item = GetScreen()->m_RedoList->Pnext; - delete GetScreen()->m_RedoList; + delete (GetScreen()->m_RedoList); GetScreen()->m_RedoList = item; } } diff --git a/eeschema/libfield.cpp b/eeschema/libfield.cpp index 1b764e41eb..4aaae497f5 100644 --- a/eeschema/libfield.cpp +++ b/eeschema/libfield.cpp @@ -35,10 +35,10 @@ static void ExitMoveField(WinEDA_DrawPanel * Panel, wxDC * DC) if(CurrentDrawItem == NULL) return; wxPoint curpos; - curpos = Panel->m_Parent->m_CurrentScreen->m_Curseur; - Panel->m_Parent->m_CurrentScreen->m_Curseur = StartCursor; + curpos = Panel->m_Parent->GetScreen()->m_Curseur; + Panel->m_Parent->GetScreen()->m_Curseur = StartCursor; ShowMoveField(Panel, DC, TRUE); - Panel->m_Parent->m_CurrentScreen->m_Curseur = curpos; + Panel->m_Parent->GetScreen()->m_Curseur = curpos; CurrentDrawItem->m_Flags = 0; CurrentDrawItem = NULL; @@ -61,13 +61,13 @@ wxPoint startPos; startPos.x = LastTextPosition.x; startPos.y = -LastTextPosition.y; DrawPanel->CursorOff(DC); - m_CurrentScreen->m_Curseur = startPos; + GetScreen()->m_Curseur = startPos; DrawPanel->MouseToCursorSchema(); DrawPanel->ManageCurseur = ShowMoveField; DrawPanel->ForceCloseManageCurseur = ExitMoveField; DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); - StartCursor = m_CurrentScreen->m_Curseur; + StartCursor = GetScreen()->m_Curseur; DrawPanel->CursorOn(DC); } @@ -165,7 +165,7 @@ int LineWidth = MAX(Field->m_Width, g_DrawMinimunLineWidth); DrawPanel->CursorOn(DC); - m_CurrentScreen->SetModify(); + GetScreen()->SetModify(); DrawPanel->ManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL; CurrentDrawItem = NULL; @@ -228,7 +228,7 @@ int LineWidth = MAX(Field->m_Width, g_DrawMinimunLineWidth); Field->m_Size, Field->m_HJustify, Field->m_VJustify, LineWidth); - m_CurrentScreen->SetModify(); + GetScreen()->SetModify(); if ( Field->m_FieldId == VALUE ) ReCreateHToolbar(); } @@ -245,7 +245,7 @@ int color; if( Field == NULL) return; - m_CurrentScreen->SetModify(); + GetScreen()->SetModify(); switch (Field->m_FieldId) { case REFERENCE: @@ -312,8 +312,8 @@ int hjustify, vjustify; else if ( vjustify == GR_TEXT_VJUSTIFY_BOTTOM ) y0 += dy; x1 = x0 + dx; y1 = y0 + dy; - if( (m_CurrentScreen->m_Curseur.x >= x0) && ( m_CurrentScreen->m_Curseur.x <= x1) && - (m_CurrentScreen->m_Curseur.y >= y0) && ( m_CurrentScreen->m_Curseur.y <= y1) ) + if( (GetScreen()->m_Curseur.x >= x0) && ( GetScreen()->m_Curseur.x <= x1) && + (GetScreen()->m_Curseur.y >= y0) && ( GetScreen()->m_Curseur.y <= y1) ) return &LibEntry->m_Name; /* Localisation du Prefix */ @@ -329,8 +329,8 @@ int hjustify, vjustify; else if ( vjustify == GR_TEXT_VJUSTIFY_BOTTOM ) y0 -= dy; x1 = x0 + dx; y1 = y0 + dy; - if( (m_CurrentScreen->m_Curseur.x >= x0) && ( m_CurrentScreen->m_Curseur.x <= x1) && - (m_CurrentScreen->m_Curseur.y >= y0) && ( m_CurrentScreen->m_Curseur.y <= y1) ) + if( (GetScreen()->m_Curseur.x >= x0) && ( GetScreen()->m_Curseur.x <= x1) && + (GetScreen()->m_Curseur.y >= y0) && ( GetScreen()->m_Curseur.y <= y1) ) return &LibEntry->m_Prefix; /* Localisation des autres fields */ @@ -349,8 +349,8 @@ int hjustify, vjustify; if ( vjustify == GR_TEXT_VJUSTIFY_CENTER ) y0 -= dy/2; else if ( vjustify == GR_TEXT_VJUSTIFY_BOTTOM ) y0 -= dy; x1 = x0 + dx; y1 = y0 + dy; - if( (m_CurrentScreen->m_Curseur.x >= x0) && ( m_CurrentScreen->m_Curseur.x <= x1) && - (m_CurrentScreen->m_Curseur.y >= y0) && ( m_CurrentScreen->m_Curseur.y <= y1) ) + if( (GetScreen()->m_Curseur.x >= x0) && ( GetScreen()->m_Curseur.x <= x1) && + (GetScreen()->m_Curseur.y >= y0) && ( GetScreen()->m_Curseur.y <= y1) ) return(Field); } @@ -367,16 +367,16 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::LocateItemUsingCursor() if ( (DrawEntry == NULL) || (DrawEntry->m_Flags == 0) ) { // Simple localisation des elements - DrawEntry = LocatePin(m_CurrentScreen->m_Curseur, CurrentLibEntry, CurrentUnit, CurrentConvert); + DrawEntry = LocatePin(GetScreen()->m_Curseur, CurrentLibEntry, CurrentUnit, CurrentConvert); if ( DrawEntry == NULL ) { - DrawEntry = CurrentDrawItem = LocateDrawItem(GetScreen(), + DrawEntry = CurrentDrawItem = LocateDrawItem((SCH_SCREEN*)GetScreen(), GetScreen()->m_MousePosition,CurrentLibEntry,CurrentUnit, CurrentConvert,LOCATE_ALL_DRAW_ITEM); } if ( DrawEntry == NULL ) { - DrawEntry = CurrentDrawItem = LocateDrawItem(GetScreen(), GetScreen()->m_Curseur, CurrentLibEntry,CurrentUnit, + DrawEntry = CurrentDrawItem = LocateDrawItem((SCH_SCREEN*)GetScreen(), GetScreen()->m_Curseur, CurrentLibEntry,CurrentUnit, CurrentConvert,LOCATE_ALL_DRAW_ITEM); } if ( DrawEntry == NULL ) diff --git a/eeschema/libframe.cpp b/eeschema/libframe.cpp index bad89bc33a..0fad8de8fd 100644 --- a/eeschema/libframe.cpp +++ b/eeschema/libframe.cpp @@ -53,7 +53,7 @@ EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE, EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, WinEDA_LibeditFrame::Process_Special_Functions ) -// PopUp Menus pour Zooms traités dans drawpanel.cpp +// PopUp Menus pour Zooms trait�s dans drawpanel.cpp END_EVENT_TABLE() @@ -90,7 +90,7 @@ WinEDA_LibeditFrame::~WinEDA_LibeditFrame() /**********************************************/ { m_Parent->m_LibeditFrame = NULL; - m_CurrentScreen = ScreenSch; + //m_CurrentScreen = ScreenSch; humm, is this needed? } @@ -100,14 +100,14 @@ void WinEDA_LibeditFrame::OnCloseWindow( wxCloseEvent& Event ) { LibraryStruct* Lib; - if( m_CurrentScreen->IsModify() ) + if( GetScreen()->IsModify() ) { if( !IsOK( this, _( "Component was modified!\nDiscard changes?" ) ) ) { Event.Veto(); return; } else - m_CurrentScreen->ClrModify(); + GetScreen()->ClrModify(); } for( Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext ) @@ -261,8 +261,8 @@ int WinEDA_LibeditFrame::BestZoom() } else { - dx = m_CurrentScreen->m_CurrentSheet->m_Size.x; - dy = m_CurrentScreen->m_CurrentSheet->m_Size.y; + dx = GetScreen()->m_CurrentSheetDesc->m_Size.x; + dy = GetScreen()->m_CurrentSheetDesc->m_Size.y; } size = DrawPanel->GetClientSize(); @@ -275,12 +275,12 @@ int WinEDA_LibeditFrame::BestZoom() if( CurrentLibEntry ) { - m_CurrentScreen->m_Curseur = BoundaryBox.Centre(); + GetScreen()->m_Curseur = BoundaryBox.Centre(); } else { - m_CurrentScreen->m_Curseur.x = 0; - m_CurrentScreen->m_Curseur.y = 0; + GetScreen()->m_Curseur.x = 0; + GetScreen()->m_Curseur.y = 0; } return bestzoom; @@ -303,7 +303,7 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event ) wxGetMousePosition( &pos.x, &pos.y ); pos.y += 20; - switch( id ) // Arret de la commande de déplacement en cours + switch( id ) // Arret de la commande de d�placement en cours { case ID_POPUP_LIBEDIT_END_CREATE_ITEM: case ID_POPUP_LIBEDIT_PIN_EDIT: @@ -339,7 +339,7 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event ) switch( id ) { case ID_LIBEDIT_SAVE_CURRENT_LIB: - if( m_CurrentScreen->IsModify() ) + if( GetScreen()->IsModify() ) { if( IsOK( this, _( "Include last component changes?" ) ) ) SaveOnePartInMemory(); @@ -608,7 +608,7 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event ) } CurrentDrawItem = NULL; - m_CurrentScreen->SetModify(); + GetScreen()->SetModify(); DrawPanel->CursorOn( &dc ); break; diff --git a/eeschema/load_one_schematic_file.cpp b/eeschema/load_one_schematic_file.cpp index 3a4d12d21f..13bd3a1e74 100644 --- a/eeschema/load_one_schematic_file.cpp +++ b/eeschema/load_one_schematic_file.cpp @@ -58,7 +58,7 @@ /* Fonctions locales */ static int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Window ); -static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Window ); +static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Window); static int ReadSchemaDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Window ); static void LoadLayers( FILE* f, int* linecnt ); @@ -71,7 +71,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F /************************************************************************************************/ /* Routine to load an EESchema file. - * Returns TRUE if file has been loaded (at list partially.) + * Returns TRUE if file has been loaded (at least partially.) */ { char Line[1024], * SLine; @@ -105,7 +105,8 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F return FALSE; } - MsgDiag = _( "Loading " ) + FullFileName; + screen->m_FileName = FullFileName; + MsgDiag = _( "Loading " ) + screen->m_FileName; PrintMsg( MsgDiag ); if( fgets( Line, 1024 - 1, f ) == NULL @@ -184,7 +185,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F wxT( "EESchema file Segment struct error at line %d, aborted" ), LineCount ); Failed = TRUE; - delete SegmentStruct; + SAFE_DELETE( SegmentStruct ) ; break; } @@ -200,7 +201,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F if( sscanf( SLine, "%s %s", Name1, Name2 ) != 2 ) { MsgDiag.Printf( - wxT( "EESchema file Raccord struct error at line %d, aborted" ), + wxT( "EESchema file record struct error at line %d, aborted" ), LineCount ); Failed = TRUE; break; @@ -220,7 +221,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F wxT( "EESchema file Raccord struct error at line %d, aborted" ), LineCount ); Failed = TRUE; - delete RaccordStruct; + SAFE_DELETE( RaccordStruct ) ; break; } @@ -264,7 +265,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F wxT( "EESchema file polyline struct error at line %d, aborted" ), LineCount ); Failed = TRUE; - delete PolylineStruct; + SAFE_DELETE( PolylineStruct ) ; break; } } @@ -286,7 +287,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F wxT( "EESchema file connection struct error at line %d, aborted" ), LineCount ); Failed = TRUE; - delete ConnectionStruct; + SAFE_DELETE( ConnectionStruct ) ; } else { @@ -380,10 +381,26 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F TextStruct->m_Orient = orient; Struct = (EDA_BaseStruct*) TextStruct; } - else if( Name1[0] == 'G' ) + else if( Name1[0] == 'G') { DrawGlobalLabelStruct* TextStruct = - new DrawGlobalLabelStruct( pos, CONV_FROM_UTF8( text ) ); + new DrawGlobalLabelStruct(pos, CONV_FROM_UTF8( text ) ); + Struct = (EDA_BaseStruct*) TextStruct; + TextStruct->m_Size.x = TextStruct->m_Size.y = size; + TextStruct->m_Orient = orient; + if( stricmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 ) + TextStruct->m_Shape = NET_OUTPUT; + if( stricmp( Name2, SheetLabelType[NET_BIDI] ) == 0 ) + TextStruct->m_Shape = NET_BIDI; + if( stricmp( Name2, SheetLabelType[NET_TRISTATE] ) == 0 ) + TextStruct->m_Shape = NET_TRISTATE; + if( stricmp( Name2, SheetLabelType[NET_UNSPECIFIED] ) == 0 ) + TextStruct->m_Shape = NET_UNSPECIFIED; + } + else if( Name1[0] == 'H') + { + DrawHierLabelStruct* TextStruct = + new DrawHierLabelStruct(pos, CONV_FROM_UTF8( text ) ); Struct = (EDA_BaseStruct*) TextStruct; TextStruct->m_Size.x = TextStruct->m_Size.y = size; TextStruct->m_Orient = orient; @@ -448,6 +465,9 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F TestDanglingEnds( screen->EEDrawList, NULL ); + MsgDiag = _( "Done Loading " ) + screen->m_FileName; + PrintMsg( MsgDiag ); + return TRUE; /* Although it may be that file is only partially loaded. */ } @@ -509,10 +529,29 @@ static int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, if( strcmp( Name2, NULL_STRING ) != 0 ) { - for( ii = 0; ii < (int) strlen( Name2 ); ii++ ) + bool isDigit = false; + for( ii = 0; ii < (int) strlen( Name2 ); ii++ ){ if( Name2[ii] == '~' ) Name2[ii] = ' '; - + //get RefBase from this, too. store in Name1. + if(Name2[ii] >= '0' && Name2[ii] <= '9'){ + isDigit = true; + Name1[ii] = 0; //null-terminate. + } + if(!isDigit){ + Name1[ii] = Name2[ii]; + } + } + Name1[ii] = 0; //just in case + int jj; + for(jj=0; jjm_PrefixString = wxT("U"); + }else{ + LibItemStruct->m_PrefixString = CONV_FROM_UTF8(&Name1[jj]); + //printf("prefix: %s\n", CONV_TO_UTF8(LibItemStruct->m_PrefixString)); + } if( !newfmt ) LibItemStruct->m_Field[REFERENCE].m_Text = CONV_FROM_UTF8( Name2 ); } @@ -527,6 +566,8 @@ static int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, * "P " = position * "U " = Num Unit, et Conversion * "Fn" = Champs ( n = 0.. = numero de champ ) + * "Ar" = AlternateReference, in the case of multiple sheets + * referring to one schematic file. */ /* Lecture des champs */ @@ -537,6 +578,7 @@ static int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, return TRUE; if( (Line[0] != 'F' ) && (Line[0] != 'P' ) + && (Line[0] != 'A' ) && (Line[0] != 'U' ) ) break; @@ -552,7 +594,32 @@ static int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, sscanf( Line + 1, "%d %d", &LibItemStruct->m_Pos.x, &LibItemStruct->m_Pos.y ); } - + if( Line[0] == 'A' && Line[1] == 'R' ) + { + /*format: + AR Path="/9086AF6E/67452AA0" Ref="C99" + where 9086AF6E is the unique timestamp of the containing sheet + and 67452AA0 is the timestamp of this component. + C99 is the reference given this path. + */ + int i=2; + while(i<256 && Line[i] != '"'){ i++; } i++; + //copy the path. + int j = 0; + while(i<256 && Line[i] != '"'){Name1[j] = Line[i]; i++; j++;} i++; + Name1[j] = 0; + wxString path = CONV_FROM_UTF8(Name1); + //i should be one after the closing quote, match the next opening quote + while(i<256 && Line[i] != '"'){ i++; } i++; + j = 0; + while(i<256 && Line[i] != '"'){Name1[j] = Line[i]; i++; j++;} i++; + Name1[j] = 0; + wxString ref = CONV_FROM_UTF8(Name1); + + LibItemStruct->m_Paths.Add(path); + LibItemStruct->m_References.Add(ref); + LibItemStruct->m_Field[REFERENCE].m_Text = ref; + } if( Line[0] == 'F' ) { char FieldUserName[1024]; @@ -695,6 +762,7 @@ static int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, { LibItemStruct->Pnext = Window->EEDrawList; Window->EEDrawList = (EDA_BaseStruct*) LibItemStruct; + LibItemStruct->m_Parent = Window; } return Failed; /* Fin lecture 1 composant */ @@ -717,8 +785,12 @@ static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Wi char* ptcar; SheetStruct = new DrawSheetStruct(); - SheetStruct->m_TimeStamp = GetTimeStamp(); - SheetStruct->m_Parent = Window; + SheetStruct->m_TimeStamp = GetTimeStamp(); + //sheets are added to the EEDrawList like other schematic components. + //however, in order to preserve the heirarchy (through m_Parent pointers), + //a duplicate of the sheet is added to m_SubSheet array. + //must be a duplicate, references just work for a two-layer structure. + //this is accomplished through the Sync() function. if( Line[0] == '$' ) /* Ligne doit etre "$Sheet" */ { @@ -749,6 +821,12 @@ static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Wi LineCount++; if( fgets( Line, 256 - 1, f ) == NULL ) return TRUE; + if( Line[0] == 'U' ){ + sscanf( Line + 1, "%lX", &(SheetStruct->m_TimeStamp) ); + if(SheetStruct->m_TimeStamp == 0) //zero is not unique! + SheetStruct->m_TimeStamp = GetTimeStamp(); + continue; + } if( Line[0] != 'F' ) break; sscanf( Line + 1, "%d", &fieldref ); @@ -804,6 +882,7 @@ static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Wi else { SheetStruct->m_FileName = CONV_FROM_UTF8( Name1 ); + //printf("in ReadSheetDescr : SheetStruct->m_FileName = %s \n", Name1); SheetStruct->m_FileNameSize = size; } } @@ -865,13 +944,12 @@ static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Wi LineCount ); Failed = TRUE; } - - if( !Failed ) - { - SheetStruct->Pnext = Window->EEDrawList; - Window->EEDrawList = (EDA_BaseStruct*) SheetStruct; - } - + if( !Failed ) + { + SheetStruct->Pnext = Window->EEDrawList; + Window->EEDrawList = (EDA_BaseStruct*)SheetStruct; + SheetStruct->m_Parent = Window; + } return Failed; /* Fin lecture 1 composant */ } @@ -918,7 +996,7 @@ static int ReadSchemaDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* W } /* Ajuste ecran */ - Window->m_CurrentSheet = wsheet; + Window->m_CurrentSheetDesc = wsheet; /* Recheche suite et fin de descr */ for( ; ; ) @@ -930,7 +1008,7 @@ static int ReadSchemaDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* W if( strnicmp( Line, "Sheet", 2 ) == 0 ) sscanf( Line + 5, " %d %d", - &Window->m_SheetNumber, &Window->m_NumberOfSheet ); + &Window->m_ScreenNumber, &Window->m_NumberOfScreen ); if( strnicmp( Line, "Title", 2 ) == 0 ) { diff --git a/eeschema/locate.cpp b/eeschema/locate.cpp index f26b017125..7ca15bba24 100644 --- a/eeschema/locate.cpp +++ b/eeschema/locate.cpp @@ -113,20 +113,19 @@ EDA_SchComponentStruct* LocateSmallestComponent( SCH_SCREEN* Screen ) */ /***********************************************************************/ EDA_BaseStruct* PickStruct( const wxPoint& refpos, - EDA_BaseStruct* DrawList, int SearchMask ) + BASE_SCREEN* screen, int SearchMask) /************************************************************************/ /* Search an item at pos pos */ { bool Snapped; - int zoom = ActiveScreen->GetZoom(); - - if( DrawList == NULL ) - return NULL; + EDA_BaseStruct* DrawList = screen->EEDrawList; + if( screen==NULL || DrawList == NULL ) + return NULL; if( ( Snapped = SnapPoint2( refpos, SearchMask, - DrawList, NULL, zoom ) ) != FALSE ) + DrawList, NULL, screen->GetZoom() ) ) != FALSE ) { return LastSnappedStruct; } @@ -136,7 +135,7 @@ EDA_BaseStruct* PickStruct( const wxPoint& refpos, /***********************************************************************/ EDA_BaseStruct* PickStruct( EDA_Rect& block, - EDA_BaseStruct* DrawList, int SearchMask ) + BASE_SCREEN* screen, int SearchMask ) /************************************************************************/ /* Search items in block @@ -155,7 +154,11 @@ EDA_BaseStruct* PickStruct( EDA_Rect& block, EXCHG( x, OrigX ); if( y < OrigY ) EXCHG( y, OrigY ); - + + EDA_BaseStruct* DrawList = screen->EEDrawList; + if( screen==NULL || DrawList == NULL ) + return NULL; + for( DrawStruct = DrawList; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) { if( DrawStructInBox( OrigX, OrigY, x, y, DrawStruct ) ) @@ -173,7 +176,7 @@ EDA_BaseStruct* PickStruct( EDA_Rect& block, /* Only one item was picked - convert to scalar form (no list): */ PickedItem = PickedList; PickedList = (DrawPickedStruct*) PickedList->m_PickedStruct; - delete PickedItem; + SAFE_DELETE( PickedItem ) ; } if( PickedList != NULL ) @@ -377,8 +380,9 @@ bool SnapPoint2( const wxPoint& PosRef, int SearchMask, case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: #undef STRUCT - #define STRUCT ( (DrawGlobalLabelStruct*) DrawList ) + #define STRUCT ( (DrawLabelStruct*) DrawList ) if( !(SearchMask & LABELITEM) ) break; dx = STRUCT->m_Size.x * ( STRUCT->GetLength() + 1 ); /* longueur */ @@ -592,9 +596,10 @@ bool DrawStructInBox( int x1, int y1, int x2, int y2, return TRUE; break; + case DRAW_HIER_LABEL_STRUCT_TYPE: case DRAW_GLOBAL_LABEL_STRUCT_TYPE: #undef STRUCT - #define STRUCT ( (DrawGlobalLabelStruct*) DrawStruct ) + #define STRUCT ( (DrawLabelStruct*) DrawStruct ) dx = STRUCT->m_Size.x * ( STRUCT->GetLength() + 1); /* longueur totale */ dy = STRUCT->m_Size.y / 2; /* Demi hauteur */ xt1 = xt2 = STRUCT->m_Pos.x; diff --git a/eeschema/makefile.include b/eeschema/makefile.include index bd7a2f86f4..66c9e511c3 100644 --- a/eeschema/makefile.include +++ b/eeschema/makefile.include @@ -20,7 +20,7 @@ OBJECTS = eeschema.o\ cross-probing.o\ setpage.o\ cmpclass.o\ - class_hierarchy_sheet.o\ + class_drawsheet.o\ class_text-label.o\ component_class.o\ libclass.o\ diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index 4ac7a1050f..ec8240b7b1 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -209,7 +209,7 @@ wxString msg; if( m_FilesMenu->FindItem(ID_LOAD_FILE_1 + ii) ) { item = m_FilesMenu->Remove(ID_LOAD_FILE_1 + ii); - if ( item ) delete item; + if ( item ){ SAFE_DELETE( item );} } } for ( ii = 0; ii < max_file; ii++ ) diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index 432b2eade0..aa1b8f7968 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -24,8 +24,9 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f, bool use_ static void WriteGENERICListOfNets( FILE* f, ObjetNetListStruct* ObjNet ); static void AddPinToComponentPinList( EDA_SchComponentStruct* Component, + DrawSheetList* sheet, LibDrawPin* PinEntry ); -static void FindOthersUnits( EDA_SchComponentStruct* Component ); +static void FindOthersUnits( EDA_SchComponentStruct* Component, DrawSheetList* Sheet_in); static int SortPinsByNum( ObjetNetListStruct** Pin1, ObjetNetListStruct** Pin2 ); static void EraseDuplicatePins( ObjetNetListStruct** TabPin, int NbrPin ); @@ -91,7 +92,7 @@ void WriteNetList( WinEDA_SchematicFrame* frame, const wxString& FileNameNL, /****************************************************************************/ static EDA_SchComponentStruct* FindNextComponentAndCreatPinList( - EDA_BaseStruct* DrawList ) + EDA_BaseStruct* DrawList, DrawSheetList* sheet) /****************************************************************************/ /* Find a "suitable" component from the DrawList @@ -116,8 +117,18 @@ static EDA_SchComponentStruct* FindNextComponentAndCreatPinList( Component = (EDA_SchComponentStruct*) DrawList; /* already tested ? : */ - if( Component->m_FlagControlMulti == 1 ) - continue; /* yes */ + bool found = false; + for(unsigned int i =0; im_UsedOnSheets.GetCount(); i++){ + if( Component->m_UsedOnSheets.Item(i) == *sheet ){ + found = true; + break; + } + } + if( found ) continue; + //if( Component->m_FlagControlMulti == 1 ) + // continue; /* yes */ + // removed because with multiple instances of one schematic + // (several sheets pointing to 1 screen), this will be erroneously be toggled. Entry = FindLibPart( Component->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); if( Entry == NULL ) @@ -125,11 +136,12 @@ static EDA_SchComponentStruct* FindNextComponentAndCreatPinList( /* Power symbol and other component which have the reference starting by * "#" are not included in netlist (pseudo components) */ - if( Component->m_Field[REFERENCE].m_Text[0] == '#' ) + wxString str = Component->GetRef(sheet); + if( str[0] == '#' ) continue; /* Create the pin table for this component */ - int ii = sizeof(ObjetNetListStruct) * MAXPIN; + int ii = sizeof(ObjetNetListStruct*) * MAXPIN; if( s_SortedComponentPinList == NULL ) s_SortedComponentPinList = (ObjetNetListStruct**) MyMalloc( ii ); memset( s_SortedComponentPinList, 0, ii ); @@ -146,14 +158,15 @@ static EDA_SchComponentStruct* FindNextComponentAndCreatPinList( && (DEntry->m_Convert != Component->m_Convert) ) continue; { - AddPinToComponentPinList( Component, (LibDrawPin*) DEntry ); + AddPinToComponentPinList( Component, sheet, (LibDrawPin*) DEntry ); } } - Component->m_FlagControlMulti = 1; - + //Component->m_FlagControlMulti = 1; + Component->m_UsedOnSheets.Add(*sheet); + if( Entry->m_UnitCount > 1 ) - FindOthersUnits( Component ); + FindOthersUnits( Component, sheet); /* Tri sur le numero de Pin de TabListePin */ qsort( s_SortedComponentPinList, s_SortedPinCount, sizeof(ObjetNetListStruct*), @@ -195,9 +208,9 @@ static wxString ReturnPinNetName( ObjetNetListStruct* Pin, { if( g_TabObjNet[jj].GetNet() != netcode ) continue; - if( ( g_TabObjNet[jj].m_Type != NET_GLOBLABEL) + if( ( g_TabObjNet[jj].m_Type != NET_HIERLABEL) && ( g_TabObjNet[jj].m_Type != NET_LABEL) - && ( g_TabObjNet[jj].m_Type != NET_PINLABEL) ) + && ( g_TabObjNet[jj].m_Type != NET_PINLABEL) ) continue; NetName = *g_TabObjNet[jj].m_Label; @@ -206,8 +219,11 @@ static wxString ReturnPinNetName( ObjetNetListStruct* Pin, if( !NetName.IsEmpty() ) { - if( g_TabObjNet[jj].m_Type != NET_PINLABEL ) - NetName << wxT( "_" ) << g_TabObjNet[jj].m_SheetNumber; + if( g_TabObjNet[jj].m_Type != NET_PINLABEL ){ + NetName = g_TabObjNet[jj].m_SheetList.PathHumanReadable() + + NetName; + } + //NetName << wxT("_") << g_TabObjNet[jj].m_SheetList.PathHumanReadable(); } else { @@ -217,7 +233,6 @@ static wxString ReturnPinNetName( ObjetNetListStruct* Pin, return NetName; } - /***********************************************************************/ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, const wxString& FullFileName ) @@ -225,10 +240,11 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, /* Create a generic netlist, and call an external netlister * to change the netlist syntax and create the file + * -- does this still work? */ { wxString Line, FootprintName; - BASE_SCREEN* CurrScreen; + DrawSheetList* sheet; EDA_BaseStruct* DrawList; EDA_SchComponentStruct* Component; wxString netname; @@ -250,12 +266,14 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, /* Create netlist module section */ fprintf( tmpfile, "$BeginComponentList\n" ); - EDA_ScreenList ScreenList( NULL ); - for( CurrScreen = ScreenList.GetFirst(); CurrScreen != NULL; CurrScreen = ScreenList.GetNext() ) - { - for( DrawList = CurrScreen->EEDrawList; DrawList != NULL; DrawList = DrawList->Pnext ) - { - DrawList = Component = FindNextComponentAndCreatPinList( DrawList ); + EDA_SheetList SheetList( NULL ); + + for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) + { + for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Pnext ) + { + DrawList = Component = FindNextComponentAndCreatPinList( DrawList, sheet ); + if( Component == NULL ) break; // No component left @@ -269,7 +287,7 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, fprintf( tmpfile, "\n$BeginComponent\n" ); fprintf( tmpfile, "TimeStamp=%8.8lX\n", Component->m_TimeStamp ); fprintf( tmpfile, "Footprint=%s\n", CONV_TO_UTF8( FootprintName ) ); - Line = wxT( "Reference=" ) + Component->m_Field[REFERENCE].m_Text + wxT( "\n" ); + Line = wxT( "Reference=" ) + Component->GetPath(sheet) + wxT( "\n" ); Line.Replace( wxT( " " ), wxT( "_" ) ); fprintf( tmpfile, CONV_TO_UTF8( Line ) ); @@ -337,7 +355,7 @@ static void ClearUsedFlags( WinEDA_SchematicFrame* frame ) SCH_SCREEN* screen; EDA_BaseStruct* DrawList; - EDA_ScreenList ScreenList( NULL ); + EDA_ScreenList ScreenList; for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) { @@ -347,7 +365,8 @@ static void ClearUsedFlags( WinEDA_SchematicFrame* frame ) if( DrawList->Type() == DRAW_LIB_ITEM_STRUCT_TYPE ) { EDA_SchComponentStruct* Component = (EDA_SchComponentStruct*) DrawList; - Component->m_FlagControlMulti = 0; + //Component->m_FlagControlMulti = 0; + Component->m_UsedOnSheets.Clear(); } DrawList = DrawList->Pnext; } @@ -365,14 +384,14 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f, * les nodes sont identifies par le netname * sinon les nodes sont identifies par le netnumber * - * tous les textes graphiques commençant par [.-+]pspice ou [.-+]gnucap - * sont considérés comme des commandes a placer dans la netliste + * tous les textes graphiques commen�ant par [.-+]pspice ou [.-+]gnucap + * sont consid�r�s comme des commandes a placer dans la netliste * [.-]pspice ou gnucap sont en debut +pspice et +gnucap sont en fin de netliste */ { char Line[1024]; - SCH_SCREEN* screen; + DrawSheetList* sheet; EDA_BaseStruct* DrawList; EDA_SchComponentStruct* Component; int ii, nbitems; @@ -389,11 +408,11 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f, /* Create text list starting by [.-]pspice , or [.-]gnucap (simulator commands) */ /* and create text list starting by [+]pspice , or [+]gnucap (simulator commands) */ bufnum[BUFYPOS_LEN] = 0; - EDA_ScreenList ScreenList( NULL ); + EDA_SheetList SheetList( NULL ); - for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) { - for( DrawList = screen->EEDrawList; DrawList != NULL; DrawList = DrawList->Pnext ) + for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Pnext ) { wxChar ident; if( DrawList->Type() != DRAW_TEXT_STRUCT_TYPE ) @@ -444,15 +463,15 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f, /* Create component list */ ClearUsedFlags( frame ); /* Reset the flags FlagControlMulti in all schematic files*/ - for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) { - for( DrawList = screen->EEDrawList; DrawList != NULL; DrawList = DrawList->Pnext ) + for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Pnext ) { - DrawList = Component = FindNextComponentAndCreatPinList( DrawList ); + DrawList = Component = FindNextComponentAndCreatPinList( DrawList, sheet ); if( Component == NULL ) break; - fprintf( f, "%s ", CONV_TO_UTF8( Component->m_Field[REFERENCE].m_Text ) ); + fprintf( f, "%s ", CONV_TO_UTF8( Component->GetRef( sheet ) ) ); // Write pin list: for( ii = 0; ii < s_SortedPinCount; ii++ ) @@ -514,11 +533,11 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with { wxString Line, FootprintName; char Buf[256]; - SCH_SCREEN* CurrScreen; + DrawSheetList* sheet; EDA_BaseStruct* DrawList; EDA_SchComponentStruct* Component; int ii; - EDA_SchComponentStruct** CmpList = NULL; + ListComponent* CmpList = NULL; int CmpListCount = 0, CmpListSize = 1000; DateAndTime( Buf ); @@ -528,16 +547,16 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with fprintf( f, "( { %s created %s }\n", NETLIST_HEAD_STRING, Buf ); - /* Create netlist module section */ + /* Create netlist module section */ ClearUsedFlags( frame ); /* Reset the flags FlagControlMulti in all schematic files*/ - EDA_ScreenList ScreenList( NULL ); + EDA_SheetList SheetList( NULL ); - for( CurrScreen = ScreenList.GetFirst(); CurrScreen != NULL; CurrScreen = ScreenList.GetNext() ) + for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) { - for( DrawList = CurrScreen->EEDrawList; DrawList != NULL; DrawList = DrawList->Pnext ) + for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Pnext ) { - DrawList = Component = FindNextComponentAndCreatPinList( DrawList ); + DrawList = Component = FindNextComponentAndCreatPinList( DrawList, sheet); if( Component == NULL ) break; @@ -548,20 +567,19 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with { if( Entry->m_FootprintList.GetCount() != 0 ) /* Put in list */ { - if( CmpList == NULL ) - CmpList = (EDA_SchComponentStruct**) MyZMalloc( sizeof( - EDA_SchComponentStruct - *) * CmpListSize ); + if( CmpList == NULL ){ + CmpList = (ListComponent*) + MyZMalloc( sizeof(ListComponent) * CmpListSize ); + } if( CmpListCount >= CmpListSize ) { CmpListSize += 1000; - CmpList = (EDA_SchComponentStruct**) realloc( + CmpList = (ListComponent*) realloc( CmpList, - sizeof( - EDA_SchComponentStruct*) - * CmpListSize ); + sizeof(ListComponent) * CmpListSize ); } - CmpList[CmpListCount] = Component; + CmpList[CmpListCount].m_Comp = Component; + strcpy(CmpList[CmpListCount].m_Ref, Component->GetRef( sheet ).mb_str()); CmpListCount++; } } @@ -574,10 +592,9 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with else FootprintName = wxT( "$noname" ); - Line = Component->m_Field[REFERENCE].m_Text; - Line.Replace( wxT( " " ), wxT( "_" ) ); - fprintf( f, " ( %8.8lX %s", - Component->m_TimeStamp, + Line = Component->GetRef(sheet); + fprintf( f, " ( %s %s", + CONV_TO_UTF8(Component->GetPath(sheet)), CONV_TO_UTF8( FootprintName ) ); fprintf( f, " %s", CONV_TO_UTF8( Line ) ); @@ -622,11 +639,16 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with EDA_LibComponentStruct* Entry; for( ii = 0; ii < CmpListCount; ii++ ) { - Component = CmpList[ii]; + Component = CmpList[ii].m_Comp; Entry = FindLibPart( Component->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); - Line = Component->m_Field[REFERENCE].m_Text; - Line.Replace( wxT( " " ), wxT( "_" ) ); - fprintf( f, "$component %s\n", CONV_TO_UTF8( Line ) ); + //Line.Printf(_("%s"), CmpList[ii].m_Ref); + //Line.Replace( wxT( " " ), wxT( "_" ) ); + unsigned int i; + for(i=0; im_FootprintList.GetCount(); jj++ ) { @@ -652,7 +674,8 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with /*************************************************************************************/ -static void AddPinToComponentPinList( EDA_SchComponentStruct* Component, LibDrawPin* Pin ) +static void AddPinToComponentPinList( EDA_SchComponentStruct* Component, + DrawSheetList* sheetlist, LibDrawPin* Pin ) /*************************************************************************************/ /* Add a new pin description in the pin list s_SortedComponentPinList @@ -669,6 +692,8 @@ static void AddPinToComponentPinList( EDA_SchComponentStruct* Component, LibDraw continue; if( g_TabObjNet[ii].m_Link != Component ) continue; + if( g_TabObjNet[ii].m_SheetList != *sheetlist ) + continue; if( g_TabObjNet[ii].m_PinNum != Pin->m_PinNum ) continue; { @@ -716,7 +741,7 @@ static void EraseDuplicatePins( ObjetNetListStruct** TabPin, int NbrPin ) /**********************************************************************/ -static void FindOthersUnits( EDA_SchComponentStruct* Component ) +static void FindOthersUnits( EDA_SchComponentStruct* Component_in, DrawSheetList* Sheet_in) /**********************************************************************/ /* Recherche les autres parts du boitier auquel appartient la part Component, @@ -728,13 +753,15 @@ static void FindOthersUnits( EDA_SchComponentStruct* Component ) EDA_SchComponentStruct* Component2; EDA_LibComponentStruct* Entry; LibEDA_BaseStruct* DEntry; - SCH_SCREEN* screen; + DrawSheetList* sheet; + wxString str; - EDA_ScreenList ScreenList( NULL ); - - for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + EDA_SheetList SheetList( NULL ); + unsigned int i; + bool found; + for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) { - DrawList = screen->EEDrawList; + DrawList = sheet->LastDrawList(); while( DrawList ) { switch( DrawList->Type() ) @@ -742,17 +769,24 @@ static void FindOthersUnits( EDA_SchComponentStruct* Component ) case DRAW_LIB_ITEM_STRUCT_TYPE: Component2 = (EDA_SchComponentStruct*) DrawList; - if( Component2->m_FlagControlMulti == 1 ) - break; - - if( Component2->m_Field[REFERENCE].m_Text.CmpNoCase( - Component->m_Field[REFERENCE].m_Text ) != 0 ) + found = false; + for( i =0; im_UsedOnSheets.GetCount(); i++){ + if( Component2->m_UsedOnSheets.Item(i) == *Sheet_in ){ + found = true; + } + } + if( found ) break; + //if( Component2->m_FlagControlMulti == 1 ) //has it been used? (on this sheet?) + // break; + str = Component2->GetRef(sheet); + if( str.CmpNoCase( Component_in->GetRef(Sheet_in) ) != 0 ) break; Entry = FindLibPart( Component2->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); if( Entry == NULL ) break; - if( Component2->m_Field[REFERENCE].m_Text[0] == '#' ) + + if( str[0] == '#' ) break; if( Entry->m_Drawings != NULL ) @@ -769,11 +803,12 @@ static void FindOthersUnits( EDA_SchComponentStruct* Component ) && (DEntry->m_Convert != Component2->m_Convert) ) continue; { - AddPinToComponentPinList( Component2, (LibDrawPin*) DEntry ); + AddPinToComponentPinList( Component2, sheet, (LibDrawPin*) DEntry ); } } } - Component2->m_FlagControlMulti = 1; + Component2->m_UsedOnSheets.Add(*Sheet_in); + //Component2->m_FlagControlMulti = 1; //mark it as used.. break; default: @@ -794,12 +829,12 @@ static int SortPinsByNum( ObjetNetListStruct** Pin1, ObjetNetListStruct** Pin2 ) * du tableau des pins s_SortedComponentPinList par qsort() */ { - ObjetNetListStruct* Obj1, * Obj2; + ObjetNetListStruct* Obj1, * Obj2; int Num1, Num2; char Line[5]; - Obj1 = *Pin1; Obj2 = *Pin2; - Num1 = Obj1->m_PinNum; Num2 = Obj2->m_PinNum; + Obj1 = *Pin1; Obj2 = *Pin2; + Num1 = Obj1->m_PinNum; Num2 = Obj2->m_PinNum; Line[4] = 0; memcpy( Line, &Num1, 4 ); Num1 = atoi( Line ); memcpy( Line, &Num2, 4 ); Num2 = atoi( Line ); return Num1 - Num2; @@ -832,7 +867,7 @@ static void WriteGENERICListOfNets( FILE* f, ObjetNetListStruct* ObjNet ) { if( ObjNet[jj].GetNet() != NetCode ) continue; - if( ( ObjNet[jj].m_Type != NET_GLOBLABEL) + if( ( ObjNet[jj].m_Type != NET_HIERLABEL) && ( ObjNet[jj].m_Type != NET_LABEL) && ( ObjNet[jj].m_Type != NET_PINLABEL) ) continue; @@ -845,8 +880,13 @@ static void WriteGENERICListOfNets( FILE* f, ObjetNetListStruct* ObjNet ) if( !NetName.IsEmpty() ) { NetcodeName += NetName; - if( g_TabObjNet[jj].m_Type != NET_PINLABEL ) // usual net name, add it the sheet number - NetcodeName << wxT( "_" ) << g_TabObjNet[jj].m_SheetNumber; + if( g_TabObjNet[jj].m_Type != NET_PINLABEL ){ + // usual net name, add in the sheet path + NetcodeName = g_TabObjNet[jj].m_SheetList.PathHumanReadable() + + NetcodeName; + //NetcodeName << wxT("_") << + // g_TabObjNet[jj].m_SheetList.PathHumanReadable(); + } } NetcodeName += wxT( "\"" ); LastNetCode = NetCode; @@ -856,7 +896,7 @@ static void WriteGENERICListOfNets( FILE* f, ObjetNetListStruct* ObjNet ) continue; Cmp = (EDA_SchComponentStruct*) ObjNet[ii].m_Link; - CmpRef = Cmp->m_Field[REFERENCE].m_Text; + CmpRef = Cmp->GetRef(&ObjNet[ii].m_SheetList); //is this correct? if( CmpRef.StartsWith( wxT( "#" ) ) ) continue; // Pseudo component (Like Power symbol) @@ -919,7 +959,7 @@ static void WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f ) wxString msg; wxString FootprintName; char Line[1024]; - BASE_SCREEN* CurrScreen; + DrawSheetList* sheet; EDA_BaseStruct* DrawList; EDA_SchComponentStruct* Component; wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion(); @@ -933,13 +973,13 @@ static void WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f ) /* Create netlist module section */ ClearUsedFlags( frame ); /* Reset the flags FlagControlMulti in all schematic files*/ - EDA_ScreenList ScreenList( NULL ); + EDA_SheetList SheetList( NULL ); - for( CurrScreen = ScreenList.GetFirst(); CurrScreen != NULL; CurrScreen = ScreenList.GetNext() ) + for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) { - for( DrawList = CurrScreen->EEDrawList; DrawList != NULL; DrawList = DrawList->Pnext ) + for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Pnext ) { - DrawList = Component = FindNextComponentAndCreatPinList( DrawList ); + DrawList = Component = FindNextComponentAndCreatPinList( DrawList, sheet); if( Component == NULL ) break; @@ -951,8 +991,7 @@ static void WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f ) else FootprintName = wxT( "$noname" ); - msg = Component->m_Field[REFERENCE].m_Text; - msg.Replace( wxT( " " ), wxT( "_" ) ); + msg = Component->GetRef(sheet); fprintf( f, "%s ", CONV_TO_UTF8( StartCmpDesc ) ); fprintf( f, "%s", CONV_TO_UTF8( msg ) ); @@ -1007,7 +1046,7 @@ static void WriteListOfNetsCADSTAR( FILE* f, ObjetNetListStruct* ObjNet ) { if( ObjNet[jj].GetNet() != NetCode ) continue; - if( ( ObjNet[jj].m_Type != NET_GLOBLABEL) + if( ( ObjNet[jj].m_Type != NET_HIERLABEL) && ( ObjNet[jj].m_Type != NET_LABEL) && ( ObjNet[jj].m_Type != NET_PINLABEL) ) continue; @@ -1019,8 +1058,12 @@ static void WriteListOfNetsCADSTAR( FILE* f, ObjetNetListStruct* ObjNet ) if( !NetName.IsEmpty() ) { NetcodeName += NetName; - if( g_TabObjNet[jj].m_Type != NET_PINLABEL ) - NetcodeName << wxT( "_" ) << g_TabObjNet[jj].m_SheetNumber; + if( g_TabObjNet[jj].m_Type != NET_PINLABEL ){ + NetcodeName = g_TabObjNet[jj].m_SheetList.PathHumanReadable() + + NetcodeName; + //NetcodeName << wxT("_") << + // g_TabObjNet[jj].m_SheetList.PathHumanReadable(); + } } else // this net has no name: create a default name $ NetcodeName << wxT( "$" ) << NetCode; @@ -1037,8 +1080,8 @@ static void WriteListOfNetsCADSTAR( FILE* f, ObjetNetListStruct* ObjNet ) continue; Cmp = (EDA_SchComponentStruct*) ObjNet[ii].m_Link; - - if( Cmp->m_Field[REFERENCE].m_Text[0] == '#' ) + wxString refstr = Cmp->GetRef(&(ObjNet[ii].m_SheetList)); + if( refstr[0] == '#' ) continue; // Pseudo composant (symboles d'alims) switch( print_ter ) @@ -1051,7 +1094,7 @@ static void WriteListOfNetsCADSTAR( FILE* f, ObjetNetListStruct* ObjNet ) str_pinnum = CONV_FROM_UTF8( buf ); InitNetDescLine.Printf( wxT( "\n%s %s %.4s %s" ), InitNetDesc.GetData(), - Cmp->m_Field[REFERENCE].m_Text.GetData(), + refstr.GetData(), str_pinnum.GetData(), NetcodeName.GetData() ); } print_ter++; @@ -1061,14 +1104,14 @@ static void WriteListOfNetsCADSTAR( FILE* f, ObjetNetListStruct* ObjNet ) fprintf( f, "%s\n", CONV_TO_UTF8( InitNetDescLine ) ); fprintf( f, "%s %s %.4s\n", CONV_TO_UTF8( StartNetDesc ), - CONV_TO_UTF8( Cmp->m_Field[REFERENCE].m_Text ), + CONV_TO_UTF8( refstr ), (char*) &ObjNet[ii].m_PinNum ); print_ter++; break; default: fprintf( f, " %s %.4s\n", - CONV_TO_UTF8( Cmp->m_Field[REFERENCE].m_Text ), + CONV_TO_UTF8( refstr ), (char*) &ObjNet[ii].m_PinNum ); break; } @@ -1085,7 +1128,9 @@ static void WriteListOfNetsCADSTAR( FILE* f, ObjetNetListStruct* ObjNet ) continue; EDA_SchComponentStruct* tstcmp = (EDA_SchComponentStruct*) ObjNet[jj].m_Link; - if( Cmp->m_Field[REFERENCE].m_Text != tstcmp->m_Field[REFERENCE].m_Text ) + wxString p = Cmp->GetPath( &( ObjNet[ii].m_SheetList ) ); + wxString tstp = tstcmp->GetPath( &( ObjNet[jj].m_SheetList ) ); + if( p.Cmp(tstp) != 0 ) continue; if( ObjNet[jj].m_PinNum == ObjNet[ii].m_PinNum ) diff --git a/eeschema/netlist.cpp b/eeschema/netlist.cpp index 9fc4c6af07..9a9b058b34 100644 --- a/eeschema/netlist.cpp +++ b/eeschema/netlist.cpp @@ -15,16 +15,16 @@ /* Routines locales */ static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus ); -static void SheetLabelConnection( ObjetNetListStruct* SheetLabel ); +static void SheetLabelConnect( ObjetNetListStruct* SheetLabel ); static int ListeObjetConnection( WinEDA_SchematicFrame* frame, - SCH_SCREEN* screen, + DrawSheetList* sheetlist, ObjetNetListStruct* ObjNet ); static int ConvertBusToMembers( ObjetNetListStruct* ObjNet ); -static void PointToPointConnect( ObjetNetListStruct* RefObj, int IsBus, +static void PointToPointConnect( ObjetNetListStruct* Ref, int IsBus, int start ); static void SegmentToPointConnect( ObjetNetListStruct* Jonction, int IsBus, int start ); -static void LabelConnection( ObjetNetListStruct* Label ); +static void LabelConnect( ObjetNetListStruct* Label ); static int TriNetCode( const void* o1, const void* o2 ); static void ConnectBusLabels( ObjetNetListStruct* Label, int NbItems ); static void SetUnconnectedFlag( ObjetNetListStruct* ObjNet, int NbItems ); @@ -37,7 +37,7 @@ static int s_PassNumber; #if defined(DEBUG) - +#include const char* ShowType( NetObjetType aType ) { const char* ret; @@ -48,9 +48,11 @@ const char* ShowType( NetObjetType aType ) case NET_BUS: ret = "bus"; break; case NET_JONCTION: ret = "junction"; break; case NET_LABEL: ret = "label"; break; - case NET_GLOBLABEL: ret = "glabel"; break; + case NET_HIERLABEL: ret = "hierlabel"; break; + case NET_GLOBLABEL: ret = "glabel"; break; case NET_BUSLABELMEMBER: ret = "buslblmember"; break; - case NET_GLOBBUSLABELMEMBER: ret = "gbuslblmember"; break; + case NET_HIERBUSLABELMEMBER: ret = "hierbuslblmember"; break; + case NET_GLOBBUSLABELMEMBER: ret = "gbuslblmember"; break; case NET_SHEETBUSLABELMEMBER: ret = "sbuslblmember"; break; case NET_SHEETLABEL: ret = "sheetlabel"; break; case NET_PINLABEL: ret = "pinlabel"; break; @@ -64,10 +66,11 @@ const char* ShowType( NetObjetType aType ) void ObjetNetListStruct::Show( std::ostream& out, int ndx ) { + wxString path = m_SheetList.PathHumanReadable(); out << "\n"; out << " \n"; @@ -117,15 +120,18 @@ void FreeTabNetList( ObjetNetListStruct* TabNetItems, int NbrNetItems ) case NET_JONCTION: case NET_BUS: case NET_LABEL: - case NET_GLOBLABEL: + case NET_HIERLABEL: + case NET_GLOBLABEL: case NET_PINLABEL: case NET_NOCONNECT: break; - case NET_GLOBBUSLABELMEMBER: + case NET_HIERBUSLABELMEMBER: + case NET_GLOBBUSLABELMEMBER: case NET_SHEETBUSLABELMEMBER: case NET_BUSLABELMEMBER: - delete TabNetItems[i].m_Label; + SAFE_DELETE( TabNetItems[i].m_Label ); + //see the note in ConvertBustToMembers break; } } @@ -137,16 +143,15 @@ void FreeTabNetList( ObjetNetListStruct* TabNetItems, int NbrNetItems ) /*****************************************************/ void* WinEDA_SchematicFrame::BuildNetListBase() /*****************************************************/ - /* Routine qui construit le tableau des elements connectes du projet * met a jour: * g_TabObjNet * g_NbrObjNet */ { - int NetNumber, SheetNumber; + int NetNumber; int i, istart, NetCode; - SCH_SCREEN* screen; + DrawSheetList* sheet; wxString msg; wxBusyCursor Busy; @@ -156,22 +161,19 @@ void* WinEDA_SchematicFrame::BuildNetListBase() MsgPanel->EraseMsgBox(); Affiche_1_Parametre( this, 1, _( "List" ), wxEmptyString, LIGHTRED ); - /* Build the screen list */ - EDA_ScreenList ScreenList( NULL ); - + /* Build the sheet (not screen) list (flattened)*/ + EDA_SheetList SheetListList( NULL ); + i=0; /* 1ere passe : Comptage du nombre d'objet de Net */ g_NbrObjNet = 0; g_TabObjNet = NULL; /* Init pour le 1er passage dans ListeObjetConnection */ - /* Update the sheet number, sheet count and date and count nelist items */ - ScreenSch->SetModify(); - int kk = 1; - for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + /* count nelist items */ + g_RootSheet->m_s->SetModify(); + + for( sheet = SheetListList.GetFirst(); sheet != NULL; sheet = SheetListList.GetNext() ) { - screen->m_SheetNumber = kk++; - screen->m_NumberOfSheet = ScreenList.GetCount(); - screen->m_Date = GenDate(); - g_NbrObjNet += ListeObjetConnection( this, screen, NULL ); + g_NbrObjNet += ListeObjetConnection( this, sheet, NULL ); } if( g_NbrObjNet == 0 ) @@ -186,15 +188,16 @@ void* WinEDA_SchematicFrame::BuildNetListBase() return NULL; /* 2eme passe : Remplissage des champs des structures des objets de Net */ + /* second pass: fill the fields of the structures in the Net */ s_PassNumber++; Affiche_1_Parametre( this, 1, _( "List" ), wxEmptyString, RED ); - screen = ScreenList.GetFirst(); + sheet = SheetListList.GetFirst(); for( ObjetNetListStruct* tabObjNet = g_TabObjNet; - screen != NULL; screen = ScreenList.GetNext() ) + sheet != NULL; sheet = SheetListList.GetNext() ) { - tabObjNet += ListeObjetConnection( this, screen, tabObjNet ); + tabObjNet += ListeObjetConnection( this, sheet, tabObjNet ); } Affiche_1_Parametre( this, -1, wxEmptyString, _( "Done" ), RED ); @@ -209,14 +212,14 @@ void* WinEDA_SchematicFrame::BuildNetListBase() Affiche_1_Parametre( this, 18, _( "Conn" ), wxEmptyString, CYAN ); - SheetNumber = g_TabObjNet[0].m_SheetNumber; + sheet = &(g_TabObjNet[0].m_SheetList); LastNetCode = LastBusNetCode = 1; for( i = istart = 0; im_NumInclude ) - continue; + if( ObjetNet[i].m_SheetList != SheetLabel->m_SheetListInclude ) + continue; //use SheetInclude, not the sheet!! - if( (ObjetNet[i].m_Type != NET_GLOBLABEL ) - && (ObjetNet[i].m_Type != NET_GLOBBUSLABELMEMBER ) ) + if( (ObjetNet[i].m_Type != NET_HIERLABEL ) + && (ObjetNet[i].m_Type != NET_HIERBUSLABELMEMBER ) ) continue; if( ObjetNet[i].GetNet() == SheetLabel->GetNet() ) - continue; + continue; //already connected. if( ObjetNet[i].m_Label->CmpNoCase( *SheetLabel->m_Label ) != 0 ) - continue; + continue; //different names. /* Propagation du Netcode a tous les Objets de meme NetCode */ if( ObjetNet[i].GetNet() ) @@ -425,32 +432,35 @@ static void SheetLabelConnection( ObjetNetListStruct* SheetLabel ) /*****************************************************************************/ -static int ListeObjetConnection( WinEDA_SchematicFrame* frame, SCH_SCREEN* screen, +static int ListeObjetConnection( WinEDA_SchematicFrame* frame, DrawSheetList* sheetlist, ObjetNetListStruct* ObjNet ) /*****************************************************************************/ /* Routine generant la liste des objets relatifs aux connection * entree: - * screen: pointeur sur l'ecran a traiter + * sheetlist: pointer to a sheetlist. * ObjNet: * si NULL: la routine compte seulement le nombre des objets * sinon: pointe le tableau a remplir */ { - int ii, NbrItem = 0, NumSheet; + int ii, NbrItem = 0; EDA_BaseStruct* DrawList; EDA_SchComponentStruct* DrawLibItem; int TransMat[2][2], PartX, PartY, x2, y2; EDA_LibComponentStruct* Entry; LibEDA_BaseStruct* DEntry; DrawSheetLabelStruct* SheetLabel; - int NumInclude; - - NumSheet = screen->m_SheetNumber; + DrawSheetList list; - DrawList = screen->EEDrawList; + DrawList = sheetlist->LastScreen()->EEDrawList; for( ; DrawList; DrawList = DrawList->Pnext ) { + if( ObjNet ){ + ObjNet[NbrItem].m_SheetList = *sheetlist; + ObjNet[NbrItem].m_SheetListInclude = *sheetlist; + //used for DrawSheetLabels + } switch( DrawList->Type() ) { case DRAW_SEGMENT_STRUCT_TYPE: @@ -463,8 +473,6 @@ static int ListeObjetConnection( WinEDA_SchematicFrame* frame, SCH_SCREEN* scree break; ObjNet[NbrItem].m_Comp = STRUCT; - ObjNet[NbrItem].m_Screen = screen; - ObjNet[NbrItem].m_SheetNumber = NumSheet; ObjNet[NbrItem].m_Start = STRUCT->m_Start; ObjNet[NbrItem].m_End = STRUCT->m_End; @@ -486,9 +494,7 @@ static int ListeObjetConnection( WinEDA_SchematicFrame* frame, SCH_SCREEN* scree if( ObjNet ) { ObjNet[NbrItem].m_Comp = STRUCT; - ObjNet[NbrItem].m_Screen = screen; ObjNet[NbrItem].m_Type = NET_JONCTION; - ObjNet[NbrItem].m_SheetNumber = NumSheet; ObjNet[NbrItem].m_Start = STRUCT->m_Pos; ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start; } @@ -501,9 +507,7 @@ static int ListeObjetConnection( WinEDA_SchematicFrame* frame, SCH_SCREEN* scree if( ObjNet ) { ObjNet[NbrItem].m_Comp = STRUCT; - ObjNet[NbrItem].m_Screen = screen; ObjNet[NbrItem].m_Type = NET_NOCONNECT; - ObjNet[NbrItem].m_SheetNumber = NumSheet; ObjNet[NbrItem].m_Start = STRUCT->m_Pos; ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start; } @@ -517,14 +521,14 @@ static int ListeObjetConnection( WinEDA_SchematicFrame* frame, SCH_SCREEN* scree if( ObjNet ) { ObjNet[NbrItem].m_Comp = STRUCT; - ObjNet[NbrItem].m_Screen = screen; ObjNet[NbrItem].m_Type = NET_LABEL; if( STRUCT->m_Layer == LAYER_GLOBLABEL ) ObjNet[NbrItem].m_Type = NET_GLOBLABEL; + if( STRUCT->m_Layer == LAYER_HIERLABEL ) + ObjNet[NbrItem].m_Type = NET_HIERLABEL; ObjNet[NbrItem].m_Label = &STRUCT->m_Text; - ObjNet[NbrItem].m_SheetNumber = NumSheet; ObjNet[NbrItem].m_Start = STRUCT->m_Pos; ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start; @@ -536,20 +540,21 @@ static int ListeObjetConnection( WinEDA_SchematicFrame* frame, SCH_SCREEN* scree break; case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: #undef STRUCT - #define STRUCT ( (DrawGlobalLabelStruct*) DrawList ) + #define STRUCT ( (DrawLabelStruct*) DrawList ) ii = IsBusLabel( STRUCT->m_Text ); if( ObjNet ) { ObjNet[NbrItem].m_Comp = STRUCT; - ObjNet[NbrItem].m_Screen = screen; ObjNet[NbrItem].m_Type = NET_LABEL; if( STRUCT->m_Layer == LAYER_GLOBLABEL ) ObjNet[NbrItem].m_Type = NET_GLOBLABEL; + if( STRUCT->m_Layer == LAYER_HIERLABEL ) + ObjNet[NbrItem].m_Type = NET_HIERLABEL; ObjNet[NbrItem].m_Label = &STRUCT->m_Text; - ObjNet[NbrItem].m_SheetNumber = NumSheet; ObjNet[NbrItem].m_Start = STRUCT->m_Pos; ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start; @@ -601,13 +606,12 @@ static int ListeObjetConnection( WinEDA_SchematicFrame* frame, SCH_SCREEN* scree if( ObjNet ) { ObjNet[NbrItem].m_Comp = DEntry; + ObjNet[NbrItem].m_SheetList = *sheetlist; ObjNet[NbrItem].m_Type = NET_PIN; ObjNet[NbrItem].m_Link = DrawLibItem; - ObjNet[NbrItem].m_Screen = screen; ObjNet[NbrItem].m_ElectricalType = Pin->m_PinType; ObjNet[NbrItem].m_PinNum = Pin->m_PinNum; ObjNet[NbrItem].m_Label = &Pin->m_PinName; - ObjNet[NbrItem].m_SheetNumber = NumSheet; ObjNet[NbrItem].m_Start.x = x2; ObjNet[NbrItem].m_Start.y = y2; ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start; @@ -621,9 +625,8 @@ static int ListeObjetConnection( WinEDA_SchematicFrame* frame, SCH_SCREEN* scree if( ObjNet ) { ObjNet[NbrItem].m_Comp = NULL; + ObjNet[NbrItem].m_SheetList = *sheetlist; ObjNet[NbrItem].m_Type = NET_PINLABEL; - ObjNet[NbrItem].m_Screen = screen; - ObjNet[NbrItem].m_SheetNumber = NumSheet; ObjNet[NbrItem].m_Label = &Pin->m_PinName; ObjNet[NbrItem].m_Start.x = x2; ObjNet[NbrItem].m_Start.y = y2; @@ -645,8 +648,8 @@ static int ListeObjetConnection( WinEDA_SchematicFrame* frame, SCH_SCREEN* scree case DRAW_SHEET_STRUCT_TYPE: #undef STRUCT #define STRUCT ( (DrawSheetStruct*) DrawList ) - NumInclude = STRUCT->m_SheetNumber; - + list = *sheetlist; + list.Push(STRUCT); SheetLabel = STRUCT->m_Label; for( ; SheetLabel != NULL; SheetLabel = (DrawSheetLabelStruct*) SheetLabel->Pnext ) @@ -654,16 +657,15 @@ static int ListeObjetConnection( WinEDA_SchematicFrame* frame, SCH_SCREEN* scree ii = IsBusLabel( SheetLabel->m_Text ); if( ObjNet ) { - ObjNet[NbrItem].m_Comp = SheetLabel; - ObjNet[NbrItem].m_Link = DrawList; - ObjNet[NbrItem].m_Type = NET_SHEETLABEL; - ObjNet[NbrItem].m_Screen = screen; + ObjNet[NbrItem].m_Comp = SheetLabel; + ObjNet[NbrItem].m_SheetList = *sheetlist; + ObjNet[NbrItem].m_Link = DrawList; + ObjNet[NbrItem].m_Type = NET_SHEETLABEL; ObjNet[NbrItem].m_ElectricalType = SheetLabel->m_Shape; - ObjNet[NbrItem].m_Label = &SheetLabel->m_Text; - ObjNet[NbrItem].m_SheetNumber = NumSheet; - ObjNet[NbrItem].m_NumInclude = NumInclude; - ObjNet[NbrItem].m_Start = SheetLabel->m_Pos; - ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start; + ObjNet[NbrItem].m_Label = &SheetLabel->m_Text; + ObjNet[NbrItem].m_SheetListInclude = list; + ObjNet[NbrItem].m_Start = SheetLabel->m_Pos; + ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start; /* Si c'est un Bus, eclatement en Label */ if( ii ) @@ -712,7 +714,7 @@ static void ConnectBusLabels( ObjetNetListStruct* Label, int NbItems ) { if( (Label->m_Type == NET_SHEETBUSLABELMEMBER) || (Label->m_Type == NET_BUSLABELMEMBER) - || (Label->m_Type == NET_GLOBBUSLABELMEMBER) ) + || (Label->m_Type == NET_HIERBUSLABELMEMBER) ) { if( Label->GetNet() == 0 ) { @@ -724,7 +726,7 @@ static void ConnectBusLabels( ObjetNetListStruct* Label, int NbItems ) { if( (LabelInTst->m_Type == NET_SHEETBUSLABELMEMBER) || (LabelInTst->m_Type == NET_BUSLABELMEMBER) - || (LabelInTst->m_Type == NET_GLOBBUSLABELMEMBER) ) + || (LabelInTst->m_Type == NET_HIERBUSLABELMEMBER) ) { if( LabelInTst->m_BusNetCode != Label->m_BusNetCode ) continue; @@ -741,8 +743,6 @@ static void ConnectBusLabels( ObjetNetListStruct* Label, int NbItems ) } } } - - /**************************************************/ int IsBusLabel( const wxString& LabelDrawList ) /**************************************************/ @@ -830,8 +830,10 @@ static int ConvertBusToMembers( ObjetNetListStruct* BusLabel ) int NumItem, BusMember; wxString BufLine; - if( BusLabel->m_Type == NET_GLOBLABEL ) - BusLabel->m_Type = NET_GLOBBUSLABELMEMBER; + if( BusLabel->m_Type == NET_HIERLABEL ) + BusLabel->m_Type = NET_HIERBUSLABELMEMBER; + else if( BusLabel->m_Type == NET_GLOBLABEL ) + BusLabel->m_Type = NET_GLOBBUSLABELMEMBER; else if( BusLabel->m_Type == NET_SHEETLABEL ) BusLabel->m_Type = NET_SHEETBUSLABELMEMBER; else @@ -881,6 +883,9 @@ static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus ) if( OldNetCode == NewNetCode ) return; +#ifdef DEBUG + //printf("replacing net %d with %d\n", OldNetCode,NewNetCode); +#endif if( IsBus == 0 ) /* Propagation du NetCode */ { @@ -922,7 +927,7 @@ static void PointToPointConnect( ObjetNetListStruct* Ref, int IsBus, int start ) * * L'objet Ref doit avoir un NetCode valide. * - * La liste des objets est supposee classe par NumSheet Croissants, + * La liste des objets est supposee classe par SheetPath Croissants, * et la recherche se fait a partir de l'element start, 1er element * de la feuille de schema * ( il ne peut y avoir connexion physique entre elements de differentes sheets) @@ -936,15 +941,17 @@ static void PointToPointConnect( ObjetNetListStruct* Ref, int IsBus, int start ) netCode = Ref->GetNet(); for( i = start; i < g_NbrObjNet; i++ ) { - if( netTable[i].m_SheetNumber > Ref->m_SheetNumber ) - break; - + + if( netTable[i].m_SheetList != Ref->m_SheetList ) //used to be > (why?) + continue; + switch( netTable[i].m_Type ) { case NET_SEGMENT: case NET_PIN: case NET_LABEL: - case NET_GLOBLABEL: + case NET_HIERLABEL: + case NET_GLOBLABEL: case NET_SHEETLABEL: case NET_PINLABEL: case NET_JONCTION: @@ -964,7 +971,8 @@ static void PointToPointConnect( ObjetNetListStruct* Ref, int IsBus, int start ) case NET_BUS: case NET_BUSLABELMEMBER: case NET_SHEETBUSLABELMEMBER: - case NET_GLOBBUSLABELMEMBER: + case NET_HIERBUSLABELMEMBER: + case NET_GLOBBUSLABELMEMBER: break; } } @@ -975,15 +983,16 @@ static void PointToPointConnect( ObjetNetListStruct* Ref, int IsBus, int start ) netCode = Ref->m_BusNetCode; for( i = start; i Ref->m_SheetNumber ) - break; + if( netTable[i].m_SheetList != Ref->m_SheetList ) + continue; switch( netTable[i].m_Type ) { case NET_SEGMENT: case NET_PIN: case NET_LABEL: - case NET_GLOBLABEL: + case NET_HIERLABEL: + case NET_GLOBLABEL: case NET_SHEETLABEL: case NET_PINLABEL: case NET_NOCONNECT: @@ -992,7 +1001,8 @@ static void PointToPointConnect( ObjetNetListStruct* Ref, int IsBus, int start ) case NET_BUS: case NET_BUSLABELMEMBER: case NET_SHEETBUSLABELMEMBER: - case NET_GLOBBUSLABELMEMBER: + case NET_HIERBUSLABELMEMBER: + case NET_GLOBBUSLABELMEMBER: case NET_JONCTION: if( Ref->m_Start == netTable[i].m_Start || Ref->m_Start == netTable[i].m_End @@ -1031,8 +1041,8 @@ static void SegmentToPointConnect( ObjetNetListStruct* Jonction, for( i = start; i < g_NbrObjNet; i++ ) { - if( Segment[i].m_SheetNumber > Jonction->m_SheetNumber ) - break; + if( Segment[i].m_SheetList != Jonction->m_SheetList ) + continue; if( IsBus == 0 ) { @@ -1074,7 +1084,7 @@ static void SegmentToPointConnect( ObjetNetListStruct* Jonction, /***************************************************************** * Function which connects the groups of object which have the same label *******************************************************************/ -static void LabelConnection( ObjetNetListStruct* LabelRef ) +static void LabelConnect( ObjetNetListStruct* LabelRef ) { if( LabelRef->GetNet() == 0 ) return; @@ -1086,13 +1096,18 @@ static void LabelConnection( ObjetNetListStruct* LabelRef ) if( netTable[i].GetNet() == LabelRef->GetNet() ) continue; - if( netTable[i].m_SheetNumber != LabelRef->m_SheetNumber ) + if( netTable[i].m_SheetList != LabelRef->m_SheetList ) { - if( netTable[i].m_Type != NET_PINLABEL ) + if( netTable[i].m_Type != NET_PINLABEL + && netTable[i].m_Type != NET_GLOBLABEL + && netTable[i].m_Type != NET_GLOBBUSLABELMEMBER) continue; } - - if( netTable[i].m_Type == NET_LABEL + //regular labels are sheet-local; + //NET_HIERLABEL are used to connect sheets. + //there are no true global labels yet, + //though I've (tried) to implement them in this file. + if( netTable[i].m_Type == NET_LABEL || netTable[i].m_Type == NET_GLOBLABEL || netTable[i].m_Type == NET_BUSLABELMEMBER || netTable[i].m_Type == NET_GLOBBUSLABELMEMBER @@ -1100,10 +1115,7 @@ static void LabelConnection( ObjetNetListStruct* LabelRef ) { if( netTable[i].m_Label->CmpNoCase( *LabelRef->m_Label ) != 0 ) continue; - - /* Ici 2 labels identiques */ - - /* Propagation du Netcode a tous les Objets de meme NetCode */ + // Propagation du Netcode a tous les Objets de meme NetCode if( netTable[i].GetNet() ) PropageNetCode( netTable[i].GetNet(), LabelRef->GetNet(), 0 ); else @@ -1112,7 +1124,6 @@ static void LabelConnection( ObjetNetListStruct* LabelRef ) } } - /****************************************************************************/ static int TriNetCode( const void* o1, const void* o2 ) /****************************************************************************/ @@ -1127,7 +1138,6 @@ static int TriNetCode( const void* o1, const void* o2 ) return Objet1->GetNet() - Objet2->GetNet(); } - /*****************************************************************************/ static int TriBySheet( const void* o1, const void* o2 ) /*****************************************************************************/ @@ -1138,11 +1148,9 @@ static int TriBySheet( const void* o1, const void* o2 ) { ObjetNetListStruct* Objet1 = (ObjetNetListStruct*) o1; ObjetNetListStruct* Objet2 = (ObjetNetListStruct*) o2; - - return Objet1->m_SheetNumber - Objet2->m_SheetNumber; + return Objet1->m_SheetList.Cmp(Objet2->m_SheetList); } - /**********************************************************************/ static void SetUnconnectedFlag( ObjetNetListStruct* ListObj, int NbItems ) /**********************************************************************/ @@ -1202,13 +1210,15 @@ static void SetUnconnectedFlag( ObjetNetListStruct* ListObj, int NbItems ) { case NET_SEGMENT: case NET_LABEL: - case NET_GLOBLABEL: + case NET_HIERLABEL: + case NET_GLOBLABEL: case NET_SHEETLABEL: case NET_PINLABEL: case NET_BUS: case NET_BUSLABELMEMBER: case NET_SHEETBUSLABELMEMBER: - case NET_GLOBBUSLABELMEMBER: + case NET_HIERBUSLABELMEMBER: + case NET_GLOBBUSLABELMEMBER: case NET_JONCTION: break; diff --git a/eeschema/netlist.h b/eeschema/netlist.h index 285a46da9d..b401378322 100644 --- a/eeschema/netlist.h +++ b/eeschema/netlist.h @@ -39,10 +39,12 @@ enum NetObjetType { /* Type des objets de Net */ NET_JONCTION, NET_LABEL, NET_GLOBLABEL, + NET_HIERLABEL, //on a screen to indicate connection to a higher-level sheet + NET_SHEETLABEL, //on a drawscreen element to indicate connection to a lower-level sheet. NET_BUSLABELMEMBER, NET_GLOBBUSLABELMEMBER, + NET_HIERBUSLABELMEMBER, NET_SHEETBUSLABELMEMBER, - NET_SHEETLABEL, NET_PINLABEL, NET_PIN, NET_NOCONNECT @@ -60,22 +62,21 @@ enum IsConnectType { /* Valeur du Flag de connection */ class ObjetNetListStruct { public: - EDA_BaseStruct* m_Comp; /* Pointeur sur la definition de l'objet */ - void* m_Link; /* Pour SheetLabelStruct: Pointeur sur la feuille de hierarchie - * Pour les Pins: pointeur sur le composant */ - int m_Flag; /* flag pour calculs internes */ - SCH_SCREEN* m_Screen; /* Ecran d'appartenance */ + EDA_BaseStruct* m_Comp; /* Pointeur sur la definition de l'objet */ + void* m_Link; /* Pour SheetLabelStruct: Pointeur sur la feuille de hierarchie + * Pour les Pins: pointeur sur le composant */ + int m_Flag; /* flag pour calculs internes */ + DrawSheetList m_SheetList; NetObjetType m_Type; - int m_ElectricalType; /* Pour Pins et sheet labels: type electrique */ + int m_ElectricalType;/* Pour Pins et sheet labels: type electrique */ private: - int m_NetCode; /* pour elements simples */ + int m_NetCode; /* pour elements simples */ public: - int m_BusNetCode; /* pour connexions type bus */ - int m_Member; /* pour les labels type BUSWIRE ( labels de bus eclate ) + int m_BusNetCode; /* pour connexions type bus */ + int m_Member; /* pour les labels type BUSWIRE ( labels de bus eclate ) * numero de membre */ IsConnectType m_FlagOfConnection; - int m_SheetNumber; /* Sheet number for this item */ - int m_NumInclude; /* Numero de sous schema correpondant a la sheet (Gestion des GLabels et Pin Sheet)*/ + DrawSheetList m_SheetListInclude; /* sheet that the hierarchal label connects to.*/ long m_PinNum; /* numero de pin( 4 octets -> 4 codes ascii) */ const wxString* m_Label; /* Tous types Labels:pointeur sur la wxString definissant le label */ wxPoint m_Start, m_End; @@ -89,8 +90,22 @@ public: int GetNet() const { return m_NetCode; } }; +/* Structures pour memo et liste des elements */ +typedef struct ListLabel +{ + int m_LabelType; + void * m_Label; + char m_SheetPath[32]; +} ListLabel; +typedef struct ListComponent +{ + EDA_SchComponentStruct * m_Comp; + char m_Ref[32]; + //have to store it here since the object refrerences will be duplicated. + DrawSheetList m_SheetList; //composed of UIDs +} ListComponent; -/* Structure decrivant 1 composant de la schematique (pour annotation ) */ +/* Structure decrivant 1 composant de la schematique (pour *annotation* ) */ struct CmpListStruct { public: @@ -98,14 +113,15 @@ public: int m_NbParts; /* Nombre de parts par boitier */ bool m_PartsLocked; // For multi part components: True if the part cannot be changed int m_Unit; /* Numero de part */ - int m_Sheet; /* Numero de hierarchie */ - unsigned long m_TimeStamp; /* Signature temporelle */ + DrawSheetList m_SheetList; + unsigned long m_TimeStamp; /* unique identification number */ int m_IsNew; /* != 0 pour composants non annotes */ char m_TextValue[32]; /* Valeur */ char m_TextRef[32]; /* Reference ( hors numero ) */ int m_NumRef; /* Numero de reference */ int m_Flag; /* flag pour calculs internes */ wxPoint m_Pos; /* position components */ + char m_Path[128]; // the 'path' of the object in the sheet hierarchy. }; diff --git a/eeschema/netlist_control.cpp b/eeschema/netlist_control.cpp index 6ba99af819..977939ffc3 100644 --- a/eeschema/netlist_control.cpp +++ b/eeschema/netlist_control.cpp @@ -539,7 +539,7 @@ void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event ) g_NetFormat = CurrPage->m_IdNetType; /* Calculate the netlist filename */ - FullFileName = ScreenSch->m_FileName; + FullFileName = g_RootSheet->m_s->m_FileName; switch( g_NetFormat ) { @@ -558,7 +558,7 @@ void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event ) Mask = wxT( "*" ) + FileExt + wxT( "*" ); ChangeFileNameExt( FullFileName, FileExt ); - + FullFileName = FullFileName.AfterLast('/'); FullFileName = EDA_FileSelector( _( "Netlist files:" ), wxEmptyString, /* Defaut path */ FullFileName, /* Defaut filename */ @@ -581,7 +581,7 @@ void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event ) } /* Cleanup the entire hierarchy */ - EDA_ScreenList ScreenList( NULL ); + EDA_ScreenList ScreenList; for( SCH_SCREEN* screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) { bool ModifyWires; @@ -649,7 +649,7 @@ void WinEDA_NetlistFrame::RunSimulator( wxCommandEvent& event ) CommandLine = g_SimulatorCommandLine.AfterFirst( ' ' ); /* Calculate the netlist filename */ - NetlistFullFileName = ScreenSch->m_FileName; + NetlistFullFileName = g_RootSheet->m_s->m_FileName; ChangeFileNameExt( NetlistFullFileName, wxT( ".cir" ) ); AddDelimiterString( NetlistFullFileName ); CommandLine += wxT( " " ) + NetlistFullFileName; diff --git a/eeschema/onleftclick.cpp b/eeschema/onleftclick.cpp index 2782d594c3..d1dfeef16e 100644 --- a/eeschema/onleftclick.cpp +++ b/eeschema/onleftclick.cpp @@ -22,11 +22,11 @@ static wxArrayString s_PowerNameList; void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) /**********************************************************************************/ -/* Traite les commandes declenchée par le bouton gauche de la souris, - * quand un outil est deja selectionné +/* Traite les commandes declench�e par le bouton gauche de la souris, + * quand un outil est deja selectionn� */ { - EDA_BaseStruct* DrawStruct = m_CurrentScreen->GetCurItem(); + EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem(); if( (m_ID_current_state == 0) || ( DrawStruct && DrawStruct->m_Flags ) ) { @@ -39,6 +39,7 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) { case DRAW_LABEL_STRUCT_TYPE: case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: case DRAW_TEXT_STRUCT_TYPE: case DRAW_SHEETLABEL_STRUCT_TYPE: case DRAW_SHEET_STRUCT_TYPE: @@ -47,8 +48,8 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) case DRAW_LIB_ITEM_STRUCT_TYPE: case DRAW_PART_TEXT_STRUCT_TYPE: DrawStruct->Place( this, DC ); - m_CurrentScreen->SetCurItem( NULL ); - TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + GetScreen()->SetCurItem( NULL ); + TestDanglingEnds( GetScreen()->EEDrawList, DC ); return; case SCREEN_STRUCT_TYPE: @@ -91,14 +92,14 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) InstallNextScreen( (DrawSheetStruct*) DrawStruct ); } else - InstallPreviousScreen(); + InstallPreviousSheet(); break; case ID_NOCONN_BUTT: if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) { g_ItemToRepeat = CreateNewNoConnectStruct( DC ); - m_CurrentScreen->SetCurItem( g_ItemToRepeat ); + GetScreen()->SetCurItem( g_ItemToRepeat ); DrawPanel->m_AutoPAN_Request = TRUE; } else @@ -106,14 +107,14 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) DrawStruct->Place( this, DC ); DrawPanel->m_AutoPAN_Request = FALSE; } - TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + TestDanglingEnds( GetScreen()->EEDrawList, DC ); break; case ID_JUNCTION_BUTT: if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) { - g_ItemToRepeat = CreateNewJunctionStruct( DC, m_CurrentScreen->m_Curseur, TRUE ); - m_CurrentScreen->SetCurItem( g_ItemToRepeat ); + g_ItemToRepeat = CreateNewJunctionStruct( DC, GetScreen()->m_Curseur, TRUE ); + GetScreen()->SetCurItem( g_ItemToRepeat ); DrawPanel->m_AutoPAN_Request = TRUE; } else @@ -121,7 +122,7 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) DrawStruct->Place( this, DC ); DrawPanel->m_AutoPAN_Request = FALSE; } - TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + TestDanglingEnds( GetScreen()->EEDrawList, DC ); break; case ID_WIRETOBUS_ENTRY_BUTT: @@ -132,23 +133,23 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) CreateBusEntry( DC, (m_ID_current_state == ID_WIRETOBUS_ENTRY_BUTT) ? WIRE_TO_BUS : BUS_TO_BUS ); - m_CurrentScreen->SetCurItem( DrawStruct ); + GetScreen()->SetCurItem( DrawStruct ); DrawPanel->m_AutoPAN_Request = TRUE; } else { DrawStruct->Place( this, DC ); - m_CurrentScreen->SetCurItem( NULL ); - TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + GetScreen()->SetCurItem( NULL ); + TestDanglingEnds( GetScreen()->EEDrawList, DC ); DrawPanel->m_AutoPAN_Request = FALSE; } break; case ID_SCHEMATIC_DELETE_ITEM_BUTT: LocateAndDeleteItem( this, DC ); - m_CurrentScreen->SetModify(); - m_CurrentScreen->SetCurItem( NULL ); - TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + GetScreen()->SetModify(); + GetScreen()->SetCurItem( NULL ); + TestDanglingEnds( GetScreen()->EEDrawList, DC ); break; case ID_WIRE_BUTT: @@ -169,7 +170,7 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) case ID_TEXT_COMMENT_BUTT: if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) { - m_CurrentScreen->SetCurItem( CreateNewText( DC, LAYER_NOTES ) ); + GetScreen()->SetCurItem( CreateNewText( DC, LAYER_NOTES ) ); DrawPanel->m_AutoPAN_Request = TRUE; } else @@ -182,42 +183,59 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) case ID_LABEL_BUTT: if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) { - m_CurrentScreen->SetCurItem( CreateNewText( DC, LAYER_LOCLABEL ) ); + GetScreen()->SetCurItem( CreateNewText( DC, LAYER_LOCLABEL ) ); DrawPanel->m_AutoPAN_Request = TRUE; } else { DrawStruct->Place( this, DC ); DrawPanel->m_AutoPAN_Request = FALSE; - TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + TestDanglingEnds( GetScreen()->EEDrawList, DC ); } break; case ID_GLABEL_BUTT: + case ID_HIERLABEL_BUTT: if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) { - m_CurrentScreen->SetCurItem( CreateNewText( DC, LAYER_GLOBLABEL ) ); + if(m_ID_current_state == ID_GLABEL_BUTT) + GetScreen()->SetCurItem( CreateNewText( DC, LAYER_GLOBLABEL ) ); + if(m_ID_current_state == ID_HIERLABEL_BUTT) + GetScreen()->SetCurItem( CreateNewText( DC, LAYER_HIERLABEL ) ); DrawPanel->m_AutoPAN_Request = TRUE; } else { DrawStruct->Place( this, DC ); DrawPanel->m_AutoPAN_Request = FALSE; - TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + TestDanglingEnds( GetScreen()->EEDrawList, DC ); } break; + + if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + GetScreen()->SetCurItem( CreateNewText( DC, LAYER_HIERLABEL ) ); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else + { + DrawStruct->Place( this, DC ); + DrawPanel->m_AutoPAN_Request = FALSE; + TestDanglingEnds( GetScreen()->EEDrawList, DC ); + } + break; case ID_SHEET_SYMBOL_BUTT: if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) { - m_CurrentScreen->SetCurItem( CreateSheet( DC ) ); + GetScreen()->SetCurItem( CreateSheet( DC ) ); DrawPanel->m_AutoPAN_Request = TRUE; } else { DrawStruct->Place( this, DC ); DrawPanel->m_AutoPAN_Request = FALSE; - TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + TestDanglingEnds( GetScreen()->EEDrawList, DC ); } break; @@ -233,24 +251,24 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) && (DrawStruct->m_Flags == 0) ) { if( m_ID_current_state == ID_IMPORT_GLABEL_BUTT ) - m_CurrentScreen->SetCurItem( + GetScreen()->SetCurItem( Import_PinSheet( (DrawSheetStruct*) DrawStruct, DC ) ); else - m_CurrentScreen->SetCurItem( + GetScreen()->SetCurItem( Create_PinSheet( (DrawSheetStruct*) DrawStruct, DC ) ); } else if( (DrawStruct->Type() == DRAW_SHEETLABEL_STRUCT_TYPE) && (DrawStruct->m_Flags != 0) ) { DrawStruct->Place( this, DC ); - TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + TestDanglingEnds( GetScreen()->EEDrawList, DC ); } break; case ID_COMPONENT_BUTT: if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) { - m_CurrentScreen->SetCurItem( Load_Component( DC, wxEmptyString, + GetScreen()->SetCurItem( Load_Component( DC, wxEmptyString, s_CmpNameList, TRUE ) ); DrawPanel->m_AutoPAN_Request = TRUE; } @@ -258,14 +276,14 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) { DrawStruct->Place( this, DC ); DrawPanel->m_AutoPAN_Request = FALSE; - TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + TestDanglingEnds( GetScreen()->EEDrawList, DC ); } break; case ID_PLACE_POWER_BUTT: if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) { - m_CurrentScreen->SetCurItem( + GetScreen()->SetCurItem( Load_Component( DC, wxT( "power" ), s_PowerNameList, FALSE ) ); DrawPanel->m_AutoPAN_Request = TRUE; } @@ -273,7 +291,7 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) { DrawStruct->Place( this, DC ); DrawPanel->m_AutoPAN_Request = FALSE; - TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + TestDanglingEnds( GetScreen()->EEDrawList, DC ); } break; @@ -294,14 +312,14 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) void WinEDA_SchematicFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) /***************************************************************************/ -/* Appelé sur un double click: - * pour un élément editable (textes, composant): +/* Appel� sur un double click: + * pour un �l�ment editable (textes, composant): * appel de l'editeur correspondant. * pour une connexion en cours: * termine la connexion */ { - EDA_BaseStruct* DrawStruct = m_CurrentScreen->GetCurItem(); + EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem(); wxPoint pos = GetPosition(); switch( m_ID_current_state ) @@ -315,7 +333,7 @@ void WinEDA_SchematicFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) if( (DrawStruct == NULL) || (DrawStruct->m_Flags != 0) ) break; - // Element localisé + // Element localis� switch( DrawStruct->Type() ) { case DRAW_SHEET_STRUCT_TYPE: @@ -330,6 +348,7 @@ void WinEDA_SchematicFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) case DRAW_TEXT_STRUCT_TYPE: case DRAW_LABEL_STRUCT_TYPE: case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: EditSchematicText( (DrawTextStruct*) DrawStruct, DC ); break; diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index d7d8718bd5..a14cb6d55d 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -56,6 +56,7 @@ static void AddMenusForPinSheet( wxMenu* PopMenu, DrawSheetLabelStruct* PinSheet static void AddMenusForText( wxMenu* PopMenu, DrawTextStruct* Text ); static void AddMenusForLabel( wxMenu* PopMenu, DrawLabelStruct* Label ); static void AddMenusForGLabel( wxMenu* PopMenu, DrawGlobalLabelStruct* GLabel ); +static void AddMenusForHLabel( wxMenu* PopMenu, DrawHierLabelStruct* GLabel ); static void AddMenusForComponent( wxMenu* PopMenu, EDA_SchComponentStruct* Component ); static void AddMenusForComponentField( wxMenu* PopMenu, PartTextStruct* Field ); static void AddMenusForJunction( wxMenu* PopMenu, DrawJunctionStruct* Junction, @@ -82,13 +83,13 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) /*****************************************************************/ -/* Prepare le menu PullUp affiché par un click sur le bouton droit +/* Prepare le menu PullUp affich� par un click sur le bouton droit * de la souris. - * Ce menu est ensuite complété par la liste des commandes de ZOOM + * Ce menu est ensuite compl�t� par la liste des commandes de ZOOM */ { - EDA_BaseStruct* DrawStruct = m_CurrentScreen->GetCurItem(); - bool BlockActive = (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE); + EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem(); + bool BlockActive = (GetScreen()->BlockLocate.m_Command != BLOCK_IDLE); DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu @@ -108,7 +109,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, { DrawSheetLabelStruct* slabel; slabel = LocateSheetLabel( (DrawSheetStruct*) DrawStruct, - m_CurrentScreen->m_Curseur ); + GetScreen()->m_Curseur ); if( slabel ) DrawStruct = slabel; } @@ -138,7 +139,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, if( DrawStruct == NULL ) { - if( m_CurrentScreen != ScreenSch ) + if( GetSheet()->Last() != g_RootSheet ) { ADD_MENUITEM( PopMenu, ID_POPUP_SCH_LEAVE_SHEET, _( "Leave Sheet" ), leave_sheet_xpm ); PopMenu->AppendSeparator(); @@ -146,7 +147,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, return true; } - m_CurrentScreen->SetCurItem( DrawStruct ); + GetScreen()->SetCurItem( DrawStruct ); int flags = DrawStruct->m_Flags; bool is_new = (flags & IS_NEW) ? TRUE : FALSE; @@ -190,6 +191,10 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, case DRAW_GLOBAL_LABEL_STRUCT_TYPE: AddMenusForGLabel( PopMenu, (DrawGlobalLabelStruct*) DrawStruct ); break; + + case DRAW_HIER_LABEL_STRUCT_TYPE: + AddMenusForHLabel( PopMenu, (DrawHierLabelStruct*) DrawStruct ); + break; case DRAW_PART_TEXT_STRUCT_TYPE: { @@ -198,7 +203,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, break; // Many fields are inside a component. If this is the case, add the component menu - EDA_SchComponentStruct* Component = LocateSmallestComponent( GetScreen() ); + EDA_SchComponentStruct* Component = LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ); if( Component ) { PopMenu->AppendSeparator(); @@ -378,6 +383,28 @@ void AddMenusForGLabel( wxMenu* PopMenu, DrawGlobalLabelStruct* GLabel ) ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT, _( "Change Type" ), gl_change_xpm ); } +/*******************************************************************/ +void AddMenusForHLabel( wxMenu* PopMenu, DrawHierLabelStruct* HLabel ) +/*******************************************************************/ +/* Add menu commands for a hierarchal Label + */ +{ + wxMenu* menu_change_type = new wxMenu; + + if( !HLabel->m_Flags ) + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _( "Move Hlabel" ), move_text_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _( "Rotate HLabel (R)" ), rotate_glabel_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, _( "Edit HLabel" ), edit_text_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Hlabel" ), delete_text_xpm ); + + // add menu change type text (to label, glabel, text): + ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL, + _( "Change to Label" ), glabel2label_xpm ); + ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT, + _( "Change to Text" ), glabel2text_xpm ); + ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type, + ID_POPUP_SCH_CHANGE_TYPE_TEXT, _( "Change Type" ), gl_change_xpm ); +} /*****************************************************************/ @@ -442,14 +469,14 @@ void AddMenusForJunction( wxMenu* PopMenu, DrawJunctionStruct* Junction, if( !is_new ) { - if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen()->EEDrawList, + if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen(), WIREITEM | BUSITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) ) ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), break_line_xpm ); } ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "delete junction" ), delete_xpm ); - if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen()->EEDrawList, + if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen(), WIREITEM | BUSITEM ) ) { ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete node" ), delete_node_xpm ); @@ -482,7 +509,7 @@ void AddMenusForWire( wxMenu* PopMenu, EDA_DrawLineStruct* Wire, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete connection" ), delete_connection_xpm ); - if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen()->EEDrawList, + if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen(), WIREITEM | BUSITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) ) ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), break_line_xpm ); diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index 2d8dfce1d1..205c769843 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -54,7 +54,7 @@ static int LastPinType = PIN_INPUT, /*************************************************************************/ void WinEDA_PinPropertiesFrame::PinPropertiesAccept(wxCommandEvent& event) /*************************************************************************/ -/* Met a jour les differents parametres pour le composant en cours d'édition +/* Met a jour les differents parametres pour le composant en cours d'�dition */ { wxString msg; @@ -282,7 +282,7 @@ wxPoint startPos; startPos.x = OldPos.x; startPos.y = -OldPos.y; DrawPanel->CursorOff(DC); - m_CurrentScreen->m_Curseur = startPos; + GetScreen()->m_Curseur = startPos; DrawPanel->MouseToCursorSchema(); CurrentPin->Display_Infos_DrawEntry(this); @@ -785,7 +785,7 @@ bool selected = (MasterPin->m_Selected & IS_SELECTED) != 0; /************************************************************************/ void WinEDA_LibeditFrame::RepeatPinItem(wxDC * DC, LibDrawPin * SourcePin) /************************************************************************/ -/* Creation d'une nouvelle pin par copie de la précédente ( fct REPEAT) */ +/* Creation d'une nouvelle pin par copie de la pr�c�dente ( fct REPEAT) */ { LibDrawPin * Pin; wxString msg; diff --git a/eeschema/plot.cpp b/eeschema/plot.cpp index 5fdaec6e38..1ce7c00ad9 100644 --- a/eeschema/plot.cpp +++ b/eeschema/plot.cpp @@ -379,7 +379,7 @@ int orient, color = -1; } SetCurrentLineWidth(-1); - + //not sure what to do here in terms of plotting components that may have multiple REFERENCE entries. if( !IsMulti || (FieldNumber != REFERENCE) ) { PlotGraphicText( g_PlotFormat, wxPoint(px, py), color, Field->m_Text, @@ -520,6 +520,7 @@ int HalfSize; switch ( Struct->Type() ) { case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: case DRAW_LABEL_STRUCT_TYPE: case DRAW_TEXT_STRUCT_TYPE: Text = ((DrawTextStruct*)Struct)->m_Text; @@ -529,8 +530,9 @@ int HalfSize; pX = ((DrawTextStruct*)Struct)->m_Pos.x; pY = ((DrawTextStruct*)Struct)->m_Pos.y; offset = TXTMARGE; - if ( Struct->Type() == DRAW_GLOBAL_LABEL_STRUCT_TYPE) - offset += Size.x; // We must also draw the Glabel graphic symbol + if ( Struct->Type() == DRAW_GLOBAL_LABEL_STRUCT_TYPE || + Struct->Type() == DRAW_HIER_LABEL_STRUCT_TYPE ) + offset += Size.x; // We must draw the Glabel graphic symbol if ( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt ) color = ReturnLayerColor(((DrawTextStruct*)Struct)->m_Layer); break; @@ -545,7 +547,8 @@ int HalfSize; switch(Orient) { case 0: /* Orientation horiz normale */ - if( Struct->Type() == DRAW_GLOBAL_LABEL_STRUCT_TYPE ) + if( Struct->Type() == DRAW_GLOBAL_LABEL_STRUCT_TYPE || + Struct->Type() == DRAW_HIER_LABEL_STRUCT_TYPE ) PlotGraphicText(g_PlotFormat, wxPoint(pX - offset, pY), color, Text, TEXT_ORIENT_HORIZ, Size, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER); @@ -556,7 +559,8 @@ int HalfSize; break; case 1: /* Orientation vert UP */ - if( Struct->Type() == DRAW_GLOBAL_LABEL_STRUCT_TYPE ) + if( Struct->Type() == DRAW_GLOBAL_LABEL_STRUCT_TYPE || + Struct->Type() == DRAW_HIER_LABEL_STRUCT_TYPE ) PlotGraphicText(g_PlotFormat, wxPoint(pX, pY + offset), color, Text, TEXT_ORIENT_VERT, Size, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP); @@ -567,7 +571,8 @@ int HalfSize; break; case 2: /* Horiz Orientation - Right justified */ - if( Struct->Type() == DRAW_GLOBAL_LABEL_STRUCT_TYPE) + if( Struct->Type() == DRAW_GLOBAL_LABEL_STRUCT_TYPE || + Struct->Type() == DRAW_HIER_LABEL_STRUCT_TYPE ) PlotGraphicText(g_PlotFormat, wxPoint(pX + offset, pY), color, Text, TEXT_ORIENT_HORIZ, Size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); @@ -578,7 +583,8 @@ int HalfSize; break; case 3: /* Orientation vert BOTTOM */ - if( Struct->Type() == DRAW_GLOBAL_LABEL_STRUCT_TYPE) + if( Struct->Type() == DRAW_GLOBAL_LABEL_STRUCT_TYPE || + Struct->Type() == DRAW_HIER_LABEL_STRUCT_TYPE ) PlotGraphicText(g_PlotFormat, wxPoint(pX, pY - offset), color, Text, TEXT_ORIENT_VERT, Size, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM); @@ -590,7 +596,8 @@ int HalfSize; } /* Trace du symbole associe au label global */ - if( Struct->Type() == DRAW_GLOBAL_LABEL_STRUCT_TYPE) + if( Struct->Type() == DRAW_GLOBAL_LABEL_STRUCT_TYPE || + Struct->Type() == DRAW_HIER_LABEL_STRUCT_TYPE ) { int jj, imax; HalfSize = Size.x / 2; diff --git a/eeschema/plothpgl.cpp b/eeschema/plothpgl.cpp index 7db53a6c37..38c532fa53 100644 --- a/eeschema/plothpgl.cpp +++ b/eeschema/plothpgl.cpp @@ -477,9 +477,9 @@ void WinEDA_PlotHPGLFrame::ReturnSheetDims( BASE_SCREEN * screen, { Ki_PageDescr * PlotSheet; - if( screen == NULL ) screen = ActiveScreen; + if( screen == NULL ) screen = m_Parent->GetScreen(); - PlotSheet = screen->m_CurrentSheet; + PlotSheet = screen->m_CurrentSheetDesc; SheetSize = PlotSheet->m_Size; SheetOffset = PlotSheet->m_Offset; @@ -499,10 +499,10 @@ int margin; g_PlotFormat = PLOT_FORMAT_HPGL; /* Build the screen list */ - EDA_ScreenList ScreenList(NULL); + EDA_ScreenList ScreenList; if ( Select_PlotAll == TRUE ) screen = ScreenList.GetFirst(); - else screen = ActiveScreen; + else screen = m_Parent->GetScreen(); for ( ; screen != NULL; screen = ScreenList.GetNext() ) { ReturnSheetDims(screen, SheetSize, SheetOffset); @@ -511,7 +511,7 @@ int margin; g_PlotScaleY = Scale_Y * SCALE_HPGL ; margin = 400; // Margin in mils - PlotSheet = screen->m_CurrentSheet; + PlotSheet = screen->m_CurrentSheetDesc; g_PlotScaleX = g_PlotScaleX * (SheetSize.x - 2 * margin)/ PlotSheet->m_Size.x; g_PlotScaleY = g_PlotScaleY * (SheetSize.y - 2 * margin) / PlotSheet->m_Size.y; @@ -636,6 +636,7 @@ wxString msg; case DRAW_TEXT_STRUCT_TYPE : case DRAW_LABEL_STRUCT_TYPE : case DRAW_GLOBAL_LABEL_STRUCT_TYPE : + case DRAW_HIER_LABEL_STRUCT_TYPE : PlotTextStruct(DrawList); break; diff --git a/eeschema/plotps.cpp b/eeschema/plotps.cpp index 5aa2a1982f..6a1f1e1670 100644 --- a/eeschema/plotps.cpp +++ b/eeschema/plotps.cpp @@ -328,13 +328,13 @@ wxPoint plot_offset; g_PlotFormat = PLOT_FORMAT_POST; /* Build the screen list */ - EDA_ScreenList ScreenList(NULL); + EDA_ScreenList ScreenList; if ( AllPages == TRUE ) screen = ScreenList.GetFirst(); else screen = ActiveScreen; for ( ; screen != NULL; screen = ScreenList.GetNext() ) { - PlotSheet = screen->m_CurrentSheet; + PlotSheet = screen->m_CurrentSheetDesc; RealSheet = &g_Sheet_A4; if ( pagesize == PAGE_SIZE_AUTO ) RealSheet = PlotSheet; else if ( pagesize == PAGE_SIZE_A ) RealSheet = &g_Sheet_A; @@ -472,6 +472,7 @@ wxPoint StartPos, EndPos; case DRAW_TEXT_STRUCT_TYPE : case DRAW_LABEL_STRUCT_TYPE : case DRAW_GLOBAL_LABEL_STRUCT_TYPE : + case DRAW_HIER_LABEL_STRUCT_TYPE : PlotTextStruct(DrawList); break; diff --git a/eeschema/program.h b/eeschema/program.h index 0d84e4cffa..79cdad2cfc 100644 --- a/eeschema/program.h +++ b/eeschema/program.h @@ -239,7 +239,7 @@ class DrawTextStruct : public EDA_BaseStruct, public EDA_TextStruct public: int m_Layer; int m_Shape; - bool m_IsDangling; // TRUE si non connecté + bool m_IsDangling; // TRUE si non connect� public: DrawTextStruct( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString, @@ -280,8 +280,8 @@ public: class DrawGlobalLabelStruct : public DrawTextStruct { public: - DrawGlobalLabelStruct( const wxPoint& pos = wxPoint( 0, 0 ), - const wxString& text = wxEmptyString ); + DrawGlobalLabelStruct(const wxPoint& pos = wxPoint( 0, 0 ), + const wxString& text = wxEmptyString); ~DrawGlobalLabelStruct() { } virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode, int Color = -1 ); @@ -291,7 +291,20 @@ public: return wxT( "DrawGlobalLabel" ); } }; +class DrawHierLabelStruct : public DrawTextStruct +{ +public: + DrawHierLabelStruct(const wxPoint& pos = wxPoint( 0, 0 ), + const wxString& text = wxEmptyString); + ~DrawHierLabelStruct() { } + virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode, + int Color = -1 ); + virtual wxString GetClass() const + { + return wxT( "DrawHierLabel" ); + } +}; #define MAX_LAYERS 44 class LayerStruct diff --git a/eeschema/protos.h b/eeschema/protos.h index 3cf215af78..4443c26b79 100644 --- a/eeschema/protos.h +++ b/eeschema/protos.h @@ -1,4 +1,4 @@ -/*****************************************/ +//*****************************************/ /* prototypage des fonctions de EESchema */ /*****************************************/ void FreeLibraryEntry(LibCmpEntry * Entry); @@ -10,11 +10,9 @@ LibEDA_BaseStruct * LocatePin(const wxPoint & RefPos, const wxString& ReturnDefaultFieldName( int aFieldNdx ); - /***************/ /* FILE_IO.CPP */ /***************/ -void SaveProject(WinEDA_SchematicFrame * frame); /****************/ @@ -125,9 +123,9 @@ EDA_SchComponentStruct * LocateSmallestComponent( SCH_SCREEN * Screen ); /* Recherche du plus petit (en surface) composant pointe par la souris */ EDA_BaseStruct * PickStruct(EDA_Rect & block, - EDA_BaseStruct *DrawList, int SearchMask ); + BASE_SCREEN* screen, int SearchMask ); EDA_BaseStruct * PickStruct(const wxPoint & refpos, - EDA_BaseStruct *DrawList, int SearchMask ); + BASE_SCREEN* screen, int SearchMask); /* 2 functions EDA_BaseStruct * PickStruct: Search in block, or Serach at location pos @@ -189,6 +187,7 @@ int distance(int dx, int dy, int spot_cX, int spot_cY, int seuil); segment vertical segment quelconque */ + /***************/ /* EEREDRAW.CPP */ /***************/ @@ -303,7 +302,7 @@ void ReAnnotatePowerSymbolsOnly(); void InstallAnnotateFrame(WinEDA_SchematicFrame * parent, wxPoint &pos); int CheckAnnotate(WinEDA_SchematicFrame * frame, bool OneSheetOnly); - /* Retourne le nombre de composants non annotes ou erronés + /* Retourne le nombre de composants non annotes ou erron�s Si OneSheetOnly : recherche sur le schema courant else: recherche sur toute la hierarchie */ @@ -328,7 +327,6 @@ void PlotTextStruct(EDA_BaseStruct *Struct); /* DELSHEET.CPP */ /***************/ void DeleteSubHierarchy(DrawSheetStruct * Sheet, bool confirm_deletion); -void ClearDrawList(EDA_BaseStruct *DrawList, bool confirm_deletion); /* free the draw list DrawList and the subhierarchies */ bool ClearProjectDrawList(SCH_SCREEN * FirstWindow, bool confirm_deletion); /* free the draw list screen->EEDrawList and the subhierarchies clear the screen datas (filenames ..) @@ -411,7 +409,8 @@ bool LibArchive(wxWindow * frame, const wxString & ArchFullFileName); /* GENLISTE.CPP */ /***************/ void InstallToolsFrame(WinEDA_DrawFrame *parent, wxPoint &pos); -int GenListeCmp( EDA_BaseStruct ** List ); +struct ListComponent; +int GenListeCmp( ListComponent * List ); /**************/ /* CLEANUP.CPP */ diff --git a/eeschema/save_schemas.cpp b/eeschema/save_schemas.cpp index 956a2e932c..f1a83f8e8a 100644 --- a/eeschema/save_schemas.cpp +++ b/eeschema/save_schemas.cpp @@ -31,18 +31,18 @@ static void SaveLayers(FILE *f); *****************************************************************************/ bool WinEDA_SchematicFrame::SaveEEFile(SCH_SCREEN *screen, int FileSave) { -wxString msg; -wxString Name, BakName; -const wxChar **LibNames; -const char * layer, *width; -int ii, shape; -bool Failed = FALSE; -EDA_BaseStruct *Phead; -Ki_PageDescr * PlotSheet; -FILE *f; -wxString dirbuf; + wxString msg; + wxString Name, BakName; + const wxChar **LibNames; + const char * layer, *width; + int ii, shape; + bool Failed = FALSE; + EDA_BaseStruct *Phead; + Ki_PageDescr * PlotSheet; + FILE *f; + wxString dirbuf; - if ( screen == NULL ) screen = (SCH_SCREEN*) ActiveScreen; + if ( screen == NULL ) screen = (SCH_SCREEN*)GetScreen(); /* If no name exists in the window yet - save as new. */ if( screen->m_FileName.IsEmpty() ) FileSave = FILE_SAVE_NEW; @@ -58,8 +58,7 @@ wxString dirbuf; { ChangeFileNameExt(BakName, wxT(".bak")); wxRemoveFile(BakName); /* delete Old .bak file */ - if( ! wxRenameFile(Name, BakName) ) - { + if( ! wxRenameFile(Name, BakName) ){ DisplayError(this, wxT("Warning: unable to rename old file"), 10); } } @@ -69,8 +68,8 @@ wxString dirbuf; { wxString mask = wxT("*") + g_SchExtBuffer; Name = EDA_FileSelector(_("Schematic files:"), - wxEmptyString, /* Chemin par defaut */ - screen->m_FileName, /* nom fichier par defaut, et resultat */ + wxEmptyString, /* Chemin par defaut */ + screen->m_FileName, /* nom fichier par defaut, et resultat */ g_SchExtBuffer, /* extension par defaut */ mask, /* Masque d'affichage */ this, @@ -122,11 +121,11 @@ wxString dirbuf; SaveLayers(f); /* Sauvegarde des dimensions du schema, des textes du cartouche.. */ - PlotSheet = screen->m_CurrentSheet; + PlotSheet = screen->m_CurrentSheetDesc; fprintf(f,"$Descr %s %d %d\n",CONV_TO_UTF8(PlotSheet->m_Name), PlotSheet->m_Size.x, PlotSheet->m_Size.y); - fprintf(f,"Sheet %d %d\n",screen->m_SheetNumber, screen->m_NumberOfSheet); + fprintf(f,"Sheet %d %d\n",screen->m_ScreenNumber, screen->m_NumberOfScreen); fprintf(f,"Title \"%s\"\n",CONV_TO_UTF8(screen->m_Title)); fprintf(f,"Date \"%s\"\n",CONV_TO_UTF8(screen->m_Date)); fprintf(f,"Rev \"%s\"\n",CONV_TO_UTF8(screen->m_Revision)); @@ -258,12 +257,23 @@ wxString dirbuf; Failed = TRUE; break; - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: /* Its a Global label item. */ #undef STRUCT #define STRUCT ((DrawGlobalLabelStruct *) Phead) shape = STRUCT->m_Shape; - if (fprintf(f, "Text GLabel %-4d %-4d %-4d %-4d %s\n%s\n", + if (fprintf(f, "Text GLabel %-4d %-4d %-4d %-4d %s\n%s\n", + STRUCT->m_Pos.x, STRUCT->m_Pos.y, + STRUCT->m_Orient, STRUCT->m_Size.x, + SheetLabelType[shape], + CONV_TO_UTF8(STRUCT->m_Text)) == EOF) + Failed = TRUE; + break; + + case DRAW_HIER_LABEL_STRUCT_TYPE: /* Its a Global label item. */ + #undef STRUCT + #define STRUCT ((DrawHierLabelStruct *) Phead) + shape = STRUCT->m_Shape; + if (fprintf(f, "Text HLabel %-4d %-4d %-4d %-4d %s\n%s\n", STRUCT->m_Pos.x, STRUCT->m_Pos.y, STRUCT->m_Orient, STRUCT->m_Size.x, SheetLabelType[shape], @@ -322,18 +332,27 @@ int ii, Failed = FALSE; char Name1[256], Name2[256]; int hjustify, vjustify; - strcpy(Name1, CONV_TO_UTF8(LibItemStruct->m_Field[REFERENCE].m_Text)); - for (ii = 0; ii < (int)strlen(Name1); ii++) - if (Name1[ii] <= ' ') Name1[ii] = '~'; - + //this is redundant with the AR entries below, but it makes the + //files backwards-compatible. + if(LibItemStruct->m_References.GetCount() > 0) + strncpy(Name1, CONV_TO_UTF8(LibItemStruct->m_References[0]), sizeof(Name1)); + else{ + if(LibItemStruct->m_Field[REFERENCE].m_Text.IsEmpty()) + strncpy(Name1, CONV_TO_UTF8(LibItemStruct->m_PrefixString),sizeof(Name1)); + else + strncpy(Name1, CONV_TO_UTF8(LibItemStruct->m_Field[REFERENCE].m_Text),sizeof(Name1)); + } + for (ii = 0; ii < (int)strlen(Name1); ii++){ + if (Name1[ii] <= ' ') Name1[ii] = '~'; + } if ( ! LibItemStruct->m_ChipName.IsEmpty() ) { - strcpy(Name2, CONV_TO_UTF8(LibItemStruct->m_ChipName)); + strncpy(Name2, CONV_TO_UTF8(LibItemStruct->m_ChipName),sizeof(Name2)); for (ii = 0; ii < (int)strlen(Name2); ii++) - if (Name2[ii] <= ' ') Name2[ii] = '~'; + if (Name2[ii] <= ' ') Name2[ii] = '~'; } - else strcpy(Name2, NULL_STRING); + else strncpy(Name2, NULL_STRING,sizeof(Name2)); fprintf(f, "$Comp\n"); @@ -355,10 +374,28 @@ int hjustify, vjustify; /* Sortie de la position */ if(fprintf(f, "P %d %d\n", LibItemStruct->m_Pos.x, LibItemStruct->m_Pos.y) == EOF) - { + { Failed = TRUE; return(Failed); + } + unsigned int i; + for(i=0; i< LibItemStruct->m_References.GetCount(); i++){ + /*format: + AR Path="/140/2" Ref="C99" + where 140 is the uid of the contianing sheet + and 2 is the timestamp of this component. + (timestamps are actually 8 hex chars) + Ref is the conventional component reference for this 'path' + */ + /*printf("AR Path=\"%s\" Ref=\"%s\" \n", + CONV_TO_UTF8( LibItemStruct->m_Paths[i]), + CONV_TO_UTF8( LibItemStruct->m_References[i] ) ); */ + if( fprintf(f, "AR Path=\"%s\" Ref=\"%s\" \n", + CONV_TO_UTF8( LibItemStruct->m_Paths[i]), + CONV_TO_UTF8( LibItemStruct->m_References[i] ) ) == EOF ) + { + Failed = TRUE; break; } - + } for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) { PartTextStruct * field = & LibItemStruct->m_Field[ii]; @@ -437,11 +474,15 @@ DrawSheetLabelStruct * SheetLabel; if (fprintf(f, "S %-4d %-4d %-4d %-4d\n", SheetStruct->m_Pos.x,SheetStruct->m_Pos.y, - SheetStruct->m_Size.x,SheetStruct->m_Size.y) == EOF) - { + SheetStruct->m_Size.x,SheetStruct->m_Size.y) == EOF){ Failed = TRUE; return(Failed); - } + } + //save the unique timestamp, like other shematic parts. + if( fprintf(f, "U %8.8lX\n", SheetStruct->m_TimeStamp) == EOF ){ + Failed = TRUE; return(Failed); + } + /* Generation de la liste des 2 textes (sheetname et filename) */ if ( ! SheetStruct->m_SheetName.IsEmpty()) { diff --git a/eeschema/savelib.cpp b/eeschema/savelib.cpp index a131d1b815..2997de0bcd 100644 --- a/eeschema/savelib.cpp +++ b/eeschema/savelib.cpp @@ -609,7 +609,7 @@ int SaveOneLibrary( wxWindow* frame, const wxString& FullFileName, LibraryStruct Library->m_Modified = 0; /* Creation de l'entete de la librairie */ - Library->m_TimeStamp = GetTimeStamp(); + Library->m_TimeStamp = GetTimeStamp(); Library->WriteHeader( SaveFile ); fprintf( SaveDocFile, "%s Date: %s\n", DOCFILE_IDENT, DateAndTime( Line ) ); diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 7a78f78219..015f107d04 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -114,7 +114,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) break; // Do nothing: case ID_POPUP_CANCEL_CURRENT_COMMAND: - if( m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE ) + if( GetScreen()->BlockLocate.m_Command != BLOCK_IDLE ) DrawPanel->SetCursor( wxCursor( DrawPanel->m_PanelCursor = DrawPanel-> m_PanelDefaultCursor ) ); @@ -123,11 +123,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); } /* ne devrait pas etre execute, sauf bug: */ - if( m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE ) + if( GetScreen()->BlockLocate.m_Command != BLOCK_IDLE ) { - m_CurrentScreen->BlockLocate.m_Command = BLOCK_IDLE; - m_CurrentScreen->BlockLocate.m_State = STATE_NO_BLOCK; - m_CurrentScreen->BlockLocate.m_BlockDrawStruct = NULL; + GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; + GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; } break; @@ -166,7 +166,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_LOAD_ONE_SHEET: - LoadOneSheet( GetScreen(), wxEmptyString ); + //how is this different from above? + //LoadOneSheet( GetSheet(), wxEmptyString ); break; case ID_LOAD_FILE_1: @@ -202,9 +203,9 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_TO_PCB: { wxString Line; - if( ScreenSch->m_FileName != wxEmptyString ) + if( g_RootSheet->m_s->m_FileName != wxEmptyString ) { - Line = ScreenSch->m_FileName; + Line = GetScreen()->m_FileName; AddDelimiterString( Line ); ChangeFileNameExt( Line, wxEmptyString ); ExecuteFile( this, PCBNEW_EXE, Line ); @@ -217,9 +218,9 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_TO_CVPCB: { wxString Line; - if( ScreenSch->m_FileName != wxEmptyString ) + if( g_RootSheet->m_s->m_FileName != wxEmptyString ) { - Line = ScreenSch->m_FileName; + Line = g_RootSheet->m_s->m_FileName; AddDelimiterString( Line ); ChangeFileNameExt( Line, wxEmptyString ); ExecuteFile( this, CVPCB_EXE, Line ); @@ -248,7 +249,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) break; case wxID_CUT: - if( m_CurrentScreen->BlockLocate.m_Command != BLOCK_MOVE ) + if( GetScreen()->BlockLocate.m_Command != BLOCK_MOVE ) break; HandleBlockEndByPopUp( BLOCK_DELETE, &dc ); g_ItemToRepeat = NULL; @@ -256,7 +257,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) case wxID_PASTE: - HandleBlockBegin( &dc, BLOCK_PASTE, m_CurrentScreen->m_Curseur ); + HandleBlockBegin( &dc, BLOCK_PASTE, GetScreen()->m_Curseur ); break; case ID_GET_ANNOTATE: @@ -310,6 +311,10 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_GLABEL_BUTT: SetToolID( id, wxCURSOR_PENCIL, _( "Add Global label" ) ); break; + + case ID_HIERLABEL_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _( "Add Hierarchal label" ) ); + break; case ID_TEXT_COMMENT_BUTT: SetToolID( id, wxCURSOR_PENCIL, _( "Add Text" ) ); @@ -346,13 +351,13 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_SCH_ENTRY_SELECT_SLASH: DrawPanel->MouseToCursorSchema(); SetBusEntryShape( &dc, - (DrawBusEntryStruct*) m_CurrentScreen->GetCurItem(), '/' ); + (DrawBusEntryStruct*) GetScreen()->GetCurItem(), '/' ); break; case ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH: DrawPanel->MouseToCursorSchema(); SetBusEntryShape( &dc, - (DrawBusEntryStruct*) m_CurrentScreen->GetCurItem(), '\\' ); + (DrawBusEntryStruct*) GetScreen()->GetCurItem(), '\\' ); break; case ID_NO_SELECT_BUTT: @@ -370,85 +375,83 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_SCH_EDIT_TEXT: - EditSchematicText( - (DrawTextStruct*) m_CurrentScreen->GetCurItem(), &dc ); + EditSchematicText((DrawTextStruct*) GetScreen()->GetCurItem(), &dc ); break; case ID_POPUP_SCH_ROTATE_TEXT: DrawPanel->MouseToCursorSchema(); - ChangeTextOrient( - (DrawTextStruct*) m_CurrentScreen->GetCurItem(), &dc ); + ChangeTextOrient((DrawTextStruct*) GetScreen()->GetCurItem(), &dc ); break; case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL: DrawPanel->MouseToCursorSchema(); - ConvertTextType( (DrawTextStruct*) m_CurrentScreen->GetCurItem(), + ConvertTextType( (DrawTextStruct*) GetScreen()->GetCurItem(), &dc, DRAW_LABEL_STRUCT_TYPE ); break; case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL: DrawPanel->MouseToCursorSchema(); - ConvertTextType( (DrawTextStruct*) m_CurrentScreen->GetCurItem(), + ConvertTextType( (DrawTextStruct*) GetScreen()->GetCurItem(), &dc, DRAW_GLOBAL_LABEL_STRUCT_TYPE ); break; case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT: DrawPanel->MouseToCursorSchema(); - ConvertTextType( (DrawTextStruct*) m_CurrentScreen->GetCurItem(), + ConvertTextType( (DrawTextStruct*) GetScreen()->GetCurItem(), &dc, DRAW_TEXT_STRUCT_TYPE ); break; case ID_POPUP_SCH_SET_SHAPE_TEXT: - // Non utilisé + // Non utilis� break; case ID_POPUP_SCH_ROTATE_FIELD: DrawPanel->MouseToCursorSchema(); - RotateCmpField( (PartTextStruct*) m_CurrentScreen->GetCurItem(), &dc ); + RotateCmpField( (PartTextStruct*) GetScreen()->GetCurItem(), &dc ); break; case ID_POPUP_SCH_EDIT_FIELD: - EditCmpFieldText( (PartTextStruct*) m_CurrentScreen->GetCurItem(), &dc ); + EditCmpFieldText( (PartTextStruct*) GetScreen()->GetCurItem(), &dc ); break; case ID_POPUP_SCH_DELETE_NODE: case ID_POPUP_SCH_DELETE_CONNECTION: DrawPanel->MouseToCursorSchema(); DeleteConnection( &dc, id == ID_POPUP_SCH_DELETE_CONNECTION ? TRUE : FALSE ); - m_CurrentScreen->SetCurItem( NULL ); + GetScreen()->SetCurItem( NULL ); g_ItemToRepeat = NULL; - TestDanglingEnds( m_CurrentScreen->EEDrawList, &dc ); + TestDanglingEnds( GetScreen()->EEDrawList, &dc ); break; case ID_POPUP_SCH_BREAK_WIRE: { DrawPickedStruct* ListForUndo; DrawPanel->MouseToCursorSchema(); - ListForUndo = BreakSegment( (SCH_SCREEN*) m_CurrentScreen, - m_CurrentScreen->m_Curseur, TRUE ); + ListForUndo = BreakSegment( (SCH_SCREEN*) GetScreen(), + GetScreen()->m_Curseur, TRUE ); if( ListForUndo ) SaveCopyInUndoList( ListForUndo, IS_NEW | IS_CHANGED ); - TestDanglingEnds( m_CurrentScreen->EEDrawList, &dc ); + TestDanglingEnds( GetScreen()->EEDrawList, &dc ); } break; case ID_POPUP_SCH_DELETE_CMP: - if( m_CurrentScreen->GetCurItem() == NULL ) + if( GetScreen()->GetCurItem() == NULL ) break; // Ensure the struct is a component (could be a struct of a component, like Field, text..) - if( m_CurrentScreen->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) - m_CurrentScreen->SetCurItem( LocateSmallestComponent( GetScreen() ) ); + if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) + GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); case ID_POPUP_SCH_DELETE: - if( m_CurrentScreen->GetCurItem() == NULL ) + if( GetScreen()->GetCurItem() == NULL ) break; - DeleteStruct( this->DrawPanel, &dc, m_CurrentScreen->GetCurItem() ); - m_CurrentScreen->SetCurItem( NULL ); + DeleteStruct( this->DrawPanel, &dc, GetScreen()->GetCurItem() ); + GetScreen()->SetCurItem( NULL ); g_ItemToRepeat = NULL; - TestDanglingEnds( m_CurrentScreen->EEDrawList, &dc ); - m_CurrentScreen->SetModify(); + TestDanglingEnds( GetScreen()->EEDrawList, &dc ); + GetScreen()->SetModify(); break; case ID_SCHEMATIC_DELETE_ITEM_BUTT: @@ -457,43 +460,43 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_SCH_END_SHEET: DrawPanel->MouseToCursorSchema(); - m_CurrentScreen->GetCurItem()->Place( this, &dc ); + GetScreen()->GetCurItem()->Place( this, &dc ); break; case ID_POPUP_SCH_RESIZE_SHEET: DrawPanel->MouseToCursorSchema(); ReSizeSheet( (DrawSheetStruct*) - m_CurrentScreen->GetCurItem(), &dc ); - TestDanglingEnds( m_CurrentScreen->EEDrawList, &dc ); + GetScreen()->GetCurItem(), &dc ); + TestDanglingEnds( GetScreen()->EEDrawList, &dc ); break; case ID_POPUP_SCH_EDIT_SHEET: EditSheet( (DrawSheetStruct*) - m_CurrentScreen->GetCurItem(), &dc ); + GetScreen()->GetCurItem(), &dc ); break; case ID_POPUP_SCH_CLEANUP_SHEET: ( (DrawSheetStruct*) - m_CurrentScreen->GetCurItem() )->CleanupSheet( this, &dc ); + GetScreen()->GetCurItem() )->CleanupSheet( this, &dc ); break; case ID_POPUP_SCH_EDIT_PINSHEET: Edit_PinSheet( (DrawSheetLabelStruct*) - m_CurrentScreen->GetCurItem(), &dc ); + GetScreen()->GetCurItem(), &dc ); break; case ID_POPUP_SCH_MOVE_PINSHEET: DrawPanel->MouseToCursorSchema(); StartMove_PinSheet( (DrawSheetLabelStruct*) - m_CurrentScreen->GetCurItem(), &dc ); + GetScreen()->GetCurItem(), &dc ); break; case ID_POPUP_SCH_DRAG_CMP_REQUEST: case ID_POPUP_SCH_MOVE_CMP_REQUEST: // Ensure the struct is a component (could be a struct of a component, like Field, text..) - if( m_CurrentScreen->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) - m_CurrentScreen->SetCurItem( LocateSmallestComponent( GetScreen() ) ); - if( m_CurrentScreen->GetCurItem() == NULL ) + if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) + GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); + if( GetScreen()->GetCurItem() == NULL ) break; case ID_POPUP_SCH_MOVE_ITEM_REQUEST: DrawPanel->MouseToCursorSchema(); @@ -505,17 +508,17 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) HandleBlockEnd( &dc ); } } - else Process_Move_Item( m_CurrentScreen->GetCurItem(), &dc ); + else Process_Move_Item( GetScreen()->GetCurItem(), &dc ); break; case ID_POPUP_SCH_EDIT_CMP: // Ensure the struct is a component (could be a struct of a component, like Field, text..) - if( m_CurrentScreen->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) - m_CurrentScreen->SetCurItem( LocateSmallestComponent( GetScreen() ) ); - if( m_CurrentScreen->GetCurItem() == NULL ) + if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) + GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); + if( GetScreen()->GetCurItem() == NULL ) break; InstallCmpeditFrame( this, pos, - (EDA_SchComponentStruct*) m_CurrentScreen->GetCurItem() ); + (EDA_SchComponentStruct*) GetScreen()->GetCurItem() ); break; case ID_POPUP_SCH_MIROR_X_CMP: @@ -525,9 +528,9 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_SCH_ORIENT_NORMAL_CMP: // Ensure the struct is a component (could be a struct of a component, like Field, text..) - if( m_CurrentScreen->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) - m_CurrentScreen->SetCurItem( LocateSmallestComponent( GetScreen() ) ); - if( m_CurrentScreen->GetCurItem() == NULL ) + if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) + GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); + if( GetScreen()->GetCurItem() == NULL ) break; { int option; @@ -552,10 +555,10 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) } DrawPanel->MouseToCursorSchema(); - if( m_CurrentScreen->GetCurItem()->m_Flags == 0 ) - SaveCopyInUndoList( m_CurrentScreen->GetCurItem(), IS_CHANGED ); + if( GetScreen()->GetCurItem()->m_Flags == 0 ) + SaveCopyInUndoList( GetScreen()->GetCurItem(), IS_CHANGED ); CmpRotationMiroir( - (EDA_SchComponentStruct*) m_CurrentScreen->GetCurItem(), + (EDA_SchComponentStruct*) GetScreen()->GetCurItem(), &dc, option ); break; } @@ -567,47 +570,47 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_SCH_EDIT_VALUE_CMP: // Ensure the struct is a component (could be a struct of a component, like Field, text..) - if( m_CurrentScreen->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) - m_CurrentScreen->SetCurItem( LocateSmallestComponent( GetScreen() ) ); - if( m_CurrentScreen->GetCurItem() == NULL ) + if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) + GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); + if( GetScreen()->GetCurItem() == NULL ) break; EditComponentValue( - (EDA_SchComponentStruct*) m_CurrentScreen->GetCurItem(), &dc ); + (EDA_SchComponentStruct*) GetScreen()->GetCurItem(), &dc ); break; case ID_POPUP_SCH_EDIT_REF_CMP: // Ensure the struct is a component (could be a struct of a component, like Field, text..) - if( m_CurrentScreen->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) - m_CurrentScreen->SetCurItem( LocateSmallestComponent( GetScreen() ) ); - if( m_CurrentScreen->GetCurItem() == NULL ) + if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) + GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); + if( GetScreen()->GetCurItem() == NULL ) break; EditComponentReference( - (EDA_SchComponentStruct*) m_CurrentScreen->GetCurItem(), &dc ); + (EDA_SchComponentStruct*) GetScreen()->GetCurItem(), &dc ); break; case ID_POPUP_SCH_EDIT_FOOTPRINT_CMP: // Ensure the struct is a component (could be a struct of a component, like Field, text..) - if( m_CurrentScreen->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) - m_CurrentScreen->SetCurItem( LocateSmallestComponent( GetScreen() ) ); - if( m_CurrentScreen->GetCurItem() == NULL ) + if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) + GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); + if( GetScreen()->GetCurItem() == NULL ) break; EditComponentFootprint( - (EDA_SchComponentStruct*) m_CurrentScreen->GetCurItem(), &dc ); + (EDA_SchComponentStruct*) GetScreen()->GetCurItem(), &dc ); break; case ID_POPUP_SCH_EDIT_CONVERT_CMP: // Ensure the struct is a component (could be a struct of a component, like Field, text..) - if( m_CurrentScreen->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) - m_CurrentScreen->SetCurItem( LocateSmallestComponent( GetScreen() ) ); - if( m_CurrentScreen->GetCurItem() == NULL ) + if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) + GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); + if( GetScreen()->GetCurItem() == NULL ) break; DrawPanel->MouseToCursorSchema(); ConvertPart( - (EDA_SchComponentStruct*) m_CurrentScreen->GetCurItem(), + (EDA_SchComponentStruct*) GetScreen()->GetCurItem(), &dc ); break; @@ -615,13 +618,13 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) DrawPanel->MouseToCursorSchema(); { EDA_SchComponentStruct* olditem, * newitem; - if( m_CurrentScreen->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) - m_CurrentScreen->SetCurItem( LocateSmallestComponent( GetScreen() ) ); - olditem = (EDA_SchComponentStruct*) m_CurrentScreen->GetCurItem(); + if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) + GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); + olditem = (EDA_SchComponentStruct*) GetScreen()->GetCurItem(); if( olditem == NULL ) break; newitem = olditem->GenCopy(); - newitem->m_TimeStamp = GetTimeStamp(); + newitem->m_TimeStamp = GetTimeStamp(); newitem->ClearAnnotation(); newitem->m_Flags = IS_NEW; StartMovePart( newitem, &dc ); @@ -658,13 +661,13 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_SCH_SELECT_UNIT26: // Ensure the struct is a component (could be a struct of a component, like Field, text..) - if( m_CurrentScreen->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) - m_CurrentScreen->SetCurItem( LocateSmallestComponent( GetScreen() ) ); - if( m_CurrentScreen->GetCurItem() == NULL ) + if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) + GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); + if( GetScreen()->GetCurItem() == NULL ) break; DrawPanel->MouseToCursorSchema(); SelPartUnit( - (EDA_SchComponentStruct*) m_CurrentScreen->GetCurItem(), + (EDA_SchComponentStruct*) GetScreen()->GetCurItem(), id + 1 - ID_POPUP_SCH_SELECT_UNIT1, &dc ); break; @@ -672,14 +675,14 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_SCH_DISPLAYDOC_CMP: // Ensure the struct is a component (could be a piece of a component, like Field, text..) - if( m_CurrentScreen->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) - m_CurrentScreen->SetCurItem( LocateSmallestComponent( GetScreen() ) ); - if( m_CurrentScreen->GetCurItem() == NULL ) + if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) + GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); + if( GetScreen()->GetCurItem() == NULL ) break; { EDA_LibComponentStruct* LibEntry; LibEntry = FindLibPart( ( (EDA_SchComponentStruct*) - m_CurrentScreen->GetCurItem() )->m_ChipName, + GetScreen()->GetCurItem() )->m_ChipName, wxEmptyString, FIND_ALIAS ); if( LibEntry && LibEntry->m_DocFile != wxEmptyString ) GetAssociatedDocument( this, g_RealLibDirBuffer, LibEntry->m_DocFile ); @@ -688,7 +691,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_SCH_ENTER_SHEET: { - EDA_BaseStruct* DrawStruct = m_CurrentScreen->GetCurItem(); + EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem(); if( DrawStruct && (DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE) ) { InstallNextScreen( (DrawSheetStruct*) DrawStruct ); @@ -697,7 +700,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_SCH_LEAVE_SHEET: - InstallPreviousScreen(); + InstallPreviousSheet(); break; case ID_POPUP_CLOSE_CURRENT_TOOL: @@ -746,22 +749,22 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_SCH_ADD_JUNCTION: DrawPanel->MouseToCursorSchema(); - m_CurrentScreen->SetCurItem( - CreateNewJunctionStruct( &dc, m_CurrentScreen->m_Curseur, TRUE ) ); - TestDanglingEnds( m_CurrentScreen->EEDrawList, &dc ); - m_CurrentScreen->SetCurItem( NULL ); + GetScreen()->SetCurItem( + CreateNewJunctionStruct( &dc, GetScreen()->m_Curseur, TRUE ) ); + TestDanglingEnds( GetScreen()->EEDrawList, &dc ); + GetScreen()->SetCurItem( NULL ); break; case ID_POPUP_SCH_ADD_LABEL: case ID_POPUP_SCH_ADD_GLABEL: - m_CurrentScreen->SetCurItem( CreateNewText( &dc, + GetScreen()->SetCurItem( CreateNewText( &dc, id == ID_POPUP_SCH_ADD_LABEL ? LAYER_LOCLABEL : LAYER_GLOBLABEL ) ); - if( m_CurrentScreen->GetCurItem() ) + if( GetScreen()->GetCurItem() ) { - m_CurrentScreen->GetCurItem()->Place( this, &dc ); - TestDanglingEnds( m_CurrentScreen->EEDrawList, &dc ); - m_CurrentScreen->SetCurItem( NULL ); + GetScreen()->GetCurItem()->Place( this, &dc ); + TestDanglingEnds( GetScreen()->EEDrawList, &dc ); + GetScreen()->SetCurItem( NULL ); } break; @@ -812,6 +815,7 @@ void WinEDA_SchematicFrame::Process_Move_Item( EDA_BaseStruct* DrawStruct, case DRAW_LABEL_STRUCT_TYPE: case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: case DRAW_TEXT_STRUCT_TYPE: StartMoveTexte( (DrawTextStruct*) DrawStruct, DC ); break; diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp index 260a81b27c..11f65717a8 100644 --- a/eeschema/schematic_undo_redo.cpp +++ b/eeschema/schematic_undo_redo.cpp @@ -90,6 +90,7 @@ void SwapData( EDA_BaseStruct* Item ) case DRAW_LABEL_STRUCT_TYPE: case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_HIER_LABEL_STRUCT_TYPE: case DRAW_TEXT_STRUCT_TYPE: #undef SOURCE #undef DEST @@ -285,7 +286,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy, GetScreen()->AddItemToUndoList( NewList ); /* Clear redo list, because after new save there is no redo to do */ - GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList ); + ((SCH_SCREEN*)GetScreen())->ClearUndoORRedoList( GetScreen()->m_RedoList ); GetScreen()->m_RedoList = NULL; } @@ -361,7 +362,7 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( DrawPickedStruct* List ) while( PickedList ) { item = PickedList->m_Image; - GetScreen()->RemoveFromDrawList( item ); + ((SCH_SCREEN*)GetScreen())->RemoveFromDrawList( item ); item->m_Flags = IS_DELETED; PickedList->m_PickedStruct = item; PickedList->m_Flags = IS_DELETED; @@ -371,7 +372,7 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( DrawPickedStruct* List ) else { FirstItem = List->m_Image; - GetScreen()->RemoveFromDrawList( FirstItem ); + ((SCH_SCREEN*)GetScreen())->RemoveFromDrawList( FirstItem ); FirstItem->m_Flags = IS_DELETED; List->m_Son = FirstItem; } @@ -406,7 +407,7 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( DrawPickedStruct* List ) case IS_WIRE_IMAGE: /* Exchange the current wires and the oild wires */ - List->m_Son = GetScreen()->ExtractWires( FALSE ); + List->m_Son = ((SCH_SCREEN*)GetScreen())->ExtractWires( FALSE ); while( FirstItem ) { EDA_BaseStruct* nextitem = FirstItem->Pnext; @@ -436,7 +437,7 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( DrawPickedStruct* List ) case IS_NEW: item = PickedList->m_Image; - GetScreen()->RemoveFromDrawList( item ); + ((SCH_SCREEN*)GetScreen())->RemoveFromDrawList( item ); item->m_Flags = IS_DELETED; PickedList->m_PickedStruct = item; PickedList->m_Flags = IS_DELETED; @@ -516,7 +517,7 @@ void SCH_SCREEN::ClearUndoORRedoList( EDA_BaseStruct* List ) FirstItem = List->m_Son; CmdType = List->m_Flags; - delete List; + SAFE_DELETE( List ); if( FirstItem == NULL ) continue; @@ -541,18 +542,22 @@ void SCH_SCREEN::ClearUndoORRedoList( EDA_BaseStruct* List ) { if( (item->m_Flags & IS_NEW) == 0 ) { + printf("schematic undo_redo.cpp: undo_redo with a DRAW_SHEET_STRUCT_TYPE, checkme!!\n"); + /* sheet->EEDrawList = NULL; sheet->m_UndoList = NULL; sheet->m_RedoList = NULL; + */ } } } - if( (item->m_Flags & IS_NEW) == 0 ) - delete item; + if( (item->m_Flags & IS_NEW) == 0 ){ + SAFE_DELETE( item ); + } } DrawPickedStruct* wrapper = PickedList; PickedList = PickedList->Next(); - delete wrapper; + SAFE_DELETE( wrapper ); } } else // This is a single item: deleted copy @@ -578,14 +583,18 @@ void SCH_SCREEN::ClearUndoORRedoList( EDA_BaseStruct* List ) { if( (FirstItem->m_Flags & IS_NEW) == 0 ) { + printf("schematic undo_redo.cpp undo_redo with a DRAW_SHEET_STRUCT_TYPE, checkme!!\n"); + /* sheet->EEDrawList = NULL; sheet->m_UndoList = NULL; sheet->m_RedoList = NULL; + */ } } } - if( (FirstItem->m_Flags & IS_NEW) == 0 ) - delete FirstItem; + if( (FirstItem->m_Flags & IS_NEW) == 0 ){ + SAFE_DELETE( FirstItem ); + } } } } diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index eaad756f60..4b09dd16d3 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -95,6 +95,7 @@ BEGIN_EVENT_TABLE(WinEDA_SchematicFrame, wxFrame) 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 ) @@ -115,7 +116,7 @@ END_EVENT_TABLE() /* Constructor */ /****************/ -WinEDA_SchematicFrame:: WinEDA_SchematicFrame(wxWindow * father, WinEDA_App *parent, +WinEDA_SchematicFrame::WinEDA_SchematicFrame(wxWindow * father, WinEDA_App *parent, const wxString & title, const wxPoint& pos, const wxSize& size, long style) : WinEDA_DrawFrame(father, SCHEMATIC_FRAME, parent, title, pos, size, style) { @@ -124,7 +125,10 @@ WinEDA_SchematicFrame:: WinEDA_SchematicFrame(wxWindow * father, WinEDA_App *par m_Draw_Axis = FALSE; // TRUE to show axis m_Draw_Grid = g_ShowGrid; // TRUE to show a grid m_Draw_Sheet_Ref = TRUE; // TRUE to show sheet references + m_CurrentSheet = new DrawSheetList(); + CreateScreens(); + // Give an icon #ifdef __WINDOWS__ SetIcon(wxICON(a_icon_eeschema)); @@ -132,7 +136,6 @@ WinEDA_SchematicFrame:: WinEDA_SchematicFrame(wxWindow * father, WinEDA_App *par SetIcon(wxICON(icon_eeschema)); #endif - m_CurrentScreen = ScreenSch; g_ItemToRepeat = NULL; /* Get config */ GetSettings(); @@ -156,28 +159,79 @@ WinEDA_SchematicFrame:: WinEDA_SchematicFrame(wxWindow * father, WinEDA_App *par WinEDA_SchematicFrame::~WinEDA_SchematicFrame() { m_Parent->m_SchematicFrame = NULL; - m_CurrentScreen = ScreenSch; + SAFE_DELETE( g_RootSheet ); + SAFE_DELETE( m_CurrentSheet ); //a DrawSheetList, on the heap. + m_CurrentSheet = NULL; +} + /***************/ + /* utility functions */ + /***************/ +DrawSheetList* WinEDA_SchematicFrame::GetSheet() +{ + return m_CurrentSheet; +} +BASE_SCREEN* WinEDA_SchematicFrame::GetScreen() +{ + return m_CurrentSheet->LastScreen(); +} +void WinEDA_SchematicFrame::SetScreen(SCH_SCREEN* screen) +{ + //find it in the hierarchy, and set it. + //there is ambiguity in this function (there may be several + //instances of a given sheet, but irregardless it is useful + //for printing etc. + DrawSheetList sheetlist; + if(g_RootSheet->LocatePathOfScreen(screen, &sheetlist)){ + *m_CurrentSheet = sheetlist; + m_CurrentSheet->UpdateAllScreenReferences(); + } +} +wxString WinEDA_SchematicFrame::GetScreenDesc() +{ + wxString s = m_CurrentSheet->PathHumanReadable(); + return s; +} +/******************************/ +void WinEDA_SchematicFrame::CreateScreens() +/******************************/ +{ + /* creation des ecrans Sch , Lib */ + if( g_RootSheet == NULL ){ + g_RootSheet = new DrawSheetStruct(); + } + if( g_RootSheet->m_s == NULL ){ + g_RootSheet->m_s = new SCH_SCREEN( SCHEMATIC_FRAME ); + g_RootSheet->m_s->m_RefCount++; + } + g_RootSheet->m_s->m_FileName = g_DefaultSchematicFileName; + g_RootSheet->m_s->m_Date = GenDate(); + m_CurrentSheet->Clear(); + m_CurrentSheet->Push(g_RootSheet); + + if( ScreenLib == NULL ) + ScreenLib = new SCH_SCREEN( LIBEDITOR_FRAME ); + ScreenLib->SetZoom( 4 ); + ScreenLib->m_UndoRedoCountMax = 10; } /**************************************************************/ void WinEDA_SchematicFrame::OnCloseWindow(wxCloseEvent & Event) /**************************************************************/ { -SCH_SCREEN * screen; + DrawSheetList* sheet; if ( m_Parent->m_LibeditFrame ) // Can close component editor ? { if ( ! m_Parent->m_LibeditFrame->Close() ) return; } - screen = ScreenSch ; - while( screen ) - { - if(screen->IsModify()) break; - screen = (SCH_SCREEN*)screen->Pnext; + EDA_SheetList sheets( g_RootSheet ); + + for(sheet = sheets.GetFirst(); sheet != NULL; sheet = sheets.GetNext() ){ + if(sheet->LastScreen() && sheet->LastScreen()->IsModify()) break; } - if ( screen ) + if ( sheet ) { unsigned ii; wxMessageDialog dialog(this, _("Schematic modified, Save before exit ?"), @@ -194,25 +248,24 @@ SCH_SCREEN * screen; case wxID_OK: case wxID_YES: - SaveProject(this); + SaveProject(); break; } } - screen = ScreenSch ; - while( screen ) // Clear "flag modify" to avoid alert messages when closing sub sheets - { - screen->ClrModify(); - screen = (SCH_SCREEN*)screen->Pnext; + for(sheet = sheets.GetFirst(); sheet != NULL; sheet = sheets.GetNext() ){ + if(sheet->LastScreen()){ + sheet->LastScreen()->ClrModify(); + } } - if ( ! ScreenSch->m_FileName.IsEmpty() && (ScreenSch->EEDrawList != NULL) ) - SetLastProject(ScreenSch->m_FileName); + if ( ! GetScreen()->m_FileName.IsEmpty() && (GetScreen()->EEDrawList != NULL) ) + SetLastProject(GetScreen()->m_FileName); - ClearProjectDrawList(ScreenSch, TRUE); + ClearProjectDrawList(g_RootSheet->m_s, TRUE); /* allof sub sheets are deleted, only the main sheet is useable */ - m_CurrentScreen = ActiveScreen = ScreenSch; + m_CurrentSheet->Clear(); SaveSettings(); @@ -231,7 +284,7 @@ void WinEDA_SchematicFrame::SetToolbars() { if( m_HToolBar ) { - if ( m_CurrentScreen->BlockLocate.m_Command == BLOCK_MOVE ) + if ( GetScreen() && GetScreen()->BlockLocate.m_Command == BLOCK_MOVE ) { m_HToolBar->EnableTool(wxID_CUT,TRUE); m_HToolBar->EnableTool(wxID_COPY,TRUE); @@ -246,7 +299,7 @@ void WinEDA_SchematicFrame::SetToolbars() else m_HToolBar->EnableTool(wxID_PASTE,FALSE); wxMenuBar * menuBar = GetMenuBar(); - if ( GetScreen()->m_RedoList ) + if ( GetScreen() && GetScreen()->m_RedoList ) { m_HToolBar->EnableTool(ID_SCHEMATIC_REDO,TRUE); menuBar->Enable(ID_SCHEMATIC_REDO,TRUE); @@ -256,7 +309,7 @@ void WinEDA_SchematicFrame::SetToolbars() m_HToolBar->EnableTool(ID_SCHEMATIC_REDO,FALSE); menuBar->Enable(ID_SCHEMATIC_REDO,FALSE); } - if ( GetScreen()->m_UndoList ) + if ( GetScreen() && GetScreen()->m_UndoList ) { m_HToolBar->EnableTool(ID_SCHEMATIC_UNDO,TRUE); menuBar->Enable(ID_SCHEMATIC_UNDO,TRUE); @@ -300,17 +353,17 @@ int dx, dy, ii,jj ; int bestzoom; wxSize size; - dx = m_CurrentScreen->m_CurrentSheet->m_Size.x; - dy = m_CurrentScreen->m_CurrentSheet->m_Size.y; + dx = GetScreen()->m_CurrentSheetDesc->m_Size.x; + dy = GetScreen()->m_CurrentSheetDesc->m_Size.y; size = DrawPanel->GetClientSize(); ii = dx / size.x; jj = dy / size.y; bestzoom = MAX(ii, jj) + 1; - m_CurrentScreen->SetZoom(ii); - m_CurrentScreen->m_Curseur.x = dx / 2; - m_CurrentScreen->m_Curseur.y = dy / 2; + GetScreen()->SetZoom(ii); + GetScreen()->m_Curseur.x = dx / 2; + GetScreen()->m_Curseur.y = dy / 2; return(bestzoom); } diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index ed0ce14732..da2c55b7de 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -292,12 +292,21 @@ void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event ) { m_CurrentSheet->m_FileName = FileName; - if( wxFileExists( FileName ) ) /* do we reload the data from the existing file */ + if( wxFileExists( FileName ) )//do we reload the data from the existing file { msg.Printf( _( "A file named %s exists, load it ?" ), FileName.GetData() ); if( IsOK( this, msg ) ) { - m_Parent->LoadOneSheet( m_CurrentSheet, FileName ); + //LoadOneSheet clears the EEDrawList, + //we do not need to delete & recreate the SCH_SCREEN obj + m_CurrentSheet->m_FileName = FileName; + if( m_CurrentSheet->m_s ){ + m_CurrentSheet->m_s->m_RefCount--; + if( m_CurrentSheet->m_s->m_RefCount == 0) + SAFE_DELETE(m_CurrentSheet->m_s); + } + m_CurrentSheet->m_s = NULL; //so that we reload.. + m_CurrentSheet->Load(m_Parent); } } } @@ -355,15 +364,19 @@ DrawSheetStruct* WinEDA_SchematicFrame::CreateSheet( wxDC* DC ) { g_ItemToRepeat = NULL; - DrawSheetStruct* Sheet = new DrawSheetStruct( m_CurrentScreen->m_Curseur ); + DrawSheetStruct* Sheet = new DrawSheetStruct( GetScreen()->m_Curseur ); Sheet->m_Flags = IS_NEW | IS_RESIZED; - Sheet->m_TimeStamp = GetTimeStamp(); - Sheet->m_Parent = m_CurrentScreen; + Sheet->m_TimeStamp = GetTimeStamp(); + Sheet->m_Parent = GetScreen(); + Sheet->m_s = NULL; s_SheetMindx = SHEET_MIN_WIDTH; s_SheetMindy = SHEET_MIN_HEIGHT; - m_CurrentScreen->SetCurItem( Sheet ); + //need to check if this is being added to the EEDrawList. + //also need to update the heirarchy, if we are adding + // a sheet to a screen that already has multiple instances (!) + GetScreen()->SetCurItem( Sheet ); DrawPanel->ManageCurseur = DeplaceSheet; DrawPanel->ForceCloseManageCurseur = ExitSheet; @@ -424,7 +437,7 @@ void WinEDA_SchematicFrame::StartMoveSheet( DrawSheetStruct* Sheet, wxDC* DC ) return; DrawPanel->CursorOff( DC ); - m_CurrentScreen->m_Curseur = Sheet->m_Pos; + GetScreen()->m_Curseur = Sheet->m_Pos; DrawPanel->MouseToCursorSchema(); s_OldPos = Sheet->m_Pos; @@ -438,14 +451,14 @@ void WinEDA_SchematicFrame::StartMoveSheet( DrawSheetStruct* Sheet, wxDC* DC ) /********************************************************/ -/*** Routine de deplacement Sheet, lie au curseur. */ +/* Routine de deplacement (move) Sheet, lie au curseur.*/ /* Appele par GeneralControle grace a ManageCurseur. */ /********************************************************/ static void DeplaceSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) { wxPoint move_vector; DrawSheetLabelStruct* SheetLabel; - BASE_SCREEN* screen = panel->m_Parent->m_CurrentScreen; + BASE_SCREEN* screen = panel->m_Parent->GetScreen(); DrawSheetStruct* Sheet = (DrawSheetStruct*) screen->GetCurItem(); @@ -479,41 +492,13 @@ static void DeplaceSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) } -/****************************************************************/ -void DrawSheetStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) -/****************************************************************/ -{ - /* Placement en liste des structures si nouveau composant:*/ - if( m_Flags & IS_NEW ) - { - if( !( (WinEDA_SchematicFrame*) frame )->EditSheet( this, DC ) ) - { - frame->m_CurrentScreen->SetCurItem( NULL ); - frame->DrawPanel->ManageCurseur = NULL; - frame->DrawPanel->ForceCloseManageCurseur = NULL; - RedrawOneStruct( frame->DrawPanel, DC, this, g_XorMode ); - delete this; - return; - } - - - if( wxFileExists( m_FileName ) ) - { - ( (WinEDA_SchematicFrame*) frame )->LoadOneSheet( - this, m_FileName ); - } - } - - EDA_BaseStruct::Place( frame, DC ); -} - /****************************************/ /* Routine de sortie du Menu de Sheet */ /****************************************/ static void ExitSheet( WinEDA_DrawPanel* Panel, wxDC* DC ) { - SCH_SCREEN* Screen = (SCH_SCREEN*) Panel->m_Parent->m_CurrentScreen; + SCH_SCREEN* Screen = (SCH_SCREEN*) Panel->m_Parent->GetScreen(); DrawSheetStruct* Sheet = (DrawSheetStruct*) Screen->GetCurItem(); if( Sheet == NULL ) @@ -523,7 +508,7 @@ static void ExitSheet( WinEDA_DrawPanel* Panel, wxDC* DC ) if( Sheet->m_Flags & IS_NEW ) /* Nouveau Placement en cours, on l'efface */ { RedrawOneStruct( Panel, DC, Sheet, g_XorMode ); - delete Sheet; + SAFE_DELETE( Sheet ); } else if( Sheet->m_Flags & IS_RESIZED )/* resize en cours: on l'annule */ { @@ -536,7 +521,7 @@ static void ExitSheet( WinEDA_DrawPanel* Panel, wxDC* DC ) else if( Sheet->m_Flags & IS_MOVED )/* move en cours: on l'annule */ { wxPoint curspos = Screen->m_Curseur; - Panel->m_Parent->m_CurrentScreen->m_Curseur = s_OldPos; + Panel->m_Parent->GetScreen()->m_Curseur = s_OldPos; DeplaceSheet( Panel, DC, TRUE ); RedrawOneStruct( Panel, DC, Sheet, GR_DEFAULT_DRAWMODE ); Sheet->m_Flags = 0; @@ -551,46 +536,6 @@ static void ExitSheet( WinEDA_DrawPanel* Panel, wxDC* DC ) } -/********************************************************************/ -void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* frame, wxDC* DC ) -/********************************************************************/ - -/* Delete pinsheets which are not corresponding to a Global label - * if DC != NULL, redraw Sheet - */ -{ - DrawSheetLabelStruct* Pinsheet, * NextPinsheet; - - if( !IsOK( frame, _( "Ok to cleanup this sheet" ) ) ) - return; - - Pinsheet = m_Label; - while( Pinsheet ) - { - /* Search Glabel corresponding to this Pinsheet */ - - EDA_BaseStruct* DrawStruct = EEDrawList; - DrawGlobalLabelStruct* GLabel = NULL; - for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) - { - if( DrawStruct->Type() != DRAW_GLOBAL_LABEL_STRUCT_TYPE ) - continue; - GLabel = (DrawGlobalLabelStruct*) DrawStruct; - if( Pinsheet->m_Text.CmpNoCase( GLabel->m_Text ) == 0 ) - break; // Found! - GLabel = NULL; - } - - NextPinsheet = (DrawSheetLabelStruct*) Pinsheet->Pnext; - if( GLabel == NULL ) // Glabel not found: delete pinsheet - { - frame->GetScreen()->SetModify(); - frame->DeleteSheetLabel( DC, Pinsheet ); - } - Pinsheet = NextPinsheet; - } -} - /*! * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL @@ -609,5 +554,4 @@ void WinEDA_SheetPropertiesFrame::OnCancelClick( wxCommandEvent& event ) void WinEDA_SheetPropertiesFrame::OnOkClick( wxCommandEvent& event ) { SheetPropertiesAccept( event ); - EndModal( 1 ); } diff --git a/eeschema/sheet.h b/eeschema/sheet.h index 41470214ca..40eee4544a 100644 --- a/eeschema/sheet.h +++ b/eeschema/sheet.h @@ -117,7 +117,7 @@ public: ////@end WinEDA_SheetPropertiesFrame member variables WinEDA_SchematicFrame * m_Parent; - DrawSheetStruct * m_CurrentSheet; + DrawSheetStruct* m_CurrentSheet; }; #endif diff --git a/eeschema/sheetlab.cpp b/eeschema/sheetlab.cpp index 4542b53f23..d259c8201a 100644 --- a/eeschema/sheetlab.cpp +++ b/eeschema/sheetlab.cpp @@ -150,7 +150,7 @@ static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC ) if( SheetLabel->m_Flags & IS_NEW ) { /* Nouveau Placement en cours, on l'efface */ RedrawOneStruct( Panel, DC, SheetLabel, g_XorMode ); - delete SheetLabel; + SAFE_DELETE( SheetLabel ); } else { @@ -354,23 +354,23 @@ DrawSheetLabelStruct* WinEDA_SchematicFrame::Import_PinSheet( DrawSheetStruct* S * de la feuille de sous hierarchie correspondante */ { - EDA_BaseStruct* DrawStruct; - DrawSheetLabelStruct* NewSheetLabel, * SheetLabel = NULL; - DrawGlobalLabelStruct* GLabel = NULL; + EDA_BaseStruct* DrawStruct; + DrawSheetLabelStruct* NewSheetLabel, * SheetLabel = NULL; + DrawHierLabelStruct* HLabel = NULL; - DrawStruct = Sheet->EEDrawList; - GLabel = NULL; + DrawStruct = Sheet->m_s->EEDrawList; + HLabel = NULL; for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) { - if( DrawStruct->Type() != DRAW_GLOBAL_LABEL_STRUCT_TYPE ) + if( DrawStruct->Type() != DRAW_HIER_LABEL_STRUCT_TYPE ) continue; - GLabel = (DrawGlobalLabelStruct*) DrawStruct; + HLabel = (DrawHierLabelStruct*) DrawStruct; /* Ici un G-Label a ete trouve: y a t-il un SheetLabel correspondant */ SheetLabel = Sheet->m_Label; for( ; SheetLabel != NULL; SheetLabel = (DrawSheetLabelStruct*) SheetLabel->Pnext ) { - if( SheetLabel->m_Text.CmpNoCase( GLabel->m_Text ) == 0 ) + if( SheetLabel->m_Text.CmpNoCase( HLabel->m_Text ) == 0 ) { break; } @@ -381,20 +381,20 @@ DrawSheetLabelStruct* WinEDA_SchematicFrame::Import_PinSheet( DrawSheetStruct* S break; } - if( (GLabel == NULL ) || SheetLabel ) + if( (HLabel == NULL ) || SheetLabel ) { - DisplayError( this, _( "No New Global Label found" ), 10 ); + DisplayError( this, _( "No New Hierarchal Label found" ), 10 ); return NULL; } - /* Ici G-Label n'a pas de SheetLabel corresp, on va le creer */ + /* Ici H-Label n'a pas de SheetLabel corresp, on va le creer */ GetScreen()->SetModify(); /* Creation en memoire */ - NewSheetLabel = new DrawSheetLabelStruct( Sheet, wxPoint( 0, 0 ), GLabel->m_Text ); + NewSheetLabel = new DrawSheetLabelStruct( Sheet, wxPoint( 0, 0 ), HLabel->m_Text ); NewSheetLabel->m_Flags = IS_NEW; NewSheetLabel->m_Size = NetSheetTextSize; - CurrentTypeLabel = NewSheetLabel->m_Shape = GLabel->m_Shape; + CurrentTypeLabel = NewSheetLabel->m_Shape = HLabel->m_Shape; GetScreen()->SetCurItem( NewSheetLabel ); DrawPanel->ManageCurseur = Move_PinSheet; diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp index af4a9c73ae..2bf49e67e5 100644 --- a/eeschema/symbdraw.cpp +++ b/eeschema/symbdraw.cpp @@ -100,7 +100,7 @@ bodygraphics_PropertiesAccept( wxCommandEvent& event ) } CurrentLibEntry->SortDrawItems(); - m_Parent->m_CurrentScreen->SetModify(); + m_Parent->GetScreen()->SetModify(); DrawLibraryDrawStruct( m_Parent->DrawPanel, &dc, CurrentLibEntry, 0, 0, CurrentDrawItem, CurrentUnit, g_XorMode ); @@ -150,7 +150,7 @@ static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC ) else DrawLibraryDrawStruct( Panel, DC, CurrentLibEntry, 0, 0, CurrentDrawItem, CurrentUnit, g_XorMode ); - delete CurrentDrawItem; + SAFE_DELETE( CurrentDrawItem ); } else { @@ -164,8 +164,6 @@ static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC ) CurrentDrawItem->m_Flags = 0; } - - CurrentDrawItem = NULL; } @@ -226,8 +224,8 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( wxDC* DC ) LibDrawArc* Arc = new LibDrawArc(); CurrentDrawItem = Arc; - ArcStartX = ArcEndX = m_CurrentScreen->m_Curseur.x; - ArcStartY = ArcEndY = -m_CurrentScreen->m_Curseur.y; + ArcStartX = ArcEndX = GetScreen()->m_Curseur.x; + ArcStartY = ArcEndY = -( GetScreen()->m_Curseur.y ); StateDrawArc = 1; Arc->m_Fill = FlSymbol_Fill; Arc->m_Width = g_LibSymbolDefaultLineWidth; @@ -239,8 +237,8 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( wxDC* DC ) LibDrawCircle* Circle = new LibDrawCircle(); CurrentDrawItem = Circle; - Circle->m_Pos.x = m_CurrentScreen->m_Curseur.x; - Circle->m_Pos.y = -m_CurrentScreen->m_Curseur.y; + Circle->m_Pos.x = GetScreen()->m_Curseur.x; + Circle->m_Pos.y = -( GetScreen()->m_Curseur.y ); Circle->m_Fill = FlSymbol_Fill; Circle->m_Width = g_LibSymbolDefaultLineWidth; } @@ -251,8 +249,8 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( wxDC* DC ) LibDrawSquare* Square = new LibDrawSquare(); CurrentDrawItem = Square; - Square->m_Pos.x = m_CurrentScreen->m_Curseur.x; - Square->m_Pos.y = -m_CurrentScreen->m_Curseur.y; + Square->m_Pos.x = GetScreen()->m_Curseur.x; + Square->m_Pos.y = -( GetScreen()->m_Curseur.y ); Square->m_End = Square->m_Pos; Square->m_Fill = FlSymbol_Fill; Square->m_Width = g_LibSymbolDefaultLineWidth; @@ -267,8 +265,8 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( wxDC* DC ) polyline->n = 2; ptpoly = (int*) MyZMalloc( 4 * sizeof(int) ); polyline->PolyList = ptpoly; - ptpoly[0] = ptpoly[2] = m_CurrentScreen->m_Curseur.x; - ptpoly[1] = ptpoly[3] = -m_CurrentScreen->m_Curseur.y; + ptpoly[0] = ptpoly[2] = GetScreen()->m_Curseur.x; + ptpoly[1] = ptpoly[3] = -( GetScreen()->m_Curseur.y ); polyline->m_Fill = FlSymbol_Fill; polyline->m_Width = g_LibSymbolDefaultLineWidth; } @@ -279,8 +277,8 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( wxDC* DC ) LibDrawSegment* Segment = new LibDrawSegment(); CurrentDrawItem = Segment; - Segment->m_Pos.x = m_CurrentScreen->m_Curseur.x; - Segment->m_Pos.y = -m_CurrentScreen->m_Curseur.y; + Segment->m_Pos.x = GetScreen()->m_Curseur.x; + Segment->m_Pos.y = -( GetScreen()->m_Curseur.y ); Segment->m_End = Segment->m_Pos; Segment->m_Width = g_LibSymbolDefaultLineWidth; } @@ -293,12 +291,12 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( wxDC* DC ) CurrentDrawItem = Text; Text->m_Size.x = Text->m_Size.y = g_LastTextSize; Text->m_Horiz = g_LastTextOrient; - Text->m_Pos.x = m_CurrentScreen->m_Curseur.x; - Text->m_Pos.y = -m_CurrentScreen->m_Curseur.y; + Text->m_Pos.x = GetScreen()->m_Curseur.x; + Text->m_Pos.y = -( GetScreen()->m_Curseur.y ); EditSymbolText( NULL, Text ); if( Text->m_Text.IsEmpty() ) { - delete Text; + SAFE_DELETE( Text ); CurrentDrawItem = NULL; DrawPanel->ManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL; @@ -364,7 +362,7 @@ void WinEDA_LibeditFrame::GraphicItemBeginDraw( wxDC* DC ) case COMPONENT_POLYLINE_DRAW_TYPE: { - wxPoint pos = m_CurrentScreen->m_Curseur; + wxPoint pos = GetScreen()->m_Curseur; ( (LibDrawPolyline*) CurrentDrawItem )->AddPoint( pos ); } break; @@ -385,7 +383,7 @@ static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool era /* Redraw the graphoc shape while moving */ { - BASE_SCREEN* Screen = panel->m_Parent->m_CurrentScreen; + BASE_SCREEN* Screen = panel->m_Parent->GetScreen(); int mx, my; /* Erase shape in the old positon*/ @@ -483,7 +481,7 @@ void WinEDA_LibeditFrame::StartMoveDrawSymbol( wxDC* DC ) SetCursor( wxCURSOR_HAND ); CurrentDrawItem->m_Flags |= IS_MOVED; - StartCursor = m_CurrentScreen->m_Curseur; + StartCursor = GetScreen()->m_Curseur; switch( CurrentDrawItem->Type() ) { @@ -515,7 +513,7 @@ void WinEDA_LibeditFrame::StartMoveDrawSymbol( wxDC* DC ) ; } - ItemPreviousPos = m_CurrentScreen->m_Curseur; + ItemPreviousPos = GetScreen()->m_Curseur; DrawPanel->ManageCurseur = RedrawWhileMovingCursor; DrawPanel->ForceCloseManageCurseur = AbortSymbolTraceOn; DrawPanel->ManageCurseur( DrawPanel, DC, TRUE ); @@ -531,7 +529,7 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) int DrawMode = g_XorMode; int* ptpoly; int dx, dy; - BASE_SCREEN* Screen = panel->m_Parent->m_CurrentScreen; + BASE_SCREEN* Screen = panel->m_Parent->GetScreen(); int mx = Screen->m_Curseur.x, my = Screen->m_Curseur.y; @@ -722,7 +720,7 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC ) CurrentDrawItem->m_Flags = 0; CurrentDrawItem = NULL; - m_CurrentScreen->SetModify(); + GetScreen()->SetModify(); DrawPanel->ManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL; @@ -834,11 +832,11 @@ void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC ) { Poly->n--; ptpoly = Poly->PolyList + ( 2 * (Poly->n - 1) ); - if( (ptpoly[0] != m_CurrentScreen->m_Curseur.x) - || (ptpoly[1] != -m_CurrentScreen->m_Curseur.y) ) + if( (ptpoly[0] != GetScreen()->m_Curseur.x) + || (ptpoly[1] != -GetScreen()->m_Curseur.y) ) { - ptpoly[0] = m_CurrentScreen->m_Curseur.x; - ptpoly[1] = -m_CurrentScreen->m_Curseur.y; + ptpoly[0] = GetScreen()->m_Curseur.x; + ptpoly[1] = -( GetScreen()->m_Curseur.y); break; } } diff --git a/eeschema/symbedit.cpp b/eeschema/symbedit.cpp index ca3f5c0210..41188ed1c4 100644 --- a/eeschema/symbedit.cpp +++ b/eeschema/symbedit.cpp @@ -114,7 +114,7 @@ void WinEDA_LibeditFrame::LoadOneSymbol( wxDC* DC ) } SuppressDuplicateDrawItem( CurrentLibEntry ); - m_CurrentScreen->SetModify(); + GetScreen()->SetModify(); // Move (and place ) the new draw items: HandleBlockBegin( DC, -1, GetScreen()->m_Curseur ); @@ -434,14 +434,14 @@ void WinEDA_LibeditFrame::PlaceAncre() EDA_LibComponentStruct* LibEntry; LibEDA_BaseStruct* DrawEntry; - dx = -m_CurrentScreen->m_Curseur.x; - dy = m_CurrentScreen->m_Curseur.y; + dx = -( GetScreen()->m_Curseur.x ); + dy = GetScreen()->m_Curseur.y; LibEntry = CurrentLibEntry; if( LibEntry == NULL ) return; - m_CurrentScreen->SetModify(); + GetScreen()->SetModify(); LibEntry->m_Name.m_Pos.x += dx; LibEntry->m_Name.m_Pos.y += dy; LibEntry->m_Prefix.m_Pos.x += dx; LibEntry->m_Prefix.m_Pos.y += dy; @@ -510,7 +510,7 @@ void WinEDA_LibeditFrame::PlaceAncre() } /* Redraw the symbol */ - m_CurrentScreen->m_Curseur.x = m_CurrentScreen->m_Curseur.y = 0; + GetScreen()->m_Curseur.x = GetScreen()->m_Curseur.y = 0; Recadre_Trace( TRUE ); - m_CurrentScreen->SetRefreshReq(); + GetScreen()->SetRefreshReq(); } diff --git a/eeschema/symbtext.cpp b/eeschema/symbtext.cpp index 8b0b1b4cbc..ee1b69bb96 100644 --- a/eeschema/symbtext.cpp +++ b/eeschema/symbtext.cpp @@ -294,7 +294,7 @@ int DrawMode = g_XorMode; new WinEDA_bodytext_PropertiesFrame(this); frame->ShowModal(); frame->Destroy(); - m_CurrentScreen->SetModify(); + GetScreen()->SetModify(); /* Affichage nouveau texte */ if( ((LibDrawText*)DrawItem)->m_Text && DC) @@ -328,7 +328,7 @@ LibDrawText * DrawItem = (LibDrawText *) CurrentDrawItem; DrawItem->m_Horiz = TEXT_ORIENT_VERT; else DrawItem->m_Horiz = TEXT_ORIENT_HORIZ; - m_CurrentScreen->SetModify(); + GetScreen()->SetModify(); /* Redraw item with new orient */ if ( DrawPanel->ManageCurseur == NULL) diff --git a/eeschema/tool_sch.cpp b/eeschema/tool_sch.cpp index 1a155ea56b..ddd7497781 100644 --- a/eeschema/tool_sch.cpp +++ b/eeschema/tool_sch.cpp @@ -202,6 +202,10 @@ void WinEDA_SchematicFrame::ReCreateVToolbar() m_VToolBar->AddTool( ID_GLABEL_BUTT, wxEmptyString, BITMAP( add_glabel_xpm ), _( "Add global label" ), wxITEM_CHECK ); + + m_VToolBar->AddTool( ID_HIERLABEL_BUTT, wxEmptyString, + BITMAP( add_glabel_xpm ), + _( "Add hierarchal label" ), wxITEM_CHECK ); m_VToolBar->AddTool( ID_JUNCTION_BUTT, wxEmptyString, BITMAP( add_junction_xpm ), @@ -214,7 +218,7 @@ void WinEDA_SchematicFrame::ReCreateVToolbar() m_VToolBar->AddTool( ID_IMPORT_GLABEL_BUTT, wxEmptyString, BITMAP( import_glabel_xpm ), - _( "import glabel from sheet & create pinsheet" ), wxITEM_CHECK ); + _( "import hierarchal label from sheet & create pinsheet" ), wxITEM_CHECK ); m_VToolBar->AddTool( ID_SHEET_LABEL_BUTT, wxEmptyString, BITMAP( add_hierar_pin_xpm ), diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index ef27d8e9f8..58e0c3f86a 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -71,7 +71,7 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame(wxWindow * father, WinEDA_App *parent, if ( m_Semaphore ) SetWindowStyle( GetWindowStyle() | wxSTAY_ON_TOP); m_CurrentScreen = new SCH_SCREEN(VIEWER_FRAME); - m_CurrentScreen->SetZoom(16); + GetScreen()->SetZoom(16); if ( Library == NULL ) { @@ -108,7 +108,7 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame(wxWindow * father, WinEDA_App *parent, WinEDA_ViewlibFrame::~WinEDA_ViewlibFrame() { - delete m_CurrentScreen; + SAFE_DELETE( m_CurrentScreen ); m_Parent->m_ViewlibFrame = NULL; } @@ -185,8 +185,8 @@ EDA_LibComponentStruct * CurrentLibEntry = NULL; if( CurrentLibEntry == NULL ) { bestzoom = 16; - m_CurrentScreen->m_Curseur.x = 0; - m_CurrentScreen->m_Curseur.y = 0; + GetScreen()->m_Curseur.x = 0; + GetScreen()->m_Curseur.y = 0; return(bestzoom); } @@ -205,8 +205,8 @@ EDA_LibComponentStruct * CurrentLibEntry = NULL; if(bestzoom > ii ) break; } - m_CurrentScreen->m_Curseur = BoundaryBox.Centre(); - m_CurrentScreen->m_Curseur.y = - m_CurrentScreen->m_Curseur.y; + GetScreen()->m_Curseur = BoundaryBox.Centre(); + GetScreen()->m_Curseur.y = -( GetScreen()->m_Curseur.y ); return(bestzoom); } @@ -236,8 +236,8 @@ bool found = FALSE; free (ListNames); - /* Librairie courante peut etre non retrouvée en liste - (peut etre effacée lors d'une modification de configuration) */ + /* Librairie courante peut etre non retrouv�e en liste + (peut etre effac�e lors d'une modification de configuration) */ if ( ! found ) { g_CurrentViewLibraryName.Empty(); @@ -262,7 +262,7 @@ LibraryStruct *Library = FindLibrary(g_CurrentViewLibraryName.GetData()); ii = 0; g_CurrentViewComponentName.Empty(); g_ViewConvert = 1; /* Vue normal / convert */ - g_ViewUnit = 1; /* unité a afficher (A, B ..) */ + g_ViewUnit = 1; /* unit� a afficher (A, B ..) */ if ( Library ) LibEntry = (EDA_LibComponentStruct *) PQFirst(&Library->m_Entries, FALSE); while( LibEntry ) diff --git a/gerbview/affiche.cpp b/gerbview/affiche.cpp index 4c29b7d83a..b07d4d5207 100644 --- a/gerbview/affiche.cpp +++ b/gerbview/affiche.cpp @@ -66,7 +66,8 @@ void Affiche_Infos_Piste( WinEDA_BasePcbFrame* frame, TRACK* pt_piste ) { int d_index, ii = -1; D_CODE* pt_D_code; - int layer = frame->GetScreen()->m_Active_Layer; + + int layer = ((PCB_SCREEN*)(frame->GetScreen()))->m_Active_Layer; wxString msg; frame->MsgPanel->EraseMsgBox(); diff --git a/gerbview/dcode.cpp b/gerbview/dcode.cpp index 92587b61c8..df21b3bca4 100644 --- a/gerbview/dcode.cpp +++ b/gerbview/dcode.cpp @@ -55,8 +55,8 @@ Outils et D_CODES D_CODES: D01 ... D9 = codes d'action: - D01 = activation de lumiere (baisser de plume) lors du déplacement - D02 = extinction de lumiere (lever de plume) lors du déplacement + D01 = activation de lumiere (baisser de plume) lors du d�placement + D02 = extinction de lumiere (lever de plume) lors du d�placement D03 = Flash D09 = VAPE Flash @@ -107,7 +107,7 @@ void GERBER_Descr::ResetDefaultValues() m_ImageNegative = FALSE; // TRUE = Negative image m_GerbMetric = FALSE; // FALSE = Inches, TRUE = metric m_Relative = FALSE; // FALSE = absolute Coord, RUE = relative Coord - m_NoTrailingZeros = FALSE; // True: zeros a droite supprimés + m_NoTrailingZeros = FALSE; // True: zeros a droite supprim�s m_MirorA = FALSE; // True: miror / axe A (X) m_MirorB = FALSE; // True: miror / axe B (Y) m_As_DCode = FALSE; // TRUE = DCodes in file (FALSE = no DCode-> @@ -158,7 +158,7 @@ int ii, jj; void GERBER_Descr::InitToolTable() /******************************/ /* Creation du tableau des MAX_TOOLS DCodes utilisables, si il n'existe pas, -et Init des DCodes à une valeur raisonnable +et Init des DCodes � une valeur raisonnable */ { int count; @@ -237,7 +237,7 @@ char Line[2000]; wxString msg; D_CODE * pt_Dcode; FILE * dest; -int layer = GetScreen()->m_Active_Layer; +int layer = GetPCBScreen()->m_Active_Layer; D_CODE ** ListeDCode; @@ -369,7 +369,7 @@ D_CODE * pt_Dcode; /* Pointeur sur le D code*/ track->m_End = track->m_Start; // m_Start = m_End = Spot center switch (pt_Dcode->m_Shape) { - case GERB_LINE : // ne devrait pas etre utilisé ici + case GERB_LINE : // ne devrait pas etre utilis� ici case GERB_CIRCLE : /* spot rond (for GERBER)*/ track->m_Shape = S_SPOT_CIRCLE; break ; @@ -430,7 +430,7 @@ D_CODE * pt_D_code ; wxString Line; WinEDA_TextFrame * List; int scale = 10000; -int curr_layer = GetScreen()->m_Active_Layer; +int curr_layer = GetPCBScreen()->m_Active_Layer; int layer; GERBER_Descr * DcodeList; @@ -471,7 +471,7 @@ GERBER_Descr * DcodeList; if (ii < 0) return; #if 0 - // Mise en surbrillance des éléments correspondant au DCode sélectionné + // Mise en surbrillance des �l�ments correspondant au DCode s�lectionn� if(Etat_Surbrillance) Hight_Light(DrawPanel, DC); net_code_Surbrillance = (GetScreen()->m_Active_Layer<< 16) + ii; Hight_Light(DrawPanel, DC); diff --git a/gerbview/edit.cpp b/gerbview/edit.cpp index 9048350a53..4578222e32 100644 --- a/gerbview/edit.cpp +++ b/gerbview/edit.cpp @@ -19,8 +19,8 @@ static void Process_Move_Item( WinEDA_GerberFrame* frame, void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) /************************************************************************/ -/* Traite les commandes declenchée par le bouton gauche de la souris, - * quand un outil est deja selectionné +/* Traite les commandes declench�e par le bouton gauche de la souris, + * quand un outil est deja selectionn� */ { EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem(); @@ -84,7 +84,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) */ { int id = event.GetId(); - int layer = GetScreen()->m_Active_Layer; + int layer = GetPCBScreen()->m_Active_Layer; GERBER_Descr* gerber_layer = g_GERBER_Descr_List[layer]; wxPoint pos; wxClientDC dc( DrawPanel ); @@ -95,7 +95,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) pos.y += 20; - switch( id ) // Arret eventuel de la commande de déplacement en cours + switch( id ) // Arret eventuel de la commande de d�placement en cours { case wxID_CUT: case wxID_COPY: @@ -126,7 +126,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor ); break; - default: // Arret dea commande de déplacement en cours + default: // Arret dea commande de d�placement en cours if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) { @@ -226,7 +226,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_TOOLBARH_PCB_SELECT_LAYER: { - GetScreen()->m_Active_Layer = m_SelLayerBox->GetChoice(); + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = m_SelLayerBox->GetChoice(); DrawPanel->Refresh( TRUE ); break; } @@ -287,7 +287,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS: if( gerber_layer ) - Delete_DCode_Items( &dc, gerber_layer->m_Selected_Tool, GetScreen()->m_Active_Layer ); + Delete_DCode_Items( &dc, gerber_layer->m_Selected_Tool, ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); break; default: @@ -326,8 +326,8 @@ static void Process_Move_Item( WinEDA_GerberFrame* frame, void WinEDA_GerberFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) /**************************************************************************/ -/* Appelé sur un double click: - * pour un élément editable (textes, composant): +/* Appel� sur un double click: + * pour un �l�ment editable (textes, composant): * appel de l'editeur correspondant. * pour une connexion en cours: * termine la connexion @@ -349,7 +349,7 @@ void WinEDA_GerberFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) if( (DrawStruct == NULL) || (DrawStruct->m_Flags != 0) ) break; - // Element localisé + // Element localis� switch( DrawStruct->Type() ) { default: diff --git a/gerbview/files.cpp b/gerbview/files.cpp index 18dc5c2b96..70d297a7d6 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -41,10 +41,10 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event ) case ID_MENU_INC_LAYER_AND_APPEND_FILE: case ID_INC_LAYER_AND_APPEND_FILE: { - int layer = GetScreen()->m_Active_Layer; - GetScreen()->m_Active_Layer++; + int layer = GetPCBScreen()->m_Active_Layer; + ((PCB_SCREEN*)GetScreen())->m_Active_Layer++; if( !LoadOneGerberFile( wxEmptyString, &dc, 0 ) ) - GetScreen()->m_Active_Layer = layer; + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = layer; SetToolbars(); } break; diff --git a/gerbview/gerberframe.cpp b/gerbview/gerberframe.cpp index 26be957edc..def49a351a 100644 --- a/gerbview/gerberframe.cpp +++ b/gerbview/gerberframe.cpp @@ -114,7 +114,7 @@ BEGIN_EVENT_TABLE(WinEDA_GerberFrame, wxFrame) WinEDA_GerberFrame::OnSelectOptionToolbar) - // PopUp Menu traités dans drawpanel.cpp + // PopUp Menu trait�s dans drawpanel.cpp END_EVENT_TABLE() @@ -131,7 +131,7 @@ WinEDA_GerberFrame::WinEDA_GerberFrame(wxWindow * father, WinEDA_App *parent, m_AboutTitle = g_GerbviewAboutTitle; m_Draw_Axis = TRUE; // TRUE pour avoir les axes dessines m_Draw_Grid = TRUE; // TRUE pour avoir la axes dessinee - m_Draw_Sheet_Ref = FALSE; // TRUE pour avoir le cartouche dessiné + m_Draw_Sheet_Ref = FALSE; // TRUE pour avoir le cartouche dessin� m_Ident = GERBER_FRAME; m_ZoomMaxValue = 1024; if ( DrawPanel ) DrawPanel->m_Block_Enable = TRUE; @@ -189,7 +189,7 @@ PCB_SCREEN * screen; } /* Reselection de l'ecran de base, - pour les evenements de refresh générés par wxWindows */ + pour les evenements de refresh g�n�r�s par wxWindows */ m_CurrentScreen = ActiveScreen = ScreenPcb; SaveSettings(); @@ -203,7 +203,7 @@ void WinEDA_GerberFrame::SetToolbars() * Set the tools state for the toolbars, accordint to display options */ { -int layer = GetScreen()->m_Active_Layer; +int layer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer; GERBER_Descr * Gerber_layer_descr = g_GERBER_Descr_List[layer]; if( m_HToolBar == NULL ) return; @@ -231,9 +231,9 @@ GERBER_Descr * Gerber_layer_descr = g_GERBER_Descr_List[layer]; } - if ( m_SelLayerBox->GetSelection() != GetScreen()->m_Active_Layer ) + if ( m_SelLayerBox->GetSelection() != ((PCB_SCREEN*)GetScreen())->m_Active_Layer ) { - m_SelLayerBox->SetSelection( GetScreen()->m_Active_Layer ); + m_SelLayerBox->SetSelection( ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); } if ( Gerber_layer_descr ) diff --git a/gerbview/hotkeys.cpp b/gerbview/hotkeys.cpp index fa43d5c436..da128c556e 100644 --- a/gerbview/hotkeys.cpp +++ b/gerbview/hotkeys.cpp @@ -137,13 +137,13 @@ void WinEDA_GerberFrame::OnHotKey( wxDC* DC, int hotkey, break; case HK_SWITCH_LAYER_TO_PREVIOUS: - if( GetScreen()->m_Active_Layer > 0 ) - GetScreen()->m_Active_Layer--; + if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer > 0 ) + ((PCB_SCREEN*)GetScreen())->m_Active_Layer--; break; case HK_SWITCH_LAYER_TO_NEXT: - if( GetScreen()->m_Active_Layer < 31 ) - GetScreen()->m_Active_Layer++; + if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer < 31 ) + ((PCB_SCREEN*)GetScreen())->m_Active_Layer++; break; } } diff --git a/gerbview/initpcb.cpp b/gerbview/initpcb.cpp index 9bd7e265e1..be963d0e8e 100644 --- a/gerbview/initpcb.cpp +++ b/gerbview/initpcb.cpp @@ -75,7 +75,7 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query ) /* Init parametres de gestion des ecrans PAD et PCB */ m_CurrentScreen = ActiveScreen = ScreenPcb; - GetScreen()->Init(); + GetPCBScreen()->Init(); return TRUE; } @@ -104,7 +104,7 @@ void WinEDA_GerberFrame::Erase_Segments_Pcb( bool all_layers, bool query ) { BOARD_ITEM* PtStruct; BOARD_ITEM* PtNext; - int layer = GetScreen()->m_Active_Layer; + int layer = GetPCBScreen()->m_Active_Layer; if( all_layers ) layer = -1; @@ -189,7 +189,7 @@ void WinEDA_GerberFrame::Erase_Textes_Pcb( bool query ) void WinEDA_GerberFrame::Erase_Current_Layer( bool query ) /*********************************************************/ { - int layer = GetScreen()->m_Active_Layer; + int layer = GetPCBScreen()->m_Active_Layer; wxString msg; msg.Printf( _( "Delete Layer %d" ), layer + 1 ); diff --git a/gerbview/locate.cpp b/gerbview/locate.cpp index 595bd68de2..22f6f572ce 100644 --- a/gerbview/locate.cpp +++ b/gerbview/locate.cpp @@ -38,7 +38,7 @@ EDA_BaseStruct* WinEDA_GerberFrame::Locate( int typeloc ) /*************************************************************/ /* Fonction de localisation generale - * Affiche les caract de la stucture localisée et retourne un pointeur + * Affiche les caract de la stucture localis�e et retourne un pointeur * sur celle-ci */ { @@ -48,7 +48,7 @@ EDA_BaseStruct* WinEDA_GerberFrame::Locate( int typeloc ) int layer; /* Localistion des pistes et vias, avec priorite aux vias */ - layer = GetScreen()->m_Active_Layer; + layer = GetPCBScreen()->m_Active_Layer; Track = Locate_Pistes( m_Pcb->m_Track, -1, typeloc ); if( Track != NULL ) { @@ -80,7 +80,7 @@ EDA_BaseStruct* WinEDA_GerberFrame::Locate( int typeloc ) } if( ( TrackLocate = Locate_Zone( (TRACK*) m_Pcb->m_Zone, - GetScreen()->m_Active_Layer, typeloc ) ) != NULL ) + GetPCBScreen()->m_Active_Layer, typeloc ) ) != NULL ) { TrackLocate->Display_Infos( this ); return TrackLocate; diff --git a/gerbview/readgerb.cpp b/gerbview/readgerb.cpp index 5c97d5c858..96fe49ef7f 100644 --- a/gerbview/readgerb.cpp +++ b/gerbview/readgerb.cpp @@ -53,8 +53,8 @@ * D_CODES: * * D01 ... D9 = codes d'action: - * D01 = activation de lumiere (baisser de plume) lors du déplacement - * D02 = extinction de lumiere (lever de plume) lors du déplacement + * D01 = activation de lumiere (baisser de plume) lors du d�placement + * D02 = extinction de lumiere (lever de plume) lors du d�placement * D03 = Flash * D09 = VAPE Flash * D51 = precede par G54 -> Select VAPE @@ -91,11 +91,11 @@ * * Representation interne: * - * Les lignes sont représentées par des TRACKS standards - * Les Flash sont représentées par des DRAWSEGMENTS + * Les lignes sont repr�sent�es par des TRACKS standards + * Les Flash sont repr�sent�es par des DRAWSEGMENTS * - ronds ou ovales: DRAWSEGMENTS * - rectangles: DRAWSEGMENTS - * la reference aux D-CODES est placée dans le membre GetNet() + * la reference aux D-CODES est plac�e dans le membre GetNet() */ @@ -126,7 +126,7 @@ bool WinEDA_GerberFrame::Read_GERBER_File( wxDC* DC, wxPoint pos; int error = 0; - layer = GetScreen()->m_Active_Layer; + layer = GetPCBScreen()->m_Active_Layer; if( g_GERBER_Descr_List[layer] == NULL ) { diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp index c3a1ef2df8..729d22c80b 100644 --- a/gerbview/rs274d.cpp +++ b/gerbview/rs274d.cpp @@ -56,8 +56,8 @@ * D_CODES: * * D01 ... D9 = codes d'action: - * D01 = activation de lumiere (baisser de plume) lors du déplacement - * D02 = extinction de lumiere (lever de plume) lors du déplacement + * D01 = activation de lumiere (baisser de plume) lors du d�placement + * D02 = extinction de lumiere (lever de plume) lors du d�placement * D03 = Flash * D09 = VAPE Flash * D51 = precede par G54 -> Select VAPE @@ -106,8 +106,8 @@ static void Append_1_Flash_ROND_GERBER( int Dcode_tool, track = new TRACK( frame->m_Pcb ); track->Insert( frame->m_Pcb, NULL ); - - track->SetLayer( frame->GetScreen()->m_Active_Layer ); + + track->SetLayer( frame->GetPCBScreen()->m_Active_Layer ); track->m_Width = diametre; track->m_Start = track->m_End = pos; NEGATE( track->m_Start.y ); @@ -140,7 +140,7 @@ static void Append_1_Flash_GERBER( int Dcode_index, track->Insert( frame->m_Pcb, NULL ); - track->SetLayer( frame->GetScreen()->m_Active_Layer ); + track->SetLayer( frame->GetPCBScreen()->m_Active_Layer ); track->m_Width = width; track->m_Start = track->m_End = pos; NEGATE( track->m_Start.y ); @@ -150,7 +150,7 @@ static void Append_1_Flash_GERBER( int Dcode_index, if( forme == PAD_OVAL ) track->m_Shape = S_SPOT_OVALE; else - track->m_Shape = S_SPOT_RECT; // donc rectangle ou carré + track->m_Shape = S_SPOT_RECT; // donc rectangle ou carr� len >>= 1; if( size.x > size.y ) // ovale / rect horizontal @@ -181,7 +181,7 @@ static void Append_1_Line_GERBER( int Dcode_index, track->Insert( frame->m_Pcb, NULL ); - track->SetLayer( frame->GetScreen()->m_Active_Layer ); + track->SetLayer( frame->GetPCBScreen()->m_Active_Layer ); track->m_Width = largeur; track->m_Start = startpoint; NEGATE( track->m_Start.y ); @@ -203,10 +203,10 @@ static void Append_1_SEG_ARC_GERBER( int Dcode_index, /* creation d'un arc: * si multiquadrant == TRUE arc de 0 a 360 degres - * et rel_center est la coordonnée du centre relativement au startpoint + * et rel_center est la coordonn�e du centre relativement au startpoint * - * si multiquadrant == FALSE arc de 0 à 90 entierement contenu dans le meme quadrant - * et rel_center est la coordonnée du centre relativement au startpoint, + * si multiquadrant == FALSE arc de 0 � 90 entierement contenu dans le meme quadrant + * et rel_center est la coordonn�e du centre relativement au startpoint, * mais en VALEUR ABSOLUE et le signe des valeurs x et y de rel_center doit * etre deduit de cette limite de 90 degres * @@ -220,7 +220,7 @@ static void Append_1_SEG_ARC_GERBER( int Dcode_index, track->Insert( frame->m_Pcb, NULL ); track->m_Shape = S_ARC; - track->SetLayer( frame->GetScreen()->m_Active_Layer ); + track->SetLayer( frame->GetPCBScreen()->m_Active_Layer ); track->m_Width = largeur; if( multiquadrant ) @@ -294,10 +294,10 @@ static void Append_1_SEG_ARC_GERBER( int Dcode_index, /**************************************************/ -/* Routines utilisées en lecture de ficher gerber */ +/* Routines utilis�es en lecture de ficher gerber */ /**************************************************/ -/* ces routines lisent la chaine de texte pointée par Text. +/* ces routines lisent la chaine de texte point�e par Text. * Apres appel, Text pointe le debut de la sequence non lue */ @@ -436,7 +436,7 @@ wxPoint GERBER_Descr::ReadIJCoord( char*& Text ) /************************************************/ /* Retourne la coord type InnJnn courante pointee par Text (InnnnJmmmm) - * Ces coordonnées sont relatives, donc si une coord est absente, sa valeur + * Ces coordonn�es sont relatives, donc si une coord est absente, sa valeur * par defaut est 0 */ { @@ -741,7 +741,7 @@ bool GERBER_Descr::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, edge_poly->Insert( frame->m_Pcb, last ); - edge_poly->SetLayer( frame->GetScreen()->m_Active_Layer ); + edge_poly->SetLayer( frame->GetPCBScreen()->m_Active_Layer ); edge_poly->m_Width = 1; edge_poly->m_Start = m_PreviousPos; NEGATE( edge_poly->m_Start.y ); @@ -850,7 +850,7 @@ bool GERBER_Descr::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, PAD_RECT ); break; - default: // Special (Macro) : Non implanté + default: // Special (Macro) : Non implant� break; } diff --git a/gerbview/tool_gerber.cpp b/gerbview/tool_gerber.cpp index e140322979..a58fef011e 100644 --- a/gerbview/tool_gerber.cpp +++ b/gerbview/tool_gerber.cpp @@ -200,7 +200,7 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void ) if( GetScreen() ) { - layer = GetScreen()->m_Active_Layer; + layer = GetPCBScreen()->m_Active_Layer; gerber_layer = g_GERBER_Descr_List[layer]; } @@ -313,7 +313,7 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void ) m_SelLayerBox = new WinEDAChoiceBox( m_HToolBar, ID_TOOLBARH_PCB_SELECT_LAYER, wxDefaultPosition, wxSize( 150, -1 ), choices ); - m_SelLayerBox->SetSelection( GetScreen()->m_Active_Layer ); + m_SelLayerBox->SetSelection( GetPCBScreen()->m_Active_Layer ); m_HToolBar->AddControl( m_SelLayerBox ); m_HToolBar->AddSeparator(); diff --git a/gerbview/tracepcb.cpp b/gerbview/tracepcb.cpp index f348d13a3b..84affb3869 100644 --- a/gerbview/tracepcb.cpp +++ b/gerbview/tracepcb.cpp @@ -64,7 +64,7 @@ void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) /* Trace le PCB, et les elements complementaires ( axes, grille .. ) */ { - PCB_SCREEN* screen = GetScreen(); + PCB_SCREEN* screen = (PCB_SCREEN*)GetScreen(); if( !m_Pcb ) return; diff --git a/include/base_struct.h b/include/base_struct.h index 8a5d597c89..be0fc40544 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -50,6 +50,7 @@ enum KICAD_T { DRAW_TEXT_STRUCT_TYPE, DRAW_LABEL_STRUCT_TYPE, DRAW_GLOBAL_LABEL_STRUCT_TYPE, + DRAW_HIER_LABEL_STRUCT_TYPE, DRAW_LIB_ITEM_STRUCT_TYPE, DRAW_PICK_ITEM_STRUCT_TYPE, DRAW_SEGMENT_STRUCT_TYPE, diff --git a/include/common.h b/include/common.h index aee16ac553..936ffe6846 100644 --- a/include/common.h +++ b/include/common.h @@ -340,7 +340,7 @@ COMMON_GLOBL int g_GridColor #endif ; -/* Current used screen: */ +/* Current used screen: (not used in eeshema)*/ COMMON_GLOBL BASE_SCREEN* ActiveScreen; diff --git a/include/dcsvg.h b/include/dcsvg.h index 8a3b3a3d4c..1dc06358b6 100644 --- a/include/dcsvg.h +++ b/include/dcsvg.h @@ -277,7 +277,7 @@ class wxSVGFileDC : public wxDC void SetFont(const wxFont& font) ; void SetLogicalFunction(int WXUNUSED(function)) - { wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetLogicalFunction Call implemented")); return ; }; + { /*wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetLogicalFunction Call implemented")); */ return ; }; void SetLogicalScale( double x, double y ) ; diff --git a/include/drawpanel_wxstruct.h b/include/drawpanel_wxstruct.h index 588489178f..1bc9e7ef10 100644 --- a/include/drawpanel_wxstruct.h +++ b/include/drawpanel_wxstruct.h @@ -58,7 +58,7 @@ public: WinEDA_DrawPanel( WinEDA_DrawFrame* parent, int id, const wxPoint& pos, const wxSize& size ); ~WinEDA_DrawPanel() { } /****************************/ - BASE_SCREEN* GetScreen() { return m_Parent->m_CurrentScreen; } + virtual BASE_SCREEN* GetScreen() { return m_Parent->GetScreen(); } void PrepareGraphicContext( wxDC* DC ); wxPoint CalcAbsolutePosition( const wxPoint& rel_pos ); @@ -104,7 +104,7 @@ public: void CursorOff( wxDC* DC ); // remove the grid cursor from the display void CursorOn( wxDC* DC ); // display the grid cursor - DECLARE_EVENT_TABLE() + DECLARE_EVENT_TABLE() }; /**************************/ @@ -196,8 +196,8 @@ public: DrawBlockStruct BlockLocate; /* Bock description for block commands */ /* Page description */ - Ki_PageDescr* m_CurrentSheet; - int m_SheetNumber, m_NumberOfSheet;/* gestion hierarchie: numero de sousfeuille + Ki_PageDescr* m_CurrentSheetDesc; + int m_ScreenNumber, m_NumberOfScreen;/* gestion hierarchie: numero de sousfeuille * et nombre de feuilles. Root: SheetNumber = 1 */ wxString m_FileName; wxString m_Title; /* titre de la feuille */ diff --git a/include/id.h b/include/id.h index 42b382ad67..65d61d413d 100644 --- a/include/id.h +++ b/include/id.h @@ -174,6 +174,7 @@ enum main_id { ID_WIRETOBUS_ENTRY_BUTT, ID_LABEL_BUTT, ID_GLABEL_BUTT, + ID_HIERLABEL_BUTT, ID_IMPORT_GLABEL_BUTT, ID_SHEET_LABEL_BUTT, ID_NOCONN_BUTT, diff --git a/include/pcbstruct.h b/include/pcbstruct.h index 4d99e1899f..d3eb399f19 100644 --- a/include/pcbstruct.h +++ b/include/pcbstruct.h @@ -266,7 +266,7 @@ public: #include "class_zone.h" -class DISPLAY_OPTIONS +class DISPLAY_OPTIONS { public: bool DisplayPadFill; diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index 5c2bcb1728..2a70b06433 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -85,7 +85,7 @@ public: virtual bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) = 0; virtual void ReCreateMenuBar(); - PCB_SCREEN* GetScreen() { return (PCB_SCREEN*) m_CurrentScreen; } + virtual BASE_SCREEN* GetScreen() { return (BASE_SCREEN*) m_CurrentScreen; } int BestZoom(); void Show3D_Frame( wxCommandEvent& event ); @@ -725,6 +725,7 @@ public: int BestZoom(); // Retourne le meilleur zoom void OnSelectOptionToolbar( wxCommandEvent& event ); void OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct ); + PCB_SCREEN* GetPCBScreen(){ return (PCB_SCREEN*)GetScreen(); } EDA_BaseStruct* GerberGeneralLocateAndDisplay(); EDA_BaseStruct* Locate( int typeloc ); diff --git a/include/wxstruct.h b/include/wxstruct.h index a906fc9479..1635a441fe 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -20,6 +20,9 @@ #include +#ifndef SAFE_DELETE +#define SAFE_DELETE(p) delete (p); (p) = NULL; +#endif #define INTERNAL_UNIT_TYPE 0 // Internal unit = inch @@ -72,6 +75,7 @@ class DrawGlobalLabelStruct; class DrawTextStruct; class EDA_DrawLineStruct; class DrawSheetStruct; +class DrawSheetList; class DrawSheetLabelStruct; class EDA_SchComponentStruct; class LibDrawField; @@ -230,7 +234,8 @@ public: ~WinEDA_DrawFrame(); - BASE_SCREEN* GetScreen() { return m_CurrentScreen; } + virtual BASE_SCREEN* GetScreen() { return m_CurrentScreen; } + virtual wxString GetScreenDesc(); void OnMenuOpen( wxMenuEvent& event ); void OnMouseEvent( wxMouseEvent& event ); @@ -337,6 +342,7 @@ class WinEDA_SchematicFrame : public WinEDA_DrawFrame { public: WinEDAChoiceBox* m_SelPartBox; + DrawSheetList* m_CurrentSheet; //which sheet we are presently working on. private: wxMenu* m_FilesMenu; @@ -355,6 +361,7 @@ public: void RedrawActiveWindow( wxDC* DC, bool EraseBg ); + void CreateScreens(); void ReCreateHToolbar(); void ReCreateVToolbar(); void ReCreateOptToolbar(); @@ -364,7 +371,10 @@ public: int hotkey, EDA_BaseStruct* DrawStruct ); - SCH_SCREEN* GetScreen() { return (SCH_SCREEN*) m_CurrentScreen; } + DrawSheetList* GetSheet(); + virtual BASE_SCREEN* GetScreen(); + virtual void SetScreen(SCH_SCREEN* screen); + virtual wxString GetScreenDesc(); void InstallConfigFrame( const wxPoint& pos ); @@ -395,18 +405,19 @@ public: void* BuildNetListBase(); // FUnctions used for hierarchy handling - void InstallPreviousScreen(); + void InstallPreviousSheet(); void InstallNextScreen( DrawSheetStruct* Sheet ); void ToPlot_PS( wxCommandEvent& event ); void ToPlot_HPGL( wxCommandEvent& event ); void ToPostProcess( wxCommandEvent& event ); - void Save_File( wxCommandEvent& event ); - int LoadOneEEProject( const wxString& FileName, bool IsNew ); - bool LoadOneEEFile( SCH_SCREEN* screen, const wxString& FullFileName ); - bool SaveEEFile( SCH_SCREEN* screen, int FileSave ); - bool LoadOneSheet( SCH_SCREEN* screen, const wxString& FullFileName ); + void Save_File( wxCommandEvent& event ); + void SaveProject(); + int LoadOneEEProject( const wxString& FileName, bool IsNew ); + bool LoadOneEEFile(SCH_SCREEN* screen, const wxString& FullFileName ); + bool SaveEEFile( SCH_SCREEN* screen, int FileSave ); + SCH_SCREEN * CreateNewScreen(SCH_SCREEN * OldScreen, int TimeStamp); // General search: @@ -571,7 +582,7 @@ public: void SetToolbars(); void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ); - SCH_SCREEN* GetScreen() { return (SCH_SCREEN*) m_CurrentScreen; } + virtual BASE_SCREEN* GetScreen() { return (BASE_SCREEN*) m_CurrentScreen; } void OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct ); private: @@ -681,7 +692,7 @@ public: void ClickOnLibList( wxCommandEvent& event ); void ClickOnCmpList( wxCommandEvent& event ); - SCH_SCREEN* GetScreen() { return (SCH_SCREEN*) m_CurrentScreen; } + virtual BASE_SCREEN* GetScreen() { return (BASE_SCREEN*) m_CurrentScreen; } private: void SelectCurrentLibrary(); diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp index a3e7f1e135..5aa1955984 100644 --- a/kicad/mainframe.cpp +++ b/kicad/mainframe.cpp @@ -135,6 +135,9 @@ void WinEDA_MainFrame::PrintMsg( const wxString& text ) { m_DialogWin->SetFont( *g_StdFont ); m_DialogWin->AppendText( text ); +#ifdef DEBUG + printf("%s\n", (const char*)text.mb_str() ); +#endif } diff --git a/libs.linux b/libs.linux index 2eedc209a8..fe4f67d33d 100644 --- a/libs.linux +++ b/libs.linux @@ -67,25 +67,25 @@ FINAL = 1 # turn on/OFF debugging for all executables, only tested without KICAD_PYTHON -DEBUG = 0 +DEBUG = 1 # common CPPFLAGS to all components, further CPPFLAGS customization in # directory specific makefile.gtk files. ifeq ($(DEBUG), 1) WXXFLAGS := $(shell wx-config --debug --cxxflags) -CPPFLAGS = -Wall -g3 -ggdb3 ${WXXFLAGS} -fno-strict-aliasing -DDEBUG +CPPFLAGS = -Wall -g3 -ggdb3 ${WXXFLAGS} -fno-strict-aliasing -DDEBUG -D_UNICODE LDFLAGS = -g3 -ggdb3 #-v else WXXFLAGS := $(shell wx-config --cxxflags) -CPPFLAGS = -Wall -O2 ${WXXFLAGS} -fno-strict-aliasing +CPPFLAGS = -Wall -O2 ${WXXFLAGS} -fno-strict-aliasing -D_UNICODE LDFLAGS = -s #-v endif # a command line define which affects pcbnew only, causing it to match current layer ifdef USE_MATCH_LAYER -CPPFLAGS += -DUSE_MATCH_LAYER +CPPFLAGS += -DUSE_MATCH_LAYER endif @@ -164,7 +164,7 @@ endif endif -# attention à l'ordre des libairies +# attention � l'ordre des libairies LIBS = -L/usr/local/lib -L/usr/X11R6/lib\ $(EXTRALIBS) $(WXSYSLIB)\ $(LIBSTDC) $(PYLIBS) diff --git a/pcbnew/autorout.cpp b/pcbnew/autorout.cpp index 289f2ea0ff..3ab8818e4e 100644 --- a/pcbnew/autorout.cpp +++ b/pcbnew/autorout.cpp @@ -29,8 +29,8 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode ) if( g_DesignSettings.m_CopperLayerCount > 1 ) { - Route_Layer_TOP = GetScreen()->m_Route_Layer_TOP; - Route_Layer_BOTTOM = GetScreen()->m_Route_Layer_BOTTOM; + Route_Layer_TOP = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP; + Route_Layer_BOTTOM = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM; } else { diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 4189fa8bc5..b1f94e67f0 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -102,7 +102,7 @@ void WinEDA_BasePcbFrame::CursorGoto( const wxPoint& aPos ) { // factored out of pcbnew/find.cpp - PCB_SCREEN* screen = GetScreen(); + PCB_SCREEN* screen = (PCB_SCREEN*)GetScreen(); wxClientDC dc( DrawPanel ); @@ -201,7 +201,7 @@ void WinEDA_BasePcbFrame::SwitchLayer( wxDC* DC, int layer ) // Note: virtual, overridden in WinEDA_PcbFrame; { - int preslayer = GetScreen()->m_Active_Layer; + int preslayer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer; // Check if the specified layer matches the present layer if( layer == preslayer ) @@ -241,7 +241,7 @@ void WinEDA_BasePcbFrame::SwitchLayer( wxDC* DC, int layer ) // and a non-copper layer, or vice-versa? // ... - GetScreen()->m_Active_Layer = layer; + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = layer; if( DisplayOpt.ContrastModeDisplay ) GetScreen()->SetRefreshReq(); @@ -315,7 +315,7 @@ GENERAL_COLLECTORS_GUIDE WinEDA_BasePcbFrame::GetCollectorsGuide() /****************************************************************/ { GENERAL_COLLECTORS_GUIDE guide( m_Pcb->m_BoardSettings->GetVisibleLayers(), - GetScreen()->m_Active_Layer ); + ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); // account for the globals guide.SetIgnoreMTextsMarkedNoShow( g_ModuleTextNOVColor & ITEM_NOT_SHOW ); diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 3ef242793c..0f39e01271 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -993,12 +993,13 @@ void BOARD::Show( int nestLevel, std::ostream& os ) for( ; p; p = p->Next() ) p->Show( nestLevel+2, os ); NestedSpace( nestLevel+1, os ) << "\n"; - + /* NestedSpace( nestLevel+1, os ) << "\n"; for( ZONE_CONTAINERS::iterator i=m_ZoneDescriptorList.begin(); i!=m_ZoneDescriptorList.end(); ++i ) (*i)->Show( nestLevel+2, os ); NestedSpace( nestLevel+1, os ) << "\n"; - + */ + p = (BOARD_ITEM*) m_Son; for( ; p; p = p->Next() ) { diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 94f0b7ffab..1f706f30c5 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -142,6 +142,7 @@ void MODULE::Copy( MODULE* Module ) m_CntRot90 = Module->m_CntRot90; m_CntRot180 = Module->m_CntRot180; m_LastEdit_Time = Module->m_LastEdit_Time; + m_Path = Module->m_Path; //is this correct behavior? m_TimeStamp = GetTimeStamp(); /* Copy des structures auxiliaires: Reference et value */ @@ -387,7 +388,7 @@ bool MODULE::Save( FILE* aFile ) const } fprintf( aFile, "Sc %8.8lX\n", m_TimeStamp ); - + fprintf( aFile, "AR %s\n", CONV_TO_UTF8(m_Path) ); fprintf( aFile, "Op %X %X 0\n", m_CntRot90, m_CntRot180 ); // attributes @@ -637,6 +638,7 @@ int MODULE::ReadDescr( FILE* File, int* LineNum ) case 'S': sscanf( PtLine, " %lX", &m_TimeStamp ); break; + case 'O': /* (Op)tions de placement auto */ itmp1 = itmp2 = 0; @@ -655,11 +657,19 @@ int MODULE::ReadDescr( FILE* File, int* LineNum ) m_CntRot90 |= itmp1 << 4; break; - case 'A': /* At = (At)tributs du module */ - if( strstr( PtLine, "SMD" ) ) - m_Attributs |= MOD_CMS; - if( strstr( PtLine, "VIRTUAL" ) ) - m_Attributs |= MOD_VIRTUAL; + case 'A': + if(Line[1] == 't'){ + /* At = (At)tributs du module */ + if( strstr( PtLine, "SMD" ) ) + m_Attributs |= MOD_CMS; + if( strstr( PtLine, "VIRTUAL" ) ) + m_Attributs |= MOD_VIRTUAL; + } + if(Line[1] == 'R'){ + //alternate reference, e.g. /478C2408/478AD1B6 + sscanf( PtLine, " %s", BufLine ); + m_Path = CONV_FROM_UTF8(BufLine); + } break; case 'T': /* lecture des textes modules */ @@ -1046,7 +1056,7 @@ void MODULE::Display_Infos( WinEDA_DrawFrame* frame ) Affiche_1_Parametre( frame, pos, m_Reference->m_Text, m_Value->m_Text, DARKCYAN ); /* Affiche signature temporelle ou date de modif (en edition de modules) */ - pos += 14; + pos += 6; if( flag ) // Affichage date de modification (utile en Module Editor) { strcpy( Line, ctime( &m_LastEdit_Time ) ); @@ -1062,10 +1072,10 @@ void MODULE::Display_Infos( WinEDA_DrawFrame* frame ) else { msg.Printf( wxT( "%8.8lX" ), m_TimeStamp ); - Affiche_1_Parametre( frame, pos, _( "TimeStamp" ), msg, BROWN ); + Affiche_1_Parametre( frame, pos, _( "Netlist path" ), /*msg*/m_Path, BROWN ); } - pos += 6; + pos += 12; Affiche_1_Parametre( frame, pos, _( "Layer" ), ReturnPcbLayerName( m_Layer ), RED ); pos += 6; diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index 2cd49e48e1..b1e46ced8d 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -65,6 +65,7 @@ public: unsigned long m_Link; // variable temporaire ( pour editions, ...) long m_LastEdit_Time; // Date de la derniere modification du module (gestion de librairies) + wxString m_Path; wxString m_Doc; // Texte de description du module wxString m_KeyWord; // Liste des mots cles relatifs au module diff --git a/pcbnew/cleaningoptions_dialog.cpp b/pcbnew/cleaningoptions_dialog.cpp index 4362727b58..315ec05ac4 100644 --- a/pcbnew/cleaningoptions_dialog.cpp +++ b/pcbnew/cleaningoptions_dialog.cpp @@ -179,7 +179,7 @@ void WinEDA_CleaningOptionsFrame::CreateControls() itemBoxSizer9->Add(itemButton10, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); // Set validators - m_CleanViasOpt->SetValidator( wxGenericValidator(& s_CleanVias) ); + m_CleanViasOpt->SetValidator( wxGenericValidator(& s_CleanVias ) ); m_MergetSegmOpt->SetValidator( wxGenericValidator(& s_MergeSegments) ); m_DeleteunconnectedOpt->SetValidator( wxGenericValidator(& s_DeleteUnconnectedSegm) ); ////@end WinEDA_CleaningOptionsFrame content construction diff --git a/pcbnew/cleaningoptions_dialog.h b/pcbnew/cleaningoptions_dialog.h index 26d42f1176..2d905463ad 100644 --- a/pcbnew/cleaningoptions_dialog.h +++ b/pcbnew/cleaningoptions_dialog.h @@ -51,7 +51,14 @@ #define SYMBOL_WINEDA_CLEANINGOPTIONSFRAME_POSITION wxDefaultPosition ////@end control identifiers +class WinEDA_PcbFrame; +/*declared in clean.cpp: +extern static bool s_CleanVias; +extern static bool s_MergeSegments; +extern static bool s_DeleteUnconnectedSegm; +void Clean_Pcb_Items( WinEDA_PcbFrame* frame, wxDC* DC ); +//end clean.cpp */ /*! * WinEDA_CleaningOptionsFrame class declaration */ diff --git a/pcbnew/cotation.cpp b/pcbnew/cotation.cpp index a167c8eef5..c5dae505e2 100644 --- a/pcbnew/cotation.cpp +++ b/pcbnew/cotation.cpp @@ -231,7 +231,7 @@ COTATION* WinEDA_PcbFrame::Begin_Cotation( COTATION* Cotation, wxDC* DC ) Cotation = new COTATION( m_Pcb ); Cotation->m_Flags = IS_NEW; - Cotation->SetLayer( GetScreen()->m_Active_Layer ); + Cotation->SetLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); Cotation->m_Width = g_DesignSettings.m_DrawSegmentWidth; Cotation->m_Text->m_Width = Cotation->m_Width; diff --git a/pcbnew/deltrack.cpp b/pcbnew/deltrack.cpp index 24d353da05..8ddc22626d 100644 --- a/pcbnew/deltrack.cpp +++ b/pcbnew/deltrack.cpp @@ -44,7 +44,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track ) { if( g_TrackSegmentCount > 0 ) { - int previous_layer = GetScreen()->m_Active_Layer; + int previous_layer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer; // effacement de la piste en cours ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE ); @@ -85,7 +85,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track ) // Rectification couche active qui a pu changer si une via // a ete effacee - GetScreen()->m_Active_Layer = previous_layer; + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = previous_layer; Affiche_Status_Box(); if( g_TwoSegmentTrackBuild ) // We must have 2 segments or more, or 0 diff --git a/pcbnew/dialog_drc.cpp b/pcbnew/dialog_drc.cpp index 6da699d06f..38e6add081 100644 --- a/pcbnew/dialog_drc.cpp +++ b/pcbnew/dialog_drc.cpp @@ -33,6 +33,7 @@ ////@begin includes ////@end includes +#include "wxstruct.h" #include "dialog_drc.h" ////@begin XPM images diff --git a/pcbnew/dialog_drc.h b/pcbnew/dialog_drc.h index e7afaa9370..d000eee0a8 100644 --- a/pcbnew/dialog_drc.h +++ b/pcbnew/dialog_drc.h @@ -24,6 +24,8 @@ ////@begin includes #include "wx/notebook.h" +#include "wxPcbStruct.h" +#include "drc_stuff.h" ////@end includes diff --git a/pcbnew/dialog_netlist.h b/pcbnew/dialog_netlist.h index f9ba1271ef..7af6e84845 100644 --- a/pcbnew/dialog_netlist.h +++ b/pcbnew/dialog_netlist.h @@ -123,7 +123,10 @@ public: int ReadListeModules(const wxString * RefCmp, long TimeStamp, wxString & NameModule); int SetPadNetName( char * Line, MODULE * Module); MODULE * ReadNetModule( char * Text, int * UseFichCmp, int TstOnly); - void AddToList(const wxString & NameLibCmp, const wxString & NameCmp,int TimeStamp ); + void AddToList(const wxString & NameLibCmp, + const wxString & NameCmp, + int TimeStamp, + const wxString& path); void LoadListeModules(wxDC *DC); ////@begin WinEDA_NetlistFrame member variables diff --git a/pcbnew/dialog_zones_by_polygon.cpp b/pcbnew/dialog_zones_by_polygon.cpp index 2fbc45612e..1001f547cb 100644 --- a/pcbnew/dialog_zones_by_polygon.cpp +++ b/pcbnew/dialog_zones_by_polygon.cpp @@ -329,7 +329,7 @@ void WinEDA_ZoneFrame::CreateControls() } else { - if( m_Parent->GetScreen()->m_Active_Layer == layer_number ) + if( ((PCB_SCREEN*)(m_Parent->GetScreen()))->m_Active_Layer == layer_number ) m_LayerSelectionCtrl->SetSelection( ii ); } } diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 48006054b5..d18caf1e1b 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -380,8 +380,8 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_PLACE_MICROVIA: - if( !GetScreen()->IsMicroViaAcceptable() ) - break; + if ( ! ((PCB_SCREEN*)GetScreen())->IsMicroViaAcceptable() ) + break; case ID_POPUP_PCB_PLACE_VIA: DrawPanel->MouseToCursorSchema(); @@ -397,7 +397,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) Other_Layer_Route( (TRACK*) GetCurItem(), &dc ); g_DesignSettings.m_CurrentViaType = v_type; if( DisplayOpt.ContrastModeDisplay ) - GetScreen()->SetRefreshReq(); + ((PCB_SCREEN*)GetScreen())->SetRefreshReq(); } break; @@ -705,9 +705,9 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_SELECT_LAYER: - itmp = SelectLayer( GetScreen()->m_Active_Layer, -1, -1 ); + itmp = SelectLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer, -1, -1 ); if( itmp >= 0 ) - GetScreen()->m_Active_Layer = itmp; + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = itmp; DrawPanel->MouseToCursorSchema(); break; @@ -716,16 +716,16 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_SELECT_NO_CU_LAYER: - itmp = SelectLayer( GetScreen()->m_Active_Layer, FIRST_NO_COPPER_LAYER, -1 ); + itmp = SelectLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer, FIRST_NO_COPPER_LAYER, -1 ); if( itmp >= 0 ) - GetScreen()->m_Active_Layer = itmp; + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = itmp; DrawPanel->MouseToCursorSchema(); break; case ID_POPUP_PCB_SELECT_CU_LAYER: - itmp = SelectLayer( GetScreen()->m_Active_Layer, -1, LAST_COPPER_LAYER ); + itmp = SelectLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer, -1, LAST_COPPER_LAYER ); if( itmp >= 0 ) - GetScreen()->m_Active_Layer = itmp; + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = itmp; break; case ID_POPUP_PCB_SELECT_LAYER_PAIR: @@ -735,7 +735,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_TOOLBARH_PCB_SELECT_LAYER: itmp = m_SelLayerBox->GetChoice(); - GetScreen()->m_Active_Layer = (int) ( (size_t) m_SelLayerBox->GetClientData( itmp ) ); + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = (int) ( (size_t) m_SelLayerBox->GetClientData( itmp ) ); if( DisplayOpt.ContrastModeDisplay ) DrawPanel->Refresh( TRUE ); break; @@ -1087,7 +1087,7 @@ void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC ) void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer ) /*****************************************************************/ { - int preslayer = GetScreen()->m_Active_Layer; + int preslayer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer; // Check if the specified layer matches the present layer if( layer == preslayer ) @@ -1140,9 +1140,9 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer ) // Want to set the routing layers so that it switches properly - // see the implementation of Other_Layer_Route - the working // layer is used to 'start' the via and set the layer masks appropriately. - GetScreen()->m_Route_Layer_TOP = preslayer; - GetScreen()->m_Route_Layer_BOTTOM = layer; - GetScreen()->m_Active_Layer = preslayer; + ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP = preslayer; + ((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM = layer; + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = preslayer; if( Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC ) ) { @@ -1163,7 +1163,7 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer ) // and a non-copper layer, or vice-versa? // ... - GetScreen()->m_Active_Layer = layer; + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = layer; if( DisplayOpt.ContrastModeDisplay ) GetScreen()->SetRefreshReq(); diff --git a/pcbnew/editedge.cpp b/pcbnew/editedge.cpp index c0e4804847..97be6bdf0c 100644 --- a/pcbnew/editedge.cpp +++ b/pcbnew/editedge.cpp @@ -265,7 +265,7 @@ DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment, DRAWSEGMENT* DrawItem; s_large = g_DesignSettings.m_DrawSegmentWidth; - if( GetScreen()->m_Active_Layer == EDGE_N ) + if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer == EDGE_N ) { s_large = g_DesignSettings.m_EdgeSegmentWidth; } @@ -277,7 +277,7 @@ DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment, { SetCurItem( Segment = new DRAWSEGMENT( m_Pcb ) ); Segment->m_Flags = IS_NEW; - Segment->SetLayer( GetScreen()->m_Active_Layer ); + Segment->SetLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); Segment->m_Width = s_large; Segment->m_Shape = shape; Segment->m_Angle = 900; diff --git a/pcbnew/editrack-part2.cpp b/pcbnew/editrack-part2.cpp index 15eee52001..e20126b8a2 100644 --- a/pcbnew/editrack-part2.cpp +++ b/pcbnew/editrack-part2.cpp @@ -165,10 +165,10 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) if( track == NULL ) { - if( GetScreen()->m_Active_Layer != GetScreen()->m_Route_Layer_TOP ) - GetScreen()->m_Active_Layer = GetScreen()->m_Route_Layer_TOP; + if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer != ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP ) + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP; else - GetScreen()->m_Active_Layer = GetScreen()->m_Route_Layer_BOTTOM; + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM; Affiche_Status_Box(); SetToolbars(); return true; @@ -214,32 +214,32 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) Via->m_Width = g_DesignSettings.m_CurrentViaSize; Via->SetNet( g_HightLigth_NetCode ); Via->m_Start = Via->m_End = g_CurrentTrackSegment->m_End; - int old_layer = GetScreen()->m_Active_Layer; + int old_layer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer; //swap the layers. - if( GetScreen()->m_Active_Layer != GetScreen()->m_Route_Layer_TOP ) - GetScreen()->m_Active_Layer = GetScreen()->m_Route_Layer_TOP; + if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer != ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP ) + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP; else - GetScreen()->m_Active_Layer = GetScreen()->m_Route_Layer_BOTTOM; + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM; /* Adjust the via layer pair */ switch ( Via->Shape() ) { case VIA_BLIND_BURIED: - Via->SetLayerPair( old_layer, GetScreen()->m_Active_Layer ); + Via->SetLayerPair( old_layer, ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); break; case VIA_MICROVIA: // from external to the near neghbour inner layer if ( old_layer == COPPER_LAYER_N ) - GetScreen()->m_Active_Layer = LAYER_N_2; + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = LAYER_N_2; else if ( old_layer == LAYER_CMP_N ) - GetScreen()->m_Active_Layer = m_Pcb->m_BoardSettings->m_CopperLayerCount - 2; + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = m_Pcb->m_BoardSettings->m_CopperLayerCount - 2; else if ( old_layer == LAYER_N_2 ) - GetScreen()->m_Active_Layer = COPPER_LAYER_N; + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = COPPER_LAYER_N; else if ( old_layer == m_Pcb->m_BoardSettings->m_CopperLayerCount - 2 ) - GetScreen()->m_Active_Layer = LAYER_CMP_N; + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = LAYER_CMP_N; // else error - Via->SetLayerPair( old_layer, GetScreen()->m_Active_Layer ); + Via->SetLayerPair( old_layer, ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); Via->m_Width = g_DesignSettings.m_CurrentMicroViaSize; break; @@ -254,7 +254,7 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) /* DRC fault: the Via cannot be placed here ... */ delete Via; - GetScreen()->m_Active_Layer = old_layer; + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = old_layer; DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); @@ -286,7 +286,7 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) * from the last entered segment, with the current width, flags, netcode, etc... values * layer, start and end point are not correct, and will be modified next */ - g_CurrentTrackSegment->SetLayer( GetScreen()->m_Active_Layer ); // set the layer to the new value + g_CurrentTrackSegment->SetLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); // set the layer to the new value /* the start point is the via position, * and the end point is the cursor which also is on the via (will change when moving mouse) @@ -331,7 +331,7 @@ void WinEDA_PcbFrame::Affiche_Status_Net( wxDC* DC ) */ { TRACK* pt_segm; - int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer]; + int masquelayer = g_TabOneLayerMask[((PCB_SCREEN*)GetScreen())->m_Active_Layer]; pt_segm = Locate_Pistes( m_Pcb->m_Track, masquelayer, CURSEUR_OFF_GRILLE ); if( pt_segm == NULL ) diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index c1b62b0941..6701dc6d46 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -86,7 +86,7 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC ) { D_PAD* pt_pad = NULL; TRACK* TrackOnStartPoint = NULL, * Track; - int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer]; + int masquelayer = g_TabOneLayerMask[((PCB_SCREEN*)GetScreen())->m_Active_Layer]; EDA_BaseStruct* LockPoint; wxPoint pos = GetScreen()->m_Curseur; static int InitialTrackWidthValue; /* first track segment width. @@ -135,7 +135,7 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC ) Hight_Light( DC ); g_CurrentTrackSegment->m_Flags = IS_NEW; - g_CurrentTrackSegment->SetLayer( GetScreen()->m_Active_Layer ); + g_CurrentTrackSegment->SetLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth; if( g_DesignSettings.m_UseConnectedTrackWidth ) { @@ -230,7 +230,7 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC ) g_CurrentTrackSegment->m_Flags = IS_NEW; g_TrackSegmentCount++; g_CurrentTrackSegment->m_Start = g_CurrentTrackSegment->m_End; - g_CurrentTrackSegment->SetLayer( GetScreen()->m_Active_Layer ); + g_CurrentTrackSegment->SetLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); if( !g_DesignSettings.m_UseConnectedTrackWidth ) { g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth; @@ -387,7 +387,7 @@ void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC ) * Routine de fin de trace d'une piste (succession de segments) */ { - int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer]; + int masquelayer = g_TabOneLayerMask[((PCB_SCREEN*)GetScreen())->m_Active_Layer]; wxPoint pos; EDA_BaseStruct* LockPoint; TRACK* adr_buf; diff --git a/pcbnew/export_gencad.cpp b/pcbnew/export_gencad.cpp index 237f195c8c..9fec8cb9a6 100644 --- a/pcbnew/export_gencad.cpp +++ b/pcbnew/export_gencad.cpp @@ -493,7 +493,7 @@ bool CreateHeaderInfoData( FILE* file, WinEDA_PcbFrame* frame ) */ { wxString msg; - PCB_SCREEN* screen = frame->GetScreen(); + PCB_SCREEN* screen = (PCB_SCREEN*)(frame->GetScreen()); fputs( "$HEADER\n", file ); fputs( "GENCAD 1.4\n", file ); diff --git a/pcbnew/find.cpp b/pcbnew/find.cpp index 07a87afa06..fb69c77b93 100644 --- a/pcbnew/find.cpp +++ b/pcbnew/find.cpp @@ -42,7 +42,7 @@ void WinEDA_PcbFrame::InstallFindFrame( const wxPoint& pos, wxDC* DC ) void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) /********************************************************/ { - PCB_SCREEN* screen = m_Parent->GetScreen(); + PCB_SCREEN* screen = (PCB_SCREEN*)(m_Parent->GetScreen()); wxPoint locate_pos; wxString msg; bool FindMarker = FALSE; diff --git a/pcbnew/gendrill.cpp b/pcbnew/gendrill.cpp index 8b2cb228fe..3f10de8460 100644 --- a/pcbnew/gendrill.cpp +++ b/pcbnew/gendrill.cpp @@ -44,7 +44,7 @@ static int s_Zeros_Format = DECIMAL_FORMAT; static DrillPrecision s_Precision( 2, 4 ); static bool DrillOriginIsAuxAxis; // Axis selection (main / auxiliary) for Drill Origin coordinates -static wxPoint File_Drill_Offset; /* Offset des coord de percage pour le fichier généré */ +static wxPoint File_Drill_Offset; /* Offset des coord de percage pour le fichier g�n�r� */ static bool Minimal = false; static bool Mirror = true; @@ -629,7 +629,7 @@ void WinEDA_DrillFrame::Write_Excellon_Header( FILE* aFile ) /* Print the DRILL file header. The full header is: * M48 * ;DRILL file {PCBNEW (2007-11-29-b)} date 17/1/2008-21:02:35 - * ;FORMAT={2:4 / absolute / Pouces / Suppression zeros de tête} + * ;FORMAT={2:4 / absolute / Pouces / Suppression zeros de t�te} * R,T * VER,1 * FMAT,2 @@ -748,7 +748,7 @@ void WinEDA_DrillFrame::GenDrillMap( const wxString aFileName, GenDrillMapFile( m_Parent->m_Pcb, dest, FullFileName, - m_Parent->m_CurrentScreen->m_CurrentSheet->m_Size, + m_Parent->m_CurrentScreen->m_CurrentSheetDesc->m_Size, s_HoleListBuffer, s_ToolListBuffer, s_Unit_Drill_is_Inch, diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index cdaa4e6ae1..25499091ea 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -207,7 +207,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, break; case HK_SWITCH_LAYER_TO_PREVIOUS: - ll = GetScreen()->m_Active_Layer; + ll = ((PCB_SCREEN*)GetScreen())->m_Active_Layer; if( (ll <= COPPER_LAYER_N) || (ll > CMP_N) ) break; if( m_Pcb->m_BoardSettings->m_CopperLayerCount < 2 ) // Single layer @@ -220,7 +220,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, break; case HK_SWITCH_LAYER_TO_NEXT: - ll = GetScreen()->m_Active_Layer; + ll = ((PCB_SCREEN*)GetScreen())->m_Active_Layer; if( (ll < COPPER_LAYER_N) || (ll >= CMP_N) ) break; if( m_Pcb->m_BoardSettings->m_CopperLayerCount < 2 ) // Single layer @@ -305,7 +305,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, break; case HK_BACK_SPACE: - if( m_ID_current_state == ID_TRACK_BUTT && GetScreen()->m_Active_Layer <= CMP_N ) + if( m_ID_current_state == ID_TRACK_BUTT && ((PCB_SCREEN*)GetScreen())->m_Active_Layer <= CMP_N ) { if( ItemFree ) { @@ -396,7 +396,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, return; // place micro via and switch layer - if ( GetScreen()->IsMicroViaAcceptable() ) + if ( ((PCB_SCREEN*)GetScreen())->IsMicroViaAcceptable() ) { int v_type = g_DesignSettings.m_CurrentViaType; g_DesignSettings.m_CurrentViaType = VIA_MICROVIA; @@ -604,7 +604,7 @@ bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct ) switch( m_ID_current_state ) { case ID_TRACK_BUTT: - if( GetScreen()->m_Active_Layer > CMP_N ) + if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer > CMP_N ) return FALSE; if( ItemFree ) { diff --git a/pcbnew/initpcb.cpp b/pcbnew/initpcb.cpp index cd219ddcd1..f7bb1ed804 100644 --- a/pcbnew/initpcb.cpp +++ b/pcbnew/initpcb.cpp @@ -186,7 +186,7 @@ bool WinEDA_BasePcbFrame::Clear_Pcb( bool query ) SetCurItem( NULL ); /* Init parametres de gestion */ - GetScreen()->Init(); + ((PCB_SCREEN*)GetScreen())->Init(); g_HightLigt_Status = 0; diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp index 5c48874245..d6d64ec07b 100644 --- a/pcbnew/ioascii.cpp +++ b/pcbnew/ioascii.cpp @@ -619,7 +619,7 @@ bool WriteSheetDescr( BASE_SCREEN* screen, FILE* File ) * @param File = an openen FILE to write info */ { - Ki_PageDescr* sheet = screen->m_CurrentSheet; + Ki_PageDescr* sheet = screen->m_CurrentSheetDesc; fprintf( File, "$SHEETDESCR\n" ); fprintf( File, "Sheet %s %d %d\n", @@ -659,7 +659,7 @@ static bool ReadSheetDescr( BASE_SCREEN* screen, FILE* File, int* LineNum ) { if( stricmp( CONV_TO_UTF8( sheet->m_Name ), text ) == 0 ) { - screen->m_CurrentSheet = sheet; + screen->m_CurrentSheetDesc = sheet; if( sheet == &g_Sheet_user ) { text = strtok( NULL, " \t\n\r" ); diff --git a/pcbnew/locate.cpp b/pcbnew/locate.cpp index 0a9cda2d7c..3f2e2255d6 100644 --- a/pcbnew/locate.cpp +++ b/pcbnew/locate.cpp @@ -35,7 +35,7 @@ MODULE* ReturnModule( BOARD* pcb, const wxString& reference ) * Recherche d'un module par sa reference * Retourne: * un pointeur sur le module - * Null si pas localisé + * Null si pas localis� */ { MODULE* Module = pcb->m_Modules; @@ -165,7 +165,7 @@ D_PAD* Locate_Pad_Connecte( BOARD* Pcb, TRACK* ptr_piste, int extr ) * pointeur NULL si pastille non trouvee * num_empr = numero d'empreinte du pad * - * la priorité est donnée a la couche active + * la priorit� est donn�e a la couche active */ D_PAD* Locate_Any_Pad( BOARD* Pcb, int typeloc, bool OnlyCurrentLayer ) @@ -240,9 +240,11 @@ D_PAD* Locate_Pads( MODULE* module, const wxPoint& ref_pos, int masque_layer ) /** * Function Locate_Prefered_Module * locates a footprint by its bounding rectangle. If several footprints - * are possible, then the priority is: on the active layer, then smallest. + * are possible, then the priority is: the closest on the active layer, then closest. * The current mouse or cursor coordinates are grabbed from the active window * to performe hit-testing. + * distance is calculated via manhattan distance from the center of the bounding rectangle + * to the cursor postition. * * @param Pcb The BOARD to search within. * @param typeloc Flag bits, tuning the search, see pcbnew.h @@ -287,26 +289,33 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc ) /* Localisation: test des dimensions minimales, choix du meilleur candidat */ /* calcul des dimensions du cadre :*/ - lx = pt_module->m_BoundaryBox.GetWidth(); - ly = pt_module->m_BoundaryBox.GetHeight(); + int offx = pt_module->m_BoundaryBox.m_Size.x/2 + + pt_module->m_BoundaryBox.m_Pos.x + + pt_module->m_Pos.x; + int offy = pt_module->m_BoundaryBox.m_Size.y/2 + + pt_module->m_BoundaryBox.m_Pos.y + + pt_module->m_Pos.y; + //off x & offy point to the middle of the box. + int dist = abs(ref_pos.x - offx) + abs(ref_pos.y - offy); + lx = pt_module->m_BoundaryBox.GetWidth(); + ly = pt_module->m_BoundaryBox.GetHeight(); + //int dist = MIN(lx, ly); // to pick the smallest module (kinda screwy with same-sized modules -- this is bad!) - if( ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer == layer ) - { - if( MIN( lx, ly ) <= min_dim ) - { + if( ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer == layer ){ + if( dist <= min_dim ){ /* meilleure empreinte localisee sur couche active */ module = pt_module; - min_dim = MIN( lx, ly ); + min_dim = dist; } } else if( !(typeloc & MATCH_LAYER) && ( !(typeloc & VISIBLE_ONLY) || IsModuleLayerVisible( layer ) ) ) { - if( MIN( lx, ly ) <= alt_min_dim ) + if( dist <= alt_min_dim ) { /* meilleure empreinte localisee sur autres couches */ Altmodule = pt_module; - alt_min_dim = MIN( lx, ly ); + alt_min_dim = dist; } } } diff --git a/pcbnew/makefile.gtk b/pcbnew/makefile.gtk index bb1eeaf453..9ed26d9e1b 100644 --- a/pcbnew/makefile.gtk +++ b/pcbnew/makefile.gtk @@ -3,6 +3,8 @@ include ../libs.linux +BOOST_LIB = /usr/include/boost + # Additional compiler flags CPPFLAGS += diff --git a/pcbnew/makefile.include b/pcbnew/makefile.include index e67b86762f..cfa2cc01f6 100644 --- a/pcbnew/makefile.include +++ b/pcbnew/makefile.include @@ -101,7 +101,6 @@ OBJECTS= $(TARGET).o classpcb.o\ work.o queue.o \ board.o dist.o graphpcb.o \ undelete.o \ - copy_track.o\ move_or_drag_track.o\ ioascii.o \ mirepcb.o xchgmod.o\ @@ -120,7 +119,11 @@ OBJECTS= $(TARGET).o classpcb.o\ modedit.o\ export_gencad.o\ hotkeys.o \ - collectors.o + collectors.o \ + specctra.cpp \ + specctra_import.cpp \ + specctra_export.cpp + PolyLine.o: ../polygon/PolyLine.cpp ../polygon/PolyLine.h $(COMMON) diff --git a/pcbnew/netlist.cpp b/pcbnew/netlist.cpp index 280e7f4a87..5c5e740335 100644 --- a/pcbnew/netlist.cpp +++ b/pcbnew/netlist.cpp @@ -36,9 +36,13 @@ class MODULEtoLOAD : public EDA_BaseStruct public: wxString m_LibName; wxString m_CmpName; + wxString m_Path; public: - MODULEtoLOAD( const wxString& libname, const wxString& cmpname, int timestamp ); + MODULEtoLOAD( const wxString& libname, + const wxString& cmpname, + int timestamp, + const wxString& path); ~MODULEtoLOAD() { }; MODULEtoLOAD* Next() { return (MODULEtoLOAD*) Pnext; } }; @@ -333,7 +337,8 @@ MODULE* WinEDA_NetlistFrame::ReadNetModule( char* Text, int* UseFichCmp, if( Error > 0 ) return NULL; - TextTimeStamp.ToULong( &TimeStamp, 16 ); + wxString LocalTimeStamp = TextTimeStamp.AfterLast('/'); + LocalTimeStamp.ToULong( &TimeStamp, 16 ); /* Tst si composant deja charge */ Module = (MODULE*) m_Parent->m_Pcb->m_Modules; @@ -343,8 +348,9 @@ MODULE* WinEDA_NetlistFrame::ReadNetModule( char* Text, int* UseFichCmp, NextModule = (MODULE*) Module->Pnext; if( m_Select_By_Timestamp->GetSelection() == 1 ) /* Reconnaissance par signature temporelle */ { - if( TimeStamp == Module->m_TimeStamp ) - Found = TRUE; + //if( TimeStamp == Module->m_TimeStamp ) + if(TextTimeStamp.CmpNoCase(Module->m_Path)) + Found = TRUE; } else /* Reconnaissance par Reference */ { @@ -414,7 +420,7 @@ MODULE* WinEDA_NetlistFrame::ReadNetModule( char* Text, int* UseFichCmp, if( TstOnly == TESTONLY ) - AddToList( NameLibCmp, TextCmpName, TimeStamp ); + AddToList( NameLibCmp, TextCmpName, TimeStamp, TextTimeStamp ); else { wxString msg; @@ -433,6 +439,9 @@ MODULE* WinEDA_NetlistFrame::ReadNetModule( char* Text, int* UseFichCmp, Module->m_Reference->m_Text = TextCmpName; Module->m_Value->m_Text = TextValeur; Module->m_TimeStamp = TimeStamp; + Module->m_Path = TextTimeStamp; + printf("in ReadNetModule() m_Path = %s\n", + CONV_TO_UTF8(Module->m_Path) ); return Module; /* composant trouve */ } @@ -556,9 +565,9 @@ void WinEDA_NetlistFrame::ModulesControle( wxCommandEvent& event ) /***************************************************************/ /* donne la liste : - * 1 - des empreintes doublées sur le PCB + * 1 - des empreintes doubl�es sur le PCB * 2 - des empreintes manquantes par rapport a la netliste - * 3 - des empreintes supplémentaires par rapport a la netliste + * 3 - des empreintes suppl�mentaires par rapport a la netliste */ #define MAX_LEN_TXT 32 { @@ -662,7 +671,7 @@ int WinEDA_NetlistFrame::BuildListeNetModules( wxCommandEvent& event, wxArrayStr /* * charge en BufName la liste des noms des modules de la netliste, - * retourne le nombre des modules cités dans la netliste + * retourne le nombre des modules cit�s dans la netliste */ { int textlen; @@ -884,7 +893,7 @@ void WinEDA_NetlistFrame::Set_NetlisteName( wxCommandEvent& event ) /***********************************************************************************/ void WinEDA_NetlistFrame::AddToList( const wxString& NameLibCmp, const wxString& CmpName, - int TimeStamp ) + int TimeStamp, const wxString& path) /************************************************************************************/ /* Fontion copiant en memoire de travail les caracteristiques @@ -893,7 +902,7 @@ void WinEDA_NetlistFrame::AddToList( const wxString& NameLibCmp, const wxString& { MODULEtoLOAD* NewMod; - NewMod = new MODULEtoLOAD( NameLibCmp, CmpName, TimeStamp ); + NewMod = new MODULEtoLOAD( NameLibCmp, CmpName, TimeStamp, path ); NewMod->Pnext = s_ModuleToLoad_List; s_ModuleToLoad_List = NewMod; s_NbNewModules++; @@ -921,7 +930,7 @@ void WinEDA_NetlistFrame::LoadListeModules( wxDC* DC ) SortListModulesToLoadByLibname( s_NbNewModules ); ref = cmp = s_ModuleToLoad_List; - // Calcul de la coordonnée de placement des modules: + // Calcul de la coordonn�e de placement des modules: if( m_Parent->SetBoardBoundaryBoxFromEdgesOnly() ) { m_Parent->m_CurrentScreen->m_Curseur.x = m_Parent->m_Pcb->m_BoundaryBox.GetRight() + 5000; @@ -953,6 +962,7 @@ void WinEDA_NetlistFrame::LoadListeModules( wxDC* DC ) * si module charge */ Module->m_Reference->m_Text = cmp->m_CmpName; Module->m_TimeStamp = cmp->m_TimeStamp; + Module->m_Path = cmp->m_Path; } else { @@ -966,6 +976,7 @@ void WinEDA_NetlistFrame::LoadListeModules( wxDC* DC ) Module = newmodule; Module->m_Reference->m_Text = cmp->m_CmpName; Module->m_TimeStamp = cmp->m_TimeStamp; + Module->m_Path = cmp->m_Path; } } @@ -1022,10 +1033,11 @@ void SortListModulesToLoadByLibname( int NbModules ) /*****************************************************************************/ MODULEtoLOAD::MODULEtoLOAD( const wxString& libname, const wxString& cmpname, - int timestamp ) : EDA_BaseStruct( TYPE_NOT_INIT ) + int timestamp, const wxString& path ) : EDA_BaseStruct( TYPE_NOT_INIT ) /*****************************************************************************/ { m_LibName = libname; m_CmpName = cmpname; m_TimeStamp = timestamp; + m_Path = path; } diff --git a/pcbnew/onleftclick.cpp b/pcbnew/onleftclick.cpp index b4b697162e..d13a59b279 100644 --- a/pcbnew/onleftclick.cpp +++ b/pcbnew/onleftclick.cpp @@ -171,7 +171,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) if( m_ID_current_state == ID_PCB_ARC_BUTT ) shape = S_ARC; - if( GetScreen()->m_Active_Layer <= LAST_COPPER_LAYER ) + if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer <= LAST_COPPER_LAYER ) { DisplayError( this, _( "Graphic not authorized on Copper layers" ) ); break; @@ -194,7 +194,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) } case ID_TRACK_BUTT: - if( GetScreen()->m_Active_Layer > LAST_COPPER_LAYER ) + if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer > LAST_COPPER_LAYER ) { DisplayError( this, _( "Tracks on Copper layers only " ) ); break; @@ -276,7 +276,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) break; case ID_PCB_COTATION_BUTT: - if( GetScreen()->m_Active_Layer <= LAST_COPPER_LAYER ) + if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer <= LAST_COPPER_LAYER ) { DisplayError( this, _( "Cotation not authorized on Copper layers" ) ); break; diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index be7bf9721e..496fa9a82b 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -581,7 +581,7 @@ void WinEDA_PcbFrame::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu ) PopMenu->Append( ID_POPUP_PCB_PLACE_VIA, msg ); // See if we can place a Micro Via (4 or more layers, and start from an external layer): - if( GetScreen()->IsMicroViaAcceptable() ) + if( ((PCB_SCREEN*)GetScreen())->IsMicroViaAcceptable() ) { msg = AddHotkeyName( _( "Place Micro Via" ), s_Board_Editor_Hokeys_Descr, diff --git a/pcbnew/pcbnew.h b/pcbnew/pcbnew.h index b499d93df0..62bd03f5fa 100644 --- a/pcbnew/pcbnew.h +++ b/pcbnew/pcbnew.h @@ -131,7 +131,7 @@ eda_global bool g_Raccord_45_Auto eda_global bool g_ShowIsolDuringCreateTrack; /* Show clearance while track creation */ /*********************************/ -/* Displa otions for board items */ +/* Display options for board items */ /*********************************/ eda_global DISPLAY_OPTIONS DisplayOpt; diff --git a/pcbnew/pcbtexte.cpp b/pcbnew/pcbtexte.cpp index d897f1a5ba..8c9fa37660 100644 --- a/pcbnew/pcbtexte.cpp +++ b/pcbnew/pcbtexte.cpp @@ -349,7 +349,7 @@ TEXTE_PCB* WinEDA_PcbFrame::Create_Texte_Pcb( wxDC* DC ) /* Mise a jour des caracteristiques */ TextePcb->m_Flags = IS_NEW; - TextePcb->SetLayer( GetScreen()->m_Active_Layer ); + TextePcb->SetLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); TextePcb->m_Miroir = 1; if( TextePcb->GetLayer() == COPPER_LAYER_N ) TextePcb->m_Miroir = 0; diff --git a/pcbnew/plothpgl.cpp b/pcbnew/plothpgl.cpp index 8a1c93f233..0d8268322e 100644 --- a/pcbnew/plothpgl.cpp +++ b/pcbnew/plothpgl.cpp @@ -39,8 +39,8 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer ) scale_y = Scale_Y * SCALE_HPGL; // calcul en unites internes des dimensions de la feuille ( connues en 1/1000 pouce ) - SheetSize.x = m_CurrentScreen->m_CurrentSheet->m_Size.x * U_PCB; - SheetSize.y = m_CurrentScreen->m_CurrentSheet->m_Size.y * U_PCB; + SheetSize.x = m_CurrentScreen->m_CurrentSheetDesc->m_Size.x * U_PCB; + SheetSize.y = m_CurrentScreen->m_CurrentSheetDesc->m_Size.y * U_PCB; g_PlotOffset.x = 0; g_PlotOffset.y = (int) (SheetSize.y * scale_y); diff --git a/pcbnew/plotps.cpp b/pcbnew/plotps.cpp index 4d4863cbc2..811b4bf38e 100644 --- a/pcbnew/plotps.cpp +++ b/pcbnew/plotps.cpp @@ -38,7 +38,7 @@ void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer ) wxSize BoardSize; wxPoint BoardCenter; bool Center = FALSE; - Ki_PageDescr* currentsheet = m_CurrentScreen->m_CurrentSheet; + Ki_PageDescr* currentsheet = m_CurrentScreen->m_CurrentSheetDesc; double scale_format; // Facteur correctif pour conversion forlat Ax->A4 double scale_x, scale_y; int PlotMarge_in_mils = 0; diff --git a/pcbnew/set_grid.cpp b/pcbnew/set_grid.cpp index 2829495deb..6fbfd3d19b 100644 --- a/pcbnew/set_grid.cpp +++ b/pcbnew/set_grid.cpp @@ -84,7 +84,7 @@ wxString msg; PCB_SCREEN * screen; m_Parent = parent; - screen = m_Parent->GetScreen(); + screen = (PCB_SCREEN*)(m_Parent->GetScreen()); g_UserGrid = screen->m_UserGrid; g_UserGrid_Unit = screen->m_UserGridUnit; diff --git a/pcbnew/tool_pcb.cpp b/pcbnew/tool_pcb.cpp index 7c8cbfe093..8b31f95192 100644 --- a/pcbnew/tool_pcb.cpp +++ b/pcbnew/tool_pcb.cpp @@ -91,19 +91,19 @@ void WinEDA_PcbFrame::PrepareLayerIndicator() previous_Route_Layer_BOTTOM_color, previous_via_color; /* get colors, and redraw bitmap button only on changes */ - active_layer_color = g_DesignSettings.m_LayerColor[GetScreen()->m_Active_Layer]; + active_layer_color = g_DesignSettings.m_LayerColor[((PCB_SCREEN*)GetScreen())->m_Active_Layer]; if( previous_active_layer_color != active_layer_color ) { previous_active_layer_color = active_layer_color; change = TRUE; } - Route_Layer_TOP_color = g_DesignSettings.m_LayerColor[GetScreen()->m_Route_Layer_TOP]; + Route_Layer_TOP_color = g_DesignSettings.m_LayerColor[((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP]; if( previous_Route_Layer_TOP_color != Route_Layer_TOP_color ) { previous_Route_Layer_TOP_color = Route_Layer_TOP_color; change = TRUE; } - Route_Layer_BOTTOM_color = g_DesignSettings.m_LayerColor[GetScreen()->m_Route_Layer_BOTTOM]; + Route_Layer_BOTTOM_color = g_DesignSettings.m_LayerColor[((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM]; if( previous_Route_Layer_BOTTOM_color != Route_Layer_BOTTOM_color ) { previous_Route_Layer_BOTTOM_color = Route_Layer_BOTTOM_color; @@ -714,7 +714,7 @@ WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent ) ll = m_SelLayerBox->GetChoice(); for( ii = 0; ii < jj; ii++ ) { - if( (int) ( (size_t) m_SelLayerBox->GetClientData( ii ) ) == GetScreen()->m_Active_Layer ) + if( (int) ( (size_t) m_SelLayerBox->GetClientData( ii ) ) == ((PCB_SCREEN*)GetScreen())->m_Active_Layer ) { if( ii != ll ) m_SelLayerBox->SetSelection( ii ); diff --git a/pcbnew/tracepcb.cpp b/pcbnew/tracepcb.cpp index e1230718d9..4191471aa7 100644 --- a/pcbnew/tracepcb.cpp +++ b/pcbnew/tracepcb.cpp @@ -32,7 +32,7 @@ void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) { MODULE* Module; - PCB_SCREEN* screen = GetScreen(); + PCB_SCREEN* screen = (PCB_SCREEN*)GetScreen(); if( !m_Pcb || !screen ) return; @@ -72,7 +72,7 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) /* Draw the BOARD, and others elements : axis, grid .. */ { - PCB_SCREEN* Screen = GetScreen(); + PCB_SCREEN* Screen = (PCB_SCREEN*)GetScreen(); if( !m_Pcb || !Screen ) return; diff --git a/pcbnew/xchgmod.cpp b/pcbnew/xchgmod.cpp index ab3328861d..8ce9c421c5 100644 --- a/pcbnew/xchgmod.cpp +++ b/pcbnew/xchgmod.cpp @@ -515,7 +515,7 @@ MODULE* WinEDA_BasePcbFrame::Exchange_Module( wxWindow* winaff, /* * Remplace le module OldModule par le module NewModule (en conservant position, orientation..) - * OldModule est supprimé de la memoire. + * OldModule est supprim� de la memoire. */ { wxPoint oldpos;/* memorisation temporaire pos curseur */ @@ -553,6 +553,7 @@ MODULE* WinEDA_BasePcbFrame::Exchange_Module( wxWindow* winaff, /* Mise a jour des autres parametres */ NewModule->m_TimeStamp = OldModule->m_TimeStamp; + NewModule->m_Path = OldModule->m_Path; /* mise a jour des netnames ( lorsque c'est possible) */ pt_pad = NewModule->m_Pads; @@ -651,6 +652,7 @@ bool WinEDA_PcbFrame::RecreateCmpFileFromBoard() { fprintf( FichCmp, "\nBeginCmp\n" ); fprintf( FichCmp, "TimeStamp = %8.8lX\n", Module->m_TimeStamp ); + fprintf( FichCmp, "Path = %s\n", CONV_TO_UTF8(Module->m_Path) ); fprintf( FichCmp, "Reference = %s;\n", !Module->m_Reference->m_Text.IsEmpty() ? CONV_TO_UTF8( Module->m_Reference->m_Text ) : "[NoRef]" ); diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index e714580d61..e4f76667cc 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -510,12 +510,12 @@ int WinEDA_PcbFrame::Begin_Zone( wxDC* DC ) if( diag == ZONE_ABORT ) return 0; - - GetScreen()->m_Active_Layer = s_Zone_Layer; // Set by the dialog frame + + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = s_Zone_Layer; // Set by the dialog frame } else /* Start a new contour: init zone params (net and layer) from an existing zone */ { - GetScreen()->m_Active_Layer = s_Zone_Layer = s_CurrentZone->GetLayer(); + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = s_Zone_Layer = s_CurrentZone->GetLayer(); s_Zone_Hatching = s_CurrentZone->m_Poly->GetHatchStyle(); } diff --git a/share/drawframe.cpp b/share/drawframe.cpp index 0c010b985b..6c6cfbdde9 100644 --- a/share/drawframe.cpp +++ b/share/drawframe.cpp @@ -61,8 +61,8 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype, m_HTOOL_current_state = 0; m_Draw_Axis = FALSE; // TRUE pour avoir les axes dessines m_Draw_Grid = FALSE; // TRUE pour avoir la axes dessinee - m_Draw_Sheet_Ref = FALSE; // TRUE pour avoir le cartouche dessiné - m_Print_Sheet_Ref = TRUE; // TRUE pour avoir le cartouche imprimé + m_Draw_Sheet_Ref = FALSE; // TRUE pour avoir le cartouche dessin� + m_Print_Sheet_Ref = TRUE; // TRUE pour avoir le cartouche imprim� m_Draw_Auxiliary_Axis = FALSE; // TRUE pour avoir les axes auxiliares dessines m_UnitType = INTERNAL_UNIT_TYPE; // Internal unit = inch @@ -266,10 +266,10 @@ void WinEDA_DrawFrame::OnSelectGrid( wxCommandEvent& event ) if( id < 0 ) return; - m_CurrentScreen->m_Curseur = DrawPanel->GetScreenCenterRealPosition(); - wxSize grid = m_CurrentScreen->GetGrid(); - m_CurrentScreen->SetGrid( g_GridList[id] ); - wxSize newgrid = m_CurrentScreen->GetGrid(); + GetScreen()->m_Curseur = DrawPanel->GetScreenCenterRealPosition(); + wxSize grid = GetScreen()->GetGrid(); + GetScreen()->SetGrid( g_GridList[id] ); + wxSize newgrid = GetScreen()->GetGrid(); if( newgrid.x != grid.x || newgrid.y != grid.y ) Recadre_Trace( FALSE ); } @@ -326,10 +326,10 @@ void WinEDA_DrawFrame::OnSelectZoom( wxCommandEvent& event ) // fonction virtue int zoom = 1 << id; if( zoom > m_ZoomMaxValue ) zoom = m_ZoomMaxValue; - if( m_CurrentScreen->GetZoom() == zoom ) + if( GetScreen()->GetZoom() == zoom ) return; - m_CurrentScreen->m_Curseur = DrawPanel->GetScreenCenterRealPosition(); - m_CurrentScreen->SetZoom( zoom ); + GetScreen()->m_Curseur = DrawPanel->GetScreenCenterRealPosition(); + GetScreen()->SetZoom( zoom ); Recadre_Trace( FALSE ); } } @@ -339,7 +339,7 @@ int WinEDA_DrawFrame::GetZoom(void) /***********************************/ /* Return the current zoom level */ { - return m_CurrentScreen->GetZoom(); + return GetScreen()->GetZoom(); } @@ -581,18 +581,18 @@ void WinEDA_DrawFrame::OnZoom( int zoom_type ) /* Fonction de traitement du zoom * Modifie le facteur de zoom et reaffiche l'ecran * Pour les commandes par menu Popup ou par le clavier, le curseur est - * replacé au centre de l'ecran + * replac� au centre de l'ecran */ { - if( DrawPanel == NULL ) - return; + if( DrawPanel == NULL ) + return; bool move_mouse_cursor = FALSE; int x, y; wxPoint old_pos; DrawPanel->GetViewStart( &x, &y ); - old_pos = m_CurrentScreen->m_Curseur; + old_pos = GetScreen()->m_Curseur; switch( zoom_type ) { @@ -603,9 +603,9 @@ void WinEDA_DrawFrame::OnZoom( int zoom_type ) case ID_ZOOM_PLUS_BUTT: if( zoom_type == ID_ZOOM_PLUS_BUTT ) - m_CurrentScreen->m_Curseur = DrawPanel->GetScreenCenterRealPosition(); + GetScreen()->m_Curseur = DrawPanel->GetScreenCenterRealPosition(); - m_CurrentScreen->SetPreviousZoom(); + GetScreen()->SetPreviousZoom(); Recadre_Trace( move_mouse_cursor ); break; @@ -617,8 +617,8 @@ void WinEDA_DrawFrame::OnZoom( int zoom_type ) case ID_ZOOM_MOINS_BUTT: if( zoom_type == ID_ZOOM_MOINS_BUTT ) - m_CurrentScreen->m_Curseur = DrawPanel->GetScreenCenterRealPosition(); - m_CurrentScreen->SetNextZoom(); + GetScreen()->m_Curseur = DrawPanel->GetScreenCenterRealPosition(); + GetScreen()->SetNextZoom(); Recadre_Trace( move_mouse_cursor ); break; @@ -673,7 +673,7 @@ void WinEDA_DrawFrame::OnPanning( int direction ) /* Fonction de traitement du zoom * Modifie le facteur de zoom et reaffiche l'ecran * Pour les commandes par menu Popup ou par le clavier, le curseur est - * replacé au centre de l'ecran + * replac� au centre de l'ecran */ { if( DrawPanel == NULL ) @@ -759,15 +759,15 @@ void WinEDA_DrawFrame::AdjustScrollBars() wxSize draw_size, panel_size; wxSize scrollbar_number; wxPoint scrollbar_pos; - int zoom = m_CurrentScreen->GetZoom(); + int zoom = GetScreen()->GetZoom(); int xUnit, yUnit; - if( m_CurrentScreen == NULL ) + if( GetScreen() == NULL ) return; if( DrawPanel == NULL ) return; - draw_size = m_CurrentScreen->ReturnPageSize(); + draw_size = GetScreen()->ReturnPageSize(); // La zone d'affichage est reglee a une taille double de la feuille de travail: draw_size.x *= 2; draw_size.y *= 2; @@ -780,20 +780,20 @@ void WinEDA_DrawFrame::AdjustScrollBars() draw_size.y += panel_size.y / 2; - if( m_CurrentScreen->m_Center ) + if( GetScreen()->m_Center ) { - m_CurrentScreen->m_DrawOrg.x = -draw_size.x / 2; - m_CurrentScreen->m_DrawOrg.y = -draw_size.y / 2; + GetScreen()->m_DrawOrg.x = -draw_size.x / 2; + GetScreen()->m_DrawOrg.y = -draw_size.y / 2; } else { - m_CurrentScreen->m_DrawOrg.x = -panel_size.x / 2; - m_CurrentScreen->m_DrawOrg.y = -panel_size.y / 2; + GetScreen()->m_DrawOrg.x = -panel_size.x / 2; + GetScreen()->m_DrawOrg.y = -panel_size.y / 2; } // DrawOrg est rendu multiple du zoom min : - m_CurrentScreen->m_DrawOrg.x -= m_CurrentScreen->m_DrawOrg.x % 256; - m_CurrentScreen->m_DrawOrg.y -= m_CurrentScreen->m_DrawOrg.y % 256; + GetScreen()->m_DrawOrg.x -= GetScreen()->m_DrawOrg.x % 256; + GetScreen()->m_DrawOrg.y -= GetScreen()->m_DrawOrg.y % 256; // Calcul du nombre de scrolls (en unites de scrool ) scrollbar_number.x = draw_size.x / (DrawPanel->m_Scroll_unit * zoom); @@ -808,10 +808,10 @@ void WinEDA_DrawFrame::AdjustScrollBars() xUnit *= zoom; yUnit *= zoom; // Calcul de la position, curseur place au centre d'ecran - scrollbar_pos = m_CurrentScreen->m_Curseur; + scrollbar_pos = GetScreen()->m_Curseur; - scrollbar_pos.x -= m_CurrentScreen->m_DrawOrg.x; - scrollbar_pos.y -= m_CurrentScreen->m_DrawOrg.y; + scrollbar_pos.x -= GetScreen()->m_DrawOrg.x; + scrollbar_pos.y -= GetScreen()->m_DrawOrg.y; scrollbar_pos.x -= panel_size.x / 2; scrollbar_pos.y -= panel_size.y / 2; @@ -823,15 +823,15 @@ void WinEDA_DrawFrame::AdjustScrollBars() scrollbar_pos.x /= xUnit; scrollbar_pos.y /= yUnit; - m_CurrentScreen->m_ScrollbarPos = scrollbar_pos; - m_CurrentScreen->m_ScrollbarNumber = scrollbar_number; + GetScreen()->m_ScrollbarPos = scrollbar_pos; + GetScreen()->m_ScrollbarNumber = scrollbar_number; DrawPanel->SetScrollbars( DrawPanel->m_Scroll_unit, DrawPanel->m_Scroll_unit, - m_CurrentScreen->m_ScrollbarNumber.x, - m_CurrentScreen->m_ScrollbarNumber.y, - m_CurrentScreen->m_ScrollbarPos.x, - m_CurrentScreen->m_ScrollbarPos.y, TRUE ); + GetScreen()->m_ScrollbarNumber.x, + GetScreen()->m_ScrollbarNumber.y, + GetScreen()->m_ScrollbarPos.x, + GetScreen()->m_ScrollbarPos.y, TRUE ); } @@ -839,8 +839,8 @@ void WinEDA_DrawFrame::AdjustScrollBars() void WinEDA_DrawFrame::SetDrawBgColor( int color_num ) /****************************************************/ -/* met a jour la couleur de fond pour les tracés - * seules les couleurs BLACK ou WHITE sont autorisées +/* met a jour la couleur de fond pour les trac�s + * seules les couleurs BLACK ou WHITE sont autoris�es * le parametre XorMode est mis a jour selon la couleur du fond */ { diff --git a/share/drawpanel.cpp b/share/drawpanel.cpp index c7d579c3ad..721149155e 100644 --- a/share/drawpanel.cpp +++ b/share/drawpanel.cpp @@ -437,7 +437,7 @@ void WinEDA_DrawPanel::SetBoundaryBox() */ { BASE_SCREEN* Screen = GetScreen();; - + if(!Screen) return; wxPoint org; int ii, jj; @@ -795,6 +795,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) static WinEDA_DrawPanel* LastPanel; static bool IgnoreNextLeftButtonRelease = false; + if(!screen) return; #define MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND 5 /* Adjust value to filter mouse deplacement before * consider the drag mouse is really a drag command, not just a movement while click */ diff --git a/share/setpage.cpp b/share/setpage.cpp index fe3419d3f6..a1f3d769a4 100644 --- a/share/setpage.cpp +++ b/share/setpage.cpp @@ -116,7 +116,7 @@ WinEDA_SetPageFrame::WinEDA_SetPageFrame( WinEDA_DrawFrame* parent, wxWindowID i wxString msg; m_ParentDrawFrame = parent; - m_Screen = m_ParentDrawFrame->m_CurrentScreen; + m_Screen = m_ParentDrawFrame->GetScreen(); m_Modified = FALSE; m_SelectedSheet = NULL; m_CurrentSelection = 0; @@ -124,10 +124,10 @@ WinEDA_SetPageFrame::WinEDA_SetPageFrame( WinEDA_DrawFrame* parent, wxWindowID i Create(parent, id, caption, pos, size, style); // Init display value for sheet User size wxString format = m_TextSheetCount->GetLabel(); - msg.Printf(format, m_Screen->m_NumberOfSheet); + msg.Printf(format, m_Screen->m_NumberOfScreen); m_TextSheetCount->SetLabel(msg); format = m_TextSheetNumber->GetLabel(); - msg.Printf(format, m_Screen->m_SheetNumber); + msg.Printf(format, m_Screen->m_ScreenNumber); m_TextSheetNumber->SetLabel(msg); if( g_UnitMetric ) { @@ -560,7 +560,7 @@ void WinEDA_SetPageFrame::SavePageSettings(wxCommandEvent& event) ii = 0; m_SelectedSheet = SheetList[ii]; - m_Screen->m_CurrentSheet = m_SelectedSheet; + m_Screen->m_CurrentSheetDesc = m_SelectedSheet; if( g_UnitMetric ) { @@ -589,7 +589,7 @@ void WinEDA_SetPageFrame::SavePageSettings(wxCommandEvent& event) /* Exports settings to other sheets if requested: */ SCH_SCREEN * screen; /* Build the screen list */ - EDA_ScreenList ScreenList(NULL); + EDA_ScreenList ScreenList; /* Update the datas */ for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) { @@ -638,7 +638,7 @@ void WinEDA_SetPageFrame::SearchPageSizeSelection() for( ii = 0; ii < NB_ITEMS; ii++ ) { sheet = SheetList[ii]; - if( m_ParentDrawFrame->m_CurrentScreen->m_CurrentSheet == sheet ) + if( m_ParentDrawFrame->GetScreen()->m_CurrentSheetDesc == sheet ) m_CurrentSelection = ii; } } diff --git a/share/svg_print.cpp b/share/svg_print.cpp index 3c313da161..4aee060b8e 100644 --- a/share/svg_print.cpp +++ b/share/svg_print.cpp @@ -287,7 +287,7 @@ wxString WinEDA_PrintSVGFrame::ReturnFullFileName() { wxString name, ext; - name = m_Parent->m_CurrentScreen->m_FileName; + name = m_Parent->GetScreen()->m_FileName; ChangeFileNameExt(name, wxT(".svg")); return name; } @@ -330,11 +330,12 @@ wxString msg; SetPenWidth(); -BASE_SCREEN * screen = m_Parent->m_CurrentScreen; +BASE_SCREEN * screen = m_Parent->GetScreen(); BASE_SCREEN *oldscreen = screen; - +#ifndef EESCHEMA if( Select_PrintAll ) while ( screen->Pback ) screen = (BASE_SCREEN *) screen->Pback; +#endif if ( (m_Parent->m_Ident == PCB_FRAME) || (m_Parent->m_Ident == GERBER_FRAME) ) { @@ -350,16 +351,15 @@ BASE_SCREEN *oldscreen = screen; #ifdef EESCHEMA if ( Select_PrintAll && m_Parent->m_Ident == SCHEMATIC_FRAME ) { - EDA_ScreenList ScreenList(NULL); - + EDA_ScreenList ScreenList; for ( SCH_SCREEN * schscreen = ScreenList.GetFirst(); schscreen != NULL; schscreen = ScreenList.GetNext() ) { /* Create all files *.svg */ - m_Parent->m_CurrentScreen = (BASE_SCREEN *)schscreen; - ActiveScreen = screen; - wxString FullFileName = ReturnFullFileName(); - bool success = DrawPage(FullFileName); + ((WinEDA_SchematicFrame*)m_Parent)->SetScreen(schscreen); + wxString FullFileName = schscreen->m_FileName; + ChangeFileNameExt(FullFileName, wxT(".svg")); + bool success = DrawPage(FullFileName, schscreen); msg = _("Create file ") + FullFileName; if ( ! success ) msg += _(" error"); msg += wxT("\n"); @@ -369,11 +369,12 @@ BASE_SCREEN *oldscreen = screen; else #endif { - ActiveScreen = screen; - wxString FullFileName = m_FileNameCtrl->GetValue(); - if ( FullFileName.IsEmpty() ) - FullFileName = ReturnFullFileName(); - bool success = DrawPage(FullFileName); + wxString FullFileName = m_FileNameCtrl->GetValue(); + if ( FullFileName.IsEmpty() ){ + FullFileName = screen->m_FileName; + ChangeFileNameExt(FullFileName, wxT(".svg")); + } + bool success = DrawPage(FullFileName, screen); msg = _("Create file ") + FullFileName; if ( ! success ) msg += _(" error"); msg += wxT("\n"); @@ -383,7 +384,7 @@ BASE_SCREEN *oldscreen = screen; } /*****************************************************************/ -bool WinEDA_PrintSVGFrame::DrawPage(const wxString & FullFileName) +bool WinEDA_PrintSVGFrame::DrawPage(const wxString & FullFileName, BASE_SCREEN* screen) /*****************************************************************/ /* Routine effective d'impression @@ -397,16 +398,16 @@ float dpi; bool success = TRUE; /* modification des cadrages et reglages locaux */ - tmp_startvisu = ActiveScreen->m_StartVisu; - tmpzoom = ActiveScreen->GetZoom(); - old_org = ActiveScreen->m_DrawOrg; - ActiveScreen->m_DrawOrg.x = ActiveScreen->m_DrawOrg.y = 0; - ActiveScreen->m_StartVisu.x = ActiveScreen->m_StartVisu.y = 0; - SheetSize = ActiveScreen->m_CurrentSheet->m_Size; // size in 1/1000 inch + tmp_startvisu = screen->m_StartVisu; + tmpzoom = screen->GetZoom(); + old_org = screen->m_DrawOrg; + screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0; + screen->m_StartVisu.x = screen->m_StartVisu.y = 0; + SheetSize = screen->m_CurrentSheetDesc->m_Size; // size in 1/1000 inch SheetSize.x *= m_Parent->m_InternalUnits / 1000; SheetSize.y *= m_Parent->m_InternalUnits / 1000; // size in pixels - ActiveScreen->SetZoom(1); + screen->SetZoom(1); dpi = (float)SheetSize.x * 25.4 /m_ImageXSize_mm; WinEDA_DrawPanel * panel = m_Parent->DrawPanel; @@ -443,9 +444,9 @@ wxSVGFileDC dc(FullFileName, SheetSize.x, SheetSize.y, dpi) ; GRForceBlackPen(FALSE); SetPenMinWidth(1); - ActiveScreen->m_StartVisu = tmp_startvisu; - ActiveScreen->m_DrawOrg = old_org; - ActiveScreen->SetZoom(tmpzoom); + screen->m_StartVisu = tmp_startvisu; + screen->m_DrawOrg = old_org; + screen->SetZoom(tmpzoom); return success; } diff --git a/share/svg_print.h b/share/svg_print.h index 04089a018f..35b404a6e9 100644 --- a/share/svg_print.h +++ b/share/svg_print.h @@ -115,7 +115,7 @@ public: static bool ShowToolTips(); void PrintSVGDoc(wxCommandEvent& event); - bool DrawPage(const wxString & FullFileName); + bool DrawPage(const wxString & FullFileName, BASE_SCREEN* screen); wxString ReturnFullFileName(); ////@begin WinEDA_PrintSVGFrame member variables diff --git a/share/worksheet.cpp b/share/worksheet.cpp index bae7ff469b..16fcc82a50 100644 --- a/share/worksheet.cpp +++ b/share/worksheet.cpp @@ -29,7 +29,7 @@ void WinEDA_DrawFrame::TraceWorkSheet(wxDC * DC, BASE_SCREEN * screen) { if ( ! m_Draw_Sheet_Ref ) return; -Ki_PageDescr * Sheet = screen->m_CurrentSheet; +Ki_PageDescr * Sheet = screen->m_CurrentSheetDesc; int ii, jj, xg , yg, ipas, gxpas, gypas; wxPoint pos; int refx, refy,Color; @@ -185,8 +185,7 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION; case WS_IDENTSHEET: if(WsItem->m_Legende) msg = WsItem->m_Legende; - msg << screen->m_SheetNumber << wxT("/") << - screen->m_NumberOfSheet; + msg = GetScreenDesc(); DrawGraphicText(DrawPanel, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); @@ -278,4 +277,4 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION; } } -} +} \ No newline at end of file diff --git a/share/wxprint.cpp b/share/wxprint.cpp index c38332245b..0d742a83e4 100644 --- a/share/wxprint.cpp +++ b/share/wxprint.cpp @@ -121,7 +121,7 @@ public: /*******************************************************/ void WinEDA_DrawFrame::ToPrinter(wxCommandEvent& event) /*******************************************************/ -/* Prepare les structures de données de gestion de l'impression +/* Prepare les structures de donn�es de gestion de l'impression et affiche la fenetre de dialogue de gestion de l'impression des feuilles */ { @@ -283,7 +283,7 @@ wxString WinEDA_PrintFrame::BuildPrintTitle() { wxString name, ext; - wxFileName::SplitPath(m_Parent->m_CurrentScreen->m_FileName, + wxFileName::SplitPath(m_Parent->GetScreen()->m_FileName, (wxString*) NULL, & name, & ext); name += wxT("-") + ext; return name; @@ -452,12 +452,12 @@ wxString msg; #ifdef EESCHEMA -BASE_SCREEN * screen = m_Parent->m_CurrentScreen; +BASE_SCREEN * screen = m_Parent->GetScreen(); BASE_SCREEN *oldscreen = screen; if( s_OptionPrintPage == 1 ) { - EDA_ScreenList ScreenList(NULL); + EDA_ScreenList ScreenList; screen = ScreenList.GetScreen(page -1); } @@ -507,7 +507,7 @@ int ii = 1; #ifdef EESCHEMA if( s_OptionPrintPage == 1 ) { - EDA_ScreenList ScreenList(NULL); + EDA_ScreenList ScreenList; ii = ScreenList.GetCount(); } #endif @@ -536,7 +536,7 @@ bool EDA_Printout::HasPage(int pageNum) #ifdef EESCHEMA int PageCount; - EDA_ScreenList ScreenList(NULL); + EDA_ScreenList ScreenList; PageCount = ScreenList.GetCount(); if( PageCount >= pageNum ) return TRUE; @@ -592,7 +592,7 @@ wxDC * dc = GetDC(); ActiveScreen->m_DrawOrg.x = ActiveScreen->m_DrawOrg.y = 0; ActiveScreen->m_StartVisu.x = ActiveScreen->m_StartVisu.y = 0; - SheetSize = ActiveScreen->m_CurrentSheet->m_Size; // size in 1/1000 inch + SheetSize = ActiveScreen->m_CurrentSheetDesc->m_Size; // size in 1/1000 inch SheetSize.x *= m_Parent->m_InternalUnits / 1000; SheetSize.y *= m_Parent->m_InternalUnits / 1000; // size in pixels diff --git a/share/zoom.cpp b/share/zoom.cpp index e672cca4f9..93c3b2042d 100644 --- a/share/zoom.cpp +++ b/share/zoom.cpp @@ -46,7 +46,7 @@ void WinEDA_DrawFrame::Recadre_Trace( bool ToMouse ) * Note: Mac OS ** does not ** allow moving mouse cursor by program. */ { - PutOnGrid( &m_CurrentScreen->m_Curseur ); + PutOnGrid( &(GetScreen()->m_Curseur) ); AdjustScrollBars(); @@ -69,9 +69,9 @@ void WinEDA_DrawFrame::PutOnGrid( wxPoint* coord ) { double ftmp; - if( !m_CurrentScreen->m_UserGridIsON ) + if( !GetScreen()->m_UserGridIsON ) { - wxSize grid_size = m_CurrentScreen->GetGrid(); + wxSize grid_size = GetScreen()->GetGrid(); ftmp = (double) coord->x / grid_size.x; coord->x = ( (int) round( ftmp ) ) * grid_size.x; @@ -81,10 +81,10 @@ void WinEDA_DrawFrame::PutOnGrid( wxPoint* coord ) } else { - double pasx = m_CurrentScreen->m_UserGrid.x * m_InternalUnits; - double pasy = m_CurrentScreen->m_UserGrid.y * m_InternalUnits; + double pasx = GetScreen()->m_UserGrid.x * m_InternalUnits; + double pasy = GetScreen()->m_UserGrid.y * m_InternalUnits; - if( m_CurrentScreen->m_UserGridUnit != INCHES ) + if( GetScreen()->m_UserGridUnit != INCHES ) { pasx /= 25.4; pasy /= 25.4; @@ -109,7 +109,7 @@ void WinEDA_DrawFrame::Zoom_Automatique( bool move_mouse_cursor ) int bestzoom; bestzoom = BestZoom(); - m_CurrentScreen->SetZoom( bestzoom ); + GetScreen()->SetZoom( bestzoom ); Recadre_Trace( move_mouse_cursor ); } @@ -136,9 +136,9 @@ void WinEDA_DrawFrame::Window_Zoom( EDA_Rect& Rect ) if( bestzoom <= 0 ) bestzoom = 1; - m_CurrentScreen->SetZoom( bestzoom ); + GetScreen()->SetZoom( bestzoom ); - m_CurrentScreen->m_Curseur = Rect.Centre(); + GetScreen()->m_Curseur = Rect.Centre(); Recadre_Trace( TRUE ); } @@ -170,127 +170,127 @@ void WinEDA_DrawPanel::Process_Popup_Zoom( wxCommandEvent& event ) break; case ID_POPUP_ZOOM_LEVEL_1: - m_Parent->m_CurrentScreen->SetZoom( 1 ); + m_Parent->GetScreen()->SetZoom( 1 ); m_Parent->Recadre_Trace( TRUE ); break; case ID_POPUP_ZOOM_LEVEL_2: - m_Parent->m_CurrentScreen->SetZoom( 2 ); + m_Parent->GetScreen()->SetZoom( 2 ); m_Parent->Recadre_Trace( TRUE ); break; case ID_POPUP_ZOOM_LEVEL_4: - m_Parent->m_CurrentScreen->SetZoom( 4 ); + m_Parent->GetScreen()->SetZoom( 4 ); m_Parent->Recadre_Trace( TRUE ); break; case ID_POPUP_ZOOM_LEVEL_8: - m_Parent->m_CurrentScreen->SetZoom( 8 ); + m_Parent->GetScreen()->SetZoom( 8 ); m_Parent->Recadre_Trace( TRUE ); break; case ID_POPUP_ZOOM_LEVEL_16: - m_Parent->m_CurrentScreen->SetZoom( 16 ); + m_Parent->GetScreen()->SetZoom( 16 ); m_Parent->Recadre_Trace( TRUE ); break; case ID_POPUP_ZOOM_LEVEL_32: - m_Parent->m_CurrentScreen->SetZoom( 32 ); + m_Parent->GetScreen()->SetZoom( 32 ); m_Parent->Recadre_Trace( TRUE ); break; case ID_POPUP_ZOOM_LEVEL_64: - m_Parent->m_CurrentScreen->SetZoom( 64 ); + m_Parent->GetScreen()->SetZoom( 64 ); m_Parent->Recadre_Trace( TRUE ); break; case ID_POPUP_ZOOM_LEVEL_128: - m_Parent->m_CurrentScreen->SetZoom( 128 ); + m_Parent->GetScreen()->SetZoom( 128 ); m_Parent->Recadre_Trace( TRUE ); break; case ID_POPUP_ZOOM_LEVEL_256: - m_Parent->m_CurrentScreen->SetZoom( 256 ); + m_Parent->GetScreen()->SetZoom( 256 ); m_Parent->Recadre_Trace( TRUE ); break; case ID_POPUP_ZOOM_LEVEL_512: - m_Parent->m_CurrentScreen->SetZoom( 512 ); + m_Parent->GetScreen()->SetZoom( 512 ); m_Parent->Recadre_Trace( TRUE ); break; case ID_POPUP_ZOOM_LEVEL_1024: - m_Parent->m_CurrentScreen->SetZoom( 1024 ); + m_Parent->GetScreen()->SetZoom( 1024 ); m_Parent->Recadre_Trace( TRUE ); break; case ID_POPUP_ZOOM_LEVEL_2048: - m_Parent->m_CurrentScreen->SetZoom( 2048 ); + m_Parent->GetScreen()->SetZoom( 2048 ); m_Parent->Recadre_Trace( TRUE ); break; case ID_POPUP_GRID_LEVEL_1: - m_Parent->m_CurrentScreen->SetGrid( wxSize( 1, 1 ) ); + m_Parent->GetScreen()->SetGrid( wxSize( 1, 1 ) ); m_Parent->ReDrawPanel(); break; case ID_POPUP_GRID_LEVEL_2: - m_Parent->m_CurrentScreen->SetGrid( wxSize( 2, 2 ) ); + m_Parent->GetScreen()->SetGrid( wxSize( 2, 2 ) ); m_Parent->ReDrawPanel(); break; case ID_POPUP_GRID_LEVEL_5: - m_Parent->m_CurrentScreen->SetGrid( wxSize( 5, 5 ) ); + m_Parent->GetScreen()->SetGrid( wxSize( 5, 5 ) ); m_Parent->ReDrawPanel(); break; case ID_POPUP_GRID_LEVEL_10: - m_Parent->m_CurrentScreen->SetGrid( wxSize( 10, 10 ) ); + m_Parent->GetScreen()->SetGrid( wxSize( 10, 10 ) ); m_Parent->ReDrawPanel(); break; case ID_POPUP_GRID_LEVEL_20: - m_Parent->m_CurrentScreen->SetGrid( wxSize( 20, 20 ) ); + m_Parent->GetScreen()->SetGrid( wxSize( 20, 20 ) ); m_Parent->ReDrawPanel(); break; case ID_POPUP_GRID_LEVEL_25: - m_Parent->m_CurrentScreen->SetGrid( wxSize( 25, 25 ) ); + m_Parent->GetScreen()->SetGrid( wxSize( 25, 25 ) ); m_Parent->ReDrawPanel(); break; case ID_POPUP_GRID_LEVEL_50: - m_Parent->m_CurrentScreen->SetGrid( wxSize( 50, 50 ) ); + m_Parent->GetScreen()->SetGrid( wxSize( 50, 50 ) ); m_Parent->ReDrawPanel(); break; case ID_POPUP_GRID_LEVEL_100: - m_Parent->m_CurrentScreen->SetGrid( wxSize( 100, 100 ) ); + m_Parent->GetScreen()->SetGrid( wxSize( 100, 100 ) ); m_Parent->ReDrawPanel(); break; case ID_POPUP_GRID_LEVEL_200: - m_Parent->m_CurrentScreen->SetGrid( wxSize( 200, 200 ) ); + m_Parent->GetScreen()->SetGrid( wxSize( 200, 200 ) ); m_Parent->ReDrawPanel(); break; case ID_POPUP_GRID_LEVEL_250: - m_Parent->m_CurrentScreen->SetGrid( wxSize( 250, 250 ) ); + m_Parent->GetScreen()->SetGrid( wxSize( 250, 250 ) ); m_Parent->ReDrawPanel(); break; case ID_POPUP_GRID_LEVEL_500: - m_Parent->m_CurrentScreen->SetGrid( wxSize( 500, 500 ) ); + m_Parent->GetScreen()->SetGrid( wxSize( 500, 500 ) ); m_Parent->ReDrawPanel(); break; case ID_POPUP_GRID_LEVEL_1000: - m_Parent->m_CurrentScreen->SetGrid( wxSize( 1000, 1000 ) ); + m_Parent->GetScreen()->SetGrid( wxSize( 1000, 1000 ) ); m_Parent->ReDrawPanel(); break; case ID_POPUP_GRID_USER: - m_Parent->m_CurrentScreen->SetGrid( wxSize( -1, -1 ) ); + m_Parent->GetScreen()->SetGrid( wxSize( -1, -1 ) ); m_Parent->ReDrawPanel(); break; @@ -368,7 +368,7 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu ) ADD_MENUITEM( MasterMenu, ID_POPUP_ZOOM_REDRAW, _( "Redraw" ), repaint_xpm ); /* Create the basic zoom list: */ - zoom = m_Parent->m_CurrentScreen->GetZoom(); + zoom = m_Parent->GetScreen()->GetZoom(); zoom_value = 1; for( ii = 0; zoom_value <= m_Parent->m_ZoomMaxValue; zoom_value <<= 1, ii++ ) // Create zoom choice 1 .. zoom max { @@ -383,7 +383,7 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu ) ADD_MENUITEM_WITH_SUBMENU( MasterMenu, grid_choice, ID_POPUP_GRID_SELECT, _( "Grid Select" ), grid_select_xpm ); - grid = m_Parent->m_CurrentScreen->GetGrid(); + grid = m_Parent->GetScreen()->GetGrid(); // Create grid list switch( m_Parent->m_Ident ) @@ -408,7 +408,7 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu ) grid_choice->Append( grid_list_pcb[ii].m_Id, msg, wxEmptyString, TRUE ); if( grid_list_pcb[ii].m_Value <= 0 ) { - if( m_Parent->m_CurrentScreen->m_UserGridIsON ) + if( m_Parent->GetScreen()->m_UserGridIsON ) grid_choice->Check( grid_list_pcb[ii].m_Id, TRUE ); break; }