From: Anthony Geay Date: Tue, 14 Apr 2015 14:04:08 +0000 (+0200) Subject: 0023021: [CEA 1440] Setting the field to display in python with reader.AllArrays... X-Git-Tag: V7_6_0rc1~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c0e923b44dea4291c82885d8a71ea83d68d45898;p=modules%2Fparavis.git 0023021: [CEA 1440] Setting the field to display in python with reader.AllArrays does not change the fields set in the MEDReader properties --- diff --git a/src/Plugins/MEDReader/IO/vtkMEDReader.cxx b/src/Plugins/MEDReader/IO/vtkMEDReader.cxx index 338c961c..0dca27f6 100644 --- a/src/Plugins/MEDReader/IO/vtkMEDReader.cxx +++ b/src/Plugins/MEDReader/IO/vtkMEDReader.cxx @@ -150,7 +150,7 @@ class vtkMEDReader::vtkMEDReaderInternal { public: - vtkMEDReaderInternal(vtkMEDReader *master):TK(0),IsMEDOrSauv(true),IsStdOrMode(false),GenerateVect(false),SIL(0),LastLev0(-1),FirstCall0(2),PK(master) + vtkMEDReaderInternal(vtkMEDReader *master):TK(0),IsMEDOrSauv(true),IsStdOrMode(false),GenerateVect(false),SIL(0),LastLev0(-1),FirstCall0(2),PK(master),MyMTime(0) { } @@ -184,6 +184,8 @@ public: int LastLev0; // The property keeper is usable only in pvsm mode. PropertyKeeper PK; + int MyMTime; + std::set _wonderful_set;// this set is used by SetFieldsStatus method to detect the fact that SetFieldsStatus has been called for all items ! Great ! private: unsigned char FirstCall0; }; @@ -212,6 +214,11 @@ void vtkMEDReader::Reload(int a) this->SetFileName(fName.c_str()); } +int vtkMEDReader::GetServerModifTime() +{ + return this->Internal->MyMTime; +} + void vtkMEDReader::GenerateVectors(int val) { if(this->Internal->FileName.empty()) @@ -353,19 +360,26 @@ int vtkMEDReader::RequestData(vtkInformation *request, vtkInformationVector **in void vtkMEDReader::SetFieldsStatus(const char* name, int status) { - //std::cerr << "vtkMEDReader::SetFieldsStatus(" << name << "," << status << ") called !" << std::endl; + //this->Internal->_wonderful_set.insert(name); if(this->Internal->FileName.empty()) {//pvsm mode this->Internal->PK.pushFieldStatusEntry(name,status); return ; } + this->Internal->_wonderful_set.insert(name); //not pvsm mode (general case) try { this->Internal->Tree.changeStatusOfAndUpdateToHaveCoherentVTKDataSet(this->Internal->Tree.getIdHavingZeName(name),status); - if(std::string(name)==GetFieldsTreeArrayName(GetNumberOfFieldsTreeArrays()-1)) - if(!this->Internal->PluginStart0()) - this->Modified(); + if(this->Internal->_wonderful_set.size()==GetNumberOfFieldsTreeArrays()) + { + if(!this->Internal->PluginStart0()) + { + this->Modified(); + } + this->Internal->MyMTime++; + this->Internal->_wonderful_set.clear(); + } } catch(INTERP_KERNEL::Exception& e) { @@ -381,9 +395,8 @@ int vtkMEDReader::GetNumberOfFieldsTreeArrays() { if(!this->Internal) return 0; - int ret(this->Internal->Tree.getNumberOfLeavesArrays()); + return this->Internal->Tree.getNumberOfLeavesArrays(); //std::cerr << "vtkMEDReader::GetNumberOfFieldsTreeArrays called ! " << ret << std::endl; - return ret; } const char *vtkMEDReader::GetFieldsTreeArrayName(int index) diff --git a/src/Plugins/MEDReader/IO/vtkMEDReader.h b/src/Plugins/MEDReader/IO/vtkMEDReader.h index 3effd17a..8412f3a2 100644 --- a/src/Plugins/MEDReader/IO/vtkMEDReader.h +++ b/src/Plugins/MEDReader/IO/vtkMEDReader.h @@ -53,6 +53,8 @@ class VTK_EXPORT vtkMEDReader : public vtkMultiBlockDataSetAlgorithm //! Build the graph used to pass information to the client on the supports virtual std::string BuildSIL(vtkMutableDirectedGraph*); virtual void Reload(int); + virtual int GetServerModifTime(); + // virtual void GenerateVectors(int); virtual void ChangeMode(int); virtual const char *GetSeparator(); diff --git a/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml b/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml index 64b3169f..cf89105d 100644 --- a/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml +++ b/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml @@ -28,6 +28,10 @@ + + + + TreeItemToPropMap; }; -pqMEDReaderPanel::pqMEDReaderPanel(pqProxy *object_proxy, QWidget *p):Superclass(object_proxy,p),_reload_req(false),_is_fields_status_changed(false),_optional_widget(0) +pqMEDReaderPanel::pqMEDReaderPanel(pqProxy *object_proxy, QWidget *p):Superclass(object_proxy,p),_reload_req(false),_is_fields_status_changed(false),_optional_widget(0),_my_mtime(0),_sm_prop_remote_mtime(0) { initAll(); } @@ -149,7 +149,11 @@ void pqMEDReaderPanel::initAll() this->UI->setupUi(this); this->UI->Fields->setHeaderHidden(true); this->updateSIL(); - //////////////////// + // + _sm_prop_remote_mtime=dynamic_cast(this->proxy()->GetProperty("ServerModifTime")); + if(_sm_prop_remote_mtime) + _sm_prop_remote_mtime->SetImmediateUpdate(1); + // vtkSMProxy *reader(this->referenceProxy()->getProxy()); vtkPVSILInformation *info(vtkPVSILInformation::New()); reader->GatherInformation(info); @@ -200,6 +204,7 @@ void pqMEDReaderPanel::initAll() vtkIdType id1(it0->Next()); // vtkSMProperty *SMProperty(this->proxy()->GetProperty("FieldsStatus")); + vtkSMProperty *SMPropertyRead(this->proxy()->GetProperty("FieldsTreeInfo")); SMProperty->ResetToDefault();//this line is very important ! // QString name0(QString::fromStdString((const char *)verticesNames2->GetValue(id1))); QList strs0; strs0.append(name0); @@ -257,7 +262,6 @@ void pqMEDReaderPanel::initAll() pqTreeWidgetItemObject *item3(new pqTreeWidgetItemObject(item2,strs3)); _all_lev4.push_back(item3); item3->setData(0,Qt::UserRole,name3); - item3->setChecked(false); if(isSpecial) { QFont font; font.setItalic(true); font.setUnderline(true); @@ -273,15 +277,10 @@ void pqMEDReaderPanel::initAll() _leaves.insert(std::pair(item3,ll)); std::ostringstream pdm; pdm << name0.toStdString() << "/" << name1.toStdString() << "/" << name2.toStdString() << "/" << name3CppFull; (static_cast(SMProperty))->SetElement(2*ll,pdm.str().c_str()); - ////char tmp2[2]; tmp2[0]=(kk==0?'1':'0'); tmp2[1]='\0'; - ////std::string tmp(tmp2); - ////(static_cast(SMProperty))->SetElement(2*ll+1,tmp.c_str()); - //SMProperty->ResetToDefault(); - const char *tmp((static_cast(SMProperty))->GetElement(2*ll+1)); - ////item2->setChecked(kk==0); - ////item3->setChecked(kk==0); + const char *tmp((static_cast(SMPropertyRead))->GetElement(2*ll+1)); item3->setChecked(tmp[0]=='1'); item3->setProperty("PosInStringVector",QVariant(ll)); + item3->setProperty("ZeKey",QVariant(QString(pdm.str().c_str()))); connect(item3,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev4HasBeenFired())); ll++; } @@ -350,6 +349,21 @@ void pqMEDReaderPanel::linkServerManagerProperties() this->Superclass::linkServerManagerProperties(); } +void pqMEDReaderPanel::paintEvent(QPaintEvent *event) +{ + if(_sm_prop_remote_mtime) + { + int remoteMTimeVal(_sm_prop_remote_mtime->GetElement(0)); + if(remoteMTimeVal>_my_mtime) + { + //std::cout << "Refresh MEDReader panel due to external update." << std::endl; + updateCheckStatusOfLev4FromServerState(); + _my_mtime=remoteMTimeVal; + } + } + pqNamedObjectPanel::paintEvent(event); +} + void pqMEDReaderPanel::updateSIL() { if(_reload_req) @@ -509,6 +523,37 @@ void pqMEDReaderPanel::vectOfBoolWidgetRequested(bool isMode) } } +void pqMEDReaderPanel::updateCheckStatusOfLev4FromServerState() +{ + this->proxy()->UpdatePropertyInformation(); + vtkSMStringVectorProperty *SMProperty(static_cast(this->proxy()->GetProperty("FieldsTreeInfo"))); + for(std::vector::const_iterator it=_all_lev4.begin();it!=_all_lev4.end();it++) + { + pqTreeWidgetItemObject *elt(*it); + if(!elt) + continue; + QVariant v(elt->property("PosInStringVector")); + if(v.isNull()) + continue; + bool isOK; + int pos(v.toInt(&isOK)); + if(!isOK) + continue; + const char *tmp(SMProperty->GetElement(2*pos+1)); + bool posCheckTarget(tmp[0]=='1'),actualPos(elt->isChecked()); + if(actualPos!=posCheckTarget) + { + QTreeWidgetItem *curFather(elt->QTreeWidgetItem::parent()); + pqTreeWidgetItemObject *father(dynamic_cast(curFather)); + disconnect(father,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev3HasBeenFired(bool))); + disconnect(elt,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev4HasBeenFired())); + elt->setChecked(posCheckTarget); + connect(elt,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev4HasBeenFired())); + connect(father,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev3HasBeenFired(bool))); + } + } +} + void pqMEDReaderPanel::getCurrentTS(QStringList& its, QStringList& dts, QStringList& tts) const { @@ -562,8 +607,6 @@ void pqMEDReaderPanel::somethingChangedInFieldRepr() vtkSMStringVectorProperty *sm(dynamic_cast(SMProperty)); unsigned int nb(sm->GetNumberOfElements()); std::vector sts(nb); - for(unsigned int i=0;iGetElement(i); /// pqExodusIIVariableSelectionWidget *sc(this->UI->Fields); for(int i0=0;i0topLevelItemCount();i0++) @@ -582,12 +625,13 @@ void pqMEDReaderPanel::somethingChangedInFieldRepr() int ll(scc->property("PosInStringVector").toInt()); int v(scc->isChecked()); std::ostringstream oss; oss << v; + sts[2*ll]=scc->property("ZeKey").toString().toStdString(); sts[2*ll+1]=oss.str(); } } } } - /// + // const char **args=new const char *[nb]; for(unsigned int i=0;i > _leaves; VectBoolWidget *_optional_widget; + int _my_mtime; + vtkSMIntVectorProperty *_sm_prop_remote_mtime; }; #endif