Example #1
0
void
aadlsubprogram_project_point_on_nearest_border(Aadlbox *aadlbox,Point *p,
					       real *angle)
{
  Point center;
  real w, h, r, t, norm_factor;

  w = aadlbox->element.width;
  h = aadlbox->element.height;
  center.x = aadlbox->element.corner.x + 0.5 * w;
  center.y = aadlbox->element.corner.y + 0.5 * h;

  point_sub(p, &center);

  /* normalize ellipse to a circle */
  r = w;
  norm_factor = r/h;
  p->y *= norm_factor;

  t = point_to_angle(p);

  p->x = 0.5*r*cos(t);
  p->y = 0.5*r*sin(t);

  /* unnormalize */
  p->y /= norm_factor;

  point_add(p, &center);
  *angle = t;
}
Example #2
0
static void
constraint_move_handle(Constraint *constraint, Handle *handle,
		 Point *to, HandleMoveReason reason, ModifierKeys modifiers)
{
  Point p1, p2;
  Point *endpoints;
  
  assert(constraint!=NULL);
  assert(handle!=NULL);
  assert(to!=NULL);

  if (handle->id == HANDLE_MOVE_TEXT) {
    constraint->text_pos = *to;
  } else  {
    endpoints = &constraint->connection.endpoints[0]; 
    p1.x = 0.5*(endpoints[0].x + endpoints[1].x);
    p1.y = 0.5*(endpoints[0].y + endpoints[1].y);
    connection_move_handle(&constraint->connection, handle->id, to, reason);
    p2.x = 0.5*(endpoints[0].x + endpoints[1].x);
    p2.y = 0.5*(endpoints[0].y + endpoints[1].y);
    point_sub(&p2, &p1);
    point_add(&constraint->text_pos, &p2);
  }

  constraint_update_data(constraint);
}
Example #3
0
File: bezier.c Project: GNOME/dia
static ObjectChange*
bezierline_move_handle(Bezierline *bezierline, Handle *handle,
		       Point *to, ConnectionPoint *cp,
		       HandleMoveReason reason, ModifierKeys modifiers)
{
  assert(bezierline!=NULL);
  assert(handle!=NULL);
  assert(to!=NULL);

  if (reason == HANDLE_MOVE_CREATE || reason == HANDLE_MOVE_CREATE_FINAL) {
    /* During creation, change the control points */
    BezierConn *bez = &bezierline->bez;
    Point dist = bez->bezier.points[0].p1;

    point_sub(&dist, to);
    dist.y = 0;
    point_scale(&dist, 0.332);

    bezierconn_move_handle(bez, handle, to, cp, reason, modifiers);

    bez->bezier.points[1].p1 = bez->bezier.points[0].p1;
    point_sub(&bez->bezier.points[1].p1, &dist);
    bez->bezier.points[1].p2 = *to;
    point_add(&bez->bezier.points[1].p2, &dist);
  } else {
    bezierconn_move_handle(&bezierline->bez, handle, to, cp, reason, modifiers);
  }

  bezierline_update_data(bezierline);

  return NULL;
}
Example #4
0
File: link.c Project: UIKit0/dia
static ObjectChange*
link_move_handle(Link *link, Handle *handle,
		 Point *to, ConnectionPoint *cp, 
		 HandleMoveReason reason, ModifierKeys modifiers)
{
  Point p1, p2;
  Point *endpoints;

  assert(link!=NULL);
  assert(handle!=NULL);
  assert(to!=NULL);

  if (handle->id == HANDLE_MOVE_MID_POINT) {
    link->pm = *to;
  } else  {
    endpoints = &link->connection.endpoints[0];
    p1.x = 0.5*(endpoints[0].x + endpoints[1].x);
    p1.y = 0.5*(endpoints[0].y + endpoints[1].y);
    connection_move_handle(&link->connection, handle->id, to, cp, reason, modifiers);
    p2.x = 0.5*(endpoints[0].x + endpoints[1].x);
    p2.y = 0.5*(endpoints[0].y + endpoints[1].y);
    point_sub(&p2, &p1);
    point_add(&link->pm, &p2);
  }

  link_update_data(link);
  return NULL;
}
Example #5
0
static ObjectChange*
message_move_handle(Message *message, Handle *handle,
		    Point *to, ConnectionPoint *cp,
		    HandleMoveReason reason, ModifierKeys modifiers)
{
  Point p1, p2;
  Point *endpoints;
  
  assert(message!=NULL);
  assert(handle!=NULL);
  assert(to!=NULL);

  if (handle->id == HANDLE_MOVE_TEXT) {
    message->text_pos = *to;
  } else  {
    endpoints = &message->connection.endpoints[0]; 
    p1.x = 0.5*(endpoints[0].x + endpoints[1].x);
    p1.y = 0.5*(endpoints[0].y + endpoints[1].y);
    connection_move_handle(&message->connection, handle->id, to, cp, reason, modifiers);
    connection_adjust_for_autogap(&message->connection);
    p2.x = 0.5*(endpoints[0].x + endpoints[1].x);
    p2.y = 0.5*(endpoints[0].y + endpoints[1].y);
    point_sub(&p2, &p1);
    point_add(&message->text_pos, &p2);
  }

  message_update_data(message);

  return NULL;
}
Example #6
0
int ECDSA_verify(const char *msg, const struct affine_point *Q,
		 const gcry_mpi_t sig, const struct curve_params *cp)
{
  gcry_mpi_t e, r, s;
  struct affine_point X1, X2;
  int res = 0;
  r = gcry_mpi_new(0);
  s = gcry_mpi_new(0);
  gcry_mpi_div(s, r, sig, cp->dp.order, 0);
  if (gcry_mpi_cmp_ui(s, 0) <= 0 || gcry_mpi_cmp(s, cp->dp.order) >= 0 ||
      gcry_mpi_cmp_ui(r, 0) <= 0 || gcry_mpi_cmp(r, cp->dp.order) >= 0) 
    goto end;
  gcry_mpi_scan(&e, GCRYMPI_FMT_USG, msg, 64, NULL);
  gcry_mpi_mod(e, e, cp->dp.order);
  gcry_mpi_invm(s, s, cp->dp.order);
  gcry_mpi_mulm(e, e, s, cp->dp.order);
  X1 = pointmul(&cp->dp.base, e, &cp->dp);
  gcry_mpi_mulm(e, r, s, cp->dp.order);
  X2 = pointmul(Q, e, &cp->dp);
  point_add(&X1, &X2, &cp->dp);
  gcry_mpi_release(e);
  if (! point_is_zero(&X1)) {
    gcry_mpi_mod(s, X1.x, cp->dp.order);
    res = ! gcry_mpi_cmp(s, r);
  }
  point_release(&X1);
  point_release(&X2);
 end:
  gcry_mpi_release(r);
  gcry_mpi_release(s);
  return res;
}
Example #7
0
ObjectChange*
beziershape_move(BezierShape *bezier, Point *to)
{
  Point p;
  int i;
  
  p = *to;
  point_sub(&p, &bezier->points[0].p1);

  bezier->points[0].p1 = bezier->points[0].p3 = *to;
  for (i = 1; i < bezier->numpoints; i++) {
    point_add(&bezier->points[i].p1, &p);
    point_add(&bezier->points[i].p2, &p);
    point_add(&bezier->points[i].p3, &p);
  }

  return NULL;
}
Example #8
0
/*!
 * \brief Move the entire object.
 * @param bezier The object being moved.
 * @param to Where the object is being moved to.  This is the first point
 * of the points array.
 * @return NULL
 * \memberof _BezierConn
 */
ObjectChange*
bezierconn_move (BezierConn *bezier, Point *to)
{
  Point p;
  int i;
  
  p = *to;
  point_sub(&p, &bezier->bezier.points[0].p1);

  bezier->bezier.points[0].p1 = *to;
  for (i = 1; i < bezier->bezier.num_points; i++) {
    point_add(&bezier->bezier.points[i].p1, &p);
    point_add(&bezier->bezier.points[i].p2, &p);
    point_add(&bezier->bezier.points[i].p3, &p);
  }

  return NULL;
}
Example #9
0
/** user_data is a struct polyline_create_data, containing an array of 
    points and a count.
    If user_data is NULL, the startpoint is used and a 1x1 line is created.
    Otherwise, the startpoint is ignored.
*/
static DiaObject *
polyline_create(Point *startpoint,
		  void *user_data,
		  Handle **handle1,
		  Handle **handle2)
{
  Polyline *polyline;
  PolyConn *poly;
  DiaObject *obj;
  Point defaultlen = { 1.0, 1.0 };

  /*polyline_init_defaults();*/
  polyline = g_malloc0(sizeof(Polyline));
  poly = &polyline->poly;
  obj = &poly->object;
  
  obj->type = &polyline_type;
  obj->ops = &polyline_ops;

  if (user_data == NULL) {
    polyconn_init(poly, 2);

    poly->points[0] = *startpoint;
    poly->points[1] = *startpoint;

    point_add(&poly->points[1], &defaultlen);

    *handle1 = poly->object.handles[0];
    *handle2 = poly->object.handles[1];
  } else {
    MultipointCreateData *pcd = (MultipointCreateData *)user_data;

    polyconn_init(poly, pcd->num_points);

    /* Handles are set up by polyconn_init and polyconn_update_data */
    polyconn_set_points(poly, pcd->num_points, pcd->points);

    *handle1 = poly->object.handles[0];
    *handle2 = poly->object.handles[pcd->num_points-1];
  }


  polyline->line_width =  attributes_get_default_linewidth();
  polyline->line_color = attributes_get_foreground();
  attributes_get_default_line_style(&polyline->line_style,
				    &polyline->dashlength);
  polyline->line_join = LINEJOIN_MITER;
  polyline->line_caps = LINECAPS_BUTT;
  polyline->start_arrow = attributes_get_default_start_arrow();
  polyline->end_arrow = attributes_get_default_end_arrow();
  polyline->corner_radius = 0.0;

  polyline_update_data(polyline);

  return &polyline->poly.object;
}
Example #10
0
/*!
 * \brief Move the whole object to the given position
 * 
 * If the object position does not change the whole object should not either.
 * This is used as a kludge to call the protected update_data() function
 *
 * \memberof StdPath
 */
static ObjectChange* 
stdpath_move (StdPath *stdpath, Point *to)
{
  DiaObject *obj = &stdpath->object;
  Point delta = *to;
  int i;

  point_sub (&delta, &obj->position);
  
  for (i = 0; i < stdpath->num_points; ++i) {
     BezPoint *bp = &stdpath->points[i];

     point_add (&bp->p1, &delta);
     point_add (&bp->p2, &delta);
     point_add (&bp->p3, &delta);
  }
  stdpath_update_data (stdpath);
  return NULL;
}
Example #11
0
static Object *
bezierline_create(Point *startpoint,
                  void *user_data,
                  Handle **handle1,
                  Handle **handle2)
{
    Bezierline *bezierline;
    BezierConn *bez;
    Object *obj;
    Point defaultlen = { .3, .3 };

    /*bezierline_init_defaults();*/
    bezierline = g_new(Bezierline, 1);
    bez = &bezierline->bez;
    obj = (Object *) bezierline;

    obj->type = &bezierline_type;
    obj->ops = &bezierline_ops;

    bezierconn_init(bez);

    bez->points[0].p1 = *startpoint;
    bez->points[1].p1 = *startpoint;
    point_add(&bez->points[1].p1, &defaultlen);
    bez->points[1].p2 = bez->points[1].p1;
    point_add(&bez->points[1].p2, &defaultlen);
    bez->points[1].p3 = bez->points[1].p2;
    point_add(&bez->points[1].p3, &defaultlen);

    bezierline_update_data(bezierline);

    bezierline->line_width =  attributes_get_default_linewidth();
    bezierline->line_color = attributes_get_foreground();
    attributes_get_default_line_style(&bezierline->line_style,
                                      &bezierline->dashlength);
    bezierline->start_arrow = attributes_get_default_start_arrow();
    bezierline->end_arrow = attributes_get_default_end_arrow();

    *handle1 = bez->object.handles[0];
    *handle2 = bez->object.handles[3];
    return (Object *)bezierline;
}
Example #12
0
static DiaObject *
bus_create(Point *startpoint,
	   void *user_data,
	   Handle **handle1,
	   Handle **handle2)
{
  Bus *bus;
  Connection *conn;
  LineBBExtras *extra;
  DiaObject *obj;
  Point defaultlen = { 5.0, 0.0 };
  int i;

  bus = g_malloc0(sizeof(Bus));

  conn = &bus->connection;
  conn->endpoints[0] = *startpoint;
  conn->endpoints[1] = *startpoint;
  point_add(&conn->endpoints[1], &defaultlen);
 
  obj = &conn->object;
  extra = &conn->extra_spacing;

  obj->type = &bus_type;
  obj->ops = &bus_ops;

  bus->num_handles = DEFAULT_NUMHANDLES;

  connection_init(conn, 2+bus->num_handles, 0);
  bus->line_color = attributes_get_foreground();
  bus->handles = g_malloc(sizeof(Handle *)*bus->num_handles);
  bus->parallel_points = g_malloc(sizeof(Point)*bus->num_handles);
  for (i=0;i<bus->num_handles;i++) {
    bus->handles[i] = g_new0(Handle,1);
    bus->handles[i]->id = HANDLE_BUS;
    bus->handles[i]->type = HANDLE_MINOR_CONTROL;
    bus->handles[i]->connect_type = HANDLE_CONNECTABLE_NOBREAK;
    bus->handles[i]->connected_to = NULL;
    bus->handles[i]->pos = *startpoint;
    bus->handles[i]->pos.x += 5*((real)i+1)/(bus->num_handles+1);
    bus->handles[i]->pos.y += (i%2==0)?1.0:-1.0;
    obj->handles[2+i] = bus->handles[i];
  }

  extra->start_trans = 
    extra->end_trans = 
    extra->start_long =
    extra->end_long = LINE_WIDTH/2.0;  
  bus_update_data(bus);

  *handle1 = obj->handles[0];
  *handle2 = obj->handles[1];
  return &bus->connection.object;
}
Example #13
0
static void
implements_move(Implements *implements, Point *to)
{
  Point start_to_end;
  Point delta;
  Point *endpoints = &implements->connection.endpoints[0]; 

  delta = *to;
  point_sub(&delta, &endpoints[0]);
  
  start_to_end = endpoints[1];
  point_sub(&start_to_end, &endpoints[0]);

  endpoints[1] = endpoints[0] = *to;
  point_add(&endpoints[1], &start_to_end);

  point_add(&implements->text_pos, &delta);
  
  implements_update_data(implements);
}
Example #14
0
static void
message_move(Message *message, Point *to)
{
  Point start_to_end;
  Point *endpoints = &message->connection.endpoints[0]; 
  Point delta;

  delta = *to;
  point_sub(&delta, &endpoints[0]);
 
  start_to_end = endpoints[1];
  point_sub(&start_to_end, &endpoints[0]);

  endpoints[1] = endpoints[0] = *to;
  point_add(&endpoints[1], &start_to_end);

  point_add(&message->text_pos, &delta);
  
  message_update_data(message);
}
Example #15
0
static Object *
implements_create(Point *startpoint,
		  void *user_data,
		  Handle **handle1,
		  Handle **handle2)
{
  Implements *implements;
  Connection *conn;
  Object *obj;
  Point defaultlen = { 1.0, 1.0 };

  if (implements_font == NULL)
    implements_font = font_getfont("Courier");
  
  implements = g_malloc(sizeof(Implements));

  conn = &implements->connection;
  conn->endpoints[0] = *startpoint;
  conn->endpoints[1] = *startpoint;
  point_add(&conn->endpoints[1], &defaultlen);
 
  obj = (Object *) implements;
  
  obj->type = &implements_type;
  obj->ops = &implements_ops;
  
  connection_init(conn, 4, 0);

  implements->text = strdup("");
  implements->text_width = 0.0;
  implements->text_pos = conn->endpoints[1];
  implements->text_pos.x -= 0.3;
  implements->circle_diameter = 0.7;

  implements->text_handle.id = HANDLE_MOVE_TEXT;
  implements->text_handle.type = HANDLE_MINOR_CONTROL;
  implements->text_handle.connect_type = HANDLE_NONCONNECTABLE;
  implements->text_handle.connected_to = NULL;
  obj->handles[2] = &implements->text_handle;
  
  implements->circle_handle.id = HANDLE_CIRCLE_SIZE;
  implements->circle_handle.type = HANDLE_MINOR_CONTROL;
  implements->circle_handle.connect_type = HANDLE_NONCONNECTABLE;
  implements->circle_handle.connected_to = NULL;
  obj->handles[3] = &implements->circle_handle;

  implements->properties_dialog = NULL;
  
  implements_update_data(implements);

  *handle1 = obj->handles[0];
  *handle2 = obj->handles[1];
  return (Object *)implements;
}
Example #16
0
static void
constraint_move(Constraint *constraint, Point *to)
{
  Point start_to_end;
  Point *endpoints = &constraint->connection.endpoints[0]; 
  Point delta;

  delta = *to;
  point_sub(&delta, &endpoints[0]);
 
  start_to_end = endpoints[1];
  point_sub(&start_to_end, &endpoints[0]);

  endpoints[1] = endpoints[0] = *to;
  point_add(&endpoints[1], &start_to_end);

  point_add(&constraint->text_pos, &delta);
  
  constraint_update_data(constraint);
}
Example #17
0
static ObjectChange *
compound_move (Compound * comp, Point * to)
{
  Point diff;
  Handle * h;
  gint i, num_handles;

  diff.x = to->x - comp->object.position.x;
  diff.y = to->y - comp->object.position.y;

  num_handles = comp->object.num_handles;
  for (i = 0; i < num_handles; i++)
    {
      h = &comp->handles[i];
      point_add (&h->pos, &diff);
    }
  point_add (&comp->mount_point.pos, &diff);

  compound_update_data (comp);
  return NULL;
}
Example #18
0
static ObjectChange*
transition_move(Transition* transition, Point* newpos)
{
  Point delta;
  ObjectChange *change;

  
  /* Find a delta in order to move the text handles along with the transition */
  delta = *newpos;
  point_sub(&delta, &transition->orth.points[0]);
  
  change = orthconn_move(&transition->orth, newpos);

  /* Move the text handles */ 
  point_add(&transition->trigger_text_pos, &delta);
  point_add(&transition->guard_text_pos, &delta);
  
  uml_transition_update_data(transition);

  return change;
}
Example #19
0
File: link.c Project: UIKit0/dia
static ObjectChange*
link_move(Link *link, Point *to)
{
  Point start_to_end;
  Point *endpoints = &link->connection.endpoints[0];
  Point delta;

  delta = *to;
  point_sub(&delta, &endpoints[0]);

  start_to_end = endpoints[1];
  point_sub(&start_to_end, &endpoints[0]);

  endpoints[1] = endpoints[0] = *to;
  point_add(&endpoints[1], &start_to_end);

  point_add(&link->pm, &delta);

  link_update_data(link);
  return NULL;
}
Example #20
0
static point center_of_mass(unsigned n, point o[])
{
  point com;
  unsigned i;
  unsigned long tn;
  com = point_zero;
  for (i = 0; i < n; ++i)
    com = point_add(com, o[i]);
  mpi_add_doubles(comm_mpi(), point_arr(&com), 3);
  tn = mpi_add_ulong(comm_mpi(), n);
  return point_scale(com, 1.0 / tn);
}
Example #21
0
static ObjectChange*
mbr_move(Mbr *mbr, Point *to)
{
  Point start_to_end;
  Point *endpoints = &mbr->connection.endpoints[0];
  Point delta;

  delta = *to;
  point_sub(&delta, &endpoints[0]);

  start_to_end = endpoints[1];
  point_sub(&start_to_end, &endpoints[0]);

  endpoints[1] = endpoints[0] = *to;
  point_add(&endpoints[1], &start_to_end);

  point_add(&mbr->pm, &delta);

  mbr_update_data(mbr);
  return NULL;
}
Example #22
0
static ObjectChange *
compound_move_handle (Compound * comp, Handle * handle,
                      Point * to, ConnectionPoint * cp,
                      HandleMoveReason reason, ModifierKeys modifiers)
{
  if (handle->id == HANDLE_MOUNT_POINT)
    {
      g_assert (handle == &comp->handles[0]);
      comp->mount_point.pos = *to;
    }
  else
    {
      /** ATTENTION: the idea is that while the handles are connected to
       *  an object and that object moves than this compound also moves
       *  (as a whole)! unfortunatelly, this method gets called for each
       *  handle connected and there is not method to register which
       *  would be called after all the handles of this object has been
       *  processed by this routine.  see also
       *  app/connectionpoint_ops.c:diagram_update_connections_object
       *
       *  as a work around we say that when the first handle is moved,
       *  only then we update the position of the mount_point. This
       *  solves the problem for compounds whose handles (all) are
       *  connected to some (even more than one) objects.
       */
      if (reason == HANDLE_MOVE_CONNECTED
          && handle == &comp->handles[1])
        {
          Point diff = *to;
          point_sub (&diff, &handle->pos);

          point_add (&comp->handles[0].pos, &diff);
          point_add (&comp->mount_point.pos, &diff);
        }
    }
  handle->pos = *to;
  compound_update_data (comp);
  return NULL;
}
Example #23
0
/* finds the point intersecting the full circle
 * on the vector defined by the center and Point *to
 * that point is returned in Point *best if 1 is returned */
static int
arc_find_radial(const Arc *arc, const Point *to, Point *best)
{
    Point tmp;
    tmp = *to;
    point_sub(&tmp, &arc->center);
    point_normalize(&tmp);
    point_scale(&tmp,arc->radius);
    point_add(&tmp, &arc->center);
    *best = tmp;
    return 1;

}
Example #24
0
static ObjectChange*
annotation_move(Annotation *annotation, Point *to)
{
  Point start_to_end;
  Point *endpoints = &annotation->connection.endpoints[0]; 
  Point delta;

  delta = *to;
  point_sub(&delta, &endpoints[0]);
 
  start_to_end = endpoints[1];
  point_sub(&start_to_end, &endpoints[0]);

  endpoints[1] = endpoints[0] = *to;
  point_add(&endpoints[1], &start_to_end);

  point_add(&annotation->text->position, &delta);
  
  annotation_update_data(annotation);

  return NULL;
}
Example #25
0
File: flow.c Project: brunetton/dia
static ObjectChange*
flow_move(Flow *flow, Point *to)
{
  Point start_to_end;
  Point *endpoints = &flow->connection.endpoints[0]; 
  Point delta;

  delta = *to;
  point_sub(&delta, &endpoints[0]);
 
  start_to_end = endpoints[1];
  point_sub(&start_to_end, &endpoints[0]);

  endpoints[1] = endpoints[0] = *to;
  point_add(&endpoints[1], &start_to_end);

  point_add(&flow->textpos, &delta);

  flow_update_data(flow);

  return NULL;
}
Example #26
0
File: arc.c Project: mpuels/dia
/** rotates p around the center by an angle given in radians 
 * a positive angle is ccw on the screen*/
static void
rotate_point_around_point(Point *p, const Point *center, real angle)
{
        real radius;
        real a;
        point_sub(p,center);
        radius = point_len(p);
        a = -atan2(p->y,p->x); /* y axis points down*/
        a += angle;
        p->x = cos(a); p->y = -sin(a);/* y axis points down*/
        point_scale(p,radius);
        point_add(p,center);
}
Example #27
0
static void ec_GFp_nistp256_add(const EC_GROUP *group, EC_RAW_POINT *r,
                                const EC_RAW_POINT *a, const EC_RAW_POINT *b) {
  fe x1, y1, z1, x2, y2, z2;
  fe_from_generic(x1, &a->X);
  fe_from_generic(y1, &a->Y);
  fe_from_generic(z1, &a->Z);
  fe_from_generic(x2, &b->X);
  fe_from_generic(y2, &b->Y);
  fe_from_generic(z2, &b->Z);
  point_add(x1, y1, z1, x1, y1, z1, 0 /* both Jacobian */, x2, y2, z2);
  fe_to_generic(&r->X, x1);
  fe_to_generic(&r->Y, y1);
  fe_to_generic(&r->Z, z1);
}
Example #28
0
File: ec.c Project: lyvius/ps3tools
static void point_mul(struct point *d, u8 *a, struct point *b)	// a is bignum
{
	u32 i;
	u8 mask;

	point_zero(d);

	for (i = 0; i < 21; i++)
		for (mask = 0x80; mask != 0; mask >>= 1) {
			point_double(d, d);
			if ((a[i] & mask) != 0)
				point_add(d, d, b);
		}
}
Example #29
0
static DiaObject *
constraint_create(Point *startpoint,
		  void *user_data,
		  Handle **handle1,
		  Handle **handle2)
{
  Constraint *constraint;
  Connection *conn;
  DiaObject *obj;
  Point defaultlen = { 1.0, 1.0 };

  constraint = g_malloc0(sizeof(Constraint));

  /* old defaults */
  constraint->font_height = 0.8;
  constraint->font =
      dia_font_new_from_style (DIA_FONT_MONOSPACE, constraint->font_height);
  constraint->line_width = 0.1;

  conn = &constraint->connection;
  conn->endpoints[0] = *startpoint;
  conn->endpoints[1] = *startpoint;
  point_add(&conn->endpoints[1], &defaultlen);

  obj = &conn->object;

  obj->type = &constraint_type;
  obj->ops = &constraint_ops;
  
  connection_init(conn, 3, 0);

  constraint->text_color = color_black;
  constraint->line_color = attributes_get_foreground();
  constraint->text = g_strdup("");
  constraint->text_pos.x = 0.5*(conn->endpoints[0].x + conn->endpoints[1].x);
  constraint->text_pos.y = 0.5*(conn->endpoints[0].y + conn->endpoints[1].y) - 0.2;

  constraint->text_handle.id = HANDLE_MOVE_TEXT;
  constraint->text_handle.type = HANDLE_MINOR_CONTROL;
  constraint->text_handle.connect_type = HANDLE_NONCONNECTABLE;
  constraint->text_handle.connected_to = NULL;
  obj->handles[2] = &constraint->text_handle;
  
  constraint->brtext = NULL;
  constraint_update_data(constraint);

  *handle1 = obj->handles[0];
  *handle2 = obj->handles[1];
  return &constraint->connection.object;
}
Example #30
0
static void
arc_move(Arc *arc, Point *to)
{
  Point start_to_end;
  Point *endpoints = &arc->connection.endpoints[0]; 

  start_to_end = endpoints[1];
  point_sub(&start_to_end, &endpoints[0]);

  endpoints[1] = endpoints[0] = *to;
  point_add(&endpoints[1], &start_to_end);

  arc_update_data(arc);
}