KiCad PCB EDA Suite
Loading...
Searching...
No Matches
SHAPE_DRAW_BEHAVIOR Class Referenceabstract

Abstract interface for interactive shape-drawing behaviours. More...

#include <shape_draw_behavior.h>

Inheritance diagram for SHAPE_DRAW_BEHAVIOR:
MANAGED_DRAW_BEHAVIOR< KIGFX::PREVIEW::ARC_GEOM_MANAGER, KIGFX::PREVIEW::ARC_ASSISTANT > MANAGED_DRAW_BEHAVIOR< KIGFX::PREVIEW::BEZIER_GEOM_MANAGER, KIGFX::PREVIEW::BEZIER_ASSISTANT > MANAGED_DRAW_BEHAVIOR< KIGFX::PREVIEW::ELLIPSE_GEOM_MANAGER, KIGFX::PREVIEW::ELLIPSE_ASSISTANT > MANAGED_DRAW_BEHAVIOR< ManagerT, AssistantT > ARC_DRAW_BEHAVIOR BEZIER_DRAW_BEHAVIOR ELLIPSE_ARC_DRAW_BEHAVIOR

Public Member Functions

virtual ~SHAPE_DRAW_BEHAVIOR ()=default
 
virtual bool IsComplete () const =0
 True when all points have been locked in.
 
virtual bool HasGeometryChanged () const =0
 True if the geometry changed since the last call to ClearGeometryChanged().
 
virtual void ClearGeometryChanged ()=0
 Reset the geometry-changed flag (call after updating the preview).
 
virtual int GetStep () const =0
 Return the current construction step (0-based, shape-specific meaning).
 
virtual void Reset ()=0
 Reset the behaviour to its initial state for chained object creation loops.
 
virtual void AddPoint (const VECTOR2I &aPosition)=0
 Lock in a point and advance the construction state.
 
virtual void SetCursorPosition (const VECTOR2I &aPosition)=0
 Preview the cursor position without advancing state.
 
virtual void RemoveLastPoint ()=0
 Undo the last locked-in point.
 
virtual void ToggleClockwise ()
 Flip arc direction (applies only when the shape has such a concept of directionality, e.g.
 
virtual void SetAngleSnap (bool aSnap)
 Enable or disable angle snapping (circular arcs only; no-op for others).
 
virtual void SetArcDrawMode (ARC_DRAW_MODE aMode)
 Select the construction sequence (circular arcs only; no-op for others).
 
virtual void SetTangentSeed (const VECTOR2I &aStart, const VECTOR2D &aDirection, bool aDirectionIsAxis=false)
 Preload the start point and departure direction for ARC_DRAW_MODE::TANGENT.
 
virtual bool OnProperties (EDA_SHAPE &aShape)
 Called when the user invokes the properties action mid-draw.
 
virtual void ApplyToShape (EDA_SHAPE &aShape) const =0
 Transfer the current geometry to an EDA_SHAPE.
 
virtual EDA_ITEM & GetAssistant ()=0
 Return the visual assistant overlay item.
 
virtual void SetUnits (EDA_UNITS aUnits)=0
 Forward a units change to the assistant overlay.
 

Detailed Description

Abstract interface for interactive shape-drawing behaviours.

Concrete implementations wrap a geometry manager (for the construction state machine) and an assistant (for the visual overlay).

Callers drive the behaviour through this class and finally must use ApplyToShape() to transfer the geometry to an EDA_SHAPE.

The visual assistant (returned by GetAssistant()) must be added to a KIGFX::VIEW by the caller.

Definition at line 53 of file shape_draw_behavior.h.

Constructor & Destructor Documentation

◆ ~SHAPE_DRAW_BEHAVIOR()

virtual SHAPE_DRAW_BEHAVIOR::~SHAPE_DRAW_BEHAVIOR ( )
virtualdefault

Member Function Documentation

◆ AddPoint()

◆ ApplyToShape()

virtual void SHAPE_DRAW_BEHAVIOR::ApplyToShape ( EDA_SHAPE & aShape) const
pure virtual

◆ ClearGeometryChanged()

◆ GetAssistant()

◆ GetStep()

◆ HasGeometryChanged()

◆ IsComplete()

◆ OnProperties()

virtual bool SHAPE_DRAW_BEHAVIOR::OnProperties ( EDA_SHAPE & aShape)
inlinevirtual

Called when the user invokes the properties action mid-draw.

Returns
true if the behavior handled the request (the event loop should continue); false if the event should be passed on.

Reimplemented in ARC_DRAW_BEHAVIOR, BEZIER_DRAW_BEHAVIOR, and ELLIPSE_ARC_DRAW_BEHAVIOR.

Definition at line 125 of file shape_draw_behavior.h.

Referenced by DRAWING_TOOL::drawManagedShape().

◆ RemoveLastPoint()

◆ Reset()

◆ SetAngleSnap()

virtual void SHAPE_DRAW_BEHAVIOR::SetAngleSnap ( bool aSnap)
inlinevirtual

Enable or disable angle snapping (circular arcs only; no-op for others).

Reimplemented in ARC_DRAW_BEHAVIOR.

Definition at line 95 of file shape_draw_behavior.h.

Referenced by DRAWING_TOOL::drawManagedShape().

◆ SetArcDrawMode()

virtual void SHAPE_DRAW_BEHAVIOR::SetArcDrawMode ( ARC_DRAW_MODE aMode)
inlinevirtual

Select the construction sequence (circular arcs only; no-op for others).

Switching mid-draw keeps the first locked point when it is an arc start in both modes, which is every mode except CENTER_START_END; otherwise construction restarts.

Reimplemented in ARC_DRAW_BEHAVIOR.

Definition at line 103 of file shape_draw_behavior.h.

Referenced by StartArcDrawMode().

◆ SetCursorPosition()

◆ SetTangentSeed()

virtual void SHAPE_DRAW_BEHAVIOR::SetTangentSeed ( const VECTOR2I & aStart,
const VECTOR2D & aDirection,
bool aDirectionIsAxis = false )
inlinevirtual

Preload the start point and departure direction for ARC_DRAW_MODE::TANGENT.

Reset() clears the seed, so call this after Reset() and before the first AddPoint(). Without a seed, TANGENT takes its start and direction from clicks exactly like START_DIR_END.

Parameters
aDirectionIsAxisfalse when aDirection is the signed departure direction (continuing from an endpoint); true when only the tangent line is known (starting inside an item), in which case the sign giving the smaller sweep to the cursor is used and ToggleClockwise() flips it.

Reimplemented in ARC_DRAW_BEHAVIOR.

Definition at line 116 of file shape_draw_behavior.h.

◆ SetUnits()

◆ ToggleClockwise()

virtual void SHAPE_DRAW_BEHAVIOR::ToggleClockwise ( )
inlinevirtual

Flip arc direction (applies only when the shape has such a concept of directionality, e.g.

circular arcs).

Reimplemented in ARC_DRAW_BEHAVIOR.

Definition at line 92 of file shape_draw_behavior.h.

Referenced by DRAWING_TOOL::drawManagedShape(), and EE_GRAPHIC_TOOL::drawManagedShape().


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