diff --git a/3d-viewer/3d_frame.cpp b/3d-viewer/3d_frame.cpp index 9410acc940..b8992865fa 100644 --- a/3d-viewer/3d_frame.cpp +++ b/3d-viewer/3d_frame.cpp @@ -116,7 +116,7 @@ END_EVENT_TABLE() EDA_3D_FRAME::EDA_3D_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent, const wxString& aTitle, long style ) : KIWAY_PLAYER( aKiway, aParent, FRAME_PCB_DISPLAY3D, aTitle, - wxDefaultPosition, wxDefaultSize, style, wxT( "Frame3D" ) ) + wxDefaultPosition, wxDefaultSize, style, VIEWER3D_FRAMENAME ) { m_canvas = NULL; m_reloadRequest = false; @@ -235,9 +235,6 @@ void EDA_3D_FRAME::Exit3DFrame( wxCommandEvent& event ) void EDA_3D_FRAME::OnCloseWindow( wxCloseEvent& Event ) { - if( Parent() ) - Parent()->m_Draw3DFrame = NULL; - Destroy(); } diff --git a/3d-viewer/3d_viewer.h b/3d-viewer/3d_viewer.h index 25c32d6a26..3412288d35 100644 --- a/3d-viewer/3d_viewer.h +++ b/3d-viewer/3d_viewer.h @@ -54,6 +54,8 @@ class wxColourData; #define KICAD_DEFAULT_3D_DRAWFRAME_STYLE (wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS) +#define VIEWER3D_FRAMENAME wxT( "Viewer3DFrameName" ) + class EDA_3D_FRAME : public KIWAY_PLAYER { diff --git a/common/dialogs/dialog_get_component_base.cpp b/common/dialogs/dialog_get_component_base.cpp index 8e8810c5d0..527278736f 100644 --- a/common/dialogs/dialog_get_component_base.cpp +++ b/common/dialogs/dialog_get_component_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 5 2013) +// C++ code generated with wxFormBuilder (version Jun 17 2015) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -14,7 +14,10 @@ DIALOG_GET_COMPONENT_BASE::DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindow this->SetSizeHints( wxDefaultSize, wxDefaultSize ); wxBoxSizer* bSizerMain; - bSizerMain = new wxBoxSizer( wxHORIZONTAL ); + bSizerMain = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bSizerUpper; + bSizerUpper = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer* bSizerLeft; bSizerLeft = new wxBoxSizer( wxVERTICAL ); @@ -34,24 +37,17 @@ DIALOG_GET_COMPONENT_BASE::DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindow m_historyList = new wxListBox( this, ID_SEL_BY_LISTBOX, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); m_historyList->SetMinSize( wxSize( 200,100 ) ); - bSizerLeft->Add( m_historyList, 1, wxALL|wxEXPAND, 5 ); + bSizerLeft->Add( m_historyList, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - bSizerMain->Add( bSizerLeft, 1, wxEXPAND, 5 ); + bSizerUpper->Add( bSizerLeft, 1, wxEXPAND, 5 ); wxBoxSizer* bSizerRight; bSizerRight = new wxBoxSizer( wxVERTICAL ); - m_buttonOK = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 ); - m_buttonOK->SetDefault(); - bSizerRight->Add( m_buttonOK, 0, wxALL|wxEXPAND, 5 ); - m_buttonKW = new wxButton( this, ID_ACCEPT_KEYWORD, _("Search by Keyword"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerRight->Add( m_buttonKW, 0, wxALL|wxEXPAND, 5 ); - m_buttonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerRight->Add( m_buttonCancel, 0, wxALL|wxEXPAND, 5 ); - m_buttonList = new wxButton( this, ID_LIST_ALL, _("List All"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerRight->Add( m_buttonList, 0, wxALL|wxEXPAND, 5 ); @@ -59,32 +55,46 @@ DIALOG_GET_COMPONENT_BASE::DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindow bSizerRight->Add( m_buttonBrowse, 0, wxALL|wxEXPAND, 5 ); - bSizerMain->Add( bSizerRight, 0, wxALIGN_CENTER_VERTICAL, 5 ); + bSizerUpper->Add( bSizerRight, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + + bSizerMain->Add( bSizerUpper, 1, wxEXPAND, 5 ); + + m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizerMain->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT, 5 ); + + m_sdbSizer = new wxStdDialogButtonSizer(); + m_sdbSizerOK = new wxButton( this, wxID_OK ); + m_sdbSizer->AddButton( m_sdbSizerOK ); + m_sdbSizerCancel = new wxButton( this, wxID_CANCEL ); + m_sdbSizer->AddButton( m_sdbSizerCancel ); + m_sdbSizer->Realize(); + + bSizerMain->Add( m_sdbSizer, 0, wxEXPAND|wxALL, 5 ); this->SetSizer( bSizerMain ); this->Layout(); - bSizerMain->Fit( this ); this->Centre( wxBOTH ); // Connect Events m_historyList->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::Accept ), NULL, this ); - m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::Accept ), NULL, this ); m_buttonKW->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::Accept ), NULL, this ); - m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::OnCancel ), NULL, this ); m_buttonList->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::Accept ), NULL, this ); m_buttonBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::GetExtraSelection ), NULL, this ); + m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::OnCancel ), NULL, this ); + m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::Accept ), NULL, this ); } DIALOG_GET_COMPONENT_BASE::~DIALOG_GET_COMPONENT_BASE() { // Disconnect Events m_historyList->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::Accept ), NULL, this ); - m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::Accept ), NULL, this ); m_buttonKW->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::Accept ), NULL, this ); - m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::OnCancel ), NULL, this ); m_buttonList->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::Accept ), NULL, this ); m_buttonBrowse->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::GetExtraSelection ), NULL, this ); + m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::OnCancel ), NULL, this ); + m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::Accept ), NULL, this ); } diff --git a/common/dialogs/dialog_get_component_base.fbp b/common/dialogs/dialog_get_component_base.fbp index 10a950c93f..51733f03e4 100644 --- a/common/dialogs/dialog_get_component_base.fbp +++ b/common/dialogs/dialog_get_component_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -44,7 +44,7 @@ DIALOG_GET_COMPONENT_BASE - -1,-1 + 361,285 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h @@ -91,7 +91,7 @@ bSizerMain - wxHORIZONTAL + wxVERTICAL none 5 @@ -99,805 +99,747 @@ 1 - bSizerLeft - wxVERTICAL + bSizerUpper + wxHORIZONTAL none 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Name: - - 0 - - - 0 - - 1 - m_staticTextName - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_textCmpNameCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - History list: - - 0 - - - 0 - - 1 - m_staticTextHistory - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND + wxEXPAND 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - ID_SEL_BY_LISTBOX - - 0 - - - 0 - 200,100 - 1 - m_historyList - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - Accept - - - - - - - - - - - - - - + + + bSizerLeft + wxVERTICAL + none + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Name: + + 0 + + + 0 + + 1 + m_staticTextName + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_textCmpNameCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + History list: + + 0 + + + 0 + + 1 + m_staticTextHistory + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_SEL_BY_LISTBOX + + 0 + + + 0 + 200,100 + 1 + m_historyList + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + Accept + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + + bSizerRight + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_ACCEPT_KEYWORD + Search by Keyword + + 0 + + + 0 + + 1 + m_buttonKW + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + Accept + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_LIST_ALL + List All + + 0 + + + 0 + + 1 + m_buttonList + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + Accept + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_EXTRA_TOOL + Select by Browser + + 0 + + + 0 + + 1 + m_buttonBrowse + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + GetExtraSelection + + + + + + + + + + + + + + + + + + + + + + + + + 5 - wxALIGN_CENTER_VERTICAL + wxEXPAND|wxTOP|wxRIGHT 0 - + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 - bSizerRight - wxVERTICAL - none - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_OK - OK - - 0 - - - 0 - - 1 - m_buttonOK - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - Accept - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - ID_ACCEPT_KEYWORD - Search by Keyword - - 0 - - - 0 - - 1 - m_buttonKW - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - Accept - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_CANCEL - Cancel - - 0 - - - 0 - - 1 - m_buttonCancel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnCancel - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - ID_LIST_ALL - List All - - 0 - - - 0 - - 1 - m_buttonList - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - Accept - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - ID_EXTRA_TOOL - Select by Browser - - 0 - - - 0 - - 1 - m_buttonBrowse - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - GetExtraSelection - - - - - - - - - - - - - - - - - - - - - - - - - + 1 + m_staticline1 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxALL + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer + protected + + OnCancel + + + + Accept + + diff --git a/common/dialogs/dialog_get_component_base.h b/common/dialogs/dialog_get_component_base.h index a0a39d5b27..37cb943b24 100644 --- a/common/dialogs/dialog_get_component_base.h +++ b/common/dialogs/dialog_get_component_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 5 2013) +// C++ code generated with wxFormBuilder (version Jun 17 2015) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -24,6 +24,7 @@ class DIALOG_SHIM; #include #include #include +#include #include /////////////////////////////////////////////////////////////////////////// @@ -45,21 +46,23 @@ class DIALOG_GET_COMPONENT_BASE : public DIALOG_SHIM wxTextCtrl* m_textCmpNameCtrl; wxStaticText* m_staticTextHistory; wxListBox* m_historyList; - wxButton* m_buttonOK; wxButton* m_buttonKW; - wxButton* m_buttonCancel; wxButton* m_buttonList; wxButton* m_buttonBrowse; + wxStaticLine* m_staticline1; + wxStdDialogButtonSizer* m_sdbSizer; + wxButton* m_sdbSizerOK; + wxButton* m_sdbSizerCancel; // Virtual event handlers, overide them in your derived class virtual void Accept( wxCommandEvent& event ) { event.Skip(); } - virtual void OnCancel( wxCommandEvent& event ) { event.Skip(); } virtual void GetExtraSelection( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCancel( wxCommandEvent& event ) { event.Skip(); } public: - DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 361,285 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_GET_COMPONENT_BASE(); }; diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp index 0b3a76a57c..dff95aee86 100644 --- a/cvpcb/class_DisplayFootprintsFrame.cpp +++ b/cvpcb/class_DisplayFootprintsFrame.cpp @@ -149,8 +149,10 @@ DISPLAY_FOOTPRINTS_FRAME::~DISPLAY_FOOTPRINTS_FRAME() void DISPLAY_FOOTPRINTS_FRAME::OnCloseWindow( wxCloseEvent& event ) { - if( m_Draw3DFrame ) - m_Draw3DFrame->Close( true ); + EDA_3D_FRAME* draw3DFrame = Get3DViewerFrame(); + + if( draw3DFrame ) + draw3DFrame->Close( true ); Destroy(); } @@ -382,25 +384,27 @@ bool DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPositi void DISPLAY_FOOTPRINTS_FRAME::Show3D_Frame( wxCommandEvent& event ) { - if( m_Draw3DFrame ) + EDA_3D_FRAME* draw3DFrame = Get3DViewerFrame(); + + if( draw3DFrame ) { // Raising the window does not show the window on Windows if iconized. // This should work on any platform. - if( m_Draw3DFrame->IsIconized() ) - m_Draw3DFrame->Iconize( false ); + if( draw3DFrame->IsIconized() ) + draw3DFrame->Iconize( false ); - m_Draw3DFrame->Raise(); + draw3DFrame->Raise(); // Raising the window does not set the focus on Linux. This should work on any platform. - if( wxWindow::FindFocus() != m_Draw3DFrame ) - m_Draw3DFrame->SetFocus(); + if( wxWindow::FindFocus() != draw3DFrame ) + draw3DFrame->SetFocus(); return; } - m_Draw3DFrame = new EDA_3D_FRAME( &Kiway(), this, _( "3D Viewer" ) ); - m_Draw3DFrame->Raise(); // Needed with some Window Managers - m_Draw3DFrame->Show( true ); + draw3DFrame = new EDA_3D_FRAME( &Kiway(), this, _( "3D Viewer" ) ); + draw3DFrame->Raise(); // Needed with some Window Managers + draw3DFrame->Show( true ); } @@ -489,7 +493,8 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay() msg.Printf( _( "Footprint: %s" ), GetChars( footprintName ) ); SetTitle( msg ); - const FOOTPRINT_INFO* module_info = parentframe->m_footprints.GetModuleInfo( footprintName ); + const FOOTPRINT_INFO* module_info = + parentframe->m_footprints.GetModuleInfo( footprintName ); const wxChar* libname; @@ -530,8 +535,10 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay() GetCanvas()->Refresh(); - if( m_Draw3DFrame ) - m_Draw3DFrame->NewDisplay(); + EDA_3D_FRAME* draw3DFrame = Get3DViewerFrame(); + + if( draw3DFrame ) + draw3DFrame->NewDisplay(); } diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index 1c612f0c49..a3deab9c17 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -910,7 +910,8 @@ COMPONENT* CVPCB_MAINFRAME::GetSelectedComponent() DISPLAY_FOOTPRINTS_FRAME* CVPCB_MAINFRAME::GetFpViewerFrame() { // returns the Footprint Viewer frame, if exists, or NULL - return (DISPLAY_FOOTPRINTS_FRAME*) wxWindow::FindWindowByName( FOOTPRINTVIEWER_FRAME_NAME ); + return dynamic_cast + ( wxWindow::FindWindowByName( FOOTPRINTVIEWER_FRAME_NAME ) ); } diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index def2a82785..9a1177e98d 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -76,9 +76,6 @@ public: int m_FastGrid1; // 1st fast grid setting (index in EDA_DRAW_FRAME::m_gridSelectBox) int m_FastGrid2; // 2nd fast grid setting (index in EDA_DRAW_FRAME::m_gridSelectBox) - EDA_3D_FRAME* m_Draw3DFrame; - - protected: BOARD* m_Pcb; GENERAL_COLLECTOR* m_Collector; @@ -111,6 +108,11 @@ public: ~PCB_BASE_FRAME(); + /** + * @return a reference to the 3D viewer frame, when exists, or NULL + */ + EDA_3D_FRAME* Get3DViewerFrame(); + /** * Function LoadFootprint * attempts to load \a aFootprintId from the footprint library table. diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index a5a5f5f489..92d5a7f45b 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -39,6 +39,8 @@ #include #include +#include <3d_viewer.h> + #include #include #include @@ -98,7 +100,6 @@ PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame EDA_DRAW_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ) { m_Pcb = NULL; - m_Draw3DFrame = NULL; // Display Window in 3D mode (OpenGL) m_UserGridSize = wxRealPoint( 100.0, 100.0 ); m_UserGridUnit = INCHES; @@ -123,6 +124,14 @@ PCB_BASE_FRAME::~PCB_BASE_FRAME() } +EDA_3D_FRAME* PCB_BASE_FRAME::Get3DViewerFrame() +{ + // return the 3D viewer frame, when exists, or NULL + return dynamic_cast + ( wxWindow::FindWindowByName( VIEWER3D_FRAMENAME ) ); +} + + FP_LIB_TABLE* PROJECT::PcbFootprintLibs() { // This is a lazy loading function, it loads the project specific table when diff --git a/pcbnew/dialogs/dialog_get_footprint_by_name.h b/pcbnew/dialogs/dialog_get_footprint_by_name.h new file mode 100644 index 0000000000..2f4bbf347f --- /dev/null +++ b/pcbnew/dialogs/dialog_get_footprint_by_name.h @@ -0,0 +1,68 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2015 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr + * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/** + * @file dialog_get_footprint_by_name.h + */ + +#ifndef DIALOG_GET_FOOTPRINT_BY_NAME_H +#define DIALOG_GET_FOOTPRINT_BY_NAME_H + +#include + +/** + * DIALOG_GET_FOOTPRINT_BY_NAME is a helper dialog to select a footprint by its reference + * One can enter any reference or select it in the list of fp references + * Get a footprint ref from user and return a pointer to the corresponding footprint + */ +class DIALOG_GET_FOOTPRINT_BY_NAME: public DIALOG_GET_FOOTPRINT_BY_NAME_BASE +{ +public: + DIALOG_GET_FOOTPRINT_BY_NAME( PCB_BASE_FRAME* aParent, wxArrayString& aFpList ) : + DIALOG_GET_FOOTPRINT_BY_NAME_BASE( aParent ) + { + m_sdbSizerOK->SetDefault(); + m_choiceFpList->Append( aFpList ); + + // Dialog should not shrink beyond it's minimal size. + GetSizer()->SetSizeHints( this ); + } + + // returns the selected text (fp reference) + const wxString GetValue() + { + return m_SearchTextCtrl->GetValue(); + } + +private: + // Called when selecting an item from the item list + void OnSelectFootprint( wxCommandEvent& aEvent ) + { + if( m_choiceFpList->GetSelection() >= 0 ) + m_SearchTextCtrl->SetValue( + m_choiceFpList->GetString( m_choiceFpList->GetSelection() ).BeforeFirst( ' ' ) ); + } +}; + +#endif // #ifndef DIALOG_GET_FOOTPRINT_BY_NAME_H diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 1567f2ceae..f4e9793ccf 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -597,8 +597,10 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in SetMsgPanel( GetBoard() ); // Refresh the 3D view, if any - if( m_Draw3DFrame ) - m_Draw3DFrame->NewDisplay(); + EDA_3D_FRAME* draw3DFrame = Get3DViewerFrame(); + + if( draw3DFrame ) + draw3DFrame->NewDisplay(); #if 0 && defined(DEBUG) // Output the board object tree to stdout, but please run from command prompt: diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index 81f2640e2a..ff4009ef18 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -210,8 +210,10 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, FOOTPRINT_WIZARD_FRAME::~FOOTPRINT_WIZARD_FRAME() { - if( m_Draw3DFrame ) - m_Draw3DFrame->Destroy(); + EDA_3D_FRAME* draw3DFrame = Get3DViewerFrame(); + + if( draw3DFrame ) + draw3DFrame->Destroy(); } @@ -513,26 +515,28 @@ bool FOOTPRINT_WIZARD_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition void FOOTPRINT_WIZARD_FRAME::Show3D_Frame( wxCommandEvent& event ) { - if( m_Draw3DFrame ) + EDA_3D_FRAME* draw3DFrame = Get3DViewerFrame(); + + if( draw3DFrame ) { // Raising the window does not show the window on Windows if iconized. // This should work on any platform. - if( m_Draw3DFrame->IsIconized() ) - m_Draw3DFrame->Iconize( false ); + if( draw3DFrame->IsIconized() ) + draw3DFrame->Iconize( false ); - m_Draw3DFrame->Raise(); + draw3DFrame->Raise(); // Raising the window does not set the focus on Linux. This should work on any platform. - if( wxWindow::FindFocus() != m_Draw3DFrame ) - m_Draw3DFrame->SetFocus(); + if( wxWindow::FindFocus() != draw3DFrame ) + draw3DFrame->SetFocus(); return; } - m_Draw3DFrame = new EDA_3D_FRAME( &Kiway(), this, wxEmptyString ); + draw3DFrame = new EDA_3D_FRAME( &Kiway(), this, wxEmptyString ); Update3D_Frame( false ); - m_Draw3DFrame->Raise(); // Needed with some Window Managers - m_Draw3DFrame->Show( true ); + draw3DFrame->Raise(); // Needed with some Window Managers + draw3DFrame->Show( true ); } @@ -543,20 +547,22 @@ void FOOTPRINT_WIZARD_FRAME::Show3D_Frame( wxCommandEvent& event ) */ void FOOTPRINT_WIZARD_FRAME::Update3D_Frame( bool aForceReloadFootprint ) { - if( m_Draw3DFrame == NULL ) + EDA_3D_FRAME* draw3DFrame = Get3DViewerFrame(); + + if( draw3DFrame == NULL ) return; wxString frm3Dtitle; frm3Dtitle.Printf( _( "ModView: 3D Viewer [%s]" ), GetChars( m_wizardName ) ); - m_Draw3DFrame->SetTitle( frm3Dtitle ); + draw3DFrame->SetTitle( frm3Dtitle ); if( aForceReloadFootprint ) { - m_Draw3DFrame->ReloadRequest(); + draw3DFrame->ReloadRequest(); // Force 3D screen refresh immediately if( GetBoard()->m_Modules ) - m_Draw3DFrame->NewDisplay(); + draw3DFrame->NewDisplay(); } } diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index 9e8ca54ebc..c51e171f4c 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -192,8 +192,10 @@ void FOOTPRINT_EDIT_FRAME::LoadModuleFromBoard( wxCommandEvent& event ) GetScreen()->ClearUndoRedoList(); GetScreen()->ClrModify(); - if( m_Draw3DFrame ) - m_Draw3DFrame->NewDisplay(); + EDA_3D_FRAME* draw3DFrame = Get3DViewerFrame(); + + if( draw3DFrame ) + draw3DFrame->NewDisplay(); } @@ -370,8 +372,10 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) updateView(); m_canvas->Refresh(); - if( m_Draw3DFrame ) - m_Draw3DFrame->NewDisplay(); + EDA_3D_FRAME* draw3DFrame = Get3DViewerFrame(); + + if( draw3DFrame ) + draw3DFrame->NewDisplay(); GetScreen()->ClrModify(); } @@ -513,9 +517,12 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) GetScreen()->ClrModify(); Zoom_Automatique( false ); m_canvas->Refresh(); + { + EDA_3D_FRAME* draw3DFrame = Get3DViewerFrame(); - if( m_Draw3DFrame ) - m_Draw3DFrame->NewDisplay(); + if( draw3DFrame ) + draw3DFrame->NewDisplay(); + } break; @@ -572,8 +579,12 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) Zoom_Automatique( false ); - if( m_Draw3DFrame ) - m_Draw3DFrame->NewDisplay(); + { + EDA_3D_FRAME* draw3DFrame = Get3DViewerFrame(); + + if( draw3DFrame ) + draw3DFrame->NewDisplay(); + } GetScreen()->ClrModify(); diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 80302a7eb4..9a9f259514 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -672,25 +672,27 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateSelectCurrentLib( wxUpdateUIEvent& aEvent ) void FOOTPRINT_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event ) { - if( m_Draw3DFrame ) + EDA_3D_FRAME* draw3DFrame = Get3DViewerFrame(); + + if( draw3DFrame ) { // Raising the window does not show the window on Windows if iconized. // This should work on any platform. - if( m_Draw3DFrame->IsIconized() ) - m_Draw3DFrame->Iconize( false ); + if( draw3DFrame->IsIconized() ) + draw3DFrame->Iconize( false ); - m_Draw3DFrame->Raise(); + draw3DFrame->Raise(); // Raising the window does not set the focus on Linux. This should work on any platform. - if( wxWindow::FindFocus() != m_Draw3DFrame ) - m_Draw3DFrame->SetFocus(); + if( wxWindow::FindFocus() != draw3DFrame ) + draw3DFrame->SetFocus(); return; } - m_Draw3DFrame = new EDA_3D_FRAME( &Kiway(), this, _( "3D Viewer" ) ); - m_Draw3DFrame->Raise(); // Needed with some Window Managers - m_Draw3DFrame->Show( true ); + draw3DFrame = new EDA_3D_FRAME( &Kiway(), this, _( "3D Viewer" ) ); + draw3DFrame->Raise(); // Needed with some Window Managers + draw3DFrame->Show( true ); } @@ -735,9 +737,10 @@ void FOOTPRINT_EDIT_FRAME::OnModify() { PCB_BASE_FRAME::OnModify(); - if( m_Draw3DFrame ) - m_Draw3DFrame->ReloadRequest(); -} + EDA_3D_FRAME* draw3DFrame = Get3DViewerFrame(); + + if( draw3DFrame ) + draw3DFrame->ReloadRequest();} void FOOTPRINT_EDIT_FRAME::updateTitle() diff --git a/pcbnew/modules.cpp b/pcbnew/modules.cpp index 6258262074..a31a2e60a5 100644 --- a/pcbnew/modules.cpp +++ b/pcbnew/modules.cpp @@ -1,10 +1,10 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr + * Copyright (C) 2015 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck * Copyright (C) 2012 Wayne Stambaugh - * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -41,7 +41,7 @@ #include #include - +#include static void MoveFootprint( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ); @@ -56,42 +56,6 @@ static PICKED_ITEMS_LIST s_PickedList; /* a picked list to * and dragged tracks */ -/* - * Get a footprint ref from user and return a pointer to the corresponding footprint - * - * DIALOG_GET_FOOTPRINT_BY_NAME is a helper dialog to select afootprint by its ref - */ -#include - -class DIALOG_GET_FOOTPRINT_BY_NAME: public DIALOG_GET_FOOTPRINT_BY_NAME_BASE -{ -public: - DIALOG_GET_FOOTPRINT_BY_NAME( PCB_BASE_FRAME* aParent, wxArrayString& aFpList ) : - DIALOG_GET_FOOTPRINT_BY_NAME_BASE( aParent ) - { - m_sdbSizerOK->SetDefault(); - m_choiceFpList->Append( aFpList ); - - // Dialog should not shrink beyond it's minimal size. - GetSizer()->SetSizeHints( this ); - } - - // returns the selected text (fp reference) - const wxString GetValue() - { - return m_SearchTextCtrl->GetValue(); - } - -private: - // Called when selecting an item from the item list - void OnSelectFootprint( wxCommandEvent& aEvent ) - { - if( m_choiceFpList->GetSelection() >= 0 ) - m_SearchTextCtrl->SetValue( - m_choiceFpList->GetString( m_choiceFpList->GetSelection() ).BeforeFirst( ' ' ) ); - } -}; - MODULE* PCB_BASE_FRAME::GetFootprintFromBoardByReference() { @@ -99,6 +63,7 @@ MODULE* PCB_BASE_FRAME::GetFootprintFromBoardByReference() MODULE* module = NULL; wxArrayString fplist; + // Build list of available fp references, to display them in dialog for( MODULE* fp = GetBoard()->m_Modules; fp; fp = fp->Next() ) fplist.Add( fp->GetReference() + wxT(" ( ") + fp->GetValue() + wxT(" )") ); @@ -106,8 +71,8 @@ MODULE* PCB_BASE_FRAME::GetFootprintFromBoardByReference() DIALOG_GET_FOOTPRINT_BY_NAME dlg( this, fplist ); - if( dlg.ShowModal() != wxID_OK ) - return NULL; //Aborted by user + if( dlg.ShowModal() != wxID_OK ) //Aborted by user + return NULL; moduleName = dlg.GetValue(); moduleName.Trim( true ); diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp index ee88cc6c43..3ca999570d 100644 --- a/pcbnew/modview_frame.cpp +++ b/pcbnew/modview_frame.cpp @@ -283,8 +283,10 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent FOOTPRINT_VIEWER_FRAME::~FOOTPRINT_VIEWER_FRAME() { - if( m_Draw3DFrame ) - m_Draw3DFrame->Destroy(); + EDA_3D_FRAME* draw3DFrame = Get3DViewerFrame(); + + if( draw3DFrame ) + draw3DFrame->Destroy(); } @@ -613,47 +615,51 @@ bool FOOTPRINT_VIEWER_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition void FOOTPRINT_VIEWER_FRAME::Show3D_Frame( wxCommandEvent& event ) { - if( m_Draw3DFrame ) + EDA_3D_FRAME* draw3DFrame = Get3DViewerFrame(); + + if( draw3DFrame ) { // Raising the window does not show the window on Windows if iconized. // This should work on any platform. - if( m_Draw3DFrame->IsIconized() ) - m_Draw3DFrame->Iconize( false ); + if( draw3DFrame->IsIconized() ) + draw3DFrame->Iconize( false ); - m_Draw3DFrame->Raise(); + draw3DFrame->Raise(); // Raising the window does not set the focus on Linux. This should work on any platform. - if( wxWindow::FindFocus() != m_Draw3DFrame ) - m_Draw3DFrame->SetFocus(); + if( wxWindow::FindFocus() != draw3DFrame ) + draw3DFrame->SetFocus(); return; } - m_Draw3DFrame = new EDA_3D_FRAME( &Kiway(), this, wxEmptyString ); + draw3DFrame = new EDA_3D_FRAME( &Kiway(), this, wxEmptyString ); Update3D_Frame( false ); - m_Draw3DFrame->Raise(); // Needed with some Window Managers - m_Draw3DFrame->Show( true ); + draw3DFrame->Raise(); // Needed with some Window Managers + draw3DFrame->Show( true ); } void FOOTPRINT_VIEWER_FRAME::Update3D_Frame( bool aForceReloadFootprint ) { - if( m_Draw3DFrame == NULL ) - return; + EDA_3D_FRAME* draw3DFrame = Get3DViewerFrame(); + + if( draw3DFrame == NULL ) + return; wxString frm3Dtitle = wxString::Format( _( "ModView: 3D Viewer [%s]" ), GetChars( getCurFootprintName() ) ); - m_Draw3DFrame->SetTitle( frm3Dtitle ); + draw3DFrame->SetTitle( frm3Dtitle ); if( aForceReloadFootprint ) { - m_Draw3DFrame->ReloadRequest(); + draw3DFrame->ReloadRequest(); // Force 3D screen refresh immediately if( GetBoard()->m_Modules ) - m_Draw3DFrame->NewDisplay(); + draw3DFrame->NewDisplay(); } } diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index b19fca1935..4eee8235c8 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -637,26 +637,28 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) void PCB_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event ) { - if( m_Draw3DFrame ) + EDA_3D_FRAME* draw3DFrame = Get3DViewerFrame(); + + if( draw3DFrame ) { // Raising the window does not show the window on Windows if iconized. // This should work on any platform. - if( m_Draw3DFrame->IsIconized() ) - m_Draw3DFrame->Iconize( false ); + if( draw3DFrame->IsIconized() ) + draw3DFrame->Iconize( false ); - m_Draw3DFrame->Raise(); + draw3DFrame->Raise(); // Raising the window does not set the focus on Linux. This should work on any platform. - if( wxWindow::FindFocus() != m_Draw3DFrame ) - m_Draw3DFrame->SetFocus(); + if( wxWindow::FindFocus() != draw3DFrame ) + draw3DFrame->SetFocus(); return; } - m_Draw3DFrame = new EDA_3D_FRAME( &Kiway(), this, _( "3D Viewer" ) ); - m_Draw3DFrame->SetDefaultFileName( GetBoard()->GetFileName() ); - m_Draw3DFrame->Raise(); // Needed with some Window Managers - m_Draw3DFrame->Show( true ); + draw3DFrame = new EDA_3D_FRAME( &Kiway(), this, _( "3D Viewer" ) ); + draw3DFrame->SetDefaultFileName( GetBoard()->GetFileName() ); + draw3DFrame->Raise(); // Needed with some Window Managers + draw3DFrame->Show( true ); } @@ -937,8 +939,10 @@ void PCB_EDIT_FRAME::OnModify( ) { PCB_BASE_FRAME::OnModify(); - if( m_Draw3DFrame ) - m_Draw3DFrame->ReloadRequest(); + EDA_3D_FRAME* draw3DFrame = Get3DViewerFrame(); + + if( draw3DFrame ) + draw3DFrame->ReloadRequest(); }