kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #27349
[PATCH] Changed the 3d model previewer to use spinboxes
Hello!
One thing that has always bothered me is that when aligning 3D models to
fit the footprint, one have to type the value and test, delete
characters and test again. Very minor issue, but it still bothers me.
With a spinbox the values can be changed using the mouse only.
attaching the patch for this minor change.
- Kristoffer
>From b327e76bca6513e6abeb14243a77fa65dbdcdb03 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kristoffer=20=C3=96dmark?= <kristoffer.odmark90@xxxxxxxxx>
Date: Thu, 26 Jan 2017 11:57:54 +0100
Subject: [PATCH] Changed so that the 3d viewer uses spinboxes instead of text
inputs.
---
3d-viewer/3d_cache/dialogs/panel_prev_model.cpp | 123 ++++++++++++------------
3d-viewer/3d_cache/dialogs/panel_prev_model.h | 20 ++--
2 files changed, 69 insertions(+), 74 deletions(-)
diff --git a/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp b/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp
index da356df47..8f6fef25f 100644
--- a/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp
+++ b/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp
@@ -133,13 +133,6 @@ PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent,
wxBoxSizer* mainBox = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* vbox = new wxStaticBoxSizer( wxVERTICAL, this, _( "3D Preview" ) );
- wxFloatingPointValidator< float > valScale( 4 );
- valScale.SetRange( 0.0f, 9999.0f );
- wxFloatingPointValidator< float > valRotate( 2 );
- valRotate.SetRange( -180.0f, 180.0f );
- wxFloatingPointValidator< float > valOffset( 4 );
- valOffset.SetRange( -9999.0f, 9999.0f );
-
wxStaticBoxSizer* vbScale = new wxStaticBoxSizer( wxVERTICAL, this, _( "Scale" ) );
wxStaticBoxSizer* vbRotate = new wxStaticBoxSizer( wxVERTICAL, this, _( "Rotation (degrees)" ) );
@@ -158,16 +151,16 @@ PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent,
wxStaticText* txtS2 = new wxStaticText( modScale, -1, wxT( "Y:" ) );
wxStaticText* txtS3 = new wxStaticText( modScale, -1, wxT( "Z:" ) );
- xscale = new wxTextCtrl( modScale, ID_SCALEX, "1", wxDefaultPosition, wxDefaultSize,
- wxTE_PROCESS_ENTER, valScale );
- yscale = new wxTextCtrl( modScale, ID_SCALEY, "1", wxDefaultPosition, wxDefaultSize,
- wxTE_PROCESS_ENTER, valScale );
- zscale = new wxTextCtrl( modScale, ID_SCALEZ, "1", wxDefaultPosition, wxDefaultSize,
- wxTE_PROCESS_ENTER, valScale );
+ xscale = new wxSpinCtrlDouble( modScale, ID_SCALEX, "1", wxDefaultPosition, wxDefaultSize,
+ wxSP_ARROW_KEYS, 0, 999, 1, 0.1 );
+ yscale = new wxSpinCtrlDouble( modScale, ID_SCALEY, "1", wxDefaultPosition, wxDefaultSize,
+ wxSP_ARROW_KEYS, 0, 999, 1, 0.1 );
+ zscale = new wxSpinCtrlDouble( modScale, ID_SCALEZ, "1", wxDefaultPosition, wxDefaultSize,
+ wxSP_ARROW_KEYS, 0, 999, 1, 0.1 );
- xscale->SetMaxLength( 9 );
- yscale->SetMaxLength( 9 );
- zscale->SetMaxLength( 9 );
+ xscale->SetDigits( 5 );
+ yscale->SetDigits( 5 );
+ zscale->SetDigits( 5 );
hbS1->Add( txtS1, 0, wxALIGN_CENTER, 2 );
hbS1->Add( xscale, 0, wxEXPAND | wxLEFT | wxRIGHT, 2 );
hbS2->Add( txtS2, 0, wxALIGN_CENTER, 2 );
@@ -185,16 +178,16 @@ PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent,
wxStaticText* txtR2 = new wxStaticText( modRotate, -1, wxT( "Y:" ) );
wxStaticText* txtR3 = new wxStaticText( modRotate, -1, wxT( "Z:" ) );
- xrot = new wxTextCtrl( modRotate, ID_ROTX, "0", wxDefaultPosition, wxDefaultSize,
- wxTE_PROCESS_ENTER, valRotate );
- yrot = new wxTextCtrl( modRotate, ID_ROTY, "0", wxDefaultPosition, wxDefaultSize,
- wxTE_PROCESS_ENTER, valRotate );
- zrot = new wxTextCtrl( modRotate, ID_ROTZ, "0", wxDefaultPosition, wxDefaultSize,
- wxTE_PROCESS_ENTER, valRotate );
+ xrot = new wxSpinCtrlDouble( modRotate, ID_ROTX, "0", wxDefaultPosition, wxDefaultSize,
+ wxSP_ARROW_KEYS, -180, 180, 1, 10 );
+ yrot = new wxSpinCtrlDouble( modRotate, ID_ROTY, "0", wxDefaultPosition, wxDefaultSize,
+ wxSP_ARROW_KEYS, -180, 180, 1, 10 );
+ zrot = new wxSpinCtrlDouble( modRotate, ID_ROTZ, "0", wxDefaultPosition, wxDefaultSize,
+ wxSP_ARROW_KEYS, -180, 180, 1, 10 );
- xrot->SetMaxLength( 9 );
- yrot->SetMaxLength( 9 );
- zrot->SetMaxLength( 9 );
+ xrot->SetDigits( 5 );
+ yrot->SetDigits( 5 );
+ zrot->SetDigits( 5 );
hbR1->Add( txtR1, 1, wxALIGN_CENTER, 2 );
hbR1->Add( xrot, 0, wxEXPAND | wxLEFT | wxRIGHT, 2 );
hbR2->Add( txtR2, 1, wxALIGN_CENTER, 2 );
@@ -213,15 +206,17 @@ PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent,
wxStaticText* txtO3 = new wxStaticText( modOffset, -1, wxT( "Z:" ) );
// The default offset is 0.0 or 0,0, depending on floating point separator:
- xoff = new wxTextCtrl( modOffset, ID_OFFX, "0", wxDefaultPosition, wxDefaultSize,
- wxTE_PROCESS_ENTER, valOffset );
- yoff = new wxTextCtrl( modOffset, ID_OFFY, "0", wxDefaultPosition, wxDefaultSize,
- wxTE_PROCESS_ENTER, valOffset );
- zoff = new wxTextCtrl( modOffset, ID_OFFZ, "0", wxDefaultPosition, wxDefaultSize,
- wxTE_PROCESS_ENTER, valOffset );
- xoff->SetMaxLength( 10 );
- yoff->SetMaxLength( 10 );
- zoff->SetMaxLength( 10 );
+ xoff = new wxSpinCtrlDouble( modOffset, ID_OFFX, "0", wxDefaultPosition, wxDefaultSize,
+ wxSP_ARROW_KEYS, -999999, 999999, 1, 1 );
+ yoff = new wxSpinCtrlDouble( modOffset, ID_OFFY, "0", wxDefaultPosition, wxDefaultSize,
+ wxSP_ARROW_KEYS, -999999, 999999, 1, 1 );
+ zoff = new wxSpinCtrlDouble( modOffset, ID_OFFZ, "0", wxDefaultPosition, wxDefaultSize,
+ wxSP_ARROW_KEYS, -999999, 999999, 1, 1 );
+
+ xoff->SetDigits( 6 );
+ yoff->SetDigits( 6 );
+ zoff->SetDigits( 6 );
+
hbO1->Add( txtO1, 0, wxALIGN_CENTER, 2 );
hbO1->Add( xoff, 0, wxEXPAND | wxLEFT | wxRIGHT, 2 );
hbO2->Add( txtO2, 0, wxALIGN_CENTER, 2 );
@@ -444,26 +439,26 @@ void PANEL_PREV_3D::SetModelDataIdx( int idx, bool aReloadPreviewModule )
const S3D_INFO *aModel = (const S3D_INFO *)&((*m_parentInfoList)[idx]);
- xscale->SetValue( wxString::Format( "%.4f", aModel->m_Scale.x ) );
- yscale->SetValue( wxString::Format( "%.4f", aModel->m_Scale.y ) );
- zscale->SetValue( wxString::Format( "%.4f", aModel->m_Scale.z ) );
+ xscale->SetValue( aModel->m_Scale.x );
+ yscale->SetValue( aModel->m_Scale.y );
+ zscale->SetValue( aModel->m_Scale.z );
- xrot->SetValue( wxString::Format( "%.2f", aModel->m_Rotation.x ) );
- yrot->SetValue( wxString::Format( "%.2f", aModel->m_Rotation.y ) );
- zrot->SetValue( wxString::Format( "%.2f", aModel->m_Rotation.z ) );
+ xrot->SetValue( aModel->m_Rotation.x );
+ yrot->SetValue( aModel->m_Rotation.y );
+ zrot->SetValue( aModel->m_Rotation.z );
switch( g_UserUnit )
{
case MILLIMETRES:
- xoff->SetValue( wxString::Format( "%.4f", aModel->m_Offset.x * 25.4 ) );
- yoff->SetValue( wxString::Format( "%.4f", aModel->m_Offset.y * 25.4 ) );
- zoff->SetValue( wxString::Format( "%.4f", aModel->m_Offset.z * 25.4 ) );
+ xoff->SetValue( aModel->m_Offset.x * 25.4 );
+ yoff->SetValue( aModel->m_Offset.y * 25.4 );
+ zoff->SetValue( aModel->m_Offset.z * 25.4 );
break;
case INCHES:
- xoff->SetValue( wxString::Format( "%.4f", aModel->m_Offset.x ) );
- yoff->SetValue( wxString::Format( "%.4f", aModel->m_Offset.y ) );
- zoff->SetValue( wxString::Format( "%.4f", aModel->m_Offset.z ) );
+ xoff->SetValue( aModel->m_Offset.x );
+ yoff->SetValue( aModel->m_Offset.y );
+ zoff->SetValue( aModel->m_Offset.z );
break;
case DEGREES:
@@ -497,17 +492,17 @@ void PANEL_PREV_3D::ResetModelData( bool aReloadPreviewModule )
{
m_currentSelectedIdx = -1;
- xscale->SetValue( wxString::FromDouble( 1.0 ) );
- yscale->SetValue( wxString::FromDouble( 1.0 ) );
- zscale->SetValue( wxString::FromDouble( 1.0 ) );
+ xscale->SetValue( 1.0 );
+ yscale->SetValue( 1.0 );
+ zscale->SetValue( 1.0 );
- xrot->SetValue( wxString::FromDouble( 0.0 ) );
- yrot->SetValue( wxString::FromDouble( 0.0 ) );
- zrot->SetValue( wxString::FromDouble( 0.0 ) );
+ xrot->SetValue( 0.0 );
+ yrot->SetValue( 0.0 );
+ zrot->SetValue( 0.0 );
- xoff->SetValue( wxString::FromDouble( 0.0 ) );
- yoff->SetValue( wxString::FromDouble( 0.0 ) );
- zoff->SetValue( wxString::FromDouble( 0.0 ) );
+ xoff->SetValue( 0.0 );
+ yoff->SetValue( 0.0 );
+ zoff->SetValue( 0.0 );
// This will update the model on the preview board with the current list of 3d shapes
if( aReloadPreviewModule )
@@ -627,21 +622,21 @@ void PANEL_PREV_3D::getOrientationVars( SGPOINT& aScale, SGPOINT& aRotation, SGP
return;
}
- xscale->GetValue().ToDouble( &aScale.x );
- yscale->GetValue().ToDouble( &aScale.y );
- zscale->GetValue().ToDouble( &aScale.z );
+ aScale.x = xscale->GetValue();
+ aScale.y = yscale->GetValue();
+ aScale.z = zscale->GetValue();
- xrot->GetValue().ToDouble( &aRotation.x );
- yrot->GetValue().ToDouble( &aRotation.y );
- zrot->GetValue().ToDouble( &aRotation.z );
+ aRotation.x = xrot->GetValue();
+ aRotation.y = yrot->GetValue();
+ aRotation.z = zrot->GetValue();
checkRotation( aRotation.x );
checkRotation( aRotation.y );
checkRotation( aRotation.z );
- xoff->GetValue().ToDouble( &aOffset.x );
- yoff->GetValue().ToDouble( &aOffset.y );
- zoff->GetValue().ToDouble( &aOffset.z );
+ aOffset.x = xoff->GetValue();
+ aOffset.y = yoff->GetValue();
+ aOffset.z = zoff->GetValue();
switch( g_UserUnit )
{
diff --git a/3d-viewer/3d_cache/dialogs/panel_prev_model.h b/3d-viewer/3d_cache/dialogs/panel_prev_model.h
index 0a2faf88b..5399b7d89 100644
--- a/3d-viewer/3d_cache/dialogs/panel_prev_model.h
+++ b/3d-viewer/3d_cache/dialogs/panel_prev_model.h
@@ -36,7 +36,7 @@
#ifndef PANEL_PREV_MODEL_H
#define PANEL_PREV_MODEL_H
-#include <wx/textctrl.h>
+#include <wx/spinctrl.h>
#include "../3d_info.h"
#include <vector>
@@ -113,15 +113,15 @@ private:
S3D_FILENAME_RESOLVER *m_resolver; ///< Used to get the full path name
// Parameters
- wxTextCtrl* xscale;
- wxTextCtrl* yscale;
- wxTextCtrl* zscale;
- wxTextCtrl* xrot;
- wxTextCtrl* yrot;
- wxTextCtrl* zrot;
- wxTextCtrl* xoff;
- wxTextCtrl* yoff;
- wxTextCtrl* zoff;
+ wxSpinCtrlDouble* xscale;
+ wxSpinCtrlDouble* yscale;
+ wxSpinCtrlDouble* zscale;
+ wxSpinCtrlDouble* xrot;
+ wxSpinCtrlDouble* yrot;
+ wxSpinCtrlDouble* zrot;
+ wxSpinCtrlDouble* xoff;
+ wxSpinCtrlDouble* yoff;
+ wxSpinCtrlDouble* zoff;
EDA_3D_CANVAS *m_previewPane;
--
2.11.0
Attachment:
photo_2017-01-26_12-04-28.jpg
Description: JPEG image
Follow ups