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
58 void setTransitions() override;
59
60private:
62 void updateParentItem( bool aSnapToGrid, SCH_COMMIT& aCommit ) const;
63
65 void dragPinsOnEdge( const std::vector<SEG>& aOldEdges, const std::vector<VECTOR2I>& aMoveVecs,
66 int aUnit, SCH_COMMIT& aCommit ) const;
67
69 void updatePoints();
70
72 void updateEditedPoint( const TOOL_EVENT& aEvent );
73
75 int clearEditedPoints( const TOOL_EVENT& aEvent );
76
78 void setEditedPoint( EDIT_POINT* aPoint );
79
81 inline bool isModified( const EDIT_POINT& aPoint ) const
82 {
83 return m_editedPoint == &aPoint;
84 }
85
86 inline int getEditedPointIndex() const
87 {
88 for( unsigned i = 0; i < m_editPoints->PointsSize(); ++i )
89 {
90 if( m_editedPoint == &m_editPoints->Point( i ) )
91 return i;
92 }
93
94 return wxNOT_FOUND;
95 }
96
97 void pinEditedCorner( int minWidth, int minHeight, VECTOR2I& topLeft, VECTOR2I& topRight,
98 VECTOR2I& botLeft, VECTOR2I& botRight, EE_GRID_HELPER* aGrid ) const;
99
100 bool addCornerCondition( const SELECTION& aSelection );
101 bool removeCornerCondition( const SELECTION& aSelection );
102
104 int addCorner( const TOOL_EVENT& aEvent );
105 int removeCorner( const TOOL_EVENT& aEvent );
106 int changeArcEditMode( const TOOL_EVENT& aEvent );
107 int modifiedSelection( const TOOL_EVENT& aEvent );
108
109private:
110 void makePointsAndBehavior( EDA_ITEM* aItem );
111
114
116
119
121 std::shared_ptr<EDIT_POINTS> m_editPoints;
122 std::unique_ptr<KIGFX::PREVIEW::ANGLE_ITEM> m_angleItem;
123
125 std::unique_ptr<POINT_EDIT_BEHAVIOR> m_editBehavior;
126};
127
128#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 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
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