0029025: TInspector include files are not installed to inc directory by CMake
[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 #ifdef _MSC_VER
24 #pragma warning(disable : 4127) // conditional expression is constant
25 #endif
26
27 #include <QVariant>
28 #include <QWidget>
29 #include <QGridLayout>
30
31 // =======================================================================
32 // function : CreateWidget
33 // purpose :
34 // =======================================================================
35 QWidget* DFBrowserPane_TDataStdBooleanArray::CreateWidget (QWidget* theParent)
36 {
37   QWidget* aMainWidget = new QWidget (theParent);
38   myTableView = new DFBrowserPane_TableView (aMainWidget);
39   myTableView->SetModel (getPaneModel());
40
41   myArrayTableHelper.CreateWidget (aMainWidget, myTableView);
42
43   return aMainWidget;
44 }
45
46 // =======================================================================
47 // function : Init
48 // purpose :
49 // =======================================================================
50 void DFBrowserPane_TDataStdBooleanArray::Init (const Handle(TDF_Attribute)& theAttribute)
51 {
52   QList<QVariant> aValues;
53   GetValues (theAttribute, aValues);
54   myArrayTableHelper.Init (aValues);
55 }
56
57 // =======================================================================
58 // function : GetValues
59 // purpose :
60 // =======================================================================
61 void DFBrowserPane_TDataStdBooleanArray::GetValues (const Handle(TDF_Attribute)& theAttribute,
62                                                     QList<QVariant>& theValues)
63 {
64   Handle(TDataStd_BooleanArray) anAttribute = Handle(TDataStd_BooleanArray)::DownCast (theAttribute);
65   if (!anAttribute.IsNull())
66   {
67     theValues.append (anAttribute->Lower());
68     theValues.append (anAttribute->Upper());
69     for (int aValuesId = anAttribute->Lower(); aValuesId <= anAttribute->Upper(); aValuesId++)
70       theValues.append (anAttribute->Value (aValuesId));
71   }
72 }
73
74 // =======================================================================
75 // function : GetShortAttributeInfo
76 // purpose :
77 // =======================================================================
78 void DFBrowserPane_TDataStdBooleanArray::GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
79                                                                 QList<QVariant>& theValues)
80 {
81   QList<QVariant> aValues;
82   GetValues (theAttribute, aValues);
83   myArrayTableHelper.Init (aValues);
84   return myArrayTableHelper.GetShortAttributeInfo (theAttribute, theValues);
85 }