0023035: TKOpenGl redesign regression caused by destruction of global OpenGl_Display...
[occt.git] / src / QARoutelous / QARoutelous_PresentableObject.cxx
1 // Created on: 2002-04-09
2 // Created by: QA Admin
3 // Copyright (c) 2002-2012 OPEN CASCADE SAS
4 //
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
9 //
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 //
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
19
20
21
22 #include <QARoutelous_PresentableObject.ixx>
23 #include <QARoutelous_PresentableObject.hxx>
24
25 #include <Graphic3d_Group.hxx>
26 #include <Graphic3d_MaterialAspect.hxx>
27 #include <Prs3d_ShadingAspect.hxx>
28 #include <Graphic3d_AspectFillArea3d.hxx>
29 #include <Aspect_Array1OfEdge.hxx>
30 #include <Graphic3d_VertexC.hxx>
31 #include <Graphic3d_VertexNC.hxx>
32 #include <Graphic3d_Array1OfVertexC.hxx>
33 #include <Graphic3d_Array1OfVertexNC.hxx>
34 #include <AIS_Drawer.hxx>
35
36 QARoutelous_PresentableObject::QARoutelous_PresentableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
37      :AIS_InteractiveObject(aTypeOfPresentation3d)
38 {
39 }
40
41 void QARoutelous_PresentableObject::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
42                                 const Handle(Prs3d_Presentation)& aPresentation,
43                                 const Standard_Integer aMode )
44 {
45   Handle(Graphic3d_Structure) theStructure = Handle(Graphic3d_Structure)::DownCast(aPresentation);
46   Handle(Graphic3d_Group) theGroup= new  Graphic3d_Group(theStructure);
47   Handle_Prs3d_ShadingAspect theAspect = myDrawer->ShadingAspect();
48   Graphic3d_MaterialAspect mat = theAspect->Aspect()->FrontMaterial();
49   mat.SetReflectionModeOff(Graphic3d_TOR_AMBIENT);
50   mat.SetReflectionModeOff(Graphic3d_TOR_DIFFUSE);
51   mat.SetReflectionModeOff(Graphic3d_TOR_SPECULAR);
52   mat.SetReflectionModeOff(Graphic3d_TOR_EMISSION);
53   theAspect->SetMaterial(mat);
54   theGroup->SetPrimitivesAspect(theAspect->Aspect());
55   
56   Aspect_Array1OfEdge aListEdge(1, 3);
57   aListEdge.SetValue(1, Aspect_Edge(1, 2, Aspect_TOE_VISIBLE));
58   aListEdge.SetValue(2, Aspect_Edge(2, 3, Aspect_TOE_VISIBLE));
59   aListEdge.SetValue(3, Aspect_Edge(3, 1, Aspect_TOE_VISIBLE));
60   theGroup->BeginPrimitives();
61
62   switch (aMode) 
63     {
64     case 0://using VertexC
65       {
66         Graphic3d_Array1OfVertexC theArray1(1, 3);
67
68         theArray1.SetValue(1, Graphic3d_VertexC(0,0,0,Quantity_NOC_RED));
69         theArray1.SetValue(2, Graphic3d_VertexC(0,5,1,Quantity_NOC_BLUE1));
70         theArray1.SetValue(3, Graphic3d_VertexC(5,0,1,Quantity_NOC_YELLOW));
71         theGroup->TriangleSet(theArray1, aListEdge);
72         
73         theArray1.SetValue(1, Graphic3d_VertexC(0,5,1,Quantity_NOC_BLUE1));
74         theArray1.SetValue(2, Graphic3d_VertexC(5,5,-1,Quantity_NOC_GREEN));
75         theArray1.SetValue(3, Graphic3d_VertexC(5,0,1,Quantity_NOC_YELLOW));
76         theGroup->TriangleSet(theArray1, aListEdge);
77       }
78       break;
79     case 1://using VertexNC
80       {
81         Graphic3d_Array1OfVertexNC theArray1(1, 3);
82         
83         theArray1.SetValue(1, Graphic3d_VertexNC(5,0,0, //coord
84                                                  0,0,1, //normal
85                                                  Quantity_NOC_RED));
86         theArray1.SetValue(2, Graphic3d_VertexNC(5,5,1, //coord
87                                                  1,1,1, //normal
88                                                  Quantity_NOC_BLUE1));
89         theArray1.SetValue(3, Graphic3d_VertexNC(10,0,1, //coord
90                                                  0,1,1,  //normal
91                                                  Quantity_NOC_YELLOW));
92         theGroup->TriangleSet(theArray1, aListEdge);
93         
94         theArray1.SetValue(1, Graphic3d_VertexNC(5,5,1, //coord
95                                                  1,1,1, //normal
96                                                  Quantity_NOC_BLUE1));
97         theArray1.SetValue(2, Graphic3d_VertexNC(10,5,-1, //coord
98                                                  0,0,-1,  //normal
99                                                  Quantity_NOC_GREEN));
100         theArray1.SetValue(3, Graphic3d_VertexNC(10,0,1, //coord
101                                                  0,1,1,  //normal
102                                                  Quantity_NOC_YELLOW));
103         theGroup->TriangleSet(theArray1, aListEdge);
104       }
105       break;
106     }
107   theGroup->EndPrimitives();
108   
109 }
110
111 void QARoutelous_PresentableObject::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
112                                          const Standard_Integer aMode) {
113 }