KiCad PCB EDA Suite
tool_sch.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) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2008-2017 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
30 #include <fctsys.h>
31 #include <class_drawpanel.h>
32 #include <sch_edit_frame.h>
33 #include <kiface_i.h>
34 #include <bitmaps.h>
35 
36 #include <general.h>
37 #include <hotkeys.h>
38 #include <eeschema_id.h>
39 
40 #include <help_common_strings.h>
41 
42 
43 /* Create the main Horizontal Toolbar for the schematic editor
44  */
46 {
47  if( m_mainToolBar )
48  m_mainToolBar->Clear();
49  else
50  m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
51  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
52 
53  wxString msg;
54 
55  // Set up toolbar
56  if( Kiface().IsSingle() ) // not when under a project mgr
57  {
58  // These 2 menus have meaning only outside a project, i.e. not under a project manager:
59  m_mainToolBar->AddTool( ID_NEW_PROJECT, wxEmptyString,
60  KiScaledBitmap( new_document_xpm, this ),
61  _( "New schematic" ) );
62 
63  m_mainToolBar->AddTool( ID_LOAD_PROJECT, wxEmptyString,
64  KiScaledBitmap( open_document_xpm, this ),
65  _( "Open schematic" ) );
66  }
67 
68  m_mainToolBar->AddTool( ID_SAVE_PROJECT, wxEmptyString,
69  KiScaledBitmap( save_xpm, this ),
70  _( "Save (all sheets)" ) );
71 
73 
74  m_mainToolBar->AddTool( ID_SHEET_SET, wxEmptyString, KiScaledBitmap( sheetset_xpm, this ),
75  _( "Edit Page settings" ) );
76 
78 
79  m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString, KiScaledBitmap( print_button_xpm, this ),
80  _( "Print schematic" ) );
81 
82  m_mainToolBar->AddTool( ID_GEN_PLOT_SCHEMATIC, wxEmptyString, KiScaledBitmap( plot_xpm, this ),
83  _( "Plot schematic" ) );
84 
86 
87  m_mainToolBar->AddTool( wxID_PASTE, wxEmptyString, KiScaledBitmap( paste_xpm, this ),
88  _( "Paste" ) );
89 
90 
92 
94  m_mainToolBar->AddTool( wxID_UNDO, wxEmptyString, KiScaledBitmap( undo_xpm, this ), msg );
95 
97  m_mainToolBar->AddTool( wxID_REDO, wxEmptyString, KiScaledBitmap( redo_xpm, this ), msg );
98 
99 
101 
103  m_mainToolBar->AddTool( ID_FIND_ITEMS, wxEmptyString, KiScaledBitmap( find_xpm, this ), msg );
104 
105  m_mainToolBar->AddTool( wxID_REPLACE, wxEmptyString, KiScaledBitmap( find_replace_xpm, this ),
106  wxNullBitmap, wxITEM_NORMAL, _( "Find and replace text" ),
107  HELP_REPLACE, nullptr );
108 
109 
111 
113  m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString,
114  KiScaledBitmap( zoom_redraw_xpm, this ), msg );
115 
117  m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiScaledBitmap( zoom_in_xpm, this ), msg );
118 
120  m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiScaledBitmap( zoom_out_xpm, this ), msg );
121 
123  m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString,
124  KiScaledBitmap( zoom_fit_in_page_xpm, this ), msg );
125 
126  m_mainToolBar->AddTool( ID_ZOOM_SELECTION, wxEmptyString, KiScaledBitmap( zoom_area_xpm, this ),
127  _( "Zoom to selection" ), wxITEM_CHECK );
128 
129 
131 
132  m_mainToolBar->AddTool( ID_HIERARCHY, wxEmptyString, KiScaledBitmap( hierarchy_nav_xpm, this ),
133  _( "Navigate schematic hierarchy" ) );
134 
135 
136  m_mainToolBar->AddTool( ID_POPUP_SCH_LEAVE_SHEET, wxEmptyString,
137  KiScaledBitmap( leave_sheet_xpm, this ), _( "Leave sheet" ) );
138 
140 
141  m_mainToolBar->AddTool( ID_RUN_LIBRARY, wxEmptyString, KiScaledBitmap( libedit_xpm, this ),
143 
144  m_mainToolBar->AddTool( ID_TO_LIBVIEW, wxEmptyString,
145  KiScaledBitmap( library_browse_xpm, this ), HELP_RUN_LIB_VIEWER );
146 
147  // modedit is with libedit in a "library section" because the user must have footprints before
148  // they can be assigned.
149  m_mainToolBar->AddTool( ID_RUN_PCB_MODULE_EDITOR, wxEmptyString,
150  KiScaledBitmap( module_editor_xpm, this ),
151  _( "Footprint Editor - Create/edit footprints" ) );
152 
154 
155  m_mainToolBar->AddTool( ID_GET_ANNOTATE, wxEmptyString, KiScaledBitmap( annotate_xpm, this ),
156  HELP_ANNOTATE );
157 
158  m_mainToolBar->AddTool( ID_GET_ERC, wxEmptyString, KiScaledBitmap( erc_xpm, this ),
159  _( "Perform electrical rules check" ) );
160 
161  m_mainToolBar->AddTool( ID_RUN_CVPCB, wxEmptyString, KiScaledBitmap( cvpcb_xpm, this ),
162  _( "Run CvPcb to associate footprints to symbols" ) );
163 
164  m_mainToolBar->AddTool( ID_GET_NETLIST, wxEmptyString, KiScaledBitmap( netlist_xpm, this ),
165  _( "Generate netlist" ) );
166 
167  m_mainToolBar->AddTool( ID_OPEN_CMP_TABLE, wxEmptyString,
168  KiScaledBitmap( spreadsheet_xpm, this ), _( "Edit symbol fields" ) );
169 
170 
171  m_mainToolBar->AddTool( ID_GET_TOOLS, wxEmptyString, KiScaledBitmap( bom_xpm, this ),
173 
175 
176  m_mainToolBar->AddTool( ID_RUN_PCB, wxEmptyString, KiScaledBitmap( pcbnew_xpm, this ),
177  _( "Run Pcbnew to layout printed circuit board" ) );
178 
179  m_mainToolBar->AddTool( ID_BACKANNO_ITEMS, wxEmptyString,
180  KiScaledBitmap( import_footprint_names_xpm, this ),
182 
183  // after adding the tools to the toolbar, must call Realize() to reflect the changes
184  m_mainToolBar->Realize();
185 }
186 
187 
188 /* Create Vertical Right Toolbar
189  */
191 {
192  if( m_drawToolBar )
193  m_drawToolBar->Clear();
194  else
195  m_drawToolBar = new wxAuiToolBar( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
196  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
197 
198  // Set up toolbar
199  m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiScaledBitmap( cursor_xpm, this ),
200  wxEmptyString, wxITEM_CHECK );
201 
202  m_drawToolBar->AddTool( ID_HIGHLIGHT, wxEmptyString,
203  KiScaledBitmap( net_highlight_schematic_xpm, this ),
204  _( "Highlight net" ), wxITEM_CHECK );
205 
206  m_drawToolBar->AddTool( ID_SCH_PLACE_COMPONENT, wxEmptyString,
207  KiScaledBitmap( add_component_xpm, this ), HELP_PLACE_COMPONENTS,
208  wxITEM_CHECK );
209 
210  m_drawToolBar->AddTool( ID_PLACE_POWER_BUTT, wxEmptyString,
211  KiScaledBitmap( add_power_xpm, this ),
212  HELP_PLACE_POWERPORT, wxITEM_CHECK );
213 
214  m_drawToolBar->AddTool( ID_WIRE_BUTT, wxEmptyString, KiScaledBitmap( add_line_xpm, this ),
215  HELP_PLACE_WIRE, wxITEM_CHECK );
216 
217  m_drawToolBar->AddTool( ID_BUS_BUTT, wxEmptyString, KiScaledBitmap( add_bus_xpm, this ),
218  HELP_PLACE_BUS, wxITEM_CHECK );
219 
220  m_drawToolBar->AddTool( ID_WIRETOBUS_ENTRY_BUTT, wxEmptyString,
221  KiScaledBitmap( add_line2bus_xpm, this ),
222  HELP_PLACE_WIRE2BUS_ENTRY, wxITEM_CHECK );
223 
224  m_drawToolBar->AddTool( ID_BUSTOBUS_ENTRY_BUTT, wxEmptyString,
225  KiScaledBitmap( add_bus2bus_xpm, this ),
226  HELP_PLACE_BUS2BUS_ENTRY, wxITEM_CHECK );
227 
228  m_drawToolBar->AddTool( ID_NOCONN_BUTT, wxEmptyString, KiScaledBitmap( noconn_xpm, this ),
229  HELP_PLACE_NC_FLAG, wxITEM_CHECK );
230 
231  m_drawToolBar->AddTool( ID_JUNCTION_BUTT, wxEmptyString,
232  KiScaledBitmap( add_junction_xpm, this ),
233  HELP_PLACE_JUNCTION, wxITEM_CHECK );
234 
235  m_drawToolBar->AddTool( ID_LABEL_BUTT, wxEmptyString,
236  KiScaledBitmap( add_line_label_xpm, this ),
237  HELP_PLACE_NETLABEL, wxITEM_CHECK );
238 
239  m_drawToolBar->AddTool( ID_GLABEL_BUTT, wxEmptyString, KiScaledBitmap( add_glabel_xpm, this ),
240  HELP_PLACE_GLOBALLABEL, wxITEM_CHECK );
241 
242  m_drawToolBar->AddTool( ID_HIERLABEL_BUTT, wxEmptyString,
243  KiScaledBitmap( add_hierarchical_label_xpm, this ),
244  HELP_PLACE_HIER_LABEL, wxITEM_CHECK );
245 
246  m_drawToolBar->AddTool( ID_SHEET_SYMBOL_BUTT, wxEmptyString,
247  KiScaledBitmap( add_hierarchical_subsheet_xpm, this ),
248  HELP_PLACE_SHEET, wxITEM_CHECK );
249 
250  m_drawToolBar->AddTool( ID_IMPORT_HLABEL_BUTT, wxEmptyString,
251  KiScaledBitmap( import_hierarchical_label_xpm, this ),
252  HELP_IMPORT_SHEETPIN, wxITEM_CHECK );
253 
254  m_drawToolBar->AddTool( ID_SHEET_PIN_BUTT, wxEmptyString,
255  KiScaledBitmap( add_hierar_pin_xpm, this ),
256  HELP_PLACE_SHEETPIN, wxITEM_CHECK );
257 
258  m_drawToolBar->AddTool( ID_LINE_COMMENT_BUTT, wxEmptyString,
259  KiScaledBitmap( add_dashed_line_xpm, this ),
260  HELP_PLACE_GRAPHICLINES, wxITEM_CHECK );
261 
262  m_drawToolBar->AddTool( ID_TEXT_COMMENT_BUTT, wxEmptyString, KiScaledBitmap( text_xpm, this ),
263  HELP_PLACE_GRAPHICTEXTS, wxITEM_CHECK );
264 
265  m_drawToolBar->AddTool( ID_ADD_IMAGE_BUTT, wxEmptyString, KiScaledBitmap( image_xpm, this ),
266  _("Add bitmap image"), wxITEM_CHECK );
267 
268  m_drawToolBar->AddTool( ID_SCHEMATIC_DELETE_ITEM_BUTT, wxEmptyString,
269  KiScaledBitmap( delete_xpm, this ),
270  HELP_DELETE_ITEMS, wxITEM_CHECK );
271 
272  m_drawToolBar->Realize();
273 }
274 
275 
276 /* Create Vertical Left Toolbar (Option Toolbar)
277  */
279 {
280  if( m_optionsToolBar )
281  m_optionsToolBar->Clear();
282  else
283  m_optionsToolBar = new wxAuiToolBar( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
284  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
285 
286  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString,
287  KiScaledBitmap( grid_xpm, this ),
288  _( "Turn grid off" ), wxITEM_CHECK );
289 
290  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
291  KiScaledBitmap( unit_inch_xpm, this ),
292  _( "Set unit to inch" ), wxITEM_CHECK );
293 
294  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
295  KiScaledBitmap( unit_mm_xpm, this ),
296  _( "Set unit to mm" ), wxITEM_CHECK );
297 
298 #ifndef __APPLE__
299  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
300  KiScaledBitmap( cursor_shape_xpm, this ),
301  _( "Change cursor shape" ), wxITEM_CHECK );
302 #else
303  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
304  KiScaledBitmap( cursor_shape_xpm, this ),
305  _( "Change cursor shape (not supported in Legacy Toolset)" ),
306  wxITEM_CHECK );
307 #endif
308 
309  //KiScaledSeparator( m_optionsToolBar, this );
310  m_optionsToolBar->AddTool( ID_TB_OPTIONS_HIDDEN_PINS, wxEmptyString,
311  KiScaledBitmap( hidden_pin_xpm, this ),
312  _( "Show hidden pins" ), wxITEM_CHECK );
313 
314  //KiScaledSeparator( m_optionsToolBar, this );
315  m_optionsToolBar->AddTool( ID_TB_OPTIONS_BUS_WIRES_ORIENT, wxEmptyString,
316  KiScaledBitmap( lines90_xpm, this ),
317  _( "HV orientation for wires and bus" ),
318  wxITEM_CHECK );
319 
320  m_optionsToolBar->Realize();
321 }
322 
323 
324 void SCH_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
325 {
326  int id = event.GetId();
327 
328  switch( id )
329  {
332 
333  if( m_canvas )
334  m_canvas->Refresh();
335  break;
336 
338  SetForceHVLines( m_optionsToolBar->GetToolToggled( id ) );
339  break;
340 
341  default:
342  wxFAIL_MSG( wxT( "Unexpected select option tool bar ID." ) );
343  break;
344  }
345 }
#define HELP_PLACE_POWERPORT
void ReCreateOptToolbar()
Definition: tool_sch.cpp:278
#define HELP_PLACE_COMPONENTS
void OnSelectOptionToolbar(wxCommandEvent &event)
Definition: tool_sch.cpp:324
#define HELP_PLACE_SHEETPIN
#define HELP_PLACE_NETLABEL
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:339
#define HELP_PLACE_GRAPHICTEXTS
void SetForceHVLines(bool aForceHVdirection)
#define HELP_ZOOM_FIT
Definition: id.h:241
#define HELP_PLACE_WIRE2BUS_ENTRY
#define HELP_PLACE_SHEET
#define HELP_PLACE_JUNCTION
Definition: id.h:66
wxBitmap KiScaledBitmap(BITMAP_DEF aBitmap, EDA_BASE_FRAME *aWindow)
Function KiScaledBitmap Constructs a wxBitmap from a memory record, scaling it if device DPI demands ...
Definition: bitmap.cpp:114
#define HELP_PLACE_GLOBALLABEL
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
#define HELP_ZOOM_OUT
EDA_DRAW_FRAME::OnSelectGrid ID_TB_OPTIONS_SELECT_UNIT_INCH
Definition: draw_frame.cpp:122
#define HELP_PLACE_BUS2BUS_ENTRY
#define HELP_ZOOM_REDRAW
#define HELP_PLACE_GRAPHICLINES
void ReCreateHToolbar() override
Definition: tool_sch.cpp:45
wxAuiToolBar * m_optionsToolBar
The options tool bar typcially located on the left edge of the main window.
Definition: draw_frame.h:129
strings common to toolbars and menubar
#define HELP_REPLACE
#define HELP_RUN_LIB_VIEWER
wxAuiToolBar * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:126
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
#define HELP_IMPORT_FOOTPRINTS
bool m_showAllPins
Flag to indicate show hidden pins.
#define HELP_PLACE_NC_FLAG
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
#define HELP_REDO
#define HELP_PLACE_BUS
wxString AddHotkeyName(const wxString &aText, EDA_HOTKEY **aList, int aCommandId, HOTKEY_ACTION_TYPE aShortCutType)
Function AddHotkeyName Add the key name from the Command id value ( m_Idcommand member value) ...
#define HELP_ZOOM_IN
#define HELP_RUN_LIB_EDITOR
#define HELP_IMPORT_SHEETPIN
#define HELP_UNDO
These strings are used in menus and tools, that do the same command But they are internationalized, and therefore must be created at run time, on the fly.
void KiScaledSeparator(wxAuiToolBar *aToolbar, EDA_BASE_FRAME *aWindow)
Function KiScaledSeparator Adds a separator to the given toolbar scaled the same way as KiScaledBitma...
Definition: bitmap.cpp:146
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars
static const char * text_xpm[]
#define HELP_GENERATE_BOM
#define HELP_FIND
#define HELP_PLACE_HIER_LABEL
#define HELP_DELETE_ITEMS
#define HELP_ANNOTATE
void ReCreateVToolbar() override
Definition: tool_sch.cpp:190
#define HELP_PLACE_WIRE
struct EDA_HOTKEY_CONFIG g_Schematic_Hokeys_Descr[]