mirror of https://github.com/KLayout/klayout.git
WIP: recent options for paths - now update on layer style change, some bug fixes, change of current layer will immediately change the drawing layer.
This commit is contained in:
parent
59d66676b0
commit
77ef3e049b
|
|
@ -462,7 +462,9 @@ commit_recent (lay::LayoutView *view)
|
|||
}
|
||||
|
||||
for (std::vector<edt::EditorOptionsPage *>::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) {
|
||||
(*op)->commit_recent (view);
|
||||
if ((*op)->active ()) {
|
||||
(*op)->commit_recent (view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ RecentConfigurationPage::init ()
|
|||
ly->addWidget (mp_tree_widget);
|
||||
|
||||
connect (mp_tree_widget, SIGNAL (itemClicked (QTreeWidgetItem *, int)), this, SLOT (item_clicked (QTreeWidgetItem *)));
|
||||
mp_view->layer_list_changed_event.add (this, &RecentConfigurationPage::layers_changed);
|
||||
|
||||
mp_tree_widget->setColumnCount (int (m_cfg.size ()));
|
||||
|
||||
|
|
@ -165,23 +166,32 @@ RecentConfigurationPage::render_to (QTreeWidgetItem *item, int column, const std
|
|||
|
||||
case RecentConfigurationPage::Layer:
|
||||
{
|
||||
// @@@ TODO: icons should be updated if style changes?
|
||||
int icon_size = mp_view->style ()->pixelMetric (QStyle::PM_ButtonIconSize);
|
||||
lay::LayerPropertiesConstIterator l = lp_iter_from_string (mp_view, values [column]);
|
||||
if (! l.at_end ()) {
|
||||
if (! l.is_null () && ! l.at_end ()) {
|
||||
item->setIcon (column, lay::LayerTreeModel::icon_for_layer (l, mp_view, icon_size, icon_size, 0, true));
|
||||
item->setText (column, tl::to_qstring (values [column]));
|
||||
} else {
|
||||
item->setIcon (column, QIcon ());
|
||||
item->setText (column, tl::to_qstring ("(" + values [column] + ")"));
|
||||
}
|
||||
item->setText (column, tl::to_qstring (values [column]));
|
||||
}
|
||||
break;
|
||||
|
||||
case RecentConfigurationPage::Int:
|
||||
case RecentConfigurationPage::Double:
|
||||
case RecentConfigurationPage::Text:
|
||||
case RecentConfigurationPage::CellLibraryName:
|
||||
item->setText (column, tl::to_qstring (values [column]));
|
||||
break;
|
||||
|
||||
case RecentConfigurationPage::CellLibraryName:
|
||||
if (values [column].empty ()) {
|
||||
item->setText (column, tr ("(local)"));
|
||||
} else {
|
||||
item->setText (column, tl::to_qstring (values [column]));
|
||||
}
|
||||
break;
|
||||
|
||||
case RecentConfigurationPage::IntIfArray:
|
||||
case RecentConfigurationPage::DoubleIfArray:
|
||||
{
|
||||
|
|
@ -262,6 +272,12 @@ RecentConfigurationPage::render_to (QTreeWidgetItem *item, int column, const std
|
|||
|
||||
}
|
||||
|
||||
void
|
||||
RecentConfigurationPage::layers_changed (int)
|
||||
{
|
||||
update_list (get_stored_values ());
|
||||
}
|
||||
|
||||
void
|
||||
RecentConfigurationPage::update_list (const std::list<std::vector<std::string> > &stored_values)
|
||||
{
|
||||
|
|
@ -333,7 +349,7 @@ RecentConfigurationPage::commit_recent (lay::Dispatcher *root)
|
|||
|
||||
std::string s;
|
||||
|
||||
if (mp_view->current_layer ()->is_visual ()) {
|
||||
if (!(mp_view->current_layer ().is_null () || mp_view->current_layer ().at_end ()) && mp_view->current_layer ()->is_visual ()) {
|
||||
|
||||
int cv_index = mp_view->current_layer ()->cellview_index ();
|
||||
const lay::CellView &cv = mp_view->cellview (cv_index);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#define HDR_edtRecentConfigurationPage
|
||||
|
||||
#include "edtEditorOptionsPage.h"
|
||||
#include "tlObject.h"
|
||||
|
||||
#include <list>
|
||||
#include <QTreeWidget>
|
||||
|
|
@ -45,7 +46,7 @@ class EditorOptionsPages;
|
|||
* @brief The base class for a object properties page
|
||||
*/
|
||||
class RecentConfigurationPage
|
||||
: public EditorOptionsPage
|
||||
: public EditorOptionsPage, public tl::Object
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
@ -104,6 +105,7 @@ private:
|
|||
std::list<std::vector<std::string> > get_stored_values () const;
|
||||
void set_stored_values (const std::list<std::vector<std::string> > &values) const;
|
||||
void render_to (QTreeWidgetItem *item, int column, const std::vector<std::string> &values, RecentConfigurationPage::ConfigurationRendering rendering);
|
||||
void layers_changed (int);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ ShapeEditService::ShapeEditService (db::Manager *manager, lay::LayoutView *view,
|
|||
: edt::Service (manager, view, shape_types),
|
||||
m_layer (0), m_cv_index (0), mp_cell (0), mp_layout (0), m_combine_mode (CM_Add)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
view->current_layer_changed_event.add (this, &ShapeEditService::update_edit_layer);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -74,13 +74,6 @@ ShapeEditService::get_edit_layer ()
|
|||
throw tl::Exception (tl::to_string (QObject::tr ("Please select a layer first")));
|
||||
}
|
||||
|
||||
if (! cl->visible (true)) {
|
||||
lay::TipDialog td (QApplication::activeWindow (),
|
||||
tl::to_string (QObject::tr ("You are about to draw on a hidden layer. The result won't be visible.")),
|
||||
"drawing-on-invisible-layer");
|
||||
td.exec_dialog ();
|
||||
}
|
||||
|
||||
int cv_index = cl->cellview_index ();
|
||||
const lay::CellView &cv = view ()->cellview (cv_index);
|
||||
int layer = cl->layer_index ();
|
||||
|
|
@ -89,6 +82,13 @@ ShapeEditService::get_edit_layer ()
|
|||
throw tl::Exception (tl::to_string (QObject::tr ("Please select a cell first")));
|
||||
}
|
||||
|
||||
if (! cl->visible (true)) {
|
||||
lay::TipDialog td (QApplication::activeWindow (),
|
||||
tl::to_string (QObject::tr ("You are about to draw on a hidden layer. The result won't be visible.")),
|
||||
"drawing-on-invisible-layer");
|
||||
td.exec_dialog ();
|
||||
}
|
||||
|
||||
if (layer < 0 || ! cv->layout ().is_valid_layer ((unsigned int) layer)) {
|
||||
|
||||
if (cl->has_children ()) {
|
||||
|
|
@ -129,6 +129,69 @@ ShapeEditService::get_edit_layer ()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
ShapeEditService::update_edit_layer (const lay::LayerPropertiesConstIterator &cl)
|
||||
{
|
||||
if (! editing ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cl.is_null () || cl->has_children ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int cv_index = cl->cellview_index ();
|
||||
const lay::CellView &cv = view ()->cellview (cv_index);
|
||||
int layer = cl->layer_index ();
|
||||
|
||||
if (cv_index < 0 || ! cv.is_valid ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cv->layout ().cell (cv.cell_index ()).is_proxy ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! cl->visible (true)) {
|
||||
lay::TipDialog td (QApplication::activeWindow (),
|
||||
tl::to_string (QObject::tr ("You are now drawing on a hidden layer. The result won't be visible.")),
|
||||
"drawing-on-invisible-layer");
|
||||
td.exec_dialog ();
|
||||
}
|
||||
|
||||
if (layer < 0 || ! cv->layout ().is_valid_layer ((unsigned int) layer)) {
|
||||
|
||||
// create this layer now
|
||||
const lay::ParsedLayerSource &source = cl->source (true /*real*/);
|
||||
|
||||
db::LayerProperties db_lp;
|
||||
if (source.has_name ()) {
|
||||
db_lp.name = source.name ();
|
||||
}
|
||||
db_lp.layer = source.layer ();
|
||||
db_lp.datatype = source.datatype ();
|
||||
|
||||
cv->layout ().insert_layer (db_lp);
|
||||
|
||||
// update the layer index inside the layer view
|
||||
cl->realize_source ();
|
||||
|
||||
// Hint: we could have taken the new index from insert_layer, but this
|
||||
// is a nice test:
|
||||
layer = cl->layer_index ();
|
||||
tl_assert (layer >= 0);
|
||||
|
||||
}
|
||||
|
||||
m_layer = (unsigned int) layer;
|
||||
m_cv_index = (unsigned int) cv_index;
|
||||
m_trans = (cl->trans ().front () * db::CplxTrans (cv->layout ().dbu ()) * cv.context_trans ()).inverted ();
|
||||
mp_layout = &(cv->layout ());
|
||||
mp_cell = &(mp_layout->cell (cv.cell_index ()));
|
||||
|
||||
current_layer_changed ();
|
||||
}
|
||||
|
||||
void
|
||||
ShapeEditService::tap (const db::DPoint &initial)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ protected:
|
|||
void deliver_shape (const db::Polygon &poly);
|
||||
void deliver_shape (const db::Path &path);
|
||||
void deliver_shape (const db::Box &box);
|
||||
virtual void current_layer_changed () { }
|
||||
|
||||
private:
|
||||
db::VCplxTrans m_trans;
|
||||
|
|
@ -74,6 +75,8 @@ private:
|
|||
db::Cell *mp_cell;
|
||||
db::Layout *mp_layout;
|
||||
combine_mode_type m_combine_mode;
|
||||
|
||||
void update_edit_layer (const lay::LayerPropertiesConstIterator &iter);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -299,17 +299,12 @@ LayerControlPanel::LayerControlPanel (lay::LayoutView *view, db::Manager *manage
|
|||
mp_model->set_font (mp_layer_list->font ());
|
||||
mp_layer_list->setIconSize (mp_model->icon_size ());
|
||||
|
||||
/*
|
||||
* At least with Qt 4.2.x setting uniform row heights has a strange side effect:
|
||||
* If a range is selected and the first selection is scrolled out of view, the
|
||||
* range does not include the first element after having clicked at the second.
|
||||
mp_layer_list->setUniformRowHeights (true);
|
||||
*/
|
||||
l->addWidget (mp_layer_list);
|
||||
connect (mp_layer_list, SIGNAL (double_clicked (const QModelIndex &, Qt::KeyboardModifiers)), this, SLOT (double_clicked (const QModelIndex &, Qt::KeyboardModifiers)));
|
||||
connect (mp_layer_list, SIGNAL (collapsed (const QModelIndex &)), this, SLOT (group_collapsed (const QModelIndex &)));
|
||||
connect (mp_layer_list, SIGNAL (expanded (const QModelIndex &)), this, SLOT (group_expanded (const QModelIndex &)));
|
||||
connect (mp_layer_list, SIGNAL (search_triggered (const QString &)), this, SLOT (search_triggered (const QString &)));
|
||||
connect (mp_layer_list->selectionModel (), SIGNAL (currentChanged (const QModelIndex &, const QModelIndex &)), this, SLOT (current_index_changed (const QModelIndex &)));
|
||||
mp_layer_list->setContextMenuPolicy (Qt::CustomContextMenu);
|
||||
connect (mp_layer_list, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT (context_menu (const QPoint &)));
|
||||
mp_layer_list->header ()->hide ();
|
||||
|
|
@ -2041,6 +2036,17 @@ LayerControlPanel::update_required (int f)
|
|||
m_do_update_content_dm ();
|
||||
}
|
||||
|
||||
void
|
||||
LayerControlPanel::current_index_changed (const QModelIndex &index)
|
||||
{
|
||||
lay::LayerPropertiesConstIterator iter = mp_model->iterator (index);
|
||||
if (! iter.is_null () && ! iter.at_end ()) {
|
||||
emit current_layer_changed (iter);
|
||||
} else {
|
||||
emit current_layer_changed (lay::LayerPropertiesConstIterator ());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LayerControlPanel::group_collapsed (const QModelIndex &index)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -284,6 +284,7 @@ public:
|
|||
signals:
|
||||
void order_changed ();
|
||||
void tab_changed ();
|
||||
void current_layer_changed (const lay::LayerPropertiesConstIterator &iter);
|
||||
|
||||
public slots:
|
||||
void cm_new_tab ();
|
||||
|
|
@ -321,6 +322,7 @@ public slots:
|
|||
void tab_context_menu (const QPoint &pt);
|
||||
void group_collapsed (const QModelIndex &index);
|
||||
void group_expanded (const QModelIndex &index);
|
||||
void current_index_changed (const QModelIndex &index);
|
||||
void up_clicked ();
|
||||
void upup_clicked ();
|
||||
void down_clicked ();
|
||||
|
|
|
|||
|
|
@ -595,6 +595,7 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/)
|
|||
connect (mp_control_frame, SIGNAL (destroyed ()), this, SLOT (side_panel_destroyed ()));
|
||||
connect (mp_control_panel, SIGNAL (tab_changed ()), this, SLOT (layer_tab_changed ()));
|
||||
connect (mp_control_panel, SIGNAL (order_changed ()), this, SLOT (layer_order_changed ()));
|
||||
connect (mp_control_panel, SIGNAL (current_layer_changed (const lay::LayerPropertiesConstIterator &)), this, SLOT (current_layer_changed_slot (const lay::LayerPropertiesConstIterator &)));
|
||||
/*
|
||||
connect (mp_control_panel, SIGNAL (marked_changed ()), this, SLOT (prop_changed ()));
|
||||
connect (mp_control_panel, SIGNAL (width_changed ()), this, SLOT (prop_changed ()));
|
||||
|
|
@ -5324,6 +5325,12 @@ LayoutView::layer_snapshot () const
|
|||
return state;
|
||||
}
|
||||
|
||||
void
|
||||
LayoutView::current_layer_changed_slot (const lay::LayerPropertiesConstIterator &iter)
|
||||
{
|
||||
current_layer_changed_event (iter);
|
||||
}
|
||||
|
||||
void
|
||||
LayoutView::add_new_layers (const LayerState &state)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -744,6 +744,12 @@ public:
|
|||
*/
|
||||
tl::event<int> current_layer_list_changed_event;
|
||||
|
||||
/**
|
||||
* @brief An event signalling that the current layer has changed
|
||||
*/
|
||||
tl::event<const lay::LayerPropertiesConstIterator &> current_layer_changed_event;
|
||||
|
||||
|
||||
/**
|
||||
* @brief An event signalling that the visibility of some cells has changed
|
||||
*/
|
||||
|
|
@ -2538,6 +2544,14 @@ public:
|
|||
*/
|
||||
void create_plugins (const lay::PluginDeclaration *except_this = 0);
|
||||
|
||||
/**
|
||||
* @brief Gets the full field box
|
||||
*
|
||||
* This is the box to which the view will zoom on zoom_fit().
|
||||
* This box is supposed to cover everything inside the view.
|
||||
*/
|
||||
db::DBox full_box () const;
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* @brief Store the current state on the "previous states" stack
|
||||
|
|
@ -2593,12 +2607,9 @@ public slots:
|
|||
void select_cell_dispatch (const cell_path_type &path, int cellview_index);
|
||||
|
||||
/**
|
||||
* @brief Gets the full field box
|
||||
*
|
||||
* This is the box to which the view will zoom on zoom_fit().
|
||||
* This box is supposed to cover everything inside the view.
|
||||
* @brief Called when the current layer changed
|
||||
*/
|
||||
db::DBox full_box () const;
|
||||
void current_layer_changed_slot (const lay::LayerPropertiesConstIterator &iter);
|
||||
|
||||
// zoom slots
|
||||
void zoom_fit ();
|
||||
|
|
@ -2685,6 +2696,11 @@ signals:
|
|||
*/
|
||||
void mode_change (int m);
|
||||
|
||||
/**
|
||||
* @brief The current layer changed
|
||||
*/
|
||||
void current_layer_changed (const lay::LayerPropertiesConstIterator &l);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Establish the view operations
|
||||
|
|
|
|||
Loading…
Reference in New Issue