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();
105 Graphic3d_MaterialAspect aMatAspect;
106 aMatAspect.SetAmbient( 1 );
107 aMatAspect.SetDiffuse( 0 );
108 aMatAspect.SetEmissive( 0 );
109 aMatAspect.SetShininess(1 );
110 aMatAspect.SetSpecular( 0 );
112 myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(aMatAspect);
113 myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(Graphic3d_NOM_JADE);
115 Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
116 Graphic3d_MaterialAspect BMat = myDrawer->ShadingAspect()->Aspect()->BackMaterial();
117 FMat.SetTransparency(myTransparency); BMat.SetTransparency(myTransparency);
118 myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat);
119 myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat);
121 //Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
122 // P->SetPrimitivesAspect(a4bis);
123 // G->SetGroupPrimitivesAspect(a4bis);
124 //a4bis->SetInteriorColor(myShadingColor);
125 myDrawer->ShadingAspect()->SetColor(myShadingColor);
127 StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
131 // aPrs->ReCompute(); // for hidden line recomputation if necessary...
134 void GEOM_AISShape::SetTransparency(const Standard_Real aValue)
136 if(aValue<0.0 || aValue>1.0) return;
144 Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
145 Graphic3d_MaterialAspect BMat = myDrawer->ShadingAspect()->Aspect()->BackMaterial();
146 FMat.SetTransparency(aValue); BMat.SetTransparency(aValue);
147 myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat);
148 myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat);
149 myTransparency = aValue;
152 void GEOM_AISShape::SetShadingColor(const Quantity_Color &aCol)
154 myShadingColor = aCol;