Commit 6b4075fd authored by Mathieu Faverge's avatar Mathieu Faverge

Connect the Render_alternate to the signal generated by the EntityValues

parent 465cc998
......@@ -48,8 +48,8 @@
#include "common/Info.hpp"
#include "common/Message.hpp"
/* -- */
//#include "render/GanttDiagram.hpp"
#include <map>
#include <GL/glew.h>
/* -- */
#include <QFile> // For loading the wait image
......@@ -65,6 +65,13 @@
#include "common/Info.hpp"
#include "common/Message.hpp"
/* -- */
#include "trace/values/Values.hpp"
#include "trace/tree/Interval.hpp"
#include "trace/tree/Node.hpp"
#include "trace/tree/BinaryTree.hpp"
#include "trace/EntityValue.hpp"
#include "trace/EntityTypes.hpp"
#include "trace/Entitys.hpp"
#include "trace/Trace.hpp"
/* -- */
#include "render/Ruler.hpp"
......@@ -976,6 +983,9 @@ void Render_alternate::draw_state(const Element_pos x, const Element_pos y, cons
Vbo *v = new Vbo(s);
std::pair<EntityValue*, Vbo*> p2(value, v);
_states.insert(p2);
connect( value, SIGNAL(changedColor( EntityValue * )),
this, SLOT(update_ev( EntityValue *)) );
}
//add the state to the vbo
_current = _states[value];
......@@ -1014,6 +1024,9 @@ void Render_alternate::start_draw_arrows(){
std::vector<Element_pos> v;
std::pair<EntityValue*, std::vector<Element_pos> > p3(value, v);
_links.insert(p3);
connect( value, SIGNAL(changedColor( EntityValue * )),
this, SLOT(update_ev( EntityValue *)) );
}
//store data in vbo
const Element_pos offset_x = -_default_entity_x_translate;
......@@ -1077,6 +1090,9 @@ void Render_alternate::draw_event(const Element_pos time, const Element_pos heig
std::pair<Vbo*, Vbo*> p1(v1, v2);
std::pair<EntityValue*, std::pair<Vbo*, Vbo*> > p2(value, p1);
_events.insert(p2);
connect( value, SIGNAL(changedColor( EntityValue * )),
this, SLOT(update_ev( EntityValue *)) );
}
const Element_pos offset_x = -_default_entity_x_translate;
const Element_pos offset_y = -_ruler_y - _ruler_height;
......@@ -1217,6 +1233,81 @@ void Render_alternate::clear_text (){
_variable_texts.clear();
}
/* Change the shader associated to entityType entity */
void
Render_alternate::update_ev_single( EntityValue *ev,
std::map<EntityValue*, Vbo*> *evmap,
bool shaded )
{
std::map<EntityValue*, Vbo*>::iterator it;
it = evmap->find( ev );
if ( it != evmap->end() ) {
Vbo *vbo = it->second;
Color *c = ev->get_used_color();
//delete previous shader
vbo->delete_shader();
//create and load the new shader*/
Shader *s = new Shader(_glsl,
c->get_red(),
c->get_green(),
c->get_blue(),
shaded );
s->charger();
vbo->set_shader(s);
}
}
void
Render_alternate::update_ev_couple( EntityValue *ev,
std::map<EntityValue*, std::pair<Vbo*, Vbo*> > *evmap,
bool shaded )
{
std::map< EntityValue*, std::pair<Vbo*, Vbo*> >::iterator it;
it = evmap->find( ev );
if ( it != evmap->end() ) {
Vbo *vbo1 = it->second.first;
Vbo *vbo2 = it->second.second;
Color *c = ev->get_used_color();
//delete previous shader
vbo1->delete_shader();
//create and load the new shader*/
Shader *s = new Shader(_glsl,
c->get_red(),
c->get_green(),
c->get_blue(),
shaded );
s->charger();
vbo1->set_shader(s);
vbo2->set_shader(s);
}
}
void
Render_alternate::update_ev( EntityValue *ev )
{
EntityClass_t ec = ev->get_class();
switch( ec ) {
case _EntityClass_State:
update_ev_single( ev, &_states, true );
break;
case _EntityClass_Event:
update_ev_couple( ev, &_events, false );
break;
case _EntityClass_Link:
update_ev_couple( ev, &_arrows, false );
}
}
/* Change the shader associated to entityType entity */
void Render_alternate::change_color(std::string entity,
Element_col r,
......
......@@ -556,6 +556,12 @@ public:
*/
Element_pos get_vertical_line();
void update_ev_single( EntityValue *ev,
std::map<EntityValue*, Vbo*> *evmap,
bool shaded );
void update_ev_couple( EntityValue *ev,
std::map<EntityValue*, std::pair<Vbo*, Vbo*> > *evmap,
bool shaded );
public slots:
/*!
* \brief slot connected to the simple click event
......@@ -594,6 +600,7 @@ public slots:
void render_text(QString text, float x, float y, float w, float h);
void update_ev( EntityValue *ev );
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment