Commit a05c4849 authored by Olivier Lagrasse's avatar Olivier Lagrasse

limit zoom to microsecond (not already fixed for containers)

parent 76810876
......@@ -62,7 +62,10 @@ const int Hook_event::DRAWING_STATE_WAITING = 1;
const int Hook_event::DRAWING_STATE_DRAWING = 2;
const int Hook_event::_ctrl_scroll_factor = 10;
const int Hook_event::_ctrl_zoom_factor = 3;
static const Element_pos zoom_limit = 0.000001;/* Use to control the minimum distance between
the minimum x visible and the maximum x visible. */
static const int scroll_margin = 100;/* Control the margin of the trace. Must be in percentage.
(i.e. between [0; 100]) */
void Hook_event::updateRender(){
// _render_instance->updateOverlayGL();
......@@ -332,6 +335,7 @@ void Hook_event::apply_zoom_box(Element_pos x_min, Element_pos x_max, Element_po
Element_pos y_scaled_middle_selection;
Element_pos x_distance_between_state_origin_and_render_middle;
Element_pos y_distance_between_state_origin_and_render_middle;
Element_pos delta;
/*
......@@ -399,6 +403,22 @@ void Hook_event::apply_zoom_box(Element_pos x_min, Element_pos x_max, Element_po
_y_state_scale *= Info::Screen::height/(y_max - y_min);
_mouse_pressed = false;
/* Now, check if zoom is not too much */
update_visible_interval_value();
delta = Info::Render::_x_max_visible - Info::Render::_x_min_visible;
if ( delta <= zoom_limit ){/* if too much, cancel */
_x_state_scale *= (x_max - x_min) / Info::Screen::width;
_y_state_scale *= (y_max - y_min) / Info::Screen::height;
_x_state_translate -= (x_scaled_middle_selection - x_distance_between_state_origin_and_render_middle);
_y_state_translate -= (y_scaled_middle_selection - y_distance_between_state_origin_and_render_middle);
}
/* Update render */
updateRender();
refresh_scroll_bars(true);
}
......@@ -532,7 +552,7 @@ void Hook_event::change_scale_y(Element_pos scale_coeff){
void Hook_event::replace_scale(Element_pos new_scale){
int buf;
if(new_scale > 0.0){
/*
* Reajust the entity translation to recenter the same point previously under the mouse pointer
......@@ -589,10 +609,10 @@ void Hook_event::change_translate_y(int translate){
void Hook_event::replace_translate(Element_pos new_translate){
if ( new_translate < 0 ){
new_translate = 0;
}else if ( new_translate > (100*_x_state_scale) ){
new_translate = 100*_x_state_scale;
if ( new_translate < (-scroll_margin*_x_state_scale) ){
new_translate = -scroll_margin*_x_state_scale;
}else if ( new_translate > (scroll_margin*_x_state_scale) ){
new_translate = scroll_margin*_x_state_scale;
}
_x_state_translate = new_translate;
......@@ -606,10 +626,10 @@ void Hook_event::replace_translate(Element_pos new_translate){
void Hook_event::replace_translate_y(Element_pos new_translate){
if ( new_translate < 0 ){
new_translate = 0;
}else if ( new_translate > (100*_y_state_scale) ){
new_translate = 100*_y_state_scale;
if ( new_translate < (-scroll_margin*_y_state_scale) ){
new_translate = -scroll_margin*_y_state_scale;
}else if ( new_translate > (scroll_margin*_y_state_scale) ){
new_translate = scroll_margin*_y_state_scale;
}
_y_state_translate = new_translate;
......@@ -665,7 +685,7 @@ void Hook_event::registered_translate(int id){
void Hook_event::refresh_scroll_bars(bool LENGTH_CHANGED){
if (LENGTH_CHANGED){
Element_pos scroll_bar_length[2] = {_x_state_scale*100, _y_state_scale*100};
Element_pos scroll_bar_length[2] = {_x_state_scale*scroll_margin, _y_state_scale*scroll_margin};
_core->launch_action(_core->_STATE_AJUST_SCROLL_BARS, scroll_bar_length);
}
......
......@@ -63,23 +63,10 @@ using namespace std;
#define message *Message::get_instance() << "(" << __FILE__ << " l." << __LINE__ << "): "
static bool _draw_container;/* Yes, it is global, but also it is static. In fact, it is used to
check if quad drawing is used to paint container. It is not an attribute of
the Render_opengl class. */
static bool _draw_ruler;/* Yes, it is global, but also it is static. In fact, it is used to
check the ruler drawing state. It is not an attribute of
the Render_opengl class. */
static bool _draw_arrow;/* Yes, it is global, but also it is static. In fact, it is used to
check the arrow drawing state. It is not an attribute of
the Render_opengl class. */
static bool _draw_event;/* Yes, it is global, but also it is static. In fact, it is used to
check the circle drawing state. It is not an attribute of
the Render_opengl class. */
static bool _draw_container;
static bool _draw_ruler;
static bool _draw_arrow;
static bool _draw_event;
const int Render_opengl::DRAWING_TIMER_DEFAULT = 10;
/***********************************
......
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