Commit fb0f9ff2 authored by Olivier Lagrasse's avatar Olivier Lagrasse

Divide the render area in sub classes

parent ebf84712
......@@ -4,6 +4,33 @@
#include "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;
int Info::Container::x_min = 0;
int Info::Container::x_max = 0;
......
......@@ -7,6 +7,7 @@
#include "../main_resource.hpp"
class Interface_console;
/*!
* \brief Class used to store informations.
......@@ -31,6 +32,145 @@ public:
virtual ~Info();
/*!
* \brief Sub structure to store core system informations.
*/
// struct Core{
// /*!
// * \brief Function pointer to the launch_action method of core system.
// */
// static void (Interface_console::* launch_action)(int, void*);
// /***********************************
// *
// * The command line parameter processing functions.
// *
// **********************************/
// /*!
// *\brief An error state.
// */
// static const int _STATE_UNKNOWN;
// /*!
// *\brief A state which corresponds to display a help text.
// */
// static const int _STATE_DISPLAY_HELP;
// /*!
// *\brief A state which corresponds to display the trace within a time.
// */
// static const int _STATE_IN_AN_INTERVAL; // 2^0
// /*!
// *\brief A state which corresponds to display a the ViTE window and opening a file.
// */
// static const int _STATE_OPEN_FILE; // 2^1
// /*!
// *\brief A state which corresponds to display the trace within a time.
// */
// static const int _STATE_OPEN_FILE_IN_AN_INTERVAL;
// /*!
// *\brief A state which corresponds to an export of file.
// */
// static const int _STATE_EXPORT_FILE; // 2^2
// /*!
// *\brief A state which corresponds to an export of file.
// */
// static const int _STATE_EXPORT_FILE_IN_INTERVAL;
// /*!
// *\brief A state which corresponds to release the OpenGL render area (display the wait screen).
// */
// static const int _STATE_RELEASE_RENDER_AREA;
// /*!
// *\brief A state which corresponds to change the render area translation.
// */
// static const int _STATE_RENDER_AREA_CHANGE_TRANSLATE;
// /*!
// *\brief A state which corresponds to change the render area scale.
// */
// static const int _STATE_RENDER_AREA_CHANGE_SCALE;
// /*!
// *\brief A state which corresponds to change the render area container/state scale.
// */
// static const int _STATE_RENDER_AREA_CHANGE_CONTAINER_SCALE;
// /*!
// *\brief Informs that a trace has to be parsed and displayed in the main window.
// */
// static const int _DRAW_OPENGL;
// /*!
// *\brief Informs that a trace has to be exported in svg format.
// */
// static const int _DRAW_SVG;
// /*!
// *\brief A state which corresponds to display the ViTE window.
// */
// static const int _STATE_LAUNCH_GRAPHICAL_INTERFACE;
// /*!
// *\brief A state which corresponds to replace the render area scale.
// */
// static const int _STATE_RENDER_AREA_REPLACE_SCALE;
// /*!
// *\brief A state which corresponds to replace the render area translate.
// */
// static const int _STATE_RENDER_AREA_REPLACE_TRANSLATE;
// /*!
// *\brief A state which corresponds to replace the render area translate.
// */
// static const int _STATE_RENDER_AREA_REPLACE_TRANSLATE_Y;
// /*!
// *\brief A state which corresponds to the registered render area translate.
// */
// static const int _STATE_RENDER_AREA_REGISTERED_TRANSLATE;
// /*!
// *\brief A state which corresponds to change the render area scale.
// */
// static const int _STATE_RENDER_AREA_CHANGE_SCALE_Y;
// /*!
// *\brief A state which corresponds to set new scroll bar length.
// */
// static const int _STATE_AJUST_SCROLL_BARS;
// /*!
// *\brief A state which corresponds to a scroll modification of the render area.
// */
// static const int _STATE_REFRESH_SCROLL_BARS;
// /*!
// *\brief Allow render area to change the graphical interface zoom box value.
// */
// static const int _STATE_ZOOM_BOX_VALUE;
// /*!
// *\brief Display information about a selected entity.
// */
// static const int _STATE_RENDER_DISPLAY_INFORMATION;
// /*!
// *\brief Update the render area.
// */
// static const int _STATE_RENDER_UPDATE;
// };
/*!
* \brief Sub structure to store container informations.
*/
......
......@@ -466,7 +466,7 @@ void Interface_console::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(this, _main_window);
_render_opengl = new Render_opengl_dl(this, _main_window);
_main_window->bind_render_area((QGLWidget*)_render_opengl);
_is_window_displayed = true;
......@@ -476,7 +476,7 @@ void Interface_console::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(this, _main_window);
_render_opengl = new Render_opengl_dl(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 */
......@@ -602,7 +602,7 @@ void Interface_console::launch_action(int state, void* arg) {
break;
case _STATE_RENDER_UPDATE:
_render_opengl->update();
_render_opengl->updateGL();
break;
default:/* like _STATE_UNKNOWN */
......
......@@ -12,11 +12,16 @@ class Interface_console;
#include "interface.hpp"
#include "interface_graphic.hpp"
#include "../render/render_opengl.hpp"
/*
* render_opengl.hpp includes render_area.hpp.
* So do not include it twice.
*/
//#ifndef RENDER_AREA_HPP
#include "../render/Render_opengl_dl.hpp"
//#endif
#include "../render/render_svg.hpp"
#include "../trace/Trace.hpp"
#include "../trace/DrawTrace.hpp"
#include "../parser/ParserPaje.hpp"
......
/*!
*\file Render.hpp
*/
#ifndef RENDER_HPP
#define RENDER_HPP
class Render;
#include "resource.hpp"
/*!
* \brief This class provides an interface for render classes like OpenGL or SVG.
*/
class Render
{
public:
/*!
* \brief Proceeds with the initialization of draw functions.
*/
virtual void start_draw() = 0;
/*!
* \brief Proceeds with the initialization of container draw functions.
*/
virtual void start_draw_containers() = 0;
/*!
* \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
*/
virtual void draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h) = 0;
/*!
* \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.
*/
virtual void draw_container_text(const Element_pos x, const Element_pos y, const std::string value) = 0;
/*!
* \brief Called when all container draws are finished.
*/
virtual void end_draw_containers() = 0;
/*!
* \brief Proceeds with the initialization of state draw functions.
*/
virtual void start_draw_states() = 0;
/*!
* \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.
*/
virtual 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) = 0;
/*!
* \brief Called when all state draws are finished.
*/
virtual void end_draw_states() = 0;
/*!
* \brief Proceeds with the initialization of arrow draw functions.
*/
virtual void start_draw_arrows() = 0;
/*!
* \brief Draw an arrow.
* \param start_time the beginning time of the arrow.
* \param end_time the ending time of the arrow.
* \param start_height vertical position of the begining time of the arrow.
* \param end_height vertical position of the ending time of the arrow.
*/
virtual void draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height) = 0;
/*!
* \brief Called when all arrow draws are finished.
*/
virtual void end_draw_arrows() = 0;
/*!
* \brief Draw an event.
* \param time time when the event occurs.
* \param height vertical position of the event.
* \param container_height information to draw event. It corresponds to the container height when they are drawn horizontally.
*/
virtual void draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height) = 0;
/*!
* \brief Proceeds with the initialization of counter draw functions.
*/
virtual void start_draw_counter() = 0;
/*!
* \brief Draw a point of the counter.
* \param x x position of the point.
* \param y y position of the point.
*
* Each time counter is increased, this function is called with the coordinates of the new point.
*/
virtual void draw_counter(const Element_pos x, const Element_pos y) = 0;
/*!
* \brief Called when all counter draws are finished.
*/
virtual void end_draw_counter() = 0;
/*!
* \brief Called when all draws are finished.
*/
virtual void end_draw() = 0;
/*!
* \brief Set Statistics and Informations about input trace
*/
virtual void set_total_width(Element_pos w) = 0;
/*!
* \brief Set Statistics and Informations about input trace
*/
virtual void set_total_time(Times t) = 0;
/*!
* \brief display the scale
*/
virtual void display_time_scale() = 0;
};
#endif
This diff is collapsed.
This diff is collapsed.
/*!
*\file Render_opengl.cpp
*/
#include "Render_area.hpp"
#include "Render_opengl.hpp"
#include "../interface/interface_console.hpp"
using namespace std;
#define message *Message::get_instance() << "(" << __FILE__ << " l." << __LINE__ << "): "
/***********************************
*
*
*
* Constructor and destructor.
*
*
*
**********************************/
Render_opengl::Render_opengl(Render_opengl* render, Interface_console* core, QWidget *parent)
: Render_area(render, core, parent){
setAutoFillBackground(false);
}
Render_opengl::~Render_opengl(){
}
/***********************************
*
*
*
* Default QGLWidget functions.
*
*
*
**********************************/
void Render_opengl::initializeGL() {
glClearColor(0.5f, 0.5f, 0.55f, 1.0f);
glEnable(GL_DEPTH_TEST);
glClearStencil(0);
_wait_list = draw_wait();
_list_ruler = draw_ruler();
}
void Render_opengl::resizeGL(int width, int height) {
glViewport(0, 0, width, height);
/* update informations about widget size */
_screen_width = width;
_screen_height = height;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(DRAWING_STATE_WAITING == _state){// A wait is drawn
glOrtho(-50, 50, -50, 50, 0, 1000);
}else if (DRAWING_STATE_DRAWING == _state){// A trace is drawn
glOrtho(0, _render_width, 0, _render_height, 0, -1000);
}else{
message << "Undefined value for the drawing state attribute - Render area" << Message::ende;
}
glMatrixMode(GL_MODELVIEW);
}
void Render_opengl::paintGL(){
resizeGL(Render_opengl::QGLWidget::width(), Render_opengl::QGLWidget::height());
Render_opengl::QGLWidget::setFocus(Qt::ActiveWindowFocusReason);/* give the focus to the render area for mouse and keyboard events */
glClearDepth(1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
if(DRAWING_STATE_WAITING == _state){/* A wait is drawn */
/* turn around y axis */
_wait_angle+=0.1f;
if (_wait_angle>=360) _wait_angle=0.0f;
glPushMatrix();
glScalef(15, 15, 0);
glRotatef(-_wait_angle,0, 1, 0);
glRotatef(_wait_angle_y, 1, 0, 0);
glCallList(_wait_list);
glPopMatrix();
}else if (DRAWING_STATE_DRAWING == _state){/* A trace is drawn */
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix();
{
static float a = 0;
a ++;
glTranslated(0.0, _render_height, 100.0);
glRotated(180.0, 1.0, 0.0, 0.0);
/* Translate containers and entities of the ruler height */
glTranslated(0.0, _ruler_height, 0.0);
display_container(0, 0);
display_state(0, 0, 0, 0, 0, 0);
if (false == Info::Render::_no_arrows)/* display arrows */
display_arrow(0, 0, 0, 0, 0, 0);
if (false == Info::Render::_no_events)/* display events */
display_event(0, 0, 0, 0);
display_counter(0, 0, 0, 0);
/* Untranslate ruler */
glTranslated(0.0, -_ruler_height, 0.0);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
call_ruler();
glDisable(GL_BLEND);
}
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix();
{
// glTranslated(0.0, _container_y_max- 3*_ruler_height, 100.0);/* not accurate */
glTranslated(0.0, 0.0, 100.0);/* not accurate */
if (_mouse_pressed){
glTranslated(0.0, 0.0, _z_container_under);
Element_pos old_x, old_y, new_x, new_y;
old_x = _mouse_x*(_render_width/_screen_width);
old_y = _render_height - _mouse_y*(_render_height/_screen_height);
new_x = _new_mouse_x*(_render_width/_screen_width);
new_y = _render_height - _new_mouse_y*(_render_height/_screen_height);
#ifdef DEBUG_MODE_RENDER_OPENGL
cerr << __FILE__ << " l." << __LINE__ << ":" << endl;
cerr << "Selection rectangle position: (" << old_x << ", " << old_y << ") - (" << new_x << ", " << new_y << ")" << endl;
#endif
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
/* Square for selection */
glBegin(GL_QUADS);
{
glColor4d(0.9, 1.0, 0.9, _selection_rectangle_alpha);glVertex2d(old_x, old_y);
glColor4d(0.9, 0.9, 0.9, _selection_rectangle_alpha);glVertex2d(old_x, new_y);
glColor4d(0.9, 0.9, 0.9, _selection_rectangle_alpha);glVertex2d(new_x, new_y);
glColor4d(0.9, 0.9, 0.9, _selection_rectangle_alpha);glVertex2d(new_x, old_y);
}
glEnd();
glDisable(GL_BLEND);
}/* end if (true==_mouse_pressed) */
}
glPopMatrix();
}else{
message << "Undefined value for the drawing state attribute - Render area" << Message::ende;
}
glFlush();
/* Check the errors */
GLenum glerror;
glerror = glGetError();
if(glerror != GL_NO_ERROR)
message << "Render area : the following OpengGL error occured: " << (char *)gluErrorString(glerror) << Message::endw;
}
This diff is collapsed.
This diff is collapsed.
......@@ -131,7 +131,7 @@ public:
inline void Render_stats_opengl::start_draw(){
_text_pos.clear();
_text_value.clear();
makeCurrent();
// makeCurrent();
_rect_list = glGenLists(10);
glNewList(_rect_list, GL_COMPILE);
}
......@@ -210,7 +210,7 @@ inline void Render_stats_opengl::draw_rect(const Element_pos x, const Element_po
inline void Render_stats_opengl::end_draw(){
glEndList();
paintGL();
doneCurrent();
// doneCurrent();
}
#endif
......@@ -41,7 +41,9 @@ HEADERS += message/Message.hpp \
interface/help.hpp \
# Render headers
render/render.hpp \
render/render_opengl.hpp \
render/Render_area.hpp \
render/Render_opengl_dl.hpp \
render/Render_opengl.hpp \
render/render_svg.hpp \
render/render_stats.hpp \
render/render_stats_opengl.hpp \
......@@ -103,7 +105,8 @@ SOURCES += message/Message.cpp \
interface/parsing_thread.cpp \
interface/help.cpp \
# Render code files
render/render_opengl.cpp \
render/Render_area.cpp \
render/Render_opengl.cpp \
render/render_svg.cpp \
render/render_stats_opengl.cpp \
# render/vbo.cpp \
......
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