Fix unlimited zoom with "Use touchpad to pan"
Additionally, fix an unreported bug allowing zoom level to get stuck at MAX_ZOOM. Fixes: lp:1625754 (3dviewer zoom not limited with Use touchpad to pan) https://bugs.launchpad.net/kicad/+bug/1625754
This commit is contained in:
parent
d0db2de015
commit
19512b46a3
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -465,14 +465,7 @@ void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent &event )
|
|||
}
|
||||
else
|
||||
{
|
||||
if( event.GetWheelRotation() > 0 )
|
||||
{
|
||||
mouseActivity = m_settings.CameraGet().ZoomIn( 1.1f );
|
||||
}
|
||||
else
|
||||
{
|
||||
mouseActivity = m_settings.CameraGet().ZoomOut( 1.1f );
|
||||
}
|
||||
mouseActivity = m_settings.CameraGet().Zoom( event.GetWheelRotation() > 0 ? 1.1f : 1/1.1f );
|
||||
}
|
||||
|
||||
// If it results on a camera movement
|
||||
|
@ -503,7 +496,7 @@ void EDA_3D_CANVAS::OnMagnify( wxMouseEvent& event )
|
|||
|
||||
float magnification = ( event.GetMagnification() + 1.0f );
|
||||
|
||||
m_settings.CameraGet().ZoomIn( magnification );
|
||||
m_settings.CameraGet().Zoom( magnification );
|
||||
|
||||
DisplayStatus();
|
||||
Request_refresh();
|
||||
|
@ -909,14 +902,14 @@ void EDA_3D_CANVAS::SetView3D( int keycode )
|
|||
case WXK_F1:
|
||||
m_settings.CameraGet().SetInterpolateMode( INTERPOLATION_BEZIER );
|
||||
m_settings.CameraGet().SetT0_and_T1_current_T();
|
||||
if( m_settings.CameraGet().ZoomIn_T1( 1.4f ) )
|
||||
if( m_settings.CameraGet().Zoom_T1( 1.4f ) )
|
||||
request_start_moving_camera( 3.0f );
|
||||
return;
|
||||
|
||||
case WXK_F2:
|
||||
m_settings.CameraGet().SetInterpolateMode( INTERPOLATION_BEZIER );
|
||||
m_settings.CameraGet().SetT0_and_T1_current_T();
|
||||
if( m_settings.CameraGet().ZoomOut_T1( 1.4f ) )
|
||||
if( m_settings.CameraGet().Zoom_T1( 1/1.4f ) )
|
||||
request_start_moving_camera( 3.0f );
|
||||
return;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -390,14 +390,7 @@ void C3D_MODEL_VIEWER::OnMouseWheel( wxMouseEvent &event )
|
|||
}
|
||||
else
|
||||
{
|
||||
if( event.GetWheelRotation() > 0 )
|
||||
{
|
||||
m_trackBallCamera.ZoomIn( 1.1f );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_trackBallCamera.ZoomOut( 1.1f );
|
||||
}
|
||||
m_trackBallCamera.Zoom( event.GetWheelRotation() > 0 ? 1.1f : 1/1.1f );
|
||||
|
||||
//DisplayStatus();
|
||||
Refresh( false );
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -451,91 +451,39 @@ void CCAMERA::ZoomReset()
|
|||
rebuildProjection();
|
||||
}
|
||||
|
||||
|
||||
bool CCAMERA::ZoomIn( float aFactor )
|
||||
bool CCAMERA::Zoom( float aFactor )
|
||||
{
|
||||
if( m_zoom > MIN_ZOOM )
|
||||
{
|
||||
const float old_zoom = m_zoom;
|
||||
if ( ( m_zoom == MIN_ZOOM && aFactor > 1 ) || ( m_zoom == MAX_ZOOM && aFactor < 1 ) || aFactor == 1 )
|
||||
return false;
|
||||
|
||||
m_zoom /= aFactor;
|
||||
m_zoom /= aFactor;
|
||||
if( m_zoom <= MIN_ZOOM )
|
||||
m_zoom = MIN_ZOOM;
|
||||
if( m_zoom >= MAX_ZOOM )
|
||||
m_zoom = MAX_ZOOM;
|
||||
|
||||
if( m_zoom <= MIN_ZOOM )
|
||||
m_zoom = MIN_ZOOM;
|
||||
m_camera_pos.z = m_camera_pos_init.z * m_zoom;
|
||||
|
||||
m_camera_pos.z = m_zoom * m_camera_pos_init.z;
|
||||
updateViewMatrix();
|
||||
rebuildProjection();
|
||||
|
||||
if( old_zoom != m_zoom )
|
||||
{
|
||||
updateViewMatrix();
|
||||
rebuildProjection();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CCAMERA::ZoomOut( float aFactor )
|
||||
bool CCAMERA::Zoom_T1( float aFactor )
|
||||
{
|
||||
if( m_zoom < MAX_ZOOM )
|
||||
{
|
||||
const float old_zoom = m_zoom;
|
||||
if( ( m_zoom == MIN_ZOOM && aFactor > 1 ) || ( m_zoom == MAX_ZOOM && aFactor < 1 ) || aFactor == 1 )
|
||||
return false;
|
||||
|
||||
m_zoom *= aFactor;
|
||||
m_zoom_t1 = m_zoom / aFactor;
|
||||
if (m_zoom_t1 < MIN_ZOOM )
|
||||
m_zoom_t1 = MIN_ZOOM;
|
||||
if (m_zoom_t1 > MAX_ZOOM )
|
||||
m_zoom_t1 = MAX_ZOOM;
|
||||
|
||||
if( m_zoom >= MAX_ZOOM )
|
||||
m_zoom = MAX_ZOOM;
|
||||
m_camera_pos_t1.z = m_camera_pos_init.z * m_zoom_t1;
|
||||
|
||||
m_camera_pos.z = m_zoom * m_camera_pos_init.z;
|
||||
|
||||
if( old_zoom != m_zoom )
|
||||
{
|
||||
updateViewMatrix();
|
||||
rebuildProjection();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CCAMERA::ZoomIn_T1( float aFactor )
|
||||
{
|
||||
if( m_zoom > MIN_ZOOM )
|
||||
{
|
||||
m_zoom_t1 = m_zoom / aFactor;
|
||||
|
||||
if( m_zoom_t1 <= MIN_ZOOM )
|
||||
m_zoom_t1 = MIN_ZOOM;
|
||||
|
||||
m_camera_pos_t1.z = m_zoom_t1 * m_camera_pos_init.z;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CCAMERA::ZoomOut_T1( float aFactor )
|
||||
{
|
||||
if( m_zoom < MAX_ZOOM )
|
||||
{
|
||||
m_zoom_t1 = m_zoom * aFactor;
|
||||
|
||||
if( m_zoom_t1 >= MAX_ZOOM )
|
||||
m_zoom_t1 = MAX_ZOOM;
|
||||
|
||||
m_camera_pos_t1.z = m_zoom_t1 * m_camera_pos_init.z;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -170,13 +170,9 @@ class CCAMERA
|
|||
|
||||
void ZoomReset();
|
||||
|
||||
bool ZoomIn( float aFactor );
|
||||
bool Zoom( float aFactor );
|
||||
|
||||
bool ZoomOut( float aFactor );
|
||||
|
||||
bool ZoomIn_T1( float aFactor );
|
||||
|
||||
bool ZoomOut_T1( float aFactor );
|
||||
bool Zoom_T1( float aFactor );
|
||||
|
||||
float ZoomGet() const ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue