0023634: Eliminate Polyline and Polygon usage in drawers
[occt.git] / src / QABugs / QABugs_PresentableObject.cxx
CommitLineData
b311480e 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
7fd59977 20
21
1cd84fee 22#include <QABugs_PresentableObject.ixx>
23#include <QABugs_PresentableObject.hxx>
7fd59977 24
25#include <Graphic3d_Group.hxx>
26#include <Graphic3d_MaterialAspect.hxx>
27#include <Prs3d_ShadingAspect.hxx>
28#include <Graphic3d_AspectFillArea3d.hxx>
2bd4c032 29#include <Graphic3d_ArrayOfTriangles.hxx>
30#include <gp_Dir.hxx>
31#include <gp_Pnt.hxx>
7fd59977 32#include <AIS_Drawer.hxx>
33
2bd4c032 34QABugs_PresentableObject::QABugs_PresentableObject(const PrsMgr_TypeOfPresentation3d theTypeOfPresentation3d)
35 :AIS_InteractiveObject(theTypeOfPresentation3d)
7fd59977 36{
37}
38
2bd4c032 39void QABugs_PresentableObject::Compute(const Handle(PrsMgr_PresentationManager3d)& ,
40 const Handle(Prs3d_Presentation)& thePrs,
41 const Standard_Integer theMode)
7fd59977 42{
2bd4c032 43 Handle(Graphic3d_Structure) aStructure = Handle(Graphic3d_Structure)::DownCast (thePrs);
44 Handle(Graphic3d_Group) aGroup = new Graphic3d_Group (aStructure);
45 Handle_Prs3d_ShadingAspect anAspect = myDrawer->ShadingAspect();
46 Graphic3d_MaterialAspect aMat = anAspect->Aspect()->FrontMaterial();
47 aMat.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
48 aMat.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
49 aMat.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
50 aMat.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
51 anAspect->SetMaterial (aMat);
52 aGroup->SetPrimitivesAspect (anAspect->Aspect());
7fd59977 53
2bd4c032 54 Handle(Graphic3d_ArrayOfTriangles) aPrims
55 = new Graphic3d_ArrayOfTriangles (6, 0,
56 theMode == 1, // normals
57 Standard_True); // color per vertex
58 switch (theMode)
59 {
60 case 0:
7fd59977 61 {
2bd4c032 62 aPrims->AddVertex (gp_Pnt (0.0, 0.0, 0.0), Quantity_Color (Quantity_NOC_RED));
63 aPrims->AddVertex (gp_Pnt (0.0, 5.0, 1.0), Quantity_Color (Quantity_NOC_BLUE1));
64 aPrims->AddVertex (gp_Pnt (5.0, 0.0, 1.0), Quantity_Color (Quantity_NOC_YELLOW));
7fd59977 65
2bd4c032 66 aPrims->AddVertex (gp_Pnt (0.0, 5.0, 1.0), Quantity_Color (Quantity_NOC_BLUE1));
67 aPrims->AddVertex (gp_Pnt (5.0, 5.0, -1.0), Quantity_Color (Quantity_NOC_GREEN));
68 aPrims->AddVertex (gp_Pnt (5.0, 0.0, 1.0), Quantity_Color (Quantity_NOC_YELLOW));
7fd59977 69 break;
70 }
2bd4c032 71 case 1:
72 {
73 aPrims->AddVertex (gp_Pnt ( 5.0, 0.0, 0.0), gp_Dir (0.0, 0.0, 1.0), Quantity_Color (Quantity_NOC_RED));
74 aPrims->AddVertex (gp_Pnt ( 5.0, 5.0, 1.0), gp_Dir (1.0, 1.0, 1.0), Quantity_Color (Quantity_NOC_BLUE1));
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 aPrims->AddVertex (gp_Pnt ( 5.0, 5.0, 1.0), gp_Dir (1.0, 1.0, 1.0), Quantity_Color (Quantity_NOC_BLUE1));
78 aPrims->AddVertex (gp_Pnt (10.0, 5.0, -1.0), gp_Dir (0.0, 0.0, -1.0), Quantity_Color (Quantity_NOC_GREEN));
79 aPrims->AddVertex (gp_Pnt (10.0, 0.0, 1.0), gp_Dir (0.0, 1.0, 1.0), Quantity_Color (Quantity_NOC_YELLOW));
80 }
81 break;
82 }
83
2bd4c032 84 aGroup->AddPrimitiveArray (aPrims);
7fd59977 85}
86
2bd4c032 87void QABugs_PresentableObject::ComputeSelection(const Handle(SelectMgr_Selection)& ,
88 const Standard_Integer ) {
7fd59977 89}