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

- 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) {
......
This diff is collapsed.
......@@ -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){
_core->launch_action(_core->_STATE_ZOOM_BOX_VALUE, &buf);
_render_instance->updateGL();
updateRender();
refresh_scroll_bars(true);
}
}
......@@ -559,7 +564,7 @@ void Hook_event::replace_scale_y(Element_pos new_scale){
_y_state_scale = new_scale;
/* TODO add a zoom box value for y zoom */
_render_instance->updateGL();
updateRender();
refresh_scroll_bars(true);
}
}
......@@ -589,7 +594,7 @@ void Hook_event::replace_translate(Element_pos new_translate){
refresh_scroll_bars();
_key_scrolling = false;
}
_render_instance->updateGL();
updateRender();
}
......@@ -606,7 +611,7 @@ void Hook_event::replace_translate_y(Element_pos new_translate){
refresh_scroll_bars();
_key_scrolling = false;
}
_render_instance->updateGL();
updateRender();
}
......@@ -647,7 +652,7 @@ void Hook_event::registered_translate(int id){
}
refresh_scroll_bars();
_render_instance->updateGL();
updateRender();
}
......@@ -667,7 +672,7 @@ void Hook_event::refresh_scroll_bars(bool LENGTH_CHANGED){
void Hook_event::change_scale_container_state(int view_size){
_x_scale_container_state = 0.01 * view_size;
_render_instance->updateGL();
updateRender();
}
......
......@@ -300,8 +300,10 @@ protected:
*/
void keyReleaseEvent(QKeyEvent * event);
/*!
* Use to update the render area.
*/
void updateRender();
/***********************************
......
......@@ -440,6 +440,8 @@ public:
graduation_diff = Ruler::get_graduation_diff(Info::Render::_x_min_visible, Info::Render::_x_max_visible);
coeff_prefix = Ruler::get_coeff_for_common_prefix(Info::Render::_x_min_visible, Info::Render::_x_max_visible);
// std::cout << __FILE__ << " " << __LINE__ << " : " << coeff_prefix << std::endl;
drawing_instance->start_ruler();
drawing_instance->set_color(1, 0, 0);
for (Element_pos i = Info::Render::_x_min_visible ; i < Info::Render::_x_max_visible ; i+=graduation_diff){
......
......@@ -166,9 +166,10 @@ void Render_opengl::resizeGL(int width, int height) {
}
void Render_opengl::paintGL(){
paintEvent(NULL);
}
/*void Render_opengl::paintGL(){
// paintEvent(NULL);
cout << __FILE__ << " " << __LINE__ << endl;
}*/
void Render_opengl::paintEvent(QPaintEvent *)
{
......@@ -201,7 +202,6 @@ void Render_opengl::paintGL(){
}else if (DRAWING_STATE_DRAWING == _state){/* A trace is drawn */
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
......@@ -341,8 +341,7 @@ void Render_opengl::paintGL(){
if(glerror != GL_NO_ERROR)
message << tr("Render area : the following OpengGL error occured: ").toStdString() << (char *)gluErrorString(glerror) << Message::endw;
QPainter painter(this);
//painter.setPen(Qt::NoPen);
//painter.setBrush(QColor(125, 125, 150));
......@@ -389,6 +388,8 @@ void Render_opengl::paintGL(){
/***********************************
*
*
......@@ -610,7 +611,7 @@ void Render_opengl::call_ruler(){
){
buf_txt << "<b>";
if (common_part==0.0){
if (variable_part!=0.0){
......
......@@ -218,8 +218,7 @@ public:
/*!
* \brief Call by the system each time the render area need to be updated.
*/
void paintGL();
// void paintGL();
/***********************************
......
......@@ -61,6 +61,16 @@ using namespace std;
#define message *Message::get_instance() << "(" << __FILE__ << " l." << __LINE__ << "): "
static int number_size(double n){
int n_floor;
n_floor = (int)n;
if (n_floor==0) return 1;
return (int)ceil(log10(n_floor));
}
/***********************************
*
......@@ -100,7 +110,7 @@ void Render_svg::draw_text(const Element_pos x, const Element_pos y, const Eleme
_buffer.str("");
_buffer << "<text x=\"" << render_to_screen_x(x) <<"\""
<< " y=\"" << render_to_screen_y(y) << "\""
<< " font-size=\"8\""
<< " font-size=\"10\""
<< " fill=\"white\">"
<< s
<< "</text>\n";
......@@ -111,15 +121,15 @@ void Render_svg::draw_text(const Element_pos x, const Element_pos y, const Eleme
void Render_svg::draw_quad(Element_pos x, Element_pos y, Element_pos , Element_pos w, Element_pos h){
const Element_pos x_min = trace_to_render_x(Info::Render::_x_min_visible);
const Element_pos x_max = trace_to_render_x(Info::Render::_x_max_visible);
// const Element_pos x_min = trace_to_render_x(Info::Render::_x_min_visible);
// const Element_pos x_max = trace_to_render_x(Info::Render::_x_max_visible);
if (render_to_screen_x(w) < 1)/* less than 1 pixel */
return;
if ((x+w) < x_min)
return;
if (x > x_max)
return;
// if ((x+w) < x_min)
// return;
// if (x > x_max)
// return;
// std::cout << __FILE__ << " " << __LINE__ << " - " << x << " " << << std::endl;
......@@ -233,22 +243,101 @@ void Render_svg::end_draw_counter(){
}
void Render_svg::start_ruler(){
_buffer.str("");
_buffer << "<text x=\"" << 0 <<"\""
<< " y=\"" << 0 << "\""
<< " font-size=\"18\""
<< " fill=\"white\">"
<< Info::Render::_x_min_visible
<< "</text>\n";
_output_file.write(_buffer.str().c_str(), _buffer.str().size());
}
void Render_svg::end_ruler(){
}
void Render_svg::end_draw(){
float intpart;
float fractpart;
int min_visible_size;
int max_visible_size;
int*j;
Element_pos k;
if (Info::Render::_x_min_visible != Info::Render::_x_max_visible){
for (j = &min_visible_size,
k = Info::Render::_x_min_visible
;
k <= Info::Render::_x_max_visible
;
j = &max_visible_size,
k += Info::Render::_x_max_visible - Info::Render::_x_min_visible){
if (k==0.0){
*j = 1;
continue;
}
*j = 0;
intpart = 0;
fractpart = k - floor(k);//modf(k, &intpart);
intpart = floor(k);
// cout << __FILE__ << " " << __LINE__ << " >> " << intpart << " " << fractpart << endl;
while(floor(fractpart) != fractpart){
// cout << __FILE__ << " " << __LINE__ << " >> " << floor(fractpart) << " " << fractpart << endl;
fractpart*=10;
(*j)++;
}
(*j) += number_size(intpart);// + number_size(fractpart);
}
// cout << __FILE__ << " " << __LINE__ << " >> " << Info::Render::_x_min_visible << " " << Info::Render::_x_max_visible << endl;
//cout << __FILE__ << " " << __LINE__ << " >> " << min_visible_size << " " << max_visible_size << endl;
/* Draw the main ruler */
const int LETTER_WIDTH = 10;
const int LETTER_HEIGHT = 14;
const int MINVISIBLE_WIDTH = min_visible_size*LETTER_WIDTH;
const int MINVISIBLE_HEIGHT = - LETTER_HEIGHT;;
const int MINVISIBLE_X = 8;
const int MINVISIBLE_Y = - MINVISIBLE_HEIGHT;
const int MAXVISIBLE_WIDTH = max_visible_size*LETTER_WIDTH;
const int MAXVISIBLE_HEIGHT = - LETTER_HEIGHT;;
const int MAXVISIBLE_X = Info::Screen::width - MAXVISIBLE_WIDTH;
const int MAXVISIBLE_Y = - MAXVISIBLE_HEIGHT;
_buffer.str("");
_buffer << "<polygon points=\""
<< MINVISIBLE_X << "," << MINVISIBLE_Y << ","
<< MINVISIBLE_X+MINVISIBLE_WIDTH << "," << MINVISIBLE_Y << ","
<< MINVISIBLE_X+MINVISIBLE_WIDTH << "," << MINVISIBLE_Y+MINVISIBLE_HEIGHT << ","
<< MINVISIBLE_X << "," << MINVISIBLE_Y+MINVISIBLE_HEIGHT << "\""
<< " style=\"fill:black\""