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* model);
59 template <class T>
60 inline QList<T> pqFindItems(const pqServerManagerModel* model, pqServer* server);
61 template <class T>
62 inline T pqFindItem(const pqServerManagerModel* model, const QString& name);
63 template <class T>
64 inline T pqFindItem(const pqServerManagerModel* model, vtkSMProxy* proxy);
65 template <class T>
66 inline T pqFindItem(const pqServerManagerModel* model, vtkTypeUInt32 id);
67 template <class T>
68 inline int pqGetNumberOfItems(const pqServerManagerModel* model);
69 template <class T>
70 inline T pqGetItemAtIndex(const pqServerManagerModel* 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 = nullptr);
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  pqServer* findServer(const QString& name) const;
116 
120  void beginRemoveServer(pqServer* server);
121  void endRemoveServer();
122 
130  void setActiveResource(const pqServerResource& resource);
131 
136  template <class T>
137  T findItem(vtkSMProxy* proxy) const
138  {
139  return ::pqFindItem<T>(this, proxy);
140  }
141 
146  template <class T>
147  T findItem(vtkTypeUInt32 id) const
148  {
149  return ::pqFindItem<T>(this, id);
150  }
151 
155  template <class T>
156  QList<T> findItems() const
157  {
158  return ::pqFindItems<T>(this);
159  }
160 
164  template <class T>
165  int getNumberOfItems() const
166  {
167  return ::pqGetNumberOfItems<T>(this);
168  }
169 
175  template <class T>
176  T getItemAtIndex(int index) const
177  {
178  return ::pqGetItemAtIndex<T>(this, index);
179  }
180 
185  template <class T>
186  QList<T> findItems(pqServer* server) const
187  {
188  return ::pqFindItems<T>(this, server);
189  }
190 
197  template <class T>
198  T findItem(const QString& name) const
199  {
200  return ::pqFindItem<T>(this, name);
201  }
202 
206  static void findItemsHelper(const pqServerManagerModel* model, const QMetaObject& mo,
207  QList<void*>* list, pqServer* server = nullptr);
208 
212  static pqServerManagerModelItem* findItemHelper(
213  const pqServerManagerModel* model, const QMetaObject& mo, vtkSMProxy* proxy);
214 
218  static pqServerManagerModelItem* findItemHelper(
219  const pqServerManagerModel* model, const QMetaObject& mo, vtkTypeUInt32 id);
220 
224  static pqServerManagerModelItem* findItemHelper(
225  const pqServerManagerModel* model, const QMetaObject& mo, const QString& name);
226 
227 Q_SIGNALS:
231  void preServerAdded(pqServer*);
232  void serverAdded(pqServer*);
233 
240  void serverReady(pqServer*);
241 
245  void preServerRemoved(pqServer*);
246  void serverRemoved(pqServer*);
247 
251  void aboutToRemoveServer(pqServer* server);
252 
256  void finishedRemovingServer();
257 
261  void preItemAdded(pqServerManagerModelItem*);
262  void itemAdded(pqServerManagerModelItem*);
263 
268  void preItemRemoved(pqServerManagerModelItem*);
269  void itemRemoved(pqServerManagerModelItem*);
270 
271  void preProxyAdded(pqProxy*);
272  void proxyAdded(pqProxy*);
273 
274  void preProxyRemoved(pqProxy*);
275  void proxyRemoved(pqProxy*);
276 
280  void preSourceAdded(pqPipelineSource* source);
281  void sourceAdded(pqPipelineSource* source);
282 
286  void preSourceRemoved(pqPipelineSource*);
287  void sourceRemoved(pqPipelineSource*);
288 
292  void preViewAdded(pqView* view);
293  void viewAdded(pqView* view);
294 
298  void preViewRemoved(pqView*);
299  void viewRemoved(pqView*);
300 
304  void preRepresentationAdded(pqRepresentation* rep);
305  void representationAdded(pqRepresentation* rep);
306 
310  void preRepresentationRemoved(pqRepresentation*);
311  void representationRemoved(pqRepresentation*);
312 
314 
317  void preExtractorAdded(pqExtractor*);
318  void extractorAdded(pqExtractor*);
319  void preExtractorRemoved(pqExtractor*);
320  void extractorRemoved(pqExtractor*);
322 
325  void nameChanged(pqServerManagerModelItem* item);
326 
330  void modifiedStateChanged(pqServerManagerModelItem* item);
331 
335  void connectionAdded(pqPipelineSource* source, pqPipelineSource* consumer, int srcOutputPort);
336  void preConnectionAdded(pqPipelineSource* source, pqPipelineSource* consumer, int srcOutputPort);
337 
341  void connectionRemoved(pqPipelineSource* source, pqPipelineSource* consumer, int srcOutputPort);
342  void preConnectionRemoved(
343  pqPipelineSource* source, pqPipelineSource* consumer, int srcOutputPort);
344 
346 
349  void connectionAdded(pqServerManagerModelItem* source, pqExtractor* consumer);
350  void connectionRemoved(pqServerManagerModelItem* source, pqExtractor* consumer);
352 
357  void dataUpdated(pqPipelineSource*);
358 
359 protected Q_SLOTS:
363  virtual void onProxyRegistered(const QString& group, const QString& name, vtkSMProxy* proxy);
364 
368  virtual void onProxyUnRegistered(const QString& group, const QString& name, vtkSMProxy* proxy);
369 
373  virtual void onConnectionCreated(vtkIdType id);
374 
378  virtual void onConnectionClosed(vtkIdType id);
379 
384  virtual void onStateLoaded(vtkPVXMLElement*, vtkSMProxyLocator*);
385 
386 private:
387  Q_DISABLE_COPY(pqServerManagerModel)
388 
389 
393  void updateSettingsFromQSettings(pqServer* server);
394 
395  class pqInternal;
396  pqInternal* Internal;
397 };
398 
399 //-----------------------------------------------------------------------------
400 template <class T>
401 inline QList<T> pqFindItems(const pqServerManagerModel* model)
402 {
403  QList<T> list;
405  model, ((T)0)->staticMetaObject, reinterpret_cast<QList<void*>*>(&list), nullptr);
406  return list;
407 }
408 
409 //-----------------------------------------------------------------------------
410 template <class T>
411 inline QList<T> pqFindItems(const pqServerManagerModel* model, pqServer* server)
412 {
413  QList<T> list;
415  model, ((T)0)->staticMetaObject, reinterpret_cast<QList<void*>*>(&list), server);
416  return list;
417 }
418 
419 //-----------------------------------------------------------------------------
420 template <class T>
421 inline T pqFindItem(const pqServerManagerModel* model, vtkSMProxy* proxy)
422 {
423  return qobject_cast<T>(
424  pqServerManagerModel::findItemHelper(model, ((T)0)->staticMetaObject, proxy));
425 }
426 
427 //-----------------------------------------------------------------------------
428 template <class T>
429 inline T pqFindItem(const pqServerManagerModel* model, vtkTypeUInt32 id)
430 {
431  return qobject_cast<T>(pqServerManagerModel::findItemHelper(model, ((T)0)->staticMetaObject, id));
432 }
433 
434 //-----------------------------------------------------------------------------
435 template <class T>
436 inline T pqFindItem(const pqServerManagerModel* model, const QString& name)
437 {
438  return qobject_cast<T>(
439  pqServerManagerModel::findItemHelper(model, ((T)0)->staticMetaObject, name));
440 }
441 
442 //-----------------------------------------------------------------------------
443 template <class T>
444 inline int pqGetNumberOfItems(const pqServerManagerModel* model)
445 {
446  return pqFindItems<T>(model).size();
447 }
448 
449 //-----------------------------------------------------------------------------
450 template <class T>
451 inline T pqGetItemAtIndex(const pqServerManagerModel* model, int index)
452 {
453  QList<T> items = pqFindItems<T>(model);
454  if (index < items.size())
455  {
456  return items[index];
457  }
458 
459  return 0;
460 }
461 
462 #endif
QList< T > pqFindItems(const pqServerManagerModel *model)
static void findItemsHelper(const pqServerManagerModel *model, const QMetaObject &mo, QList< void *> *list, pqServer *server=nullptr)
Internal method.
vtkSMSession is the default ParaView session.
Definition: vtkSMSession.h:34
This is PQ representation for a single representation.
pqServerManagerModelItem is a element maintained by pqServerManagerModel.
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.
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.
T pqGetItemAtIndex(const pqServerManagerModel *model, int index)
T pqFindItem(const pqServerManagerModel *model, const QString &name)
QList< T > findItems() const
Returns a list of pqServerManagerModelItem of the given type.
#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.
static pqServerManagerModelItem * findItemHelper(const pqServerManagerModel *model, const QMetaObject &mo, vtkSMProxy *proxy)
Internal method.
int pqGetNumberOfItems(const pqServerManagerModel *model)
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.
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:63