Back to index

salome-paravis  6.5.0
pqExtractGroupPanel.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2010-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "pqExtractGroupPanel.h"
00021 #include "ui_ExtractGroupPanel.h"
00022 
00023 #include "vtkProcessModule.h"
00024 #include "vtkMultiBlockDataSet.h"
00025 #include "vtkInformation.h"
00026 #include "vtkIntArray.h"
00027 #include "vtkSMDoubleVectorProperty.h"
00028 #include "vtkSMIntVectorProperty.h"
00029 #include "vtkSMStringVectorProperty.h"
00030 #include "vtkSMProxy.h"
00031 #include "vtkEventQtSlotConnect.h"
00032 #include "vtkPVSILInformation.h"
00033 #include "vtkGraph.h"
00034 #include "vtkSMPropertyHelper.h"
00035 #include "vtkStringArray.h"
00036 #include "vtkDataSetAttributes.h"
00037 
00038 #include "vtkMedUtilities.h"
00039 
00040 #include "pqTreeWidget.h"
00041 #include "pqTreeWidgetItemObject.h"
00042 #include "pqSMAdaptor.h"
00043 #include "pqProxy.h"
00044 #include "pqPropertyManager.h"
00045 #include "pqSILModel.h"
00046 #include "pqProxySILModel.h"
00047 #include "pqTreeViewSelectionHelper.h"
00048 #include "pqTreeWidgetSelectionHelper.h"
00049 #include "pqPropertyLinks.h"
00050 
00051 #include <QHeaderView>
00052 
00053 class pqExtractGroupPanel::pqUI : public QObject, public Ui::ExtractGroupPanel
00054 {
00055 public:
00056   pqUI(pqExtractGroupPanel* p) :
00057     QObject(p)
00058   {
00059     this->VTKConnect = vtkSmartPointer<vtkEventQtSlotConnect>::New();
00060     this->SILUpdateStamp = -1;
00061   }
00062 
00063   ~pqUI()
00064   {
00065   }
00066 
00067   pqSILModel SILModel;
00068   vtkSmartPointer<vtkEventQtSlotConnect> VTKConnect;
00069   pqPropertyLinks Links;
00070   pqProxySILModel* entityModel;
00071   pqProxySILModel* groupModel;
00072   int SILUpdateStamp;
00073 };
00074 
00075 pqExtractGroupPanel::pqExtractGroupPanel(pqProxy* object_proxy, QWidget* p) :
00076   Superclass(object_proxy, p)
00077 {
00078   this->UI = new pqUI(this);
00079   this->UI->setupUi(this);
00080 
00081   pqProxySILModel* proxyModel;
00082 
00083   // connect groups to groupsRoot
00084   proxyModel = new pqProxySILModel("GroupTree", &this->UI->SILModel);
00085   proxyModel->setSourceModel(&this->UI->SILModel);
00086   this->UI->Groups->setModel(proxyModel);
00087   this->UI->Groups->setHeaderHidden(true);
00088 
00089   this->UI->groupModel = new pqProxySILModel("Groups", &this->UI->SILModel);
00090   this->UI->groupModel->setSourceModel(&this->UI->SILModel);
00091 
00092   // connect cell types to "EntityRoot"
00093   proxyModel = new pqProxySILModel("EntityTree", &this->UI->SILModel);
00094   proxyModel->setSourceModel(&this->UI->SILModel);
00095   this->UI->Entity->setModel(proxyModel);
00096   this->UI->Entity->setHeaderHidden(true);
00097 
00098   this->UI->entityModel = new pqProxySILModel("Entity", &this->UI->SILModel);
00099   this->UI->entityModel->setSourceModel(&this->UI->SILModel);
00100 
00101   this->updateSIL();
00102 
00103   this->UI->Groups->header()->setStretchLastSection(true);
00104   this->UI->Entity->header()->setStretchLastSection(true);
00105 
00106   this->linkServerManagerProperties();
00107 
00108   QList<pqTreeWidget*> treeWidgets = this->findChildren<pqTreeWidget*> ();
00109   foreach (pqTreeWidget* tree, treeWidgets)
00110       {
00111       new pqTreeWidgetSelectionHelper(tree);
00112       }
00113 
00114   QList<pqTreeView*> treeViews = this->findChildren<pqTreeView*> ();
00115   foreach (pqTreeView* tree, treeViews)
00116       {
00117       new pqTreeViewSelectionHelper(tree);
00118       }
00119 
00120   this->connect(this->UI->groupModel, SIGNAL(valuesChanged()),
00121                 this, SLOT(setModified()));
00122   this->connect(this->UI->entityModel, SIGNAL(valuesChanged()),
00123                 this, SLOT(setModified()));
00124 
00125   this->UI->tabWidget->setCurrentIndex(0);
00126 
00127   this->UI->VTKConnect->Connect(this->proxy(),
00128       vtkCommand::UpdateInformationEvent, this, SLOT(updateSIL()));
00129 
00130 }
00131 
00132 pqExtractGroupPanel::~pqExtractGroupPanel()
00133 {
00134 }
00135 
00136 void pqExtractGroupPanel::linkServerManagerProperties()
00137 {
00138   this->UI->Links.addPropertyLink(this->UI->groupModel, "values",
00139       SIGNAL(valuesChanged()), this->proxy(), this->proxy()->GetProperty(
00140           "Groups"));
00141 
00142   this->UI->Links.addPropertyLink(this->UI->entityModel, "values",
00143       SIGNAL(valuesChanged()), this->proxy(), this->proxy()->GetProperty(
00144           "Entity"));
00145 
00146   this->Superclass::linkServerManagerProperties();
00147 
00148 }
00149 
00150 void pqExtractGroupPanel::updateSIL()
00151 {
00152 
00153   vtkSMProxy* reader = this->referenceProxy()->getProxy();
00154   reader->UpdatePropertyInformation(reader->GetProperty("SILUpdateStamp"));
00155 
00156   int stamp = vtkSMPropertyHelper(reader, "SILUpdateStamp").GetAsInt();
00157   if (stamp != this->UI->SILUpdateStamp)
00158     {
00159     this->UI->SILUpdateStamp = stamp;
00160     vtkPVSILInformation* info = vtkPVSILInformation::New();
00161     reader->GatherInformation(info);
00162     this->UI->SILModel.update(info->GetSIL());
00163 
00164     this->UI->Groups->expandAll();
00165     this->UI->Entity->expandAll();
00166 
00167     info->Delete();
00168     }
00169 
00170 }