eeschema: Allow hierarchy navigator to stay open

ADD: User can now decide to keep the hierarchy navigator open while working
on a schematic.

This behavior can be configured in eeschema->preferences->eeschema->Editing options.
This commit is contained in:
Franck Jullien 2019-10-24 19:07:01 +02:00
parent d1a05e27a5
commit ea218bc722
12 changed files with 288 additions and 102 deletions

View File

@ -49,6 +49,7 @@ bool PANEL_EESCHEMA_SETTINGS::TransferDataToWindow()
m_checkHVOrientation->SetValue( m_frame->GetForceHVLines() );
m_footprintPreview->SetValue( m_frame->GetShowFootprintPreviews() );
m_navigatorStaysOpen->SetValue( m_frame->GetNavigatorStaysOpen() );
m_checkAutoplaceFields->SetValue( m_frame->GetAutoplaceFields() );
m_checkAutoplaceJustify->SetValue( m_frame->GetAutoplaceJustify() );
@ -82,6 +83,7 @@ bool PANEL_EESCHEMA_SETTINGS::TransferDataFromWindow()
m_frame->SetForceHVLines( m_checkHVOrientation->GetValue() );
m_frame->SetShowFootprintPreviews( m_footprintPreview->GetValue() );
m_frame->SetNavigatorStaysOpen( m_navigatorStaysOpen->GetValue() );
m_frame->SetAutoplaceFields( m_checkAutoplaceFields->GetValue() );
m_frame->SetAutoplaceJustify( m_checkAutoplaceJustify->GetValue() );

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jul 10 2019)
// C++ code generated with wxFormBuilder (version Oct 24 2019)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -141,6 +141,10 @@ PANEL_EESCHEMA_SETTINGS_BASE::PANEL_EESCHEMA_SETTINGS_BASE( wxWindow* parent, wx
m_footprintPreview = new wxCheckBox( this, wxID_ANY, _("Show footprint previews in symbol chooser"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerPreviewOpt->Add( m_footprintPreview, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 );
m_navigatorStaysOpen = new wxCheckBox( this, wxID_ANY, _("Keep hierarchy navigator open"), wxDefaultPosition, wxDefaultSize, 0 );
m_navigatorStaysOpen->SetValue(true);
bSizerPreviewOpt->Add( m_navigatorStaysOpen, 0, wxALL, 5 );
bRightColumn->Add( bSizerPreviewOpt, 0, wxALL, 5 );

View File

@ -1420,6 +1420,70 @@
<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="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>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jul 10 2019)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -59,6 +59,7 @@ class PANEL_EESCHEMA_SETTINGS_BASE : public wxPanel
wxCheckBox* m_checkAutoplaceJustify;
wxCheckBox* m_checkAutoplaceAlign;
wxCheckBox* m_footprintPreview;
wxCheckBox* m_navigatorStaysOpen;
// Virtual event handlers, overide them in your derived class
virtual void OnChooseUnits( wxCommandEvent& event ) { event.Skip(); }

View File

@ -312,6 +312,7 @@ const wxChar AutoplaceJustifyEntry[] = wxT( "AutoplaceJustify" );
const wxChar AutoplaceAlignEntry[] = wxT( "AutoplaceAlign" );
static const wxChar DragActionIsMoveEntry[] = wxT( "DragActionIsMove" );
static const wxChar FootprintPreviewEntry[] = wxT( "FootprintPreview" );
static const wxChar NavigatorStaysOpenEntry[] = wxT( "NavigatorStaysOpen" );
static const wxChar DefaultBusWidthEntry[] = wxT( "DefaultBusWidth" );
static const wxChar DefaultWireWidthEntry[] = wxT( "DefaultWireWidth" );
static const wxChar DefaultDrawLineWidthEntry[] = wxT( "DefaultDrawLineWidth" );
@ -424,6 +425,7 @@ void SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
aCfg->Read( AutoplaceJustifyEntry, &m_autoplaceJustify, true );
aCfg->Read( AutoplaceAlignEntry, &m_autoplaceAlign, false );
aCfg->Read( FootprintPreviewEntry, &m_footprintPreview, false );
aCfg->Read( NavigatorStaysOpenEntry, &m_navigatorStaysOpen, false );
wxString templateFieldNames = aCfg->Read( FieldNamesEntry, wxEmptyString );
@ -474,6 +476,7 @@ void SCH_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg )
aCfg->Write( drawSelectedChildren, GetSelectionDrawChildItems() );
aCfg->Write( selectionFillShapes, GetSelectionFillShapes() );
aCfg->Write( selectionThickness, GetSelectionThickness() );
aCfg->Write( NavigatorStaysOpenEntry, m_navigatorStaysOpen );
// Save template fieldnames
STRING_FORMATTER sf;

View File

@ -41,6 +41,7 @@
//#include <netlist_object.h>
#include <sch_sheet_path.h>
#include <hierarch.h>
#include <view/view.h>
class HIERARCHY_NAVIG_DLG;
@ -60,24 +61,6 @@ public:
}
};
/**
* Handle hierarchy tree control.
*/
class HIERARCHY_TREE : public wxTreeCtrl
{
private:
HIERARCHY_NAVIG_DLG* m_parent;
wxImageList* imageList;
public:
HIERARCHY_TREE( HIERARCHY_NAVIG_DLG* parent );
// Closes the dialog on escape key
void onChar( wxKeyEvent& event );
};
HIERARCHY_TREE::HIERARCHY_TREE( HIERARCHY_NAVIG_DLG* parent ) :
wxTreeCtrl( (wxWindow*) parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
wxTR_HAS_BUTTONS, wxDefaultValidator, wxT( "HierachyTreeCtrl" ) )
@ -95,51 +78,6 @@ HIERARCHY_TREE::HIERARCHY_TREE( HIERARCHY_NAVIG_DLG* parent ) :
AssignImageList( imageList );
}
class HIERARCHY_NAVIG_DLG : public DIALOG_SHIM
{
public:
SCH_EDIT_FRAME* m_SchFrameEditor;
HIERARCHY_TREE* m_Tree;
int m_nbsheets;
private:
SCH_SHEET_PATH m_currSheet; // The currently opened scheet in hierarchy
public:
HIERARCHY_NAVIG_DLG( SCH_EDIT_FRAME* aParent );
~HIERARCHY_NAVIG_DLG();
private:
/**
* Create the hierarchical tree of the schematic.
*
* This routine is reentrant!
* @param aList = the SCH_SHEET_PATH* list to explore
* @param aPreviousmenu = the wxTreeItemId used as parent to add sub items
*/
void buildHierarchyTree( SCH_SHEET_PATH* aList, wxTreeItemId* aPreviousmenu );
/**
* Open the selected sheet and display the corresponding screen when a tree item is
* selected.
*/
void onSelectSheetPath( wxTreeEvent& event );
};
int SCH_EDITOR_CONTROL::NavigateHierarchy( const TOOL_EVENT& aEvent )
{
HIERARCHY_NAVIG_DLG* treeframe = new HIERARCHY_NAVIG_DLG( m_frame );
treeframe->ShowQuasiModal();
treeframe->Destroy();
return 0;
}
HIERARCHY_NAVIG_DLG::HIERARCHY_NAVIG_DLG( SCH_EDIT_FRAME* aParent ) :
DIALOG_SHIM( aParent, wxID_ANY, _( "Navigator" ), wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
@ -155,14 +93,13 @@ HIERARCHY_NAVIG_DLG::HIERARCHY_NAVIG_DLG( SCH_EDIT_FRAME* aParent ) :
wxTreeItemId root = m_Tree->AddRoot( _( "Root" ), 0, 1 );
m_Tree->SetItemBold( root, true );
SCH_SHEET_PATH list;
list.push_back( g_RootSheet );
m_Tree->SetItemData( root, new TreeItemData( list ) );
m_list.push_back( g_RootSheet );
m_Tree->SetItemData( root, new TreeItemData( m_list ) );
if( m_SchFrameEditor->GetCurrentSheet().Last() == g_RootSheet )
m_Tree->SelectItem( root );
buildHierarchyTree( &list, &root );
buildHierarchyTree( &m_list, &root );
m_Tree->ExpandAll();
@ -245,6 +182,15 @@ void HIERARCHY_NAVIG_DLG::buildHierarchyTree( SCH_SHEET_PATH* aList, wxTreeItemI
}
}
void HIERARCHY_NAVIG_DLG::UpdateHierarchyTree()
{
m_currSheet = m_SchFrameEditor->GetCurrentSheet();
wxTreeItemId root = m_Tree->GetRootItem();
m_Tree->DeleteChildren( root );
m_list.clear();
m_list.push_back( g_RootSheet );
buildHierarchyTree( &m_list, &root );
}
void HIERARCHY_NAVIG_DLG::onSelectSheetPath( wxTreeEvent& event )
{
@ -254,9 +200,14 @@ void HIERARCHY_NAVIG_DLG::onSelectSheetPath( wxTreeEvent& event )
wxTreeItemId ItemSel = m_Tree->GetSelection();
m_SchFrameEditor->SetCurrentSheet(( (TreeItemData*) m_Tree->GetItemData( ItemSel ) )->m_SheetPath );
m_SchFrameEditor->DisplayCurrentSheet();
if( m_SchFrameEditor->GetNavigatorStaysOpen() == false )
Close( true );
}
void HIERARCHY_NAVIG_DLG::OnClose( wxCloseEvent& event )
{
m_SchFrameEditor->CloseHierarchyNavigator();
}
void SCH_EDIT_FRAME::DisplayCurrentSheet()
{

91
eeschema/hierarch.h Normal file
View File

@ -0,0 +1,91 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2004-2019 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HIERARCH_H
#define HIERARCH_H
#include <dialog_shim.h>
#include <wx/imaglist.h>
#include <wx/treectrl.h>
class SCH_EDIT_FRAME;
class SCH_SHEET_PATH;
class HIERARCHY_NAVIG_DLG;
/**
* Handle hierarchy tree control.
*/
class HIERARCHY_TREE : public wxTreeCtrl
{
private:
HIERARCHY_NAVIG_DLG* m_parent;
wxImageList* imageList;
public:
HIERARCHY_TREE( HIERARCHY_NAVIG_DLG* parent );
// Closes the dialog on escape key
void onChar( wxKeyEvent& event );
};
class HIERARCHY_NAVIG_DLG : public DIALOG_SHIM
{
private:
SCH_SHEET_PATH m_currSheet;
SCH_SHEET_PATH m_list;
SCH_EDIT_FRAME* m_SchFrameEditor;
HIERARCHY_TREE* m_Tree;
int m_nbsheets;
public:
HIERARCHY_NAVIG_DLG( SCH_EDIT_FRAME* aParent );
~HIERARCHY_NAVIG_DLG();
void OnClose( wxCloseEvent& event );
/**
* Update the hierarchical tree of the schematic.
*/
void UpdateHierarchyTree();
private:
/**
* Create the hierarchical tree of the schematic.
*
* This routine is reentrant!
* @param aList = the SCH_SHEET_PATH* list to explore
* @param aPreviousmenu = the wxTreeItemId used as parent to add sub items
*/
void buildHierarchyTree( SCH_SHEET_PATH* aList, wxTreeItemId* aPreviousmenu );
/**
* Open the selected sheet and display the corresponding screen when a tree item is
* selected.
*/
void onSelectSheetPath( wxTreeEvent& event );
};
#endif // HIERARCH_H

View File

@ -22,51 +22,52 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <advanced_config.h>
#include <base_units.h>
#include <class_library.h>
#include <confirm.h>
#include <connection_graph.h>
#include <dialog_symbol_remap.h>
#include <dialogs/dialog_schematic_find.h>
#include <eeschema_config.h>
#include <eeschema_id.h>
#include <executable_names.h>
#include <fctsys.h>
#include <general.h>
#include <gestfich.h>
#include <gr_basic.h>
#include <hierarch.h>
#include <html_messagebox.h>
#include <invoke_sch_dialog.h>
#include <kiface_i.h>
#include <kiway.h>
#include <pgm_base.h>
#include <profile.h>
#include <advanced_config.h>
#include <general.h>
#include <eeschema_id.h>
#include <class_library.h>
#include <sch_edit_frame.h>
#include <symbol_lib_table.h>
#include <reporter.h>
#include <lib_edit_frame.h>
#include <lib_view_frame.h>
#include <eeschema_config.h>
#include <pgm_base.h>
#include <profile.h>
#include <reporter.h>
#include <sch_edit_frame.h>
#include <sch_painter.h>
#include <sch_sheet.h>
#include <sim/sim_plot_frame.h>
#include <invoke_sch_dialog.h>
#include <dialogs/dialog_schematic_find.h>
#include <dialog_symbol_remap.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <symbol_lib_table.h>
#include <tool/action_toolbar.h>
#include <tool/common_control.h>
#include <tool/common_tools.h>
#include <tool/picker_tool.h>
#include <tool/tool_dispatcher.h>
#include <tool/tool_manager.h>
#include <tool/zoom_tool.h>
#include <tools/ee_actions.h>
#include <tools/ee_selection_tool.h>
#include <tools/ee_inspection_tool.h>
#include <tools/ee_point_editor.h>
#include <tools/ee_selection_tool.h>
#include <tools/sch_drawing_tools.h>
#include <tools/sch_edit_tool.h>
#include <tools/sch_editor_control.h>
#include <tools/sch_line_wire_bus_tool.h>
#include <tools/sch_move_tool.h>
#include <tools/sch_edit_tool.h>
#include <tools/ee_inspection_tool.h>
#include <tools/sch_editor_control.h>
#include <wildcards_and_files_ext.h>
#include <connection_graph.h>
#include <sch_painter.h>
#include <gal/graphics_abstraction_layer.h>
@ -247,6 +248,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
m_findReplaceDialog = nullptr;
m_findReplaceStatusPopup = nullptr;
m_hierarchyDialog = nullptr;
SetForceHVLines( true );
SetSpiceAdjustPassiveValues( false );
@ -560,6 +562,12 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
m_findReplaceDialog = nullptr;
}
if( m_hierarchyDialog )
{
m_hierarchyDialog->Destroy();
m_hierarchyDialog = nullptr;
}
SCH_SCREENS screens;
wxFileName fn;
@ -668,6 +676,25 @@ wxFindReplaceData* SCH_EDIT_FRAME::GetFindReplaceData()
return nullptr;
}
void SCH_EDIT_FRAME::UpdateHierarchyNavigator( bool aForceUpdate )
{
if( aForceUpdate )
{
if( m_hierarchyDialog )
CloseHierarchyNavigator();
m_hierarchyDialog = new HIERARCHY_NAVIG_DLG( this );
m_hierarchyDialog->Connect(
wxEVT_CLOSE_WINDOW, wxCloseEventHandler( HIERARCHY_NAVIG_DLG::OnClose ) );
m_hierarchyDialog->Show( true );
}
else
{
if( m_hierarchyDialog )
m_hierarchyDialog->UpdateHierarchyTree();
}
}
void SCH_EDIT_FRAME::ShowFindReplaceDialog( bool aReplace )
{
@ -721,6 +748,11 @@ void SCH_EDIT_FRAME::OnFindDialogClose()
m_findReplaceDialog = nullptr;
}
void SCH_EDIT_FRAME::CloseHierarchyNavigator()
{
m_hierarchyDialog->Destroy();
m_hierarchyDialog = nullptr;
}
void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
{

View File

@ -52,7 +52,7 @@ class DIALOG_SCH_FIND;
class wxFindDialogEvent;
class wxFindReplaceData;
class RESCUER;
class HIERARCHY_NAVIG_DLG;
/// enum used in RotationMiroir()
enum COMPONENT_ORIENTATION_T {
@ -133,11 +133,13 @@ private:
bool m_autoplaceJustify; ///< allow autoplace to change justification
bool m_autoplaceAlign; ///< align autoplaced fields to the grid
bool m_footprintPreview; ///< whether to show footprint previews
bool m_navigatorStaysOpen; ///< whether to keep Navigator open
bool m_showIllegalSymbolLibDialog;
bool m_showSheetFileNameCaseSensitivityDlg;
DIALOG_SCH_FIND* m_findReplaceDialog;
STATUS_TEXT_POPUP* m_findReplaceStatusPopup;
HIERARCHY_NAVIG_DLG* m_hierarchyDialog;
/// Flag to indicate show hidden pins.
bool m_showAllPins;
@ -214,6 +216,15 @@ public:
bool GetShowFootprintPreviews() const { return m_footprintPreview; }
void SetShowFootprintPreviews( bool aEnable ) { m_footprintPreview = aEnable; }
bool GetNavigatorStaysOpen() const
{
return m_navigatorStaysOpen;
}
void SetNavigatorStaysOpen( bool aEnable )
{
m_navigatorStaysOpen = aEnable;
}
bool GetAutoplaceFields() const { return m_autoplaceFields; }
void SetAutoplaceFields( bool aEnable ) { m_autoplaceFields = aEnable; }
@ -344,6 +355,13 @@ 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.
*/
void UpdateHierarchyNavigator( bool aForceUpdate = false );
void ShowFindReplaceStatus( const wxString& aMsg );
void ClearFindReplaceStatus();
@ -357,6 +375,11 @@ public:
*/
void OnFindDialogClose();
/**
* Destroy the Hierarchy Navigator dialog.
*/
void CloseHierarchyNavigator();
/**
* Breaks a single segment into two at the specified point.
*

View File

@ -853,6 +853,7 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
if( m_frame->EditSheet( (SCH_SHEET*)sheet, g_CurrentSheet, nullptr ) )
{
m_frame->AddItemToScreenAndUndoList( sheet );
m_frame->UpdateHierarchyNavigator();
m_selectionTool->AddItemToSel( sheet );
}
else

View File

@ -955,6 +955,9 @@ int SCH_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
}
else
m_frame->RemoveFromScreen( sch_item );
if( sch_item->Type() == SCH_SHEET_T )
m_frame->UpdateHierarchyNavigator();
}
}
@ -1249,6 +1252,7 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
{
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
m_frame->GetCanvas()->Refresh();
m_frame->UpdateHierarchyNavigator();
}
break;

View File

@ -130,6 +130,11 @@ int SCH_EDITOR_CONTROL::FindAndReplace( const TOOL_EVENT& aEvent )
return UpdateFind( 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 )
{
@ -1132,7 +1137,10 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
}
if( sheetsPasted )
{
m_frame->SetSheetNumberAndCount();
m_frame->UpdateHierarchyNavigator();
}
// Now clear the previous selection, select the pasted items, and fire up the "move"
// tool.
@ -1273,6 +1281,7 @@ int SCH_EDITOR_CONTROL::EnterSheet( const TOOL_EVENT& aEvent )
g_CurrentSheet->push_back( sheet );
m_frame->DisplayCurrentSheet();
m_frame->UpdateHierarchyNavigator();
}
return 0;
@ -1288,6 +1297,7 @@ int SCH_EDITOR_CONTROL::LeaveSheet( const TOOL_EVENT& aEvent )
g_CurrentSheet->pop_back();
m_frame->DisplayCurrentSheet();
m_frame->UpdateHierarchyNavigator();
}
return 0;