Commit 15793646 authored by Thibault Soucarre's avatar Thibault Soucarre
Browse files

settings working for events

parent 1fd6f716
......@@ -1316,11 +1316,21 @@ void Core::change_entity_color(std::string entity, Element_col r, Element_col g,
_render_opengl->change_color(entity, r, g, b);
}
void Core::change_event_color(std::string event, Element_col r, Element_col g, Element_col b){
std::cout << "core" << std::endl;
_render_opengl->change_event_color(event, r, g, b);
}
void Core::change_entity_visible(std::string entity, bool visible){
std::cout << "core" << std::endl;
_render_opengl->change_visible(entity, visible);
}
void Core::change_event_visible(std::string event, bool visible){
std::cout << "core" << std::endl;
_render_opengl->change_event_visible(event, visible);
}
void Core::reload_states(){
_render_opengl->reload_states();
}
......@@ -509,7 +509,11 @@ public:
*/
void change_entity_color(std::string entity, Element_col r, Element_col g, Element_col b);
void change_event_color(std::string event, Element_col r, Element_col g, Element_col b);
void change_entity_visible(std::string entity, bool visible);
void change_event_visible(std::string event, bool visible);
/*!
* \brief reload state color from trace file
*/
......
......@@ -206,15 +206,24 @@ void Settings_window::color_changed(string name, QTableWidget *table, const QCol
QColor q(old->get_red()*255, old->get_green()*255, old->get_blue()*255);
bool checked = qobject_cast<QCheckBox *>(table->cellWidget(row, 2))->checkState()== Qt::Checked;
std::cout << name << std::endl;
std::map<std::string, Color> *changes;
if(name == "palette")
changes = &_states_changes;
else if (name == "event_types")
changes = &_events_color_changes;
else
changes = NULL;
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());
if(_states_changes.count(state_name)>0)
_states_changes[state_name] = color;
if(changes->count(state_name)>0)
(*changes)[state_name] = color;
else{
std::pair<std::string, Color> change(state_name, color);
_states_changes.insert(change);
std::pair<std::string, Color> p(state_name, color);
changes->insert(p);
std::pair<QtColorPicker*, const QColor> cancel((QtColorPicker*)sender(), q);
_color_cancel.insert(cancel);
}
......@@ -240,13 +249,20 @@ void Settings_window::visible_changed(string name, QTableWidget *table, const bo
Palette *p = S.get_palette(name, palette_name);////////////////////////////
QColor qc = qobject_cast<QtColorPicker *>(table->cellWidget(row, 1))->currentColor();
Color color(qc.red()/255, qc.green()/255, qc.blue()/255);
std::map<std::string, bool> *changes;
if(name == "palette")
changes = &_states_visible_changes;
else if(name == "event_types")
changes = &_events_visible_changes;
else
changes = NULL;
S.add_state_to_palette(name, palette_name, state_name, color, checked );
p->add_state(state_name, color, checked );
if(_states_visible_changes.count(state_name)>0)
_states_visible_changes[state_name] = checked;
if(changes->count(state_name)>0)
(*changes)[state_name] = checked;
else{
std::pair<std::string, bool> change(state_name, checked);
_states_visible_changes.insert(change);
std::pair<std::string, bool> p(state_name, checked);
changes->insert(p);
std::pair<QCheckBox*, bool> cancel((QCheckBox*)sender(), !checked);
_visible_cancel.insert(cancel);
}
......@@ -492,6 +508,8 @@ void Settings_window::on_reload_states_btn_clicked(){
_reload = true;
_states_changes.clear();
_states_visible_changes.clear();
_events_color_changes.clear();
_events_visible_changes.clear();
}
......@@ -734,19 +752,32 @@ void Settings_window::on_apply_clicked() {
_c->reload_states();
_reload = false;
std::map<std::string, Color>::iterator it = _states_changes.begin();
std::map<std::string, bool>::iterator it2 = _states_visible_changes.begin();
Color color;
while(it != _states_changes.end()){
color = it->second;
_c->change_entity_color(it->first, color.get_red(), color.get_green(), color.get_blue());
it++;
}
std::map<std::string, bool>::iterator it2 = _states_visible_changes.begin();
while(it2 != _states_visible_changes.end()){
_c->change_entity_visible(it2->first, it2->second);
it2++;
}
it = _events_color_changes.begin();
while(it != _events_color_changes.end()){
color = it->second;
_c->change_event_color(it->first, color.get_red(), color.get_green(), color.get_blue());
it++;
}
it2 = _events_visible_changes.begin();
while(it2 != _events_visible_changes.end()){
_c->change_event_visible(it2->first, it2->second);
it2++;
}
_states_changes.clear();
_states_visible_changes.clear();
_events_color_changes.clear();
_events_visible_changes.clear();
_color_cancel.clear();
_visible_cancel.clear();
emit settings_changed(); // Catch by at least the interface_graphic which will dispatch it to the classes which needs
......@@ -766,6 +797,7 @@ void Settings_window::on_cancel_clicked() {
}
std::map<QCheckBox*, bool>::iterator it2 = _visible_cancel.begin();
while(it2 != _visible_cancel.end()){
//we need to use affectation with Qt:: because QCheckBox could be partially checked
if(it2->second)
it2->first->setCheckState(Qt::Checked);
else
......@@ -774,6 +806,8 @@ void Settings_window::on_cancel_clicked() {
}
_states_visible_changes.clear();
_states_changes.clear();
_events_color_changes.clear();
_events_visible_changes.clear();
_color_cancel.clear();
_visible_cancel.clear();
_reload = false;
......
......@@ -73,6 +73,8 @@ private:
std::map<QtColorPicker*, const QColor> _color_cancel;
std::map<QCheckBox*, bool> _visible_cancel;
std::map<std::string, bool> _states_visible_changes;
std::map<std::string, Color> _events_color_changes;
std::map<std::string, bool> _events_visible_changes;
bool _reload;
//used to check if leaving the tab needs an apply first when OK button is pressed
bool _changed;
......
......@@ -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
**
*/
......@@ -83,20 +83,20 @@ OTFTraceBuilderThread::~OTFTraceBuilderThread() {
void OTFTraceBuilderThread::build_trace(int n_structs, OTF_Trace_builder_struct* tb_struct){
for(int i=0; i<n_structs; i++){
tb_struct[i].func(&tb_struct[i]);
}
}
_freeSlots->release();
delete[] tb_struct;
}
}
void OTFTraceBuilderThread::build_finished(){
//locks the mutex and automatically unlocks it when going out of scope
QMutexLocker locker(_mutex);
_is_finished=true;
_cond->wakeAll();
//locks the mutex and automatically unlocks it when going out of scope
QMutexLocker locker(_mutex);
_is_finished=true;
_cond->wakeAll();
}
int OTFTraceBuilderThread::handler_begin_process(OTF_Trace_builder_struct* tb_struct) {
......@@ -109,7 +109,7 @@ int OTFTraceBuilderThread::handler_begin_process(OTF_Trace_builder_struct* tb_st
map<string, Value *> extra_fields;
Date d = (double)tb_struct->time/(double)ParserDefinitionOTF::get_ticks_per_second();
Name n = Name(current_process._name, "");
ContainerType *process_container_type = t->search_container_type(String(process_group._name));
Container *parent_container = t->search_container(String(process_parent._name));
......@@ -137,7 +137,7 @@ int OTFTraceBuilderThread::handler_begin_process(OTF_Trace_builder_struct* tb_st
int OTFTraceBuilderThread::handler_end_process (OTF_Trace_builder_struct* tb_struct) {
Trace *t = (Trace *)tb_struct->trace;
Process process = ParserDefinitionOTF::get_process_by_id(tb_struct->process);
ProcessGroup process_group = ParserDefinitionOTF::get_processgroup_by_process(tb_struct->process);
......@@ -169,7 +169,7 @@ int OTFTraceBuilderThread::handler_end_process (OTF_Trace_builder_struct* tb_str
int OTFTraceBuilderThread::handler_enter (OTF_Trace_builder_struct* tb_struct) {
Trace *t = (Trace *)tb_struct->trace;
Date d = (double)tb_struct->time/(double)ParserDefinitionOTF::get_ticks_per_second();
Function &temp_function = ParserDefinitionOTF::get_function_by_id(tb_struct->process);
......@@ -187,7 +187,7 @@ int OTFTraceBuilderThread::handler_enter (OTF_Trace_builder_struct* tb_struct) {
StateType *temp_state_type = t->search_state_type(function_group_name);
EntityValue *temp_value = NULL;
map<string, Value *> extra_fields;
if(_containers.find(proc_name) != _containers.end()) {
temp_container = _containers[proc_name];
}
......@@ -204,14 +204,14 @@ int OTFTraceBuilderThread::handler_enter (OTF_Trace_builder_struct* tb_struct) {
if(!temp_function._is_defined) {
temp_function._is_defined = true;
Name name_temp(temp_function._name, "");
map<string, Value *> opt;
/* Optional fields */
FileLine source_file_locator;
FileSource source_file;
if(temp_function._file_source != 0) {
source_file_locator = ParserDefinitionOTF::get_fileline_by_id(temp_function._file_source);
source_file = ParserDefinitionOTF::get_filesource_by_id(source_file_locator._file_id);
......@@ -221,7 +221,7 @@ int OTFTraceBuilderThread::handler_enter (OTF_Trace_builder_struct* tb_struct) {
opt["File name"] = new String(source_file._name);
opt["Line"] = new Integer(source_file_locator._line_number);
}
opt["Color"] = ParserDefinitionOTF::get_color(tb_struct->process);
t->define_entity_value(name_temp, t->search_entity_type(function_group_name), opt);
......@@ -232,7 +232,7 @@ int OTFTraceBuilderThread::handler_enter (OTF_Trace_builder_struct* tb_struct) {
if(temp_container == NULL && temp_proc._name != "0") {
// Creation of the container if not already done with beginProcess
tb_struct->process=tb_struct->process2;
handler_begin_process(tb_struct);
temp_proc = ParserDefinitionOTF::get_process_by_id(tb_struct->process2);
......@@ -257,7 +257,7 @@ int OTFTraceBuilderThread::handler_enter (OTF_Trace_builder_struct* tb_struct) {
int OTFTraceBuilderThread::handler_leave (OTF_Trace_builder_struct*) {
//Trace *t = (Trace *)trace;
//Date d = (double)time/(double)ParserDefinitionOTF::get_ticks_per_second();
//Function temp_function = ParserDefinitionOTF::get_function_by_id(func_id);
......@@ -290,9 +290,9 @@ int OTFTraceBuilderThread::handler_counter(OTF_Trace_builder_struct* tb_struct)
VariableType *temp_variable_type = t->search_variable_type(counter_group_name);
ProcessGroup process_group = ParserDefinitionOTF::get_processgroup_by_process(tb_struct->process);
ContainerType *temp_container_type = t->search_container_type(String(process_group._name));
const String temp_proc_name = String(temp_proc._name);
if(_containers.find(temp_proc_name) != _containers.end()) {
temp_container = _containers[temp_proc_name];
}
......@@ -309,7 +309,7 @@ int OTFTraceBuilderThread::handler_counter(OTF_Trace_builder_struct* tb_struct)
if(temp_container == NULL && temp_proc._name != "0") {
// Creation of the container if not already done with beginProcess
handler_begin_process(tb_struct);
temp_proc = ParserDefinitionOTF::get_process_by_id(tb_struct->process);
temp_container = t->search_container(temp_proc_name);
......@@ -349,10 +349,9 @@ int OTFTraceBuilderThread::handler_marker(OTF_Trace_builder_struct* tb_struct) {
ProcessGroup process_group = ParserDefinitionOTF::get_processgroup_by_process(tb_struct->process);
ContainerType *temp_container_type = t->search_container_type(String(process_group._name));
EntityValue *value = NULL;
const String temp_proc_name = String(temp_proc._name);
if(_containers.find(temp_proc_name) != _containers.end()) {
temp_container = _containers[temp_proc_name];
}
......@@ -367,8 +366,6 @@ int OTFTraceBuilderThread::handler_marker(OTF_Trace_builder_struct* tb_struct) {
event_type = t->search_event_type(str_eventType);
}
value = t->search_entity_value(str_event, event_type);
if(temp_container == NULL && temp_proc._name != "0") {
// Creation of the container if not already done with beginProcess
handler_begin_process(tb_struct);
......@@ -384,7 +381,7 @@ int OTFTraceBuilderThread::handler_marker(OTF_Trace_builder_struct* tb_struct) {
//Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + temp_counter_group._name, Error::VITE_ERRCODE_ERROR);
}
t->new_event(d, event_type, temp_container, value, extra_fields);
t->new_event(d, event_type, temp_container, extra_fields);
return OTF_RETURN_OK;
}
......@@ -419,7 +416,7 @@ int OTFTraceBuilderThread::handler_send_message (OTF_Trace_builder_struct* tb_st
Name name_temp = Name(name, "");
LinkType *link_type = t->search_link_type(link_type_string);
Container *source_container = NULL;
Container *ancestor_container = NULL;
......@@ -430,7 +427,7 @@ int OTFTraceBuilderThread::handler_send_message (OTF_Trace_builder_struct* tb_st
EntityValue *value;
map<string, Value *> opt;
if(_containers.find(sender_string) != _containers.end()) {
source_container = _containers[sender_string];
}
......@@ -447,7 +444,7 @@ int OTFTraceBuilderThread::handler_send_message (OTF_Trace_builder_struct* tb_st
// receiver not found
ancestor_container = t->search_container(ancestor_string);
if(ancestor_container) {
_containers[ancestor_string] = ancestor_container;
_containers[ancestor_string] = ancestor_container;
}
}
......@@ -534,7 +531,7 @@ int OTFTraceBuilderThread::handler_receive_message (OTF_Trace_builder_struct* tb
/* Value */
string name = temp_sender._name + " to " + temp_receiver._name;
String name_string = String(name);
ostringstream link_type_oss;
......@@ -570,7 +567,7 @@ int OTFTraceBuilderThread::handler_receive_message (OTF_Trace_builder_struct* tb
else {
ancestor_cont = t->search_container(ancestor_string);
if(ancestor_cont)
_containers[ancestor_string] = ancestor_cont;
_containers[ancestor_string] = ancestor_cont;
}
if(ancestor_type == 0) {
......@@ -628,4 +625,3 @@ int OTFTraceBuilderThread::handler_receive_message (OTF_Trace_builder_struct* tb
t->end_link(d, link_type, ancestor_cont, destination_cont, value, name_string, opt);
return OTF_RETURN_OK;
}
......@@ -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,13 +37,13 @@
** - MARCOUEILLE Jule
** - NOISETTE Pascal
** - REDONDY Arthur
** - VUCHENER Clément
** - VUCHENER Clément
**
*/
/**
* @file ParserEventOTF.cpp
*
* @author Lagrasse Olivier
* @author Lagrasse Olivier
* @author Johnny Jazeix
* @author Mathieu Faverge
*
......@@ -143,7 +143,7 @@ int ParserEventOTF::handler_Enter( void* userData,
OTF_KeyValueList *list )
{
Trace *t = (Trace *)userData;
Date d = (double)time/(double)ParserDefinitionOTF::get_ticks_per_second();
Function &temp_function = ParserDefinitionOTF::get_function_by_id(func_id);
......@@ -161,7 +161,7 @@ int ParserEventOTF::handler_Enter( void* userData,
StateType *temp_state_type = t->search_state_type(function_group_name);
EntityValue *temp_value = NULL;
map<string, Value *> extra_fields;
if(_containers.find(proc_name) != _containers.end()) {
temp_container = _containers[proc_name];
}
......@@ -178,14 +178,14 @@ int ParserEventOTF::handler_Enter( void* userData,
if(!temp_function._is_defined) {
temp_function._is_defined = true;
Name name_temp(temp_function._name, "");
map<string, Value *> opt;
/* Optional fields */
FileLine source_file_locator;
FileSource source_file;
if(temp_function._file_source != 0) {
source_file_locator = ParserDefinitionOTF::get_fileline_by_id(temp_function._file_source);
source_file = ParserDefinitionOTF::get_filesource_by_id(source_file_locator._file_id);
......@@ -195,7 +195,7 @@ int ParserEventOTF::handler_Enter( void* userData,
opt["File name"] = new String(source_file._name);
opt["Line"] = new Integer(source_file_locator._line_number);
}
opt["Color"] = ParserDefinitionOTF::get_color(func_id);
t->define_entity_value(name_temp, t->search_entity_type(function_group_name), opt);
......@@ -235,7 +235,7 @@ int ParserEventOTF::handler_Leave( void* userData,
OTF_KeyValueList *list )
{
//Trace *t = (Trace *)userData;
//Date d = (double)time/(double)ParserDefinitionOTF::get_ticks_per_second();
//Function temp_function = ParserDefinitionOTF::get_function_by_id(func_id);
......@@ -266,7 +266,7 @@ int ParserEventOTF::handler_SendMsg( void* userData,
// We define the LinkType if not exist and we store the time and other fields
Trace *t = (Trace *)userData;
Date d = (double)time/(double)ParserDefinitionOTF::get_ticks_per_second();
Process temp_sender = ParserDefinitionOTF::get_process_by_id(sender);
Process temp_receiver = ParserDefinitionOTF::get_process_by_id(receiver);
// The sender process may have no ancestor, so let's say that his ancestor is himself
......@@ -293,7 +293,7 @@ int ParserEventOTF::handler_SendMsg( void* userData,
Name name_temp = Name(name, "");
LinkType *link_type = t->search_link_type(link_type_string);
Container *source_container = NULL;
Container *ancestor_container = NULL;
......@@ -304,7 +304,7 @@ int ParserEventOTF::handler_SendMsg( void* userData,
EntityValue *value;
map<string, Value *> opt;
if(_containers.find(sender_string) != _containers.end()) {
source_container = _containers[sender_string];
}
......@@ -321,7 +321,7 @@ int ParserEventOTF::handler_SendMsg( void* userData,
// receiver not found
ancestor_container = t->search_container(ancestor_string);
if(ancestor_container) {
_containers[ancestor_string] = ancestor_container;
_containers[ancestor_string] = ancestor_container;
}
}
......@@ -417,7 +417,7 @@ int ParserEventOTF::handler_RecvMsg( void* userData,
/* Value */
string name = temp_sender._name + " to " + temp_receiver._name;
String name_string = String(name);
ostringstream link_type_oss;
......@@ -453,7 +453,7 @@ int ParserEventOTF::handler_RecvMsg( void* userData,
else {
ancestor_cont = t->search_container(ancestor_string);
if(ancestor_cont)
_containers[ancestor_string] = ancestor_cont;
_containers[ancestor_string] = ancestor_cont;
}
if(ancestor_type == 0) {
......@@ -636,7 +636,7 @@ int ParserEventOTF::handler_BeginProcess( void* userData,
map<string, Value *> extra_fields;
Date d = (double)time/(double)ParserDefinitionOTF::get_ticks_per_second();
Name n = Name(current_process._name, "");
ContainerType *process_container_type = t->search_container_type(String(process_group._name));
Container *parent_container = t->search_container(String(process_parent._name));
......@@ -645,7 +645,7 @@ int ParserEventOTF::handler_BeginProcess( void* userData,
}
if(process_container_type == 0) {
Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + process_group._name,
Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + process_group._name,
Error::VITE_ERRCODE_ERROR);
}
if(parent_container == 0 && process_parent._name != "0") {
......@@ -668,7 +668,7 @@ int ParserEventOTF::handler_EndProcess( void* userData,
OTF_KeyValueList *list )
{
Trace *t = (Trace *)userData;
Process process = ParserDefinitionOTF::get_process_by_id(proc_id);
ProcessGroup process_group = ParserDefinitionOTF::get_processgroup_by_process(proc_id);
......@@ -802,24 +802,24 @@ int ParserEventOTF::handler_RMAEnd( void* userData,
//
// Start definition of handlers for OTF marker records
//
int ParserEventOTF::handler_DefMarker(void *,
uint32_t stream,
uint32_t id,
const char *name,
int ParserEventOTF::handler_DefMarker(void *,
uint32_t stream,
uint32_t id,
const char *name,
uint32_t type,
OTF_KeyValueList *list )
OTF_KeyValueList *list )
{
Marker temp = {name, stream, type};
ParserEventOTF::_marker[id] = temp;
return OTF_RETURN_OK;
}
int ParserEventOTF::handler_Marker(void *trace,
uint64_t time,
uint32_t proc_id,
uint32_t id,
int ParserEventOTF::handler_Marker(void *trace,
uint64_t time,
uint32_t proc_id,
uint32_t id,
const char *text,
OTF_KeyValueList *list )
OTF_KeyValueList *list )
{
Trace *t = (Trace *)trace;
Date d = (double)time/(double)ParserDefinitionOTF::get_ticks_per_second();
......@@ -836,10 +836,9 @@ int ParserEventOTF::handler_Marker(void *trace,
ProcessGroup process_group = ParserDefinitionOTF::get_processgroup_by_process(proc_id);
ContainerType *temp_container_type = t->search_container_type(String(process_group._name));
EntityValue *value = NULL;
const String temp_proc_name = String(temp_proc._name);
if(_containers.find(temp_proc_name) != _containers.end()) {
temp_container = _containers[temp_proc_name];
}
......@@ -854,8 +853,6 @@ int ParserEventOTF::handler_Marker(void *trace,
event_type = t->search_event_type(str_eventType);
}
value = t->search_entity_value(str_event, event_type);