Пример #1
0
/*! \brief Property change notification for any/all settings
 *
 *  \param [in] w_current
 */
static void
notify_options (GschemToplevel *w_current)
{
  g_return_if_fail (w_current != NULL);

  /* Events can occur before the drawing area is created */

  if (w_current->drawing_area != NULL) {
    /* maybe remove those two lines
     * gschem_toplevel_get_toplevel (w_current)->page_current->CHANGED=1;
     * o_undo_savestate_old(w_current, UNDO_ALL);
     */

    i_update_grid_info (w_current);
    gschem_page_view_invalidate_all (gschem_toplevel_get_current_page_view (w_current));
  }
}
Пример #2
0
/*! \todo Finish function documentation!!!
 *  \brief
 *  \par Function Description
 *
 */
void a_pan_general(GSCHEM_TOPLEVEL *w_current, double world_cx, double world_cy,
		   double relativ_zoom_factor,int flags)
{
  TOPLEVEL *toplevel = w_current->toplevel;
  /* see libgeda/include/defines.h for flags */
  /*if the borders should be ignored always, remove, outcomment or changes
    the flags in the function-calls*/
  /*	flags |= A_PAN_IGNORE_BORDERS;
   */		
  /* think it's better that the zoomfactor is defined as pix/mills
     this will be the same as w_current->page_current->to_screen_x/y_constant*/
  int zoom_max = 5;	
  int diff;
  double zx, zy, zoom_old, zoom_new, zoom_min;

#if DEBUG
  printf("a_pan_general(): world_cx=%f, world_cy=%f\n",world_cx, world_cy);
#endif	

  /* calc minimum zoomfactors and choose the smaller one. They are equal
     if the aspectratio of the world is the same as the screen ratio */
  zx = (double) toplevel->width / (toplevel->init_right -
                                    toplevel->init_left);
  zy = (double) toplevel->height / (toplevel->init_bottom -
                                     toplevel->init_top);
  zoom_min = zx < zy ? zx : zy;

#if DEBUG
  printf("  zx_min=%f, zy_min=%f , flags=%d\n ",zx, zy, flags);
#endif	

  /* to_screen_x_constant and to_screen_y_constant are almost the same.
     lets use to_screen_y_constant */
  zoom_old = toplevel->page_current->to_screen_y_constant;
		
  /* calc new zooming factor */
  /* check if there's a zoom_full (relativ_zoom_factor == -1) */
  if (relativ_zoom_factor <0)  {
    zoom_new = zoom_min;
  }
  else {
    zoom_new = zoom_old * relativ_zoom_factor;
    zoom_new = zoom_new > zoom_max ? zoom_max : zoom_new;
    if (!(flags & A_PAN_IGNORE_BORDERS)) {
      zoom_new = zoom_new < zoom_min ? zoom_min : zoom_new;
    }
  }

  /* calculate the new visible area; adding 0.5 to round */
  toplevel->page_current->left = world_cx - (double) toplevel->width
    / 2 / zoom_new + 0.5;
  toplevel->page_current->right = world_cx + (double) toplevel->width
    / 2 / zoom_new + 0.5;
  toplevel->page_current->top = world_cy - (double) toplevel->height
    / 2 / zoom_new + 0.5;
  toplevel->page_current->bottom = world_cy + (double) toplevel->height
    / 2 / zoom_new + 0.5;
	
  /* and put it back to the borders */
  if (!(flags & A_PAN_IGNORE_BORDERS)) {
    /* check right border */
    if (toplevel->page_current->right > toplevel->init_right) {
      toplevel->page_current->left += toplevel->init_right -
                                       toplevel->page_current->right;
      toplevel->page_current->right = toplevel->init_right;
    }
    /* check left border */
    if (toplevel->page_current->left < toplevel->init_left) {
      toplevel->page_current->right += toplevel->init_left -
                                        toplevel->page_current->left;
      toplevel->page_current->left = toplevel->init_left;
    }

    /* If there is any slack, center the view */
    diff = (toplevel->page_current->right -
            toplevel->page_current->left) -
           (toplevel->init_right - toplevel->init_left);
    if (diff > 0) {
      toplevel->page_current->left -= diff / 2;
      toplevel->page_current->right -= diff / 2;
    }

    /* check bottom border */
    if (toplevel->page_current->bottom > toplevel->init_bottom) {
      toplevel->page_current->top += toplevel->init_bottom -
                                      toplevel->page_current->bottom;
      toplevel->page_current->bottom = toplevel->init_bottom;
    }
    /* check top border */
    if (toplevel->page_current->top < toplevel->init_top) {
      toplevel->page_current->bottom += toplevel->init_top -
                                         toplevel->page_current->top;
      toplevel->page_current->top = toplevel->init_top;
    }

    /* If there is any slack, center the view */
    diff = (toplevel->page_current->bottom -
            toplevel->page_current->top) -
           (toplevel->init_bottom - toplevel->init_top);
    if (diff > 0) {
      toplevel->page_current->top -= diff / 2;
      toplevel->page_current->bottom -= diff / 2;
    }

  }
	
#if DEBUG
  printf("zoom_old: %f, zoom_new: %f \n ",zoom_old, zoom_new);
  printf("left: %d, right: %d, top: %d, bottom: %d\n",
         toplevel->page_current->left, toplevel->page_current->right, 
	 toplevel->page_current->top, toplevel->page_current->bottom);
  printf("aspect: %f\n",
         (float) fabs(toplevel->page_current->right  
		      - toplevel->page_current->left) /
         (float) fabs(toplevel->page_current->bottom 
		      - toplevel->page_current->top ));
#endif
	
  /* set_window */
  set_window(toplevel, toplevel->page_current,
             toplevel->page_current->left  ,
             toplevel->page_current->right ,
             toplevel->page_current->top   ,
             toplevel->page_current->bottom);

  i_update_grid_info (w_current);

  /* redraw */
  if (!(flags & A_PAN_DONT_REDRAW)) {
    x_scrollbars_update(w_current);
    o_invalidate_all (w_current);
  }
}