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 pqPipelineModelDataItem;
66 class pqPipelineModelInternal;
67 class pqPipelineSource;
68 class pqServer;
71 class vtkSession;
72 
82 class PQCOMPONENTS_EXPORT pqPipelineModel : public QAbstractItemModel
83 {
84  Q_OBJECT;
85 
86 public:
87  enum ItemType
88  {
89  Invalid = -1,
90  Server = 0,
93  Link
94  };
95 
96  enum ItemRole
97  {
98  AnnotationFilterRole = 33,
99  SessionFilterRole = 34
100  };
101 
102 public:
103  pqPipelineModel(QObject* parent = 0);
104 
111  pqPipelineModel(const pqPipelineModel& other, QObject* parent = 0);
112 
119  pqPipelineModel(const pqServerManagerModel& other, QObject* parent = 0);
120 
121  ~pqPipelineModel() override;
122 
134  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
135 
143  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
144 
152  bool hasChildren(const QModelIndex& parent = QModelIndex()) const override;
153 
163  QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
164 
172  QModelIndex parent(const QModelIndex& index) const override;
173 
182  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
183 
189  bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
190 
201  Qt::ItemFlags flags(const QModelIndex& index) const override;
203 
208 
213  pqServerManagerModelItem* getItemFor(const QModelIndex&) const;
214 
215  QModelIndex getIndexFor(pqServerManagerModelItem* item) const;
216 
224  ItemType getTypeFor(const QModelIndex& index) const;
226 
233  bool isEditable() const { return this->Editable; }
234 
240  void setEditable(bool editable) { this->Editable = editable; }
241 
248  void setSelectable(const QModelIndex& index, bool selectable);
249 
257  bool isSelectable(const QModelIndex& index) const;
258 
265  void setSubtreeSelectable(pqServerManagerModelItem* item, bool selectable);
266 
276  QModelIndex getNextIndex(const QModelIndex index, const QModelIndex& root = QModelIndex()) const;
277 
281  pqView* view() const { return this->View; }
282 
288  void setModifiedFont(const QFont& font);
289 
297  void enableFilterAnnotationKey(const QString& expectedAnnotation);
298 
305  void disableFilterAnnotationKey();
306 
310  void setAnnotationFilterMatching(bool matching);
311 
319  void enableFilterSession(vtkSession* session);
320 
327  void disableFilterSession();
328 
329 public slots:
334  void addServer(pqServer* server);
335 
339  void removeServer(pqServer* server);
340 
344  void addSource(pqPipelineSource* source);
345 
349  void removeSource(pqPipelineSource* source);
350 
355  void addConnection(pqPipelineSource* source, pqPipelineSource* sink, int);
356 
361  void removeConnection(pqPipelineSource* source, pqPipelineSource* sink, int);
362 
369  void setView(pqView* module);
370 
371 signals:
372  void firstChildAdded(const QModelIndex& index);
373 
374 private slots:
375  void onInsituConnectionInitiated(pqServer* server);
376 
377  void serverDataChanged();
378 
382  void updateVisibility(pqPipelineSource*, ItemType type = Proxy);
383 
388  void delayedUpdateVisibility(pqPipelineSource*);
389  void delayedUpdateVisibilityTimeout();
390 
394  void updateData(pqServerManagerModelItem*, ItemType type = Proxy);
395  void updateDataServer(pqServer* server);
396 
397 private:
398  friend class pqPipelineModelDataItem;
399 
400  // Add an item as a child under the parent at the given index.
401  // Note that this method does not actually change the underlying
402  // pqServerManagerModel, it merely signals that such an addition
403  // has taken place.
404  void addChild(pqPipelineModelDataItem* parent, pqPipelineModelDataItem* child);
405 
406  // Remove a child item from under the parent.
407  // Note that this method does not actually change the underlying
408  // pqServerManagerModel, it merely signals that such an addition
409  // has taken place.
410  void removeChildFromParent(pqPipelineModelDataItem* child);
411 
412  // Returns the pqPipelineModelDataItem for the given pqServerManagerModelItem.
413  pqPipelineModelDataItem* getDataItem(pqServerManagerModelItem* item,
414  pqPipelineModelDataItem* subtreeRoot, ItemType type = Invalid) const;
415 
416  // called by pqPipelineModelDataItem to indicate that the data for the item
417  // may have changed.
418  void itemDataChanged(pqPipelineModelDataItem*);
422  void setSubtreeSelectable(pqPipelineModelDataItem* item, bool selectable);
423 
424  QModelIndex getIndex(pqPipelineModelDataItem* item) const;
425 
433  bool checkAndLoadPipelinePixmap(const QString& iconType);
434 
435 private:
436  pqPipelineModelInternal* Internal;
437  QMap<QString, QPixmap> PixmapMap;
438  QPointer<pqView> View;
439  bool Editable;
440  bool FilterAnnotationMatching;
441  QString FilterRoleAnnotationKey;
442  vtkSession* FilterRoleSession;
443  ModifiedLiveInsituLink* LinkCallback;
444  void constructor();
445 
446  friend class ModifiedLiveInsituLink;
447 };
448 
449 #endif
data
void setEditable(bool editable)
Sets whether or not the model indexes are editable.
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.
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
pqServer (should be renamed to pqSession) is a pqServerManagerModelItem subclass that represents a vt...
Definition: pqServer.h:64