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>
26 // =======================================================================
27 // function : Constructor
29 // =======================================================================
30 DFBrowserPane_TPrsStdAISPresentation::DFBrowserPane_TPrsStdAISPresentation()
31 : DFBrowserPane_AttributePane()
33 getPaneModel()->SetColumnCount (2);
35 QList<QVariant> theValues;
36 theValues << "Method" << "Value";
37 getPaneModel()->SetHeaderValues (theValues, Qt::Horizontal);
40 // =======================================================================
41 // function : toString
43 // =======================================================================
44 QString toString (const Quantity_NameOfColor& theNameOfColor)
46 Quantity_Color aColor(theNameOfColor);
47 return QString ("(%1, %2, %3)").arg (aColor.Red()).arg (aColor.Green()).arg (aColor.Blue());
50 // =======================================================================
51 // function : GetValues
53 // =======================================================================
54 void DFBrowserPane_TPrsStdAISPresentation::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
56 Handle(TPrsStd_AISPresentation) anAttribute = Handle(TPrsStd_AISPresentation)::DownCast (theAttribute);
57 if (anAttribute.IsNull())
59 Handle(AIS_InteractiveObject) anIO = anAttribute->GetAIS();
60 theValues << "GetDriverGUID" << ""//DFBrowserPane_Tools::ToString (anAttribute->GetDriverGUID())
61 << "GetAIS" << (anIO.IsNull() ? "Null" : anAttribute->DynamicType()->Name())
62 << "IsDisplayed" << DFBrowserPane_Tools::BoolToStr (anAttribute->IsDisplayed())
63 << "GetContext()" << (!anIO->GetContext().IsNull() ?
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()) : "");
81 // =======================================================================
82 // function : GetPresentation
84 // =======================================================================
85 Handle(Standard_Transient) DFBrowserPane_TPrsStdAISPresentation::GetPresentation (
86 const Handle(TDF_Attribute)& theAttribute)
88 Handle(Standard_Transient) aPresentation;
90 Handle(TPrsStd_AISPresentation) anAttribute = Handle(TPrsStd_AISPresentation)::DownCast (theAttribute);
91 if (!anAttribute.IsNull())
92 aPresentation = anAttribute->GetAIS();