From: ouv Date: Fri, 1 Feb 2013 10:35:15 +0000 (+0000) Subject: Porting to VTK 6. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1b93f3cbab7ce1a1e95d635b7911494bbdbd3889;p=modules%2Fgui.git Porting to VTK 6. Debug. --- diff --git a/src/SVTK/Makefile.am b/src/SVTK/Makefile.am index 6fc34fed2..e11dfa66c 100755 --- a/src/SVTK/Makefile.am +++ b/src/SVTK/Makefile.am @@ -88,12 +88,11 @@ dist_libSVTK_la_SOURCES= \ SVTK_RecorderDlg.cxx \ SVTK_ImageWriter.cxx \ SVTK_ImageWriterMgr.cxx \ - SVTK_Utils.cxx -# OUV_PORTING_VTK6: to do -# vtkPVAxesActor.h \ -# vtkPVAxesActor.cxx \ -# vtkPVAxesWidget.h \ -# vtkPVAxesWidget.cxx + SVTK_Utils.cxx \ + vtkPVAxesActor.h \ + vtkPVAxesActor.cxx \ + vtkPVAxesWidget.h \ + vtkPVAxesWidget.cxx # internal headers @@ -150,7 +149,7 @@ libSVTK_la_CPPFLAGS = \ -I$(srcdir)/../Prs \ -I$(srcdir)/../VTKViewer \ -I$(srcdir)/../OpenGLUtils \ - -DvtkRenderingCore_AUTOINIT="2(vtkInteractionStyle,vtkRenderingOpenGL)" + -DvtkRenderingCore_AUTOINIT="3(vtkInteractionStyle,vtkRenderingOpenGL,vtkRenderingFreeTypeOpenGL)" libSVTK_la_LDFLAGS = \ $(VTK_LIBS) $(OGL_LIBS) \ diff --git a/src/SVTK/SVTK_DeviceActor.cxx b/src/SVTK/SVTK_DeviceActor.cxx index 72259a06b..9b15c76f5 100644 --- a/src/SVTK/SVTK_DeviceActor.cxx +++ b/src/SVTK/SVTK_DeviceActor.cxx @@ -138,12 +138,7 @@ SVTK_DeviceActor myPassFilter[ anId + 1 ]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() ); anId++; // 5 - // OUV_PORTING_VTK6: to check - if(VTKViewer_DataSetMapper* aMapper = dynamic_cast(theMapper)){ - aMapper->SetInputConnection(myPassFilter[anId]->GetOutputPort()); - }else if(VTKViewer_PolyDataMapper* aMapper = dynamic_cast(theMapper)){ - aMapper->SetInputConnection(myPassFilter[anId]->GetOutputPort()); - } + theMapper->SetInputConnection(myPassFilter[anId]->GetOutputPort()); } Superclass::SetMapper(theMapper); } @@ -257,18 +252,18 @@ SVTK_DeviceActor if ( !myIsShrinkable ) return; - if ( vtkAlgorithmOutput* aDataSet = myPassFilter[ 0 ]->GetOutputPort() ) + if ( vtkAlgorithmOutput* anOutput = myPassFilter[ 0 ]->GetOutputPort() ) { myPassFilter[ 0 ]->Update(); - // OUV_PORTING_VTK6: to do - /* - int numCells=aDataSet->GetNumberOfCells(); - int numPts = aDataSet->GetNumberOfPoints(); - //It's impossible to use to apply "shrink" for "empty" dataset - if (numCells < 1 || numPts < 1) - return; - */ - myShrinkFilter->SetInputConnection( aDataSet ); + if ( vtkDataSet* aDataSet = myPassFilter[ 0 ]->GetOutput() ) + { + int numCells=aDataSet->GetNumberOfCells(); + int numPts = aDataSet->GetNumberOfPoints(); + //It's impossible to use to apply "shrink" for "empty" dataset + if (numCells < 1 || numPts < 1) + return; + } + myShrinkFilter->SetInputConnection( anOutput ); myPassFilter[ 1 ]->SetInputConnection( myShrinkFilter->GetOutputPort() ); myIsShrunk = true; } @@ -282,9 +277,9 @@ SVTK_DeviceActor ::UnShrink() { if ( !myIsShrunk ) return; - if ( vtkAlgorithmOutput* aDataSet = myPassFilter[ 0 ]->GetOutputPort() ) + if ( vtkAlgorithmOutput* anOutput = myPassFilter[ 0 ]->GetOutputPort() ) { - myPassFilter[ 1 ]->SetInputConnection( aDataSet ); + myPassFilter[ 1 ]->SetInputConnection( anOutput ); myIsShrunk = false; } } diff --git a/src/SVTK/SVTK_ImageWriter.cxx b/src/SVTK/SVTK_ImageWriter.cxx index 35455be0d..87b9680cd 100755 --- a/src/SVTK/SVTK_ImageWriter.cxx +++ b/src/SVTK/SVTK_ImageWriter.cxx @@ -21,6 +21,7 @@ #include +#include #include #include #include @@ -36,11 +37,13 @@ static int MYDEBUG = 0; //---------------------------------------------------------------------------- SVTK_ImageWriter ::SVTK_ImageWriter(QSemaphore* theSemaphore, + vtkAlgorithm* theAlgorithm, vtkImageData* theImageData, const std::string& theName, int theProgressive, int theQuality): mySemaphore(theSemaphore), + myAlgorithm(theAlgorithm), myImageData(theImageData), myName(theName), myProgressive(theProgressive), @@ -67,11 +70,8 @@ SVTK_ImageWriter // if(myConstraint16Flag){ int uExtent[6]; - // OUV_PORTING_VTK6: to do - /* - myImageData->UpdateInformation(); - myImageData->GetUpdateExtent(uExtent); - */ + myAlgorithm->UpdateInformation(); + myAlgorithm->GetUpdateExtent(uExtent); unsigned int width = uExtent[1] - uExtent[0] + 1; unsigned int height = uExtent[3] - uExtent[2] + 1; width = (width / 16) * 16; diff --git a/src/SVTK/SVTK_ImageWriter.h b/src/SVTK/SVTK_ImageWriter.h index 5973b9f44..2ca2f9ca0 100755 --- a/src/SVTK/SVTK_ImageWriter.h +++ b/src/SVTK/SVTK_ImageWriter.h @@ -23,6 +23,7 @@ #include #include +class vtkAlgorithm; class vtkImageData; class QSemaphore; @@ -30,6 +31,7 @@ class SVTK_ImageWriter : public QThread { public: SVTK_ImageWriter(QSemaphore* theSemaphore, + vtkAlgorithm* theAlgorithm, vtkImageData* theImageData, const std::string& theName, int theProgressive, @@ -44,6 +46,7 @@ public: protected: QSemaphore* mySemaphore; + vtkAlgorithm *myAlgorithm; vtkImageData *myImageData; std::string myName; int myProgressive; diff --git a/src/SVTK/SVTK_ImageWriterMgr.cxx b/src/SVTK/SVTK_ImageWriterMgr.cxx index 22e7b97ba..97e0717e2 100755 --- a/src/SVTK/SVTK_ImageWriterMgr.cxx +++ b/src/SVTK/SVTK_ImageWriterMgr.cxx @@ -20,6 +20,7 @@ #include "SVTK_ImageWriterMgr.h" #include "SVTK_ImageWriter.h" +#include #include #include @@ -58,13 +59,15 @@ SVTK_ImageWriterMgr //---------------------------------------------------------------------------- void SVTK_ImageWriterMgr -::StartImageWriter(vtkImageData *theImageData, +::StartImageWriter(vtkAlgorithm *theAlgorithm, + vtkImageData *theImageData, const std::string& theName, const int theProgressive, const int theQuality) { SVTK_ImageWriter *anImageWriter = new SVTK_ImageWriter(mySemaphore, + theAlgorithm, theImageData, theName, theProgressive, diff --git a/src/SVTK/SVTK_ImageWriterMgr.h b/src/SVTK/SVTK_ImageWriterMgr.h index 86a445946..09a909bd2 100755 --- a/src/SVTK/SVTK_ImageWriterMgr.h +++ b/src/SVTK/SVTK_ImageWriterMgr.h @@ -24,6 +24,7 @@ #include class QString; +class vtkAlgorithm; class vtkImageData; class SVTK_ImageWriter; class QSemaphore; @@ -35,7 +36,8 @@ class SVTK_ImageWriterMgr ~SVTK_ImageWriterMgr(); void - StartImageWriter(vtkImageData *theImageData, + StartImageWriter(vtkAlgorithm *theAlgorithm, + vtkImageData *theImageData, const std::string& theName, const int theProgressive, const int theQuality); diff --git a/src/SVTK/SVTK_Recorder.cxx b/src/SVTK/SVTK_Recorder.cxx index afd6866cc..666c4b6e6 100755 --- a/src/SVTK/SVTK_Recorder.cxx +++ b/src/SVTK/SVTK_Recorder.cxx @@ -375,7 +375,7 @@ SVTK_Recorder vtkImageData *anImageData = vtkImageData::New(); anImageData->DeepCopy(myFilter->GetOutput()); - myWriterMgr->StartImageWriter(anImageData,aName,myProgressiveMode,myQuality); + myWriterMgr->StartImageWriter(myFilter,anImageData,aName,myProgressiveMode,myQuality); myNbWrittenFrames++; myRenderWindow->AddObserver(vtkCommand::EndEvent, @@ -395,15 +395,9 @@ SVTK_Recorder myErrorStatus = 20; return; } - // OUV_PORTING_VTK6: to do - /* - anImageData->UpdateInformation(); - int *anExtent = anImageData->GetWholeExtent(); - anImageData->SetUpdateExtent(anExtent[0], anExtent[1], - anExtent[2], anExtent[3], - 0,0); - anImageData->UpdateData(); - */ + myFilter->UpdateInformation(); + myFilter->SetUpdateExtentToWholeExtent(); + myFilter->Update(); } diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 9f1878a26..b93407e68 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -91,9 +91,8 @@ #include "SVTK_Recorder.h" #include "SVTK_RecorderDlg.h" -// OUV_PORTING_VTK6: to do -//#include "vtkPVAxesWidget.h" -//#include "vtkPVAxesActor.h" +#include "vtkPVAxesWidget.h" +#include "vtkPVAxesActor.h" #include "SALOME_ListIteratorOfListIO.hxx" @@ -201,8 +200,6 @@ void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel) setCentralWidget(myInteractor); - // OUV_PORTING_VTK6: to do - /* myAxesWidget = vtkPVAxesWidget::New(); myAxesWidget->SetParentRenderer(aRenderer->GetDevice()); myAxesWidget->SetViewport(0, 0, 0.25, 0.25); @@ -220,7 +217,6 @@ void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel) anAxesActor->GetZAxisTipProperty()->SetColor( 0.0, 0.0, 1.0 ); anAxesActor->GetZAxisShaftProperty()->SetColor( 0.0, 0.0, 1.0 ); anAxesActor->GetZAxisLabelProperty()->SetColor( 0.0, 0.0, 1.0 ); - */ myView = new SVTK_View(this); Initialize(myView,theModel); @@ -274,8 +270,7 @@ void SVTK_ViewWindow::Initialize(SVTK_View* theView, SVTK_ViewWindow::~SVTK_ViewWindow() { myRecorder->Delete(); - // OUV_PORTING_VTK6: to do - //myAxesWidget->Delete(); + myAxesWidget->Delete(); } @@ -1249,9 +1244,7 @@ void SVTK_ViewWindow::SetSelectionTolerance(const double& theTolNodes, */ bool SVTK_ViewWindow::IsStaticTrihedronVisible() const { - // OUV_PORTING_VTK6: to do - //return (bool)myAxesWidget->GetEnabled(); - return false; + return (bool)myAxesWidget->GetEnabled(); } /*! @@ -1259,8 +1252,7 @@ bool SVTK_ViewWindow::IsStaticTrihedronVisible() const */ void SVTK_ViewWindow::SetStaticTrihedronVisible( const bool theIsVisible ) { - // OUV_PORTING_VTK6: to do - //myAxesWidget->SetEnabled( (int)theIsVisible ); + myAxesWidget->SetEnabled( (int)theIsVisible ); } /*! diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index 0285a0c17..cd94e94bd 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -66,8 +66,7 @@ class SVTK_KeyFreeInteractorStyle; class SVTK_ViewParameterDlg; class SVTK_Recorder; -// OUV_PORTING_VTK6: to do -//class vtkPVAxesWidget; +class vtkPVAxesWidget; class vtkObject; class QtxAction; @@ -447,8 +446,7 @@ protected: int myToolBar; int myRecordingToolBar; - // OUV_PORTING_VTK6: to do - //vtkPVAxesWidget* myAxesWidget; + vtkPVAxesWidget* myAxesWidget; Qtx::BackgroundData myBackground; private: diff --git a/src/SVTK/vtkPVAxesActor.cxx b/src/SVTK/vtkPVAxesActor.cxx index cac96a21b..4431e3ea6 100644 --- a/src/SVTK/vtkPVAxesActor.cxx +++ b/src/SVTK/vtkPVAxesActor.cxx @@ -152,9 +152,9 @@ vtkPVAxesActor::vtkPVAxesActor() vtkPolyDataMapper *ymapper = vtkPolyDataMapper::New(); vtkPolyDataMapper *zmapper = vtkPolyDataMapper::New(); - xmapper->SetInput( this->XAxisVectorText->GetOutput() ); - ymapper->SetInput( this->YAxisVectorText->GetOutput() ); - zmapper->SetInput( this->ZAxisVectorText->GetOutput() ); + xmapper->SetInputConnection( this->XAxisVectorText->GetOutputPort() ); + ymapper->SetInputConnection( this->YAxisVectorText->GetOutputPort() ); + zmapper->SetInputConnection( this->ZAxisVectorText->GetOutputPort() ); this->XAxisLabel->SetMapper( xmapper ); this->YAxisLabel->SetMapper( ymapper ); @@ -256,7 +256,7 @@ int vtkPVAxesActor::RenderOpaqueGeometry(vtkViewport *vp) } //----------------------------------------------------------------------------- -#if (VTK_MINOR_VERSION>=2) +#if (VTK_MAJOR_VERSION>5 || VTK_MINOR_VERSION>=2) // porting to VTK 5.0.x int vtkPVAxesActor::RenderTranslucentPolygonalGeometry(vtkViewport *vp) { @@ -585,36 +585,34 @@ void vtkPVAxesActor::UpdateProps() { case vtkPVAxesActor::CYLINDER_SHAFT: (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))-> - SetInput( this->CylinderSource->GetOutput() ); + SetInputConnection( this->CylinderSource->GetOutputPort() ); break; case vtkPVAxesActor::LINE_SHAFT: (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))-> - SetInput( this->LineSource->GetOutput() ); + SetInputConnection( this->LineSource->GetOutputPort() ); break; case vtkPVAxesActor::USER_DEFINED_SHAFT: (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))-> - SetInput( this->UserDefinedShaft ); + SetInputData( this->UserDefinedShaft ); } switch ( this->TipType ) { case vtkPVAxesActor::CONE_TIP: (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))-> - SetInput( this->ConeSource->GetOutput() ); + SetInputConnection( this->ConeSource->GetOutputPort() ); break; case vtkPVAxesActor::SPHERE_TIP: (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))-> - SetInput( this->SphereSource->GetOutput() ); + SetInputConnection( this->SphereSource->GetOutputPort() ); break; case vtkPVAxesActor::USER_DEFINED_TIP: (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))-> - SetInput( this->UserDefinedTip ); + SetInputData( this->UserDefinedTip ); } - (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))-> - GetInput()->Update(); - (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))-> - GetInput()->Update(); + (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->Update(); + (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->Update(); diff --git a/src/SVTK/vtkPVAxesActor.h b/src/SVTK/vtkPVAxesActor.h index 9188f48d7..b76f59f93 100644 --- a/src/SVTK/vtkPVAxesActor.h +++ b/src/SVTK/vtkPVAxesActor.h @@ -43,6 +43,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "SVTK.h" #include "vtkProp3D.h" +#include + class vtkRenderer; class vtkPropCollection; class vtkMapper; @@ -73,7 +75,7 @@ public: // Description: // Support the standard render methods. virtual int RenderOpaqueGeometry(vtkViewport *viewport); -#if (VTK_MINOR_VERSION>=2) +#if (VTK_MAJOR_VERSION>5 || VTK_MINOR_VERSION>=2) virtual int RenderTranslucentPolygonalGeometry(vtkViewport *viewport); // porting to VTK 5.0.x virtual int HasTranslucentPolygonalGeometry(); // porting to VTK 5.0.x #else diff --git a/src/SVTK/vtkPVAxesWidget.cxx b/src/SVTK/vtkPVAxesWidget.cxx index e29c710c3..b83b1dea3 100644 --- a/src/SVTK/vtkPVAxesWidget.cxx +++ b/src/SVTK/vtkPVAxesWidget.cxx @@ -114,7 +114,7 @@ vtkPVAxesWidget::vtkPVAxesWidget() vtkCoordinate *tcoord = vtkCoordinate::New(); tcoord->SetCoordinateSystemToDisplay(); vtkPolyDataMapper2D *mapper = vtkPolyDataMapper2D::New(); - mapper->SetInput(this->Outline); + mapper->SetInputData(this->Outline); mapper->SetTransformCoordinate(tcoord); this->OutlineActor = vtkActor2D::New(); this->OutlineActor->SetMapper(mapper); diff --git a/src/VTKViewer/Makefile.am b/src/VTKViewer/Makefile.am index 58fecd67e..dde868def 100755 --- a/src/VTKViewer/Makefile.am +++ b/src/VTKViewer/Makefile.am @@ -143,7 +143,8 @@ nodist_salomeres_DATA = \ VTKViewer_msg_fr.qm libVTKViewer_la_CPPFLAGS = $(QT_INCLUDES) $(VTK_INCLUDES) $(CAS_CPPFLAGS) \ - -I$(srcdir)/../Qtx -I$(srcdir)/../SUIT + -I$(srcdir)/../Qtx -I$(srcdir)/../SUIT \ + -DvtkRenderingCore_AUTOINIT="3(vtkInteractionStyle,vtkRenderingOpenGL,vtkRenderingFreeTypeOpenGL)" libVTKViewer_la_LDFLAGS = $(KERNEL_LDFLAGS) $(VTK_LIBS) $(QT_MT_LIBS) \ $(CAS_KERNEL) $(OGL_LIBS) ../Qtx/libqtx.la ../SUIT/libsuit.la diff --git a/src/VTKViewer/VTKViewer_Actor.cxx b/src/VTKViewer/VTKViewer_Actor.cxx index 5c21dc552..eecfbc211 100755 --- a/src/VTKViewer/VTKViewer_Actor.cxx +++ b/src/VTKViewer/VTKViewer_Actor.cxx @@ -199,12 +199,7 @@ VTKViewer_Actor myPassFilter[ anId + 1 ]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() ); anId++; // 5 - // OUV_PORTING_VTK6: to check - if(vtkDataSetMapper* aMapper = dynamic_cast(theMapper)){ - aMapper->SetInputConnection(myPassFilter[anId]->GetOutputPort()); - }else if(vtkPolyDataMapper* aMapper = dynamic_cast(theMapper)){ - aMapper->SetInputConnection(myPassFilter[anId]->GetOutputPort()); - } + theMapper->SetInputConnection(myPassFilter[anId]->GetOutputPort()); } Superclass::SetMapper(theMapper); } diff --git a/src/VTKViewer/VTKViewer_ArcBuilder.cxx b/src/VTKViewer/VTKViewer_ArcBuilder.cxx index b5d2a0f38..9057c9893 100644 --- a/src/VTKViewer/VTKViewer_ArcBuilder.cxx +++ b/src/VTKViewer/VTKViewer_ArcBuilder.cxx @@ -292,7 +292,6 @@ VTKViewer_ArcBuilder::VTKViewer_ArcBuilder(const Pnt& thePnt1, vtkUnstructuredGrid* aTransformedGrid; if(needRotation) { aTransformedGrid = TransformGrid(aGrid,aAxis,anAngle); - //aTransformedGrid->Update(); // OUV_PORTING_VTK6: seems to be useless #ifdef _MY_DEBUG_ cout<<"Need Rotation!!!"< aScalarValues; vtkUnstructuredGrid* anArc = BuildArc(aScalarValues); vtkUnstructuredGrid* anTransArc; - if(needRotation) { + if(needRotation) anTransArc = TransformGrid(anArc,aAxis,-anAngle); - //anTransArc->Update(); // OUV_PORTING_VTK6: seems to be useless - } else anTransArc = anArc; @@ -335,7 +332,6 @@ VTKViewer_ArcBuilder::VTKViewer_ArcBuilder(const Pnt& thePnt1, aList.push_back(thePnt2); aList.push_back(thePnt3); vtkUnstructuredGrid* aGrid = BuildGrid(aList); - //aGrid->Update(); // OUV_PORTING_VTK6: seems to be useless myPoints = aGrid->GetPoints(); myScalarValues.clear(); diff --git a/src/VTKViewer/VTKViewer_MarkerUtils.cxx b/src/VTKViewer/VTKViewer_MarkerUtils.cxx index 64959af30..32b0fdc09 100755 --- a/src/VTKViewer/VTKViewer_MarkerUtils.cxx +++ b/src/VTKViewer/VTKViewer_MarkerUtils.cxx @@ -92,10 +92,7 @@ namespace VTK anImageData->Delete(); anImageData->SetExtent( 0, aWidth-1, 0, aHeight-1, 0, 0 ); - // OUV_PORTING_VTK6: to do (see Scalars Manipulation Functions) - //anImageData->SetScalarTypeToUnsignedChar(); - //anImageData->SetNumberOfScalarComponents( 4 ); - //anImageData->AllocateScalars(); + anImageData->AllocateScalars( VTK_UNSIGNED_CHAR, 4 ); unsigned char* aDataPtr = (unsigned char*)anImageData->GetScalarPointer(); @@ -110,7 +107,6 @@ namespace VTK aDataPtr[ anId++ ] = aValue * aCoef; aDataPtr[ anId++ ] = aValue; } - //anImageData->Update(); // OUV_PORTING_VTK6: seems to be useless return anImageData; }