diff --git a/src/box3d.cpp b/src/box3d.cpp
index 250c1f5004b132029fa93034087a84070f3a72fc..d51df9df3a1e18e3895e3d6a82c2517489317e7a 100644 (file)
--- a/src/box3d.cpp
+++ b/src/box3d.cpp
-#define __SP_BOX3D_C__
-
/*
* SVG <box3d> implementation
*
* Maximilian Albert <Anhalter42@gmx.de>
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
+ * Abhishek Sharma
*
* Copyright (C) 2007 Authors
* Copyright (C) 1999-2002 Lauris Kaplinski
box->persp_ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(box3d_ref_changed), box));
- object->readAttr( "inkscape:perspectiveID");
- object->readAttr( "inkscape:corner0");
- object->readAttr( "inkscape:corner7");
+ object->readAttr( "inkscape:perspectiveID" );
+ object->readAttr( "inkscape:corner0" );
+ object->readAttr( "inkscape:corner7" );
}
/**
box3d_position_set(box);
}
break;
- default:
+ default:
if (((SPObjectClass *) (parent_class))->set) {
((SPObjectClass *) (parent_class))->set(object, key, value);
}
@@ -290,13 +289,9 @@ static Inkscape::XML::Node * box3d_write(SPObject *object, Inkscape::XML::Docume
repr->setAttribute("inkscape:perspectiveID", uri_string);
g_free(uri_string);
} else {
- //Inkscape::XML::Node *persp_repr = SP_OBJECT_REPR(doc->getCurrentPersp3D());
- //const gchar *persp_id = persp_repr->attribute("id");
- //gchar *href = g_strdup_printf("#%s", persp_id);
- Glib::ustring href = "#";
- href += doc->getCurrentPersp3D()->getId();
+ Glib::ustring href = "#";
+ href += doc->getCurrentPersp3D()->getId();
repr->setAttribute("inkscape:perspectiveID", href.c_str());
- //g_free(href);
}
}
return g_strdup(_("<b>3D Box</b>"));
}
-void
-box3d_position_set (SPBox3D *box)
+void box3d_position_set(SPBox3D *box)
{
/* This draws the curve and calls requestDisplayUpdate() for each side (the latter is done in
box3d_side_position_set() to avoid update conflicts with the parent box) */
- for (SPObject *child = SP_OBJECT (box)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) {
- if (SP_IS_BOX3D_SIDE(child))
+ for ( SPObject *child = box->firstChild(); child; child = child->getNext() ) {
+ if (SP_IS_BOX3D_SIDE(child)) {
box3d_side_position_set(SP_BOX3D_SIDE(child));
+ }
}
}
gdouble const sw = hypot(ret[0], ret[1]);
gdouble const sh = hypot(ret[2], ret[3]);
- for (SPObject *child = box->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) {
+ for ( SPObject *child = box->firstChild(); child; child = child->getNext() ) {
if (SP_IS_ITEM(child)) {
SPItem *childitem = SP_ITEM(child);
@@ -511,16 +506,14 @@ box3d_snap (SPBox3D *box, int id, Proj::Pt3 const &pt_proj, Proj::Pt3 const &sta
return box3d_get_perspective(box)->perspective_impl->tmat.preimage (result, z_coord, Proj::Z);
}
-/*create a SPBox3D and append it to the parent*/
-
SPBox3D * SPBox3D::createBox3D(SPItem * parent)
{
- SPBox3D *box3d = 0;
- Inkscape::XML::Document *xml_doc = parent->document->rdoc;
- Inkscape::XML::Node *repr = xml_doc->createElement("svg:g");
- repr->setAttribute("sodipodi:type", "inkscape:box3d");
- box3d = (SPBox3D *)parent->appendChildRepr(repr);
- return box3d;
+ SPBox3D *box3d = 0;
+ Inkscape::XML::Document *xml_doc = parent->document->rdoc;
+ Inkscape::XML::Node *repr = xml_doc->createElement("svg:g");
+ repr->setAttribute("sodipodi:type", "inkscape:box3d");
+ box3d = reinterpret_cast<SPBox3D *>(parent->appendChildRepr(repr));
+ return box3d;
}
void
@@ -686,15 +679,15 @@ box3d_half_line_crosses_joining_line (Geom::Point const &A, Geom::Point const &B
Geom::Line lineCD(C,D);
Geom::OptCrossing inters = Geom::OptCrossing(); // empty by default
- try
- {
- inters = Geom::intersection(lineAB, lineCD);
- }
- catch (Geom::InfiniteSolutions e)
- {
- // We're probably dealing with parallel lines, so they don't really cross
- return false;
- }
+ try
+ {
+ inters = Geom::intersection(lineAB, lineCD);
+ }
+ catch (Geom::InfiniteSolutions e)
+ {
+ // We're probably dealing with parallel lines, so they don't really cross
+ return false;
+ }
if (!inters) {
return false;
return false;
}
-static std::map<int, Box3DSide *>
-box3d_get_sides (SPBox3D *box) {
+static std::map<int, Box3DSide *> box3d_get_sides(SPBox3D *box)
+{
std::map<int, Box3DSide *> sides;
- for (SPObject *side = box->first_child(); side != NULL; side = SP_OBJECT_NEXT(side)) {
-
+ for ( SPObject *side = box->firstChild(); side; side = side->getNext() ) {
if (SP_IS_BOX3D_SIDE(side)){
- Box3DSide *bside = SP_BOX3D_SIDE(side);
+ Box3DSide *bside = SP_BOX3D_SIDE(side);
sides[Box3D::face_to_int(bside->getFaceId())] = bside;
- }
+ }
}
sides.erase(-1);
return sides;
box3d_exchange_coords(box);
}
-static void
-box3d_extract_boxes_rec(SPObject *obj, std::list<SPBox3D *> &boxes) {
+static void box3d_extract_boxes_rec(SPObject *obj, std::list<SPBox3D *> &boxes) {
if (SP_IS_BOX3D(obj)) {
boxes.push_back(SP_BOX3D(obj));
} else if (SP_IS_GROUP(obj)) {
- for (SPObject *child = obj->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) {
+ for ( SPObject *child = obj->firstChild(); child; child = child->getNext() ) {
box3d_extract_boxes_rec(child, boxes);
}
}
@@ -1344,38 +1335,33 @@ box3d_switch_perspectives(SPBox3D *box, Persp3D *old_persp, Persp3D *new_persp,
persp3d_remove_box (old_persp, box);
persp3d_add_box (new_persp, box);
- //gchar *href = g_strdup_printf("#%s", SP_OBJECT_REPR(new_persp)->attribute("id"));
- Glib::ustring href = "#";
- href += new_persp->getId();
- //SP_OBJECT_REPR(box)->setAttribute("inkscape:perspectiveID", href.c_str());
- static_cast<SPObject *>(box)->setAttribute("inkscape:perspectiveID", href.c_str());
- //g_free(href);
+ Glib::ustring href = "#";
+ href += new_persp->getId();
+ box->setAttribute("inkscape:perspectiveID", href.c_str());
}
/* Converts the 3D box to an ordinary SPGroup, adds it to the XML tree at the same position as
the original box and deletes the latter */
-SPGroup *
-box3d_convert_to_group(SPBox3D *box) {
+SPGroup *box3d_convert_to_group(SPBox3D *box)
+{
SPDocument *doc = SP_OBJECT_DOCUMENT(box);
- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+ Inkscape::XML::Document *xml_doc = doc->getReprDoc();
// remember position of the box
- int pos = static_cast<SPObject *>(box)->getPosition();
+ int pos = box->getPosition();
// remember important attributes
- //Inkscape::XML::Node *repr_source = SP_OBJECT_REPR(box);
- gchar const *id = static_cast<SPObject *>(box)->getAttribute("id");
- gchar const *style = static_cast<SPObject *>(box)->getAttribute("style");
- gchar const *mask = static_cast<SPObject *>(box)->getAttribute("mask");
- gchar const *clip_path = static_cast<SPObject *>(box)->getAttribute("clip-path");
+ gchar const *id = box->getAttribute("id");
+ gchar const *style = box->getAttribute("style");
+ gchar const *mask = box->getAttribute("mask");
+ gchar const *clip_path = box->getAttribute("clip-path");
// create a new group and add the sides (converted to ordinary paths) as its children
Inkscape::XML::Node *grepr = xml_doc->createElement("svg:g");
- Inkscape::XML::Node *repr;
- for (SPObject *child = SP_OBJECT(box)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) {
+ for ( SPObject *child = box->firstChild(); child; child = child->getNext() ) {
if (SP_IS_BOX3D_SIDE(child)) {
- repr = box3d_side_convert_to_path(SP_BOX3D_SIDE(child));
+ Inkscape::XML::Node *repr = box3d_side_convert_to_path(SP_BOX3D_SIDE(child));
grepr->appendChild(repr);
} else {
g_warning("Non-side item encountered as child of a 3D box.");
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (!prefs->getBool("/tools/shapes/3dbox/convertguides", true)) {
- SP_ITEM(box)->convert_to_guides();
+ box->convert_to_guides();
return;
}