1 // Copyright (C) 2010-2015 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
19 // Author : Anthony Geay
21 #include "pqMEDReaderPanel.h"
22 #include "ui_MEDReaderPanel.h"
23 #include "VectBoolWidget.h"
25 #include "vtkProcessModule.h"
26 #include "vtkMultiBlockDataSet.h"
27 #include "vtkInformation.h"
28 #include "vtkIntArray.h"
29 #include "vtkSMDoubleVectorProperty.h"
30 #include "vtkSMIntVectorProperty.h"
31 #include "vtkSMStringVectorProperty.h"
32 #include "vtkSMProxy.h"
33 #include "vtkEventQtSlotConnect.h"
34 #include "vtkPVSILInformation.h"
36 #include "vtkMutableDirectedGraph.h"
37 #include "vtkAdjacentVertexIterator.h"
38 #include "vtkSMPropertyHelper.h"
39 #include "vtkStringArray.h"
40 #include "vtkDataSetAttributes.h"
41 #include "vtkMEDReader.h"
42 #include "vtkSMSourceProxy.h"
44 #include "pqTreeWidgetItemObject.h"
45 #include "pqSMAdaptor.h"
47 #include "pqPropertyManager.h"
48 #include "pqSILModel.h"
49 #include "pqProxySILModel.h"
50 #include "pqTreeViewSelectionHelper.h"
51 #include "pqTreeWidgetSelectionHelper.h"
53 #include <QHeaderView>
57 static const char ZE_SEP[]="@@][@@";
62 static const PixSingle &GetInstance();
63 QPixmap getPixFromStr(const std::string& st) const;
64 QPixmap getWholeMeshPix() const;
67 static const int NB_OF_DISCR=4;
68 static PixSingle *UNIQUE_PIX_SINGLE;
69 QPixmap _pixmaps[NB_OF_DISCR];
70 std::map<std::string,int> _ze_map;
74 PixSingle *PixSingle::UNIQUE_PIX_SINGLE=0;
76 const PixSingle &PixSingle::GetInstance()
78 if(!UNIQUE_PIX_SINGLE)
79 UNIQUE_PIX_SINGLE=new PixSingle;
80 return *UNIQUE_PIX_SINGLE;
83 PixSingle::PixSingle()
85 _pixmaps[0]=QPixmap(":/ParaViewResources/Icons/pqCellData16.png");
86 _pixmaps[1]=QPixmap(":/ParaViewResources/Icons/pqPointData16.png");
87 _pixmaps[2]=QPixmap(":/ParaViewResources/Icons/pqQuadratureData16.png");
88 _pixmaps[3]=QPixmap(":/ParaViewResources/Icons/pqElnoData16.png");
89 _ze_map[std::string("P0")]=0;
90 _ze_map[std::string("P1")]=1;
91 _ze_map[std::string("GAUSS")]=2;
92 _ze_map[std::string("GSSNE")]=3;
93 _whole_mesh=QPixmap(":/ParaViewResources/Icons/pqCellDataForWholeMesh16.png");
96 QPixmap PixSingle::getPixFromStr(const std::string& st) const
98 std::map<std::string,int>::const_iterator it(_ze_map.find(st));
100 return _pixmaps[(*it).second];
105 QPixmap PixSingle::getWholeMeshPix() const
110 class pqMEDReaderPanel::pqUI: public QObject, public Ui::MEDReaderPanel
113 pqUI(pqMEDReaderPanel *p):QObject(p)
115 this->VTKConnect = vtkSmartPointer<vtkEventQtSlotConnect>::New();
120 vtkSmartPointer<vtkEventQtSlotConnect> VTKConnect;
121 QMap<QTreeWidgetItem*, QString> TreeItemToPropMap;
124 pqMEDReaderPanel::pqMEDReaderPanel(pqProxy *object_proxy, QWidget *p):Superclass(object_proxy,p),_reload_req(false),_optional_widget(0),_my_mtime(0),_sm_prop_remote_mtime(0)
129 // VSR, 16/03/2015, PAL22921
130 // Below is the helper class which is implemented a workaround about ugly pqTreeWidgetItemObject class.
131 // We use this helper class to make 1st and 2nd level tree items uncheckable.
132 class pqMyTreeWidgetItemObject : public pqTreeWidgetItemObject
135 pqMyTreeWidgetItemObject(const QStringList& t, int type=QTreeWidgetItem::UserType): pqTreeWidgetItemObject(t, type){}
136 pqMyTreeWidgetItemObject(QTreeWidget* p, const QStringList& t, int type=QTreeWidgetItem::UserType): pqTreeWidgetItemObject(p, t, type){}
137 pqMyTreeWidgetItemObject(QTreeWidgetItem* p, const QStringList& t, int type=QTreeWidgetItem::UserType): pqTreeWidgetItemObject(p, t, type){}
138 virtual void setData ( int column, int role, const QVariant & value )
140 if ( role != Qt::CheckStateRole)
141 pqTreeWidgetItemObject::setData(column, role, value );
145 void pqMEDReaderPanel::initAll()
148 this->UI=new pqUI(this);
149 this->UI->setupUi(this);
150 this->UI->Fields->setHeaderHidden(true);
153 _sm_prop_remote_mtime=dynamic_cast<vtkSMIntVectorProperty *>(this->proxy()->GetProperty("ServerModifTime"));
154 if(_sm_prop_remote_mtime)
155 _sm_prop_remote_mtime->SetImmediateUpdate(1);
157 vtkSMProxy *reader(this->referenceProxy()->getProxy());
158 vtkPVSILInformation *info(vtkPVSILInformation::New());
159 reader->GatherInformation(info);
160 vtkGraph *g(info->GetSIL());
161 if(!g)//something wrong server side...
163 //vtkMutableDirectedGraph *g2(vtkMutableDirectedGraph::SafeDownCast(g));// agy: this line does not work in client/server mode ! but it works in standard mode ! Don't know why. ParaView bug ?
164 vtkMutableDirectedGraph *g2(static_cast<vtkMutableDirectedGraph *>(g));
166 vtkAbstractArray *verticesNames(g2->GetVertexData()->GetAbstractArray("Names",idNames));
167 vtkStringArray *verticesNames2(vtkStringArray::SafeDownCast(verticesNames));
170 for(int i=0;i<verticesNames2->GetNumberOfValues();i++)
172 vtkStdString &st(verticesNames2->GetValue(i));
173 if(st=="FieldsStatusTree")
180 std::cerr << "There is an internal error ! The tree on server side has not the expected look !" << std::endl;
181 vtkAdjacentVertexIterator *it0(vtkAdjacentVertexIterator::New());
182 g2->GetAdjacentVertices(id0,it0);
184 while(it0->HasNext())
186 vtkIdType idToolTipForTS(it0->Next());
187 QString toolTipName0(QString::fromStdString((const char *)verticesNames2->GetValue(idToolTipForTS)));
189 QList<QString> dts,its,tts;
191 vtkAdjacentVertexIterator *itForTS(vtkAdjacentVertexIterator::New());
192 g2->GetAdjacentVertices(idToolTipForTS,itForTS);
193 vtkIdType idForNbTS(itForTS->Next());
194 nbTS=QString::fromStdString((const char *)verticesNames2->GetValue(idForNbTS));
196 int nbTSInt(nbTS.toInt());
197 for(int ii=0;ii<nbTSInt;ii++)
199 dts.push_back(QString::fromStdString((const char *)verticesNames2->GetValue(idForNbTS+3*ii+1)));
200 its.push_back(QString::fromStdString((const char *)verticesNames2->GetValue(idForNbTS+3*ii+2)));
201 tts.push_back(QString::fromStdString((const char *)verticesNames2->GetValue(idForNbTS+3*ii+3)));
204 vtkIdType id1(it0->Next());
206 vtkSMProperty *SMProperty(this->proxy()->GetProperty("FieldsStatus"));
207 vtkSMProperty *SMPropertyRead(this->proxy()->GetProperty("FieldsTreeInfo"));
208 SMProperty->ResetToDefault();//this line is very important !
210 QString name0(QString::fromStdString((const char *)verticesNames2->GetValue(id1))); QList<QString> strs0; strs0.append(name0);
211 pqTreeWidgetItemObject *item0(new pqMyTreeWidgetItemObject(this->UI->Fields,strs0));
212 item0->setData(0,Qt::UserRole,name0);
213 item0->setData(0,Qt::ToolTipRole,toolTipName0);
215 QList<QVariant> modulesAct;
216 for(int i=0;i<nbTS.toInt();i++)
217 modulesAct.push_back(QVariant(true));
218 item0->setProperty("NbOfTS",nbTS);
219 item0->setProperty("DTS",QVariant(dts));
220 item0->setProperty("ITS",QVariant(its));
221 item0->setProperty("TTS",QVariant(tts));
222 item0->setProperty("ChosenTS",QVariant(modulesAct));
224 vtkAdjacentVertexIterator *it1(vtkAdjacentVertexIterator::New());//mesh
225 g2->GetAdjacentVertices(id1,it1);
226 while(it1->HasNext())
228 vtkIdType id2(it1->Next());
229 QString name1(QString::fromStdString((const char *)verticesNames2->GetValue(id2))); QList<QString> strs1; strs1.append(name1);
230 QString toolTipName1(name1);
231 pqTreeWidgetItemObject *item1(new pqMyTreeWidgetItemObject(item0,strs1));
232 item1->setData(0,Qt::UserRole,name1);
233 item1->setData(0,Qt::ToolTipRole,toolTipName1);
234 vtkAdjacentVertexIterator *it2(vtkAdjacentVertexIterator::New());//common support
235 g2->GetAdjacentVertices(id2,it2);
236 while(it2->HasNext())
238 vtkIdType id3(it2->Next());
239 QString name2(QString::fromStdString((const char *)verticesNames2->GetValue(id3))); QList<QString> strs2; strs2.append(name2);
240 pqTreeWidgetItemObject *item2(new pqTreeWidgetItemObject(item1,strs2));
241 item2->setData(0,Qt::UserRole,name2);
242 item2->setChecked(false);
243 vtkAdjacentVertexIterator *it3(vtkAdjacentVertexIterator::New());//fields !
244 g2->GetAdjacentVertices(id3,it3);
245 vtkIdType id3Arrs(it3->Next());
246 vtkAdjacentVertexIterator *it3Arrs(vtkAdjacentVertexIterator::New());//arrs in fields !
247 g2->GetAdjacentVertices(id3Arrs,it3Arrs);
248 while(it3Arrs->HasNext())
250 vtkIdType id4(it3Arrs->Next());
251 std::string name3CppFull((const char *)verticesNames2->GetValue(id4));
252 std::size_t pos(name3CppFull.find(ZE_SEP));
253 std::string name3Only(name3CppFull.substr(0,pos)); std::string spatialDiscr(name3CppFull.substr(pos+sizeof(ZE_SEP)-1));
254 QString name3(QString::fromStdString(name3Only)); QList<QString> strs3; strs3.append(name3);
255 QString toolTipName3(name3+QString(" (")+spatialDiscr.c_str()+QString(")"));
257 vtkAdjacentVertexIterator *it4(vtkAdjacentVertexIterator::New());// is it a special field ? A field mesh ?
258 g2->GetAdjacentVertices(id4,it4);
259 bool isSpecial(it4->HasNext());
262 pqTreeWidgetItemObject *item3(new pqTreeWidgetItemObject(item2,strs3));
263 _all_lev4.push_back(item3);
264 item3->setData(0,Qt::UserRole,name3);
267 QFont font; font.setItalic(true); font.setUnderline(true);
268 item3->setData(0,Qt::FontRole,QVariant(font));
269 item3->setData(0,Qt::ToolTipRole,QString("Whole \"%1\" mesh").arg(name3));
270 item3->setData(0,Qt::DecorationRole,PixSingle::GetInstance().getWholeMeshPix());
274 item3->setData(0,Qt::ToolTipRole,toolTipName3);
275 item3->setData(0,Qt::DecorationRole,PixSingle::GetInstance().getPixFromStr(spatialDiscr));
277 _leaves.insert(std::pair<pqTreeWidgetItemObject *,int>(item3,ll));
278 std::ostringstream pdm; pdm << name0.toStdString() << "/" << name1.toStdString() << "/" << name2.toStdString() << "/" << name3CppFull;
279 (static_cast<vtkSMStringVectorProperty *>(SMProperty))->SetElement(2*ll,pdm.str().c_str());
280 const char *tmp((static_cast<vtkSMStringVectorProperty *>(SMPropertyRead))->GetElement(2*ll+1));
281 item3->setChecked(tmp[0]=='1');
282 item3->setProperty("PosInStringVector",QVariant(ll));
283 item3->setProperty("ZeKey",QVariant(QString(pdm.str().c_str())));
284 connect(item3,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev4HasBeenFired()));
287 connect(item2,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev3HasBeenFired(bool)));
288 vtkIdType id3Gts(it3->Next());
289 vtkAdjacentVertexIterator *it3Gts(vtkAdjacentVertexIterator::New());//geo types in fields !
290 g2->GetAdjacentVertices(id3Gts,it3Gts);
291 QString toolTipName2(name2);
292 while(it3Gts->HasNext())
294 vtkIdType idGt(it3Gts->Next());
295 std::string gtName((const char *)verticesNames2->GetValue(idGt));
296 toolTipName2=QString("%1\n- %2").arg(toolTipName2).arg(QString(gtName.c_str()));
298 item2->setData(0,Qt::ToolTipRole,toolTipName2);
309 this->UI->Fields->header()->setStretchLastSection(true);
310 this->UI->Fields->expandAll();
312 this->UI->stdMode->setChecked(true);
313 this->UI->VTKConnect->Connect(this->proxy(),vtkCommand::UpdateInformationEvent, this, SLOT(updateSIL()));
315 this->UI->Reload->setProperty("NbOfReloadDynProp",QVariant(1));
316 vtkSMProperty *SMProperty(this->proxy()->GetProperty("ReloadReq"));
317 connect(this->UI->Reload,SIGNAL(pressed()),this,SLOT(reloadFired()));
318 this->propertyManager()->registerLink(this->UI->Reload,"NbOfReloadDynProp",SIGNAL(pressed()),this->proxy(),SMProperty);
320 vtkSMProperty *SMProperty0(this->proxy()->GetProperty("GenerateVectors"));
321 this->propertyManager()->registerLink(this->UI->GenerateVects,"checked",SIGNAL(stateChanged(int)),this->proxy(),SMProperty0);
323 vtkSMProperty *SMProperty2(this->proxy()->GetProperty("TimeOrModal"));
324 SMProperty2->ResetToDefault();//this line is very important !
325 this->propertyManager()->registerLink(this->UI->modeMode,"checked",SIGNAL(toggled(bool)),this->proxy(),SMProperty2);
327 delete _optional_widget;
328 _optional_widget=new VectBoolWidget(this->UI->timeStepsInspector,getMaxNumberOfTS());
329 _optional_widget->hide();
330 this->UI->timeStepsInspector->setMinimumSize(QSize(0,0));
331 connect(this->UI->modeMode,SIGNAL(toggled(bool)),this,SLOT(vectOfBoolWidgetRequested(bool)));
332 vtkSMProperty *SMProperty3(this->proxy()->GetProperty("TimesFlagsStatus"));
333 SMProperty3->ResetToDefault();
334 const QVector<VectBoolItem *>& items(_optional_widget->getItems());
336 foreach(VectBoolItem *item,items)
338 this->propertyManager()->registerLink(item,"activated",SIGNAL(changed()),this->proxy(),SMProperty3,itt++);
342 pqMEDReaderPanel::~pqMEDReaderPanel()
344 delete _optional_widget;
347 void pqMEDReaderPanel::linkServerManagerProperties()
349 this->Superclass::linkServerManagerProperties();
352 void pqMEDReaderPanel::updateSIL()
357 this->UI->geometryGroupBox->hide();
359 foreach(QObject *child,children())
361 QLayout *layout(qobject_cast<QLayout *>(child));
369 void pqMEDReaderPanel::aLev3HasBeenFired(bool v)
371 pqTreeWidgetItemObject *zeItem(qobject_cast<pqTreeWidgetItemObject *>(sender()));
374 for(int i=0;i<zeItem->childCount();i++)
376 QTreeWidgetItem *elt(zeItem->child(i));
377 pqTreeWidgetItemObject *eltC(dynamic_cast<pqTreeWidgetItemObject *>(elt));
381 aLev4HasBeenFiredBy(eltC);
385 somethingChangedInFieldRepr();
388 void pqMEDReaderPanel::aLev4HasBeenFired()
390 pqTreeWidgetItemObject *zeItem(qobject_cast<pqTreeWidgetItemObject *>(sender()));
392 aLev4HasBeenFiredBy(zeItem);
394 somethingChangedInFieldRepr();
397 void pqMEDReaderPanel::aLev4HasBeenFiredBy(pqTreeWidgetItemObject *zeItem)
399 pqTreeWidgetItemObject *father(dynamic_cast<pqTreeWidgetItemObject *>(zeItem->QTreeWidgetItem::parent()));
400 QTreeWidgetItem *godFather(father->QTreeWidgetItem::parent()->parent());
403 if(zeItem->isChecked())
405 bool isActivatedTSChanged(false);
406 // This part garantees that all leaves having not the same father than zeItem are desactivated
407 foreach(pqTreeWidgetItemObject* elt,this->_all_lev4)
409 QTreeWidgetItem *testFath(elt->QTreeWidgetItem::parent());
414 disconnect(elt,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev4HasBeenFired()));
415 elt->setChecked(false);
416 connect(elt,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev4HasBeenFired()));
418 if(godFather!=testFath->parent()->parent())
419 isActivatedTSChanged=true;
422 // the user by clicking to a new entry has changed of TimeStepSeries -> notify it to thee time step selector widget
423 if(isActivatedTSChanged)
425 QStringList its,dts,tts;
426 getCurrentTS(its,dts,tts);
427 _optional_widget->setItems(its,dts,tts);
432 // if all are unchecked - check it again
433 bool allItemsAreUnChked(true);
434 foreach(pqTreeWidgetItemObject* elt,this->_all_lev4)
436 if(elt && elt->isChecked())
437 allItemsAreUnChked=false;
439 if(allItemsAreUnChked)
441 disconnect(zeItem,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev4HasBeenFired()));
442 zeItem->setChecked(true);// OK zeItem was required to be unchecked but as it is the last one. Recheck it !
443 connect(zeItem,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev4HasBeenFired()));
448 void pqMEDReaderPanel::putLev3InOrder()
450 std::vector<pqTreeWidgetItemObject *>::iterator it0(_all_lev4.begin()),it1;
451 while(it0!=_all_lev4.end())
453 QTreeWidgetItem *curFather((*it0)->QTreeWidgetItem::parent());
454 for(it1=it0+1;it1!=_all_lev4.end() && (*it1)->QTreeWidgetItem::parent()==curFather;it1++);
455 bool isAllFalse(true),isAllTrue(true);
456 for(std::vector<pqTreeWidgetItemObject *>::iterator it=it0;it!=it1;it++)
458 if((*it)->isChecked())
463 if(isAllFalse || isAllTrue)
465 pqTreeWidgetItemObject *father(dynamic_cast<pqTreeWidgetItemObject *>(curFather));
468 disconnect(father,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev3HasBeenFired(bool)));
469 father->setChecked(isAllTrue);
470 connect(father,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev3HasBeenFired(bool)));
477 void pqMEDReaderPanel::reloadFired()
481 this->UI->Reload->setProperty("NbOfReloadDynProp",v);
483 for(std::set<std::pair<pqTreeWidgetItemObject *,int> >::const_iterator it=_leaves.begin();it!=_leaves.end();it++)
484 ((*it).first)->disconnect(SIGNAL(checkedStateChanged(bool)));
486 vtkSMProperty *SMProperty(this->proxy()->GetProperty("FieldsStatus"));
487 for(std::set<std::pair<pqTreeWidgetItemObject *,int> >::const_iterator it=_leaves.begin();it!=_leaves.end();it++)
488 this->propertyManager()->unregisterLink((*it).first,"checked",SIGNAL(checkedStateChanged(bool)),this->proxy(),SMProperty,(*it).second);
489 this->propertyManager()->propertyChanged();
490 vtkSMProperty *SMProperty3(this->proxy()->GetProperty("TimeOrModal"));
491 this->propertyManager()->unregisterLink(this->UI->modeMode,"checked",SIGNAL(toggled(bool)),this->proxy(),SMProperty3);
494 void pqMEDReaderPanel::vectOfBoolWidgetRequested(bool isMode)
498 this->UI->timeStepsInspector->setMinimumSize(QSize(200,250));
499 _optional_widget->show();
500 QStringList its,dts,tts;
501 getCurrentTS(its,dts,tts);
502 _optional_widget->setItems(its,dts,tts);
506 _optional_widget->hide();
507 this->UI->timeStepsInspector->setMinimumSize(QSize(0,0));
511 void pqMEDReaderPanel::updateCheckStatusOfLev4FromServerState()
513 this->proxy()->UpdatePropertyInformation();
514 vtkSMStringVectorProperty *SMProperty(static_cast<vtkSMStringVectorProperty *>(this->proxy()->GetProperty("FieldsTreeInfo")));
515 for(std::vector<pqTreeWidgetItemObject *>::const_iterator it=_all_lev4.begin();it!=_all_lev4.end();it++)
517 pqTreeWidgetItemObject *elt(*it);
520 QVariant v(elt->property("PosInStringVector"));
524 int pos(v.toInt(&isOK));
527 const char *tmp(SMProperty->GetElement(2*pos+1));
528 bool posCheckTarget(tmp[0]=='1'),actualPos(elt->isChecked());
529 if(actualPos!=posCheckTarget)
531 QTreeWidgetItem *curFather(elt->QTreeWidgetItem::parent());
532 pqTreeWidgetItemObject *father(dynamic_cast<pqTreeWidgetItemObject *>(curFather));
533 disconnect(father,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev3HasBeenFired(bool)));
534 disconnect(elt,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev4HasBeenFired()));
535 elt->setChecked(posCheckTarget);
536 connect(elt,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev4HasBeenFired()));
537 connect(father,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev3HasBeenFired(bool)));
542 void pqMEDReaderPanel::getCurrentTS(QStringList& its, QStringList& dts, QStringList& tts) const
545 for(std::vector<pqTreeWidgetItemObject *>::const_iterator it=_all_lev4.begin();it!=_all_lev4.end();it++)
547 if((*it)->property("checked").toInt())
549 QTreeWidgetItem *obj((*it)->QTreeWidgetItem::parent()->QTreeWidgetItem::parent()->QTreeWidgetItem::parent());
550 pqTreeWidgetItemObject *objC(dynamic_cast<pqTreeWidgetItemObject *>(obj));
551 its=objC->property("ITS").toStringList();
552 dts=objC->property("DTS").toStringList();
553 tts=objC->property("TTS").toStringList();
557 std::cerr << "pqMEDReaderPanel::getCurrentTS : internal error ! Something is going wrong !" << std::endl;
560 int pqMEDReaderPanel::getMaxNumberOfTS() const
563 for(std::vector<pqTreeWidgetItemObject *>::const_iterator it=_all_lev4.begin();it!=_all_lev4.end();it++)
565 QTreeWidgetItem *obj((*it)->QTreeWidgetItem::parent()->QTreeWidgetItem::parent()->QTreeWidgetItem::parent());
566 pqTreeWidgetItemObject *objC(dynamic_cast<pqTreeWidgetItemObject *>(obj));
567 ret=std::max(ret,objC->property("NbOfTS").toInt());
572 void pqMEDReaderPanel::updateInformationAndDomains()
574 //std::cerr << "updateInformationAndDomains called !" << std::endl;
575 pqNamedObjectPanel::updateInformationAndDomains();
576 if(_sm_prop_remote_mtime)
578 int remoteMTimeVal(_sm_prop_remote_mtime->GetElement(0));
579 if(remoteMTimeVal>_my_mtime)
581 //std::cout << "Refresh MEDReader panel due to external update." << std::endl;
582 updateCheckStatusOfLev4FromServerState();
583 _my_mtime=remoteMTimeVal;
586 // now force modification of FieldsStatus property to appear in trace as AllArrays.
587 vtkSMProxy *proxy(this->proxy());
588 vtkSMProperty *SMProperty(proxy->GetProperty("FieldsStatus"));
589 SMProperty->Modified();// agy : THE LINE FOR 7.5.1 !
593 * This slot is called by this->UI->Fields when one/several leaves have been modified.
595 void pqMEDReaderPanel::somethingChangedInFieldRepr()
598 vtkSMProxy *proxy(this->proxy());
599 vtkSMProperty *SMProperty(proxy->GetProperty("FieldsStatus"));
600 vtkSMStringVectorProperty *sm(dynamic_cast<vtkSMStringVectorProperty *>(SMProperty));
601 unsigned int nb(sm->GetNumberOfElements());
602 std::vector<std::string> sts(nb);
604 pqExodusIIVariableSelectionWidget *sc(this->UI->Fields);
605 for(int i0=0;i0<sc->topLevelItemCount();i0++)
607 QTreeWidgetItem *lev0(sc->topLevelItem(i0));//TS
608 for(int i1=0;i1<lev0->childCount();i1++)
610 QTreeWidgetItem *lev1(lev0->child(i1));//Mesh
611 for(int i2=0;i2<lev1->childCount();i2++)
613 QTreeWidgetItem *lev2(lev1->child(i2));//Comp
614 for(int i3=0;i3<lev2->childCount();i3++)
616 QTreeWidgetItem *lev3(lev2->child(i3));
617 pqTreeWidgetItemObject *scc(dynamic_cast<pqTreeWidgetItemObject *>(lev3));
618 int ll(scc->property("PosInStringVector").toInt());
619 int v(scc->isChecked());
620 std::ostringstream oss; oss << v;
621 sts[2*ll]=scc->property("ZeKey").toString().toStdString();
622 sts[2*ll+1]=oss.str();
628 const char **args=new const char *[nb];
629 for(unsigned int i=0;i<nb;i++)
631 args[i]=sts[i].c_str();
633 {//agy : let's go to put info in property FieldsStatus
634 int iup(sm->GetImmediateUpdate());
635 //sm->SetNumberOfElements(0);
636 sm->SetElements(args,nb);
637 proxy->UpdateVTKObjects(); // push properties states abroad
638 sm->SetImmediateUpdate(iup);
642 ((vtkSMSourceProxy *)proxy)->UpdatePipelineInformation();//performs an update of all properties of proxy and proxy itself
643 // here wonderful proxy is declared modified right after FieldsStatus and FieldsTreeInfo -> IMPORTANT : The updated MTime of proxy will be the ref
644 // to detect modified properties. The idea here is to make FieldsTreeInfo property deprecated and so avoid to appear in trace. Don't know why InformationOnly property appear in trace ?