KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pl_editor_control.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 (C) 2019 CERN
5 * Copyright (C) 2019-2020 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#include <kiway.h>
26#include <view/view.h>
27#include <tool/tool_manager.h>
28#include <confirm.h>
29#include <bitmaps.h>
33
34#include "pl_editor_frame.h"
35#include "pl_editor_id.h"
36#include "properties_frame.h"
37#include "tools/pl_actions.h"
40
41
43{
44 m_frame = getEditFrame<PL_EDITOR_FRAME>();
45 return true;
46}
47
48
50{
51 if( aReason == MODEL_RELOAD )
52 m_frame = getEditFrame<PL_EDITOR_FRAME>();
53}
54
55
57{
58 wxCommandEvent evt( wxEVT_NULL, wxID_NEW );
59 m_frame->Files_io( evt );
60 return 0;
61}
62
63
65{
66 wxCommandEvent evt( wxEVT_NULL, wxID_OPEN );
67 m_frame->Files_io( evt );
68 return 0;
69}
70
71
73{
74 wxCommandEvent evt( wxEVT_NULL, wxID_SAVE );
75 m_frame->Files_io( evt );
76 return 0;
77}
78
79
81{
82 wxCommandEvent evt( wxEVT_NULL, wxID_SAVEAS );
83 m_frame->Files_io( evt );
84 return 0;
85}
86
87
89{
91
96 dlg.EnableWksFileNamePicker( false );
97
98 if( dlg.ShowModal() != wxID_OK )
99 {
100 // Nothing to roll back but we have to at least pop the stack
102 }
103 else
104 {
105 m_frame->OnModify();
107 }
108 return 0;
109}
110
111
113{
114 m_frame->ToPrinter( false );
115 return 0;
116}
117
118
120{
121 wxMessageBox( wxT( "Not yet available" ) );
122 return 0;
123}
124
125
127{
129 return 0;
130}
131
132
134{
135 if( aEvent.IsAction( &PL_ACTIONS::layoutEditMode ) )
137 else
139
141 return 0;
142}
143
144
146{
148 PL_SELECTION& selection = selTool->GetSelection();
149
150 // The Properties frame will be updated. Avoid flicker during update:
151 m_frame->GetPropertiesFrame()->Freeze();
152
153 if( selection.GetSize() == 1 )
154 {
155 EDA_ITEM* item = (EDA_ITEM*) selection.Front();
156
157 std::vector<MSG_PANEL_ITEM> msgItems;
158 item->GetMsgPanelInfo( m_frame, msgItems );
159 m_frame->SetMsgPanel( msgItems );
160
161 DS_DATA_ITEM* dataItem = static_cast<DS_DRAW_ITEM_BASE*>( item )->GetPeer();
163 }
164 else
165 {
168 }
169
171
172 // The Properties frame is updated. Reenable it:
173 m_frame->GetPropertiesFrame()->Thaw();
174
175 return 0;
176}
177
178
180{
187
192
197}
constexpr EDA_IU_SCALE drawSheetIUScale
Definition: base_units.h:109
static TOOL_ACTION saveAs
Definition: actions.h:52
static TOOL_ACTION plot
Definition: actions.h:58
static TOOL_ACTION open
Definition: actions.h:50
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION doNew
Definition: actions.h:47
void EnableWksFileNamePicker(bool aEnable)
void SetWksFileName(const wxString &aFilename)
Drawing sheet structure type definitions.
Definition: ds_data_item.h:96
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
Base class to handle basic graphic items.
Definition: ds_draw_item.h:59
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:88
virtual void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: eda_item.h:202
static const TOOL_EVENT ClearedEvent
Definition: actions.h:262
static const TOOL_EVENT SelectedEvent
Definition: actions.h:260
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:267
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:261
static TOOL_ACTION showInspector
Definition: pl_actions.h:72
static TOOL_ACTION previewSettings
Definition: pl_actions.h:73
static TOOL_ACTION layoutNormalMode
Definition: pl_actions.h:67
static TOOL_ACTION layoutEditMode
Definition: pl_actions.h:68
int PageSetup(const TOOL_EVENT &aEvent)
int SaveAs(const TOOL_EVENT &aEvent)
int TitleBlockDisplayMode(const TOOL_EVENT &aEvent)
bool Init() override
Init() is called once upon a registration of the tool.
int New(const TOOL_EVENT &aEvent)
int UpdateMessagePanel(const TOOL_EVENT &aEvent)
Update the message panel and the Properties frame, after change (selection, move, edit ....
int Print(const TOOL_EVENT &aEvent)
int Save(const TOOL_EVENT &aEvent)
PL_EDITOR_FRAME * m_frame
int ShowInspector(const TOOL_EVENT &aEvent)
int Open(const TOOL_EVENT &aEvent)
int Plot(const TOOL_EVENT &aEvent)
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
void setTransitions() override
< Set up handlers for various events.
void ShowDesignInspector()
Show the dialog displaying the list of DS_DATA_ITEM items in the page layout.
void OnModify() override
Must be called after a change in order to set the "modify" flag.
void Files_io(wxCommandEvent &event)
void ToPrinter(bool doPreview)
Open a dialog frame to print layers.
void UpdateMsgPanelInfo()
Display the size of the sheet to the message panel.
wxString GetCurrentFileName() const override
void RollbackFromUndo()
Apply the last command in Undo List without stacking a Redo.
void SaveCopyInUndoList()
Save a copy of the description (in a S expr string) for Undo/redo commands.
void HardRedraw() override
Refresh the library tree and redraw the window.
PROPERTIES_FRAME * GetPropertiesFrame()
PL_SELECTION & GetSelection()
Return the set of currently selected items.
void CopyPrmsFromItemToPanel(DS_DATA_ITEM *aItem)
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition: tool_base.h:80
Generic, UI-independent tool event.
Definition: tool_event.h:167
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:82
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).
This file is part of the common library.
#define MAX_PAGE_SIZE_EESCHEMA_MILS
Definition: page_info.h:40
const double IU_PER_MILS
Definition: base_units.h:77