1 // Copyright (C) 2010-2012 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.
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
20 #include "pqExtractGroupPanel.h"
21 #include "ui_ExtractGroupPanel.h"
23 #include "vtkProcessModule.h"
24 #include "vtkMultiBlockDataSet.h"
25 #include "vtkInformation.h"
26 #include "vtkIntArray.h"
27 #include "vtkSMDoubleVectorProperty.h"
28 #include "vtkSMIntVectorProperty.h"
29 #include "vtkSMStringVectorProperty.h"
30 #include "vtkSMProxy.h"
31 #include "vtkEventQtSlotConnect.h"
32 #include "vtkPVSILInformation.h"
34 #include "vtkSMPropertyHelper.h"
35 #include "vtkStringArray.h"
36 #include "vtkDataSetAttributes.h"
38 #include "vtkMedUtilities.h"
40 #include "pqTreeWidget.h"
41 #include "pqTreeWidgetItemObject.h"
42 #include "pqSMAdaptor.h"
44 #include "pqPropertyManager.h"
45 #include "pqSILModel.h"
46 #include "pqProxySILModel.h"
47 #include "pqTreeViewSelectionHelper.h"
48 #include "pqTreeWidgetSelectionHelper.h"
49 #include "pqPropertyLinks.h"
51 #include <QHeaderView>
53 class pqExtractGroupPanel::pqUI : public QObject, public Ui::ExtractGroupPanel
56 pqUI(pqExtractGroupPanel* p) :
59 this->VTKConnect = vtkSmartPointer<vtkEventQtSlotConnect>::New();
60 this->SILUpdateStamp = -1;
68 vtkSmartPointer<vtkEventQtSlotConnect> VTKConnect;
69 pqPropertyLinks Links;
70 pqProxySILModel* entityModel;
71 pqProxySILModel* groupModel;
75 pqExtractGroupPanel::pqExtractGroupPanel(pqProxy* object_proxy, QWidget* p) :
76 Superclass(object_proxy, p)
78 this->UI = new pqUI(this);
79 this->UI->setupUi(this);
81 pqProxySILModel* proxyModel;
83 // connect groups to groupsRoot
84 proxyModel = new pqProxySILModel("GroupTree", &this->UI->SILModel);
85 proxyModel->setSourceModel(&this->UI->SILModel);
86 this->UI->Groups->setModel(proxyModel);
87 this->UI->Groups->setHeaderHidden(true);
89 this->UI->groupModel = new pqProxySILModel("Groups", &this->UI->SILModel);
90 this->UI->groupModel->setSourceModel(&this->UI->SILModel);
92 // connect cell types to "EntityRoot"
93 proxyModel = new pqProxySILModel("EntityTree", &this->UI->SILModel);
94 proxyModel->setSourceModel(&this->UI->SILModel);
95 this->UI->Entity->setModel(proxyModel);
96 this->UI->Entity->setHeaderHidden(true);
98 this->UI->entityModel = new pqProxySILModel("Entity", &this->UI->SILModel);
99 this->UI->entityModel->setSourceModel(&this->UI->SILModel);
103 this->UI->Groups->header()->setStretchLastSection(true);
104 this->UI->Entity->header()->setStretchLastSection(true);
106 this->linkServerManagerProperties();
108 QList<pqTreeWidget*> treeWidgets = this->findChildren<pqTreeWidget*> ();
109 foreach (pqTreeWidget* tree, treeWidgets)
111 new pqTreeWidgetSelectionHelper(tree);
114 QList<pqTreeView*> treeViews = this->findChildren<pqTreeView*> ();
115 foreach (pqTreeView* tree, treeViews)
117 new pqTreeViewSelectionHelper(tree);
120 this->connect(this->UI->groupModel, SIGNAL(valuesChanged()),
121 this, SLOT(setModified()));
122 this->connect(this->UI->entityModel, SIGNAL(valuesChanged()),
123 this, SLOT(setModified()));
125 this->UI->tabWidget->setCurrentIndex(0);
127 this->UI->VTKConnect->Connect(this->proxy(),
128 vtkCommand::UpdateInformationEvent, this, SLOT(updateSIL()));
132 pqExtractGroupPanel::~pqExtractGroupPanel()
136 void pqExtractGroupPanel::linkServerManagerProperties()
138 this->UI->Links.addPropertyLink(this->UI->groupModel, "values",
139 SIGNAL(valuesChanged()), this->proxy(), this->proxy()->GetProperty(
142 this->UI->Links.addPropertyLink(this->UI->entityModel, "values",
143 SIGNAL(valuesChanged()), this->proxy(), this->proxy()->GetProperty(
146 this->Superclass::linkServerManagerProperties();
150 void pqExtractGroupPanel::updateSIL()
153 //<<<<<<< HEAD:ParaViewPlugin/pqExtractGroupPanel.cxx
155 this->proxy()->UpdatePropertyInformation(
156 this->proxy()->GetProperty("SILUpdateStamp"));
158 //>>>>>>> medparallel:ParaViewPlugin/pqExtractGroupPanel.cxx
160 vtkSMProxy* reader = this->referenceProxy()->getProxy();
161 reader->UpdatePropertyInformation(reader->GetProperty("SILUpdateStamp"));
163 int stamp = vtkSMPropertyHelper(reader, "SILUpdateStamp").GetAsInt();
164 if (stamp != this->UI->SILUpdateStamp)
166 this->UI->SILUpdateStamp = stamp;
167 vtkPVSILInformation* info = vtkPVSILInformation::New();
168 reader->GatherInformation(info);
169 this->UI->SILModel.update(info->GetSIL());
171 this->UI->Groups->expandAll();
172 this->UI->Entity->expandAll();