Distributed under the GPL
*/
+#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <limits>
#include "mainpanel.h"
#include "trainpanel.h"
#include "trainproperties.h"
+#include "trainview.h"
using namespace std;
using namespace Marklin;
layout.signal_block_reserved.connect(sigc::mem_fun(this, &Engineer::block_reserved));
layout.signal_emergency.connect(sigc::mem_fun(this, &Engineer::set_status));
layout.get_driver().signal_sensor.connect(sigc::mem_fun(this, &Engineer::sensor_event));
- if(FS::exists("engineer.state"))
- DataFile::load(layout, "engineer.state");
+ if(FS::exists(options.state_fn))
+ DataFile::load(layout, options.state_fn);
if(options.network)
{
DataFile::load(arrow_mesh, "arrow.mesh");
pipeline.set_camera(&camera);
- pipeline.add_renderable(layout_3d.get_scene());
+ pipeline.add_renderable_for_pass(layout_3d.get_scene(), 0);
+ pipeline.add_renderable_for_pass(layout_3d.get_path_scene(), "unlit");
- light.set_position(0, -0.259, 0.966, 0);
+ light.set_position(GL::Vector4(0, -0.259, 0.966, 0));
+ light.set_diffuse(GL::Color(0.9));
+ lighting.set_ambient(GL::Color(0.4));
lighting.attach(0, light);
- GL::PipelinePass &pass = pipeline.add_pass(0);
- pass.depth_test = &GL::DepthTest::lequal();
- pass.lighting = &lighting;
+ GL::PipelinePass *pass = &pipeline.add_pass(0);
+ pass->depth_test = &GL::DepthTest::lequal();
+ pass->lighting = &lighting;
+
+ pass = &pipeline.add_pass("unlit");
+ pass->depth_test = &GL::DepthTest::lequal();
view_all();
layout.get_driver().flush();
if(!options.simulate)
- layout.save_trains("engineer.state");
+ layout.save_trains(options.state_fn);
delete overlay;
delete root;
status_timeout = Time::now()+10*Time::sec;
}
+void Engineer::rearrange_panels()
+{
+ int y = main_panel->get_geometry().y;
+ for(list<TrainPanel *>::iterator i=train_panels.begin(); i!=train_panels.end(); ++i)
+ {
+ y -= (*i)->get_geometry().h;
+ (*i)->set_position(0, y);
+ }
+}
+
+void Engineer::add_train_view(TrainView &tv)
+{
+ train_views.push_back(&tv);
+}
+
+void Engineer::remove_train_view(TrainView &tv)
+{
+ train_views.erase(remove(train_views.begin(), train_views.end(), &tv), train_views.end());
+}
+
void Engineer::pick(bool with_ep)
{
picking = true;
layout.tick();
event_disp.tick(Time::zero);
+ for(list<TrainView *>::iterator i=train_views.begin(); i!=train_views.end(); ++i)
+ (*i)->prepare();
+
if(status_timeout && Time::now()>status_timeout)
{
main_panel->set_status_text(string());
status_timeout = Time::TimeStamp();
}
- GL::clear(GL::COLOR_BUFFER_BIT|GL::DEPTH_BUFFER_BIT);
+ GL::Framebuffer::system().clear(GL::COLOR_BUFFER_BIT|GL::DEPTH_BUFFER_BIT);
pipeline.render_all();
- {
- GL::Bind depth(GL::DepthTest::lequal());
- layout_3d.get_path_scene().render();
- }
{
GL::Bind blend(GL::Blend::alpha());
overlay->render(0);
{
TrainPanel *tpanel = new TrainPanel(*this, ui_res, train);
root->add(*tpanel);
- int y = main_panel->get_geometry().y;
- for(list<TrainPanel *>::iterator i=train_panels.begin(); i!=train_panels.end(); ++i)
- y -= (*i)->get_geometry().h;
- tpanel->set_position(0, y-tpanel->get_geometry().h);
train_panels.push_back(tpanel);
- tpanel->set_visible(true);
+ rearrange_panels();
Vehicle3D &loco3d = layout_3d.get_vehicle(train.get_vehicle(0));
overlay->set_label(loco3d, train.get_name());