2015-12-08 07:31:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-07-19 17:35:25 +00:00
|
|
|
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
2015-12-08 07:31:57 +00:00
|
|
|
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
2017-02-06 14:20:46 +00:00
|
|
|
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2018-01-13 01:58:44 +00:00
|
|
|
* Copyright (C) 2015-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
2015-12-08 07:31:57 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
/**
|
|
|
|
* @file panel_prev_model.cpp
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <3d_canvas/eda_3d_canvas.h>
|
2015-12-08 07:31:57 +00:00
|
|
|
#include <common_ogl/cogl_att_list.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2018-03-28 17:14:04 +00:00
|
|
|
#include <base_units.h>
|
2016-01-25 04:55:36 +00:00
|
|
|
|
|
|
|
#include "project.h"
|
2015-12-08 07:31:57 +00:00
|
|
|
#include "panel_prev_model.h"
|
2016-07-19 17:35:25 +00:00
|
|
|
#include <class_board.h>
|
2018-03-28 17:14:04 +00:00
|
|
|
#include <class_drawpanel.h>
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, PCB_BASE_FRAME* aFrame, MODULE* aModule,
|
2018-07-20 20:56:12 +00:00
|
|
|
std::vector<MODULE_3D_SETTINGS> *aParentModelList ) :
|
2018-01-13 01:58:44 +00:00
|
|
|
PANEL_PREV_3D_BASE( aParent, wxID_ANY )
|
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
m_userUnits = aFrame->GetUserUnits();
|
2018-02-02 15:56:09 +00:00
|
|
|
|
2018-01-13 01:58:44 +00:00
|
|
|
initPanel();
|
2015-12-09 05:43:30 +00:00
|
|
|
|
2018-01-13 01:58:44 +00:00
|
|
|
// Initialize the color settings to draw the board and the footprint
|
2018-03-28 17:14:04 +00:00
|
|
|
m_dummyBoard->SetColorsSettings( &aFrame->Settings().Colors() );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2018-07-20 20:56:12 +00:00
|
|
|
m_parentModelList = aParentModelList;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2018-07-20 20:56:12 +00:00
|
|
|
m_dummyModule = new MODULE( *aModule );
|
|
|
|
m_dummyBoard->Add( m_dummyModule );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-01-13 01:58:44 +00:00
|
|
|
// Set 3d viewer configuration for preview
|
|
|
|
m_settings3Dviewer = new CINFO3D_VISU();
|
2018-03-28 17:14:04 +00:00
|
|
|
m_settings3Dviewer->SetFlag( FL_MOUSEWHEEL_PANNING,
|
|
|
|
aFrame->GetCanvas()->GetEnableMousewheelPan() );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-01-13 01:58:44 +00:00
|
|
|
// Create the 3D canvas
|
2018-03-28 17:14:04 +00:00
|
|
|
m_previewPane = new EDA_3D_CANVAS( this, COGL_ATT_LIST::GetAttributesList( true ),
|
|
|
|
m_dummyBoard, *m_settings3Dviewer,
|
|
|
|
aFrame->Prj().Get3DCacheManager() );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_SizerPanelView->Add( m_previewPane, 1, wxEXPAND, 5 );
|
2018-01-13 01:58:44 +00:00
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
|
2017-02-19 07:30:34 +00:00
|
|
|
PANEL_PREV_3D::~PANEL_PREV_3D()
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2017-02-06 14:20:46 +00:00
|
|
|
delete m_settings3Dviewer;
|
2016-07-19 17:35:25 +00:00
|
|
|
delete m_dummyBoard;
|
|
|
|
delete m_previewPane;
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-19 07:30:34 +00:00
|
|
|
void PANEL_PREV_3D::initPanel()
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2017-02-06 14:20:46 +00:00
|
|
|
m_dummyBoard = new BOARD();
|
2018-07-20 20:56:12 +00:00
|
|
|
m_selected = -1;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2017-02-07 09:26:03 +00:00
|
|
|
// Set the bitmap of 3D view buttons:
|
2017-02-06 14:20:46 +00:00
|
|
|
m_bpvTop->SetBitmap( KiBitmap( axis3d_top_xpm ) );
|
|
|
|
m_bpvFront->SetBitmap( KiBitmap( axis3d_front_xpm ) );
|
|
|
|
m_bpvBack->SetBitmap( KiBitmap( axis3d_back_xpm ) );
|
|
|
|
m_bpvLeft->SetBitmap( KiBitmap( axis3d_left_xpm ) );
|
|
|
|
m_bpvRight->SetBitmap( KiBitmap( axis3d_right_xpm ) );
|
|
|
|
m_bpvBottom->SetBitmap( KiBitmap( axis3d_bottom_xpm ) );
|
|
|
|
m_bpvISO->SetBitmap( KiBitmap( ortho_xpm ) );
|
|
|
|
m_bpUpdate->SetBitmap( KiBitmap( reload_xpm ) );
|
2017-02-07 09:26:03 +00:00
|
|
|
|
|
|
|
// Set the min and max values of spin buttons (mandatory on Linux)
|
2017-02-07 10:05:08 +00:00
|
|
|
// They are not used, so they are set to min and max 32 bits int values
|
|
|
|
// (the min and max values supported by a wxSpinButton)
|
|
|
|
// It avoids blocking the up or down arrows when reaching this limit after
|
|
|
|
// a few clicks.
|
2017-02-07 09:26:03 +00:00
|
|
|
wxSpinButton* spinButtonList[] =
|
|
|
|
{
|
|
|
|
m_spinXscale, m_spinYscale, m_spinZscale,
|
|
|
|
m_spinXrot, m_spinYrot, m_spinZrot,
|
|
|
|
m_spinXoffset,m_spinYoffset, m_spinZoffset
|
|
|
|
};
|
|
|
|
|
|
|
|
for( int ii = 0; ii < 9; ii++ )
|
2017-02-07 10:05:08 +00:00
|
|
|
spinButtonList[ii]->SetRange( INT_MIN, INT_MAX );
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-06 14:20:46 +00:00
|
|
|
/**
|
2018-03-28 17:14:04 +00:00
|
|
|
* @brief rotationFromString
|
2017-02-06 20:28:35 +00:00
|
|
|
* Ensure -MAX_ROTATION <= rotation <= MAX_ROTATION
|
|
|
|
* aRotation will be normalized between -MAX_ROTATION and MAX_ROTATION
|
2017-02-06 14:20:46 +00:00
|
|
|
*/
|
2018-03-28 17:14:04 +00:00
|
|
|
static double rotationFromString( const wxString& aValue )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
double rotation = DoubleValueFromString( DEGREES, aValue ) / 10.0;
|
|
|
|
|
|
|
|
if( rotation > MAX_ROTATION )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
int n = rotation / MAX_ROTATION;
|
|
|
|
rotation -= MAX_ROTATION * n;
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
2018-03-28 17:14:04 +00:00
|
|
|
else if( rotation < -MAX_ROTATION )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
int n = -rotation / MAX_ROTATION;
|
|
|
|
rotation += MAX_ROTATION * n;
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
return rotation;
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
2018-01-13 01:58:44 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
wxString PANEL_PREV_3D::formatScaleValue( double aValue )
|
2018-01-13 01:58:44 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
return wxString::Format( "%.4f", aValue );
|
2017-02-06 19:49:29 +00:00
|
|
|
}
|
|
|
|
|
2017-02-06 20:28:35 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
wxString PANEL_PREV_3D::formatRotationValue( double aValue )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
return wxString::Format( "%.2f %s", aValue, GetAbbreviatedUnitsLabel( DEGREES ) );
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
wxString PANEL_PREV_3D::formatOffsetValue( double aValue )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
// Convert from internal units (mm) to user units
|
|
|
|
if( m_userUnits == INCHES )
|
|
|
|
aValue /= 25.4f;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
return wxString::Format( "%.4f %s", aValue, GetAbbreviatedUnitsLabel( m_userUnits ) );
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-20 20:56:12 +00:00
|
|
|
void PANEL_PREV_3D::SetSelectedModel( int idx )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2018-07-20 20:56:12 +00:00
|
|
|
if( m_parentModelList && idx >= 0 && idx < (int) m_parentModelList->size() )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2018-07-20 20:56:12 +00:00
|
|
|
m_selected = idx;
|
|
|
|
const MODULE_3D_SETTINGS& modelInfo = m_parentModelList->at( (unsigned) m_selected );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
// Use ChangeValue() instead of SetValue(). It's not the user making the change, so we
|
|
|
|
// don't want to generate wxEVT_GRID_CELL_CHANGED events.
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
xscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.x ) );
|
|
|
|
yscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.y ) );
|
|
|
|
zscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.z ) );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
xrot->ChangeValue( formatRotationValue( modelInfo.m_Rotation.x ) );
|
|
|
|
yrot->ChangeValue( formatRotationValue( modelInfo.m_Rotation.y ) );
|
|
|
|
zrot->ChangeValue( formatRotationValue( modelInfo.m_Rotation.z ) );
|
2016-01-25 04:55:36 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
xoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.x ) );
|
|
|
|
yoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.y ) );
|
|
|
|
zoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.z ) );
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-07-20 20:56:12 +00:00
|
|
|
m_selected = -1;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
xscale->ChangeValue( wxEmptyString );
|
|
|
|
yscale->ChangeValue( wxEmptyString );
|
|
|
|
zscale->ChangeValue( wxEmptyString );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
xrot->ChangeValue( wxEmptyString );
|
|
|
|
yrot->ChangeValue( wxEmptyString );
|
|
|
|
zrot->ChangeValue( wxEmptyString );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
xoff->ChangeValue( wxEmptyString );
|
|
|
|
yoff->ChangeValue( wxEmptyString );
|
|
|
|
zoff->ChangeValue( wxEmptyString );
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
void PANEL_PREV_3D::updateOrientation( wxCommandEvent &event )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2018-07-20 20:56:12 +00:00
|
|
|
if( m_parentModelList && m_selected >= 0 && m_selected < (int) m_parentModelList->size() )
|
|
|
|
{
|
|
|
|
// Write settings back to the parent
|
|
|
|
MODULE_3D_SETTINGS* modelInfo = &m_parentModelList->at( (unsigned) m_selected );
|
2015-12-08 23:38:25 +00:00
|
|
|
|
2018-07-20 20:56:12 +00:00
|
|
|
modelInfo->m_Scale.x = DoubleValueFromString( UNSCALED_UNITS, xscale->GetValue() );
|
|
|
|
modelInfo->m_Scale.y = DoubleValueFromString( UNSCALED_UNITS, yscale->GetValue() );
|
|
|
|
modelInfo->m_Scale.z = DoubleValueFromString( UNSCALED_UNITS, zscale->GetValue() );
|
2015-12-09 05:43:30 +00:00
|
|
|
|
2018-07-20 20:56:12 +00:00
|
|
|
modelInfo->m_Rotation.x = rotationFromString( xrot->GetValue() );
|
|
|
|
modelInfo->m_Rotation.y = rotationFromString( yrot->GetValue() );
|
|
|
|
modelInfo->m_Rotation.z = rotationFromString( zrot->GetValue() );
|
2015-12-09 05:43:30 +00:00
|
|
|
|
2018-07-20 20:56:12 +00:00
|
|
|
modelInfo->m_Offset.x = DoubleValueFromString( m_userUnits, xoff->GetValue() ) / IU_PER_MM;
|
|
|
|
modelInfo->m_Offset.y = DoubleValueFromString( m_userUnits, yoff->GetValue() ) / IU_PER_MM;
|
|
|
|
modelInfo->m_Offset.z = DoubleValueFromString( m_userUnits, zoff->GetValue() ) / IU_PER_MM;
|
2015-12-09 05:43:30 +00:00
|
|
|
|
2018-07-20 20:56:12 +00:00
|
|
|
// Update the dummy module for the preview
|
|
|
|
UpdateDummyModule( false );
|
2015-12-09 05:43:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
void PANEL_PREV_3D::doIncrementScale( wxSpinEvent& event, double aSign )
|
2017-02-06 19:49:29 +00:00
|
|
|
{
|
|
|
|
wxSpinButton* spinCtrl = (wxSpinButton*) event.GetEventObject();
|
|
|
|
|
|
|
|
wxTextCtrl * textCtrl = xscale;
|
|
|
|
|
|
|
|
if( spinCtrl == m_spinYscale )
|
|
|
|
textCtrl = yscale;
|
|
|
|
else if( spinCtrl == m_spinZscale )
|
|
|
|
textCtrl = zscale;
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
double curr_value = DoubleValueFromString( UNSCALED_UNITS, textCtrl->GetValue() );
|
2017-02-06 19:49:29 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
curr_value += ( SCALE_INCREMENT * aSign );
|
|
|
|
curr_value = std::max( 1/MAX_SCALE, curr_value );
|
|
|
|
curr_value = std::min( curr_value, MAX_SCALE );
|
2017-02-06 19:49:29 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
textCtrl->SetValue( formatScaleValue( curr_value ) );
|
2017-02-06 19:49:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
void PANEL_PREV_3D::doIncrementRotation( wxSpinEvent& aEvent, double aSign )
|
2017-02-06 19:49:29 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
wxSpinButton* spinCtrl = (wxSpinButton*) aEvent.GetEventObject();
|
|
|
|
wxTextCtrl* textCtrl = xrot;
|
2017-02-06 19:49:29 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
if( spinCtrl == m_spinYrot )
|
|
|
|
textCtrl = yrot;
|
|
|
|
else if( spinCtrl == m_spinZrot )
|
|
|
|
textCtrl = zrot;
|
2017-02-06 19:49:29 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
double curr_value = DoubleValueFromString( DEGREES, textCtrl->GetValue() ) / 10.0;
|
2017-02-06 19:49:29 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
curr_value += ( ROTATION_INCREMENT * aSign );
|
|
|
|
curr_value = std::max( -MAX_ROTATION, curr_value );
|
|
|
|
curr_value = std::min( curr_value, MAX_ROTATION );
|
2017-02-06 19:49:29 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
textCtrl->SetValue( formatRotationValue( curr_value ) );
|
2017-02-06 19:49:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
void PANEL_PREV_3D::doIncrementOffset( wxSpinEvent& event, double aSign )
|
2017-02-06 19:49:29 +00:00
|
|
|
{
|
|
|
|
wxSpinButton* spinCtrl = (wxSpinButton*) event.GetEventObject();
|
|
|
|
|
|
|
|
wxTextCtrl * textCtrl = xoff;
|
|
|
|
|
|
|
|
if( spinCtrl == m_spinYoffset )
|
|
|
|
textCtrl = yoff;
|
|
|
|
else if( spinCtrl == m_spinZoffset )
|
|
|
|
textCtrl = zoff;
|
|
|
|
|
|
|
|
double step = OFFSET_INCREMENT_MM;
|
|
|
|
|
2018-02-02 15:56:09 +00:00
|
|
|
if( m_userUnits == INCHES )
|
2017-02-06 19:49:29 +00:00
|
|
|
step = OFFSET_INCREMENT_MIL/1000.0;
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
double curr_value = DoubleValueFromString( m_userUnits, textCtrl->GetValue() ) / IU_PER_MM;
|
|
|
|
|
|
|
|
curr_value += ( step * aSign );
|
|
|
|
curr_value = std::max( -MAX_OFFSET, curr_value );
|
|
|
|
curr_value = std::min( curr_value, MAX_OFFSET );
|
|
|
|
|
|
|
|
textCtrl->SetValue( formatOffsetValue( curr_value ) );
|
2017-02-06 19:49:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_PREV_3D::onMouseWheelScale( wxMouseEvent& event )
|
|
|
|
{
|
|
|
|
wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
|
|
|
|
|
|
|
|
double step = SCALE_INCREMENT;
|
|
|
|
|
2017-03-02 18:58:14 +00:00
|
|
|
if( event.ShiftDown( ) )
|
|
|
|
step = SCALE_INCREMENT_FINE;
|
|
|
|
|
2017-02-06 19:49:29 +00:00
|
|
|
if( event.GetWheelRotation() >= 0 )
|
|
|
|
step = -step;
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
double curr_value = DoubleValueFromString( UNSCALED_UNITS, textCtrl->GetValue() );
|
|
|
|
|
|
|
|
curr_value += step;
|
|
|
|
curr_value = std::max( 1/MAX_SCALE, curr_value );
|
|
|
|
curr_value = std::min( curr_value, MAX_SCALE );
|
|
|
|
|
|
|
|
textCtrl->SetValue( formatScaleValue( curr_value ) );
|
2017-02-06 19:49:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_PREV_3D::onMouseWheelRot( wxMouseEvent& event )
|
|
|
|
{
|
|
|
|
wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
|
|
|
|
|
|
|
|
double step = ROTATION_INCREMENT_WHEEL;
|
|
|
|
|
2017-03-02 18:58:14 +00:00
|
|
|
if( event.ShiftDown( ) )
|
|
|
|
step = ROTATION_INCREMENT_WHEEL_FINE;
|
|
|
|
|
2017-02-06 19:49:29 +00:00
|
|
|
if( event.GetWheelRotation() >= 0 )
|
|
|
|
step = -step;
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
double curr_value = DoubleValueFromString( DEGREES, textCtrl->GetValue() ) / 10.0;
|
|
|
|
|
|
|
|
curr_value += step;
|
|
|
|
curr_value = std::max( -MAX_ROTATION, curr_value );
|
|
|
|
curr_value = std::min( curr_value, MAX_ROTATION );
|
|
|
|
|
|
|
|
textCtrl->SetValue( formatRotationValue( curr_value ) );
|
2017-02-06 19:49:29 +00:00
|
|
|
}
|
|
|
|
|
2018-01-13 01:58:44 +00:00
|
|
|
|
2017-02-06 19:49:29 +00:00
|
|
|
void PANEL_PREV_3D::onMouseWheelOffset( wxMouseEvent& event )
|
|
|
|
{
|
|
|
|
wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
|
|
|
|
|
|
|
|
double step = OFFSET_INCREMENT_MM;
|
2018-01-13 01:58:44 +00:00
|
|
|
|
2017-03-02 18:58:14 +00:00
|
|
|
if( event.ShiftDown( ) )
|
|
|
|
step = OFFSET_INCREMENT_MM_FINE;
|
2017-02-06 19:49:29 +00:00
|
|
|
|
2018-02-02 15:56:09 +00:00
|
|
|
if( m_userUnits == INCHES )
|
2017-03-02 18:58:14 +00:00
|
|
|
{
|
2017-02-06 19:49:29 +00:00
|
|
|
step = OFFSET_INCREMENT_MIL/1000.0;
|
2017-03-02 18:58:14 +00:00
|
|
|
if( event.ShiftDown( ) )
|
|
|
|
step = OFFSET_INCREMENT_MIL_FINE/1000.0;
|
|
|
|
}
|
2017-02-06 19:49:29 +00:00
|
|
|
|
|
|
|
if( event.GetWheelRotation() >= 0 )
|
|
|
|
step = -step;
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
double curr_value = DoubleValueFromString( m_userUnits, textCtrl->GetValue() ) / IU_PER_MM;
|
2018-01-13 01:58:44 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
curr_value += step;
|
|
|
|
curr_value = std::max( -MAX_OFFSET, curr_value );
|
|
|
|
curr_value = std::min( curr_value, MAX_OFFSET );
|
2016-01-12 06:09:04 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
textCtrl->SetValue( formatOffsetValue( curr_value ) );
|
2015-12-09 05:43:30 +00:00
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
|
2018-07-20 20:56:12 +00:00
|
|
|
void PANEL_PREV_3D::UpdateDummyModule( bool aReloadRequired )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2018-07-20 20:56:12 +00:00
|
|
|
m_dummyModule->Models().clear();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-07-20 20:56:12 +00:00
|
|
|
for( size_t i = 0; i < m_parentModelList->size(); ++i )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2018-07-20 20:56:12 +00:00
|
|
|
if( m_parentModelList->at( i ).m_Preview )
|
|
|
|
{
|
|
|
|
m_dummyModule->Models().insert( m_dummyModule->Models().end(),
|
|
|
|
m_parentModelList->at( i ) );
|
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
if( aReloadRequired )
|
|
|
|
m_previewPane->ReloadRequest();
|
2018-01-13 01:58:44 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_previewPane->Request_refresh();
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|