Mentions légales du service

Skip to content
Snippets Groups Projects
Commit fc6d809b authored by Olivier Lagrasse's avatar Olivier Lagrasse
Browse files

correction bug, amelioration des commentaires, publication de l'algorithme de rendu

parent a01dd8c7
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,17 @@
/***********************************
*
*
*
* Constructor and destructor.
*
*
*
**********************************/
Interface_console::Interface_console(int argc, char ** argv){
int state;
......@@ -21,6 +32,25 @@ Interface_console::Interface_console(int argc, char ** argv){
}
Interface_console::~Interface_console(){
/* Qt desallocates _main_window automatically */
}
/***********************************
*
*
*
* The command line parameter processing functions.
*
*
*
**********************************/
int Interface_console::get_state(int argc, char** argv){
if (argc==1){/* just the name of the program, launch the window interface */
......@@ -77,13 +107,18 @@ void Interface_console::display_help(){
}
Interface_console::~Interface_console(){
/* Qt desallocates _main_window automatically */
}
/***********************************
*
*
*
* Informative message functions.
*
*
*
**********************************/
void Interface_console::error(const string s) const{
cerr << "ERROR : " << s <<endl;
}
......
......@@ -11,35 +11,52 @@
/*!
*\brief An error state
*/
#define STATE_UNKNOWN -1
/*!
*\brief A state which corresponds to display a help text.
*\brief This class is an terminal interface, it inherited from the Interface interface.
*/
#define STATE_DISPLAY_HELP 0
class Interface_console : public Interface{
/*!
*\brief A state which corresponds to display the ViTE window.
*/
#define STATE_LAUNCH_GRAPHICAL_INTERFACE 1
/*!
*\brief This class is an terminal interface, it inherited from the Interface interface.
*/
class Interface_console : public Interface{
protected:
protected:
/***********************************
*
* Window interface instance.
*
**********************************/
/*!
* \brief Containt the instance of the window class.
*/
Interface_graphic* _main_window;
/***********************************
*
* The command line parameter processing functions.
*
**********************************/
/*!
*\brief An error state.
*/
static const int STATE_UNKNOWN = -1;
/*!
*\brief A state which corresponds to display a help text.
*/
static const int STATE_DISPLAY_HELP = 0;
/*!
*\brief A state which corresponds to display the ViTE window.
*/
static const int STATE_LAUNCH_GRAPHICAL_INTERFACE = 1;
/*!
* \brief Return the state of ViTE according to the arguments.
* \arg argc : the number of parameters given when the program was called.
......@@ -73,6 +90,15 @@ class Interface_console : public Interface{
public:
/***********************************
*
* Constructor and destructor.
*
**********************************/
/*!
* \brief The default constructor of the class.
* \arg argc : the number of parameters given when the program was called.
......@@ -86,6 +112,13 @@ class Interface_console : public Interface{
~Interface_console();
/***********************************
*
* Informative message functions.
*
**********************************/
/*!
\arg string : the string to be displayed.
\brief The function takes a string then displayed it into the terminal, then killed the application.
......
......@@ -8,6 +8,17 @@
/***********************************
*
*
*
* Constructor and destructor.
*
*
*
**********************************/
Interface_graphic::Interface_graphic(QWidget *parent):QWidget(parent){
/*if (!QGLFormat::hasOpenGL())
......@@ -65,6 +76,17 @@ Interface_graphic::~Interface_graphic(){
}
/***********************************
*
*
*
* Informative message functions.
*
*
*
**********************************/
void Interface_graphic::error(const string s) const{
QString buf = s.c_str();
_ui_info_trace_text->moveCursor(QTextCursor::Start);/* Insert the new text on the beginning */
......@@ -87,17 +109,32 @@ void Interface_graphic::information(const string s) const{
/***********************************
*
*
*
* Trace building function.
*
*
*
**********************************/
bool Interface_graphic::build(){
return _ui_render_area->build();
}
/***** SLOTS *****/
/***********************************
*
*
*
* Widget slot functions.
*
*
*
**********************************/
void Interface_graphic::on_open_triggered(){
......
......@@ -21,18 +21,23 @@ class Interface_graphic : public QWidget, public Interface{
Q_OBJECT
protected:
/***********************************
*
* Main window widget attributes.
*
**********************************/
/*!
* \brief This variable contains the main window of the application.
*/
QWidget* _ui_main_window;
/*!
* \brief This variable contains the floatting info box window of the application.
*/
QWidget* _ui_info_window;
/*!
* \brief This variable contains the action to switch in fullscreen mode.
*/
......@@ -48,16 +53,45 @@ class Interface_graphic : public QWidget, public Interface{
*/
QVBoxLayout* _ui_render_area_layout;
/***********************************
*
* Informative window widget attributes.
*
**********************************/
/*!
* \brief This variable contains the floatting info box window of the application.
*/
QWidget* _ui_info_window;
/*!
* \brief Text area which informs the user about the trace resume.
*/
QTextEdit* _ui_info_trace_text;
/***********************************
*
* Parser attribute.
*
**********************************/
/*!
* \brief The parser attribute.
*/
//Parser* _parser;
/***********************************
*
* Data structure attributes.
*
**********************************/
/*!
* \brief The data structure attribute.
*/
......@@ -71,6 +105,14 @@ class Interface_graphic : public QWidget, public Interface{
public:
/***********************************
*
* Constructor and destructor.
*
**********************************/
/*!
* \brief The default constructor
*/
......@@ -81,6 +123,14 @@ public:
*/
virtual ~Interface_graphic();
/***********************************
*
* Informative message functions.
*
**********************************/
/*!
* \arg string : the string to be displayed.
*\brief The function takes strings and/or numbers then displayed an info box containing it, then the application will be killed.
......@@ -102,6 +152,14 @@ public:
void information(const string) const;
/***********************************
*
* Trace building function.
*
**********************************/
/*!
*\brief This function will build the trace sent by the data structure ('_trace').
*/
......@@ -111,6 +169,14 @@ public:
protected slots:
/***********************************
*
* Widget slot functions.
*
**********************************/
/*!
*\brief A slot which called when 'open' in the menu is clicked.
*/
......
......@@ -2,13 +2,19 @@
*\file render_area.cpp
*/
#include <QtGui>
#include "render_area.hpp"
/***********************************
*
*
*
* Constructor and destructor.
*
*
*
**********************************/
Render_area::Render_area(QWidget *parent)
: QGLWidget(parent)
......@@ -20,7 +26,7 @@ Render_area::Render_area(QWidget *parent)
exit(EXIT_FAILURE);
}
_drawing_state = DRAWING_STATE_WAINTING;/* At the beginning, no trace is drawing */
_state = DRAWING_STATE_WAINTING;/* At the beginning, no trace is drawing */
/* init the wait animation */
_wait_list = 0;/* init list */
......@@ -28,9 +34,10 @@ Render_area::Render_area(QWidget *parent)
_wait_timer = NULL;
_wait_spf=DRAWING_TIMER_DEFAULT;/* DRAWING_TIMER_DEFAULT milliseconds per frame */
/* init the trace drawing */
_drawing_list=0;
_drawing_height = DRAWING_HEIGHT_DEFAULT;
}
Render_area::~Render_area()
......@@ -91,7 +98,7 @@ void Render_area::paintGL()
gluLookAt(0,0,60,0,0,0,0,1,0);
switch(_drawing_state){
switch(_state){
case DRAWING_STATE_WAINTING:/* A wait is drawn */
......@@ -161,7 +168,7 @@ bool Render_area::build(){
return false;
}
_drawing_state = DRAWING_STATE_DRAWING;/* change the drawing state */
_state = DRAWING_STATE_DRAWING;/* change the drawing state */
/* disable some OpenGL features to enhance the rendering */
glDisable(GL_TEXTURE_2D);
......@@ -201,7 +208,7 @@ bool Render_area::unbuild(){
if (_wait_timer->isActive()==false)/* if timer for the wait animation is running */
_wait_timer->start(_wait_spf);
_drawing_state = DRAWING_STATE_WAINTING;/* change the drawing state */
_state = DRAWING_STATE_WAINTING;/* change the drawing state */
/* enable some OpenGL features*/
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
......@@ -305,6 +312,7 @@ GLuint Render_area::draw_trace()
{
GLuint object;
container_draw_info info = {0, 0, DRAWING_CONTAINER_WIDTH_DEFAULT, DRAWING_CONTAINER_HEIGHT_DEFAULT};
object = glGenLists(1);/* create the list */
if (object==0){
......@@ -314,9 +322,33 @@ GLuint Render_area::draw_trace()
glNewList(object, GL_COMPILE);/* open the list */
{
/*** Drawing containers ***/
/*
* Start with the root containers.
* if a container has more than one child, it will be draw
* vertically, else horizontally.
*/
/* size_type container_size;
list<Container *> * container_list;
container_list = _trace->get_root_containers();
container_size = container_list.size();
while ( ){
for (size_type i=0;i<container_size;i++){
container_list = get_children();
if (container_list->get_type()
}
}*/
draw_container(1, "AZZ");
draw_container(2, "B");
/*** Drawing state ***/
draw_state(0, 67.89, 20);
}
......@@ -333,10 +365,10 @@ void Render_area::draw_container(const Level level, const string &name) const{
glBegin(GL_QUADS);/* create a quads */
{
glVertex2f(0, level*_drawing_height);
glVertex2f(0, (level+1)*_drawing_height);
glVertex2f(name.size(), (level+1)*_drawing_height);
glVertex2f(name.size(), level*_drawing_height);
glVertex2f(0, level*DRAWING_CONTAINER_SPACE_DEFAULT);
glVertex2f(0, (level+1)*DRAWING_CONTAINER_SPACE_DEFAULT);
glVertex2f(name.size(), (level+1)*DRAWING_CONTAINER_SPACE_DEFAULT);
glVertex2f(name.size(), level*DRAWING_CONTAINER_SPACE_DEFAULT);
}
glEnd();
......@@ -346,10 +378,10 @@ void Render_area::draw_state(const Date start, const Date end, const Level level
glBegin(GL_QUADS);/* create a quads */
{
glVertex2f(start, level*_drawing_height);
glVertex2f(end, (level+1)*_drawing_height);
glVertex2f(end, (level+1)*_drawing_height);
glVertex2f(start, level*_drawing_height);
glVertex2f(start, level*DRAWING_CONTAINER_SPACE_DEFAULT);
glVertex2f(end, (level+1)*DRAWING_CONTAINER_SPACE_DEFAULT);
glVertex2f(end, (level+1)*DRAWING_CONTAINER_SPACE_DEFAULT);
glVertex2f(start, level*DRAWING_CONTAINER_SPACE_DEFAULT);
}
glEnd();
}
......@@ -17,55 +17,101 @@ typedef double Date;
#include "interface_graphic.hpp"
#include <QtDesigner/QDesignerExportWidget>
#include <QtDesigner/QDesignerExportWidget>/* For the render area plugin */
/*!
* \brief State when there is no file opened.
*/
#define DRAWING_STATE_WAINTING 1
/*!
* \brief State when the application is drawing traces.
* \brief This class redefined the OpenGL widget - QGLWidget - to display the trace.
*/
#define DRAWING_STATE_DRAWING 2
class QDESIGNER_WIDGET_EXPORT Render_area : public QGLWidget
{
Q_OBJECT
/*!
* \brief Time in ms between two frames for the waiting screen.
*/
#define DRAWING_TIMER_DEFAULT 10
protected:
/*!
* \brief The default height for containers and others trace elements.
*/
#define DRAWING_HEIGHT_DEFAULT 20
/***********************************
*
* Environment attributes.
*
**********************************/
/*!
* \brief Refers to the parent widget of the render area.
*/
Interface_graphic* _parent;
class QDESIGNER_WIDGET_EXPORT Render_area : public QGLWidget
{
Q_OBJECT
protected:
/***********************************
*
* Render area state attributes.
*
**********************************/
/*!
* \brief The wait GLu list.
*/
GLuint _wait_list;
* \brief State when there is no file opened.
*/
static const int DRAWING_STATE_WAINTING = 1;
/*!
* \brief State when the application is drawing traces.
*/
static const int DRAWING_STATE_DRAWING = 2;
/*!
* \brief The trace Glu list.
* \brief Contains the kind of state for the render area (drawing, waiting, etc.).
*/
int _state;
/***********************************
*
* Default QGLWidget functions.
*
**********************************/
/*!
* \brief Call by the system to initialize the OpenGL render area.
*/
void initializeGL();
/*!
* \brief Call by the system when the render area was resized (occurs during a window resizement).
* \arg width : the new width of the render area.
* height : the new height of the render area.
*/
void resizeGL(int width, int height);
/*!
* \brief Call by the system each time the render area need to be updated.
*/
GLuint _drawing_list;
void paintGL();
/***********************************
*
* The wait screen drawing.
*
**********************************/
/***********************************
* The wait list Attributes.
**********************************/
/*!
* \brief Define the trace height.
* \brief The wait GLu list.
*/
double _drawing_height;
GLuint _wait_list;
/*!
* \brief Rotation angle for the wait.
......@@ -73,54 +119,114 @@ class QDESIGNER_WIDGET_EXPORT Render_area : public QGLWidget
float _wait_angle;
/*!
* \brief Timer to animate the wait.
*/
QTimer* _wait_timer;
* \brief Time in ms between two frames for the waiting screen.
*/
static const int DRAWING_TIMER_DEFAULT = 10;
/*!
* \brief Wait animation seconds per frame.
*/
* \brief Wait animation seconds per frame.
*/
int _wait_spf;
/*!
* \brief Timer to animate the wait.
*/
QTimer* _wait_timer;
Interface_graphic* _parent;
int _drawing_state;
/***********************************
* Drawing function for the wait screen.
**********************************/
/*!
* \brief Call by the system to initialize the OpenGL render area.
* \brief Display a wait on the screen if there is no file opened.
* \return Asset value of the wait.
*/
void initializeGL();
GLuint draw_wait();
/***********************************
*
* The trace drawing.
*
**********************************/
/***********************************
* The drawing list Attributes.
**********************************/
/*!
* \brief Call by the system when the render area was resized (occurs during a window resizement).
* \arg width : the new width of the render area.
* height : the new height of the render area.
* \brief The trace Glu list.
*/
void resizeGL(int width, int height);
GLuint _drawing_list;
/*!
* \brief Call by the system each time the render area need to be updated.
*/
void paintGL();
* \brief The default height for containers.
*/
static const float DRAWING_CONTAINER_HEIGHT_DEFAULT = 20.0f;
/*!
* \brief The default width for containers.
*/
static const float DRAWING_CONTAINER_WIDTH_DEFAULT = 50.0f;
/*!
* \brief Display a wait on the screen if there is no file opened.
* \return Asset value of the wait.
*/
GLuint draw_wait();
* \brief The default space between containers.
*/
static const float DRAWING_CONTAINER_SPACE_DEFAULT = 5.0f;
/*!
* \brief Geometrical informations about the trace shape.
*/
struct container_draw_info{
double current_x;
double current_y;
double normal_w;
double normal_h;
};
/***********************************
* 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();
/*!
* \brief Draw a container according to the parameters
* \param level the vertical position of the container.
* \param name the name of the container.
*/
void draw_container(const Level level, const string &name) const;
/*!
* \brief Draw a state of the trace.
* \param start the beginning time of the state.
* \param end the ending time of the state.
* \param level refer to the container which state belongs to.
*/
void draw_state(const Date start, const Date end, const Level level) const;
public:
/***********************************
*
* Constructor and destructor.
*
**********************************/
/*!
* \brief The default constructor
*/
......@@ -131,14 +237,22 @@ class QDESIGNER_WIDGET_EXPORT Render_area : public QGLWidget
*/
virtual ~Render_area();
/***********************************
*
* Building functions.
*
**********************************/
/*!
* \brief This function draws the trace.
*/
* \brief This function draws the trace.
*/
bool build();
/*!
* \brief This function releases the trace.
*/
* \brief This function releases the trace.
*/
bool unbuild();
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment