KiCad PCB EDA Suite
Loading...
Searching...
No Matches
EDA_ELLIPSE_POINT_EDIT_BEHAVIOR Class Reference

Edit behavior for ELLIPSE and ELLIPSE_ARC shapes. More...

#include <point_editor_behavior.h>

Inheritance diagram for EDA_ELLIPSE_POINT_EDIT_BEHAVIOR:
POINT_EDIT_BEHAVIOR

Public Member Functions

 EDA_ELLIPSE_POINT_EDIT_BEHAVIOR (EDA_SHAPE &aEllipse)
 
void MakePoints (EDIT_POINTS &aPoints) override
 Construct the initial set of edit points for the item and append to the given list.
 
bool UpdatePoints (EDIT_POINTS &aPoints) override
 Update the list of the edit points for the item.
 
void UpdateItem (const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
 Update the item with the new positions of the edit points.
 
virtual void FinalizeItem (EDIT_POINTS &aPoints, COMMIT &aCommit)
 Finalize the edit operation.
 
virtual OPT_VECTOR2I Get45DegreeConstrainer (const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints) const
 Get the 45-degree constrainer for the item, when the given point is moved.
 

Protected Types

enum  ELLIPSE_POINTS {
  ELLIPSE_CENTER = 0 , ELLIPSE_MAJOR_END , ELLIPSE_MINOR_END , ELLIPSE_ARC_START ,
  ELLIPSE_ARC_END , ELLIPSE_CLOSED_POINTS = 3 , ELLIPSE_ARC_POINTS = 5
}
 

Static Protected Member Functions

static bool isModified (const EDIT_POINT &aEditedPoint, const EDIT_POINT &aPoint)
 Checks if two points are the same instance - which means the point is being edited.
 

Private Member Functions

VECTOR2I evaluateAt (const EDA_ANGLE &aTheta) const
 World-space point on the ellipse at the given parametric angle.
 
EDA_ANGLE parametricAngleOf (const VECTOR2I &aWorldPt) const
 Inverse: the parametric angle of a world-space point relative to this ellipse.
 

Private Attributes

EDA_SHAPEm_ellipse
 

Detailed Description

Edit behavior for ELLIPSE and ELLIPSE_ARC shapes.


Closed ellipse: 3 handles (center, major-axis endpoint, minor-axis endpoint).
Elliptical arc: 5 handles (the above + arc start + arc end).

Drag semantics:

  • Center: translate the whole ellipse.
  • Major-end: set major radius + rotation (rotation follows the drag vector's world angle).
  • Minor-end: set minor radius only (rotation preserved; drag is projected onto the minor axis).
  • Arc start/end: set the respective parametric angles.

Definition at line 355 of file point_editor_behavior.h.

Member Enumeration Documentation

◆ ELLIPSE_POINTS

Enumerator
ELLIPSE_CENTER 
ELLIPSE_MAJOR_END 
ELLIPSE_MINOR_END 
ELLIPSE_ARC_START 
ELLIPSE_ARC_END 
ELLIPSE_CLOSED_POINTS 
ELLIPSE_ARC_POINTS 

Definition at line 372 of file point_editor_behavior.h.

Constructor & Destructor Documentation

◆ EDA_ELLIPSE_POINT_EDIT_BEHAVIOR()

EDA_ELLIPSE_POINT_EDIT_BEHAVIOR::EDA_ELLIPSE_POINT_EDIT_BEHAVIOR ( EDA_SHAPE & aEllipse)
inline

Definition at line 358 of file point_editor_behavior.h.

References ELLIPSE, ELLIPSE_ARC, EDA_SHAPE::GetShape(), and m_ellipse.

Member Function Documentation

◆ evaluateAt()

VECTOR2I EDA_ELLIPSE_POINT_EDIT_BEHAVIOR::evaluateAt ( const EDA_ANGLE & aTheta) const
private

World-space point on the ellipse at the given parametric angle.

Definition at line 139 of file point_editor_behavior.cpp.

References center, EDA_ANGLE::Cos(), KiROUND(), m_ellipse, and EDA_ANGLE::Sin().

Referenced by MakePoints(), and UpdatePoints().

◆ FinalizeItem()

virtual void POINT_EDIT_BEHAVIOR::FinalizeItem ( EDIT_POINTS & aPoints,
COMMIT & aCommit )
inlinevirtualinherited

Finalize the edit operation.

(optional)

This is called once, after the user has finished editing a point (e.g. released the mouse button).

Parameters
aPointsThe final positions of the edit points.
aCommitThe commit object to use to modify the item.

Reimplemented in EDA_POLYGON_POINT_EDIT_BEHAVIOR, and POLYGON_POINT_EDIT_BEHAVIOR.

Definition at line 82 of file point_editor_behavior.h.

◆ Get45DegreeConstrainer()

virtual OPT_VECTOR2I POINT_EDIT_BEHAVIOR::Get45DegreeConstrainer ( const EDIT_POINT & aEditedPoint,
EDIT_POINTS & aPoints ) const
inlinevirtualinherited

Get the 45-degree constrainer for the item, when the given point is moved.

Return std::nullopt if not, and the caller can decide.

If you want to actively disable constraining, return the aEditedPoint position.

Reimplemented in ALIGNED_DIMENSION_POINT_EDIT_BEHAVIOR, DIM_CENTER_POINT_EDIT_BEHAVIOR, DIM_RADIAL_POINT_EDIT_BEHAVIOR, EDA_ARC_POINT_EDIT_BEHAVIOR, EDA_CIRCLE_POINT_EDIT_BEHAVIOR, and EDA_SEGMENT_POINT_EDIT_BEHAVIOR.

Definition at line 109 of file point_editor_behavior.h.

◆ isModified()

◆ MakePoints()

void EDA_ELLIPSE_POINT_EDIT_BEHAVIOR::MakePoints ( EDIT_POINTS & aPoints)
overridevirtual

Construct the initial set of edit points for the item and append to the given list.

Parameters
aPointsThe list of edit points to fill.

Implements POINT_EDIT_BEHAVIOR.

Definition at line 177 of file point_editor_behavior.cpp.

References EDIT_POINTS::AddPoint(), center, EDA_ANGLE::Cos(), ELLIPSE_ARC, evaluateAt(), KiROUND(), m_ellipse, and EDA_ANGLE::Sin().

◆ parametricAngleOf()

EDA_ANGLE EDA_ELLIPSE_POINT_EDIT_BEHAVIOR::parametricAngleOf ( const VECTOR2I & aWorldPt) const
private

Inverse: the parametric angle of a world-space point relative to this ellipse.

Definition at line 158 of file point_editor_behavior.cpp.

References center, EDA_ANGLE::Cos(), m_ellipse, RADIANS_T, EDA_ANGLE::Sin(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by UpdateItem().

◆ UpdateItem()

void EDA_ELLIPSE_POINT_EDIT_BEHAVIOR::UpdateItem ( const EDIT_POINT & aEditedPoint,
EDIT_POINTS & aPoints,
COMMIT & aCommit,
std::vector< EDA_ITEM * > & aUpdatedItems )
overridevirtual

Update the item with the new positions of the edit points.

This method should all commit and add to the update list anything that is NOT the parent item of the EDIT_POINTs. For example, connected lines, parent tables, etc. The item itself is already handled (most behaviors don't need more than that).

Parameters
aEditedPointThe point that was dragged. You can use this to check by address which point to update.
aPointsThe new positions of the edit points.
aCommitThe commit object to use to modify the item.
aUpdatedItemsThe list of items that were updated by the edit (not only the item that was being edited, but also any other items that were affected, e.g. by being conneted to the edited item).

Implements POINT_EDIT_BEHAVIOR.

Definition at line 229 of file point_editor_behavior.cpp.

References std::abs(), ANGLE_360, center, CHECK_POINT_COUNT, EDA_ANGLE::Cos(), ELLIPSE_ARC, ELLIPSE_ARC_END, ELLIPSE_ARC_POINTS, ELLIPSE_ARC_START, ELLIPSE_CENTER, ELLIPSE_CLOSED_POINTS, ELLIPSE_MAJOR_END, ELLIPSE_MINOR_END, expected, EDIT_POINT::GetPosition(), POINT_EDIT_BEHAVIOR::isModified(), KiROUND(), m_ellipse, parametricAngleOf(), EDIT_POINTS::Point(), RADIANS_T, EDA_ANGLE::Sin(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ UpdatePoints()

bool EDA_ELLIPSE_POINT_EDIT_BEHAVIOR::UpdatePoints ( EDIT_POINTS & aPoints)
overridevirtual

Update the list of the edit points for the item.

Be very careful not to overrun the list of points - this class knows how big they are because it made them in the first place.

If item has changed such that that number of points needs to change, this method has to handle that (probably by clearing the list and refilling it).

If the behavior itself must change (for instance, a rectangle is non-cardinallly rotated to a polygon), the method should return false.

Parameters
aPointsThe list of edit points to update.

Implements POINT_EDIT_BEHAVIOR.

Definition at line 199 of file point_editor_behavior.cpp.

References center, EDA_ANGLE::Cos(), ELLIPSE_ARC, ELLIPSE_ARC_END, ELLIPSE_ARC_POINTS, ELLIPSE_ARC_START, ELLIPSE_CENTER, ELLIPSE_CLOSED_POINTS, ELLIPSE_MAJOR_END, ELLIPSE_MINOR_END, evaluateAt(), expected, KiROUND(), m_ellipse, EDIT_POINTS::Point(), EDIT_POINTS::PointsSize(), EDIT_POINT::SetPosition(), and EDA_ANGLE::Sin().

Member Data Documentation

◆ m_ellipse

EDA_SHAPE& EDA_ELLIPSE_POINT_EDIT_BEHAVIOR::m_ellipse
private

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