Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Commit 81284e56 authored by Mathieu Faverge's avatar Mathieu Faverge
Browse files

Simplify EntityValue creation

parent 758bdcae
...@@ -123,7 +123,6 @@ public: ...@@ -123,7 +123,6 @@ public:
virtual ~GanttDiagram(){ virtual ~GanttDiagram(){
} }
/*********************************** /***********************************
* *
* Building functions. * Building functions.
......
...@@ -55,7 +55,13 @@ ...@@ -55,7 +55,13 @@
/* -- */ /* -- */
using namespace std; using namespace std;
EntityValue::EntityValue(const Name &name, EntityType *type, map<std::string, Value *> opt): _name(name), _type(type), _opt(opt), _visible(true){ EntityValue::EntityValue(const Name &name, EntityType *type, map<std::string, Value *> opt)
: _name(name), _type(type), _opt(opt), _visible(true)
{
Palette *sp = NULL;
Color *color = NULL;
Color *new_color;
std::string palette_name = "default";
// Search opt field for color to set the default (random if not provided within the trace file) // 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")); map<std::string, Value *>::iterator it = opt.find(string("Color"));
...@@ -71,60 +77,38 @@ EntityValue::EntityValue(const Name &name, EntityType *type, map<std::string, Va ...@@ -71,60 +77,38 @@ EntityValue::EntityValue(const Name &name, EntityType *type, map<std::string, Va
// Set the used color to the color selected in the palette if existing, otherwise equal to the filecolor. // Set the used color to the color selected in the palette if existing, otherwise equal to the filecolor.
_usedcolor = _filecolor; _usedcolor = _filecolor;
Palette *sp = NULL;
Color *color = NULL;
Color *new_color;
switch (type->get_class()) { switch (type->get_class()) {
case _EntityClass_State: case _EntityClass_State:
//if(Session::get_use_palette("palette")){ palette_name = "palette";
sp = Session::get_palette("palette", Session::get_current_palette("palette"));
color = sp->get_color(name.get_name());
if(color != NULL){
std::cout << name.get_alias() << " " << color->get_red() << " " << color->get_green() << " " << color->get_blue() << std::endl;
//color is used in palette class. It will be free'd when modifying palette (remove_palette -> create_palette) but we don't want _usedcolor to be free'd at the same moment. So we use new_color to make a copy
new_color = new Color(color->get_red(), color->get_green(), color->get_blue());
_usedcolor = new_color;
}
if(sp->is_visible(name.get_name()))
_visible=true;
else
_visible = false;
break; break;
case _EntityClass_Link: case _EntityClass_Link:
//if(Session::get_use_palette("palette")){ palette_name = "link_types";
sp = Session::get_palette("link_types", Session::get_current_palette("link_types"));
color = sp->get_color(name.get_name());
if(color != NULL){
std::cout << name.get_alias() << " " << color->get_red() << " " << color->get_green() << " " << color->get_blue() << std::endl;
//color is used in palette class. It will be free'd when modifying palette (remove_palette -> create_palette) but we don't want _usedcolor to be free'd at the same moment. So we use new_color to make a copy
new_color = new Color(color->get_red(), color->get_green(), color->get_blue());
_usedcolor = new_color;
}
if(sp->is_visible(name.get_name()))
_visible=true;
else
_visible = false;
break; break;
case _EntityClass_Event: case _EntityClass_Event:
sp = Session::get_palette("event_types", Session::get_current_palette("event_types")); palette_name = "event_types";
color = sp->get_color(name.get_name());
if(color != NULL){
std::cout << name.get_alias() << " " << color->get_red() << " " << color->get_green() << " " << color->get_blue() << std::endl;
//color is used in palette class. It will be free'd when modifying palette (remove_palette -> create_palette) but we don't want _usedcolor to be free'd at the same moment. So we use new_color to make a copy
new_color = new Color(color->get_red(), color->get_green(), color->get_blue());
_usedcolor = new_color;
}
if(sp->is_visible(name.get_name()))
_visible=true;
else
_visible = false;
break; break;
case _EntityClass_Variable: case _EntityClass_Variable:
break; break;
default: default:
std::cerr << "Error unsupported type for Entity value" << std::endl; std::cerr << "Error unsupported type for Entity value" << std::endl;
break; break;
} }
if ( type->get_class() != _EntityClass_Variable ) {
sp = Session::get_palette( palette_name,
Session::get_current_palette( palette_name ) );
color = sp->get_color( name.get_name() );
if( color != NULL ) {
_usedcolor = new Color( color );
}
if( sp->is_visible( name.get_name() ) ) {
_visible = true;
}
else {
_visible = false;
}
}
} }
EntityValue::~EntityValue() EntityValue::~EntityValue()
......
...@@ -68,6 +68,10 @@ Color::Color(const Color &c) : Value(c), _r(c._r), _g(c._g), _b(c._b) { ...@@ -68,6 +68,10 @@ Color::Color(const Color &c) : Value(c), _r(c._r), _g(c._g), _b(c._b) {
_is_correct = c._is_correct; _is_correct = c._is_correct;
} }
Color::Color(const Color *c) : Value(*c), _r(c->_r), _g(c->_g), _b(c->_b) {
_is_correct = c->_is_correct;
}
Color::Color(const std::string &in) { Color::Color(const std::string &in) {
string separated_color[3]; string separated_color[3];
string temp = in; string temp = in;
......
...@@ -73,16 +73,9 @@ public: ...@@ -73,16 +73,9 @@ public:
* \brief Constructor * \brief Constructor
*/ */
Color(double, double, double); Color(double, double, double);
/*!
* \brief Constructor
*/
Color(const std::string &); Color(const std::string &);
/*!
* \brief Constructor
*/
Color(const Color &); Color(const Color &);
Color(const Color *);
/*! /*!
* \fn to_string() const * \fn to_string() const
......
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