Skip to content

Commit f0b15e1

Browse files
author
Matthias Koefferlein
committed
Merge branch 'master' of github.com:KLayout/klayout
2 parents f45095e + b4b2b57 commit f0b15e1

File tree

8 files changed

+110
-190
lines changed

8 files changed

+110
-190
lines changed

src/edt/edt/edtInstPropertiesPage.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,9 @@ static bool is_orthogonal (const db::DVector &rv, const db::DVector &cv)
104104
InstPropertiesPage::InstPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent)
105105
: lay::PropertiesPage (parent, manager, service), mp_service (service), m_enable_cb_callback (true), mp_pcell_parameters (0)
106106
{
107-
m_selection_ptrs.reserve (service->selection ().size ());
108-
for (edt::Service::obj_iterator s = service->selection ().begin (); s != service->selection ().end (); ++s) {
107+
const edt::Service::objects &selection = service->selection ();
108+
m_selection_ptrs.reserve (selection.size ());
109+
for (edt::Service::obj_iterator s = selection.begin (); s != selection.end (); ++s) {
109110
m_selection_ptrs.push_back (s);
110111
}
111112

@@ -787,7 +788,8 @@ InstPropertiesPage::recompute_selection_ptrs (const std::vector<lay::ObjectInstP
787788
{
788789
std::map<lay::ObjectInstPath, edt::Service::obj_iterator> ptrs;
789790

790-
for (edt::Service::obj_iterator pos = mp_service->selection ().begin (); pos != mp_service->selection ().end (); ++pos) {
791+
const edt::Service::objects &selection = mp_service->selection ();
792+
for (edt::Service::obj_iterator pos = selection.begin (); pos != selection.end (); ++pos) {
791793
ptrs.insert (std::make_pair (*pos, pos));
792794
}
793795

src/edt/edt/edtMainService.cc

Lines changed: 67 additions & 34 deletions
Large diffs are not rendered by default.

src/edt/edt/edtPropertiesPageUtils.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ CombinedChangeApplicator::~CombinedChangeApplicator ()
6868
bool CombinedChangeApplicator::supports_relative_mode () const
6969
{
7070
for (std::vector<ChangeApplicator *>::const_iterator a = m_appl.begin (); a != m_appl.end (); ++a) {
71-
if ((*a)->supports_relative_mode ()) {
71+
if ((*a) && (*a)->supports_relative_mode ()) {
7272
return true;
7373
}
7474
}

src/edt/edt/edtPropertiesPages.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ ShapePropertiesPage::ShapePropertiesPage (const std::string &description, edt::S
4747
: lay::PropertiesPage (parent, manager, service),
4848
m_description (description), mp_service (service), m_enable_cb_callback (true)
4949
{
50-
m_selection_ptrs.reserve (service->selection ().size ());
51-
for (edt::Service::obj_iterator s = service->selection ().begin (); s != service->selection ().end (); ++s) {
50+
const edt::Service::objects &selection = service->selection ();
51+
m_selection_ptrs.reserve (selection.size ());
52+
for (edt::Service::obj_iterator s = selection.begin (); s != selection.end (); ++s) {
5253
m_selection_ptrs.push_back (s);
5354
}
5455
m_prop_id = 0;
@@ -202,7 +203,8 @@ ShapePropertiesPage::recompute_selection_ptrs (const std::vector<lay::ObjectInst
202203
{
203204
std::map<lay::ObjectInstPath, edt::Service::obj_iterator> ptrs;
204205

205-
for (edt::Service::obj_iterator pos = mp_service->selection ().begin (); pos != mp_service->selection ().end (); ++pos) {
206+
const edt::Service::objects &selection = mp_service->selection ();
207+
for (edt::Service::obj_iterator pos = selection.begin (); pos != selection.end (); ++pos) {
206208
ptrs.insert (std::make_pair (*pos, pos));
207209
}
208210

src/edt/edt/edtService.cc

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,8 @@ Service::copy_selected ()
459459
unsigned int inst_mode = 0;
460460

461461
if (m_hier_copy_mode < 0) {
462-
for (objects::const_iterator r = selection ().begin (); r != selection ().end () && ! need_to_ask_for_copy_mode; ++r) {
462+
const objects &sel = selection ();
463+
for (objects::const_iterator r = sel.begin (); r != sel.end () && ! need_to_ask_for_copy_mode; ++r) {
463464
if (r->is_cell_inst ()) {
464465
const db::Cell &cell = view ()->cellview (r->cv_index ())->layout ().cell (r->back ().inst_ptr.cell_index ());
465466
if (! cell.is_proxy ()) {
@@ -499,10 +500,12 @@ Service::copy_selected ()
499500
void
500501
Service::copy_selected (unsigned int inst_mode)
501502
{
503+
const objects &sel = selection ();
504+
502505
// create one ClipboardData object per cv_index because, this one assumes that there is
503506
// only one source layout object.
504507
std::set <unsigned int> cv_indices;
505-
for (objects::const_iterator r = selection ().begin (); r != selection ().end (); ++r) {
508+
for (objects::const_iterator r = sel.begin (); r != sel.end (); ++r) {
506509
cv_indices.insert (r->cv_index ());
507510
}
508511

@@ -512,7 +515,7 @@ Service::copy_selected (unsigned int inst_mode)
512515

513516
// add the selected objects to the clipboard data objects.
514517
const lay::CellView &cv = view ()->cellview (*cvi);
515-
for (objects::const_iterator r = selection ().begin (); r != selection ().end (); ++r) {
518+
for (objects::const_iterator r = sel.begin (); r != sel.end (); ++r) {
516519
if (r->cv_index () == *cvi) {
517520
if (! r->is_cell_inst ()) {
518521
cd->get ().add (cv->layout (), r->layer (), r->shape (), cv.context_trans () * r->trans ());
@@ -614,7 +617,9 @@ Service::selection_bbox ()
614617
lay::TextInfo text_info (view ());
615618

616619
db::DBox box;
617-
for (objects::const_iterator r = selection ().begin (); r != selection ().end (); ++r) {
620+
621+
const objects &sel = selection ();
622+
for (objects::const_iterator r = sel.begin (); r != sel.end (); ++r) {
618623

619624
const lay::CellView &cv = view ()->cellview (r->cv_index ());
620625
const db::Layout &layout = cv->layout ();
@@ -694,10 +699,12 @@ Service::transform (const db::DCplxTrans &trans, const std::vector<db::DCplxTran
694699

695700
size_t n;
696701

702+
const objects &sel = selection ();
703+
697704
// build a list of object references corresponding to the p_trv vector
698705
std::vector <objects::iterator> obj_ptrs;
699-
obj_ptrs.reserve (selection ().size ());
700-
for (objects::iterator r = selection ().begin (); r != selection ().end (); ++r) {
706+
obj_ptrs.reserve (sel.size ());
707+
for (objects::iterator r = sel.begin (); r != sel.end (); ++r) {
701708
obj_ptrs.push_back (r);
702709
}
703710

@@ -710,7 +717,7 @@ Service::transform (const db::DCplxTrans &trans, const std::vector<db::DCplxTran
710717
// The key is a triple: cell_index, cv_index, layer
711718
std::map <std::pair <db::cell_index_type, std::pair <unsigned int, unsigned int> >, std::vector <size_t> > shapes_by_cell;
712719
n = 0;
713-
for (objects::iterator r = selection ().begin (); r != selection ().end (); ++r, ++n) {
720+
for (objects::iterator r = sel.begin (); r != sel.end (); ++r, ++n) {
714721
if (! r->is_cell_inst ()) {
715722
shapes_by_cell.insert (std::make_pair (std::make_pair (r->cell_index (), std::make_pair (r->cv_index (), r->layer ())), std::vector <size_t> ())).first->second.push_back (n);
716723
}
@@ -780,7 +787,7 @@ Service::transform (const db::DCplxTrans &trans, const std::vector<db::DCplxTran
780787
// The key is a pair: cell_index, cv_index
781788
std::map <std::pair <db::cell_index_type, unsigned int>, std::vector <size_t> > insts_by_cell;
782789
n = 0;
783-
for (objects::iterator r = selection ().begin (); r != selection ().end (); ++r, ++n) {
790+
for (objects::iterator r = sel.begin (); r != sel.end (); ++r, ++n) {
784791
if (r->is_cell_inst ()) {
785792
insts_by_cell.insert (std::make_pair (std::make_pair (r->cell_index (), r->cv_index ()), std::vector <size_t> ())).first->second.push_back (n);
786793
}
@@ -1032,7 +1039,8 @@ Service::del_selected ()
10321039
std::set<db::Layout *> needs_cleanup;
10331040

10341041
// delete all shapes and instances.
1035-
for (objects::const_iterator r = selection ().begin (); r != selection ().end (); ++r) {
1042+
const objects &sel = selection ();
1043+
for (objects::const_iterator r = sel.begin (); r != sel.end (); ++r) {
10361044
const lay::CellView &cv = view ()->cellview (r->cv_index ());
10371045
if (cv.is_valid ()) {
10381046
db::Cell &cell = cv->layout ().cell (r->cell_index ());
@@ -1722,15 +1730,17 @@ Service::selection_to_view ()
17221730
void
17231731
Service::do_selection_to_view ()
17241732
{
1733+
const objects &sel = selection ();
1734+
17251735
// Hint: this is a lower bound:
1726-
m_markers.reserve (selection ().size ());
1736+
m_markers.reserve (sel.size ());
17271737

17281738
// build the transformation variants cache
17291739
TransformationVariants tv (view ());
17301740

17311741
// Build markers
17321742

1733-
for (std::set<lay::ObjectInstPath>::iterator r = selection ().begin (); r != selection ().end (); ++r) {
1743+
for (objects::const_iterator r = sel.begin (); r != sel.end (); ++r) {
17341744

17351745
const lay::CellView &cv = view ()->cellview (r->cv_index ());
17361746

@@ -1984,10 +1994,16 @@ EditableSelectionIterator::operator++ ()
19841994
return *this;
19851995
}
19861996

1987-
const EditableSelectionIterator::value_type &
1997+
EditableSelectionIterator::pointer
1998+
EditableSelectionIterator::operator-> () const
1999+
{
2000+
return m_iter.operator-> ();
2001+
}
2002+
2003+
EditableSelectionIterator::reference
19882004
EditableSelectionIterator::operator* () const
19892005
{
1990-
return *m_iter;
2006+
return m_iter.operator* ();
19912007
}
19922008

19932009
void

src/edt/edt/edtService.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ class EditableSelectionIterator
700700
public:
701701
typedef edt::Service::objects::value_type value_type;
702702
typedef edt::Service::objects::const_iterator iterator_type;
703-
typedef void pointer;
703+
typedef const value_type *pointer;
704704
typedef const value_type &reference;
705705
typedef std::forward_iterator_tag iterator_category;
706706
typedef void difference_type;
@@ -710,7 +710,8 @@ class EditableSelectionIterator
710710
bool at_end () const;
711711

712712
EditableSelectionIterator &operator++ ();
713-
const value_type &operator* () const;
713+
reference operator* () const;
714+
pointer operator-> () const;
714715

715716
private:
716717
std::vector<edt::Service *> m_services;

src/edt/edt/edtUtils.cc

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -74,73 +74,6 @@ std::map<std::string, tl::Variant> pcell_parameters_from_string (const std::stri
7474
return pm;
7575
}
7676

77-
// -------------------------------------------------------------
78-
// SelectionIterator implementation
79-
80-
SelectionIterator::SelectionIterator (lay::LayoutViewBase *view, bool including_transient)
81-
: m_transient_mode (false)
82-
{
83-
mp_edt_services = view->get_plugins <edt::Service> ();
84-
85-
m_current_service = mp_edt_services.begin ();
86-
if (m_current_service != mp_edt_services.end ()) {
87-
m_current_object = (*m_current_service)->selection ().begin ();
88-
}
89-
90-
next ();
91-
92-
if (at_end () && including_transient) {
93-
94-
m_transient_mode = true;
95-
96-
m_current_service = mp_edt_services.begin ();
97-
if (m_current_service != mp_edt_services.end ()) {
98-
m_current_object = (*m_current_service)->transient_selection ().begin ();
99-
}
100-
101-
next ();
102-
103-
}
104-
}
105-
106-
bool
107-
SelectionIterator::at_end () const
108-
{
109-
return m_current_service == mp_edt_services.end ();
110-
}
111-
112-
void
113-
SelectionIterator::inc ()
114-
{
115-
tl_assert (! at_end ());
116-
++m_current_object;
117-
}
118-
119-
void
120-
SelectionIterator::next ()
121-
{
122-
if (at_end ()) {
123-
return;
124-
}
125-
126-
const edt::Service::objects *sel = m_transient_mode ? &(*m_current_service)->transient_selection () : &(*m_current_service)->selection ();
127-
128-
while (m_current_object == sel->end ()) {
129-
130-
++m_current_service;
131-
132-
if (m_current_service != mp_edt_services.end ()) {
133-
134-
sel = m_transient_mode ? &(*m_current_service)->transient_selection () : &(*m_current_service)->selection ();
135-
m_current_object = sel->begin ();
136-
137-
} else {
138-
break;
139-
}
140-
141-
}
142-
}
143-
14477
// -------------------------------------------------------------
14578
// TransformationsVariants implementation
14679
// for a lay::LayoutView

src/edt/edt/edtUtils.h

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -92,73 +92,6 @@ class TransformationVariants
9292
std::map < std::pair<unsigned int, unsigned int>, std::vector<db::DCplxTrans> > m_per_cv_and_layer_tv;
9393
};
9494

95-
/**
96-
* @brief An iterator for the selected objects of all edt services in a layout view
97-
*/
98-
class SelectionIterator
99-
{
100-
public:
101-
typedef lay::ObjectInstPath value_type;
102-
typedef const lay::ObjectInstPath &reference;
103-
typedef const lay::ObjectInstPath *pointer;
104-
105-
/**
106-
* @brief Creates a new iterator iterating over all selected edt objects from the given view
107-
*
108-
* If "including_transient" is true, the transient selection will be used as fallback.
109-
*/
110-
SelectionIterator (lay::LayoutViewBase *view, bool including_transient = true);
111-
112-
/**
113-
* @brief Returns a value indicating whether the transient selection is taken
114-
*/
115-
bool is_transient () const
116-
{
117-
return m_transient_mode;
118-
}
119-
120-
/**
121-
* @brief Increments the iterator
122-
*/
123-
void operator++ ()
124-
{
125-
inc ();
126-
next ();
127-
}
128-
129-
/**
130-
* @brief Dereferencing
131-
*/
132-
const lay::ObjectInstPath &operator* () const
133-
{
134-
tl_assert (! at_end ());
135-
return *m_current_object;
136-
}
137-
138-
/**
139-
* @brief Arrow operator
140-
*/
141-
const lay::ObjectInstPath *operator-> () const
142-
{
143-
return & operator* ();
144-
}
145-
146-
/**
147-
* @brief Returns a value indicating whether the iterator has finished
148-
*/
149-
bool at_end () const;
150-
151-
private:
152-
void inc ();
153-
void next ();
154-
155-
private:
156-
std::vector<edt::Service *> mp_edt_services;
157-
std::vector<edt::Service *>::const_iterator m_current_service;
158-
std::set<lay::ObjectInstPath>::const_iterator m_current_object;
159-
bool m_transient_mode;
160-
};
161-
16295
} // namespace edt
16396

16497
#endif

0 commit comments

Comments
 (0)