KiCad PCB EDA Suite
sch_navigate_tool.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 (C) 1992-2020 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, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include <schematic.h>
26 #include <eeschema_id.h>
27 #include <tools/ee_actions.h>
29 
30 
32 {
34  return 0;
35 }
36 
37 
39 {
40  wxString* page = aEvent.Parameter<wxString*>();
41 
42  wxCHECK( page, 0 );
43 
44  auto goToPage =
45  [&]( wxString* aPage )
46  {
47  for( const SCH_SHEET_PATH& sheet : m_frame->Schematic().GetSheets() )
48  {
49  if( sheet.GetPageNumber() == *aPage )
50  {
53 
54  m_frame->SetCurrentSheet( sheet );
56 
57  return;
58  }
59  }
60  };
61 
62  if( *page == "HYPERTEXT_BACK" )
63  {
64  if( m_hypertextStack.size() > 0 )
65  {
66  goToPage( &m_hypertextStack.top() );
67  m_hypertextStack.pop();
68  }
69  }
70  else
71  {
73  goToPage( page );
74  }
75 
76  return 0;
77 }
78 
79 
81 {
83  const EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
84 
85  if( selection.GetSize() == 1 )
86  {
87  SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
88 
91 
92  m_frame->GetCurrentSheet().push_back( sheet );
95  }
96 
97  return 0;
98 }
99 
100 
102 {
103  if( m_frame->GetCurrentSheet().Last() != &m_frame->Schematic().Root() )
104  {
107 
111  }
112 
113  return 0;
114 }
115 
116 
118 {
123 }
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
static TOOL_ACTION navigateHierarchy
Definition: ee_actions.h:186
int LeaveSheet(const TOOL_EVENT &aEvent)
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:97
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:141
void DisplayCurrentSheet()
Draw the current sheet on the display.
Definition: hierarch.cpp:285
static const KICAD_T SheetsOnly[]
Definition: ee_collectors.h:48
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
void pop_back()
Forwarded method from std::vector.
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:185
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
int EnterSheet(const TOOL_EVENT &aEvent)
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
wxString GetPageNumber() const
std::stack< wxString > m_hypertextStack
TOOL_EVENT.
Definition: tool_event.h:171
SCHEMATIC & Schematic() const
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
void setTransitions() override
Sets up handlers for various events.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:219
SCH_SHEET & Root() const
Definition: schematic.h:102
int HypertextCommand(const TOOL_EVENT &aEvent)
static TOOL_ACTION enterSheet
Definition: ee_actions.h:184
int NavigateHierarchy(const TOOL_EVENT &aEvent)
SCH_SHEET_PATH & GetCurrentSheet() const
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:76
static TOOL_ACTION hypertextCommand
Definition: ee_actions.h:187