Skip to content
Merged

Devel #2123

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/ant/ant/antPropertiesPage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,19 @@ PropertiesPage::description () const
return tl::to_string (tr ("Rulers and Annotations"));
}

void
PropertiesPage::confine_selection (const std::vector<size_t> &remaining_entries)
{
std::vector <ant::Service::obj_iterator> 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 ()
{
Expand Down
1 change: 1 addition & 0 deletions src/ant/ant/antPropertiesPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Q_OBJECT
virtual void select_entries (const std::vector<size_t> &entries);
virtual std::string description (size_t entry) const;
virtual std::string description () const;
virtual void confine_selection (const std::vector<size_t> &remaining_entries);
virtual void update ();
virtual void leave ();
virtual bool readonly ();
Expand Down
73 changes: 41 additions & 32 deletions src/ant/ant/antService.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1410,8 +1410,8 @@ Service::begin_move (lay::Editable::MoveMode mode, const db::DPoint &p, lay::ang
double dmin = std::numeric_limits <double>::max ();

const ant::Object *robj_min = 0;
for (std::map<obj_iterator, unsigned int>::const_iterator r = m_selected.begin (); r != m_selected.end (); ++r) {
const ant::Object *robj = dynamic_cast<const ant::Object *> ((*r->first).ptr ());
for (auto r = m_selected.begin (); r != m_selected.end (); ++r) {
const ant::Object *robj = dynamic_cast<const ant::Object *> ((*r)->ptr ());
if (robj) {
double d;
if (is_selected (*robj, p, l, d)) {
Expand All @@ -1425,17 +1425,17 @@ Service::begin_move (lay::Editable::MoveMode mode, const db::DPoint &p, lay::ang

// further investigate what part to drag

for (std::map<obj_iterator, unsigned int>::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 <const ant::Object *> ((*ri).ptr ());
if (robj && (! robj_min || robj == robj_min)) {

if (dragging_what (robj, search_dbox, m_move_mode, m_p1, m_seg_index) && m_move_mode != MoveRuler) {

// 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));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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<obj_iterator, unsigned int>::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<const ant::Object *> (s->first->ptr ());
const ant::Object *robj = dynamic_cast<const ant::Object *> ((*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);

}
Expand All @@ -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)
Expand All @@ -1717,9 +1717,8 @@ Service::selection_to_view ()
}
m_rulers.clear ();
m_rulers.reserve (m_selected.size ());
for (std::map<obj_iterator, unsigned int>::iterator r = m_selected.begin (); r != m_selected.end (); ++r) {
r->second = (unsigned int) m_rulers.size ();
const ant::Object *robj = dynamic_cast<const ant::Object *> (r->first->ptr ());
for (auto r = m_selected.begin (); r != m_selected.end (); ++r) {
const ant::Object *robj = dynamic_cast<const ant::Object *> ((*r)->ptr ());
m_rulers.push_back (new ant::View (this, robj, true /*selected*/));
}
}
Expand All @@ -1728,8 +1727,8 @@ db::DBox
Service::selection_bbox ()
{
db::DBox box;
for (std::map<obj_iterator, unsigned int>::iterator r = m_selected.begin (); r != m_selected.end (); ++r) {
const ant::Object *robj = dynamic_cast<const ant::Object *> (r->first->ptr ());
for (auto r = m_selected.begin (); r != m_selected.end (); ++r) {
const ant::Object *robj = dynamic_cast<const ant::Object *> ((*r)->ptr ());
if (robj) {
box += robj->box ();
}
Expand All @@ -1741,16 +1740,16 @@ void
Service::transform (const db::DCplxTrans &trans)
{
// replace the rulers that were transformed:
for (std::map<obj_iterator, unsigned int>::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<const ant::Object *> (s->first->ptr ());
const ant::Object *robj = dynamic_cast<const ant::Object *> ((*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);

}
Expand Down Expand Up @@ -2173,9 +2172,8 @@ void
Service::copy_selected ()
{
// extract all selected rulers and paste in "micron" space
for (std::map<obj_iterator, unsigned int>::iterator r = m_selected.begin (); r != m_selected.end (); ++r) {
r->second = (unsigned int) m_rulers.size ();
const ant::Object *robj = dynamic_cast<const ant::Object *> (r->first->ptr ());
for (auto r = m_selected.begin (); r != m_selected.end (); ++r) {
const ant::Object *robj = dynamic_cast<const ant::Object *> ((*r)->ptr ());
if (robj) {
db::Clipboard::instance () += new db::ClipboardValue<ant::Object> (*robj);
}
Expand Down Expand Up @@ -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 ();
Expand Down Expand Up @@ -2240,8 +2238,8 @@ Service::del_selected ()
// positions will hold a set of iterators that are to be erased
std::vector <lay::AnnotationShapes::iterator> positions;
positions.reserve (m_selected.size ());
for (std::map<obj_iterator, unsigned int>::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
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}
Expand All @@ -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<obj_iterator, unsigned int> *exclude = 0;
const std::set<obj_iterator> *exclude = 0;
if (mode == lay::Editable::Replace) {
exclude = &m_previous_selection;
} else if (mode == lay::Editable::Add) {
Expand Down Expand Up @@ -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 <const ant::Object *> (r->ptr ());
if (robj == mp_transient_ruler->ruler ()) {
m_selected.insert (std::make_pair (r, 0));
m_selected.insert (r);
selection_to_view ();
return;
}
Expand Down Expand Up @@ -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<obj_iterator, unsigned int> *exclude = 0;
const std::set<obj_iterator> *exclude = 0;
if (mode == lay::Editable::Replace) {
exclude = &m_previous_selection;
} else if (mode == lay::Editable::Add) {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -2667,11 +2665,22 @@ Service::get_selection (std::vector <obj_iterator> &sel) const
sel.reserve (m_selected.size ());

// positions will hold a set of iterators that are to be erased
for (std::map<obj_iterator, unsigned int>::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);
}
}

void
Service::set_selection (const std::vector<obj_iterator> &selection)
{
m_selected.clear ();
for (auto i = selection.begin (); i != selection.end (); ++i) {
m_selected.insert (*i);
}

selection_to_view ();
}

void
Service::delete_ruler (obj_iterator pos)
{
Expand Down
13 changes: 9 additions & 4 deletions src/ant/ant/antService.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,19 @@ Q_OBJECT
#endif

/**
* @brief Get the selection for the properties page
* @brief Gets the selection for the properties page
*/
void get_selection (std::vector <obj_iterator> &selection) const;

/**
* @brief Sets the selection for the properties page
*/
void set_selection (const std::vector <obj_iterator> &selection);

/**
* @brief Direct access to the selection
*/
const std::map<obj_iterator, unsigned int> &selection () const
const std::set<obj_iterator> &selection () const
{
return m_selected;
}
Expand Down Expand Up @@ -558,9 +563,9 @@ public slots:
// and the moved rules in move mode
std::vector<ant::View *> m_rulers;
// The selection
std::map<obj_iterator, unsigned int> m_selected;
std::set<obj_iterator> m_selected;
// The previous selection
std::map<obj_iterator, unsigned int> m_previous_selection;
std::set<obj_iterator> m_previous_selection;
// The reference point in move mode
db::DPoint m_p1;
// The transformation in MoveSelection mode
Expand Down
4 changes: 2 additions & 2 deletions src/ant/ant/gsiDeclAnt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ class AnnotationSelectionIterator
{
public:
typedef AnnotationRef value_type;
typedef std::map<ant::Service::obj_iterator, unsigned int>::const_iterator iterator_type;
typedef std::set<ant::Service::obj_iterator>::const_iterator iterator_type;
typedef void pointer;
typedef value_type reference;
typedef std::forward_iterator_tag iterator_category;
Expand Down Expand Up @@ -1292,7 +1292,7 @@ class AnnotationSelectionIterator

reference operator* () const
{
return value_type (*(static_cast<const ant::Object *> (m_iter->first->ptr ())), m_services[m_service]->view ());
return value_type (*(static_cast<const ant::Object *> ((*m_iter)->ptr ())), m_services[m_service]->view ());
}

private:
Expand Down
5 changes: 4 additions & 1 deletion src/db/db/dbCompoundOperation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ CompoundRegionMultiInputOperationNode::CompoundRegionMultiInputOperationNode (co
(*c)->keep ();
m_children.push_back (*c);
}
init ();

if (! no_init) {
init ();
}
}

CompoundRegionMultiInputOperationNode::CompoundRegionMultiInputOperationNode ()
Expand Down
20 changes: 20 additions & 0 deletions src/edt/edt/edtInstPropertiesPage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,26 @@ InstPropertiesPage::description () const
return tl::to_string (tr ("Instances"));
}

void
InstPropertiesPage::confine_selection (const std::vector<size_t> &remaining_entries)
{
std::vector<lay::ObjectInstPath> 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 ()
{
Expand Down
1 change: 1 addition & 0 deletions src/edt/edt/edtInstPropertiesPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Q_OBJECT
virtual void select_entries (const std::vector<size_t> &entries);
virtual std::string description (size_t entry) const;
virtual std::string description () const;
virtual void confine_selection (const std::vector<size_t> &remaining_entries);
virtual void leave ();

private:
Expand Down
23 changes: 22 additions & 1 deletion src/edt/edt/edtPropertiesPages.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<size_t> &remaining_entries)
{
std::vector<lay::ObjectInstPath> 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 ()
{
Expand Down Expand Up @@ -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;
Expand Down
Loading
Loading