Commit 48ca7f55 authored by Olivier Lagrasse's avatar Olivier Lagrasse

- Mise en page FAQ dans manuel utilisateur.

- Correction bug d'alignement entre etats et conteneurs.
- Ajout fichiers source pour les vbo.
- Ajout debut test vbo.
- Fusion dans interface console de draw trace pour l'OpenGL et le SVG.
- Quand on ferme un trace, on ne peut plus l'exporter.
parent 6010f256
This diff is collapsed.
......@@ -8,8 +8,7 @@
class Interface_console;
#include <QtGui>
#include <QApplication>
#include "interface.hpp"
#include "interface_graphic.hpp"
#include "../render/render_opengl.hpp"
......@@ -95,6 +94,16 @@ public:
*\brief A state which corresponds to release the OpenGL render area (display the wait screen).
*/
static const int _STATE_RENDER_AREA_CHANGE_CONTAINER_SCALE = 9;
/*!
*\brief Informs that a trace has to be parsed and diplayed in the main window.
*/
static const int _DRAW_OPENGL = 10;
/*!
*\brief Informs that a trace has to be exported in svg format.
*/
static const int _DRAW_SVG = 11;
/*!
*\brief A state which corresponds to display the ViTE window.
......@@ -154,12 +163,12 @@ protected:
/*!
*\brief If a file must be opened, this attributes contains its path.
*/
char* _file_opened;
std::string _file_opened;
/*!
*\brief If a file must be exported, this attributes contains its path.
*/
char* _path_to_export;
std::string _path_to_export;
/*!
*\brief The time where we start to watch the trace.
......@@ -233,22 +242,11 @@ protected:
/*!
* \brief This function launch trace drawing.
* \param filename Path of the trace file.
* \param render_area Pointer to the render area.
* \param format Format of the render output between: Interface_console::_DRAW_OPENGL and Interface_console::_DRAW_SVG.
*
* \return true if no errors occurs.
*/
bool draw_trace(const std::string & filename);//, Render_opengl* render_area);
/*!
* \brief This function launch SVG drawing.
* \param filename Path of the trace file.
* \param svg Pointer to the svg instance.
*
* \return true if no errors occurs.
*/
bool draw_trace(const std::string & filename, Svg* svg);
bool draw_trace(const std::string & filename, const int format);
/*!
* \brief This function launch Qt event loop.
......@@ -262,6 +260,13 @@ protected:
*/
const std::string get_filename() const;
/*!
* \brief Set the name of the output file for SVG export.
* \param path Path of the output file.
*
*/
void set_path_to_export(const std::string& path);
/*!
* \brief Get the _run_env matrix.
*
......
......@@ -211,7 +211,7 @@ void Interface_graphic::on_open_triggered(){
else{
opening_file(filename.toStdString());
if(false==_core->draw_trace(filename.toStdString()))
if(false==_core->draw_trace(filename.toStdString(), Interface_console::_DRAW_OPENGL))
error("Draw trace failed");
}/* end else of if (_is_rendering_trace == true) */
......@@ -230,17 +230,10 @@ void Interface_graphic::on_export_file_triggered(){
if (!filename.isEmpty()){
information(string("Exporting trace to ")+filename.toStdString());
{
Svg svg;
svg.init(filename.toStdString().c_str());
_core->draw_trace(_trace_path, &svg);
}
_core->set_path_to_export(filename.toStdString());
// _core->draw_trace(_trace_path, Interface_console::_DRAW_SVG);
_core->launch_action(Interface_console::_STATE_EXPORT_FILE);
}
else
error("No file specified for exportation");
......
......@@ -9,9 +9,6 @@
class Interface_graphic;
#include <QtUiTools>/* for the run-time loading .ui file */
#include <QGLWidget>/* for the OpenGL Widget */
#include "../ui_main_window.h"/* the main window graphical interface */
#include "interface.hpp"
......
......@@ -5,19 +5,35 @@
#ifndef RESOURCE_HPP
#define RESOURCE_HPP
#ifndef INTERFACE_RESOURCE_HPP
#define INTERFACE_RESOURCE_HPP
#include "../main_resource.hpp"
/*
*
* WARNING : Take care that GL/glew.h MUST be included before others OpenGL includes (like GL/glut.h or QGLWidget).
*
*/
#include <GL/glew.h>/* For OpenGL VBO and shaders */
#include <GL/glut.h>/* For OpenGL text rendering */
#include <QtGui>
#include <QApplication>
#include <QtUiTools>/* for the run-time loading .ui file */
#include <QGLWidget>/* for the OpenGL Widget */
#include <cmath>
#include <stack>
#include <list>
/* For OpenGL text rendering */
#include <GL/glut.h>
......@@ -66,9 +82,5 @@
exit(EXIT_FAILURE); \
}
/* Define the unity of time */
typedef double Times;
#endif
......@@ -8,15 +8,19 @@
* \brief The main launcher.
*/
#include <QApplication>
#include "interface/interface_console.hpp"
/*!
*\brief The main function of ViTE.
*/
int main(int argc, char **argv) {
Q_INIT_RESOURCE(vite);
glutInit(&argc, argv);
Interface_console console(argc, argv);
return console.run();
......
......@@ -13,6 +13,10 @@
#include <cstdlib> /* for macros EXIT_SUCCESS and EXIT_FAILURE */
/*!
* \brief unity for count elements such as number of states or events... NOT USED YET
*/
......@@ -26,6 +30,10 @@ typedef double Element_pos;
*/
typedef double Element_col;
/* Define the unity of time */
typedef double Times;
/* Message management */
......
......@@ -59,7 +59,7 @@ std::ostream &operator<<(std::ostream &out, Message::end_information_t) {
Interface *interface = Message::get_interface();
if (interface) {
interface->warning(message->str());
interface->information(message->str());
message->str(""); // flush the stream
} else {
std::cerr << "Warning: no interface designed to display messages." << std::endl;
......
......@@ -25,6 +25,18 @@ using namespace std;
Render_opengl::Render_opengl(QWidget *parent)
: QGLWidget(parent){
GLenum glew_code;
if (!QGLFormat::hasOpenGL()){
QMessageBox::information(0, "ViTE: Fatal OpenGL error","This system does not support OpenGL.");
}
_state = DRAWING_STATE_WAINTING;/* At the beginning, no trace is drawing */
/* init the wait animation */
......@@ -101,6 +113,19 @@ Render_opengl::Render_opengl(QWidget *parent)
setMouseTracking (true);/* to catch mouse events */
updateGL();
glew_code = glewInit();/* use for VBO and shaders */
if(GLEW_OK != glew_code){
message << "Cannot initialize GLEW: " << glewGetErrorString(glew_code) << Message::ende;
}
/*Check if VBO is supported */
if (GL_FALSE == glewIsSupported("GL_ARB_vertex_buffer_object")){
message << "VBO OpenGL extension is not supported by your graphic card." << Message::ende;
}
}
......@@ -136,6 +161,8 @@ void Render_opengl::initializeGL(){
glClearStencil(0);
_wait_list = draw_wait();
}
void Render_opengl::resizeGL(int width, int height){
......@@ -297,7 +324,7 @@ void Render_opengl::paintGL(){
const char letter = buf_txt.c_str()[i];
length += glutBitmapWidth(GLUT_BITMAP_HELVETICA_10, letter);
if(length > size_of_container){
cout << "break" << endl;
break;
}
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, letter);
......@@ -311,7 +338,7 @@ void Render_opengl::paintGL(){
glTranslated( _default_entity_x_translate - _state_translate , 0.0f, _z_state);
glScalef(_state_scale*(_render_width/_state_x_max), (_render_height-_rule_height)/_state_y_max, 0.0f);
glScalef(_state_scale*(_render_width/_state_x_max), (_render_height-_rule_height)/_container_y_max, 0.0f);
......@@ -746,6 +773,144 @@ void Render_opengl::create_rule(){
}
*/
}
// void Render_opengl::create_rule(){
// ostringstream buf_txt;
// Element_pos rule_width;
// Element_pos entity_width;
// Element_pos graduation_distance;
// Element_pos x_min;
// Element_pos start_delay;
// Element_pos coeff;
// Element_pos buf_number;
// Element_pos graduation_distance_per_5;
// int units;
// int ten_units;
// Element_pos buf_g_d;
// units = 0;//3;
// ten_units = 1;//1000;
// coeff = (_state_x_max - _state_x_min)/_render_width;/* from [0;100] to [_state_x_min;_state_x_max], used to obtain correct coordinate texts */
// entity_width = _render_width*_state_scale;/* the render width from a given scale */
// graduation_distance = entity_width/ceil(entity_width/_rule_distance);/* distance between two graduations calculated from a desire distance */
// x_min = _default_entity_x_translate-_state_translate;/* received the first integer inside render width */
// start_delay = x_min - graduation_distance*floor(x_min/graduation_distance);/* delaying rule start at 0.0 x coordinate to fit with graduation distance */
// graduation_distance_per_5 = graduation_distance/5.0;
// rule_width = (_render_width*_state_scale+x_min)/_rule_distance;
// /* Calculate the rule unit (cm, mm, um, nm, ...) */
// buf_g_d = _state_x_max/((double)_state_scale);
// /* cerr << buf_g_d << endl;
// while( (buf_g_d > 0.0) && (buf_g_d <= 1.0) ){
// buf_g_d *= 10.0;
// units ++;
// ten_units *= 10;
// }*/
// /* Draw the rule top line */
// glColor3d(1.0, 1.0, 1.0);
// glBegin(GL_LINES);
// {
// glVertex3d(max(x_min, 0.0), _rule_y, _z_rule);
// glVertex3d(entity_width+x_min, _rule_y, _z_rule);
// }
// glEnd();
// if ( (x_min<0.0) && ((entity_width+x_min)>graduation_distance)){/* we are not viewing the beginning of the trace (i.e. the 0.0 coordinate) but we still viewing the trace (not after the end) */
// /* draw previous small graduations */
// for (char k=1 ; k<5 ; k++){
// glBegin(GL_LINES);
// {
// glColor3d(1.0, 1.0, 1.0);glVertex3d(start_delay-k*graduation_distance_per_5, _rule_y, _z_rule);
// glColor3d(1.0, 0.6, 0.6);glVertex3d(start_delay-k*graduation_distance_per_5, _rule_y+_rule_height/3.0, _z_rule);
// }
// glEnd();
// }
// }
// /* Draw spaced graduation of _rule_distance */
// for (Element_pos i=max(x_min, start_delay) ; i<=min(entity_width+x_min, _render_width) ; i+=graduation_distance){
// if (i != min(entity_width+x_min, _render_width) ){/* prepare small graduations between the current and the next main graduation */
// /* draw small graduations */
// for (char k=1 ; k<5 ; k++){
// glBegin(GL_LINES);
// {
// glColor3d(1.0, 1.0, 1.0);glVertex3d(i+k*graduation_distance_per_5, _rule_y, _z_rule);
// glColor3d(1.0, 0.6, 0.6);glVertex3d(i+k*graduation_distance_per_5, _rule_y+_rule_height/3.0, _z_rule);
// }
// glEnd();
// }
// }
// /* Draw the main graduation line */
// glBegin(GL_LINES);
// {
// glColor3d(1.0, 1.0, 1.0);glVertex3d(i, _rule_y, _z_rule);
// glColor3d(1.0, 0.6, 0.6);glVertex3d(i, _rule_y+_rule_height, _z_rule);
// }
// glEnd();
// /* Draw the graduation text */
// glColor3d(1.0, 1.0, 1.0);
// glRasterPos2f(i, _rule_y+_rule_height);
// buf_number = (i - x_min)*coeff/_state_scale;
// /* trunc numbers */
// buf_number = floor(buf_number*ten_units);
// buf_txt << buf_number;
// for(unsigned int j=0;j<buf_txt.str().length();j++){
// glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, buf_txt.str().c_str()[j]);
// }
// buf_txt.str("");/* flush the buffer */
// }
// /* Draw the ended graduation line */
// glBegin(GL_LINES);
// {
// glColor3d(1.0, 1.0, 1.0);glVertex3d(rule_width*_rule_distance, _rule_y, _z_rule);
// glColor3d(1.0, 0.6, 0.6);glVertex3d(rule_width*_rule_distance, _rule_y+_rule_height, _z_rule);
// }
// glEnd();
// /* Indicate the unit */
// glColor3d(1.0, 1.0, 1.0);
// glRasterPos2f(0, _rule_y+_rule_height);
// buf_txt << "10^-" << units;
// for(unsigned int j=0;j<buf_txt.str().length();j++){
// glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, buf_txt.str().c_str()[j]);
// }
// }
void Render_opengl::set_total_width(Element_pos w){}
......
......@@ -6,17 +6,19 @@
#define RENDER_OPENGL_HPP
class Render_opengl;
#include <QtGui>
#include <QGLWidget>/* for the OpenGL Widget */
class Render_opengl;
#include "render.hpp"
#include "resource.hpp"
/*!
* \brief Structure used to store event information.
*/
......@@ -40,19 +42,19 @@ struct Event_{
*/
struct Arrow_{
/*!
* \brief time when the arrow starts
* \brief time when the arrow starts.
*/
Element_pos start_time;
/*!
* \brief time when the arrow ends
* \brief time when the arrow ends.
*/
Element_pos end_time;
/*!
* \brief ?
* \brief The start height of the arrow.
*/
Element_pos start_height;
/*!
* \brief ?
* \brief The end height of the arrow.
*/
Element_pos end_height;
};
......
......@@ -5,55 +5,13 @@
#ifndef RESOURCE_HPP
#define RESOURCE_HPP
#ifndef RENDER_RESOURCE_HPP
#define RENDER_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;
#include "../main_resource.hpp"
......
/*!
*\file vbo.cpp
*/
#include "vbo.hpp"
using namespace std;
#define message *Message::get_instance() << "(" << __FILE__ << " l." << __LINE__ << "): "
/***********************************
*
*
*
* Constructor and destructor.
*
*
*
**********************************/
Vbo::Vbo(){
/* init class attributes */
_cur = 0;
/* init OpenGL */
// glGenBuffers(1, &_id);/* create the buffer an put its value to _id */
// glBindBuffer(GL_ARRAY_BUFFER, _id);/* select our vbo */
// glBufferData(GL_ARRAY_BUFFER, _size, NULL, GL_STATIC_DRAW);/* allocate memory space inside graphic card */
// glBindBuffer(GL_ARRAY_BUFFER, 0);/* deselect our vbo */
}
Vbo::~Vbo(){
//glDeleteBuffers(1, &_id);/* release the buffer and free its memory inside graphic card */
}
/*!
*\file vbo.hpp
*/
#ifndef VBO_HPP
#define VBO_HPP
class Vbo;
#include "resource.hpp"
/*!
* \brief Manage the Vertex Buffer Object.
*/
class Vbo{
protected:
/*!
* \brief The vbo instance identity.
*/
GLuint _id;
/*!
* \brief The size of the vbo buffer. (10 000 verteces)
*/
static const int _size = 100;
/*!
* \brief Define the position indicator inside the VBO buffer. Must be lesser than _size !
*/
int _cur;
public:
/***********************************
*
* Constructor and destructor.
*
**********************************/
/*!
* \brief The default constructor.
*/
Vbo();
/*!
* \brief The destructor.
*/
virtual ~Vbo();
/***********************************
*
* Buffer filling.
*
**********************************/
/*!
* \brief Used to inform that data have been successfully added to graphic card.
*/
static const int VBO_OK = 0;
/*!
* \brief Used to inform that the buffer is full and another VBO must be create.
*/
static const int VBO_OUT_OF_MEMORY = 1;
/*!
* \brief Used to inform that an unidentified error occurs.
*/
static const int VBO_UNDEFINED_ERROR = 2;
/*!
* \brief Fill the vertex buffer object.
* \return The state of the buffer.
*
* This function is called for each vertex, so it is an inline function. It can return several number :
* <ul>
* <li><b>VBO_OK</b>: data have been added to graphic card. No error.
* <li><b>VBO_OUT_OF_MEMORY</b>: buffer is full. Another VBO must be create.
* <li><b>VBO_UNDEFINED_ERROR</b>: an error occurs but has not been identified.
* </ul>
*/
virtual int fill_buffer() = 0;
/***********************************
*
* Buffer display.
*
**********************************/
/*!
* \brief Display the VBO list inside the OpenGL area.
*/
virtual void display_buffer() = 0;
};
#endif
......@@ -7,7 +7,7 @@ OBJECTS_DIR=../bin
DESTDIR=../bin
CONFIG+=uitools debug
QT+=opengl
LIBS += -lglut