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