ParaView
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 =========================================================================*/
32 
38 #ifndef _pqPipelineModel_h
39 #define _pqPipelineModel_h
40 
41 #include "pqComponentsModule.h"
42 
43 #include "pqView.h"
44 #include "vtkSmartPointer.h"
45 #include <QAbstractItemModel>
46 #include <QPointer>
47 
49 class pqPipelineModelFilter;
50 class pqPipelineModelInternal;
51 class pqPipelineModelItem;
52 class pqPipelineModelOutput;
53 class pqPipelineModelSource;
54 class pqPipelineSource;
55 class pqView;
56 class pqServer;
59 class QFont;
60 class QPixmap;
61 class ModifiedLiveInsituLink;
62 
82 class pqPipelineModelInternal;
84 class pqPipelineSource;
85 class pqServer;
86 class QPixmap;
87 class QString;
88 class pqPipelineModelDataItem;
89 class vtkSession;
90 
100 class PQCOMPONENTS_EXPORT pqPipelineModel : public QAbstractItemModel
101 {
102  Q_OBJECT;
103 
104 public:
105  enum ItemType
106  {
107  Invalid = -1,
108  Server = 0,
111  Link
112  };
113 
114  enum ItemRole
115  {
116  AnnotationFilterRole = 33,
117  SessionFilterRole = 34
118  };
119 
120 public:
121  pqPipelineModel(QObject* parent = 0);
122 
129  pqPipelineModel(const pqPipelineModel& other, QObject* parent = 0);
130 
137  pqPipelineModel(const pqServerManagerModel& other, QObject* parent = 0);
138 
139  virtual ~pqPipelineModel();
140 
152  virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
153 
161  virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
162 
170  virtual bool hasChildren(const QModelIndex& parent = QModelIndex()) const;
171 
181  virtual QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
182 
190  virtual QModelIndex parent(const QModelIndex& index) const;
191 
200  virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
201 
207  bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
208 
219  virtual Qt::ItemFlags flags(const QModelIndex& index) const;
221 
226 
231  pqServerManagerModelItem* getItemFor(const QModelIndex&) const;
232 
233  QModelIndex getIndexFor(pqServerManagerModelItem* item) const;
234 
242  ItemType getTypeFor(const QModelIndex& index) const;
244 
251  bool isEditable() const { return this->Editable; }
252 
258  void setEditable(bool editable) { this->Editable = editable; }
259 
266  void setSelectable(const QModelIndex& index, bool selectable);
267 
275  bool isSelectable(const QModelIndex& index) const;
276 
283  void setSubtreeSelectable(pqServerManagerModelItem* item, bool selectable);
284 
294  QModelIndex getNextIndex(const QModelIndex index, const QModelIndex& root = QModelIndex()) const;
295 
299  pqView* view() const { return this->View; }
300 
306  void setModifiedFont(const QFont& font);
307 
315  void enableFilterAnnotationKey(const QString& expectedAnnotation);
316 
323  void disableFilterAnnotationKey();
324 
332  void enableFilterSession(vtkSession* session);
333 
340  void disableFilterSession();
341 
342 public slots:
347  void addServer(pqServer* server);
348 
352  void removeServer(pqServer* server);
353 
357  void addSource(pqPipelineSource* source);
358 
362  void removeSource(pqPipelineSource* source);
363 
368  void addConnection(pqPipelineSource* source, pqPipelineSource* sink, int);
369 
374  void removeConnection(pqPipelineSource* source, pqPipelineSource* sink, int);
375 
382  void setView(pqView* module);
383 
384 signals:
385  void firstChildAdded(const QModelIndex& index);
386 
387 private slots:
388  void onInsituConnectionInitiated(pqServer* server);
389 
390  void serverDataChanged();
391 
395  void updateVisibility(pqPipelineSource*, ItemType type = Proxy);
396 
401  void delayedUpdateVisibility(pqPipelineSource*);
402  void delayedUpdateVisibilityTimeout();
403 
407  void updateData(pqServerManagerModelItem*, ItemType type = Proxy);
408  void updateDataServer(pqServer* server);
409 
410 private:
411  friend class pqPipelineModelDataItem;
412 
413  // Add an item as a child under the parent at the given index.
414  // Note that this method does not actually change the underlying
415  // pqServerManagerModel, it merely signals that such an addition
416  // has taken place.
417  void addChild(pqPipelineModelDataItem* parent, pqPipelineModelDataItem* child);
418 
419  // Remove a child item from under the parent.
420  // Note that this method does not actually change the underlying
421  // pqServerManagerModel, it merely signals that such an addition
422  // has taken place.
423  void removeChildFromParent(pqPipelineModelDataItem* child);
424 
425  // Returns the pqPipelineModelDataItem for the given pqServerManagerModelItem.
426  pqPipelineModelDataItem* getDataItem(pqServerManagerModelItem* item,
427  pqPipelineModelDataItem* subtreeRoot, ItemType type = Invalid) const;
428 
429  // called by pqPipelineModelDataItem to indicate that the data for the item
430  // may have changed.
431  void itemDataChanged(pqPipelineModelDataItem*);
435  void setSubtreeSelectable(pqPipelineModelDataItem* item, bool selectable);
436 
437  QModelIndex getIndex(pqPipelineModelDataItem* item) const;
438 
439 private:
440  pqPipelineModelInternal* Internal;
441  QPixmap* PixmapList;
442  QPointer<pqView> View;
443  bool Editable;
444  QString FilterRoleAnnotationKey;
445  vtkSession* FilterRoleSession;
446  ModifiedLiveInsituLink* LinkCallback;
447  void constructor();
448 
449  friend class ModifiedLiveInsituLink;
450 };
451 
452 #endif
void setEditable(bool editable)
Sets whether or not the model indexes are editable.
pqDataRepresentation is the superclass for a display for a pqPipelineSource i.e.
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:56
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
pqServer (should be renamed to pqSession) is a pqServerManagerModelItem subclass that represents a vt...
Definition: pqServer.h:64