KiCad PCB EDA Suite
Loading...
Searching...
No Matches
shape_draw_behavior.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <eda_item.h>
23#include <eda_units.h>
24#include <math/vector2d.h>
25#include <tool/arc_draw_mode.h>
26
27class EDA_SHAPE;
28
29
39
40
54{
55public:
56 virtual ~SHAPE_DRAW_BEHAVIOR() = default;
57
58 //
59 // Non-geometric state interfaces
60 //
61
63 virtual bool IsComplete() const = 0;
64
66 virtual bool HasGeometryChanged() const = 0;
67
69 virtual void ClearGeometryChanged() = 0;
70
72 virtual int GetStep() const = 0;
73
75 virtual void Reset() = 0;
76
77 //
78 // Interactive operations called from a TOOL framework event loop
79 //
80
82 virtual void AddPoint( const VECTOR2I& aPosition ) = 0;
83
85 virtual void SetCursorPosition( const VECTOR2I& aPosition ) = 0;
86
88 virtual void RemoveLastPoint() = 0;
89
92 virtual void ToggleClockwise() {}
93
95 virtual void SetAngleSnap( bool aSnap ) {}
96
103 virtual void SetArcDrawMode( ARC_DRAW_MODE aMode ) {}
104
116 virtual void SetTangentSeed( const VECTOR2I& aStart, const VECTOR2D& aDirection,
117 bool aDirectionIsAxis = false ) {}
118
125 virtual bool OnProperties( EDA_SHAPE& aShape ) { return false; }
126
127 //
128 // Geometry access
129 //
130
132 virtual void ApplyToShape( EDA_SHAPE& aShape ) const = 0;
133
135 virtual EDA_ITEM& GetAssistant() = 0;
136
138 virtual void SetUnits( EDA_UNITS aUnits ) = 0;
139};
ARC_DRAW_MODE
Construction sequence used when interactively drawing a circular arc.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
Abstract interface for interactive shape-drawing behaviours.
virtual void AddPoint(const VECTOR2I &aPosition)=0
Lock in a point and advance the construction state.
virtual void Reset()=0
Reset the behaviour to its initial state for chained object creation loops.
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 void SetArcDrawMode(ARC_DRAW_MODE aMode)
Select the construction sequence (circular arcs only; no-op for others).
virtual bool IsComplete() const =0
True when all points have been locked in.
virtual int GetStep() const =0
Return the current construction step (0-based, shape-specific meaning).
virtual void SetCursorPosition(const VECTOR2I &aPosition)=0
Preview the cursor position without advancing state.
virtual void SetUnits(EDA_UNITS aUnits)=0
Forward a units change to the assistant overlay.
virtual bool HasGeometryChanged() const =0
True if the geometry changed since the last call to ClearGeometryChanged().
virtual void RemoveLastPoint()=0
Undo the last locked-in point.
virtual EDA_ITEM & GetAssistant()=0
Return the visual assistant overlay item.
virtual void ClearGeometryChanged()=0
Reset the geometry-changed flag (call after updating the preview).
virtual ~SHAPE_DRAW_BEHAVIOR()=default
virtual void ApplyToShape(EDA_SHAPE &aShape) const =0
Transfer the current geometry to an EDA_SHAPE.
virtual void SetAngleSnap(bool aSnap)
Enable or disable angle snapping (circular arcs only; no-op for others).
virtual bool OnProperties(EDA_SHAPE &aShape)
Called when the user invokes the properties action mid-draw.
virtual void ToggleClockwise()
Flip arc direction (applies only when the shape has such a concept of directionality,...
EDA_UNITS
Definition eda_units.h:44
SHAPE_DRAW_RESULT
Outcome of an interactive shape drawing loop, telling the caller how to continue.
@ NEXT_SHAPE
Commit the shape, if any, and start drawing another.
@ FINISHED
The user finished; commit the shape, if any, and stop drawing.
@ CANCELLED
The user cancelled; nothing to commit, stop drawing.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707