[vtkusers] OrientationMarkerWidget giving erros in QT+VTK

Alex Malyushytskyy alexmalvtk at gmail.com
Fri Nov 30 17:55:33 EST 2012


All the difference if you have QT is that you do not create interactor yourself
you let your QVTKWidget subclass to do it.

And  when you need interactor you can get a pointer to it with  QVTKWidget
GetRenderWindow()->GetInteractor()

I am not sure I can follow your code, but this probably means you had to

widget->SetInteractor(ui->mipvolume->GetRenderWindow()->GetInteractor());
instead of
widget->SetInteractor(ui->mipvolume->GetInteractor());

Also I highly recommend to make a self-sufficient test case.
This would allow people to give more valuable advices and 90% of the
time will let your answer your own cases without even asking it.

Alex

On Fri, Nov 30, 2012 at 6:01 AM, Rodrigo Lovera
<lobo.theslayer at gmail.com> wrote:
> Well I checked that example of Qt and VTK, got some others qvtkwidgets
> working fine, my last is as follows:
>
>
> vtkSmartPointer< vtkDICOMImageReader > reader =
>         vtkSmartPointer< vtkDICOMImageReader >::New();
>     reader->SetDataByteOrderToLittleEndian();
>     //reader->SetDirectoryName(argv[1]);
>     reader->SetDirectoryName("C:\\VTK5.10\\DATA\\DICOM");
>     //reader->SetDirectoryName("C:\\VTK5.10\\DATA\\TUBO");
>     //reader->SetDataSpacing(3.2, 3.2, 1.5);
>     //reader->SetDataOrigin(0.0, 0.0, 0.0);
>     reader->Update();
>
>     vtkSmartPointer< vtkImageCast > readerImageCast =
>         vtkSmartPointer< vtkImageCast >::New();
>     readerImageCast->SetInput((vtkDataObject *)reader->GetOutput());
>     readerImageCast->SetOutputScalarTypeToUnsignedChar();
>     readerImageCast->ClampOverflowOn();
>
>     vtkSmartPointer< vtkImageThreshold > thresh =
>         vtkSmartPointer< vtkImageThreshold >::New();
>     thresh->SetInputConnection(readerImageCast->GetOutputPort());
>     //thresh->SetInValue(32768);
>     thresh->SetInValue(32768);
>     thresh->ThresholdBetween(350, 500);
>
>     m_opacityFunction = vtkPiecewiseFunction::New();
>     m_colorTransferFunction = vtkColorTransferFunction::New();
>
>     vtkSmartPointer< vtkVolumeProperty > volumeProperty =
>         vtkSmartPointer <vtkVolumeProperty >::New();
>     volumeProperty->SetColor(m_colorTransferFunction);
>     volumeProperty->SetScalarOpacity(m_opacityFunction);
>     volumeProperty->ShadeOn();
>     volumeProperty->SetInterpolationTypeToLinear();
>
>     UpdateMIP();
>
>     //vtkSmartPointer< vtkVolumeRayCastCompositeFunction > compositeFunction
> =
>     //            vtkSmartPointer< vtkVolumeRayCastCompositeFunction
>>::New();
>     vtkSmartPointer< vtkFixedPointVolumeRayCastMapper > volumeMapper =
>         vtkSmartPointer< vtkFixedPointVolumeRayCastMapper >::New();
>     //vtkSmartPointer< vtkVolumeRayCastMapper > volumeMapper =
>     //    vtkSmartPointer< vtkVolumeRayCastMapper >::New();
>     //volumeMapper->SetVolumeRayCastFunction(compositeFunction);
>     //volumeMapperMIP->SetInput(readerImageCast->GetOutput());
>     volumeMapper->SetInputConnection(thresh->GetOutputPort());
>     //volumeMapper->SetInput(thresh->GetOutput());
>
>     vtkSmartPointer< vtkVolume > volume =
>         vtkSmartPointer< vtkVolume >::New();
>     volume->SetMapper(volumeMapper);
>     volume->SetProperty(volumeProperty);
>
>     volumeMapper->SetBlendModeToComposite();
>     volumeProperty->ShadeOn();
>
>     vtkSmartPointer< vtkRenderer > renderer =
>         vtkSmartPointer< vtkRenderer >::New();
>     renderer->AddVolume(volume);
>     renderer->ResetCamera();
>     renderer->SetBackground(0.1, 0.2, 0.3);
>
>     //ui->mipvolume->GetRenderWindow()->AddRenderer(renderer);
>     connect(this->ui->updateMIP, SIGNAL(clicked()), this,
> SLOT(UpdateMIP()));
>
>
>     vtkSmartPointer< vtkAxesActor > axes =
>         vtkSmartPointer< vtkAxesActor >::New();
>     vtkSmartPointer< vtkOrientationMarkerWidget > widget =
>         vtkSmartPointer< vtkOrientationMarkerWidget >::New();
>     widget->SetInteractor(ui->mipvolume->GetInteractor());
>
>     widget->SetOutlineColor(0.9300, 0.5700, 0.1300);
>     widget->SetOrientationMarker(axes);
>     //widget->SetViewport(0.0, 0.0, 0.4, 0.4);
>     widget->EnabledOn();
>     widget->SetEnabled(1);
>     widget->InteractiveOn();
>
>     //this->ui->mipvolume->GetInteractor()->Initialize();
>     //this->ui->mipvolume->GetInteractor()->Start();
>
> //this->ui->mipvolume->GetInteractor()->SetRenderWindow(this->ui->mipvolume->GetRenderWindow());
>     ui->mipvolume->GetRenderWindow()->AddRenderer(renderer);
>
> These gives me the following error when opening the .exe output
>
> Generic Warning: In C:\Users\RODRIGO LOVERA\Documents\PUCP\Tesis\VTK
> 5.10\VTK\Widgets\vtkOrientationMarkerWidget.cxx, line 532
> Set interactor and Enabled before changing       interaction.
>
> I really dont know how to solve it.
>
>
> 2012/11/26 David Doria <daviddoria at gmail.com>
>>
>> On Sun, Nov 25, 2012 at 10:49 PM, Rodrigo Lovera
>> <lobo.theslayer at gmail.com> wrote:
>>>
>>> I just added the code I linked before, I can't fully provide the code im
>>> working on cuz it's a gui and in these case it's just a function I call to
>>> the main for a qvtkwidget.
>>
>>
>> Why can you not provide minimal code for a GUI?
>>
>> The first thing I suggest you do is look at the examples (e.g.
>> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Qt/RenderWindowUIMultipleInheritance)
>> - you will see that there is no vtkRenderWindowInteractor created (and thus
>> no interactor->Start() called) because all of this is handled inside the
>> QVTKWidget.
>>
>> David
>>
>>
>
>
>
>
> --
> Rodrigo aka WarHearT
>
> _______________________________________________
> 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