// VISU OBJECT : interactive object for VISU entities implementation
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : VISU_MeshAct.cxx
-// Author : Laurent CORNABE with the help of Nicolas REJNERI
+// Author :
// Module : VISU
// $Header$
#include "VISU_MeshAct.h"
-#include "SALOME_PassThroughFilter.h"
+#include "SVTK_DeviceActor.h"
+
+#include <vtkObjectFactory.h>
+#include <vtkRenderer.h>
+#include <vtkTexture.h>
#include <vtkFeatureEdges.h>
#include <vtkDataSetMapper.h>
#include <vtkDataSet.h>
+#include <vtkMatrix4x4.h>
+#include <vtkMapperCollection.h>
+
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_MeshAct);
-VISU_MeshAct::VISU_MeshAct(){
- mySurfaceActor = VISU_Actor::New();
- mySurfaceActor->SetParent(this);
- mySurfaceActor->GetProperty()->FrontfaceCullingOff();
- mySurfaceActor->GetProperty()->BackfaceCullingOff();
- mySurfaceActor->SetRepresentation(2); //SURFACE
-
- myEdgeActor = VISU_Actor::New();
- myEdgeActor->SetParent(this);
- myEdgeActor->PickableOff();
- myEdgeActor->GetProperty()->FrontfaceCullingOff();
- myEdgeActor->GetProperty()->BackfaceCullingOff();
- myEdgeActor->SetRepresentation(1); //WIREFRAME
-
- myNodeActor = VISU_Actor::New();
- myNodeActor->SetParent(this);
- myNodeActor->PickableOff();
- myNodeActor->GetProperty()->SetPointSize(SALOME_POINT_SIZE);
- myNodeActor->GetProperty()->FrontfaceCullingOff();
- myNodeActor->GetProperty()->BackfaceCullingOff();
- myNodeActor->SetRepresentation(0); //POINT
-
- SetRepresentation(2); //SURFACE
-}
-
-VISU_MeshAct::~VISU_MeshAct(){
+
+//----------------------------------------------------------------------------
+VISU_MeshAct
+::VISU_MeshAct()
+{
+ vtkMatrix4x4 *m;
+ m = vtkMatrix4x4::New();
+
+ mySurfaceActor = SVTK_DeviceActor::New();
+ mySurfaceActor->SetRepresentation(SVTK::Representation::Surface);
+ mySurfaceActor->SetUserMatrix(m);
+
+ myEdgeActor = SVTK_DeviceActor::New();
+ myEdgeActor->SetRepresentation(SVTK::Representation::Wireframe);
+ myEdgeActor->SetUserMatrix(m);
+
+ myNodeActor = SVTK_DeviceActor::New();
+ myNodeActor->SetRepresentation(SVTK::Representation::Points);
+ myNodeActor->SetUserMatrix(m);
+
+ m->Delete();
+ SetRepresentation(SVTK::Representation::Surface);
+}
+
+VISU_MeshAct
+::~VISU_MeshAct()
+{
mySurfaceActor->Delete();
myEdgeActor->Delete();
myNodeActor->Delete();
}
-void VISU_MeshAct::setIO(const Handle(SALOME_InteractiveObject)& theIO){
- mySurfaceActor->setIO(theIO);
- myEdgeActor->setIO(theIO);
- myNodeActor->setIO(theIO);
-}
-void VISU_MeshAct::SetPrs3d(VISU::Prs3d_i* thePrs3d){
- if(thePrs3d){
- VISU_Actor::SetPrs3d(thePrs3d);
- mySurfaceActor->SetPrs3d(thePrs3d);
- myEdgeActor->SetPrs3d(thePrs3d);
- myNodeActor->SetPrs3d(thePrs3d);
- }
-}
+//----------------------------------------------------------------------------
+void
+VISU_MeshAct
+::SetMapperInput(vtkDataSet* theDataSet)
+{
+ Superclass::SetMapperInput(theDataSet);
-void VISU_MeshAct::AddToRender(vtkRenderer* theRenderer){
- theRenderer->AddActor(mySurfaceActor);
- theRenderer->AddActor(myEdgeActor);
- theRenderer->AddActor(myNodeActor);
+ mySurfaceActor->SetInput(theDataSet);
+ myEdgeActor->SetInput(theDataSet);
+ myNodeActor->SetInput(theDataSet);
}
-void VISU_MeshAct::RemoveFromRender(vtkRenderer* theRenderer){
- theRenderer->RemoveActor(mySurfaceActor);
- theRenderer->RemoveActor(myEdgeActor);
- theRenderer->RemoveActor(myNodeActor);
-}
-void VISU_MeshAct::SetPipeLine(VISU_PipeLine* thePipeLine) throw(std::runtime_error&){
- VISU_Actor::SetPipeLine(thePipeLine);
- mySurfaceActor->SetPipeLine(thePipeLine);
- myEdgeActor->SetPipeLine(thePipeLine);
- myNodeActor->SetPipeLine(thePipeLine);
-}
+//----------------------------------------------------------------------------
+void
+VISU_MeshAct
+::SetTransform(VTKViewer_Transform* theTransform)
+{
+ Superclass::SetTransform(theTransform);
-void VISU_MeshAct::SetTransform(SALOME_Transform* theTransform){
mySurfaceActor->SetTransform(theTransform);
myEdgeActor->SetTransform(theTransform);
myNodeActor->SetTransform(theTransform);
}
-void VISU_MeshAct::SetShrinkable(bool theIsShrinkable){
- VISU_Actor::SetShrinkable(theIsShrinkable);
+
+//----------------------------------------------------------------------------
+void
+VISU_MeshAct
+::SetShrinkable(bool theIsShrinkable)
+{
+ Superclass::SetShrinkable(theIsShrinkable);
+
mySurfaceActor->SetShrinkable(theIsShrinkable);
myEdgeActor->SetShrinkable(theIsShrinkable);
- myNodeActor->SetShrinkable(theIsShrinkable);
}
-vtkProperty* VISU_MeshAct::GetProperty(){
- mySurfaceActor->GetProperty();
-}
+void
+VISU_MeshAct
+::SetShrinkFactor(float theValue)
+{
+ Superclass::SetShrinkFactor(theValue);
-void VISU_MeshAct::SetProperty(vtkProperty* theProperty){
- mySurfaceActor->SetProperty(theProperty);
+ mySurfaceActor->SetShrinkFactor(theValue);
+ myEdgeActor->SetShrinkFactor(theValue);
}
-vtkProperty* VISU_MeshAct::GetEdgeProperty(){
- myEdgeActor->GetProperty();
-}
-void VISU_MeshAct::SetEdgeProperty(vtkProperty* theProperty){
- myEdgeActor->SetProperty(theProperty);
+//----------------------------------------------------------------------------
+vtkProperty*
+VISU_MeshAct
+::GetSurfaceProperty()
+{
+ return mySurfaceActor->GetProperty();
}
-vtkProperty* VISU_MeshAct::GetNodeProperty(){
- myNodeActor->GetProperty();
-}
+vtkProperty*
+VISU_MeshAct
+::GetEdgeProperty()
+{
+ return myEdgeActor->GetProperty();
+}
+
+vtkProperty*
+VISU_MeshAct
+::GetNodeProperty()
+{
+ return myNodeActor->GetProperty();
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_MeshAct
+::SetOpacity(float theValue)
+{
+ GetSurfaceProperty()->SetOpacity(theValue);
+}
-void VISU_MeshAct::SetNodeProperty(vtkProperty* theProperty){
- myNodeActor->SetProperty(theProperty);
+float
+VISU_MeshAct
+::GetOpacity()
+{
+ return GetSurfaceProperty()->GetOpacity();
}
-void VISU_MeshAct::SetLineWidth(float theLineWidth){
+//----------------------------------------------------------------------------
+void
+VISU_MeshAct
+::SetLineWidth(float theLineWidth)
+{
GetEdgeProperty()->SetLineWidth(theLineWidth);
}
-float VISU_MeshAct::GetLineWidth(){
+float
+VISU_MeshAct::GetLineWidth()
+{
return GetEdgeProperty()->GetLineWidth();
}
-void VISU_MeshAct::SetShrink(float theFactor){
- VISU_Actor::SetShrink(theFactor);
- mySurfaceActor->SetShrink(theFactor);
- myEdgeActor->SetShrink(theFactor);
- SetRepresentation(GetRepresentation());
+//----------------------------------------------------------------------------
+void
+VISU_MeshAct
+::SetShrink()
+{
+ if(myRepresentation == VTK_POINTS)
+ return;
+
+ Superclass::SetShrink();
+
+ mySurfaceActor->SetShrink();
+ myEdgeActor->SetShrink();
}
-void VISU_MeshAct::UnShrink(){
- VISU_Actor::UnShrink();
+void
+VISU_MeshAct
+::UnShrink()
+{
+ Superclass::UnShrink();
+
mySurfaceActor->UnShrink();
myEdgeActor->UnShrink();
- SetRepresentation(GetRepresentation());
}
-void VISU_MeshAct::SetRepresentation(int theMode){
- SALOME_Actor::SetRepresentation(theMode);
- mySurfaceActor->VisibilityOff();
- myEdgeActor->VisibilityOff();
- myNodeActor->VisibilityOff();
- switch(theMode){
- case 0: //POINTS
- myNodeActor->VisibilityOn();
- break;
- case 1: //WIREFRAME
- myEdgeActor->VisibilityOn();
- myEdgeActor->SetRepresentation(1);
+
+//----------------------------------------------------------------------------
+void
+VISU_MeshAct
+::SetRepresentation(int theMode)
+{
+ Superclass::SetRepresentation(theMode);
+
+ if(theMode == SVTK::Representation::Insideframe)
+ myEdgeActor->SetRepresentation(SVTK::Representation::Insideframe);
+ else
+ myEdgeActor->SetRepresentation(SVTK::Representation::Wireframe);
+}
+
+//----------------------------------------------------------------------------
+int
+VISU_MeshAct
+::RenderOpaqueGeometry(vtkViewport *ren)
+{
+ GetMatrix(myNodeActor->GetUserMatrix());
+ GetMatrix(myEdgeActor->GetUserMatrix());
+ GetMatrix(mySurfaceActor->GetUserMatrix());
+
+ using namespace SVTK::Representation;
+ switch(GetRepresentation()){
+ case Points :
+ myNodeActor->RenderOpaqueGeometry(ren);
break;
- case 2: //SURFACE
- mySurfaceActor->VisibilityOn();
+ case Wireframe :
+ case Insideframe :
+ myEdgeActor->RenderOpaqueGeometry(ren);
break;
- case 3: //INSIDEFRAME
- myEdgeActor->VisibilityOn();
- myEdgeActor->SetRepresentation(3);
+ case Surface :
+ mySurfaceActor->RenderOpaqueGeometry(ren);
break;
- case 4: //SURFACEFRAME
- myEdgeActor->VisibilityOn();
- myEdgeActor->SetRepresentation(1);
- mySurfaceActor->VisibilityOn();
+ case Surfaceframe :
+ mySurfaceActor->RenderOpaqueGeometry(ren);
+ myEdgeActor->RenderOpaqueGeometry(ren);
break;
}
+ return 1;
}
-void VISU_MeshAct::SetVisibility(int theMode){
- VISU_Actor::SetVisibility(theMode);
- if(GetVisibility())
- SetRepresentation(GetRepresentation());
- else{
- myNodeActor->VisibilityOff();
- myEdgeActor->VisibilityOff();
- mySurfaceActor->VisibilityOff();
+int
+VISU_MeshAct
+::RenderTranslucentGeometry(vtkViewport *ren)
+{
+ GetMatrix(myNodeActor->GetUserMatrix());
+ GetMatrix(myEdgeActor->GetUserMatrix());
+ GetMatrix(mySurfaceActor->GetUserMatrix());
+
+ using namespace SVTK::Representation;
+ switch(GetRepresentation()){
+ case Points :
+ myNodeActor->RenderTranslucentGeometry(ren);
+ break;
+ case Wireframe :
+ case Insideframe :
+ myEdgeActor->RenderTranslucentGeometry(ren);
+ break;
+ case Surface :
+ mySurfaceActor->RenderTranslucentGeometry(ren);
+ break;
+ case Surfaceframe :
+ mySurfaceActor->RenderTranslucentGeometry(ren);
+ myEdgeActor->RenderTranslucentGeometry(ren);
+ break;
}
+ return 1;
}