[vtkusers] OrientationMarkerWidget giving erros in QT+VTK

Rodrigo Lovera lobo.theslayer at gmail.com
Fri Nov 30 09:01:14 EST 2012


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*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121130/8993df9c/attachment.htm>


More information about the vtkusers mailing list