Commit 316d17d9 authored by Olivier Lagrasse's avatar Olivier Lagrasse

Realisation du plugin render_area pour le qtDesigner

parent 925fd2bf
......@@ -14,7 +14,6 @@
all:
cd ./src && make
# mv src/*.o bin/ # Object files are moved manually.
@echo " "
@echo "Compilation completed! (release)"
@echo " "
......@@ -28,16 +27,21 @@ doc:
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.
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
@echo " "
@echo "Rebuilt and compiled! (release)"
@echo " "
plugins:
cd ./plugin && qmake-qt4 && make
@echo " "
@echo "Plugins are built and installed ! Please manually install it ('libplugin.so') from 'plugin' folder to the qtdesigner plugin folder ('/usr/lib/qt4/plugins/designer' on linux) (plugin)"
@echo " "
debugs:
cd ./src && qmake-qt4 -project && qmake-qt4 -makefile -o Makefile "CONFIG+=uitools debug console" "QT+=opengl" "DESTDIR = ../debug" src.pro && make all
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
mv src/*.o bin/
@echo " "
@echo "Compilation completed! (debug)"
......@@ -45,7 +49,7 @@ debugs:
tests: rebuild
cd ./tests && qmake-qt4 -project && qmake-qt4 -makefile -o Makefile "CONFIG+=uitools" "QT+= opengl" "DESTDIR = ../bin" tests.pro && make all
cd ./tests && qmake-qt4 -project && qmake-qt4 -makefile -o Makefile "OBJECTS_DIR=../bin" "CONFIG+=uitools" "QT+= opengl" "DESTDIR = ../bin" tests.pro && make all
mv tests/*.o bin/
@echo " "
@echo "Compilation completed! (test)"
......@@ -62,5 +66,5 @@ clean:
wash:
cd ./src && rm *~ *.o *pro Makefile
cd ./tests && rm *~ *.o *pro Makefile
# cd ./bin && rm *
cd ./bin && rm *.o
cd ./debug && rm *
......@@ -7,6 +7,9 @@ For Debian/Ubuntu users, you can use apt-get :
sudo apt-get install libqt4-dev libqt4-opengl-dev
For Doxygen, it necessary to have epstopdf for the latex version. You can install it with the package texlive-extra-utils.
Then, until Qt development files are installed, you can compile ViTE :
......@@ -15,6 +18,8 @@ make rebuild -> the first time you compile the project. Compiled files are place
make -> if you have ever done "make rebuild". Compiled files are placed in "bin" folder.
make plugins -> the first time you compile the project. It generates the 'libplugin.so' file in 'plugin' folder which used by qtDesigner for the render area.
make doc -> generates the documentation of the source code.
make tests -> to compile test files. Compiled files are placed in "bin" folder.
......
......@@ -10,7 +10,7 @@
</rect>
</property>
<property name="windowTitle" >
<string>MainWindow</string>
<string>Informations</string>
</property>
<widget class="QWidget" name="centralwidget" >
<layout class="QHBoxLayout" name="horizontalLayout_2" >
......
......@@ -31,7 +31,7 @@
<item>
<widget class="QToolButton" name="toolButton_2" >
<property name="text" >
<string>Open...</string>
<string>Open</string>
</property>
</widget>
</item>
......@@ -134,22 +134,13 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="QWidget" native="1" name="render_area" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="mouseTracking" >
<bool>false</bool>
<widget class="Render_area" name="render_area" >
<property name="toolTip" >
<string>Render area</string>
</property>
<property name="styleSheet" >
<string notr="true" >background-color: qlineargradient(spread:pad, x1:0.453, y1:0.0799545, x2:0.466667, y2:0.932, stop:0 rgba(250, 250, 250, 125), stop:1 rgba(250, 250, 250, 0));</string>
<property name="whatsThis" >
<string>An OpenGL render area for ViTE.</string>
</property>
<zorder>horizontalLayoutWidget_2</zorder>
<zorder>widget</zorder>
<zorder>dock</zorder>
</widget>
</item>
</layout>
......@@ -246,6 +237,13 @@
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<class>Render_area</class>
<extends></extends>
<header>analogclock.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="vite.qrc" />
</resources>
......
CONFIG += designer plugin
QT += opengl
TARGET = $$qtLibraryTarget($$TARGET)
TEMPLATE = lib
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/designer
HEADERS = render_area_plugin.hpp \
../src/render_area.hpp
SOURCES = render_area_plugin.cpp \
../src/render_area.cpp
# install
target.path = $$[QT_INSTALL_PLUGINS]/designer
sources.files = $$SOURCES $$HEADERS *.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/designer/customwidgetplugin
INSTALLS += target sources
#include "../src/render_area.hpp"
#include "render_area_plugin.hpp"
#include <QtPlugin>
Render_areaPlugin::Render_areaPlugin(QObject *parent)
: QObject(parent)
{
initialized = false;
}
void Render_areaPlugin::initialize(QDesignerFormEditorInterface * /* core */)
{
if (initialized)
return;
initialized = true;
}
bool Render_areaPlugin::isInitialized() const
{
return initialized;
}
QWidget *Render_areaPlugin::createWidget(QWidget *parent)
{
return new Render_area(parent);
}
QString Render_areaPlugin::name() const
{
return "Render_area";
}
QString Render_areaPlugin::group() const
{
return "Display Widgets [Examples]";
}
QIcon Render_areaPlugin::icon() const
{
return QIcon();
}
QString Render_areaPlugin::toolTip() const
{
return "";
}
QString Render_areaPlugin::whatsThis() const
{
return "";
}
bool Render_areaPlugin::isContainer() const
{
return false;
}
QString Render_areaPlugin::domXml() const
{
return "<widget class=\"Render_area\" name=\"render_area\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>450</width>\n"
" <height>300</height>\n"
" </rect>\n"
" </property>\n"
" <property name=\"toolTip\" >\n"
" <string>Render area</string>\n"
" </property>\n"
" <property name=\"whatsThis\" >\n"
" <string>An OpenGL render area for ViTE.</string>\n"
" </property>\n"
"</widget>\n";
}
QString Render_areaPlugin::includeFile() const
{
return "analogclock.h";
}
Q_EXPORT_PLUGIN2(customwidgetplugin, Render_areaPlugin)
#ifndef RENDER_AREA_PLUGIN_HPP
#define RENDER_AREA_PLUGIN_HPP
#include <QDesignerCustomWidgetInterface>
class Render_areaPlugin : public QObject, public QDesignerCustomWidgetInterface
{
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetInterface)
public:
Render_areaPlugin(QObject *parent = 0);
bool isContainer() const;
bool isInitialized() const;
QIcon icon() const;
QString domXml() const;
QString group() const;
QString includeFile() const;
QString name() const;
QString toolTip() const;
QString whatsThis() const;
QWidget *createWidget(QWidget *parent);
void initialize(QDesignerFormEditorInterface *core);
private:
bool initialized;
};
#endif
/*!
*\file interface.h
*\brief This is an interface, used by the terminal and graphical interfaces.
*\file interface.hpp
*/
#ifndef INTERFACE_H
#define INTERFACE_H
#ifndef INTERFACE_HPP
#define INTERFACE_HPP
#include "resource.hpp"
/*!
*\brief This class is an interface for the human interaction with the program.
*\brief This is an interface, used by the terminal and graphical interfaces.
*
*Interface defines functions implemented in their inherited classes. It gives functions which can be used by others parts of ViTE (for example the Parser and the Data Structure). Thus, it hides which kind of interface is used: a console interface (where messages are displayed in the terminal) or a graphical interface (where messages are displayed in a dialog box).
*/
class Interface{
public:
/*!
\arg string : the string to be displayed.
\brief The function takes a string then displayed it either on the terminal if there is an Interface_console instance, or on a dialof box for the Interface_graphic. Then, it killed the application.
* \arg string : the string to be displayed.
* \brief The function takes a string then displayed it either on the terminal if there is an Interface_console instance, or on a dialof box for the Interface_graphic. Then, it killed the application.
*/
virtual bool error(const string) const =0;
virtual void error(const string) const =0;
/*!
\arg string : the string to be displayed.
\brief The function takes a string then displayed it either on the terminal if there is an Interface_console instance, or on a dialof box for the Interface_graphic. Then the program go on.
*/
virtual bool warning(const string) const =0;
virtual void warning(const string) const =0;
};
......
......@@ -21,7 +21,7 @@ Interface_console::Interface_console(int argc, char ** argv){
}
int Interface_console::get_state(int, char**){
int Interface_console::get_state(int argc, char** argv){
return STATE_LAUNCH_GRAPHICAL_INTERFACE;
......@@ -64,11 +64,9 @@ Interface_console::~Interface_console(){
}
bool Interface_console::error(const string s) const{
return true;
void Interface_console::error(const string s) const{
}
bool Interface_console::warning(const string s) const{
return true;
void Interface_console::warning(const string s) const{
}
/*!
*\file interface_console.h
*\brief This is a terminal interface.
*\file interface_console.hpp
*/
#ifndef INTERFACE_CONSOLE_H
#define INTERFACE_CONSOLE_H
#ifndef INTERFACE_CONSOLE_HPP
#define INTERFACE_CONSOLE_HPP
#include "interface.hpp"
#include "interface_graphic.hpp"
/*!
*\brief A state which corresponds to display a help text.
*/
#define STATE_DISPLAY_HELP 0
/*!
*\brief A state which corresponds to display the ViTE window.
*/
#define STATE_LAUNCH_GRAPHICAL_INTERFACE 1
......@@ -30,16 +36,31 @@ class Interface_console : public Interface{
/*!
* \brief Return the state of ViTE according to the arguments.
* \arg argc : the number of parameters given when the program was called.
* \arg argv : a set of strings which contains each parameter.
* \return an integer corresponding to a command which will be processed by ViTE.
*/
int get_state(int, char**);
int get_state(int argc, char** argv);
/*!
* \brief Launch the action according to the argument state value.
* \brief Launch an action according to the argument state value.
* \arg state : an integer corresponding to a kind of action which must be executed.
*
* This functions triggers an action of ViTE according to its argument. state can takes some values :
* <ul><li><b>STATE_DISPLAY_HELP</b> -> this value means that the console interface must be displayed
* in the terminal the help text, then wait until user specify an other command.</li>
* <li><b>STATE_LAUNCH_GRAPHICAL_INTERFACE</b> -> this value means that the console interface will let
* user to use the graphical interface: in that case, ViTE displays the window and all
* of the warning or error messages will be displayed in dialog boxes.</li>
* </ul>
*/
void launch_action(int);
void launch_action(int state);
/*!
* \brief Displays in the terminal the help text.
*/
void display_help();
......@@ -47,12 +68,14 @@ class Interface_console : public Interface{
public:
/*!
* \brief The default constructor
* \brief The default constructor of the class.
* \arg argc : the number of parameters given when the program was called.
* argv : a set of strings which contains each parameter.
*/
Interface_console(int, char**);
Interface_console(int argc, char** argv);
/*!
* \brief The destructor
* \brief The destructor.
*/
~Interface_console();
......@@ -61,14 +84,14 @@ class Interface_console : public Interface{
\arg string : the string to be displayed.
\brief The function takes a string then displayed it into the terminal, then killed the application.
*/
bool error(const string) const;
void error(const string) const;
/*!
\arg string : the string to be displayed.
\brief The function takes a string then displayed it into the terminal, then the program go on.
*/
bool warning(const string) const;
void warning(const string) const;
};
......
......@@ -10,6 +10,10 @@
Interface_graphic::Interface_graphic(QWidget *parent):QWidget(parent){
/*if (!QGLFormat::hasOpenGL())
qFatal("This system has no OpenGL support");
*/
QUiLoader loader;
QFile file_main(UI_MAIN_WINDOW_NAME);
QFile file_info(UI_INFO_WINDOW_NAME);
......@@ -17,66 +21,60 @@ Interface_graphic::Interface_graphic(QWidget *parent):QWidget(parent){
file_main.open(QFile::ReadOnly);
CKFP(ui_main_window = loader.load(&file_main, this), "Cannot open the .ui file : " << UI_MAIN_WINDOW_NAME);
CKFP(_ui_main_window = loader.load(&file_main, this), "Cannot open the .ui file : " << UI_MAIN_WINDOW_NAME);
file_main.close();
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);
CKFP(_ui_info_window = loader.load(&file_info, _ui_main_window), "Cannot open the .ui file : " << UI_MAIN_WINDOW_NAME);
file_info.close();
ui_info_window->setWindowOpacity(0.7);/* Change alpha value of the informative window */
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");
CKFP(ui_fullscreen_menu = qFindChild<QAction*>(this, "fullscreen"), "Cannot find the fullscreen menu in the .ui file");
_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 */
CKFP(_ui_render_area = qFindChild<QWidget*>(this, "render_area"), "Cannot find the render_area QWidget in the .ui file");
CKFP(_ui_fullscreen_menu = qFindChild<QAction*>(this, "fullscreen"), "Cannot find the fullscreen menu in the .ui file");
/*
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 */
_ui_main_window->show();/* Display the main window */
_ui_info_window->show();/* Display the info window */
}
Interface_graphic::~Interface_graphic(){
/* Qt desallocates ui_main_window and _render_area automatically */
/* Qt desallocates _ui_main_window, _ui_info_window and _render_area automatically */
}
bool Interface_graphic::error(const string s) const{
return true;
void Interface_graphic::error(const string s) const{
}
bool Interface_graphic::warning(const string s) const{
return true;
void Interface_graphic::warning(const string s) const{
}
/***** SLOTS *****/
void Interface_graphic::on_open_triggered(){
/*
Be careful, here, ui_main_window is used instead this because of this is not a window,
it's an interface class. The real window is ui_main_window.
If this is put, the application closes after the getOpenFilename dialog box closes.
Be careful! Here, _ui_main_window is used instead 'this' pointer because 'this' is not a window,
it's an interface class (Interface_graphic*). The real window is _ui_main_window.
If 'this' is put, the application closes after the getOpenFilename() dialog box closes.
*/
QString filename = QFileDialog::getOpenFileName(ui_main_window);
QString filename = QFileDialog::getOpenFileName(_ui_main_window);
if (!filename.isEmpty())
/*******************************************************/
......@@ -106,20 +104,25 @@ void Interface_graphic::on_quit_triggered(){
void Interface_graphic::on_fullscreen_triggered(){
/* Notice that some problems can appears under X system with
the window decoration. Please refer to official documentation of Qt
/*
Notice that some problems can appears under X systems with
the window decoration. Please refer to the Qt official documentation.
*/
/*
The menu is checked before function call, so if 'fullscreen menu' is checked,
the main window is displayed in fullscreen mode
*/
if (ui_fullscreen_menu->isChecked())/* It is checked before this function is called */
ui_main_window->showFullScreen();
if (_ui_fullscreen_menu->isChecked())
_ui_main_window->showFullScreen();
else
ui_main_window->showNormal();
_ui_main_window->showNormal();
}
void Interface_graphic::on_help_triggered(){
/**************************************************/
/* Not Yet Implemented -> Display the user manual */
/**************************************************/
......@@ -130,10 +133,10 @@ void Interface_graphic::on_help_triggered(){
void Interface_graphic::on_about_triggered(){
QMessageBox::about(ui_main_window, tr("About ViTE"),
tr("The <b>Application</b> example demonstrates how to "
"write modern GUI applications using Qt, with a menu bar, "
"toolbars, and a status bar."));
QMessageBox::about(_ui_main_window, tr("About ViTE"),
tr("<b>ViTE</b> is a trace format visualizer developped "
"by french engineering school students for INRIA searchers (<a href='http://www.inria.fr'>http://www.inria.fr</a>).<br/><br/>"
"It is licensed under <i>CECILL-A</i>."));
}
......
/*!
*\file interface_graphic.h
*\brief This is a graphical interface.
*\file interface_graphic.hpp
*/
#ifndef INTERFACE_GRAPHIC_H
#define INTERFACE_GRAPHIC_H
#ifndef INTERFACE_GRAPHIC_HPP
#define INTERFACE_GRAPHIC_HPP
#include "interface.hpp"
......@@ -24,14 +21,24 @@ class Interface_graphic : public QWidget, public Interface{
protected:
/*!
* \brief Used to load the .ui window files.
* \brief This variable contains the main window of the application.
*/
QWidget* ui_main_window;
QWidget* ui_info_window;
QAction* ui_fullscreen_menu;
QWidget* _ui_main_window;
/*!
* \brief This variable contains the floatting info box window of the application.
*/
QWidget* _ui_info_window;
QWidget* ui_render_area;
/*!
* \brief This variable contains the action to switch in fullscreen mode.
*/
QAction* _ui_fullscreen_menu;
/*!
* \brief This variable contains the OpenGL render area.
*/
QWidget* _ui_render_area;
public:
......@@ -50,32 +57,49 @@ public:
* \arg string : the string to be displayed.
*\brief The function takes a string then displayed an info box containing it, then the application will be killed.
*/
bool error(const string) const;
void error(const string) const;
/*!
*\arg string : the string to be displayed.
*\brief The function takes a string then displayed an info box containing it, then the program go on.
*/
bool warning(const string) const;
void warning(const string) const;
protected slots:
/*!
*\brief A slot which called when 'open' in the menu is clicked.
*/
void on_open_triggered();
/*!
*\brief A slot which called when 'close' in the menu is clicked.
*/
void on_close_triggered();
/*!
*\brief A slot which called when 'quit' in the menu is clicked.
*/
void on_quit_triggered();
/*!
*\brief A slot which called when 'fullscreen' in the menu is clicked.
*/
void on_fullscreen_triggered();
/*!
*\brief A slot which called when 'help' in the menu is clicked.
*/
void on_help_triggered();
/*!
*\brief A slot which called when 'about' in the menu is clicked.
*/
void on_about_triggered();
};
#endif
......@@ -5,6 +5,9 @@
#include "interface_console.hpp"
/*!
*\brief The main function of ViTE.
*/
int main(int argc, char **argv)
{
QApplication app(argc, argv);
......
/*!
*\file render_area.cpp
*/
#include <QtGui>
#include "render_area.hpp"
Render_area::Render_area(QWidget *parent)
: QGLWidget(parent)
{}
Render_area::~Render_area()
{}