2 #include "libr2c2/block.h"
9 Object *Selection::get_object() const
14 return *objects.begin();
17 void Selection::clear()
20 signal_changed.emit();
23 void Selection::add_object(Object *o)
25 if(objects.insert(o).second)
26 signal_changed.emit();
29 void Selection::remove_object(Object *o)
32 signal_changed.emit();
35 void Selection::toggle_object(Object *o)
40 signal_changed.emit();
43 void Selection::select_more()
45 set<Object *> new_objects;
46 for(set<Object *>::iterator i=objects.begin(); i!=objects.end(); ++i)
48 unsigned nls = (*i)->get_n_link_slots();
49 for(unsigned j=0; j<nls; ++j)
50 if(Object *obj = (*i)->get_link(j))
51 new_objects.insert(obj);
55 for(set<Object *>::iterator i=new_objects.begin(); i!=new_objects.end(); ++i)
56 if(objects.insert(*i).second)
60 signal_changed.emit();
63 void Selection::select_linked()
66 list<Object *> queue(objects.begin(), objects.end());
70 Object *obj = queue.front();
73 unsigned nls = obj->get_n_link_slots();
74 for(unsigned j=0; j<nls; ++j)
75 if(Object *linked = obj->get_link(j))
76 if(objects.insert(linked).second)
78 queue.push_back(linked);
84 signal_changed.emit();
87 void Selection::select_blocks()
90 for(set<Object *>::iterator i=objects.begin(); i!=objects.end(); ++i)
91 if(Track *track = dynamic_cast<Track *>(*i))
93 const set<Track *> &btracks = track->get_block().get_tracks();
94 for(set<Track *>::iterator j=btracks.begin(); j!=btracks.end(); ++j)
95 if(objects.insert(*j).second)
100 signal_changed.emit();