Commit 76810876 authored by Olivier Lagrasse's avatar Olivier Lagrasse

- Events are available again for render and export.

- Add color for events.
- Change QPainter by QGLWidget::renderText in Render_opengl.cpp.
parent dd6bf6cf
......@@ -112,8 +112,8 @@ Geometry::Geometry(){
_z_container_under = -1.2;
_z_ruler = -0.5;
_z_ruler_under = -0.6;
_z_arrow = -2.0;/* closer to camera than containers or states (MUST be negative)*/
_z_event = -3.0;/* closer to camera than containers or states (MUST be negative)*/
_z_arrow = -3.0;/* closer to camera than containers or states (MUST be negative)*/
_z_event = -2.0;/* closer to camera than containers or states (MUST be negative)*/
_z_counter = -4.0;
_z_state = -5.0;
......
......@@ -333,10 +333,10 @@ public:
inline void end_draw_arrows(){
drawing_instance->end_draw_arrows();
}
/*
inline void start_draw_events(){
drawing_instance->start_draw_events();
}*/
}
/*!
* \brief Draw an event.
......@@ -346,16 +346,18 @@ 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){
inline void draw_event(Element_pos time, Element_pos height, Element_pos container_height, const Element_col r, const Element_col g, const Element_col b){
/* For SVG */
Element_pos radius;/* the circle radius */
drawing_instance->set_color(r, g, b);
time = trace_to_render_x(time);
height = trace_to_render_y(height);
container_height = container_height*coeff_trace_render_y();
radius = 0.3f;
radius = .5f;
drawing_instance->draw_circle(time, height, _z_event, radius);
drawing_instance->draw_line(time, height,
......@@ -364,10 +366,10 @@ public:
/* For OpenGL */
drawing_instance->draw_event(time, height, container_height);
}
/*
inline void end_draw_events(){
drawing_instance->end_draw_events();
}*/
}
/*!
* \brief Creates and opens the display list for counter draws.
......
This diff is collapsed.
......@@ -66,17 +66,24 @@ struct Arrow_{
* \brief Coordinates.
*/
Element_pos start_time, end_time, start_height, end_height;
/*!
* \brief Colors.
*/
Element_col red, green, blue;
};
/*!
* \brief Structure used to store circle information.
* \brief Structure used to store event information.
*/
struct Circle_{
struct Event_{
/*!
* \brief Coordinates and radius.
*/
Element_pos time, height, container_height;
/*!
* \brief Colors.
*/
Element_col red, green, blue;
};
......@@ -125,7 +132,7 @@ protected:
std::vector<Container_text_> _texts;
std::vector<Arrow_> _arrows;
std::vector<Circle_> _circles;
std::vector<Event_> _circles;
/***********************************
......@@ -327,6 +334,8 @@ public:
*/
// void draw_stored_arrows(std::vector<Arrow_> &arrows);
void start_draw_events();
/*!
* \brief Draw an event.
* \param time time when the event occurs.
......@@ -340,6 +349,9 @@ public:
*/
void draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height);
void end_draw_events();
/*!
* \brief Draw events contained in the Event_ vector
* \param events An event vector.
......
......@@ -118,7 +118,6 @@ void Render_svg::draw_text(const Element_pos x, const Element_pos y, const Eleme
void Render_svg::draw_quad(Element_pos x, Element_pos y, Element_pos , Element_pos w, Element_pos h){
// const Element_pos x_min = trace_to_render_x(Info::Render::_x_min_visible);
// const Element_pos x_max = trace_to_render_x(Info::Render::_x_max_visible);
......@@ -175,9 +174,10 @@ void Render_svg::draw_circle(Element_pos x, Element_pos y, Element_pos , Element
_buffer.str("");
_buffer << "<circle"
<< " cx=\"" << render_to_screen_x(x) << "\""
<< " cy=\"" << render_to_screen_x(y) << "\""
<< " cy=\"" << render_to_screen_y(y) << "\""
<< " r=\"" << max(render_to_screen_x(r), render_to_screen_y(r)) << "\""
<< " style=\"fill:yellow\""
<< " fill=\"rgb(" << floor(_red*256) << "," << floor(_green*256) << "," << floor(_blue*256) << ")\""/* TODO: choice better scale than '*256' */
<< " stroke=\"rgb(" << floor((1.0-_red)*256) << "," << floor((1.0-_green)*256) << "," << floor((1.0-_blue)*256) << ")\""/* TODO: choice better scale than '*256' */
<< "/>\n";
_output_file.write(_buffer.str().c_str(), _buffer.str().size());
......@@ -228,9 +228,15 @@ void Render_svg::draw_arrow(const Element_pos , const Element_pos , const Elemen
void Render_svg::end_draw_arrows(){
}
void Render_svg::start_draw_events(){
}
void Render_svg::draw_event(const Element_pos , const Element_pos , const Element_pos ){
}
void Render_svg::end_draw_events(){
}
void Render_svg::start_draw_counter(){
}
......
......@@ -173,6 +173,8 @@ public:
*/
// void draw_stored_arrows(std::vector<Arrow_> &arrows);
void start_draw_events();
/*!
* \brief Draw an event.
* \param time time when the event occurs.
......@@ -186,6 +188,7 @@ public:
*/
void draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height);
void end_draw_events();
/*!
* \brief Draw events contained in the Event_ vector
* \param events An event vector.
......
......@@ -370,6 +370,7 @@ public:
lvl_zoom = 0;
draw_object->start_draw_states();
draw_object->start_draw_events();
for (std::list<const Container *>::const_iterator c = _entity_containers.begin();
c != _entity_containers.end();
c++) {
......@@ -393,6 +394,7 @@ public:
}
}/* end for (!_stack_states.empty()) */
draw_object->end_draw_events();
draw_object->end_draw_states();
......
......@@ -129,9 +129,9 @@ public:
* \brief Draw an event
* \param time Time of the event
*/
inline void draw_event(double time) {
inline void draw_event(double time, double r, double g, double b) {
Element_pos y = _position*(_container_height+_container_v_space) + _container_v_space/2;
_draw_object->draw_event(time, y, _state_height);
_draw_object->draw_event(time, y, _state_height, r, g, b);
}
/*!
......@@ -171,7 +171,26 @@ struct DrawNode<D, Event> {
b=true;
i++;
draw->draw_event(node->get_element()->get_time().get_value());
std::map<std::string, Value *>::const_iterator field;
const Event *event = node->get_element();
const std::map<std::string, Value *> *extra_fields;
const Color *color;
extra_fields = event->get_value()->get_extra_fields();
// Search the color
if (event->get_value() &&
!event->get_value()->get_extra_fields()->empty() &&
((field = event->get_value()->get_extra_fields()->find(std::string("Color"))) != extra_fields->end())) {
/* Call the object event drawing function with the event color */
color = (const Color *)(*field).second;
draw->draw_event(node->get_element()->get_time().get_value(),
color->get_red(), color->get_green(), color->get_blue());
}else{
/* Call the object event drawing function with default color */
draw->draw_event(node->get_element()->get_time().get_value(),
1.0, 1.0, 1.0);
}
}
};
......
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