mirror of https://github.com/KLayout/klayout.git
commit
af54c6ad46
|
|
@ -419,6 +419,19 @@ PropertiesPage::description () const
|
||||||
return tl::to_string (tr ("Rulers and Annotations"));
|
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
|
void
|
||||||
PropertiesPage::leave ()
|
PropertiesPage::leave ()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ public:
|
||||||
virtual void select_entries (const std::vector<size_t> &entries);
|
virtual void select_entries (const std::vector<size_t> &entries);
|
||||||
virtual std::string description (size_t entry) const;
|
virtual std::string description (size_t entry) const;
|
||||||
virtual std::string description () const;
|
virtual std::string description () const;
|
||||||
|
virtual void confine_selection (const std::vector<size_t> &remaining_entries);
|
||||||
virtual void update ();
|
virtual void update ();
|
||||||
virtual void leave ();
|
virtual void leave ();
|
||||||
virtual bool readonly ();
|
virtual bool readonly ();
|
||||||
|
|
|
||||||
|
|
@ -1410,8 +1410,8 @@ Service::begin_move (lay::Editable::MoveMode mode, const db::DPoint &p, lay::ang
|
||||||
double dmin = std::numeric_limits <double>::max ();
|
double dmin = std::numeric_limits <double>::max ();
|
||||||
|
|
||||||
const ant::Object *robj_min = 0;
|
const ant::Object *robj_min = 0;
|
||||||
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) {
|
||||||
const ant::Object *robj = dynamic_cast<const ant::Object *> ((*r->first).ptr ());
|
const ant::Object *robj = dynamic_cast<const ant::Object *> ((*r)->ptr ());
|
||||||
if (robj) {
|
if (robj) {
|
||||||
double d;
|
double d;
|
||||||
if (is_selected (*robj, p, l, 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
|
// 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 ());
|
const ant::Object *robj = dynamic_cast <const ant::Object *> ((*ri).ptr ());
|
||||||
if (robj && (! robj_min || robj == robj_min)) {
|
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
|
// found anything: make the moved ruler the selection
|
||||||
clear_selection ();
|
clear_selection ();
|
||||||
m_selected.insert (std::make_pair (ri, 0));
|
m_selected.insert (ri);
|
||||||
m_current = *robj;
|
m_current = *robj;
|
||||||
m_original = m_current;
|
m_original = m_current;
|
||||||
m_rulers.push_back (new ant::View (this, &m_current, true));
|
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
|
// found anything: make the moved ruler the selection
|
||||||
clear_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_current = *robj;
|
||||||
m_original = m_current;
|
m_original = m_current;
|
||||||
m_rulers.push_back (new ant::View (this, &m_current, true));
|
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) {
|
if (m_move_mode == MoveSelected) {
|
||||||
|
|
||||||
// replace the rulers that were moved:
|
// 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) {
|
if (robj) {
|
||||||
|
|
||||||
// compute moved object and replace
|
// compute moved object and replace
|
||||||
ant::Object *rnew = new ant::Object (*robj);
|
ant::Object *rnew = new ant::Object (*robj);
|
||||||
rnew->transform (m_trans);
|
rnew->transform (m_trans);
|
||||||
int new_id = rnew->id ();
|
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);
|
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
|
// replace the ruler that was moved
|
||||||
m_current.clean_points ();
|
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 ());
|
annotation_changed_event (m_current.id ());
|
||||||
|
|
||||||
// clear the selection (that was artifically created before)
|
// clear the selection (that was artifically created before)
|
||||||
|
|
@ -1717,9 +1717,8 @@ Service::selection_to_view ()
|
||||||
}
|
}
|
||||||
m_rulers.clear ();
|
m_rulers.clear ();
|
||||||
m_rulers.reserve (m_selected.size ());
|
m_rulers.reserve (m_selected.size ());
|
||||||
for (std::map<obj_iterator, unsigned int>::iterator r = m_selected.begin (); r != m_selected.end (); ++r) {
|
for (auto 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)->ptr ());
|
||||||
const ant::Object *robj = dynamic_cast<const ant::Object *> (r->first->ptr ());
|
|
||||||
m_rulers.push_back (new ant::View (this, robj, true /*selected*/));
|
m_rulers.push_back (new ant::View (this, robj, true /*selected*/));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1728,8 +1727,8 @@ db::DBox
|
||||||
Service::selection_bbox ()
|
Service::selection_bbox ()
|
||||||
{
|
{
|
||||||
db::DBox box;
|
db::DBox box;
|
||||||
for (std::map<obj_iterator, unsigned int>::iterator r = m_selected.begin (); r != m_selected.end (); ++r) {
|
for (auto r = m_selected.begin (); r != m_selected.end (); ++r) {
|
||||||
const ant::Object *robj = dynamic_cast<const ant::Object *> (r->first->ptr ());
|
const ant::Object *robj = dynamic_cast<const ant::Object *> ((*r)->ptr ());
|
||||||
if (robj) {
|
if (robj) {
|
||||||
box += robj->box ();
|
box += robj->box ();
|
||||||
}
|
}
|
||||||
|
|
@ -1741,16 +1740,16 @@ void
|
||||||
Service::transform (const db::DCplxTrans &trans)
|
Service::transform (const db::DCplxTrans &trans)
|
||||||
{
|
{
|
||||||
// replace the rulers that were transformed:
|
// 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) {
|
if (robj) {
|
||||||
|
|
||||||
// compute transformed object and replace
|
// compute transformed object and replace
|
||||||
int id = robj->id ();
|
int id = robj->id ();
|
||||||
ant::Object *rnew = new ant::Object (*robj);
|
ant::Object *rnew = new ant::Object (*robj);
|
||||||
rnew->transform (trans);
|
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);
|
annotation_changed_event (id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -2173,9 +2172,8 @@ void
|
||||||
Service::copy_selected ()
|
Service::copy_selected ()
|
||||||
{
|
{
|
||||||
// extract all selected rulers and paste in "micron" space
|
// 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) {
|
for (auto 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)->ptr ());
|
||||||
const ant::Object *robj = dynamic_cast<const ant::Object *> (r->first->ptr ());
|
|
||||||
if (robj) {
|
if (robj) {
|
||||||
db::Clipboard::instance () += new db::ClipboardValue<ant::Object> (*robj);
|
db::Clipboard::instance () += new db::ClipboardValue<ant::Object> (*robj);
|
||||||
}
|
}
|
||||||
|
|
@ -2212,7 +2210,7 @@ Service::paste ()
|
||||||
if (! new_objects.empty ()) {
|
if (! new_objects.empty ()) {
|
||||||
|
|
||||||
for (auto r = new_objects.begin (); r != new_objects.end (); ++r) {
|
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 ();
|
selection_to_view ();
|
||||||
|
|
@ -2240,8 +2238,8 @@ Service::del_selected ()
|
||||||
// positions will hold a set of iterators that are to be erased
|
// positions will hold a set of iterators that are to be erased
|
||||||
std::vector <lay::AnnotationShapes::iterator> positions;
|
std::vector <lay::AnnotationShapes::iterator> positions;
|
||||||
positions.reserve (m_selected.size ());
|
positions.reserve (m_selected.size ());
|
||||||
for (std::map<obj_iterator, unsigned int>::iterator r = m_selected.begin (); r != m_selected.end (); ++r) {
|
for (auto r = m_selected.begin (); r != m_selected.end (); ++r) {
|
||||||
positions.push_back (r->first);
|
positions.push_back (*r);
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear selection
|
// clear selection
|
||||||
|
|
@ -2276,7 +2274,7 @@ Service::select (obj_iterator obj, lay::Editable::SelectionMode mode)
|
||||||
if (mode == lay::Editable::Replace || mode == lay::Editable::Add) {
|
if (mode == lay::Editable::Replace || mode == lay::Editable::Add) {
|
||||||
// select
|
// select
|
||||||
if (m_selected.find (obj) == m_selected.end ()) {
|
if (m_selected.find (obj) == m_selected.end ()) {
|
||||||
m_selected.insert (std::make_pair (obj, 0));
|
m_selected.insert (obj);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (mode == lay::Editable::Reset) {
|
} 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 ()) {
|
if (m_selected.find (obj) != m_selected.end ()) {
|
||||||
m_selected.erase (obj);
|
m_selected.erase (obj);
|
||||||
} else {
|
} else {
|
||||||
m_selected.insert (std::make_pair (obj, 0));
|
m_selected.insert (obj);
|
||||||
}
|
}
|
||||||
return true;
|
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
|
// for single-point selections either exclude the current selection or the
|
||||||
// accumulated previous selection from the search.
|
// 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) {
|
if (mode == lay::Editable::Replace) {
|
||||||
exclude = &m_previous_selection;
|
exclude = &m_previous_selection;
|
||||||
} else if (mode == lay::Editable::Add) {
|
} 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) {
|
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 ());
|
const ant::Object *robj = dynamic_cast <const ant::Object *> (r->ptr ());
|
||||||
if (robj == mp_transient_ruler->ruler ()) {
|
if (robj == mp_transient_ruler->ruler ()) {
|
||||||
m_selected.insert (std::make_pair (r, 0));
|
m_selected.insert (r);
|
||||||
selection_to_view ();
|
selection_to_view ();
|
||||||
return;
|
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
|
// for single-point selections either exclude the current selection or the
|
||||||
// accumulated previous selection from the search.
|
// 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) {
|
if (mode == lay::Editable::Replace) {
|
||||||
exclude = &m_previous_selection;
|
exclude = &m_previous_selection;
|
||||||
} else if (mode == lay::Editable::Add) {
|
} 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
|
// select the one that was found
|
||||||
if (any_selected) {
|
if (any_selected) {
|
||||||
select (mp_view->annotation_shapes ().iterator_from_pointer (&*rmin), mode);
|
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;
|
needs_update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2667,11 +2665,22 @@ Service::get_selection (std::vector <obj_iterator> &sel) const
|
||||||
sel.reserve (m_selected.size ());
|
sel.reserve (m_selected.size ());
|
||||||
|
|
||||||
// positions will hold a set of iterators that are to be erased
|
// 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) {
|
for (auto r = m_selected.begin (); r != m_selected.end (); ++r) {
|
||||||
sel.push_back (r->first);
|
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
|
void
|
||||||
Service::delete_ruler (obj_iterator pos)
|
Service::delete_ruler (obj_iterator pos)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -381,14 +381,19 @@ public:
|
||||||
#endif
|
#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;
|
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
|
* @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;
|
return m_selected;
|
||||||
}
|
}
|
||||||
|
|
@ -558,9 +563,9 @@ private:
|
||||||
// and the moved rules in move mode
|
// and the moved rules in move mode
|
||||||
std::vector<ant::View *> m_rulers;
|
std::vector<ant::View *> m_rulers;
|
||||||
// The selection
|
// The selection
|
||||||
std::map<obj_iterator, unsigned int> m_selected;
|
std::set<obj_iterator> m_selected;
|
||||||
// The previous selection
|
// 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
|
// The reference point in move mode
|
||||||
db::DPoint m_p1;
|
db::DPoint m_p1;
|
||||||
// The transformation in MoveSelection mode
|
// The transformation in MoveSelection mode
|
||||||
|
|
|
||||||
|
|
@ -1263,7 +1263,7 @@ class AnnotationSelectionIterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef AnnotationRef value_type;
|
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 void pointer;
|
||||||
typedef value_type reference;
|
typedef value_type reference;
|
||||||
typedef std::forward_iterator_tag iterator_category;
|
typedef std::forward_iterator_tag iterator_category;
|
||||||
|
|
@ -1292,7 +1292,7 @@ public:
|
||||||
|
|
||||||
reference operator* () const
|
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:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -308,7 +308,10 @@ CompoundRegionMultiInputOperationNode::CompoundRegionMultiInputOperationNode (co
|
||||||
(*c)->keep ();
|
(*c)->keep ();
|
||||||
m_children.push_back (*c);
|
m_children.push_back (*c);
|
||||||
}
|
}
|
||||||
init ();
|
|
||||||
|
if (! no_init) {
|
||||||
|
init ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundRegionMultiInputOperationNode::CompoundRegionMultiInputOperationNode ()
|
CompoundRegionMultiInputOperationNode::CompoundRegionMultiInputOperationNode ()
|
||||||
|
|
|
||||||
|
|
@ -330,6 +330,26 @@ InstPropertiesPage::description () const
|
||||||
return tl::to_string (tr ("Instances"));
|
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
|
void
|
||||||
InstPropertiesPage::leave ()
|
InstPropertiesPage::leave ()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ public:
|
||||||
virtual void select_entries (const std::vector<size_t> &entries);
|
virtual void select_entries (const std::vector<size_t> &entries);
|
||||||
virtual std::string description (size_t entry) const;
|
virtual std::string description (size_t entry) const;
|
||||||
virtual std::string description () const;
|
virtual std::string description () const;
|
||||||
|
virtual void confine_selection (const std::vector<size_t> &remaining_entries);
|
||||||
virtual void leave ();
|
virtual void leave ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -137,12 +137,33 @@ ShapePropertiesPage::icon (size_t entry, int w, int h) const
|
||||||
|
|
||||||
return QIcon ();
|
return QIcon ();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
ShapePropertiesPage::description () const
|
ShapePropertiesPage::description () const
|
||||||
{
|
{
|
||||||
return m_description;
|
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
|
void
|
||||||
ShapePropertiesPage::leave ()
|
ShapePropertiesPage::leave ()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ public:
|
||||||
virtual void select_entries (const std::vector<size_t> &entries);
|
virtual void select_entries (const std::vector<size_t> &entries);
|
||||||
virtual std::string description (size_t entry) const;
|
virtual std::string description (size_t entry) const;
|
||||||
virtual std::string description () const;
|
virtual std::string description () const;
|
||||||
|
virtual void confine_selection (const std::vector<size_t> &remaining_entries);
|
||||||
virtual QIcon icon (size_t entry, int w, int h) const;
|
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 QIcon icon (int w, int h) const { return lay::PropertiesPage::icon (w, h); }
|
||||||
virtual void leave ();
|
virtual void leave ();
|
||||||
|
|
|
||||||
|
|
@ -1272,7 +1272,7 @@ class SelectionIterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef ImageRef value_type;
|
typedef ImageRef value_type;
|
||||||
typedef std::map<img::Service::obj_iterator, unsigned int>::const_iterator iterator_type;
|
typedef std::set<img::Service::obj_iterator>::const_iterator iterator_type;
|
||||||
typedef void pointer;
|
typedef void pointer;
|
||||||
typedef value_type reference;
|
typedef value_type reference;
|
||||||
typedef std::forward_iterator_tag iterator_category;
|
typedef std::forward_iterator_tag iterator_category;
|
||||||
|
|
@ -1301,7 +1301,7 @@ public:
|
||||||
|
|
||||||
value_type operator* () const
|
value_type operator* () const
|
||||||
{
|
{
|
||||||
return value_type (*(dynamic_cast<const img::Object *> (m_iter->first->ptr ())), m_services[m_service]->view ());
|
return value_type (*(dynamic_cast<const img::Object *> ((*m_iter)->ptr ())), m_services[m_service]->view ());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -192,6 +192,19 @@ PropertiesPage::description () const
|
||||||
return tl::to_string (tr ("Images"));
|
return tl::to_string (tr ("Images"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PropertiesPage::confine_selection (const std::vector<size_t> &remaining_entries)
|
||||||
|
{
|
||||||
|
std::vector <img::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_service->set_selection (m_selection);
|
||||||
|
mp_service->clear_highlights ();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PropertiesPage::leave ()
|
PropertiesPage::leave ()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ public:
|
||||||
virtual void select_entries (const std::vector<size_t> &entries);
|
virtual void select_entries (const std::vector<size_t> &entries);
|
||||||
virtual std::string description (size_t entry) const;
|
virtual std::string description (size_t entry) const;
|
||||||
virtual std::string description () const;
|
virtual std::string description () const;
|
||||||
|
virtual void confine_selection (const std::vector<size_t> &remaining_entries);
|
||||||
virtual void update ();
|
virtual void update ();
|
||||||
virtual void leave ();
|
virtual void leave ();
|
||||||
virtual bool readonly ();
|
virtual bool readonly ();
|
||||||
|
|
|
||||||
|
|
@ -609,11 +609,11 @@ Service::begin_move (lay::Editable::MoveMode mode, const db::DPoint &p, lay::ang
|
||||||
} else if (mode == lay::Editable::Partial) {
|
} else if (mode == lay::Editable::Partial) {
|
||||||
|
|
||||||
// test, whether we are moving a handle of one selected object
|
// test, whether we are moving a handle of one selected object
|
||||||
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) {
|
||||||
|
|
||||||
MoveMode mm = move_none;
|
MoveMode mm = move_none;
|
||||||
size_t ml = 0;
|
size_t ml = 0;
|
||||||
obj_iterator si = s->first;
|
obj_iterator si = *s;
|
||||||
|
|
||||||
const img::Object *iobj = dynamic_cast <const img::Object *> ((*si).ptr ());
|
const img::Object *iobj = dynamic_cast <const img::Object *> ((*si).ptr ());
|
||||||
if (iobj && dragging_what (iobj, search_dbox, mm, ml, m_p1) && mm != move_all) {
|
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
|
// found a handle of one of the selected object: make the moved image the selection
|
||||||
clear_selection ();
|
clear_selection ();
|
||||||
m_selected.insert (std::make_pair (si, 0));
|
m_selected.insert (si);
|
||||||
m_current = *iobj;
|
m_current = *iobj;
|
||||||
m_initial = m_current;
|
m_initial = m_current;
|
||||||
m_selected_image_views.push_back (new img::View (this, &m_current, img::View::mode_transient_move));
|
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
|
// found anything: make the moved image the selection
|
||||||
clear_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_current = *iobj;
|
||||||
m_initial = m_current;
|
m_initial = m_current;
|
||||||
m_selected_image_views.push_back (new img::View (this, &m_current, img::View::mode_transient_move));
|
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) {
|
if (m_move_mode == move_selected) {
|
||||||
|
|
||||||
// replace the images that were moved:
|
// replace the images 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 img::Object *iobj = dynamic_cast<const img::Object *> (s->first->ptr ());
|
const img::Object *iobj = dynamic_cast<const img::Object *> ((*s)->ptr ());
|
||||||
|
|
||||||
// compute moved object and replace
|
// compute moved object and replace
|
||||||
// KLUDGE: this creates a copy of the data!
|
// KLUDGE: this creates a copy of the data!
|
||||||
img::Object *inew = new img::Object (*iobj);
|
img::Object *inew = new img::Object (*iobj);
|
||||||
inew->transform (m_trans);
|
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);
|
image_changed_event (id);
|
||||||
|
|
||||||
|
|
@ -886,7 +886,7 @@ Service::end_move (const db::DPoint &, lay::angle_constraint_type)
|
||||||
|
|
||||||
// replace the image that was moved
|
// replace the image that was moved
|
||||||
img::Object *inew = new img::Object (m_current);
|
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);
|
image_changed_event (id);
|
||||||
|
|
||||||
// clear the selection (that was artificially created before)
|
// 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
|
// replace the image that was moved
|
||||||
img::Object *inew = new img::Object (m_current);
|
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);
|
image_changed_event (id);
|
||||||
|
|
||||||
// clear the selection (that was artificially created before)
|
// 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 *
|
const db::DUserObject *
|
||||||
Service::find_image (const db::DPoint &p, const db::DBox &search_box, double l, double &dmin, const std::map<img::Service::obj_iterator, unsigned int> *exclude)
|
Service::find_image (const db::DPoint &p, const db::DBox &search_box, double l, double &dmin, const std::set<img::Service::obj_iterator> *exclude)
|
||||||
{
|
{
|
||||||
if (! m_images_visible) {
|
if (! m_images_visible) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -967,9 +967,8 @@ Service::selection_to_view (img::View::Mode mode)
|
||||||
m_selected_image_views.clear ();
|
m_selected_image_views.clear ();
|
||||||
|
|
||||||
m_selected_image_views.reserve (m_selected.size ());
|
m_selected_image_views.reserve (m_selected.size ());
|
||||||
for (std::map<obj_iterator, unsigned int>::iterator r = m_selected.begin (); r != m_selected.end (); ++r) {
|
for (auto 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, mode));
|
||||||
m_selected_image_views.push_back (new img::View (this, r->first, mode));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -977,8 +976,8 @@ db::DBox
|
||||||
Service::selection_bbox ()
|
Service::selection_bbox ()
|
||||||
{
|
{
|
||||||
db::DBox box;
|
db::DBox box;
|
||||||
for (std::map<obj_iterator, unsigned int>::iterator r = m_selected.begin (); r != m_selected.end (); ++r) {
|
for (auto r = m_selected.begin (); r != m_selected.end (); ++r) {
|
||||||
const img::Object *iobj = dynamic_cast<const img::Object *> (r->first->ptr ());
|
const img::Object *iobj = dynamic_cast<const img::Object *> ((*r)->ptr ());
|
||||||
if (iobj) {
|
if (iobj) {
|
||||||
box += iobj->box ();
|
box += iobj->box ();
|
||||||
}
|
}
|
||||||
|
|
@ -990,14 +989,14 @@ void
|
||||||
Service::transform (const db::DCplxTrans &trans)
|
Service::transform (const db::DCplxTrans &trans)
|
||||||
{
|
{
|
||||||
// replace the images that were transformed:
|
// replace the images 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 img::Object *iobj = dynamic_cast<const img::Object *> (s->first->ptr ());
|
const img::Object *iobj = dynamic_cast<const img::Object *> ((*s)->ptr ());
|
||||||
|
|
||||||
// compute transformed object and replace
|
// compute transformed object and replace
|
||||||
img::Object *inew = new img::Object (*iobj);
|
img::Object *inew = new img::Object (*iobj);
|
||||||
inew->transform (trans);
|
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);
|
image_changed_event (id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1037,9 +1036,8 @@ void
|
||||||
Service::copy_selected ()
|
Service::copy_selected ()
|
||||||
{
|
{
|
||||||
// extract all selected images and paste in "micron" space
|
// extract all selected images and paste in "micron" space
|
||||||
for (std::map<obj_iterator, unsigned int>::iterator r = m_selected.begin (); r != m_selected.end (); ++r) {
|
for (auto r = m_selected.begin (); r != m_selected.end (); ++r) {
|
||||||
r->second = (unsigned int) m_selected_image_views.size ();
|
const img::Object *iobj = dynamic_cast<const img::Object *> ((*r)->ptr ());
|
||||||
const img::Object *iobj = dynamic_cast<const img::Object *> (r->first->ptr ());
|
|
||||||
db::Clipboard::instance () += new db::ClipboardValue<img::Object> (*iobj);
|
db::Clipboard::instance () += new db::ClipboardValue<img::Object> (*iobj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1077,8 +1075,8 @@ Service::del_selected ()
|
||||||
// positions will hold a set of iterators that are to be erased
|
// positions will hold a set of iterators that are to be erased
|
||||||
std::vector <lay::AnnotationShapes::iterator> positions;
|
std::vector <lay::AnnotationShapes::iterator> positions;
|
||||||
positions.reserve (m_selected.size ());
|
positions.reserve (m_selected.size ());
|
||||||
for (std::map<obj_iterator, unsigned int>::iterator r = m_selected.begin (); r != m_selected.end (); ++r) {
|
for (auto r = m_selected.begin (); r != m_selected.end (); ++r) {
|
||||||
positions.push_back (r->first);
|
positions.push_back (*r);
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear selection
|
// clear selection
|
||||||
|
|
@ -1117,7 +1115,7 @@ void
|
||||||
Service::transient_to_selection ()
|
Service::transient_to_selection ()
|
||||||
{
|
{
|
||||||
if (mp_transient_view) {
|
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 ();
|
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) {
|
if (mode == lay::Editable::Replace || mode == lay::Editable::Add) {
|
||||||
// select
|
// select
|
||||||
if (m_selected.find (obj) == m_selected.end ()) {
|
if (m_selected.find (obj) == m_selected.end ()) {
|
||||||
m_selected.insert (std::make_pair (obj, 0));
|
m_selected.insert (obj);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (mode == lay::Editable::Reset) {
|
} 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 ()) {
|
if (m_selected.find (obj) != m_selected.end ()) {
|
||||||
m_selected.erase (obj);
|
m_selected.erase (obj);
|
||||||
} else {
|
} else {
|
||||||
m_selected.insert (std::make_pair (obj, 0));
|
m_selected.insert (obj);
|
||||||
}
|
}
|
||||||
return true;
|
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
|
// for single-point selections either exclude the current selection or the
|
||||||
// accumulated previous selection from the search.
|
// 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) {
|
if (mode == lay::Editable::Replace) {
|
||||||
exclude = &m_previous_selection;
|
exclude = &m_previous_selection;
|
||||||
} else if (mode == lay::Editable::Add) {
|
} 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
|
// for single-point selections either exclude the current selection or the
|
||||||
// accumulated previous selection from the search.
|
// 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) {
|
if (mode == lay::Editable::Replace) {
|
||||||
exclude = &m_previous_selection;
|
exclude = &m_previous_selection;
|
||||||
} else if (mode == lay::Editable::Add) {
|
} 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
|
// select the one that was found
|
||||||
if (robj) {
|
if (robj) {
|
||||||
select (mp_view->annotation_shapes ().iterator_from_pointer (robj), mode);
|
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;
|
needs_update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1397,11 +1395,22 @@ Service::get_selection (std::vector <obj_iterator> &sel) const
|
||||||
sel.reserve (m_selected.size ());
|
sel.reserve (m_selected.size ());
|
||||||
|
|
||||||
// positions will hold a set of iterators that are to be erased
|
// 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) {
|
for (auto r = m_selected.begin (); r != m_selected.end (); ++r) {
|
||||||
sel.push_back (r->first);
|
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
|
void
|
||||||
Service::erase_image (obj_iterator pos)
|
Service::erase_image (obj_iterator pos)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -377,14 +377,19 @@ public:
|
||||||
#endif
|
#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;
|
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
|
* @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;
|
return m_selected;
|
||||||
}
|
}
|
||||||
|
|
@ -486,11 +491,10 @@ private:
|
||||||
|
|
||||||
// The view objects representing the selection and the moved images in move mode
|
// The view objects representing the selection and the moved images in move mode
|
||||||
std::vector<View *> m_selected_image_views;
|
std::vector<View *> m_selected_image_views;
|
||||||
// The present views - only used for issueing a proper
|
|
||||||
// The selection
|
// The selection
|
||||||
std::map<obj_iterator, unsigned int> m_selected;
|
std::set<obj_iterator> m_selected;
|
||||||
// The previous selection
|
// 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
|
// The reference point in move mode
|
||||||
db::DPoint m_p1;
|
db::DPoint m_p1;
|
||||||
// The image object representing the image being moved as it was before it was moved
|
// The image object representing the image being moved as it was before it was moved
|
||||||
|
|
@ -541,7 +545,7 @@ private:
|
||||||
/**
|
/**
|
||||||
* @brief Finds an image object from the given point
|
* @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<img::Service::obj_iterator, unsigned int> *exclude = 0);
|
const db::DUserObject *find_image (const db::DPoint &p, const db::DBox &search_box, double l, double &dmin, const std::set<img::Service::obj_iterator> *exclude = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Update m_selected_image_views to reflect the selection
|
* @brief Update m_selected_image_views to reflect the selection
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ public:
|
||||||
options.push_back (std::pair<std::string, std::string> (cfg_reader_options_show_always, "false"));
|
options.push_back (std::pair<std::string, std::string> (cfg_reader_options_show_always, "false"));
|
||||||
options.push_back (std::pair<std::string, std::string> (cfg_assistant_bookmarks, ""));
|
options.push_back (std::pair<std::string, std::string> (cfg_assistant_bookmarks, ""));
|
||||||
options.push_back (std::pair<std::string, std::string> (cfg_always_exit_without_saving, "false"));
|
options.push_back (std::pair<std::string, std::string> (cfg_always_exit_without_saving, "false"));
|
||||||
|
options.push_back (std::pair<std::string, std::string> (cfg_properties_dialog_relative_mode, "true"));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::vector<std::pair <std::string, ConfigPage *> > config_pages (QWidget *parent) const
|
virtual std::vector<std::pair <std::string, ConfigPage *> > config_pages (QWidget *parent) const
|
||||||
|
|
|
||||||
|
|
@ -2642,7 +2642,9 @@ LayoutViewBase::signal_apply_technology (lay::LayoutHandle *layout_handle)
|
||||||
|
|
||||||
// remove all references to the cellview in the layer properties
|
// remove all references to the cellview in the layer properties
|
||||||
for (unsigned int lindex = 0; lindex < layer_lists (); ++lindex) {
|
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
|
// if a layer properties file is set, create the layer properties now
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,14 @@ public:
|
||||||
return QIcon ();
|
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<size_t> &remaining_entries) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Update the display
|
* @brief Update the display
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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_line_width ("guiding-shape-line-width");
|
||||||
static const std::string cfg_guiding_shape_vertex_size ("guiding-shape-vertex-size");
|
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
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,9 @@
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::ActionsContextMenu</enum>
|
||||||
|
</property>
|
||||||
<property name="selectionMode">
|
<property name="selectionMode">
|
||||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -198,6 +201,14 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
<action name="action_reduce_selection">
|
||||||
|
<property name="text">
|
||||||
|
<string>Select highlighted rows</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Reduce selection to highlighted rows</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@
|
||||||
#include "tlLog.h"
|
#include "tlLog.h"
|
||||||
#include "layEditable.h"
|
#include "layEditable.h"
|
||||||
#include "layProperties.h"
|
#include "layProperties.h"
|
||||||
|
#include "layDispatcher.h"
|
||||||
|
#include "laybasicConfig.h"
|
||||||
#include "tlExceptions.h"
|
#include "tlExceptions.h"
|
||||||
|
|
||||||
#include "ui_PropertiesDialog.h"
|
#include "ui_PropertiesDialog.h"
|
||||||
|
|
@ -158,6 +160,16 @@ public:
|
||||||
emit dataChanged (index (0, 0, QModelIndex ()), index (rowCount (QModelIndex ()) - 1, columnCount (QModelIndex ()) - 1, QModelIndex ()));
|
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:
|
private:
|
||||||
PropertiesDialog *mp_dialog;
|
PropertiesDialog *mp_dialog;
|
||||||
int m_icon_width, m_icon_height;
|
int m_icon_width, m_icon_height;
|
||||||
|
|
@ -200,9 +212,6 @@ PropertiesDialog::PropertiesDialog (QWidget * /*parent*/, db::Manager *manager,
|
||||||
connect (mp_properties_pages [i], SIGNAL (edited ()), this, SLOT (properties_edited ()));
|
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
|
// Add a label as a dummy
|
||||||
mp_none = new QLabel (QObject::tr ("No object with properties to display"), mp_ui->content_frame);
|
mp_none = new QLabel (QObject::tr ("No object with properties to display"), mp_ui->content_frame);
|
||||||
mp_none->setAlignment (Qt::AlignHCenter | Qt::AlignVCenter);
|
mp_none->setAlignment (Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
|
|
@ -223,7 +232,6 @@ PropertiesDialog::PropertiesDialog (QWidget * /*parent*/, db::Manager *manager,
|
||||||
|
|
||||||
update_title ();
|
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_tree_model = new PropertiesTreeModel (this, mp_ui->tree->iconSize ().width (), mp_ui->tree->iconSize ().height ());
|
||||||
mp_ui->tree->setModel (mp_tree_model);
|
mp_ui->tree->setModel (mp_tree_model);
|
||||||
#if QT_VERSION >= 0x50000
|
#if QT_VERSION >= 0x50000
|
||||||
|
|
@ -233,6 +241,8 @@ PropertiesDialog::PropertiesDialog (QWidget * /*parent*/, db::Manager *manager,
|
||||||
#endif
|
#endif
|
||||||
mp_ui->tree->expandAll ();
|
mp_ui->tree->expandAll ();
|
||||||
|
|
||||||
|
mp_ui->tree->addAction (mp_ui->action_reduce_selection);
|
||||||
|
|
||||||
if (mp_properties_pages.empty ()) {
|
if (mp_properties_pages.empty ()) {
|
||||||
mp_ui->tree->hide ();
|
mp_ui->tree->hide ();
|
||||||
}
|
}
|
||||||
|
|
@ -246,11 +256,14 @@ PropertiesDialog::PropertiesDialog (QWidget * /*parent*/, db::Manager *manager,
|
||||||
mp_ui->apply_to_all_cbx->setChecked (false);
|
mp_ui->apply_to_all_cbx->setChecked (false);
|
||||||
mp_ui->relative_cbx->setChecked (true);
|
mp_ui->relative_cbx->setChecked (true);
|
||||||
|
|
||||||
|
fetch_config ();
|
||||||
|
|
||||||
connect (mp_ui->ok_button, SIGNAL (clicked ()), this, SLOT (ok_pressed ()));
|
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->cancel_button, SIGNAL (clicked ()), this, SLOT (cancel_pressed ()));
|
||||||
connect (mp_ui->prev_button, SIGNAL (clicked ()), this, SLOT (prev_pressed ()));
|
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->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->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 (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 ()));
|
connect (mp_ui->tree->selectionModel (), SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT (selection_changed ()));
|
||||||
}
|
}
|
||||||
|
|
@ -263,6 +276,26 @@ PropertiesDialog::~PropertiesDialog ()
|
||||||
disconnect ();
|
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
|
void
|
||||||
PropertiesDialog::disconnect ()
|
PropertiesDialog::disconnect ()
|
||||||
{
|
{
|
||||||
|
|
@ -287,6 +320,98 @@ PropertiesDialog::apply_to_all_pressed ()
|
||||||
m_signals_enabled = true;
|
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 <lay::PropertiesPage *>::iterator p = mp_properties_pages.begin (); p != mp_properties_pages.end (); ++p) {
|
||||||
|
|
||||||
|
int page_index = int (p - mp_properties_pages.begin ());
|
||||||
|
std::vector<size_t> 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 <lay::PropertiesPage *>::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
|
void
|
||||||
PropertiesDialog::selection_changed ()
|
PropertiesDialog::selection_changed ()
|
||||||
{
|
{
|
||||||
|
|
@ -617,6 +742,7 @@ PropertiesDialog::cancel_pressed ()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
store_config ();
|
||||||
// make sure that the property pages are no longer used ..
|
// make sure that the property pages are no longer used ..
|
||||||
disconnect ();
|
disconnect ();
|
||||||
// close the dialog
|
// close the dialog
|
||||||
|
|
@ -641,6 +767,7 @@ BEGIN_PROTECTED
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
store_config ();
|
||||||
// make sure that the property pages are no longer used ..
|
// make sure that the property pages are no longer used ..
|
||||||
disconnect ();
|
disconnect ();
|
||||||
QDialog::accept ();
|
QDialog::accept ();
|
||||||
|
|
@ -651,6 +778,7 @@ END_PROTECTED
|
||||||
void
|
void
|
||||||
PropertiesDialog::reject ()
|
PropertiesDialog::reject ()
|
||||||
{
|
{
|
||||||
|
store_config ();
|
||||||
// make sure that the property pages are no longer used ..
|
// make sure that the property pages are no longer used ..
|
||||||
disconnect ();
|
disconnect ();
|
||||||
QDialog::reject ();
|
QDialog::reject ();
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,8 @@ private:
|
||||||
|
|
||||||
const std::vector<lay::PropertiesPage *> &properties_pages () { return mp_properties_pages; }
|
const std::vector<lay::PropertiesPage *> &properties_pages () { return mp_properties_pages; }
|
||||||
void disconnect ();
|
void disconnect ();
|
||||||
|
void fetch_config ();
|
||||||
|
void store_config ();
|
||||||
bool any_prev () const;
|
bool any_prev () const;
|
||||||
bool any_next () const;
|
bool any_next () const;
|
||||||
void update_title ();
|
void update_title ();
|
||||||
|
|
@ -111,6 +113,7 @@ public slots:
|
||||||
void cancel_pressed ();
|
void cancel_pressed ();
|
||||||
void ok_pressed ();
|
void ok_pressed ();
|
||||||
void apply_to_all_pressed ();
|
void apply_to_all_pressed ();
|
||||||
|
void reduce_selection ();
|
||||||
void current_index_changed (const QModelIndex &index, const QModelIndex &previous);
|
void current_index_changed (const QModelIndex &index, const QModelIndex &previous);
|
||||||
void selection_changed ();
|
void selection_changed ();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue