本文整理汇总了C++中SPCurve::get_pathvector方法的典型用法代码示例。如果您正苦于以下问题:C++ SPCurve::get_pathvector方法的具体用法?C++ SPCurve::get_pathvector怎么用?C++ SPCurve::get_pathvector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPCurve
的用法示例。
在下文中一共展示了SPCurve::get_pathvector方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addCanvasIndicators
/**
* Return a vector of PathVectors which contain all helperpaths that should be drawn by the effect.
* This is the function called by external code like SPLPEItem.
*/
std::vector<Geom::PathVector>
Effect::getHelperPaths(SPLPEItem *lpeitem)
{
std::vector<Geom::PathVector> hp_vec;
if (!SP_IS_SHAPE(lpeitem)) {
// g_print ("How to handle helperpaths for non-shapes?\n"); // non-shapes are for example SPGroups.
return hp_vec;
}
// TODO: we can probably optimize this by using a lot more references
// rather than copying PathVectors all over the place
if (show_orig_path) {
// add original path to helperpaths
SPCurve* curve = sp_shape_get_curve (SP_SHAPE(lpeitem));
hp_vec.push_back(curve->get_pathvector());
}
// add other helperpaths provided by the effect itself
addCanvasIndicators(lpeitem, hp_vec);
// add helperpaths provided by the effect's parameters
for (std::vector<Parameter *>::iterator p = param_vector.begin(); p != param_vector.end(); ++p) {
(*p)->addCanvasIndicators(lpeitem, hp_vec);
}
return hp_vec;
}
示例2: if
static void
sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write)
{
GSList const *item_list = sp_item_group_item_list(SP_GROUP(group));
for ( GSList const *iter = item_list; iter; iter = iter->next ) {
SPObject *subitem = static_cast<SPObject *>(iter->data);
if (SP_IS_GROUP(subitem)) {
sp_group_perform_patheffect(SP_GROUP(subitem), topgroup, write);
} else if (SP_IS_SHAPE(subitem)) {
SPCurve * c = NULL;
if (SP_IS_PATH(subitem)) {
c = SP_PATH(subitem)->get_original_curve();
} else {
c = SP_SHAPE(subitem)->getCurve();
}
// only run LPEs when the shape has a curve defined
if (c) {
sp_lpe_item_perform_path_effect(SP_LPE_ITEM(topgroup), c);
SP_SHAPE(subitem)->setCurve(c, TRUE);
if (write) {
Inkscape::XML::Node *repr = subitem->getRepr();
gchar *str = sp_svg_write_path(c->get_pathvector());
repr->setAttribute("d", str);
#ifdef GROUP_VERBOSE
g_message("sp_group_perform_patheffect writes 'd' attribute");
#endif
g_free(str);
}
c->unref();
}
}
}
}
示例3: refresh_source
void SPUsePath::refresh_source()
{
sourceDirty = false;
delete originalPath;
originalPath = NULL;
// le mauvais cas: pas d'attribut d => il faut verifier que c'est une SPShape puis prendre le contour
// [tr: The bad case: no d attribute. Must check that it's a SPShape and then take the outline.]
SPObject *refobj = sourceObject;
if ( refobj == NULL ) return;
SPItem *item = SP_ITEM(refobj);
SPCurve *curve = NULL;
if (SP_IS_SHAPE(item))
{
curve = SP_SHAPE(item)->getCurve();
}
else if (SP_IS_TEXT(item))
{
curve = SP_TEXT(item)->getNormalizedBpath();
}
else
{
return;
}
if (curve == NULL)
return;
originalPath = new Path;
originalPath->LoadPathVector(curve->get_pathvector(), item->transform, true);
curve->unref();
}
示例4:
void
lpetool_update_measuring_items(LpeTool *lc)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
for ( std::map<SPPath *, SPCanvasItem*>::iterator i = lc->measuring_items->begin();
i != lc->measuring_items->end();
++i )
{
SPPath *path = i->first;
SPCurve *curve = path->getCurve();
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = Geom::paths_to_pw(curve->get_pathvector());
Inkscape::Util::Unit const * unit = NULL;
if (prefs->getString("/tools/lpetool/unit").compare("")) {
unit = unit_table.getUnit(prefs->getString("/tools/lpetool/unit"));
} else {
unit = unit_table.getUnit("px");
}
double lengthval = Geom::length(pwd2);
lengthval = Inkscape::Util::Quantity::convert(lengthval, "px", unit);
gchar *arc_length = g_strdup_printf("%.2f %s", lengthval, unit->abbr.c_str());
sp_canvastext_set_text (SP_CANVASTEXT(i->second), arc_length);
set_pos_and_anchor(SP_CANVASTEXT(i->second), pwd2, 0.5, 10);
// TODO: must we free arc_length?
}
}
示例5:
void
sp_selected_path_reverse(SPDesktop *desktop)
{
Inkscape::Selection *selection = desktop->getSelection();
std::vector<SPItem*> items = selection->itemList();
if (items.empty()) {
desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to reverse."));
return;
}
// set "busy" cursor
desktop->setWaitingCursor();
bool did = false;
desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Reversing paths..."));
for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); ++i){
SPPath *path = dynamic_cast<SPPath *>(*i);
if (!path) {
continue;
}
did = true;
SPCurve *rcurve = path->get_curve_reference()->create_reverse();
gchar *str = sp_svg_write_path(rcurve->get_pathvector());
if ( path->hasPathEffectRecursive() ) {
path->getRepr()->setAttribute("inkscape:original-d", str);
} else {
path->getRepr()->setAttribute("d", str);
}
g_free(str);
rcurve->unref();
// reverse nodetypes order (Bug #179866)
gchar *nodetypes = g_strdup(path->getRepr()->attribute("sodipodi:nodetypes"));
if ( nodetypes ) {
path->getRepr()->setAttribute("sodipodi:nodetypes", g_strreverse(nodetypes));
g_free(nodetypes);
}
}
desktop->clearWaitingCursor();
if (did) {
DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_REVERSE,
_("Reverse path"));
} else {
desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No paths</b> to reverse in the selection."));
}
}
示例6:
void
sp_selected_path_reverse(SPDesktop *desktop)
{
Inkscape::Selection *selection = sp_desktop_selection(desktop);
GSList *items = (GSList *) selection->itemList();
if (!items) {
sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to reverse."));
return;
}
// set "busy" cursor
desktop->setWaitingCursor();
bool did = false;
desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Reversing paths..."));
for (GSList *i = items; i != NULL; i = i->next) {
if (!SP_IS_PATH(i->data)) {
continue;
}
did = true;
SPPath *path = SP_PATH(i->data);
SPCurve *rcurve = path->get_curve_reference()->create_reverse();
gchar *str = sp_svg_write_path(rcurve->get_pathvector());
if ( path->hasPathEffectRecursive() ) {
path->getRepr()->setAttribute("inkscape:original-d", str);
} else {
path->getRepr()->setAttribute("d", str);
}
g_free(str);
rcurve->unref();
// reverse nodetypes order (Bug #179866)
gchar *nodetypes = g_strdup(path->getRepr()->attribute("sodipodi:nodetypes"));
if ( nodetypes ) {
path->getRepr()->setAttribute("sodipodi:nodetypes", g_strreverse(nodetypes));
g_free(nodetypes);
}
}
desktop->clearWaitingCursor();
if (did) {
DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_REVERSE,
_("Reverse path"));
} else {
sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("<b>No paths</b> to reverse in the selection."));
}
}
示例7:
/**
* Computes a point on the offset; used to set a "seed" position for
* the control knot.
*
* \return the topmost point on the offset.
*/
void
sp_offset_top_point (SPOffset const * offset, Geom::Point *px)
{
(*px) = Geom::Point(0, 0);
if (offset == NULL) {
return;
}
if (offset->knotSet)
{
(*px) = offset->knot;
return;
}
SPCurve *curve = SP_SHAPE (offset)->getCurve();
if (curve == NULL)
{
// CPPIFY
//offset->set_shape();
const_cast<SPOffset*>(offset)->set_shape();
curve = SP_SHAPE (offset)->getCurve();
if (curve == NULL)
return;
}
if (curve->is_empty())
{
curve->unref();
return;
}
Path *finalPath = new Path;
finalPath->LoadPathVector(curve->get_pathvector());
Shape *theShape = new Shape;
finalPath->Convert (1.0);
finalPath->Fill (theShape, 0);
if (theShape->hasPoints())
{
theShape->SortPoints ();
*px = theShape->getPoint(0).x;
}
delete theShape;
delete finalPath;
curve->unref();
}
开发者ID:NotBrianZach,项目名称:modalComposableProgrammableFuzzySearchingVectorGraphicEditing,代码行数:59,代码来源:sp-offset.cpp
示例8: SPCurve
/**
* Return new curve that is the concatenation of all curves in list.
*/
SPCurve *
SPCurve::concat(GSList const *list)
{
SPCurve *new_curve = new SPCurve();
for (GSList const *l = list; l != NULL; l = l->next) {
SPCurve *c = static_cast<SPCurve *>(l->data);
new_curve->_pathv.insert( new_curve->_pathv.end(), c->get_pathvector().begin(), c->get_pathvector().end() );
}
return new_curve;
}
示例9: if
void
SPLPEItem::apply_to_clip_or_mask_group(SPItem *group, SPItem *item)
{
if (!SP_IS_GROUP(group)) {
return;
}
GSList *item_list = sp_item_group_item_list(SP_GROUP(group));
for ( GSList *iter = item_list; iter; iter = iter->next ) {
SPObject *subitem = static_cast<SPObject *>(iter->data);
if (SP_IS_GROUP(subitem)) {
apply_to_clip_or_mask_group(SP_ITEM(subitem), item);
} else if (SP_IS_SHAPE(subitem)) {
SPCurve * c = NULL;
if (SP_IS_PATH(subitem)) {
c = SP_PATH(subitem)->get_original_curve();
} else {
c = SP_SHAPE(subitem)->getCurve();
}
if (c) {
bool success = false;
if(SP_IS_GROUP(group)){
c->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this)));
success = this->performPathEffect(c);
c->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this)).inverse());
} else {
success = this->performPathEffect(c);
}
Inkscape::XML::Node *repr = subitem->getRepr();
if (success) {
gchar *str = sp_svg_write_path(c->get_pathvector());
repr->setAttribute("d", str);
g_free(str);
} else {
// LPE was unsuccesfull. Read the old 'd'-attribute.
if (gchar const * value = repr->attribute("d")) {
Geom::PathVector pv = sp_svg_read_pathv(value);
SPCurve *oldcurve = new SPCurve(pv);
if (oldcurve) {
SP_SHAPE(subitem)->setCurve(oldcurve, TRUE);
oldcurve->unref();
}
}
}
c->unref();
}
}
}
}
示例10:
void
lpetool_create_measuring_items(SPLPEToolContext *lc, Inkscape::Selection *selection)
{
if (!selection) {
selection = sp_desktop_selection(lc->desktop);
}
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool show = prefs->getBool("/tools/lpetool/show_measuring_info", true);
SPPath *path;
SPCurve *curve;
SPCanvasText *canvas_text;
SPCanvasGroup *tmpgrp = sp_desktop_tempgroup(lc->desktop);
gchar *arc_length;
double lengthval;
for (GSList const *i = selection->itemList(); i != NULL; i = i->next) {
if (SP_IS_PATH(i->data)) {
path = SP_PATH(i->data);
curve = sp_shape_get_curve(SP_SHAPE(path));
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = paths_to_pw(curve->get_pathvector());
canvas_text = (SPCanvasText *) sp_canvastext_new(tmpgrp, lc->desktop, Geom::Point(0,0), "");
if (!show)
sp_canvas_item_hide(SP_CANVAS_ITEM(canvas_text));
SPUnitId unitid = static_cast<SPUnitId>(prefs->getInt("/tools/lpetool/unitid", SP_UNIT_PX));
SPUnit unit = sp_unit_get_by_id(unitid);
lengthval = Geom::length(pwd2);
gboolean success;
success = sp_convert_distance(&lengthval, &sp_unit_get_by_id(SP_UNIT_PX), &unit);
arc_length = g_strdup_printf("%.2f %s", lengthval, success ? sp_unit_get_abbreviation(&unit) : "px");
sp_canvastext_set_text (canvas_text, arc_length);
set_pos_and_anchor(canvas_text, pwd2, 0.5, 10);
// TODO: must we free arc_length?
(*lc->measuring_items)[path] = SP_CANVAS_ITEM(canvas_text);
}
}
}
示例11:
void
KnotHolderEntityAttachPt::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state)
{
using namespace Geom;
LPETangentToCurve* lpe = dynamic_cast<LPETangentToCurve *>(_effect);
Geom::Point const s = snap_knot_position(p, state);
// FIXME: There must be a better way of converting the path's SPCurve* to pwd2.
SPCurve *curve = SP_PATH(item)->get_curve_for_edit();
Geom::PathVector pathv = curve->get_pathvector();
Piecewise<D2<SBasis> > pwd2;
for (unsigned int i=0; i < pathv.size(); i++) {
pwd2.concat(pathv[i].toPwSb());
}
double t0 = nearest_point(s, pwd2);
lpe->t_attach.param_set_value(t0);
// FIXME: this should not directly ask for updating the item. It should write to SVG, which triggers updating.
sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true);
}
示例12:
void
OriginalPathParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*/)
{
SPCurve *curve = NULL;
if (SP_IS_SHAPE(linked_obj)) {
curve = SP_SHAPE(linked_obj)->getCurveBeforeLPE();
}
if (SP_IS_TEXT(linked_obj)) {
curve = SP_TEXT(linked_obj)->getNormalizedBpath();
}
if (curve == NULL) {
// curve invalid, set empty pathvector
_pathvector = Geom::PathVector();
} else {
_pathvector = curve->get_pathvector();
curve->unref();
}
must_recalculate_pwd2 = true;
emit_changed();
SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
示例13:
void
PathParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*/)
{
SPCurve *curve = NULL;
if (SP_IS_SHAPE(linked_obj)) {
curve = SP_SHAPE(linked_obj)->getCurve();
}
if (SP_IS_TEXT(linked_obj)) {
curve = SP_TEXT(linked_obj)->getNormalizedBpath();
}
if (curve == NULL) {
// curve invalid, set default value
_pathvector = sp_svg_read_pathv(defvalue);
} else {
_pathvector = curve->get_pathvector();
curve->unref();
}
must_recalculate_pwd2 = true;
emit_changed();
SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
示例14: itemlist
void
sp_selected_path_break_apart(SPDesktop *desktop, bool skip_undo)
{
Inkscape::Selection *selection = desktop->getSelection();
if (selection->isEmpty()) {
desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to break apart."));
return;
}
desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Breaking apart paths..."));
// set "busy" cursor
desktop->setWaitingCursor();
bool did = false;
std::vector<SPItem*> itemlist(selection->itemList());
for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i != itemlist.end(); ++i){
SPItem *item = *i;
SPPath *path = dynamic_cast<SPPath *>(item);
if (!path) {
continue;
}
SPCurve *curve = path->get_curve_for_edit();
if (curve == NULL) {
continue;
}
did = true;
Inkscape::XML::Node *parent = item->getRepr()->parent();
gint pos = item->getRepr()->position();
char const *id = item->getRepr()->attribute("id");
// XML Tree being used directly here while it shouldn't be...
gchar *style = g_strdup(item->getRepr()->attribute("style"));
// XML Tree being used directly here while it shouldn't be...
gchar *path_effect = g_strdup(item->getRepr()->attribute("inkscape:path-effect"));
Geom::Affine transform = path->transform;
// it's going to resurrect as one of the pieces, so we delete without advertisement
item->deleteObject(false);
GSList *list = curve->split();
curve->unref();
std::vector<Inkscape::XML::Node*> reprs;
for (GSList *l = list; l != NULL; l = l->next) {
curve = (SPCurve *) l->data;
Inkscape::XML::Node *repr = parent->document()->createElement("svg:path");
repr->setAttribute("style", style);
repr->setAttribute("inkscape:path-effect", path_effect);
gchar *str = sp_svg_write_path(curve->get_pathvector());
if (path_effect)
repr->setAttribute("inkscape:original-d", str);
else
repr->setAttribute("d", str);
g_free(str);
repr->setAttribute("transform", sp_svg_transform_write(transform));
// add the new repr to the parent
parent->appendChild(repr);
// move to the saved position
repr->setPosition(pos > 0 ? pos : 0);
// if it's the first one, restore id
if (l == list)
repr->setAttribute("id", id);
reprs.push_back(repr);
Inkscape::GC::release(repr);
}
selection->setReprList(reprs);
g_slist_free(list);
g_free(style);
g_free(path_effect);
}
desktop->clearWaitingCursor();
if (did) {
if ( !skip_undo ) {
DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_BREAK_APART,
_("Break apart"));
}
} else {
desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No path(s)</b> to break apart in the selection."));
}
}
示例15: SPCurve
void
LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result)
{
if(steps < 1) {
return;
}
Geom::PathVector tmp_path;
Geom::CubicBezier const *cubic = NULL;
for (Geom::PathVector::iterator path_it = result.begin(); path_it != result.end(); ++path_it) {
if (path_it->empty()) {
continue;
}
Geom::Path::iterator curve_it1 = path_it->begin(); // incoming curve
Geom::Path::iterator curve_it2 = ++(path_it->begin());// outgoing curve
Geom::Path::iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop
SPCurve *nCurve = new SPCurve();
if (path_it->closed()) {
// if the path is closed, maybe we have to stop a bit earlier because the
// closing line segment has zerolength.
const Geom::Curve &closingline =
path_it->back_closed(); // the closing line segment is always of type
// Geom::LineSegment.
if (are_near(closingline.initialPoint(), closingline.finalPoint())) {
// closingline.isDegenerate() did not work, because it only checks for
// *exact* zero length, which goes wrong for relative coordinates and
// rounding errors...
// the closing line segment has zero-length. So stop before that one!
curve_endit = path_it->end_open();
}
}
if(helper_size > 0) {
drawNode(curve_it1->initialPoint());
}
nCurve->moveto(curve_it1->initialPoint());
Geom::Point start = Geom::Point(0,0);
while (curve_it1 != curve_endit) {
cubic = dynamic_cast<Geom::CubicBezier const *>(&*curve_it1);
Geom::Point point_at1 = curve_it1->initialPoint();
Geom::Point point_at2 = curve_it1->finalPoint();
Geom::Point point_at3 = curve_it1->finalPoint();
Geom::Point point_at4 = curve_it1->finalPoint();
if(start == Geom::Point(0,0)) {
start = point_at1;
}
if (cubic) {
point_at1 = (*cubic)[1];
point_at2 = (*cubic)[2];
}
if(path_it->closed() && curve_it2 == curve_endit) {
point_at4 = start;
}
if(curve_it2 != curve_endit) {
cubic = dynamic_cast<Geom::CubicBezier const *>(&*curve_it2);
if (cubic) {
point_at4 = (*cubic)[1];
}
}
Geom::Ray ray1(point_at2, point_at3);
Geom::Ray ray2(point_at3, point_at4);
double angle1 = Geom::deg_from_rad(ray1.angle());
double angle2 = Geom::deg_from_rad(ray2.angle());
if((smooth_angles >= std::abs(angle2 - angle1)) && !are_near(point_at4,point_at3) && !are_near(point_at2,point_at3)) {
double dist = Geom::distance(point_at2,point_at3);
Geom::Angle angleFixed = ray2.angle();
angleFixed -= Geom::Angle::from_degrees(180.0);
point_at2 = Geom::Point::polar(angleFixed, dist) + point_at3;
}
nCurve->curveto(point_at1, point_at2, curve_it1->finalPoint());
cubic = dynamic_cast<Geom::CubicBezier const *>(nCurve->last_segment());
if (cubic) {
point_at1 = (*cubic)[1];
point_at2 = (*cubic)[2];
if(helper_size > 0) {
if(!are_near((*cubic)[0],(*cubic)[1])) {
drawHandle((*cubic)[1]);
drawHandleLine((*cubic)[0],(*cubic)[1]);
}
if(!are_near((*cubic)[3],(*cubic)[2])) {
drawHandle((*cubic)[2]);
drawHandleLine((*cubic)[3],(*cubic)[2]);
}
}
}
if(helper_size > 0) {
drawNode(curve_it1->finalPoint());
}
++curve_it1;
++curve_it2;
}
if (path_it->closed()) {
nCurve->closepath_current();
}
tmp_path.push_back(nCurve->get_pathvector()[0]);
nCurve->reset();
delete nCurve;
}
//.........这里部分代码省略.........