[vtkusers] Resizing vtkSliderRepresentation2D
Karthik Krishnan
karthik.krishnan at kitware.com
Thu May 27 09:23:02 EDT 2010
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/ec09d0e3/attachment.htm>
More information about the vtkusers
mailing list