diff --git a/3d-viewer/3d_cache/dialogs/panel_preview_3d_model.cpp b/3d-viewer/3d_cache/dialogs/panel_preview_3d_model.cpp index f7ffdc87f9..5bbbcf84f9 100644 --- a/3d-viewer/3d_cache/dialogs/panel_preview_3d_model.cpp +++ b/3d-viewer/3d_cache/dialogs/panel_preview_3d_model.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include @@ -49,7 +48,7 @@ PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAM m_infobar( nullptr ), m_boardAdapter(), m_currentCamera( m_trackBallCamera ), - m_trackBallCamera( RANGE_SCALE_3D ) + m_trackBallCamera( RANGE_SCALE_3D, 0.85f ) { m_userUnits = aFrame->GetUserUnits(); diff --git a/3d-viewer/3d_model_viewer/eda_3d_model_viewer.cpp b/3d-viewer/3d_model_viewer/eda_3d_model_viewer.cpp index 077b264946..405669d3b5 100644 --- a/3d-viewer/3d_model_viewer/eda_3d_model_viewer.cpp +++ b/3d-viewer/3d_model_viewer/eda_3d_model_viewer.cpp @@ -38,6 +38,9 @@ #include #include #include +#include +#include +#include /** * Scale conversion from 3d model units to pcb units @@ -86,7 +89,8 @@ EDA_3D_MODEL_VIEWER::EDA_3D_MODEL_VIEWER( wxWindow* aParent, const int* aAttribL S3D_CACHE* aCacheManager ) : HIDPI_GL_CANVAS( aParent, wxID_ANY, aAttribList, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE ), - m_trackBallCamera( RANGE_SCALE_3D * 2.0f ), m_cacheManager( aCacheManager ) + m_trackBallCamera( RANGE_SCALE_3D * 2.0f, 0.38f ), + m_cacheManager( aCacheManager ) { wxLogTrace( m_logTrace, wxT( "EDA_3D_MODEL_VIEWER::EDA_3D_MODEL_VIEWER" ) ); @@ -97,6 +101,11 @@ EDA_3D_MODEL_VIEWER::EDA_3D_MODEL_VIEWER( wxWindow* aParent, const int* aAttribL m_BiuTo3dUnits = 1.0; m_glRC = nullptr; + + COMMON_SETTINGS* settings = Pgm().GetCommonSettings(); + + const DPI_SCALING dpi{ settings, this }; + SetScaleFactor( dpi.GetScaleFactor() ); } diff --git a/3d-viewer/3d_rendering/camera.cpp b/3d-viewer/3d_rendering/camera.cpp index 0604cffe72..adb21c3e98 100644 --- a/3d-viewer/3d_rendering/camera.cpp +++ b/3d-viewer/3d_rendering/camera.cpp @@ -51,11 +51,12 @@ const wxChar *CAMERA::m_logTrace = wxT( "KI_TRACE_CAMERA" ); #define MAX_ZOOM 1.25f -CAMERA::CAMERA( float aRangeScale ) +CAMERA::CAMERA( float aRangeScale, float aDefaultZoom ) { wxLogTrace( m_logTrace, wxT( "CAMERA::CAMERA" ) ); m_range_scale = aRangeScale; + m_default_zoom = aDefaultZoom; m_camera_pos_init = SFVEC3F( 0.0f, 0.0f, -(aRangeScale * 2.0f ) ); m_board_lookat_pos_init = SFVEC3F( 0.0f ); m_windowSize = SFVEC2I( 0, 0 ); @@ -75,9 +76,9 @@ void CAMERA::Reset() m_rotationMatrixAux = glm::mat4( 1.0f ); m_lastPosition = wxPoint( 0, 0 ); - m_zoom = 1.0f; - m_zoom_t0 = 1.0f; - m_zoom_t1 = 1.0f; + m_zoom = m_default_zoom; + m_zoom_t0 = m_default_zoom; + m_zoom_t1 = m_default_zoom; m_camera_pos = m_camera_pos_init; m_camera_pos_t0 = m_camera_pos_init; m_camera_pos_t1 = m_camera_pos_init; @@ -101,7 +102,7 @@ void CAMERA::Reset() void CAMERA::Reset_T1() { m_camera_pos_t1 = m_camera_pos_init; - m_zoom_t1 = 1.0f; + m_zoom_t1 = m_default_zoom; m_rotate_aux_t1 = SFVEC3F( 0.0f ); m_lookat_pos_t1 = m_board_lookat_pos_init; diff --git a/3d-viewer/3d_rendering/camera.h b/3d-viewer/3d_rendering/camera.h index 8b38cba497..d213aa9006 100644 --- a/3d-viewer/3d_rendering/camera.h +++ b/3d-viewer/3d_rendering/camera.h @@ -84,7 +84,7 @@ public: * -aRangeScale/2 to +aRangeScale/2. It will initialize the * Z position with aRangeScale. */ - explicit CAMERA( float aRangeScale ); + explicit CAMERA( float aRangeScale, float aDefaultZoom ); virtual ~CAMERA() { @@ -251,9 +251,11 @@ protected: */ float m_range_scale; + /** * 3D zoom value (Min 0.0 ... Max 1.0) */ + float m_default_zoom; float m_zoom; float m_zoom_t0; float m_zoom_t1; diff --git a/3d-viewer/3d_rendering/track_ball.cpp b/3d-viewer/3d_rendering/track_ball.cpp index 4d543ef73f..040adc7ad4 100644 --- a/3d-viewer/3d_rendering/track_ball.cpp +++ b/3d-viewer/3d_rendering/track_ball.cpp @@ -34,7 +34,8 @@ #include -TRACK_BALL::TRACK_BALL( float aRangeScale ) : CAMERA( aRangeScale ) +TRACK_BALL::TRACK_BALL( float aRangeScale, float aDefaultZoom ) : + CAMERA( aRangeScale, aDefaultZoom ) { wxLogTrace( m_logTrace, wxT( "TRACK_BALL::TRACK_BALL" ) ); diff --git a/3d-viewer/3d_rendering/track_ball.h b/3d-viewer/3d_rendering/track_ball.h index e8b1125fe0..9dd86132ac 100644 --- a/3d-viewer/3d_rendering/track_ball.h +++ b/3d-viewer/3d_rendering/track_ball.h @@ -36,7 +36,7 @@ class TRACK_BALL : public CAMERA { public: - explicit TRACK_BALL( float aRangeScale ); + explicit TRACK_BALL( float aRangeScale, float aDefaultZoom ); virtual ~TRACK_BALL() { diff --git a/3d-viewer/3d_viewer/eda_3d_viewer.cpp b/3d-viewer/3d_viewer/eda_3d_viewer.cpp index aac7f42f9b..2d18096040 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer.cpp +++ b/3d-viewer/3d_viewer/eda_3d_viewer.cpp @@ -92,7 +92,7 @@ EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME( KIWAY *aKiway, PCB_BASE_FRAME *aParent m_mainToolBar( nullptr ), m_canvas( nullptr ), m_currentCamera( m_trackBallCamera ), - m_trackBallCamera( RANGE_SCALE_3D ) + m_trackBallCamera( RANGE_SCALE_3D, 0.66f ) { wxLogTrace( m_logTrace, "EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME %s", aTitle );