From: Mikko Rasa Date: Wed, 20 Nov 2013 11:19:03 +0000 (+0200) Subject: Display icons and addresses for signals and beam gates X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=a34ddfcc90e80188545fdd2c6bbca8dfba7f1ad0;p=r2c2.git Display icons and addresses for signals and beam gates --- diff --git a/icons/beamgate.mesh b/icons/beamgate.mesh new file mode 100644 index 0000000..8db75e7 --- /dev/null +++ b/icons/beamgate.mesh @@ -0,0 +1,17 @@ +vertices VERTEX2 +{ + vertex2 0.0 0.0; + vertex2 0.0 0.5; + vertex2 0.2 0.5; + vertex2 1.0 0.0; + vertex2 1.0 0.5; + vertex2 0.8 0.5; +}; +batch LINE_STRIP +{ + indices 0 1 2; +}; +batch LINE_STRIP +{ + indices 3 4 5; +}; diff --git a/icons/sensor.mesh b/icons/sensor.mesh deleted file mode 100644 index cea93f2..0000000 --- a/icons/sensor.mesh +++ /dev/null @@ -1,13 +0,0 @@ -vertices VERTEX2 -{ - vertex2 0.0 0.45; - vertex2 0.3 0.45; - vertex2 1.0 0.45; - vertex2 0.7 0.45; - vertex2 0.3 0.65; -}; -batch LINES -{ - indices 0 1; - indices 2 3 3 4; -}; diff --git a/icons/signal.mesh b/icons/signal.mesh new file mode 100644 index 0000000..8139f32 --- /dev/null +++ b/icons/signal.mesh @@ -0,0 +1,10 @@ +vertices VERTEX2 +{ + vertex2 0.4 0.0; + vertex2 0.4 1.0; + vertex2 0.6 1.0; +}; +batch LINE_STRIP +{ + indices 0 1 2; +}; diff --git a/icons/trackcircuit.mesh b/icons/trackcircuit.mesh new file mode 100644 index 0000000..cea93f2 --- /dev/null +++ b/icons/trackcircuit.mesh @@ -0,0 +1,13 @@ +vertices VERTEX2 +{ + vertex2 0.0 0.45; + vertex2 0.3 0.45; + vertex2 1.0 0.45; + vertex2 0.7 0.45; + vertex2 0.3 0.65; +}; +batch LINES +{ + indices 0 1; + indices 2 3 3 4; +}; diff --git a/source/designer/designer.cpp b/source/designer/designer.cpp index a59b3a1..6ae9c07 100644 --- a/source/designer/designer.cpp +++ b/source/designer/designer.cpp @@ -148,9 +148,9 @@ Designer::Designer(int argc, char **argv): cat_view->view_all(true); main_view->view_all(); - const set &tracks = layout->get_all(); - for(set::const_iterator i=tracks.begin(); i!=tracks.end(); ++i) - update_track_icon(layout_3d->get_3d(**i)); + const set &objects = layout->get_all(); + for(set::const_iterator i=objects.begin(); i!=objects.end(); ++i) + update_object_icon(**i); } Designer::~Designer() @@ -406,7 +406,7 @@ void Designer::key_press(unsigned key) if(*j!=*i) (*i)->snap_to(**j, true); - update_track_icon(layout_3d->get_3d(**i)); + update_object_icon(**i); } } else if(key==Msp::Input::KEY_F) @@ -509,25 +509,39 @@ Object *Designer::pick_object(const Vector &pointer) return view.get_layout().get_layout().pick(Ray(cpos, Vector(cray))); } -void Designer::update_track_icon(Track3D &track) +void Designer::update_object_icon(Object &obj) { - overlay->clear(track); + Object3D &obj3d = layout_3d->get_3d(obj); + overlay->clear(obj3d); - if(track.get_track().get_flex()) - overlay->add_graphic(track, "flex"); + if(Track *track = dynamic_cast(&obj)) + { + if(track->get_flex()) + overlay->add_graphic(obj3d, "flex"); - if(unsigned saddr = track.get_track().get_sensor_address()) + if(unsigned saddr = track->get_sensor_address()) + { + overlay->add_graphic(obj3d, "trackcircuit"); + overlay->set_label(obj3d, lexical_cast(saddr)); + } + else if(unsigned taddr = track->get_turnout_address()) + { + if(taddr<0x800) + { + overlay->add_graphic(obj3d, "turnout"); + overlay->set_label(obj3d, lexical_cast(taddr)); + } + } + } + else if(Signal *signal = dynamic_cast(&obj)) { - overlay->add_graphic(track, "sensor"); - overlay->set_label(track, lexical_cast(saddr)); + overlay->add_graphic(obj3d, "signal"); + overlay->set_label(obj3d, lexical_cast(signal->get_address())); } - else if(unsigned taddr = track.get_track().get_turnout_address()) + else if(BeamGate *gate = dynamic_cast(&obj)) { - if(taddr<0x800) - { - overlay->add_graphic(track, "turnout"); - overlay->set_label(track, lexical_cast(taddr)); - } + overlay->add_graphic(obj3d, "beamgate"); + overlay->set_label(obj3d, lexical_cast(gate->get_address())); } } @@ -538,9 +552,9 @@ void Designer::tool_status(const string &status) void Designer::object_properties_response(int) { - const set &tracks = selection.get_objects(); - for(set::const_iterator i=tracks.begin(); i!=tracks.end(); ++i) - update_track_icon(layout_3d->get_3d(**i)); + const set &objects = selection.get_objects(); + for(set::const_iterator i=objects.begin(); i!=objects.end(); ++i) + update_object_icon(**i); } void Designer::route_name_accept(const string &text) diff --git a/source/designer/designer.h b/source/designer/designer.h index c09feb9..499c06c 100644 --- a/source/designer/designer.h +++ b/source/designer/designer.h @@ -116,7 +116,7 @@ private: void apply_camera(); void render(); R2C2::Object *pick_object(const R2C2::Vector &); - void update_track_icon(R2C2::Track3D &); + void update_object_icon(R2C2::Object &); void tool_status(const std::string &); void object_properties_response(int); void route_name_accept(const std::string &);