pqPipelineModel.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: pqPipelineModel.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 =========================================================================*/
51 #ifndef pqPipelineModel_h
52 #define pqPipelineModel_h
53 
54 #include "pqComponentsModule.h" // For export macro
55 #include "pqView.h" // For View
56 
57 #include <QAbstractItemModel>
58 #include <QMap> // For PixmapMap
59 #include <QPointer> // For View
60 
61 class ModifiedLiveInsituLink;
62 class QFont;
63 class QPixmap;
64 class QString;
65 class pqExtractor;
66 class pqPipelineModelDataItem;
67 class pqPipelineModelInternal;
68 class pqPipelineSource;
69 class pqServer;
72 class vtkSession;
73 
83 class PQCOMPONENTS_EXPORT pqPipelineModel : public QAbstractItemModel
84 {
85  Q_OBJECT;
86 
87 public:
88  enum ItemType
89  {
90  Invalid = -1,
91  Server = 0,
95  Link
96  };
97 
98  enum ItemRole
99  {
100  AnnotationFilterRole = 33,
101  SessionFilterRole = 34
102  };
103 
104 public:
105  pqPipelineModel(QObject* parent = 0);
106 
113  pqPipelineModel(const pqPipelineModel& other, QObject* parent = 0);
114 
121  pqPipelineModel(const pqServerManagerModel& other, QObject* parent = 0);
122 
123  ~pqPipelineModel() override;
124 
136  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
137 
145  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
146 
154  bool hasChildren(const QModelIndex& parent = QModelIndex()) const override;
155 
165  QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
166 
174  QModelIndex parent(const QModelIndex& index) const override;
175 
184  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
185 
191  bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
192 
203  Qt::ItemFlags flags(const QModelIndex& index) const override;
205 
210 
215  pqServerManagerModelItem* getItemFor(const QModelIndex&) const;
216 
217  QModelIndex getIndexFor(pqServerManagerModelItem* item) const;
218 
226  ItemType getTypeFor(const QModelIndex& index) const;
228 
235  bool isEditable() const { return this->Editable; }
236 
242  void setEditable(bool editable) { this->Editable = editable; }
243 
250  void setSelectable(const QModelIndex& index, bool selectable);
251 
259  bool isSelectable(const QModelIndex& index) const;
260 
267  void setSubtreeSelectable(pqServerManagerModelItem* item, bool selectable);
268 
278  QModelIndex getNextIndex(const QModelIndex index, const QModelIndex& root = QModelIndex()) const;
279 
283  pqView* view() const { return this->View; }
284 
290  void setModifiedFont(const QFont& font);
291 
299  void enableFilterAnnotationKey(const QString& expectedAnnotation);
300 
307  void disableFilterAnnotationKey();
308 
312  void setAnnotationFilterMatching(bool matching);
313 
321  void enableFilterSession(vtkSession* session);
322 
329  void disableFilterSession();
330 
331 public Q_SLOTS:
336  void addServer(pqServer* server);
337 
341  void removeServer(pqServer* server);
342 
346  void addSource(pqPipelineSource* source);
347 
351  void removeSource(pqPipelineSource* source);
352 
357  void addConnection(pqPipelineSource* source, pqPipelineSource* sink, int);
358 
363  void removeConnection(pqPipelineSource* source, pqPipelineSource* sink, int);
364 
366 
369  void addConnection(pqServerManagerModelItem* source, pqExtractor* sink);
370  void removeConnection(pqServerManagerModelItem* source, pqExtractor* sink);
372 
374 
377  void addExtractor(pqExtractor*);
378  void removeExtractor(pqExtractor*);
380 
387  void setView(pqView* module);
388 
389 Q_SIGNALS:
390  void firstChildAdded(const QModelIndex& index);
391 
392 private Q_SLOTS:
393  void onInsituConnectionInitiated(pqServer* server);
394 
395  void serverDataChanged();
396 
400  void updateVisibility(pqPipelineSource*, ItemType type = Proxy);
401 
406  void delayedUpdateVisibility(pqPipelineSource*);
407  void delayedUpdateVisibilityTimeout();
408 
412  void updateData(pqServerManagerModelItem*, ItemType type = Proxy);
413  void updateDataServer(pqServer* server);
414 
415 private:
416  friend class pqPipelineModelDataItem;
417 
418  // Add an item as a child under the parent at the given index.
419  // Note that this method does not actually change the underlying
420  // pqServerManagerModel, it merely signals that such an addition
421  // has taken place.
422  void addChild(pqPipelineModelDataItem* parent, pqPipelineModelDataItem* child);
423 
424  // Remove a child item from under the parent.
425  // Note that this method does not actually change the underlying
426  // pqServerManagerModel, it merely signals that such an addition
427  // has taken place.
428  void removeChildFromParent(pqPipelineModelDataItem* child);
429 
430  // Returns the pqPipelineModelDataItem for the given pqServerManagerModelItem.
431  pqPipelineModelDataItem* getDataItem(pqServerManagerModelItem* item,
432  pqPipelineModelDataItem* subtreeRoot, ItemType type = Invalid) const;
433 
434  // called by pqPipelineModelDataItem to indicate that the data for the item
435  // may have changed.
436  void itemDataChanged(pqPipelineModelDataItem*);
440  void setSubtreeSelectable(pqPipelineModelDataItem* item, bool selectable);
441 
442  QModelIndex getIndex(pqPipelineModelDataItem* item) const;
443 
451  bool checkAndLoadPipelinePixmap(const QString& iconType);
452 
453 private:
454  pqPipelineModelInternal* Internal;
455  QMap<QString, QPixmap> PixmapMap;
456  QPointer<pqView> View;
457  bool Editable;
458  bool FilterAnnotationMatching;
459  QString FilterRoleAnnotationKey;
460  vtkSession* FilterRoleSession;
461  ModifiedLiveInsituLink* LinkCallback;
462  void constructor();
463 
464  friend class ModifiedLiveInsituLink;
465 };
466 
467 #endif
data
void setEditable(bool editable)
Sets whether or not the model indexes are editable.
type
#define PQCOMPONENTS_EXPORT
pqView * view() const
Provides access to the view.
pqServerManagerModelItem is a element maintained by pqServerManagerModel.
This is a PQ abstraction of a generic view module.
Definition: pqView.h:54
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.
vtkSession defines a session i.e.
Definition: vtkSession.h:29
index
pqProxy subclass for extractors
Definition: pqExtractor.h:49
pqServer (should be renamed to pqSession) is a pqServerManagerModelItem subclass that represents a vt...
Definition: pqServer.h:64