Commit ab2bdec2 authored by Thibault Soucarre's avatar Thibault Soucarre

add ruler with Render_alternate but it's not affected by zoom

parent e8af4795
......@@ -187,9 +187,13 @@ void Render_alternate::paintGL(){
_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));
glDrawArrays(GL_QUADS, 0, _ruler.getNbVertex());
glDrawArrays(GL_QUADS, 0, 8);
glDrawArrays(GL_LINES, 8, _ruler.getNbVertex());
_ruler.unlock();
/* drawing containers*/
/* drawing containers*/
_containers.lock();
//_modelview = glm::translate(_modelview, glm::vec3(0.0f, _ruler_y + _ruler_height -_y_state_translate, _z_container));
_modelview = glm::translate(_modelview, glm::vec3(0.0, _ruler_y + _ruler_height - _y_state_translate, 0.0));
......@@ -292,6 +296,55 @@ void Render_alternate::paintGL(){
//displayed++;
}//else{skipped++;}
}
/* 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);
}
// Render_alternate::QGLWidget::setFocus(Qt::ActiveWindowFocusReason);/* give the focus to the render area for mouse and keyboard events */
......@@ -679,6 +732,19 @@ void Render_alternate::call_ruler(){
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);
//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
set_color(1.0, 1.0, 1.0);
for (Element_pos i = Info::Render::_x_min_visible ; i < Info::Render::_x_max_visible ; i+=graduation_diff){
......@@ -692,26 +758,6 @@ void Render_alternate::call_ruler(){
trace_to_render_x(i) + offset_x, 4+offset_y, _z_ruler);
}
glBegin(GL_QUADS);
{
glColor4d(0.0, 0.0, 1.0, 0.8);
glVertex3d(trace_to_render_x(Info::Render::_x_min_visible) , 0, _z_ruler_under );
glVertex3d(trace_to_render_x(Info::Render::_x_min_visible) , 8, _z_ruler_under );
glVertex3d(trace_to_render_x(Info::Render::_x_max_visible) , 8, _z_ruler_under );
glVertex3d(trace_to_render_x(Info::Render::_x_max_visible) , 0, _z_ruler_under );
}
glEnd();
glBegin(GL_QUADS);
{
glColor4d(0.0, 0.0, 0.0, 1.0);
glVertex3d(trace_to_render_x(Info::Render::_x_min_visible) , 0, _z_ruler_over );
glVertex3d(trace_to_render_x(Info::Render::_x_min_visible) , 3, _z_ruler_over );
glVertex3d(trace_to_render_x(Info::Render::_x_max_visible) , 3, _z_ruler_over );
glVertex3d(trace_to_render_x(Info::Render::_x_max_visible) , 0, _z_ruler_over );
}
glEnd();
return;
}
......@@ -797,7 +843,7 @@ void Render_alternate::draw_triangle(Element_pos , Element_pos ,
}
void Render_alternate::draw_line(Element_pos x1, Element_pos y1, Element_pos x2, Element_pos y2, Element_pos z){
if (_draw_ruler || _draw_arrow || _draw_event) return;/* do not draw line for ruler or for arrow or for event */
// if (_draw_ruler || _draw_arrow || _draw_event) return;/* do not draw line for ruler or for arrow or for event */
const Element_pos offset_x = -_default_entity_x_translate;
......@@ -807,6 +853,10 @@ void Render_alternate::draw_line(Element_pos x1, Element_pos y1, Element_pos x2,
_counters.add(x1+offset_x,y1+offset_y,_r,_g,_b);
_counters.add(x2+offset_x,y2+offset_y,_r,_g,_b);
}
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);
}
else{
glBegin(GL_LINES);
......
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