Commit d5d7cbac authored by Johnny Jazeix's avatar Johnny Jazeix

Ajout de la barre en couleur ^^ (enfin dans la console directement, les

couleurs ne s'affichent pas dans emacs ou dans d'autres trucs surement.

D'autres trucs plus intelligents aussi.
parent 9ba6ca39
......@@ -7,11 +7,53 @@ void Progress_bar_thread::init(Parser *p, Interface_console *i){
void Progress_bar_thread::run() {
int loaded = 0;
int current_color = VIOLET;
int number_of_color = 7;
color("47");
while(loaded < 95) {
loaded = _parser->get_size_loaded() + 1;
msleep(500); // We wait 500 ms
loaded = _parser->get_size_loaded();
sleep(1); // We wait 1 second
QApplication::processEvents();
_interface_console->update_progress_bar(loaded);
char text[3];
std::cout << "Loading of the trace : " ;
// Choice of the color to do a rainbow ^^, because it is useless
if(loaded < 100 / number_of_color){
current_color = RED;
}
else if(loaded < 200 / number_of_color){
current_color = ORANGE;
}
else if(loaded < 300 / number_of_color){
current_color = YELLOW;
}
else if(loaded < 400 / number_of_color){
current_color = GREEN;
}
else if(loaded < 500 / number_of_color){
current_color = CYAN;
}
else if(loaded < 600 / number_of_color){
current_color = BLUE;
}
else {
current_color = VIOLET;
}
sprintf(text, "%2d", current_color);
color(text);
std::cout << loaded << "%" << std::endl;
// Reinit of the color
color("0");
color("47");
color("30");
//_interface_console->update_progress_bar(loaded);
}
color("0");
}
......@@ -6,6 +6,29 @@
#include "interface_console.hpp"
#include <iostream>
/*
* \def couleur
* \param couleur
* \brief print in the console in color ^^
* useless and temporary
* Color Texte Arrière-plan
* Noir 30 40
* Rouge 31 41
* Vert 32 42
* Jaune 33 43
* Bleu 34 44
* Magenta 35 45
* Cyan 36 46
* Blanc 37 47
*/
#define color(param) printf("\033[%sm",param)
#define RED 30
#define ORANGE 31
#define YELLOW 33
#define GREEN 32
#define CYAN 36
#define BLUE 34
#define VIOLET 35
/*!
* \class Progress_bar_thread
......
......@@ -7,6 +7,12 @@
#include <QtGui>
/*!
* \class Help
* \brief Show the help menu
*/
class Help : public QWidget{
private:
QTextEdit *_text;
......
......@@ -113,12 +113,12 @@ bool Interface_console::draw_trace(const string & filename, const int format){
{
DrawTrace<Render_opengl> drawing_ogl;
// // Init of the thread
// Progress_bar_thread thread;
// thread.init(&parser, this);
// _progress_dialog = new QProgressDialog("Parsing", "Cancel", 0, 100, _main_window);
// _progress_dialog->show();
// thread.start();
// // Init of the thread
Progress_bar_thread thread;
thread.init(&parser, this);
// _progress_dialog = new QProgressDialog("Parsing", "Cancel", 0, 100, _main_window);
// _progress_dialog->show();
thread.start();
if (NULL == _trace){/* no trace is loaded, parse the file */
_trace = new Trace();
......@@ -134,16 +134,22 @@ bool Interface_console::draw_trace(const string & filename, const int format){
//delete _progress_dialog;
*Message::get_instance() << "Reason : " << error << Message::ende;
QApplication::restoreOverrideCursor();
// Wait for the end thread
while(!thread.isFinished()){
thread.exit();
}
return false;
}
//delete _progress_dialog;
_main_window->setDisabled (false);
// Wait for the end thread
while(!thread.isFinished());
}else if ( _file_opened != filename){/* just check if execution is normal */
*Message::get_instance() << "Try to use file: " << filename << " instead of a previous parsed file: " << _file_opened << Message::ende;
}
//delete _progress_dialog;
Interval interval(_time_start, ((0==_time_end)?_trace->get_max_date():_time_end) );
drawing_ogl.build(_render_opengl, _trace, 0, interval);
_render_opengl->build();
......@@ -233,7 +239,7 @@ int Interface_console::run(){
int Interface_console::get_state(int argc, char** argv){
/*The folowing statics must be initialised in case their are not overrided by a command line request*/
/*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);
......
......@@ -382,9 +382,8 @@ public:
/*!
* \brief Only use in graphic interface.
* \param string The string to be displayed.
*/
void selection_information(const std::string /*string*/) const{
void selection_information(const std::string ) const{
}
......
......@@ -33,8 +33,6 @@ const string Error::_UNKNOWN_VARIABLE_TYPE = "Unknown variable type: ";
const string Error::_UNKNOWN_LINK_TYPE = "Unknown link type: ";
const string Error::_UNKNOWN_ENTITY_TYPE = "Unknown entity type: ";
int Error::_priority_printable_min;
string Error::_content = "";
......@@ -144,7 +142,3 @@ void Error::flush_in_file(const string &filename){
}
}
void Error::set_priority_min_printable(const int priority_min){
Error::_priority_printable_min = priority_min;
}
......@@ -20,8 +20,6 @@ private:
Error();
static int _line_error;
static int _priority_printable_min;
static std::queue<std::string> _errors;
static std::queue<std::string> _warnings;
static std::string _content;
......@@ -220,9 +218,6 @@ public:
*/
static void flush_in_file(const std::string &filename);
static void set_priority_min_printable(const int priority_min);
};
#endif // ERRORS_HPP
......@@ -39,8 +39,6 @@ public:
*/
virtual int get_size_loaded() const = 0;
};
#endif // PARSER_HPP
......@@ -15,19 +15,16 @@ void ParserPaje::parse(string filename, Trace &trace){
Line line(_file_to_parse);
static const string PERCENT = "%";
string event_identity_string;
unsigned int event_identity;
int temp = 0;
while(!line.is_eof()) {
// For the thread of the progress bar
if(temp % 2000 == 0){
QApplication::processEvents();
}
temp ++;
// For the rabbit, else it does not turn :(
QApplication::processEvents();
line.newline();
if(line.starts_with(PERCENT)) {
parserdefinition->store_definition(line);
......@@ -61,6 +58,8 @@ void ParserPaje::parse(string filename, Trace &trace){
Error::print_numbers();
Error::flush_in_file("log.txt");
TokenSource::reinit_cursor();
delete parserdefinition;
delete parserevent;
}
......@@ -74,3 +73,4 @@ void ParserPaje::set_file_to_parse(const string filename){
int ParserPaje::get_size_loaded() const{
return (TokenSource::get_size_loaded());
}
......@@ -13,6 +13,7 @@ TokenSource::TokenSource(){
//no file are opened
//you must use open later
_is_eof = true;
_cursor = 0;
}
......@@ -27,12 +28,12 @@ TokenSource::~TokenSource(){
if (munmap(_buffer, _filesize) == -1){
Error::set_and_print(Error::_MUNMAP, Error::_WARNING);
}
_buffer = NULL;
close(_fd);
#endif
}
void TokenSource::open(const char *filename){
_cursor = 0;
_is_eof = false;
......@@ -201,20 +202,26 @@ std::string *TokenSource::read_token() {
}
int TokenSource::get_size_loaded() {
if(_filesize == 0) {
return 1;
}
#ifdef WIN32
if (_file == NULL)
return 1;
if (_file == NULL)
return 1;
if (!_file.is_open())
return 2;
if (!_file.is_open())
return 2;
if (_file.bad())
return 3;
if (_file.bad())
return 3;
return _file.tellg();
return _file.tellg();
#else
//std::cerr<<(int)((_cursor*100.0)/_filesize)<<"%"<<endl;
return (_cursor*100.0)/_filesize;
return (_cursor*100.0)/_filesize;
#endif
}
void TokenSource::reinit_cursor() {
_cursor = 0;
}
......@@ -107,7 +107,14 @@ public:
* \return the size already parsed
*/
static int get_size_loaded();
/*!
* \fn reinit_cursor()
* \brief Reinitialise the cursor of the file
*/
static void reinit_cursor();
};
#endif // TOKENSOURCE_HPP
......@@ -29,7 +29,7 @@ public:
/*!
* \brief Constructor
* \param container Container of this variable
* \parma type Type of this variable
* \param type Type of this variable
*/
Variable(Container *container, VariableType *type);
......
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