Commit 5d8bafe7 authored by Olivier Lagrasse's avatar Olivier Lagrasse

barre conteneur qui n'agit que sur les conteneurs + icone souris en attente...

barre conteneur qui n'agit que sur les conteneurs + icone souris en attente quand ouvre une trace ou exporte en svg + correction export en export_file dans fichier .ui + menu qui permet en cliquant d'afficher ou de masquer la barre d'information
parent 64cab618
......@@ -20,7 +20,9 @@ using namespace std;
**********************************/
Interface_graphic::Interface_graphic(Interface_console* core, QWidget *parent):QWidget(parent){
Interface_graphic::Interface_graphic(Interface_console* core, QWidget *parent):QMainWindow(parent){
setupUi(this);
_core = core;
_is_rendering_trace = false;
......@@ -29,7 +31,9 @@ Interface_graphic::Interface_graphic(Interface_console* core, QWidget *parent):Q
}
Interface_graphic::Interface_graphic(Interface_console* core, const string file_path, QWidget *parent):QWidget(parent){
Interface_graphic::Interface_graphic(Interface_console* core, const string file_path, QWidget *parent):QMainWindow(parent){
setupUi(this);
_core = core;
_is_rendering_trace = false;
......@@ -44,7 +48,7 @@ Interface_graphic::~Interface_graphic(){
/* Qt desallocates _ui_main_window, _ui_info_window and _render_area automatically */
/* Qt desallocates this, _ui_info_window and _render_area automatically */
}
......@@ -68,15 +72,9 @@ void Interface_graphic::load_windows(){
if (!QGLFormat::hasOpenGL())
qFatal("This system has no OpenGL support");
/* 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);
CKFP(_ui_info_window = loader.load(&file_info, this), "Cannot open the .ui file : " << UI_MAIN_WINDOW_NAME);
file_info.close();
......@@ -97,11 +95,12 @@ void Interface_graphic::load_windows(){
/*
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(this);
QMetaObject::connectSlotsByName(NULL);
/* Display both the main and informative windows */
_ui_main_window->show();
/* Display the main window */
this->show();
}
......@@ -121,7 +120,7 @@ void Interface_graphic::error(const string s) const{
_ui_info_trace_text->moveCursor(QTextCursor::End);/* Insert the new text on the beginning */
_ui_info_trace_text->insertHtml("<font color='red'>"+buf+"</font><br /><br />");
_ui_info_window->show();
_ui_info_window->show();/* show info_window */
}
......@@ -130,7 +129,7 @@ void Interface_graphic::warning(const string s) const{
_ui_info_trace_text->moveCursor(QTextCursor::End);/* Insert the new text on the beginning */
_ui_info_trace_text->insertHtml("<font color='orange'>"+buf+"</font><br /><br />");
_ui_info_window->show();
_ui_info_window->show();/* show info_window */
}
......@@ -158,36 +157,21 @@ void Interface_graphic::opening_file(string const &path){
_trace_path = path;
_ui_main_window->setWindowTitle(QString("ViTE :: ")+_trace_path.c_str());
this->setWindowTitle(QString("ViTE :: ")+_trace_path.c_str());
QApplication::setOverrideCursor(Qt::WaitCursor);
_core->draw_trace(path, _ui_render_area);
_ui_render_area->build();
_is_rendering_trace = true;
_ui_render_area->updateGL();
}
/***********************************
*
*
*
* Trace building function.
*
*
*
**********************************/
_ui_render_area->updateGL();
QApplication::restoreOverrideCursor();
/*bool Interface_graphic::build(Trace* trace){
return _ui_render_area->build();
}*/
}
/***********************************
......@@ -203,11 +187,11 @@ void Interface_graphic::opening_file(string const &path){
void Interface_graphic::on_open_triggered(){
/*
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.
Be careful! Here, this is used instead 'this' pointer because 'this' is not a window,
it's an interface class (Interface_graphic*). The real window is this.
If 'this' is put, the application closes after the getOpenFilename() dialog box closes.
*/
QString filename = QFileDialog::getOpenFileName(_ui_main_window);
QString filename = QFileDialog::getOpenFileName(this);
if (!filename.isEmpty()){
......@@ -219,8 +203,6 @@ void Interface_graphic::on_open_triggered(){
QProcess * new_process = new QProcess();
new_process->startDetached(program, arguments);
cerr << program.toStdString() << " " << filename.toStdString() << endl;
}
else{
opening_file(filename.toStdString());
......@@ -228,43 +210,33 @@ void Interface_graphic::on_open_triggered(){
}
}
}
void Interface_graphic::on_export_file_triggered(){
void Interface_graphic::on_export_triggered(){
QString filename = QFileDialog::getSaveFileName(_ui_main_window, tr("Export File"),
"",
tr("Images (*.svg)"));
QString filename = QFileDialog::getSaveFileName(this, tr("Export File"),
"",
tr("Images (*.svg)"));
if (!filename.isEmpty()){
/* QApplication::setOverrideCursor(Qt::WaitCursor);
out << textEdit->toPlainText();
QApplication::restoreOverrideCursor();
*/
information(string("Exporting trace to ")+filename.toStdString());
{
Svg svg;
svg.init(filename.toStdString().c_str());
_core->draw_trace(_trace_path, &svg);
}
information(string("Exporting trace to ")+filename.toStdString());
{
Svg svg;
QApplication::setOverrideCursor(Qt::WaitCursor);
svg.init(filename.toStdString().c_str());
_core->draw_trace(_trace_path, &svg);
QApplication::restoreOverrideCursor();
}
}
else
error("No file specified for exportation");
}
......@@ -283,14 +255,14 @@ void Interface_graphic::on_close_triggered(){
_ui_render_area->update();
_ui_main_window->setWindowTitle(QString("ViTE"));
this->setWindowTitle(QString("ViTE"));
}
void Interface_graphic::on_quit_triggered(){
close();
((QWidget*)this)->close();
}
......@@ -306,10 +278,9 @@ void Interface_graphic::on_fullscreen_triggered(){
the main window is displayed in fullscreen mode
*/
if (_ui_fullscreen_menu->isChecked())
_ui_main_window->showFullScreen();
this->showFullScreen();
else
_ui_main_window->showNormal();
this->showNormal();
}
void Interface_graphic::on_toolbar_menu_triggered(){
......@@ -320,7 +291,10 @@ void Interface_graphic::on_toolbar_menu_triggered(){
}
void Interface_graphic::on_show_info_triggered(){
_ui_info_window->show();
if (_ui_info_window->isHidden())
_ui_info_window->show();
else
_ui_info_window->hide();
}
......@@ -336,13 +310,13 @@ void Interface_graphic::on_help_triggered(){
void Interface_graphic::on_about_triggered(){
/* QMessageBox::about(_ui_main_window, tr("About ViTE"),
/* QMessageBox::about(this, tr("About ViTE"),
tr("<b>ViTE</b> is a trace format visualizer developped "
"by french engineering school students for INRIA researchers (<a href='http://www.inria.fr'>http://www.inria.fr</a>).<br/><br/>"
"It is licensed under <i>CECILL-A</i>."));*/
QMessageBox::about(_ui_main_window, tr("About ViTE"),
tr("<b>ViTE</b> version 0.2"));
QMessageBox::about(this, tr("About ViTE"),
tr("<b>ViTE</b> version 0.3"));
}
......@@ -370,12 +344,13 @@ void Interface_graphic::on_scale_container_state_valueChanged(int new_value){
}
void Interface_graphic::on_main_window_hide(){
void Interface_graphic::closeEvent(QCloseEvent *event){
cerr << "GoodBye"<<endl;
event->accept();/* accept to hide the window for a further destruction */
}
const std::string Interface_graphic::get_filename() const{
return _trace_path;
}
......@@ -12,6 +12,8 @@ class Interface_graphic;
#include <QtGui>
#include <QtUiTools>/* for the run-time loading .ui file */
#include "../ui_main_window.h"/* the main window graphical interface */
#include "interface.hpp"
#include "interface_console.hpp"
#include "render_area.hpp"
......@@ -22,7 +24,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 QWidget, public Interface{
class Interface_graphic : public QMainWindow, protected Ui::main_window, public Interface{
Q_OBJECT
......@@ -54,7 +56,7 @@ class Interface_graphic : public QWidget, public Interface{
/*!
* \brief This variable contains the main window of the application.
*/
QWidget* _ui_main_window;
// QWidget* _ui_main_window;
/*!
* \brief This variable contains the action to switch in fullscreen mode.
......@@ -216,7 +218,7 @@ protected slots:
/*!
*\brief A slot which called when 'export' in the menu is clicked.
*/
void on_export_triggered();
void on_export_file_triggered();
/*!
*\brief A slot which called when 'close' in the menu is clicked.
......@@ -272,9 +274,13 @@ protected slots:
void on_scale_container_state_valueChanged(int new_value);/* temporary slot */
/*!
* \brief temporary.
* \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 on_main_window_hide();
void closeEvent(QCloseEvent *event);
};
#endif
......@@ -160,7 +160,7 @@
<string>&amp;File</string>
</property>
<addaction name="open" />
<addaction name="export" />
<addaction name="export_file" />
<addaction name="separator" />
<addaction name="close" />
<addaction name="separator" />
......@@ -215,7 +215,7 @@
<bool>false</bool>
</attribute>
<addaction name="open" />
<addaction name="export" />
<addaction name="export_file" />
<addaction name="separator" />
<addaction name="actionZoomin" />
<addaction name="actionZoomout" />
......@@ -309,7 +309,7 @@
<string>Show infos window</string>
</property>
</action>
<action name="export" >
<action name="export_file" >
<property name="icon" >
<iconset resource="vite.qrc" >
<normaloff>:/icon/icon/export_svg.png</normaloff>:/icon/icon/export_svg.png</iconset>
......
......@@ -54,15 +54,20 @@ Render_area::Render_area(QWidget *parent)
_render_width = 100;/* 100 OpenGL units for the render scene width */
_render_height = 100;/* 100 OpenGL units for the render scene height */
_x_scale_container_state = 0.2;/* 20% of screen is used for containers then the other part for states */
_default_entity_x_translate = 20;/* _render_width * _x_scale_container_state */
_container_x_max = 0;
_container_y_max = 0;
_container_x_min = 0;
_container_y_min = 0;
_state_x_max = 0;
_state_y_max = 0;
_state_x_min = 0;
_state_y_min = 0;
_x_scale_container_state = 0.2;/* 20% of screen is used for containers then the other part for states */
/* OpenGL lists */
......@@ -159,6 +164,8 @@ void Render_area::paintGL(){
string buf_txt;
resizeGL(width(), height());
glClearDepth(1.0);
......@@ -268,9 +275,10 @@ void Render_area::paintGL(){
/* Draw states */
glPushMatrix();
glTranslated( _render_width*_x_scale_container_state-_state_translate , 0.0f, _z_state);
//glScalef( _state_scale*(_render_width/_state_x_max), _render_height/_state_y_max, 0.0f);
glScalef( _state_scale*(_render_width/_state_x_max), _render_height/_container_y_max, 0.0f);
// glTranslated( _render_width*_x_scale_container_state-_state_translate , 0.0f, _z_state);
glTranslated( _default_entity_x_translate - _state_translate , 0.0f, _z_state);
glScalef( _state_scale*(_render_width/_state_x_max), _render_height/_state_y_max, 0.0f);
......@@ -284,7 +292,7 @@ void Render_area::paintGL(){
/* Draw counters */
glPushMatrix();
glTranslated( _render_width*_x_scale_container_state-_state_translate , 0.0f, _z_counter);
glTranslated(_default_entity_x_translate - _state_translate , 0.0f, _z_counter);
glScalef( _state_scale*(_render_width/_state_x_max), _render_height/_container_y_max, 0.0f);
if (glIsList(_list_counters)==GL_FALSE)
......
......@@ -264,6 +264,16 @@ class Render_area : public QGLWidget, public Render
*/
Element_pos _container_y_max;
/*!
* \brief The x base of container area draw.
*/
Element_pos _container_x_min;
/*!
* \brief The y base of container area draw.
*/
Element_pos _container_y_min;
/*!
* \brief The width of state area draw.
*/
......@@ -273,6 +283,16 @@ class Render_area : public QGLWidget, public Render
* \brief The height of state area draw.
*/
Element_pos _state_y_max;
/*!
* \brief The x base of state area draw.
*/
Element_pos _state_x_min;
/*!
* \brief The y base of state area draw.
*/
Element_pos _state_y_min;
/*!
* \brief z position for containers.
......@@ -299,6 +319,10 @@ class Render_area : public QGLWidget, public Render
*/
Element_pos _z_counter;
/*!
* Default offset of entities drawing.
*/
Element_pos _default_entity_x_translate;
/***********************************
* Trace Drawing functions and attributes.
......@@ -540,6 +564,7 @@ inline void Render_area::draw_container(const Element_pos x, const Element_pos y
float j=0.6;
glBegin(GL_QUADS);/* create a quads */
{
glColor3d(0, 0, j);glVertex2d(x, y);
......@@ -555,6 +580,22 @@ inline void Render_area::draw_container(const Element_pos x, const Element_pos y
if ((y+h)>_container_y_max)
_container_y_max = y+h;
if (_container_x_min > x)
_container_x_min = x;
if (_container_y_min > y)
_container_y_min = y;
#ifdef DEBUG_MODE_RENDER_AREA
std::cerr << __FILE__ << " l." << __LINE__ << ":" << std::endl;
std::cerr < "Container drawing:" << std::endl;
std::cerr << "x: " << x << " y: " << y << " w: " << w << " h: " << h << " xmax-xmin: " << _container_x_max << " - " << _container_x_min << " ymax-ymin: " << _container_y_max << " - " << _container_y_min << std::endl;
#endif
}
inline void Render_area::draw_container_text(const Element_pos x, const Element_pos y, const std::string value){
......@@ -616,6 +657,12 @@ inline void Render_area::draw_state(const Element_pos start, const Element_pos e
if ((base+height)>_state_y_max)
_state_y_max = base+height;
if (_state_x_min > start)
_state_x_min = start;
if (_state_y_min > base)
_state_y_min = base;
}
......@@ -652,8 +699,8 @@ inline void Render_area::draw_stored_arrows(std::vector<Arrow_> &arrows){
for (long i=0 ; i<(long)arrows.size() ; i++){
start_time = arrows[i].start_time*arrow_scale_x + _render_width*_x_scale_container_state-_state_translate;
end_time = arrows[i].end_time*arrow_scale_x + _render_width*_x_scale_container_state-_state_translate;
start_time = arrows[i].start_time*arrow_scale_x + _default_entity_x_translate -_state_translate;
end_time = arrows[i].end_time*arrow_scale_x + _default_entity_x_translate - _state_translate;
start_height = arrows[i].start_height*arrow_scale_y;
end_height = arrows[i].end_height*arrow_scale_y;
......@@ -734,7 +781,7 @@ inline void Render_area::draw_stored_events(std::vector<Event_> &events){
for (long i=0 ; i<(long)events.size() ; i++){
time = events[i].time*event_scale_x + _render_width*_x_scale_container_state-_state_translate;
time = events[i].time*event_scale_x + _default_entity_x_translate -_state_translate;
height = events[i].height*event_scale_y;
container_height = events[i].container_height*event_scale_y;
......
......@@ -2,7 +2,7 @@
# Automatically generated by qmake (2.01a) mar. mars 3 19:58:07 2009
######################################################################
RESOURCES= vite.qrc
#RESOURCES= vite.qrc
OBJECTS_DIR=../bin
DESTDIR=../bin
CONFIG+=uitools debug
......
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