diff --git a/src/edt/edt/edtMainService.cc b/src/edt/edt/edtMainService.cc index bee8c5b43..2477a7788 100644 --- a/src/edt/edt/edtMainService.cc +++ b/src/edt/edt/edtMainService.cc @@ -2409,7 +2409,7 @@ MainService::cm_change_layer () int cv_index = -1; // get (common) cellview index of the selected shapes - for (SelectionIterator s (view ()); ! s.at_end (); ++s) { + for (EditableSelectionIterator s = begin_objects_selected (view ()); ! s.at_end (); ++s) { if (cv_index >= 0 && cv_index != int (s->cv_index ())) { throw tl::Exception (tl::to_string (tr ("Selections originate from different layouts - cannot switch layer in this case."))); } @@ -2477,7 +2477,7 @@ MainService::cm_change_layer () // Insert and delete the shape. This exploits the fact, that a shape can be erased multiple times - // this is important since the selection potentially contains the same shape multiple times. - for (SelectionIterator s (view ()); ! s.at_end (); ++s) { + for (EditableSelectionIterator s = begin_objects_selected (view ()); ! s.at_end (); ++s) { if (!s->is_cell_inst () && int (s->layer ()) != layer) { diff --git a/src/edt/edt/edtService.cc b/src/edt/edt/edtService.cc index f001af81c..d0f766888 100644 --- a/src/edt/edt/edtService.cc +++ b/src/edt/edt/edtService.cc @@ -1994,10 +1994,16 @@ EditableSelectionIterator::operator++ () return *this; } -const EditableSelectionIterator::value_type & +EditableSelectionIterator::pointer +EditableSelectionIterator::operator-> () const +{ + return m_iter.operator-> (); +} + +EditableSelectionIterator::reference EditableSelectionIterator::operator* () const { - return *m_iter; + return m_iter.operator* (); } void diff --git a/src/edt/edt/edtService.h b/src/edt/edt/edtService.h index ac2e5ad4c..dc0250f81 100644 --- a/src/edt/edt/edtService.h +++ b/src/edt/edt/edtService.h @@ -700,7 +700,7 @@ class EditableSelectionIterator public: typedef edt::Service::objects::value_type value_type; typedef edt::Service::objects::const_iterator iterator_type; - typedef void pointer; + typedef const value_type *pointer; typedef const value_type &reference; typedef std::forward_iterator_tag iterator_category; typedef void difference_type; @@ -710,7 +710,8 @@ public: bool at_end () const; EditableSelectionIterator &operator++ (); - const value_type &operator* () const; + reference operator* () const; + pointer operator-> () const; private: std::vector m_services; diff --git a/src/edt/edt/edtUtils.cc b/src/edt/edt/edtUtils.cc index bcae4ea72..1aac2097f 100644 --- a/src/edt/edt/edtUtils.cc +++ b/src/edt/edt/edtUtils.cc @@ -74,73 +74,6 @@ std::map pcell_parameters_from_string (const std::stri return pm; } -// ------------------------------------------------------------- -// SelectionIterator implementation - -SelectionIterator::SelectionIterator (lay::LayoutViewBase *view, bool including_transient) - : m_transient_mode (false) -{ - mp_edt_services = view->get_plugins (); - - m_current_service = mp_edt_services.begin (); - if (m_current_service != mp_edt_services.end ()) { - m_current_object = (*m_current_service)->selection ().begin (); - } - - next (); - - if (at_end () && including_transient) { - - m_transient_mode = true; - - m_current_service = mp_edt_services.begin (); - if (m_current_service != mp_edt_services.end ()) { - m_current_object = (*m_current_service)->transient_selection ().begin (); - } - - next (); - - } -} - -bool -SelectionIterator::at_end () const -{ - return m_current_service == mp_edt_services.end (); -} - -void -SelectionIterator::inc () -{ - tl_assert (! at_end ()); - ++m_current_object; -} - -void -SelectionIterator::next () -{ - if (at_end ()) { - return; - } - - const edt::Service::objects *sel = m_transient_mode ? &(*m_current_service)->transient_selection () : &(*m_current_service)->selection (); - - while (m_current_object == sel->end ()) { - - ++m_current_service; - - if (m_current_service != mp_edt_services.end ()) { - - sel = m_transient_mode ? &(*m_current_service)->transient_selection () : &(*m_current_service)->selection (); - m_current_object = sel->begin (); - - } else { - break; - } - - } -} - // ------------------------------------------------------------- // TransformationsVariants implementation // for a lay::LayoutView diff --git a/src/edt/edt/edtUtils.h b/src/edt/edt/edtUtils.h index 17470054d..1f9afec79 100644 --- a/src/edt/edt/edtUtils.h +++ b/src/edt/edt/edtUtils.h @@ -92,73 +92,6 @@ private: std::map < std::pair, std::vector > m_per_cv_and_layer_tv; }; -/** - * @brief An iterator for the selected objects of all edt services in a layout view - */ -class SelectionIterator -{ -public: - typedef lay::ObjectInstPath value_type; - typedef const lay::ObjectInstPath &reference; - typedef const lay::ObjectInstPath *pointer; - - /** - * @brief Creates a new iterator iterating over all selected edt objects from the given view - * - * If "including_transient" is true, the transient selection will be used as fallback. - */ - SelectionIterator (lay::LayoutViewBase *view, bool including_transient = true); - - /** - * @brief Returns a value indicating whether the transient selection is taken - */ - bool is_transient () const - { - return m_transient_mode; - } - - /** - * @brief Increments the iterator - */ - void operator++ () - { - inc (); - next (); - } - - /** - * @brief Dereferencing - */ - const lay::ObjectInstPath &operator* () const - { - tl_assert (! at_end ()); - return *m_current_object; - } - - /** - * @brief Arrow operator - */ - const lay::ObjectInstPath *operator-> () const - { - return & operator* (); - } - - /** - * @brief Returns a value indicating whether the iterator has finished - */ - bool at_end () const; - -private: - void inc (); - void next (); - -private: - std::vector mp_edt_services; - std::vector::const_iterator m_current_service; - std::set::const_iterator m_current_object; - bool m_transient_mode; -}; - } // namespace edt #endif