1 // Created on: 2020-02-10
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2020 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/VInspector_ItemV3dViewer.hxx>
19 #include <AIS_InteractiveContext.hxx>
20 #include <inspector/VInspector_ItemContext.hxx>
21 #include <inspector/VInspector_ItemContextProperties.hxx>
23 // =======================================================================
24 // function : initRowCount
26 // =======================================================================
27 int VInspector_ItemV3dViewer::initRowCount() const
32 // =======================================================================
33 // function : initValue
35 // =======================================================================
36 QVariant VInspector_ItemV3dViewer::initValue (const int theItemRole) const
38 QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
39 if (aParentValue.isValid())
42 if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
45 if (GetViewer().IsNull())
46 return Column() == 0 ? "Empty viewer" : "";
48 return Column() == 0 ? GetViewer()->DynamicType()->Name() : QVariant();
51 // =======================================================================
54 // =======================================================================
55 void VInspector_ItemV3dViewer::Init()
57 VInspector_ItemContextPropertiesPtr aParentItem = itemDynamicCast<VInspector_ItemContextProperties>(Parent());
58 Handle(V3d_Viewer) aViewer;
61 VInspector_ItemContextPtr aParentContextItem = itemDynamicCast<VInspector_ItemContext>(aParentItem->Parent());
62 if (aParentContextItem)
64 Handle(AIS_InteractiveContext) aContext = aParentContextItem->GetContext();
65 aViewer = aContext->CurrentViewer();
69 TreeModel_ItemBase::Init();
72 // =======================================================================
75 // =======================================================================
76 void VInspector_ItemV3dViewer::Reset()
78 VInspector_ItemBase::Reset();
83 // =======================================================================
84 // function : initItem
86 // =======================================================================
87 void VInspector_ItemV3dViewer::initItem() const
91 const_cast<VInspector_ItemV3dViewer*>(this)->Init();
94 // =======================================================================
95 // function : initStream
97 // =======================================================================
98 void VInspector_ItemV3dViewer::initStream (Standard_OStream& theOStream) const
100 Handle(V3d_Viewer) aViewer = GetViewer();
101 if (aViewer.IsNull())
104 aViewer->DumpJson (theOStream);