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 225 of file panel_preview_3d_model.cpp.

226 {
227  double rotation = DoubleValueFromString( EDA_UNITS::DEGREES, aValue ) / 10.0;
228 
229  if( rotation > MAX_ROTATION )
230  {
231  int n = KiROUND( rotation / MAX_ROTATION );
232  rotation -= MAX_ROTATION * n;
233  }
234  else if( rotation < -MAX_ROTATION )
235  {
236  int n = KiROUND( -rotation / MAX_ROTATION );
237  rotation += MAX_ROTATION * n;
238  }
239 
240  return rotation;
241 }
#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:302

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

Referenced by PANEL_PREVIEW_3D_MODEL::updateOrientation().