SketcherGui::DrawSketchHandlerEllipse Class Reference

This class handles user interaction to draw and save the ellipse. More...

#include <DrawSketchHandlerEllipse.h>

Public Types

enum  ConstructionMethod { CENTER_PERIAPSIS_B , PERIAPSIS_APOAPSIS_B }
 Construction methods, describes the method used to construct the ellipse. More...
 
enum  SelectMode {
  STATUS_SEEK_PERIAPSIS , STATUS_SEEK_APOAPSIS , STATUS_SEEK_CENTROID , STATUS_SEEK_A ,
  STATUS_SEEK_B , STATUS_Close
}
 Mode table, describes what step of the process we are in. More...
 

Public Member Functions

 DrawSketchHandlerEllipse (int constructionMethod)
 
virtual void mouseMove (Base::Vector2d onSketchPos) override
 Updates the ellipse when the cursor moves. More...
 
virtual bool pressButton (Base::Vector2d onSketchPos) override
 Changes drawing mode on user-click. More...
 
virtual bool releaseButton (Base::Vector2d onSketchPos) override
 Calls saveEllipse() after last user input. More...
 
virtual ~DrawSketchHandlerEllipse ()
 
- Public Member Functions inherited from SketcherGui::DrawSketchHandler
void activate (ViewProviderSketch *)
 
void createAutoConstraints (const std::vector< AutoConstraint > &autoConstrs, int geoId, Sketcher::PointPos pointPos=Sketcher::PointPos::none, bool createowncommand=true)
 
void deactivate ()
 
 DrawSketchHandler ()
 
int getHighestCurveIndex (void)
 
int getHighestVertexIndex (void)
 
virtual void mouseMove (Base::Vector2d onSketchPos)=0
 
virtual bool onSelectionChanged (const Gui::SelectionChanges &)
 
virtual bool pressButton (Base::Vector2d onSketchPos)=0
 
virtual void quit (void)
 
virtual void registerPressedKey (bool, int)
 
virtual bool releaseButton (Base::Vector2d onSketchPos)=0
 
void renderSuggestConstraintsCursor (std::vector< AutoConstraint > &suggestedConstraints)
 
void resetPositionText (void)
 
int seekAutoConstraint (std::vector< AutoConstraint > &suggestedConstraints, const Base::Vector2d &Pos, const Base::Vector2d &Dir, AutoConstraint::TargetType type=AutoConstraint::VERTEX)
 
void setPositionText (const Base::Vector2d &Pos)
 
void setPositionText (const Base::Vector2d &Pos, const SbString &text)
 
virtual ~DrawSketchHandler ()
 

Protected Attributes

std::vector< AutoConstraintsugConstr1
 
std::vector< AutoConstraintsugConstr2
 
std::vector< AutoConstraintsugConstr3
 
- Protected Attributes inherited from SketcherGui::DrawSketchHandler
ViewProviderSketchsketchgui
 
QCursor oldCursor
 
QCursor actCursor
 
QPixmap actCursorPixmap
 

Additional Inherited Members

- Protected Member Functions inherited from SketcherGui::DrawSketchHandler
virtual QString getCrosshairCursorSVGName () const
 
void setCursor (const QPixmap &pixmap, int x, int y, bool autoScale=true)
 
void updateCursor ()
 updates the actCursor with the icon by calling getCrosshairCursorSVGName(), enabling to set data member dependent icons (i.e. More...
 
void unsetCursor (void)
 restitutes the cursor that was in use at the moment of starting the DrawSketchHandler (i.e. oldCursor) More...
 
void applyCursor (void)
 restitutes the DSH cached cursor (e.g. without any tail due to autoconstraints, ...) More...
 
unsigned long getCrosshairColor ()
 returns the color to be used for the crosshair (configurable as a parameter) More...
 
qreal devicePixelRatio ()
 functions to set the cursor to a given svgName (to be migrated to NVI style) More...
 
void drawEdit (const std::vector< Base::Vector2d > &EditCurve)
 
void drawEdit (const std::list< std::vector< Base::Vector2d > > &list)
 
void drawEdit (const std::vector< Part::Geometry * > &geometries)
 
void drawEditMarkers (const std::vector< Base::Vector2d > &EditMarkers, unsigned int augmentationlevel=0)
 
void setAxisPickStyle (bool on)
 
void moveCursorToSketchPoint (Base::Vector2d point)
 
void preselectAtPoint (Base::Vector2d point)
 
void drawPositionAtCursor (const Base::Vector2d &position)
 
void drawDirectionAtCursor (const Base::Vector2d &position, const Base::Vector2d &origin)
 
int getPreselectPoint (void) const
 
int getPreselectCurve (void) const
 
int getPreselectCross (void) const
 
Sketcher::SketchObjectgetSketchObject ()
 
std::vector< QPixmap > suggestedConstraintsPixmaps (std::vector< AutoConstraint > &suggestedConstraints)
 Returns constraints icons scaled to width. More...
 

Detailed Description

This class handles user interaction to draw and save the ellipse.

Two construction methods are implemented: -Periapsis, apoapsis, and b; and -Center, periapsis, and b.

The first method limits the ellipse to a circle, while the second method allows for swapping of the semi-major and semi-minor axes.

We use three reference frames in this class. The first (and primary), is the cartesian frame of the sketcher; all our work begins and ends in this frame. The second is the perifocal frame of the ellipse using polar coordinates. We use this frame for naming conventions and working with the ellipse. The last is a rotated right-handed cartesian frame centered at the ellipse center with the +X direction towards periapsis, +Z out of screen.

When working with an ellipse in the perifocal frame, the following equations are useful:

\begin{eqnarray*}
       r &\equiv& \textrm{ radial distance from the focus to a point on the ellipse}\\
       r_a &\equiv& \textrm{ radial distance from the focus to apopasis}\\
       r_p &\equiv& \textrm{ radial distance from the focus to periapsis}\\
       a &\equiv& \textrm{ length of the semi-major axis, colloquially 'radius'}\\
       b &\equiv& \textrm{ length of the semi-minor axis, colloquially 'radius'}\\
       e &\equiv& \textrm{ eccentricity of the ellipse}\\
       \theta_b &\equiv& \textrm{ angle to the intersection of the semi-minor axis and the ellipse, relative to the focus}\\
       ae &\equiv& \textrm{ distance from the focus to the centroid}\\
       r &=& \frac{a(1-e^2)}{1+e\cos(\theta)} = \frac{r_a(1-e)}{1+e\cos(\theta)} = \frac{r_p(1+e)}{1+e\cos(\theta)}\\
       r_a &=& a(1-e)\\
       r_p &=& a(1+e)\\
       a &=& \frac{r_p+r_a}{2}\\
       b &=& a\sqrt{1-e^2}\\
       e &=& \frac{r_a-r_p}{r_a+r_p} = \sqrt{1-\frac{b^2}{a^2}}\\
       \theta_b &=& \left[\pi - \arctan\left(\frac{b}{ae}\right)\right] \pm N\pi
  \end{eqnarray*}

Member Enumeration Documentation

◆ ConstructionMethod

Construction methods, describes the method used to construct the ellipse.

Enumerator
CENTER_PERIAPSIS_B 

enum value, click on center, then periapsis, then b point.

PERIAPSIS_APOAPSIS_B 

enum value, click on periapsis, then apoapsis, then b point.

◆ SelectMode

Mode table, describes what step of the process we are in.

Enumerator
STATUS_SEEK_PERIAPSIS 

enum value, looking for click to set periapsis.

STATUS_SEEK_APOAPSIS 

enum value, looking for click to set apoapsis.

STATUS_SEEK_CENTROID 

enum value, looking for click to set centroid.

STATUS_SEEK_A 

enum value, looking for click to set a.

STATUS_SEEK_B 

enum value, looking for click to set b.

STATUS_Close 

enum value, finalizing and saving ellipse.

Constructor & Destructor Documentation

◆ DrawSketchHandlerEllipse()

SketcherGui::DrawSketchHandlerEllipse::DrawSketchHandlerEllipse ( int  constructionMethod)

◆ ~DrawSketchHandlerEllipse()

virtual SketcherGui::DrawSketchHandlerEllipse::~DrawSketchHandlerEllipse ( )
virtual

Member Function Documentation

◆ mouseMove()

◆ pressButton()

virtual bool SketcherGui::DrawSketchHandlerEllipse::pressButton ( Base::Vector2d  onSketchPos)
overridevirtual

Changes drawing mode on user-click.

Parameters
onSketchPosthe position of the cursor on the sketch
Returns

Implements SketcherGui::DrawSketchHandler.

References PERIAPSIS_APOAPSIS_B, STATUS_Close, STATUS_SEEK_APOAPSIS, STATUS_SEEK_B, STATUS_SEEK_CENTROID, and STATUS_SEEK_PERIAPSIS.

◆ releaseButton()

virtual bool SketcherGui::DrawSketchHandlerEllipse::releaseButton ( Base::Vector2d  onSketchPos)
overridevirtual

Calls saveEllipse() after last user input.

Parameters
onSketchPosthe position of the cursor on the sketch
Returns

Implements SketcherGui::DrawSketchHandler.

References CENTER_PERIAPSIS_B, App::GetApplication(), ParameterGrp::GetBool(), App::Application::GetParameterGroupByPath(), PERIAPSIS_APOAPSIS_B, STATUS_Close, STATUS_SEEK_CENTROID, and STATUS_SEEK_PERIAPSIS.

Member Data Documentation

◆ sugConstr1

std::vector<AutoConstraint> SketcherGui::DrawSketchHandlerEllipse::sugConstr1
protected

Referenced by mouseMove().

◆ sugConstr2

std::vector<AutoConstraint> SketcherGui::DrawSketchHandlerEllipse::sugConstr2
protected

Referenced by mouseMove().

◆ sugConstr3

std::vector<AutoConstraint> SketcherGui::DrawSketchHandlerEllipse::sugConstr3
protected

Referenced by mouseMove().


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