More sensible zoom defaults for 3D viewers.

Also fixes a bug where the model viewer in the file picker was using
only 1/4 of the screen on HIDPI displays.
This commit is contained in:
Jeff Young 2021-06-28 16:47:23 +01:00
parent bcb5618315
commit 73b91a1a92
7 changed files with 24 additions and 12 deletions

View File

@ -36,7 +36,6 @@
#include <common_ogl/ogl_attr_list.h>
#include <gal/dpi_scaling.h>
#include <pgm_base.h>
#include <project.h>
#include <settings/common_settings.h>
#include <widgets/infobar.h>
@ -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();

View File

@ -38,6 +38,9 @@
#include <wx/dcclient.h>
#include <base_units.h>
#include <gl_context_mgr.h>
#include <settings/common_settings.h>
#include <pgm_base.h>
#include <gal/dpi_scaling.h>
/**
* 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() );
}

View File

@ -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;

View File

@ -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;

View File

@ -34,7 +34,8 @@
#include <wx/log.h>
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" ) );

View File

@ -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()
{

View File

@ -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 );