KiCad PCB EDA Suite
PANEL_PREV_3D Class Reference

#include <panel_prev_model.h>

Inheritance diagram for PANEL_PREV_3D:
PANEL_PREV_3D_BASE

Public Member Functions

 PANEL_PREV_3D (wxWindow *aParent, PCB_BASE_FRAME *aFrame, MODULE *aModule, std::vector< MODULE_3D_SETTINGS > *aParentModelList)
 
 ~PANEL_PREV_3D ()
 
void SetSelectedModel (int idx)
 SetModelDataIdx - Sets the currently selected index in the model list so that the scale/rotation/offset controls can be updated. More...
 
void UpdateDummyModule (bool aRelaodRequired=true)
 UpdateModelInfoList - copy shapes from the current shape list which are flagged for preview to the copy of module that is on the preview dummy board. More...
 

Public Attributes

wxTextCtrl * yoff
 

Protected Attributes

wxStaticText * m_staticText1
 
wxTextCtrl * xscale
 
wxSpinButton * m_spinXscale
 
wxStaticText * m_staticText2
 
wxTextCtrl * yscale
 
wxSpinButton * m_spinYscale
 
wxStaticText * m_staticText3
 
wxTextCtrl * zscale
 
wxSpinButton * m_spinZscale
 
wxStaticText * m_staticText11
 
wxTextCtrl * xrot
 
wxSpinButton * m_spinXrot
 
wxStaticText * m_staticText21
 
wxTextCtrl * yrot
 
wxSpinButton * m_spinYrot
 
wxStaticText * m_staticText31
 
wxTextCtrl * zrot
 
wxSpinButton * m_spinZrot
 
wxStaticText * m_staticText12
 
wxTextCtrl * xoff
 
wxSpinButton * m_spinXoffset
 
wxStaticText * m_staticText22
 
wxSpinButton * m_spinYoffset
 
wxStaticText * m_staticText32
 
wxTextCtrl * zoff
 
wxSpinButton * m_spinZoffset
 
wxBoxSizer * m_SizerPanelView
 
wxBitmapButton * m_bpvISO
 
wxBitmapButton * m_bpvLeft
 
wxBitmapButton * m_bpvRight
 
wxBitmapButton * m_bpvFront
 
wxBitmapButton * m_bpvBack
 
wxBitmapButton * m_bpvTop
 
wxBitmapButton * m_bpvBottom
 
wxBitmapButton * m_bpUpdate
 

Private Member Functions

void initPanel ()
 
void updateOrientation (wxCommandEvent &event) override
 updateOrientation - it will receive the events from editing the fields More...
 
void onMouseWheelScale (wxMouseEvent &event) override
 
void onMouseWheelRot (wxMouseEvent &event) override
 
void onMouseWheelOffset (wxMouseEvent &event) override
 
void onIncrementRot (wxSpinEvent &event) override
 
void onDecrementRot (wxSpinEvent &event) override
 
void onIncrementScale (wxSpinEvent &event) override
 
void onDecrementScale (wxSpinEvent &event) override
 
void onIncrementOffset (wxSpinEvent &event) override
 
void onDecrementOffset (wxSpinEvent &event) override
 
void doIncrementScale (wxSpinEvent &aEvent, double aSign)
 
void doIncrementRotation (wxSpinEvent &aEvent, double aSign)
 
void doIncrementOffset (wxSpinEvent &aEvent, double aSign)
 
wxString formatScaleValue (double aValue)
 
wxString formatRotationValue (double aValue)
 
wxString formatOffsetValue (double aValue)
 
void View3DISO (wxCommandEvent &event) override
 
void View3DLeft (wxCommandEvent &event) override
 
void View3DFront (wxCommandEvent &event) override
 
void View3DTop (wxCommandEvent &event) override
 
void View3DUpdate (wxCommandEvent &event) override
 
void View3DRight (wxCommandEvent &event) override
 
void View3DBack (wxCommandEvent &event) override
 
void View3DBottom (wxCommandEvent &event) override
 

Private Attributes

EDA_3D_CANVASm_previewPane
 
CINFO3D_VISUm_settings3Dviewer
 
BOARDm_dummyBoard
 
MODULEm_dummyModule
 
std::vector< MODULE_3D_SETTINGS > * m_parentModelList
 
int m_selected
 
EDA_UNITS_T m_userUnits
 Index into m_parentInfoList. More...
 

Detailed Description

Definition at line 72 of file panel_prev_model.h.

Constructor & Destructor Documentation

PANEL_PREV_3D::PANEL_PREV_3D ( wxWindow *  aParent,
PCB_BASE_FRAME aFrame,
MODULE aModule,
std::vector< MODULE_3D_SETTINGS > *  aParentModelList 
)

Definition at line 42 of file panel_prev_model.cpp.

References BOARD::Add(), PCB_GENERAL_SETTINGS::Colors(), PGM_BASE::CommonSettings(), ENBL_MOUSEWHEEL_PAN_KEY, FL_MOUSEWHEEL_PANNING, COGL_ATT_LIST::GetAttributesList(), EDA_DRAW_FRAME::GetUserUnits(), initPanel(), m_dummyBoard, m_dummyModule, m_parentModelList, m_previewPane, m_settings3Dviewer, PANEL_PREV_3D_BASE::m_SizerPanelView, m_userUnits, Pgm(), KIWAY_HOLDER::Prj(), BOARD::SetColorsSettings(), CINFO3D_VISU::SetFlag(), and PCB_BASE_FRAME::Settings().

43  :
44  PANEL_PREV_3D_BASE( aParent, wxID_ANY )
45 {
46  m_userUnits = aFrame->GetUserUnits();
47 
48  initPanel();
49 
50  // Initialize the color settings to draw the board and the footprint
52 
53  m_parentModelList = aParentModelList;
54 
55  m_dummyModule = new MODULE( *aModule );
57 
58  // Set 3d viewer configuration for preview
60 
61  bool option;
62  Pgm().CommonSettings()->Read( ENBL_MOUSEWHEEL_PAN_KEY, &option, false );
64 
65  // Create the 3D canvas
68  aFrame->Prj().Get3DCacheManager() );
69 
70  m_SizerPanelView->Add( m_previewPane, 1, wxEXPAND, 5 );
71 }
void SetColorsSettings(COLORS_DESIGN_SETTINGS *aColorsSettings)
Function SetColorsSettings.
Definition: class_board.h:575
PANEL_PREV_3D_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL)
CINFO3D_VISU * m_settings3Dviewer
static const int * GetAttributesList(bool aUseAntiAliasing)
Get a list of attributes to pass to wxGLCanvas.
Class EDA_3D_CANVAS Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:53
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
wxBoxSizer * m_SizerPanelView
std::vector< MODULE_3D_SETTINGS > * m_parentModelList
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
PCB_GENERAL_SETTINGS & Settings()
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:284
MODULE * m_dummyModule
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_INSERT) override
Adds an item to the container.
EDA_3D_CANVAS * m_previewPane
Class CINFO3D_VISU Helper class to handle information needed to display 3D board. ...
Definition: cinfo3d_visu.h:70
#define ENBL_MOUSEWHEEL_PAN_KEY
Definition: pgm_base.h:48
EDA_UNITS_T m_userUnits
Index into m_parentInfoList.
COLORS_DESIGN_SETTINGS & Colors()
VTBL_ENTRY wxConfigBase * CommonSettings() const
Definition: pgm_base.h:187
BOARD * m_dummyBoard
void SetFlag(DISPLAY3D_FLG aFlag, bool aState)
SetFlag - set the status of a flag.
PANEL_PREV_3D::~PANEL_PREV_3D ( )

Definition at line 74 of file panel_prev_model.cpp.

References m_dummyBoard, m_previewPane, and m_settings3Dviewer.

75 {
76  delete m_settings3Dviewer;
77  delete m_dummyBoard;
78  delete m_previewPane;
79 }
CINFO3D_VISU * m_settings3Dviewer
EDA_3D_CANVAS * m_previewPane
BOARD * m_dummyBoard

Member Function Documentation

void PANEL_PREV_3D::doIncrementOffset ( wxSpinEvent &  aEvent,
double  aSign 
)
private

Definition at line 267 of file panel_prev_model.cpp.

References DoubleValueFromString(), formatOffsetValue(), INCHES, PANEL_PREV_3D_BASE::m_spinYoffset, PANEL_PREV_3D_BASE::m_spinZoffset, m_userUnits, max, MAX_OFFSET, min, OFFSET_INCREMENT_MIL, OFFSET_INCREMENT_MM, PANEL_PREV_3D_BASE::xoff, PANEL_PREV_3D_BASE::yoff, and PANEL_PREV_3D_BASE::zoff.

Referenced by onDecrementOffset(), and onIncrementOffset().

268 {
269  wxSpinButton* spinCtrl = (wxSpinButton*) event.GetEventObject();
270 
271  wxTextCtrl * textCtrl = xoff;
272 
273  if( spinCtrl == m_spinYoffset )
274  textCtrl = yoff;
275  else if( spinCtrl == m_spinZoffset )
276  textCtrl = zoff;
277 
278  double step = OFFSET_INCREMENT_MM;
279 
280  if( m_userUnits == INCHES )
281  step = OFFSET_INCREMENT_MIL/1000.0;
282 
283  double curr_value = DoubleValueFromString( m_userUnits, textCtrl->GetValue() ) / IU_PER_MM;
284 
285  curr_value += ( step * aSign );
286  curr_value = std::max( -MAX_OFFSET, curr_value );
287  curr_value = std::min( curr_value, MAX_OFFSET );
288 
289  textCtrl->SetValue( formatOffsetValue( curr_value ) );
290 }
wxSpinButton * m_spinZoffset
wxSpinButton * m_spinYoffset
#define OFFSET_INCREMENT_MM
wxString formatOffsetValue(double aValue)
Definition: common.h:160
double DoubleValueFromString(EDA_UNITS_T aUnits, const wxString &aTextValue, bool aUseMils)
Function DoubleValueFromString converts aTextValue to a double.
Definition: base_units.cpp:302
EDA_UNITS_T m_userUnits
Index into m_parentInfoList.
#define OFFSET_INCREMENT_MIL
#define max(a, b)
Definition: auxiliary.h:86
#define MAX_OFFSET
#define min(a, b)
Definition: auxiliary.h:85
void PANEL_PREV_3D::doIncrementRotation ( wxSpinEvent &  aEvent,
double  aSign 
)
private

Definition at line 247 of file panel_prev_model.cpp.

References DEGREES, DoubleValueFromString(), formatRotationValue(), PANEL_PREV_3D_BASE::m_spinYrot, PANEL_PREV_3D_BASE::m_spinZrot, max, MAX_ROTATION, min, ROTATION_INCREMENT, PANEL_PREV_3D_BASE::xrot, PANEL_PREV_3D_BASE::yrot, and PANEL_PREV_3D_BASE::zrot.

Referenced by onDecrementOffset(), onDecrementRot(), and onIncrementRot().

248 {
249  wxSpinButton* spinCtrl = (wxSpinButton*) aEvent.GetEventObject();
250  wxTextCtrl* textCtrl = xrot;
251 
252  if( spinCtrl == m_spinYrot )
253  textCtrl = yrot;
254  else if( spinCtrl == m_spinZrot )
255  textCtrl = zrot;
256 
257  double curr_value = DoubleValueFromString( DEGREES, textCtrl->GetValue() ) / 10.0;
258 
259  curr_value += ( ROTATION_INCREMENT * aSign );
260  curr_value = std::max( -MAX_ROTATION, curr_value );
261  curr_value = std::min( curr_value, MAX_ROTATION );
262 
263  textCtrl->SetValue( formatRotationValue( curr_value ) );
264 }
wxString formatRotationValue(double aValue)
#define ROTATION_INCREMENT
wxSpinButton * m_spinZrot
double DoubleValueFromString(EDA_UNITS_T aUnits, const wxString &aTextValue, bool aUseMils)
Function DoubleValueFromString converts aTextValue to a double.
Definition: base_units.cpp:302
wxSpinButton * m_spinYrot
#define max(a, b)
Definition: auxiliary.h:86
#define MAX_ROTATION
#define min(a, b)
Definition: auxiliary.h:85
void PANEL_PREV_3D::doIncrementScale ( wxSpinEvent &  aEvent,
double  aSign 
)
private

Definition at line 226 of file panel_prev_model.cpp.

References DoubleValueFromString(), formatScaleValue(), PANEL_PREV_3D_BASE::m_spinYscale, PANEL_PREV_3D_BASE::m_spinZscale, max, MAX_SCALE, min, SCALE_INCREMENT, UNSCALED_UNITS, PANEL_PREV_3D_BASE::xscale, PANEL_PREV_3D_BASE::yscale, and PANEL_PREV_3D_BASE::zscale.

Referenced by onDecrementOffset(), onDecrementScale(), and onIncrementScale().

227 {
228  wxSpinButton* spinCtrl = (wxSpinButton*) event.GetEventObject();
229 
230  wxTextCtrl * textCtrl = xscale;
231 
232  if( spinCtrl == m_spinYscale )
233  textCtrl = yscale;
234  else if( spinCtrl == m_spinZscale )
235  textCtrl = zscale;
236 
237  double curr_value = DoubleValueFromString( UNSCALED_UNITS, textCtrl->GetValue() );
238 
239  curr_value += ( SCALE_INCREMENT * aSign );
240  curr_value = std::max( 1/MAX_SCALE, curr_value );
241  curr_value = std::min( curr_value, MAX_SCALE );
242 
243  textCtrl->SetValue( formatScaleValue( curr_value ) );
244 }
wxString formatScaleValue(double aValue)
#define SCALE_INCREMENT
double DoubleValueFromString(EDA_UNITS_T aUnits, const wxString &aTextValue, bool aUseMils)
Function DoubleValueFromString converts aTextValue to a double.
Definition: base_units.cpp:302
#define MAX_SCALE
wxSpinButton * m_spinZscale
#define max(a, b)
Definition: auxiliary.h:86
#define min(a, b)
Definition: auxiliary.h:85
wxSpinButton * m_spinYscale
wxString PANEL_PREV_3D::formatOffsetValue ( double  aValue)
private

Definition at line 150 of file panel_prev_model.cpp.

References Format(), GetAbbreviatedUnitsLabel(), INCHES, and m_userUnits.

Referenced by doIncrementOffset(), onDecrementOffset(), onMouseWheelOffset(), and SetSelectedModel().

151 {
152  // Convert from internal units (mm) to user units
153  if( m_userUnits == INCHES )
154  aValue /= 25.4f;
155 
156  return wxString::Format( "%.4f %s", aValue, GetAbbreviatedUnitsLabel( m_userUnits ) );
157 }
Definition: common.h:160
EDA_UNITS_T m_userUnits
Index into m_parentInfoList.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
wxString GetAbbreviatedUnitsLabel(EDA_UNITS_T aUnit, bool aUseMils)
Get the units string for a given units type.
Definition: base_units.cpp:432
wxString PANEL_PREV_3D::formatRotationValue ( double  aValue)
private

Definition at line 144 of file panel_prev_model.cpp.

References DEGREES, Format(), and GetAbbreviatedUnitsLabel().

Referenced by doIncrementRotation(), onDecrementOffset(), onMouseWheelRot(), and SetSelectedModel().

145 {
146  return wxString::Format( "%.2f %s", aValue, GetAbbreviatedUnitsLabel( DEGREES ) );
147 }
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
wxString GetAbbreviatedUnitsLabel(EDA_UNITS_T aUnit, bool aUseMils)
Get the units string for a given units type.
Definition: base_units.cpp:432
wxString PANEL_PREV_3D::formatScaleValue ( double  aValue)
private

Definition at line 138 of file panel_prev_model.cpp.

References Format().

Referenced by doIncrementScale(), onDecrementOffset(), onMouseWheelScale(), and SetSelectedModel().

139 {
140  return wxString::Format( "%.4f", aValue );
141 }
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void PANEL_PREV_3D::initPanel ( )
private

Definition at line 82 of file panel_prev_model.cpp.

References KiBitmap(), PANEL_PREV_3D_BASE::m_bpUpdate, PANEL_PREV_3D_BASE::m_bpvBack, PANEL_PREV_3D_BASE::m_bpvBottom, PANEL_PREV_3D_BASE::m_bpvFront, PANEL_PREV_3D_BASE::m_bpvISO, PANEL_PREV_3D_BASE::m_bpvLeft, PANEL_PREV_3D_BASE::m_bpvRight, PANEL_PREV_3D_BASE::m_bpvTop, m_dummyBoard, m_selected, PANEL_PREV_3D_BASE::m_spinXoffset, PANEL_PREV_3D_BASE::m_spinXrot, PANEL_PREV_3D_BASE::m_spinXscale, PANEL_PREV_3D_BASE::m_spinYoffset, PANEL_PREV_3D_BASE::m_spinYrot, PANEL_PREV_3D_BASE::m_spinYscale, PANEL_PREV_3D_BASE::m_spinZoffset, PANEL_PREV_3D_BASE::m_spinZrot, and PANEL_PREV_3D_BASE::m_spinZscale.

Referenced by PANEL_PREV_3D().

83 {
84  m_dummyBoard = new BOARD();
85  m_selected = -1;
86 
87  // Set the bitmap of 3D view buttons:
88  m_bpvTop->SetBitmap( KiBitmap( axis3d_top_xpm ) );
89  m_bpvFront->SetBitmap( KiBitmap( axis3d_front_xpm ) );
90  m_bpvBack->SetBitmap( KiBitmap( axis3d_back_xpm ) );
91  m_bpvLeft->SetBitmap( KiBitmap( axis3d_left_xpm ) );
92  m_bpvRight->SetBitmap( KiBitmap( axis3d_right_xpm ) );
93  m_bpvBottom->SetBitmap( KiBitmap( axis3d_bottom_xpm ) );
94  m_bpvISO->SetBitmap( KiBitmap( ortho_xpm ) );
95  m_bpUpdate->SetBitmap( KiBitmap( reload_xpm ) );
96 
97  // Set the min and max values of spin buttons (mandatory on Linux)
98  // They are not used, so they are set to min and max 32 bits int values
99  // (the min and max values supported by a wxSpinButton)
100  // It avoids blocking the up or down arrows when reaching this limit after
101  // a few clicks.
102  wxSpinButton* spinButtonList[] =
103  {
107  };
108 
109  for( int ii = 0; ii < 9; ii++ )
110  spinButtonList[ii]->SetRange( INT_MIN, INT_MAX );
111 }
wxBitmapButton * m_bpvTop
wxBitmapButton * m_bpvBottom
wxSpinButton * m_spinZoffset
wxSpinButton * m_spinYoffset
wxBitmapButton * m_bpvBack
wxBitmapButton * m_bpvLeft
wxBitmapButton * m_bpUpdate
wxBitmapButton * m_bpvRight
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
wxSpinButton * m_spinZrot
wxSpinButton * m_spinXoffset
wxSpinButton * m_spinYrot
wxSpinButton * m_spinXrot
wxBitmapButton * m_bpvFront
wxSpinButton * m_spinZscale
wxSpinButton * m_spinXscale
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:170
wxBitmapButton * m_bpvISO
BOARD * m_dummyBoard
wxSpinButton * m_spinYscale
void PANEL_PREV_3D::onDecrementOffset ( wxSpinEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_PREV_3D_BASE.

Definition at line 126 of file panel_prev_model.h.

References doIncrementOffset(), doIncrementRotation(), doIncrementScale(), formatOffsetValue(), formatRotationValue(), and formatScaleValue().

127  {
128  doIncrementOffset( event, -1.0 );
129  }
void doIncrementOffset(wxSpinEvent &aEvent, double aSign)
void PANEL_PREV_3D::onDecrementRot ( wxSpinEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_PREV_3D_BASE.

Definition at line 110 of file panel_prev_model.h.

References doIncrementRotation().

111  {
112  doIncrementRotation( event, -1.0 );
113  }
void doIncrementRotation(wxSpinEvent &aEvent, double aSign)
void PANEL_PREV_3D::onDecrementScale ( wxSpinEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_PREV_3D_BASE.

Definition at line 118 of file panel_prev_model.h.

References doIncrementScale().

119  {
120  doIncrementScale( event, -1.0 );
121  }
void doIncrementScale(wxSpinEvent &aEvent, double aSign)
void PANEL_PREV_3D::onIncrementOffset ( wxSpinEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_PREV_3D_BASE.

Definition at line 122 of file panel_prev_model.h.

References doIncrementOffset().

123  {
124  doIncrementOffset( event, 1.0 );
125  }
void doIncrementOffset(wxSpinEvent &aEvent, double aSign)
void PANEL_PREV_3D::onIncrementRot ( wxSpinEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_PREV_3D_BASE.

Definition at line 106 of file panel_prev_model.h.

References doIncrementRotation().

107  {
108  doIncrementRotation( event, 1.0 );
109  }
void doIncrementRotation(wxSpinEvent &aEvent, double aSign)
void PANEL_PREV_3D::onIncrementScale ( wxSpinEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_PREV_3D_BASE.

Definition at line 114 of file panel_prev_model.h.

References doIncrementScale().

115  {
116  doIncrementScale( event, 1.0 );
117  }
void doIncrementScale(wxSpinEvent &aEvent, double aSign)
void PANEL_PREV_3D::onMouseWheelOffset ( wxMouseEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_PREV_3D_BASE.

Definition at line 337 of file panel_prev_model.cpp.

References DoubleValueFromString(), formatOffsetValue(), INCHES, m_userUnits, max, MAX_OFFSET, min, OFFSET_INCREMENT_MIL, OFFSET_INCREMENT_MIL_FINE, OFFSET_INCREMENT_MM, and OFFSET_INCREMENT_MM_FINE.

338 {
339  wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
340 
341  double step = OFFSET_INCREMENT_MM;
342 
343  if( event.ShiftDown( ) )
345 
346  if( m_userUnits == INCHES )
347  {
348  step = OFFSET_INCREMENT_MIL/1000.0;
349  if( event.ShiftDown( ) )
350  step = OFFSET_INCREMENT_MIL_FINE/1000.0;
351  }
352 
353  if( event.GetWheelRotation() >= 0 )
354  step = -step;
355 
356  double curr_value = DoubleValueFromString( m_userUnits, textCtrl->GetValue() ) / IU_PER_MM;
357 
358  curr_value += step;
359  curr_value = std::max( -MAX_OFFSET, curr_value );
360  curr_value = std::min( curr_value, MAX_OFFSET );
361 
362  textCtrl->SetValue( formatOffsetValue( curr_value ) );
363 }
#define OFFSET_INCREMENT_MM_FINE
#define OFFSET_INCREMENT_MM
wxString formatOffsetValue(double aValue)
Definition: common.h:160
double DoubleValueFromString(EDA_UNITS_T aUnits, const wxString &aTextValue, bool aUseMils)
Function DoubleValueFromString converts aTextValue to a double.
Definition: base_units.cpp:302
EDA_UNITS_T m_userUnits
Index into m_parentInfoList.
#define OFFSET_INCREMENT_MIL_FINE
#define OFFSET_INCREMENT_MIL
#define max(a, b)
Definition: auxiliary.h:86
#define MAX_OFFSET
#define min(a, b)
Definition: auxiliary.h:85
void PANEL_PREV_3D::onMouseWheelRot ( wxMouseEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_PREV_3D_BASE.

Definition at line 315 of file panel_prev_model.cpp.

References DEGREES, DoubleValueFromString(), formatRotationValue(), max, MAX_ROTATION, min, ROTATION_INCREMENT_WHEEL, and ROTATION_INCREMENT_WHEEL_FINE.

316 {
317  wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
318 
319  double step = ROTATION_INCREMENT_WHEEL;
320 
321  if( event.ShiftDown( ) )
323 
324  if( event.GetWheelRotation() >= 0 )
325  step = -step;
326 
327  double curr_value = DoubleValueFromString( DEGREES, textCtrl->GetValue() ) / 10.0;
328 
329  curr_value += step;
330  curr_value = std::max( -MAX_ROTATION, curr_value );
331  curr_value = std::min( curr_value, MAX_ROTATION );
332 
333  textCtrl->SetValue( formatRotationValue( curr_value ) );
334 }
wxString formatRotationValue(double aValue)
double DoubleValueFromString(EDA_UNITS_T aUnits, const wxString &aTextValue, bool aUseMils)
Function DoubleValueFromString converts aTextValue to a double.
Definition: base_units.cpp:302
#define max(a, b)
Definition: auxiliary.h:86
#define ROTATION_INCREMENT_WHEEL_FINE
#define ROTATION_INCREMENT_WHEEL
#define MAX_ROTATION
#define min(a, b)
Definition: auxiliary.h:85
void PANEL_PREV_3D::onMouseWheelScale ( wxMouseEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_PREV_3D_BASE.

Definition at line 293 of file panel_prev_model.cpp.

References DoubleValueFromString(), formatScaleValue(), max, MAX_SCALE, min, SCALE_INCREMENT, SCALE_INCREMENT_FINE, and UNSCALED_UNITS.

294 {
295  wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
296 
297  double step = SCALE_INCREMENT;
298 
299  if( event.ShiftDown( ) )
300  step = SCALE_INCREMENT_FINE;
301 
302  if( event.GetWheelRotation() >= 0 )
303  step = -step;
304 
305  double curr_value = DoubleValueFromString( UNSCALED_UNITS, textCtrl->GetValue() );
306 
307  curr_value += step;
308  curr_value = std::max( 1/MAX_SCALE, curr_value );
309  curr_value = std::min( curr_value, MAX_SCALE );
310 
311  textCtrl->SetValue( formatScaleValue( curr_value ) );
312 }
#define SCALE_INCREMENT_FINE
wxString formatScaleValue(double aValue)
#define SCALE_INCREMENT
double DoubleValueFromString(EDA_UNITS_T aUnits, const wxString &aTextValue, bool aUseMils)
Function DoubleValueFromString converts aTextValue to a double.
Definition: base_units.cpp:302
#define MAX_SCALE
#define max(a, b)
Definition: auxiliary.h:86
#define min(a, b)
Definition: auxiliary.h:85
void PANEL_PREV_3D::SetSelectedModel ( int  idx)

SetModelDataIdx - Sets the currently selected index in the model list so that the scale/rotation/offset controls can be updated.

Definition at line 160 of file panel_prev_model.cpp.

References formatOffsetValue(), formatRotationValue(), formatScaleValue(), MODULE_3D_SETTINGS::m_Offset, m_parentModelList, MODULE_3D_SETTINGS::m_Rotation, MODULE_3D_SETTINGS::m_Scale, m_selected, MODULE_3D_SETTINGS::VECTOR3D::x, PANEL_PREV_3D_BASE::xoff, PANEL_PREV_3D_BASE::xrot, PANEL_PREV_3D_BASE::xscale, MODULE_3D_SETTINGS::VECTOR3D::y, PANEL_PREV_3D_BASE::yoff, PANEL_PREV_3D_BASE::yrot, PANEL_PREV_3D_BASE::yscale, MODULE_3D_SETTINGS::VECTOR3D::z, PANEL_PREV_3D_BASE::zoff, PANEL_PREV_3D_BASE::zrot, and PANEL_PREV_3D_BASE::zscale.

Referenced by DIALOG_FOOTPRINT_FP_EDITOR::select3DModel(), DIALOG_FOOTPRINT_BOARD_EDITOR::select3DModel(), and View3DBottom().

161 {
162  if( m_parentModelList && idx >= 0 && idx < (int) m_parentModelList->size() )
163  {
164  m_selected = idx;
165  const MODULE_3D_SETTINGS& modelInfo = m_parentModelList->at( (unsigned) m_selected );
166 
167  // Use ChangeValue() instead of SetValue(). It's not the user making the change, so we
168  // don't want to generate wxEVT_GRID_CELL_CHANGED events.
169 
170  xscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.x ) );
171  yscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.y ) );
172  zscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.z ) );
173 
174  xrot->ChangeValue( formatRotationValue( modelInfo.m_Rotation.x ) );
175  yrot->ChangeValue( formatRotationValue( modelInfo.m_Rotation.y ) );
176  zrot->ChangeValue( formatRotationValue( modelInfo.m_Rotation.z ) );
177 
178  xoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.x ) );
179  yoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.y ) );
180  zoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.z ) );
181  }
182  else
183  {
184  m_selected = -1;
185 
186  xscale->ChangeValue( wxEmptyString );
187  yscale->ChangeValue( wxEmptyString );
188  zscale->ChangeValue( wxEmptyString );
189 
190  xrot->ChangeValue( wxEmptyString );
191  yrot->ChangeValue( wxEmptyString );
192  zrot->ChangeValue( wxEmptyString );
193 
194  xoff->ChangeValue( wxEmptyString );
195  yoff->ChangeValue( wxEmptyString );
196  zoff->ChangeValue( wxEmptyString );
197  }
198 }
wxString formatRotationValue(double aValue)
std::vector< MODULE_3D_SETTINGS > * m_parentModelList
wxString formatScaleValue(double aValue)
VECTOR3D m_Offset
3D model offset (mm)
Definition: class_module.h:102
wxString formatOffsetValue(double aValue)
VECTOR3D m_Rotation
3D model rotation (degrees)
Definition: class_module.h:101
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
Definition: class_module.h:100
void PANEL_PREV_3D::UpdateDummyModule ( bool  aRelaodRequired = true)

UpdateModelInfoList - copy shapes from the current shape list which are flagged for preview to the copy of module that is on the preview dummy board.

Definition at line 366 of file panel_prev_model.cpp.

References i, m_dummyModule, m_parentModelList, m_previewPane, MODULE::Models(), EDA_3D_CANVAS::ReloadRequest(), and EDA_3D_CANVAS::Request_refresh().

Referenced by DIALOG_FOOTPRINT_FP_EDITOR::Cfg3DPath(), DIALOG_FOOTPRINT_BOARD_EDITOR::Cfg3DPath(), DIALOG_FOOTPRINT_FP_EDITOR::On3DModelCellChanged(), DIALOG_FOOTPRINT_BOARD_EDITOR::On3DModelCellChanged(), DIALOG_FOOTPRINT_FP_EDITOR::OnAdd3DModel(), DIALOG_FOOTPRINT_BOARD_EDITOR::OnAdd3DModel(), DIALOG_FOOTPRINT_FP_EDITOR::OnRemove3DModel(), DIALOG_FOOTPRINT_BOARD_EDITOR::OnRemove3DModel(), updateOrientation(), and View3DBottom().

367 {
368  m_dummyModule->Models().clear();
369 
370  for( size_t i = 0; i < m_parentModelList->size(); ++i )
371  {
372  if( m_parentModelList->at( i ).m_Preview )
373  {
374  m_dummyModule->Models().insert( m_dummyModule->Models().end(),
375  m_parentModelList->at( i ) );
376  }
377  }
378 
379  if( aReloadRequired )
381 
383 }
std::vector< MODULE_3D_SETTINGS > * m_parentModelList
void Request_refresh(bool aRedrawImmediately=true)
Request_refresh - Schedule a refresh update of the canvas.
void ReloadRequest(BOARD *aBoard=NULL, S3D_CACHE *aCachePointer=NULL)
MODULE * m_dummyModule
EDA_3D_CANVAS * m_previewPane
std::list< MODULE_3D_SETTINGS > & Models()
Definition: class_module.h:179
size_t i
Definition: json11.cpp:597
void PANEL_PREV_3D::updateOrientation ( wxCommandEvent &  event)
overrideprivatevirtual

updateOrientation - it will receive the events from editing the fields

Parameters
event

Reimplemented from PANEL_PREV_3D_BASE.

Definition at line 201 of file panel_prev_model.cpp.

References DoubleValueFromString(), MODULE_3D_SETTINGS::m_Offset, m_parentModelList, MODULE_3D_SETTINGS::m_Rotation, MODULE_3D_SETTINGS::m_Scale, m_selected, m_userUnits, rotationFromString(), UNSCALED_UNITS, UpdateDummyModule(), MODULE_3D_SETTINGS::VECTOR3D::x, PANEL_PREV_3D_BASE::xoff, PANEL_PREV_3D_BASE::xrot, PANEL_PREV_3D_BASE::xscale, MODULE_3D_SETTINGS::VECTOR3D::y, PANEL_PREV_3D_BASE::yoff, PANEL_PREV_3D_BASE::yrot, PANEL_PREV_3D_BASE::yscale, MODULE_3D_SETTINGS::VECTOR3D::z, PANEL_PREV_3D_BASE::zoff, PANEL_PREV_3D_BASE::zrot, and PANEL_PREV_3D_BASE::zscale.

202 {
203  if( m_parentModelList && m_selected >= 0 && m_selected < (int) m_parentModelList->size() )
204  {
205  // Write settings back to the parent
206  MODULE_3D_SETTINGS* modelInfo = &m_parentModelList->at( (unsigned) m_selected );
207 
208  modelInfo->m_Scale.x = DoubleValueFromString( UNSCALED_UNITS, xscale->GetValue() );
209  modelInfo->m_Scale.y = DoubleValueFromString( UNSCALED_UNITS, yscale->GetValue() );
210  modelInfo->m_Scale.z = DoubleValueFromString( UNSCALED_UNITS, zscale->GetValue() );
211 
212  modelInfo->m_Rotation.x = rotationFromString( xrot->GetValue() );
213  modelInfo->m_Rotation.y = rotationFromString( yrot->GetValue() );
214  modelInfo->m_Rotation.z = rotationFromString( zrot->GetValue() );
215 
216  modelInfo->m_Offset.x = DoubleValueFromString( m_userUnits, xoff->GetValue() ) / IU_PER_MM;
217  modelInfo->m_Offset.y = DoubleValueFromString( m_userUnits, yoff->GetValue() ) / IU_PER_MM;
218  modelInfo->m_Offset.z = DoubleValueFromString( m_userUnits, zoff->GetValue() ) / IU_PER_MM;
219 
220  // Update the dummy module for the preview
221  UpdateDummyModule( false );
222  }
223 }
void UpdateDummyModule(bool aRelaodRequired=true)
UpdateModelInfoList - copy shapes from the current shape list which are flagged for preview to the co...
std::vector< MODULE_3D_SETTINGS > * m_parentModelList
VECTOR3D m_Offset
3D model offset (mm)
Definition: class_module.h:102
double DoubleValueFromString(EDA_UNITS_T aUnits, const wxString &aTextValue, bool aUseMils)
Function DoubleValueFromString converts aTextValue to a double.
Definition: base_units.cpp:302
EDA_UNITS_T m_userUnits
Index into m_parentInfoList.
VECTOR3D m_Rotation
3D model rotation (degrees)
Definition: class_module.h:101
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
Definition: class_module.h:100
static double rotationFromString(const wxString &aValue)
rotationFromString Ensure -MAX_ROTATION <= rotation <= MAX_ROTATION aRotation will be normalized betw...
void PANEL_PREV_3D::View3DBack ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_PREV_3D_BASE.

Definition at line 171 of file panel_prev_model.h.

References GR_KB_SHIFT, and EDA_3D_CANVAS::SetView3D().

172  {
174  }
EDA_3D_CANVAS * m_previewPane
#define GR_KB_SHIFT
bool SetView3D(int aKeycode)
SetView3D - Helper function to call view commands.
void PANEL_PREV_3D::View3DBottom ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_PREV_3D_BASE.

Definition at line 176 of file panel_prev_model.h.

References GR_KB_SHIFT, SetSelectedModel(), EDA_3D_CANVAS::SetView3D(), and UpdateDummyModule().

177  {
179  }
EDA_3D_CANVAS * m_previewPane
#define GR_KB_SHIFT
bool SetView3D(int aKeycode)
SetView3D - Helper function to call view commands.
void PANEL_PREV_3D::View3DFront ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_PREV_3D_BASE.

Definition at line 150 of file panel_prev_model.h.

References EDA_3D_CANVAS::SetView3D().

151  {
152  m_previewPane->SetView3D( 'Y' );
153  }
EDA_3D_CANVAS * m_previewPane
bool SetView3D(int aKeycode)
SetView3D - Helper function to call view commands.
void PANEL_PREV_3D::View3DISO ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_PREV_3D_BASE.

Definition at line 139 of file panel_prev_model.h.

References CINFO3D_VISU::CameraGet(), and CCAMERA::ToggleProjection().

140  {
142  m_previewPane->Refresh();
143  }
CINFO3D_VISU * m_settings3Dviewer
void ToggleProjection()
Definition: ccamera.cpp:417
EDA_3D_CANVAS * m_previewPane
CCAMERA & CameraGet() const
CameraGet - get current camera in use.
Definition: cinfo3d_visu.h:210
void PANEL_PREV_3D::View3DLeft ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_PREV_3D_BASE.

Definition at line 145 of file panel_prev_model.h.

References GR_KB_SHIFT, and EDA_3D_CANVAS::SetView3D().

146  {
148  }
EDA_3D_CANVAS * m_previewPane
#define GR_KB_SHIFT
bool SetView3D(int aKeycode)
SetView3D - Helper function to call view commands.
void PANEL_PREV_3D::View3DRight ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_PREV_3D_BASE.

Definition at line 166 of file panel_prev_model.h.

References EDA_3D_CANVAS::SetView3D().

167  {
168  m_previewPane->SetView3D( 'X' );
169  }
EDA_3D_CANVAS * m_previewPane
bool SetView3D(int aKeycode)
SetView3D - Helper function to call view commands.
void PANEL_PREV_3D::View3DTop ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_PREV_3D_BASE.

Definition at line 155 of file panel_prev_model.h.

References EDA_3D_CANVAS::SetView3D().

156  {
157  m_previewPane->SetView3D( 'Z' );
158  }
EDA_3D_CANVAS * m_previewPane
bool SetView3D(int aKeycode)
SetView3D - Helper function to call view commands.
void PANEL_PREV_3D::View3DUpdate ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_PREV_3D_BASE.

Definition at line 160 of file panel_prev_model.h.

References EDA_3D_CANVAS::ReloadRequest().

161  {
163  m_previewPane->Refresh();
164  }
void ReloadRequest(BOARD *aBoard=NULL, S3D_CACHE *aCachePointer=NULL)
EDA_3D_CANVAS * m_previewPane

Member Data Documentation

wxBitmapButton* PANEL_PREV_3D_BASE::m_bpUpdate
protectedinherited
wxBitmapButton* PANEL_PREV_3D_BASE::m_bpvBack
protectedinherited
wxBitmapButton* PANEL_PREV_3D_BASE::m_bpvBottom
protectedinherited
wxBitmapButton* PANEL_PREV_3D_BASE::m_bpvFront
protectedinherited
wxBitmapButton* PANEL_PREV_3D_BASE::m_bpvISO
protectedinherited
wxBitmapButton* PANEL_PREV_3D_BASE::m_bpvLeft
protectedinherited
wxBitmapButton* PANEL_PREV_3D_BASE::m_bpvRight
protectedinherited
wxBitmapButton* PANEL_PREV_3D_BASE::m_bpvTop
protectedinherited
BOARD* PANEL_PREV_3D::m_dummyBoard
private

Definition at line 84 of file panel_prev_model.h.

Referenced by initPanel(), PANEL_PREV_3D(), and ~PANEL_PREV_3D().

MODULE* PANEL_PREV_3D::m_dummyModule
private

Definition at line 85 of file panel_prev_model.h.

Referenced by PANEL_PREV_3D(), and UpdateDummyModule().

std::vector<MODULE_3D_SETTINGS>* PANEL_PREV_3D::m_parentModelList
private
EDA_3D_CANVAS* PANEL_PREV_3D::m_previewPane
private

Definition at line 81 of file panel_prev_model.h.

Referenced by PANEL_PREV_3D(), UpdateDummyModule(), and ~PANEL_PREV_3D().

int PANEL_PREV_3D::m_selected
private

Definition at line 88 of file panel_prev_model.h.

Referenced by initPanel(), SetSelectedModel(), and updateOrientation().

CINFO3D_VISU* PANEL_PREV_3D::m_settings3Dviewer
private

Definition at line 82 of file panel_prev_model.h.

Referenced by PANEL_PREV_3D(), and ~PANEL_PREV_3D().

wxBoxSizer* PANEL_PREV_3D_BASE::m_SizerPanelView
protectedinherited

Definition at line 68 of file panel_prev_3d_base.h.

Referenced by PANEL_PREV_3D(), and PANEL_PREV_3D_BASE::PANEL_PREV_3D_BASE().

wxSpinButton* PANEL_PREV_3D_BASE::m_spinXoffset
protectedinherited
wxSpinButton* PANEL_PREV_3D_BASE::m_spinXrot
protectedinherited
wxSpinButton* PANEL_PREV_3D_BASE::m_spinXscale
protectedinherited
wxSpinButton* PANEL_PREV_3D_BASE::m_spinYoffset
protectedinherited
wxSpinButton* PANEL_PREV_3D_BASE::m_spinYrot
protectedinherited
wxSpinButton* PANEL_PREV_3D_BASE::m_spinYscale
protectedinherited
wxSpinButton* PANEL_PREV_3D_BASE::m_spinZoffset
protectedinherited
wxSpinButton* PANEL_PREV_3D_BASE::m_spinZrot
protectedinherited
wxSpinButton* PANEL_PREV_3D_BASE::m_spinZscale
protectedinherited
wxStaticText* PANEL_PREV_3D_BASE::m_staticText1
protectedinherited

Definition at line 42 of file panel_prev_3d_base.h.

Referenced by PANEL_PREV_3D_BASE::PANEL_PREV_3D_BASE().

wxStaticText* PANEL_PREV_3D_BASE::m_staticText11
protectedinherited

Definition at line 51 of file panel_prev_3d_base.h.

Referenced by PANEL_PREV_3D_BASE::PANEL_PREV_3D_BASE().

wxStaticText* PANEL_PREV_3D_BASE::m_staticText12
protectedinherited

Definition at line 60 of file panel_prev_3d_base.h.

Referenced by PANEL_PREV_3D_BASE::PANEL_PREV_3D_BASE().

wxStaticText* PANEL_PREV_3D_BASE::m_staticText2
protectedinherited

Definition at line 45 of file panel_prev_3d_base.h.

Referenced by PANEL_PREV_3D_BASE::PANEL_PREV_3D_BASE().

wxStaticText* PANEL_PREV_3D_BASE::m_staticText21
protectedinherited

Definition at line 54 of file panel_prev_3d_base.h.

Referenced by PANEL_PREV_3D_BASE::PANEL_PREV_3D_BASE().

wxStaticText* PANEL_PREV_3D_BASE::m_staticText22
protectedinherited

Definition at line 63 of file panel_prev_3d_base.h.

Referenced by PANEL_PREV_3D_BASE::PANEL_PREV_3D_BASE().

wxStaticText* PANEL_PREV_3D_BASE::m_staticText3
protectedinherited

Definition at line 48 of file panel_prev_3d_base.h.

Referenced by PANEL_PREV_3D_BASE::PANEL_PREV_3D_BASE().

wxStaticText* PANEL_PREV_3D_BASE::m_staticText31
protectedinherited

Definition at line 57 of file panel_prev_3d_base.h.

Referenced by PANEL_PREV_3D_BASE::PANEL_PREV_3D_BASE().

wxStaticText* PANEL_PREV_3D_BASE::m_staticText32
protectedinherited

Definition at line 65 of file panel_prev_3d_base.h.

Referenced by PANEL_PREV_3D_BASE::PANEL_PREV_3D_BASE().

EDA_UNITS_T PANEL_PREV_3D::m_userUnits
private

Index into m_parentInfoList.

Definition at line 90 of file panel_prev_model.h.

Referenced by doIncrementOffset(), formatOffsetValue(), onMouseWheelOffset(), PANEL_PREV_3D(), and updateOrientation().

wxTextCtrl* PANEL_PREV_3D_BASE::xoff
protectedinherited
wxTextCtrl* PANEL_PREV_3D_BASE::xrot
protectedinherited
wxTextCtrl* PANEL_PREV_3D_BASE::xscale
protectedinherited
wxTextCtrl* PANEL_PREV_3D_BASE::yrot
protectedinherited
wxTextCtrl* PANEL_PREV_3D_BASE::yscale
protectedinherited
wxTextCtrl* PANEL_PREV_3D_BASE::zoff
protectedinherited
wxTextCtrl* PANEL_PREV_3D_BASE::zrot
protectedinherited
wxTextCtrl* PANEL_PREV_3D_BASE::zscale
protectedinherited

The documentation for this class was generated from the following files: