void CurveCtx::nav_zoom() { if ( nodraw) return; if ( a.size() > 0) { double x_nav_left, x_nav_right, y_nav_low, y_nav_high; get_borders(); // cout << "Borders : <" << x_left << " > " << x_right << " ^ " << // y_high << " Y " << y_low << endl; x_nav_left = x_left; x_nav_right = x_right; y_nav_low = y_low; y_nav_high = y_high; if ( x_nav_right - x_nav_left == 0 || y_nav_high - y_nav_low == 0) return; navw.zoom_factor_x = navw.window_width / (x_nav_right - x_nav_left); navw.zoom_factor_y = navw.window_height / (y_nav_high - y_nav_low); navw.offset_x = int( x_nav_left * navw.zoom_factor_x); navw.offset_y = int( y_nav_low * navw.zoom_factor_y); a.nav_zoom(); clear( &navw); nav_draw( &navw, 0, 0, navw.window_width, navw.window_height); } }
void FlowText::move( void* pos, double x, double y, int highlight, int dimmed, int hot) { erase(pos, hot, NULL); nav_erase(pos, NULL); p.x = x; p.y = y; zoom(); nav_zoom(); draw(pos, highlight, dimmed, hot, NULL); nav_draw(pos, highlight, NULL); }
void FlowPixmap::move( void *pos, double x, double y, int highlight, int hot) { erase( pos, hot, NULL); nav_erase( pos, NULL); p.x = x; p.y = y; zoom(); nav_zoom(); draw( pos, highlight, hot, NULL); nav_draw( pos, highlight, NULL); }
void FlowPixmap::shift( void *pos, double delta_x, double delta_y, int highlight, int hot) { erase( pos, hot, NULL); nav_erase( pos, NULL); p.x += delta_x; p.y += delta_y; zoom(); nav_zoom(); draw( pos, highlight, hot, NULL); nav_draw( pos, highlight, NULL); }
void FlowLine::move( void *pos, double x1, double y1, double x2, double y2, int highlight, int hot) { erase( pos, hot, NULL); nav_erase( pos, NULL); p1.x = x1; p1.y = y1; p2.x = x2; p2.y = y2; zoom(); nav_zoom(); draw( pos, highlight, hot, NULL); nav_draw( pos, highlight, NULL); }
void FlowImage::shift( void *pos, double delta_x, double delta_y, int highlight, int hot) { erase( pos, hot, NULL); nav_erase( pos, NULL); ll.x += delta_x; ll.y += delta_y; ur.x += delta_x; ur.y += delta_y; zoom(); nav_zoom(); draw( pos, highlight, hot, NULL); nav_draw( pos, highlight, NULL); }
void FlowArc::move( void *pos, double x1, double y1, double x2, double y2, int ang1, int ang2, int highlight, int hot) { erase( pos, hot, NULL); nav_erase( pos, NULL); ll.x = x1; ll.y = y1; ur.x = x2; ur.y = y2; angle1 = ang1; angle2 = ang2; zoom(); nav_zoom(); draw( pos, highlight, hot, NULL); nav_draw( pos, highlight, NULL); }
void FlowImage::move( void *pos, double x, double y, int highlight, int hot) { double width, height; width = ur.x - ll.x; height = ur.y - ll.y; erase( pos, hot, NULL); nav_erase( pos, NULL); ll.x = x; ll.y = y; ur.x = x + width; ur.y = y + height; zoom(); nav_zoom(); draw( pos, highlight, hot, NULL); nav_draw( pos, highlight, NULL); }
void FlowArrow::shift(void* pos, double delta_x, double delta_y, int highlight, int dimmed, int hot) { erase(pos, hot, NULL); nav_erase(pos, NULL); p_dest.x += delta_x; p_dest.y += delta_y; p1.x += delta_x; p1.y += delta_y; p2.x += delta_x; p2.y += delta_y; zoom(); nav_zoom(); draw(pos, highlight, dimmed, hot, NULL); nav_draw(pos, highlight, NULL); }
void FlowArrow::move(void* pos, double x1, double y1, double x2, double y2, int highlight, int dimmed, int hot) { erase(pos, hot, NULL); nav_erase(pos, NULL); if (fabs(x2 - x1) < DBL_EPSILON) { if (y1 > y2) { p1.x = x2 + arrow_width / 2; p1.y = y2 + arrow_length; p2.x = x2 - arrow_width / 2; p2.y = y2 + arrow_length; } else { p1.x = x2 + arrow_width / 2; p1.y = y2 - arrow_length; p2.x = x2 - arrow_width / 2; p2.y = y2 - arrow_length; } } else if (fabs(y2 - y1) < DBL_EPSILON) { if (x1 > x2) { p1.x = x2 + arrow_length; p1.y = y2 + arrow_width / 2; p2.x = x2 + arrow_length; p2.y = y2 - arrow_width / 2; } else { p1.x = x2 - arrow_length; p1.y = y2 - arrow_width / 2; p2.x = x2 - arrow_length; p2.y = y2 + arrow_width / 2; } } else { double d = sqrt((y1 - y2) * (y1 - y2) + (x1 - x2) * (x1 - x2)); p1.x = x2 + (x1 - x2) * arrow_length / d + (y1 - y2) * arrow_width / d / 2; p1.y = y2 + (y1 - y2) * arrow_length / d - (x1 - x2) * arrow_width / d / 2; p2.x = x2 + (x1 - x2) * arrow_length / d - (y1 - y2) * arrow_width / d / 2; p2.y = y2 + (y1 - y2) * arrow_length / d + (x1 - x2) * arrow_width / d / 2; } p_dest.x = x2; p_dest.y = y2; zoom(); nav_zoom(); draw(pos, highlight, dimmed, hot, NULL); nav_draw(pos, highlight, NULL); }
int CurveCtx::event_handler_nav( glow_eEvent event, int x, int y) { GlowCtx *ctx; ctx = this; switch ( event) { case glow_eEvent_MB1Press: if ( nav_rect_ll_x < x && x < nav_rect_ur_x && nav_rect_ll_y < y && y < nav_rect_ur_y) { nav_rect_movement_active = 1; nav_rect_move_last_x = x; nav_rect_move_last_y = y; } break; case glow_eEvent_MB2Press: if ( nav_rect_ll_x < x && x < nav_rect_ur_x && nav_rect_ll_y < y && y < nav_rect_ur_y) { nav_rect_zoom_active = 1; nav_rect_move_last_x = x; nav_rect_move_last_y = y; } break; case glow_eEvent_CursorMotion: if ( nav_rect_ll_x < x && x < nav_rect_ur_x && nav_rect_ll_y < y && y < nav_rect_ur_y) { if ( !nav_rect_hot) { gdraw->set_cursor( &navw, glow_eDrawCursor_CrossHair); nav_rect_hot = 1; } } else { if ( nav_rect_hot) { gdraw->set_cursor( &navw, glow_eDrawCursor_Normal); nav_rect_hot = 0; } } break; case glow_eEvent_Exposure: gdraw->get_window_size( &navw, &navw.window_width, &navw.window_height); nav_zoom(); break; case glow_eEvent_ButtonMotion: if ( nav_rect_movement_active) { int delta_x, delta_y, mainwind_delta_x, mainwind_delta_y; gdraw->rect_erase( &navw, nav_rect_ll_x, nav_rect_ll_y, nav_rect_ur_x - nav_rect_ll_x, nav_rect_ur_y - nav_rect_ll_y, 0); delta_x = x - nav_rect_move_last_x; delta_y = 0; nav_rect_ll_x += delta_x; nav_rect_ur_x += delta_x; nav_rect_ll_y += delta_y; nav_rect_ur_y += delta_y; nav_rect_move_last_x = x; nav_rect_move_last_y = y; nav_draw( &navw, nav_rect_ll_x - 10, nav_rect_ll_y - 10, nav_rect_ur_x + 10, nav_rect_ur_y + 10); // glow_draw_nav_rect( this, nav_rect_ll_x, nav_rect_ll_y, // nav_rect_ur_x - nav_rect_ll_x, nav_rect_ur_y - nav_rect_ll_y, // glow_eDrawType_Line, 0, 0); mainwind_delta_x = int( - mw.zoom_factor_x / navw.zoom_factor_x * delta_x); mainwind_delta_y = int( - mw.zoom_factor_y / navw.zoom_factor_y * delta_y); mw.offset_x -= mainwind_delta_x; mw.offset_y -= mainwind_delta_y; a.traverse( mainwind_delta_x, mainwind_delta_y); if ( ctx_type == glow_eCtxType_Grow) { ((GrowCtx *)this)->polyline_last_end_x += mainwind_delta_x; ((GrowCtx *)this)->polyline_last_end_y += mainwind_delta_y; } gdraw->copy_area( &mw, mainwind_delta_x, mainwind_delta_y); // clear(); if ( !unobscured) draw( &mw, 0, 0, mw.window_width, mw.window_height); else { if ( mainwind_delta_x >= 0 && mainwind_delta_y >= 0) { if ( mainwind_delta_x) draw( &mw, 0, 0, mainwind_delta_x, mw.window_height); if ( mainwind_delta_y) draw( &mw, mainwind_delta_x, 0, mw.window_width, mainwind_delta_y); } else if ( mainwind_delta_x <= 0 && mainwind_delta_y <= 0) { if ( mainwind_delta_x) draw( &mw, mw.window_width+mainwind_delta_x, 0, mw.window_width, mw.window_height); if ( mainwind_delta_y) draw( &mw, 0, mw.window_height + mainwind_delta_y, mw.window_width + mainwind_delta_x, mw.window_height); } else if ( mainwind_delta_x <= 0 && mainwind_delta_y >= 0) { if ( mainwind_delta_x) draw( &mw, mw.window_width + mainwind_delta_x, 0, mw.window_width, mw.window_height); if ( mainwind_delta_y) draw( &mw, 0, 0, mw.window_width + mainwind_delta_x, mainwind_delta_y); } else { if ( mainwind_delta_x) draw( &mw, 0, 0, mainwind_delta_x, mw.window_height); if ( mainwind_delta_y) draw( &mw, mainwind_delta_x, mw.window_height+ mainwind_delta_y, mw.window_width, mw.window_height); } } change_scrollbar(); } else if ( nav_rect_zoom_active) { int delta_x, delta_y; double zoom_f; double center_x, center_y; double center_dist, center_dist_last; gdraw->rect_erase( &navw, nav_rect_ll_x, nav_rect_ll_y, nav_rect_ur_x - nav_rect_ll_x, nav_rect_ur_y - nav_rect_ll_y, 0); delta_x = x - nav_rect_move_last_x; delta_y = 0; center_x = 0.5 * (nav_rect_ur_x + nav_rect_ll_x); center_y = 0.5 * (nav_rect_ur_y + nav_rect_ll_y); center_dist_last = sqrt( (nav_rect_move_last_x - center_x) * (nav_rect_move_last_x - center_x) + (nav_rect_move_last_y - center_y) * (nav_rect_move_last_y - center_y)); center_dist = sqrt((x - center_x)*(x - center_x) + (y - center_y)*(y - center_y)); if ( center_dist < DBL_EPSILON) return 1; zoom_f = center_dist_last / center_dist; // if ( fabs(zoom_f - 1) < 0.2) // return 1; zoom( zoom_f); nav_rect_move_last_x = x; nav_rect_move_last_y = y; } break; case glow_eEvent_ButtonRelease: if ( nav_rect_movement_active) { nav_rect_movement_active = 0; nav_zoom(); } if ( nav_rect_zoom_active) { nav_rect_zoom_active = 0; } break; default: ; } return 1; }