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 pqExtractor;
41 class pqPipelineSource;
42 class pqProxy;
43 class pqRepresentation;
44 class pqServer;
47 class pqServerResource;
48 class pqView;
49 class vtkPVXMLElement;
50 class vtkSession;
51 class vtkSMProxy;
52 class vtkSMProxyLocator;
53 class vtkSMSession;
54 
56 
57 template <class T>
58 inline QList<T> pqFindItems(const pqServerManagerModel* const model);
59 template <class T>
60 inline QList<T> pqFindItems(const pqServerManagerModel* const model, pqServer* server);
61 template <class T>
62 inline T pqFindItem(const pqServerManagerModel* const model, const QString& name);
63 template <class T>
64 inline T pqFindItem(const pqServerManagerModel* const model, vtkSMProxy* proxy);
65 template <class T>
66 inline T pqFindItem(const pqServerManagerModel* const model, vtkTypeUInt32 id);
67 template <class T>
68 inline int pqGetNumberOfItems(const pqServerManagerModel* const model);
69 template <class T>
70 inline T pqGetItemAtIndex(const pqServerManagerModel* const model, int index);
71 
80 class PQCORE_EXPORT pqServerManagerModel : public QObject
81 {
82  Q_OBJECT
83  typedef QObject Superclass;
84 
85 public:
91  pqServerManagerModel(pqServerManagerObserver* observer, QObject* parent = 0);
92  ~pqServerManagerModel() override;
93 
98  pqServer* findServer(vtkIdType cid) const;
99 
104  pqServer* findServer(vtkSession*) const;
105  pqServer* findServer(vtkSMSession*) const;
106 
110  pqServer* findServer(const pqServerResource& resource) const;
111 
115  void beginRemoveServer(pqServer* server);
116  void endRemoveServer();
117 
125  void setActiveResource(const pqServerResource& resource);
126 
131  template <class T>
132  T findItem(vtkSMProxy* proxy) const
133  {
134  return ::pqFindItem<T>(this, proxy);
135  }
136 
141  template <class T>
142  T findItem(vtkTypeUInt32 id) const
143  {
144  return ::pqFindItem<T>(this, id);
145  }
146 
150  template <class T>
151  QList<T> findItems() const
152  {
153  return ::pqFindItems<T>(this);
154  }
155 
159  template <class T>
160  int getNumberOfItems() const
161  {
162  return ::pqGetNumberOfItems<T>(this);
163  }
164 
170  template <class T>
171  T getItemAtIndex(int index) const
172  {
173  return ::pqGetItemAtIndex<T>(this, index);
174  }
175 
180  template <class T>
181  QList<T> findItems(pqServer* server) const
182  {
183  return ::pqFindItems<T>(this, server);
184  }
185 
192  template <class T>
193  T findItem(const QString& name) const
194  {
195  return ::pqFindItem<T>(this, name);
196  }
197 
201  static void findItemsHelper(const pqServerManagerModel* const model, const QMetaObject& mo,
202  QList<void*>* list, pqServer* server = 0);
203 
207  static pqServerManagerModelItem* findItemHelper(
208  const pqServerManagerModel* const model, const QMetaObject& mo, vtkSMProxy* proxy);
209 
213  static pqServerManagerModelItem* findItemHelper(
214  const pqServerManagerModel* const model, const QMetaObject& mo, vtkTypeUInt32 id);
215 
219  static pqServerManagerModelItem* findItemHelper(
220  const pqServerManagerModel* const model, const QMetaObject& mo, const QString& name);
221 
222 Q_SIGNALS:
226  void preServerAdded(pqServer*);
227  void serverAdded(pqServer*);
228 
235  void serverReady(pqServer*);
236 
240  void preServerRemoved(pqServer*);
241  void serverRemoved(pqServer*);
242 
246  void aboutToRemoveServer(pqServer* server);
247 
251  void finishedRemovingServer();
252 
256  void preItemAdded(pqServerManagerModelItem*);
257  void itemAdded(pqServerManagerModelItem*);
258 
263  void preItemRemoved(pqServerManagerModelItem*);
264  void itemRemoved(pqServerManagerModelItem*);
265 
266  void preProxyAdded(pqProxy*);
267  void proxyAdded(pqProxy*);
268 
269  void preProxyRemoved(pqProxy*);
270  void proxyRemoved(pqProxy*);
271 
275  void preSourceAdded(pqPipelineSource* source);
276  void sourceAdded(pqPipelineSource* source);
277 
281  void preSourceRemoved(pqPipelineSource*);
282  void sourceRemoved(pqPipelineSource*);
283 
287  void preViewAdded(pqView* view);
288  void viewAdded(pqView* view);
289 
293  void preViewRemoved(pqView*);
294  void viewRemoved(pqView*);
295 
299  void preRepresentationAdded(pqRepresentation* rep);
300  void representationAdded(pqRepresentation* rep);
301 
305  void preRepresentationRemoved(pqRepresentation*);
306  void representationRemoved(pqRepresentation*);
307 
309 
312  void preExtractorAdded(pqExtractor*);
313  void extractorAdded(pqExtractor*);
314  void preExtractorRemoved(pqExtractor*);
315  void extractorRemoved(pqExtractor*);
317 
320  void nameChanged(pqServerManagerModelItem* item);
321 
325  void modifiedStateChanged(pqServerManagerModelItem* item);
326 
330  void connectionAdded(pqPipelineSource* source, pqPipelineSource* consumer, int srcOutputPort);
331  void preConnectionAdded(pqPipelineSource* source, pqPipelineSource* consumer, int srcOutputPort);
332 
336  void connectionRemoved(pqPipelineSource* source, pqPipelineSource* consumer, int srcOutputPort);
337  void preConnectionRemoved(
338  pqPipelineSource* source, pqPipelineSource* consumer, int srcOutputPort);
339 
341 
344  void connectionAdded(pqServerManagerModelItem* source, pqExtractor* consumer);
345  void connectionRemoved(pqServerManagerModelItem* source, pqExtractor* consumer);
347 
352  void dataUpdated(pqPipelineSource*);
353 
354 protected Q_SLOTS:
358  virtual void onProxyRegistered(const QString& group, const QString& name, vtkSMProxy* proxy);
359 
363  virtual void onProxyUnRegistered(const QString& group, const QString& name, vtkSMProxy* proxy);
364 
368  virtual void onConnectionCreated(vtkIdType id);
369 
373  virtual void onConnectionClosed(vtkIdType id);
374 
379  virtual void onStateLoaded(vtkPVXMLElement*, vtkSMProxyLocator*);
380 
381 private:
382  Q_DISABLE_COPY(pqServerManagerModel)
383 
384 
388  void updateSettingsFromQSettings(pqServer* server);
389 
390  class pqInternal;
391  pqInternal* Internal;
392 };
393 
394 //-----------------------------------------------------------------------------
395 template <class T>
396 inline QList<T> pqFindItems(const pqServerManagerModel* const model)
397 {
398  QList<T> list;
400  model, ((T)0)->staticMetaObject, reinterpret_cast<QList<void*>*>(&list), 0);
401  return list;
402 }
403 
404 //-----------------------------------------------------------------------------
405 template <class T>
406 inline QList<T> pqFindItems(const pqServerManagerModel* const model, pqServer* server)
407 {
408  QList<T> list;
410  model, ((T)0)->staticMetaObject, reinterpret_cast<QList<void*>*>(&list), server);
411  return list;
412 }
413 
414 //-----------------------------------------------------------------------------
415 template <class T>
416 inline T pqFindItem(const pqServerManagerModel* const model, vtkSMProxy* proxy)
417 {
418  return qobject_cast<T>(
419  pqServerManagerModel::findItemHelper(model, ((T)0)->staticMetaObject, proxy));
420 }
421 
422 //-----------------------------------------------------------------------------
423 template <class T>
424 inline T pqFindItem(const pqServerManagerModel* const model, vtkTypeUInt32 id)
425 {
426  return qobject_cast<T>(pqServerManagerModel::findItemHelper(model, ((T)0)->staticMetaObject, id));
427 }
428 
429 //-----------------------------------------------------------------------------
430 template <class T>
431 inline T pqFindItem(const pqServerManagerModel* const model, const QString& name)
432 {
433  return qobject_cast<T>(
434  pqServerManagerModel::findItemHelper(model, ((T)0)->staticMetaObject, name));
435 }
436 
437 //-----------------------------------------------------------------------------
438 template <class T>
439 inline int pqGetNumberOfItems(const pqServerManagerModel* const model)
440 {
441  return pqFindItems<T>(model).size();
442 }
443 
444 //-----------------------------------------------------------------------------
445 template <class T>
446 inline T pqGetItemAtIndex(const pqServerManagerModel* const model, int index)
447 {
448  QList<T> items = pqFindItems<T>(model);
449  if (index < items.size())
450  {
451  return items[index];
452  }
453 
454  return 0;
455 }
456 
457 #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)
#define PQCORE_EXPORT
Definition: pqCoreModule.h:15
size
source
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.
QList< T > findItems(pqServer *server) const
Same as findItems<T>() except that this returns only those items that are on the indicated server...
pqServerResource encapsulates a resource in ParaView.
static void findItemsHelper(const pqServerManagerModel *const model, const QMetaObject &mo, QList< void *> *list, pqServer *server=0)
Internal method.
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