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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef SCH_POINT_EDITOR_H
26#define SCH_POINT_EDITOR_H
27
28#include <tools/sch_tool_base.h>
29#include <tool/edit_points.h>
30#include <tool/selection.h>
31
32namespace KIGFX { namespace PREVIEW { class ANGLE_ITEM; } }
33
36class SCH_BASE_FRAME;
37class SCH_COMMIT;
38
42class SCH_POINT_EDITOR : public SCH_TOOL_BASE<SCH_BASE_FRAME>
43{
44public:
46
48 void Reset( RESET_REASON aReason ) override;
49
51 bool Init() override;
52
53 int Main( const TOOL_EVENT& aEvent );
54
59 bool HasPoint() { return m_editedPoint != nullptr; }
60
62 void setTransitions() override;
63
64private:
66 void updateParentItem( bool aSnapToGrid, SCH_COMMIT& aCommit ) const;
67
69 void dragPinsOnEdge( const std::vector<SEG>& aOldEdges, const std::vector<VECTOR2I>& aMoveVecs,
70 int aUnit, SCH_COMMIT& aCommit ) const;
71
73 void updatePoints();
74
76 void updateEditedPoint( const TOOL_EVENT& aEvent );
77
79 int clearEditedPoints( const TOOL_EVENT& aEvent );
80
82 void setEditedPoint( EDIT_POINT* aPoint );
83
85 inline bool isModified( const EDIT_POINT& aPoint ) const
86 {
87 return m_editedPoint == &aPoint;
88 }
89
90 inline int getEditedPointIndex() const
91 {
92 for( unsigned i = 0; i < m_editPoints->PointsSize(); ++i )
93 {
94 if( m_editedPoint == &m_editPoints->Point( i ) )
95 return i;
96 }
97
98 return wxNOT_FOUND;
99 }
100
101 void pinEditedCorner( int minWidth, int minHeight, VECTOR2I& topLeft, VECTOR2I& topRight,
102 VECTOR2I& botLeft, VECTOR2I& botRight, EE_GRID_HELPER* aGrid ) const;
103
104 bool addCornerCondition( const SELECTION& aSelection );
105 bool removeCornerCondition( const SELECTION& aSelection );
106
108 int addCorner( const TOOL_EVENT& aEvent );
109 int removeCorner( const TOOL_EVENT& aEvent );
110 int changeArcEditMode( const TOOL_EVENT& aEvent );
111 int modifiedSelection( const TOOL_EVENT& aEvent );
112
113private:
114 void makePointsAndBehavior( EDA_ITEM* aItem );
115
118
120
123
125 std::shared_ptr<EDIT_POINTS> m_editPoints;
126 std::unique_ptr<KIGFX::PREVIEW::ANGLE_ITEM> m_angleItem;
127
129 std::unique_ptr<POINT_EDIT_BEHAVIOR> m_editBehavior;
130};
131
132#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:48
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:171
void Reset() override
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:33
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695