pqServerManagerModel.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: pqServerManagerModel.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 #ifndef pqServerManagerModel_h
33 #define pqServerManagerModel_h
34 
35 #include "pqCoreModule.h"
36 #include "vtkType.h" // for vtkIdType.
37 #include <QList>
38 #include <QObject>
39 
40 class pqPipelineSource;
41 class pqProxy;
42 class pqRepresentation;
43 class pqServer;
46 class pqServerResource;
47 class pqView;
48 class vtkPVXMLElement;
49 class vtkSession;
50 class vtkSMProxy;
51 class vtkSMProxyLocator;
52 class vtkSMSession;
53 
55 
56 template <class T>
57 inline QList<T> pqFindItems(const pqServerManagerModel* const model);
58 template <class T>
59 inline QList<T> pqFindItems(const pqServerManagerModel* const model, pqServer* server);
60 template <class T>
61 inline T pqFindItem(const pqServerManagerModel* const model, const QString& name);
62 template <class T>
63 inline T pqFindItem(const pqServerManagerModel* const model, vtkSMProxy* proxy);
64 template <class T>
65 inline T pqFindItem(const pqServerManagerModel* const model, vtkTypeUInt32 id);
66 template <class T>
67 inline int pqGetNumberOfItems(const pqServerManagerModel* const model);
68 template <class T>
69 inline T pqGetItemAtIndex(const pqServerManagerModel* const model, int index);
70 
79 class PQCORE_EXPORT pqServerManagerModel : public QObject
80 {
81  Q_OBJECT
82  typedef QObject Superclass;
83 
84 public:
90  pqServerManagerModel(pqServerManagerObserver* observer, QObject* parent = 0);
91  ~pqServerManagerModel() override;
92 
97  pqServer* findServer(vtkIdType cid) const;
98 
103  pqServer* findServer(vtkSession*) const;
104  pqServer* findServer(vtkSMSession*) const;
105 
109  pqServer* findServer(const pqServerResource& resource) const;
110 
114  void beginRemoveServer(pqServer* server);
115  void endRemoveServer();
116 
124  void setActiveResource(const pqServerResource& resource);
125 
130  template <class T>
131  T findItem(vtkSMProxy* proxy) const
132  {
133  return ::pqFindItem<T>(this, proxy);
134  }
135 
140  template <class T>
141  T findItem(vtkTypeUInt32 id) const
142  {
143  return ::pqFindItem<T>(this, id);
144  }
145 
149  template <class T>
150  QList<T> findItems() const
151  {
152  return ::pqFindItems<T>(this);
153  }
154 
158  template <class T>
159  int getNumberOfItems() const
160  {
161  return ::pqGetNumberOfItems<T>(this);
162  }
163 
169  template <class T>
170  T getItemAtIndex(int index) const
171  {
172  return ::pqGetItemAtIndex<T>(this, index);
173  }
174 
179  template <class T>
180  QList<T> findItems(pqServer* server) const
181  {
182  return ::pqFindItems<T>(this, server);
183  }
184 
191  template <class T>
192  T findItem(const QString& name) const
193  {
194  return ::pqFindItem<T>(this, name);
195  }
196 
200  static void findItemsHelper(const pqServerManagerModel* const model, const QMetaObject& mo,
201  QList<void*>* list, pqServer* server = 0);
202 
206  static pqServerManagerModelItem* findItemHelper(
207  const pqServerManagerModel* const model, const QMetaObject& mo, vtkSMProxy* proxy);
208 
212  static pqServerManagerModelItem* findItemHelper(
213  const pqServerManagerModel* const model, const QMetaObject& mo, vtkTypeUInt32 id);
214 
218  static pqServerManagerModelItem* findItemHelper(
219  const pqServerManagerModel* const model, const QMetaObject& mo, const QString& name);
220 
221 signals:
225  void preServerAdded(pqServer*);
226  void serverAdded(pqServer*);
227 
234  void serverReady(pqServer*);
235 
239  void preServerRemoved(pqServer*);
240  void serverRemoved(pqServer*);
241 
245  void aboutToRemoveServer(pqServer* server);
246 
250  void finishedRemovingServer();
251 
255  void preItemAdded(pqServerManagerModelItem*);
256  void itemAdded(pqServerManagerModelItem*);
257 
262  void preItemRemoved(pqServerManagerModelItem*);
263  void itemRemoved(pqServerManagerModelItem*);
264 
265  void preProxyAdded(pqProxy*);
266  void proxyAdded(pqProxy*);
267 
268  void preProxyRemoved(pqProxy*);
269  void proxyRemoved(pqProxy*);
270 
274  void preSourceAdded(pqPipelineSource* source);
275  void sourceAdded(pqPipelineSource* source);
276 
280  void preSourceRemoved(pqPipelineSource*);
281  void sourceRemoved(pqPipelineSource*);
282 
286  void preViewAdded(pqView* view);
287  void viewAdded(pqView* view);
288 
292  void preViewRemoved(pqView*);
293  void viewRemoved(pqView*);
294 
298  void preRepresentationAdded(pqRepresentation* rep);
299  void representationAdded(pqRepresentation* rep);
300 
304  void preRepresentationRemoved(pqRepresentation*);
305  void representationRemoved(pqRepresentation*);
306 
310  void nameChanged(pqServerManagerModelItem* item);
311 
315  void modifiedStateChanged(pqServerManagerModelItem* item);
316 
320  void connectionAdded(pqPipelineSource* source, pqPipelineSource* consumer, int srcOutputPort);
321  void preConnectionAdded(pqPipelineSource* source, pqPipelineSource* consumer, int srcOutputPort);
322 
326  void connectionRemoved(pqPipelineSource* source, pqPipelineSource* consumer, int srcOutputPort);
327  void preConnectionRemoved(
328  pqPipelineSource* source, pqPipelineSource* consumer, int srcOutputPort);
329 
334  void dataUpdated(pqPipelineSource*);
335 
336 protected slots:
340  virtual void onProxyRegistered(const QString& group, const QString& name, vtkSMProxy* proxy);
341 
345  virtual void onProxyUnRegistered(const QString& group, const QString& name, vtkSMProxy* proxy);
346 
350  virtual void onConnectionCreated(vtkIdType id);
351 
355  virtual void onConnectionClosed(vtkIdType id);
356 
361  virtual void onStateLoaded(vtkPVXMLElement*, vtkSMProxyLocator*);
362 
363 private:
364  Q_DISABLE_COPY(pqServerManagerModel)
365 
366 
370  void updateSettingsFromQSettings(pqServer* server);
371 
372  class pqInternal;
373  pqInternal* Internal;
374 };
375 
376 //-----------------------------------------------------------------------------
377 template <class T>
378 inline QList<T> pqFindItems(const pqServerManagerModel* const model)
379 {
380  QList<T> list;
382  model, ((T)0)->staticMetaObject, reinterpret_cast<QList<void*>*>(&list), 0);
383  return list;
384 }
385 
386 //-----------------------------------------------------------------------------
387 template <class T>
388 inline QList<T> pqFindItems(const pqServerManagerModel* const model, pqServer* server)
389 {
390  QList<T> list;
392  model, ((T)0)->staticMetaObject, reinterpret_cast<QList<void*>*>(&list), server);
393  return list;
394 }
395 
396 //-----------------------------------------------------------------------------
397 template <class T>
398 inline T pqFindItem(const pqServerManagerModel* const model, vtkSMProxy* proxy)
399 {
400  return qobject_cast<T>(
401  pqServerManagerModel::findItemHelper(model, ((T)0)->staticMetaObject, proxy));
402 }
403 
404 //-----------------------------------------------------------------------------
405 template <class T>
406 inline T pqFindItem(const pqServerManagerModel* const model, vtkTypeUInt32 id)
407 {
408  return qobject_cast<T>(pqServerManagerModel::findItemHelper(model, ((T)0)->staticMetaObject, id));
409 }
410 
411 //-----------------------------------------------------------------------------
412 template <class T>
413 inline T pqFindItem(const pqServerManagerModel* const model, const QString& name)
414 {
415  return qobject_cast<T>(
416  pqServerManagerModel::findItemHelper(model, ((T)0)->staticMetaObject, name));
417 }
418 
419 //-----------------------------------------------------------------------------
420 template <class T>
421 inline int pqGetNumberOfItems(const pqServerManagerModel* const model)
422 {
423  return pqFindItems<T>(model).size();
424 }
425 
426 //-----------------------------------------------------------------------------
427 template <class T>
428 inline T pqGetItemAtIndex(const pqServerManagerModel* const model, int index)
429 {
430  QList<T> items = pqFindItems<T>(model);
431  if (index < items.size())
432  {
433  return items[index];
434  }
435 
436  return 0;
437 }
438 
439 #endif
int pqGetNumberOfItems(const pqServerManagerModel *const model)
QList< T > pqFindItems(const pqServerManagerModel *const model)
vtkSMSession is the default ParaView session.
Definition: vtkSMSession.h:35
This is PQ representation for a single representation.
pqServerManagerModelItem is a element maintained by pqServerManagerModel.
T pqGetItemAtIndex(const pqServerManagerModel *const model, int index)
int vtkIdType
This is a PQ abstraction of a generic view module.
Definition: pqView.h:54
T findItem(const QString &name) const
Returns an item with the given name.
static pqServerManagerModelItem * findItemHelper(const pqServerManagerModel *const model, const QMetaObject &mo, vtkSMProxy *proxy)
Internal method.
T findItem(vtkTypeUInt32 id) const
Given the global id for a proxy, locates a pqServerManagerModelItem subclass for the proxy.
name
This is a vtkSMProxyManager observer.
QList< T > findItems() const
Returns a list of pqServerManagerModelItem of the given type.
T pqFindItem(const pqServerManagerModel *const model, const QString &name)
T findItem(vtkSMProxy *proxy) const
Given a proxy, locates a pqServerManagerModelItem subclass for the given proxy.
This class represents any registered Server Manager proxy.
Definition: pqProxy.h:56
pqServerManagerModel is the model for the Server Manager.
proxy for a VTK object(s) on a server
Definition: vtkSMProxy.h:152
int getNumberOfItems() const
Returns the number of items of the given type.
is used to locate proxies referred to in state xmls while loading state files.
PQ representation for a vtkSMProxy that can be involved in a pipeline.
vtkSession defines a session i.e.
Definition: vtkSession.h:29
T getItemAtIndex(int index) const
Returns the item of the given type and the given index.
This is used by vtkPVXMLParser to represent an XML document starting at the root element.
index
QList< T > findItems(pqServer *server) const
Same as findItems<T>() except that this returns only those items that are on the indicated server.
static void findItemsHelper(const pqServerManagerModel *const model, const QMetaObject &mo, QList< void * > *list, pqServer *server=0)
Internal method.
pqServerResource encapsulates a resource in ParaView.
pqServer (should be renamed to pqSession) is a pqServerManagerModelItem subclass that represents a vt...
Definition: pqServer.h:64