3b210443a4eb0fed6125e24e2073067cd3ae08fd
[occt.git] / tools / DFBrowserPane / DFBrowserPane_TPrsStdAISPresentation.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/DFBrowserPane_TPrsStdAISPresentation.hxx>
17
18 #include <inspector/DFBrowserPane_AttributePaneModel.hxx>
19 #include <inspector/DFBrowserPane_Tools.hxx>
20
21 #include <TPrsStd_AISPresentation.hxx>
22
23 #include <Standard_WarningsDisable.hxx>
24 #include <QVariant>
25 #include <QWidget>
26 #include <Standard_WarningsRestore.hxx>
27
28 // =======================================================================
29 // function : Constructor
30 // purpose :
31 // =======================================================================
32 DFBrowserPane_TPrsStdAISPresentation::DFBrowserPane_TPrsStdAISPresentation()
33  : DFBrowserPane_AttributePane()
34 {
35 }
36
37 // =======================================================================
38 // function : toString
39 // purpose :
40 // =======================================================================
41 QString toString (const Quantity_NameOfColor& theNameOfColor)
42 {
43   Quantity_Color aColor(theNameOfColor);
44   return QString ("(%1, %2, %3)").arg (aColor.Red()).arg (aColor.Green()).arg (aColor.Blue());
45 }
46
47 // =======================================================================
48 // function : GetValues
49 // purpose :
50 // =======================================================================
51 void DFBrowserPane_TPrsStdAISPresentation::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
52 {
53   Handle(TPrsStd_AISPresentation) anAttribute = Handle(TPrsStd_AISPresentation)::DownCast (theAttribute);
54   if (anAttribute.IsNull())
55     return;
56   Handle(AIS_InteractiveObject) anIO = anAttribute->GetAIS();
57
58   char aStr[256];
59   anAttribute->GetDriverGUID().ToCString(aStr);
60   TCollection_AsciiString aString(aStr);
61
62   theValues << "GetDriverGUID" << DFBrowserPane_Tools::ToString (aString)
63             << "GetAIS" << (anIO.IsNull() ? "Null" : anAttribute->DynamicType()->Name())
64             << "IsDisplayed" << DFBrowserPane_Tools::BoolToStr (anAttribute->IsDisplayed())
65             << "GetContext()" << ((!anIO.IsNull() && !anIO->GetContext().IsNull()) ?
66                                  DFBrowserPane_Tools::GetPointerInfo (anIO->GetContext()).ToCString() : "")
67             << "HasOwnMaterial" << DFBrowserPane_Tools::BoolToStr (anAttribute->HasOwnMaterial())
68             << "Material" << (anAttribute->HasOwnMaterial() ?
69                              DFBrowserPane_Tools::ToName (DB_MATERIAL_TYPE, anAttribute->Material()) : "").ToCString()
70             << "Transparency" << TCollection_AsciiString (anAttribute->Transparency()).ToCString()
71             << "HasOwnColor" << DFBrowserPane_Tools::BoolToStr (anAttribute->HasOwnColor())
72             << "Color" << (anAttribute->HasOwnColor() ? toString (anAttribute->Color()) : "")
73             << "HasOwnWidth"<< DFBrowserPane_Tools::BoolToStr (anAttribute->HasOwnWidth())
74             << "Width"<< (anAttribute->HasOwnWidth() ? QString::number (anAttribute->Width()) : "")
75             << "HasOwnMode"<< DFBrowserPane_Tools::BoolToStr (anAttribute->HasOwnMode())
76             << "Width"<< (anAttribute->HasOwnMode() ? DFBrowserPane_Tools::ToName (
77                           DB_DISPLAY_MODE, anAttribute->Mode()) : "").ToCString()
78             << "HasOwnSelectionMode" << DFBrowserPane_Tools::BoolToStr (anAttribute->HasOwnSelectionMode())
79             << "SelectionMode" << (anAttribute->HasOwnSelectionMode() ?
80                                    QString::number (anAttribute->SelectionMode()) : "");
81 }
82
83 // =======================================================================
84 // function : GetPresentation
85 // purpose :
86 // =======================================================================
87 Handle(Standard_Transient) DFBrowserPane_TPrsStdAISPresentation::GetPresentation (
88                                                     const Handle(TDF_Attribute)& theAttribute)
89 {
90   Handle(Standard_Transient) aPresentation;
91
92   Handle(TPrsStd_AISPresentation) anAttribute = Handle(TPrsStd_AISPresentation)::DownCast (theAttribute);
93   if (!anAttribute.IsNull())
94     aPresentation = anAttribute->GetAIS();
95
96   return aPresentation;
97 }