0029695: Shape Healing - infinite loop in ShapeFix_IntersectionTool
[occt.git] / tools / VInspector / VInspector_ItemHistoryElement.cxx
CommitLineData
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/VInspector_ItemHistoryElement.hxx>
14bbbdcb 17
0cb512c0 18#include <inspector/VInspector_ItemHistoryRoot.hxx>
19#include <inspector/VInspector_ItemHistoryType.hxx>
20#include <inspector/VInspector_ItemHistoryElement.hxx>
21#include <inspector/VInspector_Tools.hxx>
14bbbdcb 22
23// =======================================================================
24// function : data
25// purpose :
26// =======================================================================
27QVariant VInspector_ItemHistoryElement::initValue(const int theRole) const
28{
29 if (theRole != Qt::DisplayRole && theRole != Qt::EditRole && theRole != Qt::ToolTipRole)
30 return QVariant();
31
32 switch (Column())
33 {
34 case 0: return getName();
35 case 1: return QVariant();
36 case 2: return GetPointerInfo();
37 case 3: return GetShapeTypeInfo();
38 default: break;
39 }
40 return QVariant();
41}
42
43// =======================================================================
44// function : Init
45// purpose :
46// =======================================================================
47void VInspector_ItemHistoryElement::Init()
48{
49 VInspector_ItemHistoryTypePtr aParentItem = itemDynamicCast<VInspector_ItemHistoryType>(Parent());
50 VInspector_ItemHistoryRootPtr aRootItem = itemDynamicCast<VInspector_ItemHistoryRoot>(aParentItem->Parent());
51
52 const VInspector_ItemHistoryTypeInfo& aTypeInfo = aRootItem->GetTypeInfo (aParentItem->Row());
53 QList<QList<QVariant>> anElements = aTypeInfo.myElements;
54
55 int aRowId = Row();
56 QList<QVariant> anInfo = anElements.at(aRowId);
57 int anInfoSize = anInfo.size();
58
59 myName = anInfoSize > 0 ? anInfo[0].toString() : QString ("Element: %1").arg (aRowId);
60 myPointerInfo = anInfoSize > 1 ? anInfo[1].toString() : QString();
61 myShapeTypeInfo = anInfoSize > 2 ? anInfo[2].toString() : QString();
62
63 TreeModel_ItemBase::Init();
64}
65
66// =======================================================================
67// function : initItem
68// purpose :
69// =======================================================================
70void VInspector_ItemHistoryElement::initItem() const
71{
72 if (IsInitialized())
73 return;
74 const_cast<VInspector_ItemHistoryElement*>(this)->Init();
75 // an empty method to don't initialize the main label, as it was not cleared in Reset()
76}
77
78// =======================================================================
79// function : getName
80// purpose :
81// =======================================================================
82QString VInspector_ItemHistoryElement::getName() const
83{
84 initItem();
85 return myName;
86}
87
88// =======================================================================
89// function : GetPointerInfo
90// purpose :
91// =======================================================================
92QString VInspector_ItemHistoryElement::GetPointerInfo() const
93{
94 initItem();
95 return myPointerInfo;
96}
97
98// =======================================================================
99// function : GetShapeTypeInfo
100// purpose :
101// =======================================================================
102QString VInspector_ItemHistoryElement::GetShapeTypeInfo() const
103{
104 initItem();
105 return myShapeTypeInfo;
106}