Commit d2b4ff74 authored by Thibault Soucarre's avatar Thibault Soucarre

currently used color and filecolor corresponding to an entity are now stocked in class EntityValue

parent aa64bd55
......@@ -1310,3 +1310,8 @@ void Core::export_variable(Variable *var, const string &filename) {
_main_window->error("Unable to open " + filename + " in order to export the counter");
}
}
void Core::change_entity_color(std::string entity, Element_col r, Element_col g, Element_col b){
std::cout << "core" << std::endl;
_render_opengl->change_color(entity, r, g, b);
}
......@@ -504,6 +504,12 @@ public:
*/
void export_variable(Variable *var, const std::string &filename);
/*!
* \brief Change the color corresponding to an EntityValue
*/
void change_entity_color(std::string entity, Element_col r, Element_col g, Element_col b);
//Qt signals fo the Parsing Thread
signals:
......
......@@ -207,6 +207,7 @@ void Settings_window::color_changed(string name, QTableWidget *table, const QCol
S.add_state_to_palette(name, palette_name, state_name, color, checked );
p->add_state(state_name, color, checked );
_c->change_entity_color(state_name, color.get_red(), color.get_green(), color.get_blue());
return;
}
......
......@@ -6,13 +6,13 @@
** use, modify and/or redistribute the software under the terms of the
** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
** URL: "http://www.cecill.info".
**
**
** As a counterpart to the access to the source code and rights to copy,
** modify and redistribute granted by the license, users are provided
** only with a limited warranty and the software's author, the holder of
** the economic rights, and the successive licensors have only limited
** liability.
**
**
** In this respect, the user's attention is drawn to the risks associated
** with loading, using, modifying and/or developing or reproducing the
** software by the user in light of its specific status of free software,
......@@ -23,7 +23,7 @@
** their requirements in conditions enabling the security of their
** systems and/or data to be ensured and, more generally, to use and
** operate it in the same conditions as regards security.
**
**
** The fact that you are presently reading this means that you have had
** knowledge of the CeCILL-A license and that you accept its terms.
**
......@@ -37,7 +37,7 @@
** - MARCOUEILLE Jule
** - NOISETTE Pascal
** - REDONDY Arthur
** - VUCHENER Clément
** - VUCHENER Clément
**
*/
/*!
......@@ -64,7 +64,7 @@ private:
public:
ParserEventPaje(ParserDefinitionPaje *Defs);
~ParserEventPaje();
/*!
......
......@@ -43,6 +43,7 @@
/*!
*\file Render_alternate.cpp
*/
#include <assert.h>
#include "common/common.hpp"
#include "common/Info.hpp"
#include "common/Message.hpp"
......@@ -754,6 +755,7 @@ void Render_alternate::draw_state(const Element_pos x, const Element_pos y, cons
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);
_states_shaders.insert(p);
Vbo *v = new Vbo(GL_QUADS);
......@@ -952,3 +954,26 @@ void Render_alternate::clear_text (){
_texts.clear();
_variable_texts.clear();
}
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;
it = _states_shaders.begin();
while(it != _states_shaders.end()){
std::cout << "salut" << std::endl;
//std::cout << it->first->get_name().get_name() << std::endl;
//assert(it->first); // TODO: check why busy state exists and uncomment this assert
if(it->first && (it->first->get_name() == entity)){
std::cout << "rentré dans le if" << std::endl;
Shader* s = it->second;
delete s;
s = new Shader(_glsl, r, g, b);
s->charger();
break;
}
std::cout << "iteration" << std::endl;
it++;
}
}
......@@ -543,9 +543,17 @@ public slots:
*/
void update_vertical_line();
/*! Function that only delete the text of the screen */
/*!
* \brief Function that only delete the text of the screen
*/
void clear_text ();
/*!
* \brief Change the color corresponding to an EntityValue
*/
void change_color(std::string entity, Element_col r, Element_col g, Element_col b);
};
......
......@@ -363,7 +363,7 @@ void DrawTree<D, E>::browse_tree(const Interval &I, Node<E> *node, bool &b) {
Date time = node->get_element()->get_time();
if(time <= I._right && time >= I._left) {
// If the node can be displayed (interval is wide enought)
// If the node can be displayed (interval is wide enough)
if (I._right - I._left > _min_size){
// Launching Recursively in children
if (n_children >= 1)//left
......
......@@ -53,8 +53,8 @@ class Container;
*/
struct Entity {
private:
Container *_container;
std::map<std::string, Value *>* _extra_fields;
Container *_container;
std::map<std::string, Value *> *_extra_fields;
public:
/*
......
......@@ -51,18 +51,19 @@
/* -- */
using namespace std;
EntityType::EntityType(Name name, ContainerType *container_type, map<std::string, Value *>& opt):
_name(name), _container_type(container_type) {
if(opt.empty())_extra_fields=NULL;
else{ _extra_fields=new map<std::string, Value *>(opt);
EntityType::EntityType(EntityClass_t ec, Name name, ContainerType *container_type, map<std::string, Value *>& opt):
_class(ec), _name(name), _container_type(container_type)
{
if( opt.empty() )
_extra_fields = NULL;
else {
_extra_fields = new map<std::string, Value *>(opt);
opt.clear();
}
}
}
EntityType::EntityType():_extra_fields(NULL)
{}
// EntityType::EntityType():_extra_fields(NULL)
// {}
void EntityType::add_value(EntityValue *value) {
_values.insert ( pair<Name , EntityValue*>(value->get_name(),value));
......@@ -72,6 +73,10 @@ const Name EntityType::get_name() const {
return _name;
}
const EntityClass_t EntityType::get_class() const {
return _class;
}
const ContainerType *EntityType::get_container_type() const {
return _container_type;
}
......
......@@ -43,6 +43,14 @@
#ifndef ENTITYTYPE_HPP
#define ENTITYTYPE_HPP
typedef enum EntityClass_e {
_EntityClass_State,
_EntityClass_Link,
_EntityClass_Event,
_EntityClass_Variable
} EntityClass_t;
/*!
* \file EntityType.hpp
*/
......@@ -53,12 +61,14 @@ class EntityValue;
*/
class EntityType {
private:
Name _name;
ContainerType *_container_type;
std::map<Name, EntityValue* > _values;
EntityClass_t _class; /* Class of EntityType: State, Link, Event or Variable */
Name _name;
ContainerType *_container_type;
std::map<Name, EntityValue* > _values;
std::map<std::string, Value *>* _extra_fields;
protected:
/*!
* \fn EntityType(Name name, ContainerType *container_type, std::map<std::string, Value *> opt)
* \brief Default constructor
......@@ -66,10 +76,11 @@ protected:
* \param container_type The type of container
* \param opt Optional fields
*/
EntityType(Name name, ContainerType *container_type, std::map<std::string, Value *>& opt);
EntityType(EntityClass_t ec, Name name, ContainerType *container_type, std::map<std::string, Value *>& opt);
public:
EntityType();
//EntityType();
/*
* \fn EntityType
* \brief Destructor
......@@ -88,6 +99,8 @@ public:
*/
const Name get_name() const;
const EntityClass_t get_class() const;
/*!
* \fn get_container_type() const
* \brief Get the type of the container
......
......@@ -43,6 +43,7 @@
#include <string>
#include "stdio.h"
#include <list>
#include <iostream>
#include <map>
/* -- */
#include "trace/values/Values.hpp"
......@@ -53,9 +54,39 @@
using namespace std;
EntityValue::EntityValue(const Name &name, EntityType *type, map<std::string, Value *> opt): _name(name), _type(type), _opt(opt) {
// 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"));
if ( it != opt.end() ) {
_filecolor = (Color*)(it->second);
opt.erase(it);
} else {
if (type->get_class() == _EntityClass_State)
_filecolor = new Color();
else
_filecolor = new Color(1., 1., 1.);
}
// Set the used color to the color selected in the palette if existing, otherwise equal to the filecolor.
_usedcolor = _filecolor;
switch (type->get_class()) {
case _EntityClass_State:
case _EntityClass_Link:
case _EntityClass_Event:
case _EntityClass_Variable:
break;
default:
std::cerr << "Error unsupported type for Entity value" << std::endl;
}
}
EntityValue::EntityValue(){}
// EntityValue::EntityValue(){
// _filecolor = new Color();
// _usedcolor = _filecolor;
// }
Name EntityValue::get_name() const {
//std::cout << "get_name" << std::endl;
return _name;
}
......@@ -75,4 +106,8 @@ EntityValue::~EntityValue(){
it++){
delete (*it).second;
}
if (_usedcolor != _filecolor)
delete _usedcolor;
delete _filecolor;
}
......@@ -42,6 +42,7 @@
*/
#ifndef ENTITYVALUE_HPP
#define ENTITYVALUE_HPP
#include "common/common.hpp"
/*!
* \file EntityValue.hpp
......@@ -52,13 +53,14 @@ class EntityType;
* \brief Describe the value of an entity
*/
class EntityValue {
private:
Name _name;
EntityType *_type;
std::map<std::string, Value *> _opt;
//Element_col _r;
//Element_col _g;
//Element_col _b;
Color *_filecolor;
Color *_usedcolor;
public:
/*!
......@@ -69,7 +71,6 @@ public:
* \param opt Extra fields
*/
EntityValue(const Name &name, EntityType *type, std::map<std::string, Value *> opt);
EntityValue();
/*!
* \fn get_name() const
......
......@@ -52,10 +52,8 @@
using namespace std;
EventType::EventType(Name name, ContainerType *container_type, map<std::string, Value *> opt):
EntityType(name, container_type, opt) {
EntityType(_EntityClass_Event, name, container_type, opt) {
}
EventType::EventType() {
}
// EventType::EventType() {
// }
......@@ -62,7 +62,7 @@ public :
* \param opt optional data about the event
*/
EventType(Name name, ContainerType *container_type, std::map<std::string, Value *> opt);
EventType();
//EventType();
};
#endif
......@@ -52,14 +52,13 @@
using namespace std;
LinkType::LinkType(Name name, ContainerType *container_type, ContainerType *source_type, ContainerType *destination_type, map<std::string, Value *> opt):
EntityType(name, container_type, opt), _source_type(source_type), _destination_type(destination_type) {
EntityType(_EntityClass_Link, name, container_type, opt), _source_type(source_type), _destination_type(destination_type) {
}
LinkType::LinkType()
{
}
// LinkType::LinkType()
// {
// }
LinkType::~LinkType(){
// All the ContainerType are deleted by the trace itself (recursively)
......@@ -69,15 +68,15 @@ LinkType::~LinkType(){
}
const ContainerType * LinkType::get_source_type() const{
return _source_type;
}
const ContainerType * LinkType::get_destination_type() const{
return _destination_type;
}
void LinkType::set_source_type(ContainerType * source){
_source_type=source;
}
void LinkType::set_destination_type(ContainerType * dest){
_destination_type=dest;
}
const ContainerType * LinkType::get_source_type() const{
return _source_type;
}
const ContainerType * LinkType::get_destination_type() const{
return _destination_type;
}
void LinkType::set_source_type(ContainerType * source){
_source_type=source;
}
void LinkType::set_destination_type(ContainerType * dest){
_destination_type=dest;
}
......@@ -66,7 +66,7 @@ public :
* \param opt optional data of the link
*/
LinkType(Name name, ContainerType *container_type, ContainerType *source_type, ContainerType *destination_type, std::map<std::string, Value *> opt);
LinkType();
//LinkType();
/*!
* \fn ~LinkType()
* \brief Destructor
......
......@@ -52,9 +52,9 @@
using namespace std;
StateType::StateType(Name name, ContainerType *container_type, map<std::string, Value *> opt):
EntityType(name, container_type, opt) {
EntityType(_EntityClass_State, name, container_type, opt)
{
}
StateType::StateType(){
}
// StateType::StateType(){
// }
......@@ -62,7 +62,7 @@ public:
* \param opt Optional parameters
*/
StateType(Name name, ContainerType *container_type, std::map<std::string, Value *> opt);
StateType();
//StateType();
};
#endif
......@@ -245,7 +245,7 @@ void Trace::define_event_type(Name &name, ContainerType *container_type, map<str
void Trace::define_state_type(Name &name, ContainerType *container_type, map<string, Value *> &opt) {
StateType* st=new StateType(name, container_type, opt);
_state_types.insert ( pair<Name , StateType*>(name,st));
_state_types.insert ( pair<Name , StateType*>(name,st) );
#if defined(USE_ITC) && defined(BOOST_SERIALIZE)
Serializer<EntityType>::Instance().setUid(st);
......@@ -284,19 +284,7 @@ void Trace::define_link_type(Name &name,
void Trace::define_entity_value(Name &name, EntityType *entity_type, map<string, Value *> &opt) {
if (entity_type) {
//don't alter the trace, reloading initial colors won't be possible after that.
// The palettes are applied ine DrawTrace or DrawTree after that
/*if(Session::_palette) {
Color *c = Session::_palette->get_color(name.to_string());
if(c != NULL) { // We set the palette color first
if(opt.find("Color") != opt.end()) {
delete opt["Color"];
}
opt["Color"] = new Color(*c);
}
}*/
// It should be only states
entity_type->add_value(new EntityValue(name, entity_type, opt));
}
}
......
......@@ -51,10 +51,10 @@
/* -- */
using namespace std;
VariableType::VariableType(Name name, ContainerType *container_type, map<std::string, Value *> opt): EntityType(name, container_type, opt) {
VariableType::VariableType(Name name, ContainerType *container_type, map<std::string, Value *> opt): EntityType(_EntityClass_Variable, name, container_type, opt) {
}
VariableType::VariableType() {
// VariableType::VariableType() {
}
// }
......@@ -59,7 +59,7 @@ public:
* \param opt optional fields
*/
VariableType(Name name, ContainerType *container_type, std::map<std::string, Value *> opt);
VariableType();
//VariableType();
};
#endif
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