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