/*! \brief Mirror the WORLD coordinates of an ARC. * \par Function Description * This function mirrors the world coordinates of an arc. * The symetry axis is given by the vertical line going through the point (<B>world_centerx</B>,<B>world_centery</B>). * * The arc is translated in order to put the point (<B>world_centerx</B>,<B>world_centery</B>) * on the origin. The center of the arc is then mirrored. The start angle of the arc * and the sweep of the arc are also mirrored. * * The arc is finally back translated to its previous location on the page. * * \param [in] toplevel The TOPLEVEL object. * \param [in] world_centerx * \param [in] world_centery * \param [in] object */ void o_arc_mirror_world(TOPLEVEL *toplevel, int world_centerx, int world_centery, OBJECT *object) { /* translate object to origin */ object->arc->x -= world_centerx; object->arc->y -= world_centery; /* get center, and mirror it (vertical mirror) */ object->arc->x = -object->arc->x; object->arc->y = object->arc->y; /* apply mirror to angles (vertical mirror) */ object->arc->start_angle = (180 - object->arc->start_angle) % 360; /* start_angle *MUST* be positive */ if(object->arc->start_angle < 0) object->arc->start_angle += 360; object->arc->end_angle = -object->arc->end_angle; /* translate object back to its previous position */ object->arc->x += world_centerx; object->arc->y += world_centery; /* update the screen coords and bounding box */ o_arc_recalc(toplevel, object); }
/*! \brief * \par Function Description * This function rotates the world coordinates of an arc of an angle * specified by <B>angle</B>. The center of the rotation is given by * (<B>world_centerx</B>,<B>world_centery</B>). * * The arc is translated in order to put the center of the rotation * on the origin. The center of the arc is then rotated of the angle * specified by <B>angle</B>. The start angle of the arc is incremented by <B>angle</B>. * * The arc is finally back translated to its previous location on the page. * * <B>world_centerx</B> and <B>world_centery</B> are in world units, <B>angle</B> is in degrees. * * \param [in] toplevel The TOPLEVEL object. * \param [in] world_centerx * \param [in] world_centery * \param [in] angle * \param [in] object */ void o_arc_rotate_world(TOPLEVEL *toplevel, int world_centerx, int world_centery, int angle, OBJECT *object) { int x, y, newx, newy; /* translate object to origin */ object->arc->x -= world_centerx; object->arc->y -= world_centery; /* get center, and rotate center */ x = object->arc->x; y = object->arc->y; if(angle % 90 == 0) { rotate_point_90(x, y, angle % 360, &newx, &newy); } else { rotate_point(x, y, angle % 360, &newx, &newy); } object->arc->x = newx; object->arc->y = newy; /* apply rotation to angles */ object->arc->start_angle = (object->arc->start_angle + angle) % 360; /* end_angle is unchanged as it is the sweep of the arc */ /* object->arc->end_angle = (object->arc->end_angle); */ /* translate object to its previous place */ object->arc->x += world_centerx; object->arc->y += world_centery; /* update the screen coords and the bounding box */ o_arc_recalc(toplevel, object); }
/*! \brief Recalculate position of the given object. * \par Function Description * This function will take an object and recalculate its * position on the screen. * * \param [in] toplevel The TOPLEVEL object. * \param [in,out] o_current OBJECT to recalculate. * */ void o_recalc_single_object(TOPLEVEL *toplevel, OBJECT *o_current) { if (o_current != NULL) { switch(o_current->type) { case(OBJ_LINE): o_line_recalc(toplevel, o_current); break; case(OBJ_NET): o_net_recalc(toplevel, o_current); break; case(OBJ_BUS): o_bus_recalc(toplevel, o_current); break; case(OBJ_BOX): o_box_recalc(toplevel, o_current); break; case(OBJ_PATH): o_path_recalc(toplevel, o_current); break; case(OBJ_PICTURE): o_picture_recalc(toplevel, o_current); break; case(OBJ_CIRCLE): o_circle_recalc(toplevel, o_current); break; case(OBJ_COMPLEX): case(OBJ_PLACEHOLDER): o_complex_recalc(toplevel, o_current); break; case(OBJ_PIN): o_pin_recalc(toplevel, o_current); break; case(OBJ_ARC): o_arc_recalc(toplevel, o_current); break; case(OBJ_TEXT): o_text_recalc(toplevel, o_current); break; } } }
/*! \brief * \par Function Description * The function creates a new OBJECT of type arc. * * The arc is defined by its center in parameters x and y. * The radius parameter specifies the radius of the arc. The start * angle is given by start_angle and the end angle by end_angle. * The line and fill type of the created arc are set to default. * * All dimensions are in world unit, except start_angle and * end_angle in degrees. * * A new object of type OBJECT is allocated. Its type and color * are initilized. The description of the arc characteristics * are stored in a new ARC structure. * * Now fixed for world coordinates. * * \param [in] toplevel The TOPLEVEL object. * \param [in] type * \param [in] color * \param [in] x * \param [in] y * \param [in] radius * \param [in] start_angle * \param [in] end_angle * \return */ OBJECT *o_arc_new(TOPLEVEL *toplevel, char type, int color, int x, int y, int radius, int start_angle, int end_angle) { OBJECT *new_node; new_node = s_basic_new_object(type, "arc"); new_node->color = color; new_node->arc = (ARC *) g_malloc(sizeof(ARC)); /*! \note * The ARC structure is initialized with the parameters. * A default initialization is performed for the line and * fill type to avoid misunderstanding. * * The functions relative to the use of the object are sets. */ /* World coordinates */ new_node->arc->x = x; new_node->arc->y = y; new_node->arc->width = 2 * radius; new_node->arc->height = 2 * radius; /* must check the sign of start_angle, end_angle ... */ if(end_angle < 0) { start_angle = start_angle + end_angle; end_angle = -end_angle; } if(start_angle < 0) start_angle = 360 + start_angle; new_node->arc->start_angle = start_angle; new_node->arc->end_angle = end_angle; /* Default init */ o_set_line_options(toplevel, new_node, o_get_line_end(toplevel->print_output_capstyle), TYPE_SOLID, 0, -1, -1); o_set_fill_options(toplevel, new_node, FILLING_HOLLOW, -1, -1, -1, -1, -1); o_arc_recalc(toplevel, new_node); /* new_node->graphical = arc; eventually */ return new_node; }
/*! \brief * \par Function Description * This function applies a translation of (<B>dx</B>,<B>dy</B>) * to the arc described in <B>*object</B>. <B>dx</B> and <B>dy</B> are in world unit. * * \param [in] toplevel The TOPLEVEL object. * \param [in] dx * \param [in] dy * \param [in] object */ void o_arc_translate_world(TOPLEVEL *toplevel, int dx, int dy, OBJECT *object) { if (object == NULL) { return; } /* Do world coords */ object->arc->x = object->arc->x + dx; object->arc->y = object->arc->y + dy; /* Recalculate screen coords from new world coords */ o_arc_recalc(toplevel, object); }
/*! \brief * \par Function Description * This function modifies the internal values of the arc object * *object according to the whichone parameter. * * The new values are given by <B>x</B> and/or <B>y</B>. Their meaning depends on the value of whichone. * * If <B>whichone</B> is equal to #ARC_CENTER, the (<B>x</B>,<B>y</B>) point is taken as the new center * of the arc in world unit. * * If <B>whichone</B> is equal to #ARC_RADIUS, the <B>x</B> parameter is taken to be the radius * of the arc in world unit. The <B>y</B> parameter is ignored. * * If <B>whichone</B> is equal to #ARC_START_ANGLE, the <B>x</B> parameter is the starting angle of the arc. * <B>x</B> is in degrees. <B>y</B> is ignored. * * If <B>whichone</B> is equal to #ARC_END_ANGLE, the <B>x</B> parameter is the ending angle of the arc. * <B>x</B> is in degrees. <B>y</B> is ignored. * * \param [in] toplevel The TOPLEVEL object. * \param [in,out] object * \param [in] x * \param [in] y * \param [in] whichone */ void o_arc_modify(TOPLEVEL *toplevel, OBJECT *object, int x, int y, int whichone) { o_emit_pre_change_notify (toplevel, object); switch(whichone) { case ARC_CENTER: /* modify the center of arc object */ object->arc->x = x; object->arc->y = y; break; case ARC_RADIUS: /* modify the radius of arc object */ object->arc->width = 2 * x; object->arc->height = 2 * x; break; case ARC_START_ANGLE: /* modify the start angle of the arc object */ object->arc->start_angle = x; break; case ARC_END_ANGLE: /* modify the end angle of the arc object */ object->arc->end_angle = x; break; default: break; } /* update the screen coords and the bounding box */ o_arc_recalc(toplevel, object); o_emit_change_notify (toplevel, object); }