Render_alternate.cpp 39.1 KB
Newer Older
1 2 3 4 5 6 7 8
/*
** This file is part of the ViTE project.
**
** This software is governed by the CeCILL-A license under French law
** and abiding by the rules of distribution of free software. You can
** use, modify and/or redistribute the software under the terms of the
** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
** URL: "http://www.cecill.info".
Thibault Soucarre's avatar
Thibault Soucarre committed
9
**
10 11 12 13 14
** As a counterpart to the access to the source code and rights to copy,
** modify and redistribute granted by the license, users are provided
** only with a limited warranty and the software's author, the holder of
** the economic rights, and the successive licensors have only limited
** liability.
Thibault Soucarre's avatar
Thibault Soucarre committed
15
**
16 17 18 19 20 21 22 23 24 25
** In this respect, the user's attention is drawn to the risks associated
** with loading, using, modifying and/or developing or reproducing the
** software by the user in light of its specific status of free software,
** that may mean that it is complicated to manipulate, and that also
** therefore means that it is reserved for developers and experienced
** professionals having in-depth computer knowledge. Users are therefore
** encouraged to load and test the software's suitability as regards
** their requirements in conditions enabling the security of their
** systems and/or data to be ensured and, more generally, to use and
** operate it in the same conditions as regards security.
Thibault Soucarre's avatar
Thibault Soucarre committed
26
**
27 28 29 30 31 32 33 34 35 36 37 38 39
** The fact that you are presently reading this means that you have had
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developers are (for version 0.* to 1.0):
**
**        - COULOMB Kevin
**        - FAVERGE Mathieu
**        - JAZEIX Johnny
**        - LAGRASSE Olivier
**        - MARCOUEILLE Jule
**        - NOISETTE Pascal
**        - REDONDY Arthur
Thibault Soucarre's avatar
Thibault Soucarre committed
40
**        - VUCHENER Clément
41 42 43 44 45 46 47 48
**
*/
/*!
 *\file Render_alternate.cpp
 */


#include "common/common.hpp"
49
#include "common/Info.hpp"
50
#include "common/Message.hpp"
51
/* -- */
52
//#include "render/GanttDiagram.hpp"
53 54 55

#include <GL/glew.h>
/* -- */
56 57 58 59
#include <QFile> // For loading the wait image
#include <QDate>
#include <QTimer>
/* -- */
60
#include "interface/resource.hpp"
61 62 63 64 65 66 67 68
#include "interface/Interface.hpp"
/* -- */
#include "common/common.hpp"
#include "common/Info.hpp"
#include "common/Message.hpp"
/* -- */
#include "render/Ruler.hpp"
#include "render/Render_alternate.hpp"
69
#include "render/GanttDiagram.hpp"
70
#include "render/Shader.hpp"
Thibault Soucarre's avatar
Thibault Soucarre committed
71
#include "render/text2D.hpp"
72
/* -- */
73 74 75
#include "core/Core.hpp"
#include "render/vbo.hpp"
#include <iostream>
76
#define PI 3.14159265
77 78 79 80 81 82 83

using namespace std;


#define message *Message::get_instance() << "(" << __FILE__ << " l." << __LINE__ << "): "

static bool _draw_container;
84
static bool _draw_state;
85 86 87
static bool _draw_ruler;
static bool _draw_arrow;
static bool _draw_event;
88
//const int Render_alternate::DRAWING_TIMER_DEFAULT = 10;
89 90 91 92 93 94 95 96 97 98 99 100

/***********************************
 *
 *
 *
 * Constructor and destructor.
 *
 *
 *
 **********************************/

Render_alternate::Render_alternate(Core* core, QWidget *parent, const QGLFormat& format)
Thibault Soucarre's avatar
Thibault Soucarre committed
101
    : Hook_event(this, core, parent, format), _containers(GL_QUADS), _states(GL_QUADS), _events(GL_POLYGON), _arrows(GL_LINE), _counters(GL_LINE), _ruler(GL_QUADS), _shader("vertexshader.vertexshader", "fragmentshader.fragmentshader"), _modelview(glm::mat4(1.0)), _projection(glm::mat4(1.0)){
Thibault Soucarre's avatar
Thibault Soucarre committed
102

103
    setAutoFillBackground(false);
104

105 106 107 108
}


Render_alternate::~Render_alternate(){
109
    //cleanupText2D();
110 111 112 113 114 115 116 117 118 119 120 121 122
}

/***********************************
 *
 *
 *
 * Default QGLWidget functions.
 *
 *
 *
 **********************************/

void  Render_alternate::initializeGL() {
123 124
    glewExperimental = GL_TRUE;
    GLenum err = glewInit();
125
    if(err!=GLEW_OK){
126
        std::cout << "ERROR : GlewInit failed" << std::endl;
127
    }
128 129
    _shader.charger();
    glClearColor(0.5f, 0.5f, 0.55f, 0.0f);
130

131
    //glEnable(GL_DEPTH_TEST);
132

133
    //glClearStencil(0);
134 135 136 137 138
    std::cout << "init" << std::endl;
    if(_core == NULL)
        std::cout << "_core = NULL" << std::endl;
    _core->waitGUIInit->quit();
    std::cout << "init ok" << std::endl;
139 140
    _modelview = glm::scale(_modelview, glm::vec3(1,-1,1));
    _modelview = glm::translate(_modelview, glm::vec3(0,-Info::Render::height, 0));
141
    //initText2D("Holstein.DDS");
142 143 144 145
}

void  Render_alternate::resizeGL(int width, int height) {
    glViewport(0, 0, width, height);
Thibault Soucarre's avatar
Thibault Soucarre committed
146

147 148 149
    /* update informations about widget size */
    Info::Screen::width  = width;
    Info::Screen::height = height;
150 151 152 153 154 155 156 157 158
    if(_state == DRAWING_STATE_WAITING)
        _projection = glm::ortho(-50, 50, -50, 50);//, 0, 1);
    else if(_state == DRAWING_STATE_DRAWING)
        _projection = glm::ortho(0., Info::Render::width, 0., Info::Render::height, 0., 1.);
    else{
     message << tr("Undefined value for the drawing state attribute - Render area").toStdString() << Message::ende;
     }

        /*glMatrixMode(GL_PROJECTION);
159 160 161 162 163
    glLoadIdentity();


    if(DRAWING_STATE_WAITING == _state){// A wait is drawn
        glOrtho(-50, 50, -50, 50, 0, 1000);
Thibault Soucarre's avatar
Thibault Soucarre committed
164
    }else if (DRAWING_STATE_DRAWING == _state){// A trace is drawn
165 166 167 168
        glOrtho(0, Info::Render::width, 0, Info::Render::height, 0, -1000);
    }else{
        message << tr("Undefined value for the drawing state attribute - Render area").toStdString() << Message::ende;
    }
Thibault Soucarre's avatar
Thibault Soucarre committed
169

170

171 172
     glMatrixMode(GL_MODELVIEW);*/

173 174 175 176
}


void  Render_alternate::paintGL(){
Thibault Soucarre's avatar
Thibault Soucarre committed
177

178
    //glClearColor(0.0, 1.0, 0.0, 1.0);
179
    resizeGL(Render_alternate::QGLWidget::width(), Render_alternate::QGLWidget::height());
180 181 182 183
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    //select shader program
    glUseProgram(_shader.getProgramID());
    std::cout << "paintGL" << std::endl;
184 185 186
    glm::mat4 tmp = _modelview;
    //_modelview = glm::translate(_modelview, glm::vec3(0.0, Info::Render::height, 100.0));
    //_modelview = glm::rotate(_modelview, (float)180.0, glm::vec3(1.0, 0.0, 0.0));
Thibault Soucarre's avatar
Thibault Soucarre committed
187 188 189
    _ruler.lock();
     glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(_modelview));
    glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "projection"), 1, GL_FALSE, glm::value_ptr(_projection));
190 191
    glDrawArrays(GL_QUADS, 0, 8);
    glDrawArrays(GL_LINES, 8, _ruler.getNbVertex());
Thibault Soucarre's avatar
Thibault Soucarre committed
192
    _ruler.unlock();
193 194 195 196



    /* drawing containers*/
197 198
    _containers.lock();
    //_modelview = glm::translate(_modelview, glm::vec3(0.0f, _ruler_y + _ruler_height -_y_state_translate,  _z_container));
Thibault Soucarre's avatar
Thibault Soucarre committed
199
    _modelview = glm::translate(_modelview, glm::vec3(0.0, _ruler_y + _ruler_height - _y_state_translate, 0.0));
Thibault Soucarre's avatar
Thibault Soucarre committed
200
    _modelview = glm::scale(_modelview, glm::vec3(_x_scale_container_state/0.20, _y_state_scale, 1.0));
201
    glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(_modelview));
202
    glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "projection"), 1, GL_FALSE, glm::value_ptr(_projection));
203 204
    glDrawArrays(GL_QUADS, 0, _containers.getNbVertex());
    _containers.unlock();
205
    _modelview = tmp;
206 207 208

    /*drawing states*/
    _states.lock();
Thibault Soucarre's avatar
Thibault Soucarre committed
209
    _modelview = glm::translate(_modelview, glm::vec3(_default_entity_x_translate - _x_state_translate, _ruler_y + _ruler_height - _y_state_translate, 0.0/*_z_state*/));
210
    _modelview = glm::scale(_modelview, glm::vec3(_x_state_scale, _y_state_scale, 1));
211
    glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(_modelview));
212
    glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "projection"), 1, GL_FALSE, glm::value_ptr(_projection));
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
    glDrawArrays(GL_QUADS, 0, _states.getNbVertex());
    _states.unlock();
    _modelview = tmp;

    /*drawing links*/
    /*_arrows.lock();
    tmp = _modelview;
    _modelview = glm::translate(_modelview, glm::vec3(_default_entity_x_translate - _x_state_translate, 0 , 0));
    glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(_modelview));
    glDrawArrays(GL_LINES, 0, _arrows.getNbVertex());
    _arrows.unlock();
     _modelview = tmp;*/
    int n = _links.size()/4;
    for(int i=0; i<n ; i++){
        _arrows.lock();
        //save current modelview
        tmp = _modelview;
        //change matrix
Thibault Soucarre's avatar
Thibault Soucarre committed
231
        _modelview = glm::translate(_modelview, glm::vec3(_default_entity_x_translate - _x_state_translate, _ruler_y + _ruler_height - _y_state_translate , 0));
232
        _modelview = glm::scale(_modelview, glm::vec3(_x_state_scale, _y_state_scale, 1.0));
233 234 235
        _modelview = glm::translate(_modelview, glm::vec3(_links[4*i+2], _links[4*i+3], 0));
        _modelview = glm::rotate(_modelview, (float) _links[4*i], glm::vec3(0,0,1));
        _modelview = glm::scale(_modelview, glm::vec3(_links[4*i+1], _links[4*i+1/10], 1));
236

237 238
        //draw the arrow
        glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(_modelview));
239
        glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "projection"), 1, GL_FALSE, glm::value_ptr(_projection));
240 241 242 243 244
        glDrawArrays(GL_LINES, 0,6);
        _arrows.unlock();
        //restore matrix
        _modelview = tmp;
    }
Thibault Soucarre's avatar
Thibault Soucarre committed
245

246 247 248 249
    //    _containers.display(_modelview);
    //rendu
    //deselect shader
    glUseProgram(0);
Thibault Soucarre's avatar
Thibault Soucarre committed
250 251
    //_modelview = glm::translate(_modelview, glm::vec3(0.0, -100*Info::Render::height, 0.0));
    //_modelview = glm::scale(_modelview, glm::vec3(1000,100,1));
Thibault Soucarre's avatar
Thibault Soucarre committed
252
    /*for(int i=0; i<_texts.size(); i++){
Thibault Soucarre's avatar
Thibault Soucarre committed
253 254 255 256 257 258 259 260
        glm::vec4 current(_texts[i].x, _texts[i].y, 0.0, 1.0);
        //we get coordinates beetween (-1 ; 1)
        current = _projection * _modelview * current;
        //conversion to (0,800) and (0,600) corresponding to the size of the texture used
        current[0] = current[0] * 400 + 400;
        current[1] = current[1] * 300 + 300;
        printText2D(_texts[i].value.c_str(), current[0], current[1], _texts[i].size, _projection, _modelview);
    }
Thibault Soucarre's avatar
Thibault Soucarre committed
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
     _modelview = tmp;*/

    QFont arial_font = QFont("Arial", 10);
    qglColor(Qt::white);

    const QFontMetrics metric(arial_font);

    //we calculate the height of the interline we want : max height of the font + 1 pixel to avoid overlapping (metric.height() returns a bigger value, a bit too much)
    int height = metric.tightBoundingRect("fg").height()+1;

    /* Draw container text */
    const unsigned int texts_size = _texts.size();
    std::map<Element_pos,Element_pos> previous_by_column;


    //int skipped,displayed=0;
        for (unsigned int i=0 ; i<texts_size ; i++){



            if (trace_to_render_y(_texts[i].y) + 0.5 < 9) continue;/* Do not display text if it is on the ruler area */

            //check if ye are not too close to another container to properly display the text
            std::map<Element_pos,Element_pos>::const_iterator it = previous_by_column.find(_texts[i].x);
            const std::map<Element_pos,Element_pos>::const_iterator it_end = previous_by_column.end();

            if (it==it_end || render_to_screen_y(trace_to_render_y(_texts[i].y)) - render_to_screen_y(trace_to_render_y((*it).second))> height ){
                const QString text_elided = metric.elidedText(_texts[i].value.c_str(), Qt::ElideRight, _x_scale_container_state*Info::Screen::width/(Info::Trace::depth+1.));
                renderText ( render_to_screen_x(_texts[i].x * _x_scale_container_state/0.20),
                         render_to_screen_y( trace_to_render_y(_texts[i].y) + 0.5),
                         text_elided,
                         arial_font);

            //push only displayed values in the map
                previous_by_column[_texts[i].x]=_texts[i].y;
                //displayed++;
            }//else{skipped++;}
        }
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
        /* Draw ruler text */
        std::ostringstream buf_txt;
        Element_pos graduation_diff;
        Element_pos coeff_prefix;
        graduation_diff = Ruler::get_graduation_diff(Info::Render::_x_min_visible, Info::Render::_x_max_visible);
        coeff_prefix    = Ruler::get_coeff_for_common_prefix(Info::Render::_x_min_visible, Info::Render::_x_max_visible);

        arial_font.setPointSize(14);

        buf_txt.str("");/* flush the buffer */
        buf_txt << "min: " << (double)Info::Render::_x_min_visible;

        renderText (render_to_screen_x(trace_to_render_x(Info::Render::_x_min_visible)),
                    render_to_screen_y(3),
                    buf_txt.str().c_str(),
                    arial_font);

        buf_txt.str("");/* flush the buffer */
        buf_txt << "max: " << (double)Info::Render::_x_max_visible;

        renderText (render_to_screen_x(trace_to_render_x(Info::Render::_x_max_visible))-130,
                    render_to_screen_y(3),
                    buf_txt.str().c_str(),
                    arial_font);

        buf_txt.str("");
        buf_txt << Ruler::get_common_part_string(Info::Render::_x_min_visible, coeff_prefix) << "--";

        renderText (render_to_screen_x(trace_to_render_x((Info::Render::_x_min_visible +
                                                          Info::Render::_x_max_visible) / 2)),
                    render_to_screen_y(3),
                    buf_txt.str().c_str(),
                    arial_font);

        arial_font.setPointSize(10);

        for (Element_pos i = Info::Render::_x_min_visible ;
             i < Info::Render::_x_max_visible ;
             i+=graduation_diff){

            buf_txt.str("");/* flush the buffer */
            buf_txt << Ruler::get_variable_part(i, coeff_prefix, 2);

            renderText (render_to_screen_x(trace_to_render_x(i)+1),
                        render_to_screen_y(8),
                        buf_txt.str().c_str(),
                        arial_font);

    }
348

349
//     Render_alternate::QGLWidget::setFocus(Qt::ActiveWindowFocusReason);/* give the focus to the render area for mouse and keyboard events */
Thibault Soucarre's avatar
Thibault Soucarre committed
350

351

352 353
//     glClearDepth(1.0);
//     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
354

355
//     glLoadIdentity();
Thibault Soucarre's avatar
Thibault Soucarre committed
356 357


358
//     if(DRAWING_STATE_WAITING == _state){/* A wait is drawn */
Thibault Soucarre's avatar
Thibault Soucarre committed
359

360 361 362
//         /* turn around y axis */
//         _wait_angle+=0.1f;
//         if (_wait_angle>=360) _wait_angle=0.0f;
Thibault Soucarre's avatar
Thibault Soucarre committed
363

364
//         glPushMatrix();
Thibault Soucarre's avatar
Thibault Soucarre committed
365

366
//         glScalef(15, 15, 0);
Thibault Soucarre's avatar
Thibault Soucarre committed
367

368 369
//         glRotatef(-_wait_angle,0, 1, 0);
//         glRotatef(_wait_angle_y, 1, 0, 0);
370

Thibault Soucarre's avatar
Thibault Soucarre committed
371

372
//         glPopMatrix();
Thibault Soucarre's avatar
Thibault Soucarre committed
373

374

375 376 377
//     }else if (DRAWING_STATE_DRAWING == _state){/* A trace is drawn */
//         glMatrixMode(GL_MODELVIEW);
//         glLoadIdentity();
Thibault Soucarre's avatar
Thibault Soucarre committed
378

379 380 381 382
//         glPushMatrix();
//         {
//             glTranslated(0.0, Info::Render::height, 100.0);
//             glRotated(180.0, 1.0, 0.0, 0.0);
383

Thibault Soucarre's avatar
Thibault Soucarre committed
384

385 386
//             glPushMatrix();
//             {
387

388 389
//                 glTranslated(_default_entity_x_translate - _x_state_translate, _ruler_y + _ruler_height - _y_state_translate, 0.0);
//                 glScalef(_x_state_scale, _y_state_scale, 1.0);
390

391 392 393 394 395 396 397
//                 for (unsigned int i=0 ;
//                      i<_vbos.size()   ;
//                      i++){
//                     _vbos[i]->display();
//                 }
//             }
//             glPopMatrix();
398

399
//             call_ruler();
400

Thibault Soucarre's avatar
Thibault Soucarre committed
401

402 403
//              if (false == Info::Render::_no_arrows)/* display arrows */
//                  draw_stored_arrows();
Thibault Soucarre's avatar
Thibault Soucarre committed
404

405 406
//              if (false == Info::Render::_no_events)/* display events */
//                  draw_stored_circles();
407

408 409
//         }
//         glPopMatrix();
Thibault Soucarre's avatar
Thibault Soucarre committed
410

411 412 413
//         glPushMatrix();
//         {
//             glTranslated(0.0,  0.0, 100.0);/* not accurate */
Thibault Soucarre's avatar
Thibault Soucarre committed
414

415
//             if (_mouse_pressed){
Thibault Soucarre's avatar
Thibault Soucarre committed
416 417


418
//                 glTranslated(0.0, 0.0, _z_container_under);
Thibault Soucarre's avatar
Thibault Soucarre committed
419

420
//                 Element_pos old_x, old_y, new_x, new_y;
Thibault Soucarre's avatar
Thibault Soucarre committed
421

422 423


424 425 426 427
//                 old_x = _mouse_x*(Info::Render::width/Info::Screen::width);
//                 old_y =  Info::Render::height - _mouse_y*(Info::Render::height/Info::Screen::height);
//                 new_x = _new_mouse_x*(Info::Render::width/Info::Screen::width);
//                 new_y =  Info::Render::height - _new_mouse_y*(Info::Render::height/Info::Screen::height);
Thibault Soucarre's avatar
Thibault Soucarre committed
428

429
// #ifdef DEBUG_MODE_RENDER_OPENGL
Thibault Soucarre's avatar
Thibault Soucarre committed
430

431 432 433
//                 cerr << __FILE__ << " l." << __LINE__ << ":" << endl;
//                 cerr << "Selection rectangle position: (" << old_x << ", " << old_y << ") - (" << new_x << ", " << new_y << ")" << endl;
// #endif
Thibault Soucarre's avatar
Thibault Soucarre committed
434

435 436
//                 glEnable(GL_BLEND);
//                 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Thibault Soucarre's avatar
Thibault Soucarre committed
437

438 439 440 441 442 443 444 445 446
//                 /* Square for selection */
//                 glBegin(GL_QUADS);
//                 {
//                     glColor4d(0.9, 1.0, 0.9, _selection_rectangle_alpha);glVertex2d(old_x, old_y);
//                     glColor4d(0.9, 0.9, 0.9, _selection_rectangle_alpha);glVertex2d(old_x, new_y);
//                     glColor4d(0.9, 0.9, 0.9, _selection_rectangle_alpha);glVertex2d(new_x, new_y);
//                     glColor4d(0.9, 0.9, 0.9, _selection_rectangle_alpha);glVertex2d(new_x, old_y);
//                 }
//                 glEnd();
Thibault Soucarre's avatar
Thibault Soucarre committed
447

448
//                 glDisable(GL_BLEND);
449

450 451 452
//             }/* end  if (true==_mouse_pressed) */
//         }
//         glPopMatrix();
453 454


Thibault Soucarre's avatar
Thibault Soucarre committed
455

456 457 458
//     }else{
//         message << tr("Undefined value for the drawing state attribute - Render area").toStdString() << Message::ende;
//     }
459

460
//     glFlush();
461 462


463 464 465 466 467
//     /* Check the errors */
//     GLenum glerror;
//     glerror = glGetError();
//     if(glerror != GL_NO_ERROR)
//         message << tr("Render area : the following OpengGL error occured: ").toStdString() << (char *)gluErrorString(glerror) << Message::endw;
468 469 470



471 472
//     if(DRAWING_STATE_WAITING == _state)/* A wait is drawn, do not take car about the ruler drawing */
//         return;
473

474 475
//     QFont arial_font = QFont("Arial", 10);
//     qglColor(Qt::white);//QColor(0, 0, 0));
476 477


478 479 480 481 482 483 484 485 486 487
//     /* Draw container text */
//     const unsigned int texts_size = _texts.size();
//     for (unsigned int i=0 ; i<texts_size ; i++){
//         const QFontMetrics metric(arial_font);
//         const QString text_elided = metric.elidedText(_texts[i].value.c_str(), Qt::ElideRight, _x_scale_container_state*Info::Screen::width/3.);
//         renderText ( render_to_screen_x(_texts[i].x * _x_scale_container_state/0.20),
//                      render_to_screen_y( trace_to_render_y(_texts[i].y) + 0.5),
//                      text_elided,
//                      arial_font);
//     }
488

489 490 491 492 493 494
//     /* Draw ruler text */
//     std::ostringstream buf_txt;
//     Element_pos graduation_diff;
//     Element_pos coeff_prefix;
//     graduation_diff = Ruler::get_graduation_diff(Info::Render::_x_min_visible, Info::Render::_x_max_visible);
//     coeff_prefix    = Ruler::get_coeff_for_common_prefix(Info::Render::_x_min_visible, Info::Render::_x_max_visible);
495

496
//     //    painter.setFont(QFont("Arial", 14));
497

498
//     arial_font.setPointSize(14);
499

500 501
//     buf_txt.str("");/* flush the buffer */
//     buf_txt << "min: " << (double)Info::Render::_x_min_visible;
502

503 504 505 506
//     renderText (render_to_screen_x(trace_to_render_x(Info::Render::_x_min_visible)),
//                 render_to_screen_y(3),
//                 buf_txt.str().c_str(),
//                 arial_font);
507

508 509
//     buf_txt.str("");/* flush the buffer */
//     buf_txt << "max: " << (double)Info::Render::_x_max_visible;
510

511 512 513 514
//     renderText (render_to_screen_x(trace_to_render_x(Info::Render::_x_max_visible))-130,
//                 render_to_screen_y(3),
//                 buf_txt.str().c_str(),
//                 arial_font);
515

516 517
//     buf_txt.str("");
//     buf_txt << Ruler::get_common_part_string(Info::Render::_x_min_visible, coeff_prefix) << "--";
518

519 520 521 522 523 524 525
//     renderText (render_to_screen_x(
//                                    trace_to_render_x(
//                                                      (Info::Render::_x_min_visible +
//                                                       Info::Render::_x_max_visible) / 2)),
//                 render_to_screen_y(3),
//                 buf_txt.str().c_str(),
//                 arial_font);
526

527
//     arial_font.setPointSize(10);
528

529 530 531
//     for (Element_pos i = Info::Render::_x_min_visible ;
//          i < Info::Render::_x_max_visible ;
//          i+=graduation_diff){
Thibault Soucarre's avatar
Thibault Soucarre committed
532

533 534 535 536 537 538 539 540
//         buf_txt.str("");/* flush the buffer */
//         buf_txt << Ruler::get_variable_part(i, coeff_prefix, 2);

//         renderText (render_to_screen_x(trace_to_render_x(i)+1),
//                     render_to_screen_y(8),
//                     buf_txt.str().c_str(),
//                     arial_font);
//     }
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559
}





/***********************************
 *
 *
 *
 * Building functions.
 *
 *
 *
 **********************************/



bool Render_alternate::build(){
Thibault Soucarre's avatar
Thibault Soucarre committed
560

561 562 563 564 565 566 567 568 569 570 571 572
    _state = DRAWING_STATE_DRAWING;/* change the drawing state */

    /* disable some OpenGL features to enhance the rendering */
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_BLEND);

    replace_scale(1);/* for states scaling */
    _x_state_translate = 0;/* for states translation */
    _y_state_scale = 1;/* for states scaling */
    _y_state_translate = 0;/* for states translation */
    _x_scroll_pos = 0;/* horizontal bar placed on 0 */
    _y_scroll_pos = 0;/* vertical bar placed on 0 */
Thibault Soucarre's avatar
Thibault Soucarre committed
573

574 575 576 577 578 579 580 581 582
    if (NULL == _render_instance)
        return true;

    return true;
}



bool Render_alternate::unbuild(){
Thibault Soucarre's avatar
Thibault Soucarre committed
583

584 585 586 587 588 589 590
    /**********************
     *
     * Init OpenGL features
     *
     **********************/

    /* enable some OpenGL features*/
591 592
    // glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    // glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
Thibault Soucarre's avatar
Thibault Soucarre committed
593

594
    // glEnable(GL_TEXTURE_2D);
595

596 597
    // glEnable(GL_BLEND);/* enable blending for the alpha color */
    // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
598

599
    // glColor3d(1.0, 1.0, 1.0);/* init color to white */
600 601


602 603 604 605 606
    // /*****************************
    //  *
    //  * Init render area attributes
    //  *
    //  *****************************/
607

608
    // _state = DRAWING_STATE_WAITING;/* change the drawing state */
609

610 611
    // _wait_angle=0.0f;/* begin with 0 rad angle */
    // _wait_angle_y=0.0f;/* begin with 0 rad angle */
612

613 614 615 616 617
    // /* init measurement attributes */
    // Info::Container::x_max = 0;
    // Info::Container::y_max = 0;
    // Info::Container::x_min = 0;
    // Info::Container::y_min = 0;
618

619 620
    // //    Info::Render::_ui_render_min_value->setText("");
    // // Info::Render::_ui_render_max_value->setText("");
621

622 623 624 625 626 627
    // Info::Entity::x_max = 0;
    // Info::Entity::x_min = 0;
    // //    _state_x_max = 0;
    // _state_y_max = 0;
    // //    _state_x_min = 0;
    // _state_y_min = 0;
628

629 630 631
    // /* clear lists to store container texts */
    // _text_pos.clear();
    // _text_value.clear();
632

633 634 635
    // _arrows.clear();
    // _circles.clear();
    // _texts.clear();
636

637 638 639 640 641 642
    // for (unsigned int i=0 ;
    //      i<_vbos.size()   ;
    //      i++){
    //     delete _vbos[i];
    // }
    // _vbos.clear();
643

644 645
    // /* clear the event vector */
    // // _events.clear();
646

647 648
    // /* clear the arrow vector */
    // // _arrows.clear();
Thibault Soucarre's avatar
Thibault Soucarre committed
649

650 651 652
    // /* empty the selection stack */
    // while(false == _previous_selection.empty())
    //     _previous_selection.pop();
653

654 655
    // if (NULL == _render_instance)
    //     return true;
656

657 658 659
    // /* Now, timer is set */
    // if (_wait_timer == NULL){
    //     _wait_angle = 0.0f;
Thibault Soucarre's avatar
Thibault Soucarre committed
660

661 662 663 664
    //     /*  _wait_timer = new QTimer(this);
    //     connect(_wait_timer, SIGNAL(timeout()), _render_instance, SLOT(updateGL()));
    //     _wait_timer->start(_wait_spf);*/
    // }
665 666


667
    // return true;//_render_instance->display_unbuild();
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686
}





/***********************************
 *
 *
 *
 * Drawing function for the wait screen.
 *
 *
 *
 **********************************/



GLuint Render_alternate::draw_wait() {
687 688
    // GLuint object;
    // GLuint texture;
689

690
    // glGenTextures(1, &texture);/* create the texture and link it with the list previously created */
Thibault Soucarre's avatar
Thibault Soucarre committed
691

692
    // QFile texture_file(QString(":/img/img/logo") +  QDate::currentDate().toString("MMdd") + QString(".png"));
Thibault Soucarre's avatar
Thibault Soucarre committed
693

694 695 696 697
    // if (true == texture_file.exists())/* The texture exists */
    //     texture = bindTexture(QPixmap(texture_file.fileName()), GL_TEXTURE_2D);
    // else/* use the default picture */
    //     texture = bindTexture(QPixmap(":/img/img/logo.png"), GL_TEXTURE_2D);
698

Thibault Soucarre's avatar
Thibault Soucarre committed
699

700 701 702
    // /* apply some parameters on the texture */
    // glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    // glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
Thibault Soucarre's avatar
Thibault Soucarre committed
703

704
    // glEnable(GL_TEXTURE_2D);
705

706 707
    // glEnable(GL_BLEND);/* enable blending for the alpha color */
    // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
708

Thibault Soucarre's avatar
Thibault Soucarre committed
709

710 711 712 713 714 715 716 717
    // /* Now, timer is set */
    // if (_wait_timer == NULL){
    //     _wait_angle = 0.0f;
    //     /*
    //     _wait_timer = new QTimer(this);
    //     connect(_wait_timer, SIGNAL(timeout()), _render_instance, SLOT(updateGL()));
    //     _wait_timer->start(_wait_spf);*/
    // }
718

719
    // return object;
720 721 722 723 724 725 726 727 728 729 730
}



void Render_alternate::call_ruler(){
    Element_pos graduation_diff;
    Element_pos coeff_prefix;
    const Element_pos offset_x = _default_entity_x_translate;
    const Element_pos offset_y = _ruler_y + _ruler_height+3.5;

    update_visible_interval_value();
Thibault Soucarre's avatar
Thibault Soucarre committed
731

732 733
    graduation_diff = Ruler::get_graduation_diff(Info::Render::_x_min_visible, Info::Render::_x_max_visible);
    coeff_prefix    = Ruler::get_coeff_for_common_prefix(Info::Render::_x_min_visible, Info::Render::_x_max_visible);
Thibault Soucarre's avatar
Thibault Soucarre committed
734

735 736 737 738 739 740 741 742 743 744 745 746 747
    //draw quads
    set_color(0.0, 0.0, 1.0);
    _ruler.add(trace_to_render_x(Info::Render::_x_min_visible), 0, _r, _g, _b);
    _ruler.add(trace_to_render_x(Info::Render::_x_min_visible), 8, _r, _g, _b);
    _ruler.add(trace_to_render_x(Info::Render::_x_max_visible), 8, _r, _g, _b);
    _ruler.add(trace_to_render_x(Info::Render::_x_max_visible), 0, _r, _g, _b);
    set_color(0.0, 0.0, 0.0);
    _ruler.add(trace_to_render_x(Info::Render::_x_min_visible), 0, _r, _g, _b);
    _ruler.add(trace_to_render_x(Info::Render::_x_min_visible), 3, _r, _g, _b);
    _ruler.add(trace_to_render_x(Info::Render::_x_max_visible), 3, _r, _g, _b);
    _ruler.add(trace_to_render_x(Info::Render::_x_max_visible), 0, _r, _g, _b);

    //draw graduations
748
    set_color(1.0, 1.0, 1.0);
Thibault Soucarre's avatar
Thibault Soucarre committed
749

750 751 752 753 754 755 756 757 758 759
    for (Element_pos i = Info::Render::_x_min_visible ; i < Info::Render::_x_max_visible ; i+=graduation_diff){
        const Element_pos grad_div_by_5 = graduation_diff/5;
        for (Element_pos j = (i+grad_div_by_5) ; j<(i+graduation_diff) ; j+= grad_div_by_5){
            draw_line( trace_to_render_x(j) + offset_x, offset_y  ,
                       trace_to_render_x(j) + offset_x, 2+offset_y, _z_ruler);
        }

        draw_line( trace_to_render_x(i) + offset_x, offset_y-1  ,
                   trace_to_render_x(i) + offset_x, 4+offset_y, _z_ruler);
    }
Thibault Soucarre's avatar
Thibault Soucarre committed
760

761
    return;
Thibault Soucarre's avatar
Thibault Soucarre committed
762
}
763 764 765 766



void Render_alternate::set_color(float r, float g, float b){
767 768 769
    _r = r;
    _g = g;
    _b = b;
770 771
}

Thibault Soucarre's avatar
Thibault Soucarre committed
772
void Render_alternate::draw_text(const Element_pos x, const Element_pos y, const Element_pos size, const std::string s){
773
    if (_draw_ruler) return;/* do not draw text for ruler */
Thibault Soucarre's avatar
Thibault Soucarre committed
774 775
    Container_text_ buf;
    buf.x     = x;
Thibault Soucarre's avatar
Thibault Soucarre committed
776
    buf.y     = render_to_trace_y(y);// + offset_y; //render_to_trace_y(y);/* Cancel previous transformation. */
Thibault Soucarre's avatar
Thibault Soucarre committed
777 778 779
    buf.value = s;
    buf.size = size;
    _texts.push_back(buf);
780 781 782 783 784 785 786
}

void Render_alternate::draw_quad(Element_pos x, Element_pos y, Element_pos z, Element_pos w, Element_pos h){
    Element_pos offset_x;
    const Element_pos offset_y = -_ruler_y - _ruler_height;

    offset_x = 0;
787 788 789 790 791 792 793 794
    if(_draw_container){
        std::cout << "container : " << x << " " << y << " " << w << " " << h <<std::endl;
        _containers.add(x+offset_x  , y+offset_y  , _r,_g,_b);
        _containers.add(x+offset_x+w, y+offset_y  , _r,_g,_b);
        _containers.add(x+offset_x+w, y+offset_y+h, _r,_g,_b);
        _containers.add(x+offset_x  , y+offset_y+h, _r,_g,_b);
    }
    else if(_draw_states){
795
        offset_x = -_default_entity_x_translate;
796
        _states.add(x+offset_x  , y+offset_y  , _r, _g, _b);
Thibault Soucarre's avatar
Thibault Soucarre committed
797 798
        _states.add(x+offset_x+w, y+offset_y  , _r/2, _g/2, _b/2);
        _states.add(x+offset_x+w, y+offset_y+h, _r/2, _g/2, _b/2);
799
        _states.add(x+offset_x  , y+offset_y+h, _r, _g, _b);
Thibault Soucarre's avatar
Thibault Soucarre committed
800 801 802 803 804 805 806 807
    }
    else if(_draw_ruler){
        std::cout << "coucou" << std::endl;
        _ruler.add(x  , y  , _r, _g, _b);
        _ruler.add(x  , y+h, _r, _g, _b);
        _ruler.add(x+w, y+h, _r, _g, _b);
        _ruler.add(x+w, y  , _r, _g, _b);
    }
808 809


810
        /*state = Vbo::VBO_OK;
811

812 813
        if(NULL != _current_vbo)
            state = _current_vbo->add(8, data);
814

815 816 817
        if (Vbo::VBO_OUT_OF_MEMORY == state){
            /* Store the current vbo */
        // _vbos.push_back(_current_vbo);
Thibault Soucarre's avatar
Thibault Soucarre committed
818

819 820 821 822 823 824
            /* Create a new vbo */
        //  _current_vbo = NULL;/* DO NOT DEALLOCATE BEFORE!
        //  _current_vbo = new Vbo(100000, _current_vbo->QUADS);

        /*  if (NULL == _current_vbo)
                                 message << tr("Cannot create a Vbo for states.").toStdString() << Message::ende;*/
825

Thibault Soucarre's avatar
Thibault Soucarre committed
826

827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845

    /*
    glBegin(GL_QUADS);
    {
        glColor3d(_red, _green, _blue);
        glVertex3d(x + offset_x    , y + offset_y    , z        );
        glVertex3d(x + offset_x    , y + h + offset_y, z        );
        glColor3d(_red/1.5         , _green/1.5      , _blue/1.5);
        glVertex3d(x + w + offset_x, y + h + offset_y, z        );
        glVertex3d(x + w + offset_x, y + offset_y    , z        );
    }
    glEnd();*/
}

void Render_alternate::draw_triangle(Element_pos , Element_pos ,
                                  Element_pos , Element_pos ){
}

void Render_alternate::draw_line(Element_pos x1, Element_pos y1, Element_pos x2, Element_pos y2, Element_pos z){
846
    //    if (_draw_ruler || _draw_arrow || _draw_event) return;/* do not draw line for ruler or for arrow or for event */
847 848 849 850 851


    const Element_pos offset_x = -_default_entity_x_translate;
    const Element_pos offset_y = -_ruler_y - _ruler_height;

852 853 854 855
    if(_draw_counter){
        _counters.add(x1+offset_x,y1+offset_y,_r,_g,_b);
        _counters.add(x2+offset_x,y2+offset_y,_r,_g,_b);
    }
856 857 858 859
    else if(_draw_ruler){
        _ruler.add(x1+offset_x, y1+offset_y, _r, _g, _b);
        _ruler.add(x2+offset_x, y2+offset_y, _r, _g, _b);
    }
860 861 862 863 864 865 866 867 868
    else{

        glBegin(GL_LINES);
        {
            glColor3d(_r, _g, _b);
            glVertex3d(x1 + offset_x, y1 + offset_y, z);
            glVertex3d(x2 + offset_x, y2 + offset_y, z);
        }
        glEnd();
869 870 871 872 873 874 875 876 877
    }
}

void Render_alternate::draw_circle(Element_pos /*x*/, Element_pos /*y*/, Element_pos /*z*/, Element_pos /*r*/){
}


void Render_alternate::start_draw(){
    /* Init GLEW */
878
    //glewInit();
879 880 881 882 883
    _draw_ruler = false;
    _draw_container = false;
    _draw_arrow = false;
    _draw_event = false;

884
    //_current_vbo = NULL;
Thibault Soucarre's avatar
Thibault Soucarre committed
885

886 887 888 889 890 891 892 893 894 895 896 897 898 899
}

void Render_alternate::start_draw_containers(){
    _draw_container = true;
}

void Render_alternate::draw_container(const Element_pos , const Element_pos , const Element_pos , const Element_pos ){
}

void Render_alternate::draw_container_text(const Element_pos , const Element_pos , const std::string ){
}

void Render_alternate::end_draw_containers(){
    _draw_container = false;
900
    _containers.config();
901
    cout << "end_draw_containers" << endl;
902 903 904
}

void Render_alternate::start_draw_states(){
905
    _draw_states = true;
906 907 908 909 910 911 912
}

void Render_alternate::draw_state(const Element_pos , const Element_pos , const Element_pos , const Element_pos , const Element_col , const Element_col , const Element_col ){
}

void Render_alternate::end_draw_states(){

913 914
    _draw_states = false;
    _states.config();
915
    cout << "end_draw_states" << endl;
916 917 918 919 920 921 922 923 924 925 926
}

void Render_alternate::start_draw_arrows(){
    _draw_arrow = true;

}

void Render_alternate::draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height, const Element_col red, const Element_col green, const Element_col blue){

    const Element_pos offset_x = -_default_entity_x_translate;
    const Element_pos offset_y = -_ruler_y - _ruler_height;
927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945
    /*_arrows.add(start_time+ offset_x, start_height + offset_y, _r, _g, _b);
     _arrows.add(end_time  + offset_x, end_height   + offset_y, _r, _g, _b);*/
    //triangles ?
    Element_pos x0, x1, y0, y1, l, alpha, cos, sin;
    x0 = start_time   + offset_x;
    x1 = end_time     + offset_x;
    y0 = start_height + offset_y;
    y1 = end_height   + offset_y;
    //size of the arrow
    l = sqrt(pow(x1-x0,2)+pow(y1-y0,2));
    //calculate angle beetween arrow and horizontal axe
    cos = (x1-x0)/l;
    sin = (y1-y0)/l;
    alpha = acos(cos);
    if(sin<0) alpha*= -1;
    _links.push_back(alpha);
    _links.push_back(l);
    _links.push_back(x0);
    _links.push_back(y0);
946 947 948
}

void Render_alternate::end_draw_arrows(){
949 950 951 952 953 954 955 956 957 958
    //coordinates that we use for all arrows, we will change the angle and scale of using the modelview matrix
    _arrows.add(1,0,1,1,1);
    _arrows.add(0,0,1,1,1);
    _arrows.add(1,0,1,1,1);
    //_arrows.add(0,0,1,1,1);
    _arrows.add(cos(PI/8), -sin(PI/8), 1, 1, 1);
    _arrows.add(1,0,1,1,1);
    //_arrows.add(0,0,1,1,1);
    _arrows.add(cos(PI/8), sin(PI/8), 1, 1, 1);
    _arrows.config();
959
    _draw_arrow = false;
960
    cout << "end_draw_arrows " << _links.size() << endl;
961 962 963 964 965 966 967
}

void Render_alternate::start_draw_events(){
    _draw_event = true;
}

void Render_alternate::draw_event(const Element_pos time, const Element_pos height,  const Element_pos container_height){
968
    /*Event_ buf;
969 970 971 972 973 974 975 976 977 978
    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;
    buf.red              = _red;
    buf.green            = _green;
    buf.blue             = _blue;

979
     _circles.push_back(buf);*/
980 981 982 983 984
}


void Render_alternate::end_draw_events(){
    _draw_event = false;
985
    _events.config();
986
    cout << "end_draw_events" << endl;
987 988 989
}

void Render_alternate::start_draw_counter(){
990
    _draw_counter = true;
991 992 993 994 995 996
}

void Render_alternate::draw_counter(const Element_pos , const Element_pos ){
}

void Render_alternate::end_draw_counter(){
997 998
    _draw_counter = false;
    _counters.config();
999
    cout << "end_draw_counters" << endl;
1000 1001 1002 1003 1004 1005 1006 1007
}

void Render_alternate::start_ruler(){
    _draw_ruler = true;
}

void Render_alternate::end_ruler(){
    _draw_ruler = false;
Thibault Soucarre's avatar
Thibault Soucarre committed
1008 1009
    std::cout << "end_ruler" << std::endl;
    _ruler.config();
1010 1011 1012
}

void Render_alternate::end_draw(){
1013
    cout << "end_draw" << endl;
1014 1015 1016 1017 1018 1019 1020 1021
}


void Render_alternate::draw_stored_texts(){
}

void Render_alternate::draw_stored_arrows(){

1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087
    // /* Only draw triangle. Lines are already in a display list */
    // const Element_pos coeff = 180.0f/M_PI;
    // Element_pos angle;
    // Element_pos start_time, end_time, start_height, end_height;
    // Element_pos scaled_start_time, scaled_end_time, scaled_start_height, scaled_end_height;



    // const unsigned int arrow_size = _arrows.size();
    // for (unsigned int i=0 ; i<arrow_size ; i++){

    //     start_time   = _arrows[i].start_time;// + _x_state_scale*_x_state_translate;
    //     end_time     = _arrows[i].end_time;// + _x_state_scale*_x_state_translate;
    //     start_height = _arrows[i].start_height;
    //     end_height   = _arrows[i].end_height;

    //     set_color(_arrows[i].red, _arrows[i].green, _arrows[i].blue);

    //     scaled_start_time   = start_time   * _x_state_scale;
    //     scaled_end_time     = end_time     * _x_state_scale;
    //     scaled_start_height = start_height * _y_state_scale;
    //     scaled_end_height   = end_height   * _y_state_scale;

    //     glPushMatrix();
    //     {

    //         glTranslated(_default_entity_x_translate + _x_state_scale*end_time - _x_state_translate,
    //                      _ruler_y + _ruler_height + _y_state_scale*end_height - _y_state_translate,
    //                      _z_arrow);

    //         if (start_time != end_time){
    //             angle = atan2((scaled_end_height - scaled_start_height), (scaled_end_time - scaled_start_time))*coeff;/* arc tangent */
    //             glRotatef(angle, 0, 0, 1);
    //         }
    //         else
    //             glRotatef(90, 0, 0, 1);/* vertical alignment */

    //         glBegin(GL_TRIANGLES);
    //         {
    //             // glColor3d(_red, _green, _blue);
    //             glVertex2d(0.0, 0.0);
    //             glVertex2d(-1.2, -0.4);
    //             glVertex2d(-1.2, 0.4);
    //         }
    //         glEnd();

    //     }
    //     glPopMatrix();

    //     glPushMatrix();
    //     {

    //         glTranslated(_default_entity_x_translate - _x_state_translate,
    //                      _ruler_y + _ruler_height - _y_state_translate,
    //                      _z_arrow);
    //         glScalef(_x_state_scale, _y_state_scale, 1.0);

    //         glBegin(GL_LINES);
    //         {
    //             glVertex2d(start_time, start_height);
    //             glVertex2d(end_time  , end_height  );
    //         }
    //         glEnd();
    //     }
    //     glPopMatrix();
    // }
1088 1089 1090
}

void Render_alternate::draw_stored_circles(){
1091 1092 1093 1094
    // 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 = .5f;
1095

1096
    // const unsigned int size = _circles.size();
1097

1098
    // for (unsigned int i=0 ; i<size ; i++){
Thibault Soucarre's avatar
Thibault Soucarre committed
1099

1100 1101
    //     glPushMatrix();
    //     {
1102

1103
    //         set_color(1.0 - _circles[i].red, 1.0 - _circles[i].green, 1.0 - _circles[i].blue);
Thibault Soucarre's avatar
Thibault Soucarre committed
1104

1105 1106 1107
    //         glTranslated(_default_entity_x_translate - _x_state_translate,
    //                      _ruler_y + _ruler_height - _y_state_translate,
    //                      _z_arrow);
Thibault Soucarre's avatar
Thibault Soucarre committed
1108

1109
    //          glScalef(_x_state_scale, _y_state_scale, 1.0);
Thibault Soucarre's avatar
Thibault Soucarre committed
1110

1111
    //          /* Draw the circle */
Thibault Soucarre's avatar
Thibault Soucarre committed
1112

1113 1114 1115 1116 1117 1118 1119 1120
    //          glBegin(GL_POLYGON);
    //          {
    //              for(int j = 0 ; j < step ; j ++){
    //                  glVertex2d(_circles[i].time + cos(angle+delta_angle*j)*radius/_x_state_scale,
    //                             _circles[i].height + sin(angle+delta_angle*j)*(radius/_y_state_scale)*Info::Screen::width/Info::Screen::height);
    //              }
    //          }
    //          glEnd();
1121

Thibault Soucarre's avatar
Thibault Soucarre committed
1122

1123
    //          set_color(_circles[i].red, _circles[i].green, _circles[i].blue);
Thibault Soucarre's avatar
Thibault Soucarre committed
1124

1125 1126 1127 1128 1129 1130 1131 1132 1133 1134
    //          /* Draw the sub-circle */
    //          glBegin(GL_POLYGON);
    //          {
    //              for(int j = 0 ; j < step ; j ++){
    //                  glVertex3d(_circles[i].time + cos(angle+delta_angle*j)*radius/(1.2*_x_state_scale) ,
    //                             _circles[i].height + sin(angle+delta_angle*j)*radius/(1.2*_y_state_scale)*Info::Screen::width/Info::Screen::height ,
    //                             0.1);
    //              }
    //          }
    //          glEnd();
Thibault Soucarre's avatar
Thibault Soucarre committed
1135 1136


1137 1138 1139 1140 1141 1142 1143 1144
    //          glLineWidth( 3.0 );
    //         /* 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();
1145

1146
    //         glLineWidth( 1.0 );
1147 1148


1149 1150 1151
    //     }
    //     glPopMatrix();
    // }
1152

1153
    // set_color(1.0, 1.0, 1.0);
Thibault Soucarre's avatar
Thibault Soucarre committed
1154

1155
}
1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185

void Render_alternate::release(){
    std::cout << "release" << std::endl;
}

void Render_alternate::draw_text_value(long int id,double text, double y){
}

void Render_alternate::show_minimap(){
}

/*!
 * \brief draws the vertical helper line
 */

void Render_alternate::draw_vertical_line(){
}

/*!
 * \brief slot connected to the simple click event
 */
void Render_alternate::update_vertical_line(){
}

/*!
     * \brief set the vertical line offset
     * \param l the line offset.
     */
void Render_alternate::set_vertical_line(Element_pos l){
}