[vtkusers] QT/C++ problem

Jothy jothybasu at gmail.com
Fri Aug 20 11:17:27 EDT 2010


Hi all,

Here is the problematic part of the code which I wrote using QtCreator. I am
trying to render axial and sagittal. But only the first "call" is called!


Source:
void MainWindow::on_actionImport_CT_triggered()

{

     this->ReadCT();

    this->ShowAxial();

     this->ShowAxial();

}

void MainWindow::ReadCT()

{

   QString  Folder=QFileDialog::getExistingDirectory();

   std::string FolderStr;

  FolderStr=Folder.toStdString();

  mDicomReader=vtkDICOMImageReader::New();

    mDicomReader->SetDirectoryName(FolderStr.c_str());

     mDicomReader->Update();

     }

 void MainWindow::ShowAxial()

{

     mImageViewerAxial=vtkImageViewer2::New();

 mImageViewerAxial->SetInputConnection(this->mDicomReader->GetOutputPort());

  mImageViewerAxial->SetSlice(20);

 mImageViewerAxial->SetSliceOrientationToXY();

mRenderWindowInteractorAxial= vtkRenderWindowInteractor::New();

  mImageViewerAxial->SetupInteractor(mRenderWindowInteractorAxial);

  mImageViewerAxial->SetRenderWindow(ui->qvtkWidgetAxial->GetRenderWindow());

  mImageViewerAxial->Render();

  mImageViewerAxial->GetRenderer()->ResetCamera();

 mImageViewerAxial->Render();

  mRenderWindowInteractorAxial->Start();

}

 void MainWindow::ShowSagittal()

{

 mImageViewerSagittal=vtkImageViewer2::New();

 mImageViewerSagittal->SetInput(this->mDicomReader->GetOutput());

  mImageViewerSagittal->SetSlice(10);

 mImageViewerSagittal->SetSliceOrientationToXZ();

  mRenderWindowInteractorSagittal =vtkRenderWindowInteractor::New();

  mImageViewerSagittal->SetupInteractor(mRenderWindowInteractorSagittal);

  mImageViewerSagittal->SetRenderWindow(ui->qvtkWidgetAxial->GetRenderWindow());

  mImageViewerSagittal->Render();

  mImageViewerSagittal->GetRenderer()->ResetCamera();

 mImageViewerSagittal->Render();

  mRenderWindowInteractorSagittal->Start();

}



Header:
class MainWindow : public QMainWindow

{

    Q_OBJECT

public:

    explicit MainWindow(QWidget *parent = 0);

    ~MainWindow();

   void ReadCT();

    void ShowAxial();

    void ShowSagittal();

private:

    Ui::MainWindow *ui;

    vtkImageData*  mImageData;

    vtkImageViewer2* mImageViewerAxial;

    vtkImageViewer2* mImageViewerSagittal;

    vtkDICOMImageReader*  mDicomReader;

    vtkRenderWindowInteractor* mRenderWindowInteractorAxial;

   vtkRenderWindowInteractor* mRenderWindowInteractorSagittal;

private slots:

    void on_verticalScrollBar_actionTriggered(int action);

    void on_actionImport_CT_triggered();

};

Thank you

Jothy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100820/7e5963ac/attachment.htm>


More information about the vtkusers mailing list