7 #include <vtkSMProxy.h>
9 #include <pqOutputPort.h>
10 #include <pqPipelineSource.h>
11 #include <pqRepresentation.h>
14 MyView::MyView(const QString& viewmoduletype,
17 vtkSMViewProxy* viewmodule,
20 : pqView(viewmoduletype, group, name, viewmodule, server, p)
22 // our view is just a simple QWidget
23 this->MyWidget = new QWidget;
24 this->MyWidget->setAutoFillBackground(true);
25 new QVBoxLayout(this->MyWidget);
27 // connect to display creation so we can show them in our view
28 this->connect(this, SIGNAL(representationAdded(pqRepresentation*)),
29 SLOT(onRepresentationAdded(pqRepresentation*)));
30 this->connect(this, SIGNAL(representationRemoved(pqRepresentation*)),
31 SLOT(onRepresentationRemoved(pqRepresentation*)));
36 delete this->MyWidget;
40 QWidget* MyView::getWidget()
42 return this->MyWidget;
45 void MyView::onRepresentationAdded(pqRepresentation* d)
47 // add a label with the display id
48 QLabel* l = new QLabel(
49 QString("Display (%1)").arg(d->getProxy()->GetSelfIDAsString()),
51 this->MyWidget->layout()->addWidget(l);
52 this->Labels.insert(d, l);
55 void MyView::onRepresentationRemoved(pqRepresentation* d)
58 QLabel* l = this->Labels.take(d);
61 this->MyWidget->layout()->removeWidget(l);
66 void MyView::setBackground(const QColor& c)
68 QPalette p = this->MyWidget->palette();
69 p.setColor(QPalette::Window, c);
70 this->MyWidget->setPalette(p);
73 QColor MyView::background() const
75 return this->MyWidget->palette().color(QPalette::Window);
78 bool MyView::canDisplay(pqOutputPort* opPort) const
80 pqPipelineSource* source = opPort? opPort->getSource() : 0;
81 // check valid source and server connections
83 this->getServer()->GetConnectionID() !=
84 source->getServer()->GetConnectionID())
89 // we can show MyExtractEdges as defined in the server manager xml
90 if(QString("MyExtractEdges") == source->getProxy()->GetXMLName())