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
30class EE_GRID_HELPER;
31enum class ARC_EDIT_MODE;
34class SCH_BASE_FRAME;
35class SCH_COMMIT;
36
40class SCH_POINT_EDITOR : public SCH_TOOL_BASE<SCH_BASE_FRAME>
41{
42public:
44
46 void Reset( RESET_REASON aReason ) override;
47
49 bool Init() override;
50
51 int Main( const TOOL_EVENT& aEvent );
52
57 bool HasPoint() { return m_editedPoint != nullptr; }
58
64 bool IsDragging() const { return m_inDrag; }
65
67 void setTransitions() override;
68
69private:
71 void updateParentItem( bool aSnapToGrid, SCH_COMMIT& aCommit ) const;
72
74 void dragPinsOnEdge( const std::vector<SEG>& aOldEdges, const std::vector<VECTOR2I>& aMoveVecs,
75 int aUnit, SCH_COMMIT& aCommit ) const;
76
78 void updatePoints();
79
81 void updateEditedPoint( const TOOL_EVENT& aEvent );
82
84 int clearEditedPoints( const TOOL_EVENT& aEvent );
85
87 void setEditedPoint( EDIT_POINT* aPoint );
88
90 inline bool isModified( const EDIT_POINT& aPoint ) const
91 {
92 return m_editedPoint == &aPoint;
93 }
94
95 inline int getEditedPointIndex() const
96 {
97 for( unsigned i = 0; i < m_editPoints->PointsSize(); ++i )
98 {
99 if( m_editedPoint == &m_editPoints->Point( i ) )
100 return i;
101 }
102
103 return wxNOT_FOUND;
104 }
105
106 void pinEditedCorner( int minWidth, int minHeight, VECTOR2I& topLeft, VECTOR2I& topRight,
107 VECTOR2I& botLeft, VECTOR2I& botRight, EE_GRID_HELPER* aGrid ) const;
108
109 bool addCornerCondition( const SELECTION& aSelection );
110 bool removeCornerCondition( const SELECTION& aSelection );
111
113 int addCorner( const TOOL_EVENT& aEvent );
114 int removeCorner( const TOOL_EVENT& aEvent );
115 int changeArcEditMode( const TOOL_EVENT& aEvent );
116 int modifiedSelection( const TOOL_EVENT& aEvent );
117
118private:
119 void makePointsAndBehavior( EDA_ITEM* aItem );
120
123
126
128
131
133 std::shared_ptr<EDIT_POINTS> m_editPoints;
134 std::unique_ptr<KIGFX::PREVIEW::ANGLE_ITEM> m_angleItem;
135
137 std::unique_ptr<POINT_EDIT_BEHAVIOR> m_editBehavior;
138};
139
140#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:98
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,...
Commit for the schematic and symbol editors.
Definition sch_commit.h:54
void updatePoints()
Update edit points with item's points.
void setEditedPoint(EDIT_POINT *aPoint)
Set the current point being edited. NULL means none.
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
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
Return true if aPoint is the currently modified point.
void updateEditedPoint(const TOOL_EVENT &aEvent)
Update which point is being edited.
bool addCornerCondition(const SELECTION &aSelection)
std::unique_ptr< POINT_EDIT_BEHAVIOR > m_editBehavior
Current item-specific edit behavior.
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
int modifiedSelection(const TOOL_EVENT &aEvent)
void dragPinsOnEdge(const std::vector< SEG > &aOldEdges, const std::vector< VECTOR2I > &aMoveVecs, int aUnit, SCH_COMMIT &aCommit) const
When dragging a graphics edge, update pins too.
int Main(const TOOL_EVENT &aEvent)
int getEditedPointIndex() const
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
int clearEditedPoints(const TOOL_EVENT &aEvent)
Clear references to the points.
bool removeCornerCondition(const SELECTION &aSelection)
bool m_inPointEditor
Re-entrancy guards.
void setTransitions() override
Set up handlers for various events.
void makePointsAndBehavior(EDA_ITEM *aItem)
bool m_inDrag
True while a point drag is in progress (between grab and release).
std::unique_ptr< KIGFX::PREVIEW::ANGLE_ITEM > m_angleItem
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:30
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708