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/DFBrowserPane_TPrsStdAISPresentation.hxx>
18 #include <inspector/DFBrowserPane_AttributePaneModel.hxx>
19 #include <inspector/DFBrowserPane_Tools.hxx>
21 #include <TPrsStd_AISPresentation.hxx>
23 #include <Standard_WarningsDisable.hxx>
26 #include <Standard_WarningsRestore.hxx>
28 // =======================================================================
29 // function : Constructor
31 // =======================================================================
32 DFBrowserPane_TPrsStdAISPresentation::DFBrowserPane_TPrsStdAISPresentation()
33 : DFBrowserPane_AttributePane()
37 // =======================================================================
38 // function : toString
40 // =======================================================================
41 QString toString (const Quantity_NameOfColor& theNameOfColor)
43 Quantity_Color aColor(theNameOfColor);
44 return QString ("(%1, %2, %3)").arg (aColor.Red()).arg (aColor.Green()).arg (aColor.Blue());
47 // =======================================================================
48 // function : GetValues
50 // =======================================================================
51 void DFBrowserPane_TPrsStdAISPresentation::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
53 Handle(TPrsStd_AISPresentation) anAttribute = Handle(TPrsStd_AISPresentation)::DownCast (theAttribute);
54 if (anAttribute.IsNull())
56 Handle(AIS_InteractiveObject) anIO = anAttribute->GetAIS();
59 anAttribute->GetDriverGUID().ToCString(aStr);
60 TCollection_AsciiString aString(aStr);
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 Standard_Dump::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()) : "");
83 // =======================================================================
84 // function : GetPresentation
86 // =======================================================================
87 Handle(Standard_Transient) DFBrowserPane_TPrsStdAISPresentation::GetPresentation (
88 const Handle(TDF_Attribute)& theAttribute)
90 Handle(Standard_Transient) aPresentation;
92 Handle(TPrsStd_AISPresentation) anAttribute = Handle(TPrsStd_AISPresentation)::DownCast (theAttribute);
93 if (!anAttribute.IsNull())
94 aPresentation = anAttribute->GetAIS();