0029807: [Regression to 7.0.0] Impossible to cut cone from prism
[occt.git] / tools / DFBrowserPane / DFBrowserPane_TDataStdIntegerArray.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/DFBrowserPane_TDataStdIntegerArray.hxx>
17#include <inspector/DFBrowserPane_TableView.hxx>
18#include <inspector/DFBrowserPane_AttributePaneModel.hxx>
19#include <inspector/DFBrowserPane_HelperArray.hxx>
14bbbdcb 20
21#include <TDataStd_IntegerArray.hxx>
22
130eb114 23#include <Standard_WarningsDisable.hxx>
14bbbdcb 24#include <QVariant>
25#include <QWidget>
130eb114 26#include <Standard_WarningsRestore.hxx>
14bbbdcb 27
28// =======================================================================
29// function : CreateWidget
30// purpose :
31// =======================================================================
32QWidget* DFBrowserPane_TDataStdIntegerArray::CreateWidget (QWidget* theParent)
33{
34 QWidget* aMainWidget = new QWidget (theParent);
35 myTableView = new DFBrowserPane_TableView (aMainWidget);
36 myTableView->SetModel (getPaneModel());
37
38 myArrayTableHelper.CreateWidget (aMainWidget, myTableView);
39
40 return aMainWidget;
41}
42
43// =======================================================================
44// function : Init
45// purpose :
46// =======================================================================
47void DFBrowserPane_TDataStdIntegerArray::Init (const Handle(TDF_Attribute)& theAttribute)
48{
49 QList<QVariant> aValues;
50 GetValues (theAttribute, aValues);
51 myArrayTableHelper.Init (aValues);
52}
53
54// =======================================================================
55// function : GetValues
56// purpose :
57// =======================================================================
58void DFBrowserPane_TDataStdIntegerArray::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
59{
60 Handle(TDataStd_IntegerArray) anAttribute = Handle(TDataStd_IntegerArray)::DownCast (theAttribute);
61 if (anAttribute.IsNull())
62 return;
63
64 theValues.append (anAttribute->Lower());
65 theValues.append (anAttribute->Upper());
66 for (int aValueId = anAttribute->Lower(); aValueId <= anAttribute->Upper(); aValueId++)
67 theValues.append (anAttribute->Value(aValueId));
68}
69
70// =======================================================================
71// function : GetShortAttributeInfo
72// purpose :
73// =======================================================================
74void DFBrowserPane_TDataStdIntegerArray::GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
75 QList<QVariant>& theValues)
76{
77 QList<QVariant> aValues;
78 GetValues (theAttribute, aValues);
79 myArrayTableHelper.Init (aValues);
80 return myArrayTableHelper.GetShortAttributeInfo (theAttribute, theValues);
81}