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 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#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#include <wx/wupdlock.h>
42
43
45{
47 return true;
48}
49
50
56
57
59{
60 wxCommandEvent evt( wxEVT_NULL, wxID_NEW );
61 m_frame->Files_io( evt );
62 return 0;
63}
64
65
67{
68 wxCommandEvent evt( wxEVT_NULL, wxID_OPEN );
69 m_frame->Files_io( evt );
70 return 0;
71}
72
73
75{
76 wxCommandEvent evt( wxEVT_NULL, wxID_SAVE );
77 m_frame->Files_io( evt );
78 return 0;
79}
80
81
83{
84 wxCommandEvent evt( wxEVT_NULL, wxID_SAVEAS );
85 m_frame->Files_io( evt );
86 return 0;
87}
88
89
91{
92 m_frame->SaveCopyInUndoList();
93
94 DIALOG_PAGES_SETTINGS dlg( m_frame, nullptr, drawSheetIUScale.IU_PER_MILS,
97 dlg.SetWksFileName( m_frame->GetCurrentFileName() );
98 dlg.EnableWksFileNamePicker( false );
99
100 if( dlg.ShowModal() != wxID_OK )
101 {
102 // Nothing to roll back but we have to at least pop the stack
103 m_frame->RollbackFromUndo();
104 }
105 else
106 {
107 m_frame->OnModify();
108 m_frame->HardRedraw();
109 }
110 return 0;
111}
112
113
115{
116 m_frame->ToPrinter( false );
117 return 0;
118}
119
120
122{
123 wxMessageBox( wxT( "Not yet available" ) );
124 return 0;
125}
126
127
129{
130 m_frame->ShowDesignInspector();
131 return 0;
132}
133
134
136{
137 if( aEvent.IsAction( &PL_ACTIONS::layoutEditMode ) )
139 else
141
142 m_frame->HardRedraw();
143 return 0;
144}
145
146
148{
149 PL_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PL_SELECTION_TOOL>();
150 PL_SELECTION& selection = selTool->GetSelection();
151
152 // The Properties frame will be updated. Avoid flicker during update:
153 wxWindowUpdateLocker updateLock( m_frame->GetPropertiesFrame() );
154
155 if( selection.GetSize() == 1 )
156 {
157 EDA_ITEM* item = (EDA_ITEM*) selection.Front();
158 std::vector<MSG_PANEL_ITEM> msgItems;
159
160 if( std::optional<wxString> uuid = GetMsgPanelDisplayUuid( item->m_Uuid ) )
161 msgItems.emplace_back( _( "UUID" ), *uuid );
162
163 item->GetMsgPanelInfo( m_frame, msgItems );
164 m_frame->SetMsgPanel( msgItems );
165
166 DS_DATA_ITEM* dataItem = static_cast<DS_DRAW_ITEM_BASE*>( item )->GetPeer();
167 m_frame->GetPropertiesFrame()->CopyPrmsFromItemToPanel( dataItem );
168 }
169 else
170 {
171 m_frame->UpdateMsgPanelInfo();
172 m_frame->GetPropertiesFrame()->CopyPrmsFromItemToPanel( nullptr );
173 }
174
175 m_frame->GetPropertiesFrame()->CopyPrmsFromGeneralToPanel();
176
177 return 0;
178}
179
180
constexpr EDA_IU_SCALE drawSheetIUScale
Definition base_units.h:113
static TOOL_ACTION saveAs
Definition actions.h:59
static TOOL_ACTION plot
Definition actions.h:65
static TOOL_ACTION open
Definition actions.h:57
static TOOL_ACTION save
Definition actions.h:58
static TOOL_ACTION print
Definition actions.h:64
static TOOL_ACTION doNew
Definition actions.h:54
void EnableWksFileNamePicker(bool aEnable)
void SetWksFileName(const wxString &aFilename)
int ShowModal() override
Drawing sheet structure type definitions.
static DS_DATA_MODEL & GetTheInstance()
Return the instance of DS_DATA_MODEL used in the application.
Base class to handle basic graphic items.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
const KIID m_Uuid
Definition eda_item.h:516
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:220
static const TOOL_EVENT ClearedEvent
Definition actions.h:348
static const TOOL_EVENT SelectedEvent
Definition actions.h:346
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition actions.h:353
static const TOOL_EVENT UnselectedEvent
Definition actions.h:347
static TOOL_ACTION showInspector
Definition pl_actions.h:54
static TOOL_ACTION previewSettings
Definition pl_actions.h:55
static TOOL_ACTION layoutNormalMode
Definition pl_actions.h:49
static TOOL_ACTION layoutEditMode
Definition pl_actions.h:50
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.
PL_SELECTION & GetSelection()
Return the set of currently selected items.
T * getEditFrame() const
Return the application window object, casted to requested user type.
Definition tool_base.h:186
TOOL_MANAGER * m_toolMgr
Definition tool_base.h:220
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:171
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
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 _(s)
std::optional< wxString > GetMsgPanelDisplayUuid(const KIID &aKiid)
Get a formatted UUID string for display in the message panel, according to the current advanced confi...
Definition msgpanel.cpp:245
#define MAX_PAGE_SIZE_EESCHEMA_MILS
Definition page_info.h:36
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695