Commit 7bda0d0d authored by Olivier Lagrasse's avatar Olivier Lagrasse

- Fix seg fault bug on startup for Linux x64.

- Moreover, restore possibility to open many traces at the same time.
parent 9aba6c07
......@@ -115,25 +115,28 @@ Core::Core(int argc, char ** argv){
bool useGUI;/* if window interface can be displayed */
QString current_path;
// QString current_path;
app = new QApplication(argc, argv);/* create the Qt application */
_run_env[0] = QDir::currentPath();
_run_env[1] = argv[0];
Message::set_interface(this);/* define which interface will receive messages */
useGUI = true;
// 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;
if (!useGUI){
// 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);
}
......@@ -146,6 +149,12 @@ Core::Core(int argc, char ** argv){
_time_start = 0;
_time_end = 0;
_run_env[0] = new QString(QDir::currentPath().toStdString().c_str());
_run_env[1] = new QString(argv[0]);
Message::set_interface(this);/* define which interface will receive messages */
_state = get_state(argc, argv);
/*
......@@ -168,6 +177,12 @@ Core::~Core(){
if(_trace != NULL){
delete _trace;
}
if (_run_env[0]!=NULL)
delete _run_env[0];
if (_run_env[1]!=NULL)
delete _run_env[1];
/* Qt desallocates _main_window and _render_opengl automatically */
//free(_run_env[0]);
......@@ -804,8 +819,8 @@ void Core::set_path_to_export(const string& path){
_path_to_export = path;
}
const QString* Core::get_runenv() const{
return _run_env;
const QString** Core::get_runenv() const{
return (const QString**)_run_env;
}
void Core::update_progress_bar(const int loaded){
......
......@@ -277,7 +277,7 @@ protected:
/*!
*\brief This attributes contains the launching current directory (_run_env[0]) and the first argument of the running command (_run_env[1]).
*/
QString _run_env[2];
QString* _run_env[2];
/*!
*\brief If a file must be opened, this attribute contains its path.
......@@ -399,7 +399,7 @@ public:
* \brief Get the _run_env matrix.
*
*/
const QString* get_runenv() const;
const QString** get_runenv() const;
/***********************************
......
......@@ -927,12 +927,14 @@ void Interface_graphic::open_trace(const QString &filename) {
QStringList arguments = (QStringList() << filename);
QString program;
const QString* run_env = _core->get_runenv();
QDir::setCurrent(run_env[0]);
QString run_cmd = run_env[1];
const QString** run_env = _core->get_runenv();
QDir::setCurrent(*run_env[0]);
QString run_cmd = *run_env[1];
cout << __FILE__ << " " << __LINE__ << " : " << run_env[0]->toStdString() << " " << run_env[1]->toStdString() << endl;
if (run_cmd.startsWith("."))
program = run_env[0]+(run_cmd.remove(0,1));
program = *run_env[0]+(run_cmd.remove(0,1));
else
program = run_cmd;
......
......@@ -340,6 +340,9 @@ public:
* This function stores all the information of the event to display it each time the render area need to be updated.
*/
inline void draw_event(Element_pos time, Element_pos height, Element_pos container_height){
/* For SVG */
Element_pos radius;/* the circle radius */
time = trace_to_render_x(time);
......@@ -350,6 +353,9 @@ public:
drawing_instance->draw_circle(time, height, _z_event, radius);
drawing_instance->draw_line(time, height,
time, height+container_height, _z_event);
/* For OpenGL */
drawing_instance->draw_event(time, height, container_height);
}
/*!
......
......@@ -76,6 +76,10 @@ static bool _draw_arrow;/* Yes, it is global, but also it is static. In fact, it
the Render_opengl class. */
static bool _draw_circle;/* Yes, it is global, but also it is static. In fact, it is used to
check the circle drawing state. It is not an attribute of
the Render_opengl class. */
const int Render_opengl::DRAWING_TIMER_DEFAULT = 10;
/***********************************
......@@ -137,7 +141,7 @@ void Render_opengl::initializeGL() {
glClearStencil(0);
_wait_list = draw_wait();
}
void Render_opengl::resizeGL(int width, int height) {
......@@ -162,7 +166,6 @@ void Render_opengl::resizeGL(int width, int height) {
glMatrixMode(GL_MODELVIEW);
}
void Render_opengl::paintGL(){
......@@ -770,7 +773,7 @@ void Render_opengl::draw_triangle(Element_pos , Element_pos ,
}
void Render_opengl::draw_line(Element_pos x1, Element_pos y1, Element_pos x2, Element_pos y2, Element_pos z){
if (_draw_ruler || _draw_arrow) return;/* do not draw line for ruler or for arrow */
if (_draw_ruler || _draw_arrow || _draw_circle) return;/* do not draw line for ruler or for arrow or for circle */
const Element_pos offset_x = -_default_entity_x_translate;
......@@ -787,7 +790,7 @@ void Render_opengl::draw_line(Element_pos x1, Element_pos y1, Element_pos x2, El
void Render_opengl::draw_circle(Element_pos x, Element_pos y, Element_pos z, Element_pos r){
Circle_ buf;
/* Circle_ buf;
const Element_pos offset_x = -_default_entity_x_translate;
const Element_pos offset_y = -_ruler_y - _ruler_height;
......@@ -796,7 +799,7 @@ void Render_opengl::draw_circle(Element_pos x, Element_pos y, Element_pos z, Ele
buf.z = z;
buf.r = r;
_circles.push_back(buf);
_circles.push_back(buf);*/
}
......@@ -805,6 +808,7 @@ void Render_opengl::start_draw(){
_draw_ruler = false;
_draw_container = false;
_draw_arrow = false;
_draw_circle = false;
}
......@@ -868,7 +872,16 @@ void Render_opengl::end_draw_arrows(){
_draw_arrow = false;
}
void Render_opengl::draw_event(const Element_pos , const Element_pos , const Element_pos ){
void Render_opengl::draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height){
Circle_ buf;
const Element_pos offset_x = -_default_entity_x_translate;
const Element_pos offset_y = -_ruler_y - _ruler_height;
buf.time = time + offset_x;
buf.height = height + offset_y;
buf.container_height = container_height + offset_y;
_circles.push_back(buf);
}
void Render_opengl::start_draw_counter(){
......@@ -992,22 +1005,32 @@ void Render_opengl::draw_stored_circles(){
const int step = 20;/* 20 polygons for the circle */
const float angle = M_PI/2.0f;
const float delta_angle = 2*M_PI/step;
const float radius = 0.3f;
set_color(1, 1, 1);
const unsigned int size = _circles.size();
for (unsigned int i=0 ; i<size ; i++){
/* Draw the circle */
glBegin(GL_POLYGON);
{
glColor3d(_red, _green, _blue);
for(int i = 0 ; i < step ; i ++){
glVertex3d(_circles[i].x + cos(angle+delta_angle*i)*_circles[i].r ,
_circles[i].y + sin(angle+delta_angle*i)*_circles[i].r ,
_circles[i].z);
glVertex3d(_circles[i].time + cos(angle+delta_angle*i)*radius ,
_circles[i].height + sin(angle+delta_angle*i)*radius ,
_z_event);
}
}
glEnd();
/* Draw the line */
glBegin(GL_LINES);
{
glVertex2d(_circles[i].time, _circles[i].height);
glVertex2d(_circles[i].time, _circles[i].height+_circles[i].container_height);
}
glEnd();
}
}
......@@ -75,7 +75,7 @@ struct Circle_{
/*!
* \brief Coordinates and radius.
*/
Element_pos x, y, z, r;
Element_pos time, height, container_height;
};
......
......@@ -159,7 +159,7 @@ void Render_stats_opengl::paintGL(){
buf_x = *it_pos + _translated_x;
it_pos ++;
buf_y = *it_pos + _translated_y;
buf_y = *it_pos - _translated_y;
buf_txt = *it_txt;
......
......@@ -220,7 +220,7 @@ inline void Render_stats_opengl::start_draw(){
_stats_beginned_drawed = true;
_rect_list = glGenLists(1);
if(_rect_list == 0) {
fprintf(stderr, "error while initialising _rect_list for stats\n");
std::cerr << "error while initialising _rect_list for stats\n" << std::endl;
}
glNewList(_rect_list, GL_COMPILE);
}
......
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