Commit c91e276d authored by Augustin Degomme's avatar Augustin Degomme

- add option to switch the reload mode from "reload the file, parse it again,...

- add option to switch the reload mode from "reload the file, parse it again, and display it with the new settings" to "just display again with the new settings", to make it quicker when using palettes
- add shaded states, vertical line and reload type settings in the config file, in order to keep these settings between sessions

-This line, and those below, will be ignored--

M    trunk/src/interface/Interface_graphic.hpp
M    trunk/src/interface/main_window.ui
M    trunk/src/interface/Interval_select.cpp
M    trunk/src/interface/Node_select.cpp
M    trunk/src/interface/Settings_window.cpp
M    trunk/src/interface/Settings_window.hpp
M    trunk/src/interface/Interface_graphic.cpp
M    trunk/src/common/Session.cpp
M    trunk/src/common/Session.hpp
M    trunk/src/common/Info.cpp
M    trunk/src/core/Core.cpp
parent b86a3b24
......@@ -46,6 +46,7 @@
#include "common/common.hpp"
#include "common/Info.hpp"
#include "common/Session.hpp"
#include <string>
using namespace std;
......@@ -78,8 +79,10 @@ Element_pos Info::Render::_info_accurate = 0.0;
bool Info::Render::_no_arrows = false;
bool Info::Render::_no_events = false;
bool Info::Render::_shaded_states = true;/* By default, enable shaded state */
bool Info::Render::_vertical_line = true;/* By default, enable vertical line */
bool Info::Render::_shaded_states = Session::get_shaded_states_setting();
//true;/* By default, enable shaded state */
bool Info::Render::_vertical_line = Session::get_vertical_line_setting();
//true;/* By default, enable vertical line */
bool Info::Splitter::split = false;
bool Info::Splitter::load_splitted = false;
......
......@@ -147,6 +147,48 @@ void Session::load_plugin_directories(QStringList &list) {
}
}
void Session::update_vertical_line_setting(bool b) {
QSettings settings(ORG_NAME, APP_NAME);
settings.setValue(VERTICAL_LINE, b);
}
bool Session::get_vertical_line_setting(){
QSettings settings(ORG_NAME, APP_NAME);
//set 1 as the default value if not set in the file
bool b;
b=settings.value(VERTICAL_LINE,1).toBool();
return b;
}
void Session::update_shaded_states_setting(bool b) {
QSettings settings(ORG_NAME, APP_NAME);
settings.setValue(SHADED_STATE, b);
}
bool Session::get_shaded_states_setting(){
QSettings settings(ORG_NAME, APP_NAME);
//set 1 as the default value if not set in the file
bool b;
b=settings.value(SHADED_STATE,1).toBool();
return b;
}
void Session::update_reload_type_setting(bool b){
QSettings settings(ORG_NAME, APP_NAME);
settings.setValue(RELOAD_TYPE, b);
}
bool Session::get_reload_type_setting(){
QSettings settings(ORG_NAME, APP_NAME);
//set 1 as the default value if not set in the file
bool b;
b=settings.value(RELOAD_TYPE,1).toBool();
return b;
}
void Session::save_plugin_directories(const QStringList &list) {
QSettings settings(ORG_NAME, APP_NAME);
settings.setValue(PLUGIN_DIR, list);
......
......@@ -75,6 +75,25 @@ class QStringList;
* \brief The recent file key for Settings
*/
#define RECENT_FILES "recentFiles"
/*!
* \def VERTICAL_LINE
* \brief The setting for the vertical line
*/
#define VERTICAL_LINE "vertical_line"
/*!
* \def RELOAD_TYPE
* \brief The setting for the vertical line
*/
#define RELOAD_TYPE "reload_type"
/*!
* \def SHADED_STATE
* \brief The setting for the shaded states
*/
#define SHADED_STATE "shaded_state"
/*!
* \def PLUGIN_DIR
* \brief The plugin directory key for Settings
......@@ -165,6 +184,19 @@ public:
static void save_config_file();
static void load_config_file();
static void update_vertical_line_setting(bool b);
static bool get_vertical_line_setting();
static void update_reload_type_setting(bool b);
static bool get_reload_type_setting();
static void update_shaded_states_setting(bool b);
static bool get_shaded_states_setting();
/*!
* \fn get_recent_files()
......
......@@ -911,7 +911,6 @@ void Core::launch_action(int state, void* arg) {
delete _trace;
_trace = NULL;
}
_render_opengl->updateGL();
/* Release all data */
......@@ -1002,8 +1001,15 @@ void Core::launch_action(int state, void* arg) {
break;
case _STATE_CLEAN_RENDER_AREA:
Info::Render::_x_min_visible = 0.0;
Info::Render::_x_max_visible = 0.0;
if (_render_opengl->unbuild()==false)
message << "Close file : an error occured while cleaning the render." << Message::ende;
_render_opengl->release();
Session::_palette = NULL;
Session::_link_types = NULL;
Session::_event_types = NULL;
_render_opengl->updateGL();
break;
case _STATE_RENDER_SHOW_MINIMAP:
......
......@@ -106,8 +106,13 @@ Interface_graphic::Interface_graphic(Core* core, QWidget *parent):QMainWindow(pa
_core = core;
_is_rendering_trace = false;
_no_warning = false;/* display warnings */
_on_manual_change = false;
_on_manual_change = false;
_reload_type=Session::get_reload_type_setting();
reload_from_file->setChecked(Session::get_reload_type_setting());
vertical_line->setChecked(Session::get_vertical_line_setting());
shaded_states->setChecked(Session::get_shaded_states_setting());
_x_factor_virtual_to_real = 0.1;
_y_factor_virtual_to_real = 0.1;
......@@ -617,7 +622,10 @@ void Interface_graphic::on_export_file_triggered(){
void Interface_graphic::on_reload_triggered() {
if(_is_rendering_trace) {
Element_pos zoom[2]={Info::Splitter::_x_min,Info::Splitter::_x_max};
if(_reload_type)
_core->launch_action(Core::_STATE_RELEASE_RENDER_AREA);
else
_core->launch_action(Core::_STATE_CLEAN_RENDER_AREA);
_core->draw_trace(_trace_path, Core::_DRAW_OPENGL);
......@@ -776,13 +784,19 @@ void Interface_graphic::on_fullscreen_triggered(){
void Interface_graphic::on_vertical_line_triggered(){
Info::Render::_vertical_line=!Info::Render::_vertical_line;
Session::update_vertical_line_setting(Info::Render::_vertical_line);
}
void Interface_graphic::on_shaded_states_triggered(){
Info::Render::_shaded_states=!Info::Render::_shaded_states;
Session::update_shaded_states_setting(Info::Render::_shaded_states);
/* Reload render area */
if (_is_rendering_trace){
if(_reload_type)
_core->launch_action(Core::_STATE_RELEASE_RENDER_AREA);
else
_core->launch_action(Core::_STATE_CLEAN_RENDER_AREA);
_core->draw_trace(_trace_path, Core::_DRAW_OPENGL);
}
}
......@@ -939,6 +953,11 @@ void Interface_graphic::on_no_events_triggered(){
_core->launch_action(Core::_STATE_RENDER_UPDATE);
}
void Interface_graphic::on_reload_from_file_triggered(){
_reload_type=!_reload_type;
Session::update_reload_type_setting(_reload_type);
}
void Interface_graphic::on_zoom_in_triggered(){
......
......@@ -304,6 +304,11 @@ class Interface_graphic : public QMainWindow, protected Ui::main_window, public
*/
bool _no_warning;
/*!
* \brief if true, reload button reloads it from the trace (new parsing), if false, just update the render
*/
bool _reload_type;
/*!
* \brief Prevent recursive callings when changing manualy scroll bars.
*/
......@@ -634,6 +639,11 @@ protected slots:
*\brief A slot called when 'no_warning' in the menu is clicked.
*/
void on_no_warning_triggered();
/*!
*\brief A slot called when 'reload_from_file' in the menu is clicked.
*/
void on_reload_from_file_triggered();
/*!
*\brief A slot called when 'no_arrows' in the menu is clicked.
......
......@@ -238,8 +238,8 @@ void Interval_select::apply_settings(){
if(minSpinBox->value()!=maxSpinBox->value()){
Element_pos zoom[2]={minSpinBox->value(), maxSpinBox->value()};
Info::Render::_x_min_visible = 0.0;
Info::Render::_x_max_visible = 0.0;
//Info::Render::_x_min_visible = 0.0;
//Info::Render::_x_max_visible = 0.0;
_console->get_console()->launch_action(Core:: _STATE_CLEAN_RENDER_AREA);
//reload data from disk if needed
......
......@@ -337,8 +337,8 @@ void Node_select::on_load_button_clicked(){
_trace->set_view_root_containers(_displayed_containers);
Element_pos it[2]={Info::Render::_x_min, Info::Render::_x_max};
Info::Render::_x_min_visible = 0.0;
Info::Render::_x_max_visible = 0.0;
//Info::Render::_x_min_visible = 0.0;
//Info::Render::_x_max_visible = 0.0;
_console->get_console()->launch_action(Core:: _STATE_CLEAN_RENDER_AREA);
#if defined(USE_ITC) && defined(BOOST_SERIALIZE)
_trace->updateTrace(new Interval(it[0], it[1]));
......
......@@ -408,6 +408,52 @@ void Settings_window::state_color_changed(const QColor &qc) {
p->add_state(state_name, color, qobject_cast<QCheckBox *>(states_table->cellWidget(row, 2))->checkState()== Qt::Checked);
}
void Settings_window::event_types_color_changed(const QColor &qc) {
_changed=true;
if(!event_types_table || !event_types_palette_list)
return;
Color color(qc.red()/255., qc.green()/255., qc.blue()/255.);
int row = 0;
while(event_types_table->cellWidget(row, 1) && event_types_table->cellWidget(row, 1) != sender()) { // Find the row of the colorPicker
row ++;
}
if(!event_types_table->cellWidget(row, 1))
return; // epic fail...
std::string palette_name = event_types_palette_list->currentText().toStdString();
std::string state_name = event_types_table->item(row, 0)->text().toStdString();
Palette *p = Session::get_palette("event_types",palette_name);
Session::add_state_to_palette("event_types",palette_name, state_name, color, qobject_cast<QCheckBox *>(event_types_table->cellWidget(row, 2))->checkState()== Qt::Checked);
p->add_state(state_name, color, qobject_cast<QCheckBox *>(event_types_table->cellWidget(row, 2))->checkState()== Qt::Checked);
}
void Settings_window::link_types_color_changed(const QColor &qc) {
_changed=true;
if(!link_types_table || !link_types_palette_list)
return;
Color color(qc.red()/255., qc.green()/255., qc.blue()/255.);
int row = 0;
while(link_types_table->cellWidget(row, 1) && link_types_table->cellWidget(row, 1) != sender()) { // Find the row of the colorPicker
row ++;
}
if(!link_types_table->cellWidget(row, 1))
return; // epic fail...
std::string palette_name = link_types_palette_list->currentText().toStdString();
std::string state_name = link_types_table->item(row, 0)->text().toStdString();
Palette *p = Session::get_palette("link_types",palette_name);
Session::add_state_to_palette("link_types",palette_name, state_name, color, qobject_cast<QCheckBox *>(link_types_table->cellWidget(row, 2))->checkState()== Qt::Checked);
p->add_state(state_name, color, qobject_cast<QCheckBox *>(link_types_table->cellWidget(row, 2))->checkState()== Qt::Checked);
}
/*************************/
/****** Types tab. ******/
/*************************/
......@@ -469,9 +515,9 @@ void Settings_window::add_event_type_line(int &row, std::string st_name, Color *
color_widget->setCurrentColor(QColor(255, 255, 255));
}
color_widget->setColorDialogEnabled(false);
/*
connect(color_widget, SIGNAL(colorChanged(const QColor &)), this, SLOT( event_types_color_changed(const QColor &)));
*/
event_types_table->setCellWidget(row, 1, color_widget);
QCheckBox *cb = new QCheckBox();
......@@ -542,9 +588,9 @@ void Settings_window::add_link_type_line(int &row, std::string st_name, Color *c
color_widget->setCurrentColor(QColor(255, 255, 255));
}
color_widget->setColorDialogEnabled(false);
/*
connect(color_widget, SIGNAL(colorChanged(const QColor &)), this, SLOT( event_types_color_changed(const QColor &)));
*/
connect(color_widget, SIGNAL(colorChanged(const QColor &)), this, SLOT( link_types_color_changed(const QColor &)));
link_types_table->setCellWidget(row, 1, color_widget);
QCheckBox *cb = new QCheckBox();
......
......@@ -311,6 +311,20 @@ private slots:
* apply changes and hide the window
*/
void on_ok_clicked();
/*!
* \fn event_types_color_changed(const QColor &c)
* \brief (event_types tab) Called when the user changes an object in the table.
* \param c : the new color
*/
void event_types_color_changed(const QColor &c);
/*!
* \fn link_types_color_changed(const QColor &c)
* \brief (link_types tab) Called when the user changes an object in the table.
* \param c : the new color
*/
void link_types_color_changed(const QColor &c);
signals:
void settings_changed();
......
......@@ -186,7 +186,7 @@
<x>0</x>
<y>0</y>
<width>1060</width>
<height>25</height>
<height>23</height>
</rect>
</property>
<widget class="QMenu" name="menuHelp">
......@@ -212,13 +212,14 @@
<addaction name="goto_end"/>
<addaction name="separator"/>
<addaction name="shaded_states"/>
<addaction name="vertical_line"/>
<addaction name="vertical_line"/>
<addaction name="separator"/>
<addaction name="fullscreen"/>
<addaction name="separator"/>
<addaction name="no_warning"/>
<addaction name="no_arrows"/>
<addaction name="no_events"/>
<addaction name="reload_from_file"/>
</widget>
<widget class="QMenu" name="menuFile">
<property name="title">
......@@ -249,7 +250,7 @@
<addaction name="separator"/>
<addaction name="show_settings"/>
<addaction name="node_selection"/>
<addaction name="interval_selection"/>
<addaction name="interval_selection"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuView"/>
......@@ -564,6 +565,20 @@
<string>Vertical Line</string>
</property>
</action>
<action name="reload_from_file">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Reload from file</string>
</property>
<property name="toolTip">
<string>When pressing reload, reload the whole trace from file</string>
</property>
</action>
</widget>
<resources>
<include location="vite.qrc"/>
......
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