1 // GEOM OBJECT : interactive object for Geometry entities visualization
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : GEOM_AISShape.cxx
25 // Author : Nicolas REJNERI
31 \class GEOM_AISShape GEOM_AISShape.hxx
35 #include "GEOM_AISShape.ixx"
36 #include "SALOME_InteractiveObject.hxx"
38 #include "utilities.h"
40 // Open CASCADE Includes
41 #include <AIS_Drawer.hxx>
42 #include <Prs3d_Drawer.hxx>
43 #include <Prs3d_IsoAspect.hxx>
44 #include <Prs3d_LineAspect.hxx>
45 #include <Prs3d_ShadingAspect.hxx>
46 #include <StdSelect_DisplayMode.hxx>
47 #include <StdPrs_WFShape.hxx>
48 #include <StdPrs_ShadedShape.hxx>
50 #include <Graphic3d_AspectFillArea3d.hxx>
52 GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape,
53 const Standard_CString aName): SALOME_AISShape(shape)
56 myName = new char [strlen(aName)+1];
57 strcpy( myName, aName);
59 myShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD );
62 void GEOM_AISShape::setIO(const Handle(SALOME_InteractiveObject)& io){
66 Handle(SALOME_InteractiveObject) GEOM_AISShape::getIO(){
70 Standard_Boolean GEOM_AISShape::hasIO(){
71 return !( myIO == NULL ) ;
74 void GEOM_AISShape::setName(const Standard_CString aName)
76 myName = new char [strlen(aName)+1];
77 strcpy( myName, aName);
83 Standard_CString GEOM_AISShape::getName(){
87 void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
88 const Handle(Prs3d_Presentation)& aPrs,
89 const Standard_Integer aMode)
91 if (IsInfinite()) aPrs->SetInfiniteState(Standard_True); //pas de prise en compte lors du FITALL
93 StdSelect_DisplayMode d = (StdSelect_DisplayMode) aMode;
96 case StdSelect_DM_Wireframe:
98 StdPrs_WFShape::Add(aPrs,myshape,myDrawer);
101 case StdSelect_DM_Shading:
103 myDrawer->ShadingAspect()->Aspect()->SetDistinguishOn();
104 myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(Graphic3d_NOM_BRASS);
105 myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(Graphic3d_NOM_JADE);
107 Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
108 Graphic3d_MaterialAspect BMat = myDrawer->ShadingAspect()->Aspect()->BackMaterial();
109 FMat.SetTransparency(myTransparency); BMat.SetTransparency(myTransparency);
110 myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat);
111 myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat);
113 //Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
114 // P->SetPrimitivesAspect(a4bis);
115 // G->SetGroupPrimitivesAspect(a4bis);
116 //a4bis->SetInteriorColor(myShadingColor);
117 myDrawer->ShadingAspect()->SetColor(myShadingColor);
119 StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
123 // aPrs->ReCompute(); // for hidden line recomputation if necessary...
126 void GEOM_AISShape::SetTransparency(const Standard_Real aValue)
128 if(aValue<0.0 || aValue>1.0) return;
136 Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
137 Graphic3d_MaterialAspect BMat = myDrawer->ShadingAspect()->Aspect()->BackMaterial();
138 FMat.SetTransparency(aValue); BMat.SetTransparency(aValue);
139 myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat);
140 myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat);
141 myTransparency = aValue;
144 void GEOM_AISShape::SetShadingColor(const Quantity_Color &aCol)
146 myShadingColor = aCol;