ParaView
pqMultiBlockInspectorPanel.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: pqMultiBlockInspectorPanel.h
5 
6  Copyright (c) Kitware, Inc.
7  All rights reserved.
8  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
16 #ifndef pqMultiBlockInspectorPanel_h
17 #define pqMultiBlockInspectorPanel_h
18 
19 #include "pqComponentsModule.h"
20 
21 #include "pqTimer.h" // needed for pqTimer.
22 #include <QIcon>
23 #include <QMap>
24 #include <QPointer>
25 #include <QWidget>
26 
27 #include <iostream>
28 
29 class QModelIndex;
30 class QTreeWidget;
31 class QTreeWidgetItem;
32 
33 class pqOutputPort;
34 class pqRepresentation;
35 class vtkDiscretizableColorTransferFunction;
36 class vtkEventQtSlotConnect;
37 class vtkPiecewiseFunction;
39 class vtkSMProxy;
40 
41 class PQCOMPONENTS_EXPORT pqMultiBlockInspectorPanel : public QWidget
42 {
43  Q_OBJECT
44 
45 public:
46  pqMultiBlockInspectorPanel(QWidget* parent = 0);
48 
49  pqOutputPort* getOutputPort() const;
50  pqRepresentation* getRepresentation() const;
51 
52  QString lookupBlockName(unsigned int flatIndex) const;
53 
54 public slots:
58  void onPortChanged(pqOutputPort* port);
59  void onRepresentationChanged(pqRepresentation* representation);
60  void onDataUpdated();
61 
62  void setBlockVisibility(unsigned int index, bool visible);
63  void clearBlockVisibility(unsigned int index);
64  void setBlockVisibility(const QList<unsigned int>& indices, bool visible);
65  void clearBlockVisibility(const QList<unsigned int>& indices);
66 
67  void setBlockColor(unsigned int index, const QColor& color);
68  void clearBlockColor(unsigned int index);
69  void setBlockColor(const QList<unsigned int>& indices, const QColor& color);
70  void clearBlockColor(const QList<unsigned int>& indices);
71 
72  void setBlockOpacity(unsigned int index, double opacity);
73  void clearBlockOpacity(unsigned int index);
74  void setBlockOpacity(const QList<unsigned int>& indices, double opacity);
75  void clearBlockOpacity(const QList<unsigned int>& indices);
76 
77  void promptAndSetBlockOpacity(unsigned int index);
78  void promptAndSetBlockOpacity(const QList<unsigned int>& indices);
79 
80  void showOnlyBlock(unsigned int index);
81  void showOnlyBlocks(const QList<unsigned int>& indices);
82  void showAllBlocks();
83 
84 private slots:
88  void onSelectionChanged(pqOutputPort* port);
89  void onColorArrayNameModified();
90 
91  void onCustomContextMenuRequested(const QPoint& pos);
92  void onItemChanged(QTreeWidgetItem* item, int column);
93  void updateTree();
94  void updateTree(vtkPVCompositeDataInformation* iter, QTreeWidgetItem* parent, int& flatIndex,
95  bool visibility, int inheritedColorIndex, int inheritedOpacityIndex);
96  void onItemSelectionChanged();
97  void onItemDoubleClicked(QTreeWidgetItem* item, int column);
98  void updateBlockVisibilities();
99  void updateBlockColors();
100  void updateBlockOpacities();
101 
102 private:
103  Q_DISABLE_COPY(pqMultiBlockInspectorPanel)
104 
105  enum NodeType
106  {
107  INTERNAL_NODE,
108  LEAF_NODE
109  };
110 
111  void buildTree(vtkPVCompositeDataInformation* iter, QTreeWidgetItem* parent,
112  int& flatIndex, // composite-data id
113  int& leafIndex); // leaf-only index.
114  void unsetChildVisibilities(QTreeWidgetItem* parent);
115  QIcon makeColorIcon(
116  int flatIndex, NodeType nodeType, int inheritedColorIndex, int leafIndex = -1) const;
117  QIcon makeOpacityIcon(int flatIndex, NodeType nodeType, int inheritedOpacityIndex) const;
118  QIcon makeNullIcon() const;
119 
120 private:
121  QTreeWidget* TreeWidget;
122  QPointer<pqOutputPort> OutputPort;
123  QPointer<pqRepresentation> Representation;
124  QMap<unsigned int, bool> BlockVisibilites;
125  QMap<unsigned int, QColor> BlockColors;
126  QMap<unsigned int, double> BlockOpacities;
127  vtkEventQtSlotConnect* PropertyListener;
128  vtkSMProxy* ColorTransferProxy;
129  vtkDiscretizableColorTransferFunction* ColorTransferFunction;
130  vtkPiecewiseFunction* OpacityTransferFunction;
131  unsigned int BlockColorsDistinctValues;
132  int CompositeWrap;
133 
134  pqTimer UpdateUITimer;
135 
136  struct BlockIcon
137  {
138  bool HasColor;
139  bool HasOpacity;
140  QColor Color;
141  double Opacity;
142 
143  bool operator<(const BlockIcon& other) const
144  {
145  QColor c = this->HasColor ? this->Color : QColor();
146  c.setAlphaF(this->HasOpacity ? this->Opacity : 1.0);
147 
148  QColor oc = other.HasColor ? other.Color : QColor();
149  oc.setAlphaF(other.HasOpacity ? other.Opacity : 1.0);
150 
151  return c.rgba() < oc.rgba();
152  }
153  };
154 };
155 
156 #endif // pqMultiBlockInspectorPanel_h
pqOutputPort is a server manager model item for an output port of any pqPipelineSource item...
Definition: pqOutputPort.h:57
Light object for holding composite data information.
This is PQ representation for a single representation.
proxy for a VTK object(s) on a server
Definition: vtkSMProxy.h:152