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-2011 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 2004-2017 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 <schframe.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 != NULL )
48  return;
49 
50  wxString msg;
51  m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
52  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
53 
54  // Set up toolbar
55  if( Kiface().IsSingle() ) // not when under a project mgr
56  {
57  // These 2 menus have meaning only outside a project, i.e. not under a project manager:
58  m_mainToolBar->AddTool( ID_NEW_PROJECT, wxEmptyString, KiBitmap( new_sch_xpm ),
59  _( "New schematic project" ) );
60 
61  m_mainToolBar->AddTool( ID_LOAD_PROJECT, wxEmptyString, KiBitmap( open_document_xpm ),
62  _( "Open schematic project" ) );
63  }
64 
65  m_mainToolBar->AddTool( ID_SAVE_PROJECT, wxEmptyString, KiBitmap( save_project_xpm ),
66  _( "Save schematic project" ) );
67 
68  m_mainToolBar->AddSeparator();
69 
70  m_mainToolBar->AddTool( ID_SHEET_SET, wxEmptyString, KiBitmap( sheetset_xpm ),
71  _( "Page settings" ) );
72 
73  m_mainToolBar->AddSeparator();
74 
75  m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString, KiBitmap( print_button_xpm ),
76  _( "Print schematic" ) );
77 
78  m_mainToolBar->AddTool( ID_GEN_PLOT_SCHEMATIC, wxEmptyString, KiBitmap( plot_xpm ),
79  _( "Plot schematic" ) );
80 
81  m_mainToolBar->AddSeparator();
82 
83  m_mainToolBar->AddTool( wxID_CUT, wxEmptyString, KiBitmap( cut_button_xpm ),
84  _( "Cut selected item" ) );
85 
86  m_mainToolBar->AddTool( wxID_COPY, wxEmptyString, KiBitmap( copy_button_xpm ),
87  _( "Copy selected item" ) );
88 
89  m_mainToolBar->AddTool( wxID_PASTE, wxEmptyString, KiBitmap( paste_xpm ),
90  _( "Paste" ) );
91 
92 
93  m_mainToolBar->AddSeparator();
94 
96  m_mainToolBar->AddTool( wxID_UNDO, wxEmptyString, KiBitmap( undo_xpm ), msg );
97 
99  m_mainToolBar->AddTool( wxID_REDO, wxEmptyString, KiBitmap( redo_xpm ), msg );
100 
101 
102  m_mainToolBar->AddSeparator();
103 
105  m_mainToolBar->AddTool( ID_FIND_ITEMS, wxEmptyString, KiBitmap( find_xpm ), msg );
106 
107  m_mainToolBar->AddTool( wxID_REPLACE, wxEmptyString, KiBitmap( find_replace_xpm ),
108  wxNullBitmap, wxITEM_NORMAL, _( "Find and replace text" ),
109  HELP_REPLACE, NULL );
110 
111 
112  m_mainToolBar->AddSeparator();
113 
115  m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiBitmap( zoom_in_xpm ), msg );
116 
118  m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiBitmap( zoom_out_xpm ), msg );
119 
121  m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, KiBitmap( zoom_redraw_xpm ), msg );
122 
124  m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, KiBitmap( zoom_fit_in_page_xpm ), msg );
125 
126 
127  m_mainToolBar->AddSeparator();
128 
129  m_mainToolBar->AddTool( ID_HIERARCHY, wxEmptyString, KiBitmap( hierarchy_nav_xpm ),
130  _( "Navigate schematic hierarchy" ) );
131 
132 
133  m_mainToolBar->AddTool( ID_POPUP_SCH_LEAVE_SHEET, wxEmptyString, KiBitmap( leave_sheet_xpm ),
134  _( "Leave sheet" ) );
135 
136  m_mainToolBar->AddSeparator();
137 
138  m_mainToolBar->AddTool( ID_RUN_LIBRARY, wxEmptyString, KiBitmap( libedit_xpm ),
140 
141  m_mainToolBar->AddTool( ID_TO_LIBVIEW, wxEmptyString, KiBitmap( library_browse_xpm ),
143 
144  // modedit is with libedit in a "library section" because the user must have footprints before
145  // they can be assigned.
146  m_mainToolBar->AddTool( ID_RUN_PCB_MODULE_EDITOR, wxEmptyString, KiBitmap( module_editor_xpm ),
147  _( "Footprint Editor" ) );
148 
149  m_mainToolBar->AddSeparator();
150 
151  m_mainToolBar->AddTool( ID_GET_ANNOTATE, wxEmptyString, KiBitmap( annotate_xpm ),
152  HELP_ANNOTATE );
153 
154  m_mainToolBar->AddTool( ID_GET_ERC, wxEmptyString, KiBitmap( erc_xpm ),
155  _( "Perform electrical rules check" ) );
156 
157  m_mainToolBar->AddTool( ID_RUN_CVPCB, wxEmptyString, KiBitmap( cvpcb_xpm ),
158  _( "Run CvPcb to associate components and footprints" ) );
159 
160  m_mainToolBar->AddTool( ID_GET_NETLIST, wxEmptyString, KiBitmap( netlist_xpm ),
161  _( "Generate netlist" ) );
162 
163  m_mainToolBar->AddTool( ID_OPEN_CMP_TABLE, wxEmptyString, KiBitmap( spreadsheet_xpm ),
164  _( "Component table view" ) );
165 
166 
167  m_mainToolBar->AddTool( ID_GET_TOOLS, wxEmptyString, KiBitmap( bom_xpm ),
169 
170  m_mainToolBar->AddSeparator();
171 
172  m_mainToolBar->AddTool( ID_RUN_PCB, wxEmptyString, KiBitmap( pcbnew_xpm ),
173  _( "Run Pcbnew to layout printed circuit board" ) );
174 
175  m_mainToolBar->AddTool( ID_BACKANNO_ITEMS, wxEmptyString,
176  KiBitmap( import_footprint_names_xpm ),
178 
179  // after adding the tools to the toolbar, must call Realize() to reflect the changes
180  m_mainToolBar->Realize();
181 }
182 
183 
184 /* Create Vertical Right Toolbar
185  */
187 {
188  if( m_drawToolBar )
189  return;
190 
191  m_drawToolBar = new wxAuiToolBar( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
192  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
193 
194  // Set up toolbar
195  m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiBitmap( cursor_xpm ),
196  wxEmptyString, wxITEM_CHECK );
197 
198  m_drawToolBar->AddTool( ID_HIGHLIGHT, wxEmptyString, KiBitmap( net_highlight_schematic_xpm ),
199  _( "Click to highlight net" ), wxITEM_CHECK );
200 
201  m_drawToolBar->AddTool( ID_ZOOM_SELECTION, wxEmptyString, KiBitmap( zoom_area_xpm ),
202  _( "Zoom to selection" ), wxITEM_CHECK );
203 
204  m_drawToolBar->AddTool( ID_HIERARCHY_PUSH_POP_BUTT, wxEmptyString,
205  KiBitmap( hierarchy_cursor_xpm ),
206  _( "Ascend/descend hierarchy" ), wxITEM_CHECK );
207 
208  m_drawToolBar->AddTool( ID_SCH_PLACE_COMPONENT, wxEmptyString, KiBitmap( add_component_xpm ),
209  HELP_PLACE_COMPONENTS, wxITEM_CHECK );
210 
211  m_drawToolBar->AddTool( ID_PLACE_POWER_BUTT, wxEmptyString, KiBitmap( add_power_xpm ),
212  HELP_PLACE_POWERPORT, wxITEM_CHECK );
213 
214  m_drawToolBar->AddTool( ID_WIRE_BUTT, wxEmptyString, KiBitmap( add_line_xpm ),
215  HELP_PLACE_WIRE, wxITEM_CHECK );
216 
217  m_drawToolBar->AddTool( ID_BUS_BUTT, wxEmptyString, KiBitmap( add_bus_xpm ),
218  HELP_PLACE_BUS, wxITEM_CHECK );
219 
220  m_drawToolBar->AddTool( ID_WIRETOBUS_ENTRY_BUTT, wxEmptyString, KiBitmap( add_line2bus_xpm ),
221  HELP_PLACE_WIRE2BUS_ENTRY, wxITEM_CHECK );
222 
223  m_drawToolBar->AddTool( ID_BUSTOBUS_ENTRY_BUTT, wxEmptyString, KiBitmap( add_bus2bus_xpm ),
224  HELP_PLACE_BUS2BUS_ENTRY, wxITEM_CHECK );
225 
226  m_drawToolBar->AddTool( ID_NOCONN_BUTT, wxEmptyString, KiBitmap( noconn_xpm ),
227  HELP_PLACE_NC_FLAG, wxITEM_CHECK );
228 
229  m_drawToolBar->AddTool( ID_JUNCTION_BUTT, wxEmptyString, KiBitmap( add_junction_xpm ),
230  HELP_PLACE_JUNCTION, wxITEM_CHECK );
231 
232  m_drawToolBar->AddTool( ID_LABEL_BUTT, wxEmptyString, KiBitmap( add_line_label_xpm ),
233  HELP_PLACE_NETLABEL, wxITEM_CHECK );
234 
235  m_drawToolBar->AddTool( ID_GLABEL_BUTT, wxEmptyString, KiBitmap( add_glabel_xpm ),
236  HELP_PLACE_GLOBALLABEL, wxITEM_CHECK );
237 
238  m_drawToolBar->AddTool( ID_HIERLABEL_BUTT, wxEmptyString,
239  KiBitmap( add_hierarchical_label_xpm ),
240  HELP_PLACE_HIER_LABEL, wxITEM_CHECK );
241 
242  m_drawToolBar->AddTool( ID_SHEET_SYMBOL_BUTT, wxEmptyString,
243  KiBitmap( add_hierarchical_subsheet_xpm ),
244  HELP_PLACE_SHEET, wxITEM_CHECK );
245 
246  m_drawToolBar->AddTool( ID_IMPORT_HLABEL_BUTT, wxEmptyString,
247  KiBitmap( import_hierarchical_label_xpm ),
248  HELP_IMPORT_SHEETPIN, wxITEM_CHECK );
249 
250  m_drawToolBar->AddTool( ID_SHEET_PIN_BUTT, wxEmptyString,
251  KiBitmap( add_hierar_pin_xpm ),
252  HELP_PLACE_SHEETPIN, wxITEM_CHECK );
253 
254  m_drawToolBar->AddTool( ID_LINE_COMMENT_BUTT, wxEmptyString,
255  KiBitmap( add_dashed_line_xpm ),
256  HELP_PLACE_GRAPHICLINES, wxITEM_CHECK );
257 
258  m_drawToolBar->AddTool( ID_TEXT_COMMENT_BUTT, wxEmptyString, KiBitmap( add_text_xpm ),
259  HELP_PLACE_GRAPHICTEXTS, wxITEM_CHECK );
260 
261  m_drawToolBar->AddTool( ID_ADD_IMAGE_BUTT, wxEmptyString, KiBitmap( image_xpm ),
262  _("Add bitmap image"), wxITEM_CHECK );
263 
264  m_drawToolBar->AddTool( ID_SCHEMATIC_DELETE_ITEM_BUTT, wxEmptyString,
265  KiBitmap( delete_xpm ),
266  HELP_DELETE_ITEMS, wxITEM_CHECK );
267 
268  m_drawToolBar->Realize();
269 }
270 
271 
272 /* Create Vertical Left Toolbar (Option Toolbar)
273  */
275 {
276  if( m_optionsToolBar )
277  return;
278 
279  m_optionsToolBar = new wxAuiToolBar( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
280  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
281 
282  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString,
283  KiBitmap( grid_xpm ),
284  _( "Turn grid off" ), wxITEM_CHECK );
285 
286  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
287  KiBitmap( unit_inch_xpm ),
288  _( "Set unit to inch" ), wxITEM_CHECK );
289 
290  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
291  KiBitmap( unit_mm_xpm ),
292  _( "Set unit to mm" ), wxITEM_CHECK );
293 
294 #ifndef __APPLE__
295  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
296  KiBitmap( cursor_shape_xpm ),
297  _( "Change cursor shape" ), wxITEM_CHECK );
298 #endif // !__APPLE__
299 
300  //m_optionsToolBar->AddSeparator();
301  m_optionsToolBar->AddTool( ID_TB_OPTIONS_HIDDEN_PINS, wxEmptyString,
302  KiBitmap( hidden_pin_xpm ),
303  _( "Show hidden pins" ), wxITEM_CHECK );
304 
305  //m_optionsToolBar->AddSeparator();
306  m_optionsToolBar->AddTool( ID_TB_OPTIONS_BUS_WIRES_ORIENT, wxEmptyString,
307  KiBitmap( lines90_xpm ),
308  _( "HV orientation for wires and bus" ),
309  wxITEM_CHECK );
310 
311  m_optionsToolBar->Realize();
312 }
313 
314 
315 void SCH_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
316 {
317  if( m_canvas == NULL )
318  return;
319 
320  int id = event.GetId();
321 
322  switch( id )
323  {
325  m_showAllPins = m_optionsToolBar->GetToolToggled( id );
326  m_canvas->Refresh();
327  break;
328 
330  SetForceHVLines( m_optionsToolBar->GetToolToggled( id ) );
331  break;
332 
333  default:
334  wxFAIL_MSG( wxT( "Unexpected select option tool bar ID." ) );
335  break;
336  }
337 }
#define HELP_PLACE_POWERPORT
void ReCreateOptToolbar()
Definition: tool_sch.cpp:274
#define HELP_PLACE_COMPONENTS
void OnSelectOptionToolbar(wxCommandEvent &event)
Definition: tool_sch.cpp:315
#define HELP_PLACE_SHEETPIN
#define HELP_PLACE_NETLABEL
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Definition: draw_panel.cpp:326
#define HELP_PLACE_GRAPHICTEXTS
void SetForceHVLines(bool aForceHVdirection)
Definition: schframe.h:241
#define HELP_ZOOM_FIT
Definition: id.h:232
#define HELP_PLACE_WIRE2BUS_ENTRY
#define HELP_PLACE_SHEET
#define HELP_PLACE_JUNCTION
Definition: id.h:66
#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:121
#define HELP_PLACE_BUS2BUS_ENTRY
#define HELP_ZOOM_REDRAW
#define HELP_PLACE_GRAPHICLINES
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
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:125
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:122
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: wxstruct.h:135
#define HELP_IMPORT_FOOTPRINTS
bool m_showAllPins
Flag to indicate show hidden pins.
Definition: schframe.h:162
#define HELP_PLACE_NC_FLAG
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:92
#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.
#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:186
#define HELP_PLACE_WIRE
struct EDA_HOTKEY_CONFIG g_Schematic_Hokeys_Descr[]