From 49eb11e135913f79018f8c50ed2fbf7037d88515 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 30 Dec 2011 20:04:40 +0100 Subject: [PATCH] Eeschema: Fix issue in Search/ReplaceAll Pcbnew: fix a very minor issue. --- eeschema/class_libentry.cpp | 7 +- eeschema/dialogs/dialog_sch_find.fbp | 663 +++++++++++++++++- .../dialogs/dialog_schematic_find_base.cpp | 5 +- eeschema/dialogs/dialog_schematic_find_base.h | 13 +- eeschema/find.cpp | 6 +- pcbnew/files.cpp | 1 - pcbnew/initpcb.cpp | 8 + 7 files changed, 686 insertions(+), 17 deletions(-) diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index b06350f400..2e2c0c3642 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -756,7 +756,7 @@ bool LIB_COMPONENT::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) if( ( p = strtok( NULL, " \t\n" ) ) != NULL && *p == 'P' ) m_options = ENTRY_POWER; - /* Read next lines */ + // Read next lines, until "ENDDEF" is found while( aLineReader.ReadLine() ) { line = aLineReader.Line(); @@ -766,11 +766,14 @@ bool LIB_COMPONENT::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) /* This is the error flag ( if an error occurs, Res = FALSE) */ Res = true; + if( *line == '#' ) // a comment + continue; + if( (*line == 'T') && (*(line + 1) == 'i') ) Res = LoadDateAndTime( aLineReader ); else if( *line == 'F' ) Res = LoadField( aLineReader, Msg ); - else if( strcmp( p, "ENDDEF" ) == 0 ) + else if( strcmp( p, "ENDDEF" ) == 0 ) // End of component description break; else if( strcmp( p, "DRAW" ) == 0 ) Res = LoadDrawEntries( aLineReader, Msg ); diff --git a/eeschema/dialogs/dialog_sch_find.fbp b/eeschema/dialogs/dialog_sch_find.fbp index ed18566f2a..a12f77090f 100644 --- a/eeschema/dialogs/dialog_sch_find.fbp +++ b/eeschema/dialogs/dialog_sch_find.fbp @@ -7,6 +7,7 @@ 1 source_name 0 + res UTF-8 connect dialog_schematic_find_base @@ -22,25 +23,57 @@ 0 0 + 1 + 1 + 1 + 1 + 0 + + + + 1 wxBOTH + 0 + 1 1 + 0 + Dock + 0 + Left 1 impl_virtual + 1 + 0 0 wxID_ANY + + + 0 + + 0 + 1 DIALOG_SCH_FIND_BASE + 1 + + + 1 - + + Resizable + + 1 + 334,225 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER Find + 0 wxFILTER_NONE @@ -51,6 +84,12 @@ + + + + + + OnClose @@ -114,23 +153,54 @@ wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT 0 + 1 + 1 + 1 + 1 + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY &Search for: + + + 0 + + 0 + 1 m_staticText1 + 1 + + protected + 1 + + Resizable + + 1 + 0 wxFILTER_NONE @@ -170,23 +240,54 @@ wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxRIGHT 0 + 1 + 1 + 1 + 1 + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY + + + 0 + + 0 125,-1 + 1 m_comboFind + 1 + + protected + 1 + + Resizable + + 1 wxCB_DROPDOWN + 0 wxFILTER_NONE @@ -229,23 +330,54 @@ wxALIGN_CENTER_VERTICAL|wxALL 0 + 1 + 1 + 1 + 1 + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 1 wxID_ANY Replace &with: + + + 0 + + 0 + 1 m_staticReplace + 1 + + protected + 1 + + Resizable + + 1 + 0 wxFILTER_NONE @@ -285,23 +417,54 @@ wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND 0 + 1 + 1 + 1 + 1 + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 1 wxID_ANY + + + 0 + + 0 + 1 m_comboReplace + 1 + + protected + 1 + + Resizable + + 1 + 0 wxFILTER_NONE @@ -344,23 +507,54 @@ 0 + 1 + 1 + 1 + 1 + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 1 wxID_ANY Direction: + + + 0 + + 0 + 1 m_staticDirection + 1 + + protected + 1 + + Resizable + + 1 + 0 wxFILTER_NONE @@ -409,23 +603,54 @@ wxALL 0 + 1 + 1 + 1 + 1 + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 1 wxID_ANY F&orward + + + 0 + + 0 + 1 m_radioForward + 1 + + protected + 1 + + Resizable + + 1 wxRB_GROUP + 0 wxFILTER_NONE @@ -466,23 +691,54 @@ wxALL 0 + 1 + 1 + 1 + 1 + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 1 wxID_ANY &Backward + + + 0 + + 0 + 1 m_radioBackward + 1 + + protected + 1 + + Resizable + + 1 + 0 wxFILTER_NONE @@ -527,24 +783,55 @@ wxALL 0 + 1 + 1 + 1 + 1 + + + + 1 + 0 1 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY Match whole wor&d + + + 0 + + 0 + 1 m_checkWholeWord + 1 + + protected + 1 + + Resizable + + 1 + 0 wxFILTER_NONE @@ -584,24 +871,55 @@ wxBOTTOM|wxLEFT|wxRIGHT 0 + 1 + 1 + 1 + 1 + + + + 1 + 0 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY &Match case + + + 0 + + 0 + 1 m_checkMatchCase + 1 + + protected + 1 + + Resizable + + 1 + 0 wxFILTER_NONE @@ -641,24 +959,55 @@ wxBOTTOM|wxLEFT|wxRIGHT 0 + 1 + 1 + 1 + 1 + + + + 1 + 0 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY Search &using simple wildcard matching + + + 0 + + 0 + 1 m_checkWildcardMatch + 1 + + protected + 1 + + Resizable + + 1 + 0 wxFILTER_NONE @@ -698,24 +1047,55 @@ wxBOTTOM|wxLEFT|wxRIGHT 0 + 1 + 1 + 1 + 1 + + + + 1 + 0 1 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY Wrap around &end of search list + + + 0 + + 0 + 1 m_checkWrap + 1 + + protected + 1 + + Resizable + + 1 + 0 wxFILTER_NONE @@ -755,24 +1135,55 @@ wxBOTTOM|wxLEFT|wxRIGHT 0 + 1 + 1 + 1 + 1 + + + + 1 + 0 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY Search all com&ponent fields + + + 0 + + 0 + 1 m_checkAllFields + 1 + + protected + 1 + + Resizable + + 1 + 0 wxFILTER_NONE @@ -812,24 +1223,55 @@ wxBOTTOM|wxRIGHT|wxLEFT 0 + 1 + 1 + 1 + 1 + + + + 1 + 0 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY Search all pin &names and numbers + + + 0 + + 0 + 1 m_checkAllPins + 1 + + protected + 1 + + Resizable + + 1 + 0 wxFILTER_NONE @@ -869,24 +1311,55 @@ wxBOTTOM|wxLEFT|wxRIGHT 0 + 1 + 1 + 1 + 1 + + + + 1 + 0 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY Search the current &sheet onl&y + + + 0 + + 0 + 1 m_checkCurrentSheetOnly + 1 + + protected + 1 + + Resizable + + 1 + 0 wxFILTER_NONE @@ -926,24 +1399,55 @@ wxBOTTOM|wxLEFT|wxRIGHT 0 + 1 + 1 + 1 + 1 + + + + 1 + 0 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 1 wxID_ANY Replace componen&t reference designators + + + 0 + + 0 + 1 m_checkReplaceReferences + 1 + + protected + 1 + + Resizable + + 1 + 0 wxFILTER_NONE @@ -983,24 +1487,55 @@ wxBOTTOM|wxLEFT|wxRIGHT 0 + 1 + 1 + 1 + 1 + + + + 1 + 0 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY D&o not warp cursor to found item + + + 0 + + 0 + 1 m_checkNoWarpCursor + 1 + + protected + 1 + + Resizable + + 1 + 0 wxFILTER_NONE @@ -1051,24 +1586,55 @@ wxALL|wxEXPAND 0 + 1 + 1 + 1 + 1 + + + + 1 + 0 + 1 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_FIND &Find + + + 0 + + 0 + 1 m_buttonFind + 1 + + protected + 1 + + Resizable + + 1 + 0 wxFILTER_NONE @@ -1108,24 +1674,55 @@ wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT 0 + 1 + 1 + 1 + 1 + + + + 1 + 0 + 1 1 0 + 0 + Dock + 0 + Left 1 + 1 + 0 1 wxID_REPLACE &Replace + + + 0 + + 0 + 1 m_buttonReplace + 1 + + protected + 1 + + Resizable + + 1 + 0 wxFILTER_NONE @@ -1165,24 +1762,55 @@ wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT 0 + 1 + 1 + 1 + 1 + + + + 1 + 0 + 1 1 0 + 0 + Dock + 0 + Left 1 + 1 + 0 1 wxID_REPLACE_ALL Replace &All + + + 0 + + 0 + 1 m_buttonReplaceAll + 1 + + protected + 1 + + Resizable + + 1 + 0 wxFILTER_NONE @@ -1222,24 +1850,55 @@ wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND 0 + 1 + 1 + 1 + 1 + + + + 1 + 0 + 1 1 0 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_CANCEL - Cancel + Close + + + 0 + + 0 + 1 m_buttonCancel + 1 + + protected + 1 + + Resizable + + 1 + 0 wxFILTER_NONE diff --git a/eeschema/dialogs/dialog_schematic_find_base.cpp b/eeschema/dialogs/dialog_schematic_find_base.cpp index c77391edff..d4eb862ef7 100644 --- a/eeschema/dialogs/dialog_schematic_find_base.cpp +++ b/eeschema/dialogs/dialog_schematic_find_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Sep 8 2010) +// C++ code generated with wxFormBuilder (version Jun 30 2011) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -117,14 +117,13 @@ DIALOG_SCH_FIND_BASE::DIALOG_SCH_FIND_BASE( wxWindow* parent, wxWindowID id, con rightSizer->Add( m_buttonReplaceAll, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 6 ); - m_buttonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonCancel = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); rightSizer->Add( m_buttonCancel, 0, wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND, 6 ); mainSizer->Add( rightSizer, 0, wxALL|wxEXPAND, 6 ); this->SetSizer( mainSizer ); this->Layout(); - mainSizer->Fit( this ); this->Centre( wxBOTH ); diff --git a/eeschema/dialogs/dialog_schematic_find_base.h b/eeschema/dialogs/dialog_schematic_find_base.h index b8b0c411a3..dfb6a36bab 100644 --- a/eeschema/dialogs/dialog_schematic_find_base.h +++ b/eeschema/dialogs/dialog_schematic_find_base.h @@ -1,15 +1,16 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Sep 8 2010) +// C++ code generated with wxFormBuilder (version Jun 30 2011) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __dialog_schematic_find_base__ -#define __dialog_schematic_find_base__ +#ifndef __DIALOG_SCHEMATIC_FIND_BASE_H__ +#define __DIALOG_SCHEMATIC_FIND_BASE_H__ +#include +#include #include - #include #include #include @@ -69,9 +70,9 @@ class DIALOG_SCH_FIND_BASE : public wxDialog public: - DIALOG_SCH_FIND_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Find"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_SCH_FIND_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Find"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 334,225 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_SCH_FIND_BASE(); }; -#endif //__dialog_schematic_find_base__ +#endif //__DIALOG_SCHEMATIC_FIND_BASE_H__ diff --git a/eeschema/find.cpp b/eeschema/find.cpp index 756bed516c..3e305ee392 100644 --- a/eeschema/find.cpp +++ b/eeschema/find.cpp @@ -403,6 +403,7 @@ void SCH_EDIT_FRAME::OnFindReplace( wxFindDialogEvent& aEvent ) if( m_foundItems.ReplaceItem() ) { + OnModify(); SaveUndoItemInUndoList( undoItem ); RedrawScreen( data.GetPosition(), warpCursor ); } @@ -411,9 +412,7 @@ void SCH_EDIT_FRAME::OnFindReplace( wxFindDialogEvent& aEvent ) if( aEvent.GetEventType() == wxEVT_COMMAND_FIND_REPLACE_ALL ) { - item = (SCH_ITEM*) m_foundItems.GetItem( data ); - - while( item != NULL ) + while( ( item = (SCH_ITEM*) m_foundItems.GetItem( data ) ) != NULL ) { wxLogTrace( traceFindReplace, wxT( "Replacing %s with %s in item %s" ), GetChars( aEvent.GetFindString() ), GetChars( aEvent.GetReplaceString() ), @@ -429,6 +428,7 @@ void SCH_EDIT_FRAME::OnFindReplace( wxFindDialogEvent& aEvent ) if( m_foundItems.ReplaceItem() ) { + OnModify(); SaveUndoItemInUndoList( undoItem ); RedrawScreen( data.GetPosition(), warpCursor ); } diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 71764e7ac3..443acc836d 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -300,7 +300,6 @@ this file again." ) ); } catch( IO_ERROR ioe ) { - wxMessageBox( _( "catch" ) ); wxString msg = wxString::Format( _( "Error loading board.\n%s" ), ioe.errorText.GetData() ); wxMessageBox( msg, _( "Open Board File" ), wxOK | wxICON_ERROR ); diff --git a/pcbnew/initpcb.cpp b/pcbnew/initpcb.cpp index 5f52b08059..29b4fab5dd 100644 --- a/pcbnew/initpcb.cpp +++ b/pcbnew/initpcb.cpp @@ -37,9 +37,17 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery ) // Clear undo and redo lists because we want a full deletion GetScreen()->ClearUndoRedoList(); + /* Items visibility flags will be set becuse a new board will be created. + * Grid and ratsnest can be left to their previous state + */ + bool showGrid = IsElementVisible( GRID_VISIBLE ); + bool showRats = IsElementVisible( RATSNEST_VISIBLE ); // delete the old BOARD and create a new BOARD so that the default // layer names are put into the BOARD. SetBoard( new BOARD() ); + SetElementVisibility( GRID_VISIBLE, showGrid ); + SetElementVisibility( RATSNEST_VISIBLE, showRats ); + SetCurItem( NULL ); /* clear filename, to avoid overwriting an old file */