示例#1
0
void BrowCtx::zoom( double factor)
{ 
  if ( fabs(factor) < DBL_EPSILON)
    return;

  zoom_factor *= factor;
  if ( offset_x != 0)
    offset_x = int( (offset_x - window_width / 2.0 * ( 1.0/factor - 1)) 
		* factor);
  if ( offset_y != 0)
    offset_y = int( (offset_y  - window_height / 2.0 * ( 1.0/factor - 1)) 
		* factor);
  offset_x = MAX( offset_x, 0);
  offset_y = MAX( offset_y, 0);
  if ( (x_right - x_left) * zoom_factor <= window_width)
    offset_x = 0;
  if ( (y_high - y_low) * zoom_factor <= window_height)
    offset_y = 0;
  a.zoom();
  clear();
  draw( 0, 0, window_width, window_height);
  nav_zoom();
  a_nc.zoom();  // Zoom inactive nodeclasses
  change_scrollbar();
}
示例#2
0
void BrowCtx::zoom( double factor)
{ 
  if ( fabs(factor) < DBL_EPSILON)
    return;

  mw.zoom_factor_x *= factor;
  mw.zoom_factor_y *= factor;
  if ( mw.offset_x != 0)
    mw.offset_x = int( (mw.offset_x - mw.window_width / 2.0 * ( 1.0/factor - 1)) 
		* factor);
  if ( mw.offset_y != 0)
    mw.offset_y = int( (mw.offset_y  - mw.window_height / 2.0 * ( 1.0/factor - 1)) 
		* factor);
  mw.offset_x = max( mw.offset_x, 0);
  mw.offset_y = max( mw.offset_y, 0);
  if ( (x_right - x_left) * mw.zoom_factor_x <= mw.window_width)
    mw.offset_x = 0;
  if ( (y_high - y_low) * mw.zoom_factor_y <= mw.window_height)
    mw.offset_y = 0;
  a.zoom();
  clear( &mw);
  draw( &mw, 0, 0, mw.window_width, mw.window_height);
  nav_zoom();
  change_scrollbar();
}
示例#3
0
void BrowCtx::zoom_absolute( double factor)
{ 
  if ( fabs(factor) < DBL_EPSILON)
    return;

  zoom_factor = factor;
  a.zoom();
  clear();
  draw( 0, 0, window_width, window_height);
  nav_zoom();
}
示例#4
0
void GlowText::move(void* pos, double x, double y, int highlight, int hot)
{
  erase(&ctx->mw, pos, hot, NULL);
  erase(&ctx->navw, pos, 0, NULL);
  p.x = x;
  p.y = y;
  zoom();
  nav_zoom();
  draw(&ctx->mw, pos, highlight, hot, NULL);
  draw(&ctx->navw, pos, highlight, 0, NULL);
}
示例#5
0
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);
}
示例#6
0
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);
}
示例#7
0
void GlowText::shift( void *pos, double delta_x, double delta_y,
	int highlight, int hot)
{
  erase( &ctx->mw, pos, hot, NULL);
  erase( &ctx->navw, pos, 0, NULL);
  p.x += delta_x;
  p.y += delta_y;
  zoom();
  nav_zoom();

  draw( &ctx->mw, pos, highlight, hot, NULL);
  draw( &ctx->navw, pos, highlight, 0, NULL);
}
示例#8
0
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);
}
示例#9
0
void CurveCtx::zoom( double factor)
{ 
  if ( fabs(factor) < DBL_EPSILON)
    return;

  mw.zoom_factor_x *= factor;
  mw.offset_x = int( (mw.offset_x - mw.window_width / 2.0 * ( 1.0/factor - 1)) * factor);
  a.zoom();
  clear( &mw);
  draw( &mw, 0, 0, mw.window_width, mw.window_height);
  nav_zoom();
  change_scrollbar();
}
示例#10
0
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);
}
示例#11
0
void GlowArc::move_noerase( void *pos, double x1, double y1, double x2, double y2,
	int ang1, int ang2, int highlight, int hot)
{
  ll.x = x1;
  ll.y = y1;
  ur.x = x2;
  ur.y = y2;
  angle1 = ang1;
  angle2 = ang2;  
  zoom();
  nav_zoom();
  draw( &ctx->mw, pos, highlight, hot, NULL);
  draw( &ctx->navw, pos, highlight, 0, NULL);
}
示例#12
0
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);
}
示例#13
0
void BrowCtx::redraw( double y_redraw)
{
  if ( y_redraw)
  {
    gdraw->clear_area( &mw, 0, mw.window_width, 
		int(y_redraw * mw.zoom_factor_y - mw.offset_y), mw.window_height);
    draw( &mw, 0, (int)(y_redraw * mw.zoom_factor_y - mw.offset_y), mw.window_width, mw.window_height);
  }
  else
  {
    clear( &mw);
    draw( &mw, 0, 0, mw.window_width, mw.window_height);
  }
  nav_zoom();
}
示例#14
0
void GlowArrow::move( void *pos, double x1, double y1, double x2, double y2,
	int highlight, int hot)
{
  erase( &ctx->mw, pos, hot, NULL);
  erase( &ctx->navw, pos, 0, 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( &ctx->mw, pos, highlight, hot, NULL);
  draw( &ctx->navw, pos, highlight, 0, NULL);
}
示例#15
0
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);
}
示例#16
0
void BrowCtx::redraw( double y_redraw)
{

  fdraw->get_window_size( this, &window_width, &window_height);

  if ( y_redraw) {
    fdraw->clear_area( this, 0, window_width, 
		int(y_redraw * zoom_factor - offset_y), window_height);
    draw( 0, int(y_redraw * zoom_factor - offset_y), window_width, window_height);
  }
  else {
    clear();
    draw( 0, 0, window_width, window_height);
  }
  nav_zoom();
}
示例#17
0
void GlowArrow::shift( void *pos, double delta_x, double delta_y, 
	int highlight, int hot)
{
  erase( &ctx->mw, pos, hot, NULL);
  erase( &ctx->navw, pos, 0, 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( &ctx->mw, pos, highlight, hot, NULL);
  draw( &ctx->navw, pos, highlight, 0, NULL);
}
示例#18
0
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);
}
示例#19
0
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);
}
示例#20
0
void GlowPolyLine::add_points( void *pos, glow_sPoint *pointarray, 
	int point_cnt, int highlight, int hot)
{
  int i;

  if ( points)
  {
    // erase( pos, hot, NULL);
    // nav_erase( pos, NULL);
    free( (char *)points);
  }
  points = (glow_sPointX *) calloc( a_points.a_size + point_cnt, sizeof(glow_sPointX));
  for ( i = 0; i < point_cnt; i++)
  {
    GlowPoint *p = new GlowPoint(ctx, pointarray[i].x, pointarray[i].y);
    a_points.insert( p);
  }
  zoom();
  nav_zoom();
  // draw( pos, highlight, hot, NULL);
  // nav_draw( pos, highlight, NULL);
}
示例#21
0
void ColPalCtx::redraw()
{
  clear( &mw);
  draw( &mw, 0, 0, mw.window_width, mw.window_height);
  nav_zoom();
}
示例#22
0
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;
}