KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ee_graphic_tool.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 <optional>
23#include <vector>
24
27#include <tools/sch_tool_base.h>
28#include <sch_base_frame.h>
29#include <sch_shape.h>
30
31class SCH_EDIT_FRAME;
33
34
39class EE_GRAPHIC_TOOL : public SCH_TOOL_BASE<SCH_BASE_FRAME>
40{
41public:
42 enum class MODE
43 {
48 };
49
51
52 bool Init() override;
53
54 int DrawShape( const TOOL_EVENT& aEvent );
55 int DrawArc( const TOOL_EVENT& aEvent );
56 int DrawBezier( const TOOL_EVENT& aEvent );
57 int DrawEllipseArc( const TOOL_EVENT& aEvent );
58 int ImportGraphics( const TOOL_EVENT& aEvent );
59
60private:
61 void setTransitions() override;
62
65
67 void commitItem( SCH_COMMIT& aCommit, std::unique_ptr<SCH_ITEM> aItem, const wxString& aDescription );
68
70 int getDefaultTextSize() const;
71
76 void applySymbolEditorFlags( SCH_ITEM& aItem ) const;
77
83 VECTOR2I snapEventPosition( const TOOL_EVENT& aEvent );
84
95 SHAPE_DRAW_RESULT drawManagedShape( const TOOL_EVENT& aTool, std::unique_ptr<SCH_SHAPE>& aShape,
96 SHAPE_DRAW_BEHAVIOR& aBehavior, const std::vector<VECTOR2D>& aInitialPts,
97 const std::optional<ARC_TANGENT_SEED>& aTangentSeed = std::nullopt,
98 VECTOR2I* aLastClick = nullptr );
99
103
107
113
115
116 // Re-entrancy guards
118};
bool Init() override
Init() is called once upon a registration of the tool.
COLOR4D m_lastTextboxFillColor
void applySymbolEditorFlags(SCH_ITEM &aItem) const
When in the symbol editor, apply unit and body-style restrictions to aItem according to the current d...
int getDefaultTextSize() const
Return the default text size (in IU) for the active editor.
int DrawEllipseArc(const TOOL_EVENT &aEvent)
STROKE_PARAMS m_lastStroke
SHAPE_DRAW_RESULT drawManagedShape(const TOOL_EVENT &aTool, std::unique_ptr< SCH_SHAPE > &aShape, SHAPE_DRAW_BEHAVIOR &aBehavior, const std::vector< VECTOR2D > &aInitialPts, const std::optional< ARC_TANGENT_SEED > &aTangentSeed=std::nullopt, VECTOR2I *aLastClick=nullptr)
Run the interactive drawing event loop for any shape driven by a SHAPE_DRAW_BEHAVIOR (arcs,...
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
GR_TEXT_H_ALIGN_T m_lastTextboxHJustify
GR_TEXT_V_ALIGN_T m_lastTextboxVJustify
int DrawArc(const TOOL_EVENT &aEvent)
void commitItem(SCH_COMMIT &aCommit, std::unique_ptr< SCH_ITEM > aItem, const wxString &aDescription)
Commit a completed item.
EDA_ANGLE m_lastTextboxAngle
VECTOR2I snapEventPosition(const TOOL_EVENT &aEvent)
Snap a tool event's position the way a click is snapped.
int DrawBezier(const TOOL_EVENT &aEvent)
int DrawShape(const TOOL_EVENT &aEvent)
STROKE_PARAMS m_lastTextboxStroke
FILL_T m_lastTextboxFillStyle
int ImportGraphics(const TOOL_EVENT &aEvent)
SCH_LAYER_ID getShapeLayer() const
The layer to use for new shapes in the current editor.
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
Commit for the schematic and symbol editors.
Definition sch_commit.h:54
Schematic editor (Eeschema) main window.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:170
SCH_TOOL_BASE(const std::string &aName)
Abstract interface for interactive shape-drawing behaviours.
Simple container to manage line stroke parameters.
The symbol library editor main window.
Generic, UI-independent tool event.
Definition tool_event.h:167
FILL_T
Definition eda_fill.h:29
SCH_LAYER_ID
Eeschema drawing layers.
Definition layer_ids.h:471
SHAPE_DRAW_RESULT
Outcome of an interactive shape drawing loop, telling the caller how to continue.
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708