Commit de59e9c8 authored by Olivier Lagrasse's avatar Olivier Lagrasse

- Connection manuelle dans interface_graphic du signal du boutton ok de la...

- Connection manuelle dans interface_graphic du signal du boutton ok de la fenetre de parametrage de l'export.
- Suppression des liens avec glew.h.
- Remise temporaire du scrolling. (correction d'un bug de conversion de type dans interface_graphic)
- La selection via la souris d'un intervalle de temps est maintenant precise sur l'axe des X.
- Correction de bugs et améliorations diverses et variees au niveau du render opengl.

parent bb1f2806
......@@ -9,8 +9,6 @@
struct Info;
#include "resource.hpp"
/*!
* \brief Class used to store informations.
*
......@@ -37,7 +35,7 @@ public:
/*!
* \brief Sub structure to store container informations.
*/
static struct Container{
struct Container{
/*!
* \brief Minimum x position.
......@@ -54,7 +52,7 @@ public:
/*!
* \brief Sub structure to store state informations.
*/
static struct Entity{
struct Entity{
/*!
* \brief Minimum x position.
......
......@@ -22,7 +22,7 @@ class Interface_console;
#include "resource.hpp"
#include <pthread.h>
//#include <pthread.h>
/*!
......
......@@ -23,6 +23,7 @@ using namespace std;
Interface_graphic::Interface_graphic(Interface_console* core, QWidget *parent):QMainWindow(parent){
setupUi(this);
_core = core;
_is_rendering_trace = false;
......@@ -71,13 +72,13 @@ void Interface_graphic::load_windows(){
/* Load the _option_export_window from a .ui file */
file_selection_export.open(QFile::ReadOnly);
CKFP(_ui_time_selection_export = loader.load(&file_selection_export, this), "Cannot open the .ui file : " << "option_export_window.ui");
_ui_time_selection_export->setWindowFlags(_ui_time_selection_export->windowFlags() | Qt::WindowStaysOnTopHint);
file_selection_export.close();
/* Set some windows properties */
_ui_info_window->setWindowFlags(_ui_info_window->windowFlags() | Qt::WindowStaysOnTopHint);/* Always display info_window on top */
_ui_time_selection_export->setWindowFlags(_ui_time_selection_export->windowFlags() | Qt::WindowStaysOnTopHint);
/* Load widget from the .ui file */
CKFP(_ui_render_area_layout = qFindChild<QVBoxLayout*>(this, "render_area_layout"), "Cannot find the render_area layout in the .ui file");
CKFP(_ui_fullscreen_menu = qFindChild<QAction*>(this, "fullscreen"), "Cannot find the fullscreen menu in the .ui file");
......@@ -88,15 +89,18 @@ void Interface_graphic::load_windows(){
CKFP(_ui_x_scroll = qFindChild<QScrollBar*>(this, "x_scroll"), "Cannot find the horizontal scroll bar in the .ui file");
CKFP(_ui_y_scroll = qFindChild<QScrollBar*>(this, "y_scroll"), "Cannot find the vertical scroll bar in the .ui file");
CKFP(_ui_export_ok_button = qFindChild<QPushButton*>(_ui_time_selection_export, "option_export_ok"), "Cannot find the ok push button in the export dialog .ui file");
connect(_ui_export_ok_button, SIGNAL(pressed()),
this, SLOT( option_export_ok_pressed()));
/*
Special function of Qt which allows methods declared as slots and which name are 'on_[widget]_[action]()' to be called when the 'widget' triggered the signal corresponding to 'action'.
/!\ -> use NULL as argument, else messages will be duplicated!
*/
QMetaObject::connectSlotsByName(NULL);
QMetaObject::connectSlotsByName(_ui_time_selection_export);
// QMetaObject::connectSlotsByName(_ui_time_selection_export);
/* Display the main window */
this->show();
......@@ -264,7 +268,7 @@ void Interface_graphic::on_export_file_triggered(){
_ui_time_selection_export->show();
}
void Interface_graphic::on_option_export_ok_clicked(){
void Interface_graphic::option_export_ok_pressed(){
// We have to save the option from _ui_time_selection_export and hide her if it is not do automatically
......@@ -434,13 +438,13 @@ void Interface_graphic::on_zoom_box_textChanged(QString s){
}
void Interface_graphic::on_x_scroll_valueChanged(int new_value){
_core->launch_action(Interface_console::_STATE_RENDER_AREA_REPLACE_TRANSLATE, &new_value);
Element_pos converted_new_value = new_value;/* change type of new_value */
_core->launch_action(Interface_console::_STATE_RENDER_AREA_REPLACE_TRANSLATE, &converted_new_value);
}
void Interface_graphic::on_y_scroll_valueChanged(int new_value){
_core->launch_action(Interface_console::_STATE_RENDER_AREA_REPLACE_TRANSLATE_Y, &new_value);
Element_pos converted_new_value = new_value;/* change type of new_value */
_core->launch_action(Interface_console::_STATE_RENDER_AREA_REPLACE_TRANSLATE_Y, &converted_new_value);
}
......
......@@ -20,7 +20,7 @@ class Interface_graphic;
/*!
*\brief This class is a graphical interface which creates a window, it inherited from the Interface interface.
*/
class Interface_graphic : public QMainWindow, protected Ui::main_window, public Interface{
class Interface_graphic : public QMainWindow, protected Ui::main_window, public Interface{
Q_OBJECT
......@@ -110,6 +110,11 @@ class Interface_graphic : public QMainWindow, protected Ui::main_window, public
*/
QWidget* _ui_info_window;
/*!
* \brief This variable contains the floatting export box window of the application.
*/
QWidget* _ui_time_selection_export;
/*!
* \brief Text area which informs the user about the trace resume.
*/
......@@ -120,10 +125,12 @@ class Interface_graphic : public QMainWindow, protected Ui::main_window, public
*/
QTextEdit* _ui_info_selection_text;
/*!
* \brief This variable contains the floatting info box window of the application.
/*!
* \brief Text area which informs the user about the selected entity information.
*/
QWidget* _ui_time_selection_export;
QPushButton* _ui_export_ok_button;
/***********************************
......@@ -229,6 +236,21 @@ public:
*/
void bind_render_area(QGLWidget* render_area);
/*!
* \brief Function called when close event is received.
* \param event The event.
*
* This function can be used to display message for user to store its work before application closes.
*/
void closeEvent(QCloseEvent *event);
/*!
* \brief Get the name of the current trace file.
*
* \return The name of the current trace file
*/
const std::string get_filename() const;
protected slots:
......@@ -241,87 +263,87 @@ protected slots:
**********************************/
/*!
*\brief A slot which called when 'open' in the menu is clicked.
*\brief A slot called when 'open' in the menu is clicked.
*/
void on_open_triggered();
/*!
*\brief A slot which called when 'export' in the menu is clicked.
*\brief A slot called when 'export' in the menu is clicked.
*/
void on_export_file_triggered();
/*!
*\brief A slot which is called when the options in export are ok.
*/
void on_option_export_ok_clicked();
*\brief A slot called when the options in export are ok.
*/
void option_export_ok_pressed();
/*!
*\brief A slot which called when 'close' in the menu is clicked.
*\brief A slot called when 'close' in the menu is clicked.
*/
void on_close_triggered();
/*!
*\brief A slot which called when 'quit' in the menu is clicked.
*\brief A slot called when 'quit' in the menu is clicked.
*/
void on_quit_triggered();
/*!
*\brief A slot which called when 'fullscreen' in the menu is clicked.
*\brief A slot called when 'fullscreen' in the menu is clicked.
*/
void on_fullscreen_triggered();
/*!
*\brief A slot which called when 'Show tool bar' in the menu is clicked.
*\brief A slot called when 'Show tool bar' in the menu is clicked.
*/
void on_toolbar_menu_triggered();
/*!
*\brief A slot which called when 'show infos' in the menu is clicked.
*\brief A slot called when 'show infos' in the menu is clicked.
*/
void on_show_info_triggered();
/*!
*\brief A slot which called when 'help' in the menu is clicked.
*\brief A slot called when 'help' in the menu is clicked.
*/
void on_help_triggered();
/*!
*\brief A slot which called when 'about' in the menu is clicked.
*\brief A slot called when 'about' in the menu is clicked.
*/
void on_about_triggered();
/*!
*\brief A slot which called when 'no_warning' in the menu is clicked.
*\brief A slot called when 'no_warning' in the menu is clicked.
*/
void on_no_warning_triggered();
/*!
*\brief A slot which called when 'zoom_in' in the menu is clicked.
*\brief A slot called when 'zoom_in' in the menu is clicked.
*/
void on_zoom_in_triggered();
/*!
*\brief A slot which called when 'zoom_out' in the menu is clicked.
*\brief A slot called when 'zoom_out' in the menu is clicked.
*/
void on_zoom_out_triggered();
/*!
*\brief A slot which called when 'goto_start' in the menu is clicked.
*\brief A slot called when 'goto_start' in the menu is clicked.
*/
void on_goto_start_triggered();
/*!
*\brief A slot which called when 'goto_end' in the menu is clicked.
*\brief A slot called when 'goto_end' in the menu is clicked.
*/
void on_goto_end_triggered();
/*!
*\brief A slot which called when 'show_all_trace' in the menu is clicked.
*\brief A slot called when 'show_all_trace' in the menu is clicked.
*/
void on_show_all_trace_triggered();
/*!
*\brief A slot which called when 'zoom_box' widget is triggered.
*\brief A slot called when 'zoom_box' widget is triggered.
*
* \arg s The new string value of the zoom box.
*/
......@@ -344,23 +366,6 @@ protected slots:
* \param new_value The new percentage (between 0 to 100).
*/
void on_scale_container_state_valueChanged(int new_value);/* temporary slot */
/*!
* \brief Function called when close event is received.
* \param event The event.
*
* This function can be used to display message for user to store its work before application closes.
*/
void closeEvent(QCloseEvent *event);
/*!
* \brief Get the name of the current trace file.
*
* \return The name of the current trace file
*/
const std::string get_filename() const;
};
......
......@@ -18,7 +18,7 @@
*
*/
#include <GL/glew.h>/* For OpenGL VBO and shaders */
//#include <GL/glew.h>/* For OpenGL VBO and shaders */
#include <GL/glut.h>/* For OpenGL text rendering */
#include <QtGui>
......
TARGET = vite
RESOURCES= vite.qrc
SOURCES+=../../main.cpp
OBJECTS_DIR=../../bin
DESTDIR=../../bin
CONFIG+=uitools debug
QT+=opengl
LIBS += -lglut
TEMPLATE = app
DEPENDPATH += .
INCLUDEPATH += . \
../../bin
# Input
HEADERS += interface.hpp \
interface_console.hpp \
interface_graphic.hpp \
render_area.hpp \
resource.hpp \
../../parser/src/Definition.hpp \
../../parser/src/Line.hpp \
../../parser/src/Parser.hpp \
../../parser/src/ParserDefinitionDecoder.hpp \
../../parser/src/ParserEventDecoder.hpp \
../../parser/src/ParserPaje.hpp \
../../parser/src/TokenSource.hpp \
../../trace/src/Container.hpp \
../../trace/src/ContainerType.hpp \
../../trace/src/Entity.hpp \
../../trace/src/EntityList.hpp \
../../trace/src/EntityType.hpp \
../../trace/src/EntityValue.hpp \
../../trace/src/State.hpp \
../../trace/src/StateType.hpp \
../../trace/src/Event.hpp \
../../trace/src/EventType.hpp \
../../trace
../../trace/src/Trace.hpp \
../../trace/src/values/Color.hpp \
../../trace/src/values/Date.hpp \
../../trace/src/values/Double.hpp \
../../trace/src/values/Hex.hpp \
../../trace/src/values/Integer.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 \
../../trace/src/DrawTrace.hpp
FORMS += info_window.ui main_window.ui maquette.ui option_export_window.ui
SOURCES += interface_console.cpp \
interface_graphic.cpp\
render_area.cpp \
../../parser/src/Definition.cpp \
../../parser/src/Line.cpp \
../../parser/src/ParserDefinitionDecoder.cpp \
../../parser/src/ParserEventDecoder.cpp \
../../parser/src/ParserPaje.cpp \
../../parser/src/TokenSource.cpp \
../../trace/src/Container.cpp \
../../trace/src/ContainerType.cpp \
../../trace/src/Entity.cpp \
../../trace/src/EntityList.cpp \
../../trace/src/EntityType.cpp \
../../trace/src/EntityValue.cpp \
../../trace/src/State.cpp \
../../trace/src/StateType.cpp \
../../trace/src/Event.cpp \
../../trace/src/EventType.cpp \
../../trace/src/Trace.cpp \
../../trace/src/values/Color.cpp \
../../trace/src/values/Date.cpp \
../../trace/src/values/Double.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
RESOURCES += vite.qrc
......@@ -126,16 +126,16 @@ Render_opengl::Render_opengl(QWidget *parent)
updateGL();
glew_code = glewInit();/* use for VBO and shaders */
// glew_code = glewInit();/* use for VBO and shaders */
if(GLEW_OK != glew_code){
message << "Cannot initialize GLEW: " << glewGetErrorString(glew_code) << Message::ende;
}
// 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;
}
// /*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;
// }
}
......@@ -532,8 +532,18 @@ void Render_opengl::mouseReleaseEvent(QMouseEvent * event){
Element_pos x_middle_selection;
Element_pos y_middle_selection;
Element_pos x_scaled_middle_selection;
Element_pos y_scaled_middle_selection;
Element_pos x_distance_between_state_origin_and_render_middle;
Element_pos y_distance_between_state_origin_and_render_middle;
/*
* When the mouse is released:
*
* First, check if there is a significant difference between mouse coordinates. Prevent bad manipulations.
*/
if ( ((_new_mouse_x-_mouse_x) < _minimum_distance_for_selection)
&& ((_new_mouse_y-_mouse_y) < _minimum_distance_for_selection) )
{
......@@ -541,13 +551,20 @@ void Render_opengl::mouseReleaseEvent(QMouseEvent * event){
updateGL();
return;
}
/*
* When the mouse is released:
* Now, we try to zoom on the selection rectangle. To perform this, the left of the selection rectangle must be fit with the left
* of the render area. Idem for the right, the top and the bottom.
*
* First, check if there is a significant difference between mouse coordinates. Prevent bad manipulations.
* Then translate the middle of the selection rectangle to the middle of the render area.
* Finally, scale entities to fit selection area to render area.
* Thus, we need to know the difference the scale between the rectangle width and height and the render area width and height.
* Results are given by the scale: _screen_width/(_new_mouse_x - _mouse_x) for the horizontal dimension.
*
* Then, our selection rectangle is scaled. Nevertheless, it should not be centered inside the render area. So, we work out
* the correct x and y translation to make both the render area middle and the selection rectangle middle fit.
* There are 3 steps for the middle x position :
* - First, find distance between the scaled selection rectangle middle and the state origin.
* - Second, find the distance between the state origin and the render area middle.
* - Finally, translate the scaled selection middle to the difference.
*/
......@@ -558,27 +575,38 @@ void Render_opengl::mouseReleaseEvent(QMouseEvent * event){
x_middle_selection = (_mouse_x + (_new_mouse_x - _mouse_x)/2 )*(_render_width/_screen_width);
y_middle_selection = (_mouse_y + (_new_mouse_y - _mouse_y)/2 )*(_render_height/_screen_height);
/*
* Translate entities.
* 1st step:
*
* Work out the new selection middle position after applying the scale.
*/
x_scaled_middle_selection = (x_middle_selection + _state_translate - _default_entity_x_translate)*(_screen_width/((_new_mouse_x - _mouse_x)));
y_scaled_middle_selection = (y_middle_selection + _y_state_translate - _ruler_height)*(_screen_height/((_new_mouse_y - _mouse_y)));
/*
* 2nd step:
*
* x_middle_selection is the current position of the selection middle in the render area coordinates.
* A is a distance between the selection middle and the state origin.
* Applying the S scale on the trace, the new distance between the selection middle and the state origin is S*A.
* Now, try to find B like S*A - B = A. Thus, B represents the translation value to recenter the scaled selection middle to the widget center.
* Hence, B = A*(S-1).
* Work out the distance between the state origin and the render area middle (_render_width/2).
*/
x_distance_between_state_origin_and_render_middle = _state_translate - _default_entity_x_translate + _render_width/2;
y_distance_between_state_origin_and_render_middle = _y_state_translate - _ruler_height + _render_height/2;
/*
* 3rd step:
*
* Here, A = x_middle_selection + _state_translate - _default_entity_x_translate.
* and S = _screen_width/(_new_mouse_x - _mouse_x) -> scale between the selection rectangle width and the widget width.
* Translate entities.
*/
_state_translate += (x_middle_selection + _state_translate - _default_entity_x_translate)*( _screen_width/(_new_mouse_x - _mouse_x) - 1);
// _y_state_translate += (y_middle_selection + _y_state_translate - _ruler_height)*( _screen_height/(_new_mouse_y - _mouse_y) - 1);
_state_translate += x_scaled_middle_selection - x_distance_between_state_origin_and_render_middle;
// _y_state_translate += y_scaled_middle_selection - y_distance_between_state_origin_and_render_middle;
/*
* Finally, perform the scale.
*/
_state_scale *= _screen_width/(_new_mouse_x - _mouse_x);
// _y_state_scale *= _screen_height/(_new_mouse_y - _mouse_y);
// _y_state_scale *= _screen_height/(_new_mouse_y - _mouse_y);
_mouse_pressed = false;
updateGL();
......@@ -670,7 +698,7 @@ void Render_opengl::change_translate(int translate){
void Render_opengl::replace_translate(Element_pos new_translate){
if (0 == new_translate){/* show the beginning states */
_state_translate = _default_entity_x_translate - (Element_pos)_render_width/2.0;
......@@ -758,6 +786,12 @@ bool Render_opengl::build(){
/* disable some OpenGL features to enhance the rendering */
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
_state_scale = 1;/* for states scaling */
_state_translate = 0;/* for states translation */
_y_state_scale = 1;/* for states scaling */
_y_state_translate = 0;/* for states translation */
_x_scroll_pos = 0;/* horizontal bar placed on 0 */
return true;
}
......
......@@ -7,7 +7,7 @@ OBJECTS_DIR=../bin
DESTDIR=../bin
CONFIG+=uitools debug
QT+=opengl
LIBS += -lglut -lGLEW
LIBS += -lglut
TEMPLATE = app
TARGET = vite
DEPENDPATH += . interface message parser trace trace/values
......@@ -26,7 +26,7 @@ HEADERS += message/Message.hpp \
render/render.hpp \
render/render_opengl.hpp \
render/render_svg.hpp \
render/vbo.hpp \
# render/vbo.hpp \
# Parser headers
parser/Definition.hpp \
parser/Line.hpp \
......@@ -71,7 +71,7 @@ SOURCES += message/Message.cpp \
# Render code files
render/render_opengl.cpp \
render/render_svg.cpp \
render/vbo.cpp \
# render/vbo.cpp \
# Parser code files
parser/Definition.cpp \
parser/Line.cpp \
......
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