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_GET_TOOLS, wxEmptyString, KiBitmap( bom_xpm ),
165 
166 
167  m_mainToolBar->AddSeparator();
168 
169  m_mainToolBar->AddTool( ID_RUN_PCB, wxEmptyString, KiBitmap( pcbnew_xpm ),
170  _( "Run Pcbnew to layout printed circuit board" ) );
171 
172  m_mainToolBar->AddTool( ID_BACKANNO_ITEMS, wxEmptyString,
173  KiBitmap( import_footprint_names_xpm ),
175 
176  // after adding the tools to the toolbar, must call Realize() to reflect the changes
177  m_mainToolBar->Realize();
178 }
179 
180 
181 /* Create Vertical Right Toolbar
182  */
184 {
185  if( m_drawToolBar )
186  return;
187 
188  m_drawToolBar = new wxAuiToolBar( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
189  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
190 
191  // Set up toolbar
192  m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiBitmap( cursor_xpm ),
193  wxEmptyString, wxITEM_CHECK );
194 
195  m_drawToolBar->AddTool( ID_HIGHLIGHT, wxEmptyString, KiBitmap( net_highlight_schematic_xpm ),
196  _( "Click to highlight net" ), wxITEM_CHECK );
197 
198  m_drawToolBar->AddTool( ID_ZOOM_SELECTION, wxEmptyString, KiBitmap( zoom_area_xpm ),
199  _( "Zoom to selection" ), wxITEM_CHECK );
200 
201  m_drawToolBar->AddTool( ID_HIERARCHY_PUSH_POP_BUTT, wxEmptyString,
202  KiBitmap( hierarchy_cursor_xpm ),
203  _( "Ascend/descend hierarchy" ), wxITEM_CHECK );
204 
205  m_drawToolBar->AddTool( ID_SCH_PLACE_COMPONENT, wxEmptyString, KiBitmap( add_component_xpm ),
206  HELP_PLACE_COMPONENTS, wxITEM_CHECK );
207 
208  m_drawToolBar->AddTool( ID_PLACE_POWER_BUTT, wxEmptyString, KiBitmap( add_power_xpm ),
209  HELP_PLACE_POWERPORT, wxITEM_CHECK );
210 
211  m_drawToolBar->AddTool( ID_WIRE_BUTT, wxEmptyString, KiBitmap( add_line_xpm ),
212  HELP_PLACE_WIRE, wxITEM_CHECK );
213 
214  m_drawToolBar->AddTool( ID_BUS_BUTT, wxEmptyString, KiBitmap( add_bus_xpm ),
215  HELP_PLACE_BUS, wxITEM_CHECK );
216 
217  m_drawToolBar->AddTool( ID_WIRETOBUS_ENTRY_BUTT, wxEmptyString, KiBitmap( add_line2bus_xpm ),
218  HELP_PLACE_WIRE2BUS_ENTRY, wxITEM_CHECK );
219 
220  m_drawToolBar->AddTool( ID_BUSTOBUS_ENTRY_BUTT, wxEmptyString, KiBitmap( add_bus2bus_xpm ),
221  HELP_PLACE_BUS2BUS_ENTRY, wxITEM_CHECK );
222 
223  m_drawToolBar->AddTool( ID_NOCONN_BUTT, wxEmptyString, KiBitmap( noconn_xpm ),
224  HELP_PLACE_NC_FLAG, wxITEM_CHECK );
225 
226  m_drawToolBar->AddTool( ID_JUNCTION_BUTT, wxEmptyString, KiBitmap( add_junction_xpm ),
227  HELP_PLACE_JUNCTION, wxITEM_CHECK );
228 
229  m_drawToolBar->AddTool( ID_LABEL_BUTT, wxEmptyString, KiBitmap( add_line_label_xpm ),
230  HELP_PLACE_NETLABEL, wxITEM_CHECK );
231 
232  m_drawToolBar->AddTool( ID_GLABEL_BUTT, wxEmptyString, KiBitmap( add_glabel_xpm ),
233  HELP_PLACE_GLOBALLABEL, wxITEM_CHECK );
234 
235  m_drawToolBar->AddTool( ID_HIERLABEL_BUTT, wxEmptyString,
236  KiBitmap( add_hierarchical_label_xpm ),
237  HELP_PLACE_HIER_LABEL, wxITEM_CHECK );
238 
239  m_drawToolBar->AddTool( ID_SHEET_SYMBOL_BUTT, wxEmptyString,
240  KiBitmap( add_hierarchical_subsheet_xpm ),
241  HELP_PLACE_SHEET, wxITEM_CHECK );
242 
243  m_drawToolBar->AddTool( ID_IMPORT_HLABEL_BUTT, wxEmptyString,
244  KiBitmap( import_hierarchical_label_xpm ),
245  HELP_IMPORT_SHEETPIN, wxITEM_CHECK );
246 
247  m_drawToolBar->AddTool( ID_SHEET_PIN_BUTT, wxEmptyString,
248  KiBitmap( add_hierar_pin_xpm ),
249  HELP_PLACE_SHEETPIN, wxITEM_CHECK );
250 
251  m_drawToolBar->AddTool( ID_LINE_COMMENT_BUTT, wxEmptyString,
252  KiBitmap( add_dashed_line_xpm ),
253  HELP_PLACE_GRAPHICLINES, wxITEM_CHECK );
254 
255  m_drawToolBar->AddTool( ID_TEXT_COMMENT_BUTT, wxEmptyString, KiBitmap( add_text_xpm ),
256  HELP_PLACE_GRAPHICTEXTS, wxITEM_CHECK );
257 
258  m_drawToolBar->AddTool( ID_ADD_IMAGE_BUTT, wxEmptyString, KiBitmap( image_xpm ),
259  _("Add bitmap image"), wxITEM_CHECK );
260 
261  m_drawToolBar->AddTool( ID_SCHEMATIC_DELETE_ITEM_BUTT, wxEmptyString,
262  KiBitmap( delete_xpm ),
263  HELP_DELETE_ITEMS, wxITEM_CHECK );
264 
265  m_drawToolBar->Realize();
266 }
267 
268 
269 /* Create Vertical Left Toolbar (Option Toolbar)
270  */
272 {
273  if( m_optionsToolBar )
274  return;
275 
276  m_optionsToolBar = new wxAuiToolBar( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
277  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
278 
279  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString,
280  KiBitmap( grid_xpm ),
281  _( "Turn grid off" ), wxITEM_CHECK );
282 
283  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
284  KiBitmap( unit_inch_xpm ),
285  _( "Set unit to inch" ), wxITEM_CHECK );
286 
287  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
288  KiBitmap( unit_mm_xpm ),
289  _( "Set unit to mm" ), wxITEM_CHECK );
290 
291 #ifndef __APPLE__
292  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
293  KiBitmap( cursor_shape_xpm ),
294  _( "Change cursor shape" ), wxITEM_CHECK );
295 #endif // !__APPLE__
296 
297  //m_optionsToolBar->AddSeparator();
298  m_optionsToolBar->AddTool( ID_TB_OPTIONS_HIDDEN_PINS, wxEmptyString,
299  KiBitmap( hidden_pin_xpm ),
300  _( "Show hidden pins" ), wxITEM_CHECK );
301 
302  //m_optionsToolBar->AddSeparator();
303  m_optionsToolBar->AddTool( ID_TB_OPTIONS_BUS_WIRES_ORIENT, wxEmptyString,
304  KiBitmap( lines90_xpm ),
305  _( "HV orientation for wires and bus" ),
306  wxITEM_CHECK );
307 
308  m_optionsToolBar->Realize();
309 }
310 
311 
312 void SCH_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
313 {
314  if( m_canvas == NULL )
315  return;
316 
317  int id = event.GetId();
318 
319  switch( id )
320  {
322  m_showAllPins = m_optionsToolBar->GetToolToggled( id );
323  m_canvas->Refresh();
324  break;
325 
327  SetForceHVLines( m_optionsToolBar->GetToolToggled( id ) );
328  break;
329 
330  default:
331  wxFAIL_MSG( wxT( "Unexpected select option tool bar ID." ) );
332  break;
333  }
334 }
#define HELP_PLACE_POWERPORT
void ReCreateOptToolbar()
Definition: tool_sch.cpp:271
#define HELP_PLACE_COMPONENTS
void OnSelectOptionToolbar(wxCommandEvent &event)
Definition: tool_sch.cpp:312
#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:183
#define HELP_PLACE_WIRE
struct EDA_HOTKEY_CONFIG g_Schematic_Hokeys_Descr[]