Commit 9c723680 authored by Olivier Lagrasse's avatar Olivier Lagrasse
Browse files

- Factorisation de code dans draw_trace() de interface_console.

parent 2098578a
......@@ -99,114 +99,75 @@ Interface_console::~Interface_console(){
bool Interface_console::draw_trace(const string & filename, const int format){
ParserPaje parser;
Svg svg;
DrawTrace<Render_opengl> drawing_ogl;
DrawTrace<Svg> drawing_svg;
parser.set_file_to_parse(filename);
QApplication::setOverrideCursor(Qt::WaitCursor);
if (_DRAW_SVG == format)
svg.init(_path_to_export.c_str());
switch(format){
/*******************
* OpenGL render
*******************/
case _DRAW_OPENGL:
{
DrawTrace<Render_opengl> drawing_ogl;
if (NULL == _trace){ /* no trace is loaded, parse the file */
_trace = new Trace();
// Init of the thread
parsing_thread thread;
thread.init(&parser, _trace, filename);
_progress_dialog = new QProgressDialog("Parsing", "Cancel", 0, 100, _main_window);
_progress_dialog->show();
thread.start();
int loaded = 0;
_main_window->setDisabled (true);
while(!parser.is_end_of_parsing()) {
loaded = parser.get_size_loaded();
sleep(1); // We wait 1 second
update_progress_bar(loaded);
QApplication::processEvents();
std::cout << "Loading of the trace : " << loaded << "%" << std::endl;
}
((ParserPaje)parser).reinit_cursor();
Error::print_numbers();
Error::flush("log.txt");
delete _progress_dialog;
_main_window->setDisabled (false);
// Wait for the end thread
while(!thread.isFinished()) {
}
if (NULL == _trace){ /* no trace is loaded, parse the file */
_trace = new Trace();
// Init of the thread
parsing_thread thread;
thread.init(&parser, _trace, filename);
_progress_dialog = new QProgressDialog("Parsing", "Cancel", 0, 100, _main_window);
_progress_dialog->show();
thread.start();
int loaded = 0;
_main_window->setDisabled (true);
while(!parser.is_end_of_parsing()) {
loaded = parser.get_size_loaded();
sleep(1); // We wait 1 second
update_progress_bar(loaded);
QApplication::processEvents();
std::cout << "Loading of the trace : " << loaded << "%" << std::endl;
}
((ParserPaje)parser).reinit_cursor();
Error::print_numbers();
Error::flush("log.txt");
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;
}
}
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;
}
Interval interval(_time_start, ((0==_time_end)?_trace->get_max_date():_time_end) );
drawing_ogl.build(_render_opengl, _trace, 0, interval);
_render_opengl->build();
_render_opengl->updateGL();
_render_opengl->refresh_scroll_bars();
_is_trace_loaded = true;
}
Interval interval(_time_start, ((0==_time_end)?_trace->get_max_date():_time_end) );
if (_DRAW_OPENGL == format){
drawing_ogl.build(_render_opengl, _trace, 0, interval);
_render_opengl->build();
_render_opengl->updateGL();
_render_opengl->refresh_scroll_bars();
_file_opened = filename;/* store filename for a future export */
break;
/*******************
* SVG render
*******************/
case _DRAW_SVG:
{
Svg svg;
svg.init(_path_to_export.c_str());
DrawTrace<Svg> drawing_svg;
if (NULL == _trace){/* no trace is loaded, parse the file */
_trace = new Trace();
try{
parser.parse(filename, *_trace);
}
catch (const string &error){
*Message::get_instance() << "Reason : " << error << Message::ende;
QApplication::restoreOverrideCursor();
return false;
}
}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;
}
Interval interval(_time_start, ((0==_time_end)?_trace->get_max_date():_time_end));
drawing_svg.build(&svg, _trace, 0, interval);
svg.end();
_is_trace_loaded = true;
}
break;
/*******************
* Error
*******************/
default:
}else if (_DRAW_SVG == format){
drawing_svg.build(&svg, _trace, 0, interval);
svg.end();
}else{/* error */
*Message::get_instance() << "No kind of render recognized" << Message::ende;
return false;
}
_is_trace_loaded = true;
QApplication::restoreOverrideCursor();
return true;
......
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