Commit a74377cc authored by Johnny Jazeix's avatar Johnny Jazeix

Fix output directory for doxygen files. Move parsing progress bar to graphical...

Fix output directory for doxygen files. Move parsing progress bar to graphical interface module (no more in the Core one). Remove some useless code commented (not used and won't be use) and some headers. Pass arguments by reference when possible (convert_to_double and export_variables functions).
parent 97d11860
......@@ -38,7 +38,7 @@ PROJECT_NUMBER = 1.2
# If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used.
OUTPUT_DIRECTORY = ../documentation/
OUTPUT_DIRECTORY = docs/
# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
# 4096 sub-directories (in 2 levels) under the output directory of each output
......
......@@ -52,7 +52,7 @@
/* -- */
using namespace std;
double convert_to_double(const string arg){
double convert_to_double(const string &arg){
double value = -1.0; // value returned
string arg_temp = arg + " 3";
int useless;
......
......@@ -49,12 +49,12 @@
#define TOOLS_HPP
/*!
* \fn convert_to_double(const std::string args)
* \fn convert_to_double(const std::string &args)
* \brief Convert the string in double
* \param args the string to be doublized.
* \return the double well converted or -1. on error.
*/
double convert_to_double(const std::string args);
double convert_to_double(const std::string &args);
// #define MIN(x,y) (((x)<(y))?(x):(y))
// #define MAX(x,y) (((x)<(y))?(y):(x))
......
......@@ -41,7 +41,7 @@
**
*/
/*!
*\file interface_console.cpp
*\file Core.cpp
*\brief This is the console interface C source code.
*/
......@@ -59,8 +59,6 @@
/* -- */
#include <QObject>
//#include <QtUiTools>/* for the run-time loading .ui file */
#include <QRadioButton>
#include <QTextEdit>
#include <QTextCodec>
#include <QTime>
#include <QDir>
......@@ -126,26 +124,16 @@ using namespace std;
Core::Core(int argc, char ** argv){
bool useGUI;/* if window interface can be displayed */
// QString current_path;
app = new QApplication(argc, argv);/* create the Qt application */
// glutInit(&argc, argv);/* use for OpenGL text */
/* Qt uses the default system encoding for QString (used when opening a file) */
QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale());
useGUI = true;
// cerr << "Core debug: " << QDir::currentPath().toStdString().c_str() << " " << argv[0] << endl;
/* if (!useGUI){
cerr << QObject::tr("Error: Graphical window cannot be displayed.").toStdString() << endl;
exit(EXIT_FAILURE);
}*/
_main_window = NULL;
_render_opengl = NULL;
_render_opengl = NULL;
_trace = NULL;
/* Init of the times */
......@@ -157,7 +145,6 @@ Core::Core(int argc, char ** argv){
Message::set_interface(this);/* define which interface will receive messages */
_state = get_state(argc, argv);
/*
......@@ -192,11 +179,7 @@ Core::~Core(){
/* Qt desallocates _main_window and _render_opengl automatically */
//free(_run_env[0]);
Message::kill();
}
......@@ -234,39 +217,33 @@ bool Core::draw_trace(const string & filename, const int format) {
if (_DRAW_SVG == format) {
_render_svg = new Render_svg(&_path_to_export);
// svg.init(_path_to_export.c_str());
}
else {
// We add the filename to the recent files opened list
Session::add_recent_file(QFileInfo(filename.c_str()).absoluteFilePath());
_main_window->update_recent_files_menu();
}
if (NULL == _trace) { /* no trace is loaded, parse the file */
/* Init data */
Info::Entity::x_min = 0;
Info::Entity::x_max = 0;
Info::Render::_x_min_visible = 0;
Info::Render::_x_max_visible = 0;
_trace = new Trace();
// Init of the thread
ParsingThread thread(parser, _trace);
int loaded = 0;
float loaded_f = 0.0f;/* floating value of the loading file state. (between 0 and 1) */
if(_main_window != NULL) { // If we have a window we show a progress bar
_progress_dialog = new QProgressDialog(QObject::tr("Parsing"), QObject::tr("Cancel"), 0, 100, _main_window);
_progress_dialog->setWindowTitle(QObject::tr("Loading of ")+QString::fromStdString(filename));
_progress_dialog->show();
_main_window->setDisabled(true);
_progress_dialog->setDisabled(false); // to be able to cancel while parsing
_main_window->init_parsing(filename);
}
thread.start();
time_elapsed.start();
buf_txt.str("");
......@@ -281,13 +258,13 @@ bool Core::draw_trace(const string & filename, const int format) {
sleep(1); // We wait 1 second
#endif
cout << QObject::tr("Loading of the trace : ").toStdString() << loaded << "%" ;
if (loaded_f>0.0f){
// divided by to have in second 1000 since time_elapsed.elapsed() returns ms */
time_buf = (int)(time_elapsed.elapsed() * (1.0 / loaded_f - 1.0) / 1000);
buf_txt.str(""); // Reinitialisation
if (loaded_f>0.0f){
// divided by to have in second 1000 since time_elapsed.elapsed() returns ms */
time_buf = (int)(time_elapsed.elapsed() * (1.0 / loaded_f - 1.0) / 1000);
if (time_buf>=3600){/* convert second in hour and min */
if (time_buf>=3600){ /* convert second in hour and min */
buf_txt << "Parsing... Remaining: " << time_buf/3600 << " h " << (time_buf%3600)/60 << " min " << time_buf%60 << " s";
}
else if (time_buf>=60){/* convert second in min */
......@@ -296,43 +273,38 @@ bool Core::draw_trace(const string & filename, const int format) {
else{
buf_txt << "Parsing... Remaining: " << time_buf << " s";
}
cout << " ~ " << buf_txt.str();
if ( (NULL!=_main_window) && (NULL!=_progress_dialog) )
_progress_dialog->setLabelText(QString( buf_txt.str().c_str()));
buf_txt.str("");
}
cout << endl;
if(_main_window != NULL) { // If we have a window we show a progress bar
update_progress_bar(loaded);
}
cout << endl;
if(_main_window != NULL) { // If we have a window we show a progress bar
_main_window->update_progress_bar(QString(buf_txt.str().c_str()), loaded);
QApplication::processEvents();
if(_progress_dialog->wasCanceled()) {
if(_main_window->is_parsing_canceled()) {
cout << QObject::tr("Canceled at ").toStdString() << loaded << "%" << endl;
parser->set_canceled();
*Message::get_instance() << QObject::tr("The trace opening was canceled by the user at ").toStdString() << loaded << "%" << Message::ende;
break; // Quit the loop
}
}
}
Error::print_numbers();
Error::flush("log.txt");
if(_main_window != NULL) { // If we have a window we show a progress bar
delete _progress_dialog;
_main_window->setDisabled (false);
}
// Wait for the end of the thread
while(!thread.wait()) {
}
if(_main_window != NULL) { // If we have a window we show a progress bar
_main_window->end_parsing();
}
delete parser;
}
else if ( _file_opened != filename) {/* just check if execution is normal */
......@@ -439,13 +411,6 @@ int Core::run(){
int Core::get_state(int argc, char** argv){
/*The following statics must be initialised in case their are not overrided by a command line request*/
/* Svg::set_height_factor (20);
Svg::set_wide_factor (100);
Svg::set_interval(0, 0);
Svg::set_accuracy(0.1);
Svg::set_scale_frequency(50);*/
if(argc == 1){
// just the name of the program, launch the window interface
return _STATE_LAUNCH_GRAPHICAL_INTERFACE;
......@@ -756,7 +721,6 @@ void Core::launch_action(int state, void* arg) {
cout << "the end of the trace.";
}
// Svg::set_interval(_time_start, _time_end);
draw_trace(_file_opened, _DRAW_SVG);
break;
......@@ -880,11 +844,6 @@ const QString** Core::get_runenv() const{
return (const QString**)_run_env;
}
void Core::update_progress_bar(const int loaded){
_progress_dialog->setValue(loaded);
_progress_dialog->update();
}
void Core::set_min_value_for_export(const double d) {
_time_start = d;
}
......@@ -898,7 +857,7 @@ Trace *Core::get_trace() const {
}
void Core::export_variable(Variable *var, string filename) {
void Core::export_variable(Variable *var, const string &filename) {
const list<pair<Date, Double> > *variable_values = var->get_values();
ofstream file(filename.c_str(), ios::out | ios::trunc);
......
......@@ -61,21 +61,18 @@ class Render_opengl;
class Render_svg;
class Trace;
//#include "render/Render.hpp"
class Variable;
class QApplication;
class QString;
//#include "render/Render.hpp"
//#include "interface/Interface.hpp"
// Todo : remove from the Core!!
#include <QProgressDialog>
/*!
*\brief This class is an terminal interface, it inherited from the Interface interface.
*/
class Core : public Interface{
public:
/***********************************
......@@ -325,11 +322,6 @@ protected:
*/
int _state;
/*!
*\brief To show the avancement of parsing.
*/
QProgressDialog *_progress_dialog;
/*!
* \brief Return the state of ViTE according to the arguments.
* \param argc The number of parameters given when the program was called.
......@@ -337,8 +329,6 @@ protected:
* \return An integer corresponding to a command which will be processed by ViTE.
*/
int get_state(int argc, char** argv);
/*!
* \brief Extracts the times of start and end in the string.
......@@ -473,16 +463,7 @@ public:
*\brief Export a counter
* Need to choose a counter, and a filename
*/
void export_variable(Variable *var, std::string filename);
public slots:
/*!
* \brief Update the progress bar value.
* \param loaded The percentage of trace which is already loaded.
*/
void update_progress_bar(const int loaded);
void export_variable(Variable *var, const std::string &filename);
};
......
......@@ -62,6 +62,7 @@
#include <QtGui/QTextEdit>
#include <QtGui/QCheckBox>
#include <QtGui/QMessageBox>
#include <QProgressDialog>
/* -- */
#include "interface/resource.hpp"
/* -- */
......@@ -114,6 +115,7 @@ Interface_graphic::Interface_graphic(Core* core, QWidget *parent):QMainWindow(pa
setMouseTracking (true);/* to catch mouse events */
_progress_dialog = NULL;
_plugin_window = NULL;
_ui_settings = NULL;
// _cmd_window = NULL;
......@@ -124,16 +126,13 @@ Interface_graphic::Interface_graphic(Core* core, QWidget *parent):QMainWindow(pa
}
Interface_graphic::~Interface_graphic(){
/* Qt desallocates this, _ui_info_window and _render_area automatically */
if(_plugin_window != NULL)
delete _plugin_window;
delete _plugin_window;
_plugin_window = NULL;
if (_cmd_window != NULL){
delete _cmd_window;
_cmd_window = NULL;
}
/* Qt desallocates this, _ui_info_window and _render_area automatically */
delete _cmd_window;
_cmd_window = NULL;
}
......@@ -151,7 +150,7 @@ Interface_graphic::~Interface_graphic(){
void Interface_graphic::load_windows(){
QUiLoader loader;
QFile file_info( ":/window/info_window.ui");
QFile file_info(":/window/info_window.ui");
QFile file_selection_export(":/window/option_export_window.ui");
QFile file_help(":/window/help_window.ui");
// QFile file_kind_of_export(":/window/kind_of_export.ui");
......@@ -239,7 +238,6 @@ void Interface_graphic::load_windows(){
/!\ -> use NULL as argument, else messages will be duplicated!
*/
QMetaObject::connectSlotsByName(NULL);
// QMetaObject::connectSlotsByName(_ui_time_selection_export);
_ui_x_scroll->setMaximum(_REAL_X_SCROLL_LENGTH);
_ui_y_scroll->setMaximum(_REAL_Y_SCROLL_LENGTH);
......@@ -395,7 +393,6 @@ int Interface_graphic::virtual_to_real_scroll_unit(Element_pos scroll_position,
case 'y':
return (int)(scroll_position*_y_factor_virtual_to_real);
break;
default:
error("Option not recognized.");
break;
......@@ -999,16 +996,15 @@ void Interface_graphic::update_recent_files_menu() {
void Interface_graphic::dragEnterEvent(QDragEnterEvent *event) {
setBackgroundRole(QPalette::Highlight);
event->acceptProposedAction();
event->acceptProposedAction();
}
void Interface_graphic::dragMoveEvent(QDragMoveEvent *event) {
event->acceptProposedAction();
event->acceptProposedAction();
}
void Interface_graphic::dragLeaveEvent(QDragLeaveEvent *event) {
event->accept();
}
void Interface_graphic::dropEvent(QDropEvent *event) {
......@@ -1029,6 +1025,35 @@ void Interface_graphic::dropEvent(QDropEvent *event) {
}
}
/* Graphical handling for parsing files */
void Interface_graphic::init_parsing(const std::string &filename) {
if(!_progress_dialog) {
_progress_dialog = new QProgressDialog(QObject::tr("Parsing"), QObject::tr("Cancel"), 0, 100, this);
}
_progress_dialog->setWindowTitle(QObject::tr("Loading of ")+QString::fromStdString(filename));
_progress_dialog->show();
setDisabled(true); // Disable the main window
_progress_dialog->setDisabled(false); // to be able to cancel while parsing
}
void Interface_graphic::update_progress_bar(const QString &text, const int loaded) {
_progress_dialog->setLabelText(text);
_progress_dialog->setValue(loaded);
_progress_dialog->update();
}
bool Interface_graphic::is_parsing_canceled() {
return _progress_dialog->wasCanceled();
}
void Interface_graphic::end_parsing() {
_progress_dialog->reset();
_progress_dialog->hide();
setDisabled(false); // Enable the main window
}
void Interface_graphic::open_trace(const QString &filename) {
......
......@@ -54,6 +54,7 @@ class Plugin_window;
class Command_window;
class Svg;
class Variable;
class QProgressDialog;
/* Includes needed by the moc */
#include <QGLWidget>
......@@ -94,7 +95,6 @@ class Interface_graphic : public QMainWindow, protected Ui::main_window, public
/*!
*\brief Drag and drop functions
*
*/
void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
......@@ -142,6 +142,11 @@ class Interface_graphic : public QMainWindow, protected Ui::main_window, public
*/
QScrollBar* _ui_y_scroll;
/*!
*\brief To show the avancement of parsing.
*/
QProgressDialog *_progress_dialog;
/*!
* \brief Contains the Core parent instance.
*/
......@@ -362,7 +367,33 @@ public:
*/
void selection_information(const std::string &string) const;
/***********************************
*
* Parsing functions.
*
**********************************/
/*!
* \brief Initialize the progress dialog bar and disable the main window.
* \param filename The file name of the file parsed.
*/
void init_parsing(const std::string &filename);
/*!
* \brief Update the bar with the new time and the percentage loaded.
* \param filename The file name of the file parsed.
*/
void update_progress_bar(const QString &text, const int loaded);
/*!
* \brief Says if the user has canceled the parsing operation. This means that he clicked on the cancel button of the progress dialog.
*/
bool is_parsing_canceled();
/*!
* \brief Finish the parsing by hiding the progress bar and enable the main window.
*/
void end_parsing();
/***********************************
......@@ -622,6 +653,7 @@ protected slots:
* \brief Says to the concerned classes that settings has been changed.
*/
void update_settings();
};
#endif
......@@ -61,6 +61,8 @@
*/
#include <QObject>
/* -- */
#include <cstdio>
#include <string>
#include <stack>
......
......@@ -44,6 +44,8 @@
*\file Render_svg.cpp
*/
#include <QObject>
/* -- */
#include <fstream>
#include <sstream>
#include <cmath>
......
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