kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #42474
[PATCH v3] [NEW] eeschema: Allow hierarchy navigator to stay open
From: Franck Jullien <franck.jullien@xxxxxxxxx>
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.
Signed-off-by: Franck Jullien <franck.jullien@xxxxxxxxx>
---
v2: fix coding style
v3: fix memory leak after Wayne review
eeschema/dialogs/panel_eeschema_settings.cpp | 2 +
.../dialogs/panel_eeschema_settings_base.cpp | 2 +
.../dialogs/panel_eeschema_settings_base.fbp | 88 +++++++++++++++++
.../dialogs/panel_eeschema_settings_base.h | 3 +-
eeschema/eeschema_config.cpp | 3 +
eeschema/hierarch.cpp | 76 +++------------
eeschema/hierarch.h | 97 +++++++++++++++++++
eeschema/sch_edit_frame.cpp | 22 +++++
eeschema/sch_edit_frame.h | 16 +++
eeschema/tools/sch_editor_control.cpp | 5 +
10 files changed, 248 insertions(+), 66 deletions(-)
create mode 100644 eeschema/hierarch.h
diff --git a/eeschema/dialogs/panel_eeschema_settings.cpp b/eeschema/dialogs/panel_eeschema_settings.cpp
index d50b8a373..3ad650d18 100644
--- a/eeschema/dialogs/panel_eeschema_settings.cpp
+++ b/eeschema/dialogs/panel_eeschema_settings.cpp
@@ -46,6 +46,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() );
@@ -75,6 +76,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() );
diff --git a/eeschema/dialogs/panel_eeschema_settings_base.cpp b/eeschema/dialogs/panel_eeschema_settings_base.cpp
index 84c6470b1..7553170b0 100644
--- a/eeschema/dialogs/panel_eeschema_settings_base.cpp
+++ b/eeschema/dialogs/panel_eeschema_settings_base.cpp
@@ -124,6 +124,8 @@ 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 );
bSizer9->Add( m_footprintPreview, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 );
+ m_navigatorStaysOpen = new wxCheckBox( this, wxID_ANY, _("Allow hierarchy navigator to stay open"), wxDefaultPosition, wxDefaultSize, 0 );
+ bSizer9->Add( m_navigatorStaysOpen, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 );
bLeftColumn->Add( bSizer9, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 );
diff --git a/eeschema/dialogs/panel_eeschema_settings_base.fbp b/eeschema/dialogs/panel_eeschema_settings_base.fbp
index 6bc9b6da1..a8996f56f 100644
--- a/eeschema/dialogs/panel_eeschema_settings_base.fbp
+++ b/eeschema/dialogs/panel_eeschema_settings_base.fbp
@@ -1810,6 +1810,94 @@
<event name="OnUpdateUI"></event>
</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">Allow hierarchy navigator to stay 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>
+ <event name="OnChar"></event>
+ <event name="OnCheckBox"></event>
+ <event name="OnEnterWindow"></event>
+ <event name="OnEraseBackground"></event>
+ <event name="OnKeyDown"></event>
+ <event name="OnKeyUp"></event>
+ <event name="OnKillFocus"></event>
+ <event name="OnLeaveWindow"></event>
+ <event name="OnLeftDClick"></event>
+ <event name="OnLeftDown"></event>
+ <event name="OnLeftUp"></event>
+ <event name="OnMiddleDClick"></event>
+ <event name="OnMiddleDown"></event>
+ <event name="OnMiddleUp"></event>
+ <event name="OnMotion"></event>
+ <event name="OnMouseEvents"></event>
+ <event name="OnMouseWheel"></event>
+ <event name="OnPaint"></event>
+ <event name="OnRightDClick"></event>
+ <event name="OnRightDown"></event>
+ <event name="OnRightUp"></event>
+ <event name="OnSetFocus"></event>
+ <event name="OnSize"></event>
+ <event name="OnUpdateUI"></event>
+ </object>
+ </object>
</object>
</object>
</object>
diff --git a/eeschema/dialogs/panel_eeschema_settings_base.h b/eeschema/dialogs/panel_eeschema_settings_base.h
index 9a0fb8394..623271490 100644
--- a/eeschema/dialogs/panel_eeschema_settings_base.h
+++ b/eeschema/dialogs/panel_eeschema_settings_base.h
@@ -59,7 +59,8 @@ 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(); }
diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp
index b8a768691..b393a108a 100644
--- a/eeschema/eeschema_config.cpp
+++ b/eeschema/eeschema_config.cpp
@@ -255,6 +255,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" );
@@ -351,6 +352,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 );
@@ -395,6 +397,7 @@ void SCH_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg )
aCfg->Write( AutoplaceJustifyEntry, m_autoplaceJustify );
aCfg->Write( AutoplaceAlignEntry, m_autoplaceAlign );
aCfg->Write( FootprintPreviewEntry, m_footprintPreview );
+ aCfg->Write( NavigatorStaysOpenEntry, m_navigatorStaysOpen );
// Save template fieldnames
STRING_FORMATTER sf;
diff --git a/eeschema/hierarch.cpp b/eeschema/hierarch.cpp
index f3d25a825..6ebb0c776 100644
--- a/eeschema/hierarch.cpp
+++ b/eeschema/hierarch.cpp
@@ -42,6 +42,7 @@
#include <sch_sheet_path.h>
#include <view/view.h>
+#include <hierarch.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 )
@@ -207,7 +145,10 @@ HIERARCHY_NAVIG_DLG::~HIERARCHY_NAVIG_DLG()
void HIERARCHY_TREE::onChar( wxKeyEvent& event )
{
if( event.GetKeyCode() == WXK_ESCAPE )
- m_parent->Close( true );
+ {
+ if( m_parent->m_SchFrameEditor->GetNavigatorStaysOpen() == false )
+ m_parent->m_SchFrameEditor->OnHierarchyNavigatorClose();
+ }
else
event.Skip();
}
@@ -254,9 +195,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();
- Close( true );
+ if( m_SchFrameEditor->GetNavigatorStaysOpen() == false )
+ m_SchFrameEditor->OnHierarchyNavigatorClose();
}
+void HIERARCHY_NAVIG_DLG::OnClose( wxCloseEvent& event )
+{
+ m_SchFrameEditor->OnHierarchyNavigatorClose();
+}
void SCH_EDIT_FRAME::DisplayCurrentSheet()
{
diff --git a/eeschema/hierarch.h b/eeschema/hierarch.h
new file mode 100644
index 000000000..6d6fadf1f
--- /dev/null
+++ b/eeschema/hierarch.h
@@ -0,0 +1,97 @@
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 2019 CERN
+ * Copyright (C) 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 HIERAR_H
+#define HIERAR_H
+
+#include <fctsys.h>
+#include <sch_draw_panel.h>
+#include <confirm.h>
+#include <id.h>
+#include <bitmaps.h>
+#include <dialog_shim.h>
+#include <sch_edit_frame.h>
+#include <general.h>
+#include <sch_sheet.h>
+#include <sch_sheet_path.h>
+#include <wx/imaglist.h>
+#include <wx/treectrl.h>
+
+
+#include <view/view.h>
+
+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
+{
+
+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();
+ void OnClose( wxCloseEvent& event );
+
+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 // SCH_EDITOR_CONTROL_H
diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp
index 60f42e3d3..c6770188d 100644
--- a/eeschema/sch_edit_frame.cpp
+++ b/eeschema/sch_edit_frame.cpp
@@ -67,6 +67,7 @@
#include <wildcards_and_files_ext.h>
#include <connection_graph.h>
#include <sch_painter.h>
+#include <hierarch.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 );
@@ -542,6 +544,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;
@@ -676,6 +684,15 @@ wxFindReplaceData* SCH_EDIT_FRAME::GetFindReplaceData()
return nullptr;
}
+void SCH_EDIT_FRAME::ShowHierarchyNavigator()
+{
+ if( m_hierarchyDialog )
+ m_hierarchyDialog->Destroy();
+
+ m_hierarchyDialog = new HIERARCHY_NAVIG_DLG( this );
+ m_hierarchyDialog->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( HIERARCHY_NAVIG_DLG::OnClose ) );
+ m_hierarchyDialog->Show( true );
+}
void SCH_EDIT_FRAME::ShowFindReplaceDialog( bool aReplace )
{
@@ -729,6 +746,11 @@ void SCH_EDIT_FRAME::OnFindDialogClose()
m_findReplaceDialog = nullptr;
}
+void SCH_EDIT_FRAME::OnHierarchyNavigatorClose()
+{
+ m_hierarchyDialog->Destroy();
+ m_hierarchyDialog = nullptr;
+}
void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
{
diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h
index c7982050c..2747bb3ac 100644
--- a/eeschema/sch_edit_frame.h
+++ b/eeschema/sch_edit_frame.h
@@ -37,6 +37,7 @@
#include <sch_text.h> // enum PINSHEETLABEL_SHAPE
#include <tool/selection.h>
#include <status_popup.h>
+#include <hierarch.h>
class SCH_ITEM;
class EDA_ITEM;
@@ -123,10 +124,12 @@ 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;
DIALOG_SCH_FIND* m_findReplaceDialog;
STATUS_TEXT_POPUP* m_findReplaceStatusPopup;
+ HIERARCHY_NAVIG_DLG* m_hierarchyDialog;
/// Flag to indicate show hidden pins.
bool m_showAllPins;
@@ -199,6 +202,9 @@ 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; }
@@ -322,6 +328,11 @@ public:
*/
void ShowFindReplaceDialog( bool aReplace );
+ /**
+ * Run the Hierarchy Navigator dialog.
+ */
+ void ShowHierarchyNavigator();
+
void ShowFindReplaceStatus( const wxString& aMsg );
void ClearFindReplaceStatus();
@@ -335,6 +346,11 @@ public:
*/
void OnFindDialogClose();
+ /**
+ * Notification that the Hierarchy Navigator dialog has closed.
+ */
+ void OnHierarchyNavigatorClose();
+
/**
* Breaks a single segment into two at the specified point.
*
diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp
index 23cb07db3..e13020bf6 100644
--- a/eeschema/tools/sch_editor_control.cpp
+++ b/eeschema/tools/sch_editor_control.cpp
@@ -131,6 +131,11 @@ int SCH_EDITOR_CONTROL::FindAndReplace( const TOOL_EVENT& aEvent )
return UpdateFind( aEvent );
}
+int SCH_EDITOR_CONTROL::NavigateHierarchy( const TOOL_EVENT& aEvent )
+{
+ m_frame->ShowHierarchyNavigator();
+ return 0;
+}
int SCH_EDITOR_CONTROL::UpdateFind( const TOOL_EVENT& aEvent )
{
--
2.17.1
Follow ups