a1d7710137bb8a4ddea915cbcea3d41e2de4b89a
[occt.git] / src / StdSelect / StdSelect_Shape.cxx
1 // Created on: 1998-03-27
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <StdSelect_Shape.hxx>
18
19 #include <Prs3d_Drawer.hxx>
20 #include <Prs3d_Presentation.hxx>
21 #include <Standard_Type.hxx>
22 #include <StdPrs_WFShape.hxx>
23 #include <StdPrs_ShadedShape.hxx>
24 #include <TopAbs_ShapeEnum.hxx>
25 #include <TopoDS_Shape.hxx>
26
27 IMPLEMENT_STANDARD_RTTIEXT(StdSelect_Shape,PrsMgr_PresentableObject)
28
29 StdSelect_Shape::StdSelect_Shape (const TopoDS_Shape& theShape,
30                                   const Handle(Prs3d_Drawer)& theDrawer)
31 : mysh (theShape)
32 {
33   if (!theDrawer.IsNull())
34   {
35     myDrawer->SetLink (theDrawer);
36   }
37 }
38
39 void StdSelect_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*PM*/,
40                               const Handle(Prs3d_Presentation)& P,
41                               const Standard_Integer aMode)
42 {
43   if(mysh.IsNull())
44   {
45     return;
46   }
47
48   Standard_Boolean CanShade = (mysh.ShapeType()<5 || mysh.ShapeType()==8);
49   if(aMode==1){
50     if(CanShade)
51       StdPrs_ShadedShape::Add (P, mysh, myDrawer);
52     else
53       StdPrs_WFShape::Add (P, mysh, myDrawer);
54   }
55   else if (aMode==0)
56     StdPrs_WFShape::Add (P, mysh, myDrawer);
57 }
58
59 void StdSelect_Shape::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
60 {
61   OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
62
63   OCCT_DUMP_BASE_CLASS (theOStream, theDepth, PrsMgr_PresentableObject)
64
65   OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &mysh)
66 }