sp-offset.cpp revision 3160bbbab034cde9669d9dbe736bd834b9cb0352
2N/A#define __SP_OFFSET_C__
2N/A * Authors: (of the sp-spiral.c upon which this file was constructed):
2N/A#ifdef HAVE_CONFIG_H
2N/A#include "attributes.h"
2N/A#include "preferences.h"
2N/A#include "sp-offset.h"
2N/A#include "sp-use-reference.h"
2N/Aclass SPDocument;
2N/A#define noOFFSET_VERBOSE
2N/Astatic Inkscape::XML::Node *sp_offset_write (SPObject * object, Inkscape::XML::Document *doc, Inkscape::XML::Node * repr,
2N/Astatic void sp_offset_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs);
2N/Astatic void sp_offset_move_compensate(Geom::Matrix const *mp, SPItem *original, SPOffset *self);
2N/Astatic bool use_slow_but_correct_offset_method=false;
2N/Asp_offset_get_type (void)
2N/A if (!offset_type)
2N/A sizeof (SPOffsetClass),
2N/A (GTypeFlags) 0);
2N/A return offset_type;
2N/A offset->_changed_connection = offset->sourceRef->changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_offset_href_changed), offset));
2N/Asp_offset_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
2N/A case SP_ATTR_INKSCAPE_RADIUS:
2N/A case SP_ATTR_SODIPODI_RADIUS:
2N/A case SP_ATTR_INKSCAPE_HREF:
2N/A case SP_ATTR_XLINK_HREF:
#ifdef OFFSET_VERBOSE
if ( res_d ) {
c->unref();
if ( use_slow_but_correct_offset_method == false ) {
float o_width;
if ( bbox ) {
if (exp != 0)
delete theShape;
delete theRes;
delete res;
float o_width;
int nbPart=0;
// this way, we avoid doing a unique big ConvertToShape when dealing with big shapes with lots of holes
for (int i=0;i<nbPart;i++) {
holes[i]=0;
onePart->ConvertToShape(oneCleanPart,fill_positive); // there aren't intersections in that one, but maybe duplicate points and null edges
if ( nPartSurf >= 0 ) {
delete parts[i];
for (int j=0;j<onePart->nbAr;j++) theShape->AddEdge(firstP+onePart->aretes[j].st,firstP+onePart->aretes[j].en);*/
if ( nPartSurf >= 0 ) {
delete parts[i];
for (int j=0;j<onePart->nbAr;j++) theShape->AddEdge(firstP+onePart->aretes[j].en,firstP+onePart->aretes[j].st);*/
delete onePart;
delete oneCleanPart;
for (int i=0;i<nbPart;i++) {
if ( parts[i] ) {
if ( holes[i] ) {
delete res;
delete theShape;
delete theRes;
delete orig;
c->unref();
static void sp_offset_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs)
// the sign. for edges, it's easy to determine which side the point is on, for points of the polygon
// another method would be to use the Winding() function to test whether the point is inside or outside
ab_a = 0;
if (ab_s < 0)
bc_a = 0;
if (bc_s < 0)
ca_a = 0;
if (ca_s < 0)
bool ptSet = false;
bool arSet = false;
ptSet = true;
ptSet = true;
arSet = true;
if (arSet == false)
if (ptSet == false)
delete theShape;
delete theRes;
return dist;
delete theShape;
delete finalPath;
offset->_delete_connection = SP_OBJECT(to)->connectDelete(sigc::bind(sigc::ptr_fun(&sp_offset_delete_self), offset));
offset->_transformed_connection = SP_ITEM(to)->connectTransformed(sigc::bind(sigc::ptr_fun(&sp_offset_move_compensate), offset));
offset->_modified_connection = SP_OBJECT(to)->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_offset_source_modified), offset));
if (!(m.isTranslation())) return;
compensate = m;
advertized_move = m;
// le mauvais cas: pas d'attribut d => il faut verifier que c'est une SPShape puis prendre le contour
delete theShape;
delete theRes;
delete res;
delete orig;
SPItem *
return NULL;