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 
35 
36 #ifndef _pqPipelineModel_h
37 #define _pqPipelineModel_h
38 
39 
40 #include "pqComponentsModule.h"
41 
42 #include "pqView.h"
43 #include "vtkSmartPointer.h"
44 #include <QAbstractItemModel>
45 #include <QPointer>
46 
47 
48 
50 class pqPipelineModelFilter;
51 class pqPipelineModelInternal;
52 class pqPipelineModelItem;
53 class pqPipelineModelOutput;
54 class pqPipelineModelSource;
55 class pqPipelineSource;
56 class pqView;
57 class pqServer;
60 class QFont;
61 class QPixmap;
62 class ModifiedLiveInsituLink;
63 
80 
81 class pqPipelineModelInternal;
83 class pqPipelineSource;
84 class pqServer;
85 class QPixmap;
86 class QString;
87 class pqPipelineModelDataItem;
88 class vtkSession;
89 
97 class PQCOMPONENTS_EXPORT pqPipelineModel : public QAbstractItemModel
98 {
99  Q_OBJECT;
100 
101 public:
102  enum ItemType {
103  Invalid = -1,
104  Server = 0,
107  Link
108  };
109 
110  enum ItemRole {
111  AnnotationFilterRole = 33,
112  SessionFilterRole = 34
113  };
114 
115 public:
116  pqPipelineModel(QObject *parent=0);
117 
122  pqPipelineModel(const pqPipelineModel &other, QObject *parent=0);
123 
128  pqPipelineModel(const pqServerManagerModel &other, QObject *parent=0);
129 
130  virtual ~pqPipelineModel();
131 
133 
134  virtual int rowCount(const QModelIndex &parent=QModelIndex()) const;
140 
146  virtual int columnCount(const QModelIndex &parent=QModelIndex()) const;
147 
153  virtual bool hasChildren(const QModelIndex &parent=QModelIndex()) const;
154 
162  virtual QModelIndex index(int row, int column,
163  const QModelIndex &parent=QModelIndex()) const;
164 
170  virtual QModelIndex parent(const QModelIndex &index) const;
171 
178  virtual QVariant data(const QModelIndex &index,
179  int role=Qt::DisplayRole) const;
180 
184  bool setData(const QModelIndex &index, const QVariant& value,
185  int role = Qt::EditRole);
186 
195  virtual Qt::ItemFlags flags(const QModelIndex &index) const;
197 
199 
200 
203  pqServerManagerModelItem* getItemFor(const QModelIndex& ) const;
204 
205 
206  QModelIndex getIndexFor(pqServerManagerModelItem *item) const;
207 
213  ItemType getTypeFor(const QModelIndex &index) const;
215 
220  bool isEditable() const {return this->Editable;}
221 
225  void setEditable(bool editable) {this->Editable = editable;}
226 
231  void setSelectable(const QModelIndex &index, bool selectable);
232 
238  bool isSelectable(const QModelIndex &index) const;
239 
244  void setSubtreeSelectable(pqServerManagerModelItem *item, bool selectable);
245 
253  QModelIndex getNextIndex(const QModelIndex index,
254  const QModelIndex &root=QModelIndex()) const;
255 
257  pqView* view() const
258  { return this->View; }
259 
263  void setModifiedFont(const QFont &font);
264 
270  void enableFilterAnnotationKey(const QString &expectedAnnotation);
271 
276  void disableFilterAnnotationKey();
277 
283  void enableFilterSession(vtkSession* session);
284 
289  void disableFilterSession();
290 
291 public slots:
294  void addServer(pqServer *server);
295 
297  void removeServer(pqServer *server);
298 
300  void addSource(pqPipelineSource* source);
301 
303  void removeSource(pqPipelineSource* source);
304 
307  void addConnection(pqPipelineSource *source, pqPipelineSource *sink, int);
308 
311  void removeConnection(pqPipelineSource *source, pqPipelineSource *sink, int);
312 
317  void setView(pqView *module);
318 
319 signals:
320  void firstChildAdded(const QModelIndex &index);
321 
322 private slots:
323  void onInsituConnectionInitiated(pqServer* server);
324 
325  void serverDataChanged();
326 
328  void updateVisibility(pqPipelineSource*, ItemType type = Proxy);
329 
332  void delayedUpdateVisibility(pqPipelineSource*);
333  void delayedUpdateVisibilityTimeout();
334 
336  void updateData(pqServerManagerModelItem*, ItemType type = Proxy);
337  void updateDataServer(pqServer* server);
338 
339 private:
340  friend class pqPipelineModelDataItem;
341 
342  // Add an item as a child under the parent at the given index.
343  // Note that this method does not actually change the underlying
344  // pqServerManagerModel, it merely signals that such an addition
345  // has taken place.
346  void addChild(pqPipelineModelDataItem* parent,
347  pqPipelineModelDataItem* child);
348 
349  // Remove a child item from under the parent.
350  // Note that this method does not actually change the underlying
351  // pqServerManagerModel, it merely signals that such an addition
352  // has taken place.
353  void removeChildFromParent(pqPipelineModelDataItem* child);
354 
355  // Returns the pqPipelineModelDataItem for the given pqServerManagerModelItem.
356  pqPipelineModelDataItem* getDataItem(pqServerManagerModelItem* item,
357  pqPipelineModelDataItem* subtreeRoot,
358  ItemType type=Invalid) const;
359 
360  // called by pqPipelineModelDataItem to indicate that the data for the item
361  // may have changed.
362  void itemDataChanged(pqPipelineModelDataItem*);
364  void setSubtreeSelectable(pqPipelineModelDataItem *item, bool selectable);
365 
366  QModelIndex getIndex(pqPipelineModelDataItem* item) const;
367 private:
368  pqPipelineModelInternal *Internal;
369  QPixmap *PixmapList;
370  QPointer<pqView> View;
371  bool Editable;
372  QString FilterRoleAnnotationKey;
373  vtkSession* FilterRoleSession;
374  ModifiedLiveInsituLink* LinkCallback;
375  void constructor();
376 
377  friend class ModifiedLiveInsituLink;
378 };
379 
380 #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:55
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.
pqServer (should be renamed to pqSession) is a pqServerManagerModelItem subclass that represents a vt...
Definition: pqServer.h:62