KiCad PCB EDA Suite
panel_prev_model.cpp File Reference
#include <3d_canvas/eda_3d_canvas.h>
#include <common_ogl/cogl_att_list.h>
#include <cstdlib>
#include <limits.h>
#include <bitmaps.h>
#include <wx/valnum.h>
#include <wx/tglbtn.h>
#include "project.h"
#include "panel_prev_model.h"
#include <class_board.h>

Go to the source code of this file.

Functions

static void checkRotation (double &aRotation)
 checkRotation Ensure -MAX_ROTATION <= rotation <= MAX_ROTATION aRotation will be normalized between -MAX_ROTATION and MAX_ROTATION More...
 
static bool validateFloatTextCtrl (wxTextCtrl *aTextCtrl)
 
static void incrementTextCtrl (wxTextCtrl *aTextCtrl, double aInc, double aMinval, double aMaxval)
 

Function Documentation

static void checkRotation ( double &  aRotation)
static

checkRotation Ensure -MAX_ROTATION <= rotation <= MAX_ROTATION aRotation will be normalized between -MAX_ROTATION and MAX_ROTATION

Parameters
aRotationin out parameter

Definition at line 164 of file panel_prev_model.cpp.

References MAX_ROTATION.

Referenced by PANEL_PREV_3D::getOrientationVars().

165 {
166  if( aRotation > MAX_ROTATION )
167  {
168  int n = aRotation / MAX_ROTATION;
169  aRotation -= MAX_ROTATION * n;
170  }
171  else if( aRotation < -MAX_ROTATION )
172  {
173  int n = -aRotation / MAX_ROTATION;
174  aRotation += MAX_ROTATION * n;
175  }
176 }
#define MAX_ROTATION
static void incrementTextCtrl ( wxTextCtrl *  aTextCtrl,
double  aInc,
double  aMinval,
double  aMaxval 
)
static

Definition at line 198 of file panel_prev_model.cpp.

References Format(), and validateFloatTextCtrl().

Referenced by PANEL_PREV_3D::onDecrementOffset(), PANEL_PREV_3D::onDecrementRot(), PANEL_PREV_3D::onDecrementScale(), PANEL_PREV_3D::onIncrementOffset(), PANEL_PREV_3D::onIncrementRot(), PANEL_PREV_3D::onIncrementScale(), PANEL_PREV_3D::onMouseWheelOffset(), PANEL_PREV_3D::onMouseWheelRot(), and PANEL_PREV_3D::onMouseWheelScale().

199 {
200  if( !validateFloatTextCtrl( aTextCtrl ) )
201  return;
202 
203  double curr_value = 0;
204 
205  aTextCtrl->GetValue().ToDouble( &curr_value );
206  curr_value += aInc;
207 
208  if( curr_value > aMaxval )
209  curr_value = aMaxval;
210 
211  if( curr_value < aMinval )
212  curr_value = aMinval;
213 
214  aTextCtrl->SetValue( wxString::Format( "%.4f", curr_value ) );
215 }
static bool validateFloatTextCtrl(wxTextCtrl *aTextCtrl)
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
static bool validateFloatTextCtrl ( wxTextCtrl *  aTextCtrl)
static

Definition at line 179 of file panel_prev_model.cpp.

Referenced by incrementTextCtrl().

180 {
181  if( aTextCtrl == NULL )
182  return false;
183 
184  if( aTextCtrl->GetLineLength(0) == 0 ) // This will skip the got and event with empty field
185  return false;
186 
187  if( aTextCtrl->GetLineLength(0) == 1 )
188  {
189  if( (aTextCtrl->GetLineText(0).compare( "." ) == 0) ||
190  (aTextCtrl->GetLineText(0).compare( "," ) == 0) )
191  return false;
192  }
193 
194  return true;
195 }