[vtkusers] vtkScalarBarWidget significantly slows down mouse interaction

Alex Malyushytskyy alexmalvtk at gmail.com
Wed Sep 23 21:22:27 EDT 2009


Thanks for suggestions.
I was going to allow  reposition/resizing the scalar bar in the user
activated if customization mode, so I used vtkScalarBarWidget.

But usage vtkScalarBarActor without vtkScalarBarWidget does not
impruve situation.
On the one hand it helps localize problem to  vtkScalarBarActor.
On the other hand it does not solve the problem.

Neither usage AddActor2D instead of AddActor does.


The code now looks like this:

	vtkSmartPointer<vtkScalarBarActor> scalarBarActor =
vtkSmartPointer<vtkScalarBarActor>::New();
	scalarBarActor->SetTitle("Data Range");
	scalarBarActor->SetLookupTable(
compositePolyDatamapperMapper->GetLookupTable() );
	scalarBarActor->PickableOn();
	scalarBarActor->SetDragable( 1 );
	scalarBarActor->SetNumberOfLabels( 64 );
	scalarBarActor->GetPositionCoordinate(
)->SetCoordinateSystemToNormalizedViewport();
	
	scalarBarActor->GetPositionCoordinate( )->SetValue( 0.91, 0.02);
	scalarBarActor->SetNumberOfLabels( 64 );
	scalarBarActor->SetWidth( 0.08 );
	scalarBarActor->SetHeight( 0.96 );

	scalarBarActor->PickableOff();
	scalarBarActor->SetLabelFormat("%.5g");
//	scalarBarActor->SetVisibility( false );

	this->ren->AddActor2D( scalarBarActor );

I have not tried  using shallow copy of look up table yet, basically
due to some design concerns.
But I don't quite understand how it can change interactor behavior,

In the worst case I decided I can display color bar in separated window.
But I was curious is anybody else experienced such behavior.

Thanks in advance,
    Alex




On Wed, Sep 23, 2009 at 3:56 PM, da <remywendy at gmail.com> wrote:
> I don't know about the slow down that you are experiencing; however I
> notcided in your implementation with vtkScalarBarWidget you never call the
> On() method, instead adding the actor directly to the renderer.
>
>  If this is all you need (the actor), then you can just use
> vtkScalarBarActor without the associated vtkScalarBarWidget. The widget is
> for use with user interactions: repositioning or resizing the scalar bar.
>
> As for the slowing, maybe try 1) use AddActor2D. 2) deep copy (or shallow,
> whichever one was the one that doesn't copy the pipeline) your lookuptable.
> no idea if any of these would be helpful though.
>
> On Fri, Sep 18, 2009 at 1:36 PM, Alex Malyushytskyy <alexmalvtk at gmail.com>
> wrote:
>>
>> System info: VTK-5.4.2, win32, Windows 64BIT, MSVC 2005 sp2, QT 4.4.3
>>
>> I have 3D poly data based model which I need to display in color based
>> on some nodal array values.
>> Also I wanted to display vtkScalarBarWidget  to present color
>> distribution by value.
>>
>> Unfortunately I found that it significantly slows down mouse interaction.
>> It does not even depend on the size of the model.
>> Effect stays the same within range I tested - from 3 to 150k triangles.
>>
>>
>> If vtkScalarBarWidget  is not present or corresponded
>> vtkScalarBarActor set hidden with GetScalarBarActor()->SetVisibility(
>> false ), interaction is smooth. Small mouse movement correspond to
>> small model rotation.
>>
>> When visibility is set to true with
>> GetScalarBarActor()->SetVisibility( true ), there is about 1-2 sec
>> delay between mouse movement and model rotation, which leads to step
>> like model rotation.
>>
>> I don't think this is normal. In my case colormap has 64 colors and no
>> array neither colormap is changing during rotation. Rendering Scalar
>> bar should not take that much time either, especially counting that no
>> information related to it changed.
>> re- rendering 150k triangles after rotation is done faster than
>> scalarbar with 64 labels and 64 colored triangle in 2D space.
>>
>> So I assume I either use it incorrectly or there is a problem with
>> .vtkScalarBarActor or vtkScalarBarWidget.
>>
>> Am I missing something obvious?
>> Am I using it incorrectly?
>> Is there a way to fix the problem?
>> Is there an actor which  hides scalarbar when interaction begin  (like
>> LODActor for data)?
>>
>>
>> Best regards,
>>          Alex
>>
>>
>> Below there is a code related to scalarbar creation:
>>
>> /////////////////////
>>        ren = vtkSmartPointer<vtkRenderer>::New();
>>        this->GetRenderWindow()->AddRenderer( ren );
>>
>>        vtkRenderWindowInteractor * iact =
>> GetRenderWindow()->GetInteractor();
>>
>>
>> //              create a colorbar
>> #if !defined USE_NO_COLOR_BAR
>>        this->scalarBarWidget = vtkSmartPointer<vtkScalarBarWidget>::New();
>>        this->scalarBarWidget->SetInteractor( iact );
>>        this->scalarBarWidget->GetScalarBarActor()->SetTitle("Data Range");
>>        this->scalarBarWidget->GetScalarBarActor()->SetLookupTable(
>> compositePolyDatamapperMapper->GetLookupTable() );
>>        this->scalarBarWidget->GetScalarBarActor()->PickableOn();
>>        this->scalarBarWidget->GetScalarBarActor()->SetDragable( 1 );
>>        this->scalarBarWidget->SetRepositionable( 1 );
>>        this->scalarBarWidget->SetSelectable( 0 );
>>
>>        this->scalarBarWidget->GetScalarBarActor()->SetNumberOfLabels( 64
>> );
>>        this->scalarBarWidget->GetScalarBarActor()->GetPositionCoordinate(
>> )->SetCoordinateSystemToNormalizedViewport();
>>
>>        this->scalarBarWidget->GetScalarBarActor()->GetPositionCoordinate(
>> )->SetValue( 0.91, 0.02);
>>        this->scalarBarWidget->GetScalarBarActor()->SetNumberOfLabels( 64
>> );
>>        this->scalarBarWidget->GetScalarBarActor()->SetWidth( 0.08 );
>>        this->scalarBarWidget->GetScalarBarActor()->SetHeight( 0.96 );
>>
>>        this->scalarBarWidget->GetScalarBarActor()->PickableOff();
>>        this->scalarBarWidget->GetScalarBarActor()->SetLabelFormat("%.5g");
>> //      this->scalarBarWidget->GetScalarBarActor()->SetVisibility( false
>> );
>>
>>        this->ren->AddActor( this->scalarBarWidget->GetScalarBarActor() );
>> #endif
>> /////////////////////
>> _______________________________________________
>> 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