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#include <wx/msgdlg.h>
41
42
44{
45 m_frame = getEditFrame<PL_EDITOR_FRAME>();
46 return true;
47}
48
49
51{
52 if( aReason == MODEL_RELOAD )
53 m_frame = getEditFrame<PL_EDITOR_FRAME>();
54}
55
56
58{
59 wxCommandEvent evt( wxEVT_NULL, wxID_NEW );
60 m_frame->Files_io( evt );
61 return 0;
62}
63
64
66{
67 wxCommandEvent evt( wxEVT_NULL, wxID_OPEN );
68 m_frame->Files_io( evt );
69 return 0;
70}
71
72
74{
75 wxCommandEvent evt( wxEVT_NULL, wxID_SAVE );
76 m_frame->Files_io( evt );
77 return 0;
78}
79
80
82{
83 wxCommandEvent evt( wxEVT_NULL, wxID_SAVEAS );
84 m_frame->Files_io( evt );
85 return 0;
86}
87
88
90{
92
97 dlg.EnableWksFileNamePicker( false );
98
99 if( dlg.ShowModal() != wxID_OK )
100 {
101 // Nothing to roll back but we have to at least pop the stack
103 }
104 else
105 {
106 m_frame->OnModify();
108 }
109 return 0;
110}
111
112
114{
115 m_frame->ToPrinter( false );
116 return 0;
117}
118
119
121{
122 wxMessageBox( wxT( "Not yet available" ) );
123 return 0;
124}
125
126
128{
130 return 0;
131}
132
133
135{
136 if( aEvent.IsAction( &PL_ACTIONS::layoutEditMode ) )
138 else
140
142 return 0;
143}
144
145
147{
149 PL_SELECTION& selection = selTool->GetSelection();
150
151 // The Properties frame will be updated. Avoid flicker during update:
152 m_frame->GetPropertiesFrame()->Freeze();
153
154 if( selection.GetSize() == 1 )
155 {
156 EDA_ITEM* item = (EDA_ITEM*) selection.Front();
157
158 std::vector<MSG_PANEL_ITEM> msgItems;
159 item->GetMsgPanelInfo( m_frame, msgItems );
160 m_frame->SetMsgPanel( msgItems );
161
162 DS_DATA_ITEM* dataItem = static_cast<DS_DRAW_ITEM_BASE*>( item )->GetPeer();
164 }
165 else
166 {
169 }
170
172
173 // The Properties frame is updated. Reenable it:
174 m_frame->GetPropertiesFrame()->Thaw();
175
176 return 0;
177}
178
179
181{
188
193
198}
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)
int ShowModal() override
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:89
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:203
static const TOOL_EVENT ClearedEvent
Definition: actions.h:294
static const TOOL_EVENT SelectedEvent
Definition: actions.h:292
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:299
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:293
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:218
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