当前位置: 首页>>代码示例>>C++>>正文


C++ inkscape::SVGOStringStream类代码示例

本文整理汇总了C++中inkscape::SVGOStringStream的典型用法代码示例。如果您正苦于以下问题:C++ SVGOStringStream类的具体用法?C++ SVGOStringStream怎么用?C++ SVGOStringStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SVGOStringStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: clearProgrammatically

void
RegisteredVector::on_value_changed()
{
    if (setProgrammatically()) {
        clearProgrammatically();
        return;
    }

    if (_wr->isUpdating())
        return;

    _wr->setUpdating (true);

    Geom::Point origin = _origin;
    Geom::Point vector = getValue();
    if (_polar_coords) {
        vector = Geom::Point::polar(vector[Geom::X]*M_PI/180, vector[Geom::Y]);
    }

    Inkscape::SVGOStringStream os;
    os << origin << " , " << vector;

    write_to_xml(os.str().c_str());

    _wr->setUpdating (false);
}
开发者ID:zanqi,项目名称:inkscape,代码行数:26,代码来源:registered-widget.cpp

示例2: fill

unsigned int PrintLatex::fill(Inkscape::Extension::Print * /*mod*/,
                              Geom::PathVector const &pathv, Geom::Affine const &transform, SPStyle const *style,
                              Geom::OptRect const & /*pbox*/, Geom::OptRect const & /*dbox*/, Geom::OptRect const & /*bbox*/)
{
    if (!_stream) {
        return 0; // XXX: fixme, returning -1 as unsigned.
    }

    if (style->fill.isColor()) {
        Inkscape::SVGOStringStream os;
        float rgb[3];
        float fill_opacity;

        os.setf(std::ios::fixed);

        fill_opacity=SP_SCALE24_TO_FLOAT(style->fill_opacity.value);
        sp_color_get_rgb_floatv(&style->fill.value.color, rgb);
        os << "{\n\\newrgbcolor{curcolor}{" << rgb[0] << " " << rgb[1] << " " << rgb[2] << "}\n";
        os << "\\pscustom[linestyle=none,fillstyle=solid,fillcolor=curcolor";
        if (fill_opacity!=1.0) {
            os << ",opacity="<<fill_opacity;
        }

        os << "]\n{\n";

        print_pathvector(os, pathv, transform);

        os << "}\n}\n";

        fprintf(_stream, "%s", os.str().c_str());
    }        

    return 0;
}
开发者ID:Grandrogue,项目名称:inkscape_metal,代码行数:34,代码来源:latex-pstricks.cpp

示例3: if

static Inkscape::XML::Node *
sp_textpath_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
{
    SPTextPath *textpath = SP_TEXTPATH(object);

    if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
        repr = xml_doc->createElement("svg:textPath");
    }
	
    textpath->attributes.writeTo(repr);
    if (textpath->startOffset._set) {
        if (textpath->startOffset.unit == SVGLength::PERCENT) {
	        Inkscape::SVGOStringStream os;
            os << (textpath->startOffset.computed * 100.0) << "%";
            SP_OBJECT_REPR(textpath)->setAttribute("startOffset", os.str().c_str());
        } else {
            /* FIXME: This logic looks rather undesirable if e.g. startOffset is to be
               in ems. */
            sp_repr_set_svg_double(repr, "startOffset", textpath->startOffset.computed);
        }
    }

    if ( textpath->sourcePath->sourceHref ) repr->setAttribute("xlink:href", textpath->sourcePath->sourceHref);
	
    if ( flags&SP_OBJECT_WRITE_BUILD ) {
        GSList *l = NULL;
        for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
            Inkscape::XML::Node* c_repr=NULL;
            if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) {
                c_repr = child->updateRepr(xml_doc, NULL, flags);
            } else if ( SP_IS_TEXTPATH(child) ) {
                //c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen
            } else if ( SP_IS_STRING(child) ) {
                c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str());
            }
            if ( c_repr ) l = g_slist_prepend(l, c_repr);
        }
        while ( l ) {
            repr->addChild((Inkscape::XML::Node *) l->data, NULL);
            Inkscape::GC::release((Inkscape::XML::Node *) l->data);
            l = g_slist_remove(l, l->data);
        }
    } else {
        for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
            if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) {
                child->updateRepr(flags);
            } else if ( SP_IS_TEXTPATH(child) ) {
                //c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen
            } else if ( SP_IS_STRING(child) ) {
                SP_OBJECT_REPR(child)->setContent(SP_STRING(child)->string.c_str());
            }
        }
    }
	
    if (((SPObjectClass *) textpath_parent_class)->write)
        ((SPObjectClass *) textpath_parent_class)->write(object, xml_doc, repr, flags);
	
    return repr;
}
开发者ID:wdmchaft,项目名称:DoonSketch,代码行数:59,代码来源:sp-tspan.cpp

示例4:

gchar *
ScalarParam::param_getSVGValue() const
{
    Inkscape::SVGOStringStream os;
    os << value;
    gchar * str = g_strdup(os.str().c_str());
    return str;
}
开发者ID:wdmchaft,项目名称:DoonSketch,代码行数:8,代码来源:parameter.cpp

示例5:

gchar *
PointParam::param_getSVGValue() const
{
    Inkscape::SVGOStringStream os;
    os << *dynamic_cast<Geom::Point const *>( this );
    gchar * str = g_strdup(os.str().c_str());
    return str;
}
开发者ID:hermixy,项目名称:inkscape,代码行数:8,代码来源:point.cpp

示例6: g_strdup

gchar *
TransfMat3x4::pt_to_str (Proj::Axis axis) {
    Inkscape::SVGOStringStream os;
    os << tmat[0][axis] << " : "
       << tmat[1][axis] << " : "
       << tmat[2][axis];
    return g_strdup(os.str().c_str());
}
开发者ID:step21,项目名称:inkscape-osx-packaging-native,代码行数:8,代码来源:transf_mat_3x4.cpp

示例7: sp_svg_length_write_with_units

/**
 * N.B.\ This routine will sometimes return strings with `e' notation, so is unsuitable for CSS
 * lengths (which don't allow scientific `e' notation).
 */
std::string sp_svg_length_write_with_units(SVGLength const &length)
{
    Inkscape::SVGOStringStream os;
    if (length.unit == SVGLength::PERCENT) {
        os << 100*length.value << sp_svg_length_get_css_units(length.unit);
    } else {
        os << length.value << sp_svg_length_get_css_units(length.unit);
    }
    return os.str();
}
开发者ID:wdmchaft,项目名称:DoonSketch,代码行数:14,代码来源:svg-length.cpp

示例8: g_strdup

char *Path::svg_dump_path() const
{
    Inkscape::SVGOStringStream os;

    for (int i = 0; i < int(descr_cmd.size()); i++) {
        Geom::Point const p = (i == 0) ? Geom::Point(0, 0) : PrevPoint(i - 1);
        descr_cmd[i]->dumpSVG(os, p);
    }
  
    return g_strdup (os.str().c_str());
}
开发者ID:Spin0za,项目名称:inkscape,代码行数:11,代码来源:Path.cpp

示例9: setViewBoxIfMissing

/*  If the viewBox is missing, set one 
*/
void Metafile::setViewBoxIfMissing(SPDocument *doc) {

    if (doc && !doc->getRoot()->viewBox_set) {
        bool saved = Inkscape::DocumentUndo::getUndoSensitive(doc);
        Inkscape::DocumentUndo::setUndoSensitive(doc, false);
        
        doc->ensureUpToDate();
        
        // Set document unit
        Inkscape::XML::Node *repr = sp_document_namedview(doc, 0)->getRepr();
        Inkscape::SVGOStringStream os;
        Inkscape::Util::Unit const* doc_unit = doc->getWidth().unit;
        os << doc_unit->abbr;
        repr->setAttribute("inkscape:document-units", os.str().c_str());

        // Set viewBox
        doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc_unit), doc->getHeight().value(doc_unit)));
        doc->ensureUpToDate();

        // Scale and translate objects
        double scale = Inkscape::Util::Quantity::convert(1, "px", doc_unit);
        Inkscape::UI::ShapeEditor::blockSetItem(true);
        double dh;
        if(SP_ACTIVE_DOCUMENT){ // for file menu open or import, or paste from clipboard
            dh = SP_ACTIVE_DOCUMENT->getHeight().value("px");
        }
        else { // for open via --file on command line
            dh = doc->getHeight().value("px");
        }

        // These should not affect input, but they do, so set them to a neutral state
        Inkscape::Preferences *prefs = Inkscape::Preferences::get();
        bool transform_stroke      = prefs->getBool("/options/transform/stroke", true);
        bool transform_rectcorners = prefs->getBool("/options/transform/rectcorners", true);
        bool transform_pattern     = prefs->getBool("/options/transform/pattern", true);
        bool transform_gradient    = prefs->getBool("/options/transform/gradient", true);
        prefs->setBool("/options/transform/stroke", true);
        prefs->setBool("/options/transform/rectcorners", true);
        prefs->setBool("/options/transform/pattern", true);
        prefs->setBool("/options/transform/gradient", true);
        
        doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, dh), true);
        Inkscape::UI::ShapeEditor::blockSetItem(false);

        // restore options
        prefs->setBool("/options/transform/stroke",      transform_stroke);
        prefs->setBool("/options/transform/rectcorners", transform_rectcorners);
        prefs->setBool("/options/transform/pattern",     transform_pattern);
        prefs->setBool("/options/transform/gradient",    transform_gradient);

        Inkscape::DocumentUndo::setUndoSensitive(doc, saved);
    }
}
开发者ID:AakashDabas,项目名称:inkscape,代码行数:55,代码来源:metafile-inout.cpp

示例10: stroke

unsigned int PrintLatex::stroke(Inkscape::Extension::Print * /*mod*/,
                                Geom::PathVector const &pathv, Geom::Affine const &transform, SPStyle const *style,
                                Geom::OptRect const & /*pbox*/, Geom::OptRect const & /*dbox*/, Geom::OptRect const & /*bbox*/)
{
    if (!_stream) {
        return 0; // XXX: fixme, returning -1 as unsigned.
    }

    if (style->stroke.isColor()) {
        Inkscape::SVGOStringStream os;
        float rgb[3];
        float stroke_opacity;
        Geom::Affine tr_stack = m_tr_stack.top();
        double const scale = tr_stack.descrim();
        os.setf(std::ios::fixed);

        stroke_opacity=SP_SCALE24_TO_FLOAT(style->stroke_opacity.value);
        sp_color_get_rgb_floatv(&style->stroke.value.color, rgb);
        os << "{\n\\newrgbcolor{curcolor}{" << rgb[0] << " " << rgb[1] << " " << rgb[2] << "}\n";

        os << "\\pscustom[linewidth=" << style->stroke_width.computed*scale<< ",linecolor=curcolor";
        
        if (stroke_opacity!=1.0) {
            os<<",strokeopacity="<<stroke_opacity;
        }

        if (style->stroke_dasharray_set &&
                style->stroke_dash.n_dash &&
                style->stroke_dash.dash) {
            int i;
            os << ",linestyle=dashed,dash=";
            for (i = 0; i < style->stroke_dash.n_dash; i++) {
                if ((i)) {
                    os << " ";
                }
                os << style->stroke_dash.dash[i];
            }
        }

        os <<"]\n{\n";

        print_pathvector(os, pathv, transform);

        os << "}\n}\n";

        fprintf(_stream, "%s", os.str().c_str());
    }

    return 0;
}
开发者ID:Spin0za,项目名称:inkscape,代码行数:50,代码来源:latex-pstricks.cpp

示例11: getUnitMenu

void
RegisteredUnitMenu::on_changed()
{
    if (_wr->isUpdating())
        return;

    Inkscape::SVGOStringStream os;
    os << getUnitMenu()->getUnitAbbr();

    _wr->setUpdating (true);

    write_to_xml(os.str().c_str());

    _wr->setUpdating (false);
}
开发者ID:zanqi,项目名称:inkscape,代码行数:15,代码来源:registered-widget.cpp

示例12: g_strdup

/*
 * sp_svg_write_polygon: Write points attribute for polygon tag.
 * pathv may only contain paths with only straight line segments
 * Return value: points attribute string.
 */
static gchar *sp_svg_write_polygon(Geom::PathVector const & pathv)
{
    Inkscape::SVGOStringStream os;

    for (Geom::PathVector::const_iterator pit = pathv.begin(); pit != pathv.end(); ++pit) {
        for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_default(); ++cit) {
            if ( is_straight_curve(*cit) )
            {
                os << cit->finalPoint()[0] << "," << cit->finalPoint()[1] << " ";
            } else {
                g_error("sp_svg_write_polygon: polygon path contains non-straight line segments");
            }
        }
    }

    return g_strdup(os.str().c_str());
}
开发者ID:wdmchaft,项目名称:DoonSketch,代码行数:22,代码来源:sp-polygon.cpp

示例13:

/**
 * Writes the object into the repr object, then calls the parent's write routine.
 */
static Inkscape::XML::Node *
sp_root_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
{
    SPRoot *root = SP_ROOT(object);

    if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
        repr = xml_doc->createElement("svg:svg");
    }

    if (flags & SP_OBJECT_WRITE_EXT) {
        repr->setAttribute("inkscape:version", Inkscape::version_string);
    }

    if ( !repr->attribute("version") ) {
        gchar* myversion = sp_version_to_string(root->version.svg);
        repr->setAttribute("version", myversion);
        g_free(myversion);
    }

    if (fabs(root->x.computed) > 1e-9)
        sp_repr_set_svg_double(repr, "x", root->x.computed);
    if (fabs(root->y.computed) > 1e-9)
        sp_repr_set_svg_double(repr, "y", root->y.computed);

    /* Unlike all other SPObject, here we want to preserve absolute units too (and only here,
     * according to the recommendation in http://www.w3.org/TR/SVG11/coords.html#Units).
     */
    repr->setAttribute("width", sp_svg_length_write_with_units(root->width).c_str());
    repr->setAttribute("height", sp_svg_length_write_with_units(root->height).c_str());

    if (root->viewBox_set) {
        Inkscape::SVGOStringStream os;
        os << root->viewBox.left() << " " << root->viewBox.top() << " "
           << root->viewBox.width() << " " << root->viewBox.height();
        repr->setAttribute("viewBox", os.str().c_str());
    }

    if (((SPObjectClass *) (parent_class))->write)
        ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags);

    return repr;
}
开发者ID:Spin0za,项目名称:inkscape,代码行数:45,代码来源:sp-root.cpp

示例14: getValue

void
RegisteredSuffixedInteger::on_value_changed()
{
    if (setProgrammatically) {
        setProgrammatically = false;
        return;
    }

    if (_wr->isUpdating())
        return;

    _wr->setUpdating (true);

    Inkscape::SVGOStringStream os;
    os << getValue();

    write_to_xml(os.str().c_str());

    _wr->setUpdating (false);
}
开发者ID:zanqi,项目名称:inkscape,代码行数:20,代码来源:registered-widget.cpp

示例15:

/**
 * Virtual write: write object attributes to repr.
 */
Inkscape::XML::Node* Persp3D::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {

    if ((flags & SP_OBJECT_WRITE_BUILD & SP_OBJECT_WRITE_EXT) && !repr) {
        // this is where we end up when saving as plain SVG (also in other circumstances?);
        // hence we don't set the sodipodi:type attribute
        repr = xml_doc->createElement("inkscape:perspective");
    }

    if (flags & SP_OBJECT_WRITE_EXT) {

        // Written values are in 'user units'.
        double scale_x = 1.0;
        double scale_y = 1.0;
        SPRoot *root = document->getRoot();
        if( root->viewBox_set ) {
            scale_x = root->viewBox.width() / root->width.computed;
            scale_y = root->viewBox.height() / root->height.computed;
        }
        {
            Proj::Pt2 pt = perspective_impl->tmat.column( Proj::X );
            Inkscape::SVGOStringStream os;
            os << pt[0] * scale_x  << " : " << pt[1] * scale_y << " : " << pt[2];
            repr->setAttribute("inkscape:vp_x", os.str().c_str());
        }
        {
            Proj::Pt2 pt = perspective_impl->tmat.column( Proj::Y );
            Inkscape::SVGOStringStream os;
            os << pt[0] * scale_x  << " : " << pt[1] * scale_y << " : " << pt[2];
            repr->setAttribute("inkscape:vp_y", os.str().c_str());
        }
        {
            Proj::Pt2 pt = perspective_impl->tmat.column( Proj::Z );
            Inkscape::SVGOStringStream os;
            os << pt[0] * scale_x  << " : " << pt[1] * scale_y << " : " << pt[2];
            repr->setAttribute("inkscape:vp_z", os.str().c_str());
        }
        {
            Proj::Pt2 pt = perspective_impl->tmat.column( Proj::W );
            Inkscape::SVGOStringStream os;
            os << pt[0] * scale_x  << " : " << pt[1] * scale_y << " : " << pt[2];
            repr->setAttribute("inkscape:persp3d-origin", os.str().c_str());
        }
    }

    SPObject::write(xml_doc, repr, flags);

    return repr;
}
开发者ID:AakashDabas,项目名称:inkscape,代码行数:51,代码来源:persp3d.cpp


注:本文中的inkscape::SVGOStringStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。