Commit b5c4de95 authored by Olivier Lagrasse's avatar Olivier Lagrasse

- Temporary commit for unified render.

parent c78e8e4a
......@@ -81,6 +81,7 @@ SET(VITE_HDRS
trace/Trace.hpp
# Render headers
render/render.hpp
render/Geometry.hpp
render/Hook_event.hpp
render/Render_opengl_dl.hpp
render/Render_opengl.hpp
......@@ -158,6 +159,7 @@ SET(VITE_SRCS
trace/Container.cpp
trace/Trace.cpp
# Render code files
render/Geometry.cpp
render/Hook_event.cpp
render/Render_opengl.cpp
render/render_svg.cpp
......
......@@ -73,11 +73,15 @@
// const int Info::Core::_STATE_RENDER_DISPLAY_INFORMATION = 21;
// const int Info::Core::_STATE_RENDER_UPDATE = 22;
int Info::Container::x_min = 0;
int Info::Container::x_max = 0;
Element_pos Info::Container::x_min = 0;
Element_pos Info::Container::x_max = 0;
Element_pos Info::Container::y_min = 0;
Element_pos Info::Container::y_max = 0;
int Info::Entity::x_min = 0;
int Info::Entity::x_max = 0;
Element_pos Info::Entity::x_min = 0;
Element_pos Info::Entity::x_max = 0;
Element_pos Info::Entity::y_min = 0;
Element_pos Info::Entity::y_max = 0;
bool Info::Render::_key_alt = false;
bool Info::Render::_key_ctrl = false;
......
......@@ -220,12 +220,22 @@ public:
/*!
* \brief Minimum x position.
*/
static int x_min;
static Element_pos x_min;
/*!
* \brief Maximum x position.
*/
static int x_max;
static Element_pos x_max;
/*!
* \brief Minimum y position.
*/
static Element_pos y_min;
/*!
* \brief Maximum y position.
*/
static Element_pos y_max;
};
......@@ -237,12 +247,22 @@ public:
/*!
* \brief Minimum x position.
*/
static int x_min;
static Element_pos x_min;
/*!
* \brief Maximum x position.
*/
static int x_max;
static Element_pos x_max;
/*!
* \brief Minimum y position.
*/
static Element_pos y_min;
/*!
* \brief Maximum y position.
*/
static Element_pos y_max;
};
......
......@@ -62,9 +62,12 @@
#include "common/Errors.hpp"
#include "common/Tools.hpp"
/* -- */
#include "render/render.hpp"
#include "render/render_svg.hpp"
#include "render/Render_opengl_dl.hpp"
#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"
......@@ -187,9 +190,17 @@ Core::~Core(){
bool Core::draw_trace(const string & filename, const int format){
Parser *parser;
Svg svg;
DrawTrace<Render_opengl> drawing_ogl;
DrawTrace<Svg> drawing_svg;
// Svg svg;
/* MOD */
DrawTrace/*<Render_opengl>*/ drawing_ogl;
// _render_opengl = new Render_opengl(this, _main_window);
Render<Render_opengl> render(_render_opengl);
//Render<Render_opengl> drawing_ogl;
// DrawTrace<Svg> drawing_svg;
QTime time_elapsed;
ostringstream buf_txt;
int time_buf;
......@@ -225,7 +236,8 @@ bool Core::draw_trace(const string & filename, const int format){
QApplication::setOverrideCursor(Qt::WaitCursor);
if (_DRAW_SVG == format)
svg.init(_path_to_export.c_str());
_render_svg = new Render_svg(&_path_to_export);// svg.init(_path_to_export.c_str());
if (NULL == _trace) { /* no trace is loaded, parse the file */
......@@ -319,22 +331,28 @@ bool Core::draw_trace(const string & filename, const int format){
*Message::get_instance() << "Try to use file: " << filename << " instead of a previous parsed file: " << _file_opened << Message::ende;
}
Interval interval(_time_start, ((0==_time_end)?_trace->get_max_date():_time_end) );
// Interval interval(_time_start, ((0==_time_end)?_trace->get_max_date():_time_end) );
//Interval interval(_time_start, ((0==_time_end)?_trace->get_max_date():_time_end) );
Interval interval(Info::Render::_x_min_visible, Info::Render::_x_max_visible);
// std::cout << __FILE__ << " " << __LINE__ << " " << Info::Render::_x_min_visible << " " << Info::Render::_x_max_visible << std::endl;
if (_DRAW_OPENGL == format) {
drawing_ogl.build(_render_opengl, _trace);
drawing_ogl.build(&render, _trace);
_render_opengl->build();
_render_opengl->updateGL();
_render_opengl->refresh_scroll_bars();
_file_opened = filename;/* store filename for a future export */
}else if (_DRAW_SVG == format) {
drawing_svg.build(&svg, _trace);
svg.end();
Render<Render_svg> render(_render_svg);
drawing_ogl.build(&render, _trace);
delete _render_svg;/* Release the svg render */
// svg.end();
}else{/* error */
*Message::get_instance() << "No kind of render recognized" << Message::ende;
return false;
}
// std::cout << _trace->get_max_date().get_value() << __FILE__ << __LINE__ << std::endl;
_is_trace_loaded = true;
QApplication::restoreOverrideCursor();
......@@ -373,11 +391,11 @@ int Core::get_state(int argc, char** argv){
/*The following statics must be initialised in case their are not overrided by a command line request*/
Svg::set_height_factor (20);
/* Svg::set_height_factor (20);
Svg::set_wide_factor (100);
Svg::set_interval(0, 0);
Svg::set_accuracy(0.1);
Svg::set_scale_frequency(50);
Svg::set_scale_frequency(50);*/
if(argc == 1){
// just the name of the program, launch the window interface
......@@ -446,7 +464,7 @@ int Core::get_state(int argc, char** argv){
return _STATE_UNKNOWN;
}
else {
Svg::set_accuracy(accuracy);
// Svg::set_accuracy(accuracy);
}
}
}
......@@ -462,7 +480,7 @@ int Core::get_state(int argc, char** argv){
return _STATE_UNKNOWN;
}
else {
Svg::set_wide_factor(wide);
// Svg::set_wide_factor(wide);
}
}
else if((string)argv[i] == "-grow") {
......@@ -477,7 +495,7 @@ int Core::get_state(int argc, char** argv){
return _STATE_UNKNOWN;
}
else {
Svg::set_height_factor(grow);
// Svg::set_height_factor(grow);
}
}
else if((string)argv[i] == "-scale") {
......@@ -492,7 +510,7 @@ int Core::get_state(int argc, char** argv){
return _STATE_UNKNOWN;
}
else {
Svg::set_scale_frequency(scale);
// Svg::set_scale_frequency(scale);
}
}
else if((string)argv[i] == "-interval") {
......@@ -518,7 +536,7 @@ int Core::get_state(int argc, char** argv){
return _STATE_UNKNOWN;
}
Svg::set_interval(t1, t2);
// Svg::set_interval(t1, t2);
i += 2;
}
else {
......@@ -567,7 +585,7 @@ void Core::extract_times(const char *name) {
void Core::launch_action(int state, void* arg) {
DrawTrace<Render_opengl> buf;
DrawTrace/*<Render_opengl>*/ buf;
switch(state) {
......@@ -580,7 +598,11 @@ void Core::launch_action(int state, void* arg) {
_main_window = new Interface_graphic(this);/* launch the window interface */
Message::set_interface(_main_window);/* define which interface will receive messages */
_render_opengl = new Render_opengl_dl(this, _main_window);
/* MOD */
// _render_opengl = new Render_opengl_dl(this, _main_window);
_render_opengl = new Render_opengl(this, _main_window);
_main_window->bind_render_area((QGLWidget*)_render_opengl);
_is_window_displayed = true;
......@@ -590,7 +612,12 @@ void Core::launch_action(int state, void* arg) {
information(string("Opening the file: ")+_file_opened);
_main_window = new Interface_graphic(this);/* launch the window interface and open a file */
Message::set_interface(_main_window);/* define which interface will receive messages */
_render_opengl = new Render_opengl_dl(this, _main_window);
/* MOD */
// _render_opengl = new Render_opengl_dl(this, _main_window);
_render_opengl = new Render_opengl(this, _main_window);
_main_window->bind_render_area((QGLWidget*)_render_opengl);
_main_window->opening_file(_file_opened);/* Must be called after binding the render area to the main window */
......@@ -658,7 +685,7 @@ void Core::launch_action(int state, void* arg) {
cout << "the end of the trace.";
}
Svg::set_interval(_time_start, _time_end);
// Svg::set_interval(_time_start, _time_end);
draw_trace(_file_opened, _DRAW_SVG);
break;
......
......@@ -50,9 +50,12 @@
class Core;
class Interface_graphic;
class Render_opengl;
class Render_svg;
class Trace;
#include "render/Render.hpp"
class Variable;
#include "interface/Interface.hpp"
/*!
......@@ -250,9 +253,16 @@ protected:
Interface_graphic* _main_window;
/*!
* \brief Contains the OpenGL render area instance.
* \brief Contains the OpenGL render instance.
*/
/* MOD */
Render_opengl* _render_opengl;
//Render<Render_opengl>* _render_opengl;
/*!
* \brief Contains the SVG render instance.
*/
Render_opengl* _render_opengl;
Render_svg* _render_svg;
/*!
* \brief Contains the main Qt application instance.
......
......@@ -61,7 +61,7 @@
#include "trace/Entitys.hpp"
#include "trace/Trace.hpp"
/* -- */
#include "render/render.hpp"
//#include "render/render.hpp"
#include "render/render_svg.hpp"
/* -- */
#include "statistics/Stats_window.hpp"
......@@ -560,10 +560,10 @@ void Interface_graphic::option_export_ok_pressed(){
double accuracy = convert_to_double(_ui_accuracy_export->text().toStdString());
double height = convert_to_double(_ui_grow_export->text().toStdString());
double wide = convert_to_double(_ui_wide_export->text().toStdString());
/*
if(_ui_more_options_export->isChecked()) {
if(accuracy >= 0. && _ui_CheckBox_accuracy_export->isChecked())
Svg::set_accuracy(accuracy);
Svg::set_accuracy(accuracy);
else { // Default value
Svg::set_accuracy(0.);
}
......@@ -578,13 +578,13 @@ void Interface_graphic::option_export_ok_pressed(){
Svg::set_wide_factor(wide);
else { // Default value
Svg::set_wide_factor(100.);
}
}
}
else{ // Default values
Svg::set_accuracy(0.);
Svg::set_height_factor(20.);
Svg::set_wide_factor(100.);
}
}*/
_core->launch_action(Core::_STATE_EXPORT_FILE_IN_INTERVAL);
}
......
/*
** 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 Geometry.cpp
*/
#include "common/common.hpp"
#include "common/info.hpp"
/* -- */
#include "render/Geometry.hpp"
using namespace std;
#define message *Message::get_instance() << "(" << __FILE__ << " l." << __LINE__ << "): "
/***********************************
*
*
*
* Constructor and destructor.
*
*
*
**********************************/
Geometry::Geometry(){
_counter_last_x = 0.0;
_counter_last_y = 0.0;
/* init main informations about OpenGL scene and QGLWidget size */
_render_width = 100; /* 100 OpenGL units for the render scene width */
_render_height = 100; /* 100 OpenGL units for the render scene height */
_x_scale_container_state = 0.2;/* 20% of screen is used for containers then the other part for states */
_ruler_height = 4.0; /* height of the ruler */
_ruler_y = 0.0; /* highness of the ruler */
_default_entity_x_translate = 20;/* _render_width * _x_scale_container_state */
_container_x_max = 0;
_container_y_max = 0;
_container_x_min = 0;
_container_y_min = 0;
_state_y_max = 0;
_state_y_min = 0;
// _ruler_distance = 5;
// _minimum_distance_for_selection = 5;/* 5 pixels */
// _selection_rectangle_alpha = 0.5;
_x_state_scale = 1;/* for states scaling */
_x_state_translate = 0;/* for states translation */
_y_state_scale = 1;/* for states scaling */
_y_state_translate = 0;/* for states translation */
_x_scroll_pos = 0;/* horizontal bar placed on 0 */
_y_scroll_pos = 0;/* vertical bar placed on 0 */
/* Camera is placed on (0,0,0) and looks to (0,0,-1) */
_z_ruler_over = -0.5;
_z_container = -1.0;
_z_container_under = -1.2;
_z_ruler = -1.5;
_z_ruler_under = -1.6;
_z_arrow = -2.0;/* closer to camera than containers or states (MUST be negative)*/
_z_event = -3.0;/* closer to camera than containers or states (MUST be negative)*/
_z_counter = -4.0;
_z_state = -5.0;
/* Set in the child class */
_screen_width = 0;
_screen_height = 0;
}
Geometry::~Geometry(){
}
/***********************************
*
*
*
* Coordinate convert functions.
*
*
*
**********************************/
Element_pos Geometry::screen_to_render_x(Element_pos e){
return e * (Element_pos)_render_width / (Element_pos)_screen_width;
}
Element_pos Geometry::screen_to_render_y(Element_pos e){
return e * (Element_pos)_render_height / (Element_pos)_screen_height;
}
Element_pos Geometry::render_to_trace_x(Element_pos e){
return (e - _default_entity_x_translate + _x_state_translate) *
(Info::Entity::x_max - Info::Entity::x_min) / ((_render_width - _default_entity_x_translate) * _x_state_scale);
}
Element_pos Geometry::render_to_trace_y(Element_pos e){
return (e-_ruler_y-_ruler_height + _y_state_translate) *
(_container_y_max - _container_y_min) / ((_render_height - _ruler_height) * _y_state_scale);
}
Element_pos Geometry::render_to_screen_x(Element_pos e){
return e * (Element_pos)_screen_width / (Element_pos)_render_width;
}
Element_pos Geometry::render_to_screen_y(Element_pos e){
return e * (Element_pos)_screen_height / (Element_pos)_render_height;
}
Element_pos Geometry::trace_to_render_x(Element_pos e){
return e * coeff_trace_render_x() +
_default_entity_x_translate - _x_state_translate;
}
Element_pos Geometry::trace_to_render_y(Element_pos e){
return e *coeff_trace_render_y() +
_ruler_y + _ruler_height - _y_state_translate;
}
Element_pos Geometry::coeff_trace_render_x(){
return ((_render_width-_default_entity_x_translate)*_x_state_scale) / (Info::Entity::x_max - Info::Entity::x_min);
}
Element_pos Geometry::coeff_trace_render_y(){
return ((_render_height-_ruler_height)*_y_state_scale) / (_container_y_max-_container_y_min);
}
/*
** 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 Geometry.hpp
*/
#ifndef GEOMETRY_HPP
#define GEOMETRY_HPP
//class Element_pos;
#include "common/common.hpp"
/*!
* \brief This class provide some tools to manage the window and render area geometry.
*/
class Geometry
{
protected:
/*!
* \brief The last x position of the point (for counter).
*/
Element_pos _counter_last_x;
/*!
* \brief The last y position of the point (for counter).
*/
Element_pos _counter_last_y;
/*!
* \brief The opengl render area width in pixels.
*/
Element_pos _screen_width;
/*!
* \brief The opengl render area height in pixels.
*/
Element_pos _screen_height;
/*!
* \brief The opengl visibled scene width in the OpenGL units.
*/
Element_pos _render_width;
/*!
* \brief The opengl visibled scene height in the OpenGL units.
*/
Element_pos _render_height;
/*!
* \brief The width of container area draw.
*/
Element_pos _container_x_max;
/*!
* \brief The height of container area draw.
*/
Element_pos _container_y_max;
/*!
* \brief The x base of container area draw.
*/
Element_pos _container_x_min;
/*!
* \brief The y base of container area draw.
*/
Element_pos _container_y_min;
/*!
* \brief The width of state area draw.
*/
//Element_pos _state_x_max;
/*!
* \brief The height of state area draw.
*/
Element_pos _state_y_max;
/*!
* \brief The x base of state area draw.
*/
// Element_pos _state_x_min;
/*!
* \brief The y base of state area draw.
*/
Element_pos _state_y_min;
/*!
* \brief z position for the ruler.
*/
Element_pos _z_ruler;
/*!
* \brief z position for objects over the ruler.
*/
Element_pos _z_ruler_over;
/*!
* \brief z position for objects under the ruler.
*/
Element_pos _z_ruler_under;
/*!
* \brief z position for containers.
*/
Element_pos _z_container;
/*!
* \brief z position for objects under containers.
*/
Element_pos _z_container_under;
/*!
* z position for states.
*/
Element_pos _z_state;
/*!
* z position for events.
*/
Element_pos _z_event;
/*!
* z position for arrows.
*/
Element_pos _z_arrow;
/*!
* z position for counters.
*/
Element_pos _z_counter;
/*!
* Default offset of entities drawing.
*/
Element_pos _default_entity_x_translate;
/*!
* Distance between two ruler measures.
*/
Element_pos _ruler_distance;
/*!
* Height of the ruler.
*/
Element_pos _ruler_height;
/*!
* Highness of the ruler.
*/
Element_pos _ruler_y;
/*!
* Width of the ruler.
*/
Element_pos _ruler_width;
/*!
* \brief The percentage taken by container display in the render area.
*/
Element_pos _x_scale_container_state;
/*!
* \brief the x scale of state drawing.
*/
Element_pos _x_state_scale;
/*!
* \brief the y scale of state drawing.
*/