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 162 of file panel_prev_model.cpp.

References MAX_ROTATION.

Referenced by PANEL_PREV_3D::getOrientationVars().

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

Definition at line 195 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().

196 {
197  if( !validateFloatTextCtrl( aTextCtrl ) )
198  return;
199 
200  double curr_value = 0;
201 
202  aTextCtrl->GetValue().ToDouble( &curr_value );
203  curr_value += aInc;
204 
205  if( curr_value > aMaxval )
206  curr_value = aMaxval;
207 
208  if( curr_value < aMinval )
209  curr_value = aMinval;
210 
211  aTextCtrl->SetValue( wxString::Format( "%.4f", curr_value ) );
212 }
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 176 of file panel_prev_model.cpp.

Referenced by incrementTextCtrl().

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