X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=inline;f=source%2Fengineer%2Fengineer.cpp;h=bc32dfb848a52d92c4069aeb076760fc90d05182;hb=29433673a88dffd61ecb8e6c8fe6ab38e2012586;hp=e24365150fd25ec159c46b20f78b53ea0de91dbe;hpb=7d567753bb7e7a6952bab98a2896fd01c7dfd319;p=r2c2.git diff --git a/source/engineer/engineer.cpp b/source/engineer/engineer.cpp index e243651..bc32dfb 100644 --- a/source/engineer/engineer.cpp +++ b/source/engineer/engineer.cpp @@ -1,29 +1,20 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2006-2011 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #include #include #include #include #include -#include #include #include -#include -#include +#include +#include #include #include #include #include #include #include -#include #include -#include +#include #include #include #include "libr2c2/driver.h" @@ -41,8 +32,6 @@ using namespace std; using namespace R2C2; using namespace Msp; -Application::RegApp Engineer::reg; - Engineer::Engineer(int argc, char **argv): options(argc, argv), window(options.screen_w, options.screen_h, options.fullscreen), @@ -82,9 +71,10 @@ Engineer::Engineer(int argc, char **argv): DataFile::load(layout, options.layout_fn); layout.signal_train_added.connect(sigc::mem_fun(this, &Engineer::train_added)); - layout.signal_block_reserved.connect(sigc::mem_fun(this, &Engineer::block_reserved)); + layout.signal_block_reserved.connect(sigc::hide<1>(sigc::mem_fun(this, &Engineer::reset_block_color))); + layout.signal_block_state_changed.connect(sigc::hide<1>(sigc::mem_fun(this, &Engineer::reset_block_color))); 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(options.state_fn)) DataFile::load(layout, options.state_fn); @@ -107,15 +97,15 @@ Engineer::Engineer(int argc, char **argv): 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::Pipeline::Pass *pass = &pipeline.add_pass(0); + pass->set_depth_test(&GL::DepthTest::lequal()); + pass->set_lighting(&lighting); pass = &pipeline.add_pass("unlit"); - pass->depth_test = &GL::DepthTest::lequal(); + pass->set_depth_test(&GL::DepthTest::lequal()); pass = &pipeline.add_pass("overlay"); - pass->blend = &GL::Blend::alpha(); + pass->set_blend(&GL::Blend::alpha()); view_all(); @@ -205,7 +195,7 @@ void Engineer::tick() GL::Framebuffer::system().clear(GL::COLOR_BUFFER_BIT|GL::DEPTH_BUFFER_BIT); - pipeline.render_all(); + pipeline.render(); if(pointer_moved) { @@ -234,29 +224,18 @@ void Engineer::tick() if(picking && picking_track && picking_entry>=0) { - GL::PushMatrix push_mat; + GL::MatrixStack::Push push_mat(GL::MatrixStack::modelview()); float rot = picking_track->get_endpoint_direction(picking_entry); Vector pos = picking_track->get_endpoint_position(picking_entry); - GL::translate(pos.x, pos.y, pos.z+0.03); - GL::rotate(rot*180/M_PI+180, 0, 0, 1); + GL::MatrixStack::modelview() *= GL::Matrix::translation(pos.x, pos.y, pos.z+0.03); + GL::MatrixStack::modelview() *= GL::Matrix::rotation(rot+M_PI, 0, 0, 1); arrow_mesh.draw(); } - const GLtk::Geometry &rgeom = root->get_geometry(); - GL::matrix_mode(GL::PROJECTION); - GL::load_identity(); - GL::ortho_bottomleft(rgeom.w, rgeom.h); - GL::matrix_mode(GL::MODELVIEW); - GL::load_identity(); - - { - GL::Bind blend(GL::Blend::alpha()); - root->render(); - GL::Texture::unbind(); - } + root->render(); window.swap_buffers(); } @@ -382,9 +361,7 @@ void Engineer::set_block_color(const Block &block, const GL::Color &color) void Engineer::reset_block_color(const Block &block) { - bool active = false; - if(unsigned sid=block.get_sensor_id()) - active = layout.get_driver().get_sensor(sid); + bool active = block.get_state()>Block::INACTIVE; if(block.get_train()) { @@ -404,19 +381,6 @@ void Engineer::reset_block_color(const Block &block) set_block_color(block, GL::Color(1)); } -void Engineer::sensor_event(unsigned addr, bool) -{ - const set &blocks = layout.get_blocks(); - for(set::const_iterator i=blocks.begin(); i!=blocks.end(); ++i) - if((*i)->get_sensor_id()==addr) - reset_block_color(**i); -} - -void Engineer::block_reserved(const Block &block, const Train *) -{ - reset_block_color(block); -} - Track *Engineer::pick_track(int x, int y) { const GL::Vector3 &start = camera.get_position();