本文整理汇总了C++中SPCurve::lineto方法的典型用法代码示例。如果您正苦于以下问题:C++ SPCurve::lineto方法的具体用法?C++ SPCurve::lineto怎么用?C++ SPCurve::lineto使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPCurve
的用法示例。
在下文中一共展示了SPCurve::lineto方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set
void SPPolyLine::set(SPObject *object, unsigned int key, const gchar *value)
{
SPPolyLine *polyline = SP_POLYLINE(object);
switch (key) {
case SP_ATTR_POINTS: {
SPCurve * curve;
const gchar * cptr;
char * eptr;
gboolean hascpt;
if (!value) break;
curve = new SPCurve ();
hascpt = FALSE;
cptr = value;
eptr = NULL;
while (TRUE) {
gdouble x, y;
while (*cptr != '\0' && (*cptr == ',' || *cptr == '\x20' || *cptr == '\x9' || *cptr == '\xD' || *cptr == '\xA')) {
cptr++;
}
if (!*cptr) break;
x = g_ascii_strtod (cptr, &eptr);
if (eptr == cptr) break;
cptr = eptr;
while (*cptr != '\0' && (*cptr == ',' || *cptr == '\x20' || *cptr == '\x9' || *cptr == '\xD' || *cptr == '\xA')) {
cptr++;
}
if (!*cptr) break;
y = g_ascii_strtod (cptr, &eptr);
if (eptr == cptr) break;
cptr = eptr;
if (hascpt) {
curve->lineto(x, y);
} else {
curve->moveto(x, y);
hascpt = TRUE;
}
}
(SP_SHAPE (polyline))->setCurve (curve, TRUE);
curve->unref();
break;
}
default:
if (((SPObjectClass *) SPPolyLineClass::static_parent_class)->set) {
((SPObjectClass *) SPPolyLineClass::static_parent_class)->set (object, key, value);
}
break;
}
}
示例2: set_shape
void SPLine::set_shape() {
SPCurve *c = new SPCurve();
c->moveto(this->x1.computed, this->y1.computed);
c->lineto(this->x2.computed, this->y2.computed);
this->setCurveInsync(c, TRUE); // *_insync does not call update, avoiding infinite recursion when set_shape is called by update
this->setCurveBeforeLPE(c);
// LPE's cannot be applied to lines. (the result can (generally) not be represented as SPLine)
c->unref();
}
示例3: SPCurve
SPCurve *
SPCurve::new_from_rect(Geom::Rect const &rect, bool all_four_sides)
{
SPCurve *c = new SPCurve();
Geom::Point p = rect.corner(0);
c->moveto(p);
for (int i=3; i>=1; i--) {
c->lineto(rect.corner(i));
}
if (all_four_sides) {
// When _constrained_ snapping to a path, the 2geom::SimpleCrosser will be invoked which doesn't consider the closing segment.
// of a path. Consequently, in case we want to snap to for example the page border, we must provide all four sides of the
// rectangle explicitly
c->lineto(rect.corner(0));
} else {
// ... instead of just three plus a closing segment
c->closepath();
}
return c;
}
示例4: set_shape
void SPStar::set_shape() {
// perhaps we should convert all our shapes into LPEs without source path
// and with knotholders for parameters, then this situation will be handled automatically
// by disabling the entire stack (including the shape LPE)
if (hasBrokenPathEffect()) {
g_warning ("The star shape has unknown LPE on it! Convert to path to make it editable preserving the appearance; editing it as star will remove the bad LPE");
if (this->getRepr()->attribute("d")) {
// unconditionally read the curve from d, if any, to preserve appearance
Geom::PathVector pv = sp_svg_read_pathv(this->getRepr()->attribute("d"));
SPCurve *cold = new SPCurve(pv);
this->setCurveInsync( cold, TRUE);
this->setCurveBeforeLPE(cold);
cold->unref();
}
return;
}
SPCurve *c = new SPCurve ();
bool not_rounded = (fabs (this->rounded) < 1e-4);
// note that we pass randomized=true to sp_star_get_xy, because the curve must be randomized;
// other places that call that function (e.g. the knotholder) need the exact point
// draw 1st segment
c->moveto(sp_star_get_xy (this, SP_STAR_POINT_KNOT1, 0, true));
if (this->flatsided == false) {
if (not_rounded) {
c->lineto(sp_star_get_xy (this, SP_STAR_POINT_KNOT2, 0, true));
} else {
c->curveto(sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT1, 0, NEXT),
sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT2, 0, PREV),
sp_star_get_xy (this, SP_STAR_POINT_KNOT2, 0, true));
}
}
// draw all middle segments
for (gint i = 1; i < sides; i++) {
if (not_rounded) {
c->lineto(sp_star_get_xy (this, SP_STAR_POINT_KNOT1, i, true));
} else {
if (this->flatsided == false) {
c->curveto(sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT2, i - 1, NEXT),
sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT1, i, PREV),
sp_star_get_xy (this, SP_STAR_POINT_KNOT1, i, true));
} else {
c->curveto(sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT1, i - 1, NEXT),
sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT1, i, PREV),
sp_star_get_xy (this, SP_STAR_POINT_KNOT1, i, true));
}
}
if (this->flatsided == false) {
if (not_rounded) {
c->lineto(sp_star_get_xy (this, SP_STAR_POINT_KNOT2, i, true));
} else {
c->curveto(sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT1, i, NEXT),
sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT2, i, PREV),
sp_star_get_xy (this, SP_STAR_POINT_KNOT2, i, true));
}
}
}
// draw last segment
if (!not_rounded) {
if (this->flatsided == false) {
c->curveto(sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT2, sides - 1, NEXT),
sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT1, 0, PREV),
sp_star_get_xy (this, SP_STAR_POINT_KNOT1, 0, true));
} else {
c->curveto(sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT1, sides - 1, NEXT),
sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT1, 0, PREV),
sp_star_get_xy (this, SP_STAR_POINT_KNOT1, 0, true));
}
}
c->closepath();
/* Reset the shape'scurve to the "original_curve"
* This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/
this->setCurveInsync( c, TRUE);
this->setCurveBeforeLPE( c );
if (hasPathEffect() && pathEffectsEnabled()) {
SPCurve *c_lpe = c->copy();
bool success = this->performPathEffect(c_lpe);
if (success) {
this->setCurveInsync( c_lpe, TRUE);
}
c_lpe->unref();
}
c->unref();
}
示例5: SPCurve
void Box3DSide::set_shape() {
if (!this->document->getRoot()) {
// avoid a warning caused by sp_document_height() (which is called from sp_item_i2d_affine() below)
// when reading a file containing 3D boxes
return;
}
SPObject *parent = this->parent;
if (!SP_IS_BOX3D(parent)) {
g_warning("Parent of 3D box side is not a 3D box.\n");
return;
}
SPBox3D *box = SP_BOX3D(parent);
Persp3D *persp = box3d_side_perspective(this);
if (!persp) {
return;
}
// TODO: Draw the correct quadrangle here
// To do this, determine the perspective of the box, the orientation of the side (e.g., XY-FRONT)
// compute the coordinates of the corners in P^3, project them onto the canvas, and draw the
// resulting path.
unsigned int corners[4];
box3d_side_compute_corner_ids(this, corners);
SPCurve *c = new SPCurve();
if (!box3d_get_corner_screen(box, corners[0]).isFinite() ||
!box3d_get_corner_screen(box, corners[1]).isFinite() ||
!box3d_get_corner_screen(box, corners[2]).isFinite() ||
!box3d_get_corner_screen(box, corners[3]).isFinite() )
{
g_warning ("Trying to draw a 3D box side with invalid coordinates.\n");
return;
}
c->moveto(box3d_get_corner_screen(box, corners[0]));
c->lineto(box3d_get_corner_screen(box, corners[1]));
c->lineto(box3d_get_corner_screen(box, corners[2]));
c->lineto(box3d_get_corner_screen(box, corners[3]));
c->closepath();
/* Reset the this'scurve to the "original_curve"
* This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/
this->setCurveInsync( c, TRUE);
if (hasPathEffect() && pathEffectsEnabled()) {
SPCurve *c_lpe = c->copy();
bool success = this->performPathEffect(c_lpe);
if (success) {
this->setCurveInsync(c_lpe, TRUE);
}
c_lpe->unref();
}
c->unref();
}
示例6: sp_polygon_set
void sp_polygon_set(SPObject *object, unsigned int key, const gchar *value)
{
SPPolygon *polygon = SP_POLYGON(object);
switch (key) {
case SP_ATTR_POINTS: {
if (!value) {
/* fixme: The points attribute is required. We should handle its absence as per
* http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing. */
break;
}
SPCurve *curve = new SPCurve();
gboolean hascpt = FALSE;
gchar const *cptr = value;
bool has_error = false;
while (TRUE) {
gdouble x;
if (!polygon_get_value(&cptr, &x)) {
break;
}
gdouble y;
if (!polygon_get_value(&cptr, &y)) {
/* fixme: It is an error for an odd number of points to be specified. We
* should display the points up to now (as we currently do, though perhaps
* without the closepath: the spec isn't quite clear on whether to do a
* closepath or not, though I'd guess it's best not to do a closepath), but
* then flag the document as in error, as per
* http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing.
*
* (Ref: http://www.w3.org/TR/SVG11/shapes.html#PolygonElement.) */
has_error = true;
break;
}
if (hascpt) {
curve->lineto(x, y);
} else {
curve->moveto(x, y);
hascpt = TRUE;
}
}
if (has_error || *cptr != '\0') {
/* TODO: Flag the document as in error, as per
* http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing. */
} else if (hascpt) {
/* We might have done a moveto but no lineto. I'm not sure how we're supposed to represent
* a single-point polygon in SPCurve. TODO: add a testcase with only one coordinate pair */
curve->closepath();
}
sp_shape_set_curve(SP_SHAPE(polygon), curve, TRUE);
curve->unref();
break;
}
default:
if (((SPObjectClass *) parent_class)->set) {
((SPObjectClass *) parent_class)->set(object, key, value);
}
break;
}
}