pqPipelineModel.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
23 #ifndef pqPipelineModel_h
24 #define pqPipelineModel_h
25 
26 #include "pqComponentsModule.h" // For export macro
27 #include "pqView.h" // For View
28 
29 #include <QAbstractItemModel>
30 #include <QMap> // For PixmapMap
31 #include <QPointer> // For View
32 
33 class ModifiedLiveInsituLink;
34 class QFont;
35 class QPixmap;
36 class QString;
37 class pqExtractor;
38 class pqPipelineModelDataItem;
39 class pqPipelineModelInternal;
40 class pqPipelineSource;
41 class pqServer;
44 class vtkSession;
45 
55 class PQCOMPONENTS_EXPORT pqPipelineModel : public QAbstractItemModel
56 {
57  Q_OBJECT;
58 
59 public:
60  enum ItemType
61  {
62  Invalid = -1,
63  Server = 0,
67  Link
68  };
69 
70  enum ItemRole
71  {
72  AnnotationFilterRole = 33,
73  SessionFilterRole = 34
74  };
75 
76  pqPipelineModel(QObject* parent = nullptr);
77 
84  pqPipelineModel(const pqPipelineModel& other, QObject* parent = nullptr);
85 
92  pqPipelineModel(const pqServerManagerModel& other, QObject* parent = nullptr);
93 
94  ~pqPipelineModel() override;
95 
99 
107  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
108 
116  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
117 
125  bool hasChildren(const QModelIndex& parent = QModelIndex()) const override;
126 
136  QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
137 
145  QModelIndex parent(const QModelIndex& index) const override;
146 
155  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
156 
162  bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
163 
174  Qt::ItemFlags flags(const QModelIndex& index) const override;
176 
180 
186  pqServerManagerModelItem* getItemFor(const QModelIndex&) const;
187 
188  QModelIndex getIndexFor(pqServerManagerModelItem* item) const;
189 
197  ItemType getTypeFor(const QModelIndex& index) const;
199 
206  bool isEditable() const { return this->Editable; }
207 
213  void setEditable(bool editable) { this->Editable = editable; }
214 
221  void setSelectable(const QModelIndex& index, bool selectable);
222 
230  bool isSelectable(const QModelIndex& index) const;
231 
238  void setSubtreeSelectable(pqServerManagerModelItem* item, bool selectable);
239 
249  QModelIndex getNextIndex(QModelIndex index, const QModelIndex& root = QModelIndex()) const;
250 
254  pqView* view() const { return this->View; }
255 
261  void setModifiedFont(const QFont& font);
262 
270  void enableFilterAnnotationKey(const QString& expectedAnnotation);
271 
278  void disableFilterAnnotationKey();
279 
283  void setAnnotationFilterMatching(bool matching);
284 
292  void enableFilterSession(vtkSession* session);
293 
300  void disableFilterSession();
301 
302 public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
307  void addServer(pqServer* server);
308 
312  void removeServer(pqServer* server);
313 
317  void addSource(pqPipelineSource* source);
318 
322  void removeSource(pqPipelineSource* source);
323 
328  void addConnection(pqPipelineSource* source, pqPipelineSource* sink, int);
329 
334  void removeConnection(pqPipelineSource* source, pqPipelineSource* sink, int);
335 
337 
340  void addConnection(pqServerManagerModelItem* source, pqExtractor* sink);
341  void removeConnection(pqServerManagerModelItem* source, pqExtractor* sink);
343 
345 
348  void addExtractor(pqExtractor*);
349  void removeExtractor(pqExtractor*);
351 
358  void setView(pqView* module);
359 
360 Q_SIGNALS:
361  void firstChildAdded(const QModelIndex& index);
362  void childWithChildrenAdded(const QModelIndex& index);
363 
364 private Q_SLOTS:
365  void onInsituConnectionInitiated(pqServer* server);
366 
367  void serverDataChanged();
368 
372  void updateVisibility(pqPipelineSource*, ItemType type = Proxy);
373 
378  void delayedUpdateVisibility(pqPipelineSource*);
379  void delayedUpdateVisibilityTimeout();
380 
384  void updateData(pqServerManagerModelItem*, ItemType type = Proxy);
385  void updateDataServer(pqServer* server);
386 
387 private: // NOLINT(readability-redundant-access-specifiers)
388  friend class pqPipelineModelDataItem;
389 
390  // Add an item as a child under the parent at the given index.
391  // Note that this method does not actually change the underlying
392  // pqServerManagerModel, it merely signals that such an addition
393  // has taken place.
394  void addChild(pqPipelineModelDataItem* parent, pqPipelineModelDataItem* child);
395 
396  // Remove a child item from under the parent.
397  // Note that this method does not actually change the underlying
398  // pqServerManagerModel, it merely signals that such an addition
399  // has taken place.
400  void removeChildFromParent(pqPipelineModelDataItem* child);
401 
402  // Returns the pqPipelineModelDataItem for the given pqServerManagerModelItem.
403  pqPipelineModelDataItem* getDataItem(pqServerManagerModelItem* item,
404  pqPipelineModelDataItem* subtreeRoot, ItemType type = Invalid) const;
405 
406  // called by pqPipelineModelDataItem to indicate that the data for the item
407  // may have changed.
408  void itemDataChanged(pqPipelineModelDataItem*);
412  void setSubtreeSelectable(pqPipelineModelDataItem* item, bool selectable);
413 
414  QModelIndex getIndex(pqPipelineModelDataItem* item) const;
415 
423  bool checkAndLoadPipelinePixmap(const QString& iconType);
424 
425  pqPipelineModelInternal* Internal;
426  QMap<QString, QPixmap> PixmapMap;
427  QPointer<pqView> View;
428  bool Editable;
429  bool FilterAnnotationMatching;
430  QString FilterRoleAnnotationKey;
431  vtkSession* FilterRoleSession;
432  ModifiedLiveInsituLink* LinkCallback;
433  void constructor();
434 
435  friend class ModifiedLiveInsituLink;
436 };
437 
438 #endif
pqServerManagerModel
pqServerManagerModel is the model for the Server Manager.
Definition: pqServerManagerModel.h:52
data
data
pqView
This is a PQ abstraction of a generic view module.
Definition: pqView.h:26
pqPipelineModel::ItemType
ItemType
Definition: pqPipelineModel.h:60
pqExtractor
pqProxy subclass for extractors
Definition: pqExtractor.h:21
vtkSession
Definition: vtkSession.h:17
pqPipelineModel::view
pqView * view() const
Provides access to the view.
Definition: pqPipelineModel.h:254
pqPipelineModel::ItemRole
ItemRole
Definition: pqPipelineModel.h:70
pqPipelineModel::Port
@ Port
Definition: pqPipelineModel.h:65
pqServer
pqServer (should be renamed to pqSession) is a pqServerManagerModelItem subclass that represents a vt...
Definition: pqServer.h:35
pqPipelineModel
This class is the model for the PipelineLine browser tree view.
Definition: pqPipelineModel.h:55
pqPipelineModel::isEditable
bool isEditable() const
Gets whether or not the model indexes are editable.
Definition: pqPipelineModel.h:206
pqPipelineModel::setEditable
void setEditable(bool editable)
Sets whether or not the model indexes are editable.
Definition: pqPipelineModel.h:213
pqPipelineSource
PQ representation for a vtkSMProxy that can be involved in a pipeline.
Definition: pqPipelineSource.h:32
pqPipelineModel::Extractor
@ Extractor
Definition: pqPipelineModel.h:66
pqServerManagerModelItem
pqServerManagerModelItem is a element maintained by pqServerManagerModel.
Definition: pqServerManagerModelItem.h:19
pqPipelineModel::Proxy
@ Proxy
Definition: pqPipelineModel.h:64
pqView.h
index
index