Code

clean up tabs and DOS-ishness
[inkscape.git] / src / persp3d.cpp
index d6ae5bd244b5dff6fbb2820a064ae0156095b893..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.
  */
@@ -552,8 +565,8 @@ persp3d_on_repr_attr_changed ( Inkscape::XML::Node * /*repr*/,
 
 /* returns a std::set() of all perspectives of the currently selected boxes */
 std::set<Persp3D *>
-persp3d_currently_selected_persps (SPEventContext *ec) {
-    Inkscape::Selection *selection = sp_desktop_selection (ec->desktop);
+persp3d_currently_selected_persps () {
+    Inkscape::Selection *selection = sp_desktop_selection(inkscape_active_desktop());
 
     std::set<Persp3D *> p;
     for (GSList *i = (GSList *) selection->itemList(); i != NULL; i = i->next) {
@@ -632,7 +645,7 @@ persp3d_print_all_selected() {
     g_print ("\n======================================\n");
     g_print ("Selected perspectives and their boxes:\n");
 
-    std::set<Persp3D *> sel_persps = persp3d_currently_selected_persps (inkscape_active_event_context());
+    std::set<Persp3D *> sel_persps = persp3d_currently_selected_persps();
 
     for (std::set<Persp3D *>::iterator j = sel_persps.begin(); j != sel_persps.end(); ++j) {
         Persp3D *persp = SP_PERSP3D(*j);