pqServerManagerModel.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 #ifndef pqServerManagerModel_h
5 #define pqServerManagerModel_h
6 
7 #include "pqCoreModule.h"
8 #include "vtkType.h" // for vtkIdType.
9 #include <QList>
10 #include <QObject>
11 
12 class pqExtractor;
13 class pqPipelineSource;
14 class pqProxy;
15 class pqRepresentation;
16 class pqServer;
19 class pqServerResource;
20 class pqView;
21 class vtkPVXMLElement;
22 class vtkSession;
23 class vtkSMProxy;
24 class vtkSMProxyLocator;
25 class vtkSMSession;
26 
28 
29 template <class T>
30 inline QList<T> pqFindItems(const pqServerManagerModel* model);
31 template <class T>
32 inline QList<T> pqFindItems(const pqServerManagerModel* model, pqServer* server);
33 template <class T>
34 inline T pqFindItem(const pqServerManagerModel* model, const QString& name);
35 template <class T>
36 inline T pqFindItem(const pqServerManagerModel* model, vtkSMProxy* proxy);
37 template <class T>
38 inline T pqFindItem(const pqServerManagerModel* model, vtkTypeUInt32 id);
39 template <class T>
40 inline int pqGetNumberOfItems(const pqServerManagerModel* model);
41 template <class T>
42 inline T pqGetItemAtIndex(const pqServerManagerModel* model, int index);
43 
52 class PQCORE_EXPORT pqServerManagerModel : public QObject
53 {
54  Q_OBJECT
55  typedef QObject Superclass;
56 
57 public:
63  pqServerManagerModel(pqServerManagerObserver* observer, QObject* parent = nullptr);
64  ~pqServerManagerModel() override;
65 
70  pqServer* findServer(vtkIdType cid) const;
71 
76  pqServer* findServer(vtkSession*) const;
77  pqServer* findServer(vtkSMSession*) const;
78 
82  pqServer* findServer(const pqServerResource& resource) const;
83 
87  pqServer* findServer(const QString& name) const;
88 
92  void beginRemoveServer(pqServer* server);
93  void endRemoveServer();
94 
102  void setActiveResource(const pqServerResource& resource);
103 
108  template <class T>
109  T findItem(vtkSMProxy* proxy) const
110  {
111  return ::pqFindItem<T>(this, proxy);
112  }
113 
118  template <class T>
119  T findItem(vtkTypeUInt32 id) const
120  {
121  return ::pqFindItem<T>(this, id);
122  }
123 
127  template <class T>
128  QList<T> findItems() const
129  {
130  return ::pqFindItems<T>(this);
131  }
132 
136  template <class T>
137  int getNumberOfItems() const
138  {
139  return ::pqGetNumberOfItems<T>(this);
140  }
141 
147  template <class T>
148  T getItemAtIndex(int index) const
149  {
150  return ::pqGetItemAtIndex<T>(this, index);
151  }
152 
157  template <class T>
158  QList<T> findItems(pqServer* server) const
159  {
160  return ::pqFindItems<T>(this, server);
161  }
162 
169  template <class T>
170  T findItem(const QString& name) const
171  {
172  return ::pqFindItem<T>(this, name);
173  }
174 
178  static void findItemsHelper(const pqServerManagerModel* model, const QMetaObject& mo,
179  QList<void*>* list, pqServer* server = nullptr);
180 
184  static pqServerManagerModelItem* findItemHelper(
185  const pqServerManagerModel* model, const QMetaObject& mo, vtkSMProxy* proxy);
186 
190  static pqServerManagerModelItem* findItemHelper(
191  const pqServerManagerModel* model, const QMetaObject& mo, vtkTypeUInt32 id);
192 
196  static pqServerManagerModelItem* findItemHelper(
197  const pqServerManagerModel* model, const QMetaObject& mo, const QString& name);
198 
199 Q_SIGNALS:
203  void preServerAdded(pqServer*);
204  void serverAdded(pqServer*);
205 
212  void serverReady(pqServer*);
213 
217  void preServerRemoved(pqServer*);
218  void serverRemoved(pqServer*);
219 
223  void aboutToRemoveServer(pqServer* server);
224 
228  void finishedRemovingServer();
229 
233  void preItemAdded(pqServerManagerModelItem*);
234  void itemAdded(pqServerManagerModelItem*);
235 
240  void preItemRemoved(pqServerManagerModelItem*);
241  void itemRemoved(pqServerManagerModelItem*);
242 
243  void preProxyAdded(pqProxy*);
244  void proxyAdded(pqProxy*);
245 
246  void preProxyRemoved(pqProxy*);
247  void proxyRemoved(pqProxy*);
248 
252  void preSourceAdded(pqPipelineSource* source);
253  void sourceAdded(pqPipelineSource* source);
254 
258  void preSourceRemoved(pqPipelineSource*);
259  void sourceRemoved(pqPipelineSource*);
260 
264  void preViewAdded(pqView* view);
265  void viewAdded(pqView* view);
266 
270  void preViewRemoved(pqView*);
271  void viewRemoved(pqView*);
272 
276  void preRepresentationAdded(pqRepresentation* rep);
277  void representationAdded(pqRepresentation* rep);
278 
282  void preRepresentationRemoved(pqRepresentation*);
283  void representationRemoved(pqRepresentation*);
284 
286 
289  void preExtractorAdded(pqExtractor*);
290  void extractorAdded(pqExtractor*);
291  void preExtractorRemoved(pqExtractor*);
292  void extractorRemoved(pqExtractor*);
294 
297  void nameChanged(pqServerManagerModelItem* item);
298 
302  void modifiedStateChanged(pqServerManagerModelItem* item);
303 
307  void connectionAdded(pqPipelineSource* source, pqPipelineSource* consumer, int srcOutputPort);
308  void preConnectionAdded(pqPipelineSource* source, pqPipelineSource* consumer, int srcOutputPort);
309 
313  void connectionRemoved(pqPipelineSource* source, pqPipelineSource* consumer, int srcOutputPort);
314  void preConnectionRemoved(
315  pqPipelineSource* source, pqPipelineSource* consumer, int srcOutputPort);
316 
318 
321  void connectionAdded(pqServerManagerModelItem* source, pqExtractor* consumer);
322  void connectionRemoved(pqServerManagerModelItem* source, pqExtractor* consumer);
324 
329  void dataUpdated(pqPipelineSource*);
330 
331 protected Q_SLOTS:
335  virtual void onProxyRegistered(const QString& group, const QString& name, vtkSMProxy* proxy);
336 
340  virtual void onProxyUnRegistered(const QString& group, const QString& name, vtkSMProxy* proxy);
341 
345  virtual void onConnectionCreated(vtkIdType id);
346 
350  virtual void onConnectionClosed(vtkIdType id);
351 
356  virtual void onStateLoaded(vtkPVXMLElement*, vtkSMProxyLocator*);
357 
358 private:
359  Q_DISABLE_COPY(pqServerManagerModel)
360 
361 
365  void updateSettingsFromQSettings(pqServer* server);
366 
367  class pqInternal;
368  pqInternal* Internal;
369 };
370 
371 //-----------------------------------------------------------------------------
372 template <class T>
373 inline QList<T> pqFindItems(const pqServerManagerModel* model)
374 {
375  QList<T> list;
377  model, ((T)0)->staticMetaObject, reinterpret_cast<QList<void*>*>(&list), nullptr);
378  return list;
379 }
380 
381 //-----------------------------------------------------------------------------
382 template <class T>
383 inline QList<T> pqFindItems(const pqServerManagerModel* model, pqServer* server)
384 {
385  QList<T> list;
387  model, ((T)0)->staticMetaObject, reinterpret_cast<QList<void*>*>(&list), server);
388  return list;
389 }
390 
391 //-----------------------------------------------------------------------------
392 template <class T>
393 inline T pqFindItem(const pqServerManagerModel* model, vtkSMProxy* proxy)
394 {
395  return qobject_cast<T>(
396  pqServerManagerModel::findItemHelper(model, ((T)0)->staticMetaObject, proxy));
397 }
398 
399 //-----------------------------------------------------------------------------
400 template <class T>
401 inline T pqFindItem(const pqServerManagerModel* model, vtkTypeUInt32 id)
402 {
403  return qobject_cast<T>(pqServerManagerModel::findItemHelper(model, ((T)0)->staticMetaObject, id));
404 }
405 
406 //-----------------------------------------------------------------------------
407 template <class T>
408 inline T pqFindItem(const pqServerManagerModel* model, const QString& name)
409 {
410  return qobject_cast<T>(
411  pqServerManagerModel::findItemHelper(model, ((T)0)->staticMetaObject, name));
412 }
413 
414 //-----------------------------------------------------------------------------
415 template <class T>
416 inline int pqGetNumberOfItems(const pqServerManagerModel* model)
417 {
418  return pqFindItems<T>(model).size();
419 }
420 
421 //-----------------------------------------------------------------------------
422 template <class T>
423 inline T pqGetItemAtIndex(const pqServerManagerModel* model, int index)
424 {
425  QList<T> items = pqFindItems<T>(model);
426  if (index < items.size())
427  {
428  return items[index];
429  }
430 
431  return 0;
432 }
433 
434 #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:22
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:26
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:28
pqServerManagerModel is the model for the Server Manager.
proxy for a VTK object(s) on a server
Definition: vtkSMProxy.h:140
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:17
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:21
pqServer (should be renamed to pqSession) is a pqServerManagerModelItem subclass that represents a vt...
Definition: pqServer.h:35