Commit 15ae9e0b authored by Olivier Lagrasse's avatar Olivier Lagrasse

- Fix a problem with color which made slow the render.

- Add an alternate render with VBO. Uncomment #define WITH_VBO on Core.hpp to use it. You need glew installed. If you cannot compile and you do not want to install glew, please remove Render_alternate.hpp et Render_alternate.cpp entries from src/src.pro and/or src/CMakeLists.txt.
- Fix some bugs.
parent a6f33bcf
......@@ -87,6 +87,7 @@ SET(VITE_HDRS
render/Geometry.hpp
render/Hook_event.hpp
render/Render_opengl.hpp
render/Render_alternate.hpp
render/Render_svg.hpp
render/render_stats.hpp
render/render_stats_opengl.hpp
......@@ -166,6 +167,7 @@ SET(VITE_SRCS
render/Hook_event.cpp
render/Render.hpp
render/Render_opengl.cpp
render/Render_alternate.cpp
render/Render_svg.cpp
render/render_stats_opengl.cpp
render/render_stats_svg.cpp
......
......@@ -47,32 +47,6 @@
#include "common/common.hpp"
#include "common/info.hpp"
// void (Interface_console:: *Info::Core::launch_action)(int, void*) = NULL;
// const int Info::Core::_STATE_UNKNOWN = -1;
// const int Info::Core::_STATE_DISPLAY_HELP = 0;
// const int Info::Core::_STATE_IN_AN_INTERVAL = 1; // 2^0
// const int Info::Core::_STATE_OPEN_FILE = 2; // 2^1
// const int Info::Core::_STATE_OPEN_FILE_IN_AN_INTERVAL = 3;
// const int Info::Core::_STATE_EXPORT_FILE = 4; // 2^2
// const int Info::Core::_STATE_EXPORT_FILE_IN_INTERVAL = 5;
// const int Info::Core::_STATE_RELEASE_RENDER_AREA = 6;
// const int Info::Core::_STATE_RENDER_AREA_CHANGE_TRANSLATE = 7;
// const int Info::Core::_STATE_RENDER_AREA_CHANGE_SCALE = 8;
// const int Info::Core::_STATE_RENDER_AREA_CHANGE_CONTAINER_SCALE = 9;
// const int Info::Core::_DRAW_OPENGL = 10;
// const int Info::Core::_DRAW_SVG = 11;
// const int Info::Core::_STATE_LAUNCH_GRAPHICAL_INTERFACE = 12;
// const int Info::Core::_STATE_RENDER_AREA_REPLACE_SCALE = 13;
// const int Info::Core::_STATE_RENDER_AREA_REPLACE_TRANSLATE = 14;
// const int Info::Core::_STATE_RENDER_AREA_REPLACE_TRANSLATE_Y = 15;
// const int Info::Core::_STATE_RENDER_AREA_REGISTERED_TRANSLATE = 16;
// const int Info::Core::_STATE_RENDER_AREA_CHANGE_SCALE_Y = 17;
// const int Info::Core::_STATE_AJUST_SCROLL_BARS = 18;
// const int Info::Core::_STATE_REFRESH_SCROLL_BARS = 19;
// const int Info::Core::_STATE_ZOOM_BOX_VALUE = 20;
// const int Info::Core::_STATE_RENDER_DISPLAY_INFORMATION = 21;
// const int Info::Core::_STATE_RENDER_UPDATE = 22;
unsigned int Info::Screen::width = 800;
unsigned int Info::Screen::height = 600;
......@@ -101,5 +75,5 @@ Element_pos Info::Render::_info_accurate = 0.0;
bool Info::Render::_no_arrows = false;
bool Info::Render::_no_events = false;
QLabel* Info::Render::_ui_render_min_value = NULL;
QLabel* Info::Render::_ui_render_max_value = NULL;
//QLabel* Info::Render::_ui_render_min_value = NULL;
//QLabel* Info::Render::_ui_render_max_value = NULL;
......@@ -48,7 +48,7 @@
#define INFO_HPP
class Interface_console;
class QLabel;
//class QLabel;
/*!
* \brief Class used to store informations.
......@@ -253,13 +253,13 @@ public:
* \brief This attribute is used to update the label which indicates
* the minimum visible trace value.
*/
static QLabel* _ui_render_min_value;
//static QLabel* _ui_render_min_value;
/*!
* \brief This attribute is used to update the label which indicates
* the maximum visible trace value.
*/
static QLabel* _ui_render_max_value;
//static QLabel* _ui_render_max_value;
};
......
......@@ -45,8 +45,6 @@
*\brief This is the console interface C source code.
*/
//#define WITH_OTF
#include <queue>
#include <string>
......@@ -66,12 +64,9 @@
/* -- */
#include "render/Render_opengl.hpp"
//#include "render/render.hpp"
#include "render/Render_svg.hpp"
#include "render/Render.hpp"
//#include "render/Render_opengl_dl.hpp"
/* -- */
#include "trace/values/Values.hpp"
#include "trace/tree/Interval.hpp"
......@@ -101,6 +96,13 @@
#include "core/Core.hpp"
#include "interface/parsing_thread.hpp"
/* -- */
#ifdef WITH_VBO
#include "render/Render_alternate.hpp"
#else
#include "render/Render_opengl.hpp"
#endif
using namespace std;
#define message *Message::get_instance() << "(" << __FILE__ << " l." << __LINE__ << "): "
......@@ -211,13 +213,19 @@ bool Core::draw_trace(const string & filename, const int format){
Parser *parser;
DrawTrace drawing_ogl;
#ifdef WITH_VBO
Render<Render_alternate> render(_render_opengl);
#else
Render<Render_opengl> render(_render_opengl);
#endif
QTime time_elapsed;
ostringstream buf_txt;
int time_buf;
time_buf = 0;
// Get the parser in function of the extension of the file
const unsigned int position_of_dot = filename.find_last_of('.');
......@@ -254,6 +262,13 @@ bool Core::draw_trace(const string & filename, const int format){
if (NULL == _trace) { /* no trace is loaded, parse the file */
/* Init data */
Info::Entity::x_min = 0;
Info::Entity::x_max = 0;
Info::Render::_x_min_visible = 0;
Info::Render::_x_max_visible = 0;
_trace = new Trace();
// Init of the thread
......@@ -633,12 +648,16 @@ void Core::launch_action(int state, void* arg) {
if ( _STATE_OPEN_FILE == state)
message << QObject::tr("Opening the file: ").toStdString ()+_file_opened << Message::endi;
_main_window = new Interface_graphic (this);/* launch the window interface */
Message::set_interface (_main_window);/* define which interface will receive messages */
// format.setOverlay(true);
#ifdef WITH_VBO
_render_opengl = new Render_alternate (this, _main_window, format);
#else
_render_opengl = new Render_opengl (this, _main_window, format);
#endif
if ( NULL == _render_opengl){
message << QObject::tr("Cannot allocate memory for an OpengGL instance").toStdString () << Message::ende;
......
......@@ -47,9 +47,18 @@
#ifndef CORE_HPP
#define CORE_HPP
//#define WITH_VBO
class Core;
class Interface_graphic;
#ifdef WITH_VBO
class Render_alternate;
#else
class Render_opengl;
#endif
class Render_svg;
class Trace;
#include "render/Render.hpp"
......@@ -256,7 +265,11 @@ protected:
* \brief Contains the OpenGL render instance.
*/
/* MOD */
Render_opengl* _render_opengl;
#ifdef WITH_VBO
Render_alternate* _render_opengl;
#else
Render_opengl* _render_opengl;
#endif
//Render<Render_opengl>* _render_opengl;
/*!
......
......@@ -195,8 +195,8 @@ void Interface_graphic::load_windows(){
CKFP(_ui_zoom_box = qFindChild<QComboBox*>(this, "zoom_box"), "Cannot find the zoom box in the .ui file");
CKFP(Info::Render::_ui_render_min_value = qFindChild<QLabel*>(this, "render_min_value"), "Cannot find the render_min_value label in the .ui file");
CKFP(Info::Render::_ui_render_max_value = qFindChild<QLabel*>(this, "render_max_value"), "Cannot find the render_max_value label in the .ui file");
// CKFP(Info::Render::_ui_render_min_value = qFindChild<QLabel*>(this, "render_min_value"), "Cannot find the render_min_value label in the .ui file");
// CKFP(Info::Render::_ui_render_max_value = qFindChild<QLabel*>(this, "render_max_value"), "Cannot find the render_max_value label in the .ui file");
/* Export window */
CKFP(_ui_export_ok_button = qFindChild<QPushButton*>(_ui_time_selection_export, "option_export_ok"), "Cannot find the ok push button in the export dialog .ui file");
......
......@@ -28,55 +28,6 @@
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="render_min_value">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="render_max_value">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
......@@ -235,7 +186,7 @@
<x>0</x>
<y>0</y>
<width>1060</width>
<height>27</height>
<height>25</height>
</rect>
</property>
<widget class="QMenu" name="menuHelp">
......
......@@ -253,7 +253,7 @@ void Hook_event::mouseDoubleClickEvent ( QMouseEvent * event ){
void Hook_event::mouseMoveEvent(QMouseEvent * event){
// if (!_mouse_pressed) return;
if (!_mouse_pressed) return;
_new_mouse_x = event->x();
_new_mouse_y = event->y();
......
......@@ -52,6 +52,7 @@
#include "render/Ruler.hpp"
#include "common/info.hpp"
#include <GL/glut.h>
/*!
* \brief Structure used to store container information.
......@@ -242,16 +243,20 @@ public:
}
drawing_instance->end_draw_containers();
}
static int bb;
/*!
* \brief Creates and opens the display list for state draws.
*/
inline void start_draw_states(){
drawing_instance->start_draw_states();
}
/*!
* \brief Draw a state of the trace.
* \param start the beginning time of the state.
......@@ -262,18 +267,17 @@ public:
* \param g the green color rate of the state.
* \param b the blue color rate of the state.
*/
inline void draw_state(const Element_pos start, const Element_pos end, const Element_pos base, const Element_pos height, const Element_col r, const Element_col g, const Element_col b) {
// std::cout << __FILE__ << " " << __LINE__ << " -* " << trace_to_render_x(start) << " " << coeff_trace_render_x() << std::endl;
inline void draw_state(const Element_pos start, const Element_pos end, const Element_pos base, const Element_pos height, const Element_col r, const Element_col g, const Element_col b) {
drawing_instance->set_color(r, g, b);
// drawing_instance->draw_quad(start, base, _z_state, end-start, height);
drawing_instance->draw_quad(trace_to_render_x(start - Info::Render::_x_min_visible),
trace_to_render_y(base),
_z_state,
(end-start)*coeff_trace_render_x(),
height*coeff_trace_render_y());
}
/*!
......@@ -449,7 +453,6 @@ public:
*/
inline void end_draw(){
// std::cerr << __FILE__ << __LINE__ << " " << Info::Render::_x_min_visible << " " << Info::Render::_x_max_visible << std::endl;
/* Now, draw ruler */
Element_pos graduation_diff;
Element_pos coeff_prefix;
......
This diff is collapsed.
/*
** 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 Render_alternate.hpp
*/
#ifndef RENDER_OPENGL_HPP
#define RENDER_OPENGL_HPP
#include <QGLWidget>
#include "core/Core.hpp"
#include "render/Hook_event.hpp"
#include "render/Render_template.hpp"
class Render_alternate;
class Interface_console;
struct Container_text_;
class Vbo;
/*!
* \brief Structure used to store arrow information.
*/
struct Arrow_{
/*!
* \brief Coordinates.
*/
Element_pos start_time, end_time, start_height, end_height;
/*!
* \brief Colors.
*/
Element_col red, green, blue;
};
/*!
* \brief Structure used to store event information.
*/
struct Event_{
/*!
* \brief Coordinates and radius.
*/
Element_pos time, height, container_height;
/*!
* \brief Colors.
*/
Element_col red, green, blue;
};
/*!
* \brief This class redefined the OpenGL widget - QGLWidget - to display the trace.
*/
class Render_alternate : /*public QGLWidget,*/ public Hook_event, public Render_template
{
Q_OBJECT
protected:
/*!
* \brief Contains the parent instance.
*/
Core* _core;
/*!
* \brief The waiting screen display list.
*/
GLuint _wait_list;
/*!
* \brief The container GLu list.
*/
GLuint _list_containers;
/*!
* \brief The state GLu list.
*/
GLuint _list_states;
/*!
* \brief The counter GLu list.
*/
GLuint _list_counters;
/*!
* \brief The wait GLu list.
*/
// GLuint _wait_list;
float _red, _green, _blue;
std::vector<Container_text_> _texts;
std::vector<Arrow_> _arrows;
std::vector<Event_> _circles;
/***********************************
*
* The wait screen drawing.
*
**********************************/
/***********************************
* The wait list Attributes.
**********************************/
/*!
* \brief Rotation angle for the wait.
*/
float _wait_angle;
/*!
* \brief Y rotation angle for the wait.
*/
float _wait_angle_y;
/*!
* \brief Time in ms between two frames for the waiting screen.
*/
static const int DRAWING_TIMER_DEFAULT;
/*!
* \brief Wait animation seconds per frame.
*/
int _wait_spf;
Vbo* _current_vbo;
std::vector<Vbo*> _vbos;
/*!
* \brief Timer to animate the wait.
*/
QTimer* _wait_timer;
public:
/***********************************
*
* Constructor and destructor.
*
**********************************/
/*!
* \brief The default constructor
*/
Render_alternate(Core* core, QWidget *parent, const QGLFormat& format);
/*!
* \brief The destructor
*/
virtual ~Render_alternate();
/*!
* \brief Set Statistics and Informations about input trace
*/
void set_total_width(Element_pos){}
/*!
* \brief Set Statistics and Informations about input trace
*/
void set_total_time(Times){}
/*!
* \brief display the scale
*/
void display_time_scale(){}
/***********************************
*
* Default QGLWidget functions.
*
**********************************/
/*!
* \brief Call by the system to initialize the OpenGL render area.
*/
void initializeGL();
/*!
* \brief Call by the system when the render area was resized (occurs during a window resizement).
* \param width : the new width of the render area.
* \param height : the new height of the render area.
*/
void resizeGL(int width, int height);
/*!
* \brief Call by the system each time the render area need to be updated.
*/
void paintGL();
//void paintEvent(QPaintEvent *event);
/* void initializeOverlayGL();
void resizeOverlayGL(int width, int height);
void paintOverlayGL();*/
/***********************************
*
* Building functions.
*
**********************************/
/*!
* \brief This function constructs the trace.
*/
// bool display_build() ;
/*!
* \brief This function releases the trace.
*/
// bool display_unbuild() ;
/*!
* \brief Proceeds with the initialization of the OpenGL draw functions.
*/
void start_draw();
/*!
* \brief Creates and opens the display list for container draws.
*/
void start_draw_containers();
/*!
* \brief Draw a container according to the parameters
* \param x the x position of the container
* \param y the y position of the container
* \param w the width of the container
* \param h the height of the container
*/
void draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h);
/*!
* \brief Draw the text of a container.
* \param x the x position of the text.
* \param y the y position of the text.
* \param value the string value of the text.
*
* This function stores text in a list. This list will be display each time the render area need to be updated.
*/
void draw_container_text(const Element_pos x, const Element_pos y, const std::string value);
/*!
* \brief Closes the container display list.
*/
void end_draw_containers();
/*!
* \brief Creates and opens the display list for stater draws.
*/
void start_draw_states();
/*!
* \brief Draw a state of the trace.
* \param start the beginning time of the state.
* \param end the ending time of the state.
* \param base vertical position of the state.
* \param height the state height.
* \param r the red color rate of the state.
* \param g the green color rate of the state.
* \param b the blue color rate of the state.
*/
void draw_state(const Element_pos start , const Element_pos end, const Element_pos base, const Element_pos height, const Element_col r, const Element_col g, const Element_col b);
/*!
* \brief Closes the state display list.
*/
void end_draw_states();