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
26class EDA_SHAPE;
27
28
38
39
53{
54public:
55 virtual ~SHAPE_DRAW_BEHAVIOR() = default;
56
57 //
58 // Non-geometric state interfaces
59 //
60
62 virtual bool IsComplete() const = 0;
63
65 virtual bool HasGeometryChanged() const = 0;
66
68 virtual void ClearGeometryChanged() = 0;
69
71 virtual int GetStep() const = 0;
72
74 virtual void Reset() = 0;
75
76 //
77 // Interactive operations called from a TOOL framework event loop
78 //
79
81 virtual void AddPoint( const VECTOR2I& aPosition ) = 0;
82
84 virtual void SetCursorPosition( const VECTOR2I& aPosition ) = 0;
85
87 virtual void RemoveLastPoint() = 0;
88
91 virtual void ToggleClockwise() {}
92
94 virtual void SetAngleSnap( bool aSnap ) {}
95
102 virtual bool OnProperties( EDA_SHAPE& aShape ) { return false; }
103
104 //
105 // Geometry access
106 //
107
109 virtual void ApplyToShape( EDA_SHAPE& aShape ) const = 0;
110
112 virtual EDA_ITEM& GetAssistant() = 0;
113
115 virtual void SetUnits( EDA_UNITS aUnits ) = 0;
116};
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 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:683