ParaView
pqSignalAdaptorCompositeTreeWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: pqSignalAdaptorCompositeTreeWidget.h
5 
6  Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
7  All rights reserved.
8 
9  ParaView is a free software; you can redistribute it and/or modify it
10  under the terms of the ParaView license version 1.2.
11 
12  See License_v1.2.txt for the full ParaView license.
13  A copy of this license can be obtained by contacting
14  Kitware Inc.
15  28 Corporate Drive
16  Clifton Park, NY 12065
17  USA
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
23 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 ========================================================================*/
32 #ifndef pqSignalAdaptorCompositeTreeWidget_h
33 #define pqSignalAdaptorCompositeTreeWidget_h
34 
35 #include "pqComponentsModule.h"
36 #include <QObject>
37 #include <QVariant>
38 
39 
40 class pqTreeWidgetItem;
41 class QTreeWidget;
42 class QTreeWidgetItem;
43 class vtkPVDataInformation;
44 class vtkSMIntVectorProperty;
45 class vtkSMOutputPort;
46 class vtkSMSourceProxy;
47 
53 class PQCOMPONENTS_EXPORT pqSignalAdaptorCompositeTreeWidget : public QObject
54 {
55  Q_OBJECT
56  typedef QObject Superclass;
57 
58  Q_PROPERTY(QList<QVariant> values READ values WRITE setValues)
59 public:
61  {
63  INDEX_MODE_LEVEL_INDEX, // this mode works only for 1 level deep trees.
64  INDEX_MODE_LEVEL, // this mode works only for 1 level deep trees.
65  };
66 
67 
76  pqSignalAdaptorCompositeTreeWidget(QTreeWidget*, vtkSMIntVectorProperty* smproperty,
77  bool autoUpdateWidgetVisibility=false,
78  bool showSelectedElementCounts=false);
79 
95  pqSignalAdaptorCompositeTreeWidget(QTreeWidget*, vtkSMOutputPort* outputport,
96  int domainMode,
97  IndexModes indexMode=INDEX_MODE_FLAT,
98  bool selectMultiple=false,
99  bool autoUpdateWidgetVisibility=false,
100  bool showSelectedElementCounts=false);
101 
104 
107  QList<QVariant> values() const;
108 
112  { this->AutoUpdateWidgetVisibility = val; }
114  { return this->AutoUpdateWidgetVisibility; }
115 
117  void select(unsigned int flatIndex);
118 
121  unsigned int getCurrentFlatIndex(bool* valid=NULL);
122 
125  QString blockName(const QTreeWidgetItem* item) const;
126 
129  unsigned int hierarchicalLevel(const QTreeWidgetItem* item) const;
130 
133  unsigned int hierarchicalBlockIndex(const QTreeWidgetItem* item) const;
134 
137  unsigned int flatIndex(const QTreeWidgetItem* item) const;
138 
139 public slots:
141  void setValues(const QList<QVariant>& values);
142 
144  void domainChanged();
145 
148  void portInformationChanged();
149 
150 signals:
152  void valuesChanged();
153 
154 private slots:
155 
158  void updateSelectionCounts();
159 
160 private:
161  Q_DISABLE_COPY(pqSignalAdaptorCompositeTreeWidget)
162 
163 
164  void setupSelectionUpdatedCallback(vtkSMSourceProxy* source, unsigned int port);
166 
167  void buildTree(pqTreeWidgetItem* item,
168  vtkPVDataInformation* info);
169 
171  void updateItemFlags();
172 
173  class pqInternal;
174  pqInternal* Internal;
175 
176  enum MetaData
177  {
178  FLAT_INDEX = Qt::UserRole,
179  AMR_LEVEL_NUMBER = Qt::UserRole+1,
180  AMR_BLOCK_INDEX = Qt::UserRole+2,
181  NODE_TYPE = Qt::UserRole+3,
182  ORIGINAL_LABEL = Qt::UserRole+4,
183  BLOCK_NAME = Qt::UserRole+5
184  };
185 
186  enum NodeTypes
187  {
188  LEAF = 21,
189  NON_LEAF = 22,
190  };
191 
192  enum CheckModes
193  {
194  SINGLE_ITEM,
195  MULTIPLE_ITEMS
196  };
197 
198  IndexModes IndexMode;
199 
200  // Determines if the widget should allow checking only 1 item at a time or
201  // multiple items should be check-able.
202  CheckModes CheckMode;
203 
204  // These are used by buildTree() to determin indices for the nodes.
205  unsigned int FlatIndex;
206  unsigned int LevelNo;
207 
208  bool AutoUpdateWidgetVisibility;
209 
210  bool ShowFlatIndex;
211 
212  bool ShowSelectedElementCounts;
213 
214  // When set to true, all pieces within a multipiece are shown.
215  bool ShowDatasetsInMultiPiece;
216 
218  void constructor(QTreeWidget* tree, bool autoUpdateVisibility);
219 
222  void updateCheckState(pqTreeWidgetItem* item, int column);
223 
224  friend class pqCallbackAdaptor;
225  class pqCallbackAdaptor;
226  pqCallbackAdaptor* CallbackAdaptor;
227 };
228 
229 #endif
230 
231 
void setAutoUpdateWidgetVisibility(bool val)
When set, the adaptor will update the visibility of the widget depending on whether the data is compo...
pqSignalAdaptorCompositeTreeWidget is used to connect a property with vtkSMCompositeTreeDomain as its...
pqTreeWidgetItem is a QTreeWidgetItem with callbacks for whenever the data for the pqTreeWidgetItem c...