[vtkusers] get the center of the vtkboxwidget
Eric E. Monson
emonson at cs.duke.edu
Tue Aug 24 09:17:16 EDT 2010
Hey Ali,
That's strange. I don't have a Java wrappers build right now, but I tried modifying the Examples/Tutorial/Step6/.../Cone6 example for both Python and Cxx and both of them give me back modified bounds as I move the box widget... They both use InteractionEvent, and if I print the bounds in the callback I see the numbers changing as I move the box...
I was going to suggest trying to add your GetPolyData and GetBounds calls to the event callback in Step6.java, but I see that doesn't exist!
So, I don't want to get too off-topic with Ali's problem, but does anyone know why there isn't a Step6.java? I don't use the Java wrappers much -- are there any special issues with the BoxWidget and Java?
Hopefully someone else can be more help,
-Eric
------------------------------------------------------
Eric E Monson
Duke Visualization Technology Group
On Aug 24, 2010, at 2:44 AM, Ali Habib wrote:
> Hi All,
>
> I want to get the center fo the vtkbox widget at the beginning of moving it and at the end of moving it
>
> I tried adding two observers one at interaction event and the second at the Endinteraction event , but unfortunatly the center result from both of thoses are the same
>
> any suggestion to solve that
>
> public static void InteractionEvent(vtk.vtkObject obj, uint eventId, Object data, IntPtr clientdata)
> {
> vtkBoxWidget widget = vtkBoxWidget.SafeDownCast(obj);
> widget.GetPlanes(planes);
> selectActor.VisibilityOn();
>
>
> vtkPolyData before = new vtkPolyData();
> widget.GetPolyData(before);
> center_Before = GetBoundsCenter(before.GetBounds());
>
> //maceActor.VisibilityOff();
> ///////////// Test writting /////////////////////////////////////////////
> //Write the file
>
> /*vtkXMLPolyDataWriter writer = new vtkXMLPolyDataWriter ();
> writer.SetInputConnection(clipper.GetOutputPort());
> writer.SetFileName("disk.vtp");
> writer.Write();*/
>
>
> }
> public static void EndInteractionEvent(vtk.vtkObject obj, uint eventId, Object data, IntPtr clientdata)
> {
> vtkBoxWidget widget = vtkBoxWidget.SafeDownCast(obj);
> vtkPolyData after = new vtkPolyData();
> widget.GetPolyData(after);
> center_After = GetBoundsCenter(after.GetBounds());
>
> ModifyData();
>
>
> }
>
> private static double[] GetBoundsCenter(double[] bounds)
> {
> double[] center = new double[3];
>
> center[0] = (bounds[0] + bounds[1]) / 2.0;
> center[1] = (bounds[2] + bounds[3]) / 2.0;
> center[2] = (bounds[4] + bounds[5]) / 2.0;
>
> return center;
> }
>
> Best regards
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list