1 // Created on: 2017-06-16
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2017 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <inspector/DFBrowserPaneXDE_XCAFDocColor.hxx>
17 #include <inspector/DFBrowserPane_AttributePaneModel.hxx>
19 #include <XCAFDoc_Color.hxx>
21 #include <Quantity_Color.hxx>
24 // =======================================================================
25 // function : Constructor
27 // =======================================================================
28 DFBrowserPaneXDE_XCAFDocColor::DFBrowserPaneXDE_XCAFDocColor()
29 : DFBrowserPane_AttributePane()
31 getPaneModel()->SetColumnCount (2);
34 // =======================================================================
35 // function : GetValues
37 // =======================================================================
38 void DFBrowserPaneXDE_XCAFDocColor::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
40 Handle(XCAFDoc_Color) anAttr = Handle(XCAFDoc_Color)::DownCast (theAttribute);
41 const Quantity_Color& aColor = anAttr->GetColor();
43 theValues << "Red" << aColor.Red();
44 theValues << "Green" << aColor.Green();
45 theValues << "Blue" << aColor.Blue();
47 theValues << "Quantity_NameOfColor (nearest)" << aColor.Name();
50 // =======================================================================
51 // function : GetShortAttributeInfo
53 // =======================================================================
54 void DFBrowserPaneXDE_XCAFDocColor::GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
55 QList<QVariant>& theValues)
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()));
62 // =======================================================================
63 // function : GetAttributeInfo
65 // =======================================================================
66 QVariant DFBrowserPaneXDE_XCAFDocColor::GetAttributeInfo (const Handle(TDF_Attribute)& theAttribute, int theRole, int theColumnId)
69 return DFBrowserPane_AttributePane::GetAttributeInfo (theAttribute, theRole, theColumnId);
73 case Qt::BackgroundRole:
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.));
81 return DFBrowserPane_AttributePane::GetAttributeInfo (theAttribute, theRole, theColumnId);