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 class pqTreeWidgetItem;
40 class QTreeWidget;
41 class QTreeWidgetItem;
44 class vtkSMOutputPort;
45 class vtkSMSourceProxy;
46 
54 class PQCOMPONENTS_EXPORT pqSignalAdaptorCompositeTreeWidget : public QObject
55 {
56  Q_OBJECT
57  typedef QObject Superclass;
58 
59  Q_PROPERTY(QList<QVariant> values READ values WRITE setValues)
60 public:
62  {
64  INDEX_MODE_LEVEL_INDEX, // this mode works only for 1 level deep trees.
65  INDEX_MODE_LEVEL, // this mode works only for 1 level deep trees.
66  };
67 
79  bool autoUpdateWidgetVisibility = false, bool showSelectedElementCounts = false);
80 
98  pqSignalAdaptorCompositeTreeWidget(QTreeWidget*, vtkSMOutputPort* outputport, int domainMode,
99  IndexModes indexMode = INDEX_MODE_FLAT, bool selectMultiple = false,
100  bool autoUpdateWidgetVisibility = false, bool showSelectedElementCounts = false);
101 
106 
111  QList<QVariant> values() const;
112 
117  void setAutoUpdateWidgetVisibility(bool val) { this->AutoUpdateWidgetVisibility = val; }
118  bool autoUpdateWidgetVisibility() const { return this->AutoUpdateWidgetVisibility; }
119 
123  void select(unsigned int flatIndex);
124 
129  unsigned int getCurrentFlatIndex(bool* valid = NULL);
130 
135  QString blockName(const QTreeWidgetItem* item) const;
136 
141  unsigned int hierarchicalLevel(const QTreeWidgetItem* item) const;
142 
147  unsigned int hierarchicalBlockIndex(const QTreeWidgetItem* item) const;
148 
153  unsigned int flatIndex(const QTreeWidgetItem* item) const;
154 
155 public slots:
159  void setValues(const QList<QVariant>& values);
160 
164  void domainChanged();
165 
170  void portInformationChanged();
171 
172 signals:
176  void valuesChanged();
177 
178 private slots:
179 
184  void updateSelectionCounts();
185 
186 private:
187  Q_DISABLE_COPY(pqSignalAdaptorCompositeTreeWidget)
188 
189 
193  void setupSelectionUpdatedCallback(vtkSMSourceProxy* source, unsigned int port);
194 
195  void buildTree(pqTreeWidgetItem* item, vtkPVDataInformation* info);
196 
200  void updateItemFlags();
201 
202  class pqInternal;
203  pqInternal* Internal;
204 
205  enum MetaData
206  {
207  FLAT_INDEX = Qt::UserRole,
208  AMR_LEVEL_NUMBER = Qt::UserRole + 1,
209  AMR_BLOCK_INDEX = Qt::UserRole + 2,
210  NODE_TYPE = Qt::UserRole + 3,
211  ORIGINAL_LABEL = Qt::UserRole + 4,
212  BLOCK_NAME = Qt::UserRole + 5
213  };
214 
215  enum NodeTypes
216  {
217  LEAF = 21,
218  NON_LEAF = 22,
219  };
220 
221  enum CheckModes
222  {
223  SINGLE_ITEM,
224  MULTIPLE_ITEMS
225  };
226 
227  IndexModes IndexMode;
228 
229  // Determines if the widget should allow checking only 1 item at a time or
230  // multiple items should be check-able.
231  CheckModes CheckMode;
232 
233  // These are used by buildTree() to determin indices for the nodes.
234  unsigned int FlatIndex;
235  unsigned int LevelNo;
236 
237  bool AutoUpdateWidgetVisibility;
238 
239  bool ShowFlatIndex;
240 
241  bool ShowSelectedElementCounts;
242 
243  // When set to true, all pieces within a multipiece are shown.
244  bool ShowDatasetsInMultiPiece;
245 
249  void constructor(QTreeWidget* tree, bool autoUpdateVisibility);
250 
255  void updateCheckState(pqTreeWidgetItem* item, int column);
256 
257  friend class pqCallbackAdaptor;
258  class pqCallbackAdaptor;
259  pqCallbackAdaptor* CallbackAdaptor;
260 };
261 
262 #endif
void setAutoUpdateWidgetVisibility(bool val)
When set, the adaptor will update the visibility of the widget depending on whether the data is compo...
Light object for holding data information.
pqSignalAdaptorCompositeTreeWidget is used to connect a property with vtkSMCompositeTreeDomain as its...
property representing a vector of integers
pqTreeWidgetItem is a QTreeWidgetItem with callbacks for whenever the data for the pqTreeWidgetItem c...
proxy for a VTK source on a server
reference for an output port of a vtkAlgorithm.