Code

clean up tabs and DOS-ishness
[inkscape.git] / src / persp3d.cpp
index 4b594d754fd9ded04022a6adbd21df4c236ba2c9..e5cade661d151f3efb1c12e6417fdc221ca529ab 100644 (file)
@@ -209,10 +209,10 @@ persp3d_create_xml_element (SPDocument *document, Persp3D *dup) {// if dup is gi
         repr = xml_doc->createElement("inkscape:perspective");
         repr->setAttribute("sodipodi:type", "inkscape:persp3d");
 
-        Proj::Pt2 proj_vp_x = Proj::Pt2 (-50.0, 600.0, 1.0);
+        Proj::Pt2 proj_vp_x = Proj::Pt2 (0.0, sp_document_height(document)/2, 1.0);
         Proj::Pt2 proj_vp_y = Proj::Pt2 (  0.0,1000.0, 0.0);
-        Proj::Pt2 proj_vp_z = Proj::Pt2 (700.0, 600.0, 1.0);
-        Proj::Pt2 proj_origin = Proj::Pt2 (300.0, 400.0, 1.0);
+        Proj::Pt2 proj_vp_z = Proj::Pt2 (sp_document_width(document), sp_document_height(document)/2, 1.0);
+        Proj::Pt2 proj_origin = Proj::Pt2 (sp_document_width(document)/2, sp_document_height(document)/3, 1.0);
 
         gchar *str = NULL;
         str = proj_vp_x.coord_string();
@@ -237,6 +237,19 @@ persp3d_create_xml_element (SPDocument *document, Persp3D *dup) {// if dup is gi
     return (Persp3D *) sp_object_get_child_by_repr (SP_OBJECT(defs), repr);
 }
 
+Persp3D *
+persp3d_document_first_persp (SPDocument *document) {
+    SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document);
+    Inkscape::XML::Node *repr;
+    for (SPObject *child = sp_object_first_child(defs); child != NULL; child = SP_OBJECT_NEXT(child) ) {
+        repr = SP_OBJECT_REPR(child);
+        if (SP_IS_PERSP3D(child)) {
+            return SP_PERSP3D(child);
+        }
+    }
+    return NULL;
+}
+
 /**
  * Virtual write: write object attributes to repr.
  */