WIP: libraries view - basic skeleton

This commit is contained in:
Matthias Koefferlein 2019-07-30 23:22:26 +02:00
parent e33c2f7b66
commit 5faf762571
9 changed files with 1419 additions and 23 deletions

View File

@ -49,6 +49,7 @@ static const std::string cfg_navigator_all_hier_levels ("navigator-show-all-hier
static const std::string cfg_navigator_show_images ("navigator-show-images");
static const std::string cfg_show_layer_toolbox ("show-layer-toolbox");
static const std::string cfg_show_hierarchy_panel ("show-hierarchy-panel");
static const std::string cfg_show_libraries_view ("show-libraries-view");
static const std::string cfg_show_layer_panel ("show-layer-panel");
static const std::string cfg_window_state ("window-state");
static const std::string cfg_layout_file_watcher_enabled ("layout-file-watcher-enabled");

View File

@ -68,6 +68,7 @@ public:
options.push_back (std::pair<std::string, std::string> (cfg_show_toolbar, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_show_layer_toolbox, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_show_hierarchy_panel, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_show_libraries_view, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_show_layer_panel, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_layout_file_watcher_enabled, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_window_state, ""));

View File

@ -506,6 +506,13 @@ MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const cha
connect (mp_hp_dock_widget, SIGNAL (visibilityChanged (bool)), this, SLOT (dock_widget_visibility_changed (bool)));
m_hp_visible = true;
mp_libs_dock_widget = new QDockWidget (QObject::tr ("Libraries"), this);
mp_libs_dock_widget->setObjectName (QString::fromUtf8 ("libs_dock_widget"));
mp_libs_stack = new ControlWidgetStack (mp_libs_dock_widget, "libs_stack");
mp_libs_dock_widget->setWidget (mp_libs_stack);
connect (mp_libs_dock_widget, SIGNAL (visibilityChanged (bool)), this, SLOT (dock_widget_visibility_changed (bool)));
m_libs_visible = true;
mp_view_stack = new ViewWidgetStack (mp_main_frame);
mp_view_stack->setObjectName (QString::fromUtf8 ("view_stack"));
vbl->addWidget (mp_view_stack);
@ -537,6 +544,7 @@ MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const cha
#endif
addDockWidget(Qt::LeftDockWidgetArea, mp_navigator_dock_widget);
addDockWidget(Qt::LeftDockWidgetArea, mp_hp_dock_widget);
addDockWidget(Qt::LeftDockWidgetArea, mp_libs_dock_widget);
addDockWidget(Qt::RightDockWidgetArea, mp_lp_dock_widget);
addDockWidget(Qt::RightDockWidgetArea, mp_layer_toolbox_dock_widget);
@ -849,6 +857,7 @@ MainWindow::init_menu ()
MenuLayoutEntry ("show_layer_panel", tl::to_string (QObject::tr ("Layers")), std::make_pair (cfg_show_layer_panel, "?")),
MenuLayoutEntry ("show_layer_toolbox", tl::to_string (QObject::tr ("Layer Toolbox")), std::make_pair (cfg_show_layer_toolbox, "?")),
MenuLayoutEntry ("show_hierarchy_panel", tl::to_string (QObject::tr ("Cells")), std::make_pair (cfg_show_hierarchy_panel, "?")),
MenuLayoutEntry ("show_libraries_view", tl::to_string (QObject::tr ("Libraries")), std::make_pair (cfg_show_libraries_view, "?")),
MenuLayoutEntry ("reset_window_state", tl::to_string (QObject::tr ("Restore Window")), SLOT (cm_reset_window_state ())),
MenuLayoutEntry::separator ("selection_group"),
MenuLayoutEntry ("transient_selection", tl::to_string (QObject::tr ("Highlight Object Under Mouse")), std::make_pair (cfg_sel_transient_mode, "?")),
@ -1073,6 +1082,8 @@ MainWindow::dock_widget_visibility_changed (bool /*visible*/)
plugin_root ()->config_set (cfg_show_layer_panel, tl::to_string (!mp_lp_dock_widget->isHidden ()));
} else if (sender () == mp_hp_dock_widget) {
plugin_root ()->config_set (cfg_show_hierarchy_panel, tl::to_string (!mp_hp_dock_widget->isHidden ()));
} else if (sender () == mp_libs_dock_widget) {
plugin_root ()->config_set (cfg_show_libraries_view, tl::to_string (!mp_libs_dock_widget->isHidden ()));
} else if (sender () == mp_navigator_dock_widget) {
plugin_root ()->config_set (cfg_show_navigator, tl::to_string (!mp_navigator_dock_widget->isHidden ()));
} else if (sender () == mp_layer_toolbox_dock_widget) {
@ -1685,6 +1696,17 @@ MainWindow::configure (const std::string &name, const std::string &value)
return true;
} else if (name == cfg_show_libraries_view) {
tl::from_string (value, m_libs_visible);
if (m_libs_visible) {
mp_libs_dock_widget->show ();
} else {
mp_libs_dock_widget->hide ();
}
return true;
} else if (name == cfg_show_layer_panel) {
tl::from_string (value, m_lp_visible);
@ -1797,6 +1819,7 @@ MainWindow::read_dock_widget_state ()
{
plugin_root ()->config_set (cfg_show_layer_panel, tl::to_string (!mp_lp_dock_widget->isHidden ()));
plugin_root ()->config_set (cfg_show_hierarchy_panel, tl::to_string (!mp_hp_dock_widget->isHidden ()));
plugin_root ()->config_set (cfg_show_libraries_view, tl::to_string (!mp_libs_dock_widget->isHidden ()));
plugin_root ()->config_set (cfg_show_navigator, tl::to_string (!mp_navigator_dock_widget->isHidden ()));
plugin_root ()->config_set (cfg_show_layer_toolbox, tl::to_string (!mp_layer_toolbox_dock_widget->isHidden ()));
}
@ -1810,6 +1833,12 @@ MainWindow::update_dock_widget_state ()
mp_hp_dock_widget->hide ();
}
if (m_libs_visible) {
mp_libs_dock_widget->show ();
} else {
mp_libs_dock_widget->hide ();
}
if (m_lp_visible) {
mp_lp_dock_widget->show ();
} else {
@ -3694,6 +3723,7 @@ MainWindow::clone_current_view ()
mp_view_stack->addWidget (view);
mp_lp_stack->addWidget (view->layer_control_frame ());
mp_hp_stack->addWidget (view->hierarchy_control_frame ());
mp_libs_stack->addWidget (view->libraries_frame ());
bool f = m_disable_tab_selected;
m_disable_tab_selected = true;
@ -4312,6 +4342,7 @@ MainWindow::create_view ()
mp_view_stack->addWidget (mp_views.back ());
mp_lp_stack->addWidget (mp_views.back ()->layer_control_frame ());
mp_hp_stack->addWidget (mp_views.back ()->hierarchy_control_frame ());
mp_libs_stack->addWidget (mp_views.back ()->libraries_frame ());
bool f = m_disable_tab_selected;
m_disable_tab_selected = true;
@ -4373,6 +4404,7 @@ MainWindow::create_or_load_layout (const std::string *filename, const db::LoadLa
mp_view_stack->addWidget (mp_views.back ());
mp_lp_stack->addWidget (mp_views.back ()->layer_control_frame ());
mp_hp_stack->addWidget (mp_views.back ()->hierarchy_control_frame ());
mp_libs_stack->addWidget (mp_views.back ()->libraries_frame ());
bool f = m_disable_tab_selected;
m_disable_tab_selected = true;

View File

@ -872,9 +872,9 @@ private:
QToolBar *mp_tool_bar;
QDockWidget *mp_navigator_dock_widget;
lay::Navigator *mp_navigator;
QDockWidget *mp_hp_dock_widget, *mp_lp_dock_widget;
ControlWidgetStack *mp_hp_stack, *mp_lp_stack;
bool m_hp_visible, m_lp_visible, m_navigator_visible, m_layer_toolbox_visible;
QDockWidget *mp_hp_dock_widget, *mp_lp_dock_widget, *mp_libs_dock_widget;
ControlWidgetStack *mp_hp_stack, *mp_lp_stack, *mp_libs_stack;
bool m_hp_visible, m_lp_visible, m_libs_visible, m_navigator_visible, m_layer_toolbox_visible;
QDockWidget *mp_layer_toolbox_dock_widget;
lay::LayerToolbox *mp_layer_toolbox;
ViewWidgetStack *mp_view_stack;

View File

@ -61,6 +61,7 @@
#include "layLayoutCanvas.h"
#include "layLayerControlPanel.h"
#include "layHierarchyControlPanel.h"
#include "layLibrariesView.h"
#include "layBrowser.h"
#include "layRedrawThread.h"
#include "layRedrawThreadWorker.h"
@ -356,6 +357,8 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/)
mp_control_frame = 0;
mp_hierarchy_panel = 0;
mp_hierarchy_frame = 0;
mp_libraries_view = 0;
mp_libraries_frame = 0;
mp_min_hier_spbx = 0;
mp_max_hier_spbx = 0;
m_from_level = 0;
@ -491,6 +494,25 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/)
}
if ((m_options & LV_NoLibrariesView) == 0 && (m_options & LV_Naked) == 0) {
QFrame *libraries_frame = new QFrame (0);
libraries_frame->setObjectName (QString::fromUtf8 ("libs_frame"));
mp_libraries_frame = libraries_frame;
QVBoxLayout *left_frame_ly = new QVBoxLayout (libraries_frame);
left_frame_ly->setMargin (0);
left_frame_ly->setSpacing (0);
mp_libraries_view = new lay::LibrariesView (this, libraries_frame, "libs");
left_frame_ly->addWidget (mp_libraries_view, 1 /*stretch*/);
#if 0 // @@@
connect (mp_libraries_view, SIGNAL (cell_selected (cell_path_type, int)), this, SLOT (select_cell_dispatch (cell_path_type, int)));
connect (mp_libraries_view, SIGNAL (active_cellview_changed (int)), this, SLOT (active_cellview_changed (int)));
#endif
}
mp_canvas = new lay::LayoutCanvas (this, this);
vbl->addWidget (mp_canvas);
connect (mp_canvas, SIGNAL (left_arrow_key_pressed ()), this, SLOT (pan_left ()));
@ -628,6 +650,12 @@ LayoutView::~LayoutView ()
}
mp_hierarchy_frame = 0;
mp_hierarchy_panel = 0;
if (mp_libraries_frame) {
delete mp_libraries_frame;
}
mp_libraries_frame = 0;
mp_libraries_view = 0;
}
void LayoutView::hideEvent (QHideEvent *)
@ -7243,7 +7271,7 @@ LayoutView::sizeHint () const
{
if ((m_options & LV_Naked) != 0) {
return QSize (200, 200);
} else if ((m_options & LV_NoLayers) != 0 || (m_options & LV_NoHierarchyPanel) != 0) {
} else if ((m_options & LV_NoLayers) != 0 || (m_options & LV_NoHierarchyPanel) != 0 || (m_options & LV_NoLibrariesView) != 0) {
return QSize (400, 200);
} else {
return QSize (600, 200);

View File

@ -70,6 +70,7 @@ namespace lay {
class AbstractMenu;
class LayerControlPanel;
class HierarchyControlPanel;
class LibrariesView;
class MouseTracker;
class ZoomService;
class SelectionService;
@ -168,13 +169,14 @@ public:
LV_Normal = 0,
LV_NoLayers = 1,
LV_NoHierarchyPanel = 2,
LV_Naked = 4,
LV_NoZoom = 8,
LV_NoGrid = 16,
LV_NoMove = 32,
LV_NoTracker = 64,
LV_NoSelection = 128,
LV_NoPlugins = 256,
LV_NoLibrariesView = 4,
LV_Naked = 8,
LV_NoZoom = 16,
LV_NoGrid = 32,
LV_NoMove = 64,
LV_NoTracker = 128,
LV_NoSelection = 256,
LV_NoPlugins = 512,
LV_NoServices = LV_NoMove + LV_NoTracker + LV_NoSelection + LV_NoPlugins
};
@ -221,7 +223,7 @@ public:
bool has_selection ();
/**
* @brief Get the container with the layer control panel
* @brief Gets the container with the layer control panel
*/
QWidget *layer_control_frame ()
{
@ -229,7 +231,7 @@ public:
}
/**
* @brief Get the container with the hierarchy control panel
* @brief Gets the container with the hierarchy control panel
*/
QWidget *hierarchy_control_frame ()
{
@ -237,7 +239,15 @@ public:
}
/**
* @brief Paste from clipboard
* @brief Gets the container with the libraries view
*/
QWidget *libraries_frame ()
{
return mp_libraries_frame;
}
/**
* @brief Pastes from clipboard
*
* This reimplementation of the lay::Editables interface additionally
* looks for paste receivers in the tree views for example.
@ -245,7 +255,7 @@ public:
void paste ();
/**
* @brief Copy to clipboard
* @brief Copies to clipboard
*
* This reimplementation of the lay::Editables interface additionally
* looks for copy providers in the tree views for example.
@ -253,7 +263,7 @@ public:
void copy ();
/**
* @brief Cut to clipboard
* @brief Cuts to clipboard
*
* This reimplementation of the lay::Editables interface additionally
* looks for cut & copy providers in the tree views for example.
@ -261,7 +271,7 @@ public:
void cut ();
/**
* @brief Get the explicit title string of the view
* @brief Gets the explicit title string of the view
*
* This is the one explicitly set, not the one displayed. The displayed text is composed of internal information
* if no title string is set.
@ -272,17 +282,17 @@ public:
}
/**
* @brief Get the window title of the view
* @brief Gets the window title of the view
*/
std::string title () const;
/**
* @brief Set the window title to an explicit string
* @brief Sets the window title to an explicit string
*/
void set_title (const std::string &t);
/**
* @brief Reset the explicit title and enable the automatic naming
* @brief Resets the explicit title and enable the automatic naming
*/
void reset_title ();
@ -2695,7 +2705,8 @@ private:
QFrame *mp_left_frame;
lay::LayerControlPanel *mp_control_panel;
lay::HierarchyControlPanel *mp_hierarchy_panel;
QWidget *mp_control_frame, *mp_hierarchy_frame;
lay::LibrariesView *mp_libraries_view;
QWidget *mp_control_frame, *mp_hierarchy_frame, *mp_libraries_frame;
QSpinBox *mp_min_hier_spbx;
QSpinBox *mp_max_hier_spbx;
std::list <CellView> m_cellviews;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,310 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2019 Matthias Koefferlein
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, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef HDR_layLibrariesView
#define HDR_layLibrariesView
#include <vector>
#include <string>
#include <algorithm>
#include <QFrame>
#include <QTreeView>
#include "dbLayout.h"
#include "layCanvasPlane.h"
#include "layViewOp.h"
#include "layLayoutView.h"
#include "layCellTreeModel.h"
#include "layWidgets.h"
#include "tlDeferredExecution.h"
class QModelIndex;
class QComboBox;
class QMenu;
class QSplitter;
class QFrame;
class QToolButton;
class QLineEdit;
class QAction;
class QCheckBox;
namespace lay
{
/**
* @brief A special QTreeView customization
*
* A customized QTreeView that is used to receive middle-mouse-button
* events and processes double clicks by bypassing the standard implementation
* that closes and opens branches.
*/
class LibraryTreeWidget
: public QTreeView
{
Q_OBJECT
public:
LibraryTreeWidget (QWidget *parent, const char *name, QWidget *key_event_receiver);
signals:
void cell_clicked (const QModelIndex &);
void cell_double_clicked (const QModelIndex &);
void cell_middle_clicked (const QModelIndex &);
void search_triggered (const QString &t);
protected:
virtual void mouseDoubleClickEvent (QMouseEvent *event);
virtual void mousePressEvent (QMouseEvent *event);
virtual void mouseReleaseEvent (QMouseEvent *event);
virtual void startDrag (Qt::DropActions supportedActions);
virtual bool focusNextPrevChild (bool next);
virtual void keyPressEvent (QKeyEvent *event);
virtual bool event (QEvent *event);
QWidget *mp_key_event_receiver;
};
/**
* @brief The hierarchy control panel
*
* The hierarchy control panel allows changing the cell shown, to
* browse the hierarchy and disable/enable cells
*
* The class communicates with a Layout interface for
* retrieval of the cell hierarchy
*/
class LibrariesView
: public QFrame,
public tl::Object
{
Q_OBJECT
public:
/**
* @brief Constructor
*
* @param parent The Qt parent widget
* @param name The layer control panel's widget name
*/
LibrariesView (lay::LayoutView *view, QWidget *parent = 0, const char *name = "libraries_view");
/**
* @brief Destructor
*/
~LibrariesView ();
/**
* @brief Perform the cell control panel's initialisations on the main menu
*/
static void init_menu (lay::AbstractMenu &menu);
/**
* @brief The sizeHint implementation for Qt layout management
*/
virtual QSize sizeHint () const;
/**
* @brief Changing of the background color
*/
void set_background_color (QColor c);
/**
* @brief Changing of the text color
*/
void set_text_color (QColor c);
#if 0 // @@@
/**
* @brief Select the active cellview
*
* selects the active cellview by index. The index must be
* a valid index within the context of the layout view.
*/
void select_active (int cellview_index);
/**
* @brief Get the active cellview
*
* get the active cellview index.
*/
int active ()
{
return m_active_index;
}
/**
* @brief Returns the paths of the selected cells
*/
void selected_cells (int cv_index, std::vector<cell_path_type> &paths) const;
/**
* @brief Return the path to the current cell for the given cellview index
*
* The current cell is the cell that is highlighted.
*/
void current_cell (int cv_index, cell_path_type &path) const;
/**
* @brief Set the path to the current cell
*
* The current cell is the cell that is highlighted. The current cv index
* can be obtained with the "active" method.
*/
void set_current_cell (int cv_index, const cell_path_type &path);
/**
* @brief Update the contents if necessary
*
* Update the cell trees according to the hierarchy found in
* the layouts. This version includes a hint which cellview has changed.
*/
void do_update_content (int cv_index);
/**
* @brief Update the contents if necessary
*
* Update the cell trees according to the hierarchy found in
* the layouts.
*/
void do_update_content ()
{
do_update_content (-1);
}
#endif
/**
* @brief Event handler
*
* The object subclasses the event handler in order to intercept
* the GTF probe events (Qt::MaxUser).
*/
virtual bool event (QEvent *e);
/**
* @brief Return true, if the tree view has the focus
*/
bool has_focus () const;
/**
* @brief Select split mode
* In split mode all cell trees are shown stacked
*/
void set_split_mode (bool sbs);
/**
* @brief Returns true if side-by-side mode is set
*/
bool split_mode () const
{
return m_split_mode;
}
/**
* @brief Gets the layout view this panel is attached to
*/
lay::LayoutView *view ()
{
return mp_view;
}
#if 0
signals:
void cell_selected (cell_path_type path, int cellview_index);
void active_cellview_changed (int cellview_index);
#endif
public slots:
void clicked (const QModelIndex &index);
void header_clicked ();
void double_clicked (const QModelIndex &index);
void middle_clicked (const QModelIndex &index);
// @@@ void selection_changed (int index);
void context_menu (const QPoint &pt);
void search_triggered (const QString &t);
void search_edited ();
void search_editing_finished ();
void search_next ();
void search_prev ();
void cm_cell_select ();
private:
db::Layout *mp_layout;
bool m_enable_cb;
lay::LayoutView *mp_view;
std::vector <QTreeView *> mp_cell_lists;
std::vector <QToolButton *> mp_cell_list_headers;
std::vector <QFrame *> mp_cell_list_frames;
std::vector <bool> m_force_close;
std::vector <bool> m_needs_update;
int m_active_index;
bool m_split_mode;
QComboBox *mp_selector;
lay::DecoratedLineEdit *mp_search_edit_box;
QAction *mp_case_sensitive;
QAction *mp_use_regular_expressions;
CellTreeModel *mp_search_model;
QFrame *mp_search_frame;
QCheckBox *mp_search_close_cb;
QSplitter *mp_splitter;
QColor m_background_color;
QColor m_text_color;
tl::DeferredMethod<LibrariesView> m_do_update_content_dm;
tl::DeferredMethod<LibrariesView> m_do_full_update_content_dm;
std::auto_ptr<QStyle> mp_tree_style;
#if 0 // @@@
// locate the CellTreeItem in the tree corresponding to a partial path starting from p.
CellTreeItem *find_child_item (cell_path_type::const_iterator start, cell_path_type::const_iterator end, CellTreeItem *p);
// get the current item
CellTreeItem *current_item () const;
// event listener for changes in the cellview and layout
void update_required ();
// path from index and item from path ..
void path_from_index (const QModelIndex &index, int cv_index, cell_path_type &path) const;
QModelIndex index_from_path (const cell_path_type &path, int cv_index);
// display string of nth cellview
std::string display_string (int n) const;
// select active cellview from sender (sender must be a cell tree)
void set_active_celltree_from_sender ();
// clears all widgets of the cell lists
void clear_all ();
#endif
// forces a complete update
void do_full_update_content ();
// updates the contents if necessary
void do_update_content ();
};
} // namespace lay
#endif

View File

@ -175,7 +175,8 @@ SOURCES = \
layNetlistBrowserModel.cc \
layIndexedNetlistModel.cc \
layNetlistCrossReferenceModel.cc \
layNetlistBrowserTreeModel.cc
layNetlistBrowserTreeModel.cc \
layLibrariesView.cc
HEADERS = \
gtf.h \
@ -271,7 +272,8 @@ HEADERS = \
layNetlistBrowserModel.h \
layIndexedNetlistModel.h \
layNetlistCrossReferenceModel.h \
layNetlistBrowserTreeModel.h
layNetlistBrowserTreeModel.h \
layLibrariesView.h
INCLUDEPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC
DEPENDPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC