1 // Copyright (C) 2010-2020 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include <QVBoxLayout>
25 #include <vtkSMProxy.h>
27 #include <pqOutputPort.h>
28 #include <pqPipelineSource.h>
29 #include <pqRepresentation.h>
32 MyView::MyView(const QString& viewmoduletype,
35 vtkSMViewProxy* viewmodule,
38 : pqView(viewmoduletype, group, name, viewmodule, server, p)
40 // our view is just a simple QWidget
41 this->MyWidget = new QWidget;
42 this->MyWidget->setAutoFillBackground(true);
43 new QVBoxLayout(this->MyWidget);
45 // connect to display creation so we can show them in our view
46 this->connect(this, SIGNAL(representationAdded(pqRepresentation*)),
47 SLOT(onRepresentationAdded(pqRepresentation*)));
48 this->connect(this, SIGNAL(representationRemoved(pqRepresentation*)),
49 SLOT(onRepresentationRemoved(pqRepresentation*)));
54 delete this->MyWidget;
58 QWidget* MyView::getWidget()
60 return this->MyWidget;
63 void MyView::onRepresentationAdded(pqRepresentation* d)
65 // add a label with the display id
66 QLabel* l = new QLabel(
67 QString("Display (%1)").arg(d->getProxy()->GetSelfIDAsString()),
69 this->MyWidget->layout()->addWidget(l);
70 this->Labels.insert(d, l);
73 void MyView::onRepresentationRemoved(pqRepresentation* d)
76 QLabel* l = this->Labels.take(d);
79 this->MyWidget->layout()->removeWidget(l);
84 void MyView::setBackground(const QColor& c)
86 QPalette p = this->MyWidget->palette();
87 p.setColor(QPalette::Window, c);
88 this->MyWidget->setPalette(p);
91 QColor MyView::background() const
93 return this->MyWidget->palette().color(QPalette::Window);
96 bool MyView::canDisplay(pqOutputPort* opPort) const
98 pqPipelineSource* source = opPort? opPort->getSource() : 0;
99 // check valid source and server connections
101 this->getServer()->GetConnectionID() !=
102 source->getServer()->GetConnectionID())
107 // we can show MyExtractEdges as defined in the server manager xml
108 if(QString("MyExtractEdges") == source->getProxy()->GetXMLName())