Skip to content
Browse files

Add object finding and removal functions.

  • Loading branch information...
1 parent d34bf7f commit b28dcf915c4cedc44a64780a3d14aa18f036eff9 @antifuchs committed Mar 27, 2009
Showing with 26 additions and 0 deletions.
  1. +26 −0 src/org/reprap/artofillusion/objects.clj
View
26 src/org/reprap/artofillusion/objects.clj
@@ -10,6 +10,12 @@
(artofillusion.object
ObjectInfo)))
+;;; Manipulating the scene itself:
+
+(defn scene
+ ([] (scene (org.reprap.artofillusion.repl/window)))
+ ([window] (.getScene window)))
+
;;; Manipulating the current selection:
(defn any-parent-selected? [object window]
@@ -92,6 +98,26 @@ parent."
(for [objspec objspecs]
(add-object (apply objspec-object-info objspec) window))))
+;;; Finding objects:
+
+(defn find-object [name window]
+ (if (isa? (class name) ObjectInfo)
+ name
+ (.getObject (scene window) name)))
+
+(defn position-of-object [name window]
+ (.indexOf (scene window) (find-object name window)))
+
+;;; Removing objects:
+
+(defn delete-object [name window]
+ (with-undo-record window
+ (let [object (find-object name window)]
+ (doseq [child (.getChildren object)]
+ (delete-object child window))
+ (.removeObject window (position-of-object object window)
+ *current-undo-record*))))
+
;;; Creating new objects:
(defn cube [x y z]

0 comments on commit b28dcf9

Please sign in to comment.
Something went wrong with that request. Please try again.