From 2e1afc846a2c405cc9c4399bdeca88d76471d109 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 10 Aug 2025 23:33:02 +0200 Subject: [PATCH 1/5] Small bug fixed --- src/db/db/dbCompoundOperation.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/db/db/dbCompoundOperation.cc b/src/db/db/dbCompoundOperation.cc index 80445387f..393010cd1 100644 --- a/src/db/db/dbCompoundOperation.cc +++ b/src/db/db/dbCompoundOperation.cc @@ -308,7 +308,10 @@ CompoundRegionMultiInputOperationNode::CompoundRegionMultiInputOperationNode (co (*c)->keep (); m_children.push_back (*c); } - init (); + + if (! no_init) { + init (); + } } CompoundRegionMultiInputOperationNode::CompoundRegionMultiInputOperationNode () From ef2b164e1a88bc40c650a3701ffaf83de0590da5 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 15 Aug 2025 15:00:10 +0200 Subject: [PATCH 2/5] Bugfix: properly supporting Undo on 'apply technology' (layer properties were cleared) --- src/laybasic/laybasic/layLayoutViewBase.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index f870f7dc5..a11ddf17a 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -2642,7 +2642,9 @@ LayoutViewBase::signal_apply_technology (lay::LayoutHandle *layout_handle) // remove all references to the cellview in the layer properties for (unsigned int lindex = 0; lindex < layer_lists (); ++lindex) { - m_layer_properties_lists [lindex]->remove_cv_references (i); + lay::LayerPropertiesList props = *m_layer_properties_lists [lindex]; + props.remove_cv_references (i); + set_properties (lindex, props); } // if a layer properties file is set, create the layer properties now From 872eaabb75799cc941c925fc88c8ea9931070dcf Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 15 Aug 2025 15:23:54 +0200 Subject: [PATCH 3/5] Enhancement: 'relative' option of properties dialog is persisted now. --- src/lay/lay/layMainConfigPages.cc | 1 + src/laybasic/laybasic/laybasicConfig.h | 2 ++ src/layui/layui/layPropertiesDialog.cc | 27 ++++++++++++++++++++++++++ src/layui/layui/layPropertiesDialog.h | 2 ++ 4 files changed, 32 insertions(+) diff --git a/src/lay/lay/layMainConfigPages.cc b/src/lay/lay/layMainConfigPages.cc index 41afe1814..67f793e23 100644 --- a/src/lay/lay/layMainConfigPages.cc +++ b/src/lay/lay/layMainConfigPages.cc @@ -85,6 +85,7 @@ public: options.push_back (std::pair (cfg_reader_options_show_always, "false")); options.push_back (std::pair (cfg_assistant_bookmarks, "")); options.push_back (std::pair (cfg_always_exit_without_saving, "false")); + options.push_back (std::pair (cfg_properties_dialog_relative_mode, "true")); } virtual std::vector > config_pages (QWidget *parent) const diff --git a/src/laybasic/laybasic/laybasicConfig.h b/src/laybasic/laybasic/laybasicConfig.h index eb99c9d4b..47ec7a75f 100644 --- a/src/laybasic/laybasic/laybasicConfig.h +++ b/src/laybasic/laybasic/laybasicConfig.h @@ -158,6 +158,8 @@ static const std::string cfg_guiding_shape_color ("guiding-shape-color"); static const std::string cfg_guiding_shape_line_width ("guiding-shape-line-width"); static const std::string cfg_guiding_shape_vertex_size ("guiding-shape-vertex-size"); +static const std::string cfg_properties_dialog_relative_mode ("properties-dialog-relative-mode"); + } #endif diff --git a/src/layui/layui/layPropertiesDialog.cc b/src/layui/layui/layPropertiesDialog.cc index edd85844b..7f6a938c8 100644 --- a/src/layui/layui/layPropertiesDialog.cc +++ b/src/layui/layui/layPropertiesDialog.cc @@ -27,6 +27,8 @@ #include "tlLog.h" #include "layEditable.h" #include "layProperties.h" +#include "layDispatcher.h" +#include "laybasicConfig.h" #include "tlExceptions.h" #include "ui_PropertiesDialog.h" @@ -246,6 +248,8 @@ PropertiesDialog::PropertiesDialog (QWidget * /*parent*/, db::Manager *manager, mp_ui->apply_to_all_cbx->setChecked (false); mp_ui->relative_cbx->setChecked (true); + fetch_config (); + connect (mp_ui->ok_button, SIGNAL (clicked ()), this, SLOT (ok_pressed ())); connect (mp_ui->cancel_button, SIGNAL (clicked ()), this, SLOT (cancel_pressed ())); connect (mp_ui->prev_button, SIGNAL (clicked ()), this, SLOT (prev_pressed ())); @@ -263,6 +267,26 @@ PropertiesDialog::~PropertiesDialog () disconnect (); } +void +PropertiesDialog::fetch_config () +{ + if (! lay::Dispatcher::instance ()) { + return; + } + + bool rm = true; + lay::Dispatcher::instance ()->config_get (cfg_properties_dialog_relative_mode, rm); + mp_ui->relative_cbx->setChecked (rm); +} + +void +PropertiesDialog::store_config () +{ + if (lay::Dispatcher::instance ()) { + lay::Dispatcher::instance ()->config_set (cfg_properties_dialog_relative_mode, mp_ui->relative_cbx->isChecked ()); + } +} + void PropertiesDialog::disconnect () { @@ -617,6 +641,7 @@ PropertiesDialog::cancel_pressed () } + store_config (); // make sure that the property pages are no longer used .. disconnect (); // close the dialog @@ -641,6 +666,7 @@ BEGIN_PROTECTED } + store_config (); // make sure that the property pages are no longer used .. disconnect (); QDialog::accept (); @@ -651,6 +677,7 @@ END_PROTECTED void PropertiesDialog::reject () { + store_config (); // make sure that the property pages are no longer used .. disconnect (); QDialog::reject (); diff --git a/src/layui/layui/layPropertiesDialog.h b/src/layui/layui/layPropertiesDialog.h index 01e09db45..f9282c0b4 100644 --- a/src/layui/layui/layPropertiesDialog.h +++ b/src/layui/layui/layPropertiesDialog.h @@ -99,6 +99,8 @@ private: const std::vector &properties_pages () { return mp_properties_pages; } void disconnect (); + void fetch_config (); + void store_config (); bool any_prev () const; bool any_next () const; void update_title (); From 5bd74b73bb609c9092fcb26f5ba57da85e8d6754 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 15 Aug 2025 17:06:33 +0200 Subject: [PATCH 4/5] Enhancement: 'select highlighted objects' from properties dialog (object tree context menu) --- src/ant/ant/antPropertiesPage.cc | 13 +++ src/ant/ant/antPropertiesPage.h | 1 + src/ant/ant/antService.cc | 11 +++ src/ant/ant/antService.h | 7 +- src/edt/edt/edtInstPropertiesPage.cc | 20 +++++ src/edt/edt/edtInstPropertiesPage.h | 1 + src/edt/edt/edtPropertiesPages.cc | 23 +++++- src/edt/edt/edtPropertiesPages.h | 1 + src/img/img/imgPropertiesPage.cc | 13 +++ src/img/img/imgPropertiesPage.h | 1 + src/img/img/imgService.cc | 11 +++ src/img/img/imgService.h | 7 +- src/laybasic/laybasic/layProperties.h | 8 ++ src/layui/layui/PropertiesDialog.ui | 11 +++ src/layui/layui/layPropertiesDialog.cc | 109 ++++++++++++++++++++++++- src/layui/layui/layPropertiesDialog.h | 1 + 16 files changed, 231 insertions(+), 7 deletions(-) diff --git a/src/ant/ant/antPropertiesPage.cc b/src/ant/ant/antPropertiesPage.cc index 15e19315e..964deaf08 100644 --- a/src/ant/ant/antPropertiesPage.cc +++ b/src/ant/ant/antPropertiesPage.cc @@ -419,6 +419,19 @@ PropertiesPage::description () const return tl::to_string (tr ("Rulers and Annotations")); } +void +PropertiesPage::confine_selection (const std::vector &remaining_entries) +{ + std::vector org_selection; + m_selection.swap (org_selection); + for (auto i = remaining_entries.begin (); i != remaining_entries.end (); ++i) { + m_selection.push_back (org_selection [*i]); + } + + mp_rulers->set_selection (m_selection); + mp_rulers->clear_highlights (); +} + void PropertiesPage::leave () { diff --git a/src/ant/ant/antPropertiesPage.h b/src/ant/ant/antPropertiesPage.h index c98c42d91..e239b1fa5 100644 --- a/src/ant/ant/antPropertiesPage.h +++ b/src/ant/ant/antPropertiesPage.h @@ -47,6 +47,7 @@ public: virtual void select_entries (const std::vector &entries); virtual std::string description (size_t entry) const; virtual std::string description () const; + virtual void confine_selection (const std::vector &remaining_entries); virtual void update (); virtual void leave (); virtual bool readonly (); diff --git a/src/ant/ant/antService.cc b/src/ant/ant/antService.cc index b1ea0441d..bccdb0a8d 100644 --- a/src/ant/ant/antService.cc +++ b/src/ant/ant/antService.cc @@ -2672,6 +2672,17 @@ Service::get_selection (std::vector &sel) const } } +void +Service::set_selection (const std::vector &selection) +{ + m_selected.clear (); + for (auto i = selection.begin (); i != selection.end (); ++i) { + m_selected.insert (std::make_pair (*i, 0)); + } + + selection_to_view (); +} + void Service::delete_ruler (obj_iterator pos) { diff --git a/src/ant/ant/antService.h b/src/ant/ant/antService.h index 3bbee87a8..89fe680a2 100644 --- a/src/ant/ant/antService.h +++ b/src/ant/ant/antService.h @@ -381,10 +381,15 @@ public: #endif /** - * @brief Get the selection for the properties page + * @brief Gets the selection for the properties page */ void get_selection (std::vector &selection) const; + /** + * @brief Sets the selection for the properties page + */ + void set_selection (const std::vector &selection); + /** * @brief Direct access to the selection */ diff --git a/src/edt/edt/edtInstPropertiesPage.cc b/src/edt/edt/edtInstPropertiesPage.cc index de27a4d90..f910d307f 100644 --- a/src/edt/edt/edtInstPropertiesPage.cc +++ b/src/edt/edt/edtInstPropertiesPage.cc @@ -330,6 +330,26 @@ InstPropertiesPage::description () const return tl::to_string (tr ("Instances")); } +void +InstPropertiesPage::confine_selection (const std::vector &remaining_entries) +{ + std::vector new_selection; + for (auto i = remaining_entries.begin (); i != remaining_entries.end (); ++i) { + new_selection.push_back (*m_selection_ptrs [*i]); + } + + mp_service->set_selection (new_selection.begin (), new_selection.end ()); + + m_selection_ptrs.clear (); + m_selection_ptrs.reserve (mp_service->selection_size ()); + for (edt::EditableSelectionIterator s = mp_service->begin_selection (); ! s.at_end (); ++s) { + m_selection_ptrs.push_back (s.operator-> ()); + } + + m_prop_id = 0; + mp_service->clear_highlights (); +} + void InstPropertiesPage::leave () { diff --git a/src/edt/edt/edtInstPropertiesPage.h b/src/edt/edt/edtInstPropertiesPage.h index f00a1a659..694627a9d 100644 --- a/src/edt/edt/edtInstPropertiesPage.h +++ b/src/edt/edt/edtInstPropertiesPage.h @@ -51,6 +51,7 @@ public: virtual void select_entries (const std::vector &entries); virtual std::string description (size_t entry) const; virtual std::string description () const; + virtual void confine_selection (const std::vector &remaining_entries); virtual void leave (); private: diff --git a/src/edt/edt/edtPropertiesPages.cc b/src/edt/edt/edtPropertiesPages.cc index 26b1def30..5cdbeb85d 100644 --- a/src/edt/edt/edtPropertiesPages.cc +++ b/src/edt/edt/edtPropertiesPages.cc @@ -137,12 +137,33 @@ ShapePropertiesPage::icon (size_t entry, int w, int h) const return QIcon (); } + std::string ShapePropertiesPage::description () const { return m_description; } +void +ShapePropertiesPage::confine_selection (const std::vector &remaining_entries) +{ + std::vector new_selection; + for (auto i = remaining_entries.begin (); i != remaining_entries.end (); ++i) { + new_selection.push_back (*m_selection_ptrs [*i]); + } + + mp_service->set_selection (new_selection.begin (), new_selection.end ()); + + m_selection_ptrs.clear (); + m_selection_ptrs.reserve (mp_service->selection_size ()); + for (edt::EditableSelectionIterator s = mp_service->begin_selection (); ! s.at_end (); ++s) { + m_selection_ptrs.push_back (s.operator-> ()); + } + + m_prop_id = 0; + mp_service->clear_highlights (); +} + void ShapePropertiesPage::leave () { @@ -661,7 +682,7 @@ BoxPropertiesPage::description (size_t entry) const return ShapePropertiesPage::description (entry) + " - " + tl::sprintf (tl::to_string (tr ("Box%s")), (dbu_trans * sh.box ()).to_string ()); } -void +void BoxPropertiesPage::do_update (const db::Shape &shape, double dbu, const std::string &lname) { m_dbu = dbu; diff --git a/src/edt/edt/edtPropertiesPages.h b/src/edt/edt/edtPropertiesPages.h index 60d844f50..5e575cb16 100644 --- a/src/edt/edt/edtPropertiesPages.h +++ b/src/edt/edt/edtPropertiesPages.h @@ -54,6 +54,7 @@ public: virtual void select_entries (const std::vector &entries); virtual std::string description (size_t entry) const; virtual std::string description () const; + virtual void confine_selection (const std::vector &remaining_entries); virtual QIcon icon (size_t entry, int w, int h) const; virtual QIcon icon (int w, int h) const { return lay::PropertiesPage::icon (w, h); } virtual void leave (); diff --git a/src/img/img/imgPropertiesPage.cc b/src/img/img/imgPropertiesPage.cc index 056e7e5ce..b5663d8aa 100644 --- a/src/img/img/imgPropertiesPage.cc +++ b/src/img/img/imgPropertiesPage.cc @@ -192,6 +192,19 @@ PropertiesPage::description () const return tl::to_string (tr ("Images")); } +void +PropertiesPage::confine_selection (const std::vector &remaining_entries) +{ + std::vector org_selection; + m_selection.swap (org_selection); + for (auto i = remaining_entries.begin (); i != remaining_entries.end (); ++i) { + m_selection.push_back (org_selection [*i]); + } + + mp_service->set_selection (m_selection); + mp_service->clear_highlights (); +} + void PropertiesPage::leave () { diff --git a/src/img/img/imgPropertiesPage.h b/src/img/img/imgPropertiesPage.h index e715f99cd..32f453a1e 100644 --- a/src/img/img/imgPropertiesPage.h +++ b/src/img/img/imgPropertiesPage.h @@ -54,6 +54,7 @@ public: virtual void select_entries (const std::vector &entries); virtual std::string description (size_t entry) const; virtual std::string description () const; + virtual void confine_selection (const std::vector &remaining_entries); virtual void update (); virtual void leave (); virtual bool readonly (); diff --git a/src/img/img/imgService.cc b/src/img/img/imgService.cc index 3b1c85589..9e5f6b072 100644 --- a/src/img/img/imgService.cc +++ b/src/img/img/imgService.cc @@ -1402,6 +1402,17 @@ Service::get_selection (std::vector &sel) const } } +void +Service::set_selection (const std::vector &selection) +{ + m_selected.clear (); + for (auto i = selection.begin (); i != selection.end (); ++i) { + m_selected.insert (std::make_pair (*i, 0)); + } + + selection_to_view (); +} + void Service::erase_image (obj_iterator pos) { diff --git a/src/img/img/imgService.h b/src/img/img/imgService.h index 42b1cabea..4e637c987 100644 --- a/src/img/img/imgService.h +++ b/src/img/img/imgService.h @@ -377,10 +377,15 @@ public: #endif /** - * @brief Get the selection for the properties page + * @brief Gets the selection for the properties page */ void get_selection (std::vector &selection) const; + /** + * @brief Sets the selection for the properties page + */ + void set_selection (const std::vector &selection); + /** * @brief Direct access to the selection */ diff --git a/src/laybasic/laybasic/layProperties.h b/src/laybasic/laybasic/layProperties.h index 09b16c2b9..fc0e7cb08 100644 --- a/src/laybasic/laybasic/layProperties.h +++ b/src/laybasic/laybasic/layProperties.h @@ -119,6 +119,14 @@ public: return QIcon (); } + /** + * @brief Confines the selection to the given selection indexes + * + * After this operation, the selection entries are renumbered with only + * the remaining ones present. + */ + virtual void confine_selection (const std::vector &remaining_entries) = 0; + /** * @brief Update the display * diff --git a/src/layui/layui/PropertiesDialog.ui b/src/layui/layui/PropertiesDialog.ui index 10f1b72b1..a38872469 100644 --- a/src/layui/layui/PropertiesDialog.ui +++ b/src/layui/layui/PropertiesDialog.ui @@ -26,6 +26,9 @@ 0 + + Qt::ActionsContextMenu + QAbstractItemView::ExtendedSelection @@ -198,6 +201,14 @@ + + + Select highlighted rows + + + Reduce selection to highlighted rows + + diff --git a/src/layui/layui/layPropertiesDialog.cc b/src/layui/layui/layPropertiesDialog.cc index 7f6a938c8..4e29f628d 100644 --- a/src/layui/layui/layPropertiesDialog.cc +++ b/src/layui/layui/layPropertiesDialog.cc @@ -160,6 +160,16 @@ public: emit dataChanged (index (0, 0, QModelIndex ()), index (rowCount (QModelIndex ()) - 1, columnCount (QModelIndex ()) - 1, QModelIndex ())); } + void begin_reset_model () + { + beginResetModel (); + } + + void end_reset_model () + { + endResetModel (); + } + private: PropertiesDialog *mp_dialog; int m_icon_width, m_icon_height; @@ -202,9 +212,6 @@ PropertiesDialog::PropertiesDialog (QWidget * /*parent*/, db::Manager *manager, connect (mp_properties_pages [i], SIGNAL (edited ()), this, SLOT (properties_edited ())); } - // Necessary to maintain the page order for UI regression testing of 0.18 vs. 0.19 (because tl::Collection has changed to order) .. - std::reverse (mp_properties_pages.begin (), mp_properties_pages.end ()); - // Add a label as a dummy mp_none = new QLabel (QObject::tr ("No object with properties to display"), mp_ui->content_frame); mp_none->setAlignment (Qt::AlignHCenter | Qt::AlignVCenter); @@ -225,7 +232,6 @@ PropertiesDialog::PropertiesDialog (QWidget * /*parent*/, db::Manager *manager, update_title (); - // if at end disable the "Next" button and return (this may only happen at the first call) mp_tree_model = new PropertiesTreeModel (this, mp_ui->tree->iconSize ().width (), mp_ui->tree->iconSize ().height ()); mp_ui->tree->setModel (mp_tree_model); #if QT_VERSION >= 0x50000 @@ -235,6 +241,8 @@ PropertiesDialog::PropertiesDialog (QWidget * /*parent*/, db::Manager *manager, #endif mp_ui->tree->expandAll (); + mp_ui->tree->addAction (mp_ui->action_reduce_selection); + if (mp_properties_pages.empty ()) { mp_ui->tree->hide (); } @@ -255,6 +263,7 @@ PropertiesDialog::PropertiesDialog (QWidget * /*parent*/, db::Manager *manager, connect (mp_ui->prev_button, SIGNAL (clicked ()), this, SLOT (prev_pressed ())); connect (mp_ui->next_button, SIGNAL (clicked ()), this, SLOT (next_pressed ())); connect (mp_ui->apply_to_all_cbx, SIGNAL (clicked ()), this, SLOT (apply_to_all_pressed ())); + connect (mp_ui->action_reduce_selection, SIGNAL (triggered ()), this, SLOT (reduce_selection ())); connect (mp_ui->tree->selectionModel (), SIGNAL (currentChanged (const QModelIndex &, const QModelIndex &)), this, SLOT (current_index_changed (const QModelIndex &, const QModelIndex &))); connect (mp_ui->tree->selectionModel (), SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT (selection_changed ())); } @@ -311,6 +320,98 @@ PropertiesDialog::apply_to_all_pressed () m_signals_enabled = true; } +void +PropertiesDialog::reduce_selection () +{ +BEGIN_PROTECTED + + // apply pending changes + if (m_index >= 0 && m_index < int (mp_properties_pages.size ()) && ! mp_properties_pages [m_index]->readonly ()) { + + db::Transaction t (mp_manager, tl::to_string (QObject::tr ("Apply changes")), m_transaction_id); + + mp_properties_pages [m_index]->apply (true); + mp_properties_pages [m_index]->update (); + + if (! t.is_empty ()) { + m_transaction_id = t.id (); + } + + } + + // confine the selection + + mp_tree_model->begin_reset_model (); + + auto selection = mp_ui->tree->selectionModel ()->selectedIndexes (); + + for (std::vector ::iterator p = mp_properties_pages.begin (); p != mp_properties_pages.end (); ++p) { + + int page_index = int (p - mp_properties_pages.begin ()); + std::vector object_indexes; + + for (auto i = selection.begin (); i != selection.end (); ++i) { + if (mp_tree_model->parent (*i).isValid () && mp_tree_model->page_index (*i) == page_index) { + object_indexes.push_back (size_t (mp_tree_model->object_index (*i))); + } + } + + (*p)->confine_selection (object_indexes); + + } + + m_signals_enabled = false; + + // rebuild the properties pages as only the ones with remaining selection are shown + + for (std::vector ::iterator p = mp_properties_pages.begin (); p != mp_properties_pages.end (); ++p) { + delete *p; + } + mp_properties_pages.clear (); + m_index = -1; + + for (lay::Editables::iterator e = mp_editables->begin (); e != mp_editables->end (); ++e) { + auto pp = e->properties_pages (mp_manager, mp_ui->content_frame); + for (auto p = pp.begin (); p != pp.end (); ++p) { + if ((*p)->count () == 0) { + delete *p; + } else { + mp_properties_pages.push_back (*p); + } + } + } + for (size_t i = 0; i < mp_properties_pages.size (); ++i) { + mp_stack->addWidget (mp_properties_pages [i]); + connect (mp_properties_pages [i], SIGNAL (edited ()), this, SLOT (properties_edited ())); + } + + // count the total number of objects + m_objects = mp_editables->selection_size (); + m_current_object = 0; + + // look for next usable editable + m_index = 0; + m_object_indexes.clear (); + if (m_index >= int (mp_properties_pages.size ())) { + m_index = -1; + } else { + m_object_indexes.push_back (0); + } + + mp_tree_model->end_reset_model (); + + update_title (); + + mp_ui->tree->expandAll (); + mp_ui->tree->setCurrentIndex (mp_tree_model->index_for (m_index, 0)); + + m_signals_enabled = true; + + update_controls (); + +END_PROTECTED +} + void PropertiesDialog::selection_changed () { diff --git a/src/layui/layui/layPropertiesDialog.h b/src/layui/layui/layPropertiesDialog.h index f9282c0b4..88836860c 100644 --- a/src/layui/layui/layPropertiesDialog.h +++ b/src/layui/layui/layPropertiesDialog.h @@ -113,6 +113,7 @@ public slots: void cancel_pressed (); void ok_pressed (); void apply_to_all_pressed (); + void reduce_selection (); void current_index_changed (const QModelIndex &index, const QModelIndex &previous); void selection_changed (); From 437c48c1fb906fb0e27cde4936f5653dafc72ae7 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 15 Aug 2025 17:36:00 +0200 Subject: [PATCH 5/5] Some refactoring (getting rid of an unused attribute) --- src/ant/ant/antService.cc | 64 +++++++++++++++++++-------------------- src/ant/ant/antService.h | 6 ++-- src/ant/ant/gsiDeclAnt.cc | 4 +-- src/img/img/gsiDeclImg.cc | 4 +-- src/img/img/imgService.cc | 62 ++++++++++++++++++------------------- src/img/img/imgService.h | 9 +++--- 6 files changed, 72 insertions(+), 77 deletions(-) diff --git a/src/ant/ant/antService.cc b/src/ant/ant/antService.cc index bccdb0a8d..37ead1bac 100644 --- a/src/ant/ant/antService.cc +++ b/src/ant/ant/antService.cc @@ -1410,8 +1410,8 @@ Service::begin_move (lay::Editable::MoveMode mode, const db::DPoint &p, lay::ang double dmin = std::numeric_limits ::max (); const ant::Object *robj_min = 0; - for (std::map::const_iterator r = m_selected.begin (); r != m_selected.end (); ++r) { - const ant::Object *robj = dynamic_cast ((*r->first).ptr ()); + for (auto r = m_selected.begin (); r != m_selected.end (); ++r) { + const ant::Object *robj = dynamic_cast ((*r)->ptr ()); if (robj) { double d; if (is_selected (*robj, p, l, d)) { @@ -1425,9 +1425,9 @@ Service::begin_move (lay::Editable::MoveMode mode, const db::DPoint &p, lay::ang // further investigate what part to drag - for (std::map::const_iterator r = m_selected.begin (); r != m_selected.end (); ++r) { + for (auto r = m_selected.begin (); r != m_selected.end (); ++r) { - obj_iterator ri = r->first; + obj_iterator ri = *r; const ant::Object *robj = dynamic_cast ((*ri).ptr ()); if (robj && (! robj_min || robj == robj_min)) { @@ -1435,7 +1435,7 @@ Service::begin_move (lay::Editable::MoveMode mode, const db::DPoint &p, lay::ang // found anything: make the moved ruler the selection clear_selection (); - m_selected.insert (std::make_pair (ri, 0)); + m_selected.insert (ri); m_current = *robj; m_original = m_current; m_rulers.push_back (new ant::View (this, &m_current, true)); @@ -1492,7 +1492,7 @@ Service::begin_move (lay::Editable::MoveMode mode, const db::DPoint &p, lay::ang // found anything: make the moved ruler the selection clear_selection (); - m_selected.insert (std::make_pair (mp_view->annotation_shapes ().iterator_from_pointer (&*r), 0)); + m_selected.insert (mp_view->annotation_shapes ().iterator_from_pointer (&*r)); m_current = *robj; m_original = m_current; m_rulers.push_back (new ant::View (this, &m_current, true)); @@ -1667,16 +1667,16 @@ Service::end_move (const db::DPoint &, lay::angle_constraint_type) if (m_move_mode == MoveSelected) { // replace the rulers that were moved: - for (std::map::const_iterator s = m_selected.begin (); s != m_selected.end (); ++s) { + for (auto s = m_selected.begin (); s != m_selected.end (); ++s) { - const ant::Object *robj = dynamic_cast (s->first->ptr ()); + const ant::Object *robj = dynamic_cast ((*s)->ptr ()); if (robj) { // compute moved object and replace ant::Object *rnew = new ant::Object (*robj); rnew->transform (m_trans); int new_id = rnew->id (); - mp_view->annotation_shapes ().replace (s->first, db::DUserObject (rnew)); + mp_view->annotation_shapes ().replace (*s, db::DUserObject (rnew)); annotation_changed_event (new_id); } @@ -1690,7 +1690,7 @@ Service::end_move (const db::DPoint &, lay::angle_constraint_type) // replace the ruler that was moved m_current.clean_points (); - mp_view->annotation_shapes ().replace (m_selected.begin ()->first, db::DUserObject (new ant::Object (m_current))); + mp_view->annotation_shapes ().replace (*m_selected.begin (), db::DUserObject (new ant::Object (m_current))); annotation_changed_event (m_current.id ()); // clear the selection (that was artifically created before) @@ -1717,9 +1717,8 @@ Service::selection_to_view () } m_rulers.clear (); m_rulers.reserve (m_selected.size ()); - for (std::map::iterator r = m_selected.begin (); r != m_selected.end (); ++r) { - r->second = (unsigned int) m_rulers.size (); - const ant::Object *robj = dynamic_cast (r->first->ptr ()); + for (auto r = m_selected.begin (); r != m_selected.end (); ++r) { + const ant::Object *robj = dynamic_cast ((*r)->ptr ()); m_rulers.push_back (new ant::View (this, robj, true /*selected*/)); } } @@ -1728,8 +1727,8 @@ db::DBox Service::selection_bbox () { db::DBox box; - for (std::map::iterator r = m_selected.begin (); r != m_selected.end (); ++r) { - const ant::Object *robj = dynamic_cast (r->first->ptr ()); + for (auto r = m_selected.begin (); r != m_selected.end (); ++r) { + const ant::Object *robj = dynamic_cast ((*r)->ptr ()); if (robj) { box += robj->box (); } @@ -1741,16 +1740,16 @@ void Service::transform (const db::DCplxTrans &trans) { // replace the rulers that were transformed: - for (std::map::const_iterator s = m_selected.begin (); s != m_selected.end (); ++s) { + for (auto s = m_selected.begin (); s != m_selected.end (); ++s) { - const ant::Object *robj = dynamic_cast (s->first->ptr ()); + const ant::Object *robj = dynamic_cast ((*s)->ptr ()); if (robj) { // compute transformed object and replace int id = robj->id (); ant::Object *rnew = new ant::Object (*robj); rnew->transform (trans); - mp_view->annotation_shapes ().replace (s->first, db::DUserObject (rnew)); + mp_view->annotation_shapes ().replace (*s, db::DUserObject (rnew)); annotation_changed_event (id); } @@ -2173,9 +2172,8 @@ void Service::copy_selected () { // extract all selected rulers and paste in "micron" space - for (std::map::iterator r = m_selected.begin (); r != m_selected.end (); ++r) { - r->second = (unsigned int) m_rulers.size (); - const ant::Object *robj = dynamic_cast (r->first->ptr ()); + for (auto r = m_selected.begin (); r != m_selected.end (); ++r) { + const ant::Object *robj = dynamic_cast ((*r)->ptr ()); if (robj) { db::Clipboard::instance () += new db::ClipboardValue (*robj); } @@ -2212,7 +2210,7 @@ Service::paste () if (! new_objects.empty ()) { for (auto r = new_objects.begin (); r != new_objects.end (); ++r) { - m_selected.insert (std::make_pair (mp_view->annotation_shapes ().iterator_from_pointer (*r), 0)); + m_selected.insert (mp_view->annotation_shapes ().iterator_from_pointer (*r)); } selection_to_view (); @@ -2240,8 +2238,8 @@ Service::del_selected () // positions will hold a set of iterators that are to be erased std::vector positions; positions.reserve (m_selected.size ()); - for (std::map::iterator r = m_selected.begin (); r != m_selected.end (); ++r) { - positions.push_back (r->first); + for (auto r = m_selected.begin (); r != m_selected.end (); ++r) { + positions.push_back (*r); } // clear selection @@ -2276,7 +2274,7 @@ Service::select (obj_iterator obj, lay::Editable::SelectionMode mode) if (mode == lay::Editable::Replace || mode == lay::Editable::Add) { // select if (m_selected.find (obj) == m_selected.end ()) { - m_selected.insert (std::make_pair (obj, 0)); + m_selected.insert (obj); return true; } } else if (mode == lay::Editable::Reset) { @@ -2290,7 +2288,7 @@ Service::select (obj_iterator obj, lay::Editable::SelectionMode mode) if (m_selected.find (obj) != m_selected.end ()) { m_selected.erase (obj); } else { - m_selected.insert (std::make_pair (obj, 0)); + m_selected.insert (obj); } return true; } @@ -2312,7 +2310,7 @@ Service::click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mo // for single-point selections either exclude the current selection or the // accumulated previous selection from the search. - const std::map *exclude = 0; + const std::set *exclude = 0; if (mode == lay::Editable::Replace) { exclude = &m_previous_selection; } else if (mode == lay::Editable::Add) { @@ -2493,7 +2491,7 @@ Service::transient_to_selection () for (lay::AnnotationShapes::iterator r = mp_view->annotation_shapes ().begin (); r != mp_view->annotation_shapes ().end (); ++r) { const ant::Object *robj = dynamic_cast (r->ptr ()); if (robj == mp_transient_ruler->ruler ()) { - m_selected.insert (std::make_pair (r, 0)); + m_selected.insert (r); selection_to_view (); return; } @@ -2523,7 +2521,7 @@ Service::select (const db::DBox &box, lay::Editable::SelectionMode mode) // for single-point selections either exclude the current selection or the // accumulated previous selection from the search. - const std::map *exclude = 0; + const std::set *exclude = 0; if (mode == lay::Editable::Replace) { exclude = &m_previous_selection; } else if (mode == lay::Editable::Add) { @@ -2605,7 +2603,7 @@ Service::select (const db::DBox &box, lay::Editable::SelectionMode mode) // select the one that was found if (any_selected) { select (mp_view->annotation_shapes ().iterator_from_pointer (&*rmin), mode); - m_previous_selection.insert (std::make_pair (mp_view->annotation_shapes ().iterator_from_pointer (&*rmin), mode)); + m_previous_selection.insert (mp_view->annotation_shapes ().iterator_from_pointer (&*rmin)); needs_update = true; } @@ -2667,8 +2665,8 @@ Service::get_selection (std::vector &sel) const sel.reserve (m_selected.size ()); // positions will hold a set of iterators that are to be erased - for (std::map::const_iterator r = m_selected.begin (); r != m_selected.end (); ++r) { - sel.push_back (r->first); + for (auto r = m_selected.begin (); r != m_selected.end (); ++r) { + sel.push_back (*r); } } @@ -2677,7 +2675,7 @@ Service::set_selection (const std::vector &selection) { m_selected.clear (); for (auto i = selection.begin (); i != selection.end (); ++i) { - m_selected.insert (std::make_pair (*i, 0)); + m_selected.insert (*i); } selection_to_view (); diff --git a/src/ant/ant/antService.h b/src/ant/ant/antService.h index 89fe680a2..509d00289 100644 --- a/src/ant/ant/antService.h +++ b/src/ant/ant/antService.h @@ -393,7 +393,7 @@ public: /** * @brief Direct access to the selection */ - const std::map &selection () const + const std::set &selection () const { return m_selected; } @@ -563,9 +563,9 @@ private: // and the moved rules in move mode std::vector m_rulers; // The selection - std::map m_selected; + std::set m_selected; // The previous selection - std::map m_previous_selection; + std::set m_previous_selection; // The reference point in move mode db::DPoint m_p1; // The transformation in MoveSelection mode diff --git a/src/ant/ant/gsiDeclAnt.cc b/src/ant/ant/gsiDeclAnt.cc index a86f84ae7..e5087c2e6 100644 --- a/src/ant/ant/gsiDeclAnt.cc +++ b/src/ant/ant/gsiDeclAnt.cc @@ -1263,7 +1263,7 @@ class AnnotationSelectionIterator { public: typedef AnnotationRef value_type; - typedef std::map::const_iterator iterator_type; + typedef std::set::const_iterator iterator_type; typedef void pointer; typedef value_type reference; typedef std::forward_iterator_tag iterator_category; @@ -1292,7 +1292,7 @@ public: reference operator* () const { - return value_type (*(static_cast (m_iter->first->ptr ())), m_services[m_service]->view ()); + return value_type (*(static_cast ((*m_iter)->ptr ())), m_services[m_service]->view ()); } private: diff --git a/src/img/img/gsiDeclImg.cc b/src/img/img/gsiDeclImg.cc index 3ec2e3cd8..549367b89 100644 --- a/src/img/img/gsiDeclImg.cc +++ b/src/img/img/gsiDeclImg.cc @@ -1272,7 +1272,7 @@ class SelectionIterator { public: typedef ImageRef value_type; - typedef std::map::const_iterator iterator_type; + typedef std::set::const_iterator iterator_type; typedef void pointer; typedef value_type reference; typedef std::forward_iterator_tag iterator_category; @@ -1301,7 +1301,7 @@ public: value_type operator* () const { - return value_type (*(dynamic_cast (m_iter->first->ptr ())), m_services[m_service]->view ()); + return value_type (*(dynamic_cast ((*m_iter)->ptr ())), m_services[m_service]->view ()); } private: diff --git a/src/img/img/imgService.cc b/src/img/img/imgService.cc index 9e5f6b072..5f23b5892 100644 --- a/src/img/img/imgService.cc +++ b/src/img/img/imgService.cc @@ -609,11 +609,11 @@ Service::begin_move (lay::Editable::MoveMode mode, const db::DPoint &p, lay::ang } else if (mode == lay::Editable::Partial) { // test, whether we are moving a handle of one selected object - for (std::map::const_iterator s = m_selected.begin (); s != m_selected.end (); ++s) { + for (auto s = m_selected.begin (); s != m_selected.end (); ++s) { MoveMode mm = move_none; size_t ml = 0; - obj_iterator si = s->first; + obj_iterator si = *s; const img::Object *iobj = dynamic_cast ((*si).ptr ()); if (iobj && dragging_what (iobj, search_dbox, mm, ml, m_p1) && mm != move_all) { @@ -624,7 +624,7 @@ Service::begin_move (lay::Editable::MoveMode mode, const db::DPoint &p, lay::ang // found a handle of one of the selected object: make the moved image the selection clear_selection (); - m_selected.insert (std::make_pair (si, 0)); + m_selected.insert (si); m_current = *iobj; m_initial = m_current; m_selected_image_views.push_back (new img::View (this, &m_current, img::View::mode_transient_move)); @@ -661,7 +661,7 @@ Service::begin_move (lay::Editable::MoveMode mode, const db::DPoint &p, lay::ang // found anything: make the moved image the selection clear_selection (); - m_selected.insert (std::make_pair (mp_view->annotation_shapes ().iterator_from_pointer (robj), 0)); + m_selected.insert (mp_view->annotation_shapes ().iterator_from_pointer (robj)); m_current = *iobj; m_initial = m_current; m_selected_image_views.push_back (new img::View (this, &m_current, img::View::mode_transient_move)); @@ -865,15 +865,15 @@ Service::end_move (const db::DPoint &, lay::angle_constraint_type) if (m_move_mode == move_selected) { // replace the images that were moved: - for (std::map::const_iterator s = m_selected.begin (); s != m_selected.end (); ++s) { + for (auto s = m_selected.begin (); s != m_selected.end (); ++s) { - const img::Object *iobj = dynamic_cast (s->first->ptr ()); + const img::Object *iobj = dynamic_cast ((*s)->ptr ()); // compute moved object and replace // KLUDGE: this creates a copy of the data! img::Object *inew = new img::Object (*iobj); inew->transform (m_trans); - int id = obj2id (mp_view->annotation_shapes ().replace (s->first, db::DUserObject (inew))); + int id = obj2id (mp_view->annotation_shapes ().replace (*s, db::DUserObject (inew))); image_changed_event (id); @@ -886,7 +886,7 @@ Service::end_move (const db::DPoint &, lay::angle_constraint_type) // replace the image that was moved img::Object *inew = new img::Object (m_current); - int id = obj2id (mp_view->annotation_shapes ().replace (m_selected.begin ()->first, db::DUserObject (inew))); + int id = obj2id (mp_view->annotation_shapes ().replace (*m_selected.begin (), db::DUserObject (inew))); image_changed_event (id); // clear the selection (that was artificially created before) @@ -900,7 +900,7 @@ Service::end_move (const db::DPoint &, lay::angle_constraint_type) // replace the image that was moved img::Object *inew = new img::Object (m_current); - int id = obj2id (mp_view->annotation_shapes ().replace (m_selected.begin ()->first, db::DUserObject (inew))); + int id = obj2id (mp_view->annotation_shapes ().replace (*m_selected.begin (), db::DUserObject (inew))); image_changed_event (id); // clear the selection (that was artificially created before) @@ -919,7 +919,7 @@ Service::end_move (const db::DPoint &, lay::angle_constraint_type) } const db::DUserObject * -Service::find_image (const db::DPoint &p, const db::DBox &search_box, double l, double &dmin, const std::map *exclude) +Service::find_image (const db::DPoint &p, const db::DBox &search_box, double l, double &dmin, const std::set *exclude) { if (! m_images_visible) { return 0; @@ -967,9 +967,8 @@ Service::selection_to_view (img::View::Mode mode) m_selected_image_views.clear (); m_selected_image_views.reserve (m_selected.size ()); - for (std::map::iterator r = m_selected.begin (); r != m_selected.end (); ++r) { - r->second = (unsigned int) m_selected_image_views.size (); - m_selected_image_views.push_back (new img::View (this, r->first, mode)); + for (auto r = m_selected.begin (); r != m_selected.end (); ++r) { + m_selected_image_views.push_back (new img::View (this, *r, mode)); } } @@ -977,8 +976,8 @@ db::DBox Service::selection_bbox () { db::DBox box; - for (std::map::iterator r = m_selected.begin (); r != m_selected.end (); ++r) { - const img::Object *iobj = dynamic_cast (r->first->ptr ()); + for (auto r = m_selected.begin (); r != m_selected.end (); ++r) { + const img::Object *iobj = dynamic_cast ((*r)->ptr ()); if (iobj) { box += iobj->box (); } @@ -990,14 +989,14 @@ void Service::transform (const db::DCplxTrans &trans) { // replace the images that were transformed: - for (std::map::const_iterator s = m_selected.begin (); s != m_selected.end (); ++s) { + for (auto s = m_selected.begin (); s != m_selected.end (); ++s) { - const img::Object *iobj = dynamic_cast (s->first->ptr ()); + const img::Object *iobj = dynamic_cast ((*s)->ptr ()); // compute transformed object and replace img::Object *inew = new img::Object (*iobj); inew->transform (trans); - int id = obj2id (mp_view->annotation_shapes ().replace (s->first, db::DUserObject (inew))); + int id = obj2id (mp_view->annotation_shapes ().replace (*s, db::DUserObject (inew))); image_changed_event (id); } @@ -1037,9 +1036,8 @@ void Service::copy_selected () { // extract all selected images and paste in "micron" space - for (std::map::iterator r = m_selected.begin (); r != m_selected.end (); ++r) { - r->second = (unsigned int) m_selected_image_views.size (); - const img::Object *iobj = dynamic_cast (r->first->ptr ()); + for (auto r = m_selected.begin (); r != m_selected.end (); ++r) { + const img::Object *iobj = dynamic_cast ((*r)->ptr ()); db::Clipboard::instance () += new db::ClipboardValue (*iobj); } } @@ -1077,8 +1075,8 @@ Service::del_selected () // positions will hold a set of iterators that are to be erased std::vector positions; positions.reserve (m_selected.size ()); - for (std::map::iterator r = m_selected.begin (); r != m_selected.end (); ++r) { - positions.push_back (r->first); + for (auto r = m_selected.begin (); r != m_selected.end (); ++r) { + positions.push_back (*r); } // clear selection @@ -1117,7 +1115,7 @@ void Service::transient_to_selection () { if (mp_transient_view) { - m_selected.insert (std::make_pair (mp_transient_view->image_ref (), 0)); + m_selected.insert (mp_transient_view->image_ref ()); selection_to_view (); } } @@ -1128,7 +1126,7 @@ Service::select (obj_iterator obj, lay::Editable::SelectionMode mode) if (mode == lay::Editable::Replace || mode == lay::Editable::Add) { // select if (m_selected.find (obj) == m_selected.end ()) { - m_selected.insert (std::make_pair (obj, 0)); + m_selected.insert (obj); return true; } } else if (mode == lay::Editable::Reset) { @@ -1142,7 +1140,7 @@ Service::select (obj_iterator obj, lay::Editable::SelectionMode mode) if (m_selected.find (obj) != m_selected.end ()) { m_selected.erase (obj); } else { - m_selected.insert (std::make_pair (obj, 0)); + m_selected.insert (obj); } return true; } @@ -1179,7 +1177,7 @@ Service::click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mo // for single-point selections either exclude the current selection or the // accumulated previous selection from the search. - const std::map *exclude = 0; + const std::set *exclude = 0; if (mode == lay::Editable::Replace) { exclude = &m_previous_selection; } else if (mode == lay::Editable::Add) { @@ -1273,7 +1271,7 @@ Service::select (const db::DBox &box, lay::Editable::SelectionMode mode) // for single-point selections either exclude the current selection or the // accumulated previous selection from the search. - const std::map *exclude = 0; + const std::set *exclude = 0; if (mode == lay::Editable::Replace) { exclude = &m_previous_selection; } else if (mode == lay::Editable::Add) { @@ -1339,7 +1337,7 @@ Service::select (const db::DBox &box, lay::Editable::SelectionMode mode) // select the one that was found if (robj) { select (mp_view->annotation_shapes ().iterator_from_pointer (robj), mode); - m_previous_selection.insert (std::make_pair (mp_view->annotation_shapes ().iterator_from_pointer (robj), mode)); + m_previous_selection.insert (mp_view->annotation_shapes ().iterator_from_pointer (robj)); needs_update = true; } @@ -1397,8 +1395,8 @@ Service::get_selection (std::vector &sel) const sel.reserve (m_selected.size ()); // positions will hold a set of iterators that are to be erased - for (std::map::const_iterator r = m_selected.begin (); r != m_selected.end (); ++r) { - sel.push_back (r->first); + for (auto r = m_selected.begin (); r != m_selected.end (); ++r) { + sel.push_back (*r); } } @@ -1407,7 +1405,7 @@ Service::set_selection (const std::vector &selection) { m_selected.clear (); for (auto i = selection.begin (); i != selection.end (); ++i) { - m_selected.insert (std::make_pair (*i, 0)); + m_selected.insert (*i); } selection_to_view (); diff --git a/src/img/img/imgService.h b/src/img/img/imgService.h index 4e637c987..266761f1f 100644 --- a/src/img/img/imgService.h +++ b/src/img/img/imgService.h @@ -389,7 +389,7 @@ public: /** * @brief Direct access to the selection */ - const std::map &selection () const + const std::set &selection () const { return m_selected; } @@ -491,11 +491,10 @@ private: // The view objects representing the selection and the moved images in move mode std::vector m_selected_image_views; - // The present views - only used for issueing a proper // The selection - std::map m_selected; + std::set m_selected; // The previous selection - std::map m_previous_selection; + std::set m_previous_selection; // The reference point in move mode db::DPoint m_p1; // The image object representing the image being moved as it was before it was moved @@ -546,7 +545,7 @@ private: /** * @brief Finds an image object from the given point */ - const db::DUserObject *find_image (const db::DPoint &p, const db::DBox &search_box, double l, double &dmin, const std::map *exclude = 0); + const db::DUserObject *find_image (const db::DPoint &p, const db::DBox &search_box, double l, double &dmin, const std::set *exclude = 0); /** * @brief Update m_selected_image_views to reflect the selection