Commit e60d1865 authored by Olivier Lagrasse's avatar Olivier Lagrasse

separation des render (opengl et svg) de l'interface - renommage de render_area en render_opengl

parent 85d5dd82
......@@ -92,7 +92,7 @@ Interface_console::~Interface_console(){
**********************************/
bool Interface_console::draw_trace(const string & filename){//, Render_area* render_area){
bool Interface_console::draw_trace(const string & filename){//, Render_opengl* render_area){
if (_render_opengl==NULL){
message << "Error, no render area bound to the main window" << Message::ende;
......@@ -100,7 +100,7 @@ bool Interface_console::draw_trace(const string & filename){//, Render_area* ren
}
Trace trace;
ParserPaje parser;
DrawTrace<Render_area> drawing;
DrawTrace<Render_opengl> drawing;
QApplication::setOverrideCursor(Qt::WaitCursor);
try{
......@@ -278,7 +278,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_area(_main_window);
_render_opengl = new Render_opengl(_main_window);
_main_window->bind_render_area((QGLWidget*)_render_opengl);
break;
......@@ -287,7 +287,7 @@ void Interface_console::launch_action(int state, void* arg){
information(string("Opening the file: ")+string(_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_area(_main_window);
_render_opengl = new Render_opengl(_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 */
......
......@@ -12,8 +12,8 @@ class Interface_console;
#include <QApplication>
#include "interface.hpp"
#include "interface_graphic.hpp"
#include "render_area.hpp"
#include "render_svg.hpp"
#include "../render/render_opengl.hpp"
#include "../render/render_svg.hpp"
#include "../trace/Trace.hpp"
#include "../trace/DrawTrace.hpp"
......@@ -134,7 +134,7 @@ protected:
/*!
* \brief Contains the OpenGL render area instance.
*/
Render_area* _render_opengl;
Render_opengl* _render_opengl;
/*!
* \brief Contains the main Qt application instance.
......@@ -232,7 +232,7 @@ protected:
*
* \return true if no errors occurs.
*/
bool draw_trace(const std::string & filename);//, Render_area* render_area);
bool draw_trace(const std::string & filename);//, Render_opengl* render_area);
/*!
......
/*!
*\file render_area.cpp
*\file render_opengl.cpp
*/
#include "render_area.hpp"
#include "render_opengl.hpp"
......@@ -22,7 +22,7 @@ using namespace std;
*
**********************************/
Render_area::Render_area(QWidget *parent)
Render_opengl::Render_opengl(QWidget *parent)
: QGLWidget(parent){
_state = DRAWING_STATE_WAINTING;/* At the beginning, no trace is drawing */
......@@ -104,7 +104,7 @@ Render_area::Render_area(QWidget *parent)
}
Render_area::~Render_area(){
Render_opengl::~Render_opengl(){
if (glIsList(_wait_list)==GL_TRUE)
glDeleteLists(_wait_list, 1);
......@@ -128,7 +128,7 @@ Render_area::~Render_area(){
**********************************/
void Render_area::initializeGL(){
void Render_opengl::initializeGL(){
glClearColor(0.5f, 0.5f, 0.55f, 1.0f);
glEnable(GL_DEPTH_TEST);
......@@ -138,7 +138,7 @@ void Render_area::initializeGL(){
_wait_list = draw_wait();
}
void Render_area::resizeGL(int width, int height){
void Render_opengl::resizeGL(int width, int height){
glViewport(0, 0, width, height);
......@@ -169,7 +169,7 @@ void Render_area::resizeGL(int width, int height){
}
void Render_area::paintGL(){
void Render_opengl::paintGL(){
list<Element_pos>::iterator it_pos;
list<string>::iterator it_txt;
......@@ -246,7 +246,7 @@ void Render_area::paintGL(){
#ifdef DEBUG_MODE_RENDER_AREA
#ifdef DEBUG_MODE_RENDER_OPENGL
cerr << __FILE__ << " l." << __LINE__ << ":" << endl;
cerr << "Default container position (before translation and scaling) : (x_max = " << _container_x_max << ", y_max = " << _container_y_max << ")" << endl << endl;
......@@ -284,7 +284,7 @@ void Render_area::paintGL(){
glColor3d(1, 1, 1);
glRasterPos2f(buf_x,buf_y);
#ifdef DEBUG_MODE_RENDER_AREA
#ifdef DEBUG_MODE_RENDER_OPENGL
cerr << __FILE__ << " l." << __LINE__ << ":" << endl;
cerr << "Container texts position: (x = " << buf_x << ", y = " << buf_y << ") -> '" << buf_txt << "'" << endl << endl;
......@@ -354,7 +354,7 @@ void Render_area::paintGL(){
void Render_area::mousePressEvent(QMouseEvent * event){
void Render_opengl::mousePressEvent(QMouseEvent * event){
_mouse_x = event->x();
_mouse_y = event->y();
_mouse_pressed = true;
......@@ -363,7 +363,7 @@ void Render_area::mousePressEvent(QMouseEvent * event){
}
void Render_area::mouseMoveEvent(QMouseEvent * event){
void Render_opengl::mouseMoveEvent(QMouseEvent * event){
if (false==_mouse_pressed) return;
......@@ -380,26 +380,26 @@ void Render_area::mouseMoveEvent(QMouseEvent * event){
}
void Render_area::mouseReleaseEvent(QMouseEvent * event){
void Render_opengl::mouseReleaseEvent(QMouseEvent * event){
_mouse_pressed = false;
QApplication::restoreOverrideCursor();
}
void Render_area::change_scale(int scale){
void Render_opengl::change_scale(int scale){
_state_scale = 0.1*scale;
updateGL();
}
void Render_area::change_translate(int translate){
void Render_opengl::change_translate(int translate){
_state_translate = translate;
updateGL();
}
void Render_area::change_scale_container_state(int view_size){
void Render_opengl::change_scale_container_state(int view_size){
_x_scale_container_state = 0.01 * view_size;
updateGL();
......@@ -419,7 +419,7 @@ void Render_area::change_scale_container_state(int view_size){
bool Render_area::build(){
bool Render_opengl::build(){
if (glIsList(_wait_list)==GL_TRUE){/* if the list exists */
glDeleteLists(_wait_list, 1);
......@@ -445,7 +445,7 @@ bool Render_area::build(){
bool Render_area::unbuild(){
bool Render_opengl::unbuild(){
/***********************
*
......@@ -563,7 +563,7 @@ bool Render_area::unbuild(){
GLuint Render_area::draw_wait() {
GLuint Render_opengl::draw_wait() {
GLuint object;
GLuint texture;
......@@ -619,7 +619,7 @@ GLuint Render_area::draw_wait() {
void Render_area::create_rule(){
void Render_opengl::create_rule(){
ostringstream buf_txt;
Element_pos rule_width;
......@@ -739,6 +739,6 @@ void Render_area::create_rule(){
}
void Render_area::set_total_width(Element_pos w){}
void Render_area::set_total_time(Times t){}
void Render_area::display_time_scale(){}
void Render_opengl::set_total_width(Element_pos w){}
void Render_opengl::set_total_time(Times t){}
void Render_opengl::display_time_scale(){}
/*!
*\file render_area.hpp
*\file render_opengl.hpp
*/
#ifndef RENDER_AREA_HPP
#define RENDER_AREA_HPP
#ifndef RENDER_OPENGL_HPP
#define RENDER_OPENGL_HPP
class Render_area;
class Render_opengl;
#include <QtGui>
......@@ -61,7 +61,7 @@ struct Arrow_{
/*!
* \brief This class redefined the OpenGL widget - QGLWidget - to display the trace.
*/
class Render_area : public QGLWidget, public Render
class Render_opengl : public QGLWidget, public Render
{
Q_OBJECT
......@@ -410,12 +410,12 @@ class Render_area : public QGLWidget, public Render
/*!
* \brief The default constructor
*/
Render_area(QWidget *parent);
Render_opengl(QWidget *parent);
/*!
* \brief The destructor
*/
virtual ~Render_area();
virtual ~Render_opengl();
/***********************************
......@@ -607,7 +607,7 @@ class Render_area : public QGLWidget, public Render
**********************************/
inline void Render_area::start_draw(){
inline void Render_opengl::start_draw(){
/* clear lists to store container texts */
_text_pos.clear();
_text_value.clear();
......@@ -620,7 +620,7 @@ inline void Render_area::start_draw(){
}
inline void Render_area::start_draw_containers(){
inline void Render_opengl::start_draw_containers(){
_list_containers = glGenLists(1);/* create the list */
if (_list_containers==0){
......@@ -633,7 +633,7 @@ inline void Render_area::start_draw_containers(){
}
inline void Render_area::draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h) {
inline void Render_opengl::draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h) {
float j=0.6;
......@@ -671,7 +671,7 @@ inline void Render_area::draw_container(const Element_pos x, const Element_pos y
}
inline void Render_area::draw_container_text(const Element_pos x, const Element_pos y, const std::string value){
inline void Render_opengl::draw_container_text(const Element_pos x, const Element_pos y, const std::string value){
_text_pos.push_back(x);
_text_pos.push_back(y);
......@@ -681,14 +681,14 @@ inline void Render_area::draw_container_text(const Element_pos x, const Element_
inline void Render_area::end_draw_containers(){
inline void Render_opengl::end_draw_containers(){
glEndList();/* close the list */
}
inline void Render_area::start_draw_states(){
inline void Render_opengl::start_draw_states(){
_list_states = glGenLists(1);/* create the list */
if (_list_states==0){
......@@ -700,7 +700,7 @@ inline void Render_area::start_draw_states(){
}
inline void Render_area::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){
inline void Render_opengl::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){
......@@ -739,12 +739,12 @@ inline void Render_area::draw_state(const Element_pos start, const Element_pos e
}
inline void Render_area::end_draw_states(){
inline void Render_opengl::end_draw_states(){
glEndList();/* close the list */
}
inline void Render_area::draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height){
inline void Render_opengl::draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height){
Arrow_ buf;
......@@ -758,7 +758,7 @@ inline void Render_area::draw_arrow(const Element_pos start_time, const Element_
inline void Render_area::draw_stored_arrows(std::vector<Arrow_> &arrows){
inline void Render_opengl::draw_stored_arrows(std::vector<Arrow_> &arrows){
Element_pos start_time, end_time, start_height, end_height;
......@@ -826,7 +826,7 @@ inline void Render_area::draw_stored_arrows(std::vector<Arrow_> &arrows){
}
inline void Render_area::draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height){
inline void Render_opengl::draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height){
Event_ buf;
......@@ -838,7 +838,7 @@ inline void Render_area::draw_event(const Element_pos time, const Element_pos he
}
inline void Render_area::draw_stored_events(std::vector<Event_> &events){
inline void Render_opengl::draw_stored_events(std::vector<Event_> &events){
Element_pos time, height, container_height;
......@@ -904,7 +904,7 @@ inline void Render_area::draw_stored_events(std::vector<Event_> &events){
* Counter
*******************/
inline void Render_area::start_draw_counter(){
inline void Render_opengl::start_draw_counter(){
_list_counters = glGenLists(1);/* create the list */
if (_list_counters==0){
......@@ -917,7 +917,7 @@ inline void Render_area::start_draw_counter(){
}
inline void Render_area::draw_counter(const Element_pos x, const Element_pos y){
inline void Render_opengl::draw_counter(const Element_pos x, const Element_pos y){
if (x <= 0.0 ){
if (_line_already_begun==true){/* it is not the first call */
......@@ -942,7 +942,7 @@ inline void Render_area::draw_counter(const Element_pos x, const Element_pos y){
}
inline void Render_area::end_draw_counter(){
inline void Render_opengl::end_draw_counter(){
if ( _line_already_begun == true){/* if a line was previously opened */
glEnd();/* suppose that line is not ended */
......@@ -953,7 +953,7 @@ inline void Render_area::end_draw_counter(){
inline void Render_area::end_draw(){
inline void Render_opengl::end_draw(){
}
......
/*!
*\file render/resource.hpp
*\brief This file gives some common header files for the render classes.
*/
#ifndef RESOURCE_HPP
#define RESOURCE_HPP
#include "../main_resource.hpp"
#include <cmath>
#include <stack>
#include <list>
/* For OpenGL text rendering */
#include <GL/glut.h>
/*!
* \brief PI with a precision of 8.
*/
#define PI 3.14159265
/* Now, two checkers are defined (the first for integer return value, the other
for pointer return value). Their body can be empty to enhance program speed.
To pass multi arguments for m, use "<<" between each arguments.
*/
/*!
* \brief Checks if a function return -1 as a value.
*
* This macro is used with C functions to check them if an error occurs. Thus, it display the file, the line and some informations (with m variable) of the error than exit the program.
*/
#define CKF(f, m) if((f)==-1) { \
cerr << "File " << __FILE__ <<" - line : " << __LINE__ <<endl; \
cerr << m <<endl; \
exit(EXIT_FAILURE); \
}
/*!
* \brief Checks if a function return NULL as a value.
*
* This macro is used with C functions to check them if an error occurs. Thus, it display the file, the line and some informations (with m variable) of the error than exit the program.
*/
#define CKFP(f, m) if((f)==NULL) { \
cerr << "File " << __FILE__ <<" - line : " << __LINE__ <<endl; \
cerr << m <<endl; \
exit(EXIT_FAILURE); \
}
/* Define the unity of time */
typedef double Times;
#endif
......@@ -20,8 +20,9 @@ HEADERS += message/Message.hpp \
interface/interface.hpp \
interface/interface_console.hpp \
interface/interface_graphic.hpp \
interface/render_area.hpp \
interface/render_svg.hpp \
render/render.hpp \
render/render_opengl.hpp \
render/render_svg.hpp \
interface/resource.hpp \
parser/Definition.hpp \
parser/Line.hpp \
......@@ -60,8 +61,8 @@ SOURCES += message/Message.cpp \
main.cpp \
interface/interface_console.cpp \
interface/interface_graphic.cpp \
interface/render_area.cpp \
interface/render_svg.cpp \
render/render_opengl.cpp \
render/render_svg.cpp \
parser/Definition.cpp \
message/Errors.cpp \
parser/Line.cpp \
......
......@@ -9,7 +9,7 @@
#include "resource.hpp"
#include "../interface/render_area.hpp"
//#include "../render/render_opengl.hpp"
#include "../message/Message.hpp"
......
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