From: tbaudier Date: Fri, 4 Dec 2015 13:51:20 +0000 (+0100) Subject: Merge branch 'VTK6_Qt5' into VTK6_Qt5_Crop X-Git-Tag: v1.4.0~90 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=9768b4757920c85042b8fd9710f3ddfc2e9bf5d4;hp=8fa0e2864d3d1737a48c7a90c482be82110cb158;p=clitk.git Merge branch 'VTK6_Qt5' into VTK6_Qt5_Crop --- diff --git a/common/clitkDicomRTStruct2ImageFilter.cxx b/common/clitkDicomRTStruct2ImageFilter.cxx index 20a4b70..eb54bdc 100644 --- a/common/clitkDicomRTStruct2ImageFilter.cxx +++ b/common/clitkDicomRTStruct2ImageFilter.cxx @@ -31,7 +31,6 @@ #include #include #include -#include //-------------------------------------------------------------------- diff --git a/itk/clitkMeshToBinaryImageFilter.txx b/itk/clitkMeshToBinaryImageFilter.txx index b67cca0..3c3ccdb 100644 --- a/itk/clitkMeshToBinaryImageFilter.txx +++ b/itk/clitkMeshToBinaryImageFilter.txx @@ -140,7 +140,7 @@ GenerateData() #if VTK_MAJOR_VERSION <= 5 sts->SetInput(extrude->GetOutput()); #else - sts->SetInputData(extrude->GetOutput()); + sts->SetInputConnection(extrude->GetOutputPort()); #endif // When extrude ScaleFactor indicate the extrusion scaling (default = 1) diff --git a/vv/CMakeLists.txt b/vv/CMakeLists.txt index 11c3b1f..5b84991 100644 --- a/vv/CMakeLists.txt +++ b/vv/CMakeLists.txt @@ -22,6 +22,7 @@ set(vv_TOOLS vvToolROIManager vvToolSegmentation ## these ones are for tests (not working) + # vvToolTest # vvToolFoo # vvToolFooWithWidgetBase # vvToolPlastimatch diff --git a/vv/qt_ui/vvToolTest.ui b/vv/qt_ui/vvToolTest.ui new file mode 100644 index 0000000..01279b5 --- /dev/null +++ b/vv/qt_ui/vvToolTest.ui @@ -0,0 +1,28 @@ + + + vvToolTest + + + + 0 + 0 + 433 + 222 + + + + Test sphere + + + + + + Qt::Horizontal + + + + + + + + diff --git a/vv/vvAnimatedGIFWriter.cxx b/vv/vvAnimatedGIFWriter.cxx index 5dbf51a..0ab7cb8 100644 --- a/vv/vvAnimatedGIFWriter.cxx +++ b/vv/vvAnimatedGIFWriter.cxx @@ -74,7 +74,7 @@ void vvAnimatedGIFWriter::End() #if VTK_MAJOR_VERSION <= 5 quant->SetInput(RGBvolume->GetOutput()); #else - quant->SetInputData(RGBvolume->GetOutput()); + quant->SetInputConnection(RGBvolume->GetOutputPort()); #endif quant->Update(); @@ -83,7 +83,7 @@ void vvAnimatedGIFWriter::End() #if VTK_MAJOR_VERSION <= 5 cast->SetInput( quant->GetOutput() ); #else - cast->SetInputData( quant->GetOutput() ); + cast->SetInputConnection( quant->GetOutputPort() ); #endif cast->SetOutputScalarTypeToUnsignedChar(); cast->Update(); diff --git a/vv/vvBinaryImageOverlayActor.cxx b/vv/vvBinaryImageOverlayActor.cxx index dc95320..1af316d 100644 --- a/vv/vvBinaryImageOverlayActor.cxx +++ b/vv/vvBinaryImageOverlayActor.cxx @@ -31,10 +31,11 @@ #include #include #include +#include //------------------------------------------------------------------------------ vvBinaryImageOverlayActor::vvBinaryImageOverlayActor() -{ +{ //out << __func__ << endl; mTSlice = -1; mSlice = 0; mColor.resize(3); @@ -52,7 +53,7 @@ vvBinaryImageOverlayActor::vvBinaryImageOverlayActor() //------------------------------------------------------------------------------ vvBinaryImageOverlayActor::~vvBinaryImageOverlayActor() -{ +{ //out << __func__ << endl; mImageActorList.clear(); } //------------------------------------------------------------------------------ @@ -60,7 +61,7 @@ vvBinaryImageOverlayActor::~vvBinaryImageOverlayActor() //------------------------------------------------------------------------------ void vvBinaryImageOverlayActor::RemoveActors() -{ +{ //out << __func__ << endl; for (unsigned int i = 0; i < mImageActorList.size(); i++) { if (mSlicer != 0) { if (mSlicer != NULL) { @@ -78,7 +79,7 @@ void vvBinaryImageOverlayActor::RemoveActors() //------------------------------------------------------------------------------ void vvBinaryImageOverlayActor::SetColor(double r, double g, double b) -{ +{ //out << __func__ << endl; mColor[0] = r; mColor[1] = g; mColor[2] = b; @@ -88,7 +89,7 @@ void vvBinaryImageOverlayActor::SetColor(double r, double g, double b) //------------------------------------------------------------------------------ void vvBinaryImageOverlayActor::SetSlicer(vvSlicer * slicer) -{ +{ //out << __func__ << endl; mSlicer = slicer; } //------------------------------------------------------------------------------ @@ -96,7 +97,7 @@ void vvBinaryImageOverlayActor::SetSlicer(vvSlicer * slicer) //------------------------------------------------------------------------------ void vvBinaryImageOverlayActor::Initialize(bool IsVisible) -{ +{ //out << __func__ << endl; if (!mSlicer) { std::cerr << "ERROR. Please use setSlicer before setSlicer in vvBinaryImageOverlayActor." << std::endl; exit(0); @@ -143,7 +144,7 @@ void vvBinaryImageOverlayActor::Initialize(bool IsVisible) #if VTK_MAJOR_VERSION <= 5 mOverlayActor->SetInput(mOverlayMapper->GetOutput()); #else - mOverlayActor->SetInputData(mOverlayMapper->GetOutput()); + mOverlayActor->GetMapper()->SetInputConnection(mOverlayMapper->GetOutputPort()); #endif mOverlayActor->SetPickable(0); mOverlayActor->SetVisibility(IsVisible); @@ -163,7 +164,7 @@ void vvBinaryImageOverlayActor::Initialize(bool IsVisible) //------------------------------------------------------------------------------ void vvBinaryImageOverlayActor::SetOpacity(double d) -{ +{ //out << __func__ << endl; mAlpha = d; } //------------------------------------------------------------------------------ @@ -205,7 +206,7 @@ void vvBinaryImageOverlayActor::SetOpacity(double d) //------------------------------------------------------------------------------ void vvBinaryImageOverlayActor::SetImage(vvImage::Pointer image, double bg, bool modeBG) -{ +{ //out << __func__ << endl; mImage = image; if (modeBG) { mBackgroundValue = bg; @@ -221,7 +222,7 @@ void vvBinaryImageOverlayActor::SetImage(vvImage::Pointer image, double bg, bool //------------------------------------------------------------------------------ void vvBinaryImageOverlayActor::HideActors() -{ +{ //out << __func__ << endl; if (!mSlicer) return; mSlice = mSlicer->GetSlice(); for(unsigned int i=0; iGetSlice(); mTSlice = mSlicer->GetTSlice(); @@ -251,7 +252,7 @@ void vvBinaryImageOverlayActor::ShowActors() //------------------------------------------------------------------------------ void vvBinaryImageOverlayActor::UpdateColor() -{ +{ //out << __func__ << endl; mColorLUT->SetTableValue(1, mColor[0], mColor[1], mColor[2], mAlpha); // FG for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) { // how many intensity ? @@ -270,7 +271,7 @@ void vvBinaryImageOverlayActor::UpdateColor() //------------------------------------------------------------------------------ void vvBinaryImageOverlayActor::UpdateSlice(int slicer, int slice, bool force) -{ +{ //out << __func__ << endl; if (!mSlicer) return; if (!force) { @@ -310,7 +311,7 @@ void vvBinaryImageOverlayActor::ComputeExtent(int orientation, int slice, int * inExtent, int * outExtent) -{ +{ //out << __func__ << endl; switch (orientation) { case vtkImageViewer2::SLICE_ORIENTATION_XY: for(int i=0; i<4; i++) outExtent[i] = inExtent[i]; @@ -332,7 +333,7 @@ void vvBinaryImageOverlayActor::ComputeExtent(int orientation, //---------------------------------------------------------------------------- void vvBinaryImageOverlayActor::ComputeExtent(int * inExtent, int * outExtent, vtkImageData * image, vtkImageData * overlay) -{ +{ //out << __func__ << endl; for(int i=0; i<3; i++) { double a = (image->GetOrigin()[i] + inExtent[i*2]*image->GetSpacing()[i] - overlay->GetOrigin()[i]) / overlay->GetSpacing()[i]; @@ -360,7 +361,7 @@ void vvBinaryImageOverlayActor::SetDisplayExtentAndCameraPosition(int orientatio int * extent, vtkImageActor * actor, double position) -{ +{ //out << __func__ << endl; /* FIXME Error according to camera orientation */ diff --git a/vv/vvImageContour.cxx b/vv/vvImageContour.cxx index 8fb22ae..e391bbb 100644 --- a/vv/vvImageContour.cxx +++ b/vv/vvImageContour.cxx @@ -27,10 +27,11 @@ #include #include #include +#include //------------------------------------------------------------------------------ vvImageContour::vvImageContour() -{ +{ //out << __func__ << endl; mTSlice = -1; mSlice = 0; mHiddenImageIsUsed = false; @@ -45,7 +46,7 @@ vvImageContour::vvImageContour() //------------------------------------------------------------------------------ vvImageContour::~vvImageContour() -{ +{ //out << __func__ << endl; mSquaresActorList.clear(); } //------------------------------------------------------------------------------ @@ -53,7 +54,7 @@ vvImageContour::~vvImageContour() //------------------------------------------------------------------------------ void vvImageContour::RemoveActors() -{ +{ //out << __func__ << endl; for (unsigned int i = 0; i < mSquaresActorList.size(); i++) { if (mSlicer != 0) { if (mSlicer!= NULL) { @@ -70,7 +71,8 @@ void vvImageContour::RemoveActors() //------------------------------------------------------------------------------ -void vvImageContour::SetSlicer(vvSlicer * slicer) { +void vvImageContour::SetSlicer(vvSlicer * slicer) +{ //out << __func__ << endl; mSlicer = slicer; // Create an actor for each time slice for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) { @@ -81,7 +83,8 @@ void vvImageContour::SetSlicer(vvSlicer * slicer) { //------------------------------------------------------------------------------ -void vvImageContour::SetImage(vvImage::Pointer image) { +void vvImageContour::SetImage(vvImage::Pointer image) +{ //out << __func__ << endl; for (unsigned int numImage = 0; numImage < image->GetVTKImages().size(); numImage++) { #if VTK_MAJOR_VERSION <= 5 mClipperList[numImage]->SetInput(image->GetVTKImages()[numImage]); @@ -96,7 +99,8 @@ void vvImageContour::SetImage(vvImage::Pointer image) { //------------------------------------------------------------------------------ -void vvImageContour::SetPreserveMemoryModeEnabled(bool b) { +void vvImageContour::SetPreserveMemoryModeEnabled(bool b) +{ //out << __func__ << endl; // FastCache mode work only if threshold is always the same if (mDisplayModeIsPreserveMemory == b) return; mDisplayModeIsPreserveMemory = b; @@ -116,9 +120,11 @@ void vvImageContour::SetPreserveMemoryModeEnabled(bool b) { //------------------------------------------------------------------------------ -void vvImageContour::SetColor(double r, double g, double b) { +void vvImageContour::SetColor(double r, double g, double b) +{ //out << __func__ << endl; for(unsigned int i=0; iGetProperty()->SetColor(r,g,b); + mSquaresActorList[i]->GetProperty()->SetOpacity(0.995); } } //------------------------------------------------------------------------------ @@ -126,7 +132,7 @@ void vvImageContour::SetColor(double r, double g, double b) { //------------------------------------------------------------------------------ void vvImageContour::SetLineWidth(double w) -{ +{ //out << __func__ << endl; for(unsigned int i=0; iGetProperty()->SetLineWidth(w); } @@ -135,7 +141,8 @@ void vvImageContour::SetLineWidth(double w) //------------------------------------------------------------------------------ -void vvImageContour::HideActors() { +void vvImageContour::HideActors() +{ //out << __func__ << endl; if (!mSlicer) return; mSlice = mSlicer->GetSlice(); for(unsigned int i=0; iGetSlice(); mTSlice = mSlicer->GetTSlice(); @@ -158,7 +166,7 @@ void vvImageContour::ShowActors() { //------------------------------------------------------------------------------ void vvImageContour::SetDepth(double d) -{ +{ //out << __func__ << endl; mDepth = d; // Move the actor to be visible double position[3] = {0, 0, 0}; @@ -171,7 +179,8 @@ void vvImageContour::SetDepth(double d) //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvImageContour::Update(double value) { +void vvImageContour::Update(double value) +{ //out << __func__ << endl; if (!mSlicer) return; if (mPreviousValue == value) { if (mPreviousSlice == mSlicer->GetSlice()) { @@ -207,7 +216,8 @@ void vvImageContour::Update(double value) { //------------------------------------------------------------------------------ -void vvImageContour::UpdateWithPreserveMemoryMode() { +void vvImageContour::UpdateWithPreserveMemoryMode() +{ //out << __func__ << endl; // Only change actor visibility if tslice change mPreviousTslice = mTSlice; mTSlice = mSlicer->GetTSlice(); @@ -223,14 +233,15 @@ void vvImageContour::UpdateWithPreserveMemoryMode() { if (mPreviousTslice != mTSlice) { if (mPreviousTslice != -1) mSquaresActorList[mPreviousTslice]->VisibilityOff(); } - + mSlicer->Render(); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvImageContour::InitializeCacheMode() { +void vvImageContour::InitializeCacheMode() +{ //out << __func__ << endl; clitkExceptionMacro("TODO : not implemented yet"); mPreviousSlice = mPreviousOrientation = 0; int dim = mSlicer->GetImage()->GetNumberOfDimensions(); @@ -248,7 +259,8 @@ clitkExceptionMacro("TODO : not implemented yet"); //------------------------------------------------------------------------------ -int vvImageContour::ComputeCurrentOrientation() { +int vvImageContour::ComputeCurrentOrientation() +{ //out << __func__ << endl; // Get extent of image in the slicer int* extent = mSlicer->GetImageActor()->GetDisplayExtent(); @@ -266,7 +278,8 @@ int vvImageContour::ComputeCurrentOrientation() { //------------------------------------------------------------------------------ -void vvImageContour::UpdateWithFastCacheMode() { +void vvImageContour::UpdateWithFastCacheMode() +{ //out << __func__ << endl; clitkExceptionMacro("TODO : not implemented yet"); // Compute orientation @@ -294,7 +307,8 @@ clitkExceptionMacro("TODO : not implemented yet"); //------------------------------------------------------------------------------ -void vvImageContour::CreateNewActor(int numImage) { +void vvImageContour::CreateNewActor(int numImage) +{ //out << __func__ << endl; vtkSmartPointer squaresActor = vtkSmartPointer::New(); vtkSmartPointer clipper = vtkSmartPointer::New(); vtkSmartPointer squares = vtkSmartPointer::New(); @@ -313,17 +327,17 @@ void vvImageContour::CreateNewActor(int numImage) { clipper->SetInputData(mSlicer->GetImage()->GetVTKImages()[numImage]); #endif } - #if VTK_MAJOR_VERSION <= 5 squares->SetInput(clipper->GetOutput()); squaresMapper->SetInput(squares->GetOutput()); #else - squares->SetInputData(clipper->GetOutput()); - squaresMapper->SetInputData(squares->GetOutput()); + squares->SetInputConnection(clipper->GetOutputPort(0)); + squaresMapper->SetInputConnection(squares->GetOutputPort(0)); #endif squaresMapper->ScalarVisibilityOff(); squaresActor->SetMapper(squaresMapper); squaresActor->GetProperty()->SetColor(1.0,0,0); + squaresActor->GetProperty()->SetOpacity(0.995); squaresActor->SetPickable(0); squaresActor->VisibilityOff(); mSlicer->GetRenderer()->AddActor(squaresActor); @@ -341,10 +355,11 @@ void vvImageContour::UpdateActor(vtkActor * actor, vtkPolyDataMapper * mapper, vtkMarchingSquares * squares, vtkImageClip * clipper, - double threshold, int orientation, int slice) { + double threshold, int orientation, int slice) +{ //out << __func__ << endl; // Set parameter for the MarchigSquare squares->SetValue(0, threshold); - + squares->Update(); // Get image extent int* extent = mSlicer->GetImageActor()->GetDisplayExtent(); @@ -381,10 +396,10 @@ void vvImageContour::UpdateActor(vtkActor * actor, extent2 = extent; actor->VisibilityOn(); } - + clipper->SetOutputWholeExtent(extent2[0],extent2[1],extent2[2], extent2[3],extent2[4],extent2[5]); - + if (mHiddenImageIsUsed) delete extent2; // Move the actor to be visible @@ -393,7 +408,6 @@ void vvImageContour::UpdateActor(vtkActor * actor, // DD(mDepth); // position[orientation] = -mDepth; // actor->SetPosition(position); - mapper->Update(); } //------------------------------------------------------------------------------ diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 590f3dd..9ee7f8c 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -3271,7 +3271,7 @@ void vvMainWindow::SaveScreenshotAllSlices() #if VTK_MAJOR_VERSION <= 5 writer->SetInput(windowToImageFilter->GetOutput()); #else - writer->SetInputData(windowToImageFilter->GetOutput()); + writer->SetInputConnection(windowToImageFilter->GetOutputPort()); #endif writer->Write(); } @@ -3329,7 +3329,7 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) #if VTK_MAJOR_VERSION <= 5 imgwriter->SetInput(image); #else - imgwriter->SetInputData(image); + imgwriter->SetInputConnection(w2i->GetOutputPort()); #endif imgwriter->SetFileName(fileName.toStdString().c_str()); imgwriter->Write(); @@ -3403,7 +3403,7 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) #if VTK_MAJOR_VERSION <= 5 vidwriter->SetInput(image); #else - vidwriter->SetInputData(image); + vidwriter->SetInputConnection(w2i->GetOutputPort()); #endif vidwriter->SetFileName(fileName.toStdString().c_str()); vidwriter->Start(); @@ -3416,7 +3416,7 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) #if VTK_MAJOR_VERSION <= 5 vidwriter->SetInput(w2i->GetOutput()); #else - vidwriter->SetInputData(w2i->GetOutput()); + vidwriter->SetInputConnection(w2i->GetOutputPort()); #endif vidwriter->Write(); } @@ -3514,6 +3514,7 @@ void vvMainWindow::ShowLastImage() QTreeWidgetItem * item=DataTree->topLevelItem(DataTree->topLevelItemCount()-1); CurrentImageChanged(mSlicerManagers.back()->GetId()); //select new image item->setData(1,Qt::CheckStateRole,2); //show the new image in the first panel + //mSlicerManagers[GetSlicerIndexFromItem(item)]->GetSlicer(0)->SetActorVisibility("image", 0, 1); //Set the Last Image visibles DisplayChanged(item,1); } } @@ -3653,13 +3654,13 @@ vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filen connect(mSlicerManagers.back(), SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint())); + + InitSlicers(); UpdateTree(); qApp->processEvents(); - InitSlicers(); - ShowLastImage(); InitDisplay(); + ShowLastImage(); qApp->processEvents(); - // End ImageInfoChanged(); return slicer_manager; diff --git a/vv/vvMesh.cxx b/vv/vvMesh.cxx index fd4faa8..e7045f5 100644 --- a/vv/vvMesh.cxx +++ b/vv/vvMesh.cxx @@ -191,7 +191,7 @@ void vvMesh::ComputeMasks(vtkImageData* sample,bool extrude) #if VTK_MAJOR_VERSION <= 5 sts->SetInput(extrude->GetOutput()); #else - sts->SetInputData(extrude->GetOutput()); + sts->SetInputConnection(extrude->GetOutputPort()); #endif } else { #if VTK_MAJOR_VERSION <= 5 diff --git a/vv/vvMeshActor.cxx b/vv/vvMeshActor.cxx index 04ea49d..d8741aa 100644 --- a/vv/vvMeshActor.cxx +++ b/vv/vvMeshActor.cxx @@ -66,7 +66,7 @@ void vvMeshActor::Init(vvMesh::Pointer mesh,int time_slice,vvImage::Pointer vf) #if VTK_MAJOR_VERSION <= 5 mMapper->SetInput(mMarching->GetOutput()); #else - mMapper->SetInputData(mMarching->GetOutput()); + mMapper->SetInputConnection(mMarching->GetOutputPort()); #endif //The following line allows to display the contour over the image //(http://www.nabble.com/What-happens-when-two-actors-are-at-the-same-depth--td23175458.html) diff --git a/vv/vvROIActor.cxx b/vv/vvROIActor.cxx index 74d5883..26f13f4 100644 --- a/vv/vvROIActor.cxx +++ b/vv/vvROIActor.cxx @@ -32,7 +32,7 @@ //------------------------------------------------------------------------------ vvROIActor::vvROIActor() -{ +{ //out << __func__ << endl; mIsVisible = true; mIsContourVisible = false; mOpacity = 0.5; @@ -52,14 +52,14 @@ vvROIActor::vvROIActor() //------------------------------------------------------------------------------ vvROIActor::~vvROIActor() -{ +{ //out << __func__ << endl; } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void vvROIActor::RemoveActors() -{ +{ //out << __func__ << endl; for(unsigned int i= 0; iRemoveActors(); } @@ -77,21 +77,23 @@ void vvROIActor::RemoveActors() //------------------------------------------------------------------------------ void vvROIActor::SetROI(clitk::DicomRT_ROI * s) -{ +{ //out << __func__ << endl; mROI = s; } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvROIActor::SetContourWidth(int n) { +void vvROIActor::SetContourWidth(int n) +{ //out << __func__ << endl; mContourWidth = n; } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvROIActor::SetSlicerManager(vvSlicerManager * s) { +void vvROIActor::SetSlicerManager(vvSlicerManager * s) +{ //out << __func__ << endl; mSlicerManager = s; } //------------------------------------------------------------------------------ @@ -99,7 +101,7 @@ void vvROIActor::SetSlicerManager(vvSlicerManager * s) { //------------------------------------------------------------------------------ void vvROIActor::UpdateImage() -{ +{ //out << __func__ << endl; mOverlayActors.clear(); mImageContour.clear(); Initialize(mDepth, mIsVisible); @@ -110,7 +112,7 @@ void vvROIActor::UpdateImage() //------------------------------------------------------------------------------ void vvROIActor::SetVisible(bool b) -{ +{ //out << __func__ << endl; mIsVisible = b; if (!b) { // remove actor for(unsigned int i= 0; iGetImage()) { mImageContour.clear(); mOverlayActors.clear(); @@ -174,7 +180,7 @@ void vvROIActor::Initialize(double depth, bool IsVisible) { mImageContour[i]->SetLineWidth(mContourWidth); mImageContour[i]->SetPreserveMemoryModeEnabled(true); mImageContour[i]->SetDepth(mDepth+0.5); - mImageContour[i]->HideActors(); + mImageContour[i]->ShowActors(); mOverlayActors.push_back(vvBinaryImageOverlayActor::New()); @@ -195,7 +201,6 @@ void vvROIActor::Initialize(double depth, bool IsVisible) { mOverlayActors[i]->Initialize(IsVisible); mOverlayActors[i]->SetDepth(mDepth); } - connect(mSlicerManager,SIGNAL(UpdateSlice(int,int)),this,SLOT(UpdateSlice(int, int))); //connect(mSlicerManager,SIGNAL(UpdateTSlice(int,int)),this,SLOT(UpdateSlice(int, int))); connect(mSlicerManager, SIGNAL(AVerticalSliderHasChanged(int, int)), SLOT(UpdateSlice(int, int))); @@ -206,7 +211,7 @@ void vvROIActor::Initialize(double depth, bool IsVisible) { //------------------------------------------------------------------------------ void vvROIActor::SetDepth(double d) -{ +{ //out << __func__ << endl; mDepth = d; if (!mSlicerManager) return; for(int i=0; iGetNumberOfSlicers(); i++) { @@ -220,7 +225,7 @@ void vvROIActor::SetDepth(double d) //------------------------------------------------------------------------------ void vvROIActor::Update(bool force) -{ +{ //out << __func__ << endl; if (!mSlicerManager) return; for(int i=0; iGetNumberOfSlicers(); i++) { UpdateSlice(i, mSlicerManager->GetSlicer(i)->GetSlice(), force); @@ -231,7 +236,7 @@ void vvROIActor::Update(bool force) //------------------------------------------------------------------------------ void vvROIActor::UpdateSlice(int slicer, int slices, bool force) -{ +{ //out << __func__ << endl; if (!mROI->GetImage()) return; if ((!mIsVisible) && (!mIsContourVisible)) return; if (!mSlicerManager) { @@ -251,14 +256,15 @@ void vvROIActor::UpdateSlice(int slicer, int slices, bool force) //------------------------------------------------------------------------------ void vvROIActor::SetOpacity(double d) -{ +{ //out << __func__ << endl; mOpacity = d; } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvROIActor::SetContourColor(double r, double v, double b) { +void vvROIActor::SetContourColor(double r, double v, double b) +{ //out << __func__ << endl; mContourColor[0] = r; mContourColor[1] = v; mContourColor[2] = b; @@ -267,7 +273,8 @@ void vvROIActor::SetContourColor(double r, double v, double b) { //------------------------------------------------------------------------------ -void vvROIActor::SetOverlayColor(double r, double v, double b) { +void vvROIActor::SetOverlayColor(double r, double v, double b) +{ //out << __func__ << endl; if (mROI) mROI->SetDisplayColor(r,v,b); } @@ -275,21 +282,24 @@ void vvROIActor::SetOverlayColor(double r, double v, double b) { //------------------------------------------------------------------------------ -std::vector & vvROIActor::GetContourColor() { +std::vector & vvROIActor::GetContourColor() +{ //out << __func__ << endl; return mContourColor; } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -std::vector & vvROIActor::GetOverlayColor() { +std::vector & vvROIActor::GetOverlayColor() +{ //out << __func__ << endl; return mROI->GetDisplayColor(); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvROIActor::UpdateColor() { +void vvROIActor::UpdateColor() +{ //out << __func__ << endl; for(unsigned int i=0; iSetOpacity(mOpacity); mOverlayActors[i]->SetColor(mROI->GetDisplayColor()[0], @@ -309,7 +319,7 @@ void vvROIActor::UpdateColor() { //------------------------------------------------------------------------------ double vvROIActor::GetOpacity() -{ +{ //out << __func__ << endl; return mOpacity; } //------------------------------------------------------------------------------ @@ -317,7 +327,7 @@ double vvROIActor::GetOpacity() //------------------------------------------------------------------------------ void vvROIActor::SetSelected(bool b) -{ +{ //out << __func__ << endl; mIsSelected = b; if (b) { for(int i=0; iGetNumberOfSlicers(); i++) { @@ -335,7 +345,7 @@ void vvROIActor::SetSelected(bool b) //------------------------------------------------------------------------------ void vvROIActor::CopyParameters(QSharedPointer roi) -{ +{ //out << __func__ << endl; // Overlay SetVisible(roi->IsVisible()); SetOpacity(roi->GetOpacity()); diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 4acddce..0237ccf 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -128,7 +128,7 @@ vvSlicer::vvSlicer() #if VTK_MAJOR_VERSION <= 5 pdm->SetInput(crossCursor->GetOutput()); #else - pdm->SetInputData(crossCursor->GetOutput()); + pdm->SetInputConnection(crossCursor->GetOutputPort(0)); #endif pdmA = vtkSmartPointer::New(); @@ -422,7 +422,6 @@ void vvSlicer::SetOverlay(vvImage::Pointer overlay) #else mOverlayReslice->SetInputData(0, mOverlay->GetFirstVTKImageData()); #endif - mImageReslice->UpdateInformation(); mOverlayReslice->Update(); if (!mOverlayMapper) @@ -430,7 +429,7 @@ void vvSlicer::SetOverlay(vvImage::Pointer overlay) #if VTK_MAJOR_VERSION <= 5 mOverlayMapper->SetInput(mOverlayReslice->GetOutput()); #else - mOverlayMapper->SetInputData(mOverlayReslice->GetOutput()); + mOverlayMapper->SetInputConnection(mOverlayReslice->GetOutputPort(0)); #endif if (!mOverlayActor) { @@ -503,7 +502,7 @@ void vvSlicer::SetFusion(vvImage::Pointer fusion, int fusionSequenceCode) #if VTK_MAJOR_VERSION <= 5 mFusionMapper->SetInput(mFusionReslice->GetOutput()); #else - mFusionMapper->SetInputData(mFusionReslice->GetOutput()); + mFusionMapper->SetInputConnection(mFusionReslice->GetOutputPort(0)); #endif if (!mFusionActor) { @@ -840,7 +839,6 @@ void vvSlicer::SetTSlice(int t, bool updateLinkedImages) #else mOverlayReslice->SetInputData( mOverlay->GetVTKImages()[mCurrentOverlayTSlice] ); #endif - // Update overlay transform mConcatenatedOverlayTransform->Identity(); mConcatenatedOverlayTransform->Concatenate(mOverlay->GetTransform()[mCurrentOverlayTSlice]); @@ -1096,9 +1094,8 @@ void vvSlicer::UpdateDisplayExtent() // Image actor this->ImageActor->SetVisibility(mImageVisibility); -#if VTK_MAJOR_VERSION <= 5 this->ImageActor->SetDisplayExtent(w_ext); -#else +#if VTK_MAJOR_VERSION >= 6 vtkSmartPointer mapperOpenGL= vtkSmartPointer::New(); try { @@ -1110,7 +1107,6 @@ void vvSlicer::UpdateDisplayExtent() } if (mFirstSetSliceOrientation) { copyExtent(ext, mRegisterExtent); - this->ImageActor->SetDisplayExtent(w_ext); //initialisation } else { int w_croppingRegion[6]; if (mUseReducedExtent) { @@ -1121,7 +1117,7 @@ void vvSlicer::UpdateDisplayExtent() this->ImageActor->SetDisplayExtent(w_ext); w_croppingRegion[ this->SliceOrientation*2 ] = this->Slice; w_croppingRegion[ this->SliceOrientation*2+1 ] = this->Slice; - mapperOpenGL->SetCroppingRegion(w_croppingRegion); + mapperOpenGL->SetCroppingRegion(w_croppingRegion); } #endif @@ -1138,7 +1134,7 @@ void vvSlicer::UpdateDisplayExtent() #if VTK_MAJOR_VERSION <= 5 bool out = ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetWholeExtent()); #else - bool out = ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetInformation()->Get(vtkDataObject::DATA_EXTENT())); + bool out = ClipDisplayedExtent(overExtent, mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())); #endif mOverlayActor->SetVisibility(!out); mOverlayActor->SetDisplayExtent( overExtent ); @@ -1158,7 +1154,7 @@ void vvSlicer::UpdateDisplayExtent() #if VTK_MAJOR_VERSION <= 5 bool out = ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent()); #else - bool out = ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetInformation()->Get(vtkDataObject::DATA_EXTENT())); + bool out = ClipDisplayedExtent(fusExtent, mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())); #endif mFusionActor->SetVisibility(!out); mFusionActor->SetDisplayExtent( fusExtent ); @@ -1554,7 +1550,7 @@ void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max, vtkImag #if VTK_MAJOR_VERSION <= 5 accFilter->SetInput(voiFilter->GetOutput()); #else - accFilter->SetInputData(voiFilter->GetOutput()); + accFilter->SetInputConnection(voiFilter->GetOutputPort(0)); #endif accFilter->Update(); @@ -1598,6 +1594,7 @@ double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, double X, doubl //---------------------------------------------------------------------------- void vvSlicer::Render() { //out << __func__ << endl; + if (this->mFusion && mFusionActor->GetVisibility() && showFusionLegend) { legend->SetLookupTable(this->GetFusionMapper()->GetLookupTable()); legend->UseOpacityOn(); @@ -1754,7 +1751,7 @@ void vvSlicer::Render() if (mLandMapper) UpdateLandmarks(); - this->GetRenderWindow()->Render(); + this->GetRenderWindow()->Render(); } //---------------------------------------------------------------------------- diff --git a/vv/vvSurfaceViewerDialog.cxx b/vv/vvSurfaceViewerDialog.cxx index f50cb09..e8a6acb 100644 --- a/vv/vvSurfaceViewerDialog.cxx +++ b/vv/vvSurfaceViewerDialog.cxx @@ -114,7 +114,7 @@ void vvSurfaceViewerDialog::LoadSurface() #if VTK_MAJOR_VERSION <= 5 mMapper->SetInput(mReaders[mCurrentTime]->GetOutput()); #else - mMapper->SetInputData(mReaders[mCurrentTime]->GetOutput()); + mMapper->SetInputConnection(mReaders[mCurrentTime]->GetOutputPort()); #endif if (!mActor) { @@ -147,7 +147,7 @@ void vvSurfaceViewerDialog::NextTime() #if VTK_MAJOR_VERSION <= 5 mMapper->SetInput(mReaders[mCurrentTime]->GetOutput()); #else - mMapper->SetInputData(mReaders[mCurrentTime]->GetOutput()); + mMapper->SetInputConnection(mReaders[mCurrentTime]->GetOutputPort()); #endif mMapper->Modified(); renderWidget->GetRenderWindow()->Render(); @@ -161,7 +161,7 @@ void vvSurfaceViewerDialog::PreviousTime() #if VTK_MAJOR_VERSION <= 5 mMapper->SetInput(mReaders[mCurrentTime]->GetOutput()); #else - mMapper->SetInputData(mReaders[mCurrentTime]->GetOutput()); + mMapper->SetInputConnection(mReaders[mCurrentTime]->GetOutputPort()); #endif mMapper->Modified(); renderWidget->GetRenderWindow()->Render(); diff --git a/vv/vvToolBinarize.cxx b/vv/vvToolBinarize.cxx index 9859d01..2e693d1 100644 --- a/vv/vvToolBinarize.cxx +++ b/vv/vvToolBinarize.cxx @@ -31,6 +31,7 @@ #include #include + //------------------------------------------------------------------------------ // Create the tool and automagically (I like this word) insert it in // the main window menu. @@ -40,7 +41,7 @@ ADD_TOOL(vvToolBinarize); //------------------------------------------------------------------------------ void vvToolBinarize::Initialize() -{ +{ //out << __func__ << endl; SetToolName("Binarize"); SetToolMenuName("Binarize"); SetToolIconFilename(":/common/icons/binarize.png"); @@ -54,7 +55,7 @@ vvToolBinarize::vvToolBinarize(vvMainWindowBase * parent, Qt::WindowFlags f) :vvToolWidgetBase(parent,f), vvToolBase(parent), Ui::vvToolBinarize() -{ +{ //out << __func__ << endl; // GUI Initialization Ui_vvToolBinarize::setupUi(mToolWidget); mInteractiveDisplayIsEnabled = mCheckBoxInteractiveDisplay->isChecked(); @@ -82,14 +83,14 @@ vvToolBinarize::vvToolBinarize(vvMainWindowBase * parent, Qt::WindowFlags f) //------------------------------------------------------------------------------ vvToolBinarize::~vvToolBinarize() -{ +{ //out << __func__ << endl; } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void vvToolBinarize::InteractiveDisplayToggled(bool b) -{ +{ //out << __func__ << endl; mInteractiveDisplayIsEnabled = b; if (!mInteractiveDisplayIsEnabled) { RemoveVTKObjects(); @@ -108,7 +109,7 @@ void vvToolBinarize::InteractiveDisplayToggled(bool b) //------------------------------------------------------------------------------ void vvToolBinarize::RemoveVTKObjects() -{ +{ //out << __func__ << endl; for(unsigned int i=0; iHideActors(); mImageContourLower[i]->HideActors(); @@ -121,7 +122,7 @@ void vvToolBinarize::RemoveVTKObjects() //------------------------------------------------------------------------------ bool vvToolBinarize::close() -{ +{ //out << __func__ << endl; // RemoveVTKObjects(); return vvToolWidgetBase::close(); } @@ -129,7 +130,8 @@ bool vvToolBinarize::close() //------------------------------------------------------------------------------ -void vvToolBinarize::closeEvent(QCloseEvent *event) { +void vvToolBinarize::closeEvent(QCloseEvent *event) +{ //out << __func__ << endl; RemoveVTKObjects(); event->accept(); } @@ -138,7 +140,7 @@ void vvToolBinarize::closeEvent(QCloseEvent *event) { //------------------------------------------------------------------------------ void vvToolBinarize::reject() -{ +{ //out << __func__ << endl; // DD("vvToolBinarize::reject"); RemoveVTKObjects(); return vvToolWidgetBase::reject(); @@ -148,7 +150,7 @@ void vvToolBinarize::reject() //------------------------------------------------------------------------------ void vvToolBinarize::enableLowerThan(bool b) -{ +{ //out << __func__ << endl; if (!b) { mThresholdSlider1->resetMaximum(); for(unsigned int i=0; iisChecked() && !mCheckBoxUseFG->isChecked()) mCheckBoxUseBG->toggle(); } @@ -182,7 +184,7 @@ void vvToolBinarize::useFGBGtoggled(bool) // DD(m.size()); // } void vvToolBinarize::InputIsSelected(vvSlicerManager * m) -{ +{ //out << __func__ << endl; mCurrentSlicerManager = m; // Specific for this gui @@ -214,7 +216,7 @@ void vvToolBinarize::InputIsSelected(vvSlicerManager * m) mImageContour.push_back(vvImageContour::New()); mImageContour[i]->SetSlicer(mCurrentSlicerManager->GetSlicer(i)); mImageContour[i]->SetColor(1.0, 0.0, 0.0); - mImageContour[i]->SetDepth(100); // to be in front of (whe used with ROI tool) + mImageContour[i]->SetDepth(0); // to be in front of (whe used with ROI tool) mImageContourLower.push_back(vvImageContour::New()); mImageContourLower[i]->SetSlicer(mCurrentSlicerManager->GetSlicer(i)); mImageContourLower[i]->SetColor(0.0, 0.0, 1.0); @@ -231,7 +233,6 @@ void vvToolBinarize::InputIsSelected(vvSlicerManager * m) connect(mCurrentSlicerManager,SIGNAL(UpdateOrientation(int,int)),this,SLOT(UpdateOrientation(int, int))); // connect(mCurrentSlicerManager, SIGNAL(LeftButtonReleaseSignal(int)), SLOT(LeftButtonReleaseEvent(int))); - InteractiveDisplayToggled(mInteractiveDisplayIsEnabled); } //------------------------------------------------------------------------------ @@ -250,21 +251,21 @@ void vvToolBinarize::InputIsSelected(vvSlicerManager * m) //------------------------------------------------------------------------------ void vvToolBinarize::UpdateOrientation(int slicer,int orientation) -{ +{ //out << __func__ << endl; Update(slicer); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void vvToolBinarize::UpdateSlice(int slicer,int slices) -{ +{ //out << __func__ << endl; Update(slicer); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void vvToolBinarize::Update(int slicer) -{ +{ //out << __func__ << endl; if (!mInteractiveDisplayIsEnabled) return; if (!mCurrentSlicerManager) close(); mImageContour[slicer]->Update(mThresholdSlider1->GetValue()); @@ -275,7 +276,7 @@ void vvToolBinarize::Update(int slicer) //------------------------------------------------------------------------------ void vvToolBinarize::GetArgsInfoFromGUI() -{ +{ //out << __func__ << endl; /* //KEEP THIS FOR READING GGO FROM FILE int argc=1; @@ -330,11 +331,11 @@ void vvToolBinarize::GetArgsInfoFromGUI() //------------------------------------------------------------------------------ void vvToolBinarize::apply() -{ +{ //out << __func__ << endl; if (!mCurrentSlicerManager) close(); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - GetArgsInfoFromGUI(); - + GetArgsInfoFromGUI(); + // Main filter clitk::BinarizeImageGenericFilter::Pointer filter = clitk::BinarizeImageGenericFilter::New(); @@ -342,8 +343,9 @@ void vvToolBinarize::apply() filter->SetArgsInfo(mArgsInfo); filter->Update(); + // Output - vvImage::Pointer output = filter->GetOutputVVImage(); + vvImage::Pointer output = filter->GetOutputVVImage(); std::ostringstream osstream; osstream << "Binarized_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd"; AddImage(output,osstream.str()); @@ -355,7 +357,7 @@ void vvToolBinarize::apply() //------------------------------------------------------------------------------ void vvToolBinarize::valueChangedT2(double v) -{ +{ //out << __func__ << endl; // DD("valueChangedT2"); if (mRadioButtonLowerThan->isChecked()) { mThresholdSlider1->SetMaximum(v); @@ -371,7 +373,7 @@ void vvToolBinarize::valueChangedT2(double v) //------------------------------------------------------------------------------ void vvToolBinarize::valueChangedT1(double v) -{ +{ //out << __func__ << endl; // DD("valueChangedT1"); if (!mCurrentSlicerManager) close(); mThresholdSlider2->SetMinimum(v); diff --git a/vv/vvToolROIManager.cxx b/vv/vvToolROIManager.cxx index c86b4b2..ef83846 100644 --- a/vv/vvToolROIManager.cxx +++ b/vv/vvToolROIManager.cxx @@ -22,7 +22,6 @@ #include "vvImageWriter.h" #include "vvROIActor.h" #include "vvSlicer.h" -#include "vvROIActor.h" #include "vvMeshReader.h" #include "vvStructSelector.h" #include "vvToolManager.h" @@ -54,7 +53,7 @@ vvToolROIManager::vvToolROIManager(vvMainWindowBase * parent, Qt::WindowFlags f) QWidget(parent->GetTab()), vvToolBase(parent), Ui::vvToolROIManager() -{ +{ //out << __func__ << endl; // Store parent mMainWindow = parent; @@ -94,7 +93,7 @@ vvToolROIManager::vvToolROIManager(vvMainWindowBase * parent, Qt::WindowFlags f) //------------------------------------------------------------------------------ vvToolROIManager::~vvToolROIManager() -{ +{ //out << __func__ << endl; mROIActorsList.clear(); } //------------------------------------------------------------------------------ @@ -102,7 +101,8 @@ vvToolROIManager::~vvToolROIManager() //------------------------------------------------------------------------------ // STATIC -void vvToolROIManager::Initialize() { +void vvToolROIManager::Initialize() +{ //out << __func__ << endl; SetToolName("ROIManager"); SetToolMenuName("Open ROI (binary image or RT-STRUCT)"); SetToolIconFilename(":/common/icons/tool-roi.png"); @@ -115,7 +115,7 @@ void vvToolROIManager::Initialize() { //------------------------------------------------------------------------------ void vvToolROIManager::InitializeNewTool(bool ReadStateFlag) -{ +{ //out << __func__ << endl; // Check if we need to start a new tool or read in the state file to load if (ReadStateFlag == false) { // Select the current image as the target @@ -221,7 +221,7 @@ void vvToolROIManager::InitializeNewTool(bool ReadStateFlag) //------------------------------------------------------------------------------ void vvToolROIManager::InputIsSelected(vvSlicerManager *m) -{ +{ //out << __func__ << endl; // Initialization mCurrentSlicerManager = m; mCurrentImage = mCurrentSlicerManager->GetImage(); @@ -244,7 +244,7 @@ void vvToolROIManager::InputIsSelected(vvSlicerManager *m) //------------------------------------------------------------------------------ void vvToolROIManager::AnImageIsBeingClosed(vvSlicerManager * m) -{ +{ //out << __func__ << endl; if (m == mCurrentSlicerManager) { close(); return; @@ -255,7 +255,7 @@ void vvToolROIManager::AnImageIsBeingClosed(vvSlicerManager * m) //------------------------------------------------------------------------------ void vvToolROIManager::close() -{ +{ //out << __func__ << endl; disconnect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree())); disconnect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool))); disconnect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int))); @@ -280,8 +280,8 @@ void vvToolROIManager::close() //------------------------------------------------------------------------------ -void vvToolROIManager::SelectedImageHasChanged(vvSlicerManager * m) { - +void vvToolROIManager::SelectedImageHasChanged(vvSlicerManager * m) +{ //out << __func__ << endl; if (mCurrentSlicerManager == NULL) return; if (m == NULL) return; if (m != mCurrentSlicerManager) hide(); @@ -294,7 +294,7 @@ void vvToolROIManager::SelectedImageHasChanged(vvSlicerManager * m) { //------------------------------------------------------------------------------ void vvToolROIManager::Open() -{ +{ //out << __func__ << endl; // Open images QString Extensions = "Images or Dicom-Struct files ( *.mha *.mhd *.hdr *.his *.dcm RS*)"; Extensions += ";;All Files (*)"; @@ -315,7 +315,7 @@ void vvToolROIManager::Open() //------------------------------------------------------------------------------ void vvToolROIManager::OpenBinaryImage(QStringList & filename) -{ +{ //out << __func__ << endl; if (filename.size() == 0) return; vvProgressDialog p("Reading ROI ...", true); @@ -359,7 +359,7 @@ void vvToolROIManager::OpenBinaryImage(QStringList & filename) //------------------------------------------------------------------------------ void vvToolROIManager::OpenDicomImage(std::string filename) -{ +{ //out << __func__ << endl; // GUI selector of roi vvMeshReader reader; reader.SetFilename(filename); @@ -411,7 +411,7 @@ void vvToolROIManager::AddImage(vvImage * binaryImage, std::string name, std::string filename, double BG, bool modeBG) -{ +{ //out << __func__ << endl; // Check Dimension int dim = mCurrentImage->GetNumberOfDimensions(); int bin_dim = binaryImage->GetNumberOfDimensions(); @@ -467,7 +467,8 @@ void vvToolROIManager::AddImage(vvImage * binaryImage, // CheckBox for "All" if (actor->IsVisible()) mNumberOfVisibleROI++; if (actor->IsContourVisible()) mNumberOfVisibleContourROI++; - + AllVisibleContourROIToggled(true); + // Add ROI in tree mTreeWidgetList.push_back(QSharedPointer(new QTreeWidgetItem(mTree))); QTreeWidgetItem * w = mTreeWidgetList.back().data(); @@ -492,7 +493,7 @@ void vvToolROIManager::AddImage(vvImage * binaryImage, //------------------------------------------------------------------------------ void vvToolROIManager::UpdateAllContours() -{ +{ //out << __func__ << endl; if (mCurrentSlicerManager == NULL) return; // Render loaded ROIs (the first is sufficient) for(unsigned int i=0; i l = mTree->selectedItems(); if (l.size() == 0) { @@ -610,7 +613,8 @@ void vvToolROIManager::SelectedItemChangedInTree() { //------------------------------------------------------------------------------ -void vvToolROIManager::VisibleROIToggled(bool b) { +void vvToolROIManager::VisibleROIToggled(bool b) +{ //out << __func__ << endl; if (mCurrentROIActor == NULL) return; if (b == mCurrentROIActor->IsVisible()) return; // nothing to do mCurrentROIActor->SetVisible(b); @@ -621,7 +625,8 @@ void vvToolROIManager::VisibleROIToggled(bool b) { //------------------------------------------------------------------------------ -void vvToolROIManager::VisibleContourROIToggled(bool b) { +void vvToolROIManager::VisibleContourROIToggled(bool b) +{ //out << __func__ << endl; if (mCurrentROIActor == NULL) return; if (mCurrentROIActor->IsContourVisible() == b) return; // nothing to do mCurrentROIActor->SetContourVisible(b); @@ -632,7 +637,8 @@ void vvToolROIManager::VisibleContourROIToggled(bool b) { //------------------------------------------------------------------------------ -void vvToolROIManager::OpacityChanged(int v) { +void vvToolROIManager::OpacityChanged(int v) +{ //out << __func__ << endl; if (mCurrentROIActor == NULL) return; mCurrentROIActor->SetOpacity((double)v/100.0); mCurrentROIActor->UpdateColor(); @@ -642,7 +648,8 @@ void vvToolROIManager::OpacityChanged(int v) { //------------------------------------------------------------------------------ -void vvToolROIManager::AllVisibleROIToggled(int b) { +void vvToolROIManager::AllVisibleROIToggled(int b) +{ //out << __func__ << endl; bool status = false; if ((mCheckBoxShowAll->checkState() == Qt::Checked) || (mCheckBoxShowAll->checkState() == Qt::PartiallyChecked)) status = true; @@ -659,7 +666,8 @@ void vvToolROIManager::AllVisibleROIToggled(int b) { //------------------------------------------------------------------------------ -void vvToolROIManager::AllVisibleContourROIToggled(bool b) { +void vvToolROIManager::AllVisibleContourROIToggled(bool b) +{ //out << __func__ << endl; bool status = false; if ((mContourCheckBoxShowAll->checkState() == Qt::Checked) || (mContourCheckBoxShowAll->checkState() == Qt::PartiallyChecked)) status = true; @@ -677,7 +685,8 @@ void vvToolROIManager::AllVisibleContourROIToggled(bool b) { //------------------------------------------------------------------------------ -void vvToolROIManager::ChangeColor() { +void vvToolROIManager::ChangeColor() +{ //out << __func__ << endl; if (mCurrentROIActor == NULL) return; QColor color; color.setRgbF(mCurrentROIActor->GetROI()->GetDisplayColor()[0], @@ -702,7 +711,8 @@ void vvToolROIManager::ChangeColor() { //------------------------------------------------------------------------------ -void vvToolROIManager::ChangeContourColor() { +void vvToolROIManager::ChangeContourColor() +{ //out << __func__ << endl; if (mCurrentROIActor == NULL) return; QColor color; color.setRgbF(mCurrentROIActor->GetContourColor()[0], @@ -719,7 +729,8 @@ void vvToolROIManager::ChangeContourColor() { //------------------------------------------------------------------------------ -void vvToolROIManager::ChangeContourWidth(int n) { +void vvToolROIManager::ChangeContourWidth(int n) +{ //out << __func__ << endl; if (mCurrentROIActor == NULL) return; mCurrentROIActor->SetContourWidth(n); mCurrentROIActor->UpdateColor(); @@ -729,7 +740,8 @@ void vvToolROIManager::ChangeContourWidth(int n) { //------------------------------------------------------------------------------ -void vvToolROIManager::ChangeDepth(int n) { +void vvToolROIManager::ChangeDepth(int n) +{ //out << __func__ << endl; if (mCurrentROIActor == NULL) return; mCurrentROIActor->SetDepth(n); // mCurrentROIActor->UpdateImage(); // FIXME @@ -742,7 +754,8 @@ void vvToolROIManager::ChangeDepth(int n) { //------------------------------------------------------------------------------ -void vvToolROIManager::ReloadCurrentROI() { +void vvToolROIManager::ReloadCurrentROI() +{ //out << __func__ << endl; if (mCurrentROI->GetFilename() == "") { return; // do nothing (contour from rt struct do not reload) } @@ -783,7 +796,7 @@ void vvToolROIManager::ReloadCurrentROI() { //------------------------------------------------------------------------------ void vvToolROIManager::SaveState(std::auto_ptr & m_XmlWriter) -{ +{ //out << __func__ << endl; // Get index of the image int n = mMainWindow->GetSlicerManagers().size(); int index=-1; @@ -829,7 +842,7 @@ void vvToolROIManager::SaveState(std::auto_ptr & m_XmlWriter) //------------------------------------------------------------------------------ void vvToolROIManager::ReadXMLInformation() -{ +{ //out << __func__ << endl; std::string value=""; mInitialImageIndex = -1; while (!(m_XmlReader->isEndElement() && value == GetToolName().toStdString())) { @@ -851,7 +864,7 @@ void vvToolROIManager::ReadXMLInformation() //------------------------------------------------------------------------------ void vvToolROIManager::ReadXMLInformation_ROI() -{ +{ //out << __func__ << endl; QString s; std::string value=""; QSharedPointer param = QSharedPointer(new vvROIActor); diff --git a/vv/vvToolTest.cxx b/vv/vvToolTest.cxx new file mode 100644 index 0000000..e583ac4 --- /dev/null +++ b/vv/vvToolTest.cxx @@ -0,0 +1,306 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + ===========================================================================**/ + +// vv +#include "vvToolTest.h" +#include "vvSlicerManager.h" +#include "vvSlicer.h" +#include "vvToolInputSelectorWidget.h" + +// clitk +#include "clitkBinarizeImageGenericFilter.h" + +// vtk +#include +#include +#include +#include +#include +#include +#include +#include + + +//------------------------------------------------------------------------------ +// Create the tool and automagically (I like this word) insert it in +// the main window menu. +ADD_TOOL(vvToolTest); +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolTest::Initialize() +{ cout << __func__ << endl; + SetToolName("Test"); + SetToolMenuName("Test"); + SetToolIconFilename(":/common/icons/binarize.png"); + SetToolTip("try to display a sphere."); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +vvToolTest::vvToolTest(vvMainWindowBase * parent, Qt::WindowFlags f) + :vvToolWidgetBase(parent,f), + vvToolBase(parent), + Ui::vvToolTest() +{ cout << __func__ << endl; + // GUI Initialization + + // Connect signals & slots + + // Main filter + mFilter = clitk::BinarizeImageGenericFilter::New(); + + // Set how many inputs are needed for this tool + AddInputSelector("Select one image", mFilter); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +vvToolTest::~vvToolTest() +{ cout << __func__ << endl; +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +/* +void vvToolTest::InteractiveDisplayToggled(bool b) +{ cout << __func__ << endl; + mInteractiveDisplayIsEnabled = b; + if (!mInteractiveDisplayIsEnabled) { + RemoveVTKObjects(); + } else { + for(unsigned int i=0; iShowActors(); + if (mRadioButtonLowerThan->isChecked()) + mImageContourLower[i]->ShowActors(); + } + if (mCurrentSlicerManager) + mCurrentSlicerManager->Render(); + } +} +*/ +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +bool vvToolTest::close() +{ cout << __func__ << endl; + return vvToolWidgetBase::close(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolTest::reject() +{ cout << __func__ << endl; + // DD("vvToolBinarize::reject"); + return vvToolWidgetBase::reject(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ + +void vvToolTest::InputIsSelected(vvSlicerManager * m) +{ cout << __func__ << endl; + mCurrentSlicerManager = m; + + + vtkSmartPointer sphereSource = + vtkSmartPointer::New(); + sphereSource->SetCenter(0, 0, 0); + //sphereSource->SetCenter(235.351, 175.781, 141.0); + sphereSource->SetRadius(10.0); + sphereSource->Update(); + vtkSmartPointer sphereMapper = + vtkSmartPointer::New(); + sphereMapper->SetInputConnection(sphereSource->GetOutputPort()); + vtkSmartPointer sphereActor = + vtkSmartPointer::New(); + sphereActor->SetMapper(sphereMapper); + sphereActor->GetProperty()->SetColor(1.0, 0.0, 0.0); + sphereActor->GetProperty()->SetOpacity(0.995); + sphereActor->SetPosition(235.351, 175.781, -10); + + + // VTK Renderer + vtkSmartPointer sphereRenderer = + vtkSmartPointer::New(); + // Add Actor to renderer + for(int i=0;iGetNumberOfSlicers(); i++) { + mCurrentSlicerManager->GetSlicer(i)->GetRenderer()->AddActor(sphereActor); + } + //sphereRenderer->AddActor(sphereActor); //mettre le vvSlicer + + // VTK/Qt wedded + //this->qvtkWidgetLeft->GetRenderWindow()->AddRenderer(leftRenderer); + + + + + + // VTK objects for interactive display + valueChangedT1(); + + //connect(mThresholdSlider1, SIGNAL(valueChanged(double)), this, SLOT(valueChangedT1())); + + connect(mCurrentSlicerManager,SIGNAL(UpdateSlice(int,int)),this,SLOT(UpdateSlice(int, int))); + connect(mCurrentSlicerManager,SIGNAL(UpdateTSlice(int,int)),this,SLOT(UpdateSlice(int, int))); + + connect(mCurrentSlicerManager,SIGNAL(UpdateOrientation(int,int)),this,SLOT(UpdateSlice(int, int))); + + // connect(mCurrentSlicerManager, SIGNAL(LeftButtonReleaseSignal(int)), SLOT(LeftButtonReleaseEvent(int))); + //InteractiveDisplayToggled(mInteractiveDisplayIsEnabled); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +// void vvToolBinarize::LeftButtonReleaseEvent(int slicer) { +// DD("LeftButtonReleaseEvent"); +// for(int i=0; iGetNumberOfSlicers(); i++) { +// if (i == slicer); +// mCurrentSlicerManager->GetSlicer(i)->GetRenderWindow()->Render(); +// } +// } +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolTest::apply() +{ cout << __func__ << endl; + if (!mCurrentSlicerManager) close(); + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + //GetArgsInfoFromGUI(); + + // Main filter + + + + // Output + QApplication::restoreOverrideCursor(); + close(); +} +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +void vvToolTest::UpdateSlice(int slicer,int slices) +{ cout << __func__ << endl; + Update(slicer); +} +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +void vvToolTest::Update(int slicer) +{ cout << __func__ << endl; + if (!mCurrentSlicerManager) close(); + mCurrentSlicerManager->Render(); + //mImageContour[slicer]->Update(mThresholdSlider1->GetValue()); +} +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/* void vvToolTest::GetArgsInfoFromGUI() +{ cout << __func__ << endl; + + /* //KEEP THIS FOR READING GGO FROM FILE + int argc=1; + std::string a = "toto"; + char * const* argv = new char*; + //a.c_str(); + struct cmdline_parser_params p; + p.check_required = 0; + int good = cmdline_parser_ext(argc, argv, &args_info, &p); + DD(good); + */ +/* cmdline_parser_clitkBinarizeImage_init(&mArgsInfo); // Initialisation to default + bool inverseBGandFG = false; + + mArgsInfo.lower_given = 1; + mArgsInfo.lower_arg = mThresholdSlider1->GetValue(); + if (mRadioButtonLowerThan->isChecked()) { + mArgsInfo.upper_given = 1; + mArgsInfo.upper_arg = mThresholdSlider2->GetValue(); + if (mArgsInfo.upper_argGetValue(); + mArgsInfo.bg_arg = mBGSlider->GetValue(); + + if (inverseBGandFG) { + mArgsInfo.fg_arg = mFGSlider->GetValue(); + mArgsInfo.bg_arg = mBGSlider->GetValue(); + } + mArgsInfo.fg_given = 1; + mArgsInfo.bg_given = 1; + + if (mCheckBoxUseBG->isChecked()) { + if (mCheckBoxUseFG->isChecked()) mArgsInfo.mode_arg = (char*)"both"; + else mArgsInfo.mode_arg = (char*)"BG"; + } else mArgsInfo.mode_arg = (char*)"FG"; + + mArgsInfo.verbose_flag = false; + + // // Required (even if not used) + // mArgsInfo.input_given = 0; + // mArgsInfo.output_given = 0; + + // mArgsInfo.input_arg = new char; + // mArgsInfo.output_arg = new char; +} */ +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolTest::valueChangedT1() +{ cout << __func__ << endl; + // DD("valueChangedT1"); + if (!mCurrentSlicerManager) close(); + for(int i=0;iGetNumberOfSlicers(); i++) { + //mImageContour[i]->Update(v); + } + mCurrentSlicerManager->Render(); +} +//------------------------------------------------------------------------------ diff --git a/vv/vvToolTest.h b/vv/vvToolTest.h new file mode 100644 index 0000000..f28a181 --- /dev/null +++ b/vv/vvToolTest.h @@ -0,0 +1,62 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================**/ +#ifndef VVTOOLTEST_H +#define VVTOOLTEST_H + +#include + +#include "vvToolBase.h" +#include "vvToolWidgetBase.h" +#include "vvImageContour.h" +#include "ui_vvToolTest.h" + + +//------------------------------------------------------------------------------ +class vvToolTest: + public vvToolWidgetBase, + public vvToolBase, + private Ui::vvToolTest +{ + Q_OBJECT + public: + vvToolTest(vvMainWindowBase * parent=0, Qt::WindowFlags f=0); + ~vvToolTest(); + + //----------------------------------------------------- + static void Initialize(); + //void GetArgsInfoFromGUI(); + virtual void InputIsSelected(vvSlicerManager * m); + + //----------------------------------------------------- + public slots: + virtual bool close(); + virtual void reject(); + virtual void apply(); + void UpdateSlice(int slicer,int slices); + void valueChangedT1(); + + protected: + Ui::vvToolTest ui; + + void Update(int slicer); + +}; // end class vvToolTest +//------------------------------------------------------------------------------ + +#endif + diff --git a/vv/vvToolWidgetBase.cxx b/vv/vvToolWidgetBase.cxx index 6abc741..6d89fcf 100644 --- a/vv/vvToolWidgetBase.cxx +++ b/vv/vvToolWidgetBase.cxx @@ -38,7 +38,7 @@ bool vvToolWidgetBase::mIsAnotherToolWaitInput = false; vvToolWidgetBase::vvToolWidgetBase(vvMainWindowBase * parent, Qt::WindowFlags f, bool initialize): QWidget(parent, f), Ui::vvToolWidgetBase() -{ +{ //out << __func__ << endl; mMainWindow = parent; setAttribute(Qt::WA_DeleteOnClose); if (initialize) Initialization(); @@ -116,7 +116,7 @@ vvToolWidgetBase::vvToolWidgetBase(vvMainWindowBase * parent, Qt::WindowFlags f, //------------------------------------------------------------------------------ void vvToolWidgetBase::Initialization() -{ +{ //out << __func__ << endl; mCurrentSlicerManager = 0; mIsInitialized = false; mFilter = 0; @@ -139,14 +139,14 @@ void vvToolWidgetBase::Initialization() //------------------------------------------------------------------------------ vvToolWidgetBase::~vvToolWidgetBase() -{ +{ //out << __func__ << endl; } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void vvToolWidgetBase::keyPressEvent(QKeyEvent *event) -{ +{ //out << __func__ << endl; if (event->key() == Qt::Key_Escape) { reject(); event->accept(); @@ -164,7 +164,7 @@ void vvToolWidgetBase::keyPressEvent(QKeyEvent *event) //------------------------------------------------------------------------------ void vvToolWidgetBase::accept() -{ +{ //out << __func__ << endl; apply(); } //------------------------------------------------------------------------------ @@ -172,7 +172,7 @@ void vvToolWidgetBase::accept() //------------------------------------------------------------------------------ void vvToolWidgetBase::reject() -{ +{ //out << __func__ << endl; close(); } //------------------------------------------------------------------------------ @@ -180,7 +180,7 @@ void vvToolWidgetBase::reject() //------------------------------------------------------------------------------ void vvToolWidgetBase::AddInputSelector(QString s, clitk::ImageToImageGenericFilterBase * f, bool allowSkip) -{ +{ //out << __func__ << endl; int j=0; mFilter = f; mSlicerManagersCompatible.clear(); @@ -219,7 +219,7 @@ void vvToolWidgetBase::AddInputSelector(QString s, clitk::ImageToImageGenericFil //------------------------------------------------------------------------------ void vvToolWidgetBase::AddInputSelector(QString s, bool allowSkip) -{ +{ //out << __func__ << endl; mSlicerManagersCompatible.clear(); for(unsigned int i=0; iGetSlicerManagers().size(); i++) { mSlicerManagersCompatible.push_back(mMainWindow->GetSlicerManagers()[i]); @@ -245,7 +245,7 @@ void vvToolWidgetBase::AddInputSelector(QString s, bool allowSkip) //------------------------------------------------------------------------------ void vvToolWidgetBase::HideInputSelector() -{ +{ //out << __func__ << endl; mToolInputSelectionWidget->hide(); } //------------------------------------------------------------------------------ @@ -253,7 +253,7 @@ void vvToolWidgetBase::HideInputSelector() //------------------------------------------------------------------------------ void vvToolWidgetBase::show() -{ +{ //out << __func__ << endl; if (!mIsInitialized) { mToolInputSelectionWidget->Initialize(); mIsInitialized = true; @@ -265,7 +265,7 @@ void vvToolWidgetBase::show() //------------------------------------------------------------------------------ void vvToolWidgetBase::closeEvent(QCloseEvent *event) -{ +{ //out << __func__ << endl; mIsAnotherToolWaitInput = false; if (isWindow()) { event->accept();//return QWidget::close(); @@ -292,7 +292,7 @@ void vvToolWidgetBase::closeEvent(QCloseEvent *event) //------------------------------------------------------------------------------ bool vvToolWidgetBase::close() -{ +{ //out << __func__ << endl; QApplication::restoreOverrideCursor(); return QWidget::close(); } @@ -301,7 +301,7 @@ bool vvToolWidgetBase::close() //------------------------------------------------------------------------------ void vvToolWidgetBase::AnImageIsBeingClosed(vvSlicerManager * m) -{ +{ //out << __func__ << endl; mToolInputSelectionWidget->AnImageIsBeingClosed(m); if (m == mCurrentSlicerManager) { close(); @@ -312,7 +312,7 @@ void vvToolWidgetBase::AnImageIsBeingClosed(vvSlicerManager * m) //------------------------------------------------------------------------------ void vvToolWidgetBase::SwapCurrentWidget() -{ +{ //out << __func__ << endl; mStaticWidgetForTab->setUpdatesEnabled(false); QList l =mStaticWidgetForTab->children(); for(int i=1; isetEnabled(true); std::vector & l = mToolInputSelectionWidget->GetSelectedInputs(); mCurrentSlicerManager = l[0]; @@ -372,7 +372,7 @@ void vvToolWidgetBase::InputIsSelected() //------------------------------------------------------------------------------ void vvToolWidgetBase::InputIsSelected(vvSlicerManager * m) -{ +{ //out << __func__ << endl; std::cerr << "You MUST overwrite this method vvToolWidgetBase::InputIsSelected(vvSlicerManager * m) if you use one single input" << std::endl; exit(0); } @@ -381,7 +381,7 @@ void vvToolWidgetBase::InputIsSelected(vvSlicerManager * m) //------------------------------------------------------------------------------ void vvToolWidgetBase::InputIsSelected(std::vector & l) -{ +{ //out << __func__ << endl; mMainButtonBox->setEnabled(true); if (l.size() == 1) InputIsSelected(l[0]); else {