geom/src/OBJECT/GEOM_Actor.h

276 lines
7.3 KiB
C
Raw Normal View History

2014-02-18 12:44:41 +06:00
// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
// 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
2014-02-18 12:44:41 +06:00
// version 2.1 of the License, or (at your option) any later version.
2003-07-09 20:44:57 +06:00
//
2012-08-09 13:58:02 +06:00
// 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.
2003-07-09 20:44:57 +06:00
//
2012-08-09 13:58:02 +06:00
// 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
2003-07-09 20:44:57 +06:00
//
2012-08-09 13:58:02 +06:00
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
2003-07-09 20:44:57 +06:00
//
2012-08-09 13:58:02 +06:00
2009-02-13 17:16:39 +05:00
// GEOM OBJECT : interactive object for Geometry entities visualization
2003-07-09 20:44:57 +06:00
// File : GEOM_Actor.h
// Author : Christophe ATTANASIO
// Module : GEOM
2009-02-13 17:16:39 +05:00
//
2003-05-12 21:09:12 +06:00
#ifndef GEOM_ACTOR_H
#define GEOM_ACTOR_H
#include "GEOM_OBJECT_defs.hxx"
2009-02-13 17:16:39 +05:00
#include "GEOM_SmartPtr.h"
2009-02-13 17:16:39 +05:00
#include <SALOME_Actor.h>
2003-05-12 21:09:12 +06:00
#include <TopoDS_Shape.hxx>
#include <vtkSmartPointer.h>
2003-05-12 21:09:12 +06:00
2009-02-13 17:16:39 +05:00
class vtkCamera;
class GEOM_VertexSource;
typedef GEOM_SmartPtr<GEOM_VertexSource> PVertexSource;
2003-05-12 21:09:12 +06:00
class GEOM_EdgeSource;
typedef GEOM_SmartPtr<GEOM_EdgeSource> PEdgeSource;
class GEOM_WireframeFace;
typedef GEOM_SmartPtr<GEOM_WireframeFace> PWFaceSource;
class GEOM_ShadingFace;
typedef GEOM_SmartPtr<GEOM_ShadingFace> PSFaceSource;
class vtkRenderer;
2003-05-12 21:09:12 +06:00
class vtkAppendPolyData;
typedef GEOM_SmartPtr<vtkAppendPolyData> PAppendFilter;
class GEOM_OBJECT_EXPORT GEOM_Actor: public SALOME_Actor
{
public:
vtkTypeMacro(GEOM_Actor,SALOME_Actor);
2003-05-12 21:09:12 +06:00
static GEOM_Actor* New();
void SetShape(const TopoDS_Shape& theShape,
2013-06-17 18:15:50 +06:00
float theDeflection,
bool theIsVector = false);
2012-08-09 13:58:02 +06:00
void SetDeflection(float theDeflection);
float GetDeflection() const{ return myDeflection;}
void AddToRender(vtkRenderer* theRenderer);
void RemoveFromRender(vtkRenderer* theRenderer);
2012-08-09 13:58:02 +06:00
enum EDisplayMode{ eWireframe, eShading, eShadingWithEdges = eShading + 2 };
/* void SetDisplayMode(EDisplayMode theMode); */
/* EDisplayMode GetDisplayMode() const { return myDisplayMode;} */
void SetSelected(bool theIsSelected);
bool IsSelected() const { return myIsSelected;}
// OLD METHODS
// Properties
void SetHighlightProperty(vtkProperty* Prop);
void SetWireframeProperty(vtkProperty* Prop);
void SetShadingProperty(vtkProperty* Prop);
2012-08-09 13:58:02 +06:00
vtkProperty* GetWireframeProperty();
vtkProperty* GetShadingProperty();
2013-02-12 17:35:16 +06:00
vtkProperty* GetIsolatedEdgeProperty();
vtkProperty* GetVertexProperty();
vtkProperty* GetSharedEdgeProperty();
vtkProperty* GetFaceEdgeProperty();
2012-08-09 13:58:02 +06:00
void setDeflection(double adef);
virtual void setDisplayMode(int thenewmode);
2003-05-12 21:09:12 +06:00
// Description:
// This causes the actor to be rendered. It, in turn, will render the actor's
// property and then mapper.
virtual void Render(vtkRenderer *, vtkMapper *);
// Description:
// Release any graphics resources that are being consumed by this actor.
// The parameter window could be used to determine which graphic
// resources to release.
void ReleaseGraphicsResources(vtkWindow *);
const TopoDS_Shape& getTopo();
void setInputShape(const TopoDS_Shape& ashape, double adef1,
2012-08-09 13:58:02 +06:00
int imode, bool isVector = false);
2003-05-12 21:09:12 +06:00
double getDeflection();
double isVector();
2003-05-12 21:09:12 +06:00
// SubShape
void SubShapeOn();
void SubShapeOff();
// Highlight
2004-12-01 15:39:14 +05:00
virtual void highlight(bool theHighlight);
virtual bool hasHighlight() { return true; }
2003-05-12 21:09:12 +06:00
void ShallowCopy(vtkProp *prop);
// Opacity
2013-03-01 19:10:52 +06:00
void SetOpacity(double opa);
double GetOpacity();
2003-05-12 21:09:12 +06:00
2013-02-12 17:35:16 +06:00
// Color (same to all sub-actors/display modes)
2013-03-01 19:10:52 +06:00
void SetColor(double r, double g, double b);
void GetColor(double& r, double& g, double& b);
2013-02-12 17:35:16 +06:00
// Color of points
2013-03-01 19:10:52 +06:00
void SetPointColor(double r, double g, double b);
2013-02-12 17:35:16 +06:00
// Color of standalone edges, wires, vectors
2013-03-01 19:10:52 +06:00
void SetIsolatedEdgeColor(double r, double g, double b);
2013-02-12 17:35:16 +06:00
// Color of shared edges
2013-03-01 19:10:52 +06:00
void SetSharedEdgeColor(double r, double g, double b);
2013-02-12 17:35:16 +06:00
// Color of free edges
2013-03-01 19:10:52 +06:00
void SetFreeEdgeColor(double r, double g, double b);
2013-02-12 17:35:16 +06:00
// Color of edges in shading+edges display mode
2013-03-01 19:10:52 +06:00
void SetEdgesInShadingColor(double r, double g, double b);
2013-02-12 17:35:16 +06:00
// Color of iso-lines
2013-03-01 19:10:52 +06:00
void SetIsosColor(double r, double g, double b);
2013-02-12 17:35:16 +06:00
2004-01-28 19:08:37 +05:00
2012-08-09 13:58:02 +06:00
// Material
void SetMaterial(std::vector<vtkProperty*> theProps);
2013-02-12 17:35:16 +06:00
vtkProperty* GetFrontMaterial();
vtkProperty* GetBackMaterial();
2009-02-13 17:16:39 +05:00
virtual bool IsInfinitive();
// overloaded functions
//! To map current selection to VTK representation
virtual
void
Highlight(bool theHighlight);
//----------------------------------------------------------------------------
//! To process prehighlight (called from #SVTK_InteractorStyle)
virtual
bool
PreHighlight(vtkInteractorStyle* theInteractorStyle,
2012-08-09 13:58:02 +06:00
SVTK_SelectionEvent* theSelectionEvent,
bool theIsHighlight);
//! To process highlight (called from #SVTK_InteractorStyle)
virtual
bool
Highlight(vtkInteractorStyle* theInteractorStyle,
2012-08-09 13:58:02 +06:00
SVTK_SelectionEvent* theSelectionEvent,
bool theIsHighlight);
//! Visibility management
virtual
void
SetVisibility( int );
//! IsoLines management
// theNb[0] - number of U lines
// theNb[1] - number of V lines
virtual
void
SetNbIsos(const int theNb[2]);
virtual
void
GetNbIsos(int &theNbU,int &theNbV);
2012-08-09 13:58:02 +06:00
virtual
void SetIsosWidth(const int width);
2012-08-09 13:58:02 +06:00
int GetIsosWidth() const;
virtual void SetWidth(const int width);
int GetWidth() const;
//! Vector mode management
virtual
void
SetVectorMode(const bool theMode);
virtual
bool
GetVectorMode();
//! Vertices mode management
virtual
void
SetVerticesMode(const bool theMode);
virtual
bool
GetVerticesMode();
2012-08-09 13:58:02 +06:00
protected:
void SetModified();
void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
2003-05-12 21:09:12 +06:00
GEOM_Actor();
~GEOM_Actor();
private:
TopoDS_Shape myShape;
2012-08-09 13:58:02 +06:00
bool isOnlyVertex;
2003-05-12 21:09:12 +06:00
float myDeflection;
bool myIsForced;
2003-05-12 21:09:12 +06:00
// EDisplayMode myDisplayMode;
bool myIsSelected;
2012-08-09 13:58:02 +06:00
bool myVectorMode;
bool myVerticesMode;
2003-05-12 21:09:12 +06:00
PDeviceActor myVertexActor;
PVertexSource myVertexSource;
2003-05-12 21:09:12 +06:00
PDeviceActor myIsolatedEdgeActor;
PEdgeSource myIsolatedEdgeSource;
2003-05-12 21:09:12 +06:00
PDeviceActor myOneFaceEdgeActor;
PEdgeSource myOneFaceEdgeSource;
2003-05-12 21:09:12 +06:00
PDeviceActor mySharedEdgeActor;
PEdgeSource mySharedEdgeSource;
2004-12-01 15:39:14 +05:00
PDeviceActor myWireframeFaceActor;
PWFaceSource myWireframeFaceSource;
2004-12-01 15:39:14 +05:00
PDeviceActor myShadingFaceActor;
PSFaceSource myShadingFaceSource;
PDeviceActor myHighlightActor;
vtkSmartPointer<vtkProperty> myHighlightProp;
vtkSmartPointer<vtkProperty> myPreHighlightProp;
vtkSmartPointer<vtkProperty> myShadingFaceProp;
2013-02-12 17:35:16 +06:00
vtkSmartPointer<vtkProperty> myShadingBackFaceProp;
2004-12-01 15:39:14 +05:00
PAppendFilter myAppendFilter;
2012-08-09 13:58:02 +06:00
PPolyGeomPainterDataMapper myPolyDataMapper;
virtual void SetMapper(vtkMapper*);
GEOM_Actor(const GEOM_Actor&);
void operator=(const GEOM_Actor&);
2012-08-09 13:58:02 +06:00
2013-03-01 19:10:52 +06:00
double myEdgesInWireframeColor[3];
double myEdgesInShadingColor[3];
double myIsolatedEdgeColor[3];
double mySharedEdgeColor[3];
double myOneFaceEdgeColor[3];
};
#endif //GEOM_ACTOR_H
2012-08-09 13:58:02 +06:00