Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Commit 1366a49e authored by Olivier Lagrasse's avatar Olivier Lagrasse
Browse files

- Add rule corrections.

parent d8952e48
......@@ -394,8 +394,10 @@ void Hook_event::mouseReleaseEvent(QMouseEvent * event){
return;
if (((_new_mouse_x-_mouse_x) < _minimum_distance_for_selection)
&& ((_new_mouse_y-_mouse_y) < _minimum_distance_for_selection))/* selection is too thin to draw a box. So, it must be a user click to displau entity information */
&& ((_new_mouse_y-_mouse_y) < _minimum_distance_for_selection)){/* selection is too thin to draw a box. So, it must be a user click to displau entity information */
_mouse_pressed = false;
return;/* escape */
}
/*
* Now, user was drawing a box. Zoom in it!
......@@ -624,15 +626,8 @@ void Hook_event::change_scale_y(Element_pos scale_coeff){
if (new_scale<1.0)
_y_state_scale = 1.0;
else{
_y_state_translate += ( _y_state_translate - _ruler_height + (Element_pos)_render_height/2.0) * ((new_scale)/(_y_state_scale) - 1);
_y_state_scale = new_scale;
_render_instance->updateGL();
refresh_scroll_bars(true);
}
else
replace_scale_y(new_scale);
}
......@@ -661,6 +656,28 @@ void Hook_event::replace_scale(Element_pos new_scale){
}
}
void Hook_event::replace_scale_y(Element_pos new_scale){
if(new_scale > 0.0){
/*
* Reajust the entity translation to recenter the same point previously under the mouse pointer
*
* Work out the distance between the point in the middle Widget and the state origin.
* Then multiply it by the scale coefficient ( (new_scale / old_scale) ) less 1.
* 1 corresponding to the original translation of the point from the state origin.
* Finally, translate the result.
*
*/
_y_state_translate += ( _y_state_translate - _ruler_height + (Element_pos)_render_height/2.0) * ((new_scale)/(_y_state_scale) - 1);
_y_state_scale = new_scale;
/* TODO add a zoom box value for y zoom */
_render_instance->updateGL();
refresh_scroll_bars(true);
}
}
void Hook_event::change_translate(int translate){
replace_translate(_x_state_translate + translate);
......@@ -725,12 +742,15 @@ void Hook_event::registered_translate(int id){
*((_render_height-_ruler_height)/(_state_y_max-_state_y_min)));
break;
case Info::Render::X_TRACE_ENTIRE:/* show the entire entities */
_x_state_translate = 0;
_x_state_scale = 1;
// replace_translate(0);//_x_state_translate = 0;
replace_scale(1);//_x_state_scale = 1;
replace_translate(0);
break;
case Info::Render::Y_TRACE_ENTIRE:/* show the entire entities */
_y_state_translate = 0;
_y_state_scale = 1;
/* _y_state_translate = 0;
_y_state_scale = 1; */
replace_scale_y(1);
replace_translate_y(0);
break;
default:
message << tr("Unknown registered translate").toStdString() << Message::endw;
......
......@@ -605,11 +605,17 @@ public:
void change_scale_y(Element_pos scale_coeff);
/*!
* \brief Replace the current scale by a new scale.
* \brief Replace the current scale by a new scale. (horizontally)
* \param new_scale The new scale value to replace the current scale.
*/
void replace_scale(Element_pos new_scale);
/*!
* \brief Replace the current scale by a new scale. (vertically)
* \param new_scale The new scale value to replace the current scale.
*/
void replace_scale_y(Element_pos new_scale);
/*!
* \brief Change the x position of camera view for state drawing area.
* \param translate The new position.
......
......@@ -246,8 +246,7 @@ void Render_opengl::paintGL(){
}else{
message << tr("Undefined value for the drawing state attribute - Render area").toStdString() << Message::ende;
}
glFlush();
......@@ -341,6 +340,16 @@ bool Render_opengl::unbuild(){
_state_y_max = 0;
_state_x_min = 0;
_state_y_min = 0;
/* clear lists to store container texts */
_text_pos.clear();
_text_value.clear();
/* clear the event vector */
_events.clear();
/* clear the arrow vector */
_arrows.clear();
_line_already_begun = false;
......@@ -446,21 +455,22 @@ GLuint Render_opengl::draw_ruler() {
}
/*
* Graduation number.
*/
nb_graduation = 20;
/*
* NOTE:
* _ruler_distance is the desire distance between 2 graduations.
* There are ceil(_render_width/_ruler_distance) graduations.
* Between 2 consecutive graduations, there are 4 small graduations.
*/
_ruler_distance = 1.0/nb_graduation;
_ruler_distance = 1.0/20.0;
/*
* Graduation number.
*/
nb_graduation = 20;
/*
* Distance between 2 small consecutive graduations.
*/
......@@ -481,7 +491,7 @@ GLuint Render_opengl::draw_ruler() {
glNewList(object, GL_COMPILE);
{
for (unsigned int i = 0 ; i<=nb_graduation ; i++){
for (unsigned int i = 0 ; i<=(nb_graduation-1) ; i++){
/*
* draw small graduations
......@@ -508,13 +518,23 @@ GLuint Render_opengl::draw_ruler() {
}/* end for ( i ) */
/*
* Draw the graduation
*/
glBegin(GL_LINES);
{
glColor3d(0.0, 0.0, 1.0);glVertex2d(nb_graduation*_ruler_distance, _ruler_y);
glColor3d(0.0, 0.0, 1.0);glVertex2d(nb_graduation*_ruler_distance, _ruler_y+_ruler_height);
}
glEnd();
/* Draw the background */
glBegin(GL_QUADS);
{
glColor4d(ruler_bg_r, ruler_bg_g, ruler_bg_b, 0.8);glVertex2d(0, _ruler_y+_ruler_height+1);
glColor4d(ruler_bg_r, ruler_bg_g, ruler_bg_b, 0.8);glVertex2d(0, _ruler_y+_ruler_height);
glColor4d(ruler_bg_r, ruler_bg_g, ruler_bg_b, 0.5);glVertex2d(0, _ruler_y);
glColor4d(ruler_bg_r, ruler_bg_g, ruler_bg_b, 0.5);glVertex2d(0 + nb_graduation*_ruler_distance, _ruler_y);
glColor4d(ruler_bg_r, ruler_bg_g, ruler_bg_b, 0.8);glVertex2d(0 + nb_graduation*_ruler_distance, _ruler_y+_ruler_height+1);
glColor4d(ruler_bg_r, ruler_bg_g, ruler_bg_b, 0.8);glVertex2d(0 + nb_graduation*_ruler_distance, _ruler_y+_ruler_height);
}
glEnd();
......@@ -535,16 +555,18 @@ void Render_opengl::call_ruler(){
unsigned int difference;
unsigned int step;
Element_pos adjustement;
// Element_pos graduation_value_adjustement;
char loop_count;/* counter to prevent infinity loop */
unsigned int distance_between_render_graduation;
ostringstream buf_txt;
ostringstream buf_string;
Element_pos buf_min;
Element_pos buf_max;
/* Use to temporary store the graduation time value text. */
buf_txt.str("");
// buf_txt.str("");
/*
......@@ -584,8 +606,19 @@ void Render_opengl::call_ruler(){
return;
}
if (difference > 10){
difference /= 10;/* integer division */
}
// graduation_value_adjustement = adjustement;
while (difference > 10){
difference /= 10;/* integer division */
adjustement /= 10;
buf_max /= 10.0;
buf_min /= 10.0;
}
/* Check within ] 7 ; 10 ] */
......@@ -608,57 +641,151 @@ void Render_opengl::call_ruler(){
message << tr("ERROR LIST not exist for the ruler.").toStdString() << Message::ende;
}
else{
int buf;
glPushMatrix();
// cout << trace_to_render_x(((int) buf_min)/adjustement) << " " << adjustement << endl;
distance_between_render_graduation = (coeff_trace_render_x()*step*20)/adjustement;/* Here, change the graduation number */
// glTranslated( trace_to_render_x(buf_min/adjustement), 0, _z_ruler);
buf = trace_to_render_x((buf_min - (int)buf_min%step)/adjustement);
// glTranslated(buf, 0, _z_ruler);
//trace_to_render_x(buf_min) << " " << (int)trace_to_render_x(buf_min) % (int)(coeff_trace_render_x()*step/adjustement) << " "<< coeff_trace_render_x()*step/adjustement << endl;
/*
* Just translate for ruler follows the entity translate.
*/
// glTranslated(trace_to_render_x((buf_min-(int)buf_min%step)/adjustement)+10, 0, _z_ruler);
buf_min = ((int)buf_min) - ((int)buf_min)%step;
distance_between_render_graduation = (coeff_trace_render_x()*step*20)/adjustement;
glTranslated( trace_to_render_x(buf_min/adjustement), 0, _z_ruler);
buf_max = ((int)buf_max) - ((int)buf_max)%step;
buf = (int)buf_min;
// cout << buf << " - " << trace_to_render_x((int)buf_min/adjustement) <<endl;
glTranslated(trace_to_render_x(buf/adjustement), 0, _z_ruler);
/* TODO: debug */
// glTranslated( trace_to_render_x(((int)buf_min%step)/adjustement) , 0, _z_ruler);
// cout << trace_to_render_x((int)Info::Render::_x_min_visible%step + Info::Render::_x_min_visible - (int)Info::Render::_x_min_visible) << endl;
glScaled(distance_between_render_graduation, 1.0, 1.0);
glCallList(_list_ruler);
glPopMatrix();
/* Of course, suppose that buf_max!=buf_min. Otherwise returns. */
if (buf_max==buf_min)
return;
/* Write text in label (the min and the max of the visible trace values) */
buf_txt.str("");/* flush the buffer */
buf_txt << "<b>" << ((int)buf_min - (int)buf_min%100)/adjustement << "</b>" << ((int)buf_min%100);
if (Info::Render::_ui_render_min_value != NULL){
Info::Render::_ui_render_min_value->setText(buf_txt.str().c_str());
}
glRasterPos2f( _render_width-10, _ruler_y+_ruler_height/2);
for ( int j = (int)buf_min ; j<=(int)buf_max ; j+=(int)(buf_max-buf_min)){
int i;/* i must not be unsigned since it will be compared with negative values! */
Element_pos buf_float;
buf_txt.str("");/* flush the buffer */
buf_string.str("");/* flush the buffer */
buf_txt.str("");/* flush the buffer */
buf_txt << "<b>" << ((int)buf_max - (int)buf_max%100)/adjustement << "</b>" << ((int)buf_max%100);
buf_float = j/adjustement;/* help compiler not to work out many time the value */
if (Info::Render::_ui_render_max_value != NULL){
Info::Render::_ui_render_max_value->setText(buf_txt.str().c_str());
}
buf_string << buf_float;
/* A tips to add a final 0 if there is a comma. Else, it will ignore. For example 1.50 -> 1.5 */
if ( (j%10)==0 && (buf_float != (int)buf_float) )
buf_string << 0;//"0";
buf_txt << "<b>";
// cerr << buf_string.str().length() << endl;
for (i=0 ; i < ((int)buf_string.str().length()-3) ; i++) {
buf_txt << buf_string.str()[i];
}
buf = (int)buf_string.str().length();/* help compiler not to work out many time the value */
if (1 == buf){
buf_txt << "</b>" << buf_string.str()[0];
}else if (2 == buf){
buf_txt << "</b>" << buf_string.str()[0] << buf_string.str()[1];
}else{
if ( buf_string.str()[i+1]=='.')/* check where is the coma */
buf_txt << "</b>" << buf_string.str()[i];
else
buf_txt << buf_string.str()[i] << "</b>";
buf_txt << buf_string.str()[i+1] << buf_string.str()[i+2];
}
// buf_txt << buf_txt.str()[i];
// buf = (j - j%100);
// if (buf != 0)
// buf_txt << "<b>" << buf/100/*adjustement*/ << "</b>";
// buf = (j%100);
// if ((buf<10) && (j!=0))
// buf_txt << "<b>" << 0 << "</b>";
// buf_txt << buf;///adjustement;
if ((j==buf_min) && (Info::Render::_ui_render_min_value != NULL)){
Info::Render::_ui_render_min_value->setText(buf_txt.str().c_str());
}
if ((j==buf_max) && (Info::Render::_ui_render_max_value != NULL)){
Info::Render::_ui_render_max_value->setText(buf_txt.str().c_str());
}
}
glColor3d(0.0, 0.0, 0.5);/* text color */
/* Now adjust the first and the last graduation */
for (int i=(int)buf_min;i<=(int)buf_max;i+=step){
buf_txt.str("");/* flush the buffer */
buf_txt << i%100;
buf = ((i-(int)buf_min)>(i%100))?100:0;/* (((i-(int)buf_min)>i)100:0) is used to have "90 - 100 - 110" instead of "90 - 0 - 10" with i%100 */
// cout << i << " " << (int)buf_min << " " << (int)buf_max << " " << adjustement << " " << graduation_value_adjustement << endl;
buf_txt << /*buf +*/ i%100;
/*
* Display the graduation time value.
*/
glRasterPos2f(trace_to_render_x(i/adjustement)+0.2, _ruler_y+_ruler_height);/* set position */
if ( _render_width*_x_scale_container_state <= trace_to_render_x(i/adjustement) ){/* Do not write if graduation is inside container area */
glRasterPos2f(trace_to_render_x(i/adjustement)+0.2, _ruler_y+_ruler_height-1);/* set position */
// cout << (int)buf_min << " " << trace_to_render_x((int)buf_min/adjustement) << endl;
/* DEBUG */
/* if (i==(int)buf_min){
cout << trace_to_render_x(i/graduation_value_adjustement) << " " << buf_min << " " << graduation_value_adjustement << endl;
}*/
// cout << trace_to_render_x(i/graduation_value_adjustement)<< endl;
//if ( _render_width*_x_scale_container_state <= trace_to_render_x(i/adjustement) ){/* Do not write if graduation is inside container area */
for(unsigned int j = 0 ; j < buf_txt.str().length() ; j ++){
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, buf_txt.str().c_str()[j]);
}
}
//}
}/* end for ( i ) */
}
}
......
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