KiCad PCB EDA Suite
panel_preview_3d_model.cpp File Reference

Go to the source code of this file.

Functions

static double rotationFromString (const wxString &aValue)
 Ensure -MAX_ROTATION <= rotation <= MAX_ROTATION. More...
 

Function Documentation

◆ rotationFromString()

static double rotationFromString ( const wxString &  aValue)
static

Ensure -MAX_ROTATION <= rotation <= MAX_ROTATION.

Parameters

Definition at line 223 of file panel_preview_3d_model.cpp.

224 {
225  double rotation = DoubleValueFromString( EDA_UNITS::DEGREES, aValue ) / 10.0;
226 
227  if( rotation > MAX_ROTATION )
228  {
229  int n = KiROUND( rotation / MAX_ROTATION );
230  rotation -= MAX_ROTATION * n;
231  }
232  else if( rotation < -MAX_ROTATION )
233  {
234  int n = KiROUND( -rotation / MAX_ROTATION );
235  rotation += MAX_ROTATION * n;
236  }
237 
238  return rotation;
239 }
#define MAX_ROTATION
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
double DoubleValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType)
Function DoubleValueFromString converts aTextValue to a double.
Definition: base_units.cpp:307

References DEGREES, DoubleValueFromString(), KiROUND(), and MAX_ROTATION.

Referenced by PANEL_PREVIEW_3D_MODEL::updateOrientation().