X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FOBJECT%2FGEOM_Actor.cxx;h=bc9c5c9f19dee6f0d1792b8d58a7d30acb3cac60;hb=2981cca5dd1ce44999a72fd8d46878518e5093fb;hp=6771efaa98b2f5b0204e744a13ce48c505e138e6;hpb=239f8109c64fa0c5a2e1d87a420bad5529b57f48;p=modules%2Fgeom.git diff --git a/src/OBJECT/GEOM_Actor.cxx b/src/OBJECT/GEOM_Actor.cxx index 6771efaa9..bc9c5c9f1 100644 --- a/src/OBJECT/GEOM_Actor.cxx +++ b/src/OBJECT/GEOM_Actor.cxx @@ -1,31 +1,31 @@ -// GEOM OBJECT : interactive object for Geometry entities visualization +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE // -// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com // + +// GEOM OBJECT : interactive object for Geometry entities visualization // File : GEOM_Actor.cxx // Author : Christophe ATTANASIO // Module : GEOM // $Header$ - +// /*! \class GEOM_Actor GEOM_Actor.h \brief This class allows to display an OpenCASCADE CAD model in a VTK viewer. @@ -37,8 +37,11 @@ #include "GEOM_EdgeSource.h" #include "GEOM_WireframeFace.h" #include "GEOM_ShadingFace.h" +#include "GEOM_PainterPolyDataMapper.h" #include "SVTK_Actor.h" +#include + #include #include #include @@ -47,14 +50,8 @@ #include #include -#include -#include -#include #include #include -#include -#include -#include #include #include @@ -67,6 +64,10 @@ #include #include +#include "utilities.h" + +#include "SALOME_InteractiveObject.hxx" + //vtkStandardNewMacro(GEOM_Actor); #ifndef MYDEBUG @@ -74,9 +75,15 @@ #endif GEOM_Actor::GEOM_Actor(): + isOnlyVertex(false), + + myDeflection(-1), + myIsForced(false), + // myDisplayMode(eWireframe), myIsSelected(false), - + myVectorMode(false), + myVertexActor(GEOM_DeviceActor::New(),true), myVertexSource(GEOM_VertexSource::New(),true), @@ -97,15 +104,20 @@ GEOM_Actor::GEOM_Actor(): myHighlightActor(GEOM_DeviceActor::New(),true), myAppendFilter(vtkAppendPolyData::New(),true), - myPolyDataMapper(vtkPolyDataMapper::New(),true), + // Use mapper as an instance of GEOM_PainterPolyDataMapper class + // to prevent drawing of mappers' content (due to an empty definition + // of GEOM_PainterPolyDataMapper::RenderPiece(...)). + // !!! Presentation of GEOM_Actor is drawing only with help of actors + // defined in this class !!! + myPolyDataMapper(GEOM_PainterPolyDataMapper::New(),true), myHighlightProp(vtkProperty::New()), myPreHighlightProp(vtkProperty::New()), - myShadingFaceProp(vtkProperty::New()) - + myShadingFaceProp(vtkProperty::New()), + myShadingBackFaceProp(vtkProperty::New()) { #ifdef MYDEBUG - cout <SetInput(myAppendFilter->GetOutput()); @@ -118,6 +130,7 @@ GEOM_Actor::GEOM_Actor(): myHighlightProp->SetAmbientColor(1, 1, 1); myHighlightProp->SetDiffuseColor(1, 1, 1); myHighlightProp->SetSpecularColor(0.5, 0.5, 0.5); + myHighlightProp->SetPointSize(SALOME_POINT_SIZE); myHighlightActor->SetProperty(myHighlightProp.GetPointer()); this->myHighlightActor->SetInput(myAppendFilter->GetOutput(),false); @@ -134,13 +147,13 @@ GEOM_Actor::GEOM_Actor(): aProperty->SetPointSize(3); aProperty->SetColor(1, 1, 0); - myAppendFilter->AddInput(myIsolatedEdgeSource->GetOutput()); + myAppendFilter->AddInput(myIsolatedEdgeSource->GetOutput()); myIsolatedEdgeActor->SetInput(myIsolatedEdgeSource->GetOutput(),false); aProperty = myIsolatedEdgeActor->GetProperty(); aProperty->SetRepresentation(VTK_WIREFRAME); aProperty->SetColor(1, 0, 0); - myAppendFilter->AddInput(myOneFaceEdgeSource->GetOutput()); + myAppendFilter->AddInput(myOneFaceEdgeSource->GetOutput()); myOneFaceEdgeActor->SetInput(myOneFaceEdgeSource->GetOutput(),false); aProperty = myOneFaceEdgeActor->GetProperty(); aProperty->SetRepresentation(VTK_WIREFRAME); @@ -160,7 +173,7 @@ GEOM_Actor::GEOM_Actor(): myShadingFaceActor->SetInput(myShadingFaceSource->GetOutput(),true); - myShadingFaceProp->SetRepresentation(VTK_SURFACE); + myShadingFaceProp->SetRepresentation(VTKViewer::Representation::Surface); myShadingFaceProp->SetInterpolationToGouraud(); myShadingFaceProp->SetAmbient(1.0); myShadingFaceProp->SetDiffuse(1.0); @@ -171,20 +184,26 @@ GEOM_Actor::GEOM_Actor(): myShadingFaceActor->SetProperty(myShadingFaceProp.GetPointer()); + StoreBoundaryColors(); + + myNbIsos[0] = -1; + myNbIsos[1] = -1; + // Toggle display mode setDisplayMode(0); // WIRE FRAME - + SetVectorMode(0); // } GEOM_Actor::~GEOM_Actor() { #ifdef MYDEBUG - cout <Delete(); myPreHighlightProp->Delete(); myShadingFaceProp->Delete(); + myShadingBackFaceProp->Delete(); } GEOM_Actor* @@ -199,7 +218,7 @@ New() void Write(vtkPolyData* theDataSet, const char* theFileName){ vtkPolyDataWriter* aWriter = vtkPolyDataWriter::New(); - cout<<"Write - "<GetNumberOfPoints()<<"; "<GetNumberOfCells()<GetNumberOfPoints()<<"; "<GetNumberOfCells()); aWriter->SetInput(theDataSet); aWriter->SetFileName(theFileName); //aWriter->Write(); @@ -275,8 +294,45 @@ GEOM_Actor:: setDisplayMode(int theMode) { #ifdef MYDEBUG - cout << "GEOM_Actor::SetDisplayMode = "<myHighlightActor->GetProperty()->DeepCopy(Prop); @@ -488,25 +491,37 @@ void GEOM_Actor::SetHighlightProperty(vtkProperty* Prop) void GEOM_Actor::SetWireframeProperty(vtkProperty* Prop) { #ifdef MYDEBUG - cout << this << " GEOM_Actor::SetWireframeProperty"<SetProperty(Prop); } + +vtkProperty* GEOM_Actor::GetWireframeProperty() +{ + return myWireframeFaceActor->GetProperty(); +} + void GEOM_Actor::SetShadingProperty(vtkProperty* Prop) { #ifdef MYDEBUG - cout << "GEOM_Actor::SetShadingProperty"<DeepCopy(Prop); } +vtkProperty* GEOM_Actor::GetShadingProperty() +{ + return myShadingFaceProp; +} + + void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *theMapper) { #ifdef MYDEBUG - cout << "GEOM_Actor::Render"<SetRepresentationToWireframe(); myHighlightProp->SetRepresentationToWireframe(); break; - case 1://shading + case eShading://shading + case eShadingWithEdges://shading with edges myPreHighlightProp->SetRepresentationToSurface(); myHighlightProp->SetRepresentationToSurface(); break; @@ -539,14 +555,17 @@ void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *theMapper) if(myIsPreselected){ this->myHighlightActor->SetProperty(myPreHighlightProp.GetPointer()); myShadingFaceActor->SetProperty(myPreHighlightProp.GetPointer()); + myShadingFaceActor->SetBackfaceProperty(myPreHighlightProp.GetPointer()); } else { this->myHighlightActor->SetProperty(myShadingFaceProp.GetPointer()); myShadingFaceActor->SetProperty(myShadingFaceProp.GetPointer()); + myShadingFaceActor->SetBackfaceProperty(myShadingBackFaceProp.GetPointer()); } } else{ this->myHighlightActor->SetProperty(myHighlightProp.GetPointer()); myShadingFaceActor->SetProperty(myHighlightProp.GetPointer()); + myShadingFaceActor->SetBackfaceProperty(myHighlightProp.GetPointer()); } this->Property->Render(this, ren); @@ -555,7 +574,7 @@ void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *theMapper) this->Device->SetBackfaceProperty(this->BackfaceProperty); } this->Device->SetProperty(this->Property); - if(myShape.ShapeType() == TopAbs_VERTEX) { + /* if(myShape.ShapeType() == TopAbs_VERTEX) { if(ren){ //The parameter determine size of vertex actor relate to diagonal of RendererWindow static vtkFloatingPointType delta = 0.01; @@ -571,15 +590,14 @@ void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *theMapper) this->Device->SetUserMatrix(aMatrix); this->Device->Render(ren,theMapper); aMatrix->Delete(); - } else + } else*/ this->Device->Render(ren, theMapper); - } void GEOM_Actor::ReleaseGraphicsResources(vtkWindow *) { #ifdef MYDEBUG - cout << "GEOM_Actor::ReleaseGraphicsResources"<SetShape(f->getTopo(),f->GetDeflection(),f->GetIsRelative()); + this->SetShape(f->getTopo(),f->GetDeflection()); } // Now do superclass @@ -602,7 +620,7 @@ void GEOM_Actor::ShallowCopy(vtkProp *prop) const TopoDS_Shape& GEOM_Actor::getTopo() { #ifdef MYDEBUG - cout << "GEOM_Actor::getTopo"<getEntry() << endl; +// int nbio = mySelector->IObjectCount(); +// cout << " nbio = " << nbio << endl; + if( !mySelector->IsSelected( myIO ) ) { - SetPreSelected( true ); + // printf ("!!!!!!!!!!!!!!!!\n"); + SetPreSelected( true ); } } default: @@ -755,12 +892,12 @@ GEOM_Actor bool GEOM_Actor ::Highlight(vtkInteractorStyle *theInteractorStyle, - SVTK_SelectionEvent* theSelectionEvent, - bool theIsHighlight) + SVTK_SelectionEvent* theSelectionEvent, + bool theIsHighlight) { // define the selection of object #ifdef MYDEBUG - cout << endl << this << " GEOM_Actor::Highlight (3) myIsSelected="<