0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / AIS / AIS_GraphicTool.cxx
CommitLineData
b311480e 1// Created on: 1997-02-10
2// Created by: Robert COUBLANC
3// Copyright (c) 1997-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
7fd59977 17
42cf5bc1 18#include <AIS_GraphicTool.hxx>
42cf5bc1 19#include <Aspect_InteriorStyle.hxx>
20#include <Graphic3d_AspectFillArea3d.hxx>
7fd59977 21#include <Graphic3d_AspectLine3d.hxx>
42cf5bc1 22#include <Graphic3d_MaterialAspect.hxx>
23#include <Prs3d_DatumAspect.hxx>
a6eb515f 24#include <Prs3d_DimensionAspect.hxx>
42cf5bc1 25#include <Prs3d_IsoAspect.hxx>
26#include <Prs3d_LineAspect.hxx>
7fd59977 27#include <Prs3d_PlaneAspect.hxx>
7fd59977 28#include <Prs3d_ShadingAspect.hxx>
42cf5bc1 29#include <Quantity_Color.hxx>
7fd59977 30
31static Handle(Prs3d_LineAspect) GetLineAspect(const Handle(Prs3d_Drawer)& Dr,
32 const AIS_TypeOfAttribute Att)
33{
7604a153 34 switch(Att)
35 {
7fd59977 36 case AIS_TOA_Line:
37 return Dr->LineAspect();
a6eb515f 38 case AIS_TOA_Dimension:
39 return Dr->DimensionAspect()->LineAspect();
7fd59977 40 case AIS_TOA_Wire:
41 return Dr->WireAspect();
7fd59977 42 case AIS_TOA_Plane:
43 return Dr->PlaneAspect()->EdgesAspect();
7fd59977 44 case AIS_TOA_Vector:
45 return Dr->VectorAspect();
7fd59977 46 case AIS_TOA_UIso:
5b111128 47 return Handle(Prs3d_LineAspect) (Dr->UIsoAspect());
7fd59977 48 case AIS_TOA_VIso:
5b111128 49 return Handle(Prs3d_LineAspect) (Dr->VIsoAspect());
7fd59977 50 case AIS_TOA_Free:
51 return Dr->FreeBoundaryAspect();
7fd59977 52 case AIS_TOA_UnFree:
53 return Dr->UnFreeBoundaryAspect();
7fd59977 54 case AIS_TOA_Section:
55 return Dr->SectionAspect();
7fd59977 56 case AIS_TOA_Hidden:
57 return Dr->HiddenLineAspect();
7fd59977 58 case AIS_TOA_Seen:
59 return Dr->SeenLineAspect();
7604a153 60 case AIS_TOA_FaceBoundary:
61 return Dr->FaceBoundaryAspect();
7fd59977 62 case AIS_TOA_FirstAxis:
bc001a40 63 return Dr->DatumAspect()->LineAspect(Prs3d_DP_XAxis);
7fd59977 64 case AIS_TOA_SecondAxis:
bc001a40 65 return Dr->DatumAspect()->LineAspect(Prs3d_DP_YAxis);
7fd59977 66 case AIS_TOA_ThirdAxis:
bc001a40 67 return Dr->DatumAspect()->LineAspect(Prs3d_DP_ZAxis);
7fd59977 68 }
69 Handle(Prs3d_LineAspect) bid;
70 return bid;
71}
72
73Quantity_NameOfColor AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att)
7fd59977 74{
75 Quantity_Color color;
76 GetLineColor(Dr,Att,color);
77 return color.Name();
78}
79
80void AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att, Quantity_Color &aColor)
7fd59977 81{
b6472664 82 aColor = GetLineAspect(Dr,Att)->Aspect()->Color();
7fd59977 83}
84
85Standard_Real AIS_GraphicTool::GetLineWidth (const Handle(Prs3d_Drawer)& Dr,
86 const AIS_TypeOfAttribute Att)
87{
7fd59977 88 Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
b6472664 89 return LA->Aspect()->Width();
7fd59977 90}
91Aspect_TypeOfLine AIS_GraphicTool::GetLineType (const Handle(Prs3d_Drawer)& Dr,
92 const AIS_TypeOfAttribute Att)
93{
7fd59977 94 Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
8c2d3314 95 return LA->Aspect()->Type();
7fd59977 96}
97
98
99void AIS_GraphicTool::GetLineAtt(const Handle(Prs3d_Drawer)& Dr,
100 const AIS_TypeOfAttribute Att,
101 Quantity_NameOfColor& Col,
102 Standard_Real& W,
103 Aspect_TypeOfLine& TYP)
104{
7fd59977 105 Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
b6472664 106 Col = LA->Aspect()->Color().Name();
107 W = LA->Aspect()->Width();
108 TYP = LA->Aspect()->Type();
7fd59977 109}
110
111Quantity_NameOfColor AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr)
7fd59977 112{
113 Quantity_Color color;
114 GetInteriorColor(Dr,color);
115 return color.Name();
116}
117
118void AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr, Quantity_Color &aColor)
7fd59977 119{
120 Handle(Graphic3d_AspectFillArea3d) AFA = Dr->ShadingAspect()->Aspect();
b6472664 121 aColor = AFA->InteriorColor();
7fd59977 122}
123
124Graphic3d_MaterialAspect AIS_GraphicTool::GetMaterial(const Handle(Prs3d_Drawer)& Dr)
125{
126 return Dr->ShadingAspect()->Aspect()->BackMaterial();
7fd59977 127}