Commit 26ffe400 authored by Olivier Lagrasse's avatar Olivier Lagrasse

Render area independante + integration du gestionnaire de messages dans...

Render area independante + integration du gestionnaire de messages dans interface console et render area
parent 95284637
......@@ -7,6 +7,7 @@
#include "interface_console.hpp"
using namespace std;
using namespace message_ns;
/***********************************
......@@ -21,9 +22,15 @@ using namespace std;
Interface_console::Interface_console(int argc, char ** argv){
int state;
bool useGUI;/* if window interface can be displayed */
Message::set_interface_instance(this);/* define which interface will receive messages */
useGUI = true;
app = new QApplication(argc, argv, useGUI);/* create the Qt application */
......@@ -211,13 +218,16 @@ void Interface_console::launch_action(int state){
break;
case _STATE_LAUNCH_GRAPHICAL_INTERFACE :
_main_window = new Interface_graphic(this);/* launch the window interface */
Message::set_interface_instance(_main_window);/* define which interface will receive messages */
break;
case _STATE_OPEN_FILE:
information(string("Opening the file: ")+string(_file_opened));
_main_window = new Interface_graphic(this, _file_opened);/* launch the window interface and open a file */
Message::set_interface_instance(_main_window);/* define which interface will receive messages */
break;
......
......@@ -9,6 +9,7 @@
using namespace std;
using namespace message_ns;
/***********************************
......@@ -24,13 +25,6 @@ using namespace std;
Render_area::Render_area(QWidget *parent)
: QGLWidget(parent){
_parent = (Interface_graphic*)parent;
if (_parent==NULL){
std::cerr << "The render area parent must be passed by arguments.";
exit(EXIT_FAILURE);
}
_state = DRAWING_STATE_WAINTING;/* At the beginning, no trace is drawing */
/* init the wait animation */
......@@ -42,8 +36,6 @@ Render_area::Render_area(QWidget *parent)
/* init the trace drawing */
_drawing_list=0;
_container_x_max = 0;
_container_y_max = 0;
......@@ -59,11 +51,9 @@ Render_area::Render_area(QWidget *parent)
_z_arrow = 1;/* closer to camera than containers or states */
setAutoFillBackground(false);
}
Render_area::~Render_area(){
if (glIsList(_wait_list)==GL_TRUE)
glDeleteLists(_wait_list, 1);
......@@ -97,13 +87,10 @@ void Render_area::initializeGL(){
glClearStencil(0);
_wait_list = draw_wait();
}
void Render_area::resizeGL(int width, int height){
// int side = qMin(width, height);
// glViewport((width - side) / 2, (height - side) / 2, side, side);
glViewport(0, 0, width, height);
......@@ -120,7 +107,7 @@ void Render_area::resizeGL(int width, int height){
glOrtho(0, 100, 0, 100, 0, 1000);
break;
default:
_parent->error("Undefined value for the drawing state attribute - Render area");
message << "Undefined value for the drawing state attribute - Render area" << ende;
}
......@@ -168,7 +155,7 @@ void Render_area::paintGL(){
case DRAWING_STATE_DRAWING:/* A trace is drawn */
if (glIsList(_list_states)==GL_FALSE)
_parent->error("ERROR LIST not exist for states.");
message << "ERROR LIST not exist for states." << ende;
glMatrixMode(GL_MODELVIEW);
......@@ -239,10 +226,7 @@ void Render_area::paintGL(){
/* Draw states */
glPushMatrix();
// glScalef(_state_scale/(_state_x_max-_state_x_min), 50.0f/_container_y_max, 0.0f);
glTranslated(20.0f-_state_translate, 40.0f, -2.0f);
glScalef(_state_scale, 50.0f/_container_y_max, 0.0f);
......@@ -255,7 +239,7 @@ void Render_area::paintGL(){
break;
default:
_parent->error("Undefined value for the drawing state attribute - Render area");
message << "Undefined value for the drawing state attribute - Render area" << ende;
}
......@@ -266,7 +250,7 @@ void Render_area::paintGL(){
GLenum glerror;
glerror = glGetError();
if( glerror != GL_NO_ERROR)
_parent->warning(std::string("Render area : the following OpengGL error occured: ") + std::string((char *)gluErrorString(glerror)));
message << "Render area : the following OpengGL error occured: " << (char *)gluErrorString(glerror) << endw;
}
......@@ -316,19 +300,6 @@ bool Render_area::build(){
if (_wait_timer->isActive()==true)/* if timer for the wait animation is running */
_wait_timer->stop();
if (glIsList(_drawing_list)==GL_FALSE)
_drawing_list = draw_trace();/* create the trace draw */
else{
_parent->warning("The trace was not released.");
return false;
}
/* if there is an error, do not display the trace an return immediatly */
if (glIsList(_drawing_list)==GL_FALSE){
_parent->warning("Cannot create the trace.");
return false;
}
_state = DRAWING_STATE_DRAWING;/* change the drawing state */
......@@ -344,30 +315,22 @@ bool Render_area::build(){
bool Render_area::unbuild(){
if (glIsList(_drawing_list)==GL_TRUE){/* if the list exists */
glDeleteLists(_drawing_list, 1);
_drawing_list = 0;
}
if (_wait_timer->isActive()==false)/* if timer for the wait animation is not running */
_wait_timer->start(_wait_spf);
if (glIsList(_wait_list)==GL_FALSE)
_wait_list = draw_wait();/* create the wait draw */
else{
_parent->warning("The wait draw was not released.");
message << "The wait draw was not released." << endw;
return false;
}
/* if there is an error, do not display the wait an return immediatly */
if (glIsList(_wait_list)==GL_FALSE) {
_parent->warning("Cannot create the wait draw.");
message << "Cannot create the wait draw." << endw;
return false;
}
if (_wait_timer->isActive()==false)/* if timer for the wait animation is running */
_wait_timer->start(_wait_spf);
_state = DRAWING_STATE_WAINTING;/* change the drawing state */
/* enable some OpenGL features*/
......@@ -404,7 +367,7 @@ GLuint Render_area::draw_wait() {
object = glGenLists(1);/* create the list */
if (object == 0){
_parent->warning("Error when creating list");
message << "Error when creating list" << endw;
}
glGenTextures(1, &texture);/* create the texture and link it with the list previously created */
......@@ -450,36 +413,3 @@ GLuint Render_area::draw_wait() {
return object;
}
/***********************************
*
*
*
* Drawing function for the trace.
*
*
*
**********************************/
GLuint Render_area::draw_trace(){//Trace trace)
// DrawTrace<Render_area> drawing;
// drawing.build(this, _trace);
GLuint object; /* Must be delete */
/* Must be delete */
object = glGenLists(2);/* create the list */
if (object==0){
_parent->warning("Error when creating list");
}
/* end Must be delete */
return object; /* Must be delete */
}
......@@ -13,7 +13,7 @@ typedef double Level;
#include <QtGui>
#include <QGLWidget>/* for the OpenGL Widget */
#include "interface_graphic.hpp"
//#include "interface_graphic.hpp"
#include "resource.hpp"
......@@ -46,7 +46,7 @@ class Render_area : public QGLWidget
/*!
* \brief Refers to the parent widget of the render area.
*/
Interface_graphic* _parent;
// Interface_graphic* _parent;
......@@ -188,20 +188,7 @@ class Render_area : public QGLWidget
/***********************************
* Trace Drawing functions and attributes.
**********************************/
/*!
* \brief Display the trace on the screen if there is a file opened.
* \return Asset value of the trace.
*/
GLuint draw_trace();
// inline Element_count number_of_children(const Container* c);
//inline Element_count return_last_visited_child(std::stack<Element_count> const &s);
/*!
* \brief Return the pos container of the list
*/
......@@ -302,9 +289,21 @@ class Render_area : public QGLWidget
};
/* inline function area */
/***********************************
*
*
*
* Drawing function for the trace.
*
*
*
**********************************/
inline void Render_area::start_draw(){
/* clear lists to store container texts */
......
......@@ -9,9 +9,9 @@
#define RESOURCE_HPP
#include <string>
#include <cstdlib> /* for macros EXIT_SUCCESS and EXIT_FAILURE */
#include <sstream> /* for message classes */
#include "../../main_resource.hpp"
#include <cmath>
#include <stack>
#include <list>
......@@ -44,11 +44,6 @@
}
typedef long Element_count ;
typedef double Element_pos;
typedef double Element_col;
#endif
......@@ -41,6 +41,12 @@ HEADERS += interface.hpp \
../../trace/src/values/Name.hpp \
../../trace/src/values/String.hpp \
../../trace/src/values/Value.hpp \
../../message/src/enderror.hpp \
../../message/src/endwarning.hpp \
../../message/src/endinformation.hpp \
../../message/src/message.hpp \
../../message/src/message_ns.hpp \
../../message/src/resource.hpp \
../../trace/src/DrawTrace.hpp
FORMS += info_window.ui main_window.ui maquette.ui
......@@ -68,6 +74,11 @@ render_area.cpp \
../../trace/src/values/Hex.cpp \
../../trace/src/values/Integer.cpp \
../../trace/src/values/Name.cpp \
../../message/src/enderror.cpp \
../../message/src/endwarning.cpp \
../../message/src/endinformation.cpp \
../../message/src/message.cpp \
../../message/src/message_ns.cpp \
../../trace/src/values/String.cpp
......
#############################################################################
# Makefile for building: test
# Generated by qmake (2.01a) (Qt 4.4.3) on: Tue Feb 24 14:12:02 2009
# Generated by qmake (2.01a) (Qt 4.4.3) on: Thu Feb 26 15:20:43 2009
# Project: test.pro
# Template: app
# Command: /usr/bin/qmake-qt4 -unix -o Makefile test.pro
......@@ -227,8 +227,11 @@ mocables: compiler_moc_header_make_all compiler_moc_source_make_all
compiler_moc_header_make_all: moc_render_area.cpp moc_interface_graphic.cpp
compiler_moc_header_clean:
-$(DEL_FILE) moc_render_area.cpp moc_interface_graphic.cpp
moc_render_area.cpp: ../src/resource.hpp \
../../main_resource.hpp \
moc_render_area.cpp: ../src/interface_graphic.hpp \
../src/interface.hpp \
../src/resource.hpp \
../src/interface_console.hpp \
../src/render_area.hpp \
../../trace/src/Trace.hpp \
../../trace/src/values/Value.hpp \
../../trace/src/values/Date.hpp \
......@@ -248,6 +251,7 @@ moc_render_area.cpp: ../src/resource.hpp \
../../trace/src/EntityList.hpp \
../../trace/src/DrawTrace.hpp \
../../trace/src/resource.hpp \
../../main_resource.hpp \
../../parser/src/ParserPaje.hpp \
../../parser/src/ParserDefinitionDecoder.hpp \
../../parser/src/Definition.hpp \
......@@ -257,15 +261,14 @@ moc_render_area.cpp: ../src/resource.hpp \
../../trace/src/values/Values.hpp \
../../parser/tests/stub/trace.hpp \
../../parser/src/Parser.hpp \
../src/interface.hpp \
../src/interface_console.hpp \
../src/interface_graphic.hpp \
../src/render_area.hpp \
../src/render_area.hpp
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) ../src/render_area.hpp -o moc_render_area.cpp
moc_interface_graphic.cpp: ../../trace/src/resource.hpp \
../../main_resource.hpp \
moc_interface_graphic.cpp: ../src/interface.hpp \
../src/resource.hpp \
../src/interface_console.hpp \
../src/interface_graphic.hpp \
../src/render_area.hpp \
../../trace/src/Trace.hpp \
../../trace/src/values/Value.hpp \
../../trace/src/values/Date.hpp \
......@@ -284,6 +287,8 @@ moc_interface_graphic.cpp: ../../trace/src/resource.hpp \
../../trace/src/EntityValue.hpp \
../../trace/src/EntityList.hpp \
../../trace/src/DrawTrace.hpp \
../../trace/src/resource.hpp \
../../main_resource.hpp \
../../parser/src/ParserPaje.hpp \
../../parser/src/ParserDefinitionDecoder.hpp \
../../parser/src/Definition.hpp \
......@@ -293,11 +298,6 @@ moc_interface_graphic.cpp: ../../trace/src/resource.hpp \
../../trace/src/values/Values.hpp \
../../parser/tests/stub/trace.hpp \
../../parser/src/Parser.hpp \
../src/interface.hpp \
../src/interface_console.hpp \
../src/interface_graphic.hpp \
../src/render_area.hpp \
../src/resource.hpp \
../src/interface_graphic.hpp
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) ../src/interface_graphic.hpp -o moc_interface_graphic.cpp
......@@ -323,8 +323,10 @@ compiler_clean: compiler_moc_header_clean
test_area.o: test_area.cpp test_area.hpp \
resource_test.hpp \
../src/render_area.hpp \
../src/interface_graphic.hpp \
../src/interface.hpp \
../src/resource.hpp \
../../main_resource.hpp \
../src/interface_console.hpp \
../../trace/src/Trace.hpp \
../../trace/src/values/Value.hpp \
../../trace/src/values/Date.hpp \
......@@ -344,6 +346,7 @@ test_area.o: test_area.cpp test_area.hpp \
../../trace/src/EntityList.hpp \
../../trace/src/DrawTrace.hpp \
../../trace/src/resource.hpp \
../../main_resource.hpp \
../../parser/src/ParserPaje.hpp \
../../parser/src/ParserDefinitionDecoder.hpp \
../../parser/src/Definition.hpp \
......@@ -352,15 +355,14 @@ test_area.o: test_area.cpp test_area.hpp \
../../parser/src/ParserEventDecoder.hpp \
../../trace/src/values/Values.hpp \
../../parser/tests/stub/trace.hpp \
../../parser/src/Parser.hpp \
../src/interface.hpp \
../src/interface_console.hpp \
../src/interface_graphic.hpp
../../parser/src/Parser.hpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o test_area.o test_area.cpp
render_area.o: ../src/render_area.cpp ../src/render_area.hpp \
../src/interface_graphic.hpp \
../src/interface.hpp \
../src/resource.hpp \
../../main_resource.hpp \
../src/interface_console.hpp \
../../trace/src/Trace.hpp \
../../trace/src/values/Value.hpp \
../../trace/src/values/Date.hpp \
......@@ -380,6 +382,7 @@ render_area.o: ../src/render_area.cpp ../src/render_area.hpp \
../../trace/src/EntityList.hpp \
../../trace/src/DrawTrace.hpp \
../../trace/src/resource.hpp \
../../main_resource.hpp \
../../parser/src/ParserPaje.hpp \
../../parser/src/ParserDefinitionDecoder.hpp \
../../parser/src/Definition.hpp \
......@@ -388,10 +391,7 @@ render_area.o: ../src/render_area.cpp ../src/render_area.hpp \
../../parser/src/ParserEventDecoder.hpp \
../../trace/src/values/Values.hpp \
../../parser/tests/stub/trace.hpp \
../../parser/src/Parser.hpp \
../src/interface.hpp \
../src/interface_console.hpp \
../src/interface_graphic.hpp
../../parser/src/Parser.hpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o render_area.o ../src/render_area.cpp
Trace.o: ../../trace/src/Trace.cpp ../../trace/src/Trace.hpp \
......@@ -599,8 +599,10 @@ ParserEventDecoder.o: ../../parser/src/ParserEventDecoder.cpp ../../parser/src/P
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o ParserEventDecoder.o ../../parser/src/ParserEventDecoder.cpp
interface_console.o: ../src/interface_console.cpp ../src/interface_console.hpp \
../../trace/src/resource.hpp \
../../main_resource.hpp \
../src/interface.hpp \
../src/resource.hpp \
../src/interface_graphic.hpp \
../src/render_area.hpp \
../../trace/src/Trace.hpp \
../../trace/src/values/Value.hpp \
../../trace/src/values/Date.hpp \
......@@ -619,6 +621,8 @@ interface_console.o: ../src/interface_console.cpp ../src/interface_console.hpp \
../../trace/src/EntityValue.hpp \
../../trace/src/EntityList.hpp \
../../trace/src/DrawTrace.hpp \
../../trace/src/resource.hpp \
../../main_resource.hpp \
../../parser/src/ParserPaje.hpp \
../../parser/src/ParserDefinitionDecoder.hpp \
../../parser/src/Definition.hpp \
......@@ -627,16 +631,14 @@ interface_console.o: ../src/interface_console.cpp ../src/interface_console.hpp \
../../parser/src/ParserEventDecoder.hpp \
../../trace/src/values/Values.hpp \
../../parser/tests/stub/trace.hpp \
../../parser/src/Parser.hpp \
../src/interface.hpp \
../src/interface_graphic.hpp \
../src/render_area.hpp \
../src/resource.hpp
../../parser/src/Parser.hpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o interface_console.o ../src/interface_console.cpp
interface_graphic.o: ../src/interface_graphic.cpp ../src/interface_graphic.hpp \
../../trace/src/resource.hpp \
../../main_resource.hpp \
../src/interface.hpp \
../src/resource.hpp \
../src/interface_console.hpp \
../src/render_area.hpp \
../../trace/src/Trace.hpp \
../../trace/src/values/Value.hpp \
../../trace/src/values/Date.hpp \
......@@ -655,6 +657,8 @@ interface_graphic.o: ../src/interface_graphic.cpp ../src/interface_graphic.hpp \
../../trace/src/EntityValue.hpp \
../../trace/src/EntityList.hpp \
../../trace/src/DrawTrace.hpp \
../../trace/src/resource.hpp \
../../main_resource.hpp \
../../parser/src/ParserPaje.hpp \
../../parser/src/ParserDefinitionDecoder.hpp \
../../parser/src/Definition.hpp \
......@@ -663,11 +667,7 @@ interface_graphic.o: ../src/interface_graphic.cpp ../src/interface_graphic.hpp \
../../parser/src/ParserEventDecoder.hpp \
../../trace/src/values/Values.hpp \
../../parser/tests/stub/trace.hpp \
../../parser/src/Parser.hpp \
../src/interface.hpp \
../src/interface_console.hpp \
../src/render_area.hpp \
../src/resource.hpp
../../parser/src/Parser.hpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o interface_graphic.o ../src/interface_graphic.cpp
moc_render_area.o: moc_render_area.cpp
......
......@@ -7,7 +7,6 @@
#include "test_area.hpp"
using namespace std;
......@@ -23,9 +22,8 @@ int main(int argc, char** argv){
r.setGeometry(0, 0, 800, 600);
cerr << "Test_trace t:" << endl;
Trace tr;
// r.build();
r.build(&tr);
Element_pos a = 50;
r.draw_container_text(a, a," a, a");
......
......@@ -8,61 +8,9 @@
#define MAIN_RESOURCE_HPP
/*** DEBUG MODE ***/
//#define DEBUG_MODE_RENDER_AREA
#include <QApplication>
#include <QtGui>/* for all of the Qt's Widgets */
#include <QtUiTools>/* for the run-time loading .ui file */
#include <QGLWidget>/* for the OpenGL Widget */
#include <iostream>/* to use the C standard library input output functions */
#include <sstream>/* to use the C standard library streams for displayed messages composed by string and numbers */
#include <string>
#include <cstdlib> /* for macros EXIT_SUCCESS and EXIT_FAILURE */
#include <cmath>
#include <stack>
#include <list>
/* For OpenGL text rendering */
#include <GL/glut.h>
/* These paths corresponding to the path in the resource file ('vite.qrc' in the 'bin' folder) */
#define UI_MAIN_WINDOW_NAME ":/window/main_window.ui"/* The main window ui file. */
#define UI_INFO_WINDOW_NAME ":/window/info_window.ui"/* The info window ui file. */
/* 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.
*/
#define CKF(f, m) if((f)==-1) { \
cerr << "File " << __FILE__ <<" - line : " << __LINE__ <<endl; \
cerr << m <<endl; \
exit(EXIT_FAILURE); \
}
#define CKFP(f, m) if((f)==NULL) { \
cerr << "File " << __FILE__ <<" - line : " << __LINE__ <<endl; \
cerr << m <<endl; \
exit(EXIT_FAILURE); \
}
/* Interface classes and headers */
class Interface;
class Interface_console;
class Interface_graphic;
class Render_area;
typedef long Element_count ;
......@@ -71,37 +19,11 @@ typedef double Element_col;
//include "interface/tests/test_trace.hpp"
#include "trace/src/Trace.hpp"
#include "trace/src/DrawTrace.hpp"
#include "parser/src/ParserPaje.hpp"
#include "interface/src/interface.hpp"
#include "interface/src/interface_console.hpp"
#include "interface/src/interface_graphic.hpp"
#include "interface/src/render_area.hpp"
/* */
/* Trace (data structure) classes and headers */
/*class Trace;
class Container;
#include "trace/src/Container.hpp"
/* Message management */
#include "message/src/message_ns.hpp"
/* Example:
* message << "Test:" << 45 << " and " << true << endi;
* -> display as an informative message.
*/
......
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