Commit fb0f9ff2 authored by Olivier Lagrasse's avatar Olivier Lagrasse
Browse files

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.
/*!
*\file Render_area.hpp
*/
#ifndef RENDER_AREA_HPP
#define RENDER_AREA_HPP
class Render_area;
class Interface_console;
class Render_opengl;
/* Global informations */
#include "info/info.hpp"
#include "resource.hpp"
/*!
* \brief Structure used to store event information.
*/
struct Event_{
/*!
* \brief time of an event
*/
Element_pos time;
/*!
* \brief height of an event
*/
Element_pos height;
/*!
* \brief height of the container
*/
Element_pos container_height;
};
/*!
* \brief Structure used to store arrow information.
*/
struct Arrow_{
/*!
* \brief time when the arrow starts.
*/
Element_pos start_time;
/*!
* \brief time when the arrow ends.
*/
Element_pos end_time;
/*!
* \brief The start height of the arrow.
*/
Element_pos start_height;
/*!
* \brief The end height of the arrow.
*/
Element_pos end_height;
};
/*!
* \brief Structure used to store selection coordinate information.
*/
struct Selection_{
/*!
* \brief x scale.
*/
Element_pos x_scale;
/*!
* \brief y scale.
*/
Element_pos y_scale;
/*!
* \brief x translation.
*/
Element_pos x_translate;
/*!
* \brief y translation.
*/
Element_pos y_translate;
};
/*!
* \brief This class redefined the OpenGL widget - QGLWidget - to display the trace.
*/
class Render_area : public QGLWidget/*, public Render*/
{
Q_OBJECT
protected:
/*!
* \brief Contains container text coordinates.
*/
std::list<Element_pos> _text_pos;
/*!
* \brief Contains container strings.
*/
std::list<std::string> _text_value;
/*!
* \brief Contains arrow informations.
*/
std::vector<Arrow_> _arrows;
/*!
* \brief Contains event informations.
*/
std::vector<Event_> _events;
/*!
* \brief Contains the previous selection coordinates.
*/
std::stack<Selection_> _previous_selection;
/*!
* \brief Contains the OpenGL render instance.
*/
Render_opengl* _render_instance;
/*!
* \brief Contains the parent instance.
*/
Interface_console* _core;
/***********************************
*
* Render area state attributes.
*
**********************************/
/*!
* \brief State when there is no file opened.
*/
static const int DRAWING_STATE_WAITING;
/*!
* \brief State when the application is drawing traces.
*/
static const int DRAWING_STATE_DRAWING;
/*!
* \brief Contains the kind of state for the render area (drawing, waiting, etc.).
*/
int _state;
/*!
* \brief Indicated if mouse is pressed or not.
*/
bool _mouse_pressed;
/*!
* \brief Used to store the mouse last x position.
*/
int _mouse_x;
/*!
* \brief Used to store the mouse last y position.
*/
int _mouse_y;
/*!
* \brief Used to store the mouse current x position.
*/
int _new_mouse_x;
/*!
* \brief Used to store the mouse current y position.
*/
int _new_mouse_y;
/*!
* \brief Indicate if the scroll was asked by key capture in openGL render area.
*/
bool _key_scrolling;
/*!
* \brief Alpha color of the selection rectangle.
*/
double _selection_rectangle_alpha;
/*!
* \brief Define the minimum width and height to draw the selection rectangle (avoid bas manipulations).
*/
Element_pos _minimum_distance_for_selection;
/*!
* \brief Define the scrolling factor when CTRL key is pressed.
*/
static const int _ctrl_scroll_factor;
/*!
* \brief Define the scrolling factor when CTRL key is pressed.
*/
static const int _ctrl_zoom_factor;
/***********************************
*
* 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;
/*!
* \brief Timer to animate the wait.
*/
QTimer* _wait_timer;
/***********************************
*
* The trace drawing.
*
**********************************/