j->object->break_link(**i);
}
- const set<Track *> <racks = designer.get_layout().get_tracks();
+ const set<Track *> <racks = designer.get_layout().get_all<Track>();
for(set<Track *>::const_iterator i=ltracks.begin(); i!=ltracks.end(); ++i)
{
bool ok = true;
i->object->set_rotation(i->rot);
}
- const set<Track *> <racks = designer.get_layout().get_tracks();
+ const set<Track *> <racks = designer.get_layout().get_all<Track>();
float limit = max(designer.get_layout().get_catalogue().get_gauge(),
designer.get_camera_controller().get_view_scale()/100.0f);
MObject *snapped = 0;
void Manipulator::update_objects()
{
- Vector minp, maxp;
+ Geometry::BoundingBox<float, 3> bbox;
for(vector<MObject>::iterator i=objects.begin(); i!=objects.end(); ++i)
- {
- // XXX Use generic bounding box when it is implemented
- if(Track *track = dynamic_cast<Track *>(i->object))
- {
- unsigned n_endpoints = track->get_type().get_endpoints().size();
- for(unsigned j=0; j<n_endpoints; ++j)
- {
- Vector p = track->get_snap_node(j).position;
- if(i==objects.begin() && j==0)
- minp = maxp = p;
- else
- {
- minp.x = min(minp.x, p.x);
- maxp.x = max(maxp.x, p.x);
- minp.y = min(minp.y, p.y);
- maxp.y = max(maxp.y, p.y);
- minp.z = min(minp.z, p.z);
- }
- }
- }
- else
- {
- const Vector &p = i->object->get_position();
- minp.x = min(minp.x, p.x);
- maxp.x = max(maxp.x, p.x);
- minp.y = min(minp.y, p.y);
- maxp.y = max(maxp.y, p.y);
- minp.z = min(minp.z, p.z);
- }
- }
+ bbox = bbox|i->object->get_bounding_box();
+
+ const Vector &minp = bbox.get_minimum_point();
+ const Vector &maxp = bbox.get_maximum_point();
center = (minp+maxp)/2.0f;
center.z = minp.z;