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-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_generic_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  _( "Edit 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_xpm ),
84  _( "Cut selected item" ) );
85 
86  m_mainToolBar->AddTool( wxID_COPY, wxEmptyString, KiBitmap( copy_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_REDRAW, wxEmptyString, KiBitmap( zoom_redraw_xpm ), msg );
116 
118  m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiBitmap( zoom_in_xpm ), msg );
119 
121  m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiBitmap( zoom_out_xpm ), msg );
122 
124  m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, KiBitmap( zoom_fit_in_page_xpm ), msg );
125 
126  m_mainToolBar->AddTool( ID_ZOOM_SELECTION, wxEmptyString, KiBitmap( zoom_area_xpm ),
127  _( "Zoom to selection" ), wxITEM_CHECK );
128 
129 
130  m_mainToolBar->AddSeparator();
131 
132  m_mainToolBar->AddTool( ID_HIERARCHY, wxEmptyString, KiBitmap( hierarchy_nav_xpm ),
133  _( "Navigate schematic hierarchy" ) );
134 
135 
136  m_mainToolBar->AddTool( ID_POPUP_SCH_LEAVE_SHEET, wxEmptyString, KiBitmap( leave_sheet_xpm ),
137  _( "Leave sheet" ) );
138 
139  m_mainToolBar->AddSeparator();
140 
141  m_mainToolBar->AddTool( ID_RUN_LIBRARY, wxEmptyString, KiBitmap( libedit_xpm ),
143 
144  m_mainToolBar->AddTool( ID_TO_LIBVIEW, wxEmptyString, KiBitmap( library_browse_xpm ),
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, KiBitmap( module_editor_xpm ),
150  _( "Footprint Editor - Create/edit footprints" ) );
151 
152  m_mainToolBar->AddSeparator();
153 
154  m_mainToolBar->AddTool( ID_GET_ANNOTATE, wxEmptyString, KiBitmap( annotate_xpm ),
155  HELP_ANNOTATE );
156 
157  m_mainToolBar->AddTool( ID_GET_ERC, wxEmptyString, KiBitmap( erc_xpm ),
158  _( "Perform electrical rules check" ) );
159 
160  m_mainToolBar->AddTool( ID_RUN_CVPCB, wxEmptyString, KiBitmap( cvpcb_xpm ),
161  _( "Run CvPcb to associate footprints to components" ) );
162 
163  m_mainToolBar->AddTool( ID_GET_NETLIST, wxEmptyString, KiBitmap( netlist_xpm ),
164  _( "Generate netlist" ) );
165 
166  m_mainToolBar->AddTool( ID_OPEN_CMP_TABLE, wxEmptyString, KiBitmap( spreadsheet_xpm ),
167  _( "Edit Components Fields" ) );
168 
169 
170  m_mainToolBar->AddTool( ID_GET_TOOLS, wxEmptyString, KiBitmap( bom_xpm ),
172 
173  m_mainToolBar->AddSeparator();
174 
175  m_mainToolBar->AddTool( ID_RUN_PCB, wxEmptyString, KiBitmap( pcbnew_xpm ),
176  _( "Run Pcbnew to layout printed circuit board" ) );
177 
178  m_mainToolBar->AddTool( ID_BACKANNO_ITEMS, wxEmptyString,
179  KiBitmap( import_footprint_names_xpm ),
181 
182  // after adding the tools to the toolbar, must call Realize() to reflect the changes
183  m_mainToolBar->Realize();
184 }
185 
186 
187 /* Create Vertical Right Toolbar
188  */
190 {
191  if( m_drawToolBar )
192  return;
193 
194  m_drawToolBar = new wxAuiToolBar( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
195  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
196 
197  // Set up toolbar
198  m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiBitmap( cursor_xpm ),
199  wxEmptyString, wxITEM_CHECK );
200 
201  m_drawToolBar->AddTool( ID_HIGHLIGHT, wxEmptyString, KiBitmap( net_highlight_schematic_xpm ),
202  _( "Highlight net" ), wxITEM_CHECK );
203 
204  m_drawToolBar->AddTool( ID_SCH_PLACE_COMPONENT, wxEmptyString, KiBitmap( add_component_xpm ),
205  HELP_PLACE_COMPONENTS, wxITEM_CHECK );
206 
207  m_drawToolBar->AddTool( ID_PLACE_POWER_BUTT, wxEmptyString, KiBitmap( add_power_xpm ),
208  HELP_PLACE_POWERPORT, wxITEM_CHECK );
209 
210  m_drawToolBar->AddTool( ID_WIRE_BUTT, wxEmptyString, KiBitmap( add_line_xpm ),
211  HELP_PLACE_WIRE, wxITEM_CHECK );
212 
213  m_drawToolBar->AddTool( ID_BUS_BUTT, wxEmptyString, KiBitmap( add_bus_xpm ),
214  HELP_PLACE_BUS, wxITEM_CHECK );
215 
216  m_drawToolBar->AddTool( ID_WIRETOBUS_ENTRY_BUTT, wxEmptyString, KiBitmap( add_line2bus_xpm ),
217  HELP_PLACE_WIRE2BUS_ENTRY, wxITEM_CHECK );
218 
219  m_drawToolBar->AddTool( ID_BUSTOBUS_ENTRY_BUTT, wxEmptyString, KiBitmap( add_bus2bus_xpm ),
220  HELP_PLACE_BUS2BUS_ENTRY, wxITEM_CHECK );
221 
222  m_drawToolBar->AddTool( ID_NOCONN_BUTT, wxEmptyString, KiBitmap( noconn_xpm ),
223  HELP_PLACE_NC_FLAG, wxITEM_CHECK );
224 
225  m_drawToolBar->AddTool( ID_JUNCTION_BUTT, wxEmptyString, KiBitmap( add_junction_xpm ),
226  HELP_PLACE_JUNCTION, wxITEM_CHECK );
227 
228  m_drawToolBar->AddTool( ID_LABEL_BUTT, wxEmptyString, KiBitmap( add_line_label_xpm ),
229  HELP_PLACE_NETLABEL, wxITEM_CHECK );
230 
231  m_drawToolBar->AddTool( ID_GLABEL_BUTT, wxEmptyString, KiBitmap( add_glabel_xpm ),
232  HELP_PLACE_GLOBALLABEL, wxITEM_CHECK );
233 
234  m_drawToolBar->AddTool( ID_HIERLABEL_BUTT, wxEmptyString,
235  KiBitmap( add_hierarchical_label_xpm ),
236  HELP_PLACE_HIER_LABEL, wxITEM_CHECK );
237 
238  m_drawToolBar->AddTool( ID_SHEET_SYMBOL_BUTT, wxEmptyString,
239  KiBitmap( add_hierarchical_subsheet_xpm ),
240  HELP_PLACE_SHEET, wxITEM_CHECK );
241 
242  m_drawToolBar->AddTool( ID_IMPORT_HLABEL_BUTT, wxEmptyString,
243  KiBitmap( import_hierarchical_label_xpm ),
244  HELP_IMPORT_SHEETPIN, wxITEM_CHECK );
245 
246  m_drawToolBar->AddTool( ID_SHEET_PIN_BUTT, wxEmptyString,
247  KiBitmap( add_hierar_pin_xpm ),
248  HELP_PLACE_SHEETPIN, wxITEM_CHECK );
249 
250  m_drawToolBar->AddTool( ID_LINE_COMMENT_BUTT, wxEmptyString,
251  KiBitmap( add_dashed_line_xpm ),
252  HELP_PLACE_GRAPHICLINES, wxITEM_CHECK );
253 
254  m_drawToolBar->AddTool( ID_TEXT_COMMENT_BUTT, wxEmptyString, KiBitmap( text_xpm ),
255  HELP_PLACE_GRAPHICTEXTS, wxITEM_CHECK );
256 
257  m_drawToolBar->AddTool( ID_ADD_IMAGE_BUTT, wxEmptyString, KiBitmap( image_xpm ),
258  _("Add bitmap image"), wxITEM_CHECK );
259 
260  m_drawToolBar->AddTool( ID_SCHEMATIC_DELETE_ITEM_BUTT, wxEmptyString,
261  KiBitmap( delete_xpm ),
262  HELP_DELETE_ITEMS, wxITEM_CHECK );
263 
264  m_drawToolBar->Realize();
265 }
266 
267 
268 /* Create Vertical Left Toolbar (Option Toolbar)
269  */
271 {
272  if( m_optionsToolBar )
273  return;
274 
275  m_optionsToolBar = new wxAuiToolBar( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
276  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
277 
278  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString,
279  KiBitmap( grid_xpm ),
280  _( "Turn grid off" ), wxITEM_CHECK );
281 
282  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
283  KiBitmap( unit_inch_xpm ),
284  _( "Set unit to inch" ), wxITEM_CHECK );
285 
286  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
287  KiBitmap( unit_mm_xpm ),
288  _( "Set unit to mm" ), wxITEM_CHECK );
289 
290 #ifndef __APPLE__
291  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
292  KiBitmap( cursor_shape_xpm ),
293  _( "Change cursor shape" ), wxITEM_CHECK );
294 #endif // !__APPLE__
295 
296  //m_optionsToolBar->AddSeparator();
297  m_optionsToolBar->AddTool( ID_TB_OPTIONS_HIDDEN_PINS, wxEmptyString,
298  KiBitmap( hidden_pin_xpm ),
299  _( "Show hidden pins" ), wxITEM_CHECK );
300 
301  //m_optionsToolBar->AddSeparator();
302  m_optionsToolBar->AddTool( ID_TB_OPTIONS_BUS_WIRES_ORIENT, wxEmptyString,
303  KiBitmap( lines90_xpm ),
304  _( "HV orientation for wires and bus" ),
305  wxITEM_CHECK );
306 
307  m_optionsToolBar->Realize();
308 }
309 
310 
311 void SCH_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
312 {
313  if( m_canvas == NULL )
314  return;
315 
316  int id = event.GetId();
317 
318  switch( id )
319  {
321  m_showAllPins = m_optionsToolBar->GetToolToggled( id );
322  m_canvas->Refresh();
323  break;
324 
326  SetForceHVLines( m_optionsToolBar->GetToolToggled( id ) );
327  break;
328 
329  default:
330  wxFAIL_MSG( wxT( "Unexpected select option tool bar ID." ) );
331  break;
332  }
333 }
#define HELP_PLACE_POWERPORT
void ReCreateOptToolbar()
Definition: tool_sch.cpp:270
#define HELP_PLACE_COMPONENTS
void OnSelectOptionToolbar(wxCommandEvent &event)
Definition: tool_sch.cpp:311
#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:240
#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:136
#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.
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:189
#define HELP_PLACE_WIRE
struct EDA_HOTKEY_CONFIG g_Schematic_Hokeys_Descr[]