Commit 889c41c0 authored by Olivier Lagrasse's avatar Olivier Lagrasse

interface : widget 3D + resolution probleme de chemins relatifs

parent 658dddcf
......@@ -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 *
<RCC>
<qresource prefix="icon_menu" >
<file>folder_yellow_open.png</file>
<file>no.png</file>
<file>help_index.png</file>
</qresource>
</RCC>
<ui version="4.0" >
<class>info_window_2</class>
<widget class="QMainWindow" name="info_window_2" >
<class>info_window</class>
<widget class="QMainWindow" name="info_window" >
<property name="geometry" >
<rect>
<x>0</x>
......@@ -17,7 +17,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QGroupBox" name="groupBox" >
<widget class="QGroupBox" name="info_trace" >
<property name="maximumSize" >
<size>
<width>300</width>
......@@ -30,13 +30,59 @@
<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>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Trace informations&lt;/p>&lt;/body>&lt;/html></string>
</property>
<property name="textInteractionFlags" >
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="info_window" >
<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>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Selection informations&lt;/p>&lt;/body>&lt;/html></string>
</property>
<property name="textInteractionFlags" >
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</widget>
</item>
</layout>
......
......@@ -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 />");
}
......
......@@ -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:
......
......@@ -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>&amp;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>&amp;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>&amp;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>
......
......@@ -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();
}
......@@ -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
*/
......
......@@ -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. */
......
<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>
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