[vtkusers] Resizing vtkSliderRepresentation2D

Eric E. Monson emonson at cs.duke.edu
Thu May 27 09:41:07 EDT 2010


Well, Karthik, the point is that it does _not_ resize automatically for us. Here is a link to a screen capture (QuickTime movie) of me running TestSliderWidget2D on my OS X 10.6 machine with VTK built with Cocoa. (I haven't tried it on other platforms yet.):

http://www.cs.duke.edu/~emonson/Slider2DwidgetTest.mov

You can see that the widget is not resizing with the window until the mouse clicks in the window.

-Eric


On May 27, 2010, at 9:23 AM, Karthik Krishnan wrote:

> I'm missing the point here. The SliderWidget is (internally) composed of vtkActor2D's and *does automatically* resize to the size of the render window. ie, its length maintains a constant ratio w.r.t the render window's size along that axis.
> 
> You can ascertain this by running the test TestSliderWidget2D and resizing the render window.
> 
>   $  ./bin/WidgetsCxxTests TestSliderWidget2D -D /home/karthik/VTKData -V Baseline/Widgets/TestSliderWidget2D.png -I 
> 
> 
> If you do *not* want it to maintain a fixed ration with respect , you can use the Point1 and Point2 coordinates; or override the SliderRepresentation and add your logic to the BuildRepresentation() method.
> 
> Thanks
> --
> karthik
> 
> On Thu, May 27, 2010 at 6:35 PM, imran khan <khan.imranh at gmail.com> wrote:
> This is a better solution than mine. Although there should ideally be something more
> evident in the design to implement resizing of widget representations for adjusting to
> resize of window.
> 
> Thanks for this.
> 
> Imran
> 
> 
> 
> On Fri, May 21, 2010 at 1:34 PM, Eric E. Monson <emonson at cs.duke.edu> wrote:
> Okay, I was able to finally get this to work. Instead of calling Render on the slider widget, it updates properly if I call
> 
> sliderRep.Modified()
> 
> after I change those point coordinates and before I call Render() on the render window.
> 
> I'm not sure exactly how this can help in your situation, Imran...
> 
> -Eric
> 
> On May 21, 2010, at 1:16 PM, Eric E. Monson wrote:
> 
>> The other place where I run into trouble with this issue is when I try to change the size/placement of the widget. I make calls like this (sliderRep is an instance of vtkSliderRepresentation2D, python code):
>> 
>> sliderRep.GetPoint1Coordinate().SetCoordinateSystemToNormalizedDisplay()
>> sliderRep.GetPoint1Coordinate().SetValue(0.1 ,0.07)
>> sliderRep.GetPoint2Coordinate().SetCoordinateSystemToNormalizedDisplay()
>> sliderRep.GetPoint2Coordinate().SetValue(0.9, 0.07)
>> 
>> but even after trying the naive methods of re-rendering the widget and window:
>> 
>> sliderWidget.Render()
>> renderWindow.Render()
>> 
>> the position of the slider isn't updated until I interact with the window.
>> 
>> -Eric
>> 
>> On May 21, 2010, at 12:41 PM, imran khan wrote:
>> 
>>> Karthik:
>>> 
>>> The issue is that the widget maintains its absolute size when the window is resized. It sizes up correctly when
>>> a mouse interaction happens within the rendered area. So what my hack is doing is mimicking a middle button
>>> press which indirectly resizes the widgets correctly.
>>> 
>>> It is not clear what changing the Point1Coordinate and a Point2Coordinate in normalized coordinates would do. As
>>> I want to maintain the same normalized locations when the window resizes.
>>> 
>>> Imran
>>> 
>>> On Fri, May 21, 2010 at 12:08 PM, Karthik Krishnan <karthik.krishnan at kitware.com> wrote:
>>> I'm not sure what that code snippet does, but this is totally not the right way to resize any widget. 
>>> 
>>> The slider representation has a Point1Coordinate and a Point2Coordinate. These define the end points of the slider (in normlized coordinates [-1, 1]). These iVars just aren't exposed. Modify the code yourself (or derive from vtkSliderRepresentation2D) and expose them so as to resize the widget.
>>> 
>>> Thanks
>>> --
>>> karthik
>>> 
>>> 
>>> 
>>> 
>> 
>> _______________________________________________
>> 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
> 
> 
> 
> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100527/39e52d23/attachment.htm>


More information about the vtkusers mailing list