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 vtkPVSession;
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(vtkPVSession* 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 
367  void sourceRenamed();
368 
369 private Q_SLOTS:
370  void onInsituConnectionInitiated(pqServer* server);
371 
372  void serverDataChanged();
373 
377  void updateVisibility(pqPipelineSource*, ItemType type = Proxy);
378 
383  void delayedUpdateVisibility(pqPipelineSource*);
384  void delayedUpdateVisibilityTimeout();
385 
389  void updateData(pqServerManagerModelItem*, ItemType type = Proxy);
390  void updateDataServer(pqServer* server);
391 
392 private: // NOLINT(readability-redundant-access-specifiers)
393  friend class pqPipelineModelDataItem;
394 
395  // Add an item as a child under the parent at the given index.
396  // Note that this method does not actually change the underlying
397  // pqServerManagerModel, it merely signals that such an addition
398  // has taken place.
399  void addChild(pqPipelineModelDataItem* parent, pqPipelineModelDataItem* child);
400 
401  // Remove a child item from under the parent.
402  // Note that this method does not actually change the underlying
403  // pqServerManagerModel, it merely signals that such an addition
404  // has taken place.
405  void removeChildFromParent(pqPipelineModelDataItem* child);
406 
407  // Returns the pqPipelineModelDataItem for the given pqServerManagerModelItem.
408  pqPipelineModelDataItem* getDataItem(pqServerManagerModelItem* item,
409  pqPipelineModelDataItem* subtreeRoot, ItemType type = Invalid) const;
410 
411  // called by pqPipelineModelDataItem to indicate that the data for the item
412  // may have changed.
413  void itemDataChanged(pqPipelineModelDataItem*);
417  void setSubtreeSelectable(pqPipelineModelDataItem* item, bool selectable);
418 
419  QModelIndex getIndex(pqPipelineModelDataItem* item) const;
420 
428  bool checkAndLoadPipelinePixmap(const QString& iconType);
429 
430  pqPipelineModelInternal* Internal;
431  QMap<QString, QPixmap> PixmapMap;
432  QPointer<pqView> View;
433  bool Editable;
434  bool FilterAnnotationMatching;
435  QString FilterRoleAnnotationKey;
436  vtkPVSession* FilterRoleSession;
437  ModifiedLiveInsituLink* LinkCallback;
438  void constructor();
439 
440  friend class ModifiedLiveInsituLink;
441 };
442 
443 #endif
data
void setEditable(bool editable)
Sets whether or not the model indexes are editable.
type
pqView * view() const
Provides access to the view.
pqServerManagerModelItem is a element maintained by pqServerManagerModel.
vtkPVSession defines a session i.e.
Definition: vtkPVSession.h:25
This is a PQ abstraction of a generic view module.
Definition: pqView.h:26
bool isEditable() const
Gets whether or not the model indexes are editable.
This class is the model for the PipelineLine browser tree view.
source
pqServerManagerModel is the model for the Server Manager.
PQ representation for a vtkSMProxy that can be involved in a pipeline.
index
pqProxy subclass for extractors
Definition: pqExtractor.h:21
pqServer (should be renamed to pqSession) is a pqServerManagerModelItem subclass that represents a vt...
Definition: pqServer.h:37