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, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <kiway.h>
22#include <view/view.h>
23#include <tool/tool_manager.h>
24#include <confirm.h>
25#include <bitmaps.h>
29
30#include <pl_editor_frame.h>
31#include <pl_editor_id.h>
32#include <properties_frame.h>
33#include <tools/pl_actions.h>
36#include <wx/msgdlg.h>
37#include <wx/wupdlock.h>
38
39
41{
43 return true;
44}
45
46
52
53
55{
56 wxCommandEvent evt( wxEVT_NULL, wxID_NEW );
57 m_frame->Files_io( evt );
58 return 0;
59}
60
61
63{
64 wxCommandEvent evt( wxEVT_NULL, wxID_OPEN );
65 m_frame->Files_io( evt );
66 return 0;
67}
68
69
71{
72 wxCommandEvent evt( wxEVT_NULL, wxID_SAVE );
73 m_frame->Files_io( evt );
74 return 0;
75}
76
77
79{
80 wxCommandEvent evt( wxEVT_NULL, wxID_SAVEAS );
81 m_frame->Files_io( evt );
82 return 0;
83}
84
85
87{
88 m_frame->SaveCopyInUndoList();
89
90 DIALOG_PAGES_SETTINGS dlg( m_frame, nullptr, drawSheetIUScale.IU_PER_MILS,
93 dlg.SetWksFileName( m_frame->GetCurrentFileName() );
94 dlg.EnableWksFileNamePicker( false );
95
96 if( dlg.ShowModal() != wxID_OK )
97 {
98 // Nothing to roll back but we have to at least pop the stack
99 m_frame->RollbackFromUndo();
100 }
101 else
102 {
103 m_frame->OnModify();
104 m_frame->HardRedraw();
105 }
106 return 0;
107}
108
109
111{
112 m_frame->ToPrinter( false );
113 return 0;
114}
115
116
118{
119 wxMessageBox( wxT( "Not yet available" ) );
120 return 0;
121}
122
123
125{
126 m_frame->ShowDesignInspector();
127 return 0;
128}
129
130
132{
133 if( aEvent.IsAction( &PL_ACTIONS::layoutEditMode ) )
135 else
137
138 m_frame->HardRedraw();
139 return 0;
140}
141
142
144{
145 PL_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PL_SELECTION_TOOL>();
146 PL_SELECTION& selection = selTool->GetSelection();
147
148 // The Properties frame will be updated. Avoid flicker during update:
149 wxWindowUpdateLocker updateLock( m_frame->GetPropertiesFrame() );
150
151 if( selection.GetSize() == 1 )
152 {
153 EDA_ITEM* item = (EDA_ITEM*) selection.Front();
154 std::vector<MSG_PANEL_ITEM> msgItems;
155
156 if( std::optional<wxString> uuid = GetMsgPanelDisplayUuid( item->m_Uuid ) )
157 msgItems.emplace_back( _( "UUID" ), *uuid );
158
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();
163 m_frame->GetPropertiesFrame()->CopyPrmsFromItemToPanel( dataItem );
164 }
165 else
166 {
167 m_frame->UpdateMsgPanelInfo();
168 m_frame->GetPropertiesFrame()->CopyPrmsFromItemToPanel( nullptr );
169 }
170
171 m_frame->GetPropertiesFrame()->CopyPrmsFromGeneralToPanel();
172
173 return 0;
174}
175
176
178{
179 m_frame->SetGridOrigin( VECTOR2I( 0, 0 ) );
180 m_frame->GetCanvas()->ForceRefresh();
181 return 0;
182}
183
184
constexpr EDA_IU_SCALE drawSheetIUScale
Definition base_units.h:122
static TOOL_ACTION saveAs
Definition actions.h:55
static TOOL_ACTION gridResetOrigin
Definition actions.h:192
static TOOL_ACTION plot
Definition actions.h:61
static TOOL_ACTION open
Definition actions.h:53
static TOOL_ACTION save
Definition actions.h:54
static TOOL_ACTION print
Definition actions.h:60
static TOOL_ACTION doNew
Definition actions.h:50
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:96
const KIID m_Uuid
Definition eda_item.h:531
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:230
static const TOOL_EVENT ClearedEvent
Definition actions.h:343
static const TOOL_EVENT SelectedEvent
Definition actions.h:341
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition actions.h:348
static const TOOL_EVENT UnselectedEvent
Definition actions.h:342
static TOOL_ACTION showInspector
Definition pl_actions.h:50
static TOOL_ACTION previewSettings
Definition pl_actions.h:51
static TOOL_ACTION layoutNormalMode
Definition pl_actions.h:45
static TOOL_ACTION layoutEditMode
Definition pl_actions.h:46
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 GridResetOrigin(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:182
TOOL_MANAGER * m_toolMgr
Definition tool_base.h:220
RESET_REASON
Determine the reason of reset for a tool.
Definition tool_base.h:74
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition tool_base.h:76
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.
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:216
#define MAX_PAGE_SIZE_EESCHEMA_MILS
Definition page_info.h:32
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683