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
42{
43public:
44 virtual ~SHAPE_DRAW_BEHAVIOR() = default;
45
46 //
47 // Non-geometric state interfaces
48 //
49
51 virtual bool IsComplete() const = 0;
52
54 virtual bool HasGeometryChanged() const = 0;
55
57 virtual void ClearGeometryChanged() = 0;
58
60 virtual int GetStep() const = 0;
61
63 virtual void Reset() = 0;
64
65 //
66 // Interactive operations called from a TOOL framework event loop
67 //
68
70 virtual void AddPoint( const VECTOR2I& aPosition ) = 0;
71
73 virtual void SetCursorPosition( const VECTOR2I& aPosition ) = 0;
74
76 virtual void RemoveLastPoint() = 0;
77
80 virtual void ToggleClockwise() {}
81
83 virtual void SetAngleSnap( bool aSnap ) {}
84
91 virtual bool OnProperties( EDA_SHAPE& aShape ) { return false; }
92
93 //
94 // Geometry access
95 //
96
98 virtual void ApplyToShape( EDA_SHAPE& aShape ) const = 0;
99
101 virtual EDA_ITEM& GetAssistant() = 0;
102
104 virtual void SetUnits( EDA_UNITS aUnits ) = 0;
105};
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:96
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
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683