[vtkusers] Resizing vtkSliderRepresentation2D

imran khan khan.imranh at gmail.com
Thu May 13 17:54:10 EDT 2010


I have an MFC application in which I have instantiated a 2D slider widget.
Everything works out fine
till I resize the window. The slider does not adjust the position in a
proportionate manner. If I then
click any mouse button down inside the window, it then adjusts its position
properly. It seems that
the mouse button event does the right thing.

I would like to put some appropriate code within the RESIZE command handler
to that the slider
size and position adjust properly when the window is resized.

My code snippet is below.

Any help would be greatly appreciated as I have trolled the user groups and
spent quite some
time trying to figure this out.

Imran

***************************************************************************************************

 sliderRep = vtkSliderRepresentation2D::New();

 sliderRep->SetRenderer(this->Renderer);

 sliderRep->GetPoint1Coordinate()->SetCoordinateSystemToNormalizedViewport();
 sliderRep->GetPoint1Coordinate()->SetValue(0.26,0.012);
 sliderRep->GetPoint2Coordinate()->SetCoordinateSystemToNormalizedViewport();
 sliderRep->GetPoint2Coordinate()->SetValue(0.95,0.012);

 sliderRep->SetSliderLength(0.015);
 sliderRep->SetSliderWidth(0.02);
 sliderRep->SetEndCapLength(0.005);;
 sliderRep->SetEndCapWidth(0.02);
 sliderRep->SetTubeWidth(0.005);
 sliderRep->SetMinimumValue(minFrameNumber);
 sliderRep->SetMaximumValue(maxFrameNumber);
 sliderRep->SetValue(uFrameNumber);
 sliderRep->GetSliderProperty()->SetColor(1,1,0);//yellow

 sliderRep->BuildRepresentation();

 sliderWidget = vtkSliderWidget::New();
 sliderWidget->SetInteractor(Interactor);
 sliderWidget->SetRepresentation(sliderRep);
 sliderWidget->SetAnimationModeToAnimate();

 vtkSlider2DCallback *callback = vtkSlider2DCallback::New();
 callback->View = this;
 sliderWidget->AddObserver(vtkCommand::InteractionEvent,callback);
 sliderWidget->EnabledOn();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100513/94ee2fda/attachment.htm>


More information about the vtkusers mailing list