diff --git a/interface/Makefile b/interface/Makefile index cc1c662b1b4ea8249677dade8a078dbaee7a6817..e53473d22fa16e773f0ae51054a0c2d5bd49e2f3 100644 --- a/interface/Makefile +++ b/interface/Makefile @@ -27,7 +27,7 @@ doc: rebuild: - cd ./src && qmake-qt4 -project "TARGET=vite" "OBJECTS_DIR=../bin" "DESTDIR=../bin" "CONFIG+=uitools" "QT+=opengl" && qmake-qt4 -makefile -o Makefile src.pro && make all + cd ./src && qmake-qt4 -project "RESOURCES= vite.qrc" "OBJECTS_DIR=../bin" "DESTDIR=../bin" "CONFIG+=uitools" "QT+=opengl" && qmake-qt4 -makefile -o Makefile src.pro && make all @echo " " @echo "Rebuilt and compiled! (release)" @echo " " @@ -41,7 +41,7 @@ plugins: debugs: - cd ./src && qmake-qt4 -project && qmake-qt4 -makefile -o Makefile "OBJECTS_DIR=../debug" "CONFIG+=uitools debug console" "QT+=opengl" "DESTDIR = ../debug" src.pro && make all + cd ./src && qmake-qt4 -project && qmake-qt4 -makefile -o Makefile "RESOURCES= vite.qrc" "OBJECTS_DIR=../debug" "CONFIG+=uitools debug console" "QT+=opengl" "DESTDIR = ../debug" src.pro && make all mv src/*.o bin/ @echo " " @echo "Compilation completed! (debug)" @@ -49,7 +49,7 @@ debugs: tests: rebuild - cd ./tests && qmake-qt4 -project && qmake-qt4 -makefile -o Makefile "OBJECTS_DIR=../bin" "CONFIG+=uitools" "QT+= opengl" "DESTDIR = ../bin" tests.pro && make all + cd ./tests && qmake-qt4 -project && qmake-qt4 -makefile -o Makefile "RESOURCES= vite.qrc" "OBJECTS_DIR=../bin" "CONFIG+=uitools" "QT+= opengl" "DESTDIR = ../bin" tests.pro && make all mv tests/*.o bin/ @echo " " @echo "Compilation completed! (test)" @@ -64,7 +64,7 @@ clean: # Must be called with option -i, otherwise an error occured in the first instructions, the followings won't be executed. wash: - cd ./src && rm *~ *.o *pro Makefile - cd ./tests && rm *~ *.o *pro Makefile + cd ./src && rm *~ *.o *pro Makefile qrc_vite.cpp core + cd ./tests && rm *~ *.o *pro Makefile core cd ./bin && rm *.o cd ./debug && rm * diff --git a/interface/bin/info_window.ui b/interface/bin/info_window.ui deleted file mode 100644 index 273264fb4b16392949884348f2b0188aee4dde46..0000000000000000000000000000000000000000 --- a/interface/bin/info_window.ui +++ /dev/null @@ -1,60 +0,0 @@ -<ui version="4.0" > - <class>info_window_2</class> - <widget class="QMainWindow" name="info_window_2" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>607</width> - <height>187</height> - </rect> - </property> - <property name="windowTitle" > - <string>Informations</string> - </property> - <widget class="QWidget" name="centralwidget" > - <layout class="QHBoxLayout" name="horizontalLayout_2" > - <item> - <layout class="QHBoxLayout" name="horizontalLayout" > - <item> - <widget class="QGroupBox" name="groupBox" > - <property name="maximumSize" > - <size> - <width>300</width> - <height>16777215</height> - </size> - </property> - <property name="focusPolicy" > - <enum>Qt::StrongFocus</enum> - </property> - <property name="title" > - <string>Trace Resume</string> - </property> - </widget> - </item> - <item> - <widget class="QGroupBox" name="info_window" > - <property name="title" > - <string>Selection Informations</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <widget class="QMenuBar" name="menubar" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>607</width> - <height>26</height> - </rect> - </property> - </widget> - <widget class="QStatusBar" name="statusbar" /> - </widget> - <resources/> - <connections/> -</ui> diff --git a/interface/bin/vite.qrc b/interface/bin/vite.qrc deleted file mode 100644 index 3b43f1da721e2b634a8e83f5033d9e80106d6ef2..0000000000000000000000000000000000000000 --- a/interface/bin/vite.qrc +++ /dev/null @@ -1,7 +0,0 @@ -<RCC> - <qresource prefix="icon_menu" > - <file>folder_yellow_open.png</file> - <file>no.png</file> - <file>help_index.png</file> - </qresource> -</RCC> diff --git a/interface/bin/folder_yellow_open.png b/interface/src/icon/folder_yellow_open.png similarity index 100% rename from interface/bin/folder_yellow_open.png rename to interface/src/icon/folder_yellow_open.png diff --git a/interface/bin/help_index.png b/interface/src/icon/help_index.png similarity index 100% rename from interface/bin/help_index.png rename to interface/src/icon/help_index.png diff --git a/interface/bin/no.png b/interface/src/icon/quit.png similarity index 100% rename from interface/bin/no.png rename to interface/src/icon/quit.png diff --git a/interface/src/img/logo.png b/interface/src/img/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..f98673cce751ae30c3833bea446d6fa6c5a5512b Binary files /dev/null and b/interface/src/img/logo.png differ diff --git a/interface/src/info_window.ui b/interface/src/info_window.ui new file mode 100644 index 0000000000000000000000000000000000000000..7cef83ff2fc01b85190283633e846cab5f338490 --- /dev/null +++ b/interface/src/info_window.ui @@ -0,0 +1,106 @@ +<ui version="4.0" > + <class>info_window</class> + <widget class="QMainWindow" name="info_window" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>607</width> + <height>187</height> + </rect> + </property> + <property name="windowTitle" > + <string>Informations</string> + </property> + <widget class="QWidget" name="centralwidget" > + <layout class="QHBoxLayout" name="horizontalLayout_2" > + <item> + <layout class="QHBoxLayout" name="horizontalLayout" > + <item> + <widget class="QGroupBox" name="info_trace" > + <property name="maximumSize" > + <size> + <width>300</width> + <height>16777215</height> + </size> + </property> + <property name="focusPolicy" > + <enum>Qt::StrongFocus</enum> + </property> + <property name="title" > + <string>Trace Resume</string> + </property> + <widget class="QTextEdit" name="info_trace_text" > + <property name="geometry" > + <rect> + <x>10</x> + <y>20</y> + <width>271</width> + <height>91</height> + </rect> + </property> + <property name="readOnly" > + <bool>true</bool> + </property> + <property name="html" > + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Trace informations</p></body></html></string> + </property> + <property name="textInteractionFlags" > + <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> + </property> + </widget> + </widget> + </item> + <item> + <widget class="QGroupBox" name="info_selection" > + <property name="title" > + <string>Selection Informations</string> + </property> + <widget class="QTextEdit" name="info_selection_text" > + <property name="geometry" > + <rect> + <x>10</x> + <y>20</y> + <width>271</width> + <height>91</height> + </rect> + </property> + <property name="readOnly" > + <bool>true</bool> + </property> + <property name="html" > + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Selection informations</p></body></html></string> + </property> + <property name="textInteractionFlags" > + <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> + </property> + </widget> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menubar" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>607</width> + <height>26</height> + </rect> + </property> + </widget> + <widget class="QStatusBar" name="statusbar" /> + </widget> + <resources/> + <connections/> +</ui> diff --git a/interface/src/interface_graphic.cpp b/interface/src/interface_graphic.cpp index bbbe9a0c992513f768e0472027b5533042c99bb1..425e6a71e64ad7412500ff12ce76835f97eb73cc 100644 --- a/interface/src/interface_graphic.cpp +++ b/interface/src/interface_graphic.cpp @@ -19,31 +19,38 @@ Interface_graphic::Interface_graphic(QWidget *parent):QWidget(parent){ QFile file_info(UI_INFO_WINDOW_NAME); - + /* Load the main window from a .ui file */ file_main.open(QFile::ReadOnly); CKFP(_ui_main_window = loader.load(&file_main, this), "Cannot open the .ui file : " << UI_MAIN_WINDOW_NAME); file_main.close(); + /* Load the informative window from a .ui file */ file_info.open(QFile::ReadOnly); CKFP(_ui_info_window = loader.load(&file_info, _ui_main_window), "Cannot open the .ui file : " << UI_MAIN_WINDOW_NAME); file_info.close(); - + /* Set some windows properties */ _ui_info_window->setWindowOpacity(0.7);/* Change alpha value of the informative window */ - _ui_info_window->setWindowFlags(_ui_info_window->windowFlags() | Qt::CustomizeWindowHint);/* Always display info_window on top */ + _ui_info_window->setWindowFlags(_ui_info_window->windowFlags() | Qt::WindowStaysOnTopHint);/* Always display info_window on top */ - CKFP(_ui_render_area = qFindChild<QWidget*>(this, "render_area"), "Cannot find the render_area QWidget in the .ui file"); + /* 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"); - + CKFP(_ui_info_trace_text = qFindChild<QTextEdit*>(this, "info_trace_text"), "Cannot find the info_trace_text QTextEdit widget in the .ui file"); + + /* Create the render area and bind it to a layout (_ui_render_area_layout) */ + _ui_render_area = new Render_area(); + _ui_render_area_layout->addWidget(_ui_render_area); /* 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'. */ QMetaObject::connectSlotsByName(this); - _ui_main_window->show();/* Display the main window */ - _ui_info_window->show();/* Display the info window */ + /* Display both the main and informative windows */ + _ui_main_window->show(); + _ui_info_window->show(); } @@ -59,6 +66,8 @@ void Interface_graphic::error(const string s) const{ void Interface_graphic::warning(const string s) const{ + QString buf = s.c_str(); + _ui_info_trace_text->insertHtml(buf+"<br />"); } diff --git a/interface/src/interface_graphic.hpp b/interface/src/interface_graphic.hpp index 85e232a20fea44022e6540cc85510414a8c5e95e..3302c72e917484577a263f052fa569fb8bb8a11f 100644 --- a/interface/src/interface_graphic.hpp +++ b/interface/src/interface_graphic.hpp @@ -8,6 +8,7 @@ #include "interface.hpp" +#include "render_area.hpp" /*! @@ -38,7 +39,23 @@ class Interface_graphic : public QWidget, public Interface{ /*! * \brief This variable contains the OpenGL render area. */ - QWidget* _ui_render_area; + Render_area* _ui_render_area; + + /*! + * \brief Layout which will contain the render area. + */ + QVBoxLayout* _ui_render_area_layout; + + /*! + * \brief Text area which informs the user about the trace resume. + */ + QTextEdit* _ui_info_trace_text; + + /*! + * \brief The parser attribute. + */ + // Parser* _parser; + public: diff --git a/interface/bin/main_window.ui b/interface/src/main_window.ui similarity index 87% rename from interface/bin/main_window.ui rename to interface/src/main_window.ui index 4b3871bfb79fc145e2d8926e5a25d845afc14774..ff6314073034889c0151cd6c5e7e460fa94ffd4b 100644 --- a/interface/bin/main_window.ui +++ b/interface/src/main_window.ui @@ -132,18 +132,7 @@ </layout> </item> <item> - <layout class="QVBoxLayout" name="verticalLayout" > - <item> - <widget class="Render_area" name="render_area" > - <property name="toolTip" > - <string>Render area</string> - </property> - <property name="whatsThis" > - <string>An OpenGL render area for ViTE.</string> - </property> - </widget> - </item> - </layout> + <layout class="QVBoxLayout" name="render_area_layout" /> </item> </layout> </widget> @@ -188,7 +177,7 @@ <action name="open" > <property name="icon" > <iconset resource="vite.qrc" > - <normaloff>:/icon_menu/folder_yellow_open.png</normaloff>:/icon_menu/folder_yellow_open.png</iconset> + <normaloff>:/icon/icon/folder_yellow_open.png</normaloff>:/icon/icon/folder_yellow_open.png</iconset> </property> <property name="text" > <string>&Open</string> @@ -202,7 +191,7 @@ <action name="quit" > <property name="icon" > <iconset resource="vite.qrc" > - <normaloff>:/icon_menu/no.png</normaloff>:/icon_menu/no.png</iconset> + <normaloff>:/icon/icon/quit.png</normaloff>:/icon/icon/quit.png</iconset> </property> <property name="text" > <string>&Quit</string> @@ -214,7 +203,7 @@ </property> <property name="icon" > <iconset resource="vite.qrc" > - <normaloff>:/icon_menu/help_index.png</normaloff>:/icon_menu/help_index.png</iconset> + <normaloff>:/icon/icon/help_index.png</normaloff>:/icon/icon/help_index.png</iconset> </property> <property name="text" > <string>&Help</string> @@ -237,13 +226,6 @@ </property> </action> </widget> - <customwidgets> - <customwidget> - <class>Render_area</class> - <extends></extends> - <header>analogclock.h</header> - </customwidget> - </customwidgets> <resources> <include location="vite.qrc" /> </resources> diff --git a/interface/src/render_area.cpp b/interface/src/render_area.cpp index a3736b81e3795b3343f3b60d823c814cde6f4e31..2cf34625745eeb6ebe5a15f5bc57ed50bccc1b58 100644 --- a/interface/src/render_area.cpp +++ b/interface/src/render_area.cpp @@ -10,8 +10,80 @@ Render_area::Render_area(QWidget *parent) : QGLWidget(parent) -{} +{ + + rot=0.0f; + + QTimer *timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(updateGL())); + timer->start(10); + + + +} Render_area::~Render_area() - {} + { + glDeleteLists(object, 1); + } + + +void Render_area::initializeGL() +{ + glClearColor(1.0f, 1.0f, 1.0f, 1.0f); + + object = glGenLists(1); + glNewList(object, GL_COMPILE); + { + glBegin(GL_QUADS); + { + + glColor3ub(255,0,0); //red face + glVertex3d(1,1,1); + glVertex3d(1,1,-1); + glVertex3d(-1,1,-1); + glVertex3d(-1,1,1); + } + glEnd(); + } + glEndList(); + + glEnable(GL_DEPTH_TEST); + +} + +void Render_area::resizeGL(int width, int height) +{ + int side = qMin(width, height); + glViewport((width - side) / 2, (height - side) / 2, side, side); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-15, +15, +15, -15, -10, 15.0); + glMatrixMode(GL_MODELVIEW); +} + +void Render_area::paintGL() +{ + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glLoadIdentity(); + gluLookAt(0,0,2,0,0,0,0,1,0); + + glRotatef(rot, 0.0f, 1.0f, 0.0f); + + rot+=1.0f; + if (rot>1000.0f) rot=0.0f; + + + + glCallList(object); + + + + + glFlush(); + +} diff --git a/interface/src/render_area.hpp b/interface/src/render_area.hpp index 7f5b6bfc8040c741aade37a24fabd66f804efa06..1f04f4aaa12cc94249ade20a43afd00146414e77 100644 --- a/interface/src/render_area.hpp +++ b/interface/src/render_area.hpp @@ -5,15 +5,42 @@ #ifndef RENDER_AREA_HPP #define RENDER_AREA_HPP -#include <QGLWidget> -// #include <QWidget> - #include <QtDesigner/QDesignerExportWidget> +#include "resource.hpp" + + + +#include <QtDesigner/QDesignerExportWidget> class QDESIGNER_WIDGET_EXPORT Render_area : public QGLWidget { Q_OBJECT + protected: + + GLuint object; + float rot; + GLuint texture; + + + /*! + * \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. + */ + void paintGL(); + public: + /*! * \brief The default constructor */ diff --git a/interface/src/resource.hpp b/interface/src/resource.hpp index 17497daa03178738f033fa7586990be259cab9e9..1bcd37681e535bad44cd2819d7250031a50f8996 100644 --- a/interface/src/resource.hpp +++ b/interface/src/resource.hpp @@ -20,9 +20,9 @@ using namespace std; - -#define UI_MAIN_WINDOW_NAME "main_window.ui"/* name of the main window ui file. This file must be included in the same folder than the compiled program. */ -#define UI_INFO_WINDOW_NAME "info_window.ui"/* name of the info window ui file. This file must be included in the same folder than the compiled program. */ +/* 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. */ diff --git a/interface/src/vite.qrc b/interface/src/vite.qrc new file mode 100644 index 0000000000000000000000000000000000000000..8a536493035d7394f1d64cde119e49c326c07547 --- /dev/null +++ b/interface/src/vite.qrc @@ -0,0 +1,14 @@ +<RCC> + <qresource prefix="icon" > + <file>icon/folder_yellow_open.png</file> + <file>icon/help_index.png</file> + <file>icon/quit.png</file> + </qresource> + <qresource prefix="img" > + <file>img/logo.png</file> + </qresource> + <qresource prefix="window" > + <file>info_window.ui</file> + <file>main_window.ui</file> + </qresource> +</RCC>