KiCad PCB EDA Suite
KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER Class Reference

Class TWO_POINT_GEOMETRY_MANAGER. More...

#include <two_point_geom_manager.h>

Public Member Functions

void SetOrigin (const VECTOR2I &aOrigin)
 

Set the origin of the ruler (the fixed end)

More...
 
VECTOR2I GetOrigin () const
 
void SetEnd (const VECTOR2I &aEnd)
 Set the current end of the rectangle (the end that moves with the cursor. More...
 
VECTOR2I GetEnd () const
 
void SetAngleSnap (bool aSnap)
 

Private Attributes

VECTOR2I m_origin
 
VECTOR2I m_end
 
bool m_angleSnap = false
 

Detailed Description

Class TWO_POINT_GEOMETRY_MANAGER.

Represents a very simple geometry manager for items that have a start and end point.

Definition at line 43 of file two_point_geom_manager.h.

Member Function Documentation

void KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER::SetAngleSnap ( bool  aSnap)
inline
void KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER::SetEnd ( const VECTOR2I aEnd)
inline

Set the current end of the rectangle (the end that moves with the cursor.

Definition at line 62 of file two_point_geom_manager.h.

References PNS::angle(), VECTOR2< T >::EuclideanNorm(), KiROUND(), m_angleSnap, m_end, m_origin, and VECTOR2< T >::Rotate().

Referenced by MICROWAVE_TOOL::drawMicrowaveInductor(), and EDIT_TOOL::MeasureTool().

63  {
64  if( m_angleSnap )
65  {
66  const auto vec = aEnd - m_origin;
67  const auto len = vec.EuclideanNorm();
68  const auto angle = KiROUND( vec.Angle() / M_PI_4 ) * M_PI_4;
69 
70  m_end = m_origin + VECTOR2I( len, 0 ).Rotate( angle );
71  }
72  else
73  {
74  m_end = aEnd;
75  }
76  }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
VECTOR2< T > Rotate(double aAngle) const
Function Rotate rotates the vector by a given angle.
Definition: vector2d.h:372
VECTOR2< int > VECTOR2I
Definition: vector2d.h:589
T EuclideanNorm() const
Destructor.
Definition: vector2d.h:294
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER::SetOrigin ( const VECTOR2I aOrigin)
inline

Set the origin of the ruler (the fixed end)

Definition at line 48 of file two_point_geom_manager.h.

References m_origin.

Referenced by MICROWAVE_TOOL::drawMicrowaveInductor(), and EDIT_TOOL::MeasureTool().

49  {
50  m_origin = aOrigin;
51  }

Member Data Documentation

bool KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER::m_angleSnap = false
private

Definition at line 91 of file two_point_geom_manager.h.

Referenced by SetAngleSnap(), and SetEnd().

VECTOR2I KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER::m_end
private

Definition at line 90 of file two_point_geom_manager.h.

Referenced by GetEnd(), and SetEnd().

VECTOR2I KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER::m_origin
private

Definition at line 90 of file two_point_geom_manager.h.

Referenced by GetOrigin(), SetEnd(), and SetOrigin().


The documentation for this class was generated from the following file: