From 6eafb9a2fdb4a4cf3401c8a4b1bcfd86f41ca319 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 30 Aug 2018 22:44:50 +0100 Subject: [PATCH] Convert Rescue Symbols dialog previews to GAL. --- eeschema/dialogs/dialog_rescue_each.cpp | 106 +- eeschema/dialogs/dialog_rescue_each_base.cpp | 93 +- eeschema/dialogs/dialog_rescue_each_base.fbp | 2236 +++++++++--------- eeschema/dialogs/dialog_rescue_each_base.h | 20 +- eeschema/widgets/symbol_preview_widget.cpp | 62 +- eeschema/widgets/symbol_preview_widget.h | 8 +- 6 files changed, 1303 insertions(+), 1222 deletions(-) diff --git a/eeschema/dialogs/dialog_rescue_each.cpp b/eeschema/dialogs/dialog_rescue_each.cpp index 5e9511509e..48bde00547 100644 --- a/eeschema/dialogs/dialog_rescue_each.cpp +++ b/eeschema/dialogs/dialog_rescue_each.cpp @@ -32,6 +32,7 @@ #include #include #include +#include class DIALOG_RESCUE_EACH: public DIALOG_RESCUE_EACH_BASE { @@ -59,12 +60,9 @@ private: bool TransferDataFromWindow() override; void PopulateConflictList(); void PopulateInstanceList(); - void OnConflictSelect( wxDataViewEvent& event ) override; - void OnNeverShowClick( wxCommandEvent& event ) override; - void OnCancelClick( wxCommandEvent& event ) override; - void OnHandleCachePreviewRepaint( wxPaintEvent& aRepaintEvent ) override; - void OnHandleLibraryPreviewRepaint( wxPaintEvent& aRepaintEvent ) override; - void renderPreview( LIB_PART* aComponent, int aUnit, wxPanel* panel ); + void OnConflictSelect( wxDataViewEvent& aEvent ) override; + void OnNeverShowClick( wxCommandEvent& aEvent ) override; + void OnCancelClick( wxCommandEvent& aEvent ) override; }; @@ -117,11 +115,11 @@ DIALOG_RESCUE_EACH::DIALOG_RESCUE_EACH( SCH_EDIT_FRAME* aParent, RESCUER& aRescu width = dc.GetTextExtent( header ).GetWidth() * 10; m_ListOfInstances->AppendTextColumn( header, wxDATAVIEW_CELL_INERT, width ); - m_componentViewOld->SetLayoutDirection( wxLayout_LeftToRight ); - m_componentViewNew->SetLayoutDirection( wxLayout_LeftToRight ); + m_previewOldWidget->SetLayoutDirection( wxLayout_LeftToRight ); + m_previewNewWidget->SetLayoutDirection( wxLayout_LeftToRight ); Layout(); - SetSizeInDU( 480, 240 ); + SetSizeInDU( 480, 360 ); // Make sure the HTML window is large enough. Some fun size juggling and // fudge factors here but it does seem to work pretty reliably. @@ -132,7 +130,7 @@ DIALOG_RESCUE_EACH::DIALOG_RESCUE_EACH( SCH_EDIT_FRAME* aParent, RESCUER& aRescu m_htmlPrompt->SetSizeHints( 2 * prompt_size.x / 3, approx_info_height ); Layout(); GetSizer()->SetSizeHints( this ); - SetSizeInDU( 480, 240 ); + SetSizeInDU( 480, 360 ); Center(); } @@ -206,77 +204,8 @@ void DIALOG_RESCUE_EACH::PopulateInstanceList() count++; } - m_titleInstances->SetLabelText( wxString::Format( - _( "Instances of this symbol (%d items):" ), count ) ); -} - - -void DIALOG_RESCUE_EACH::OnHandleCachePreviewRepaint( wxPaintEvent& aRepaintEvent ) -{ - int row = m_ListOfConflicts->GetSelectedRow(); - - if( row == wxNOT_FOUND ) - row = 0; - - RESCUE_CANDIDATE& selected_part = m_Rescuer->m_all_candidates[row]; - - if( selected_part.GetCacheCandidate() ) - renderPreview( selected_part.GetCacheCandidate(), 0, m_componentViewOld ); -} - - -void DIALOG_RESCUE_EACH::OnHandleLibraryPreviewRepaint( wxPaintEvent& aRepaintEvent ) -{ - int row = m_ListOfConflicts->GetSelectedRow(); - - if( row == wxNOT_FOUND ) - row = 0; - - RESCUE_CANDIDATE& selected_part = m_Rescuer->m_all_candidates[row]; - - if( selected_part.GetLibCandidate() ) - renderPreview( selected_part.GetLibCandidate(), 0, m_componentViewNew ); -} - - -// Render the preview in our m_componentView. If this gets more complicated, we should -// probably have a derived class from wxPanel; but this keeps things local. -// Call it only from a Paint Event, because we are using a wxPaintDC to draw the component -void DIALOG_RESCUE_EACH::renderPreview( LIB_PART* aComponent, int aUnit, wxPanel* aPanel ) -{ - wxPaintDC dc( aPanel ); - wxColour bgColor = m_Parent->GetDrawBgColor().ToColour(); - - dc.SetBackground( wxBrush( bgColor ) ); - dc.Clear(); - - if( aComponent == NULL ) - return; - - if( aUnit <= 0 ) - aUnit = 1; - - const wxSize dc_size = dc.GetSize(); - dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 ); - - // Find joint bounding box for everything we are about to draw. - EDA_RECT bBox = aComponent->GetUnitBoundingBox( aUnit, /* deMorganConvert */ 1 ); - const double xscale = (double) dc_size.x / bBox.GetWidth(); - const double yscale = (double) dc_size.y / bBox.GetHeight(); - const double scale = std::min( xscale, yscale ) * 0.85; - - dc.SetUserScale( scale, scale ); - - wxPoint offset = - bBox.Centre(); - - // Avoid rendering when either dimension is zero - int width, height; - - dc.GetSize( &width, &height ); - if( !width || !height ) - return; - - aComponent->Draw( NULL, &dc, offset, aUnit, 1, PART_DRAW_OPTIONS::Default() ); + wxString msg = wxString::Format( _( "Instances of this symbol (%d items):" ), count ); + m_titleInstances->SetLabelText( msg ); } @@ -290,8 +219,19 @@ void DIALOG_RESCUE_EACH::OnConflictSelect( wxDataViewEvent& aEvent ) PopulateInstanceList(); - m_componentViewOld->Refresh(); - m_componentViewNew->Refresh(); + int row = m_ListOfConflicts->GetSelectedRow(); + + if( row < 0 ) + { + m_previewOldWidget->DisplayPart( nullptr, 0 ); + m_previewNewWidget->DisplayPart( nullptr, 0 ); + } + else + { + RESCUE_CANDIDATE& selected_part = m_Rescuer->m_all_candidates[row]; + m_previewOldWidget->DisplayPart( selected_part.GetCacheCandidate(), 0 ); + m_previewNewWidget->DisplayPart( selected_part.GetLibCandidate(), 0 ); + } } diff --git a/eeschema/dialogs/dialog_rescue_each_base.cpp b/eeschema/dialogs/dialog_rescue_each_base.cpp index bc89612ab8..336523c803 100644 --- a/eeschema/dialogs/dialog_rescue_each_base.cpp +++ b/eeschema/dialogs/dialog_rescue_each_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Aug 2 2018) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -17,71 +17,90 @@ DIALOG_RESCUE_EACH_BASE::DIALOG_RESCUE_EACH_BASE( wxWindow* parent, wxWindowID i bSizerMain = new wxBoxSizer( wxVERTICAL ); m_htmlPrompt = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO ); - bSizerMain->Add( m_htmlPrompt, 1, wxALL|wxEXPAND, 5 ); + m_htmlPrompt->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) ); + m_htmlPrompt->SetMinSize( wxSize( -1,50 ) ); + + bSizerMain->Add( m_htmlPrompt, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); m_titleSymbols = new wxStaticText( this, wxID_ANY, _("Symbols to update:"), wxDefaultPosition, wxDefaultSize, 0 ); m_titleSymbols->Wrap( -1 ); m_titleSymbols->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) ); - bSizerMain->Add( m_titleSymbols, 0, wxLEFT|wxRIGHT, 5 ); + bSizerMain->Add( m_titleSymbols, 0, wxLEFT|wxRIGHT, 10 ); m_ListOfConflicts = new wxDataViewListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - bSizerMain->Add( m_ListOfConflicts, 2, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + bSizerMain->Add( m_ListOfConflicts, 3, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 ); m_titleInstances = new wxStaticText( this, wxID_ANY, _("Instances of this symbol:"), wxDefaultPosition, wxDefaultSize, 0 ); m_titleInstances->Wrap( -1 ); m_titleInstances->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) ); - bSizerMain->Add( m_titleInstances, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + bSizerMain->Add( m_titleInstances, 0, wxRIGHT|wxLEFT, 10 ); m_ListOfInstances = new wxDataViewListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - bSizerMain->Add( m_ListOfInstances, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + bSizerMain->Add( m_ListOfInstances, 2, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 ); - wxBoxSizer* bSizerView; - bSizerView = new wxBoxSizer( wxHORIZONTAL ); + wxBoxSizer* bSizerPreviews; + bSizerPreviews = new wxBoxSizer( wxHORIZONTAL ); - wxBoxSizer* bSizer6; - bSizer6 = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bSizerLeftPreview; + bSizerLeftPreview = new wxBoxSizer( wxVERTICAL ); - m_staticText2 = new wxStaticText( this, wxID_ANY, _("Cached Symbol:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText2->Wrap( -1 ); - m_staticText2->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) ); + m_previewOldLabel = new wxStaticText( this, wxID_ANY, _("Cached Symbol:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_previewOldLabel->Wrap( -1 ); + m_previewOldLabel->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) ); - bSizer6->Add( m_staticText2, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + bSizerLeftPreview->Add( m_previewOldLabel, 0, 0, 5 ); - m_componentViewOld = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE ); - m_componentViewOld->SetMinSize( wxSize( 150,150 ) ); + m_previewOldPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizerOldPanel; + bSizerOldPanel = new wxBoxSizer( wxVERTICAL ); - bSizer6->Add( m_componentViewOld, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + m_previewOldWidget = new SYMBOL_PREVIEW_WIDGET( m_previewOldPanel, Kiway() ); + bSizerOldPanel->Add( m_previewOldWidget, 1, wxEXPAND, 5 ); - bSizerView->Add( bSizer6, 1, wxEXPAND, 5 ); - - wxBoxSizer* bSizer7; - bSizer7 = new wxBoxSizer( wxVERTICAL ); - - m_staticText3 = new wxStaticText( this, wxID_ANY, _("Library Symbol:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText3->Wrap( -1 ); - m_staticText3->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) ); - - bSizer7->Add( m_staticText3, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_componentViewNew = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE ); - m_componentViewNew->SetMinSize( wxSize( 150,150 ) ); - - bSizer7->Add( m_componentViewNew, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + m_previewOldPanel->SetSizer( bSizerOldPanel ); + m_previewOldPanel->Layout(); + bSizerOldPanel->Fit( m_previewOldPanel ); + bSizerLeftPreview->Add( m_previewOldPanel, 1, wxEXPAND | wxALL, 5 ); - bSizerView->Add( bSizer7, 1, wxEXPAND, 5 ); + bSizerPreviews->Add( bSizerLeftPreview, 1, wxEXPAND, 5 ); + + wxBoxSizer* bSizerRightPreview; + bSizerRightPreview = new wxBoxSizer( wxVERTICAL ); + + m_previewNewLabel = new wxStaticText( this, wxID_ANY, _("Library Symbol:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_previewNewLabel->Wrap( -1 ); + m_previewNewLabel->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) ); + + bSizerRightPreview->Add( m_previewNewLabel, 0, 0, 5 ); + + m_previewNewPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizerNewPanel; + bSizerNewPanel = new wxBoxSizer( wxVERTICAL ); + + m_previewNewWidget = new SYMBOL_PREVIEW_WIDGET( m_previewNewPanel, Kiway() ); + bSizerNewPanel->Add( m_previewNewWidget, 1, wxEXPAND, 5 ); - bSizerMain->Add( bSizerView, 2, wxEXPAND, 5 ); + m_previewNewPanel->SetSizer( bSizerNewPanel ); + m_previewNewPanel->Layout(); + bSizerNewPanel->Fit( m_previewNewPanel ); + bSizerRightPreview->Add( m_previewNewPanel, 1, wxEXPAND | wxALL, 5 ); + + + bSizerPreviews->Add( bSizerRightPreview, 1, wxEXPAND, 5 ); + + + bSizerMain->Add( bSizerPreviews, 3, wxEXPAND|wxRIGHT|wxLEFT, 10 ); wxBoxSizer* bSizer5; bSizer5 = new wxBoxSizer( wxHORIZONTAL ); m_btnNeverShowAgain = new wxButton( this, wxID_ANY, _("Never Show Again"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer5->Add( m_btnNeverShowAgain, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + bSizer5->Add( m_btnNeverShowAgain, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 10 ); bSizer5->Add( 0, 0, 1, wxEXPAND, 5 ); @@ -108,8 +127,6 @@ DIALOG_RESCUE_EACH_BASE::DIALOG_RESCUE_EACH_BASE( wxWindow* parent, wxWindowID i // Connect Events this->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_RESCUE_EACH_BASE::OnDialogResize ) ); m_ListOfConflicts->Connect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_RESCUE_EACH_BASE::OnConflictSelect ), NULL, this ); - m_componentViewOld->Connect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_RESCUE_EACH_BASE::OnHandleCachePreviewRepaint ), NULL, this ); - m_componentViewNew->Connect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_RESCUE_EACH_BASE::OnHandleLibraryPreviewRepaint ), NULL, this ); m_btnNeverShowAgain->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_RESCUE_EACH_BASE::OnNeverShowClick ), NULL, this ); m_stdButtonsCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_RESCUE_EACH_BASE::OnCancelClick ), NULL, this ); } @@ -119,8 +136,6 @@ DIALOG_RESCUE_EACH_BASE::~DIALOG_RESCUE_EACH_BASE() // Disconnect Events this->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_RESCUE_EACH_BASE::OnDialogResize ) ); m_ListOfConflicts->Disconnect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_RESCUE_EACH_BASE::OnConflictSelect ), NULL, this ); - m_componentViewOld->Disconnect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_RESCUE_EACH_BASE::OnHandleCachePreviewRepaint ), NULL, this ); - m_componentViewNew->Disconnect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_RESCUE_EACH_BASE::OnHandleLibraryPreviewRepaint ), NULL, this ); m_btnNeverShowAgain->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_RESCUE_EACH_BASE::OnNeverShowClick ), NULL, this ); m_stdButtonsCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_RESCUE_EACH_BASE::OnCancelClick ), NULL, this ); diff --git a/eeschema/dialogs/dialog_rescue_each_base.fbp b/eeschema/dialogs/dialog_rescue_each_base.fbp index 857dbe4734..8b032182db 100644 --- a/eeschema/dialogs/dialog_rescue_each_base.fbp +++ b/eeschema/dialogs/dialog_rescue_each_base.fbp @@ -1,1075 +1,1161 @@ - - - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - connect - dialog_rescue_each_base - 1000 - none - - 1 - dialog_rescue_each_base - - . - - 1 - 1 - 1 - 1 - UI - 0 - 0 - - 0 - wxAUI_MGR_DEFAULT - - wxBOTH - - 1 - 1 - impl_virtual - - - - 0 - wxID_ANY - - 400,-1 - DIALOG_RESCUE_EACH_BASE - - -1,-1 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - DIALOG_SHIM; dialog_shim.h - Project Rescue Helper - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OnDialogResize - - - - bSizerMain - wxVERTICAL - none - - 5 - wxALL|wxEXPAND - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_htmlPrompt - 1 - - - protected - 1 - - Resizable - 1 - - wxHW_SCROLLBAR_AUTO - ; forward_declare - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - ,90,92,-1,70,0 - 0 - 0 - wxID_ANY - Symbols to update: - 0 - - 0 - - - 0 - - 1 - m_titleSymbols - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 2 - - - - 1 - 1 - - - 0 - wxID_ANY - - - m_ListOfConflicts - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OnConflictSelect - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - ,90,92,-1,70,0 - 0 - 0 - wxID_ANY - Instances of this symbol: - 0 - - 0 - - - 0 - - 1 - m_titleInstances - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 1 - - - - 1 - 1 - - - 0 - wxID_ANY - - - m_ListOfInstances - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 2 - - - bSizerView - wxHORIZONTAL - none - - 5 - wxEXPAND - 1 - - - bSizer6 - wxVERTICAL - none - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - ,90,92,-1,70,0 - 0 - 0 - wxID_ANY - Cached Symbol: - 0 - - 0 - - - 0 - - 1 - m_staticText2 - 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 - wxID_ANY - - 0 - - - 0 - 150,150 - 1 - m_componentViewOld - 1 - - - protected - 1 - - Resizable - 1 - - - 0 - - - - wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE - - - - - - - - - - - - - - - - - - - - - - - - OnHandleCachePreviewRepaint - - - - - - - - - - - - 5 - wxEXPAND - 1 - - - bSizer7 - wxVERTICAL - none - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - ,90,92,-1,70,0 - 0 - 0 - wxID_ANY - Library Symbol: - 0 - - 0 - - - 0 - - 1 - m_staticText3 - 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 - wxID_ANY - - 0 - - - 0 - 150,150 - 1 - m_componentViewNew - 1 - - - protected - 1 - - Resizable - 1 - - - 0 - - - - wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE - - - - - - - - - - - - - - - - - - - - - - - - OnHandleLibraryPreviewRepaint - - - - - - - - - - - - - - 5 - wxEXPAND - 0 - - - bSizer5 - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Never Show Again - - 0 - - 0 - - - 0 - - 1 - m_btnNeverShowAgain - 1 - - - protected - 1 - - - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - OnNeverShowClick - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxALL|wxEXPAND - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_stdButtons - protected - - OnCancelClick - - - - - - - - - - - - - - + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + dialog_rescue_each_base + 1000 + none + 1 + dialog_rescue_each_base + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + 400,-1 + DIALOG_RESCUE_EACH_BASE + + -1,-1 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + Project Rescue Helper + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnDialogResize + + + + bSizerMain + wxVERTICAL + none + + 5 + wxEXPAND|wxTOP|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + wxSYS_COLOUR_BTNFACE + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + -1,50 + 1 + m_htmlPrompt + 1 + + + protected + 1 + + Resizable + 1 + + wxHW_SCROLLBAR_AUTO + ; forward_declare + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + ,90,92,-1,70,0 + 0 + 0 + wxID_ANY + Symbols to update: + + 0 + + + 0 + + 1 + m_titleSymbols + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 3 + + + + 1 + 1 + + + 0 + wxID_ANY + + + m_ListOfConflicts + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + OnConflictSelect + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + ,90,92,-1,70,0 + 0 + 0 + wxID_ANY + Instances of this symbol: + + 0 + + + 0 + + 1 + m_titleInstances + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 2 + + + + 1 + 1 + + + 0 + wxID_ANY + + + m_ListOfInstances + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + wxEXPAND|wxRIGHT|wxLEFT + 3 + + + bSizerPreviews + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + + bSizerLeftPreview + wxVERTICAL + none + + 5 + + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + ,90,92,-1,70,0 + 0 + 0 + wxID_ANY + Cached Symbol: + + 0 + + + 0 + + 1 + m_previewOldLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND | wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_previewOldPanel + 1 + + + protected + 1 + + Resizable + 1 + + ; forward_declare + 0 + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + bSizerOldPanel + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + SYMBOL_PREVIEW_WIDGET + 1 + m_previewOldWidget = new SYMBOL_PREVIEW_WIDGET( m_previewOldPanel, Kiway() ); + + 1 + + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + #include <symbol_preview_widget.h> + + 0 + + + 0 + + 1 + m_previewOldWidget + 1 + + + protected + 1 + + Resizable + + 1 + + ; forward_declare + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + bSizerRightPreview + wxVERTICAL + none + + 5 + + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + ,90,92,-1,70,0 + 0 + 0 + wxID_ANY + Library Symbol: + + 0 + + + 0 + + 1 + m_previewNewLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND | wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_previewNewPanel + 1 + + + protected + 1 + + Resizable + 1 + + ; forward_declare + 0 + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + bSizerNewPanel + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + SYMBOL_PREVIEW_WIDGET + 1 + m_previewNewWidget = new SYMBOL_PREVIEW_WIDGET( m_previewNewPanel, Kiway() ); + + 1 + + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + #include <symbol_preview_widget.h> + + 0 + + + 0 + + 1 + m_previewNewWidget + 1 + + + protected + 1 + + Resizable + + 1 + + ; forward_declare + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + + bSizer5 + wxHORIZONTAL + none + + 10 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Never Show Again + + 0 + + + 0 + + 1 + m_btnNeverShowAgain + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnNeverShowClick + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALL|wxEXPAND + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_stdButtons + protected + + OnCancelClick + + + + + + + + + + + + + + diff --git a/eeschema/dialogs/dialog_rescue_each_base.h b/eeschema/dialogs/dialog_rescue_each_base.h index 2b87d80d1b..f6bc920b92 100644 --- a/eeschema/dialogs/dialog_rescue_each_base.h +++ b/eeschema/dialogs/dialog_rescue_each_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Aug 2 2018) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -20,11 +20,9 @@ #include #include #include -#include +#include #include -#include -#include -#include +#include #include #include @@ -44,10 +42,12 @@ class DIALOG_RESCUE_EACH_BASE : public DIALOG_SHIM wxDataViewListCtrl* m_ListOfConflicts; wxStaticText* m_titleInstances; wxDataViewListCtrl* m_ListOfInstances; - wxStaticText* m_staticText2; - wxPanel* m_componentViewOld; - wxStaticText* m_staticText3; - wxPanel* m_componentViewNew; + wxStaticText* m_previewOldLabel; + wxPanel* m_previewOldPanel; + SYMBOL_PREVIEW_WIDGET* m_previewOldWidget; + wxStaticText* m_previewNewLabel; + wxPanel* m_previewNewPanel; + SYMBOL_PREVIEW_WIDGET* m_previewNewWidget; wxButton* m_btnNeverShowAgain; wxStdDialogButtonSizer* m_stdButtons; wxButton* m_stdButtonsOK; @@ -56,8 +56,6 @@ class DIALOG_RESCUE_EACH_BASE : public DIALOG_SHIM // Virtual event handlers, overide them in your derived class virtual void OnDialogResize( wxSizeEvent& event ) { event.Skip(); } virtual void OnConflictSelect( wxDataViewEvent& event ) { event.Skip(); } - virtual void OnHandleCachePreviewRepaint( wxPaintEvent& event ) { event.Skip(); } - virtual void OnHandleLibraryPreviewRepaint( wxPaintEvent& event ) { event.Skip(); } virtual void OnNeverShowClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } diff --git a/eeschema/widgets/symbol_preview_widget.cpp b/eeschema/widgets/symbol_preview_widget.cpp index 514035f7f9..c571a46187 100644 --- a/eeschema/widgets/symbol_preview_widget.cpp +++ b/eeschema/widgets/symbol_preview_widget.cpp @@ -29,12 +29,11 @@ #include SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aKiway ) : - wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, - wxFULL_REPAINT_ON_RESIZE | wxTAB_TRAVERSAL ), + wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ), m_kiway( aKiway ), m_preview( nullptr ), m_status( nullptr ), - m_sizer( nullptr ), + m_statusSizer( nullptr ), m_previewItem( nullptr ) { m_galDisplayOptions.ReadConfig( Pgm().CommonSettings(), GAL_DISPLAY_OPTIONS_KEY ); @@ -47,16 +46,16 @@ SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aKiway ) SetForegroundColour( *wxBLACK ); m_status = new wxStaticText( this, -1, wxEmptyString ); - m_sizer = new wxBoxSizer( wxVERTICAL ); - m_sizer->Add( 0, 0, 1 ); - m_sizer->Add( m_status, 0, wxALL | wxALIGN_CENTER, 0 ); - m_sizer->Add( 0, 0, 1 ); + m_statusSizer = new wxBoxSizer( wxVERTICAL ); + m_statusSizer->Add( 0, 0, 1 ); + m_statusSizer->Add( m_status, 0, wxALL | wxALIGN_CENTER, 0 ); + m_statusSizer->Add( 0, 0, 1 ); auto outer_sizer = new wxBoxSizer( wxVERTICAL ); outer_sizer->Add( m_preview, 1, wxALL | wxEXPAND, 0 ); - outer_sizer->Add( m_sizer, 1, wxALL | wxALIGN_CENTER, 0 ); + outer_sizer->Add( m_statusSizer, 1, wxALL | wxALIGN_CENTER, 0 ); - m_sizer->ShowItems( false ); + m_statusSizer->ShowItems( false ); SetSizer( outer_sizer ); } @@ -72,7 +71,7 @@ SYMBOL_PREVIEW_WIDGET::~SYMBOL_PREVIEW_WIDGET() void SYMBOL_PREVIEW_WIDGET::SetStatusText( wxString const& aText ) { m_status->SetLabel( aText ); - m_sizer->ShowItems( true ); + m_statusSizer->ShowItems( true ); m_preview->Hide(); Layout(); } @@ -131,8 +130,47 @@ void SYMBOL_PREVIEW_WIDGET::DisplaySymbol( const LIB_ID& aSymbolID, int aUnit ) m_preview->ForceRefresh(); m_preview->Show(); - m_sizer->ShowItems( false ); - Layout(); + m_statusSizer->ShowItems( false ); +} + + +void SYMBOL_PREVIEW_WIDGET::DisplayPart( LIB_PART* aPart, int aUnit ) +{ + KIGFX::VIEW* view = m_preview->GetView(); + + if( m_previewItem ) + { + view->Remove( m_previewItem ); + m_previewItem = nullptr; + } + + if( aPart ) + { + // If unit isn't specified for a multi-unit part, pick the first. (Otherwise we'll + // draw all of them.) + if( aPart->IsMulti() && aUnit == 0 ) + aUnit = 1; + + view->Add( aPart ); + m_previewItem = aPart; + + // Zoom to fit + BOX2I bBox = aPart->GetUnitBoundingBox( aUnit, 0 ); + VECTOR2D clientSize = m_preview->GetClientSize(); + double scale = std::min( fabs( clientSize.x / bBox.GetWidth() ), + fabs( clientSize.y / bBox.GetHeight() ) ); + + // Above calculation will yield an exact fit; add a bit of whitespace around symbol + scale /= 1.2; + + view->SetScale( scale ); + view->SetCenter( bBox.Centre() ); + } + + m_preview->ForceRefresh(); + + m_preview->Show(); + m_statusSizer->ShowItems( false ); } diff --git a/eeschema/widgets/symbol_preview_widget.h b/eeschema/widgets/symbol_preview_widget.h index b44da2471b..b0944f476e 100644 --- a/eeschema/widgets/symbol_preview_widget.h +++ b/eeschema/widgets/symbol_preview_widget.h @@ -25,8 +25,10 @@ #include +class EDA_ITEM; class LIB_ID; class LIB_ALIAS; +class LIB_PART; class EDA_DRAW_PANEL_GAL; class wxStaticText; class wxSizer; @@ -56,6 +58,8 @@ public: */ void DisplaySymbol( const LIB_ID& aSymbolID, int aUnit ); + void DisplayPart( LIB_PART* aPart, int aUnit ); + private: KIWAY& m_kiway; @@ -63,9 +67,9 @@ private: EDA_DRAW_PANEL_GAL* m_preview; wxStaticText* m_status; - wxSizer* m_sizer; + wxSizer* m_statusSizer; - LIB_ALIAS* m_previewItem; + EDA_ITEM* m_previewItem; };