Пример #1
0
/*!
 * \brief Object update function called after property change
 * 
 * Not in the object interface but very important anyway.
 * Used to recalculate the object data after a change
 * \protected \memberof StdPath
 */
static void
stdpath_update_data (StdPath *stdpath)
{
  DiaObject *obj = &stdpath->object;
  Rectangle *bb = &obj->bounding_box;
  PolyBBExtras extra = { 0 };
  real lw = stdpath->stroke_or_fill & PDO_STROKE ? stdpath->line_width : 0.0;

  extra.start_trans =
  extra.end_trans = 
  extra.start_long =
  extra.end_long =
  extra.middle_trans = lw/2.0;

  /* recalculate the bounding box */
  polybezier_bbox (stdpath->points, stdpath->num_points, &extra,
		   FALSE /*(stdpath->stroke_or_fill & PDO_FILL)*/, bb);
  /* adjust position from it */
  obj->position.x = stdpath->points[0].p1.x;
  obj->position.y = stdpath->points[0].p1.y;
  /* adjust handles */
  stdpath_update_handles (stdpath);
}
Пример #2
0
/*!
 * \brief Change the direction of the path
 */
static void
_stdpath_invert (StdPath *stdpath)
{
  BezPoint *bezier = stdpath->points;
  gsize n = stdpath->num_points;
  BezPoint *inverted = g_alloca (sizeof(BezPoint)*n);
  guint i;

  inverted[0].type = BEZ_MOVE_TO;
  inverted[0].p1 = (bezier[n-1].type == BEZ_CURVE_TO ? bezier[n-1].p3 : bezier[n-1].p1);
  for (i = 1; i < n; ++i) {
    inverted[i].type = bezier[n-i].type;
    if (bezier[n-i].type == BEZ_CURVE_TO) {
      inverted[i].p1 = bezier[n-i].p2;
      inverted[i].p2 = bezier[n-i].p1;
      inverted[i].p3 = (bezier[n-i-1].type == BEZ_CURVE_TO ? bezier[n-i-1].p3 : bezier[n-i-1].p1);
    } else {
      inverted[i].p1 = (bezier[n-i-1].type == BEZ_CURVE_TO ? bezier[n-i-1].p3 : bezier[n-i-1].p1);
    }
  }
  memcpy (stdpath->points, inverted, sizeof(BezPoint)*n);
  stdpath_update_handles (stdpath);
}
Пример #3
0
/*!
 * \brief Change the object state regarding selection 
 * \memberof StdPath
 */
static void 
stdpath_select (StdPath *stdpath, Point *clicked_point,
		DiaRenderer *interactive_renderer)
{
  stdpath_update_handles (stdpath);
}