Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

Commit 4f3dec29 authored by Olivier Lagrasse's avatar Olivier Lagrasse
Browse files

- Improve ruler.

- Simplify export dialog boxes.
- Add bitmap export. (PNG and JPG)

Known bugs:
- Only the whole trace is exported in SVG.
- Some errors with ruler graduation.
- No min and max ruler values for PNG and JPG files.

parent 241b9dc3
/*
** This file is part of the ViTE project.
**
** This software is governed by the CeCILL-A license under French law
** and abiding by the rules of distribution of free software. You can
** 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,
** that may mean that it is complicated to manipulate, and that also
** therefore means that it is reserved for developers and experienced
** professionals having in-depth computer knowledge. Users are therefore
** encouraged to load and test the software's suitability as regards
** 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.
**
**
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
** - JAZEIX Johnny
** - LAGRASSE Olivier
** - MARCOUEILLE Jule
** - NOISETTE Pascal
** - REDONDY Arthur
** - VUCHENER Clément
**
*/
/*!
*\file Session.cpp
*/
#include "common/Session.hpp"
const QByteArray Session::Export::DEFAULT_STATE = QByteArray::number(-1);
QByteArray Session::Export::file_dialog_state = Session::Export::DEFAULT_STATE;
/*
** This file is part of the ViTE project.
**
** This software is governed by the CeCILL-A license under French law
** and abiding by the rules of distribution of free software. You can
** 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,
** that may mean that it is complicated to manipulate, and that also
** therefore means that it is reserved for developers and experienced
** professionals having in-depth computer knowledge. Users are therefore
** encouraged to load and test the software's suitability as regards
** 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.
**
**
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
** - JAZEIX Johnny
** - LAGRASSE Olivier
** - MARCOUEILLE Jule
** - NOISETTE Pascal
** - REDONDY Arthur
** - VUCHENER Clément
**
*/
/*!
*\file Session.hpp
*/
#ifndef SESSION_HPP
#define SESSION_HPP
#include <QObject>
/*!
* \brief Class used to store information between two software launch.
*
*/
class Session{
private:
/*!
* \brief The class constructor.
*/
Session();
public:
/*!
* \brief The class destructor.
*/
virtual ~Session();
/*!
* \brief Sub structure to store export information.
*/
struct Export{
/*!
* \brief Store the export file dialog state.
*/
static QByteArray file_dialog_state;
/*!
* \brief Default value of the export dialog state.
*/
const static QByteArray DEFAULT_STATE;
};
};
#endif
......@@ -74,7 +74,7 @@ public:
/*!
* \brief Sub structure to store screen informations.
* \brief Sub structure to store screen information.
*/
struct Screen{
......@@ -91,7 +91,7 @@ public:
/*!
* \brief Sub structure to store container informations.
* \brief Sub structure to store container information.
*/
struct Container{
......@@ -118,7 +118,7 @@ public:
};
/*!
* \brief Sub structure to store state informations.
* \brief Sub structure to store state information.
*/
struct Entity{
......@@ -145,7 +145,7 @@ public:
};
/*!
* \brief Sub structure to store render area informations.
* \brief Sub structure to store render area information.
*/
struct Render{
......
......@@ -332,7 +332,8 @@ bool Core::draw_trace(const string & filename, const int format){
}
//Interval interval(_time_start, ((0==_time_end)?_trace->get_max_date():_time_end) );
Interval interval(Info::Entity::x_min, Info::Entity::x_max);
Interval interval(Info::Entity::x_min, Info::Entity::x_max);
// std::cout << __FILE__ << " " << __LINE__ << " " << Info::Render::_x_min_visible << " " << Info::Render::_x_max_visible << std::endl;
if (_DRAW_OPENGL == format) {
......
......@@ -55,6 +55,7 @@
#include "common/common.hpp"
#include "common/info.hpp"
#include "common/Tools.hpp"
#include "common/Session.hpp"
/* -- */
#include "trace/values/Values.hpp"
#include "trace/EntityTypes.hpp"
......@@ -138,7 +139,7 @@ void Interface_graphic::load_windows(){
QFile file_info( ":/window/info_window.ui");
QFile file_selection_export(":/window/option_export_window.ui");
QFile file_help(":/window/help_window.ui");
QFile file_kind_of_export(":/window/kind_of_export.ui");
// QFile file_kind_of_export(":/window/kind_of_export.ui");
QFile file_counter_to_export(":/window/list_of_counter_to_export.ui");
if (!QGLFormat::hasOpenGL())
......@@ -167,11 +168,12 @@ void Interface_graphic::load_windows(){
file_help.close();
/* Load the export combo box choice from a .ui file */
file_kind_of_export.open(QFile::ReadOnly);
CKFP(_ui_kind_of_export_choice = loader.load(&file_kind_of_export, this), "Cannot open the .ui file : " << ":/window/kind_of_export.ui");
/* file_kind_of_export.open(QFile::ReadOnly);
CKFP(_ui_kind_of_export_choice = loader.load(&file_kind_of_export, this), "Cannot open the .ui file : " << ":/window/kind_of_export.ui");
CKFP(_ui_svg_export_button = qFindChild<QRadioButton*>(_ui_kind_of_export_choice, "svg_export"), "Cannot find the svg export button in the .ui file");
CKFP(_ui_counter_export_button = qFindChild<QRadioButton*>(_ui_kind_of_export_choice, "counter_export"), "Cannot find the svg export button in the .ui file");
file_kind_of_export.close();
CKFP(_ui_png_export_button = qFindChild<QRadioButton*>(_ui_kind_of_export_choice, "png_export"), "Cannot find the png export button in the .ui file");
CKFP(_ui_counter_export_button = qFindChild<QRadioButton*>(_ui_kind_of_export_choice, "counter_export"), "Cannot find the svg export button in the .ui file");
file_kind_of_export.close();*/
/* Set some windows properties */
_ui_info_window->setWindowFlags(_ui_info_window->windowFlags() | Qt::WindowStaysOnTopHint);/* Always display info_window on top */
......@@ -217,9 +219,9 @@ void Interface_graphic::load_windows(){
connect(_ui_counter_choice_to_export, SIGNAL(accepted()),
this, SLOT(counter_choosed_triggered()));
connect(_ui_kind_of_export_choice, SIGNAL(accepted()),
/* connect(_ui_kind_of_export_choice, SIGNAL(accepted()),
this, SLOT(choice_of_the_export_pressed()));
*/
connect(_ui_export_ok_button, SIGNAL(pressed()),
this, SLOT(option_export_ok_pressed()));
......@@ -474,8 +476,81 @@ void Interface_graphic::on_open_triggered(){
}
void Interface_graphic::choice_of_the_export_pressed() {
if(_ui_svg_export_button->isChecked()) {
//void Interface_graphic::choice_of_the_export_pressed() {
void Interface_graphic::on_export_file_triggered(){
if(_is_rendering_trace == false)
return;
QStringList selected_files;
QFileDialog file_dialog(this);
QString filename;
QString extension;
/*
filename = QFileDialog(this)::getSaveFileName(this, tr("Save File"),
"",
tr("Vector (*.svg);;Bitmap (*.png *.xpm *.jpg);;Counter (*.txt)"));
*/
/* Try to recover the last file dialog state. */
if (Session::Export::file_dialog_state!=Session::Export::DEFAULT_STATE){
if (!file_dialog.restoreState(Session::Export::file_dialog_state))
warning("Cannot restore the export file dialog state");
}
file_dialog.setLabelText(QFileDialog::FileName, QString(_trace_path.substr(0, _trace_path.find_last_of('.')).c_str()) + ".svg");
file_dialog.setFileMode(QFileDialog::AnyFile);/* Allow to browse among directories */
file_dialog.setAcceptMode(QFileDialog::AcceptSave);/* Only save file */
file_dialog.setNameFilter(tr("Vector (*.svg);;Bitmap PNG (*.png);;Bitmap JPEG (*.jpeg *.jpg);;Counter (*.txt)"));
// file_dialog.setDefaultSuffix("svg");
if (file_dialog.exec()){/* Display the file dialog */
selected_files = file_dialog.selectedFiles();//"/tmp/test.png";//file_dialog.selectedFile();
if (selected_files.length()==1)
filename = selected_files[0];/* Get the first filename */
else{
if (selected_files.length()==0)
warning("No file was selected.");
else
warning("Cannot save: too much files were selected.");
return;
}
if (filename.right(4)!="."){/* No extension or extension is not correct */
/* Add it manually */
const QString filter_selected = file_dialog.selectedNameFilter();
if ("Vector (*.svg)"==filter_selected){
filename += ".svg";
extension = "svg";
}else if ("Bitmap PNG (*.png)"==filter_selected){
filename += ".png";
extension = "png";
}else if ("Bitmap JPEG (*.jpeg *.jpg)"==filter_selected){
filename += ".jpg";
extension = "jpg";
}else if ("Counter (*.txt)"==filter_selected){
filename += ".txt";
extension = "txt";
}else
warning("Cannot recognize the filter: "+filter_selected.toStdString());
/* Update the _export_filename attribute which will be used in SVG or Counter export functions */
_export_filename = filename;
}else
extension = filename.right(3).toLower();/* in lower case */
}
/* Save the file dialog state (History and current directory) */
Session::Export::file_dialog_state = file_dialog.saveState();
if (extension=="svg"){
// if(_ui_svg_export_button->isChecked()) {
ostringstream temp;
temp.str("");
......@@ -488,7 +563,8 @@ void Interface_graphic::choice_of_the_export_pressed() {
_ui_max_time_export->setText(temp.str().c_str());
_ui_time_selection_export->show();
}
else if (_ui_counter_export_button->isChecked()) {
else if (extension=="txt"){
// else if (_ui_counter_export_button->isChecked()) {
// In order to easily retrieve the good variable, we store them with an index representing the container name followed by the variabletype name (because a variable has no name)
_all_variables.clear();
_core->get_trace()->get_all_variables(_all_variables);
......@@ -508,54 +584,70 @@ void Interface_graphic::choice_of_the_export_pressed() {
_ui_counter_choice_to_export->show();
}
else if (extension=="png" || extension=="jpg" || extension=="jpeg"){
// else if (_ui_png_export_button->isChecked()) {
QImage tempImage = _ui_render_area->grabFrameBuffer(true);/* true = with alpha channel */ // new QImage( pPixelData, width, height, QImage::Format_RGB32);
if ( !tempImage.save( filename, extension.toUpper().toStdString().c_str()) ){
error("The trace cannot be exported into "+filename.toStdString()+" file.");
}else{
information("The trace was exported into "+filename.toStdString()+" file.");
}
}else{
error("Cannot recognize the file extension: "+extension.toStdString()+".");
}
}
void Interface_graphic::counter_choosed_triggered() {
// Il faut faire choisir le nom du fichier! et enfin on peut lancer l'action !
const QString path_by_default = QString(_trace_path.substr(0, _trace_path.find_last_of('.')).c_str()) + ".txt";
QString filename = QFileDialog::getSaveFileName(this, QObject::tr("Export File"),
path_by_default,
QObject::tr("All files"));
// const QString path_by_default = QString(_trace_path.substr(0, _trace_path.find_last_of('.')).c_str()) + ".txt";
//QString filename = QFileDialog::getSaveFileName(this, QObject::tr("Export File"),
// path_by_default,
// QObject::tr("All files"));
Variable *temp = _all_variables[_counter_list_names->currentText().toStdString()];
_core->export_variable(temp, filename.toStdString());
// _core->export_variable(temp, filename.toStdString());
_core->export_variable(temp, _export_filename.toStdString());
}
void Interface_graphic::on_export_file_triggered(){
/*void Interface_graphic::on_export_file_triggered(){
if(_is_rendering_trace == false)
return;
_ui_kind_of_export_choice->show();
}
}*/
void Interface_graphic::option_export_ok_pressed(){
// We have to save the option from _ui_time_selection_export and hide her if it is not do automatically
_ui_time_selection_export->hide();
const QString path_by_default = QString(_trace_path.substr(0, _trace_path.find_last_of('.')).c_str()) + ".svg";
QString filename = QFileDialog::getSaveFileName(this, tr("Export File"),
path_by_default,
tr("Images (*.svg)"));
// const QString path_by_default = QString(_trace_path.substr(0, _trace_path.find_last_of('.')).c_str()) + ".svg";
//QString filename = QFileDialog::getSaveFileName(this, tr("Export File"),
// path_by_default,
// tr("Images (*.svg)"));
QString filename = _export_filename;
if (!filename.isEmpty()) {
// Adding .svg to the end
if(!filename.endsWith(".svg")) {
/* if(!filename.endsWith(".svg")) {
filename += ".svg";
}
}*/
information(string("Exporting trace to ")+filename.toStdString());
_core->set_path_to_export(filename.toStdString());
// _core->draw_trace(_trace_path, Core::_DRAW_SVG);
if(_ui_CheckBox_time_export->isChecked()){
_core->set_min_value_for_export(convert_to_double(_ui_min_time_export->text().toStdString()));
_core->set_max_value_for_export(convert_to_double(_ui_max_time_export->text().toStdString()));
}
// if(_ui_CheckBox_time_export->isChecked()){
// _core->set_min_value_for_export(convert_to_double(_ui_min_time_export->text().toStdString()));
// _core->set_max_value_for_export(convert_to_double(_ui_max_time_export->text().toStdString()));
/* }
else{
_core->set_min_value_for_export(0);
_core->set_max_value_for_export(Info::Entity::x_max);//TO DO TODO max_size de la trace?
}
}*/
_core->launch_action(Core::_STATE_EXPORT_FILE_IN_INTERVAL);
}
......
......@@ -81,7 +81,6 @@ class Interface_graphic : public QMainWindow, protected Ui::main_window, public
*/
void load_windows();
/***********************************
*
* Main window widget attributes.
......@@ -184,6 +183,11 @@ class Interface_graphic : public QMainWindow, protected Ui::main_window, public
*/
QComboBox* _ui_zoom_box;
/*!
* \brief Use to store the filename when the trace is exported.
*/
QString _export_filename;
/*!
* \brief Contains the last zoom value. (Prevent recursive calls)
*/
......@@ -272,6 +276,7 @@ class Interface_graphic : public QMainWindow, protected Ui::main_window, public
*/
QWidget* _ui_kind_of_export_choice;
QRadioButton* _ui_svg_export_button;
QRadioButton* _ui_png_export_button;
QRadioButton* _ui_counter_export_button;
/*!
......@@ -484,7 +489,7 @@ protected slots:
/*!
*\brief A slot called when the choice of the export is done and ok.
*/
void choice_of_the_export_pressed();
// void choice_of_the_export_pressed();
/*!
*\brief A slot called when the choice of the counter is done and ok.
......
<ui version="4.0" >
<class>kind_of_export</class>
<widget class="QDialog" name="kind_of_export" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>369</width>
<height>255</height>
</rect>
</property>
<property name="windowTitle" >
<string>Kind of export</string>
</property>
<property name="windowIcon" >
<iconset resource="vite.qrc" >
<normaloff>:/icon/icon/vite.png</normaloff>:/icon/icon/vite.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string>Choose the kind of export:</string>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="QRadioButton" name="svg_export" >
<property name="text" >
<string>Svg export of all the trace</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="counter_export" >
<property name="text" >
<string>Counter export</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
<zorder>buttonBox</zorder>
<zorder>groupBox</zorder>
</widget>
<resources>
<include location="vite.qrc" />
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>kind_of_export</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel" >
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>kind_of_export</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>184</x>
<y>229</y>
</hint>
<hint type="destinationlabel" >
<x>184</x>
<y>127</y>
</hint>
</hints>
</connection>
</connections>
</ui>
......@@ -30,7 +30,6 @@
<file>main_window.ui</file>
<file>option_export_window.ui</file>
<file>stats_viewer.ui</file>
<file>kind_of_export.ui</file>
<file>list_of_counter_to_export.ui</file>
</qresource>
</RCC>
......@@ -64,6 +64,11 @@ const int Hook_event::_ctrl_scroll_factor = 10;
const int Hook_event::_ctrl_zoom_factor = 3;
void Hook_event::updateRender(){
_render_instance->update();
}
/***********************************
*
*
......@@ -133,7 +138,7 @@ Hook_event::Hook_event(Render_opengl* render_instance, Core* core, QWidget *pare
setMouseTracking (true);/* to catch mouse events */
setFocusPolicy(Qt::StrongFocus);/* to catch keybord events (focus by tabbing or clicking) */
//_render_instance->updateGL();
//updateRender();
}
......@@ -165,7 +170,7 @@ void Hook_event::mousePressEvent(QMouseEvent * event){
to cancel the drawing */
if ( true == _mouse_pressed){
_mouse_pressed = false;
_render_instance->updateGL();
updateRender();
return;
}
......@@ -184,7 +189,7 @@ void Hook_event::mousePressEvent(QMouseEvent * event){
_previous_selection.pop();
refresh_scroll_bars(true);
_render_instance->updateGL();
updateRender();
#ifdef DEBUG_MODE_RENDER_AREA_
......@@ -232,7 +237,7 @@ void Hook_event::mouseDoubleClickEvent ( QMouseEvent * event ){
_core->launch_action(_core->_STATE_RENDER_DISPLAY_INFORMATION, NULL);
_mouse_pressed = false;
_render_instance->updateGL();
updateRender();
}
}
......@@ -244,7 +249,7 @@ void Hook_event::mouseMoveEvent(QMouseEvent * event){
_new_mouse_x = event->x();
_new_mouse_y = event->y();
_render_instance->updateGL();
updateRender();
}
......@@ -387,7 +392,7 @@ void Hook_event::apply_zoom_box(Element_pos x_min, Element_pos x_max, Element_po
_y_state_scale *= Info::Screen::height/(y_max - y_min);
_mouse_pressed = false;
_render_instance->updateGL();
updateRender();
refresh_scroll_bars(true);
}
......@@ -538,7 +543,7 @@ void Hook_event::replace_scale(Element_pos new_scale){