Hierarchy: turn into a left side pane
Drop auto-closing option as well.
This commit is contained in:
parent
bd51b33f65
commit
857990a883
|
@ -116,6 +116,12 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
|
|||
wxEVT_MIDDLE_UP,
|
||||
wxEVT_MIDDLE_DOWN,
|
||||
wxEVT_MIDDLE_DCLICK,
|
||||
wxEVT_AUX1_UP,
|
||||
wxEVT_AUX1_DOWN,
|
||||
wxEVT_AUX1_DCLICK,
|
||||
wxEVT_AUX2_UP,
|
||||
wxEVT_AUX2_DOWN,
|
||||
wxEVT_AUX2_DCLICK,
|
||||
wxEVT_MOTION,
|
||||
wxEVT_MOUSEWHEEL,
|
||||
wxEVT_CHAR,
|
||||
|
|
|
@ -1329,6 +1329,12 @@ CAIRO_GAL::CAIRO_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent,
|
|||
Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
||||
Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
||||
Connect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
||||
Connect( wxEVT_AUX1_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
||||
Connect( wxEVT_AUX1_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
||||
Connect( wxEVT_AUX1_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
||||
Connect( wxEVT_AUX2_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
||||
Connect( wxEVT_AUX2_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
||||
Connect( wxEVT_AUX2_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
||||
Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
||||
#if defined _WIN32 || defined _WIN64
|
||||
Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
||||
|
|
|
@ -256,6 +256,12 @@ OPENGL_GAL::OPENGL_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent,
|
|||
Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
||||
Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
||||
Connect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
||||
Connect( wxEVT_AUX1_DOWN, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
||||
Connect( wxEVT_AUX1_UP, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
||||
Connect( wxEVT_AUX1_DCLICK, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
||||
Connect( wxEVT_AUX2_DOWN, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
||||
Connect( wxEVT_AUX2_UP, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
||||
Connect( wxEVT_AUX2_DCLICK, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
||||
Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
||||
#if wxCHECK_VERSION( 3, 1, 0 ) || defined( USE_OSX_MAGNIFY_EVENT )
|
||||
Connect( wxEVT_MAGNIFY, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
||||
|
|
|
@ -113,6 +113,12 @@ struct TOOL_DISPATCHER::BUTTON_STATE
|
|||
case BUT_RIGHT:
|
||||
return mouseState.RightIsDown();
|
||||
|
||||
case BUT_AUX1:
|
||||
return mouseState.Aux1IsDown();
|
||||
|
||||
case BUT_AUX2:
|
||||
return mouseState.Aux2IsDown();
|
||||
|
||||
default:
|
||||
assert( false );
|
||||
break;
|
||||
|
@ -138,6 +144,10 @@ TOOL_DISPATCHER::TOOL_DISPATCHER( TOOL_MANAGER* aToolMgr ) :
|
|||
wxEVT_RIGHT_UP, wxEVT_RIGHT_DCLICK ) );
|
||||
m_buttons.push_back( new BUTTON_STATE( BUT_MIDDLE, wxEVT_MIDDLE_DOWN,
|
||||
wxEVT_MIDDLE_UP, wxEVT_MIDDLE_DCLICK ) );
|
||||
m_buttons.push_back( new BUTTON_STATE( BUT_AUX1, wxEVT_AUX1_DOWN,
|
||||
wxEVT_AUX1_UP, wxEVT_AUX1_DCLICK ) );
|
||||
m_buttons.push_back( new BUTTON_STATE( BUT_AUX2, wxEVT_AUX2_DOWN,
|
||||
wxEVT_AUX2_UP, wxEVT_AUX2_DCLICK ) );
|
||||
|
||||
ResetState();
|
||||
}
|
||||
|
@ -311,10 +321,11 @@ static bool isKeyModifierOnly( int aKeyCode )
|
|||
|
||||
static bool isMouseClick( wxEventType type )
|
||||
{
|
||||
return type == wxEVT_LEFT_DOWN || type == wxEVT_LEFT_UP || type == wxEVT_MIDDLE_DOWN
|
||||
|| type == wxEVT_MIDDLE_UP || type == wxEVT_RIGHT_DOWN || type == wxEVT_RIGHT_UP
|
||||
|| type == wxEVT_LEFT_DCLICK || type == wxEVT_MIDDLE_DCLICK
|
||||
|| type == wxEVT_RIGHT_DCLICK;
|
||||
return type == wxEVT_LEFT_DOWN || type == wxEVT_LEFT_UP || type == wxEVT_LEFT_DCLICK
|
||||
|| type == wxEVT_MIDDLE_DOWN || type == wxEVT_MIDDLE_UP || type == wxEVT_MIDDLE_DCLICK
|
||||
|| type == wxEVT_RIGHT_DOWN || type == wxEVT_RIGHT_UP || type == wxEVT_RIGHT_DCLICK
|
||||
|| type == wxEVT_AUX1_DOWN || type == wxEVT_AUX1_UP || type == wxEVT_AUX1_DCLICK
|
||||
|| type == wxEVT_AUX2_DOWN || type == wxEVT_AUX2_UP || type == wxEVT_AUX2_DCLICK;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -136,6 +136,8 @@ const std::string TOOL_EVENT::Format() const
|
|||
{ BUT_LEFT, "left" },
|
||||
{ BUT_RIGHT, "right" },
|
||||
{ BUT_MIDDLE, "middle" },
|
||||
{ BUT_AUX1, "aux1" },
|
||||
{ BUT_AUX2, "aux2" },
|
||||
{ 0, "" }
|
||||
};
|
||||
|
||||
|
|
|
@ -32,7 +32,10 @@ void SetAuiPaneSize( wxAuiManager& aManager, wxAuiPaneInfo& aPane, int aWidth, i
|
|||
aManager.Update();
|
||||
|
||||
// now make it resizable again
|
||||
aPane.MinSize( minSize.x, minSize.y );
|
||||
aPane.Resizable();
|
||||
aManager.Update();
|
||||
|
||||
// Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
|
||||
// back to minimum.
|
||||
aPane.MinSize( minSize.x, minSize.y );
|
||||
}
|
||||
|
|
|
@ -65,7 +65,6 @@ void PANEL_EESCHEMA_EDITING_OPTIONS::loadEEschemaSettings( EESCHEMA_SETTINGS* aC
|
|||
|
||||
m_choiceLineMode->SetSelection( aCfg->m_Drawing.line_mode );
|
||||
m_footprintPreview->SetValue( aCfg->m_Appearance.footprint_preview );
|
||||
m_navigatorStaysOpen->SetValue( aCfg->m_Appearance.navigator_stays_open );
|
||||
|
||||
m_checkAutoplaceFields->SetValue( aCfg->m_AutoplaceFields.enable );
|
||||
m_checkAutoplaceJustify->SetValue( aCfg->m_AutoplaceFields.allow_rejustify );
|
||||
|
@ -103,7 +102,6 @@ bool PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataFromWindow()
|
|||
|
||||
cfg->m_Drawing.line_mode = m_choiceLineMode->GetSelection();
|
||||
cfg->m_Appearance.footprint_preview = m_footprintPreview->GetValue();
|
||||
cfg->m_Appearance.navigator_stays_open = m_navigatorStaysOpen->GetValue();
|
||||
|
||||
cfg->m_AutoplaceFields.enable = m_checkAutoplaceFields->GetValue();
|
||||
cfg->m_AutoplaceFields.allow_rejustify = m_checkAutoplaceJustify->GetValue();
|
||||
|
|
|
@ -268,10 +268,6 @@ PANEL_EESCHEMA_EDITING_OPTIONS_BASE::PANEL_EESCHEMA_EDITING_OPTIONS_BASE( wxWind
|
|||
m_footprintPreview = new wxCheckBox( sbSizer6->GetStaticBox(), wxID_ANY, _("Show footprint previews in Symbol Chooser"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
sbSizer6->Add( m_footprintPreview, 0, wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_navigatorStaysOpen = new wxCheckBox( sbSizer6->GetStaticBox(), wxID_ANY, _("Keep hierarchy navigator open"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_navigatorStaysOpen->SetValue(true);
|
||||
sbSizer6->Add( m_navigatorStaysOpen, 0, wxALL, 5 );
|
||||
|
||||
|
||||
bRightColumn->Add( sbSizer6, 1, wxEXPAND|wxALL, 5 );
|
||||
|
||||
|
|
|
@ -2870,71 +2870,6 @@
|
|||
<property name="window_style"></property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxCheckBox" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="checked">1</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="drag_accept_files">0</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Keep hierarchy navigator open</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_navigatorStaysOpen</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="subclass">; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="validator_data_type"></property>
|
||||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
|
|
|
@ -80,7 +80,6 @@ class PANEL_EESCHEMA_EDITING_OPTIONS_BASE : public RESETTABLE_PANEL
|
|||
wxStaticText* m_labelIncrementLabel;
|
||||
wxSpinCtrl* m_spinLabelRepeatStep;
|
||||
wxCheckBox* m_footprintPreview;
|
||||
wxCheckBox* m_navigatorStaysOpen;
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <sch_edit_frame.h>
|
||||
#include <sch_painter.h>
|
||||
#include <schematic.h>
|
||||
#include <hierarch.h>
|
||||
#include <settings/app_settings.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <symbol_lib_table.h>
|
||||
|
@ -143,6 +144,8 @@ void SCH_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
|||
// For now, axes are forced off in Eeschema even if turned on in config
|
||||
eeconfig()->m_Window.grid.axes_enabled = false;
|
||||
|
||||
m_showHierarchy = eeconfig()->m_AuiPanels.show_schematic_hierarchy;
|
||||
|
||||
SCH_BASE_FRAME::LoadSettings( eeconfig() );
|
||||
|
||||
GetRenderSettings()->m_ShowPinsElectricalType = false;
|
||||
|
@ -155,7 +158,11 @@ void SCH_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
|||
|
||||
// TODO(JE) do we need to keep m_userUnits around?
|
||||
if( eeconfig() )
|
||||
{
|
||||
eeconfig()->m_System.units = static_cast<int>( m_userUnits );
|
||||
eeconfig()->m_AuiPanels.show_schematic_hierarchy = m_showHierarchy;
|
||||
eeconfig()->m_AuiPanels.left_panel_width = m_hierarchy->GetSize().x;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -88,9 +88,6 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() :
|
|||
m_params.emplace_back( new PARAM<bool>( "appearance.footprint_preview",
|
||||
&m_Appearance.footprint_preview, true ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( "appearance.navigator_stays_open",
|
||||
&m_Appearance.navigator_stays_open, false ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( "appearance.print_sheet_reference",
|
||||
&m_Appearance.print_sheet_reference, true ) );
|
||||
|
||||
|
@ -125,6 +122,12 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() :
|
|||
new PARAM<bool>( "appearance.show_sheet_filename_case_sensitivity_dialog",
|
||||
&m_Appearance.show_sheet_filename_case_sensitivity_dialog, true ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( "aui.show_schematic_hierarchy",
|
||||
&m_AuiPanels.show_schematic_hierarchy, true ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<int>( "aui.left_panel_width",
|
||||
&m_AuiPanels.left_panel_width, -1 ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( "autoplace_fields.enable",
|
||||
&m_AutoplaceFields.enable, true ) );
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ public:
|
|||
wxString edit_label_visible_columns;
|
||||
int erc_severities;
|
||||
bool footprint_preview;
|
||||
bool navigator_stays_open;
|
||||
bool print_sheet_reference;
|
||||
wxString default_font;
|
||||
bool show_hidden_pins;
|
||||
|
@ -65,6 +64,12 @@ public:
|
|||
bool show_sheet_filename_case_sensitivity_dialog;
|
||||
};
|
||||
|
||||
struct AUI_PANELS
|
||||
{
|
||||
int left_panel_width;
|
||||
bool show_schematic_hierarchy;
|
||||
};
|
||||
|
||||
struct AUTOPLACE_FIELDS
|
||||
{
|
||||
bool enable;
|
||||
|
@ -255,6 +260,8 @@ public:
|
|||
|
||||
AUTOPLACE_FIELDS m_AutoplaceFields;
|
||||
|
||||
AUI_PANELS m_AuiPanels;
|
||||
|
||||
DRAWING m_Drawing;
|
||||
|
||||
INPUT m_Input;
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include <tool/actions.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/sch_editor_control.h>
|
||||
#include <tools/sch_navigate_tool.h>
|
||||
#include <trace_helpers.h>
|
||||
#include <widgets/infobar.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
@ -518,6 +519,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
|||
|
||||
UpdateHierarchyNavigator();
|
||||
UpdateTitle();
|
||||
m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->ResetHistory();
|
||||
|
||||
wxFileName fn = Prj().AbsolutePath( GetScreen()->GetFileName() );
|
||||
|
||||
|
|
|
@ -23,29 +23,21 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <id.h>
|
||||
#include <bitmaps.h>
|
||||
#include <dialog_shim.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <sch_sheet_path.h>
|
||||
#include <schematic.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/ee_actions.h>
|
||||
#include <tools/sch_editor_control.h>
|
||||
#include <sch_sheet_path.h>
|
||||
|
||||
#include <hierarch.h>
|
||||
#include <view/view.h>
|
||||
#include <kiface_base.h>
|
||||
#include "eeschema_settings.h"
|
||||
#include <eeschema_settings.h>
|
||||
|
||||
#include <wx/object.h>
|
||||
|
||||
class HIERARCHY_NAVIG_DLG;
|
||||
|
||||
|
||||
/**
|
||||
* Store an SCH_SHEET_PATH of each sheet in hierarchy.
|
||||
|
@ -61,105 +53,12 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
// Need to use wxRTTI macros in order for OnCompareItems to work properly
|
||||
// See: https://docs.wxwidgets.org/3.1/classwx_tree_ctrl.html#ab90a465793c291ca7aa827a576b7d146
|
||||
wxIMPLEMENT_ABSTRACT_CLASS( HIERARCHY_TREE, wxTreeCtrl );
|
||||
|
||||
|
||||
HIERARCHY_TREE::HIERARCHY_TREE( HIERARCHY_NAVIG_DLG* parent ) :
|
||||
wxTreeCtrl( (wxWindow*) parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
||||
wxTR_HAS_BUTTONS, wxDefaultValidator, wxT( "HierachyTreeCtrl" ) )
|
||||
{
|
||||
m_parent = parent;
|
||||
|
||||
// Make an image list containing small icons
|
||||
// All icons are expected having the same size.
|
||||
wxBitmap tree_nosel_bm( KiBitmap( BITMAPS::tree_nosel ) );
|
||||
imageList = new wxImageList( tree_nosel_bm.GetWidth(), tree_nosel_bm.GetHeight(), true, 2 );
|
||||
|
||||
imageList->Add( tree_nosel_bm );
|
||||
imageList->Add( KiBitmap( BITMAPS::tree_sel ) );
|
||||
|
||||
AssignImageList( imageList );
|
||||
}
|
||||
|
||||
|
||||
HIERARCHY_NAVIG_DLG::HIERARCHY_NAVIG_DLG( SCH_EDIT_FRAME* aParent ) :
|
||||
DIALOG_SHIM( aParent, wxID_ANY, _( "Navigator" ), wxDefaultPosition, wxDefaultSize,
|
||||
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER, HIERARCHY_NAVIG_DLG_WNAME )
|
||||
{
|
||||
wxASSERT( dynamic_cast< SCH_EDIT_FRAME* >( aParent ) );
|
||||
|
||||
m_SchFrameEditor = aParent;
|
||||
m_currSheet = aParent->GetCurrentSheet();
|
||||
m_Tree = new HIERARCHY_TREE( this );
|
||||
m_nbsheets = 1;
|
||||
|
||||
// root is the link to the main sheet.
|
||||
wxTreeItemId root = m_Tree->AddRoot( getRootString(), 0, 1 );
|
||||
m_Tree->SetItemBold( root, true );
|
||||
|
||||
m_list.push_back( &m_SchFrameEditor->Schematic().Root() );
|
||||
m_Tree->SetItemData( root, new TreeItemData( m_list ) );
|
||||
|
||||
if( m_SchFrameEditor->GetCurrentSheet().Last() == &m_SchFrameEditor->Schematic().Root() )
|
||||
m_Tree->SelectItem( root );
|
||||
|
||||
buildHierarchyTree( &m_list, &root );
|
||||
|
||||
m_Tree->ExpandAll();
|
||||
|
||||
// This bloc gives a good size to the dialog, better than the default "best" size,
|
||||
// the first time the dialog is opened, during a session
|
||||
wxRect itemrect;
|
||||
wxSize tree_size;
|
||||
|
||||
m_Tree->GetBoundingRect( root, itemrect );
|
||||
|
||||
// Set dialog window size to be large enough
|
||||
tree_size.x = itemrect.GetWidth() + 20;
|
||||
tree_size.x = std::max( tree_size.x, 250 );
|
||||
|
||||
// Readjust the size of the frame to an optimal value.
|
||||
tree_size.y = m_nbsheets * itemrect.GetHeight();
|
||||
|
||||
if( m_nbsheets < 2 )
|
||||
tree_size.y += 10; // gives a better look for small trees
|
||||
|
||||
SetClientSize( tree_size );
|
||||
|
||||
// manage the ESC key to close the dialog, because there is no Cancel button
|
||||
// in dialog
|
||||
m_Tree->Connect( wxEVT_CHAR, wxKeyEventHandler( HIERARCHY_TREE::onChar ) );
|
||||
|
||||
// Manage double click on a selection, or the enter key:
|
||||
Bind( wxEVT_TREE_ITEM_ACTIVATED, &HIERARCHY_NAVIG_DLG::onSelectSheetPath, this );
|
||||
// Manage a simple click on a selection, if the selection changes
|
||||
Bind( wxEVT_TREE_SEL_CHANGED, &HIERARCHY_NAVIG_DLG::onSelectSheetPath, this );
|
||||
|
||||
// Connect close event for the dialog:
|
||||
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( HIERARCHY_NAVIG_DLG::OnCloseNav ) );
|
||||
}
|
||||
|
||||
|
||||
HIERARCHY_NAVIG_DLG::~HIERARCHY_NAVIG_DLG()
|
||||
{
|
||||
Unbind( wxEVT_TREE_ITEM_ACTIVATED, &HIERARCHY_NAVIG_DLG::onSelectSheetPath, this );
|
||||
Unbind( wxEVT_TREE_SEL_CHANGED, &HIERARCHY_NAVIG_DLG::onSelectSheetPath, this );
|
||||
m_Tree->Disconnect( wxEVT_CHAR, wxKeyEventHandler( HIERARCHY_TREE::onChar ) );
|
||||
Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( HIERARCHY_NAVIG_DLG::OnCloseNav ) );
|
||||
}
|
||||
|
||||
|
||||
void HIERARCHY_TREE::onChar( wxKeyEvent& event )
|
||||
{
|
||||
if( event.GetKeyCode() == WXK_ESCAPE )
|
||||
m_parent->Close( true );
|
||||
else
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
int HIERARCHY_TREE::OnCompareItems( const wxTreeItemId& item1, const wxTreeItemId& item2 )
|
||||
{
|
||||
SCH_SHEET_PATH* item1Path = &static_cast<TreeItemData*>( GetItemData( item1 ) )->m_SheetPath;
|
||||
|
@ -169,10 +68,42 @@ int HIERARCHY_TREE::OnCompareItems( const wxTreeItemId& item1, const wxTreeItemI
|
|||
}
|
||||
|
||||
|
||||
void HIERARCHY_NAVIG_DLG::buildHierarchyTree( SCH_SHEET_PATH* aList, wxTreeItemId* aPreviousmenu )
|
||||
HIERARCHY_NAVIG_PANEL::HIERARCHY_NAVIG_PANEL( SCH_EDIT_FRAME* aParent ) : WX_PANEL( aParent )
|
||||
{
|
||||
wxCHECK_RET( m_nbsheets < NB_MAX_SHEET, "Maximum number of sheets exceeded." );
|
||||
wxASSERT( dynamic_cast<SCH_EDIT_FRAME*>( aParent ) );
|
||||
|
||||
m_frame = aParent;
|
||||
|
||||
wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
|
||||
SetSizer( sizer );
|
||||
m_tree = new HIERARCHY_TREE( this );
|
||||
|
||||
// Make an image list containing small icons
|
||||
// All icons are expected having the same size.
|
||||
wxBitmap tree_nosel_bm( KiBitmap( BITMAPS::tree_nosel ) );
|
||||
wxImageList* imageList =
|
||||
new wxImageList( tree_nosel_bm.GetWidth(), tree_nosel_bm.GetHeight(), true, 2 );
|
||||
|
||||
imageList->Add( tree_nosel_bm );
|
||||
imageList->Add( KiBitmap( BITMAPS::tree_sel ) );
|
||||
|
||||
m_tree->AssignImageList( imageList );
|
||||
|
||||
sizer->Add( m_tree, 1, wxEXPAND, wxBORDER_NONE, 0 );
|
||||
|
||||
UpdateHierarchyTree();
|
||||
}
|
||||
|
||||
|
||||
HIERARCHY_NAVIG_PANEL::~HIERARCHY_NAVIG_PANEL()
|
||||
{
|
||||
Unbind( wxEVT_TREE_ITEM_ACTIVATED, &HIERARCHY_NAVIG_PANEL::onSelectSheetPath, this );
|
||||
Unbind( wxEVT_TREE_SEL_CHANGED, &HIERARCHY_NAVIG_PANEL::onSelectSheetPath, this );
|
||||
}
|
||||
|
||||
|
||||
void HIERARCHY_NAVIG_PANEL::buildHierarchyTree( SCH_SHEET_PATH* aList, const wxTreeItemId& aParent )
|
||||
{
|
||||
std::vector<SCH_ITEM*> sheetChildren;
|
||||
aList->LastScreen()->GetSheets( &sheetChildren );
|
||||
|
||||
|
@ -183,86 +114,87 @@ void HIERARCHY_NAVIG_DLG::buildHierarchyTree( SCH_SHEET_PATH* aList, wxTreeItemI
|
|||
|
||||
wxString sheetName = formatPageString( sheet->GetFields()[SHEETNAME].GetShownText(),
|
||||
sheet->GetPageNumber( *aList ) );
|
||||
m_nbsheets++;
|
||||
wxTreeItemId menu;
|
||||
menu = m_Tree->AppendItem( *aPreviousmenu, sheetName, 0, 1 );
|
||||
m_Tree->SetItemData( menu, new TreeItemData( *aList ) );
|
||||
wxTreeItemId child = m_tree->AppendItem( aParent, sheetName, 0, 1 );
|
||||
m_tree->SetItemData( child, new TreeItemData( *aList ) );
|
||||
|
||||
if( *aList == m_currSheet )
|
||||
{
|
||||
m_Tree->EnsureVisible( menu );
|
||||
m_Tree->SelectItem( menu );
|
||||
}
|
||||
|
||||
buildHierarchyTree( aList, &menu );
|
||||
buildHierarchyTree( aList, child );
|
||||
aList->pop_back();
|
||||
|
||||
if( m_nbsheets >= NB_MAX_SHEET )
|
||||
break;
|
||||
}
|
||||
|
||||
m_Tree->SortChildren( *aPreviousmenu );
|
||||
m_tree->SortChildren( aParent );
|
||||
}
|
||||
|
||||
|
||||
void HIERARCHY_NAVIG_DLG::UpdateHierarchyTree()
|
||||
void HIERARCHY_NAVIG_PANEL::UpdateHierarchySelection()
|
||||
{
|
||||
std::function<void( const wxTreeItemId& )> selectSheet = [&]( const wxTreeItemId& id )
|
||||
{
|
||||
wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
|
||||
|
||||
TreeItemData* itemData = static_cast<TreeItemData*>( m_tree->GetItemData( id ) );
|
||||
if( itemData->m_SheetPath == m_frame->GetCurrentSheet() )
|
||||
{
|
||||
m_tree->EnsureVisible( id );
|
||||
m_tree->SelectItem( id );
|
||||
}
|
||||
|
||||
wxTreeItemIdValue cookie;
|
||||
wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
|
||||
while( child.IsOk() )
|
||||
{
|
||||
selectSheet( child );
|
||||
child = m_tree->GetNextChild( id, cookie );
|
||||
}
|
||||
};
|
||||
|
||||
selectSheet( m_tree->GetRootItem() );
|
||||
}
|
||||
|
||||
|
||||
void HIERARCHY_NAVIG_PANEL::UpdateHierarchyTree()
|
||||
{
|
||||
Freeze();
|
||||
|
||||
// Disable selection events
|
||||
Unbind( wxEVT_TREE_ITEM_ACTIVATED, &HIERARCHY_NAVIG_DLG::onSelectSheetPath, this );
|
||||
Unbind( wxEVT_TREE_SEL_CHANGED, &HIERARCHY_NAVIG_DLG::onSelectSheetPath, this );
|
||||
|
||||
m_currSheet = m_SchFrameEditor->GetCurrentSheet();
|
||||
m_Tree->DeleteAllItems();
|
||||
m_nbsheets = 1;
|
||||
|
||||
wxTreeItemId root = m_Tree->AddRoot( getRootString(), 0, 1 );
|
||||
m_Tree->SetItemBold( root, true );
|
||||
Unbind( wxEVT_TREE_ITEM_ACTIVATED, &HIERARCHY_NAVIG_PANEL::onSelectSheetPath, this );
|
||||
Unbind( wxEVT_TREE_SEL_CHANGED, &HIERARCHY_NAVIG_PANEL::onSelectSheetPath, this );
|
||||
|
||||
m_list.clear();
|
||||
m_list.push_back( &m_SchFrameEditor->Schematic().Root() );
|
||||
m_Tree->SetItemData( root, new TreeItemData( m_list ) );
|
||||
m_list.push_back( &m_frame->Schematic().Root() );
|
||||
|
||||
if( m_SchFrameEditor->GetCurrentSheet().Last() == &m_SchFrameEditor->Schematic().Root() )
|
||||
m_Tree->SelectItem( root );
|
||||
m_tree->DeleteAllItems();
|
||||
|
||||
buildHierarchyTree( &m_list, &root );
|
||||
m_Tree->ExpandAll();
|
||||
wxTreeItemId root = m_tree->AddRoot( getRootString(), 0, 1 );
|
||||
m_tree->SetItemBold( root, true );
|
||||
m_tree->SetItemData( root, new TreeItemData( m_list ) );
|
||||
|
||||
buildHierarchyTree( &m_list, root );
|
||||
UpdateHierarchySelection();
|
||||
|
||||
m_tree->ExpandAll();
|
||||
|
||||
// Enable selection events
|
||||
Bind( wxEVT_TREE_ITEM_ACTIVATED, &HIERARCHY_NAVIG_DLG::onSelectSheetPath, this );
|
||||
Bind( wxEVT_TREE_SEL_CHANGED, &HIERARCHY_NAVIG_DLG::onSelectSheetPath, this );
|
||||
Bind( wxEVT_TREE_ITEM_ACTIVATED, &HIERARCHY_NAVIG_PANEL::onSelectSheetPath, this );
|
||||
Bind( wxEVT_TREE_SEL_CHANGED, &HIERARCHY_NAVIG_PANEL::onSelectSheetPath, this );
|
||||
|
||||
Thaw();
|
||||
}
|
||||
|
||||
|
||||
void HIERARCHY_NAVIG_DLG::onSelectSheetPath( wxTreeEvent& event )
|
||||
void HIERARCHY_NAVIG_PANEL::onSelectSheetPath( wxTreeEvent& event )
|
||||
{
|
||||
m_SchFrameEditor->GetToolManager()->RunAction( ACTIONS::cancelInteractive, true );
|
||||
m_SchFrameEditor->GetToolManager()->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
wxTreeItemId itemSel = m_tree->GetSelection();
|
||||
TreeItemData* itemData = static_cast<TreeItemData*>( m_tree->GetItemData( itemSel ) );
|
||||
|
||||
wxTreeItemId itemSel = m_Tree->GetSelection();
|
||||
TreeItemData* itemData = static_cast<TreeItemData*>( m_Tree->GetItemData( itemSel ) );
|
||||
|
||||
// Store the current zoom level into the current screen before switching
|
||||
m_SchFrameEditor->GetScreen()->m_LastZoomLevel =
|
||||
m_SchFrameEditor->GetCanvas()->GetView()->GetScale();
|
||||
|
||||
m_SchFrameEditor->SetCurrentSheet( itemData->m_SheetPath );
|
||||
m_SchFrameEditor->DisplayCurrentSheet();
|
||||
|
||||
EESCHEMA_SETTINGS* appSettings = static_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
|
||||
|
||||
if( !appSettings->m_Appearance.navigator_stays_open )
|
||||
Close( true );
|
||||
SetCursor( wxCURSOR_ARROWWAIT );
|
||||
m_frame->GetToolManager()->RunAction( EE_ACTIONS::changeSheet, true, &itemData->m_SheetPath );
|
||||
SetCursor( wxCURSOR_ARROW );
|
||||
}
|
||||
|
||||
|
||||
wxString HIERARCHY_NAVIG_DLG::getRootString()
|
||||
wxString HIERARCHY_NAVIG_PANEL::getRootString()
|
||||
{
|
||||
SCH_SHEET* rootSheet = &m_SchFrameEditor->Schematic().Root();
|
||||
SCH_SHEET* rootSheet = &m_frame->Schematic().Root();
|
||||
SCH_SHEET_PATH rootPath;
|
||||
rootPath.push_back( rootSheet );
|
||||
|
||||
|
@ -270,50 +202,7 @@ wxString HIERARCHY_NAVIG_DLG::getRootString()
|
|||
}
|
||||
|
||||
|
||||
wxString HIERARCHY_NAVIG_DLG::formatPageString( const wxString& aName, const wxString& aPage )
|
||||
wxString HIERARCHY_NAVIG_PANEL::formatPageString( const wxString& aName, const wxString& aPage )
|
||||
{
|
||||
return aName + wxT( " " ) + wxString::Format( _( "(page %s)" ), aPage );
|
||||
}
|
||||
|
||||
|
||||
void HIERARCHY_NAVIG_DLG::OnCloseNav( wxCloseEvent& event )
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::DisplayCurrentSheet()
|
||||
{
|
||||
m_toolManager->RunAction( ACTIONS::cancelInteractive, true );
|
||||
m_toolManager->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
SCH_SCREEN* screen = GetCurrentSheet().LastScreen();
|
||||
|
||||
wxASSERT( screen );
|
||||
|
||||
SetScreen( screen );
|
||||
|
||||
// update the References
|
||||
GetCurrentSheet().UpdateAllScreenReferences();
|
||||
SetSheetNumberAndCount();
|
||||
|
||||
if( !screen->m_zoomInitialized )
|
||||
{
|
||||
initScreenZoom();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set zoom to last used in this screen
|
||||
GetCanvas()->GetView()->SetScale( GetScreen()->m_LastZoomLevel );
|
||||
RedrawScreen( (wxPoint) GetScreen()->m_ScrollCenter, false );
|
||||
}
|
||||
|
||||
UpdateTitle();
|
||||
|
||||
HardRedraw(); // Ensure all items are redrawn (especially the drawing-sheet items)
|
||||
|
||||
SCH_EDITOR_CONTROL* editTool = m_toolManager->GetTool<SCH_EDITOR_CONTROL>();
|
||||
TOOL_EVENT dummy;
|
||||
editTool->UpdateNetHighlighting( dummy );
|
||||
|
||||
UpdateHierarchyNavigator();
|
||||
}
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2022 Mike Williams <mike at mikebwilliams.com>
|
||||
* Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -31,25 +32,29 @@
|
|||
#include <wx/imaglist.h>
|
||||
#include <wx/object.h> // wxRTTI macros
|
||||
#include <wx/treectrl.h>
|
||||
#include <widgets/wx_panel.h>
|
||||
|
||||
// The window name of the hierarchy navigator, used to find it
|
||||
#define HIERARCHY_NAVIG_DLG_WNAME "hierarchy_navig_dlg"
|
||||
|
||||
class SCH_EDIT_FRAME;
|
||||
class SCH_SHEET_PATH;
|
||||
|
||||
class HIERARCHY_NAVIG_DLG;
|
||||
class HIERARCHY_NAVIG_PANEL;
|
||||
|
||||
|
||||
/**
|
||||
* Handle hierarchy tree control.
|
||||
* Navigation hierarchy tree control.
|
||||
*
|
||||
* wxTreeCtrl must be subclassed to implement the OnCompareItems method
|
||||
* to sort according to page numbers.
|
||||
*/
|
||||
class HIERARCHY_TREE : public wxTreeCtrl
|
||||
{
|
||||
public:
|
||||
HIERARCHY_TREE( HIERARCHY_NAVIG_DLG* parent );
|
||||
|
||||
// Closes the dialog on escape key
|
||||
void onChar( wxKeyEvent& event );
|
||||
HIERARCHY_TREE( HIERARCHY_NAVIG_PANEL* parent ) :
|
||||
wxTreeCtrl( (wxWindow*) parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
||||
wxTR_HAS_BUTTONS, wxDefaultValidator, wxT( "HierachyTreeCtrl" ) )
|
||||
{
|
||||
}
|
||||
|
||||
int OnCompareItems( const wxTreeItemId& item1, const wxTreeItemId& item2 ) override;
|
||||
|
||||
|
@ -57,25 +62,26 @@ private:
|
|||
// Need to use wxRTTI macros in order for OnCompareItems to work properly
|
||||
// See: https://docs.wxwidgets.org/3.1/classwx_tree_ctrl.html#ab90a465793c291ca7aa827a576b7d146
|
||||
wxDECLARE_ABSTRACT_CLASS( HIERARCHY_TREE );
|
||||
|
||||
HIERARCHY_NAVIG_DLG* m_parent;
|
||||
wxImageList* imageList;
|
||||
};
|
||||
|
||||
class HIERARCHY_NAVIG_DLG : public DIALOG_SHIM
|
||||
|
||||
class HIERARCHY_NAVIG_PANEL : public WX_PANEL
|
||||
{
|
||||
public:
|
||||
HIERARCHY_NAVIG_DLG( SCH_EDIT_FRAME* aParent );
|
||||
HIERARCHY_NAVIG_PANEL( SCH_EDIT_FRAME* aParent );
|
||||
|
||||
~HIERARCHY_NAVIG_DLG();
|
||||
|
||||
void OnCloseNav( wxCloseEvent& event );
|
||||
~HIERARCHY_NAVIG_PANEL();
|
||||
|
||||
/**
|
||||
* Update the hierarchical tree of the schematic.
|
||||
*/
|
||||
void UpdateHierarchyTree();
|
||||
|
||||
/**
|
||||
* Updates the tree's selection to match current page
|
||||
*/
|
||||
void UpdateHierarchySelection();
|
||||
|
||||
private:
|
||||
/**
|
||||
* Create the hierarchical tree of the schematic.
|
||||
|
@ -85,7 +91,7 @@ private:
|
|||
* @param[in] aList is the #SCH_SHEET_PATH list to explore.
|
||||
* @param aPreviousmenu is the wxTreeItemId used as parent to add sub items.
|
||||
*/
|
||||
void buildHierarchyTree( SCH_SHEET_PATH* aList, wxTreeItemId* aPreviousmenu );
|
||||
void buildHierarchyTree( SCH_SHEET_PATH* aList, const wxTreeItemId& aParent );
|
||||
|
||||
/**
|
||||
* Open the selected sheet and display the corresponding screen when a tree item is
|
||||
|
@ -103,11 +109,9 @@ private:
|
|||
*/
|
||||
wxString formatPageString( const wxString& aName, const wxString& aPage );
|
||||
|
||||
SCH_SHEET_PATH m_currSheet;
|
||||
SCH_SHEET_PATH m_list;
|
||||
SCH_EDIT_FRAME* m_SchFrameEditor;
|
||||
HIERARCHY_TREE* m_Tree;
|
||||
int m_nbsheets;
|
||||
SCH_EDIT_FRAME* m_frame;
|
||||
HIERARCHY_TREE* m_tree;
|
||||
};
|
||||
|
||||
#endif // HIERARCH_H
|
||||
|
|
|
@ -167,8 +167,12 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
|
|||
ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
|
||||
|
||||
viewMenu->Add( ACTIONS::showSymbolBrowser );
|
||||
viewMenu->Add( EE_ACTIONS::navigateHierarchy );
|
||||
viewMenu->Add( EE_ACTIONS::leaveSheet );
|
||||
viewMenu->Add( EE_ACTIONS::showHierarchy, ACTION_MENU::CHECK );
|
||||
viewMenu->Add( EE_ACTIONS::navigateBack );
|
||||
viewMenu->Add( EE_ACTIONS::navigateUp );
|
||||
viewMenu->Add( EE_ACTIONS::navigateForward );
|
||||
viewMenu->Add( EE_ACTIONS::navigatePrevious );
|
||||
viewMenu->Add( EE_ACTIONS::navigateNext );
|
||||
|
||||
viewMenu->AppendSeparator();
|
||||
viewMenu->Add( ACTIONS::zoomInCenter );
|
||||
|
|
|
@ -84,6 +84,7 @@
|
|||
#include <wx/app.h>
|
||||
#include <wx/filedlg.h>
|
||||
#include <wx/socket.h>
|
||||
#include <widgets/wx_aui_utils.h>
|
||||
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
#include <drawing_sheet/ds_proxy_view_item.h>
|
||||
|
@ -220,6 +221,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
m_schematic = new SCHEMATIC( nullptr );
|
||||
|
||||
m_showBorderAndTitleBlock = true; // true to show sheet references
|
||||
m_showHierarchy = true;
|
||||
m_supportsAutoSave = true;
|
||||
m_aboutTitle = _( "KiCad Schematic Editor" );
|
||||
|
||||
|
@ -250,6 +252,8 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
ReCreateVToolbar();
|
||||
ReCreateOptToolbar();
|
||||
|
||||
m_hierarchy = new HIERARCHY_NAVIG_PANEL( this );
|
||||
|
||||
// Initialize common print setup dialog settings.
|
||||
m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
|
||||
m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
|
||||
|
@ -262,7 +266,12 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" )
|
||||
.Top().Layer( 6 ) );
|
||||
m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
|
||||
.Left().Layer( 3 ) );
|
||||
.Left().Layer( 4 ) );
|
||||
m_auimgr.AddPane( m_hierarchy, EDA_PANE().Palette().Name( "SchematicHierarchy" )
|
||||
.Caption( _("Schematic Hierarchy") )
|
||||
.Left().Layer( 3 )
|
||||
.MinSize(120, -1)
|
||||
.BestSize(200, -1));
|
||||
m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
|
||||
.Right().Layer( 2 ) );
|
||||
m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" )
|
||||
|
@ -279,6 +288,12 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
|
||||
initScreenZoom();
|
||||
|
||||
wxAuiPaneInfo& hierarchy = m_auimgr.GetPane( "SchematicHierarchy" );
|
||||
hierarchy.Show( m_showHierarchy );
|
||||
|
||||
if( eeconfig() && ( eeconfig()->m_AuiPanels.left_panel_width > 0 ) )
|
||||
SetAuiPaneSize( m_auimgr, hierarchy, eeconfig()->m_AuiPanels.left_panel_width, -1 );
|
||||
|
||||
// This is used temporarily to fix a client size issue on GTK that causes zoom to fit
|
||||
// to calculate the wrong zoom size. See SCH_EDIT_FRAME::onSize().
|
||||
Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
|
||||
|
@ -297,6 +312,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
DefaultExecFlags();
|
||||
|
||||
UpdateTitle();
|
||||
m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->ResetHistory();
|
||||
|
||||
// Default shutdown reason until a file is loaded
|
||||
KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New schematic file is unsaved" ) );
|
||||
|
@ -346,6 +362,8 @@ SCH_EDIT_FRAME::~SCH_EDIT_FRAME()
|
|||
wxLogError( wxT( "Settings exception '%s' occurred." ), exc.what() );
|
||||
}
|
||||
}
|
||||
|
||||
delete m_hierarchy;
|
||||
}
|
||||
|
||||
|
||||
|
@ -397,6 +415,13 @@ void SCH_EDIT_FRAME::setupUIConditions()
|
|||
( !GetScreen()->Items().empty() || !SELECTION_CONDITIONS::Idle( aSel ) );
|
||||
};
|
||||
|
||||
auto hierarchyNavigatorCond =
|
||||
[ this ] ( const SELECTION& aSel )
|
||||
{
|
||||
return m_auimgr.GetPane( "SchematicHierarchy" ).IsShown();
|
||||
};
|
||||
|
||||
|
||||
#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
|
||||
#define CHECK( x ) ACTION_CONDITIONS().Check( x )
|
||||
|
||||
|
@ -404,6 +429,8 @@ void SCH_EDIT_FRAME::setupUIConditions()
|
|||
mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
|
||||
mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
|
||||
|
||||
mgr->SetConditions( EE_ACTIONS::showHierarchy, CHECK( hierarchyNavigatorCond ) );
|
||||
|
||||
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
|
||||
mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) );
|
||||
mgr->SetConditions( ACTIONS::millimetersUnits,
|
||||
|
@ -493,10 +520,39 @@ void SCH_EDIT_FRAME::setupUIConditions()
|
|||
auto belowRootSheetCondition =
|
||||
[this]( const SELECTION& aSel )
|
||||
{
|
||||
return GetCurrentSheet().Last() != &Schematic().Root();
|
||||
return m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->CanGoUp();
|
||||
};
|
||||
|
||||
auto navHistoryHasForward =
|
||||
[this]( const SELECTION& aSel )
|
||||
{
|
||||
return m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->CanGoForward();
|
||||
};
|
||||
|
||||
auto navHistoryHasBackward =
|
||||
[this]( const SELECTION& aSel )
|
||||
{
|
||||
return m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->CanGoBack();
|
||||
};
|
||||
|
||||
auto navSchematicHasPreviousSheet =
|
||||
[this]( const SELECTION& aSel )
|
||||
{
|
||||
return m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->CanGoPrevious();
|
||||
};
|
||||
|
||||
auto navSchematicHasNextSheet =
|
||||
[this]( const SELECTION& aSel )
|
||||
{
|
||||
return m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->CanGoNext();
|
||||
};
|
||||
|
||||
mgr->SetConditions( EE_ACTIONS::leaveSheet, ENABLE( belowRootSheetCondition ) );
|
||||
mgr->SetConditions( EE_ACTIONS::navigateUp, ENABLE( belowRootSheetCondition ) );
|
||||
mgr->SetConditions( EE_ACTIONS::navigateForward, ENABLE( navHistoryHasForward ) );
|
||||
mgr->SetConditions( EE_ACTIONS::navigateBack, ENABLE( navHistoryHasBackward ) );
|
||||
mgr->SetConditions( EE_ACTIONS::navigatePrevious, ENABLE( navSchematicHasPreviousSheet ) );
|
||||
mgr->SetConditions( EE_ACTIONS::navigateNext, ENABLE( navSchematicHasNextSheet ) );
|
||||
mgr->SetConditions( EE_ACTIONS::remapSymbols, ENABLE( remapSymbolsCondition ) );
|
||||
mgr->SetConditions( EE_ACTIONS::toggleHiddenPins, CHECK( showHiddenPinsCond ) );
|
||||
mgr->SetConditions( EE_ACTIONS::toggleHiddenFields, CHECK( showHiddenFieldsCond ) );
|
||||
|
@ -776,9 +832,6 @@ void SCH_EDIT_FRAME::doCloseWindow()
|
|||
m_findReplaceDialog = nullptr;
|
||||
}
|
||||
|
||||
if( FindHierarchyNavigator() )
|
||||
FindHierarchyNavigator()->Close( true );
|
||||
|
||||
if( Kiway().Player( FRAME_SIMULATOR, false ) )
|
||||
Prj().GetProjectFile().m_SchematicSettings->m_NgspiceSimulatorSettings->SaveToFile();
|
||||
|
||||
|
@ -939,30 +992,10 @@ void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
HIERARCHY_NAVIG_DLG* SCH_EDIT_FRAME::FindHierarchyNavigator()
|
||||
void SCH_EDIT_FRAME::UpdateHierarchyNavigator()
|
||||
{
|
||||
wxWindow* navigator = wxWindow::FindWindowByName( HIERARCHY_NAVIG_DLG_WNAME );
|
||||
|
||||
return static_cast< HIERARCHY_NAVIG_DLG* >( navigator );
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::UpdateHierarchyNavigator( bool aForceUpdate )
|
||||
{
|
||||
if( aForceUpdate )
|
||||
{
|
||||
if( FindHierarchyNavigator() )
|
||||
FindHierarchyNavigator()->Close();
|
||||
|
||||
HIERARCHY_NAVIG_DLG* hierarchyDialog = new HIERARCHY_NAVIG_DLG( this );
|
||||
|
||||
hierarchyDialog->Show( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( FindHierarchyNavigator() )
|
||||
FindHierarchyNavigator()->UpdateHierarchyTree();
|
||||
}
|
||||
m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->CleanHistory();
|
||||
m_hierarchy->UpdateHierarchyTree();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1827,3 +1860,40 @@ void SCH_EDIT_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aUpda
|
|||
if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( aItem ) )
|
||||
sch_item->ClearCaches();
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::DisplayCurrentSheet()
|
||||
{
|
||||
m_toolManager->RunAction( ACTIONS::cancelInteractive, true );
|
||||
m_toolManager->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
SCH_SCREEN* screen = GetCurrentSheet().LastScreen();
|
||||
|
||||
wxASSERT( screen );
|
||||
|
||||
SetScreen( screen );
|
||||
|
||||
// update the References
|
||||
GetCurrentSheet().UpdateAllScreenReferences();
|
||||
SetSheetNumberAndCount();
|
||||
|
||||
if( !screen->m_zoomInitialized )
|
||||
{
|
||||
initScreenZoom();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set zoom to last used in this screen
|
||||
GetCanvas()->GetView()->SetScale( GetScreen()->m_LastZoomLevel );
|
||||
RedrawScreen( (wxPoint) GetScreen()->m_ScrollCenter, false );
|
||||
}
|
||||
|
||||
UpdateTitle();
|
||||
|
||||
HardRedraw(); // Ensure all items are redrawn (especially the drawing-sheet items)
|
||||
|
||||
SCH_EDITOR_CONTROL* editTool = m_toolManager->GetTool<SCH_EDITOR_CONTROL>();
|
||||
TOOL_EVENT dummy;
|
||||
editTool->UpdateNetHighlighting( dummy );
|
||||
|
||||
m_hierarchy->UpdateHierarchySelection();
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ class SCHEMATIC;
|
|||
class DIALOG_SCH_FIND;
|
||||
class wxFindReplaceData;
|
||||
class RESCUER;
|
||||
class HIERARCHY_NAVIG_DLG;
|
||||
class HIERARCHY_NAVIG_PANEL;
|
||||
|
||||
// @todo Move this to transform alone with all of the transform manipulation code.
|
||||
/// enum used in RotationMiroir()
|
||||
|
@ -232,16 +232,9 @@ public:
|
|||
void ShowFindReplaceDialog( bool aReplace );
|
||||
|
||||
/**
|
||||
* Run the Hierarchy Navigator dialog.
|
||||
* @param aForceUpdate: When true, creates a new dialog. And if a dialog
|
||||
* already exist, it destroys it first.
|
||||
* Update the hierarchy navigation tree and history
|
||||
*/
|
||||
void UpdateHierarchyNavigator( bool aForceUpdate = false );
|
||||
|
||||
/**
|
||||
* @return a reference to the Hierarchy Navigator dialog if exists, or nullptr.
|
||||
*/
|
||||
HIERARCHY_NAVIG_DLG* FindHierarchyNavigator();
|
||||
void UpdateHierarchyNavigator();
|
||||
|
||||
void ShowFindReplaceStatus( const wxString& aMsg, int aStatusTime );
|
||||
void ClearFindReplaceStatus();
|
||||
|
@ -834,6 +827,12 @@ public:
|
|||
*/
|
||||
virtual void CheckForAutoSaveFile( const wxFileName& aFileName ) override;
|
||||
|
||||
|
||||
/**
|
||||
* Toggle the show/hide state of the left side schematic navigation panel
|
||||
*/
|
||||
void ToggleSchematicHierarchy();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
protected:
|
||||
|
@ -940,6 +939,9 @@ private:
|
|||
///< to call a custom net list generator.
|
||||
|
||||
DIALOG_SCH_FIND* m_findReplaceDialog;
|
||||
|
||||
HIERARCHY_NAVIG_PANEL* m_hierarchy;
|
||||
bool m_showHierarchy;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -73,9 +73,6 @@ enum SCH_LINE_TEST_T
|
|||
};
|
||||
|
||||
|
||||
/// Max number of sheets in a hierarchy project
|
||||
#define NB_MAX_SHEET 500
|
||||
|
||||
struct PICKED_SYMBOL
|
||||
{
|
||||
LIB_ID LibId;
|
||||
|
|
|
@ -30,11 +30,13 @@
|
|||
#include <kiface_base.h>
|
||||
#include <bitmaps.h>
|
||||
#include <eeschema_id.h>
|
||||
#include <hierarch.h>
|
||||
#include <python_scripting.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tool/action_toolbar.h>
|
||||
#include <tools/ee_actions.h>
|
||||
#include <tools/ee_selection_tool.h>
|
||||
#include <widgets/wx_aui_utils.h>
|
||||
|
||||
/* Create the main Horizontal Toolbar for the schematic editor
|
||||
*/
|
||||
|
@ -89,8 +91,9 @@ void SCH_EDIT_FRAME::ReCreateHToolbar()
|
|||
m_mainToolBar->Add( ACTIONS::zoomTool, ACTION_TOOLBAR::TOGGLE, ACTION_TOOLBAR::CANCEL );
|
||||
|
||||
m_mainToolBar->AddScaledSeparator( this );
|
||||
m_mainToolBar->Add( EE_ACTIONS::navigateHierarchy );
|
||||
m_mainToolBar->Add( EE_ACTIONS::leaveSheet );
|
||||
m_mainToolBar->Add( EE_ACTIONS::navigateBack );
|
||||
m_mainToolBar->Add( EE_ACTIONS::navigateUp );
|
||||
m_mainToolBar->Add( EE_ACTIONS::navigateForward );
|
||||
|
||||
m_mainToolBar->AddScaledSeparator( this );
|
||||
m_mainToolBar->Add( EE_ACTIONS::rotateCCW );
|
||||
|
@ -217,3 +220,22 @@ void SCH_EDIT_FRAME::ReCreateOptToolbar()
|
|||
|
||||
m_optionsToolBar->KiRealize();
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::ToggleSchematicHierarchy()
|
||||
{
|
||||
EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
|
||||
wxAuiPaneInfo& hierarchy = m_auimgr.GetPane( "SchematicHierarchy" );
|
||||
|
||||
// show auxiliary Vertical layers and visibility manager toolbar
|
||||
m_showHierarchy = !m_showHierarchy;
|
||||
hierarchy.Show( m_showHierarchy );
|
||||
|
||||
if( m_showHierarchy && cfg )
|
||||
SetAuiPaneSize( m_auimgr, hierarchy, cfg->m_AuiPanels.left_panel_width, -1 );
|
||||
else
|
||||
{
|
||||
cfg->m_AuiPanels.left_panel_width = m_hierarchy->GetSize().x;
|
||||
m_auimgr.Update();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -728,6 +728,11 @@ TOOL_ACTION EE_ACTIONS::showPythonConsole( "eeschema.EditorControl.showPythonCon
|
|||
|
||||
// SCH_NAVIGATE_TOOL
|
||||
//
|
||||
TOOL_ACTION EE_ACTIONS::changeSheet( "eeschema.NavigateTool.changeSheet",
|
||||
AS_GLOBAL, 0, "",
|
||||
_( "Enter Sheet" ), _( "Change to provided sheet's contents in the schematic editor" ),
|
||||
BITMAPS::enter_sheet );
|
||||
|
||||
TOOL_ACTION EE_ACTIONS::enterSheet( "eeschema.NavigateTool.enterSheet",
|
||||
AS_GLOBAL, 0, "",
|
||||
_( "Enter Sheet" ), _( "Display the selected sheet's contents in the schematic editor" ),
|
||||
|
@ -739,8 +744,38 @@ TOOL_ACTION EE_ACTIONS::leaveSheet( "eeschema.NavigateTool.leaveSheet",
|
|||
_( "Leave Sheet" ), _( "Display the parent sheet in the schematic editor" ),
|
||||
BITMAPS::leave_sheet );
|
||||
|
||||
TOOL_ACTION EE_ACTIONS::navigateHierarchy( "eeschema.NavigateTool.navigateHierarchy",
|
||||
AS_GLOBAL, 0, "",
|
||||
TOOL_ACTION EE_ACTIONS::navigateUp( "eeschema.NavigateTool.up",
|
||||
AS_GLOBAL, MD_ALT + WXK_UP, "",
|
||||
_( "Navigate Up" ), _( "Navigate up one sheet in the hierarchy" ),
|
||||
BITMAPS::up );
|
||||
|
||||
TOOL_ACTION EE_ACTIONS::navigateBack( "eeschema.NavigateTool.back",
|
||||
AS_GLOBAL,
|
||||
MD_ALT + WXK_LEFT, "",
|
||||
_( "Navigate Back" ), _( "Move forward in sheet navigation history" ),
|
||||
BITMAPS::left );
|
||||
|
||||
TOOL_ACTION EE_ACTIONS::navigateForward( "eeschema.NavigateTool.forward",
|
||||
AS_GLOBAL,
|
||||
MD_ALT + WXK_RIGHT, "",
|
||||
_( "Navigate Forward" ), _( "Move backward in sheet navigation history" ),
|
||||
BITMAPS::right );
|
||||
|
||||
TOOL_ACTION EE_ACTIONS::navigatePrevious( "eeschema.NavigateTool.previous",
|
||||
AS_GLOBAL,
|
||||
WXK_PAGEUP, "",
|
||||
_( "Previous Sheet" ), _( "Move to previous sheet by number" ),
|
||||
BITMAPS::left );
|
||||
|
||||
TOOL_ACTION EE_ACTIONS::navigateNext( "eeschema.NavigateTool.next",
|
||||
AS_GLOBAL,
|
||||
WXK_PAGEDOWN, "",
|
||||
_( "Next Sheet" ), _( "Move to next sheet by number" ),
|
||||
BITMAPS::right );
|
||||
|
||||
TOOL_ACTION EE_ACTIONS::showHierarchy( "eeschema.EditorTool.showHierarchy",
|
||||
AS_GLOBAL,
|
||||
MD_CTRL + 'H', "",
|
||||
_( "Hierarchy Navigator" ), _( "Show schematic sheet hierarchy" ),
|
||||
BITMAPS::hierarchy_nav );
|
||||
|
||||
|
|
|
@ -88,6 +88,7 @@ public:
|
|||
static TOOL_ACTION placeGlobalLabel;
|
||||
static TOOL_ACTION placeHierLabel;
|
||||
static TOOL_ACTION drawSheet;
|
||||
static TOOL_ACTION importSingleSheetPin;
|
||||
static TOOL_ACTION importSheetPin;
|
||||
static TOOL_ACTION placeSchematicText;
|
||||
static TOOL_ACTION drawTextBox;
|
||||
|
@ -189,11 +190,16 @@ public:
|
|||
static TOOL_ACTION updateSymbolFields;
|
||||
|
||||
// Hierarchy navigation
|
||||
static TOOL_ACTION changeSheet;
|
||||
static TOOL_ACTION enterSheet;
|
||||
static TOOL_ACTION leaveSheet;
|
||||
static TOOL_ACTION navigateHierarchy;
|
||||
static TOOL_ACTION navigateUp;
|
||||
static TOOL_ACTION navigateForward;
|
||||
static TOOL_ACTION navigateBack;
|
||||
static TOOL_ACTION navigatePrevious;
|
||||
static TOOL_ACTION navigateNext;
|
||||
static TOOL_ACTION showHierarchy;
|
||||
static TOOL_ACTION hypertextCommand;
|
||||
static TOOL_ACTION importSingleSheetPin;
|
||||
|
||||
// Global edit tools
|
||||
static TOOL_ACTION cleanupSheetPins;
|
||||
|
|
|
@ -535,6 +535,14 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
}
|
||||
}
|
||||
else if( evt->IsMouseDown( BUT_AUX1 ) )
|
||||
{
|
||||
m_toolMgr->RunAction( EE_ACTIONS::navigateBack, true );
|
||||
}
|
||||
else if( evt->IsMouseDown( BUT_AUX2 ) )
|
||||
{
|
||||
m_toolMgr->RunAction( EE_ACTIONS::navigateForward, true );
|
||||
}
|
||||
else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CHOICE_MENU_CHOICE )
|
||||
{
|
||||
m_disambiguateTimer.Stop();
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
#include <tools/ee_selection.h>
|
||||
#include <tools/ee_selection_tool.h>
|
||||
#include <tools/sch_editor_control.h>
|
||||
#include <tools/sch_navigate_tool.h>
|
||||
#include <drawing_sheet/ds_proxy_undo_item.h>
|
||||
#include <dialog_update_from_pcb.h>
|
||||
#include <eda_list_dialog.h>
|
||||
|
@ -316,13 +317,6 @@ int SCH_EDITOR_CONTROL::FindAndReplace( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
int SCH_EDITOR_CONTROL::NavigateHierarchy( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_frame->UpdateHierarchyNavigator( true );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int SCH_EDITOR_CONTROL::UpdateFind( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
wxFindReplaceData& data = m_frame->GetFindReplaceData();
|
||||
|
@ -2112,43 +2106,9 @@ int SCH_EDITOR_CONTROL::ShowBusManager( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
int SCH_EDITOR_CONTROL::EnterSheet( const TOOL_EVENT& aEvent )
|
||||
int SCH_EDITOR_CONTROL::ShowHierarchy( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
const EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
|
||||
|
||||
if( selection.GetSize() == 1 )
|
||||
{
|
||||
SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
|
||||
|
||||
m_toolMgr->RunAction( ACTIONS::cancelInteractive, true );
|
||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
|
||||
// Store the current zoom level into the current screen before switching
|
||||
m_frame->GetScreen()->m_LastZoomLevel = m_frame->GetCanvas()->GetView()->GetScale();
|
||||
|
||||
m_frame->GetCurrentSheet().push_back( sheet );
|
||||
m_frame->DisplayCurrentSheet();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int SCH_EDITOR_CONTROL::LeaveSheet( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
if( m_frame->GetCurrentSheet().Last() != &m_frame->Schematic().Root() )
|
||||
{
|
||||
m_toolMgr->RunAction( ACTIONS::cancelInteractive, true );
|
||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
|
||||
// Store the current zoom level into the current screen before switching
|
||||
m_frame->GetScreen()->m_LastZoomLevel = m_frame->GetCanvas()->GetView()->GetScale();
|
||||
|
||||
m_frame->GetCurrentSheet().pop_back();
|
||||
m_frame->DisplayCurrentSheet();
|
||||
}
|
||||
|
||||
getEditFrame<SCH_EDIT_FRAME>()->ToggleSchematicHierarchy();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2424,10 +2384,7 @@ void SCH_EDITOR_CONTROL::setTransitions()
|
|||
Go( &SCH_EDITOR_CONTROL::DrawSheetOnClipboard, EE_ACTIONS::drawSheetOnClipboard.MakeEvent() );
|
||||
|
||||
Go( &SCH_EDITOR_CONTROL::ShowBusManager, EE_ACTIONS::showBusManager.MakeEvent() );
|
||||
|
||||
Go( &SCH_EDITOR_CONTROL::EnterSheet, EE_ACTIONS::enterSheet.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::LeaveSheet, EE_ACTIONS::leaveSheet.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::NavigateHierarchy, EE_ACTIONS::navigateHierarchy.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::ShowHierarchy, EE_ACTIONS::showHierarchy.MakeEvent() );
|
||||
|
||||
Go( &SCH_EDITOR_CONTROL::ToggleHiddenPins, EE_ACTIONS::toggleHiddenPins.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::ToggleHiddenFields, EE_ACTIONS::toggleHiddenFields.MakeEvent() );
|
||||
|
|
|
@ -132,10 +132,7 @@ public:
|
|||
int DrawSheetOnClipboard( const TOOL_EVENT& aEvent );
|
||||
|
||||
int ShowBusManager( const TOOL_EVENT& aEvent );
|
||||
|
||||
int EnterSheet( const TOOL_EVENT& aEvent );
|
||||
int LeaveSheet( const TOOL_EVENT& aEvent );
|
||||
int NavigateHierarchy( const TOOL_EVENT& aEvent );
|
||||
int ShowHierarchy( const TOOL_EVENT& aEvent );
|
||||
|
||||
int ToggleHiddenPins( const TOOL_EVENT& aEvent );
|
||||
int ToggleHiddenFields( const TOOL_EVENT& aEvent );
|
||||
|
|
|
@ -28,10 +28,28 @@
|
|||
#include <tools/sch_navigate_tool.h>
|
||||
|
||||
|
||||
int SCH_NAVIGATE_TOOL::NavigateHierarchy( const TOOL_EVENT& aEvent )
|
||||
void SCH_NAVIGATE_TOOL::ResetHistory()
|
||||
{
|
||||
m_frame->UpdateHierarchyNavigator( true );
|
||||
return 0;
|
||||
m_navHistory.clear();
|
||||
m_navHistory.push_back( m_frame->GetCurrentSheet() );
|
||||
m_navIndex = m_navHistory.begin();
|
||||
}
|
||||
|
||||
|
||||
void SCH_NAVIGATE_TOOL::CleanHistory()
|
||||
{
|
||||
SCH_SHEET_LIST sheets = m_frame->Schematic().GetSheets();
|
||||
|
||||
// Search through our history, and removing any entries
|
||||
// that the no longer point to a sheet on the schematic
|
||||
auto entry = m_navHistory.begin();
|
||||
while( entry != m_navHistory.end() )
|
||||
{
|
||||
if( std::find( sheets.begin(), sheets.end(), *entry ) != sheets.end() )
|
||||
++entry;
|
||||
else
|
||||
entry = m_navHistory.erase( entry );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,35 +66,125 @@ int SCH_NAVIGATE_TOOL::HypertextCommand( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
if( sheet.GetPageNumber() == *aPage )
|
||||
{
|
||||
m_frame->GetToolManager()->RunAction( ACTIONS::cancelInteractive, true );
|
||||
m_frame->GetToolManager()->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
|
||||
m_frame->SetCurrentSheet( sheet );
|
||||
m_frame->DisplayCurrentSheet();
|
||||
|
||||
changeSheet( sheet );
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if( *page == "HYPERTEXT_BACK" )
|
||||
{
|
||||
if( m_hypertextStack.size() > 0 )
|
||||
{
|
||||
goToPage( &m_hypertextStack.top() );
|
||||
m_hypertextStack.pop();
|
||||
}
|
||||
}
|
||||
Back( aEvent );
|
||||
else
|
||||
{
|
||||
m_hypertextStack.push( m_frame->GetCurrentSheet().GetPageNumber() );
|
||||
goToPage( page );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int SCH_NAVIGATE_TOOL::Up( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
// Checks for CanGoUp()
|
||||
LeaveSheet( aEvent );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int SCH_NAVIGATE_TOOL::Forward( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
if( CanGoForward() )
|
||||
{
|
||||
m_navIndex++;
|
||||
|
||||
m_frame->GetToolManager()->RunAction( ACTIONS::cancelInteractive, true );
|
||||
m_frame->GetToolManager()->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
|
||||
m_frame->SetCurrentSheet( *m_navIndex );
|
||||
m_frame->DisplayCurrentSheet();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int SCH_NAVIGATE_TOOL::Back( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
if( CanGoBack() )
|
||||
{
|
||||
m_navIndex--;
|
||||
|
||||
m_frame->GetToolManager()->RunAction( ACTIONS::cancelInteractive, true );
|
||||
m_frame->GetToolManager()->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
|
||||
m_frame->SetCurrentSheet( *m_navIndex );
|
||||
m_frame->DisplayCurrentSheet();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int SCH_NAVIGATE_TOOL::Previous( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
if( CanGoPrevious() )
|
||||
changeSheet( m_frame->Schematic().GetSheets().at(
|
||||
m_frame->GetCurrentSheet().GetVirtualPageNumber() - 2 ) );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int SCH_NAVIGATE_TOOL::Next( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
if( CanGoNext() )
|
||||
changeSheet( m_frame->Schematic().GetSheets().at(
|
||||
m_frame->GetCurrentSheet().GetVirtualPageNumber() ) );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool SCH_NAVIGATE_TOOL::CanGoBack()
|
||||
{
|
||||
return m_navIndex != m_navHistory.begin();
|
||||
}
|
||||
|
||||
|
||||
bool SCH_NAVIGATE_TOOL::CanGoForward()
|
||||
{
|
||||
return m_navIndex != --m_navHistory.end();
|
||||
}
|
||||
|
||||
|
||||
bool SCH_NAVIGATE_TOOL::CanGoUp()
|
||||
{
|
||||
return m_frame->GetCurrentSheet().Last() != &m_frame->Schematic().Root();
|
||||
}
|
||||
|
||||
|
||||
bool SCH_NAVIGATE_TOOL::CanGoPrevious()
|
||||
{
|
||||
return m_frame->GetCurrentSheet().GetVirtualPageNumber() > 1;
|
||||
}
|
||||
|
||||
|
||||
bool SCH_NAVIGATE_TOOL::CanGoNext()
|
||||
{
|
||||
return m_frame->GetCurrentSheet().GetVirtualPageNumber()
|
||||
< (int) m_frame->Schematic().GetSheets().size();
|
||||
}
|
||||
|
||||
|
||||
int SCH_NAVIGATE_TOOL::ChangeSheet( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SCH_SHEET_PATH* path = aEvent.Parameter<SCH_SHEET_PATH*>();
|
||||
wxCHECK( path, 0 );
|
||||
|
||||
changeSheet( *path );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int SCH_NAVIGATE_TOOL::EnterSheet( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
|
@ -84,13 +192,10 @@ int SCH_NAVIGATE_TOOL::EnterSheet( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( selection.GetSize() == 1 )
|
||||
{
|
||||
SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
|
||||
SCH_SHEET_PATH pushed = m_frame->GetCurrentSheet();
|
||||
pushed.push_back( (SCH_SHEET*) selection.Front() );
|
||||
|
||||
m_toolMgr->RunAction( ACTIONS::cancelInteractive, true );
|
||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
|
||||
m_frame->GetCurrentSheet().push_back( sheet );
|
||||
m_frame->DisplayCurrentSheet();
|
||||
changeSheet( pushed );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -99,13 +204,12 @@ int SCH_NAVIGATE_TOOL::EnterSheet( const TOOL_EVENT& aEvent )
|
|||
|
||||
int SCH_NAVIGATE_TOOL::LeaveSheet( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
if( m_frame->GetCurrentSheet().Last() != &m_frame->Schematic().Root() )
|
||||
if( CanGoUp() )
|
||||
{
|
||||
m_toolMgr->RunAction( ACTIONS::cancelInteractive, true );
|
||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
SCH_SHEET_PATH popped = m_frame->GetCurrentSheet();
|
||||
popped.pop_back();
|
||||
|
||||
m_frame->GetCurrentSheet().pop_back();
|
||||
m_frame->DisplayCurrentSheet();
|
||||
changeSheet( popped );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -114,8 +218,40 @@ int SCH_NAVIGATE_TOOL::LeaveSheet( const TOOL_EVENT& aEvent )
|
|||
|
||||
void SCH_NAVIGATE_TOOL::setTransitions()
|
||||
{
|
||||
Go( &SCH_NAVIGATE_TOOL::ChangeSheet, EE_ACTIONS::changeSheet.MakeEvent() );
|
||||
Go( &SCH_NAVIGATE_TOOL::EnterSheet, EE_ACTIONS::enterSheet.MakeEvent() );
|
||||
Go( &SCH_NAVIGATE_TOOL::LeaveSheet, EE_ACTIONS::leaveSheet.MakeEvent() );
|
||||
Go( &SCH_NAVIGATE_TOOL::NavigateHierarchy, EE_ACTIONS::navigateHierarchy.MakeEvent() );
|
||||
Go( &SCH_NAVIGATE_TOOL::HypertextCommand, EE_ACTIONS::hypertextCommand.MakeEvent() );
|
||||
|
||||
Go( &SCH_NAVIGATE_TOOL::Up, EE_ACTIONS::navigateUp.MakeEvent() );
|
||||
Go( &SCH_NAVIGATE_TOOL::Forward, EE_ACTIONS::navigateForward.MakeEvent() );
|
||||
Go( &SCH_NAVIGATE_TOOL::Back, EE_ACTIONS::navigateBack.MakeEvent() );
|
||||
|
||||
Go( &SCH_NAVIGATE_TOOL::Previous, EE_ACTIONS::navigatePrevious.MakeEvent() );
|
||||
Go( &SCH_NAVIGATE_TOOL::Next, EE_ACTIONS::navigateNext.MakeEvent() );
|
||||
}
|
||||
|
||||
|
||||
void SCH_NAVIGATE_TOOL::pushToHistory( SCH_SHEET_PATH aPath )
|
||||
{
|
||||
if( CanGoForward() )
|
||||
m_navHistory.erase( std::next( m_navIndex ), m_navHistory.end() );
|
||||
|
||||
m_navHistory.push_back( aPath );
|
||||
m_navIndex = --m_navHistory.end();
|
||||
}
|
||||
|
||||
|
||||
void SCH_NAVIGATE_TOOL::changeSheet( SCH_SHEET_PATH aPath )
|
||||
{
|
||||
m_frame->GetToolManager()->RunAction( ACTIONS::cancelInteractive, true );
|
||||
m_frame->GetToolManager()->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
|
||||
// Store the current zoom level into the current screen before switching
|
||||
m_frame->GetScreen()->m_LastZoomLevel = m_frame->GetCanvas()->GetView()->GetScale();
|
||||
|
||||
pushToHistory( aPath );
|
||||
|
||||
m_frame->SetCurrentSheet( aPath );
|
||||
m_frame->DisplayCurrentSheet();
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019 CERN
|
||||
* Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2019-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -38,23 +38,51 @@ class SCH_EDIT_FRAME;
|
|||
class SCH_NAVIGATE_TOOL : public wxEvtHandler, public EE_TOOL_BASE<SCH_EDIT_FRAME>
|
||||
{
|
||||
public:
|
||||
SCH_NAVIGATE_TOOL() :
|
||||
EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.NavigateTool" )
|
||||
{ }
|
||||
SCH_NAVIGATE_TOOL() : EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.NavigateTool" ) {}
|
||||
|
||||
~SCH_NAVIGATE_TOOL() { }
|
||||
|
||||
///< Reset navigation history. Must be done when schematic changes
|
||||
void ResetHistory();
|
||||
///< Remove deleted pages from history. Must be done when schematic
|
||||
// hierarchy changes.
|
||||
void CleanHistory();
|
||||
|
||||
///< Enter sheet provided in aEvent
|
||||
int ChangeSheet( const TOOL_EVENT& aEvent );
|
||||
///< Enter selected sheet
|
||||
int EnterSheet( const TOOL_EVENT& aEvent );
|
||||
///< Return to parent sheet. Synonymous with Up
|
||||
int LeaveSheet( const TOOL_EVENT& aEvent );
|
||||
int NavigateHierarchy( const TOOL_EVENT& aEvent );
|
||||
///< Navigate up in sheet hierarchy
|
||||
int Up( const TOOL_EVENT& aEvent );
|
||||
///< Navigate forward in sheet history
|
||||
int Forward( const TOOL_EVENT& aEvent );
|
||||
///< Navigate back in sheet history
|
||||
int Back( const TOOL_EVENT& aEvent );
|
||||
///< Navigate to previous sheet by numeric sheet number
|
||||
int Previous( const TOOL_EVENT& aEvent );
|
||||
///< Navigate to next sheet by numeric sheet number
|
||||
int Next( const TOOL_EVENT& aEvent );
|
||||
int HypertextCommand( const TOOL_EVENT& aEvent );
|
||||
|
||||
bool CanGoBack();
|
||||
bool CanGoForward();
|
||||
bool CanGoUp();
|
||||
bool CanGoPrevious();
|
||||
bool CanGoNext();
|
||||
|
||||
private:
|
||||
///< Set up handlers for various events.
|
||||
void setTransitions() override;
|
||||
///< Clear history after this nav index and pushes aPath to history
|
||||
void pushToHistory( SCH_SHEET_PATH aPath );
|
||||
///< Change current sheet to aPath and handle history, zooming, etc.
|
||||
void changeSheet( SCH_SHEET_PATH aPath );
|
||||
|
||||
private:
|
||||
std::stack<wxString> m_hypertextStack;
|
||||
std::list<SCH_SHEET_PATH> m_navHistory;
|
||||
std::list<SCH_SHEET_PATH>::iterator m_navIndex;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -77,9 +77,6 @@ public:
|
|||
OPT<TOOL_EVENT> GetToolEvent( wxKeyEvent* aKeyEvent, bool* aSpecialKeyFlag );
|
||||
|
||||
private:
|
||||
///< Number of mouse buttons that is handled in events.
|
||||
static const int MouseButtonCount = 3;
|
||||
|
||||
///< The time threshold for a mouse button press that distinguishes between a single mouse
|
||||
///< click and a beginning of drag event (expressed in milliseconds).
|
||||
static const int DragTimeThreshold = 300;
|
||||
|
|
|
@ -126,7 +126,9 @@ enum TOOL_MOUSE_BUTTONS
|
|||
BUT_LEFT = 0x1,
|
||||
BUT_RIGHT = 0x2,
|
||||
BUT_MIDDLE = 0x4,
|
||||
BUT_BUTTON_MASK = BUT_LEFT | BUT_RIGHT | BUT_MIDDLE,
|
||||
BUT_AUX1 = 0x8,
|
||||
BUT_AUX2 = 0x10,
|
||||
BUT_BUTTON_MASK = BUT_LEFT | BUT_RIGHT | BUT_MIDDLE | BUT_AUX1 | BUT_AUX2,
|
||||
BUT_ANY = 0xffffffff
|
||||
};
|
||||
|
||||
|
|
|
@ -245,24 +245,10 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
|
||||
FinishAUIInitialization();
|
||||
|
||||
wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Footprints" );
|
||||
|
||||
if( m_editorSettings->m_LibWidth > 0 )
|
||||
{
|
||||
wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Footprints" );
|
||||
|
||||
// wxAUI hack: force width by setting MinSize() and then Fixed()
|
||||
// thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
|
||||
treePane.MinSize( m_editorSettings->m_LibWidth, -1 );
|
||||
treePane.Fixed();
|
||||
m_auimgr.Update();
|
||||
|
||||
// now make it resizable again
|
||||
treePane.Resizable();
|
||||
m_auimgr.Update();
|
||||
|
||||
// Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
|
||||
// back to minimum.
|
||||
treePane.MinSize( 250, -1 );
|
||||
}
|
||||
SetAuiPaneSize( m_auimgr, treePane, m_editorSettings->m_LibWidth, -1 );
|
||||
|
||||
// Apply saved visibility stuff at the end
|
||||
FOOTPRINT_EDITOR_SETTINGS* cfg = GetSettings();
|
||||
|
@ -357,7 +343,14 @@ void FOOTPRINT_EDIT_FRAME::ToggleSearchTree()
|
|||
{
|
||||
wxAuiPaneInfo& treePane = m_auimgr.GetPane( m_treePane );
|
||||
treePane.Show( !IsSearchTreeShown() );
|
||||
m_auimgr.Update();
|
||||
|
||||
if( IsSearchTreeShown() )
|
||||
SetAuiPaneSize( m_auimgr, treePane, m_editorSettings->m_LibWidth, -1 );
|
||||
else
|
||||
{
|
||||
m_editorSettings->m_LibWidth = m_treePane->GetSize().x;
|
||||
m_auimgr.Update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue