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

Arc drawing mode and tangent seed bookkeeping for one pass of an editor's managed-shape draw loop. More...

#include <arc_mode_session.h>

Public Types

using SEED_FINDER
 Tangent seed from a graphic under the cursor, given the raw and the snapped cursor positions.
 

Public Member Functions

 ARC_MODE_SESSION (SHAPE_DRAW_BEHAVIOR &aBehavior, APP_SETTINGS_BASE *aSettings, bool aDrawingArc, const std::optional< ARC_TANGENT_SEED > &aChainSeed, SEED_FINDER aFindSeed, std::function< void(ARC_DRAW_MODE)> aOnModeChanged)
 
ARC_DRAW_MODE Mode () const
 
void SetMode (ARC_DRAW_MODE aMode)
 Switch mode mid-draw, which drops any seed. Does nothing unless an arc is being drawn.
 
bool HandleModeEvent (const TOOL_EVENT &aEvent)
 Handle a mode or cycle action; return true if aEvent was one.
 
void PlacePoint (const VECTOR2I &aMouse, const VECTOR2I &aPos)
 Lock in a point, or seed a tangent arc from the graphic under it when it would be the arc's first point.
 
void RemoveLastPoint ()
 Undo the last point. A seed taken from a click is undone too, one from a chain is kept.
 

Private Attributes

SHAPE_DRAW_BEHAVIOR & m_behavior
 
APP_SETTINGS_BASE * m_settings
 
bool m_drawingArc
 
bool m_chainSeeded
 
bool m_clickSeeded = false
 
SEED_FINDER m_findSeed
 
std::function< void(ARC_DRAW_MODE)> m_onModeChanged
 

Detailed Description

Arc drawing mode and tangent seed bookkeeping for one pass of an editor's managed-shape draw loop.

The editor supplies how to find a graphic to seed a tangent arc from and what to refresh when the mode changes. For shapes other than arcs the session only forwards points to the behavior.

Definition at line 49 of file arc_mode_session.h.

Member Typedef Documentation

◆ SEED_FINDER

Initial value:
std::function<std::optional<ARC_TANGENT_SEED>( const VECTOR2I& aMouse,
const VECTOR2I& aPos )>
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708

Tangent seed from a graphic under the cursor, given the raw and the snapped cursor positions.

Definition at line 53 of file arc_mode_session.h.

Constructor & Destructor Documentation

◆ ARC_MODE_SESSION()

ARC_MODE_SESSION::ARC_MODE_SESSION ( SHAPE_DRAW_BEHAVIOR & aBehavior,
APP_SETTINGS_BASE * aSettings,
bool aDrawingArc,
const std::optional< ARC_TANGENT_SEED > & aChainSeed,
SEED_FINDER aFindSeed,
std::function< void(ARC_DRAW_MODE)> aOnModeChanged )
Parameters
aChainSeedseeds the arc from the previous one in a chain. It is applied here, so construct the session after the behavior's Reset().

Definition at line 44 of file arc_mode_session.cpp.

References m_behavior, m_chainSeeded, m_drawingArc, m_findSeed, m_onModeChanged, m_settings, and move.

Member Function Documentation

◆ HandleModeEvent()

bool ARC_MODE_SESSION::HandleModeEvent ( const TOOL_EVENT & aEvent)

Handle a mode or cycle action; return true if aEvent was one.

Definition at line 82 of file arc_mode_session.cpp.

References TOOL_EVENT::Category(), ACTIONS::cycleArcDrawMode, IncrementArcDrawMode(), TOOL_EVENT::IsAction(), m_drawingArc, Mode(), TOOL_EVENT::ParameterIf(), SetMode(), and TC_COMMAND.

Referenced by DRAWING_TOOL::drawManagedShape().

◆ Mode()

ARC_DRAW_MODE ARC_MODE_SESSION::Mode ( ) const

Definition at line 59 of file arc_mode_session.cpp.

References CENTER_START_END, and m_settings.

Referenced by HandleModeEvent(), and PlacePoint().

◆ PlacePoint()

void ARC_MODE_SESSION::PlacePoint ( const VECTOR2I & aMouse,
const VECTOR2I & aPos )

Lock in a point, or seed a tangent arc from the graphic under it when it would be the arc's first point.

Definition at line 103 of file arc_mode_session.cpp.

References m_behavior, m_chainSeeded, m_clickSeeded, m_drawingArc, m_findSeed, Mode(), and TANGENT.

Referenced by DRAWING_TOOL::drawManagedShape().

◆ RemoveLastPoint()

void ARC_MODE_SESSION::RemoveLastPoint ( )

Undo the last point. A seed taken from a click is undone too, one from a chain is kept.

Definition at line 122 of file arc_mode_session.cpp.

References m_behavior, and m_clickSeeded.

Referenced by DRAWING_TOOL::drawManagedShape().

◆ SetMode()

void ARC_MODE_SESSION::SetMode ( ARC_DRAW_MODE aMode)

Switch mode mid-draw, which drops any seed. Does nothing unless an arc is being drawn.

Definition at line 65 of file arc_mode_session.cpp.

References m_behavior, m_chainSeeded, m_clickSeeded, m_drawingArc, m_onModeChanged, and m_settings.

Referenced by HandleModeEvent().

Member Data Documentation

◆ m_behavior

SHAPE_DRAW_BEHAVIOR& ARC_MODE_SESSION::m_behavior
private

Definition at line 79 of file arc_mode_session.h.

Referenced by ARC_MODE_SESSION(), PlacePoint(), RemoveLastPoint(), and SetMode().

◆ m_chainSeeded

bool ARC_MODE_SESSION::m_chainSeeded
private

Definition at line 82 of file arc_mode_session.h.

Referenced by ARC_MODE_SESSION(), PlacePoint(), and SetMode().

◆ m_clickSeeded

bool ARC_MODE_SESSION::m_clickSeeded = false
private

Definition at line 83 of file arc_mode_session.h.

Referenced by PlacePoint(), RemoveLastPoint(), and SetMode().

◆ m_drawingArc

bool ARC_MODE_SESSION::m_drawingArc
private

Definition at line 81 of file arc_mode_session.h.

Referenced by ARC_MODE_SESSION(), HandleModeEvent(), PlacePoint(), and SetMode().

◆ m_findSeed

SEED_FINDER ARC_MODE_SESSION::m_findSeed
private

Definition at line 84 of file arc_mode_session.h.

Referenced by ARC_MODE_SESSION(), and PlacePoint().

◆ m_onModeChanged

std::function<void( ARC_DRAW_MODE )> ARC_MODE_SESSION::m_onModeChanged
private

Definition at line 85 of file arc_mode_session.h.

Referenced by ARC_MODE_SESSION(), and SetMode().

◆ m_settings

APP_SETTINGS_BASE* ARC_MODE_SESSION::m_settings
private

Definition at line 80 of file arc_mode_session.h.

Referenced by ARC_MODE_SESSION(), Mode(), and SetMode().


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