Commit 2de68443 authored by Olivier Lagrasse's avatar Olivier Lagrasse

Ajout des compteurs

Correction du bug ou les containers et les etats etaient decales 
(reinitialisation des positions)
Vidage des vecteurs de fleches et d'evenements pour eviter une 
accumulation entre les dessins
Reduction epaisseur des fleches et evenements
Ajout chemin de la trace dans barre de titre lors de l'ouverture en 
ligne de commande
La fenetre d'information ne s'affiche plus au demarrage mais quand un 
warning ou une erreur surviennent
Suppression warning a la compilation de info_window.ui
Reajustement de la profondeur (z-buffer) des entites
parent 441f570d
......@@ -61,10 +61,6 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
</layout>
<zorder>info_trace_text</zorder>
<zorder>info_trace_clear</zorder>
<zorder>verticalLayoutWidget</zorder>
<zorder>verticalLayoutWidget_2</zorder>
</widget>
</item>
<item>
......@@ -122,15 +118,6 @@ p, li { white-space: pre-wrap; }
</layout>
</item>
</layout>
<zorder>horizontalLayoutWidget</zorder>
<zorder>horizontalLayoutWidget</zorder>
<zorder>verticalLayoutWidget</zorder>
<zorder>gridLayoutWidget</zorder>
<zorder>verticalLayoutWidget</zorder>
<zorder>info_trace_clear</zorder>
<zorder>verticalLayoutWidget</zorder>
<zorder>verticalLayoutWidget_2</zorder>
<zorder>info_trace</zorder>
</widget>
</widget>
<resources>
......
......@@ -99,7 +99,6 @@ void Interface_graphic::load_windows(){
QMetaObject::connectSlotsByName(this);
/* Display both the main and informative windows */
_ui_info_window->show();
_ui_main_window->show();
}
......@@ -119,6 +118,8 @@ void Interface_graphic::error(const string s) const{
QString buf = s.c_str();
_ui_info_trace_text->moveCursor(QTextCursor::End);/* Insert the new text on the beginning */
_ui_info_trace_text->insertHtml("<font color='red'>"+buf+"</font><br /><br />");
_ui_info_window->show();
}
......@@ -126,6 +127,8 @@ void Interface_graphic::warning(const string s) const{
QString buf = s.c_str();
_ui_info_trace_text->moveCursor(QTextCursor::End);/* Insert the new text on the beginning */
_ui_info_trace_text->insertHtml("<font color='orange'>"+buf+"</font><br /><br />");
_ui_info_window->show();
}
......@@ -152,6 +155,8 @@ void Interface_graphic::opening_file(string const &path){
information(string("File opened: ")+ path);
_trace_path = path;
_ui_main_window->setWindowTitle(QString("ViTE :: ")+_trace_path.c_str());
_core->draw_trace(path, _ui_render_area);
......@@ -211,8 +216,7 @@ void Interface_graphic::on_open_triggered(){
}
else{
opening_file(filename.toStdString());
_ui_main_window->setWindowTitle(QString("ViTE :: ")+filename);
}
}
......
......@@ -75,7 +75,8 @@ Render_area::Render_area(QWidget *parent)
/* Camera is placed on (0,0,0) and looks to (0,0,-1) */
_z_container = -1.0f;
_z_arrow = -2.0f;/* closer to camera than containers or states (MUST be negative)*/
_z_state= -3.0f;
_z_event = -3.0f;/* closer to camera than containers or states (MUST be negative)*/
_z_state= -4.0f;
setAutoFillBackground(false);
}
......@@ -115,9 +116,6 @@ void Render_area::initializeGL(){
glClearStencil(0);
_wait_list = draw_wait();
message << "Counter drawing not yet implemented" << endw;
}
void Render_area::resizeGL(int width, int height){
......@@ -262,7 +260,7 @@ void Render_area::paintGL(){
glTranslated( _render_width*_x_scale_container_state-_state_translate , 0.0f, _z_state);
glScalef( _state_scale*(_render_width/_state_x_max), _render_height/_state_y_max, 0.0f);
if (glIsList(_list_states)==GL_FALSE)
message << "ERROR LIST not exist for states." << ende;
......@@ -271,7 +269,11 @@ void Render_area::paintGL(){
glPopMatrix();
//glCallList(_list_counters);
if (glIsList(_list_counters)==GL_FALSE)
;// message << "ERROR LIST not exist for counters." << ende;
else
glCallList(_list_counters);
draw_stored_arrows(_arrows);/* draw arrows without display lists */
......@@ -346,8 +348,7 @@ bool Render_area::build(){
/* disable some OpenGL features to enhance the rendering */
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
return true;
}
......@@ -385,6 +386,14 @@ bool Render_area::unbuild(){
glColor3d(1.0, 1.0, 1.0);/* init color to white */
/* init measurement attributes */
_container_x_max = 0;
_container_y_max = 0;
_state_x_max = 0;
_state_y_max = 0;
return true;
}
......
......@@ -236,6 +236,7 @@ class Render_area : public QGLWidget, public Render
Element_pos _z_container;/* z position for containers */
Element_pos _z_state;/* z position for states */
Element_pos _z_event;/* z position for events */
Element_pos _z_arrow;/* z position for arrows */
/***********************************
......@@ -377,6 +378,12 @@ inline void Render_area::start_draw(){
/* clear lists to store container texts */
_text_pos.clear();
_text_value.clear();
/* clear the event vector */
_events.clear();
/* clear the arrow vector */
_arrows.clear();
}
......@@ -524,19 +531,19 @@ inline void Render_area::draw_stored_arrows(std::vector<Arrow_> &arrows){
angle = atan2((end_height - start_height), (end_time - start_time))*180.0f/PI;/* arc tangent */
glRotatef(angle,0, 0, 1);
glRotatef(angle, 0, 0, 1);
}/* end if (start_time != end_time) */
else
glRotatef(90,0, 0, 1);/* vertical alignment */
glRotatef(90, 0, 0, 1);/* vertical alignment */
glBegin(GL_TRIANGLES);/* create an arrow */
{
glColor3d(1.0, 1.0, 1.0);glVertex2d(0.4, 0.0);
glColor3d(0.9, 0.9, 0.9);glVertex2d(-0.4, -0.4);
glColor3d(0.9, 0.9, 0.9);glVertex2d(-0.4, 0.4);
glColor3d(1.0, 1.0, 1.0);glVertex2d(0.0, 0.0);
glColor3d(0.9, 0.9, 0.9);glVertex2d(-0.6, -0.2);
glColor3d(0.9, 0.9, 0.9);glVertex2d(-0.6, 0.2);
}
glEnd();
......@@ -545,14 +552,14 @@ inline void Render_area::draw_stored_arrows(std::vector<Arrow_> &arrows){
glPushMatrix();
glTranslated(0, 0, _z_arrow);
glLineWidth(1.5f);
// glLineWidth(1.5f);
glBegin(GL_LINES);
{
glColor3d(1.0, 1.0, 1.0);glVertex2d(start_time, start_height);
glColor3d(0.9, 0.9, 0.9);glVertex2d(end_time, end_height);
glColor3d(0.8, 0.8, 0.8);glVertex2d(start_time, start_height);
glColor3d(1.0, 1.0, 1.0);glVertex2d(end_time, end_height);
}
glEnd();
glLineWidth(1.0f);/* 1 is the default value */
// glLineWidth(1.0f);/* 1 is the default value */
glPopMatrix();
}
......@@ -619,21 +626,21 @@ inline void Render_area::draw_stored_events(std::vector<Event_> &events){
glBegin(GL_POLYGON);
{
for(int i =0 ; i<step ; i++){
glVertex3d(time + cos(angle+delta_angle*i)*radius , height + sin(angle+delta_angle*i)*radius , _z_arrow);
glVertex3d(time + cos(angle+delta_angle*i)*radius , height + sin(angle+delta_angle*i)*radius , _z_event);
}
}
glEnd();
/* draw line */
glLineWidth(1.5f);
// glLineWidth(1.5f);
glBegin(GL_LINES);
{
glColor3d(0.5, 0.8, 0.5);glVertex3d(time, height, _z_arrow);
glColor3d(0.4, 0.7, 0.4);glVertex3d(time, height+container_height, _z_arrow);
glColor3d(0.5, 0.8, 0.5);glVertex3d(time, height, _z_event);
glColor3d(0.4, 0.7, 0.4);glVertex3d(time, height+container_height, _z_event);
}
glEnd();
glLineWidth(1.0f);
// glLineWidth(1.0f);
}/* and loop */
}
......@@ -647,8 +654,7 @@ inline void Render_area::start_draw_counter(){
_list_counters = glGenLists(1);/* create the list */
if (_list_counters==0){
// _parent->warning("Error when creating list");
//message_ns::message << "Error when creating list" << message_ns::ende;
}
glNewList(_list_counters, GL_COMPILE);/* open the list */
......@@ -659,34 +665,35 @@ inline void Render_area::start_draw_counter(){
inline void Render_area::draw_counter(const Element_pos x, const Element_pos y){
static bool which_color = true;
float a;
if (which_color==true){/* yellow color */
a = 0.0f;
which_color = false;
}else{/* white color */
a = 1.0f;
which_color = true;
}
glLineWidth(2.5f);
glBegin(GL_QUADS);
{
glColor3d(1.0, 1.0, a);glVertex2d(_counter_last_x, 0);
glColor3d(1.0, 1.0, a);glVertex2d(_counter_last_x, _counter_last_y);
glColor3d(1.0, 1.0, a);glVertex2d(x, y);
glColor3d(1.0, 1.0, a);glVertex2d(x, 0);
static bool line_already_begun = false;
if (x <= 0.0f ){
if (line_already_begun==true){/* it is not the first call */
glEnd();
}else
line_already_begun = true;
glBegin(GL_LINE_STRIP);/* set of connected verteces */
glColor3d(1.0, 1.0, 1.0);glVertex2d(0.0f, y);/* draw the init point */
_counter_last_x = 0.0f;
}else{
glColor3d(1.0, 1.0, 1.0);glVertex2d(x, y);
_counter_last_x = x;
}
glEnd();
glLineWidth(1.0f);
_counter_last_x = x;
_counter_last_y = y;
}
inline void Render_area::end_draw_counter(){
glEnd();/* suppose that line is not ended */
glEndList();/* close the list */
}
......
......@@ -19,9 +19,13 @@ public:
cerr << s << endl;
}
void information(string s) const{
cerr << s << endl;
}
void information(string s) const{
cerr << s << endl;
}
const std::string get_filename() const{
return string("Filename");
}
};
......@@ -44,16 +48,14 @@ int main(int argc, char** argv){
t.show();
Element_pos a = 50;
r.start_draw();
{
r.start_draw_containers();
{
r.draw_container(0, 0, 30, 20);
/* r.draw_container(0, 0, 30, 20);
r.draw_container(0, 22, 10, 20);
r.draw_container(0, 43, 15, 20);
r.draw_container(0, 43, 15, 20);*/
// r.draw_container(1, 60, 60, 20);
r.draw_container_text(0, 10,"Container 2");
r.draw_container_text(0, 32,"Container 1");
......@@ -63,7 +65,7 @@ int main(int argc, char** argv){
r.start_draw_states();
{
r.draw_state(0, 4, 0, 20, 0.6, 0.7, 0.8);
/* r.draw_state(0, 4, 0, 20, 0.6, 0.7, 0.8);
r.draw_state(4.5, 7.98, 0, 20, 0.6, 0.7, 0.8);
r.draw_arrow(10, 10, 0, 3);
r.draw_arrow(10, -10, -15, -3);
......@@ -71,18 +73,19 @@ int main(int argc, char** argv){
r.draw_event(14, 4, 2);
r.draw_event(10, 4, 1);
r.draw_event(18, 4, 3);
r.draw_event(10, 4, 10);
r.draw_event(10, 4, 10);*/
}
r.end_draw_states();
r.start_draw_counter();
{
r.draw_counter(5, 1);
r.draw_counter(17, 2);
r.draw_counter(0.0f, 1);
r.draw_counter(5, 1.2);
r.draw_counter(7, 2);
r.draw_counter(19.345, 3);
r.draw_counter(21.45, 2);
r.draw_counter(24.45, 2);
r.draw_counter(32, 6);
}
r.end_draw_counter();
......
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