From 5134856f18fd76b9a6433eaa86fca1bf1ff59412 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 26 Mar 2020 14:05:20 +0000 Subject: [PATCH] Rationalise 3D settings data-structure. Move the camera out to its own so that everything else is board- related, and then rename BOARD_ADAPTER. At some point the flags should probably be moved out too, and they can have the EDA_3D_SETTINGS name. --- 3d-viewer/3d_cache/dialogs/panel_prev_3d.cpp | 14 +- 3d-viewer/3d_cache/dialogs/panel_prev_3d.h | 15 +- .../{3d_settings.cpp => board_adapter.cpp} | 49 ++- .../{3d_settings.h => board_adapter.h} | 57 +--- .../3d_canvas/create_3Dgraphic_brd_items.cpp | 91 +++--- 3d-viewer/3d_canvas/create_layer_items.cpp | 8 +- 3d-viewer/3d_canvas/create_layer_poly.cpp | 28 +- 3d-viewer/3d_canvas/eda_3d_canvas.cpp | 206 ++++++------ 3d-viewer/3d_canvas/eda_3d_canvas.h | 13 +- 3d-viewer/3d_canvas/eda_3d_canvas_pivot.cpp | 6 +- .../c3d_render_createscene_ogl_legacy.cpp | 136 ++++---- .../c3d_render_ogl_legacy.cpp | 206 ++++++------ .../c3d_render_ogl_legacy.h | 12 +- .../c3d_render_createscene.cpp | 309 +++++++++--------- .../c3d_render_raytracing.cpp | 103 +++--- .../c3d_render_raytracing.h | 2 +- 3d-viewer/3d_rendering/c3d_render_base.cpp | 5 +- 3d-viewer/3d_rendering/c3d_render_base.h | 8 +- 3d-viewer/3d_viewer/3d_menubar.cpp | 38 +-- 3d-viewer/3d_viewer/3d_toolbar.cpp | 2 +- .../dialogs/dialog_3D_view_option.cpp | 14 +- 3d-viewer/3d_viewer/eda_3d_viewer.cpp | 133 ++++---- 3d-viewer/3d_viewer/eda_3d_viewer.h | 19 +- 3d-viewer/3d_viewer/tools/3d_controller.cpp | 30 +- 3d-viewer/3d_viewer/tools/3d_controller.h | 14 +- 3d-viewer/CMakeLists.txt | 2 +- eeschema/sch_painter.h | 2 +- eeschema/sim/sim_plot_frame_base.fbp | 2 +- eeschema/tools/backannotate.h | 2 +- gerbview/gerbview_painter.h | 2 +- include/painter.h | 2 +- include/tool/tool_base.h | 2 +- include/ws_painter.h | 2 +- pcbnew/pcb_painter.h | 2 +- 34 files changed, 749 insertions(+), 787 deletions(-) rename 3d-viewer/3d_canvas/{3d_settings.cpp => board_adapter.cpp} (90%) rename 3d-viewer/3d_canvas/{3d_settings.h => board_adapter.h} (95%) diff --git a/3d-viewer/3d_cache/dialogs/panel_prev_3d.cpp b/3d-viewer/3d_cache/dialogs/panel_prev_3d.cpp index 7a12e9bc81..a1bb6bfb2d 100644 --- a/3d-viewer/3d_cache/dialogs/panel_prev_3d.cpp +++ b/3d-viewer/3d_cache/dialogs/panel_prev_3d.cpp @@ -42,7 +42,11 @@ PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, PCB_BASE_FRAME* aFrame, MODULE* aModule, std::vector* aParentModelList ) : - PANEL_PREV_3D_BASE( aParent, wxID_ANY ) + PANEL_PREV_3D_BASE( aParent, wxID_ANY ), + m_previewPane( nullptr ), + m_boardAdapter(), + m_currentCamera( m_trackBallCamera ), + m_trackBallCamera( RANGE_SCALE_3D ) { m_userUnits = aFrame->GetUserUnits(); @@ -79,12 +83,9 @@ PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, PCB_BASE_FRAME* aFrame, MODULE* m_dummyModule = new MODULE( *aModule ); m_dummyBoard->Add( m_dummyModule ); - // Set 3d viewer configuration for preview - m_settings3Dviewer = new EDA_3D_SETTINGS(); - // Create the 3D canvas m_previewPane = new EDA_3D_CANVAS( this, COGL_ATT_LIST::GetAttributesList( true ), - m_dummyBoard, *m_settings3Dviewer, + m_dummyBoard, m_boardAdapter, m_currentCamera, aFrame->Prj().Get3DCacheManager() ); loadCommonSettings(); @@ -113,7 +114,6 @@ PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, PCB_BASE_FRAME* aFrame, MODULE* PANEL_PREV_3D::~PANEL_PREV_3D() { - delete m_settings3Dviewer; delete m_dummyBoard; delete m_previewPane; } @@ -137,7 +137,7 @@ void PANEL_PREV_3D::loadCommonSettings() const DPI_SCALING dpi{ settings, this }; m_previewPane->SetScaleFactor( dpi.GetScaleFactor() ); - m_settings3Dviewer->SetFlag( FL_MOUSEWHEEL_PANNING, settings->m_Input.mousewheel_pan ); + m_boardAdapter.SetFlag( FL_MOUSEWHEEL_PANNING, settings->m_Input.mousewheel_pan ); } diff --git a/3d-viewer/3d_cache/dialogs/panel_prev_3d.h b/3d-viewer/3d_cache/dialogs/panel_prev_3d.h index 2908c945c0..4f7e80fc89 100644 --- a/3d-viewer/3d_cache/dialogs/panel_prev_3d.h +++ b/3d-viewer/3d_cache/dialogs/panel_prev_3d.h @@ -42,6 +42,7 @@ #include #include <3d_canvas/eda_3d_canvas.h> #include <3d_viewer_id.h> +#include <3d_rendering/ctrack_ball.h> // Define min and max parameter values #define MAX_SCALE 10000.0 @@ -66,10 +67,10 @@ class S3D_CACHE; class FILENAME_RESOLVER; class BOARD; -class EDA_3D_SETTINGS; +class BOARD_ADAPTER; class MODULE; -class PANEL_PREV_3D: public EDA_3D_SETTINGS_HOLDER, public TOOLS_HOLDER, public PANEL_PREV_3D_BASE +class PANEL_PREV_3D: public EDA_3D_BOARD_HOLDER, public TOOLS_HOLDER, public PANEL_PREV_3D_BASE { public: PANEL_PREV_3D( wxWindow* aParent, PCB_BASE_FRAME* aFrame, MODULE* aModule, @@ -79,7 +80,9 @@ public: private: EDA_3D_CANVAS* m_previewPane; - EDA_3D_SETTINGS* m_settings3Dviewer; + BOARD_ADAPTER m_boardAdapter; + CCAMERA& m_currentCamera; + CTRACK_BALL m_trackBallCamera; BOARD* m_dummyBoard; MODULE* m_dummyModule; @@ -141,7 +144,7 @@ private: void View3DISO( wxCommandEvent& event ) override { - m_settings3Dviewer->CameraGet().ToggleProjection(); + m_currentCamera.ToggleProjection(); m_previewPane->Refresh(); } @@ -189,7 +192,9 @@ public: void OnMenuEvent( wxMenuEvent& aEvent ); wxWindow* GetToolCanvas() const override { return m_previewPane; } - EDA_3D_SETTINGS* GetSettings() override { return m_settings3Dviewer; } + + BOARD_ADAPTER& GetAdapter() override { return m_boardAdapter; } + CCAMERA& GetCurrentCamera() override { return m_currentCamera; } /** * @brief SetModelDataIdx - Sets the currently selected index in the model list so that diff --git a/3d-viewer/3d_canvas/3d_settings.cpp b/3d-viewer/3d_canvas/board_adapter.cpp similarity index 90% rename from 3d-viewer/3d_canvas/3d_settings.cpp rename to 3d-viewer/3d_canvas/board_adapter.cpp index 78e0a15274..3c89aa31fd 100644 --- a/3d-viewer/3d_canvas/3d_settings.cpp +++ b/3d-viewer/3d_canvas/board_adapter.cpp @@ -28,7 +28,7 @@ */ #include "../3d_rendering/ccamera.h" -#include "3d_settings.h" +#include "board_adapter.h" #include <3d_rendering/3d_render_raytracing/shapes2D/cpolygon2d.h> #include #include <3d_math.h> @@ -44,22 +44,17 @@ * "KI_TRACE_EDA_CINFO3D_VISU". See the wxWidgets documentation on wxLogTrace for * more information. */ -const wxChar *EDA_3D_SETTINGS::m_logTrace = wxT( "KI_TRACE_EDA_CINFO3D_VISU" ); +const wxChar *BOARD_ADAPTER::m_logTrace = wxT( "KI_TRACE_EDA_CINFO3D_VISU" ); -EDA_3D_SETTINGS G_null_EDA_3D_SETTINGS; - - -EDA_3D_SETTINGS::EDA_3D_SETTINGS() : +BOARD_ADAPTER::BOARD_ADAPTER() : m_board( nullptr ), m_3d_model_manager( nullptr ), m_colors( nullptr ), m_layerZcoordTop(), - m_layerZcoordBottom(), - m_currentCamera( m_trackBallCamera ), - m_trackBallCamera( RANGE_SCALE_3D ) + m_layerZcoordBottom() { - wxLogTrace( m_logTrace, wxT( "EDA_3D_SETTINGS::EDA_3D_SETTINGS" ) ); + wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::BOARD_ADAPTER" ) ); m_3D_grid_type = GRID3D_TYPE::NONE; m_drawFlags.resize( FL_LAST, false ); @@ -119,13 +114,13 @@ EDA_3D_SETTINGS::EDA_3D_SETTINGS() : } -EDA_3D_SETTINGS::~EDA_3D_SETTINGS() +BOARD_ADAPTER::~BOARD_ADAPTER() { destroyLayers(); } -bool EDA_3D_SETTINGS::Is3DLayerEnabled( PCB_LAYER_ID aLayer ) const +bool BOARD_ADAPTER::Is3DLayerEnabled( PCB_LAYER_ID aLayer ) const { wxASSERT( aLayer < PCB_LAYER_ID_COUNT ); @@ -208,7 +203,7 @@ bool EDA_3D_SETTINGS::Is3DLayerEnabled( PCB_LAYER_ID aLayer ) const } -bool EDA_3D_SETTINGS::GetFlag( DISPLAY3D_FLG aFlag ) const +bool BOARD_ADAPTER::GetFlag( DISPLAY3D_FLG aFlag ) const { wxASSERT( aFlag < FL_LAST ); @@ -216,14 +211,14 @@ bool EDA_3D_SETTINGS::GetFlag( DISPLAY3D_FLG aFlag ) const } -void EDA_3D_SETTINGS::SetFlag( DISPLAY3D_FLG aFlag, bool aState ) +void BOARD_ADAPTER::SetFlag( DISPLAY3D_FLG aFlag, bool aState ) { wxASSERT( aFlag < FL_LAST ); m_drawFlags[aFlag] = aState; } -bool EDA_3D_SETTINGS::ShouldModuleBeDisplayed( MODULE_ATTR_T aModuleAttributs ) const +bool BOARD_ADAPTER::ShouldModuleBeDisplayed( MODULE_ATTR_T aModuleAttributs ) const { if( ( ( aModuleAttributs == MOD_DEFAULT ) && GetFlag( FL_MODULE_ATTRIBUTES_NORMAL ) ) || @@ -243,12 +238,12 @@ bool EDA_3D_SETTINGS::ShouldModuleBeDisplayed( MODULE_ATTR_T aModuleAttributs ) #define COPPER_THICKNESS KiROUND( 0.035 * IU_PER_MM ) // for 35 um #define TECH_LAYER_THICKNESS KiROUND( 0.04 * IU_PER_MM ) -int EDA_3D_SETTINGS::GetCopperThicknessBIU() const +int BOARD_ADAPTER::GetCopperThicknessBIU() const { return COPPER_THICKNESS; } -unsigned int EDA_3D_SETTINGS::GetNrSegmentsCircle( float aDiameter3DU ) const +unsigned int BOARD_ADAPTER::GetNrSegmentsCircle( float aDiameter3DU ) const { wxASSERT( aDiameter3DU > 0.0f ); @@ -256,7 +251,7 @@ unsigned int EDA_3D_SETTINGS::GetNrSegmentsCircle( float aDiameter3DU ) const } -unsigned int EDA_3D_SETTINGS::GetNrSegmentsCircle( int aDiameterBIU ) const +unsigned int BOARD_ADAPTER::GetNrSegmentsCircle( int aDiameterBIU ) const { wxASSERT( aDiameterBIU > 0 ); @@ -265,7 +260,7 @@ unsigned int EDA_3D_SETTINGS::GetNrSegmentsCircle( int aDiameterBIU ) const } -double EDA_3D_SETTINGS::GetCircleCorrectionFactor( int aNrSides ) const +double BOARD_ADAPTER::GetCircleCorrectionFactor( int aNrSides ) const { wxASSERT( aNrSides >= 3 ); @@ -273,9 +268,9 @@ double EDA_3D_SETTINGS::GetCircleCorrectionFactor( int aNrSides ) const } -void EDA_3D_SETTINGS::InitSettings( REPORTER* aStatusTextReporter, REPORTER* aWarningTextReporter ) +void BOARD_ADAPTER::InitSettings( REPORTER* aStatusTextReporter, REPORTER* aWarningTextReporter ) { - wxLogTrace( m_logTrace, wxT( "EDA_3D_SETTINGS::InitSettings" ) ); + wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::InitSettings" ) ); // Calculates the board bounding box // First, use only the board outlines @@ -446,7 +441,7 @@ void EDA_3D_SETTINGS::InitSettings( REPORTER* aStatusTextReporter, REPORTER* aWa #ifdef PRINT_STATISTICS_3D_VIEWER unsigned stats_stopCreateLayersTime = GetRunningMicroSecs(); - printf( "EDA_3D_SETTINGS::InitSettings times\n" ); + printf( "BOARD_ADAPTER::InitSettings times\n" ); printf( " CreateBoardPoly: %.3f ms\n", (float)( stats_stopCreateBoardPolyTime - stats_startCreateBoardPolyTime ) / 1e3 ); printf( " CreateLayers and holes: %.3f ms\n", @@ -456,7 +451,7 @@ void EDA_3D_SETTINGS::InitSettings( REPORTER* aStatusTextReporter, REPORTER* aWa } -bool EDA_3D_SETTINGS::createBoardPolygon() +bool BOARD_ADAPTER::createBoardPolygon() { m_board_poly.RemoveAllContours(); @@ -466,7 +461,7 @@ bool EDA_3D_SETTINGS::createBoardPolygon() } -float EDA_3D_SETTINGS::GetModulesZcoord3DIU( bool aIsFlipped ) const +float BOARD_ADAPTER::GetModulesZcoord3DIU( bool aIsFlipped ) const { if( aIsFlipped ) { @@ -485,7 +480,7 @@ float EDA_3D_SETTINGS::GetModulesZcoord3DIU( bool aIsFlipped ) const } -SFVEC3F EDA_3D_SETTINGS::GetLayerColor( PCB_LAYER_ID aLayerId ) const +SFVEC3F BOARD_ADAPTER::GetLayerColor( PCB_LAYER_ID aLayerId ) const { wxASSERT( aLayerId < PCB_LAYER_ID_COUNT ); @@ -495,13 +490,13 @@ SFVEC3F EDA_3D_SETTINGS::GetLayerColor( PCB_LAYER_ID aLayerId ) const } -SFVEC3F EDA_3D_SETTINGS::GetItemColor( int aItemId ) const +SFVEC3F BOARD_ADAPTER::GetItemColor( int aItemId ) const { return GetColor( m_colors->GetColor( aItemId ) ); } -SFVEC3F EDA_3D_SETTINGS::GetColor( COLOR4D aColor ) const +SFVEC3F BOARD_ADAPTER::GetColor( COLOR4D aColor ) const { return SFVEC3F( aColor.r, aColor.g, aColor.b ); } diff --git a/3d-viewer/3d_canvas/3d_settings.h b/3d-viewer/3d_canvas/board_adapter.h similarity index 95% rename from 3d-viewer/3d_canvas/3d_settings.h rename to 3d-viewer/3d_canvas/board_adapter.h index a464360d5a..2fd7267ae4 100644 --- a/3d-viewer/3d_canvas/3d_settings.h +++ b/3d-viewer/3d_canvas/board_adapter.h @@ -22,8 +22,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef EDA_3D_SETTINGS_H -#define EDA_3D_SETTINGS_H +#ifndef BOARD_ADAPTER_H +#define BOARD_ADAPTER_H #include #include @@ -31,7 +31,6 @@ #include "../3d_rendering/3d_render_raytracing/accelerators/ccontainer.h" #include "../3d_rendering/3d_render_raytracing/shapes3D/cbbox.h" #include "../3d_rendering/ccamera.h" -#include "../3d_rendering/ctrack_ball.h" #include "../3d_enums.h" #include "../3d_cache/3d_cache.h" @@ -62,16 +61,16 @@ typedef std::map< PCB_LAYER_ID, SHAPE_POLY_SET *> MAP_POLY; /** - * Class EDA_3D_SETTINGS + * Class BOARD_ADAPTER * Helper class to handle information needed to display 3D board */ -class EDA_3D_SETTINGS +class BOARD_ADAPTER { public: - EDA_3D_SETTINGS(); + BOARD_ADAPTER(); - ~EDA_3D_SETTINGS(); + ~BOARD_ADAPTER(); /** * @brief Set3DCacheManager - Update the Cache manager pointer @@ -198,12 +197,6 @@ class EDA_3D_SETTINGS */ float GetModulesZcoord3DIU( bool aIsFlipped ) const ; - /** - * @brief CameraGet - get current camera in use - * @return a camera - */ - CCAMERA &CameraGet() const { return m_currentCamera; } - /** * @brief GridGet - get the current grid * @return space type of the grid @@ -517,27 +510,15 @@ public: private: - /// Current board - BOARD *m_board; - - /// pointer to the 3d model manager - S3D_CACHE *m_3d_model_manager; - - /// pointer to current color settings - COLOR_SETTINGS* m_colors; + BOARD* m_board; + S3D_CACHE* m_3d_model_manager; + COLOR_SETTINGS* m_colors; // Render options - /// options flags to render the board std::vector< bool > m_drawFlags; - - /// Stores the current grid type GRID3D_TYPE m_3D_grid_type; - - /// render engine currently on use RENDER_ENGINE m_render_engine; - - /// mode to render the 3d shape models material MATERIAL_MODE m_material_mode; @@ -556,7 +537,7 @@ private: // Pcb board bounding boxes /// 3d bounding box of the pcb board in 3d units - CBBOX m_boardBoundingBox; + CBBOX m_boardBoundingBox; /// It contains polygon contours for each layer MAP_POLY m_layers_poly; @@ -635,13 +616,6 @@ private: /// Non copper layers thickness float m_nonCopperLayerThickness3DU; - - // Cameras - - /// Holds a pointer to current camera in use. - CCAMERA &m_currentCamera; - CTRACK_BALL m_trackBallCamera; - /// min factor used for cicle segment approximation calculation float m_calc_seg_min_factor3DU; @@ -680,14 +654,11 @@ private: }; -/// This is a dummy visualization configuration -extern EDA_3D_SETTINGS G_null_EDA_3D_SETTINGS; - - -class EDA_3D_SETTINGS_HOLDER +class EDA_3D_BOARD_HOLDER { public: - virtual EDA_3D_SETTINGS* GetSettings() = 0; + virtual BOARD_ADAPTER& GetAdapter() = 0; + virtual CCAMERA& GetCurrentCamera() = 0; }; -#endif // EDA_3D_SETTINGS_H +#endif // BOARD_ADAPTER_H diff --git a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp index e897307baf..c1d2357f08 100644 --- a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp +++ b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp @@ -30,17 +30,12 @@ * board_items_to_polygon_shape_transform.cpp */ -#include "3d_settings.h" #include "../3d_rendering/3d_render_raytracing/shapes2D/cring2d.h" #include "../3d_rendering/3d_render_raytracing/shapes2D/cfilledcircle2d.h" #include "../3d_rendering/3d_render_raytracing/shapes2D/croundsegment2d.h" #include "../3d_rendering/3d_render_raytracing/shapes2D/cpolygon4pts2d.h" -#include "../3d_rendering/3d_render_raytracing/shapes2D/cpolygon2d.h" #include "../3d_rendering/3d_render_raytracing/shapes2D/ctriangle2d.h" -#include "../3d_rendering/3d_render_raytracing/accelerators/ccontainer2d.h" -#include "../3d_rendering/3d_render_raytracing/shapes3D/ccylinder.h" -#include "../3d_rendering/3d_render_raytracing/shapes3D/clayeritem.h" - +#include #include #include #include @@ -87,10 +82,10 @@ void addTextSegmToContainer( int x0, int y0, int xf, int yf, void* aData ) // Based on // void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet // board_items_to_polygon_shape_transform.cpp -void EDA_3D_SETTINGS::AddShapeWithClearanceToContainer( const TEXTE_PCB* aText, - CGENERICCONTAINER2D *aDstContainer, - PCB_LAYER_ID aLayerId, - int aClearanceValue ) +void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const TEXTE_PCB* aText, + CGENERICCONTAINER2D *aDstContainer, + PCB_LAYER_ID aLayerId, + int aClearanceValue ) { wxSize size = aText->GetTextSize(); @@ -131,10 +126,10 @@ void EDA_3D_SETTINGS::AddShapeWithClearanceToContainer( const TEXTE_PCB* aText, } -void EDA_3D_SETTINGS::AddShapeWithClearanceToContainer( const DIMENSION* aDimension, - CGENERICCONTAINER2D *aDstContainer, - PCB_LAYER_ID aLayerId, - int aClearanceValue ) +void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const DIMENSION* aDimension, + CGENERICCONTAINER2D *aDstContainer, + PCB_LAYER_ID aLayerId, + int aClearanceValue ) { AddShapeWithClearanceToContainer(&aDimension->Text(), aDstContainer, aLayerId, aClearanceValue); @@ -168,10 +163,10 @@ void EDA_3D_SETTINGS::AddShapeWithClearanceToContainer( const DIMENSION* aDimens // Based on // void MODULE::TransformGraphicShapesWithClearanceToPolygonSet // board_items_to_polygon_shape_transform.cpp#L204 -void EDA_3D_SETTINGS::AddGraphicsShapesWithClearanceToContainer( const MODULE* aModule, - CGENERICCONTAINER2D *aDstContainer, - PCB_LAYER_ID aLayerId, - int aInflateValue ) +void BOARD_ADAPTER::AddGraphicsShapesWithClearanceToContainer( const MODULE* aModule, + CGENERICCONTAINER2D *aDstContainer, + PCB_LAYER_ID aLayerId, + int aInflateValue ) { std::vector texts; // List of TEXTE_MODULE to convert EDGE_MODULE* outline; @@ -234,8 +229,8 @@ void EDA_3D_SETTINGS::AddGraphicsShapesWithClearanceToContainer( const MODULE* a } -COBJECT2D *EDA_3D_SETTINGS::createNewTrack( const TRACK* aTrack, - int aClearanceValue ) const +COBJECT2D *BOARD_ADAPTER::createNewTrack( const TRACK* aTrack, + int aClearanceValue ) const { SFVEC2F start3DU( aTrack->GetStart().x * m_biuTo3Dunits, -aTrack->GetStart().y * m_biuTo3Dunits ); // y coord is inverted @@ -281,9 +276,9 @@ COBJECT2D *EDA_3D_SETTINGS::createNewTrack( const TRACK* aTrack, // Based on: // void D_PAD:: TransformShapeWithClearanceToPolygon( // board_items_to_polygon_shape_transform.cpp -void EDA_3D_SETTINGS::createNewPadWithClearance( const D_PAD* aPad, - CGENERICCONTAINER2D *aDstContainer, - wxSize aClearanceValue ) const +void BOARD_ADAPTER::createNewPadWithClearance( const D_PAD* aPad, + CGENERICCONTAINER2D *aDstContainer, + wxSize aClearanceValue ) const { // note: for most of shapes, aClearanceValue.x = aClearanceValue.y // only rectangular and oval shapes can have different values @@ -295,7 +290,7 @@ void EDA_3D_SETTINGS::createNewPadWithClearance( const D_PAD* aPad, if( !dx || !dy ) { wxLogTrace( m_logTrace, - wxT( "EDA_3D_SETTINGS::createNewPadWithClearance - found an invalid pad" ) ); + wxT( "BOARD_ADAPTER::createNewPadWithClearance - found an invalid pad" ) ); return; } @@ -533,13 +528,13 @@ void EDA_3D_SETTINGS::createNewPadWithClearance( const D_PAD* aPad, // Based on: // BuildPadDrillShapePolygon // board_items_to_polygon_shape_transform.cpp -COBJECT2D *EDA_3D_SETTINGS::createNewPadDrill( const D_PAD* aPad, int aInflateValue ) +COBJECT2D *BOARD_ADAPTER::createNewPadDrill( const D_PAD* aPad, int aInflateValue ) { wxSize drillSize = aPad->GetDrillSize(); if( !drillSize.x || !drillSize.y ) { - wxLogTrace( m_logTrace, wxT( "EDA_3D_SETTINGS::createNewPadDrill - found an invalid pad" ) ); + wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::createNewPadDrill - found an invalid pad" ) ); return NULL; } @@ -584,11 +579,11 @@ COBJECT2D *EDA_3D_SETTINGS::createNewPadDrill( const D_PAD* aPad, int aInflateVa } -void EDA_3D_SETTINGS::AddPadsShapesWithClearanceToContainer( const MODULE* aModule, - CGENERICCONTAINER2D *aDstContainer, - PCB_LAYER_ID aLayerId, - int aInflateValue, - bool aSkipNPTHPadsWihNoCopper ) +void BOARD_ADAPTER::AddPadsShapesWithClearanceToContainer( const MODULE* aModule, + CGENERICCONTAINER2D *aDstContainer, + PCB_LAYER_ID aLayerId, + int aInflateValue, + bool aSkipNPTHPadsWihNoCopper ) { wxSize margin; @@ -647,13 +642,13 @@ void EDA_3D_SETTINGS::AddPadsShapesWithClearanceToContainer( const MODULE* aModu // based on TransformArcToPolygon function from // common/convert_basic_shapes_to_polygon.cpp -void EDA_3D_SETTINGS::TransformArcToSegments( const wxPoint &aCentre, - const wxPoint &aStart, - double aArcAngle, - int aCircleToSegmentsCount, - int aWidth, - CGENERICCONTAINER2D *aDstContainer, - const BOARD_ITEM &aBoardItem ) +void BOARD_ADAPTER::TransformArcToSegments( const wxPoint &aCentre, + const wxPoint &aStart, + double aArcAngle, + int aCircleToSegmentsCount, + int aWidth, + CGENERICCONTAINER2D *aDstContainer, + const BOARD_ITEM &aBoardItem ) { wxPoint arc_start, arc_end; int delta = 3600 / aCircleToSegmentsCount; // rotate angle in 0.1 degree @@ -724,10 +719,10 @@ void EDA_3D_SETTINGS::TransformArcToSegments( const wxPoint &aCentre, // Based on // TransformShapeWithClearanceToPolygon // board_items_to_polygon_shape_transform.cpp#L431 -void EDA_3D_SETTINGS::AddShapeWithClearanceToContainer( const DRAWSEGMENT* aDrawSegment, - CGENERICCONTAINER2D *aDstContainer, - PCB_LAYER_ID aLayerId, - int aClearanceValue ) +void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const DRAWSEGMENT* aDrawSegment, + CGENERICCONTAINER2D *aDstContainer, + PCB_LAYER_ID aLayerId, + int aClearanceValue ) { // The full width of the lines to create // The extra 1 protects the inner/outer radius values from degeneracy @@ -815,9 +810,9 @@ void EDA_3D_SETTINGS::AddShapeWithClearanceToContainer( const DRAWSEGMENT* aDraw // Based on // TransformSolidAreasShapesToPolygonSet // board_items_to_polygon_shape_transform.cpp -void EDA_3D_SETTINGS::AddSolidAreasShapesToContainer( const ZONE_CONTAINER* aZoneContainer, - CGENERICCONTAINER2D *aDstContainer, - PCB_LAYER_ID aLayerId ) +void BOARD_ADAPTER::AddSolidAreasShapesToContainer( const ZONE_CONTAINER* aZoneContainer, + CGENERICCONTAINER2D *aDstContainer, + PCB_LAYER_ID aLayerId ) { // Copy the polys list because we have to simplify it SHAPE_POLY_SET polyList = SHAPE_POLY_SET( aZoneContainer->GetFilledPolysList(), true ); @@ -896,9 +891,9 @@ void EDA_3D_SETTINGS::AddSolidAreasShapesToContainer( const ZONE_CONTAINER* aZon -void EDA_3D_SETTINGS::buildPadShapeThickOutlineAsSegments( const D_PAD* aPad, - CGENERICCONTAINER2D *aDstContainer, - int aWidth ) +void BOARD_ADAPTER::buildPadShapeThickOutlineAsSegments( const D_PAD* aPad, + CGENERICCONTAINER2D *aDstContainer, + int aWidth ) { if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // Draw a ring { diff --git a/3d-viewer/3d_canvas/create_layer_items.cpp b/3d-viewer/3d_canvas/create_layer_items.cpp index fa4dd59d9a..2cca8ab56e 100644 --- a/3d-viewer/3d_canvas/create_layer_items.cpp +++ b/3d-viewer/3d_canvas/create_layer_items.cpp @@ -30,7 +30,7 @@ * board_items_to_polygon_shape_transform.cpp */ -#include "3d_settings.h" +#include "board_adapter.h" #include "../3d_rendering/3d_render_raytracing/shapes2D/cring2d.h" #include "../3d_rendering/3d_render_raytracing/shapes2D/cfilledcircle2d.h" #include "../3d_rendering/3d_render_raytracing/shapes2D/croundsegment2d.h" @@ -58,7 +58,7 @@ #include -void EDA_3D_SETTINGS::destroyLayers() +void BOARD_ADAPTER::destroyLayers() { if( !m_layers_poly.empty() ) { @@ -113,7 +113,7 @@ void EDA_3D_SETTINGS::destroyLayers() } -void EDA_3D_SETTINGS::createLayers( REPORTER *aStatusTextReporter ) +void BOARD_ADAPTER::createLayers( REPORTER *aStatusTextReporter ) { destroyLayers(); @@ -1059,7 +1059,7 @@ void EDA_3D_SETTINGS::createLayers( REPORTER *aStatusTextReporter ) #ifdef PRINT_STATISTICS_3D_VIEWER unsigned stats_endHolesBVHTime = GetRunningMicroSecs(); - printf( "EDA_3D_SETTINGS::createLayers times\n" ); + printf( "BOARD_ADAPTER::createLayers times\n" ); printf( " Copper Layers: %.3f ms\n", (float)( stats_endCopperLayersTime - stats_startCopperLayersTime ) / 1e3 ); printf( " Holes BVH creation: %.3f ms\n", diff --git a/3d-viewer/3d_canvas/create_layer_poly.cpp b/3d-viewer/3d_canvas/create_layer_poly.cpp index 59a5c75bc2..e3e6c6f5ef 100644 --- a/3d-viewer/3d_canvas/create_layer_poly.cpp +++ b/3d-viewer/3d_canvas/create_layer_poly.cpp @@ -30,7 +30,7 @@ * board_items_to_polygon_shape_transform.cpp */ -#include "3d_settings.h" +#include "board_adapter.h" #include #include #include @@ -38,9 +38,9 @@ // This is the same function as in board_items_to_polygon_shape_transform.cpp // but it adds the rect/trapezoid shapes with a different winding -void EDA_3D_SETTINGS::buildPadShapePolygon( const D_PAD* aPad, - SHAPE_POLY_SET& aCornerBuffer, - wxSize aInflateValue ) const +void BOARD_ADAPTER::buildPadShapePolygon( const D_PAD* aPad, + SHAPE_POLY_SET& aCornerBuffer, + wxSize aInflateValue ) const { wxPoint PadShapePos = aPad->ShapePos(); /* Note: for pad having a shape offset, * the pad position is NOT the shape position */ @@ -105,9 +105,9 @@ void EDA_3D_SETTINGS::buildPadShapePolygon( const D_PAD* aPad, } -void EDA_3D_SETTINGS::buildPadShapeThickOutlineAsPolygon( const D_PAD* aPad, - SHAPE_POLY_SET& aCornerBuffer, - int aWidth ) const +void BOARD_ADAPTER::buildPadShapeThickOutlineAsPolygon( const D_PAD* aPad, + SHAPE_POLY_SET& aCornerBuffer, + int aWidth ) const { if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // Draw a ring { @@ -139,10 +139,10 @@ void EDA_3D_SETTINGS::buildPadShapeThickOutlineAsPolygon( const D_PAD* aPad, // Based on the same function name in board_items_to_polyshape_transform.cpp // It was implemented here to allow dynamic segments count per pad shape -void EDA_3D_SETTINGS::transformPadsShapesWithClearanceToPolygon( const PADS& aPads, PCB_LAYER_ID aLayer, - SHAPE_POLY_SET& aCornerBuffer, - int aInflateValue, - bool aSkipNPTHPadsWihNoCopper ) const +void BOARD_ADAPTER::transformPadsShapesWithClearanceToPolygon( const PADS& aPads, PCB_LAYER_ID aLayer, + SHAPE_POLY_SET& aCornerBuffer, + int aInflateValue, + bool aSkipNPTHPadsWihNoCopper ) const { wxSize margin; for( auto pad : aPads ) @@ -198,9 +198,9 @@ void EDA_3D_SETTINGS::transformPadsShapesWithClearanceToPolygon( const PADS& aPa } } -void EDA_3D_SETTINGS::transformGraphicModuleEdgeToPolygonSet( const MODULE *aModule, - PCB_LAYER_ID aLayer, - SHAPE_POLY_SET& aCornerBuffer ) const +void BOARD_ADAPTER::transformGraphicModuleEdgeToPolygonSet( const MODULE *aModule, + PCB_LAYER_ID aLayer, + SHAPE_POLY_SET& aCornerBuffer ) const { for( auto item : aModule->GraphicalItems() ) { diff --git a/3d-viewer/3d_canvas/eda_3d_canvas.cpp b/3d-viewer/3d_canvas/eda_3d_canvas.cpp index 396d8f4c45..ad1c9e7ffa 100644 --- a/3d-viewer/3d_canvas/eda_3d_canvas.cpp +++ b/3d-viewer/3d_canvas/eda_3d_canvas.cpp @@ -84,14 +84,16 @@ BEGIN_EVENT_TABLE( EDA_3D_CANVAS, wxGLCanvas ) END_EVENT_TABLE() -EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow *aParent, const int *aAttribList, BOARD *aBoard, - EDA_3D_SETTINGS &aSettings , S3D_CACHE *a3DCachePointer ) : +EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow* aParent, const int* aAttribList, BOARD* aBoard, + BOARD_ADAPTER& aBoardAdapter, CCAMERA& aCamera, + S3D_CACHE* a3DCachePointer ) : HIDPI_GL_CANVAS( aParent, wxID_ANY, aAttribList, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE ), m_eventDispatcher( nullptr ), m_parentStatusBar( nullptr ), m_glRC( nullptr ), - m_settings( aSettings ), + m_boardAdapter( aBoardAdapter ), + m_camera( aCamera ), m_3d_render( nullptr ) { wxLogTrace( m_logTrace, "EDA_3D_CANVAS::EDA_3D_CANVAS" ); @@ -123,8 +125,8 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow *aParent, const int *aAttribList, BOARD * m_render_raytracing_was_requested = false; m_opengl_supports_raytracing = false; - m_3d_render_raytracing = new C3D_RENDER_RAYTRACING( aSettings ); - m_3d_render_ogl_legacy = new C3D_RENDER_OGL_LEGACY( aSettings ); + m_3d_render_raytracing = new C3D_RENDER_RAYTRACING( m_boardAdapter, m_camera ); + m_3d_render_ogl_legacy = new C3D_RENDER_OGL_LEGACY( m_boardAdapter, m_camera ); wxASSERT( m_3d_render_raytracing != NULL ); wxASSERT( m_3d_render_ogl_legacy != NULL ); @@ -137,12 +139,12 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow *aParent, const int *aAttribList, BOARD * RenderEngineChanged(); wxASSERT( aBoard != NULL ); - m_settings.SetBoard( aBoard ); + m_boardAdapter.SetBoard( aBoard ); - m_settings.SetColorSettings( Pgm().GetSettingsManager().GetColorSettings() ); + m_boardAdapter.SetColorSettings( Pgm().GetSettingsManager().GetColorSettings() ); wxASSERT( a3DCachePointer != NULL ); - m_settings.Set3DCacheManager( a3DCachePointer ); + m_boardAdapter.Set3DCacheManager( a3DCachePointer ); const wxEventType events[] = { @@ -287,12 +289,12 @@ void EDA_3D_CANVAS::GetScreenshot( wxImage &aDstImage ) void EDA_3D_CANVAS::ReloadRequest( BOARD *aBoard , S3D_CACHE *aCachePointer ) { if( aCachePointer != NULL ) - m_settings.Set3DCacheManager( aCachePointer ); + m_boardAdapter.Set3DCacheManager( aCachePointer ); if( aBoard != NULL ) - m_settings.SetBoard( aBoard ); + m_boardAdapter.SetBoard( aBoard ); - m_settings.SetColorSettings( Pgm().GetSettingsManager().GetColorSettings() ); + m_boardAdapter.SetColorSettings( Pgm().GetSettingsManager().GetColorSettings() ); if( m_3d_render ) m_3d_render->ReloadRequest(); @@ -319,10 +321,10 @@ void EDA_3D_CANVAS::DisplayStatus() { wxString msg; - msg.Printf( "dx %3.2f", m_settings.CameraGet().GetCameraPos().x ); + msg.Printf( "dx %3.2f", m_camera.GetCameraPos().x ); m_parentStatusBar->SetStatusText( msg, static_cast( EDA_3D_VIEWER_STATUSBAR::X_POS ) ); - msg.Printf( "dy %3.2f", m_settings.CameraGet().GetCameraPos().y ); + msg.Printf( "dy %3.2f", m_camera.GetCameraPos().y ); m_parentStatusBar->SetStatusText( msg, static_cast( EDA_3D_VIEWER_STATUSBAR::Y_POS ) ); } } @@ -380,7 +382,7 @@ void EDA_3D_CANVAS::OnPaint( wxPaintEvent &event ) // is wrong when next another canvas is repainted. wxSize clientSize = GetNativePixelSize(); - const bool windows_size_changed = m_settings.CameraGet().SetCurWindowSize( clientSize ); + const bool windows_size_changed = m_camera.SetCurWindowSize( clientSize ); // Initialize openGL if need // ///////////////////////////////////////////////////////////////////////// @@ -399,13 +401,13 @@ void EDA_3D_CANVAS::OnPaint( wxPaintEvent &event ) { m_3d_render = m_3d_render_ogl_legacy; m_render_raytracing_was_requested = false; - m_settings.RenderEngineSet( RENDER_ENGINE::OPENGL_LEGACY ); + m_boardAdapter.RenderEngineSet( RENDER_ENGINE::OPENGL_LEGACY ); } // Check if a raytacing was requested and need to switch to raytracing mode - if( m_settings.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) + if( m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) { - const bool was_camera_changed = m_settings.CameraGet().ParametersChanged(); + const bool was_camera_changed = m_camera.ParametersChanged(); // It reverts back to OpenGL mode if it was requested a raytracing // render of the current scene. AND the mouse / camera is moving @@ -426,7 +428,7 @@ void EDA_3D_CANVAS::OnPaint( wxPaintEvent &event ) { const unsigned curtime_delta = GetRunningMicroSecs() - m_strtime_camera_movement; curtime_delta_s = (curtime_delta / 1e6) * m_camera_moving_speed; - m_settings.CameraGet().Interpolate( curtime_delta_s ); + m_camera.Interpolate( curtime_delta_s ); if( curtime_delta_s > 1.0f ) { @@ -456,7 +458,7 @@ void EDA_3D_CANVAS::OnPaint( wxPaintEvent &event ) if( m_render_pivot ) { - const float scale = glm::min( m_settings.CameraGet().ZoomGet(), 1.0f ); + const float scale = glm::min( m_camera.ZoomGet(), 1.0f ); render_pivot( curtime_delta_s, scale * scale ); } @@ -480,7 +482,7 @@ void EDA_3D_CANVAS::OnPaint( wxPaintEvent &event ) } // This will reset the flag of camera parameters changed - m_settings.CameraGet().ParametersChanged(); + m_camera.ParametersChanged(); if( !err_messages.IsEmpty() ) wxLogMessage( err_messages ); @@ -540,9 +542,9 @@ void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent &event ) if( m_camera_is_moving ) return; - float delta_move = m_delta_move_step_factor * m_settings.CameraGet().ZoomGet(); + float delta_move = m_delta_move_step_factor * m_camera.ZoomGet(); - if( m_settings.GetFlag( FL_MOUSEWHEEL_PANNING ) ) + if( m_boardAdapter.GetFlag( FL_MOUSEWHEEL_PANNING ) ) delta_move *= (0.01f * event.GetWheelRotation()); else if( event.GetWheelRotation() < 0 ) @@ -557,28 +559,28 @@ void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent &event ) // wheel + ctrl -> horizontal scrolling; // wheel -> zooming. - if( m_settings.GetFlag( FL_MOUSEWHEEL_PANNING ) && !event.ControlDown() ) + if( m_boardAdapter.GetFlag( FL_MOUSEWHEEL_PANNING ) && !event.ControlDown() ) { if( event.GetWheelAxis() == wxMOUSE_WHEEL_HORIZONTAL || event.ShiftDown() ) - m_settings.CameraGet().Pan( SFVEC3F( -delta_move, 0.0f, 0.0f ) ); + m_camera.Pan( SFVEC3F( -delta_move, 0.0f, 0.0f ) ); else - m_settings.CameraGet().Pan( SFVEC3F( 0.0f, -delta_move, 0.0f ) ); + m_camera.Pan( SFVEC3F( 0.0f, -delta_move, 0.0f ) ); mouseActivity = true; } - else if( event.ShiftDown() && !m_settings.GetFlag( FL_MOUSEWHEEL_PANNING ) ) + else if( event.ShiftDown() && !m_boardAdapter.GetFlag( FL_MOUSEWHEEL_PANNING ) ) { - m_settings.CameraGet().Pan( SFVEC3F( 0.0f, -delta_move, 0.0f ) ); + m_camera.Pan( SFVEC3F( 0.0f, -delta_move, 0.0f ) ); mouseActivity = true; } - else if( event.ControlDown() && !m_settings.GetFlag( FL_MOUSEWHEEL_PANNING ) ) + else if( event.ControlDown() && !m_boardAdapter.GetFlag( FL_MOUSEWHEEL_PANNING ) ) { - m_settings.CameraGet().Pan( SFVEC3F( delta_move, 0.0f, 0.0f ) ); + m_camera.Pan( SFVEC3F( delta_move, 0.0f, 0.0f ) ); mouseActivity = true; } else { - mouseActivity = m_settings.CameraGet().Zoom( event.GetWheelRotation() > 0 ? 1.1f : 1/1.1f ); + mouseActivity = m_camera.Zoom( event.GetWheelRotation() > 0 ? 1.1f : 1/1.1f ); } // If it results on a camera movement @@ -594,7 +596,7 @@ void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent &event ) } // Update the cursor current mouse position on the camera - m_settings.CameraGet().SetCurMousePosition( event.GetPosition() ); + m_camera.SetCurMousePosition( event.GetPosition() ); } @@ -611,7 +613,7 @@ void EDA_3D_CANVAS::OnMagnify( wxMouseEvent& event ) float magnification = ( event.GetMagnification() + 1.0f ); - m_settings.CameraGet().Zoom( magnification ); + m_camera.Zoom( magnification ); DisplayStatus(); Request_refresh(); @@ -626,14 +628,14 @@ void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent &event ) if( m_camera_is_moving ) return; - m_settings.CameraGet().SetCurWindowSize( GetNativePixelSize() ); + m_camera.SetCurWindowSize( GetNativePixelSize() ); if( event.Dragging() ) { if( event.LeftIsDown() ) // Drag - m_settings.CameraGet().Drag( event.GetPosition() ); + m_camera.Drag( event.GetPosition() ); else if( event.MiddleIsDown() ) // Pan - m_settings.CameraGet().Pan( event.GetPosition() ); + m_camera.Pan( event.GetPosition() ); m_mouse_is_moving = true; m_mouse_was_moved = true; @@ -644,7 +646,7 @@ void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent &event ) } const wxPoint eventPosition = event.GetPosition(); - m_settings.CameraGet().SetCurMousePosition( eventPosition ); + m_camera.SetCurMousePosition( eventPosition ); } @@ -774,7 +776,7 @@ void EDA_3D_CANVAS::move_pivot_based_on_cur_mouse_position() SFVEC3F rayDir; // Generate a ray origin and direction based on current mouser position and camera - m_settings.CameraGet().MakeRayAtCurrrentMousePosition( rayOrigin, rayDir ); + m_camera.MakeRayAtCurrrentMousePosition( rayOrigin, rayDir ); RAY mouseRay; mouseRay.Init( rayOrigin, rayDir ); @@ -782,12 +784,12 @@ void EDA_3D_CANVAS::move_pivot_based_on_cur_mouse_position() float hit_t; // Test it with the board bounding box - if( m_settings.GetBBox3DU().Intersect( mouseRay, &hit_t ) ) + if( m_boardAdapter.GetBBox3DU().Intersect( mouseRay, &hit_t ) ) { - m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); - m_settings.CameraGet().SetT0_and_T1_current_T(); - m_settings.CameraGet().SetLookAtPos_T1( mouseRay.at( hit_t ) ); - m_settings.CameraGet().ResetXYpos_T1(); + m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); + m_camera.SetT0_and_T1_current_T(); + m_camera.SetLookAtPos_T1( mouseRay.at( hit_t ) ); + m_camera.ResetXYpos_T1(); request_start_moving_camera(); } @@ -799,7 +801,7 @@ bool EDA_3D_CANVAS::SetView3D( int aKeycode ) if( m_camera_is_moving ) return false; - const float delta_move = m_delta_move_step_factor * m_settings.CameraGet().ZoomGet(); + const float delta_move = m_delta_move_step_factor * m_camera.ZoomGet(); const float arrow_moving_time_speed = 8.0f; bool handled = false; @@ -810,126 +812,124 @@ bool EDA_3D_CANVAS::SetView3D( int aKeycode ) return true; case WXK_LEFT: - m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::LINEAR ); - m_settings.CameraGet().SetT0_and_T1_current_T(); - m_settings.CameraGet().Pan_T1( SFVEC3F( -delta_move, 0.0f, 0.0f ) ); + m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::LINEAR ); + m_camera.SetT0_and_T1_current_T(); + m_camera.Pan_T1( SFVEC3F( -delta_move, 0.0f, 0.0f ) ); request_start_moving_camera( arrow_moving_time_speed, false ); return true; case WXK_RIGHT: - m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::LINEAR ); - m_settings.CameraGet().SetT0_and_T1_current_T(); - m_settings.CameraGet().Pan_T1( SFVEC3F( +delta_move, 0.0f, 0.0f ) ); + m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::LINEAR ); + m_camera.SetT0_and_T1_current_T(); + m_camera.Pan_T1( SFVEC3F( +delta_move, 0.0f, 0.0f ) ); request_start_moving_camera( arrow_moving_time_speed, false ); return true; case WXK_UP: - m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::LINEAR ); - m_settings.CameraGet().SetT0_and_T1_current_T(); - m_settings.CameraGet().Pan_T1( SFVEC3F( 0.0f, +delta_move, 0.0f ) ); + m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::LINEAR ); + m_camera.SetT0_and_T1_current_T(); + m_camera.Pan_T1( SFVEC3F( 0.0f, +delta_move, 0.0f ) ); request_start_moving_camera( arrow_moving_time_speed, false ); return true; case WXK_DOWN: - m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::LINEAR ); - m_settings.CameraGet().SetT0_and_T1_current_T(); - m_settings.CameraGet().Pan_T1( SFVEC3F( 0.0f, -delta_move, 0.0f ) ); + m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::LINEAR ); + m_camera.SetT0_and_T1_current_T(); + m_camera.Pan_T1( SFVEC3F( 0.0f, -delta_move, 0.0f ) ); request_start_moving_camera( arrow_moving_time_speed, false ); return true; case WXK_HOME: - m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); - m_settings.CameraGet().SetT0_and_T1_current_T(); - m_settings.CameraGet().Reset_T1(); - request_start_moving_camera( glm::min( glm::max( m_settings.CameraGet().ZoomGet(), 1/1.26f ), 1.26f ) ); + m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); + m_camera.SetT0_and_T1_current_T(); + m_camera.Reset_T1(); + request_start_moving_camera( glm::min( glm::max( m_camera.ZoomGet(), 1/1.26f ), 1.26f ) ); return true; case WXK_END: break; case WXK_TAB: - m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::EASING_IN_OUT ); - m_settings.CameraGet().SetT0_and_T1_current_T(); - m_settings.CameraGet().RotateZ_T1( glm::radians( 45.0f ) ); + m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::EASING_IN_OUT ); + m_camera.SetT0_and_T1_current_T(); + m_camera.RotateZ_T1( glm::radians( 45.0f ) ); request_start_moving_camera(); handled = true; break; case WXK_F1: - m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); - m_settings.CameraGet().SetT0_and_T1_current_T(); + m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); + m_camera.SetT0_and_T1_current_T(); - if( m_settings.CameraGet().Zoom_T1( 1.26f ) ) // 3 steps per doubling + if( m_camera.Zoom_T1( 1.26f ) ) // 3 steps per doubling request_start_moving_camera( 3.0f ); return true; case WXK_F2: - m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); - m_settings.CameraGet().SetT0_and_T1_current_T(); + m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); + m_camera.SetT0_and_T1_current_T(); - if( m_settings.CameraGet().Zoom_T1( 1/1.26f ) ) // 3 steps per halving + if( m_camera.Zoom_T1( 1/1.26f ) ) // 3 steps per halving request_start_moving_camera( 3.0f ); return true; case ID_VIEW3D_RESET: - m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); - m_settings.CameraGet().SetT0_and_T1_current_T(); - m_settings.CameraGet().Reset_T1(); - request_start_moving_camera( glm::min( glm::max( m_settings.CameraGet().ZoomGet(), 0.5f ), 1.125f ) ); + m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); + m_camera.SetT0_and_T1_current_T(); + m_camera.Reset_T1(); + request_start_moving_camera( glm::min( glm::max( m_camera.ZoomGet(), 0.5f ), 1.125f ) ); return true; case ID_VIEW3D_RIGHT: - m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); - m_settings.CameraGet().SetT0_and_T1_current_T(); - m_settings.CameraGet().Reset_T1(); - m_settings.CameraGet().RotateZ_T1( glm::radians( -90.0f ) ); - m_settings.CameraGet().RotateX_T1( glm::radians( -90.0f ) ); + m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); + m_camera.SetT0_and_T1_current_T(); + m_camera.Reset_T1(); + m_camera.RotateZ_T1( glm::radians( -90.0f ) ); + m_camera.RotateX_T1( glm::radians( -90.0f ) ); request_start_moving_camera(); return true; case ID_VIEW3D_LEFT: - m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); - m_settings.CameraGet().SetT0_and_T1_current_T(); - m_settings.CameraGet().Reset_T1(); - m_settings.CameraGet().RotateZ_T1( glm::radians( 90.0f ) ); - m_settings.CameraGet().RotateX_T1( glm::radians( -90.0f ) ); + m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); + m_camera.SetT0_and_T1_current_T(); + m_camera.Reset_T1(); + m_camera.RotateZ_T1( glm::radians( 90.0f ) ); + m_camera.RotateX_T1( glm::radians( -90.0f ) ); request_start_moving_camera(); return true; case ID_VIEW3D_FRONT: - m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); - m_settings.CameraGet().SetT0_and_T1_current_T(); - m_settings.CameraGet().Reset_T1(); - m_settings.CameraGet().RotateX_T1( glm::radians( -90.0f ) ); + m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); + m_camera.SetT0_and_T1_current_T(); + m_camera.Reset_T1(); + m_camera.RotateX_T1( glm::radians( -90.0f ) ); request_start_moving_camera(); return true; case ID_VIEW3D_BACK: - m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); - m_settings.CameraGet().SetT0_and_T1_current_T(); - m_settings.CameraGet().Reset_T1(); - m_settings.CameraGet().RotateX_T1( glm::radians( -90.0f ) ); - m_settings.CameraGet().RotateZ_T1( glm::radians( -180.0f ) ); + m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); + m_camera.SetT0_and_T1_current_T(); + m_camera.Reset_T1(); + m_camera.RotateX_T1( glm::radians( -90.0f ) ); + m_camera.RotateZ_T1( glm::radians( -180.0f ) ); request_start_moving_camera(); return true; case ID_VIEW3D_TOP: - m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); - m_settings.CameraGet().SetT0_and_T1_current_T(); - m_settings.CameraGet().Reset_T1(); - request_start_moving_camera( - glm::min( glm::max( m_settings.CameraGet().ZoomGet(), 0.5f ), 1.125f ) ); + m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); + m_camera.SetT0_and_T1_current_T(); + m_camera.Reset_T1(); + request_start_moving_camera( glm::min( glm::max( m_camera.ZoomGet(), 0.5f ), 1.125f ) ); return true; case ID_VIEW3D_BOTTOM: - m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); - m_settings.CameraGet().SetT0_and_T1_current_T(); - m_settings.CameraGet().Reset_T1(); - m_settings.CameraGet().RotateY_T1( glm::radians( 180.0f ) ); - request_start_moving_camera( - glm::min( glm::max( m_settings.CameraGet().ZoomGet(), 0.5f ), 1.125f ) ); + m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); + m_camera.SetT0_and_T1_current_T(); + m_camera.Reset_T1(); + m_camera.RotateY_T1( glm::radians( 180.0f ) ); + request_start_moving_camera( glm::min( glm::max( m_camera.ZoomGet(), 0.5f ), 1.125f ) ); return true; default: @@ -949,7 +949,7 @@ bool EDA_3D_CANVAS::SetView3D( int aKeycode ) void EDA_3D_CANVAS::RenderEngineChanged() { - switch( m_settings.RenderEngineGet() ) + switch( m_boardAdapter.RenderEngineGet() ) { case RENDER_ENGINE::OPENGL_LEGACY: m_3d_render = m_3d_render_ogl_legacy; break; case RENDER_ENGINE::RAYTRACING: m_3d_render = m_3d_render_raytracing; break; diff --git a/3d-viewer/3d_canvas/eda_3d_canvas.h b/3d-viewer/3d_canvas/eda_3d_canvas.h index b5ae7c57c1..9936f5ce64 100644 --- a/3d-viewer/3d_canvas/eda_3d_canvas.h +++ b/3d-viewer/3d_canvas/eda_3d_canvas.h @@ -26,7 +26,7 @@ #define EDA_3D_CANVAS_H -#include "3d_settings.h" +#include "board_adapter.h" #include "3d_rendering/c3d_render_base.h" #include "3d_cache/3d_cache.h" #include @@ -53,11 +53,8 @@ class EDA_3D_CANVAS : public HIDPI_GL_CANVAS * @param aBoard: The board * @param aSettings: the settings options to be used by this canvas */ - EDA_3D_CANVAS( wxWindow *aParent, - const int *aAttribList = 0, - BOARD *aBoard = NULL, - EDA_3D_SETTINGS &aSettings = G_null_EDA_3D_SETTINGS, - S3D_CACHE *a3DCachePointer = NULL ); + EDA_3D_CANVAS( wxWindow* aParent, const int* aAttribList, BOARD* aBoard, + BOARD_ADAPTER& aSettings, CCAMERA& aCamera, S3D_CACHE* a3DCachePointer ); ~EDA_3D_CANVAS(); @@ -212,8 +209,8 @@ private: float m_camera_moving_speed; // 1.0f will be 1:1 unsigned m_strtime_camera_movement; // Ticktime of camera movement start - EDA_3D_SETTINGS& m_settings; // Pre-computed 3D information and visual - // settings to render the board + BOARD_ADAPTER& m_boardAdapter; // Pre-computed 3D info and settings + CCAMERA& m_camera; C3D_RENDER_BASE* m_3d_render; C3D_RENDER_RAYTRACING* m_3d_render_raytracing; C3D_RENDER_OGL_LEGACY* m_3d_render_ogl_legacy; diff --git a/3d-viewer/3d_canvas/eda_3d_canvas_pivot.cpp b/3d-viewer/3d_canvas/eda_3d_canvas_pivot.cpp index 8b8452c1d2..f829100eb9 100644 --- a/3d-viewer/3d_canvas/eda_3d_canvas_pivot.cpp +++ b/3d-viewer/3d_canvas/eda_3d_canvas_pivot.cpp @@ -81,7 +81,7 @@ void EDA_3D_CANVAS::render_pivot( float t , float aScale ) if( t > 1.0f ) t = 1.0f; - const SFVEC3F &lookAtPos = m_settings.CameraGet().GetLookAtPos_T1(); + const SFVEC3F &lookAtPos = m_camera.GetLookAtPos_T1(); glDisable( GL_LIGHTING ); glDisable( GL_DEPTH_TEST ); @@ -90,11 +90,11 @@ void EDA_3D_CANVAS::render_pivot( float t , float aScale ) // Set projection and modelview matrixes // ///////////////////////////////////////////////////////////////////////// glMatrixMode( GL_PROJECTION ); - glLoadMatrixf( glm::value_ptr( m_settings.CameraGet().GetProjectionMatrix() ) ); + glLoadMatrixf( glm::value_ptr( m_camera.GetProjectionMatrix() ) ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); - glLoadMatrixf( glm::value_ptr( m_settings.CameraGet().GetViewMatrix() ) ); + glLoadMatrixf( glm::value_ptr( m_camera.GetViewMatrix() ) ); glEnable( GL_COLOR_MATERIAL ); glColor4f( 0.0f, 1.0f, 0.0f, 0.75f - t * 0.75f ); diff --git a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_createscene_ogl_legacy.cpp b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_createscene_ogl_legacy.cpp index 94b54b2139..3901bf1a0f 100644 --- a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_createscene_ogl_legacy.cpp +++ b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_createscene_ogl_legacy.cpp @@ -141,7 +141,7 @@ void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer( const CRING2D * aRing, generate_ring_contour( center, inner, outer, - m_settings.GetNrSegmentsCircle( outer * 2.0f ), + m_boardAdapter.GetNrSegmentsCircle( outer * 2.0f ), innerContour, outerContour, false ); @@ -318,7 +318,7 @@ CLAYERS_OGL_DISP_LISTS *C3D_RENDER_OGL_LEGACY::generate_holes_display_list( layerTriangles->AddToMiddleContourns( aPoly, aZbot, aZtop, - m_settings.BiuTo3Dunits(), + m_boardAdapter.BiuTo3Dunits(), aInvertFaces ); } @@ -348,14 +348,14 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusTextReporter, REPORTER* aWa unsigned stats_startReloadTime = GetRunningMicroSecs(); - m_settings.InitSettings( aStatusTextReporter, aWarningTextReporter ); + m_boardAdapter.InitSettings( aStatusTextReporter, aWarningTextReporter ); #ifdef PRINT_STATISTICS_3D_VIEWER unsigned stats_endReloadTime = GetRunningMicroSecs(); #endif - SFVEC3F camera_pos = m_settings.GetBoardCenter3DU(); - m_settings.CameraGet().SetBoardLookAtPos( camera_pos ); + SFVEC3F camera_pos = m_boardAdapter.GetBoardCenter3DU(); + m_camera.SetBoardLookAtPos( camera_pos ); #ifdef PRINT_STATISTICS_3D_VIEWER unsigned stats_start_OpenGL_Load_Time = GetRunningMicroSecs(); @@ -368,11 +368,11 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusTextReporter, REPORTER* aWa // ///////////////////////////////////////////////////////////////////////// CCONTAINER2D boardContainer; - SHAPE_POLY_SET tmpBoard = m_settings.GetBoardPoly(); + SHAPE_POLY_SET tmpBoard = m_boardAdapter.GetBoardPoly(); Convert_shape_line_polygon_to_triangles( tmpBoard, boardContainer, - m_settings.BiuTo3Dunits(), - (const BOARD_ITEM &)*m_settings.GetBoard() ); + m_boardAdapter.BiuTo3Dunits(), + (const BOARD_ITEM &)*m_boardAdapter.GetBoard() ); const LIST_OBJECT2D &listBoardObject2d = boardContainer.GetList(); @@ -409,7 +409,7 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusTextReporter, REPORTER* aWa layer_z_bot ); } - const SHAPE_POLY_SET &boardPoly = m_settings.GetBoardPoly(); + const SHAPE_POLY_SET &boardPoly = m_boardAdapter.GetBoardPoly(); wxASSERT( boardPoly.OutlineCount() > 0 ); @@ -418,7 +418,7 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusTextReporter, REPORTER* aWa layerTriangles->AddToMiddleContourns( boardPoly, layer_z_bot, layer_z_top, - m_settings.BiuTo3Dunits(), + m_boardAdapter.BiuTo3Dunits(), false ); m_ogl_disp_list_board = new CLAYERS_OGL_DISP_LISTS( *layerTriangles, @@ -437,52 +437,52 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusTextReporter, REPORTER* aWa aStatusTextReporter->Report( _( "Load OpenGL: holes and vias" ) ); m_ogl_disp_list_through_holes_outer = generate_holes_display_list( - m_settings.GetThroughHole_Outer().GetList(), - m_settings.GetThroughHole_Outer_poly(), - 1.0f, - 0.0f, - false ); + m_boardAdapter.GetThroughHole_Outer().GetList(), + m_boardAdapter.GetThroughHole_Outer_poly(), + 1.0f, + 0.0f, + false ); - SHAPE_POLY_SET bodyHoles = m_settings.GetThroughHole_Outer_poly(); + SHAPE_POLY_SET bodyHoles = m_boardAdapter.GetThroughHole_Outer_poly(); - bodyHoles.BooleanAdd( m_settings.GetThroughHole_Outer_poly_NPTH(), + bodyHoles.BooleanAdd( m_boardAdapter.GetThroughHole_Outer_poly_NPTH(), SHAPE_POLY_SET::PM_FAST ); m_ogl_disp_list_through_holes_outer_with_npth = generate_holes_display_list( - m_settings.GetThroughHole_Outer().GetList(), - bodyHoles, - 1.0f, - 0.0f, - false ); + m_boardAdapter.GetThroughHole_Outer().GetList(), + bodyHoles, + 1.0f, + 0.0f, + false ); m_ogl_disp_list_through_holes_inner = generate_holes_display_list( - m_settings.GetThroughHole_Inner().GetList(), - m_settings.GetThroughHole_Inner_poly(), - 1.0f, - 0.0f, - true ); + m_boardAdapter.GetThroughHole_Inner().GetList(), + m_boardAdapter.GetThroughHole_Inner_poly(), + 1.0f, + 0.0f, + true ); m_ogl_disp_list_through_holes_vias_outer = generate_holes_display_list( - m_settings.GetThroughHole_Vias_Outer().GetList(), - m_settings.GetThroughHole_Vias_Outer_poly(), - 1.0f, - 0.0f, - false ); + m_boardAdapter.GetThroughHole_Vias_Outer().GetList(), + m_boardAdapter.GetThroughHole_Vias_Outer_poly(), + 1.0f, + 0.0f, + false ); // Not in use //m_ogl_disp_list_through_holes_vias_inner = generate_holes_display_list( - // m_settings.GetThroughHole_Vias_Inner().GetList(), - // m_settings.GetThroughHole_Vias_Inner_poly(), + // m_boardAdapter.GetThroughHole_Vias_Inner().GetList(), + // m_boardAdapter.GetThroughHole_Vias_Inner_poly(), // 1.0f, 0.0f, // false ); - const MAP_POLY & innerMapHoles = m_settings.GetPolyMapHoles_Inner(); - const MAP_POLY & outerMapHoles = m_settings.GetPolyMapHoles_Outer(); + const MAP_POLY & innerMapHoles = m_boardAdapter.GetPolyMapHoles_Inner(); + const MAP_POLY & outerMapHoles = m_boardAdapter.GetPolyMapHoles_Outer(); wxASSERT( innerMapHoles.size() == outerMapHoles.size() ); - const MAP_CONTAINER_2D &map_holes = m_settings.GetMapLayersHoles(); + const MAP_CONTAINER_2D &map_holes = m_boardAdapter.GetMapLayersHoles(); if( outerMapHoles.size() > 0 ) { @@ -526,13 +526,13 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusTextReporter, REPORTER* aWa if( aStatusTextReporter ) aStatusTextReporter->Report( _( "Load OpenGL: layers" ) ); - for( MAP_CONTAINER_2D::const_iterator ii = m_settings.GetMapLayers().begin(); - ii != m_settings.GetMapLayers().end(); + for( MAP_CONTAINER_2D::const_iterator ii = m_boardAdapter.GetMapLayers().begin(); + ii != m_boardAdapter.GetMapLayers().end(); ++ii ) { PCB_LAYER_ID layer_id = static_cast(ii->first); - if( !m_settings.Is3DLayerEnabled( layer_id ) ) + if( !m_boardAdapter.Is3DLayerEnabled( layer_id ) ) continue; const CBVHCONTAINER2D *container2d = static_cast(ii->second); @@ -593,7 +593,7 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusTextReporter, REPORTER* aWa } } - const MAP_POLY &map_poly = m_settings.GetPolyMap(); + const MAP_POLY &map_poly = m_boardAdapter.GetPolyMap(); // Load the vertical (Z axis) component of shapes if( map_poly.find( layer_id ) != map_poly.end() ) @@ -602,7 +602,7 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusTextReporter, REPORTER* aWa if( polyList->OutlineCount() > 0 ) layerTriangles->AddToMiddleContourns( *polyList, layer_z_bot, layer_z_top, - m_settings.BiuTo3Dunits(), false ); + m_boardAdapter.BiuTo3Dunits(), false ); } // Create display list @@ -675,8 +675,8 @@ void C3D_RENDER_OGL_LEGACY::get_layer_z_pos ( PCB_LAYER_ID aLayerID, float &aOutZtop, float &aOutZbot ) const { - aOutZbot = m_settings.GetLayerBottomZpos3DU( aLayerID ); - aOutZtop = m_settings.GetLayerTopZpos3DU( aLayerID ); + aOutZbot = m_boardAdapter.GetLayerBottomZpos3DU( aLayerID ); + aOutZtop = m_boardAdapter.GetLayerTopZpos3DU( aLayerID ); if( aOutZtop < aOutZbot ) { @@ -731,12 +731,12 @@ void C3D_RENDER_OGL_LEGACY::generate_cylinder( const SFVEC2F &aCenter, void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads() { - if( m_settings.GetStats_Nr_Vias() ) + if( m_boardAdapter.GetStats_Nr_Vias() ) { const unsigned int reserve_nr_triangles_estimation = - m_settings.GetNrSegmentsCircle( m_settings.GetStats_Med_Via_Hole_Diameter3DU() ) * + m_boardAdapter.GetNrSegmentsCircle( m_boardAdapter.GetStats_Med_Via_Hole_Diameter3DU() ) * 8 * - m_settings.GetStats_Nr_Vias(); + m_boardAdapter.GetStats_Nr_Vias(); CLAYER_TRIANGLES *layerTriangleVIA = new CLAYER_TRIANGLES( reserve_nr_triangles_estimation ); @@ -744,20 +744,20 @@ void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads() // ///////////////////////////////////////////////////////////////////////// // Insert vias holes (vertical cylinders) - for( auto track : m_settings.GetBoard()->Tracks() ) + for( auto track : m_boardAdapter.GetBoard()->Tracks() ) { if( track->Type() == PCB_VIA_T ) { const VIA *via = static_cast(track); - const float holediameter = via->GetDrillValue() * m_settings.BiuTo3Dunits(); - const float thickness = m_settings.GetCopperThickness3DU(); - const int nrSegments = m_settings.GetNrSegmentsCircle( via->GetDrillValue() ); - const double correctionFactor = m_settings.GetCircleCorrectionFactor( nrSegments ); + const float holediameter = via->GetDrillValue() * m_boardAdapter.BiuTo3Dunits(); + const float thickness = m_boardAdapter.GetCopperThickness3DU(); + const int nrSegments = m_boardAdapter.GetNrSegmentsCircle( via->GetDrillValue() ); + const double correctionFactor = m_boardAdapter.GetCircleCorrectionFactor( nrSegments ); const float hole_inner_radius = ( holediameter / 2.0f ) * correctionFactor; - const SFVEC2F via_center( via->GetStart().x * m_settings.BiuTo3Dunits(), - -via->GetStart().y * m_settings.BiuTo3Dunits() ); + const SFVEC2F via_center( via->GetStart().x * m_boardAdapter.BiuTo3Dunits(), + -via->GetStart().y * m_boardAdapter.BiuTo3Dunits() ); PCB_LAYER_ID top_layer, bottom_layer; via->LayerPair( &top_layer, &bottom_layer ); @@ -788,7 +788,7 @@ void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads() } - if( m_settings.GetStats_Nr_Holes() > 0 ) + if( m_boardAdapter.GetStats_Nr_Holes() > 0 ) { SHAPE_POLY_SET tht_outer_holes_poly; // Stores the outer poly of the copper holes (the pad) SHAPE_POLY_SET tht_inner_holes_poly; // Stores the inner poly of the copper holes (the hole) @@ -797,7 +797,7 @@ void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads() tht_inner_holes_poly.RemoveAllContours(); // Insert pads holes (vertical cylinders) - for( const auto module : m_settings.GetBoard()->Modules() ) + for( const auto module : m_boardAdapter.GetBoard()->Modules() ) { for( auto pad : module->Pads() ) { @@ -812,10 +812,10 @@ void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads() // we use the hole diameter to calculate the seg count. // for round holes, drillsize.x == drillsize.y // for slots, the diameter is the smaller of (drillsize.x, drillsize.y) - int copperThickness = m_settings.GetCopperThicknessBIU(); + int copperThickness = m_boardAdapter.GetCopperThicknessBIU(); int radius = std::min( drillsize.x, drillsize.y ) / 2 + copperThickness; - int nrSegments = m_settings.GetNrSegmentsCircle( radius * 2 ); - double correctionFactor = m_settings.GetCircleCorrectionFactor( nrSegments ); + int nrSegments = m_boardAdapter.GetNrSegmentsCircle( radius * 2 ); + double correctionFactor = m_boardAdapter.GetCircleCorrectionFactor( nrSegments ); int correction = radius * ( correctionFactor - 1 ); pad->BuildPadDrillShapePolygon( @@ -834,8 +834,8 @@ void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads() Convert_shape_line_polygon_to_triangles( tht_outer_holes_poly, holesContainer, - m_settings.BiuTo3Dunits(), - (const BOARD_ITEM &)*m_settings.GetBoard() ); + m_boardAdapter.BiuTo3Dunits(), + (const BOARD_ITEM &)*m_boardAdapter.GetBoard() ); const LIST_OBJECT2D &listHolesObject2d = holesContainer.GetList(); @@ -873,7 +873,7 @@ void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads() { layerTriangles->AddToMiddleContourns( tht_outer_holes_poly, layer_z_bot, layer_z_top, - m_settings.BiuTo3Dunits(), + m_boardAdapter.BiuTo3Dunits(), false ); m_ogl_disp_list_pads_holes = new CLAYERS_OGL_DISP_LISTS( @@ -896,13 +896,13 @@ void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads() */ void C3D_RENDER_OGL_LEGACY::load_3D_models( REPORTER *aStatusTextReporter ) { - if( (!m_settings.GetFlag( FL_MODULE_ATTRIBUTES_NORMAL )) && - (!m_settings.GetFlag( FL_MODULE_ATTRIBUTES_NORMAL_INSERT )) && - (!m_settings.GetFlag( FL_MODULE_ATTRIBUTES_VIRTUAL )) ) + if((!m_boardAdapter.GetFlag( FL_MODULE_ATTRIBUTES_NORMAL )) && + (!m_boardAdapter.GetFlag( FL_MODULE_ATTRIBUTES_NORMAL_INSERT )) && + (!m_boardAdapter.GetFlag( FL_MODULE_ATTRIBUTES_VIRTUAL )) ) return; // Go for all modules - for( auto module : m_settings.GetBoard()->Modules() ) + for( auto module : m_boardAdapter.GetBoard()->Modules() ) { if( !module->Models().empty() ) { @@ -930,14 +930,14 @@ void C3D_RENDER_OGL_LEGACY::load_3D_models( REPORTER *aStatusTextReporter ) { // It is not present, try get it from cache const S3DMODEL *modelPtr = - m_settings.Get3DCacheManager()->GetModel( sM->m_Filename ); + m_boardAdapter.Get3DCacheManager()->GetModel( sM->m_Filename ); // only add it if the return is not NULL if( modelPtr ) { C_OGL_3DMODEL* ogl_model = new C_OGL_3DMODEL( *modelPtr, - m_settings.MaterialModeGet() ); + m_boardAdapter.MaterialModeGet() ); if( ogl_model ) m_3dmodel_map[ sM->m_Filename ] = ogl_model; diff --git a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp index 1a844ad8c6..07a1873c58 100644 --- a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp +++ b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp @@ -44,8 +44,8 @@ */ #define UNITS3D_TO_UNITSPCB (IU_PER_MM) -C3D_RENDER_OGL_LEGACY::C3D_RENDER_OGL_LEGACY( EDA_3D_SETTINGS &aSettings ) : - C3D_RENDER_BASE( aSettings ) +C3D_RENDER_OGL_LEGACY::C3D_RENDER_OGL_LEGACY( BOARD_ADAPTER& aAdapter, CCAMERA& aCamera ) : + C3D_RENDER_BASE( aAdapter, aCamera ) { wxLogTrace( m_logTrace, wxT( "C3D_RENDER_OGL_LEGACY::C3D_RENDER_OGL_LEGACY" ) ); @@ -148,8 +148,7 @@ void C3D_RENDER_OGL_LEGACY::render_3D_arrows() glm::mat4(1.0f), SFVEC3F( 0.0f, 0.0f, -(arrow_size * 2.75f) ) ); - const glm::mat4 ViewMatrix = TranslationMatrix * - m_settings.CameraGet().GetRotationMatrix(); + const glm::mat4 ViewMatrix = TranslationMatrix * m_camera.GetRotationMatrix(); glLoadMatrixf( glm::value_ptr( ViewMatrix ) ); @@ -178,23 +177,23 @@ void C3D_RENDER_OGL_LEGACY::setupMaterials() { m_materials = {}; - if( m_settings.GetFlag( FL_USE_REALISTIC_MODE ) ) + if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) ) { // http://devernay.free.fr/cours/opengl/materials.html // Copper material mixed with the copper color - m_materials.m_Copper.m_Ambient = SFVEC3F( m_settings.m_CopperColor.r * 0.1f, - m_settings.m_CopperColor.g * 0.1f, - m_settings.m_CopperColor.b * 0.1f); + m_materials.m_Copper.m_Ambient = SFVEC3F( m_boardAdapter.m_CopperColor.r * 0.1f, + m_boardAdapter.m_CopperColor.g * 0.1f, + m_boardAdapter.m_CopperColor.b * 0.1f); - m_materials.m_Copper.m_Specular = SFVEC3F( m_settings.m_CopperColor.r * 0.75f + 0.25f, - m_settings.m_CopperColor.g * 0.75f + 0.25f, - m_settings.m_CopperColor.b * 0.75f + 0.25f ); + m_materials.m_Copper.m_Specular = SFVEC3F( m_boardAdapter.m_CopperColor.r * 0.75f + 0.25f, + m_boardAdapter.m_CopperColor.g * 0.75f + 0.25f, + m_boardAdapter.m_CopperColor.b * 0.75f + 0.25f ); // This guess the material type(ex: copper vs gold) to determine the // shininess factor between 0.1 and 0.4 - float shininessfactor = 0.40f - mapf( fabs( m_settings.m_CopperColor.r - - m_settings.m_CopperColor.g ), + float shininessfactor = 0.40f - mapf( fabs( m_boardAdapter.m_CopperColor.r - + m_boardAdapter.m_CopperColor.g ), 0.15f, 1.00f, 0.00f, 0.30f ); @@ -203,69 +202,73 @@ void C3D_RENDER_OGL_LEGACY::setupMaterials() // Paste material mixed with paste color - m_materials.m_Paste.m_Ambient = SFVEC3F( m_settings.m_SolderPasteColor.r, - m_settings.m_SolderPasteColor.g, - m_settings.m_SolderPasteColor.b ); + m_materials.m_Paste.m_Ambient = SFVEC3F( m_boardAdapter.m_SolderPasteColor.r, + m_boardAdapter.m_SolderPasteColor.g, + m_boardAdapter.m_SolderPasteColor.b ); - m_materials.m_Paste.m_Specular = SFVEC3F( m_settings.m_SolderPasteColor.r * - m_settings.m_SolderPasteColor.r, - m_settings.m_SolderPasteColor.g * - m_settings.m_SolderPasteColor.g, - m_settings.m_SolderPasteColor.b * - m_settings.m_SolderPasteColor.b ); + m_materials.m_Paste.m_Specular = SFVEC3F( m_boardAdapter.m_SolderPasteColor.r * + m_boardAdapter.m_SolderPasteColor.r, + m_boardAdapter.m_SolderPasteColor.g * + m_boardAdapter.m_SolderPasteColor.g, + m_boardAdapter.m_SolderPasteColor.b * + m_boardAdapter.m_SolderPasteColor.b ); m_materials.m_Paste.m_Shininess = 0.1f * 128.0f; m_materials.m_Paste.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f ); // Silk screen material mixed with silk screen color - m_materials.m_SilkSTop.m_Ambient = SFVEC3F( m_settings.m_SilkScreenColorTop.r, - m_settings.m_SilkScreenColorTop.g, m_settings.m_SilkScreenColorTop.b ); + m_materials.m_SilkSTop.m_Ambient = SFVEC3F( m_boardAdapter.m_SilkScreenColorTop.r, + m_boardAdapter.m_SilkScreenColorTop.g, + m_boardAdapter.m_SilkScreenColorTop.b ); m_materials.m_SilkSTop.m_Specular = SFVEC3F( - m_settings.m_SilkScreenColorTop.r * m_settings.m_SilkScreenColorTop.r + 0.10f, - m_settings.m_SilkScreenColorTop.g * m_settings.m_SilkScreenColorTop.g + 0.10f, - m_settings.m_SilkScreenColorTop.b * m_settings.m_SilkScreenColorTop.b + 0.10f ); + m_boardAdapter.m_SilkScreenColorTop.r * m_boardAdapter.m_SilkScreenColorTop.r + 0.10f, + m_boardAdapter.m_SilkScreenColorTop.g * m_boardAdapter.m_SilkScreenColorTop.g + 0.10f, + m_boardAdapter.m_SilkScreenColorTop.b * m_boardAdapter.m_SilkScreenColorTop.b + 0.10f ); m_materials.m_SilkSTop.m_Shininess = 0.078125f * 128.0f; m_materials.m_SilkSTop.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f ); // Silk screen material mixed with silk screen color - m_materials.m_SilkSBot.m_Ambient = SFVEC3F( m_settings.m_SilkScreenColorBot.r, - m_settings.m_SilkScreenColorBot.g, m_settings.m_SilkScreenColorBot.b ); + m_materials.m_SilkSBot.m_Ambient = SFVEC3F( m_boardAdapter.m_SilkScreenColorBot.r, + m_boardAdapter.m_SilkScreenColorBot.g, + m_boardAdapter.m_SilkScreenColorBot.b ); m_materials.m_SilkSBot.m_Specular = SFVEC3F( - m_settings.m_SilkScreenColorBot.r * m_settings.m_SilkScreenColorBot.r + 0.10f, - m_settings.m_SilkScreenColorBot.g * m_settings.m_SilkScreenColorBot.g + 0.10f, - m_settings.m_SilkScreenColorBot.b * m_settings.m_SilkScreenColorBot.b + 0.10f ); + m_boardAdapter.m_SilkScreenColorBot.r * m_boardAdapter.m_SilkScreenColorBot.r + 0.10f, + m_boardAdapter.m_SilkScreenColorBot.g * m_boardAdapter.m_SilkScreenColorBot.g + 0.10f, + m_boardAdapter.m_SilkScreenColorBot.b * m_boardAdapter.m_SilkScreenColorBot.b + 0.10f ); m_materials.m_SilkSBot.m_Shininess = 0.078125f * 128.0f; m_materials.m_SilkSBot.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f ); // Solder mask material mixed with solder mask color - m_materials.m_SolderMaskTop.m_Ambient = SFVEC3F( m_settings.m_SolderMaskColorTop.r * 0.3f, - m_settings.m_SolderMaskColorTop.g * 0.3f, - m_settings.m_SolderMaskColorTop.b * 0.3f ); + m_materials.m_SolderMaskTop.m_Ambient = SFVEC3F( + m_boardAdapter.m_SolderMaskColorTop.r * 0.3f, + m_boardAdapter.m_SolderMaskColorTop.g * 0.3f, + m_boardAdapter.m_SolderMaskColorTop.b * 0.3f ); - m_materials.m_SolderMaskTop.m_Specular = - SFVEC3F( m_settings.m_SolderMaskColorTop.r * m_settings.m_SolderMaskColorTop.r, - m_settings.m_SolderMaskColorTop.g * m_settings.m_SolderMaskColorTop.g, - m_settings.m_SolderMaskColorTop.b * m_settings.m_SolderMaskColorTop.b ); + m_materials.m_SolderMaskTop.m_Specular = SFVEC3F( + m_boardAdapter.m_SolderMaskColorTop.r * m_boardAdapter.m_SolderMaskColorTop.r, + m_boardAdapter.m_SolderMaskColorTop.g * m_boardAdapter.m_SolderMaskColorTop.g, + m_boardAdapter.m_SolderMaskColorTop.b * m_boardAdapter.m_SolderMaskColorTop.b ); m_materials.m_SolderMaskTop.m_Shininess = 0.8f * 128.0f; m_materials.m_SolderMaskTop.m_Transparency = 0.17f; m_materials.m_SolderMaskTop.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f ); // Solder mask material mixed with solder mask color - m_materials.m_SolderMaskBot.m_Ambient = SFVEC3F( m_settings.m_SolderMaskColorBot.r * 0.3f, - m_settings.m_SolderMaskColorBot.g * 0.3f, - m_settings.m_SolderMaskColorBot.b * 0.3f ); + m_materials.m_SolderMaskBot.m_Ambient = SFVEC3F( + m_boardAdapter.m_SolderMaskColorBot.r * 0.3f, + m_boardAdapter.m_SolderMaskColorBot.g * 0.3f, + m_boardAdapter.m_SolderMaskColorBot.b * 0.3f ); - m_materials.m_SolderMaskBot.m_Specular = - SFVEC3F( m_settings.m_SolderMaskColorBot.r * m_settings.m_SolderMaskColorBot.r, - m_settings.m_SolderMaskColorBot.g * m_settings.m_SolderMaskColorBot.g, - m_settings.m_SolderMaskColorBot.b * m_settings.m_SolderMaskColorBot.b ); + m_materials.m_SolderMaskBot.m_Specular = SFVEC3F( + m_boardAdapter.m_SolderMaskColorBot.r * m_boardAdapter.m_SolderMaskColorBot.r, + m_boardAdapter.m_SolderMaskColorBot.g * m_boardAdapter.m_SolderMaskColorBot.g, + m_boardAdapter.m_SolderMaskColorBot.b * m_boardAdapter.m_SolderMaskColorBot.b ); m_materials.m_SolderMaskBot.m_Shininess = 0.8f * 128.0f; m_materials.m_SolderMaskBot.m_Transparency = 0.17f; @@ -277,7 +280,7 @@ void C3D_RENDER_OGL_LEGACY::setupMaterials() 97.0f / 255.0f, 47.0f / 255.0f ); - m_materials.m_EpoxyBoard.m_Diffuse = m_settings.m_BoardBodyColor; + m_materials.m_EpoxyBoard.m_Diffuse = m_boardAdapter.m_BoardBodyColor; m_materials.m_EpoxyBoard.m_Specular = SFVEC3F( 18.0f / 255.0f, 3.0f / 255.0f, @@ -332,7 +335,7 @@ void C3D_RENDER_OGL_LEGACY::setupMaterials() // Epoxy material m_materials.m_EpoxyBoard.m_Ambient = matAmbientColor; - m_materials.m_EpoxyBoard.m_Diffuse = m_settings.m_BoardBodyColor; + m_materials.m_EpoxyBoard.m_Diffuse = m_boardAdapter.m_BoardBodyColor; m_materials.m_EpoxyBoard.m_Specular = matSpecularColor; m_materials.m_EpoxyBoard.m_Shininess = matShininess; m_materials.m_EpoxyBoard.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f ); @@ -415,9 +418,9 @@ void C3D_RENDER_OGL_LEGACY::set_layer_material( PCB_LAYER_ID aLayerID ) SFVEC3F C3D_RENDER_OGL_LEGACY::get_layer_color( PCB_LAYER_ID aLayerID ) { - SFVEC3F layerColor = m_settings.GetLayerColor( aLayerID ); + SFVEC3F layerColor = m_boardAdapter.GetLayerColor( aLayerID ); - if( m_settings.GetFlag( FL_USE_REALISTIC_MODE ) ) + if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) ) { switch( aLayerID ) { @@ -426,22 +429,22 @@ SFVEC3F C3D_RENDER_OGL_LEGACY::get_layer_color( PCB_LAYER_ID aLayerID ) break; case B_Mask: - layerColor = m_settings.m_SolderMaskColorBot; + layerColor = m_boardAdapter.m_SolderMaskColorBot; break; case F_Mask: - layerColor = m_settings.m_SolderMaskColorTop; + layerColor = m_boardAdapter.m_SolderMaskColorTop; break; case B_Paste: case F_Paste: - layerColor = m_settings.m_SolderPasteColor; + layerColor = m_boardAdapter.m_SolderPasteColor; break; case B_SilkS: - layerColor = m_settings.m_SilkScreenColorBot; + layerColor = m_boardAdapter.m_SilkScreenColorBot; break; case F_SilkS: - layerColor = m_settings.m_SilkScreenColorTop; + layerColor = m_boardAdapter.m_SilkScreenColorTop; break; case Dwgs_User: @@ -461,7 +464,7 @@ SFVEC3F C3D_RENDER_OGL_LEGACY::get_layer_color( PCB_LAYER_ID aLayerID ) break; default: - layerColor = m_settings.m_CopperColor; + layerColor = m_boardAdapter.m_CopperColor; break; } } @@ -539,16 +542,16 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( setupMaterials(); // generate a new 3D grid as the size of the board may had changed - m_last_grid_type = m_settings.GridGet(); + m_last_grid_type = m_boardAdapter.GridGet(); generate_new_3DGrid( m_last_grid_type ); } else { // Check if grid was changed - if( m_settings.GridGet() != m_last_grid_type ) + if( m_boardAdapter.GridGet() != m_last_grid_type ) { // and generate a new one - m_last_grid_type = m_settings.GridGet(); + m_last_grid_type = m_boardAdapter.GridGet(); generate_new_3DGrid( m_last_grid_type ); } } @@ -573,8 +576,8 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( // Draw the background ( rectangle with color gradient) // ///////////////////////////////////////////////////////////////////////// - OGL_DrawBackground( SFVEC3F( m_settings.m_BgColorTop ), - SFVEC3F( m_settings.m_BgColorBot ) ); + OGL_DrawBackground( SFVEC3F( m_boardAdapter.m_BgColorTop ), + SFVEC3F( m_boardAdapter.m_BgColorBot ) ); glEnable( GL_DEPTH_TEST ); @@ -582,11 +585,11 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( // Set projection and modelview matrixes // ///////////////////////////////////////////////////////////////////////// glMatrixMode( GL_PROJECTION ); - glLoadMatrixf( glm::value_ptr( m_settings.CameraGet().GetProjectionMatrix() ) ); + glLoadMatrixf( glm::value_ptr( m_camera.GetProjectionMatrix() ) ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); - glLoadMatrixf( glm::value_ptr( m_settings.CameraGet().GetViewMatrix() ) ); + glLoadMatrixf( glm::value_ptr( m_camera.GetViewMatrix() ) ); // Position the headlight @@ -599,7 +602,7 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( glEnable( GL_LIGHTING ); { - const SFVEC3F &cameraPos = m_settings.CameraGet().GetPos(); + const SFVEC3F &cameraPos = m_camera.GetPos(); // Place the light at a minimun Z so the diffuse factor will not drop // and the board will still look with good light. @@ -625,12 +628,12 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( // Display board body // ///////////////////////////////////////////////////////////////////////// - if( m_settings.GetFlag( FL_SHOW_BOARD_BODY ) ) + if( m_boardAdapter.GetFlag( FL_SHOW_BOARD_BODY ) ) { if( m_ogl_disp_list_board ) { - m_ogl_disp_list_board->ApplyScalePosition( -m_settings.GetEpoxyThickness3DU() / 2.0f, - m_settings.GetEpoxyThickness3DU() ); + m_ogl_disp_list_board->ApplyScalePosition( -m_boardAdapter.GetEpoxyThickness3DU() / 2.0f, + m_boardAdapter.GetEpoxyThickness3DU() ); OGL_SetMaterial( m_materials.m_EpoxyBoard ); @@ -639,8 +642,8 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( if( m_ogl_disp_list_through_holes_outer_with_npth ) { m_ogl_disp_list_through_holes_outer_with_npth->ApplyScalePosition( - -m_settings.GetEpoxyThickness3DU() / 2.0f, - m_settings.GetEpoxyThickness3DU() ); + -m_boardAdapter.GetEpoxyThickness3DU() / 2.0f, + m_boardAdapter.GetEpoxyThickness3DU() ); m_ogl_disp_list_board->DrawAllCameraCulledSubtractLayer( m_ogl_disp_list_through_holes_outer_with_npth, @@ -654,7 +657,7 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( } - if( m_settings.GetFlag( FL_USE_REALISTIC_MODE ) ) + if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) ) { // Draw vias and pad holes with copper material set_layer_material( B_Cu ); @@ -689,7 +692,7 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( continue; // Do not show inner layers when it is displaying the board - if( m_settings.GetFlag( FL_SHOW_BOARD_BODY ) ) + if( m_boardAdapter.GetFlag( FL_SHOW_BOARD_BODY ) ) { if( (layer_id > F_Cu) && (layer_id < B_Cu) ) continue; @@ -737,7 +740,7 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( } else { - if( m_settings.GetFlag( FL_SUBTRACT_MASK_FROM_SILK ) && + if( m_boardAdapter.GetFlag( FL_SUBTRACT_MASK_FROM_SILK ) && ( ( ( layer_id == B_SilkS ) && ( m_ogl_disp_lists_layers.find( B_Mask ) != m_ogl_disp_lists_layers.end() ) ) || ( ( layer_id == F_SilkS ) && @@ -767,8 +770,7 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( } else { - pLayerDispList->DrawAllCameraCulled( m_settings.CameraGet().GetPos().z, - (aIsMoving == false) ); + pLayerDispList->DrawAllCameraCulled( m_camera.GetPos().z, aIsMoving == false ); } } } @@ -791,7 +793,7 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( // Display transparent mask layers // ///////////////////////////////////////////////////////////////////////// - if( m_settings.GetFlag( FL_SOLDERMASK ) ) + if( m_boardAdapter.GetFlag( FL_SOLDERMASK ) ) { //setLight_Top( true ); //setLight_Bottom( true ); @@ -801,20 +803,20 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( glEnable( GL_POLYGON_OFFSET_FILL ); glPolygonOffset( 0.0f, -1.0f ); - if( m_settings.CameraGet().GetPos().z > 0 ) + if( m_camera.GetPos().z > 0 ) { - render_solder_mask_layer( B_Mask, m_settings.GetLayerTopZpos3DU( B_Mask ), + render_solder_mask_layer( B_Mask, m_boardAdapter.GetLayerTopZpos3DU( B_Mask ), aIsMoving ); - render_solder_mask_layer( F_Mask, m_settings.GetLayerBottomZpos3DU( F_Mask ), + render_solder_mask_layer( F_Mask, m_boardAdapter.GetLayerBottomZpos3DU( F_Mask ), aIsMoving ); } else { - render_solder_mask_layer( F_Mask, m_settings.GetLayerBottomZpos3DU( F_Mask ), + render_solder_mask_layer( F_Mask, m_boardAdapter.GetLayerBottomZpos3DU( F_Mask ), aIsMoving ); - render_solder_mask_layer( B_Mask, m_settings.GetLayerTopZpos3DU( B_Mask ), + render_solder_mask_layer( B_Mask, m_boardAdapter.GetLayerTopZpos3DU( B_Mask ), aIsMoving ); } @@ -838,7 +840,7 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( // Render Grid // ///////////////////////////////////////////////////////////////////////// - if( m_settings.GridGet() != GRID3D_TYPE::NONE ) + if( m_boardAdapter.GridGet() != GRID3D_TYPE::NONE ) { glDisable( GL_LIGHTING ); @@ -851,7 +853,7 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( // Render 3D arrows // ///////////////////////////////////////////////////////////////////////// - if( m_settings.GetFlag( FL_AXIS ) ) + if( m_boardAdapter.GetFlag( FL_AXIS ) ) render_3D_arrows(); // Return back to the original viewport (this is important if we want @@ -1032,12 +1034,12 @@ void C3D_RENDER_OGL_LEGACY::render_solder_mask_layer( PCB_LAYER_ID aLayerID, if( m_ogl_disp_list_through_holes_vias_outer ) m_ogl_disp_list_through_holes_vias_outer->ApplyScalePosition( - aZPosition, - m_settings.GetNonCopperLayerThickness3DU() ); + aZPosition, + m_boardAdapter.GetNonCopperLayerThickness3DU() ); m_ogl_disp_list_board->ApplyScalePosition( - aZPosition, - m_settings.GetNonCopperLayerThickness3DU() ); + aZPosition, + m_boardAdapter.GetNonCopperLayerThickness3DU() ); set_layer_material( aLayerID ); @@ -1054,12 +1056,12 @@ void C3D_RENDER_OGL_LEGACY::render_solder_mask_layer( PCB_LAYER_ID aLayerID, if( m_ogl_disp_list_through_holes_vias_outer ) m_ogl_disp_list_through_holes_vias_outer->ApplyScalePosition( - aZPosition, - m_settings.GetNonCopperLayerThickness3DU() ); + aZPosition, + m_boardAdapter.GetNonCopperLayerThickness3DU() ); m_ogl_disp_list_board->ApplyScalePosition( - aZPosition, - m_settings.GetNonCopperLayerThickness3DU() ); + aZPosition, + m_boardAdapter.GetNonCopperLayerThickness3DU() ); set_layer_material( aLayerID ); @@ -1078,10 +1080,10 @@ void C3D_RENDER_OGL_LEGACY::render_3D_models( bool aRenderTopOrBot, bool aRenderTransparentOnly ) { // Go for all modules - for( auto module : m_settings.GetBoard()->Modules() ) + for( auto module : m_boardAdapter.GetBoard()->Modules() ) { if( !module->Models().empty() ) - if( m_settings.ShouldModuleBeDisplayed( (MODULE_ATTR_T) module->GetAttributes() ) ) + if( m_boardAdapter.ShouldModuleBeDisplayed((MODULE_ATTR_T) module->GetAttributes() ) ) if( ( aRenderTopOrBot && !module->IsFlipped() ) || ( !aRenderTopOrBot && module->IsFlipped() ) ) render_3D_module( module, aRenderTransparentOnly ); @@ -1094,14 +1096,14 @@ void C3D_RENDER_OGL_LEGACY::render_3D_module( const MODULE* module, { if( !module->Models().empty() ) { - const double zpos = m_settings.GetModulesZcoord3DIU( module->IsFlipped() ); + const double zpos = m_boardAdapter.GetModulesZcoord3DIU( module->IsFlipped() ); glPushMatrix(); wxPoint pos = module->GetPosition(); - glTranslatef( pos.x * m_settings.BiuTo3Dunits(), - -pos.y * m_settings.BiuTo3Dunits(), + glTranslatef( pos.x * m_boardAdapter.BiuTo3Dunits(), + -pos.y * m_boardAdapter.BiuTo3Dunits(), zpos ); if( module->GetOrientation() ) @@ -1113,7 +1115,7 @@ void C3D_RENDER_OGL_LEGACY::render_3D_module( const MODULE* module, glRotatef( 180.0f, 0.0f, 0.0f, 1.0f ); } - double modelunit_to_3d_units_factor = m_settings.BiuTo3Dunits() * UNITS3D_TO_UNITSPCB; + double modelunit_to_3d_units_factor = m_boardAdapter.BiuTo3Dunits() * UNITS3D_TO_UNITSPCB; glScaled( modelunit_to_3d_units_factor, modelunit_to_3d_units_factor, @@ -1153,7 +1155,7 @@ void C3D_RENDER_OGL_LEGACY::render_3D_module( const MODULE* module, else modelPtr->Draw_opaque(); - if( m_settings.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ) ) + if( m_boardAdapter.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ) ) { glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); @@ -1210,11 +1212,11 @@ void C3D_RENDER_OGL_LEGACY::generate_new_3DGrid( GRID3D_TYPE aGridType ) const double zpos = 0.0; // Color of grid lines - const SFVEC3F gridColor = m_settings.GetColor( DARKGRAY ); + const SFVEC3F gridColor = m_boardAdapter.GetColor( DARKGRAY ); // Color of grid lines every 5 lines - const SFVEC3F gridColor_marker = m_settings.GetColor( LIGHTGRAY ); - const double scale = m_settings.BiuTo3Dunits(); + const SFVEC3F gridColor_marker = m_boardAdapter.GetColor( LIGHTGRAY ); + const double scale = m_boardAdapter.BiuTo3Dunits(); const double transparency = 0.35; double griSizeMM = 0.0; @@ -1240,8 +1242,8 @@ void C3D_RENDER_OGL_LEGACY::generate_new_3DGrid( GRID3D_TYPE aGridType ) glNormal3f( 0.0, 0.0, 1.0 ); - const wxSize brd_size = m_settings.GetBoardSizeBIU(); - wxPoint brd_center_pos = m_settings.GetBoardPosBIU(); + const wxSize brd_size = m_boardAdapter.GetBoardSizeBIU(); + wxPoint brd_center_pos = m_boardAdapter.GetBoardPosBIU(); brd_center_pos.y = -brd_center_pos.y; diff --git a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.h b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.h index 494ec1dac1..59cbbd734c 100644 --- a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.h +++ b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.h @@ -59,14 +59,14 @@ typedef std::map< wxString, C_OGL_3DMODEL * > MAP_3DMODEL; class C3D_RENDER_OGL_LEGACY : public C3D_RENDER_BASE { public: - explicit C3D_RENDER_OGL_LEGACY( EDA_3D_SETTINGS &aSettings ); + explicit C3D_RENDER_OGL_LEGACY( BOARD_ADAPTER& aAdapter, CCAMERA& aCamera ); ~C3D_RENDER_OGL_LEGACY(); // Imported from C3D_RENDER_BASE void SetCurWindowSize( const wxSize &aSize ) override; bool Redraw( bool aIsMoving, REPORTER* aStatusTextReporter, - REPORTER* aWarningTextReporter ) override; + REPORTER* aWarningTextReporter ) override; int GetWaitForEditingTimeOut() override; @@ -108,9 +108,6 @@ private: MAP_3DMODEL m_3dmodel_map; private: - void generate_through_outer_holes(); - void generate_through_inner_holes(); - CLAYERS_OGL_DISP_LISTS *generate_holes_display_list( const LIST_OBJECT2D &aListHolesObject2d, const SHAPE_POLY_SET &aPoly, float aZtop, @@ -213,11 +210,6 @@ private: void set_layer_material( PCB_LAYER_ID aLayerID ); SFVEC3F get_layer_color( PCB_LAYER_ID aLayerID ); - -public: - const MAP_OGL_DISP_LISTS &GetLayerDispListMap() const { return m_ogl_disp_lists_layers; } - const CLAYERS_OGL_DISP_LISTS *GetLayerDispList( PCB_LAYER_ID aLayerId ) const { return m_ogl_disp_lists_layers.at( aLayerId ); } - const CLAYERS_OGL_DISP_LISTS *GetBoardDispList() const { return m_ogl_disp_list_board; } }; #endif // C3D_RENDER_OGL_LEGACY_H_ diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp index 3fb5ddbc93..6932f4898d 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp @@ -55,47 +55,48 @@ void C3D_RENDER_RAYTRACING::setupMaterials() { + double mmTo3Dunits = IU_PER_MM * m_boardAdapter.BiuTo3Dunits(); - if( m_settings.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) ) + if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) ) { - m_board_normal_perturbator = CBOARDNORMAL( 0.5f * IU_PER_MM * m_settings.BiuTo3Dunits() ); + m_board_normal_perturbator = CBOARDNORMAL( 0.5f * mmTo3Dunits ); - m_copper_normal_perturbator = CCOPPERNORMAL( 4.0f * IU_PER_MM * m_settings.BiuTo3Dunits(), + m_copper_normal_perturbator = CCOPPERNORMAL( 4.0f * mmTo3Dunits, &m_board_normal_perturbator ); m_solder_mask_normal_perturbator = CSOLDERMASKNORMAL( &m_board_normal_perturbator ); - m_plastic_normal_perturbator = CPLASTICNORMAL( 0.15f * IU_PER_MM * m_settings.BiuTo3Dunits() ); + m_plastic_normal_perturbator = CPLASTICNORMAL( 0.15f * mmTo3Dunits ); - m_plastic_shine_normal_perturbator = CPLASTICSHINENORMAL( 1.0f * IU_PER_MM * m_settings.BiuTo3Dunits() ); + m_plastic_shine_normal_perturbator = CPLASTICSHINENORMAL( 1.0f * mmTo3Dunits ); - m_brushed_metal_normal_perturbator = CMETALBRUSHEDNORMAL( 1.0f * IU_PER_MM * m_settings.BiuTo3Dunits() ); + m_brushed_metal_normal_perturbator = CMETALBRUSHEDNORMAL( 1.0f * mmTo3Dunits ); } // http://devernay.free.fr/cours/opengl/materials.html // Copper m_materials.m_Copper = CBLINN_PHONG_MATERIAL( - ConvertSRGBToLinear( (SFVEC3F)m_settings.m_CopperColor ) * - (SFVEC3F)(0.18f), // ambient + ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_CopperColor ) * + (SFVEC3F)(0.18f), // ambient SFVEC3F( 0.0f, 0.0f, 0.0f ), // emissive glm::clamp( ((SFVEC3F)(1.0f) - - ConvertSRGBToLinear( (SFVEC3F)m_settings.m_CopperColor ) ), + ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_CopperColor ) ), SFVEC3F( 0.0f ), SFVEC3F( 0.35f ) ), // specular 0.4f * 128.0f, // shiness 0.0f, // transparency 0.0f ); - if( m_settings.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) ) + if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) ) m_materials.m_Copper.SetNormalPerturbator( &m_copper_normal_perturbator ); m_materials.m_Paste = CBLINN_PHONG_MATERIAL( - ConvertSRGBToLinear( (SFVEC3F)m_settings.m_SolderPasteColor ) * - ConvertSRGBToLinear( (SFVEC3F)m_settings.m_SolderPasteColor ), // ambient + ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_SolderPasteColor ) * + ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_SolderPasteColor ), // ambient SFVEC3F( 0.0f, 0.0f, 0.0f ), // emissive - ConvertSRGBToLinear( (SFVEC3F)m_settings.m_SolderPasteColor ) * - ConvertSRGBToLinear( (SFVEC3F)m_settings.m_SolderPasteColor ), // specular + ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_SolderPasteColor ) * + ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_SolderPasteColor ), // specular 0.10f * 128.0f, // shiness 0.0f, // transparency 0.0f ); @@ -104,7 +105,7 @@ void C3D_RENDER_RAYTRACING::setupMaterials() SFVEC3F( 0.0f, 0.0f, 0.0f ), // emissive glm::clamp( ( ( SFVEC3F )( 1.0f ) - - ConvertSRGBToLinear( (SFVEC3F) m_settings.m_SilkScreenColorTop ) ), + - ConvertSRGBToLinear( (SFVEC3F) m_boardAdapter.m_SilkScreenColorTop ) ), SFVEC3F( 0.0f ), SFVEC3F( 0.10f ) ), // specular 0.078125f * 128.0f, // shiness @@ -112,18 +113,18 @@ void C3D_RENDER_RAYTRACING::setupMaterials() 0.0f ); const float solderMaskTop_gray = - ( m_settings.m_SolderMaskColorTop.r + m_settings.m_SolderMaskColorTop.g - + m_settings.m_SolderMaskColorTop.b ) + ( m_boardAdapter.m_SolderMaskColorTop.r + m_boardAdapter.m_SolderMaskColorTop.g + + m_boardAdapter.m_SolderMaskColorTop.b ) / 3.0f; const float solderMaskTop_transparency = solderMaskTop_gray * 0.40f + 0.005f; m_materials.m_SolderMask = CBLINN_PHONG_MATERIAL( - ConvertSRGBToLinear( (SFVEC3F) m_settings.m_SolderMaskColorTop ) * 0.10f, // ambient + ConvertSRGBToLinear( (SFVEC3F) m_boardAdapter.m_SolderMaskColorTop ) * 0.10f, // ambient SFVEC3F( 0.0f, 0.0f, 0.0f ), // emissive glm::clamp( ( ( SFVEC3F )( 1.0f ) - - ConvertSRGBToLinear( (SFVEC3F) m_settings.m_SolderMaskColorTop ) ), + - ConvertSRGBToLinear( (SFVEC3F) m_boardAdapter.m_SolderMaskColorTop ) ), SFVEC3F( 0.0f ), SFVEC3F( solderMaskTop_gray * 2.0f ) ), // specular 0.85f * 128.0f, // shiness @@ -131,18 +132,18 @@ void C3D_RENDER_RAYTRACING::setupMaterials() 0.16f ); // reflection const float solderMaskBot_gray = - ( m_settings.m_SolderMaskColorBot.r + m_settings.m_SolderMaskColorBot.g - + m_settings.m_SolderMaskColorBot.b ) + ( m_boardAdapter.m_SolderMaskColorBot.r + m_boardAdapter.m_SolderMaskColorBot.g + + m_boardAdapter.m_SolderMaskColorBot.b ) / 3.0f; const float solderMaskBot_transparency = solderMaskBot_gray * 0.40f + 0.005f; m_materials.m_SolderMask = CBLINN_PHONG_MATERIAL( - ConvertSRGBToLinear( (SFVEC3F) m_settings.m_SolderMaskColorBot ) * 0.10f, // ambient + ConvertSRGBToLinear( (SFVEC3F) m_boardAdapter.m_SolderMaskColorBot ) * 0.10f, // ambient SFVEC3F( 0.0f, 0.0f, 0.0f ), // emissive glm::clamp( ( ( SFVEC3F )( 1.0f ) - - ConvertSRGBToLinear( (SFVEC3F) m_settings.m_SolderMaskColorBot ) ), + - ConvertSRGBToLinear( (SFVEC3F) m_boardAdapter.m_SolderMaskColorBot ) ), SFVEC3F( 0.0f ), SFVEC3F( solderMaskBot_gray * 2.0f ) ), // specular 0.85f * 128.0f, // shiness @@ -153,7 +154,7 @@ void C3D_RENDER_RAYTRACING::setupMaterials() m_materials.m_SolderMask.SetNrRefractionsSamples( 1 ); m_materials.m_SolderMask.SetNrReflectionsSamples( 2 ); - if( m_settings.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) ) + if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) ) m_materials.m_SolderMask.SetNormalPerturbator( &m_solder_mask_normal_perturbator ); m_materials.m_EpoxyBoard = CBLINN_PHONG_MATERIAL( @@ -171,11 +172,11 @@ void C3D_RENDER_RAYTRACING::setupMaterials() m_materials.m_EpoxyBoard.SetAbsorvance( 10.0f ); m_materials.m_EpoxyBoard.SetNrRefractionsSamples( 3 ); - if( m_settings.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) ) + if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) ) m_materials.m_EpoxyBoard.SetNormalPerturbator( &m_board_normal_perturbator ); - SFVEC3F bgTop = ConvertSRGBToLinear( (SFVEC3F)m_settings.m_BgColorTop ); - //SFVEC3F bgBot = (SFVEC3F)m_settings.m_BgColorBot; + SFVEC3F bgTop = ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_BgColorTop ); + //SFVEC3F bgBot = (SFVEC3F)m_boardAdapter.m_BgColorBot; m_materials.m_Floor = CBLINN_PHONG_MATERIAL( bgTop * 0.125f, // ambient @@ -270,15 +271,15 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa unsigned stats_startReloadTime = GetRunningMicroSecs(); - m_settings.InitSettings( aStatusTextReporter, aWarningTextReporter ); + m_boardAdapter.InitSettings( aStatusTextReporter, aWarningTextReporter ); #ifdef PRINT_STATISTICS_3D_VIEWER unsigned stats_endReloadTime = GetRunningMicroSecs(); unsigned stats_startConvertTime = GetRunningMicroSecs(); #endif - SFVEC3F camera_pos = m_settings.GetBoardCenter3DU(); - m_settings.CameraGet().SetBoardLookAtPos( camera_pos ); + SFVEC3F camera_pos = m_boardAdapter.GetBoardCenter3DU(); + m_camera.SetBoardLookAtPos( camera_pos ); m_object_container.Clear(); m_containerWithObjectsToDelete.Clear(); @@ -295,33 +296,33 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa m_outlineBoard2dObjects = new CCONTAINER2D; - const int outlineCount = m_settings.GetBoardPoly().OutlineCount(); + const int outlineCount = m_boardAdapter.GetBoardPoly().OutlineCount(); if( outlineCount > 0 ) { float divFactor = 0.0f; - if( m_settings.GetStats_Nr_Vias() ) - divFactor = m_settings.GetStats_Med_Via_Hole_Diameter3DU() * 18.0f; + if( m_boardAdapter.GetStats_Nr_Vias() ) + divFactor = m_boardAdapter.GetStats_Med_Via_Hole_Diameter3DU() * 18.0f; else - if( m_settings.GetStats_Nr_Holes() ) - divFactor = m_settings.GetStats_Med_Hole_Diameter3DU() * 8.0f; + if( m_boardAdapter.GetStats_Nr_Holes() ) + divFactor = m_boardAdapter.GetStats_Med_Hole_Diameter3DU() * 8.0f; - SHAPE_POLY_SET boardPolyCopy = m_settings.GetBoardPoly(); + SHAPE_POLY_SET boardPolyCopy = m_boardAdapter.GetBoardPoly(); boardPolyCopy.Fracture( SHAPE_POLY_SET::PM_FAST ); for( int iOutlinePolyIdx = 0; iOutlinePolyIdx < outlineCount; iOutlinePolyIdx++ ) { Convert_path_polygon_to_polygon_blocks_and_dummy_blocks( - boardPolyCopy, - *m_outlineBoard2dObjects, - m_settings.BiuTo3Dunits(), - divFactor, - *dynamic_cast( m_settings.GetBoard() ), - iOutlinePolyIdx ); + boardPolyCopy, + *m_outlineBoard2dObjects, + m_boardAdapter.BiuTo3Dunits(), + divFactor, + *dynamic_cast( m_boardAdapter.GetBoard() ), + iOutlinePolyIdx ); } - if( m_settings.GetFlag( FL_SHOW_BOARD_BODY ) ) + if( m_boardAdapter.GetFlag( FL_SHOW_BOARD_BODY ) ) { const LIST_OBJECT2D &listObjects = m_outlineBoard2dObjects->GetList(); @@ -334,11 +335,11 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa std::vector *object2d_B = new std::vector(); // Check if there are any THT that intersects this outline object part - if( !m_settings.GetThroughHole_Outer().GetList().empty() ) + if( !m_boardAdapter.GetThroughHole_Outer().GetList().empty() ) { CONST_LIST_OBJECT2D intersectionList; - m_settings.GetThroughHole_Outer().GetListObjectsIntersects( + m_boardAdapter.GetThroughHole_Outer().GetListObjectsIntersects( object2d_A->GetBBox(), intersectionList ); @@ -367,17 +368,17 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa { #if 0 create_3d_object_from( m_object_container, object2d_A, - m_settings.GetLayerBottomZpos3DU( F_Cu ), - m_settings.GetLayerBottomZpos3DU( B_Cu ), + m_boardAdapter.GetLayerBottomZpos3DU( F_Cu ), + m_boardAdapter.GetLayerBottomZpos3DU( B_Cu ), &m_materials.m_EpoxyBoard, g_epoxyColor ); #else CLAYERITEM *objPtr = new CLAYERITEM( object2d_A, - m_settings.GetLayerBottomZpos3DU( F_Cu ), - m_settings.GetLayerBottomZpos3DU( B_Cu ) ); + m_boardAdapter.GetLayerBottomZpos3DU( F_Cu ), + m_boardAdapter.GetLayerBottomZpos3DU( B_Cu ) ); objPtr->SetMaterial( &m_materials.m_EpoxyBoard ); - objPtr->SetColor( ConvertSRGBToLinear( (SFVEC3F)m_settings.m_BoardBodyColor ) ); + objPtr->SetColor( ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_BoardBodyColor ) ); m_object_container.Add( objPtr ); #endif } @@ -387,16 +388,16 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa object2d_A, object2d_B, CSGITEM_FULL, - (const BOARD_ITEM &)*m_settings.GetBoard() ); + (const BOARD_ITEM &)*m_boardAdapter.GetBoard() ); m_containerWithObjectsToDelete.Add( itemCSG2d ); CLAYERITEM *objPtr = new CLAYERITEM( itemCSG2d, - m_settings.GetLayerBottomZpos3DU( F_Cu ), - m_settings.GetLayerBottomZpos3DU( B_Cu ) ); + m_boardAdapter.GetLayerBottomZpos3DU( F_Cu ), + m_boardAdapter.GetLayerBottomZpos3DU( B_Cu ) ); objPtr->SetMaterial( &m_materials.m_EpoxyBoard ); - objPtr->SetColor( ConvertSRGBToLinear( (SFVEC3F)m_settings.m_BoardBodyColor ) ); + objPtr->SetColor( ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_BoardBodyColor ) ); m_object_container.Add( objPtr ); } } @@ -408,9 +409,9 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa // So this will add a full hole. // In fact, that is not need if the hole have copper. // ///////////////////////////////////////////////////////////////////////// - if( !m_settings.GetThroughHole_Outer().GetList().empty() ) + if( !m_boardAdapter.GetThroughHole_Outer().GetList().empty() ) { - const LIST_OBJECT2D &holeList = m_settings.GetThroughHole_Outer().GetList(); + const LIST_OBJECT2D &holeList = m_boardAdapter.GetThroughHole_Outer().GetList(); for( LIST_OBJECT2D::const_iterator hole = holeList.begin(); hole != holeList.end(); @@ -426,12 +427,12 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa CVCYLINDER *objPtr = new CVCYLINDER( hole2d->GetCentroid(), - NextFloatDown( m_settings.GetLayerBottomZpos3DU( F_Cu ) ), - NextFloatUp( m_settings.GetLayerBottomZpos3DU( B_Cu ) ), + NextFloatDown( m_boardAdapter.GetLayerBottomZpos3DU( F_Cu ) ), + NextFloatUp( m_boardAdapter.GetLayerBottomZpos3DU( B_Cu ) ), radius ); objPtr->SetMaterial( &m_materials.m_EpoxyBoard ); - objPtr->SetColor( ConvertSRGBToLinear( (SFVEC3F)m_settings.m_BoardBodyColor ) ); + objPtr->SetColor( ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_BoardBodyColor ) ); m_object_container.Add( objPtr ); } @@ -453,8 +454,8 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa printf("Add layers maps...\n"); #endif - for( MAP_CONTAINER_2D::const_iterator ii = m_settings.GetMapLayers().begin(); - ii != m_settings.GetMapLayers().end(); + for( MAP_CONTAINER_2D::const_iterator ii = m_boardAdapter.GetMapLayers().begin(); + ii != m_boardAdapter.GetMapLayers().end(); ++ii ) { PCB_LAYER_ID layer_id = static_cast(ii->first); @@ -476,27 +477,27 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa case F_Paste: materialLayer = &m_materials.m_Paste; - if( m_settings.GetFlag( FL_USE_REALISTIC_MODE ) ) - layerColor = m_settings.m_SolderPasteColor; + if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) ) + layerColor = m_boardAdapter.m_SolderPasteColor; else - layerColor = m_settings.GetLayerColor( layer_id ); + layerColor = m_boardAdapter.GetLayerColor( layer_id ); break; case B_SilkS: materialLayer = &m_materials.m_SilkS; - if( m_settings.GetFlag( FL_USE_REALISTIC_MODE ) ) - layerColor = m_settings.m_SilkScreenColorBot; + if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) ) + layerColor = m_boardAdapter.m_SilkScreenColorBot; else - layerColor = m_settings.GetLayerColor( layer_id ); + layerColor = m_boardAdapter.GetLayerColor( layer_id ); break; case F_SilkS: materialLayer = &m_materials.m_SilkS; - if( m_settings.GetFlag( FL_USE_REALISTIC_MODE ) ) - layerColor = m_settings.m_SilkScreenColorTop; + if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) ) + layerColor = m_boardAdapter.m_SilkScreenColorTop; else - layerColor = m_settings.GetLayerColor( layer_id ); + layerColor = m_boardAdapter.GetLayerColor( layer_id ); break; case Dwgs_User: @@ -518,10 +519,10 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa default: materialLayer = &m_materials.m_Copper; - if( m_settings.GetFlag( FL_USE_REALISTIC_MODE ) ) - layerColor = m_settings.m_CopperColor; + if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) ) + layerColor = m_boardAdapter.m_CopperColor; else - layerColor = m_settings.GetLayerColor( layer_id ); + layerColor = m_boardAdapter.GetLayerColor( layer_id ); break; } @@ -548,7 +549,7 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa // Check if there are any layerhole that intersects this object // Eg: a segment is cutted by a via hole or THT hole. // ///////////////////////////////////////////////////////////// - const MAP_CONTAINER_2D &layerHolesMap = m_settings.GetMapLayersHoles(); + const MAP_CONTAINER_2D &layerHolesMap = m_boardAdapter.GetMapLayersHoles(); if( layerHolesMap.find(layer_id) != layerHolesMap.end() ) { @@ -579,11 +580,11 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa // Check if there are any THT that intersects this object // ///////////////////////////////////////////////////////////// - if( !m_settings.GetThroughHole_Outer().GetList().empty() ) + if( !m_boardAdapter.GetThroughHole_Outer().GetList().empty() ) { CONST_LIST_OBJECT2D intersectionList; - m_settings.GetThroughHole_Outer().GetListObjectsIntersects( + m_boardAdapter.GetThroughHole_Outer().GetListObjectsIntersects( object2d_A->GetBBox(), intersectionList ); @@ -604,9 +605,9 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa } - const MAP_CONTAINER_2D& mapLayers = m_settings.GetMapLayers(); + const MAP_CONTAINER_2D& mapLayers = m_boardAdapter.GetMapLayers(); - if( m_settings.GetFlag( FL_SUBTRACT_MASK_FROM_SILK ) && + if( m_boardAdapter.GetFlag( FL_SUBTRACT_MASK_FROM_SILK ) && ( ( ( layer_id == B_SilkS ) && ( mapLayers.find( B_Mask ) != mapLayers.end() ) ) || ( ( layer_id == F_SilkS ) && @@ -647,14 +648,14 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa #if 0 create_3d_object_from( m_object_container, object2d_A, - m_settings.GetLayerBottomZpos3DU( layer_id ), - m_settings.GetLayerTopZpos3DU( layer_id ), + m_boardAdapter.GetLayerBottomZpos3DU( layer_id ), + m_boardAdapter.GetLayerTopZpos3DU( layer_id ), materialLayer, layerColor ); #else CLAYERITEM *objPtr = new CLAYERITEM( object2d_A, - m_settings.GetLayerBottomZpos3DU( layer_id ), - m_settings.GetLayerTopZpos3DU( layer_id ) ); + m_boardAdapter.GetLayerBottomZpos3DU( layer_id ), + m_boardAdapter.GetLayerTopZpos3DU( layer_id ) ); objPtr->SetMaterial( materialLayer ); objPtr->SetColor( ConvertSRGBToLinear( layerColor ) ); m_object_container.Add( objPtr ); @@ -670,8 +671,8 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa m_containerWithObjectsToDelete.Add( itemCSG2d ); CLAYERITEM *objPtr = new CLAYERITEM( itemCSG2d, - m_settings.GetLayerBottomZpos3DU( layer_id ), - m_settings.GetLayerTopZpos3DU( layer_id ) ); + m_boardAdapter.GetLayerBottomZpos3DU( layer_id ), + m_boardAdapter.GetLayerTopZpos3DU( layer_id ) ); objPtr->SetMaterial( materialLayer ); objPtr->SetColor( ConvertSRGBToLinear( layerColor ) ); @@ -690,13 +691,13 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa // We will check for all objects in the outline if it intersects any object // in the layer container and also any hole. // ///////////////////////////////////////////////////////////////////////// - if( m_settings.GetFlag( FL_SOLDERMASK ) && + if( m_boardAdapter.GetFlag( FL_SOLDERMASK ) && (m_outlineBoard2dObjects->GetList().size() >= 1) ) { CMATERIAL *materialLayer = &m_materials.m_SolderMask; - for( MAP_CONTAINER_2D::const_iterator ii = m_settings.GetMapLayers().begin(); - ii != m_settings.GetMapLayers().end(); + for( MAP_CONTAINER_2D::const_iterator ii = m_boardAdapter.GetMapLayers().begin(); + ii != m_boardAdapter.GetMapLayers().end(); ++ii ) { PCB_LAYER_ID layer_id = static_cast(ii->first); @@ -709,18 +710,18 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa continue; SFVEC3F layerColor; - if( m_settings.GetFlag( FL_USE_REALISTIC_MODE ) ) + if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) ) { if( layer_id == B_Mask ) - layerColor = m_settings.m_SolderMaskColorBot; + layerColor = m_boardAdapter.m_SolderMaskColorBot; else - layerColor = m_settings.m_SolderMaskColorTop; + layerColor = m_boardAdapter.m_SolderMaskColorTop; } else - layerColor = m_settings.GetLayerColor( layer_id ); + layerColor = m_boardAdapter.GetLayerColor( layer_id ); - const float zLayerMin = m_settings.GetLayerBottomZpos3DU( layer_id ); - const float zLayerMax = m_settings.GetLayerTopZpos3DU( layer_id ); + const float zLayerMin = m_boardAdapter.GetLayerBottomZpos3DU( layer_id ); + const float zLayerMax = m_boardAdapter.GetLayerTopZpos3DU( layer_id ); // Get the outline board objects const LIST_OBJECT2D &listObjects = m_outlineBoard2dObjects->GetList(); @@ -734,12 +735,12 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa std::vector *object2d_B = new std::vector(); // Check if there are any THT that intersects this outline object part - if( !m_settings.GetThroughHole_Outer().GetList().empty() ) + if( !m_boardAdapter.GetThroughHole_Outer().GetList().empty() ) { CONST_LIST_OBJECT2D intersectionList; - m_settings.GetThroughHole_Outer().GetListObjectsIntersects( + m_boardAdapter.GetThroughHole_Outer().GetListObjectsIntersects( object2d_A->GetBBox(), intersectionList ); @@ -846,9 +847,9 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa // Add floor // ///////////////////////////////////////////////////////////////////////// - if( m_settings.GetFlag( FL_RENDER_RAYTRACING_BACKFLOOR ) ) + if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_BACKFLOOR ) ) { - CBBOX boardBBox = m_settings.GetBBox3DU(); + CBBOX boardBBox = m_boardAdapter.GetBBox3DU(); if( boardBBox.IsInitialized() ) { @@ -891,8 +892,8 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa newTriangle1->SetMaterial( (const CMATERIAL *)&m_materials.m_Floor ); newTriangle2->SetMaterial( (const CMATERIAL *)&m_materials.m_Floor ); - newTriangle1->SetColor( ConvertSRGBToLinear( (SFVEC3F)m_settings.m_BgColorTop ) ); - newTriangle2->SetColor( ConvertSRGBToLinear( (SFVEC3F)m_settings.m_BgColorTop ) ); + newTriangle1->SetColor( ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_BgColorTop ) ); + newTriangle2->SetColor( ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_BgColorTop ) ); } } } @@ -915,7 +916,7 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa // Option 1 - using Point Lights - const SFVEC3F &boarCenter = m_settings.GetBBox3DU().GetCenter(); + const SFVEC3F &boarCenter = m_boardAdapter.GetBBox3DU().GetCenter(); m_lights.Add( new CPOINTLIGHT( SFVEC3F( boarCenter.x, boarCenter.y, +RANGE_SCALE_3D * 2.0f ), SFVEC3F( light_top_bottom ) ) ); @@ -1035,19 +1036,19 @@ void C3D_RENDER_RAYTRACING::insert3DViaHole( const VIA* aVia ) aVia->LayerPair( &top_layer, &bottom_layer ); - float topZ = m_settings.GetLayerBottomZpos3DU( top_layer ) + - m_settings.GetCopperThickness3DU(); + float topZ = m_boardAdapter.GetLayerBottomZpos3DU( top_layer ) + + m_boardAdapter.GetCopperThickness3DU(); - float botZ = m_settings.GetLayerBottomZpos3DU( bottom_layer ) - - m_settings.GetCopperThickness3DU(); + float botZ = m_boardAdapter.GetLayerBottomZpos3DU( bottom_layer ) - + m_boardAdapter.GetCopperThickness3DU(); - const SFVEC2F center = SFVEC2F( aVia->GetStart().x * m_settings.BiuTo3Dunits(), - -aVia->GetStart().y * m_settings.BiuTo3Dunits() ); + const SFVEC2F center = SFVEC2F( aVia->GetStart().x * m_boardAdapter.BiuTo3Dunits(), + -aVia->GetStart().y * m_boardAdapter.BiuTo3Dunits() ); CRING2D *ring = new CRING2D( center, - radiusBUI * m_settings.BiuTo3Dunits(), - ( radiusBUI + m_settings.GetCopperThicknessBIU() ) * - m_settings.BiuTo3Dunits(), + radiusBUI * m_boardAdapter.BiuTo3Dunits(), + ( radiusBUI + m_boardAdapter.GetCopperThicknessBIU() ) * + m_boardAdapter.BiuTo3Dunits(), *aVia ); m_containerWithObjectsToDelete.Add( ring ); @@ -1057,11 +1058,11 @@ void C3D_RENDER_RAYTRACING::insert3DViaHole( const VIA* aVia ) objPtr->SetMaterial( &m_materials.m_Copper ); - if( m_settings.GetFlag( FL_USE_REALISTIC_MODE ) ) - objPtr->SetColor( ConvertSRGBToLinear( (SFVEC3F)m_settings.m_CopperColor ) ); + if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) ) + objPtr->SetColor( ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_CopperColor ) ); else objPtr->SetColor( ConvertSRGBToLinear( - m_settings.GetItemColor( LAYER_VIAS + static_cast( aVia->GetViaType() ) ) ) ); + m_boardAdapter.GetItemColor( LAYER_VIAS + static_cast( aVia->GetViaType() ) ) ) ); m_object_container.Add( objPtr ); } @@ -1075,10 +1076,10 @@ void C3D_RENDER_RAYTRACING::insert3DPadHole( const D_PAD* aPad ) SFVEC3F objColor; - if( m_settings.GetFlag( FL_USE_REALISTIC_MODE ) ) - objColor = (SFVEC3F)m_settings.m_CopperColor; + if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) ) + objColor = (SFVEC3F)m_boardAdapter.m_CopperColor; else - objColor = m_settings.GetItemColor( LAYER_PADS_TH ); + objColor = m_boardAdapter.GetItemColor( LAYER_PADS_TH ); const wxSize drillsize = aPad->GetDrillSize(); const bool hasHole = drillsize.x && drillsize.y; @@ -1086,22 +1087,22 @@ void C3D_RENDER_RAYTRACING::insert3DPadHole( const D_PAD* aPad ) if( !hasHole ) return; - const float topZ = m_settings.GetLayerBottomZpos3DU( F_Cu ) + - m_settings.GetCopperThickness3DU(); + const float topZ = m_boardAdapter.GetLayerBottomZpos3DU( F_Cu ) + + m_boardAdapter.GetCopperThickness3DU(); - const float botZ = m_settings.GetLayerBottomZpos3DU( B_Cu ) - - m_settings.GetCopperThickness3DU(); + const float botZ = m_boardAdapter.GetLayerBottomZpos3DU( B_Cu ) - + m_boardAdapter.GetCopperThickness3DU(); if( drillsize.x == drillsize.y ) // usual round hole { - SFVEC2F center = SFVEC2F( aPad->GetPosition().x * m_settings.BiuTo3Dunits(), - -aPad->GetPosition().y * m_settings.BiuTo3Dunits() ); + SFVEC2F center = SFVEC2F( aPad->GetPosition().x * m_boardAdapter.BiuTo3Dunits(), + -aPad->GetPosition().y * m_boardAdapter.BiuTo3Dunits() ); CRING2D *ring = new CRING2D( center, - ( drillsize.x / 2 ) * m_settings.BiuTo3Dunits(), - ( ( drillsize.x / 2 ) + - m_settings.GetCopperThicknessBIU() ) * - m_settings.BiuTo3Dunits(), + ( drillsize.x / 2 ) * m_boardAdapter.BiuTo3Dunits(), + (( drillsize.x / 2 ) + + m_boardAdapter.GetCopperThicknessBIU() ) * + m_boardAdapter.BiuTo3Dunits(), *aPad ); m_containerWithObjectsToDelete.Add( ring ); @@ -1130,20 +1131,20 @@ void C3D_RENDER_RAYTRACING::insert3DPadHole( const D_PAD* aPad ) wxPoint end = aPad->GetPosition() - ends_offset; CROUNDSEGMENT2D *innerSeg = new CROUNDSEGMENT2D( - SFVEC2F( start.x * m_settings.BiuTo3Dunits(), - -start.y * m_settings.BiuTo3Dunits() ), - SFVEC2F( end.x * m_settings.BiuTo3Dunits(), - -end.y * m_settings.BiuTo3Dunits() ), - width * m_settings.BiuTo3Dunits(), + SFVEC2F( start.x * m_boardAdapter.BiuTo3Dunits(), + -start.y * m_boardAdapter.BiuTo3Dunits() ), + SFVEC2F( end.x * m_boardAdapter.BiuTo3Dunits(), + -end.y * m_boardAdapter.BiuTo3Dunits() ), + width * m_boardAdapter.BiuTo3Dunits(), *aPad ); CROUNDSEGMENT2D *outerSeg = new CROUNDSEGMENT2D( - SFVEC2F( start.x * m_settings.BiuTo3Dunits(), - -start.y * m_settings.BiuTo3Dunits() ), - SFVEC2F( end.x * m_settings.BiuTo3Dunits(), - -end.y * m_settings.BiuTo3Dunits() ), - ( width + m_settings.GetCopperThicknessBIU() * 2 ) * - m_settings.BiuTo3Dunits(), + SFVEC2F( start.x * m_boardAdapter.BiuTo3Dunits(), + -start.y * m_boardAdapter.BiuTo3Dunits() ), + SFVEC2F( end.x * m_boardAdapter.BiuTo3Dunits(), + -end.y * m_boardAdapter.BiuTo3Dunits() ), + ( width + m_boardAdapter.GetCopperThicknessBIU() * 2 ) * + m_boardAdapter.BiuTo3Dunits(), *aPad ); // NOTE: the round segment width is the "diameter", so we double the thickness @@ -1170,12 +1171,12 @@ void C3D_RENDER_RAYTRACING::insert3DPadHole( const D_PAD* aPad ) // Check if there are any other THT that intersects this hole // It will use the non inflated holes - if( !m_settings.GetThroughHole_Inner().GetList().empty() ) + if( !m_boardAdapter.GetThroughHole_Inner().GetList().empty() ) { CONST_LIST_OBJECT2D intersectionList; - m_settings.GetThroughHole_Inner().GetListObjectsIntersects( object2d_A->GetBBox(), - intersectionList ); + m_boardAdapter.GetThroughHole_Inner().GetListObjectsIntersects( object2d_A->GetBBox(), + intersectionList ); if( !intersectionList.empty() ) { @@ -1232,7 +1233,7 @@ void C3D_RENDER_RAYTRACING::add_3D_vias_and_pads_to_container() // ///////////////////////////////////////////////////////////////////////// // Insert vias holes (vertical cylinders) - for( auto track : m_settings.GetBoard()->Tracks() ) + for( auto track : m_boardAdapter.GetBoard()->Tracks() ) { if( track->Type() == PCB_VIA_T ) { @@ -1242,7 +1243,7 @@ void C3D_RENDER_RAYTRACING::add_3D_vias_and_pads_to_container() } // Insert pads holes (vertical cylinders) - for( auto module : m_settings.GetBoard()->Modules() ) + for( auto module : m_boardAdapter.GetBoard()->Modules() ) { for( auto pad : module->Pads() ) if( pad->GetAttribute () != PAD_ATTRIB_HOLE_NOT_PLATED ) @@ -1256,20 +1257,20 @@ void C3D_RENDER_RAYTRACING::add_3D_vias_and_pads_to_container() void C3D_RENDER_RAYTRACING::load_3D_models() { // Go for all modules - for( auto module : m_settings.GetBoard()->Modules() ) + for( auto module : m_boardAdapter.GetBoard()->Modules() ) { - if( (!module->Models().empty() ) && - m_settings.ShouldModuleBeDisplayed( (MODULE_ATTR_T)module->GetAttributes() ) ) + if((!module->Models().empty() ) && + m_boardAdapter.ShouldModuleBeDisplayed((MODULE_ATTR_T)module->GetAttributes() ) ) { - double zpos = m_settings.GetModulesZcoord3DIU( module->IsFlipped() ); + double zpos = m_boardAdapter.GetModulesZcoord3DIU( module->IsFlipped() ); wxPoint pos = module->GetPosition(); glm::mat4 moduleMatrix = glm::mat4( 1.0f ); moduleMatrix = glm::translate( moduleMatrix, - SFVEC3F( pos.x * m_settings.BiuTo3Dunits(), - -pos.y * m_settings.BiuTo3Dunits(), + SFVEC3F( pos.x * m_boardAdapter.BiuTo3Dunits(), + -pos.y * m_boardAdapter.BiuTo3Dunits(), zpos ) ); if( module->GetOrientation() ) @@ -1292,7 +1293,7 @@ void C3D_RENDER_RAYTRACING::load_3D_models() SFVEC3F( 0.0f, 0.0f, 1.0f ) ); } - const double modelunit_to_3d_units_factor = m_settings.BiuTo3Dunits() * + const double modelunit_to_3d_units_factor = m_boardAdapter.BiuTo3Dunits() * UNITS3D_TO_UNITSPCB; moduleMatrix = glm::scale( moduleMatrix, @@ -1309,7 +1310,7 @@ void C3D_RENDER_RAYTRACING::load_3D_models() { // get it from cache const S3DMODEL *modelPtr = - m_settings.Get3DCacheManager()->GetModel( sM->m_Filename ); + m_boardAdapter.Get3DCacheManager()->GetModel( sM->m_Filename ); // only add it if the return is not NULL if( modelPtr ) @@ -1392,7 +1393,7 @@ void C3D_RENDER_RAYTRACING::add_3D_models( const S3DMODEL *a3DModel, imat < a3DModel->m_MaterialsSize; ++imat ) { - if( m_settings.MaterialModeGet() == MATERIAL_MODE::NORMAL ) + if( m_boardAdapter.MaterialModeGet() == MATERIAL_MODE::NORMAL ) { const SMATERIAL &material = a3DModel->m_Materials[imat]; @@ -1412,7 +1413,7 @@ void C3D_RENDER_RAYTRACING::add_3D_models( const S3DMODEL *a3DModel, SFVEC3F ambient; - if( m_settings.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) ) + if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) ) { // apply a gain to the (dark) ambient colors @@ -1440,7 +1441,7 @@ void C3D_RENDER_RAYTRACING::add_3D_models( const S3DMODEL *a3DModel, material.m_Transparency, reflectionFactor ); - if( m_settings.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) ) + if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) ) { // Guess material type and apply a normal perturbator @@ -1571,14 +1572,14 @@ void C3D_RENDER_RAYTRACING::add_3D_models( const S3DMODEL *a3DModel, const SFVEC3F diffuseColor = a3DModel->m_Materials[mesh.m_MaterialIdx].m_Diffuse; - if( m_settings.MaterialModeGet() == MATERIAL_MODE::CAD_MODE ) + if( m_boardAdapter.MaterialModeGet() == MATERIAL_MODE::CAD_MODE ) newTriangle->SetColor( ConvertSRGBToLinear( MaterialDiffuseToColorCAD( diffuseColor ) ) ); else newTriangle->SetColor( ConvertSRGBToLinear( diffuseColor ) ); } else { - if( m_settings.MaterialModeGet() == MATERIAL_MODE::CAD_MODE ) + if( m_boardAdapter.MaterialModeGet() == MATERIAL_MODE::CAD_MODE ) newTriangle->SetColor( ConvertSRGBToLinear( MaterialDiffuseToColorCAD( mesh.m_Color[idx0] ) ), ConvertSRGBToLinear( MaterialDiffuseToColorCAD( mesh.m_Color[idx1] ) ), ConvertSRGBToLinear( MaterialDiffuseToColorCAD( mesh.m_Color[idx2] ) ) ); diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.cpp index 144231960d..8c8613c048 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.cpp @@ -46,9 +46,9 @@ // convertLinearToSRGB //#include -C3D_RENDER_RAYTRACING::C3D_RENDER_RAYTRACING( EDA_3D_SETTINGS &aSettings ) : - C3D_RENDER_BASE( aSettings ), - m_postshader_ssao( aSettings.CameraGet() ) +C3D_RENDER_RAYTRACING::C3D_RENDER_RAYTRACING( BOARD_ADAPTER& aAdapter, CCAMERA& aCamera ) : + C3D_RENDER_BASE( aAdapter, aCamera ), + m_postshader_ssao( aCamera ) { wxLogTrace( m_logTrace, wxT( "C3D_RENDER_RAYTRACING::C3D_RENDER_RAYTRACING" ) ); @@ -213,7 +213,7 @@ bool C3D_RENDER_RAYTRACING::Redraw( glDisable( GL_BLEND ); - const bool was_camera_changed = m_settings.CameraGet().ParametersChanged(); + const bool was_camera_changed = m_camera.ParametersChanged(); if( requestRedraw || aIsMoving || was_camera_changed ) m_rt_render_state = RT_RENDER_STATE_MAX; // Set to an invalid state, @@ -225,10 +225,10 @@ bool C3D_RENDER_RAYTRACING::Redraw( { // Set head light (camera view light) with the oposite direction of the camera if( m_camera_light ) - m_camera_light->SetDirection( -m_settings.CameraGet().GetDir() ); + m_camera_light->SetDirection( -m_camera.GetDir() ); - OGL_DrawBackground( SFVEC3F(m_settings.m_BgColorTop), - SFVEC3F(m_settings.m_BgColorBot) ); + OGL_DrawBackground( SFVEC3F( m_boardAdapter.m_BgColorTop), + SFVEC3F( m_boardAdapter.m_BgColorBot) ); // Bind PBO glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, m_pboId ); @@ -274,8 +274,8 @@ bool C3D_RENDER_RAYTRACING::Redraw( { glClear( GL_COLOR_BUFFER_BIT ); // Options if we want draw background instead - //OGL_DrawBackground( SFVEC3F(m_settings.m_BgColorTop), - // SFVEC3F(m_settings.m_BgColorBot) ); + //OGL_DrawBackground( SFVEC3F(m_boardAdapter.m_BgColorTop), + // SFVEC3F(m_boardAdapter.m_BgColorBot) ); } glWindowPos2i( m_xoffset, m_yoffset ); @@ -307,9 +307,9 @@ void C3D_RENDER_RAYTRACING::render( GLubyte *ptrPBO , REPORTER *aStatusTextRepor restart_render_state(); if( m_camera_light ) - m_camera_light->SetDirection( -m_settings.CameraGet().GetDir() ); + m_camera_light->SetDirection( -m_camera.GetDir() ); - if( m_settings.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) + if( m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) { // Set all pixels of PBO transparent (Alpha to 0) // This way it will draw the full buffer but only shows the updated ( @@ -325,8 +325,8 @@ void C3D_RENDER_RAYTRACING::render( GLubyte *ptrPBO , REPORTER *aStatusTextRepor } } - m_BgColorTop_LinearRGB = ConvertSRGBToLinear( (SFVEC3F)m_settings.m_BgColorTop ); - m_BgColorBot_LinearRGB = ConvertSRGBToLinear( (SFVEC3F)m_settings.m_BgColorBot ); + m_BgColorTop_LinearRGB = ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_BgColorTop ); + m_BgColorBot_LinearRGB = ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_BgColorBot ); } switch( m_rt_render_state ) @@ -418,12 +418,10 @@ void C3D_RENDER_RAYTRACING::rt_render_tracing( GLubyte *ptrPBO , // or mark it as finished if( m_nrBlocksRenderProgress >= m_blockPositions.size() ) { - if( m_settings.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) ) + if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) ) m_rt_render_state = RT_RENDER_STATE_POST_PROCESS_SHADE; else - { m_rt_render_state = RT_RENDER_STATE_FINISH; - } } } @@ -462,8 +460,7 @@ SFVEC3F ConvertSRGBToLinear( const SFVEC3F &aSRGBcolor ) #endif -void C3D_RENDER_RAYTRACING::rt_final_color( GLubyte *ptrPBO, - const SFVEC3F &rgbColor, +void C3D_RENDER_RAYTRACING::rt_final_color( GLubyte *ptrPBO, const SFVEC3F &rgbColor, bool applyColorSpaceConversion ) { @@ -535,7 +532,7 @@ void C3D_RENDER_RAYTRACING::rt_trace_AA_packet( const SFVEC3F *aBgColorY, const RAY *aRayPck, SFVEC3F *aOutHitColor ) { - const bool is_testShadow = m_settings.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ); + const bool is_testShadow = m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ); for( unsigned int y = 0, i = 0; y < RAYPACKET_DIM; ++y ) { @@ -665,10 +662,9 @@ void C3D_RENDER_RAYTRACING::rt_render_trace_block( GLubyte *ptrPBO , const SFVEC2I blockPosI = SFVEC2I( blockPos.x + m_xoffset, blockPos.y + m_yoffset ); - RAYPACKET blockPacket( m_settings.CameraGet(), - (SFVEC2F)blockPosI + SFVEC2F(DISP_FACTOR, DISP_FACTOR), - SFVEC2F(DISP_FACTOR, DISP_FACTOR) // Displacement random factor - ); + RAYPACKET blockPacket( m_camera, (SFVEC2F)blockPosI + SFVEC2F(DISP_FACTOR, DISP_FACTOR), + SFVEC2F(DISP_FACTOR, DISP_FACTOR) /* Displacement random factor */ ); + HITINFO_PACKET hitPacket_X0Y0[RAYPACKET_RAYS_PER_PACKET]; @@ -692,7 +688,7 @@ void C3D_RENDER_RAYTRACING::rt_render_trace_block( GLubyte *ptrPBO , { // If block is empty then set shades and continue - if( m_settings.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) ) + if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) ) { for( unsigned int y = 0; y < RAYPACKET_DIM; ++y ) { @@ -718,14 +714,13 @@ void C3D_RENDER_RAYTRACING::rt_render_trace_block( GLubyte *ptrPBO , // (as the final color will be computed on post processing) // but it is used for report progress - const bool isFinalColor = !m_settings.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ); + const bool isFinalColor = !m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ); for( unsigned int y = 0; y < RAYPACKET_DIM; ++y ) { const SFVEC3F &outColor = bgColor[y]; - const unsigned int yConst = blockPos.x + - ( (y + blockPos.y) * m_realBufferSize.x); + const unsigned int yConst = blockPos.x + ( (y + blockPos.y) * m_realBufferSize.x); for( unsigned int x = 0; x < RAYPACKET_DIM; ++x ) { @@ -748,10 +743,10 @@ void C3D_RENDER_RAYTRACING::rt_render_trace_block( GLubyte *ptrPBO , rt_shades_packet( bgColor, blockPacket.m_ray, hitPacket_X0Y0, - m_settings.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ), + m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ), hitColor_X0Y0 ); - if( m_settings.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING ) ) + if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING ) ) { SFVEC3F hitColor_AA_X1Y1[RAYPACKET_RAYS_PER_PACKET]; @@ -761,10 +756,8 @@ void C3D_RENDER_RAYTRACING::rt_render_trace_block( GLubyte *ptrPBO , HITINFO_PACKET hitPacket_AA_X1Y1[RAYPACKET_RAYS_PER_PACKET]; HITINFO_PACKET_init( hitPacket_AA_X1Y1 ); - RAYPACKET blockPacket_AA_X1Y1( m_settings.CameraGet(), - (SFVEC2F)blockPosI + SFVEC2F(0.5f, 0.5f), - SFVEC2F(DISP_FACTOR, DISP_FACTOR) // Displacement random factor - ); + RAYPACKET blockPacket_AA_X1Y1( m_camera, (SFVEC2F)blockPosI + SFVEC2F(0.5f, 0.5f), + SFVEC2F(DISP_FACTOR, DISP_FACTOR) ); if( !m_accelerator->Intersect( blockPacket_AA_X1Y1, hitPacket_AA_X1Y1 ) ) { @@ -784,7 +777,7 @@ void C3D_RENDER_RAYTRACING::rt_render_trace_block( GLubyte *ptrPBO , rt_shades_packet( bgColor, blockPacket_AA_X1Y1.m_ray, hitPacket_AA_X1Y1, - m_settings.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ), + m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ), hitColor_AA_X1Y1 ); } @@ -807,17 +800,17 @@ void C3D_RENDER_RAYTRACING::rt_render_trace_block( GLubyte *ptrPBO , RAY blockRayPck_AA_X0Y1[RAYPACKET_RAYS_PER_PACKET]; RAY blockRayPck_AA_X1Y1_half[RAYPACKET_RAYS_PER_PACKET]; - RAYPACKET_InitRays_with2DDisplacement( m_settings.CameraGet(), + RAYPACKET_InitRays_with2DDisplacement( m_camera, (SFVEC2F)blockPosI + SFVEC2F(0.5f - DISP_FACTOR, DISP_FACTOR), SFVEC2F(DISP_FACTOR, DISP_FACTOR), // Displacement random factor blockRayPck_AA_X1Y0 ); - RAYPACKET_InitRays_with2DDisplacement( m_settings.CameraGet(), + RAYPACKET_InitRays_with2DDisplacement( m_camera, (SFVEC2F)blockPosI + SFVEC2F(DISP_FACTOR, 0.5f - DISP_FACTOR), SFVEC2F(DISP_FACTOR, DISP_FACTOR), // Displacement random factor blockRayPck_AA_X0Y1 ); - RAYPACKET_InitRays_with2DDisplacement( m_settings.CameraGet(), + RAYPACKET_InitRays_with2DDisplacement( m_camera, (SFVEC2F)blockPosI + SFVEC2F(0.25f - DISP_FACTOR, 0.25f - DISP_FACTOR), SFVEC2F(DISP_FACTOR, DISP_FACTOR), // Displacement random factor blockRayPck_AA_X1Y1_half ); @@ -858,7 +851,7 @@ void C3D_RENDER_RAYTRACING::rt_render_trace_block( GLubyte *ptrPBO , const uint32_t ptrInc = (m_realBufferSize.x - RAYPACKET_DIM) * 4; - if( m_settings.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) ) + if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) ) { SFVEC2I bPos; bPos.y = blockPos.y; @@ -918,7 +911,7 @@ void C3D_RENDER_RAYTRACING::rt_render_post_process_shade( GLubyte *ptrPBO, { (void)ptrPBO; // unused - if( m_settings.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) ) + if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) ) { if( aStatusTextReporter ) aStatusTextReporter->Report( _("Rendering: Post processing shader") ); @@ -969,7 +962,7 @@ void C3D_RENDER_RAYTRACING::rt_render_post_process_blur_finish( GLubyte *ptrPBO, { (void)aStatusTextReporter; //unused - if( m_settings.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) ) + if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) ) { // Now blurs the shader result and compute the final color std::atomic nextBlock( 0 ); @@ -1105,16 +1098,16 @@ void C3D_RENDER_RAYTRACING::render_preview( GLubyte *ptrPBO ) const SFVEC2I windowsPos = SFVEC2I( windowPosUI.x + m_xoffset, windowPosUI.y + m_yoffset ); - RAYPACKET blockPacket( m_settings.CameraGet(), windowsPos, 4 ); + RAYPACKET blockPacket( m_camera, windowsPos, 4 ); HITINFO_PACKET hitPacket[RAYPACKET_RAYS_PER_PACKET]; // Initialize hitPacket with a "not hit" information - for( unsigned int i = 0; i < RAYPACKET_RAYS_PER_PACKET; ++i ) + for( HITINFO_PACKET& packet : hitPacket ) { - hitPacket[i].m_HitInfo.m_tHit = std::numeric_limits::infinity(); - hitPacket[i].m_HitInfo.m_acc_node_info = 0; - hitPacket[i].m_hitresult = false; + packet.m_HitInfo.m_tHit = std::numeric_limits::infinity(); + packet.m_HitInfo.m_acc_node_info = 0; + packet.m_hitresult = false; } // Intersect packet block @@ -1129,8 +1122,8 @@ void C3D_RENDER_RAYTRACING::render_preview( GLubyte *ptrPBO ) { const float posYfactor = (float)(windowsPos.y + y * 4.0f) / (float)m_windowSize.y; - bgColor[y] = (SFVEC3F)m_settings.m_BgColorTop * SFVEC3F(posYfactor) + - (SFVEC3F)m_settings.m_BgColorBot * ( SFVEC3F(1.0f) - SFVEC3F(posYfactor) ); + bgColor[y] = (SFVEC3F)m_boardAdapter.m_BgColorTop * SFVEC3F( posYfactor) + + (SFVEC3F)m_boardAdapter.m_BgColorBot * ( SFVEC3F( 1.0f) - SFVEC3F( posYfactor) ); } CCOLORRGB hitColorShading[RAYPACKET_RAYS_PER_PACKET]; @@ -1728,7 +1721,7 @@ SFVEC3F C3D_RENDER_RAYTRACING::shadeHit( const SFVEC3F &aBgColor, SFVEC3F hitPoint = aHitInfo.m_HitPoint; if( !m_isPreview ) - hitPoint += aHitInfo.m_HitNormal * m_settings.GetNonCopperLayerThickness3DU() * 1.2f; + hitPoint += aHitInfo.m_HitNormal * m_boardAdapter.GetNonCopperLayerThickness3DU() * 1.2f; const CMATERIAL *objMaterial = aHitInfo.pHitObject->GetMaterial(); wxASSERT( objMaterial != NULL ); @@ -1740,7 +1733,7 @@ SFVEC3F C3D_RENDER_RAYTRACING::shadeHit( const SFVEC3F &aBgColor, const LIST_LIGHT &lightList = m_lights.GetList(); #if USE_EXPERIMENTAL_SOFT_SHADOWS - const bool is_aa_enabled = m_settings.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING ) && + const bool is_aa_enabled = m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING ) && (!m_isPreview); #endif @@ -1766,7 +1759,7 @@ SFVEC3F C3D_RENDER_RAYTRACING::shadeHit( const SFVEC3F &aBgColor, /* if( (!m_isPreview) && // Little hack to make randomness to the shading and shadows - m_settings.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) ) + m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) ) vectorToLight = glm::normalize( vectorToLight + UniformRandomHemisphereDirection() * 0.1f ); */ @@ -1789,7 +1782,7 @@ SFVEC3F C3D_RENDER_RAYTRACING::shadeHit( const SFVEC3F &aBgColor, (aRecursiveLevel > 0) || // Only use soft shadows if using post processing - (!m_settings.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) ) + (!m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) ) ) { #endif @@ -1835,7 +1828,7 @@ SFVEC3F C3D_RENDER_RAYTRACING::shadeHit( const SFVEC3F &aBgColor, shadow_att_factor_sum += shadow_att_factor_light; } - if( !m_settings.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) ) + if( !m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) ) { outColor += objMaterial->Shade( aRay, aHitInfo, @@ -1894,7 +1887,7 @@ SFVEC3F C3D_RENDER_RAYTRACING::shadeHit( const SFVEC3F &aBgColor, if( !aIsInsideObject && (objMaterial->GetReflection() > 0.0f) && - m_settings.GetFlag( FL_RENDER_RAYTRACING_REFLECTIONS ) ) + m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_REFLECTIONS ) ) { const unsigned int reflection_number_of_samples = objMaterial->GetNrReflectionsSamples(); @@ -1941,8 +1934,8 @@ SFVEC3F C3D_RENDER_RAYTRACING::shadeHit( const SFVEC3F &aBgColor, // Refractions // ///////////////////////////////////////////////////////////////////// - if( (objMaterial->GetTransparency() > 0.0f) && - m_settings.GetFlag( FL_RENDER_RAYTRACING_REFRACTIONS ) ) + if((objMaterial->GetTransparency() > 0.0f) && + m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_REFRACTIONS ) ) { const float airIndex = 1.000293f; const float glassIndex = 1.49f; diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.h b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.h index bee7466a81..571f596e0c 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.h +++ b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.h @@ -59,7 +59,7 @@ typedef enum class C3D_RENDER_RAYTRACING : public C3D_RENDER_BASE { public: - explicit C3D_RENDER_RAYTRACING( EDA_3D_SETTINGS &aSettings ); + explicit C3D_RENDER_RAYTRACING( BOARD_ADAPTER& aAdapter, CCAMERA& aCamera ); ~C3D_RENDER_RAYTRACING(); diff --git a/3d-viewer/3d_rendering/c3d_render_base.cpp b/3d-viewer/3d_rendering/c3d_render_base.cpp index 0f885f5beb..b1cac973dd 100644 --- a/3d-viewer/3d_rendering/c3d_render_base.cpp +++ b/3d-viewer/3d_rendering/c3d_render_base.cpp @@ -40,8 +40,9 @@ const wxChar * C3D_RENDER_BASE::m_logTrace = wxT( "KI_TRACE_3D_RENDER" ); -C3D_RENDER_BASE::C3D_RENDER_BASE( EDA_3D_SETTINGS &aSettings) : - m_settings( aSettings ) +C3D_RENDER_BASE::C3D_RENDER_BASE( BOARD_ADAPTER& aBoardAdapter, CCAMERA& aCamera ) : + m_boardAdapter( aBoardAdapter ), + m_camera( aCamera ) { wxLogTrace( m_logTrace, wxT( "C3D_RENDER_BASE::C3D_RENDER_BASE" ) ); m_is_opengl_initialized = false; diff --git a/3d-viewer/3d_rendering/c3d_render_base.h b/3d-viewer/3d_rendering/c3d_render_base.h index 57f1e0c87b..3a4d72b7bf 100644 --- a/3d-viewer/3d_rendering/c3d_render_base.h +++ b/3d-viewer/3d_rendering/c3d_render_base.h @@ -32,7 +32,7 @@ #include -#include "3d_canvas/3d_settings.h" +#include "3d_canvas/board_adapter.h" #include #include @@ -47,7 +47,7 @@ class C3D_RENDER_BASE // Operations public: - explicit C3D_RENDER_BASE( EDA_3D_SETTINGS &aSettings ); + explicit C3D_RENDER_BASE( BOARD_ADAPTER& aBoardAdapter, CCAMERA& aCamera ); virtual ~C3D_RENDER_BASE() = 0; @@ -107,7 +107,9 @@ protected: std::unique_ptr CreateBusyIndicator() const; /// settings refrence in use for this render - EDA_3D_SETTINGS &m_settings; + BOARD_ADAPTER& m_boardAdapter; + + CCAMERA& m_camera; /// flag if the opengl specific for this render was already initialized bool m_is_opengl_initialized; diff --git a/3d-viewer/3d_viewer/3d_menubar.cpp b/3d-viewer/3d_viewer/3d_menubar.cpp index e5221d0fb3..44588e8223 100644 --- a/3d-viewer/3d_viewer/3d_menubar.cpp +++ b/3d-viewer/3d_viewer/3d_menubar.cpp @@ -103,72 +103,72 @@ void EDA_3D_VIEWER::CreateMenuBar() //clang-format off auto raytracingCondition = [this]( const SELECTION& aSel ) { - return m_settings.RenderEngineGet() != RENDER_ENGINE::OPENGL_LEGACY; + return m_boardAdapter.RenderEngineGet() != RENDER_ENGINE::OPENGL_LEGACY; }; auto NormalModeCondition = [this]( const SELECTION& aSel ) { - return m_settings.MaterialModeGet() == MATERIAL_MODE::NORMAL; + return m_boardAdapter.MaterialModeGet() == MATERIAL_MODE::NORMAL; }; auto DiffuseModeCondition = [this]( const SELECTION& aSel ) { - return m_settings.MaterialModeGet() == MATERIAL_MODE::DIFFUSE_ONLY; + return m_boardAdapter.MaterialModeGet() == MATERIAL_MODE::DIFFUSE_ONLY; }; auto CADModeCondition = [this]( const SELECTION& aSel ) { - return m_settings.MaterialModeGet() == MATERIAL_MODE::CAD_MODE; + return m_boardAdapter.MaterialModeGet() == MATERIAL_MODE::CAD_MODE; }; auto copperThicknessCondition = [this]( const SELECTION& aSel ) { - return m_settings.GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ); + return m_boardAdapter.GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ); }; auto boundingBoxesCondition = [this]( const SELECTION& aSel ) { - return m_settings.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ); + return m_boardAdapter.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ); }; auto renderShadowsCondition = [this]( const SELECTION& aSel ) { - return m_settings.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ); + return m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ); }; auto proceduralTexturesCondition = [this]( const SELECTION& aSel ) { - return m_settings.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ); + return m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ); }; auto showFloorCondition = [this]( const SELECTION& aSel ) { - return m_settings.GetFlag( FL_RENDER_RAYTRACING_BACKFLOOR ); + return m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_BACKFLOOR ); }; auto useRefractionsCondition = [this]( const SELECTION& aSel ) { - return m_settings.GetFlag( FL_RENDER_RAYTRACING_REFRACTIONS ); + return m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_REFRACTIONS ); }; auto useReflectionsCondition = [this]( const SELECTION& aSel ) { - return m_settings.GetFlag( FL_RENDER_RAYTRACING_REFLECTIONS ); + return m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_REFLECTIONS ); }; auto antiAliasingCondition = [this]( const SELECTION& aSel ) { - return m_settings.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING ); + return m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING ); }; auto postProcessCondition = [this]( const SELECTION& aSel ) { - return m_settings.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ); + return m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ); }; auto showAxesCondition = [this]( const SELECTION& aSel ) { - return m_settings.GetFlag( FL_AXIS ); + return m_boardAdapter.GetFlag( FL_AXIS ); }; //clang-format on @@ -272,27 +272,27 @@ void EDA_3D_VIEWER::CreateMenuBar() //clang-format off auto noGridCondition = [this]( const SELECTION& aSel ) { - return m_settings.GridGet() == GRID3D_TYPE::NONE; + return m_boardAdapter.GridGet() == GRID3D_TYPE::NONE; }; auto grid10mmCondition = [this]( const SELECTION& aSel ) { - return m_settings.GridGet() == GRID3D_TYPE::GRID_10MM; + return m_boardAdapter.GridGet() == GRID3D_TYPE::GRID_10MM; }; auto grid5mmCondition = [this]( const SELECTION& aSel ) { - return m_settings.GridGet() == GRID3D_TYPE::GRID_5MM; + return m_boardAdapter.GridGet() == GRID3D_TYPE::GRID_5MM; }; auto grid2p5mmCondition = [this]( const SELECTION& aSel ) { - return m_settings.GridGet() == GRID3D_TYPE::GRID_2P5MM; + return m_boardAdapter.GridGet() == GRID3D_TYPE::GRID_2P5MM; }; auto grid_1mmCondition = [this]( const SELECTION& aSel ) { - return m_settings.GridGet() == GRID3D_TYPE::GRID_1MM; + return m_boardAdapter.GridGet() == GRID3D_TYPE::GRID_1MM; }; //clang-format on diff --git a/3d-viewer/3d_viewer/3d_toolbar.cpp b/3d-viewer/3d_viewer/3d_toolbar.cpp index a5a6fcd4ff..c62940c2e7 100644 --- a/3d-viewer/3d_viewer/3d_toolbar.cpp +++ b/3d-viewer/3d_viewer/3d_toolbar.cpp @@ -102,7 +102,7 @@ void EDA_3D_VIEWER::ReCreateMainToolbar() void EDA_3D_VIEWER::SyncToolbars() { - bool isOrtho = m_settings.CameraGet().GetProjection() == PROJECTION_TYPE::ORTHO; + bool isOrtho = m_currentCamera.GetProjection() == PROJECTION_TYPE::ORTHO; m_mainToolBar->Toggle( EDA_3D_ACTIONS::toggleOrtho, isOrtho ); m_mainToolBar->Refresh(); diff --git a/3d-viewer/3d_viewer/dialogs/dialog_3D_view_option.cpp b/3d-viewer/3d_viewer/dialogs/dialog_3D_view_option.cpp index cb93be6ab3..2e94a6eaf6 100644 --- a/3d-viewer/3d_viewer/dialogs/dialog_3D_view_option.cpp +++ b/3d-viewer/3d_viewer/dialogs/dialog_3D_view_option.cpp @@ -24,7 +24,7 @@ #include "dialog_3D_view_option_base.h" #include <3d_viewer/eda_3d_viewer.h> -#include <3d_canvas/3d_settings.h> +#include <3d_canvas/board_adapter.h> #include class DIALOG_3D_VIEW_OPTIONS : public DIALOG_3D_VIEW_OPTIONS_BASE @@ -33,8 +33,8 @@ public: explicit DIALOG_3D_VIEW_OPTIONS( EDA_3D_VIEWER* parent ); private: - EDA_3D_VIEWER* m_parent; - EDA_3D_SETTINGS& m_settings; + EDA_3D_VIEWER* m_parent; + BOARD_ADAPTER& m_settings; void initDialog(); @@ -57,11 +57,11 @@ void EDA_3D_VIEWER::Install3DViewOptionDialog( wxCommandEvent& event ) } -DIALOG_3D_VIEW_OPTIONS::DIALOG_3D_VIEW_OPTIONS( EDA_3D_VIEWER* parent ) - : DIALOG_3D_VIEW_OPTIONS_BASE( parent ), m_settings( *parent->GetSettings() ) +DIALOG_3D_VIEW_OPTIONS::DIALOG_3D_VIEW_OPTIONS( EDA_3D_VIEWER* parent ) : + DIALOG_3D_VIEW_OPTIONS_BASE( parent ), + m_parent( parent ), + m_settings( parent->GetAdapter() ) { - m_parent = parent; - initDialog(); m_sdbSizerOK->SetDefault(); diff --git a/3d-viewer/3d_viewer/eda_3d_viewer.cpp b/3d-viewer/3d_viewer/eda_3d_viewer.cpp index 316e145e0e..c954508ef1 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer.cpp +++ b/3d-viewer/3d_viewer/eda_3d_viewer.cpp @@ -89,6 +89,8 @@ EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent, const wxSt wxDefaultSize, style, QUALIFIED_VIEWER3D_FRAMENAME( aParent ) ), m_mainToolBar( nullptr ), m_canvas( nullptr ), + m_currentCamera( m_trackBallCamera ), + m_trackBallCamera( RANGE_SCALE_3D ), m_toolDispatcher( nullptr ) { wxLogTrace( m_logTrace, "EDA_3D_VIEWER::EDA_3D_VIEWER %s", aTitle ); @@ -112,7 +114,8 @@ EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent, const wxSt SetStatusWidths( arrayDim( status_dims ), status_dims ); m_canvas = new EDA_3D_CANVAS( this, COGL_ATT_LIST::GetAttributesList( true ), - aParent->GetBoard(), m_settings, Prj().Get3DCacheManager() ); + aParent->GetBoard(), m_boardAdapter, m_currentCamera, + Prj().Get3DCacheManager() ); if( m_canvas ) m_canvas->SetStatusBar( status_bar ); @@ -236,10 +239,10 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event ) return; case ID_MENU3D_BGCOLOR_BOTTOM: - if( Set3DColorFromUser( m_settings.m_BgColorBot, _( "Background Color, Bottom" ), + if( Set3DColorFromUser( m_boardAdapter.m_BgColorBot, _( "Background Color, Bottom" ), nullptr ) ) { - if( m_settings.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) + if( m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) m_canvas->Request_refresh(); else NewDisplay( true ); @@ -247,9 +250,9 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event ) return; case ID_MENU3D_BGCOLOR_TOP: - if( Set3DColorFromUser( m_settings.m_BgColorTop, _( "Background Color, Top" ), nullptr ) ) + if( Set3DColorFromUser( m_boardAdapter.m_BgColorTop, _( "Background Color, Top" ), nullptr ) ) { - if( m_settings.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) + if( m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) m_canvas->Request_refresh(); else NewDisplay( true ); @@ -282,17 +285,17 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event ) break; case ID_MENU3D_FL_RENDER_MATERIAL_MODE_NORMAL: - m_settings.MaterialModeSet( MATERIAL_MODE::NORMAL ); + m_boardAdapter.MaterialModeSet( MATERIAL_MODE::NORMAL ); NewDisplay( true ); return; case ID_MENU3D_FL_RENDER_MATERIAL_MODE_DIFFUSE_ONLY: - m_settings.MaterialModeSet( MATERIAL_MODE::DIFFUSE_ONLY ); + m_boardAdapter.MaterialModeSet( MATERIAL_MODE::DIFFUSE_ONLY ); NewDisplay( true ); return; case ID_MENU3D_FL_RENDER_MATERIAL_MODE_CAD_MODE: - m_settings.MaterialModeSet( MATERIAL_MODE::CAD_MODE ); + m_boardAdapter.MaterialModeSet( MATERIAL_MODE::CAD_MODE ); NewDisplay( true ); return; @@ -318,18 +321,18 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event ) void EDA_3D_VIEWER::OnRenderEngineSelection( wxCommandEvent &event ) { - const RENDER_ENGINE old_engine = m_settings.RenderEngineGet(); + const RENDER_ENGINE old_engine = m_boardAdapter.RenderEngineGet(); if( old_engine == RENDER_ENGINE::OPENGL_LEGACY ) - m_settings.RenderEngineSet( RENDER_ENGINE::RAYTRACING ); + m_boardAdapter.RenderEngineSet( RENDER_ENGINE::RAYTRACING ); else - m_settings.RenderEngineSet( RENDER_ENGINE::OPENGL_LEGACY ); + m_boardAdapter.RenderEngineSet( RENDER_ENGINE::OPENGL_LEGACY ); wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnRenderEngineSelection type %s ", - ( m_settings.RenderEngineGet() == RENDER_ENGINE::RAYTRACING ) ? "Ray Trace" : - "OpenGL Legacy" ); + ( m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::RAYTRACING ) ? "Ray Trace" : + "OpenGL Legacy" ); - if( old_engine != m_settings.RenderEngineGet() ) + if( old_engine != m_boardAdapter.RenderEngineGet() ) RenderEngineChanged(); } @@ -339,7 +342,7 @@ void EDA_3D_VIEWER::OnDisableRayTracing( wxCommandEvent& aEvent ) wxLogTrace( m_logTrace, "EDA_3D_VIEWER::%s disabling ray tracing.", __WXFUNCTION__ ); m_disable_ray_tracing = true; - m_settings.RenderEngineSet( RENDER_ENGINE::OPENGL_LEGACY ); + m_boardAdapter.RenderEngineSet( RENDER_ENGINE::OPENGL_LEGACY ); } @@ -390,19 +393,19 @@ void EDA_3D_VIEWER::LoadSettings( APP_SETTINGS_BASE *aCfg ) aTarget.b = aColor.b; }; - set_color( colors->GetColor( LAYER_3D_BACKGROUND_BOTTOM ), m_settings.m_BgColorBot ); - set_color( colors->GetColor( LAYER_3D_BACKGROUND_TOP ), m_settings.m_BgColorTop ); - set_color( colors->GetColor( LAYER_3D_BOARD ), m_settings.m_BoardBodyColor ); - set_color( colors->GetColor( LAYER_3D_COPPER ), m_settings.m_CopperColor ); - set_color( colors->GetColor( LAYER_3D_SILKSCREEN_BOTTOM ), m_settings.m_SilkScreenColorBot ); - set_color( colors->GetColor( LAYER_3D_SILKSCREEN_TOP ), m_settings.m_SilkScreenColorTop ); - set_color( colors->GetColor( LAYER_3D_SOLDERMASK ), m_settings.m_SolderMaskColorBot ); - set_color( colors->GetColor( LAYER_3D_SOLDERMASK ), m_settings.m_SolderMaskColorTop ); - set_color( colors->GetColor( LAYER_3D_SOLDERPASTE ), m_settings.m_SolderPasteColor ); + set_color( colors->GetColor( LAYER_3D_BACKGROUND_BOTTOM ), m_boardAdapter.m_BgColorBot ); + set_color( colors->GetColor( LAYER_3D_BACKGROUND_TOP ), m_boardAdapter.m_BgColorTop ); + set_color( colors->GetColor( LAYER_3D_BOARD ), m_boardAdapter.m_BoardBodyColor ); + set_color( colors->GetColor( LAYER_3D_COPPER ), m_boardAdapter.m_CopperColor ); + set_color( colors->GetColor( LAYER_3D_SILKSCREEN_BOTTOM ), m_boardAdapter.m_SilkScreenColorBot ); + set_color( colors->GetColor( LAYER_3D_SILKSCREEN_TOP ), m_boardAdapter.m_SilkScreenColorTop ); + set_color( colors->GetColor( LAYER_3D_SOLDERMASK ), m_boardAdapter.m_SolderMaskColorBot ); + set_color( colors->GetColor( LAYER_3D_SOLDERMASK ), m_boardAdapter.m_SolderMaskColorTop ); + set_color( colors->GetColor( LAYER_3D_SOLDERPASTE ), m_boardAdapter.m_SolderPasteColor ); if( cfg ) { -#define TRANSER_SETTING( flag, field ) m_settings.SetFlag( flag, cfg->m_Render.field ) +#define TRANSER_SETTING( flag, field ) m_boardAdapter.SetFlag( flag, cfg->m_Render.field ) TRANSER_SETTING( FL_USE_REALISTIC_MODE, realistic ); TRANSER_SETTING( FL_SUBTRACT_MASK_FROM_SILK, subtract_mask_from_silk ); @@ -433,15 +436,15 @@ void EDA_3D_VIEWER::LoadSettings( APP_SETTINGS_BASE *aCfg ) TRANSER_SETTING( FL_ECO, show_eco ); TRANSER_SETTING( FL_SHOW_BOARD_BODY, show_board_body ); - m_settings.GridSet( static_cast( cfg->m_Render.grid_type ) ); + m_boardAdapter.GridSet( static_cast( cfg->m_Render.grid_type ) ); RENDER_ENGINE engine = static_cast( cfg->m_Render.engine ); wxLogTrace( m_logTrace, engine == RENDER_ENGINE::RAYTRACING ? "EDA_3D_VIEWER::LoadSettings render setting Ray Trace" : "EDA_3D_VIEWER::LoadSettings render setting OpenGL" ); - m_settings.RenderEngineSet( engine ); + m_boardAdapter.RenderEngineSet( engine ); - m_settings.MaterialModeSet( static_cast( cfg->m_Render.material_mode ) ); + m_boardAdapter.MaterialModeSet( static_cast( cfg->m_Render.material_mode ) ); #undef TRANSFER_SETTING } @@ -463,26 +466,26 @@ void EDA_3D_VIEWER::SaveSettings( APP_SETTINGS_BASE *aCfg ) colors->SetColor( aTarget, COLOR4D( aSource.r, aSource.g, aSource.b, 1.0 ) ); }; - save_color( m_settings.m_BgColorBot, LAYER_3D_BACKGROUND_BOTTOM ); - save_color( m_settings.m_BgColorTop, LAYER_3D_BACKGROUND_TOP ); - save_color( m_settings.m_BoardBodyColor, LAYER_3D_BOARD ); - save_color( m_settings.m_CopperColor, LAYER_3D_COPPER ); - save_color( m_settings.m_SilkScreenColorBot, LAYER_3D_SILKSCREEN_BOTTOM ); - save_color( m_settings.m_SilkScreenColorTop, LAYER_3D_SILKSCREEN_TOP ); - save_color( m_settings.m_SolderMaskColorTop, LAYER_3D_SOLDERMASK ); - save_color( m_settings.m_SolderPasteColor, LAYER_3D_SOLDERPASTE ); + save_color( m_boardAdapter.m_BgColorBot, LAYER_3D_BACKGROUND_BOTTOM ); + save_color( m_boardAdapter.m_BgColorTop, LAYER_3D_BACKGROUND_TOP ); + save_color( m_boardAdapter.m_BoardBodyColor, LAYER_3D_BOARD ); + save_color( m_boardAdapter.m_CopperColor, LAYER_3D_COPPER ); + save_color( m_boardAdapter.m_SilkScreenColorBot, LAYER_3D_SILKSCREEN_BOTTOM ); + save_color( m_boardAdapter.m_SilkScreenColorTop, LAYER_3D_SILKSCREEN_TOP ); + save_color( m_boardAdapter.m_SolderMaskColorTop, LAYER_3D_SOLDERMASK ); + save_color( m_boardAdapter.m_SolderPasteColor, LAYER_3D_SOLDERPASTE ); - wxLogTrace( m_logTrace, m_settings.RenderEngineGet() == RENDER_ENGINE::RAYTRACING ? + wxLogTrace( m_logTrace, m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::RAYTRACING ? "EDA_3D_VIEWER::SaveSettings render setting Ray Trace" : "EDA_3D_VIEWER::SaveSettings render setting OpenGL" ); if( cfg ) { -#define TRANSFER_SETTING( field, flag ) cfg->m_Render.field = m_settings.GetFlag( flag ) +#define TRANSFER_SETTING( field, flag ) cfg->m_Render.field = m_boardAdapter.GetFlag( flag ) - cfg->m_Render.engine = static_cast( m_settings.RenderEngineGet() ); - cfg->m_Render.grid_type = static_cast( m_settings.GridGet() ); - cfg->m_Render.material_mode = static_cast( m_settings.MaterialModeGet() ); + cfg->m_Render.engine = static_cast( m_boardAdapter.RenderEngineGet() ); + cfg->m_Render.grid_type = static_cast( m_boardAdapter.GridGet() ); + cfg->m_Render.material_mode = static_cast( m_boardAdapter.MaterialModeGet() ); TRANSFER_SETTING( opengl_copper_thickness, FL_RENDER_OPENGL_COPPER_THICKNESS ); TRANSFER_SETTING( opengl_show_model_bbox, FL_RENDER_OPENGL_SHOW_MODEL_BBOX ); @@ -548,24 +551,24 @@ void EDA_3D_VIEWER::SynchroniseColoursWithBoard() switch( stckpItem->GetBrdLayerId() ) { case F_SilkS: - m_settings.m_SilkScreenColorTop.r = color.Red() / 255.0; - m_settings.m_SilkScreenColorTop.g = color.Green() / 255.0; - m_settings.m_SilkScreenColorTop.b = color.Blue() / 255.0; + m_boardAdapter.m_SilkScreenColorTop.r = color.Red() / 255.0; + m_boardAdapter.m_SilkScreenColorTop.g = color.Green() / 255.0; + m_boardAdapter.m_SilkScreenColorTop.b = color.Blue() / 255.0; break; case B_SilkS: - m_settings.m_SilkScreenColorBot.r = color.Red() / 255.0; - m_settings.m_SilkScreenColorBot.g = color.Green() / 255.0; - m_settings.m_SilkScreenColorBot.b = color.Blue() / 255.0; + m_boardAdapter.m_SilkScreenColorBot.r = color.Red() / 255.0; + m_boardAdapter.m_SilkScreenColorBot.g = color.Green() / 255.0; + m_boardAdapter.m_SilkScreenColorBot.b = color.Blue() / 255.0; break; case F_Mask: - m_settings.m_SolderMaskColorTop.r = color.Red() / 255.0; - m_settings.m_SolderMaskColorTop.g = color.Green() / 255.0; - m_settings.m_SolderMaskColorTop.b = color.Blue() / 255.0; + m_boardAdapter.m_SolderMaskColorTop.r = color.Red() / 255.0; + m_boardAdapter.m_SolderMaskColorTop.g = color.Green() / 255.0; + m_boardAdapter.m_SolderMaskColorTop.b = color.Blue() / 255.0; break; case B_Mask: - m_settings.m_SolderMaskColorBot.r = color.Red() / 255.0; - m_settings.m_SolderMaskColorBot.g = color.Green() / 255.0; - m_settings.m_SolderMaskColorBot.b = color.Blue() / 255.0; + m_boardAdapter.m_SolderMaskColorBot.r = color.Red() / 255.0; + m_boardAdapter.m_SolderMaskColorBot.g = color.Green() / 255.0; + m_boardAdapter.m_SolderMaskColorBot.b = color.Blue() / 255.0; break; default: break; @@ -724,9 +727,9 @@ bool EDA_3D_VIEWER::Set3DSilkScreenColorFromUser() colors.push_back( CUSTOM_COLOR_ITEM( 241.0/255.0, 241.0/255.0, 241.0/255.0, "White" ) ); colors.push_back( CUSTOM_COLOR_ITEM( 4.0/255.0, 18.0/255.0, 21.0/255.0, "Dark" ) ); - if( Set3DColorFromUser( m_settings.m_SilkScreenColorTop, _( "Silkscreen Color" ), &colors ) ) + if( Set3DColorFromUser( m_boardAdapter.m_SilkScreenColorTop, _( "Silkscreen Color" ), &colors ) ) { - m_settings.m_SilkScreenColorBot = m_settings.m_SilkScreenColorTop; + m_boardAdapter.m_SilkScreenColorBot = m_boardAdapter.m_SilkScreenColorTop; NewDisplay( true ); return true; } @@ -754,9 +757,9 @@ bool EDA_3D_VIEWER::Set3DSolderMaskColorFromUser() colors.push_back( CUSTOM_COLOR_ITEM( 119/255.0, 31/255.0, 91/255.0, "Purple" ) ); colors.push_back( CUSTOM_COLOR_ITEM( 32/255.0, 2/255.0, 53/255.0, "Purple Dark" ) ); - if( Set3DColorFromUser( m_settings.m_SolderMaskColorTop, _( "Solder Mask Color" ), &colors ) ) + if( Set3DColorFromUser( m_boardAdapter.m_SolderMaskColorTop, _( "Solder Mask Color" ), &colors ) ) { - m_settings.m_SolderMaskColorBot = m_settings.m_SolderMaskColorTop; + m_boardAdapter.m_SolderMaskColorBot = m_boardAdapter.m_SolderMaskColorTop; NewDisplay( true ); return true; } @@ -774,7 +777,7 @@ bool EDA_3D_VIEWER::Set3DCopperColorFromUser() colors.push_back( CUSTOM_COLOR_ITEM( 213/255.0, 213/255.0, 213/255.0, "Silver" ) ); colors.push_back( CUSTOM_COLOR_ITEM( 160/255.0, 160/255.0, 160/255.0, "Tin" ) ); - if( Set3DColorFromUser( m_settings.m_CopperColor, _( "Copper Color" ), &colors ) ) + if( Set3DColorFromUser( m_boardAdapter.m_CopperColor, _( "Copper Color" ), &colors ) ) { NewDisplay( true ); return true; @@ -797,7 +800,7 @@ bool EDA_3D_VIEWER::Set3DBoardBodyColorFromUser() colors.push_back( CUSTOM_COLOR_ITEM( 63/255.0, 126/255.0, 71/255.0, "green 1" ) ); colors.push_back( CUSTOM_COLOR_ITEM( 117/255.0, 122/255.0, 90/255.0, "green 2" ) ); - if( Set3DColorFromUser( m_settings.m_BoardBodyColor, _( "Board Body Color" ), &colors ) ) + if( Set3DColorFromUser( m_boardAdapter.m_BoardBodyColor, _( "Board Body Color" ), &colors ) ) { NewDisplay( true ); return true; @@ -815,7 +818,7 @@ bool EDA_3D_VIEWER::Set3DSolderPasteColorFromUser() colors.push_back( CUSTOM_COLOR_ITEM( 213/255.0, 213/255.0, 213/255.0, "Silver" ) ); colors.push_back( CUSTOM_COLOR_ITEM( 90/255.0, 90/255.0, 90/255.0, "grey 2" ) ); - if( Set3DColorFromUser( m_settings.m_SolderPasteColor, _( "Solder Paste Color" ), &colors ) ) + if( Set3DColorFromUser( m_boardAdapter.m_SolderPasteColor, _( "Solder Paste Color" ), &colors ) ) { NewDisplay( true ); return true; @@ -827,7 +830,7 @@ bool EDA_3D_VIEWER::Set3DSolderPasteColorFromUser() void EDA_3D_VIEWER::OnUpdateUIEngine( wxUpdateUIEvent& aEvent ) { - aEvent.Check( m_settings.RenderEngineGet() != RENDER_ENGINE::OPENGL_LEGACY ); + aEvent.Check( m_boardAdapter.RenderEngineGet() != RENDER_ENGINE::OPENGL_LEGACY ); } @@ -837,15 +840,15 @@ void EDA_3D_VIEWER::OnUpdateUIMaterial( wxUpdateUIEvent& aEvent ) switch( aEvent.GetId() ) { case ID_MENU3D_FL_RENDER_MATERIAL_MODE_NORMAL: - aEvent.Check( m_settings.MaterialModeGet() == MATERIAL_MODE::NORMAL ); + aEvent.Check( m_boardAdapter.MaterialModeGet() == MATERIAL_MODE::NORMAL ); break; case ID_MENU3D_FL_RENDER_MATERIAL_MODE_DIFFUSE_ONLY: - aEvent.Check( m_settings.MaterialModeGet() == MATERIAL_MODE::DIFFUSE_ONLY ); + aEvent.Check( m_boardAdapter.MaterialModeGet() == MATERIAL_MODE::DIFFUSE_ONLY ); break; case ID_MENU3D_FL_RENDER_MATERIAL_MODE_CAD_MODE: - aEvent.Check( m_settings.MaterialModeGet() == MATERIAL_MODE::CAD_MODE ); + aEvent.Check( m_boardAdapter.MaterialModeGet() == MATERIAL_MODE::CAD_MODE ); break; default: @@ -862,5 +865,5 @@ void EDA_3D_VIEWER::loadCommonSettings() const DPI_SCALING dpi{ settings, this }; m_canvas->SetScaleFactor( dpi.GetScaleFactor() ); - m_settings.SetFlag( FL_MOUSEWHEEL_PANNING, settings->m_Input.mousewheel_pan ); + m_boardAdapter.SetFlag( FL_MOUSEWHEEL_PANNING, settings->m_Input.mousewheel_pan ); } diff --git a/3d-viewer/3d_viewer/eda_3d_viewer.h b/3d-viewer/3d_viewer/eda_3d_viewer.h index 6e0977cd27..d6c155c3bb 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer.h +++ b/3d-viewer/3d_viewer/eda_3d_viewer.h @@ -32,8 +32,9 @@ #ifndef EDA_3D_VIEWER_H #define EDA_3D_VIEWER_H -#include "3d_canvas/3d_settings.h" -#include "../3d_canvas/eda_3d_canvas.h" +#include "3d_canvas/board_adapter.h" +#include "3d_canvas/eda_3d_canvas.h" +#include "3d_rendering/ctrack_ball.h" #include #include #include <../common/dialogs/dialog_color_picker.h> // for CUSTOM_COLORS_LIST definition @@ -62,7 +63,7 @@ enum EDA_3D_VIEWER_STATUSBAR /** * Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard */ -class EDA_3D_VIEWER : public EDA_3D_SETTINGS_HOLDER, public KIWAY_PLAYER +class EDA_3D_VIEWER : public EDA_3D_BOARD_HOLDER, public KIWAY_PLAYER { public: @@ -101,10 +102,8 @@ class EDA_3D_VIEWER : public EDA_3D_SETTINGS_HOLDER, public KIWAY_PLAYER */ void NewDisplay( bool aForceImmediateRedraw = false ); - /** - * @return current settings - */ - EDA_3D_SETTINGS* GetSettings() override { return &m_settings; } + BOARD_ADAPTER& GetAdapter() override { return m_boardAdapter; } + CCAMERA& GetCurrentCamera() override { return m_currentCamera; } /** * Get a SFVEC3D from a wx colour dialog @@ -155,7 +154,7 @@ class EDA_3D_VIEWER : public EDA_3D_SETTINGS_HOLDER, public KIWAY_PLAYER void CommonSettingsChanged( bool aEnvVarsChanged ) override; - void SynchroniseColoursWithBoard( void ); + void SynchroniseColoursWithBoard(); private: /// Called when user press the File->Exit @@ -209,7 +208,9 @@ private: ACTION_TOOLBAR* m_mainToolBar; EDA_3D_CANVAS* m_canvas; - EDA_3D_SETTINGS m_settings; + BOARD_ADAPTER m_boardAdapter; + CCAMERA& m_currentCamera; + CTRACK_BALL m_trackBallCamera; TOOL_DISPATCHER* m_toolDispatcher; diff --git a/3d-viewer/3d_viewer/tools/3d_controller.cpp b/3d-viewer/3d_viewer/tools/3d_controller.cpp index 9c6b8a6280..1b0caece78 100644 --- a/3d-viewer/3d_viewer/tools/3d_controller.cpp +++ b/3d-viewer/3d_viewer/tools/3d_controller.cpp @@ -68,12 +68,14 @@ void EDA_3D_CONTROLLER::Reset( RESET_REASON aReason ) if( holder ) { m_canvas = dynamic_cast( holder->GetToolCanvas() ); - m_settings = dynamic_cast( holder )->GetSettings(); + m_boardAdapter = &dynamic_cast( holder )->GetAdapter(); + m_camera = &dynamic_cast( holder )->GetCurrentCamera(); } else { m_canvas = nullptr; - m_settings = nullptr; + m_boardAdapter = nullptr; + m_camera = nullptr; } } @@ -138,16 +140,16 @@ int EDA_3D_CONTROLLER::RotateView( const TOOL_EVENT& aEvent ) { switch( aEvent.Parameter() ) { - case ID_ROTATE3D_X_NEG: m_settings->CameraGet().RotateX( -glm::radians( ROT_ANGLE ) ); break; - case ID_ROTATE3D_X_POS: m_settings->CameraGet().RotateX( glm::radians( ROT_ANGLE ) ); break; - case ID_ROTATE3D_Y_NEG: m_settings->CameraGet().RotateY( -glm::radians( ROT_ANGLE ) ); break; - case ID_ROTATE3D_Y_POS: m_settings->CameraGet().RotateY( glm::radians( ROT_ANGLE ) ); break; - case ID_ROTATE3D_Z_NEG: m_settings->CameraGet().RotateZ( -glm::radians( ROT_ANGLE ) ); break; - case ID_ROTATE3D_Z_POS: m_settings->CameraGet().RotateZ( glm::radians( ROT_ANGLE ) ); break; - default: wxFAIL; break; + case ID_ROTATE3D_X_NEG: m_camera->RotateX( -glm::radians( ROT_ANGLE ) ); break; + case ID_ROTATE3D_X_POS: m_camera->RotateX( glm::radians( ROT_ANGLE ) ); break; + case ID_ROTATE3D_Y_NEG: m_camera->RotateY( -glm::radians( ROT_ANGLE ) ); break; + case ID_ROTATE3D_Y_POS: m_camera->RotateY( glm::radians( ROT_ANGLE ) ); break; + case ID_ROTATE3D_Z_NEG: m_camera->RotateZ( -glm::radians( ROT_ANGLE ) ); break; + case ID_ROTATE3D_Z_POS: m_camera->RotateZ( glm::radians( ROT_ANGLE ) ); break; + default: wxFAIL; break; } - if( m_settings->RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) + if( m_boardAdapter->RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) m_canvas->Request_refresh(); else m_canvas->RenderRaytracingRequest(); @@ -158,9 +160,9 @@ int EDA_3D_CONTROLLER::RotateView( const TOOL_EVENT& aEvent ) int EDA_3D_CONTROLLER::ToggleOrtho( const TOOL_EVENT& aEvent ) { - m_settings->CameraGet().ToggleProjection(); + m_camera->ToggleProjection(); - if( m_settings->RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) + if( m_boardAdapter->RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) m_canvas->Request_refresh(); else m_canvas->RenderRaytracingRequest(); @@ -173,7 +175,7 @@ int EDA_3D_CONTROLLER::ToggleVisibility( const TOOL_EVENT& aEvent ) { DISPLAY3D_FLG flag = aEvent.Parameter(); - m_settings->SetFlag( flag, !m_settings->GetFlag( flag ) ); + m_boardAdapter->SetFlag( flag, !m_boardAdapter->GetFlag( flag ) ); switch( flag ) { @@ -205,7 +207,7 @@ int EDA_3D_CONTROLLER::ToggleVisibility( const TOOL_EVENT& aEvent ) int EDA_3D_CONTROLLER::On3DGridSelection( const TOOL_EVENT& aEvent ) { GRID3D_TYPE grid = aEvent.Parameter(); - m_settings->GridSet( grid ); + m_boardAdapter->GridSet( grid ); if( m_canvas ) m_canvas->Request_refresh(); diff --git a/3d-viewer/3d_viewer/tools/3d_controller.h b/3d-viewer/3d_viewer/tools/3d_controller.h index 7dfdbffcd5..c0e14dc81c 100644 --- a/3d-viewer/3d_viewer/tools/3d_controller.h +++ b/3d-viewer/3d_viewer/tools/3d_controller.h @@ -27,7 +27,7 @@ #include class EDA_3D_VIEWER; -class EDA_3D_SETTINGS; +class BOARD_ADAPTER; /** @@ -40,9 +40,10 @@ class EDA_3D_CONTROLLER : public TOOL_INTERACTIVE { public: EDA_3D_CONTROLLER() : - TOOL_INTERACTIVE( "3DViewer.Control" ), - m_canvas( nullptr ), - m_settings( nullptr ) + TOOL_INTERACTIVE( "3DViewer.Control" ), + m_canvas( nullptr ), + m_boardAdapter( nullptr ), + m_camera( nullptr ) { } ~EDA_3D_CONTROLLER() override { } @@ -79,8 +80,9 @@ private: int doZoomInOut( bool aDirection, bool aCenterOnCursor ); private: - EDA_3D_CANVAS* m_canvas; - EDA_3D_SETTINGS* m_settings; + EDA_3D_CANVAS* m_canvas; + BOARD_ADAPTER* m_boardAdapter; + CCAMERA* m_camera; }; #endif diff --git a/3d-viewer/CMakeLists.txt b/3d-viewer/CMakeLists.txt index 7f4a6d3374..41dbf5a36c 100644 --- a/3d-viewer/CMakeLists.txt +++ b/3d-viewer/CMakeLists.txt @@ -35,7 +35,7 @@ set(3D-VIEWER_SRCS ${DIR_DLG}/dlg_select_3dmodel.cpp ${DIR_DLG}/panel_prev_3d_base.cpp ${DIR_DLG}/panel_prev_3d.cpp - 3d_canvas/3d_settings.cpp + 3d_canvas/board_adapter.cpp 3d_canvas/create_layer_items.cpp 3d_canvas/create_3Dgraphic_brd_items.cpp 3d_canvas/create_layer_poly.cpp diff --git a/eeschema/sch_painter.h b/eeschema/sch_painter.h index 94cad54bb1..812f3b04ee 100644 --- a/eeschema/sch_painter.h +++ b/eeschema/sch_painter.h @@ -128,7 +128,7 @@ public: m_schSettings = *static_cast( aSettings ); } - /// @copydoc PAINTER::GetSettings() + /// @copydoc PAINTER::GetAdapter() virtual SCH_RENDER_SETTINGS* GetSettings() override { return &m_schSettings; diff --git a/eeschema/sim/sim_plot_frame_base.fbp b/eeschema/sim/sim_plot_frame_base.fbp index 72eb2fa789..62871a9ca9 100644 --- a/eeschema/sim/sim_plot_frame_base.fbp +++ b/eeschema/sim/sim_plot_frame_base.fbp @@ -268,7 +268,7 @@ ID_MENU_SET_SIMUL wxITEM_NORMAL Settings... - m_settings + m_boardAdapter protected diff --git a/eeschema/tools/backannotate.h b/eeschema/tools/backannotate.h index 875b23ed5a..355fecf273 100644 --- a/eeschema/tools/backannotate.h +++ b/eeschema/tools/backannotate.h @@ -127,7 +127,7 @@ private: wxString getTextFromField( const SCH_REFERENCE& aRef, const NumFieldType aField ); /** - * @brief Check if modules has different data. Check only if corresponding \ref m_settings + * @brief Check if modules has different data. Check only if corresponding \ref m_boardAdapter * flag is rised * @param aFirst first module to compare * @param aSecond second module to compare diff --git a/gerbview/gerbview_painter.h b/gerbview/gerbview_painter.h index efd399974c..0596c93a79 100644 --- a/gerbview/gerbview_painter.h +++ b/gerbview/gerbview_painter.h @@ -175,7 +175,7 @@ public: m_gerbviewSettings = *static_cast( aSettings ); } - /// @copydoc PAINTER::GetSettings() + /// @copydoc PAINTER::GetAdapter() virtual GERBVIEW_RENDER_SETTINGS* GetSettings() override { return &m_gerbviewSettings; diff --git a/include/painter.h b/include/painter.h index 3f8ada918d..acb1687962 100644 --- a/include/painter.h +++ b/include/painter.h @@ -338,7 +338,7 @@ public: virtual void ApplySettings( const RENDER_SETTINGS* aSettings ) = 0; /** - * Function GetSettings + * Function GetAdapter * Returns pointer to current settings that are going to be used when drawing items. * @return Current rendering settings. */ diff --git a/include/tool/tool_base.h b/include/tool/tool_base.h index 5d5483ff60..ef1a2e38df 100644 --- a/include/tool/tool_base.h +++ b/include/tool/tool_base.h @@ -145,7 +145,7 @@ public: return m_toolMgr; } - //TOOL_SETTINGS& GetSettings(); + //TOOL_SETTINGS& GetAdapter(); bool IsToolActive() const; diff --git a/include/ws_painter.h b/include/ws_painter.h index 1731eab68a..6e21d97626 100644 --- a/include/ws_painter.h +++ b/include/ws_painter.h @@ -114,7 +114,7 @@ public: m_renderSettings = *static_cast( aSettings ); } - /// @copydoc PAINTER::GetSettings() + /// @copydoc PAINTER::GetAdapter() virtual RENDER_SETTINGS* GetSettings() override { return &m_renderSettings; } private: diff --git a/pcbnew/pcb_painter.h b/pcbnew/pcb_painter.h index d0c39b6be5..356c12c21b 100644 --- a/pcbnew/pcb_painter.h +++ b/pcbnew/pcb_painter.h @@ -232,7 +232,7 @@ public: m_pcbSettings = *static_cast( aSettings ); } - /// @copydoc PAINTER::GetSettings() + /// @copydoc PAINTER::GetAdapter() virtual PCB_RENDER_SETTINGS* GetSettings() override { return &m_pcbSettings;