Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 48fd4526 authored by Thibault Soucarre's avatar Thibault Soucarre
Browse files

Settings for states corrected

parent d2b4ff74
Branches
Tags
No related merge requests found
......@@ -1315,3 +1315,7 @@ void Core::change_entity_color(std::string entity, Element_col r, Element_col g,
std::cout << "core" << std::endl;
_render_opengl->change_color(entity, r, g, b);
}
void Core::reload_states(){
_render_opengl->reload_states();
}
......@@ -509,6 +509,10 @@ public:
*/
void change_entity_color(std::string entity, Element_col r, Element_col g, Element_col b);
/*!
* \brief reload state color from trace file
*/
void reload_states();
//Qt signals fo the Parsing Thread
signals:
......
......@@ -427,6 +427,7 @@ void Settings_window::on_reload_states_btn_clicked(){
add_table_line(states_table, SLOT(state_color_changed(const QColor &)),
row, (*it).first.c_str(), (*it).second, true);
}
_c->reload_states();
}
......
......@@ -267,7 +267,7 @@ public:
* \param b the blue color rate of the state.
*/
inline void draw_state(const Element_pos start, const Element_pos end, const Element_pos base, const Element_pos height, const Element_col r, const Element_col g, const Element_col b, const EntityValue * value) {
inline void draw_state(const Element_pos start, const Element_pos end, const Element_pos base, const Element_pos height, const Element_col r, const Element_col g, const Element_col b, EntityValue * value) {
drawing_instance->set_color(r, g, b);
......
......@@ -76,7 +76,7 @@ public:
*/
virtual void start_draw_states() = 0;
virtual void draw_state(const Element_pos , const Element_pos , const Element_pos , const Element_pos , const Element_pos , const EntityValue* type) = 0;
virtual void draw_state(const Element_pos , const Element_pos , const Element_pos , const Element_pos , const Element_pos , EntityValue* type) = 0;
/*!
* \brief Called when all state draws are finished.
......
......@@ -226,7 +226,7 @@ void Render_alternate::paintGL(){
_modelview = glm::translate(_modelview, glm::vec3(_default_entity_x_translate - _x_state_translate, _ruler_y + _ruler_height - _y_state_translate, _z_state));
_modelview = glm::scale(_modelview, glm::vec3(_x_state_scale, _y_state_scale, 1));
mvp = _projection * _modelview;
std::map<const EntityValue*, Vbo*>::iterator it_state;
std::map<EntityValue*, Vbo*>::iterator it_state;
it_state = _states.begin();
while(it_state!=_states.end()){
Shader *s = _states_shaders[it_state->first];
......@@ -751,15 +751,15 @@ void Render_alternate::start_draw_states(){
_draw_states = true;
}
void Render_alternate::draw_state(const Element_pos x, const Element_pos y, const Element_pos z, const Element_pos w, const Element_pos h, const EntityValue* value){
void Render_alternate::draw_state(const Element_pos x, const Element_pos y, const Element_pos z, const Element_pos w, const Element_pos h, EntityValue* value){
if(_states.count(value)==0){
Shader *s = new Shader(_glsl, _r, _g, _b);
s->charger();
//assert(value); // TODO: check why busy state exists and uncomment this assert
std::pair<const EntityValue*, Shader*> p(value, s);
std::pair<EntityValue*, Shader*> p(value, s);
_states_shaders.insert(p);
Vbo *v = new Vbo(GL_QUADS);
std::pair<const EntityValue*, Vbo*> p2(value, v);
std::pair<EntityValue*, Vbo*> p2(value, v);
_states.insert(p2);
}
_current = _states[value];
......@@ -769,7 +769,7 @@ void Render_alternate::draw_state(const Element_pos x, const Element_pos y, cons
void Render_alternate::end_draw_states(){
_draw_states = false;
std::map<const EntityValue*, Vbo*>::iterator it;
std::map<EntityValue*, Vbo*>::iterator it;
it = _states.begin();
while(it!=_states.end()){
it->second->config(_glsl);
......@@ -957,7 +957,7 @@ void Render_alternate::clear_text (){
void Render_alternate::change_color(std::string entity, Element_col r, Element_col g, Element_col b){
std::cout << "changement shader" << std::endl;
std::map<const EntityValue*, Shader*>::iterator it;
std::map<EntityValue*, Shader*>::iterator it;
it = _states_shaders.begin();
while(it != _states_shaders.end()){
std::cout << "salut" << std::endl;
......@@ -965,6 +965,8 @@ void Render_alternate::change_color(std::string entity, Element_col r, Element_c
//assert(it->first); // TODO: check why busy state exists and uncomment this assert
if(it->first && (it->first->get_name() == entity)){
Color *c = new Color(r, g, b);
it->first->set_used_color(c);
std::cout << "rentré dans le if" << std::endl;
Shader* s = it->second;
delete s;
......@@ -977,3 +979,17 @@ void Render_alternate::change_color(std::string entity, Element_col r, Element_c
}
}
void Render_alternate::reload_states(){
std::map<EntityValue*, Shader*>::iterator it;
it = _states_shaders.begin();
while(it != _states_shaders.end()){
it->first->reload_file_color();
Shader* s = it->second;
delete s;
s = new Shader(_glsl, it->first->get_used_color()->get_red(),
it->first->get_used_color()->get_green(),
it->first->get_used_color()->get_blue());
s->charger();
it++;
}
}
......@@ -123,8 +123,8 @@ private:
Vbo _ruler;
Vbo _wait;
Vbo *_current;
std::map<const EntityValue*, Vbo*> _states;
std::map<const EntityValue*, Shader*> _states_shaders;
std::map<EntityValue*, Vbo*> _states;
std::map<EntityValue*, Shader*> _states_shaders;
GLuint _textureID;
/*!
* \brief Offset of the vertical helper line
......@@ -259,7 +259,7 @@ void start_draw_states();
* \param g the green color rate of the state.
* \param b the blue color rate of the state.
*/
void draw_state(const Element_pos start , const Element_pos end, const Element_pos base, const Element_pos height, const Element_pos r, const EntityValue* type);
void draw_state(const Element_pos start , const Element_pos end, const Element_pos base, const Element_pos height, const Element_pos r, EntityValue* type);
/*!
* \brief Closes the state display list.
......@@ -554,6 +554,11 @@ public slots:
void change_color(std::string entity, Element_col r, Element_col g, Element_col b);
/*!
* \brief reload state color from trace file
*/
void reload_states();
};
......
......@@ -872,7 +872,7 @@ void Render_opengl::start_draw_states(){
glNewList(_list_states, GL_COMPILE);/* open the list */
}
void Render_opengl::draw_state(const Element_pos x, const Element_pos y, const Element_pos z, const Element_pos w, const Element_pos h, const EntityValue* value){
void Render_opengl::draw_state(const Element_pos x, const Element_pos y, const Element_pos z, const Element_pos w, const Element_pos h, EntityValue* value){
draw_quad(x, y, z, w, h);
}
......
......@@ -379,7 +379,7 @@ public:
* \param g the green color rate of the state.
* \param b the blue color rate of the state.
*/
void draw_state(const Element_pos, const Element_pos, const Element_pos, const Element_pos, const Element_col, const EntityValue* );
void draw_state(const Element_pos, const Element_pos, const Element_pos, const Element_pos, const Element_col, EntityValue* );
/*!
* \brief Closes the state display list.
......
......@@ -221,7 +221,7 @@ void Render_svg::start_draw_states(){
}
void Render_svg::draw_state(const Element_pos, const Element_pos, const Element_pos, const Element_pos, const Element_col, const EntityValue* ){
void Render_svg::draw_state(const Element_pos, const Element_pos, const Element_pos, const Element_pos, const Element_col, EntityValue* ){
}
void Render_svg::end_draw_states(){
......
......@@ -136,7 +136,7 @@ public:
* \param g the green color rate of the state.
* \param b the blue color rate of the state.
*/
void draw_state(const Element_pos, const Element_pos, const Element_pos, const Element_pos, const Element_col, const EntityValue* );
void draw_state(const Element_pos, const Element_pos, const Element_pos, const Element_pos, const Element_col, EntityValue* );
/*!
* \brief Closes the state display list.
......
......@@ -119,7 +119,7 @@ public:
* \param g Green value of the state color
* \param b Blue value of the state color
*/
inline void draw_state(double starttime, double endtime, double r, double g, double b, const EntityValue * value) {
inline void draw_state(double starttime, double endtime, double r, double g, double b, EntityValue * value) {
Element_pos y = _position + _container_v_space/2;
_draw_object->draw_state(starttime, endtime, y, _state_height, r, g, b, value);
}
......@@ -239,7 +239,7 @@ struct DrawNode<D, StateChange> {
node->get_element()->get_left_state()){
std::map<std::string, Value *>::const_iterator field;
const State *state = node->get_element()->get_left_state();
const std::map<std::string, Value *> *extra_fields;
/*const std::map<std::string, Value *> *extra_fields;
const Color *color=NULL;
extra_fields = state->get_value()->get_extra_fields();
......@@ -265,17 +265,18 @@ struct DrawNode<D, StateChange> {
extra_fields!=NULL &&
!extra_fields->empty() &&
((field = extra_fields->find(std::string("Color"))) != extra_fields->end())) {
/* Call the object state drawing function with the state color */
// Call the object state drawing function with the state color
color = (const Color *)(*field).second;
}else{
color=new Color(0.7, 0.7, 0.75);
}
}
}*/
const EntityValue * value = state->get_value();
EntityValue * value = state->get_value();
const Color * color = value->get_used_color();
draw->draw_state(interval->_left.get_value(), state->get_end_time().get_value(),
color->get_red(), color->get_green(), color->get_blue(), value);
}
//}
......
......@@ -50,10 +50,12 @@
#include "trace/ContainerType.hpp"
#include "trace/EntityType.hpp"
#include "trace/EntityValue.hpp"
#include "common/Session.hpp"
#include "common/Palette.hpp"
/* -- */
using namespace std;
EntityValue::EntityValue(const Name &name, EntityType *type, map<std::string, Value *> opt): _name(name), _type(type), _opt(opt) {
EntityValue::EntityValue(const Name &name, EntityType *type, map<std::string, Value *> opt): _name(name), _type(type), _opt(opt), _display(true){
// Search opt field for color to set the default (random if not provided within the trace file)
map<std::string, Value *>::iterator it = opt.find(string("Color"));
......@@ -71,6 +73,15 @@ EntityValue::EntityValue(const Name &name, EntityType *type, map<std::string, Va
_usedcolor = _filecolor;
switch (type->get_class()) {
case _EntityClass_State:
if(Session::get_use_palette("palette")){
Palette *sp = Session::get_palette("palette", Session::get_current_palette("palette"));
Color* color = sp->get_color(type->get_name().to_string());
if(!color)
_display=false;
else
_usedcolor = color;
}
break;
case _EntityClass_Link:
case _EntityClass_Event:
case _EntityClass_Variable:
......@@ -98,6 +109,22 @@ const map<string, Value *> *EntityValue::get_extra_fields() const {
return &_opt;
}
const Color* EntityValue::get_used_color() const{
return _usedcolor;
}
void EntityValue::set_used_color(Color *c){
if(_usedcolor!=_filecolor)
delete _usedcolor;
_usedcolor = c;
}
void EntityValue::reload_file_color(){
if(_usedcolor!=_filecolor)
delete _usedcolor;
_usedcolor = _filecolor;
}
EntityValue::~EntityValue(){
_type = NULL;
......@@ -107,7 +134,8 @@ EntityValue::~EntityValue(){
delete (*it).second;
}
if (_usedcolor != _filecolor)
/*if (_usedcolor != _filecolor && _usedcolor!=NULL)
delete _usedcolor;
delete _filecolor;
if(_filecolor!=NULL)
delete _filecolor;*/
}
......@@ -61,6 +61,7 @@ private:
Color *_filecolor;
Color *_usedcolor;
bool _display;
public:
/*!
......@@ -90,6 +91,12 @@ public:
*/
const std::map<std::string, Value *> *get_extra_fields() const;
const Color * get_used_color() const;
void set_used_color(Color *c);
void reload_file_color();
virtual ~EntityValue();
};
......
......@@ -77,6 +77,10 @@ const StateType *State::get_type() const {
return _type;
}
const EntityValue *State::get_value() const {
/*const EntityValue *State::get_value() const {
return _value;
}*/
EntityValue *State::get_value() const {
return _value;
}
......@@ -91,7 +91,9 @@ public:
* \brief Get the value of the state
* \return Pointer to the Entityvalue or NULL if it has no value
*/
const EntityValue *get_value() const;
//const EntityValue *get_value() const;
EntityValue *get_value() const;
/*!
* \fn set_left_date(Date)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment