KiCad PCB EDA Suite
Loading...
Searching...
No Matches
embed_tool.cpp
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 modify it
7
* under the terms of the GNU General Public License as published by the
8
* Free Software Foundation, either version 3 of the License, or (at your
9
* option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License along
17
* with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#include <
dialogs/panel_embedded_files.h
>
21
#include <
eda_draw_frame.h
>
22
#include <
eda_item.h
>
23
#include <
embedded_files.h
>
24
#include <
tool/actions.h
>
25
#include <wx/debug.h>
26
#include <wx/filedlg.h>
27
28
#include <
tool/embed_tool.h
>
29
30
31
EMBED_TOOL::EMBED_TOOL
(
const
std::string& aName ) :
32
TOOL_INTERACTIVE
( aName ),
33
m_files
( nullptr )
34
{
35
}
36
37
38
EMBED_TOOL::EMBED_TOOL
() :
39
TOOL_INTERACTIVE
(
"common.Embed"
),
40
m_files
( nullptr )
41
{
42
}
43
44
45
bool
EMBED_TOOL::Init
()
46
{
47
m_files
=
getModel<EDA_ITEM>
()->GetEmbeddedFiles();
48
49
return
true
;
50
}
51
52
53
void
EMBED_TOOL::Reset
(
RESET_REASON
aReason )
54
{
55
m_files
=
getModel<EDA_ITEM>
()->GetEmbeddedFiles();
56
}
57
58
59
int
EMBED_TOOL::AddFile
(
const
TOOL_EVENT
& aEvent )
60
{
61
wxString
name
= aEvent.
Parameter
<wxString>();
62
m_files
->AddFile(
name
,
false
);
63
64
return
1;
65
}
66
67
68
int
EMBED_TOOL::RemoveFile
(
const
TOOL_EVENT
& aEvent )
69
{
70
wxString
name
= aEvent.
Parameter
<wxString>();
71
m_files
->RemoveFile(
name
);
72
73
return
1;
74
}
75
76
77
std::vector<wxString>
EMBED_TOOL::GetFileList
()
78
{
79
std::vector<wxString> list;
80
81
for
(
auto
& [
name
, file] :
m_files
->EmbeddedFileMap() )
82
list.push_back(
name
);
83
84
return
list;
85
}
86
87
88
void
EMBED_TOOL::setTransitions
()
89
{
90
Go
( &
EMBED_TOOL::AddFile
,
ACTIONS::embeddedFiles
.MakeEvent() );
91
Go
( &
EMBED_TOOL::RemoveFile
,
ACTIONS::removeFile
.MakeEvent() );
92
}
93
name
const char * name
Definition
DXF_plotter.cpp:63
actions.h
ACTIONS::removeFile
static TOOL_ACTION removeFile
Cursor control event types.
Definition
actions.h:300
ACTIONS::embeddedFiles
static TOOL_ACTION embeddedFiles
Definition
actions.h:298
EMBED_TOOL::Init
bool Init() override
Init() is called once upon a registration of the tool.
Definition
embed_tool.cpp:45
EMBED_TOOL::m_files
EMBEDDED_FILES * m_files
Definition
embed_tool.h:54
EMBED_TOOL::AddFile
int AddFile(const TOOL_EVENT &aEvent)
Definition
embed_tool.cpp:59
EMBED_TOOL::GetFileList
std::vector< wxString > GetFileList()
Definition
embed_tool.cpp:77
EMBED_TOOL::EMBED_TOOL
EMBED_TOOL()
Definition
embed_tool.cpp:38
EMBED_TOOL::RemoveFile
int RemoveFile(const TOOL_EVENT &aEvent)
Definition
embed_tool.cpp:68
EMBED_TOOL::Reset
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
Definition
embed_tool.cpp:53
EMBED_TOOL::setTransitions
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
Definition
embed_tool.cpp:88
TOOL_BASE::getModel
T * getModel() const
Return the model object if it matches the requested type.
Definition
tool_base.h:198
TOOL_BASE::RESET_REASON
RESET_REASON
Determine the reason of reset for a tool.
Definition
tool_base.h:78
TOOL_EVENT
Generic, UI-independent tool event.
Definition
tool_event.h:171
TOOL_EVENT::Parameter
T Parameter() const
Return a parameter assigned to the event.
Definition
tool_event.h:473
TOOL_INTERACTIVE::Go
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
Definition
tool_interactive.h:147
TOOL_INTERACTIVE::TOOL_INTERACTIVE
TOOL_INTERACTIVE(TOOL_ID aId, const std::string &aName)
Create a tool with given id & name.
Definition
tool_interactive.cpp:39
eda_draw_frame.h
eda_item.h
embed_tool.h
embedded_files.h
panel_embedded_files.h
src
common
tool
embed_tool.cpp
Generated on Sun Sep 21 2025 01:05:21 for KiCad PCB EDA Suite by
1.13.2