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

References MAX_ROTATION.

Referenced by PANEL_PREV_3D::getOrientationVars().

131 {
132  if( aRotation > MAX_ROTATION )
133  {
134  int n = aRotation / MAX_ROTATION;
135  aRotation -= MAX_ROTATION * n;
136  }
137  else if( aRotation < -MAX_ROTATION )
138  {
139  int n = -aRotation / MAX_ROTATION;
140  aRotation += MAX_ROTATION * n;
141  }
142 }
#define MAX_ROTATION
static void incrementTextCtrl ( wxTextCtrl *  aTextCtrl,
double  aInc,
double  aMinval,
double  aMaxval 
)
static

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

164 {
165  if( !validateFloatTextCtrl( aTextCtrl ) )
166  return;
167 
168  double curr_value = 0;
169 
170  aTextCtrl->GetValue().ToDouble( &curr_value );
171  curr_value += aInc;
172 
173  if( curr_value > aMaxval )
174  curr_value = aMaxval;
175 
176  if( curr_value < aMinval )
177  curr_value = aMinval;
178 
179  aTextCtrl->SetValue( wxString::Format( "%.4f", curr_value ) );
180 }
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 144 of file panel_prev_model.cpp.

Referenced by incrementTextCtrl().

145  {
146  if( aTextCtrl == NULL )
147  return false;
148 
149  if( aTextCtrl->GetLineLength(0) == 0 ) // This will skip the got and event with empty field
150  return false;
151 
152  if( aTextCtrl->GetLineLength(0) == 1 )
153  {
154  if( (aTextCtrl->GetLineText(0).compare( "." ) == 0) ||
155  (aTextCtrl->GetLineText(0).compare( "," ) == 0) )
156  return false;
157  }
158 
159  return true;
160 }