0029025: TInspector include files are not installed to inc directory by CMake
[occt.git] / tools / DFBrowserPaneXDE / DFBrowserPaneXDE_XCAFDocColor.cxx
1 // Created on: 2017-06-16
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2017 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 #include <inspector/DFBrowserPaneXDE_XCAFDocColor.hxx>
17 #include <inspector/DFBrowserPane_AttributePaneModel.hxx>
18
19 #include <XCAFDoc_Color.hxx>
20
21 #include <Quantity_Color.hxx>
22
23 #include <QColor>
24 // =======================================================================
25 // function : Constructor
26 // purpose :
27 // =======================================================================
28 DFBrowserPaneXDE_XCAFDocColor::DFBrowserPaneXDE_XCAFDocColor()
29 : DFBrowserPane_AttributePane()
30 {
31   getPaneModel()->SetColumnCount (2);
32 }
33
34 // =======================================================================
35 // function : GetValues
36 // purpose :
37 // =======================================================================
38 void DFBrowserPaneXDE_XCAFDocColor::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
39 {
40   Handle(XCAFDoc_Color) anAttr = Handle(XCAFDoc_Color)::DownCast (theAttribute);
41   const Quantity_Color& aColor = anAttr->GetColor();
42
43   theValues << "Red" << aColor.Red();
44   theValues << "Green" << aColor.Green();
45   theValues << "Blue" << aColor.Blue();
46
47   theValues << "Quantity_NameOfColor (nearest)" << aColor.Name();
48 }
49
50 // =======================================================================
51 // function : GetShortAttributeInfo
52 // purpose :
53 // =======================================================================
54 void DFBrowserPaneXDE_XCAFDocColor::GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
55                                                            QList<QVariant>& theValues)
56 {
57   Handle(XCAFDoc_Color) anAttr = Handle(XCAFDoc_Color)::DownCast (theAttribute);
58   const Quantity_Color& aColor = anAttr->GetColor();
59   theValues.append (QString ("(%1, %2, %3)").arg (aColor.Red()).arg (aColor.Green()).arg (aColor.Blue()));
60 }
61
62 // =======================================================================
63 // function : GetAttributeInfo
64 // purpose :
65 // =======================================================================
66 QVariant DFBrowserPaneXDE_XCAFDocColor::GetAttributeInfo (const Handle(TDF_Attribute)& theAttribute, int theRole, int theColumnId)
67 {
68   if (theColumnId != 0)
69     return DFBrowserPane_AttributePane::GetAttributeInfo (theAttribute, theRole, theColumnId);
70
71   switch (theRole)
72   {
73     case Qt::BackgroundRole:
74     {
75       const Quantity_Color& aColor = Handle(XCAFDoc_Color)::DownCast (theAttribute)->GetColor();
76       return QColor ((int)(aColor.Red()*255.), (int)(aColor.Green()*255.), (int)(aColor.Blue()*255.));
77     }
78     default:
79     break;
80   }
81   return DFBrowserPane_AttributePane::GetAttributeInfo (theAttribute, theRole, theColumnId);
82 }