From c08a6adb2a213956046cb74dc1f5450bb8e2fcba Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 19 Apr 2020 18:23:40 +0100 Subject: [PATCH] Implement GUI and file R/W for 3D model opacity. Fixes https://gitlab.com/kicad/code/kicad/issues/2087 --- 3d-viewer/3d_cache/dialogs/panel_prev_3d.cpp | 19 + 3d-viewer/3d_cache/dialogs/panel_prev_3d.h | 2 + .../3d_cache/dialogs/panel_prev_3d_base.cpp | 189 +-- .../3d_cache/dialogs/panel_prev_3d_base.fbp | 1074 +++-------------- .../3d_cache/dialogs/panel_prev_3d_base.h | 27 +- common/pcb.keywords | 1 + pcbnew/class_module.h | 2 + pcbnew/kicad_plugin.cpp | 3 + pcbnew/pcb_parser.cpp | 7 +- 9 files changed, 310 insertions(+), 1014 deletions(-) diff --git a/3d-viewer/3d_cache/dialogs/panel_prev_3d.cpp b/3d-viewer/3d_cache/dialogs/panel_prev_3d.cpp index cf42d5e7b5..715557613e 100644 --- a/3d-viewer/3d_cache/dialogs/panel_prev_3d.cpp +++ b/3d-viewer/3d_cache/dialogs/panel_prev_3d.cpp @@ -208,6 +208,8 @@ void PANEL_PREV_3D::SetSelectedModel( int idx ) xoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.x ) ); yoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.y ) ); zoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.z ) ); + + m_opacity->SetValue( modelInfo.m_Opacity * 100.0 ); } else { @@ -224,6 +226,8 @@ void PANEL_PREV_3D::SetSelectedModel( int idx ) xoff->ChangeValue( wxEmptyString ); yoff->ChangeValue( wxEmptyString ); zoff->ChangeValue( wxEmptyString ); + + m_opacity->SetValue( 100 ); } } @@ -253,6 +257,21 @@ void PANEL_PREV_3D::updateOrientation( wxCommandEvent &event ) } +void PANEL_PREV_3D::onOpacitySlider( wxCommandEvent& event ) +{ + if( m_parentModelList && m_selected >= 0 && m_selected < (int) m_parentModelList->size() ) + { + // Write settings back to the parent + MODULE_3D_SETTINGS* modelInfo = &m_parentModelList->at( (unsigned) m_selected ); + + modelInfo->m_Opacity = m_opacity->GetValue() / 100.0; + + // Update the dummy module for the preview + UpdateDummyModule( false ); + } +} + + void PANEL_PREV_3D::doIncrementScale( wxSpinEvent& event, double aSign ) { wxSpinButton* spinCtrl = (wxSpinButton*) event.GetEventObject(); diff --git a/3d-viewer/3d_cache/dialogs/panel_prev_3d.h b/3d-viewer/3d_cache/dialogs/panel_prev_3d.h index fe300f5877..9ef3729610 100644 --- a/3d-viewer/3d_cache/dialogs/panel_prev_3d.h +++ b/3d-viewer/3d_cache/dialogs/panel_prev_3d.h @@ -134,6 +134,8 @@ private: doIncrementOffset( event, -1.0 ); } + void onOpacitySlider( wxCommandEvent& event ) override; + void doIncrementScale( wxSpinEvent& aEvent, double aSign ); void doIncrementRotation( wxSpinEvent& aEvent, double aSign ); void doIncrementOffset( wxSpinEvent& aEvent, double aSign ); diff --git a/3d-viewer/3d_cache/dialogs/panel_prev_3d_base.cpp b/3d-viewer/3d_cache/dialogs/panel_prev_3d_base.cpp index eeea2444f1..2abef875bb 100644 --- a/3d-viewer/3d_cache/dialogs/panel_prev_3d_base.cpp +++ b/3d-viewer/3d_cache/dialogs/panel_prev_3d_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2018) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -9,209 +9,224 @@ /////////////////////////////////////////////////////////////////////////// -PANEL_PREV_3D_BASE::PANEL_PREV_3D_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) +PANEL_PREV_3D_BASE::PANEL_PREV_3D_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) { wxBoxSizer* bSizermain; bSizermain = new wxBoxSizer( wxHORIZONTAL ); - + wxBoxSizer* bSizerLeft; bSizerLeft = new wxBoxSizer( wxVERTICAL ); - + wxStaticBoxSizer* sbSizerScale; sbSizerScale = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Scale") ), wxVERTICAL ); - + wxFlexGridSizer* fgSizerScale; fgSizerScale = new wxFlexGridSizer( 0, 3, 0, 0 ); fgSizerScale->SetFlexibleDirection( wxBOTH ); fgSizerScale->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - + m_staticText1 = new wxStaticText( sbSizerScale->GetStaticBox(), wxID_ANY, _("X:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText1->Wrap( -1 ); fgSizerScale->Add( m_staticText1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - + xscale = new wxTextCtrl( sbSizerScale->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerScale->Add( xscale, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - + m_spinXscale = new wxSpinButton( sbSizerScale->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_VERTICAL ); fgSizerScale->Add( m_spinXscale, 0, wxALIGN_CENTER_VERTICAL, 5 ); - + m_staticText2 = new wxStaticText( sbSizerScale->GetStaticBox(), wxID_ANY, _("Y:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText2->Wrap( -1 ); fgSizerScale->Add( m_staticText2, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - + yscale = new wxTextCtrl( sbSizerScale->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerScale->Add( yscale, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - + m_spinYscale = new wxSpinButton( sbSizerScale->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_VERTICAL ); fgSizerScale->Add( m_spinYscale, 0, wxALIGN_CENTER_VERTICAL, 5 ); - + m_staticText3 = new wxStaticText( sbSizerScale->GetStaticBox(), wxID_ANY, _("Z:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText3->Wrap( -1 ); fgSizerScale->Add( m_staticText3, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 ); - + zscale = new wxTextCtrl( sbSizerScale->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerScale->Add( zscale, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 ); - + m_spinZscale = new wxSpinButton( sbSizerScale->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_VERTICAL ); fgSizerScale->Add( m_spinZscale, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 ); - - + + sbSizerScale->Add( fgSizerScale, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 ); - - + + bSizerLeft->Add( sbSizerScale, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - + wxStaticBoxSizer* sbSizerRotation; sbSizerRotation = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Rotation") ), wxVERTICAL ); - + wxFlexGridSizer* fgSizerRotate; fgSizerRotate = new wxFlexGridSizer( 0, 3, 0, 0 ); fgSizerRotate->SetFlexibleDirection( wxBOTH ); fgSizerRotate->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - + m_staticText11 = new wxStaticText( sbSizerRotation->GetStaticBox(), wxID_ANY, _("X:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText11->Wrap( -1 ); fgSizerRotate->Add( m_staticText11, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - + xrot = new wxTextCtrl( sbSizerRotation->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerRotate->Add( xrot, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - + m_spinXrot = new wxSpinButton( sbSizerRotation->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_VERTICAL ); fgSizerRotate->Add( m_spinXrot, 0, wxALIGN_CENTER_VERTICAL, 5 ); - + m_staticText21 = new wxStaticText( sbSizerRotation->GetStaticBox(), wxID_ANY, _("Y:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText21->Wrap( -1 ); fgSizerRotate->Add( m_staticText21, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - + yrot = new wxTextCtrl( sbSizerRotation->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerRotate->Add( yrot, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - + m_spinYrot = new wxSpinButton( sbSizerRotation->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_VERTICAL ); fgSizerRotate->Add( m_spinYrot, 0, wxALIGN_CENTER_VERTICAL, 5 ); - + m_staticText31 = new wxStaticText( sbSizerRotation->GetStaticBox(), wxID_ANY, _("Z:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText31->Wrap( -1 ); fgSizerRotate->Add( m_staticText31, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 ); - + zrot = new wxTextCtrl( sbSizerRotation->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerRotate->Add( zrot, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 ); - + m_spinZrot = new wxSpinButton( sbSizerRotation->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_VERTICAL ); fgSizerRotate->Add( m_spinZrot, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 ); - - + + sbSizerRotation->Add( fgSizerRotate, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 ); - - + + bSizerLeft->Add( sbSizerRotation, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - + wxStaticBoxSizer* sbSizerOffset; sbSizerOffset = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Offset") ), wxVERTICAL ); - + wxFlexGridSizer* fgSizerOffset; fgSizerOffset = new wxFlexGridSizer( 0, 3, 0, 0 ); fgSizerOffset->SetFlexibleDirection( wxBOTH ); fgSizerOffset->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - + m_staticText12 = new wxStaticText( sbSizerOffset->GetStaticBox(), wxID_ANY, _("X:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText12->Wrap( -1 ); fgSizerOffset->Add( m_staticText12, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - + xoff = new wxTextCtrl( sbSizerOffset->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerOffset->Add( xoff, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - + m_spinXoffset = new wxSpinButton( sbSizerOffset->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_VERTICAL ); fgSizerOffset->Add( m_spinXoffset, 0, wxALIGN_CENTER_VERTICAL, 5 ); - + m_staticText22 = new wxStaticText( sbSizerOffset->GetStaticBox(), wxID_ANY, _("Y:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText22->Wrap( -1 ); fgSizerOffset->Add( m_staticText22, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - + yoff = new wxTextCtrl( sbSizerOffset->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerOffset->Add( yoff, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - + m_spinYoffset = new wxSpinButton( sbSizerOffset->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_VERTICAL ); fgSizerOffset->Add( m_spinYoffset, 0, wxALIGN_CENTER_VERTICAL, 5 ); - + m_staticText32 = new wxStaticText( sbSizerOffset->GetStaticBox(), wxID_ANY, _("Z:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText32->Wrap( -1 ); fgSizerOffset->Add( m_staticText32, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 ); - + zoff = new wxTextCtrl( sbSizerOffset->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerOffset->Add( zoff, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 ); - + m_spinZoffset = new wxSpinButton( sbSizerOffset->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_VERTICAL ); fgSizerOffset->Add( m_spinZoffset, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 ); - - + + sbSizerOffset->Add( fgSizerOffset, 0, wxEXPAND|wxLEFT|wxRIGHT, 10 ); - - - bSizerLeft->Add( sbSizerOffset, 0, wxEXPAND|wxALL, 5 ); - - + + + bSizerLeft->Add( sbSizerOffset, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + + wxStaticBoxSizer* sbSizer4; + sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Opacity") ), wxVERTICAL ); + + m_opacity = new wxSlider( sbSizer4->GetStaticBox(), wxID_ANY, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS ); + sbSizer4->Add( m_opacity, 0, wxEXPAND, 5 ); + + + bSizerLeft->Add( sbSizer4, 1, wxEXPAND|wxALL, 5 ); + + bSizermain->Add( bSizerLeft, 0, 0, 5 ); - + wxBoxSizer* bSizerRight; bSizerRight = new wxBoxSizer( wxVERTICAL ); - + wxStaticText* staticPreviewLabel; staticPreviewLabel = new wxStaticText( this, wxID_ANY, _("Preview"), wxDefaultPosition, wxDefaultSize, 0 ); staticPreviewLabel->Wrap( -1 ); staticPreviewLabel->SetFont( wxFont( 11, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) ); - + bSizerRight->Add( staticPreviewLabel, 0, wxLEFT, 15 ); - + m_SizerPanelView = new wxBoxSizer( wxVERTICAL ); - - + + bSizerRight->Add( m_SizerPanelView, 1, wxEXPAND|wxBOTTOM, 8 ); - - + + bSizermain->Add( bSizerRight, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 4 ); - + wxBoxSizer* bSizer3DButtons; bSizer3DButtons = new wxBoxSizer( wxVERTICAL ); - - + + bSizer3DButtons->Add( 0, 0, 0, wxEXPAND|wxTOP, 4 ); - - m_bpvISO = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); + + m_bpvISO = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW|0 ); m_bpvISO->SetToolTip( _("Change to isometric perspective") ); - + bSizer3DButtons->Add( m_bpvISO, 0, wxTOP|wxBOTTOM, 5 ); - - m_bpvLeft = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); + + + bSizer3DButtons->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_bpvLeft = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW|0 ); bSizer3DButtons->Add( m_bpvLeft, 0, 0, 5 ); - - m_bpvRight = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); + + m_bpvRight = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW|0 ); bSizer3DButtons->Add( m_bpvRight, 0, 0, 5 ); - - m_bpvFront = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); + + m_bpvFront = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW|0 ); bSizer3DButtons->Add( m_bpvFront, 0, 0, 5 ); - - m_bpvBack = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); + + m_bpvBack = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW|0 ); bSizer3DButtons->Add( m_bpvBack, 0, 0, 5 ); - - m_bpvTop = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); + + m_bpvTop = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW|0 ); bSizer3DButtons->Add( m_bpvTop, 0, 0, 5 ); - - m_bpvBottom = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); + + m_bpvBottom = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW|0 ); bSizer3DButtons->Add( m_bpvBottom, 0, 0, 5 ); - - m_bpUpdate = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); + + + bSizer3DButtons->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_bpUpdate = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW|0 ); m_bpUpdate->SetToolTip( _("Reload board and 3D models") ); - + bSizer3DButtons->Add( m_bpUpdate, 0, wxTOP, 5 ); - - + + bSizermain->Add( bSizer3DButtons, 0, wxALL|wxEXPAND, 5 ); - - + + this->SetSizer( bSizermain ); this->Layout(); bSizermain->Fit( this ); - + // Connect Events xscale->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PANEL_PREV_3D_BASE::onMouseWheelScale ), NULL, this ); xscale->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_PREV_3D_BASE::updateOrientation ), NULL, this ); @@ -249,6 +264,7 @@ PANEL_PREV_3D_BASE::PANEL_PREV_3D_BASE( wxWindow* parent, wxWindowID id, const w zoff->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_PREV_3D_BASE::updateOrientation ), NULL, this ); m_spinZoffset->Connect( wxEVT_SCROLL_LINEDOWN, wxSpinEventHandler( PANEL_PREV_3D_BASE::onDecrementOffset ), NULL, this ); m_spinZoffset->Connect( wxEVT_SCROLL_LINEUP, wxSpinEventHandler( PANEL_PREV_3D_BASE::onIncrementOffset ), NULL, this ); + m_opacity->Connect( wxEVT_SLIDER, wxCommandEventHandler( PANEL_PREV_3D_BASE::onOpacitySlider ), NULL, this ); m_bpvISO->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DISO ), NULL, this ); m_bpvLeft->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DLeft ), NULL, this ); m_bpvRight->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DRight ), NULL, this ); @@ -298,6 +314,7 @@ PANEL_PREV_3D_BASE::~PANEL_PREV_3D_BASE() zoff->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_PREV_3D_BASE::updateOrientation ), NULL, this ); m_spinZoffset->Disconnect( wxEVT_SCROLL_LINEDOWN, wxSpinEventHandler( PANEL_PREV_3D_BASE::onDecrementOffset ), NULL, this ); m_spinZoffset->Disconnect( wxEVT_SCROLL_LINEUP, wxSpinEventHandler( PANEL_PREV_3D_BASE::onIncrementOffset ), NULL, this ); + m_opacity->Disconnect( wxEVT_SLIDER, wxCommandEventHandler( PANEL_PREV_3D_BASE::onOpacitySlider ), NULL, this ); m_bpvISO->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DISO ), NULL, this ); m_bpvLeft->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DLeft ), NULL, this ); m_bpvRight->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DRight ), NULL, this ); @@ -306,5 +323,5 @@ PANEL_PREV_3D_BASE::~PANEL_PREV_3D_BASE() m_bpvTop->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DTop ), NULL, this ); m_bpvBottom->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DBottom ), NULL, this ); m_bpUpdate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DUpdate ), NULL, this ); - + } diff --git a/3d-viewer/3d_cache/dialogs/panel_prev_3d_base.fbp b/3d-viewer/3d_cache/dialogs/panel_prev_3d_base.fbp index e50c66c738..989617d9bf 100644 --- a/3d-viewer/3d_cache/dialogs/panel_prev_3d_base.fbp +++ b/3d-viewer/3d_cache/dialogs/panel_prev_3d_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -49,36 +49,6 @@ wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bSizermain @@ -105,7 +75,6 @@ wxVERTICAL 1 none - 10 wxEXPAND|wxRIGHT|wxLEFT @@ -155,6 +124,7 @@ 0 wxID_ANY X: + 0 0 @@ -180,29 +150,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -267,33 +214,8 @@ - - - - - - - - - - - - - - - onMouseWheelScale - - - - - - updateOrientation - - - - @@ -352,32 +274,8 @@ - - - - - - - - - - - - - - - - - - - - - - - onDecrementScale onIncrementScale - @@ -413,6 +311,7 @@ 0 wxID_ANY Y: + 0 0 @@ -438,29 +337,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -525,33 +401,8 @@ - - - - - - - - - - - - - - - onMouseWheelScale - - - - - - updateOrientation - - - - @@ -610,32 +461,8 @@ - - - - - - - - - - - - - - - - - - - - - - - onDecrementScale onIncrementScale - @@ -671,6 +498,7 @@ 0 wxID_ANY Z: + 0 0 @@ -696,29 +524,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -783,33 +588,8 @@ - - - - - - - - - - - - - - - onMouseWheelScale - - - - - - updateOrientation - - - - @@ -868,32 +648,8 @@ - - - - - - - - - - - - - - - - - - - - - - - onDecrementScale onIncrementScale - @@ -912,7 +668,6 @@ wxVERTICAL 1 none - 10 wxEXPAND|wxRIGHT|wxLEFT @@ -962,6 +717,7 @@ 0 wxID_ANY X: + 0 0 @@ -987,29 +743,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -1074,33 +807,8 @@ - - - - - - - - - - - - - - - onMouseWheelRot - - - - - - updateOrientation - - - - @@ -1159,32 +867,8 @@ - - - - - - - - - - - - - - - - - - - - - - - onDecrementRot onIncrementRot - @@ -1220,6 +904,7 @@ 0 wxID_ANY Y: + 0 0 @@ -1245,29 +930,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -1332,33 +994,8 @@ - - - - - - - - - - - - - - - onMouseWheelRot - - - - - - updateOrientation - - - - @@ -1417,32 +1054,8 @@ - - - - - - - - - - - - - - - - - - - - - - - onDecrementRot onIncrementRot - @@ -1478,6 +1091,7 @@ 0 wxID_ANY Z: + 0 0 @@ -1503,29 +1117,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -1590,33 +1181,8 @@ - - - - - - - - - - - - - - - onMouseWheelRot - - - - - - updateOrientation - - - - @@ -1675,32 +1241,8 @@ - - - - - - - - - - - - - - - - - - - - - - - onDecrementRot onIncrementRot - @@ -1709,7 +1251,7 @@ 5 - wxEXPAND|wxALL + wxEXPAND|wxTOP|wxRIGHT|wxLEFT 0 wxID_ANY @@ -1719,7 +1261,6 @@ wxVERTICAL 1 none - 10 wxEXPAND|wxLEFT|wxRIGHT @@ -1769,6 +1310,7 @@ 0 wxID_ANY X: + 0 0 @@ -1794,29 +1336,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -1881,33 +1400,8 @@ - - - - - - - - - - - - - - - onMouseWheelOffset - - - - - - updateOrientation - - - - @@ -1966,32 +1460,8 @@ - - - - - - - - - - - - - - - - - - - - - - - onDecrementOffset onIncrementOffset - @@ -2027,6 +1497,7 @@ 0 wxID_ANY Y: + 0 0 @@ -2052,29 +1523,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -2139,33 +1587,8 @@ - - - - - - - - - - - - - - - onMouseWheelOffset - - - - - - updateOrientation - - - - @@ -2224,32 +1647,8 @@ - - - - - - - - - - - - - - - - - - - - - - - onDecrementOffset onIncrementOffset - @@ -2285,6 +1684,7 @@ 0 wxID_ANY Z: + 0 0 @@ -2310,29 +1710,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -2397,33 +1774,8 @@ - - - - - - - - - - - - - - - onMouseWheelOffset - - - - - - updateOrientation - - - - @@ -2482,38 +1834,94 @@ - - - - - - - - - - - - - - - - - - - - - - - onDecrementOffset onIncrementOffset - + + 5 + wxEXPAND|wxALL + 1 + + wxID_ANY + Opacity + + sbSizer4 + wxVERTICAL + 1 + none + + 5 + wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + 100 + + 0 + + 0 + + 0 + + 1 + m_opacity + 1 + + + protected + 1 + + Resizable + 1 + + wxSL_HORIZONTAL|wxSL_LABELS + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 50 + + + + onOpacitySlider + + + + @@ -2558,6 +1966,7 @@ 0 wxID_ANY Preview + 0 0 @@ -2583,29 +1992,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -2662,6 +2048,7 @@ 1 1 + 0 0 @@ -2675,9 +2062,10 @@ 0 0 - wxID_ANY MyButton + + 0 0 @@ -2692,11 +2080,12 @@ protected 1 + + Resizable - 1 40,40 - wxBU_AUTODRAW + 0 Change to isometric perspective @@ -2708,29 +2097,16 @@ View3DISO - - - - - - - - - - - - - - - - - - - - - - - + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 @@ -2755,6 +2131,7 @@ 1 1 + 0 0 @@ -2768,9 +2145,10 @@ 0 0 - wxID_ANY MyButton + + 0 0 @@ -2785,11 +2163,12 @@ protected 1 + + Resizable - 1 40,40 - wxBU_AUTODRAW + 0 @@ -2801,29 +2180,6 @@ View3DLeft - - - - - - - - - - - - - - - - - - - - - - - @@ -2848,6 +2204,7 @@ 1 1 + 0 0 @@ -2861,9 +2218,10 @@ 0 0 - wxID_ANY MyButton + + 0 0 @@ -2878,11 +2236,12 @@ protected 1 + + Resizable - 1 40,40 - wxBU_AUTODRAW + 0 @@ -2894,29 +2253,6 @@ View3DRight - - - - - - - - - - - - - - - - - - - - - - - @@ -2941,6 +2277,7 @@ 1 1 + 0 0 @@ -2954,9 +2291,10 @@ 0 0 - wxID_ANY MyButton + + 0 0 @@ -2971,11 +2309,12 @@ protected 1 + + Resizable - 1 40,40 - wxBU_AUTODRAW + 0 @@ -2987,29 +2326,6 @@ View3DFront - - - - - - - - - - - - - - - - - - - - - - - @@ -3034,6 +2350,7 @@ 1 1 + 0 0 @@ -3047,9 +2364,10 @@ 0 0 - wxID_ANY MyButton + + 0 0 @@ -3064,11 +2382,12 @@ protected 1 + + Resizable - 1 40,40 - wxBU_AUTODRAW + 0 @@ -3080,29 +2399,6 @@ View3DBack - - - - - - - - - - - - - - - - - - - - - - - @@ -3127,6 +2423,7 @@ 1 1 + 0 0 @@ -3140,9 +2437,10 @@ 0 0 - wxID_ANY MyButton + + 0 0 @@ -3157,11 +2455,12 @@ protected 1 + + Resizable - 1 40,40 - wxBU_AUTODRAW + 0 @@ -3173,29 +2472,6 @@ View3DTop - - - - - - - - - - - - - - - - - - - - - - - @@ -3220,6 +2496,7 @@ 1 1 + 0 0 @@ -3233,9 +2510,10 @@ 0 0 - wxID_ANY MyButton + + 0 0 @@ -3250,11 +2528,12 @@ protected 1 + + Resizable - 1 40,40 - wxBU_AUTODRAW + 0 @@ -3266,29 +2545,16 @@ View3DBottom - - - - - - - - - - - - - - - - - - - - - - - + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 @@ -3313,6 +2579,7 @@ 1 1 + 0 0 @@ -3326,9 +2593,10 @@ 0 0 - wxID_ANY MyButton + + 0 0 @@ -3343,11 +2611,12 @@ protected 1 + + Resizable - 1 40,40 - wxBU_AUTODRAW + 0 Reload board and 3D models @@ -3359,29 +2628,6 @@ View3DUpdate - - - - - - - - - - - - - - - - - - - - - - - diff --git a/3d-viewer/3d_cache/dialogs/panel_prev_3d_base.h b/3d-viewer/3d_cache/dialogs/panel_prev_3d_base.h index ceca33b4c0..338a147f75 100644 --- a/3d-viewer/3d_cache/dialogs/panel_prev_3d_base.h +++ b/3d-viewer/3d_cache/dialogs/panel_prev_3d_base.h @@ -1,12 +1,11 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2018) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __PANEL_PREV_3D_BASE_H__ -#define __PANEL_PREV_3D_BASE_H__ +#pragma once #include #include @@ -21,10 +20,11 @@ #include #include #include +#include +#include #include #include #include -#include #include #include @@ -34,10 +34,10 @@ /////////////////////////////////////////////////////////////////////////////// /// Class PANEL_PREV_3D_BASE /////////////////////////////////////////////////////////////////////////////// -class PANEL_PREV_3D_BASE : public wxPanel +class PANEL_PREV_3D_BASE : public wxPanel { private: - + protected: wxStaticText* m_staticText1; wxTextCtrl* xscale; @@ -65,6 +65,7 @@ class PANEL_PREV_3D_BASE : public wxPanel wxStaticText* m_staticText32; wxTextCtrl* zoff; wxSpinButton* m_spinZoffset; + wxSlider* m_opacity; wxBoxSizer* m_SizerPanelView; wxBitmapButton* m_bpvISO; wxBitmapButton* m_bpvLeft; @@ -74,7 +75,7 @@ class PANEL_PREV_3D_BASE : public wxPanel wxBitmapButton* m_bpvTop; wxBitmapButton* m_bpvBottom; wxBitmapButton* m_bpUpdate; - + // Virtual event handlers, overide them in your derived class virtual void onMouseWheelScale( wxMouseEvent& event ) { event.Skip(); } virtual void updateOrientation( wxCommandEvent& event ) { event.Skip(); } @@ -86,6 +87,7 @@ class PANEL_PREV_3D_BASE : public wxPanel virtual void onMouseWheelOffset( wxMouseEvent& event ) { event.Skip(); } virtual void onDecrementOffset( wxSpinEvent& event ) { event.Skip(); } virtual void onIncrementOffset( wxSpinEvent& event ) { event.Skip(); } + virtual void onOpacitySlider( wxCommandEvent& event ) { event.Skip(); } virtual void View3DISO( wxCommandEvent& event ) { event.Skip(); } virtual void View3DLeft( wxCommandEvent& event ) { event.Skip(); } virtual void View3DRight( wxCommandEvent& event ) { event.Skip(); } @@ -94,14 +96,13 @@ class PANEL_PREV_3D_BASE : public wxPanel virtual void View3DTop( wxCommandEvent& event ) { event.Skip(); } virtual void View3DBottom( wxCommandEvent& event ) { event.Skip(); } virtual void View3DUpdate( wxCommandEvent& event ) { event.Skip(); } - - + + public: wxTextCtrl* yoff; - - PANEL_PREV_3D_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL ); + + PANEL_PREV_3D_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); ~PANEL_PREV_3D_BASE(); - + }; -#endif //__PANEL_PREV_3D_BASE_H__ diff --git a/common/pcb.keywords b/common/pcb.keywords index d18e0c330d..251119018d 100644 --- a/common/pcb.keywords +++ b/common/pcb.keywords @@ -153,6 +153,7 @@ none not_allowed np_thru_hole offset +opacity options other_layers_line_width other_layers_text_dims diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index bb117237b5..4b98918739 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -85,6 +85,7 @@ class MODULE_3D_SETTINGS m_Scale { 1, 1, 1 }, m_Rotation { 0, 0, 0 }, m_Offset { 0, 0, 0 }, + m_Opacity( 1.0 ), m_Show( true ) { } @@ -97,6 +98,7 @@ class MODULE_3D_SETTINGS VECTOR3D m_Scale; ///< 3D model scaling factor (dimensionless) VECTOR3D m_Rotation; ///< 3D model rotation (degrees) VECTOR3D m_Offset; ///< 3D model offset (mm) + double m_Opacity; wxString m_Filename; ///< The 3D shape filename in 3D library bool m_Show; ///< Include module in rendering }; diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 41096768cc..7d81099c19 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -1160,6 +1160,9 @@ void PCB_IO::format( MODULE* aModule, int aNestLevel ) const m_out->Quotew( bs3D->m_Filename ).c_str(), bs3D->m_Show ? "" : " hide" ); + if( bs3D->m_Opacity != 1.0 ) + m_out->Print( aNestLevel+2, "(opacity %0.4f)", bs3D->m_Opacity ); + /* Write 3D model offset in mm * 4.0.x wrote "at" which was actually in inches * 5.0.x onwards, 3D model offset is written using "offset" diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index 0e911a69bc..fc9ef3beb9 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -415,6 +415,11 @@ MODULE_3D_SETTINGS* PCB_PARSER::parse3DModel() n3D->m_Show = false; break; + case T_opacity: + n3D->m_Opacity = parseDouble( "opacity value" ); + NeedRIGHT(); + break; + case T_offset: NeedLEFT(); token = NextTok(); @@ -464,7 +469,7 @@ MODULE_3D_SETTINGS* PCB_PARSER::parse3DModel() break; default: - Expecting( "at, hide, offset, scale, or rotate" ); + Expecting( "at, hide, opacity, offset, scale, or rotate" ); } }