Commit d37357e8 authored by Olivier Lagrasse's avatar Olivier Lagrasse
Browse files

Affichage de la fenetre (lancer le programme depuis le dossier bin)

parent a19e7538
CC=g++
FLAGS=-Wall
DEBUG=-g -O0
FINAL=-03
####
#
# /*!
# * \brief Makefile for the ViTE interface. Commands are : \
# * make all : compiles the released version.
# * make debugs : compiles with debug informations.
# * make tests : compiles the tests.
# * make clean : deletes generated files.
# */
#
###
all:
cd ./src && qmake-qt4 -project "DESTDIR=../bin" "CONFIG+=uitools opengl" && qmake-qt4 -makefile -o Makefile src.pro && make all
mv src/*.o bin/
cd ./src && make
# mv src/*.o bin/ # Object files are moved manually.
@echo " "
@echo "Compilation completed! (release)"
@echo " "
rebuild:
cd ./src && qmake-qt4 -project "DESTDIR=../bin" "CONFIG+=uitools" "QT+=opengl" && qmake-qt4 -makefile -o Makefile src.pro && make all
# mv src/*.o bin/ # Object files are moved manually.
@echo " "
@echo "Rebuilt and compiled! (release)"
@echo " "
debugs:
cd ./src && qmake-qt4 -project && qmake-qt4 -makefile -o Makefile "CONFIG+=uitools opengl debug" "DESTDIR = ../debug" src.pro && make all
cd ./src && qmake-qt4 -project && qmake-qt4 -makefile -o Makefile "CONFIG+=uitools debug console" "QT+=opengl" "DESTDIR = ../debug" src.pro && make all
mv src/*.o bin/
@echo " "
@echo "Compilation completed! (debug)"
@echo " "
tests: all
cd ./tests && qmake-qt4 -project && qmake-qt4 -makefile -o Makefile "CONFIG+=uitools opengl debug" "DESTDIR = ../bin" tests.pro && make all
tests: rebuild
cd ./tests && qmake-qt4 -project && qmake-qt4 -makefile -o Makefile "CONFIG+=uitools" "QT+= opengl" "DESTDIR = ../bin" tests.pro && make all
mv tests/*.o bin/
@echo " "
@echo "Compilation completed! (test)"
@echo " "
clean:
make -i -f Makefile wash
make -i -f Makefile wash # The washing is launched to ignore errors.
@echo " "
@echo "Cleaned!"
@echo " "
wash:
# 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 ./bin && rm *
......
<ui version="4.0" >
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow" >
<class>main_window</class>
<widget class="QMainWindow" name="main_window" >
<property name="geometry" >
<rect>
<x>0</x>
......@@ -10,7 +10,7 @@
</rect>
</property>
<property name="windowTitle" >
<string>ViTE - Project</string>
<string>ViTE</string>
</property>
<widget class="QWidget" name="centralwidget" >
<widget class="QWidget" name="horizontalLayoutWidget" >
......@@ -144,31 +144,7 @@
<number>5</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea_3" >
<property name="widgetResizable" >
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_3" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>373</width>
<height>335</height>
</rect>
</property>
<widget class="QGraphicsView" name="graphicsView" >
<property name="geometry" >
<rect>
<x>-5</x>
<y>-9</y>
<width>381</width>
<height>351</height>
</rect>
</property>
</widget>
</widget>
</widget>
<widget class="QWidget" native="1" name="render_area" />
</item>
<item>
<widget class="Line" name="line" >
......@@ -177,36 +153,6 @@
</property>
</widget>
</item>
<item>
<widget class="QScrollArea" name="scrollArea_2" >
<property name="verticalScrollBarPolicy" >
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable" >
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_2" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>373</width>
<height>335</height>
</rect>
</property>
<widget class="QGraphicsView" name="graphicsView_2" >
<property name="geometry" >
<rect>
<x>-10</x>
<y>-10</y>
<width>391</width>
<height>351</height>
</rect>
</property>
</widget>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
......@@ -445,6 +391,13 @@
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<class>QGLWidget</class>
<extends>QWidget</extends>
<header>qglwidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
......@@ -8,13 +8,58 @@
Interface_console::Interface_console(){
Interface_console::Interface_console(int argc, char ** argv){
int state;
_main_window=NULL;
state = get_state(argc, argv);
launch_action(state);
}
int Interface_console::get_state(int, char**){
return STATE_LAUNCH_GRAPHICAL_INTERFACE;
}
void Interface_console::launch_action(int state){
switch(state) {
case STATE_DISPLAY_HELP :
display_help();
break;
case STATE_LAUNCH_GRAPHICAL_INTERFACE :
/* launch the window interface */
_main_window = new Interface_graphic();
break;
default:
warning("Cannot determine the arguments past");
}
}
void Interface_console::display_help(){
}
Interface_console::~Interface_console(){
/* Qt desallocates _main_window automatically */
}
......
......@@ -8,20 +8,48 @@
#include "interface.h"
#include "interface_graphic.h"
#define STATE_DISPLAY_HELP 0
#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:
/*!
* \brief Containt the instance of the window class.
*/
Interface_graphic* _main_window;
/*!
* \brief Return the state of ViTE according to the arguments.
*/
int get_state(int, char**);
/*!
* \brief Launch the action according to the argument state value.
*/
void launch_action(int);
void display_help();
public:
/*!
* \brief The default constructor
*/
Interface_console();
Interface_console(int, char**);
/*!
* \brief The destructor
......
......@@ -8,22 +8,44 @@
Interface_graphic::Interface_graphic(){
Interface_graphic::Interface_graphic(){
QUiLoader loader;
QFile file(UI_MAIN_WINDOW_NAME);
file.open(QFile::ReadOnly);
_main_window = loader.load(&file, this);
_load_window = loader.load(&file, this);
if (_load_window==NULL){
/* Error message displays in the terminal */
cerr << "Cannot open the .ui file : " << UI_MAIN_WINDOW_NAME ;//<< " (file " << __FILE << ", l." << __LINE__ <<" )" << endl;
exit(EXIT_FAILURE);
}
file.close();
_render_area = qFindChild<QWidget*>(this, "render_area");
QMetaObject::connectSlotsByName(this);
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(_load_window);
setLayout(layout);
_load_window->show();
}
Interface_graphic::~Interface_graphic(){
delete _main_window;
/* Qt desallocates _load_window and _render_area automatically */
}
......
......@@ -13,17 +13,23 @@
/*!
*\brief This class is a graphical interface which creates a window, it inherited from the Interface interface.
*/
class Interface_graphic : public Interface, public QWidget{
protected:
/*!
* \brief Containt the instance of the window class.
* \brief Used to load the .ui window file.
*/
QWidget* _main_window;
QWidget* _load_window;
QWidget* _render_area;
public:
......
/*!
*\file main.cpp
*\brief The launcher.
*\brief The main launcher.
*/
#include "interface_console.h"
......@@ -8,7 +8,11 @@
int main(int argc, char **argv)
{
QApplication app(argc, argv);
Interface_console console;
Interface_console console(argc, argv);
return app.exec();
}
<ui version="4.0" >
<class>main_window</class>
<widget class="QMainWindow" name="main_window" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>745</width>
<height>514</height>
</rect>
</property>
<property name="windowTitle" >
<string>ViTE v 0.1</string>
</property>
<widget class="QWidget" name="centralwidget" >
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="QWidget" native="1" name="render_area" />
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>745</width>
<height>26</height>
</rect>
</property>
<widget class="QMenu" name="menuFile" >
<property name="title" >
<string>File</string>
</property>
<addaction name="actionOpen" />
<addaction name="actionClose" />
<addaction name="separator" />
<addaction name="actionQuit" />
</widget>
<addaction name="menuFile" />
</widget>
<widget class="QStatusBar" name="statusbar" />
<action name="actionOpen" >
<property name="text" >
<string>Open</string>
</property>
</action>
<action name="actionClose" >
<property name="text" >
<string>Close</string>
</property>
</action>
<action name="actionQuit" >
<property name="text" >
<string>Quit</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>
......@@ -11,9 +11,11 @@
#include <QApplication>
#include <QtGui>/* for all of the Qt's Widgets */
#include <QtUiTools>/* for the run-time loading .ui file */
#include <QGLWidget>/* for the OpenGL Widget */
#include <iostream>/* to use the C standard library input output functions */
#include <string>
#include <string>
#include <cstdlib> /* for macros EXIT_SUCCESS and EXIT_FAILURE */
using namespace std;
......
......@@ -12,4 +12,10 @@
#include "../src/interface_graphic.h"
#define ASSERT_SUCCESS 0
#define ASSERT_FAILURE 1
#define assert__must_be_equal_int(A,B) if ((A)!=(B)){cerr << "Assert failed: "<<A<<" must be equal to "<<B<<" (file: "<<__FILE__<<", l."<<__LINE__<<")"<<endl; return ASSERT_FAILURE;}
#endif
Supports Markdown
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