KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_point_editor.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 (C) 2019 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef SCH_POINT_EDITOR_H
22#define SCH_POINT_EDITOR_H
23
24#include <tools/sch_tool_base.h>
25#include <tool/edit_points.h>
26#include <tool/selection.h>
27
28namespace KIGFX { namespace PREVIEW { class ANGLE_ITEM; } }
29
32class SCH_BASE_FRAME;
33class SCH_COMMIT;
34
38class SCH_POINT_EDITOR : public SCH_TOOL_BASE<SCH_BASE_FRAME>
39{
40public:
42
44 void Reset( RESET_REASON aReason ) override;
45
47 bool Init() override;
48
49 int Main( const TOOL_EVENT& aEvent );
50
55 bool HasPoint() { return m_editedPoint != nullptr; }
56
62 bool IsDragging() const { return m_inDrag; }
63
65 void setTransitions() override;
66
67private:
69 void updateParentItem( bool aSnapToGrid, SCH_COMMIT& aCommit ) const;
70
72 void dragPinsOnEdge( const std::vector<SEG>& aOldEdges, const std::vector<VECTOR2I>& aMoveVecs,
73 int aUnit, SCH_COMMIT& aCommit ) const;
74
76 void updatePoints();
77
79 void updateEditedPoint( const TOOL_EVENT& aEvent );
80
82 int clearEditedPoints( const TOOL_EVENT& aEvent );
83
85 void setEditedPoint( EDIT_POINT* aPoint );
86
88 inline bool isModified( const EDIT_POINT& aPoint ) const
89 {
90 return m_editedPoint == &aPoint;
91 }
92
93 inline int getEditedPointIndex() const
94 {
95 for( unsigned i = 0; i < m_editPoints->PointsSize(); ++i )
96 {
97 if( m_editedPoint == &m_editPoints->Point( i ) )
98 return i;
99 }
100
101 return wxNOT_FOUND;
102 }
103
104 void pinEditedCorner( int minWidth, int minHeight, VECTOR2I& topLeft, VECTOR2I& topRight,
105 VECTOR2I& botLeft, VECTOR2I& botRight, EE_GRID_HELPER* aGrid ) const;
106
107 bool addCornerCondition( const SELECTION& aSelection );
108 bool removeCornerCondition( const SELECTION& aSelection );
109
111 int addCorner( const TOOL_EVENT& aEvent );
112 int removeCorner( const TOOL_EVENT& aEvent );
113 int changeArcEditMode( const TOOL_EVENT& aEvent );
114 int modifiedSelection( const TOOL_EVENT& aEvent );
115
116private:
117 void makePointsAndBehavior( EDA_ITEM* aItem );
118
121
124
126
129
131 std::shared_ptr<EDIT_POINTS> m_editPoints;
132 std::unique_ptr<KIGFX::PREVIEW::ANGLE_ITEM> m_angleItem;
133
135 std::unique_ptr<POINT_EDIT_BEHAVIOR> m_editBehavior;
136};
137
138#endif // SCH_POINT_EDITOR_H
ARC_EDIT_MODE
Settings for arc editing.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:96
Represent a single point that can be used for modifying items.
Definition edit_points.h:44
A helper class interface to manage the edit points for a single item.
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
void updatePoints()
Update which point is being edited.
void setEditedPoint(EDIT_POINT *aPoint)
Return true if aPoint is the currently modified point.
void pinEditedCorner(int minWidth, int minHeight, VECTOR2I &topLeft, VECTOR2I &topRight, VECTOR2I &botLeft, VECTOR2I &botRight, EE_GRID_HELPER *aGrid) const
bool IsDragging() const
Return true while a point is actively being dragged (the model is mid-mutation between grab and relea...
bool Init() override
Init() is called once upon a registration of the tool.
ARC_EDIT_MODE m_arcEditMode
Re-entrancy guards.
void updateParentItem(bool aSnapToGrid, SCH_COMMIT &aCommit) const
< Update item's points with edit points.
bool HasPoint()
Indicate the cursor is over an edit point.
bool isModified(const EDIT_POINT &aPoint) const
void updateEditedPoint(const TOOL_EVENT &aEvent)
Clear references to the points.
bool addCornerCondition(const SELECTION &aSelection)
std::unique_ptr< POINT_EDIT_BEHAVIOR > m_editBehavior
EDIT_POINT * m_editedPoint
True while a point drag is in progress (between grab and release).
int modifiedSelection(const TOOL_EVENT &aEvent)
void dragPinsOnEdge(const std::vector< SEG > &aOldEdges, const std::vector< VECTOR2I > &aMoveVecs, int aUnit, SCH_COMMIT &aCommit) const
Update edit points with item's points.
int Main(const TOOL_EVENT &aEvent)
int getEditedPointIndex() const
std::shared_ptr< EDIT_POINTS > m_editPoints
int clearEditedPoints(const TOOL_EVENT &aEvent)
Set the current point being edited. NULL means none.
bool removeCornerCondition(const SELECTION &aSelection)
bool m_inPointEditor
Currently available edit points.
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
void makePointsAndBehavior(EDA_ITEM *aItem)
Currently edited point, NULL if there is none.
std::unique_ptr< KIGFX::PREVIEW::ANGLE_ITEM > m_angleItem
Current item-specific edit behavior.
int changeArcEditMode(const TOOL_EVENT &aEvent)
int removeCorner(const TOOL_EVENT &aEvent)
int addCorner(const TOOL_EVENT &aEvent)
TOOL_ACTION handlers.
SCH_TOOL_BASE(const std::string &aName)
Generic, UI-independent tool event.
Definition tool_event.h:167
void Reset() override
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:29
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683