Re: How I can use InteractionEvent in clojure?
It works!!! Thanks Aaron Cohen and Mark Rathwell. The code final that works 100% of the example cone6 of vtk in clojure is this: (ns example (:import (javax.swing JFrame JPanel SwingUtilities))) (clojure.lang.RT/loadLibrary vtkCommonJava) (clojure.lang.RT/loadLibrary vtkWidgetsJava) (def boxWidget (vtk.vtkBoxWidget.)) (def myCallback (fn [] (println Invoked!) (let [t (vtk.vtkTransform.)] (doto boxWidget (.GetTransform t) (.. GetProp3D (SetUserTransform t)) (defn main [] (let [cone (vtk.vtkConeSource.) coneMapper (vtk.vtkPolyDataMapper.) coneActor (vtk.vtkActor.) ren(vtk.vtkRenderer.) renWin (vtk.vtkRenderWindow.) iren (vtk.vtkRenderWindowInteractor.) style (vtk.vtkInteractorStyleTrackballCamera.) t (vtk.vtkTransform.)] (doto cone (.SetHeight 3.0) (.SetRadius 1.0) (.SetResolution 10)) (doto coneMapper (.SetInput (.GetOutput cone))) (doto coneActor (.SetMapper coneMapper)) (doto ren (.GradientBackgroundOn) (.SetBackground 0.5 0.6 0.8) (.AddActor coneActor) (.ResetCamera)) (doto renWin (.AddRenderer ren) (.SetSize 300 300)) (doto iren (.SetRenderWindow renWin) (.SetInteractorStyle style)) (doto boxWidget (.SetInteractor iren) (.SetPlaceFactor 1.25) (.SetProp3D coneActor) (.PlaceWidget) (.AddObserver InteractionEvent myCallback run) (.On)) (doto iren (.Initialize) (.Start (example/main) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How I can use InteractionEvent in clojure?
Unfortunately, I've been unable to get vtk to compile locally. At this point, it's seeming to me that your issue is more vtk-related than clojure, though. Can you put a println in the callback to confirm that it's at least being called? One question, is it significant that your code is slightly different from the example here? (doto coneMapper (.SetInputConnection (.GetOutputPort cone))) Although I'm not sure if it's significant, from reading the example code, it would be: (doto coneMapper (.SetInput (.GetOutput cone))) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How I can use InteractionEvent in clojure?
When I print myCallback I obtain this: (println myCallback) user = #example$myCallback example$myCallback@6e1c51b4 I have used this: (doto coneMapper (.SetInput (.GetOutput cone))) And the applications runs, with not errors in the prompt too, but the boxWidget still doesn't work. On Wednesday, March 7, 2012 9:19:38 PM UTC+1, Aaron Cohen wrote: Unfortunately, I've been unable to get vtk to compile locally. At this point, it's seeming to me that your issue is more vtk-related than clojure, though. Can you put a println in the callback to confirm that it's at least being called? One question, is it significant that your code is slightly different from the example here? (doto coneMapper (.SetInputConnection (.GetOutputPort cone))) Although I'm not sure if it's significant, from reading the example code, it would be: (doto coneMapper (.SetInput (.GetOutput cone))) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How I can use InteractionEvent in clojure?
I meant do: (def myCallback (fn [] (println Invoked!) (let [t (vtk.vtkTransform.)] (.GetTransform t) (- boxWidget .GetProp3D (.SetUserTransform t) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How I can use InteractionEvent in clojure?
It seems that callback is not called. I have added (println Testing callback) in the definition of myCallback and there is not message in the prompt when I run the application. (def myCallback (fn [] (let [t (vtk.vtkTransform.)] (.GetTransform t) (- boxWidget .GetProp3D (.SetUserTransform t)) (println Testing callback -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How I can use InteractionEvent in clojure?
On Mon, Mar 5, 2012 at 5:50 PM, Antonio Recio amdx6...@gmail.com wrote: (.AddObserver interactionEvent myCallback run) I suspect this is mis-capitalized, it need to be InteractionEvent. --Aaron -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How I can use InteractionEvent in clojure?
You are right. I have capitalized InteractionEvent and now callback it is called and it prints invoke. The application runs but the boxWidget still doesn't work, and I obtain an error message: Exception in thread main java.lang.IllegalArgumentException: No matching field found: GetTransform for class vtk.vtkTransform at clojure.lang.Reflector.getInstanceField(Reflector.java:285) at clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:314) at example$myCallback.invoke(cone.clj:15) at clojure.lang.AFn.run(AFn.java:24) at vtk.vtkRenderWindowInteractor.Start_5(Native Method) at vtk.vtkRenderWindowInteractor.Start(vtkRenderWindowInteractor.java:32) at example$main.invoke(cone.clj:54) at example$eval21.invoke(cone.clj:58) at clojure.lang.Compiler.eval(Compiler.java:6488) at clojure.lang.Compiler.load(Compiler.java:6929) at clojure.lang.Compiler.loadFile(Compiler.java:6889) at clojure.main$load_script.invoke(main.clj:283) at clojure.main$script_opt.invoke(main.clj:343) at clojure.main$main.doInvoke(main.clj:427) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.lang.Var.invoke(Var.java:415) at clojure.lang.AFn.applyToHelper(AFn.java:161) at clojure.lang.Var.applyTo(Var.java:532) at clojure.main.main(main.java:37) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How I can use InteractionEvent in clojure?
You are trying to call method GetTransform on an instance of vtk.vtkTransform, and this method does not exist (you are probably wanting to call that method on boxWidget, not t). On Thu, Mar 8, 2012 at 12:32 AM, Antonio Recio amdx6...@gmail.com wrote: You are right. I have capitalized InteractionEvent and now callback it is called and it prints invoke. The application runs but the boxWidget still doesn't work, and I obtain an error message: Exception in thread main java.lang.IllegalArgumentException: No matching field found: GetTransform for class vtk.vtkTransform at clojure.lang.Reflector.getInstanceField(Reflector.java:285) at clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:314) at example$myCallback.invoke(cone.clj:15) at clojure.lang.AFn.run(AFn.java:24) at vtk.vtkRenderWindowInteractor.Start_5(Native Method) at vtk.vtkRenderWindowInteractor.Start(vtkRenderWindowInteractor.java:32) at example$main.invoke(cone.clj:54) at example$eval21.invoke(cone.clj:58) at clojure.lang.Compiler.eval(Compiler.java:6488) at clojure.lang.Compiler.load(Compiler.java:6929) at clojure.lang.Compiler.loadFile(Compiler.java:6889) at clojure.main$load_script.invoke(main.clj:283) at clojure.main$script_opt.invoke(main.clj:343) at clojure.main$main.doInvoke(main.clj:427) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.lang.Var.invoke(Var.java:415) at clojure.lang.AFn.applyToHelper(AFn.java:161) at clojure.lang.Var.applyTo(Var.java:532) at clojure.main.main(main.java:37) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How I can use InteractionEvent in clojure?
Yes I have tried using fn and I gives me the same error : Exception in thread main java.lang.NoSuchMethodError: invoke -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How I can use InteractionEvent in clojure?
Actually, one last try before I build vtk and try it myself. The problem seems to me that vtk is looking for a method that takes no parameters and return void. invoke returns Object, let's use run instead. So try this: (def myCallback (fn [] (let [t (vtkTransform.)] (.GetTransform t) (- boxWidget .GetProp3D (.SetUserTransform t) ; AddObserver is looking for a no-args method that return void, and fns with no args qualify. For fns, run should work. (.AddObserver boxWidget interactionEvent myCallback run) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How I can use InteractionEvent in clojure?
I have tried the new code. There are not errors in the prompt, but the boxWidget still doesn't work. It seems like boxWidget and the cone are not well connected. The final code that I have after using run: (ns example (:import (javax.swing JFrame JPanel SwingUtilities))) (clojure.lang.RT/loadLibrary vtkCommonJava) (clojure.lang.RT/loadLibrary vtkWidgetsJava) (def boxWidget (vtk.vtkBoxWidget.)) (def myCallback (fn [] (let [t (vtk.vtkTransform.)] (.GetTransform t) (- boxWidget .GetProp3D (.SetUserTransform t) (defn main [] (let [cone (vtk.vtkConeSource.) coneMapper (vtk.vtkPolyDataMapper.) coneActor (vtk.vtkActor.) ren(vtk.vtkRenderer.) renWin (vtk.vtkRenderWindow.) iren (vtk.vtkRenderWindowInteractor.) style (vtk.vtkInteractorStyleTrackballCamera.) t (vtk.vtkTransform.)] (doto cone (.SetHeight 3.0) (.SetRadius 1.0) (.SetResolution 10)) (doto coneMapper (.SetInputConnection (.GetOutputPort cone))) (doto coneActor (.SetMapper coneMapper)) (doto ren (.GradientBackgroundOn) (.SetBackground 0.5 0.6 0.8) (.AddActor coneActor) (.ResetCamera)) (doto renWin (.AddRenderer ren) (.SetSize 300 300)) (doto iren (.SetRenderWindow renWin) (.SetInteractorStyle style)) (doto boxWidget (.SetInteractor iren) (.SetPlaceFactor 1.25) (.SetProp3D coneActor) (.PlaceWidget) (.AddObserver interactionEvent myCallback run) (.On)) (doto iren (.Initialize) (.Start (example/main) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How I can use InteractionEvent in clojure?
How I can use proxy to set the AddObserver? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How I can use InteractionEvent in clojure?
On Sun, Mar 4, 2012 at 10:07 AM, Antonio Recio amdx6...@gmail.com wrote: How I can use proxy to set the AddObserver? I'm not sure what you mean, sorry, but I'll take a guess. If for some reason you want to use proxy rather than fn, it's possible. Also note, there's nothing magic about using IFn here, any interface that provides a method that takes no arguments could potentially work. To me, proxy seems a little less likely to actually work than my first example. I have no idea what vtk is doing under the hood, but in all likelihood they're using reflection, and reflection tends to have some issues with proxy. (def myCallback (proxy [clojure.lang.IFn] [] (invoke [] (let [t (vtkTransform.)] (.GetTransform t) (- boxWidget .GetProp3D (.SetUserTransform t) ; AddObserver is looking for a no-args method, and fns with no args qualify. Their method is named invoke from the IFn interface (.AddObserver boxWidget interactionEvent myCallback invoke) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How I can use InteractionEvent in clojure?
I obtain this error: Exception in thread main java.lang.NoSuchMethodError: invoke -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How I can use InteractionEvent in clojure?
This example works if you have installed vtk in your system, but it is not possible to re-size the cone using the boxWidget. I have disabled the line of AddObserver because it gives an error (Exception in thread main java.lang.NoSuchMethodError: invoke). What I am doing wrong? The source of the example written in java is herehttp://www.cmake.org/Wiki/VTK/Examples/Java/Miscellaneous/Cone6 (ns example (:use [clojure reflect pprint]) (:import (javax.swing JFrame JPanel SwingUtilities))) (clojure.lang.RT/loadLibrary vtkCommonJava) (clojure.lang.RT/loadLibrary vtkWidgetsJava) (def boxWidget (vtk.vtkBoxWidget.)) (def myCallback (proxy [clojure.lang.IFn] [] (invoke [] (let [t (vtk.vtkTransform.)] (.GetTransform t) (- boxWidget .GetProp3D (.SetUserTransform t)) (defn main [] (let [cone (vtk.vtkConeSource.) coneMapper (vtk.vtkPolyDataMapper.) coneActor (vtk.vtkActor.) ren(vtk.vtkRenderer.) renWin (vtk.vtkRenderWindow.) iren (vtk.vtkRenderWindowInteractor.) style (vtk.vtkInteractorStyleTrackballCamera.) t (vtk.vtkTransform.)] (doto cone (.SetHeight 3.0) (.SetRadius 1.0) (.SetResolution 10)) (doto coneMapper (.SetInputConnection (.GetOutputPort cone))) (doto coneActor (.SetMapper coneMapper)) (doto ren (.GradientBackgroundOn) (.SetBackground 0.5 0.6 0.8) (.AddActor coneActor) (.ResetCamera)) (doto renWin (.AddRenderer ren) (.SetSize 300 300)) (doto iren (.SetRenderWindow renWin) (.SetInteractorStyle style)) (doto boxWidget (.SetInteractor iren) (.SetPlaceFactor 1.25) (.SetProp3D coneActor) (.PlaceWidget) ;; (.AddObserver interactionEvent myCallback invoke) ;; Exception in thread main java.lang.NoSuchMethodError: invoke!! (.On)) (doto iren (.Initialize) (.Start (example/main) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How I can use InteractionEvent in clojure?
If it is not possible to use AddObserver, how I can use gen-class in this example? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How I can use InteractionEvent in clojure?
On Sun, Mar 4, 2012 at 2:17 PM, Antonio Recio amdx6...@gmail.com wrote: If it is not possible to use AddObserver, how I can use gen-class in this example? Hi Antonio, I can't use vtk on my laptop at the moment and don't want to send you down any more blind alleys with anything I can't confirm to work, so I'll have to take a look tomorrow. Just to confirm, did you try it using the first thing I suggested, using fn rather than proxy? --Aaron -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How I can use InteractionEvent in clojure?
Any advice? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How I can use InteractionEvent in clojure?
On Sat, Mar 3, 2012 at 12:47 PM, Antonio Recio amdx6...@gmail.com wrote: Any advice? This is an odd library. My first shot would be to try something like: (def myCallback (fn [] (let [t (vtkTransform.)] (.GetTransform t) (- boxWidget .GetProp3D (.SetUserTransform t) ; AddObserver is looking for a no-args method, and fns with no args qualify. Their method is named invoke from the IFn interface (.AddObserver boxWidget interactionEvent myCallback invoke) If this can't be made to work, you'll have to fall back to gen-class to make something that fully matches what the example does. This library doesn't even really look like java code, so it's super-weird seeing it in clojure. Good luck! --Aaron -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
How I can use InteractionEvent in clojure?
How I can translate this InteractionEvent written for a java example to clojure? void myCallback() { vtkTransform t = new vtkTransform(); boxWidget.GetTransform(t); boxWidget.GetProp3D().SetUserTransform(t);} boxWidget.AddObserver(InteractionEvent, this, myCallback); http://www.cmake.org/Wiki/VTK/Examples/Java/Miscellaneous/Cone6 http://www.vtk.org/doc/nightly/html/classvtkBoxWidget.html -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en