0022972: Eliminate macro definitions that has compiler-provided analogs (WNT and...
[occt.git] / src / QABugs / QABugs_PresentableObject.cxx
1 // Created on: 2002-04-09
2 // Created by: QA Admin
3 // Copyright (c) 2002-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16
17 #include <gp_Dir.hxx>
18 #include <gp_Pnt.hxx>
19 #include <Graphic3d_ArrayOfTriangles.hxx>
20 #include <Graphic3d_AspectFillArea3d.hxx>
21 #include <Graphic3d_Group.hxx>
22 #include <Graphic3d_MaterialAspect.hxx>
23 #include <Graphic3d_Structure.hxx>
24 #include <Prs3d_Drawer.hxx>
25 #include <Prs3d_Presentation.hxx>
26 #include <Prs3d_ShadingAspect.hxx>
27 #include <QABugs_PresentableObject.hxx>
28 #include <Standard_Type.hxx>
29
30 QABugs_PresentableObject::QABugs_PresentableObject(const PrsMgr_TypeOfPresentation3d theTypeOfPresentation3d)
31      :AIS_InteractiveObject(theTypeOfPresentation3d)
32 {
33 }
34
35 void QABugs_PresentableObject::Compute(const Handle(PrsMgr_PresentationManager3d)& ,
36                                 const Handle(Prs3d_Presentation)& thePrs,
37                                 const Standard_Integer theMode)
38 {
39   Handle(Graphic3d_Structure) aStructure = Handle(Graphic3d_Structure)::DownCast (thePrs);
40   Handle(Graphic3d_Group)     aGroup     = aStructure->NewGroup();
41   Handle(Prs3d_ShadingAspect) anAspect = myDrawer->ShadingAspect();
42   Graphic3d_MaterialAspect aMat = anAspect->Aspect()->FrontMaterial();
43   aMat.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
44   aMat.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
45   aMat.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
46   aMat.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
47   anAspect->SetMaterial (aMat);
48   aGroup->SetPrimitivesAspect (anAspect->Aspect());
49
50   Handle(Graphic3d_ArrayOfTriangles) aPrims
51     = new Graphic3d_ArrayOfTriangles (6, 0,
52                                       theMode == 1,   // normals
53                                       Standard_True); // color per vertex
54   switch (theMode)
55   {
56     case 0:
57     {
58       aPrims->AddVertex (gp_Pnt (0.0,  0.0,  0.0), Quantity_Color (Quantity_NOC_RED));
59       aPrims->AddVertex (gp_Pnt (0.0,  5.0,  1.0), Quantity_Color (Quantity_NOC_BLUE1));
60       aPrims->AddVertex (gp_Pnt (5.0,  0.0,  1.0), Quantity_Color (Quantity_NOC_YELLOW));
61
62       aPrims->AddVertex (gp_Pnt (0.0,  5.0,  1.0), Quantity_Color (Quantity_NOC_BLUE1));
63       aPrims->AddVertex (gp_Pnt (5.0,  5.0, -1.0), Quantity_Color (Quantity_NOC_GREEN));
64       aPrims->AddVertex (gp_Pnt (5.0,  0.0,  1.0), Quantity_Color (Quantity_NOC_YELLOW));
65       break;
66     }
67     case 1:
68     {
69       aPrims->AddVertex (gp_Pnt ( 5.0, 0.0,  0.0), gp_Dir (0.0, 0.0,  1.0), Quantity_Color (Quantity_NOC_RED));
70       aPrims->AddVertex (gp_Pnt ( 5.0, 5.0,  1.0), gp_Dir (1.0, 1.0,  1.0), Quantity_Color (Quantity_NOC_BLUE1));
71       aPrims->AddVertex (gp_Pnt (10.0, 0.0,  1.0), gp_Dir (0.0, 1.0,  1.0), Quantity_Color (Quantity_NOC_YELLOW));
72
73       aPrims->AddVertex (gp_Pnt ( 5.0, 5.0,  1.0), gp_Dir (1.0, 1.0,  1.0), Quantity_Color (Quantity_NOC_BLUE1));
74       aPrims->AddVertex (gp_Pnt (10.0, 5.0, -1.0), gp_Dir (0.0, 0.0, -1.0), Quantity_Color (Quantity_NOC_GREEN));
75       aPrims->AddVertex (gp_Pnt (10.0, 0.0,  1.0), gp_Dir (0.0, 1.0,  1.0), Quantity_Color (Quantity_NOC_YELLOW));
76     }
77     break;
78   }
79
80   aGroup->AddPrimitiveArray (aPrims);
81 }
82
83 void QABugs_PresentableObject::ComputeSelection(const Handle(SelectMgr_Selection)& ,
84                                          const Standard_Integer ) {
85 }