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

References MAX_ROTATION.

Referenced by PANEL_PREV_3D::getOrientationVars().

141 {
142  if( aRotation > MAX_ROTATION )
143  {
144  int n = aRotation / MAX_ROTATION;
145  aRotation -= MAX_ROTATION * n;
146  }
147  else if( aRotation < -MAX_ROTATION )
148  {
149  int n = -aRotation / MAX_ROTATION;
150  aRotation += MAX_ROTATION * n;
151  }
152 }
#define MAX_ROTATION
static void incrementTextCtrl ( wxTextCtrl *  aTextCtrl,
double  aInc,
double  aMinval,
double  aMaxval 
)
static

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

174 {
175  if( !validateFloatTextCtrl( aTextCtrl ) )
176  return;
177 
178  double curr_value = 0;
179 
180  aTextCtrl->GetValue().ToDouble( &curr_value );
181  curr_value += aInc;
182 
183  if( curr_value > aMaxval )
184  curr_value = aMaxval;
185 
186  if( curr_value < aMinval )
187  curr_value = aMinval;
188 
189  aTextCtrl->SetValue( wxString::Format( "%.4f", curr_value ) );
190 }
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 154 of file panel_prev_model.cpp.

Referenced by incrementTextCtrl().

155  {
156  if( aTextCtrl == NULL )
157  return false;
158 
159  if( aTextCtrl->GetLineLength(0) == 0 ) // This will skip the got and event with empty field
160  return false;
161 
162  if( aTextCtrl->GetLineLength(0) == 1 )
163  {
164  if( (aTextCtrl->GetLineText(0).compare( "." ) == 0) ||
165  (aTextCtrl->GetLineText(0).compare( "," ) == 0) )
166  return false;
167  }
168 
169  return true;
170 }