From: Anthony Geay Date: Wed, 29 Jul 2015 08:12:51 +0000 (+0200) Subject: Porting to PV50 X-Git-Tag: V8_0_0a1~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=88fa99f207bdea2f62e4ecef7421a8c6e00b3ccf;p=modules%2Fparavis.git Porting to PV50 --- diff --git a/src/PVGUI/PVGUI_Module.cxx b/src/PVGUI/PVGUI_Module.cxx index 2b956634..2902f451 100644 --- a/src/PVGUI/PVGUI_Module.cxx +++ b/src/PVGUI/PVGUI_Module.cxx @@ -798,24 +798,25 @@ QString PVGUI_Module::getTraceString() } // Save camera position to, which is no longer output by the tracer ... - VTK_PY_GIL_ENSURE - PyObject * mods(PySys_GetObject(const_cast("modules"))); - PyObject * trace_mod(PyDict_GetItemString(mods, "paraview.smtrace")); // module was already (really) imported by vtkSMTrace - if (PyModule_Check(trace_mod)) { - vtkSmartPyObject save_cam(PyObject_GetAttrString(trace_mod, const_cast("SaveCameras"))); - vtkSmartPyObject camera_trace(PyObject_CallMethod(save_cam, const_cast("get_trace"), NULL)); - // Convert to a single string - vtkSmartPyObject ret(PyString_FromString(end_line.toStdString().c_str())); - vtkSmartPyObject final_string(PyObject_CallMethod(ret, const_cast("join"), - const_cast("O"), (PyObject*)camera_trace)); - if (PyString_CheckExact(final_string)) - { - QString camera_qs(PyString_AsString(final_string)); // deep copy - traceString = traceString + end_line + end_line + QString("#### saving camera placements for all active views") - + end_line + end_line + camera_qs + end_line; - } - } - VTK_PY_GIL_RELEASE + { + vtkPythonScopeGilEnsurer psge; + PyObject * mods(PySys_GetObject(const_cast("modules"))); + PyObject * trace_mod(PyDict_GetItemString(mods, "paraview.smtrace")); // module was already (really) imported by vtkSMTrace + if (PyModule_Check(trace_mod)) { + vtkSmartPyObject save_cam(PyObject_GetAttrString(trace_mod, const_cast("SaveCameras"))); + vtkSmartPyObject camera_trace(PyObject_CallMethod(save_cam, const_cast("get_trace"), NULL)); + // Convert to a single string + vtkSmartPyObject ret(PyString_FromString(end_line.toStdString().c_str())); + vtkSmartPyObject final_string(PyObject_CallMethod(ret, const_cast("join"), + const_cast("O"), (PyObject*)camera_trace)); + if (PyString_CheckExact(final_string)) + { + QString camera_qs(PyString_AsString(final_string)); // deep copy + traceString = traceString + end_line + end_line + QString("#### saving camera placements for all active views") + + end_line + end_line + camera_qs + end_line; + } + } + } return traceString; } diff --git a/src/Plugins/JSONReader/ParaViewPlugin/vtkJSONReader.cxx b/src/Plugins/JSONReader/ParaViewPlugin/vtkJSONReader.cxx index 5a02d465..adec0627 100644 --- a/src/Plugins/JSONReader/ParaViewPlugin/vtkJSONReader.cxx +++ b/src/Plugins/JSONReader/ParaViewPlugin/vtkJSONReader.cxx @@ -30,8 +30,8 @@ #include #include -#include -#include +#include +#include vtkStandardNewMacro(vtkJSONReader); diff --git a/src/Plugins/MEDReader/CMakeLists.txt b/src/Plugins/MEDReader/CMakeLists.txt index dc157a4a..36f86d08 100644 --- a/src/Plugins/MEDReader/CMakeLists.txt +++ b/src/Plugins/MEDReader/CMakeLists.txt @@ -29,8 +29,10 @@ # -DMEDFILE_ROOT_DIR=/where/is/med-3.0.7_install -DMEDCOUPLING_ROOT_DIR=/where/is/medcoupling_install \ # -DParaView_DIR=/lib/cmake/paraview-4.3 +IF(NOT KW_TESTING_PLATFORM) PROJECT(MEDReader) CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +ENDIF(NOT KW_TESTING_PLATFORM) IF(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) @@ -107,6 +109,7 @@ IF(MEDReader_BUILD_ParaView_Plugin) ADD_SUBDIRECTORY(ParaViewPlugin) ENDIF(MEDReader_BUILD_ParaView_Plugin) +SET(SALOME_BUILD_TESTS ON CACHE BOOL "Build Salome Test") IF(SALOME_BUILD_TESTS) ENABLE_TESTING() ADD_SUBDIRECTORY(Test) diff --git a/src/Plugins/MEDReader/IO/CMakeLists.txt b/src/Plugins/MEDReader/IO/CMakeLists.txt index 1f763b88..ec86a828 100644 --- a/src/Plugins/MEDReader/IO/CMakeLists.txt +++ b/src/Plugins/MEDReader/IO/CMakeLists.txt @@ -48,9 +48,7 @@ ELSE(HDF5_IS_PARALLEL) ENDIF(HDF5_IS_PARALLEL) VTK_MODULE_LIBRARY(vtkMEDReader ${MEDReader_SRCS}) -TARGET_LINK_LIBRARIES(vtkMEDReader vtkPVVTKExtensionsRendering vtkRenderingFreeType vtkRenderingOpenGL - vtkRenderingFreeTypeOpenGL vtkInteractionStyle vtkFiltersCore vtkFiltersGeneral - MEDLoaderForPV ${MEDFILE_C_LIBRARIES}) +TARGET_LINK_LIBRARIES(vtkMEDReader ${PARAVIEW_LIBRARIES} MEDLoaderForPV ${MEDFILE_C_LIBRARIES}) INSTALL( TARGETS vtkMEDReader MEDLoaderForPV diff --git a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx index b3512390..7367368f 100644 --- a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx +++ b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx @@ -50,9 +50,6 @@ #include "vtkFieldData.h" #include "vtkCellData.h" -#include "vtksys/stl/string" -#include "vtksys/ios/fstream" -#include "vtksys/stl/algorithm" #include "vtkMutableDirectedGraph.h" using namespace ParaMEDMEM; @@ -110,7 +107,7 @@ vtkIdTypeArray *ELGACmp::isExisting(const std::vector& locsReallyUs vtkIdTypeArray *ELGACmp::createNew(const ParaMEDMEM::MEDFileFieldGlobsReal *globs, const std::vector& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds) const { - static const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; + const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; std::vector< std::vector > locNames(_loc_names); std::vector elgas(_elgas); std::vector< std::pair< vtkQuadratureSchemeDefinition *, unsigned char > > defs; @@ -167,7 +164,7 @@ vtkIdTypeArray *ELGACmp::createNew(const ParaMEDMEM::MEDFileFieldGlobsReal *glob offset+=delta; } elga->GetInformation()->Set(MEDUtilities::ELGA(),1); - elga->SetArray(pt,ncell,0,VTK_DATA_ARRAY_DELETE); + elga->SetVoidArray(pt,ncell,0,VTK_DATA_ARRAY_DELETE); std::ostringstream oss; oss << "ELGA" << "@" << _loc_names.size(); std::string ossStr(oss.str()); elga->SetName(ossStr.c_str()); @@ -275,8 +272,8 @@ bool MEDFileFieldRepresentationLeavesArrays::setStatus(bool status) const void MEDFileFieldRepresentationLeavesArrays::appendFields(const MEDTimeReq *tr, const ParaMEDMEM::MEDFileFieldGlobsReal *globs, const ParaMEDMEM::MEDMeshMultiLev *mml, const ParaMEDMEM::MEDFileMeshStruct *mst, vtkDataSet *ds) const { - static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; - static const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; + const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; + const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; tr->setNumberOfTS((operator->())->getNumberOfTS()); tr->initIterator(); for(int timeStepId=0;timeStepIdsize();timeStepId++,++(*tr)) @@ -366,7 +363,7 @@ void MEDFileFieldRepresentationLeavesArrays::appendFields(const MEDTimeReq *tr, offset+=delta; } elno->GetInformation()->Set(MEDUtilities::ELNO(),1); - elno->SetArray(pt,ncell,0,VTK_DATA_ARRAY_DELETE); + elno->SetVoidArray(pt,ncell,0,VTK_DATA_ARRAY_DELETE); std::string nameElno("ELNO"); nameElno+="@"; nameElno+=name; elno->SetName(nameElno.c_str()); ds->GetCellData()->AddArray(elno); @@ -634,7 +631,7 @@ void MEDFileFieldRepresentationLeaves::appendFields(const MEDTimeReq *tr, const vtkUnstructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolationUnstructured(MEDUMeshMultiLev *mm) const { - static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; + const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; DataArrayDouble *coordsMC(0); DataArrayByte *typesMC(0); DataArrayInt *cellLocationsMC(0),*cellsMC(0),*faceLocationsMC(0),*facesMC(0); @@ -648,18 +645,18 @@ vtkUnstructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInt vtkUnsignedCharArray *cellTypes(vtkUnsignedCharArray::New()); cellTypes->SetArray(reinterpret_cast(typesSafe->getPointer()),nbOfCells,0,VTK_DATA_ARRAY_FREE); typesSafe->accessToMemArray().setSpecificDeallocator(0); vtkIdTypeArray *cellLocations(vtkIdTypeArray::New()); - cellLocations->SetArray(cellLocationsSafe->getPointer(),nbOfCells,0,VTK_DATA_ARRAY_FREE); cellLocationsSafe->accessToMemArray().setSpecificDeallocator(0); + cellLocations->SetVoidArray(cellLocationsSafe->getPointer(),nbOfCells,0,VTK_DATA_ARRAY_FREE); cellLocationsSafe->accessToMemArray().setSpecificDeallocator(0); vtkCellArray *cells(vtkCellArray::New()); vtkIdTypeArray *cells2(vtkIdTypeArray::New()); - cells2->SetArray(cellsSafe->getPointer(),cellsSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); cellsSafe->accessToMemArray().setSpecificDeallocator(0); + cells2->SetVoidArray(cellsSafe->getPointer(),cellsSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); cellsSafe->accessToMemArray().setSpecificDeallocator(0); cells->SetCells(nbOfCells,cells2); cells2->Delete(); if(faceLocationsMC!=0 && facesMC!=0) { vtkIdTypeArray *faces(vtkIdTypeArray::New()); - faces->SetArray(facesSafe->getPointer(),facesSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); facesSafe->accessToMemArray().setSpecificDeallocator(0); + faces->SetVoidArray(facesSafe->getPointer(),facesSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); facesSafe->accessToMemArray().setSpecificDeallocator(0); vtkIdTypeArray *faceLocations(vtkIdTypeArray::New()); - faceLocations->SetArray(faceLocationsSafe->getPointer(),faceLocationsSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); faceLocationsSafe->accessToMemArray().setSpecificDeallocator(0); + faceLocations->SetVoidArray(faceLocationsSafe->getPointer(),faceLocationsSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); faceLocationsSafe->accessToMemArray().setSpecificDeallocator(0); ret->SetCells(cellTypes,cellLocations,cells,faceLocations,faces); faceLocations->Delete(); faces->Delete(); @@ -689,7 +686,7 @@ vtkUnstructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInt vtkRectilinearGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolationCartesian(ParaMEDMEM::MEDCMeshMultiLev *mm) const { - static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; + const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; bool isInternal; std::vector< DataArrayDouble * > arrs(mm->buildVTUArrays(isInternal)); vtkDoubleArray *vtkTmp(0); @@ -742,7 +739,7 @@ vtkRectilinearGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInte vtkStructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolationCurveLinear(ParaMEDMEM::MEDCurveLinearMeshMultiLev *mm) const { - static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; + const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; int meshStr[3]={1,1,1}; DataArrayDouble *coords(0); std::vector nodeStrct; @@ -784,7 +781,7 @@ vtkStructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInter vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolation(const MEDTimeReq *tr, const MEDFileFieldGlobsReal *globs, const ParaMEDMEM::MEDFileMeshes *meshes) const { - static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; + const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; vtkDataSet *ret(0); //_fsp->isDataSetSupportEqualToThePreviousOne(i,globs); MEDCouplingAutoRefCountObjectPtr mml(_fsp->buildFromScratchDataSetSupport(0,globs));//0=timestep Id. Make the hypothesis that support does not change @@ -1207,12 +1204,12 @@ void MEDFileFieldRepresentationTree::loadMainStructureOfFile(const char *fileNam this->_data_structure.resize(allFMTSLeavesPerTimeSeriesSafe.size()); for(std::size_t i=0;i meshNamesLoc; + std::vector< std::string > meshNamesLoc; std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr > > splitByMeshName; for(std::size_t j=0;jgetMeshName()); - vtksys_stl::vector< vtksys_stl::string >::iterator it(std::find(meshNamesLoc.begin(),meshNamesLoc.end(),meshName)); + std::vector< std::string >::iterator it(std::find(meshNamesLoc.begin(),meshNamesLoc.end(),meshName)); if(it==meshNamesLoc.end()) { meshNamesLoc.push_back(meshName); @@ -1476,7 +1473,7 @@ void MEDFileFieldRepresentationTree::AppendFieldFromMeshes(const ParaMEDMEM::MED std::string MEDFileFieldRepresentationTree::BuildAUniqueArrayNameForMesh(const std::string& meshName, const ParaMEDMEM::MEDFileFields *ret) { - static const char KEY_STR_TO_AVOID_COLLIDE[]="MESH@"; + const char KEY_STR_TO_AVOID_COLLIDE[]="MESH@"; if(!ret) throw INTERP_KERNEL::Exception("MEDFileFieldRepresentationTree::BuildAUniqueArrayNameForMesh : internal error ! NULL ret !"); std::vector fieldNamesAlreadyExisting(ret->getFieldsNames()); @@ -1536,7 +1533,7 @@ std::vector MEDFileFieldRepresentationTree::SplitFieldNameIntoParts */ std::string MEDFileFieldRepresentationTree::PostProcessFieldName(const std::string& fullFieldName) { - static const char SEP('_'); + const char SEP('_'); std::vector v(SplitFieldNameIntoParts(fullFieldName,SEP)); if(v.empty()) return fullFieldName;//should never happen diff --git a/src/Plugins/MEDReader/IO/module.cmake b/src/Plugins/MEDReader/IO/module.cmake index 645d5d44..5363aad1 100644 --- a/src/Plugins/MEDReader/IO/module.cmake +++ b/src/Plugins/MEDReader/IO/module.cmake @@ -7,6 +7,6 @@ vtk_module(vtkMEDReader vtkRenderingCore vtkTestingRendering vtkInteractionStyle - vtkRenderingFreeTypeOpenGL + #vtkRenderingFreeTypeOpenGL EXCLUDE_FROM_WRAP_HIERARCHY ) diff --git a/src/Plugins/MEDReader/IO/vtkExtractCellType.cxx b/src/Plugins/MEDReader/IO/vtkExtractCellType.cxx index 21c1b4b9..841257af 100644 --- a/src/Plugins/MEDReader/IO/vtkExtractCellType.cxx +++ b/src/Plugins/MEDReader/IO/vtkExtractCellType.cxx @@ -368,8 +368,8 @@ int vtkExtractCellType::RequestInformation(vtkInformation *request, vtkInformati vtkDataSet *FilterFamilies(vtkDataSet *input, const std::vector& idsToKeep, bool insideOut) { - static const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; - static const char ZE_SELECTION_ARR_NAME[]="@@ZeSelection@@"; + const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; + const char ZE_SELECTION_ARR_NAME[]="@@ZeSelection@@"; vtkDataSet *output(input->NewInstance()); output->ShallowCopy(input); vtkSmartPointer thres(vtkSmartPointer::New()); diff --git a/src/Plugins/MEDReader/IO/vtkExtractGroup.cxx b/src/Plugins/MEDReader/IO/vtkExtractGroup.cxx index 1db4ee49..06ceb7a9 100644 --- a/src/Plugins/MEDReader/IO/vtkExtractGroup.cxx +++ b/src/Plugins/MEDReader/IO/vtkExtractGroup.cxx @@ -20,6 +20,7 @@ #include "vtkExtractGroup.h" #include "MEDFileFieldRepresentationTree.hxx" +#include "vtkMEDReader.h" #include "vtkAdjacentVertexIterator.h" #include "vtkIntArray.h" @@ -54,6 +55,7 @@ #include "vtkThreshold.h" #include "vtkMultiBlockDataGroupFilter.h" #include "vtkCompositeDataToUnstructuredGridFilter.h" +#include "vtkInformationDataObjectMetaDataKey.h" #include #include @@ -163,9 +165,12 @@ bool ExtractGroupGrp::isSameAs(const ExtractGroupGrp& other) const bool vtkExtractGroup::vtkExtractGroupInternal::IsInformationOK(vtkInformation *info) { - if(!info->Has(vtkDataObject::SIL())) + // Check the information contain meta data key + if(!info->Has(vtkMEDReader::META_DATA())) return false; - vtkMutableDirectedGraph *sil(vtkMutableDirectedGraph::SafeDownCast(info->Get(vtkDataObject::SIL()))); + + // Recover Meta Data + vtkMutableDirectedGraph *sil(vtkMutableDirectedGraph::SafeDownCast(info->Get(vtkMEDReader::META_DATA()))); if(!sil) return false; int idNames(0); @@ -182,6 +187,16 @@ bool vtkExtractGroup::vtkExtractGroupInternal::IsInformationOK(vtkInformation *i return false; } +const char* vtkExtractGroup::GetGrpStart() +{ + return ExtractGroupGrp::START; +} + +const char* vtkExtractGroup::GetFamStart() +{ + return ExtractGroupFam::START; +} + const char *vtkExtractGroup::vtkExtractGroupInternal::getMeshName() const { return this->_mesh_name.c_str(); @@ -249,7 +264,7 @@ void vtkExtractGroup::vtkExtractGroupInternal::loadFrom(vtkMutableDirectedGraph } itFams->Delete(); } - it0->Delete(); + it0->Delete(); // std::size_t szg(_groups.size()),szf(_fams.size()); if(szg==oldGrps.size() && szf==oldFams.size()) @@ -427,32 +442,22 @@ void vtkExtractGroup::SetInsideOut(int val) int vtkExtractGroup::RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) { - vtkUnstructuredGridAlgorithm::RequestInformation(request,inputVector,outputVector); +// vtkUnstructuredGridAlgorithm::RequestInformation(request,inputVector,outputVector); try { - //std::cerr << "########################################## vtkExtractGroup::RequestInformation ##########################################" << std::endl; +// std::cerr << "########################################## vtkExtractGroup::RequestInformation ##########################################" << std::endl; +// request->Print(cout); vtkInformation *outInfo(outputVector->GetInformationObject(0)); - vtkInformation *inputInfo(inputVector[0]->GetInformationObject(0));//unfortunately inputInfo->Has(vtkDataObject::SIL) returns false... use executive to find it ! - // - vtkExecutive *exe(GetExecutive()); - vtkAlgorithm *alg(this); - vtkInformation *infoOnSIL(alg->GetOutputInformation(0)); - while(!vtkExtractGroup::vtkExtractGroupInternal::IsInformationOK(infoOnSIL))// skipping vtkPVPostFilter - { - if(exe->GetNumberOfInputConnections(0)<1) - { - vtkErrorMacro("No SIL Data available ! The source of this filter must be MEDReader !"); + vtkInformation *inputInfo(inputVector[0]->GetInformationObject(0)); + if(!vtkExtractGroup::vtkExtractGroupInternal::IsInformationOK(inputInfo)) + { + vtkErrorMacro("No SIL Data available ! The source of this filter must be MEDReader !"); return 0; - } - vtkExecutive *exe2(exe->GetInputExecutive(0,0)); - // - alg=exe2->GetAlgorithm(); exe=exe2; infoOnSIL=alg->GetOutputInformation(0); - } - // - this->SetSIL(vtkMutableDirectedGraph::SafeDownCast(infoOnSIL->Get(vtkDataObject::SIL()))); + } + + this->SetSIL(vtkMutableDirectedGraph::SafeDownCast(inputInfo->Get(vtkMEDReader::META_DATA()))); this->Internal->loadFrom(this->SIL); //this->Internal->printMySelf(std::cerr); - outInfo->Set(vtkDataObject::SIL(),this->SIL); } catch(INTERP_KERNEL::Exception& e) { @@ -477,8 +482,8 @@ vtkDataSet *FilterFamilies(vtkSmartPointer& thres, vtkDataSet *input, const std::set& idsToKeep, bool insideOut, const char *arrNameOfFamilyField, const char *associationForThreshold, bool& catchAll, bool& catchSmth) { - static const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; - static const char ZE_SELECTION_ARR_NAME[]="@@ZeSelection@@"; + const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; + const char ZE_SELECTION_ARR_NAME[]="@@ZeSelection@@"; vtkDataSet *output(input->NewInstance()); output->ShallowCopy(input); thres->SetInputData(output); @@ -487,7 +492,7 @@ vtkDataSet *FilterFamilies(vtkSmartPointer& thres, // double vMin(insideOut==0?1.:0.),vMax(insideOut==0?2.:1.); thres->ThresholdBetween(vMin,vMax); - // OK for the output + // OK for the output // CellPointExtractor cpe2(input); vtkDataArray *da(cpe2.Get()->GetScalars(arrNameOfFamilyField)); @@ -560,7 +565,8 @@ int vtkExtractGroup::RequestData(vtkInformation *request, vtkInformationVector * { try { - //std::cerr << "########################################## vtkExtractGroup::RequestData ##########################################" << std::endl; +// std::cerr << "########################################## vtkExtractGroup::RequestData ##########################################" << std::endl; +// request->Print(cout); vtkInformation* inputInfo=inputVector[0]->GetInformationObject(0); vtkDataSet *input(vtkDataSet::SafeDownCast(inputInfo->Get(vtkDataObject::DATA_OBJECT()))); vtkInformation *info(input->GetInformation()); @@ -679,14 +685,14 @@ int vtkExtractGroup::GetNumberOfGroupsFlagsArrays() const char *vtkExtractGroup::GetGroupsFlagsArrayName(int index) { const char *ret(this->Internal->getKeyOfEntry(index)); - //std::cerr << "vtkExtractGroup::GetFieldsTreeArrayName(" << index << ") -> " << ret << std::endl; +// std::cerr << "vtkExtractGroup::GetFieldsTreeArrayName(" << index << ") -> " << ret << std::endl; return ret; } int vtkExtractGroup::GetGroupsFlagsArrayStatus(const char *name) { int ret((int)this->Internal->getStatusOfEntryStr(name)); - //std::cerr << "vtkExtractGroup::GetGroupsFlagsArrayStatus(" << name << ") -> " << ret << std::endl; +// std::cerr << "vtkExtractGroup::GetGroupsFlagsArrayStatus(" << name << ") -> " << ret << std::endl; return ret; } diff --git a/src/Plugins/MEDReader/IO/vtkExtractGroup.h b/src/Plugins/MEDReader/IO/vtkExtractGroup.h index fa01f37d..d3cca44b 100644 --- a/src/Plugins/MEDReader/IO/vtkExtractGroup.h +++ b/src/Plugins/MEDReader/IO/vtkExtractGroup.h @@ -40,6 +40,8 @@ public: // Every time the SIL is updated a this will return a different value. virtual int GetSILUpdateStamp(); const char *GetMeshName(); + static const char* GetGrpStart(); + static const char* GetFamStart(); protected: vtkExtractGroup(); ~vtkExtractGroup(); @@ -49,6 +51,7 @@ protected: int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector); + // Description: // This SIL stores the structure of the mesh/groups/cell types // that can be selected. diff --git a/src/Plugins/MEDReader/IO/vtkGenerateVectors.cxx b/src/Plugins/MEDReader/IO/vtkGenerateVectors.cxx index ceefad36..c60d249c 100644 --- a/src/Plugins/MEDReader/IO/vtkGenerateVectors.cxx +++ b/src/Plugins/MEDReader/IO/vtkGenerateVectors.cxx @@ -70,7 +70,7 @@ void vtkGenerateVectors::Operate(vtkFieldData *fd) vtkDoubleArray *vtkGenerateVectors::Operate2Compo(vtkDoubleArray *oldArr) { - static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; + const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; vtkDoubleArray *ret(vtkDoubleArray::New()); std::size_t nbOfTuples(oldArr->GetNumberOfTuples()); const double *inPt(oldArr->GetPointer(0)); @@ -93,7 +93,7 @@ vtkDoubleArray *vtkGenerateVectors::Operate2Compo(vtkDoubleArray *oldArr) vtkDoubleArray *vtkGenerateVectors::OperateMoreThan3Compo(vtkDoubleArray *oldArr) { - static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; + const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; vtkDoubleArray *ret(vtkDoubleArray::New()); int nbOfCompo(oldArr->GetNumberOfComponents()); std::size_t nbOfTuples(oldArr->GetNumberOfTuples()); diff --git a/src/Plugins/MEDReader/IO/vtkMEDReader.cxx b/src/Plugins/MEDReader/IO/vtkMEDReader.cxx index 07d89f1b..dba03ca0 100644 --- a/src/Plugins/MEDReader/IO/vtkMEDReader.cxx +++ b/src/Plugins/MEDReader/IO/vtkMEDReader.cxx @@ -44,6 +44,8 @@ #include "vtkCellArray.h" #include "vtkDoubleArray.h" #include "vtkObjectFactory.h" +#include "vtkInformationDataObjectMetaDataKey.h" + #ifdef MEDREADER_USE_MPI #include "vtkMultiProcessController.h" #endif @@ -58,7 +60,7 @@ /*! * This class stores properties in loading state mode (pvsm) when the MED file has not been read yet. - * The file is not read beacause FileName has not been informed yet ! So this class stores properties of vtkMEDReader instance that + * The file is not read beacause FileName has not been informed yet ! So this class stores properties of vtkMEDReader instance that * owns it and wait the vtkMEDReader::SetFileName to apply properties afterwards. */ class PropertyKeeper @@ -154,15 +156,16 @@ public: vtkMEDReaderInternal(vtkMEDReader *master):TK(0),IsMEDOrSauv(true),IsStdOrMode(false),GenerateVect(false),SIL(0),LastLev0(-1),FirstCall0(2),PK(master),MyMTime(0) { } - + bool PluginStart0() { + return false; // TODO Useless and buggy if(FirstCall0==0) return false; FirstCall0--; return true; } - + ~vtkMEDReaderInternal() { if(this->SIL) @@ -188,11 +191,13 @@ public: 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 Items are not sorted ! Why ? std::map _wonderful_ref;// this map stores the state before a SetFieldsStatus status. + private: unsigned char FirstCall0; }; vtkStandardNewMacro(vtkMEDReader); +vtkInformationKeyMacro(vtkMEDReader, META_DATA, DataObjectMetaData); vtkMEDReader::vtkMEDReader():Internal(new vtkMEDReaderInternal(this)) { @@ -206,11 +211,8 @@ vtkMEDReader::~vtkMEDReader() this->Internal = 0; } -void vtkMEDReader::Reload(int a) +void vtkMEDReader::Reload() { - if(a==0) - return; - std::cerr << "vtkMEDReader::Reload" << a << std::endl; std::string fName((const char *)this->GetFileName()); delete this->Internal; this->Internal=new vtkMEDReaderInternal(this); @@ -255,7 +257,6 @@ void vtkMEDReader::ChangeMode(int newMode) } //not pvsm mode (general case) this->Internal->IsStdOrMode=newMode!=0; - //std::cerr << "vtkMEDReader::ChangeMode : " << this->Internal->IsStdOrMode << std::endl; this->Modified(); } @@ -320,15 +321,20 @@ char *vtkMEDReader::GetFileName() int vtkMEDReader::RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) { - //std::cerr << "########################################## RequestInformation ##########################################" << std::endl; +// std::cout << "########################################## vtkMEDReader::RequestInformation ##########################################" << std::endl; if(!this->Internal) return 0; try { +// request->Print(cout); vtkInformation *outInfo(outputVector->GetInformationObject(0)); outInfo->Set(vtkDataObject::DATA_TYPE_NAME(),"vtkMultiBlockDataSet"); - this->UpdateSIL(outInfo); - // + this->UpdateSIL(request, outInfo); + + // Set the meta data graph as a meta data key in the information + // That's all that is needed to transfer it along the pipeline + outInfo->Set(vtkMEDReader::META_DATA(),this->Internal->SIL); + bool dummy(false); this->PublishTimeStepsIfNeeded(outInfo,dummy); } @@ -348,22 +354,23 @@ int vtkMEDReader::RequestInformation(vtkInformation *request, vtkInformationVect int vtkMEDReader::RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) { - //std::cerr << "########################################## RequestData ##########################################"; +// std::cout << "########################################## vtkMEDReader::RequestData ##########################################" << std::endl; if(!this->Internal) return 0; try { +// request->Print(cout); vtkInformation *outInfo(outputVector->GetInformationObject(0)); vtkMultiBlockDataSet *output(vtkMultiBlockDataSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()))); bool isUpdated(false); double reqTS(0.); if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP())) reqTS=outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()); - //std::cerr << reqTS << std::endl; this->FillMultiBlockDataSetInstance(output,reqTS); output->GetInformation()->Set(vtkDataObject::DATA_TIME_STEP(),reqTS); - this->UpdateSIL(outInfo); - //this->UpdateProgress((float) progress/((float) maxprogress-1)); + + // Is it really needed ? TODO + this->UpdateSIL(request, outInfo); } catch(INTERP_KERNEL::Exception& e) { @@ -419,7 +426,6 @@ int vtkMEDReader::GetNumberOfFieldsTreeArrays() if(!this->Internal) return 0; return this->Internal->Tree.getNumberOfLeavesArrays(); - //std::cerr << "vtkMEDReader::GetNumberOfFieldsTreeArrays called ! " << ret << std::endl; } const char *vtkMEDReader::GetFieldsTreeArrayName(int index) @@ -427,7 +433,6 @@ const char *vtkMEDReader::GetFieldsTreeArrayName(int index) if(!this->Internal) return 0; return this->Internal->Tree.getNameOfC(index); - //std::cerr << "vtkMEDReader::GetFieldsTreeArrayName(" << index << ") called ! " << ret << std::endl; } int vtkMEDReader::GetFieldsTreeArrayStatus(const char *name) @@ -483,11 +488,13 @@ int vtkMEDReader::GetTimesFlagsArrayStatus(const char *name) return (int)this->Internal->TK.getTimesFlagArray()[pos].first; } -void vtkMEDReader::UpdateSIL(vtkInformation *info) +void vtkMEDReader::UpdateSIL(vtkInformation* request, vtkInformation *info) { if(!this->Internal) return; vtkMutableDirectedGraph *sil(vtkMutableDirectedGraph::New()); + + // This Should be more clever, TODO std::string meshName(this->BuildSIL(sil)); if(meshName!=this->Internal->DftMeshName) { @@ -495,8 +502,6 @@ void vtkMEDReader::UpdateSIL(vtkInformation *info) this->Internal->SIL->Delete(); this->Internal->SIL=sil; this->Internal->DftMeshName=meshName; - info->Set(vtkDataObject::SIL(),this->Internal->SIL); - //request->AppendUnique(vtkExecutive::KEYS_TO_COPY(),vtkDataObject::SIL()); } else { diff --git a/src/Plugins/MEDReader/IO/vtkMEDReader.h b/src/Plugins/MEDReader/IO/vtkMEDReader.h index 8412f3a2..646bbb42 100644 --- a/src/Plugins/MEDReader/IO/vtkMEDReader.h +++ b/src/Plugins/MEDReader/IO/vtkMEDReader.h @@ -26,6 +26,7 @@ #include "vtkMultiBlockDataSetAlgorithm.h" class vtkMutableDirectedGraph; +class vtkInformationDataObjectMetaDataKey; class VTK_EXPORT vtkMEDReader : public vtkMultiBlockDataSetAlgorithm { @@ -52,24 +53,34 @@ class VTK_EXPORT vtkMEDReader : public vtkMultiBlockDataSetAlgorithm virtual const char *GetTimesFlagsArrayName(int index); //! Build the graph used to pass information to the client on the supports virtual std::string BuildSIL(vtkMutableDirectedGraph*); - virtual void Reload(int); + + // Description + // Reload will delete the internal reader and recreate it with default properties + virtual void Reload(); + virtual int GetServerModifTime(); // virtual void GenerateVectors(int); virtual void ChangeMode(int); - virtual const char *GetSeparator(); + static const char *GetSeparator(); + + // Description + // Static information key used to transfer the meta data graph along the pipeline + static vtkInformationDataObjectMetaDataKey* META_DATA(); + protected: vtkMEDReader(); virtual ~vtkMEDReader(); virtual int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*); virtual int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*); private: - void UpdateSIL(vtkInformation *info); + void UpdateSIL(vtkInformation *request, vtkInformation *info); virtual double PublishTimeStepsIfNeeded(vtkInformation*, bool& isUpdated); virtual void FillMultiBlockDataSetInstance(vtkMultiBlockDataSet *output, double reqTS); private: //BTX //ETX + class vtkMEDReaderInternal; vtkMEDReaderInternal* Internal; }; diff --git a/src/Plugins/MEDReader/IO/vtkMEDReader2.cxx b/src/Plugins/MEDReader/IO/vtkMEDReader2.cxx new file mode 100644 index 00000000..a0035f78 --- /dev/null +++ b/src/Plugins/MEDReader/IO/vtkMEDReader2.cxx @@ -0,0 +1,573 @@ +// Copyright (C) 2010-2015 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "vtkMEDReader.h" +#include "vtkGenerateVectors.h" + +#include "vtkMultiBlockDataSet.h" +#include "vtkInformation.h" +#include "vtkDataSetAttributes.h" +#include "vtkStringArray.h" +#include "vtkMutableDirectedGraph.h" +#include "vtkInformationStringKey.h" +// +#include "vtkUnsignedCharArray.h" +#include "vtkInformationVector.h" +#include "vtkSmartPointer.h" +#include "vtkVariantArray.h" +#include "vtkExecutive.h" +#include "vtkStreamingDemandDrivenPipeline.h" +#include "vtkMultiTimeStepAlgorithm.h" +#include "vtkUnstructuredGrid.h" +#include "vtkInformationQuadratureSchemeDefinitionVectorKey.h" +#include "vtkQuadratureSchemeDefinition.h" +#include "vtkPointData.h" +#include "vtkCellData.h" +#include "vtkCellType.h" +#include "vtkCellArray.h" +#include "vtkDoubleArray.h" +#include "vtkObjectFactory.h" +#ifdef MEDREADER_USE_MPI +#include "vtkMultiProcessController.h" +#endif + +#include "MEDFileFieldRepresentationTree.hxx" + +#include +#include +#include +#include +#include + +/*! + * This class stores properties in loading state mode (pvsm) when the MED file has not been read yet. + * The file is not read beacause FileName has not been informed yet ! So this class stores properties of vtkMEDReader instance that + * owns it and wait the vtkMEDReader::SetFileName to apply properties afterwards. + */ +class PropertyKeeper +{ +public: + PropertyKeeper(vtkMEDReader *master):_master(master),IsGVActivated(false),GVValue(0),IsCMActivated(false),CMValue(0) { } + void assignPropertiesIfNeeded(); + bool arePropertiesOnTreeToSetAfter() const; + // + void pushFieldStatusEntry(const char* name, int status); + void pushGenerateVectorsValue(int value); + void pushChangeModeValue(int value); + void pushTimesFlagsStatusEntry(const char* name, int status); +protected: + // pool of pairs to assign in SetFieldsStatus if needed. The use case is the load using pvsm. + std::vector< std::pair > SetFieldsStatusPairs; + // generate vector + bool IsGVActivated; + int GVValue; + // change mode + bool IsCMActivated; + int CMValue; + // + std::vector< std::pair > TimesFlagsStatusPairs; + vtkMEDReader *_master; +}; + +void PropertyKeeper::assignPropertiesIfNeeded() +{ + if(!this->SetFieldsStatusPairs.empty()) + { + for(std::vector< std::pair >::const_iterator it=this->SetFieldsStatusPairs.begin();it!=this->SetFieldsStatusPairs.end();it++) + _master->SetFieldsStatus((*it).first.c_str(),(*it).second); + this->SetFieldsStatusPairs.clear(); + } + if(!this->TimesFlagsStatusPairs.empty()) + { + for(std::vector< std::pair >::const_iterator it=this->TimesFlagsStatusPairs.begin();it!=this->TimesFlagsStatusPairs.end();it++) + _master->SetTimesFlagsStatus((*it).first.c_str(),(*it).second); + this->TimesFlagsStatusPairs.clear(); + } + if(this->IsGVActivated) + { + _master->GenerateVectors(this->GVValue); + this->IsGVActivated=false; + } + if(this->IsCMActivated) + { + _master->ChangeMode(this->CMValue); + this->IsCMActivated=false; + } +} + +void PropertyKeeper::pushFieldStatusEntry(const char* name, int status) +{ + bool found(false); + for(std::vector< std::pair >::const_iterator it=this->SetFieldsStatusPairs.begin();it!=this->SetFieldsStatusPairs.end() && !found;it++) + found=(*it).first==name; + if(!found) + this->SetFieldsStatusPairs.push_back(std::pair(name,status)); +} + +void PropertyKeeper::pushTimesFlagsStatusEntry(const char* name, int status) +{ + bool found(false); + for(std::vector< std::pair >::const_iterator it=this->TimesFlagsStatusPairs.begin();it!=this->TimesFlagsStatusPairs.end() && !found;it++) + found=(*it).first==name; + if(!found) + this->TimesFlagsStatusPairs.push_back(std::pair(name,status)); +} + +void PropertyKeeper::pushGenerateVectorsValue(int value) +{ + this->IsGVActivated=true; + this->GVValue=value; +} + +void PropertyKeeper::pushChangeModeValue(int value) +{ + this->IsCMActivated=true; + this->CMValue=value; +} + +bool PropertyKeeper::arePropertiesOnTreeToSetAfter() const +{ + return !SetFieldsStatusPairs.empty(); +} + +class vtkMEDReader::vtkMEDReaderInternal +{ + +public: + vtkMEDReaderInternal(vtkMEDReader *master):TK(0),IsMEDOrSauv(true),IsStdOrMode(false),GenerateVect(false),SIL(0),LastLev0(-1),FirstCall0(2),PK(master),MyMTime(0), ReloadReq(0) + { + } + + bool PluginStart0() + { + if(FirstCall0==0) + return false; + FirstCall0--; + return true; + } + + ~vtkMEDReaderInternal() + { + if(this->SIL) + this->SIL->Delete(); + } +public: + MEDFileFieldRepresentationTree Tree; + TimeKeeper TK; + std::string FileName; + //when true the file is MED file. when false it is a Sauv file + bool IsMEDOrSauv; + //when false -> std, true -> mode. By default std (false). + bool IsStdOrMode; + //when false -> do nothing. When true cut off or extend to nbOfCompo=3 vector arrays. + bool GenerateVect; + std::string DftMeshName; + // Store the vtkMutableDirectedGraph that represents links between family, groups and cell types + vtkMutableDirectedGraph* SIL; + // store the lev0 id in Tree corresponding to the TIME_STEPS in the pipeline. + 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 Items are not sorted ! Why ? + std::map _wonderful_ref;// this map stores the state before a SetFieldsStatus status. + + int ReloadReq; +private: + unsigned char FirstCall0; +}; + +vtkStandardNewMacro(vtkMEDReader); + +vtkMEDReader::vtkMEDReader():Internal(new vtkMEDReaderInternal(this)) +{ + this->SetNumberOfInputPorts(0); + this->SetNumberOfOutputPorts(1); +} + +vtkMEDReader::~vtkMEDReader() +{ + delete this->Internal; +} + +void vtkMEDReader::Reload() +{ + this->Internal->ReloadReq = this->Internal->ReloadReq++; + std::cerr << "vtkMEDReader::Reload" << std::endl; + std::string fName((const char *)this->GetFileName()); + delete this->Internal; + this->Internal=new vtkMEDReaderInternal(this); + this->SetFileName(fName.c_str()); +} + +int vtkMEDReader::GetReloadReq() +{ + cout<<"Get Reload Req Null" <Internal->ReloadReq; + // this->Internal->ReloadReq = 0; + return ret;*/ +} +int vtkMEDReader::GetReloadReq(int a) +{ + cout<<"Get Reload Req:"<< a <Internal->ReloadReq; + // this->Internal->ReloadReq = 0; + return ret;*/ +} + +int vtkMEDReader::GetServerModifTime() +{ + return this->Internal->MyMTime; +} + +void vtkMEDReader::GenerateVectors(int val) +{ + if(this->Internal->FileName.empty()) + {//pvsm mode + this->Internal->PK.pushGenerateVectorsValue(val); + return ; + } + //not pvsm mode (general case) + bool val2((bool)val); + if(val2!=this->Internal->GenerateVect) + { + this->Internal->GenerateVect=val2; + this->Modified(); + } +} + +void vtkMEDReader::ChangeMode(int newMode) +{ + if(this->Internal->FileName.empty()) + {//pvsm mode + this->Internal->PK.pushChangeModeValue(newMode); + return ; + } + //not pvsm mode (general case) + this->Internal->IsStdOrMode=newMode!=0; + this->Modified(); +} + +const char *vtkMEDReader::GetSeparator() +{ + return MEDFileFieldRepresentationLeavesArrays::ZE_SEP; +} + +void vtkMEDReader::SetFileName(const char *fname) +{ + try + { + this->Internal->FileName=fname; + std::size_t pos(this->Internal->FileName.find_last_of('.')); + if(pos!=std::string::npos) + { + std::string ext(this->Internal->FileName.substr(pos)); + if(ext.find("sauv")!=std::string::npos) + this->Internal->IsMEDOrSauv=false; + } + if(this->Internal->Tree.getNumberOfLeavesArrays()==0) + { + int iPart(-1),nbOfParts(-1); +#ifdef MEDREADER_USE_MPI + vtkMultiProcessController *vmpc(vtkMultiProcessController::GetGlobalController()); + if(vmpc) + { + iPart=vmpc->GetLocalProcessId(); + nbOfParts=vmpc->GetNumberOfProcesses(); + } +#endif + this->Internal->Tree.loadMainStructureOfFile(this->Internal->FileName.c_str(),this->Internal->IsMEDOrSauv,iPart,nbOfParts); + if(!this->Internal->PK.arePropertiesOnTreeToSetAfter()) + this->Internal->Tree.activateTheFirst();//This line manually initialize the status of server (this) with the remote client. + this->Internal->TK.setMaxNumberOfTimeSteps(this->Internal->Tree.getMaxNumberOfTimeSteps()); + } + this->Modified(); + this->Internal->PK.assignPropertiesIfNeeded(); + } + catch(INTERP_KERNEL::Exception& e) + { + delete this->Internal; + this->Internal=0; + std::ostringstream oss; + oss << "Exception has been thrown in vtkMEDReader::SetFileName : " << e.what() << std::endl; + if(this->HasObserver("ErrorEvent") ) + this->InvokeEvent("ErrorEvent",const_cast(oss.str().c_str())); + else + vtkOutputWindowDisplayErrorText(const_cast(oss.str().c_str())); + vtkObject::BreakOnError(); + } +} + +char *vtkMEDReader::GetFileName() +{ + return const_cast(this->Internal->FileName.c_str()); +} + +int vtkMEDReader::RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) +{ + std::cout << "########################################## RequestInformation ##########################################" << std::endl; + if(!this->Internal) + return 0; + try + { + vtkInformation *outInfo(outputVector->GetInformationObject(0)); + outInfo->Set(vtkDataObject::DATA_TYPE_NAME(),"vtkMultiBlockDataSet"); + this->UpdateSIL(outInfo); + // + bool dummy(false); + this->PublishTimeStepsIfNeeded(outInfo,dummy); + } + catch(INTERP_KERNEL::Exception& e) + { + std::ostringstream oss; + oss << "Exception has been thrown in vtkMEDReader::RequestInformation : " << e.what() << std::endl; + if(this->HasObserver("ErrorEvent") ) + this->InvokeEvent("ErrorEvent",const_cast(oss.str().c_str())); + else + vtkOutputWindowDisplayErrorText(const_cast(oss.str().c_str())); + vtkObject::BreakOnError(); + return 0; + } + return 1; +} + +int vtkMEDReader::RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) +{ + std::cout << "########################################## RequestData ##########################################" << std::endl; + if(!this->Internal) + return 0; + try + { + vtkInformation *outInfo(outputVector->GetInformationObject(0)); + vtkMultiBlockDataSet *output(vtkMultiBlockDataSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()))); + bool isUpdated(false); + double reqTS(0.); + if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP())) + reqTS=outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()); + this->FillMultiBlockDataSetInstance(output,reqTS); + output->GetInformation()->Set(vtkDataObject::DATA_TIME_STEP(),reqTS); + this->UpdateSIL(outInfo); + //this->UpdateProgress((float) progress/((float) maxprogress-1)); + } + catch(INTERP_KERNEL::Exception& e) + { + std::cerr << "Exception has been thrown in vtkMEDReader::RequestData : " << e.what() << std::endl; + return 0; + } + return 1; +} + +void vtkMEDReader::SetFieldsStatus(const char* name, int status) +{ + //this->Internal->_wonderful_set.insert(name); + if(this->Internal->FileName.empty()) + {//pvsm mode + this->Internal->PK.pushFieldStatusEntry(name,status); + return ; + } + if(this->Internal->_wonderful_set.empty()) + this->Internal->_wonderful_ref=this->Internal->Tree.dumpState();// start of SetFieldsStatus serie -> store ref to compare at the end of the SetFieldsStatus serie. + this->Internal->_wonderful_set.insert(name); + //not pvsm mode (general case) + try + { + this->Internal->Tree.changeStatusOfAndUpdateToHaveCoherentVTKDataSet(this->Internal->Tree.getIdHavingZeName(name),status); + if(this->Internal->_wonderful_set.size()==GetNumberOfFieldsTreeArrays()) + { + if(this->Internal->_wonderful_ref!=this->Internal->Tree.dumpState()) + { + if(!this->Internal->PluginStart0()) + { + this->Modified(); + } + this->Internal->MyMTime++; + } + this->Internal->_wonderful_set.clear(); + } + } + catch(INTERP_KERNEL::Exception& e) + { + if(!this->Internal->FileName.empty()) + { + std::cerr << "vtkMEDReader::SetFieldsStatus error : " << e.what() << " *** WITH STATUS=" << status << endl; + return ; + } + } +} + +int vtkMEDReader::GetNumberOfFieldsTreeArrays() +{ + if(!this->Internal) + return 0; +// std::cout << "vtkMEDReader::GetNumberOfFieldsTreeArrays called ! " << std::endl; + return this->Internal->Tree.getNumberOfLeavesArrays(); +} + +const char *vtkMEDReader::GetFieldsTreeArrayName(int index) +{ +// std::cout << "vtkMEDReader::GetFieldsTreeArrayName(" << index << ") called ! " << std::endl; + return this->Internal->Tree.getNameOfC(index); +} + +int vtkMEDReader::GetFieldsTreeArrayStatus(const char *name) +{ + int zeId(this->Internal->Tree.getIdHavingZeName(name)); + int ret(this->Internal->Tree.getStatusOf(zeId)); + return ret; +} + +void vtkMEDReader::SetTimesFlagsStatus(const char *name, int status) +{ + if(this->Internal->FileName.empty()) + {//pvsm mode + this->Internal->PK.pushTimesFlagsStatusEntry(name,status); + return ; + } + //not pvsm mode (general case) + int pos(0); + std::istringstream iss(name); iss >> pos; + this->Internal->TK.getTimesFlagArray()[pos].first=(bool)status; + if(pos==this->Internal->TK.getTimesFlagArray().size()-1) + if(!this->Internal->PluginStart0()) + { + this->Modified(); + //this->Internal->TK.printSelf(std::cerr); + } +} + +int vtkMEDReader::GetNumberOfTimesFlagsArrays() +{ + if(!this->Internal) + return 0; + return (int)this->Internal->TK.getTimesFlagArray().size(); +} + +const char *vtkMEDReader::GetTimesFlagsArrayName(int index) +{ + return this->Internal->TK.getTimesFlagArray()[index].second.c_str(); +} + +int vtkMEDReader::GetTimesFlagsArrayStatus(const char *name) +{ + int pos(0); + std::istringstream iss(name); iss >> pos; + return (int)this->Internal->TK.getTimesFlagArray()[pos].first; +} + +void vtkMEDReader::UpdateSIL(vtkInformation *info) +{ + if(!this->Internal) + return ; + vtkMutableDirectedGraph *sil(vtkMutableDirectedGraph::New()); + std::string meshName(this->BuildSIL(sil)); + if(meshName!=this->Internal->DftMeshName) + { + if(this->Internal->SIL) + this->Internal->SIL->Delete(); + this->Internal->SIL=sil; + this->Internal->DftMeshName=meshName; + info->Set(vtkDataObject::SIL(),this->Internal->SIL); + //request->AppendUnique(vtkExecutive::KEYS_TO_COPY(),vtkDataObject::SIL()); + } + else + { + sil->Delete(); + } +} + +/*! + * The returned string is the name of the mesh activated which groups and families are in \a sil. + */ +std::string vtkMEDReader::BuildSIL(vtkMutableDirectedGraph* sil) +{ + sil->Initialize(); + vtkSmartPointer childEdge(vtkSmartPointer::New()); + childEdge->InsertNextValue(0); + vtkSmartPointer crossEdge(vtkSmartPointer::New()); + crossEdge->InsertNextValue(1); + // CrossEdge is an edge linking hierarchies. + vtkUnsignedCharArray* crossEdgesArray=vtkUnsignedCharArray::New(); + crossEdgesArray->SetName("CrossEdges"); + sil->GetEdgeData()->AddArray(crossEdgesArray); + crossEdgesArray->Delete(); + std::vector names; + // Now build the hierarchy. + vtkIdType rootId=sil->AddVertex(); + names.push_back("SIL"); + // Add global fields root + vtkIdType fieldsRoot(sil->AddChild(rootId,childEdge)); + names.push_back("FieldsStatusTree"); + this->Internal->Tree.feedSIL(sil,fieldsRoot,childEdge,names); + vtkIdType meshesFamsGrpsRoot(sil->AddChild(rootId,childEdge)); + names.push_back("MeshesFamsGrps"); + std::string dftMeshName(this->Internal->Tree.feedSILForFamsAndGrps(sil,meshesFamsGrpsRoot,childEdge,names)); + // This array is used to assign names to nodes. + vtkStringArray *namesArray(vtkStringArray::New()); + namesArray->SetName("Names"); + namesArray->SetNumberOfTuples(sil->GetNumberOfVertices()); + sil->GetVertexData()->AddArray(namesArray); + namesArray->Delete(); + std::vector::const_iterator iter; + vtkIdType cc; + for(cc=0, iter=names.begin(); iter!=names.end(); ++iter, ++cc) + namesArray->SetValue(cc,(*iter).c_str()); + return dftMeshName; +} + +double vtkMEDReader::PublishTimeStepsIfNeeded(vtkInformation *outInfo, bool& isUpdated) +{ + int lev0(-1); + std::vector tsteps; + if(!this->Internal->IsStdOrMode) + tsteps=this->Internal->Tree.getTimeSteps(lev0,this->Internal->TK); + else + { tsteps.resize(1); tsteps[0]=0.; } + isUpdated=false; + if(lev0!=this->Internal->LastLev0) + { + isUpdated=true; + double timeRange[2]; + timeRange[0]=tsteps.front(); + timeRange[1]=tsteps.back(); + outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),&tsteps[0],tsteps.size()); + outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(),timeRange,2); + this->Internal->LastLev0=lev0; + } + return tsteps.front(); +} + +void vtkMEDReader::FillMultiBlockDataSetInstance(vtkMultiBlockDataSet *output, double reqTS) +{ + std::string meshName; + vtkDataSet *ret(this->Internal->Tree.buildVTKInstance(this->Internal->IsStdOrMode,reqTS,meshName,this->Internal->TK)); + if(this->Internal->GenerateVect) + { + vtkGenerateVectors::Operate(ret->GetPointData()); + vtkGenerateVectors::Operate(ret->GetCellData()); + vtkGenerateVectors::Operate(ret->GetFieldData()); + } + output->SetBlock(0,ret); + ret->Delete(); +} + +void vtkMEDReader::PrintSelf(ostream& os, vtkIndent indent) +{ + this->Superclass::PrintSelf(os, indent); +} diff --git a/src/Plugins/MEDReader/IO/vtkMEDReader2.h b/src/Plugins/MEDReader/IO/vtkMEDReader2.h new file mode 100644 index 00000000..17bc1231 --- /dev/null +++ b/src/Plugins/MEDReader/IO/vtkMEDReader2.h @@ -0,0 +1,80 @@ +// Copyright (C) 2010-2015 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#ifndef __vtkMEDReader_h_ +#define __vtkMEDReader_h_ + +#include + +#include "vtkMultiBlockDataSetAlgorithm.h" + +class vtkMutableDirectedGraph; + +class VTK_EXPORT vtkMEDReader : public vtkMultiBlockDataSetAlgorithm +{ + private: + vtkMEDReader(const vtkMEDReader&); // Not implemented. + void operator=(const vtkMEDReader&); // Not implemented. + public: + static vtkMEDReader *New(); + vtkTypeMacro(vtkMEDReader, vtkMultiBlockDataSetAlgorithm); + void PrintSelf(ostream& os, vtkIndent indent); + virtual void SetFileName(const char*); + virtual char *GetFileName(); + virtual const char *GetFileExtensions() { return ".med .rmed .sauv .sauve"; } + virtual const char *GetDescriptiveName() { return "MED file (Data Exchange Model)"; } + // + virtual void SetFieldsStatus(const char *name, int status); + virtual int GetNumberOfFieldsTreeArrays(); + virtual const char *GetFieldsTreeArrayName(int index); + virtual int GetFieldsTreeArrayStatus(const char *name); + // + virtual int GetTimesFlagsArrayStatus(const char *name); + virtual void SetTimesFlagsStatus(const char *name, int status); + virtual int GetNumberOfTimesFlagsArrays(); + virtual const char *GetTimesFlagsArrayName(int index); + //! Build the graph used to pass information to the client on the supports + virtual std::string BuildSIL(vtkMutableDirectedGraph*); + virtual void Reload(); + virtual int GetReloadReq(int a); + virtual int GetReloadReq(); + virtual int GetServerModifTime(); + // + virtual void GenerateVectors(int); + virtual void ChangeMode(int); + static const char *GetSeparator(); + + protected: + vtkMEDReader(); + virtual ~vtkMEDReader(); + virtual int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*); + virtual int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*); + private: + void UpdateSIL(vtkInformation *info); + virtual double PublishTimeStepsIfNeeded(vtkInformation*, bool& isUpdated); + virtual void FillMultiBlockDataSetInstance(vtkMultiBlockDataSet *output, double reqTS); + private: + //BTX + //ETX + class vtkMEDReaderInternal; + vtkMEDReaderInternal* Internal; +}; + +#endif //__vtkMEDReader_h_ diff --git a/src/Plugins/MEDReader/ParaViewPlugin/CMakeLists.txt b/src/Plugins/MEDReader/ParaViewPlugin/CMakeLists.txt index cf81df25..65991d57 100644 --- a/src/Plugins/MEDReader/ParaViewPlugin/CMakeLists.txt +++ b/src/Plugins/MEDReader/ParaViewPlugin/CMakeLists.txt @@ -17,52 +17,95 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/IO ) +INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../IO ) IF(PARAVIEW_BUILD_QT_GUI) - QT4_WRAP_UI(CLIENT_UI_SRCS Resources/UI/MEDReaderPanel.ui Resources/UI/ExtractGroupPanel.ui Resources/UI/ExtractCellTypePanel.ui) - + QT4_WRAP_UI(CLIENT_UI_SRCS + Resources/UI/MEDReaderVectorsWidget.ui + Resources/UI/MEDReaderTimeModeWidget.ui) + # create a plugin that implements an object panel for the reader - SET(CLIENT_SRCS pqMEDReaderPanel.cxx pqExtractGroupPanel.cxx pqExtractCellTypePanel.cxx VectBoolSpreadSheet.cxx VectBoolWidget.cxx) - - QT4_WRAP_CPP(MOC_SRCS pqMEDReaderPanel.h pqExtractGroupPanel.h pqExtractCellTypePanel.h VectBoolSpreadSheet.h VectBoolWidget.h) - - ADD_PARAVIEW_OBJECT_PANEL(MEDREADER_IFACES MEDREADER_IFACE_SRCS - CLASS_NAME pqMEDReaderPanel - XML_NAME MEDReader - XML_GROUP sources - ) - - ADD_PARAVIEW_OBJECT_PANEL(EXTRACTGROUP_IFACES EXTRACTGROUP_IFACE_SRCS - CLASS_NAME pqExtractGroupPanel - XML_NAME ExtractGroup - XML_GROUP filters - ) + SET(SM_SRCS + vtkPVMetaDataInformation.cxx) + + SET(CLIENT_SRCS + pqExtractGroupFieldsWidget.cxx + pqAbstractFieldsWidget.cxx + VectBoolSpreadSheet.cxx + VectBoolWidget.cxx + pqMEDReaderGraphUtils.cxx + pqMEDReaderVectorsWidget.cxx + pqMEDReaderTimeModeWidget.cxx + pqMEDReaderReloadWidget.cxx + pqMEDReaderTimesFlagsWidget.cxx + pqMEDReaderFieldsWidget.cxx) + + QT4_WRAP_CPP(MOC_SRCS + pqExtractGroupFieldsWidget.h + pqAbstractFieldsWidget.h + VectBoolSpreadSheet.h + VectBoolWidget.h + pqMEDReaderVectorsWidget.h + pqMEDReaderTimeModeWidget.h + pqMEDReaderReloadWidget.h + pqMEDReaderTimesFlagsWidget.h + pqMEDReaderFieldsWidget.h) + + ADD_PARAVIEW_PROPERTY_WIDGET(MEDREADER_TIMEMODE_IFACES MEDREADER_TIMEMODE_IFACE_SRCS + TYPE "MEDReaderTimeModeWidgetType" + CLASS_NAME pqMEDReaderTimeModeWidget) + + ADD_PARAVIEW_PROPERTY_WIDGET(MEDREADER_RELOAD_IFACES MEDREADER_RELOAD_IFACE_SRCS + TYPE "MEDReaderReloadWidgetType" + CLASS_NAME pqMEDReaderReloadWidget) + + ADD_PARAVIEW_PROPERTY_WIDGET(MEDREADER_VECTORS_IFACES MEDREADER_VECTORS_IFACE_SRCS + TYPE "MEDReaderVectorsWidgetType" + CLASS_NAME pqMEDReaderVectorsWidget) + + ADD_PARAVIEW_PROPERTY_WIDGET(MEDREADER_TIMESFLAGS_IFACES MEDREADER_TIMESFLAGS_IFACE_SRCS + TYPE "MEDReaderTimesFlagsWidgetType" + CLASS_NAME pqMEDReaderTimesFlagsWidget) + + ADD_PARAVIEW_PROPERTY_WIDGET(MEDREADER_FIELDS_IFACES MEDREADER_FIELDS_IFACE_SRCS + TYPE "MEDReaderFieldsWidgetType" + CLASS_NAME pqMEDReaderFieldsWidget) + + ADD_PARAVIEW_PROPERTY_WIDGET(EXTRACTGROUP_FIELDS_IFACES EXTRACTGROUP_FIELDS_IFACES_SRCS + TYPE "ExtractGroupFieldsWidgetType" + CLASS_NAME pqExtractGroupFieldsWidget) - ADD_PARAVIEW_OBJECT_PANEL(EXTRACTCELLTYPE_IFACES EXTRACTCELLTYPE_IFACE_SRCS - CLASS_NAME pqExtractCellTypePanel - XML_NAME ExtractCellType - XML_GROUP filters - ) - # create the med reader plugin itself ADD_PARAVIEW_PLUGIN(MEDReaderPlugin "4.0" + SERVER_MANAGER_SOURCES ${SM_SRCS} SERVER_MANAGER_XML Resources/MEDReaderServer.xml - GUI_INTERFACES ${MEDREADER_IFACES} ${EXTRACTGROUP_IFACES} ${EXTRACTCELLTYPE_IFACES} + GUI_INTERFACES + ${MEDREADER_TIMEMODE_IFACES} + ${MEDREADER_RELOAD_IFACES} + ${MEDREADER_TIMESFLAGS_IFACES} + ${MEDREADER_FIELDS_IFACES} + ${MEDREADER_VECTORS_IFACES} + ${EXTRACTGROUP_FIELDS_IFACES} GUI_RESOURCES Resources/pqMEDReader.qrc - GUI_SOURCES ${CLIENT_SRCS} - ${CLIENT_UI_SRCS} - ${MOC_SRCS} - ${MEDREADER_IFACE_SRCS} ${EXTRACTGROUP_IFACE_SRCS} ${EXTRACTCELLTYPE_IFACE_SRCS} + SOURCES + ${CLIENT_SRCS} + ${CLIENT_UI_SRCS} + ${MOC_SRCS} + ${MEDREADER_TIMEMODE_IFACE_SRCS} + ${MEDREADER_RELOAD_IFACE_SRCS} + ${MEDREADER_TIMESFLAGS_IFACE_SRCS} + ${MEDREADER_FIELDS_IFACE_SRCS} + ${MEDREADER_VECTORS_IFACE_SRCS} + ${EXTRACTGROUP_FIELDS_IFACES_SRCS} CS_KITS # this is the same name as the name in module.cmake file IO # directory. vtkMEDReader ) - + ELSE(PARAVIEW_BUILD_QT_GUI) - + # create the med reader plugin itself ADD_PARAVIEW_PLUGIN(MEDReaderPlugin "4.0" SERVER_MANAGER_SOURCES ${SM_SRCS} @@ -72,7 +115,7 @@ ELSE(PARAVIEW_BUILD_QT_GUI) # directory. vtkMEDReader ) - + ENDIF(PARAVIEW_BUILD_QT_GUI) TARGET_LINK_LIBRARIES(MEDReaderPlugin vtkMEDReader vtkMEDReaderCS) @@ -85,5 +128,3 @@ INSTALL( ) - - diff --git a/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderClient2.xml b/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderClient2.xml deleted file mode 100644 index 415554f8..00000000 --- a/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderClient2.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml b/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml index cf89105d..f4a772d6 100644 --- a/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml +++ b/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml @@ -8,53 +8,31 @@ + + This property specifies the file name for the MED reader. - - - - - - - - - - - - - + + information_property="FieldsTreeInfo" + immediate_update="1" + panel_widget="MEDReaderFieldsWidgetType"> @@ -74,26 +54,28 @@ - - - - - - - - - - - - This property lists all groups and families to select. - - + + + This property define if the reader generate vectors. + + + + + + This property define if the reader read time steps as modes or not. + + + - + + + + + + + + + + + + This property define which time steps the reader should read. + + + + + + + + + @@ -133,27 +142,19 @@ This property specifies the input to the Level Scalars filter. - - - - - Information property indicating the update stamp of the SIL. Every - time the SIL is rebuild, this - time stamp is changed. - - - + - + + information_property="GroupsFlagsInfo" + panel_widget="ExtractGroupFieldsWidgetType"> @@ -164,7 +165,7 @@ - + Choose which part of the dataset to keep regarding the selected Groups/Families. When 0 (default) the direct selection is kept. When 1 the complementary part is selected. @@ -181,9 +182,10 @@ This property returns the name of the mesh. + - + @@ -198,22 +200,13 @@ This property specifies the input to the Level Scalars filter. - - - - - Information property indicating the update stamp of the SIL. Every - time the SIL is rebuild, this - time stamp is changed. - - - + - + - + Choose which part of the dataset to keep regarding the selected geometric types. When 0 (default) the direct selection is kept. When 1 the complementary part is selected. @@ -293,7 +286,7 @@ - + @@ -358,7 +351,7 @@ - + - - - ExtractCellTypePanel - - - - 0 - 0 - 649 - 839 - - - - - 0 - 0 - - - - Form - - - - 9 - - - - - - 0 - 1 - - - - Geometric types available - - - - 6 - - - 9 - - - - - - - - 0 - 200 - - - - - 1 - - - - - - - - - - Extract the complementary - - - - - - - - - - - pqTreeWidget - QTreeWidget -
pqTreeWidget.h
-
-
- - - - - 10 - - - 10 - - - false - - - false - - - true - - -
diff --git a/src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/ExtractGroupPanel.ui b/src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/ExtractGroupPanel.ui deleted file mode 100644 index b328a632..00000000 --- a/src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/ExtractGroupPanel.ui +++ /dev/null @@ -1,101 +0,0 @@ - - - ExtractGroupPanel - - - - 0 - 0 - 649 - 839 - - - - - 0 - 0 - - - - Form - - - - 9 - - - - - - 0 - 1 - - - - Groups And Families - - - - 6 - - - 9 - - - - - - - - 0 - 200 - - - - - 1 - - - - - - - - - - Extract the complementary - - - - - - - - - - - pqTreeWidget - QTreeWidget -
pqTreeWidget.h
-
-
- - - - - 10 - - - 10 - - - false - - - false - - - true - - -
diff --git a/src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/MEDReaderPanel.ui b/src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/MEDReaderPanel.ui deleted file mode 100644 index e6da8d91..00000000 --- a/src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/MEDReaderPanel.ui +++ /dev/null @@ -1,227 +0,0 @@ - - - MEDReaderPanel - - - - 0 - 0 - 649 - 839 - - - - - 0 - 0 - - - - Form - - - - 9 - - - - - - 0 - 1 - - - - Representation - - - - 6 - - - 9 - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - true - - - Reload current file - - - true - - - - - - - :/ParaViewResources/Icons/pqReloadFile16.png:/ParaViewResources/Icons/pqReloadFile16.png - - - false - - - - - - - - - - 0 - 200 - - - - - 1 - - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 16777215 - 25 - - - - GenerateVectors - - - - - - - - - - true - - - - - - - - - Time - - - - - - - Mode - - - - - - - - - - - 0 - 0 - - - - - 250 - 400 - - - - - - - - - - - - - - - - - pqExodusIIVariableSelectionWidget - QTreeWidget -
pqExodusIIVariableSelectionWidget.h
-
-
- - - - - - - 10 - - - 10 - - - false - - - false - - - true - - -
diff --git a/src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/MEDReaderTimeModeWidget.ui b/src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/MEDReaderTimeModeWidget.ui new file mode 100644 index 00000000..419d1e7b --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/MEDReaderTimeModeWidget.ui @@ -0,0 +1,37 @@ + + + MEDReaderTimeModeWidget + + + + + + true + + + + + + + + + Time + + + true + + + + + + + Mode + + + + + + + + + diff --git a/src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/MEDReaderVectorsWidget.ui b/src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/MEDReaderVectorsWidget.ui new file mode 100644 index 00000000..c9424273 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/MEDReaderVectorsWidget.ui @@ -0,0 +1,39 @@ + + + MEDReaderVectorsWidget + + + + 0 + + + 0 + + + + + true + + + + + + + 0 + + + 0 + + + + + GenerateVectors + + + + + + + + + diff --git a/src/Plugins/MEDReader/ParaViewPlugin/Resources/pqMEDReader.qrc b/src/Plugins/MEDReader/ParaViewPlugin/Resources/pqMEDReader.qrc index 5b3479aa..1006ebf7 100644 --- a/src/Plugins/MEDReader/ParaViewPlugin/Resources/pqMEDReader.qrc +++ b/src/Plugins/MEDReader/ParaViewPlugin/Resources/pqMEDReader.qrc @@ -3,7 +3,6 @@ Icons/pqCellData16.png Icons/pqPointData16.png Icons/pqQuadratureData16.png - MEDReaderClient2.xml Icons/pqElnoData16.png Icons/pqReloadFile16.png Icons/pqCellDataForWholeMesh16.png diff --git a/src/Plugins/MEDReader/ParaViewPlugin/VectBoolSpreadSheet.cxx b/src/Plugins/MEDReader/ParaViewPlugin/VectBoolSpreadSheet.cxx index 2e29fce9..b878cbb3 100644 --- a/src/Plugins/MEDReader/ParaViewPlugin/VectBoolSpreadSheet.cxx +++ b/src/Plugins/MEDReader/ParaViewPlugin/VectBoolSpreadSheet.cxx @@ -233,6 +233,7 @@ void VectBoolSpreadSheet::selectionChanged(const QItemSelection & selected, cons m->setData(ind,QVariant(true),Qt::UserRole); } QTableView::selectionChanged(selected,deselected); + this->clearSelection(); } void VectBoolSpreadSheet::nbOfRowsHasChanged(int newNbOfRows) diff --git a/src/Plugins/MEDReader/ParaViewPlugin/VectBoolWidget.cxx b/src/Plugins/MEDReader/ParaViewPlugin/VectBoolWidget.cxx index 534fa2f1..5af5d9f8 100644 --- a/src/Plugins/MEDReader/ParaViewPlugin/VectBoolWidget.cxx +++ b/src/Plugins/MEDReader/ParaViewPlugin/VectBoolWidget.cxx @@ -62,7 +62,8 @@ bool VectBoolItem::isActivated() const void VectBoolItem::activated(bool val) { - //_model->setStatusAt(_pos,val); + _model->setStatusAt(_pos,val); + _old_status=val; } void VectBoolItem::theModelHasChanged() @@ -149,11 +150,11 @@ VectBoolWidget::VectBoolWidget(QWidget *parent, int nbOfItems):QFrame(parent) _vbm->selectUnselectAll(); _nb_of_rows_selecter->setValue(_nb_of_rows_selecter->maximum()); // - _items.resize(nbOfItems); for(int i=0;igetNumberOfBoolItems()) { std::cerr << "ERROR ! Internal Error in VectBoolWidget::setItems ! Current number of items is bigger than the current one !" << std::endl; + std::cerr << curNbOfItems << " "<setCurrentItems(dts,its,tts)) diff --git a/src/Plugins/MEDReader/ParaViewPlugin/VectBoolWidget.h b/src/Plugins/MEDReader/ParaViewPlugin/VectBoolWidget.h index 510d2ff4..ba4f137a 100644 --- a/src/Plugins/MEDReader/ParaViewPlugin/VectBoolWidget.h +++ b/src/Plugins/MEDReader/ParaViewPlugin/VectBoolWidget.h @@ -23,6 +23,7 @@ #include #include +#include class QSlider; class QGroupBox; @@ -71,11 +72,11 @@ public: ~VectBoolWidget(); int getNumberOfBoolItems() const; void setItems(const QStringList& dts, const QStringList& its, const QStringList& tts); - const QVector& getItems() const { return _items; } + const QMap& getItems() const { return _items; } private: static int GetMaxTickValueOfSlider(int val); private: - QVector _items; + QMap _items; QHBoxLayout *_horizontal_layout; QFrame *_spreadsheet_container; QGridLayout *_grid_layout; diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqAbstractFieldsWidget.cxx b/src/Plugins/MEDReader/ParaViewPlugin/pqAbstractFieldsWidget.cxx new file mode 100644 index 00000000..bde26578 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqAbstractFieldsWidget.cxx @@ -0,0 +1,147 @@ +// Copyright (C) 2010-2015 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "pqAbstractFieldsWidget.h" + +#include "pqArrayListDomain.h" +#include "pqTreeWidget.h" +#include "pqTreeWidgetItemObject.h" + +#include +#include +//----------------------------------------------------------------------------- +pqAbstractFieldsWidget::pqAbstractFieldsWidget( + vtkSMProxy *smproxy, vtkSMProperty *smproperty, QWidget *parentObject) +: Superclass(smproxy, parentObject) +{ + this->NItems = 0; + this->visibleHeader = true; + this->setShowLabel(false); + + // Grid Layout + QGridLayout* gridLayout = new QGridLayout(this); + + // Tree widget + this->TreeWidget = new pqTreeWidget(this); + gridLayout->addWidget(this->TreeWidget); +} + +//----------------------------------------------------------------------------- +pqAbstractFieldsWidget::~pqAbstractFieldsWidget() +{ + delete this->TreeWidget; +} + +void pqAbstractFieldsWidget::initializeTreeWidget(vtkSMProxy *smproxy, vtkSMProperty *smproperty) +{ + // Load Tree Widget Items + this->loadTreeWidgetItems(); + + // Connect Property Domain to the fieldDomain property, + // so setFieldDomain is called when the domain changes. + vtkSMDomain* arraySelectionDomain = smproperty->GetDomain("array_list"); + new pqArrayListDomain(this,"fieldsDomain", smproxy, smproperty, arraySelectionDomain); + + // Connect property to field QProperty using a biderectionnal property link + this->addPropertyLink(this, "fields", SIGNAL(fieldsChanged()), + smproxy, smproperty); + + // Call slot when the tree is changed + QObject::connect(this->TreeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), + this, SLOT(onItemChanged(QTreeWidgetItem*, int))); + +} + +//----------------------------------------------------------------------------- +QSize pqAbstractFieldsWidget::sizeHint() const +{ + // TreeWidget sizeHintForRow is too low, correcting to +3. + int pix = (this->TreeWidget->sizeHintForRow(0) + 3) * this->NItems; + int margin[4]; + this->TreeWidget->getContentsMargins(margin, margin + 1, margin + 2, margin + 3); + int h = pix + margin[1] + margin[3]; + if (this->visibleHeader) + { + h += this->TreeWidget->header()->frameSize().height(); + } + h = std::min(300, h); + return QSize(156, h); +} + +//----------------------------------------------------------------------------- +void pqAbstractFieldsWidget::onItemChanged(QTreeWidgetItem* item, int column) const +{ + if (column != 0) + { + return; + } + emit fieldsChanged(); +} + +//----------------------------------------------------------------------------- +QList< QList< QVariant> > pqAbstractFieldsWidget::getFields() const +{ + // Put together a Field list, using ItemMap + QList< QList< QVariant> > ret; + QList< QVariant > field; + QMap::const_iterator it; + for (it = this->ItemMap.begin(); it != this->ItemMap.end(); it++) + { + field.clear(); + field.append(it.key()); + field.append(it.value()->isChecked()); + ret.append(field); + } + return ret; +} + +//----------------------------------------------------------------------------- +void pqAbstractFieldsWidget::setFields(QList< QList< QVariant> > fields) +{ + // Update each item checkboxes, using fields names and ItemMap + QMap::iterator it; + foreach (QList< QVariant> field, fields) + { + it = this->ItemMap.find(field[0].toString()); + if (it == this->ItemMap.end()) + { + qDebug("Found an unknow Field in pqAbstractFieldsWidget::setFields, ignoring"); + continue; + } + it.value()->setChecked(field[1].toBool()); + } +} + +//----------------------------------------------------------------------------- +void pqAbstractFieldsWidget::setFieldsDomain(QList< QList< QVariant> > fields) +{ + // Block signals so the reloading does not trigger + // UncheckPropertyModified event + this->blockSignals(true); + + // Load the tree widget + this->loadTreeWidgetItems(); + + // Set fields checkboxes + this->setFields(fields); + + // Restore signals + this->blockSignals(false); +} diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqAbstractFieldsWidget.h b/src/Plugins/MEDReader/ParaViewPlugin/pqAbstractFieldsWidget.h new file mode 100644 index 00000000..c4f29c85 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqAbstractFieldsWidget.h @@ -0,0 +1,103 @@ +// Copyright (C) 2010-2015 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#ifndef __pqAbstractFieldsWidget_h +#define __pqAbstractFieldsWidget_h + +#include "pqPropertyWidget.h" + +class pqTreeWidget; +class pqTreeWidgetItemObject; +class QTreeWidgetItem; +class vtkSMProxy; +class vtkSMProperty; + +class pqAbstractFieldsWidget : public pqPropertyWidget +{ + typedef pqPropertyWidget Superclass; + Q_OBJECT + + // Description + // Property Qt used to set/get the fields with the property link + Q_PROPERTY(QList< QList< QVariant> > fields READ getFields WRITE setFields) + + // Description + // Property Qt used to set the gorup fields domain with the property link + Q_PROPERTY(QList< QList< QVariant> > fieldsDomain READ getFields WRITE setFieldsDomain) +public: + pqAbstractFieldsWidget( + vtkSMProxy *smproxy, vtkSMProperty *smproperty, QWidget *parentObject = 0); + virtual ~pqAbstractFieldsWidget(); + + // Description + // Corrected size hint, +3 pixel on each line + virtual QSize sizeHint() const; + +signals: + // Description + // Signal emited when selected field changed + void fieldsChanged() const; + +protected: + // Description + // bidrectionnal property link setter/getter + virtual QList< QList< QVariant> > getFields() const; + virtual void setFields(QList< QList< QVariant> > fields); + + // Description + // Update the domain, eg: reload + virtual void setFieldsDomain(QList< QList< QVariant> > fields); + + + // Description + // Initialize the widget items and connect it to property + // To be called by subclasses in constructor + virtual void initializeTreeWidget(vtkSMProxy *smproxy, vtkSMProperty *smproperty); + + // Description + // (Re)Load the tree widget items using recovered meta data graph + virtual void loadTreeWidgetItems() = 0; + + // Description + // Tree widget + pqTreeWidget* TreeWidget; + + // Description + // Number of items, for graphic purpose + int NItems; + + // Description + // Map of ItemPropertyName -> Item Pointer, contains only leaf. + QMap< QString, pqTreeWidgetItemObject*> ItemMap; + + // Description + // Bug in qt, header->isVisible always return false, storing this info here + // https://bugreports.qt.io/browse/QTBUG-12939 + bool visibleHeader; +protected slots: + // Description + // Slot called when the tree widget changed + virtual void onItemChanged(QTreeWidgetItem* itemOrig, int column) const; + +private: + Q_DISABLE_COPY(pqAbstractFieldsWidget); +}; + +#endif diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqExtractCellTypePanel.cxx b/src/Plugins/MEDReader/ParaViewPlugin/pqExtractCellTypePanel.cxx deleted file mode 100644 index b27a6cd3..00000000 --- a/src/Plugins/MEDReader/ParaViewPlugin/pqExtractCellTypePanel.cxx +++ /dev/null @@ -1,221 +0,0 @@ -// Copyright (C) 2010-2015 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// Author : Anthony Geay - -#include "pqExtractCellTypePanel.h" -#include "ui_ExtractCellTypePanel.h" - -#include "vtkProcessModule.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkInformation.h" -#include "vtkIntArray.h" -#include "vtkSMDoubleVectorProperty.h" -#include "vtkSMIntVectorProperty.h" -#include "vtkSMStringVectorProperty.h" -#include "vtkSMProxy.h" -#include "vtkSMSourceProxy.h" -#include "vtkEventQtSlotConnect.h" -#include "vtkPVSILInformation.h" -#include "vtkGraph.h" -#include "vtkMutableDirectedGraph.h" -#include "vtkAdjacentVertexIterator.h" -#include "vtkSMPropertyHelper.h" -#include "vtkStringArray.h" -#include "vtkDataSetAttributes.h" -#include "vtkExtractCellType.h" - -#include "pqTreeWidgetItemObject.h" -#include "pqSMAdaptor.h" -#include "pqProxy.h" -#include "pqPropertyManager.h" -#include "pqSILModel.h" -#include "pqProxySILModel.h" -#include "pqTreeViewSelectionHelper.h" -#include "pqTreeWidgetSelectionHelper.h" -#include "pqPropertyLinks.h" - -#include - -#include - -static const char ZE_SEP[]="@@][@@"; - -class pqExtractCellTypePanel::pqUI: public QObject, public Ui::ExtractCellTypePanel -{ -public: - pqUI(pqExtractCellTypePanel* p):QObject(p) - { - this->VTKConnect = vtkSmartPointer::New(); - this->SILUpdateStamp = -1; - } - - ~pqUI() { } - - pqSILModel SILModel; - vtkSmartPointer VTKConnect; - pqPropertyLinks Links; - QMap TreeItemToPropMap; - int SILUpdateStamp; -}; - -pqExtractCellTypePanel::pqExtractCellTypePanel(pqProxy* object_proxy, QWidget* p):Superclass(object_proxy, p) -{ - this->UI=new pqUI(this); - this->UI->setupUi(this); - pqProxySILModel*proxyModel2 = new pqProxySILModel("GeoTypesStatusTree", &this->UI->SILModel); - proxyModel2->setSourceModel(&this->UI->SILModel); - this->UI->Fields->setHeaderHidden(true); - this->updateSIL(); - this->linkServerManagerProperties(); - //////////////////// - vtkSMProperty *SMProperty(this->proxy()->GetProperty("GeoTypesStatus")); - //////////////////// - vtkSMProxy* reader = this->referenceProxy()->getProxy(); - vtkPVSILInformation* info=vtkPVSILInformation::New(); - reader->GatherInformation(info); - vtkGraph *g(info->GetSIL()); - //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 ? - vtkMutableDirectedGraph *g2(static_cast(g)); - if(!g2) - return ; - int idNames(0); - vtkAbstractArray *verticesNames(g2->GetVertexData()->GetAbstractArray("Names",idNames)); - vtkStringArray *verticesNames2(vtkStringArray::SafeDownCast(verticesNames)); - vtkIdType id0; - bool found(false); - for(int i=0;iGetNumberOfValues();i++) - { - vtkStdString &st(verticesNames2->GetValue(i)); - if(st=="CellTypesTree") - { - id0=i; - found=true; - } - } - if(!found) - std::cerr << "There is an internal error ! The tree on server side has not the expected look !" << std::endl; - vtkAdjacentVertexIterator *it0(vtkAdjacentVertexIterator::New()); - g2->GetAdjacentVertices(id0,it0); - int kk(0),ll(0); - while(it0->HasNext()) - { - vtkIdType id1(it0->Next()); - QString geoTypeName(QString::fromStdString((const char *)verticesNames2->GetValue(id1))); - vtkAdjacentVertexIterator *it1(vtkAdjacentVertexIterator::New()); - g2->GetAdjacentVertices(id1,it1); - QList strs0; strs0.append(QString("%1").arg(geoTypeName)); - pqTreeWidgetItemObject *item0(new pqTreeWidgetItemObject(this->UI->Fields,strs0)); - vtkAdjacentVertexIterator *itGrps(vtkAdjacentVertexIterator::New()); - g2->GetAdjacentVertices(id1,itGrps); - vtkIdType idg(itGrps->Next()); - QString name0(QString::fromStdString((const char *)verticesNames2->GetValue(idg))); - QString toolTipName0(QString("%1 (vtkId=%2)").arg(geoTypeName).arg(name0)); - item0->setData(0,Qt::UserRole,geoTypeName); - item0->setData(0,Qt::ToolTipRole,toolTipName0); - item0->setData(0,Qt::CheckStateRole,0); - item0->setProperty("PosInStringVector",QVariant(ll++)); - connect(item0,SIGNAL(checkedStateChanged(bool)),this,SLOT(anItemAsBeenFired())); - } - it0->Delete(); - this->UI->Fields->header()->setStretchLastSection(true); - this->UI->Fields->expandAll(); - info->Delete(); - //////////////////// - vtkSMProperty *SMPropertyExtractComp(this->proxy()->GetProperty("InsideOut")); - this->propertyManager()->registerLink(this->UI->ExtractComplementary,"checked",SIGNAL(stateChanged(int)),this->proxy(),SMPropertyExtractComp); - //////////////////// - this->UI->VTKConnect->Connect(this->proxy(),vtkCommand::UpdateInformationEvent,this,SLOT(updateSIL())); -} - -pqExtractCellTypePanel::~pqExtractCellTypePanel() -{ -} - -void pqExtractCellTypePanel::linkServerManagerProperties() -{ - this->Superclass::linkServerManagerProperties(); -} - -void pqExtractCellTypePanel::updateSIL() -{ - vtkSMProxy* reader = this->referenceProxy()->getProxy(); - reader->UpdatePropertyInformation(reader->GetProperty("SILUpdateStamp")); - int stamp = vtkSMPropertyHelper(reader, "SILUpdateStamp").GetAsInt(); - if (stamp != this->UI->SILUpdateStamp) - { - this->UI->SILUpdateStamp = stamp; - vtkPVSILInformation* info = vtkPVSILInformation::New(); - reader->GatherInformation(info); - vtkGraph *sil(info->GetSIL()); - if(sil) - { - this->UI->SILModel.update(sil); - this->UI->Fields->expandAll(); - } - info->Delete(); - } -} - -void pqExtractCellTypePanel::anItemAsBeenFired() -{ - /// - vtkSMProxy *proxy(this->proxy()); - vtkSMProperty *SMProperty(proxy->GetProperty("GeoTypesStatus")); - vtkSMStringVectorProperty *sm(dynamic_cast(SMProperty)); - unsigned int nb(sm->GetNumberOfElements()); - std::vector sts(nb); - for(unsigned int i=0;iGetElement(i); - /// - pqTreeWidget *sc(this->UI->Fields); - for(int i0=0;i0topLevelItemCount();i0++) - { - QTreeWidgetItem *lev0(sc->topLevelItem(i0)); - pqTreeWidgetItemObject *scc(dynamic_cast(lev0)); - int ll(scc->property("PosInStringVector").toInt()); - int v(scc->isChecked()); - std::ostringstream oss; oss << v; - sts[2*ll+1]=oss.str(); - } - /// - const char **args=new const char *[nb]; - for(unsigned int i=0;iGetImmediateUpdate()); - //sm->SetNumberOfElements(0); - sm->SetElements(args,nb); - proxy->UpdateVTKObjects(); - sm->SetImmediateUpdate(iup); - } - delete [] args; - // - ((vtkSMSourceProxy *)proxy)->UpdatePipelineInformation(); - setModified(); -} - -void pqExtractCellTypePanel::updateInformationAndDomains() -{ - pqNamedObjectPanel::updateInformationAndDomains(); - vtkSMProxy *proxy(this->proxy()); - vtkSMProperty *SMProperty(proxy->GetProperty("GeoTypesStatus")); - SMProperty->Modified();// agy : THE LINE FOR 7.5.1 ! -} diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqExtractCellTypePanel.h b/src/Plugins/MEDReader/ParaViewPlugin/pqExtractCellTypePanel.h deleted file mode 100644 index 2a9bc411..00000000 --- a/src/Plugins/MEDReader/ParaViewPlugin/pqExtractCellTypePanel.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2010-2015 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// Author : Anthony Geay - -#ifndef _pqExtractCellTypePanel_h -#define _pqExtractCellTypePanel_h - -#include "pqNamedObjectPanel.h" - -#include - -class pqTreeWidgetItemObject; - -class vtkSMProperty; -class vtkMutableDirectedGraph; - -class pqExtractCellTypePanel : public pqNamedObjectPanel -{ -Q_OBJECT - typedef pqNamedObjectPanel Superclass; -public: - pqExtractCellTypePanel(pqProxy* proxy, QWidget* p = NULL); - ~pqExtractCellTypePanel(); - void updateInformationAndDomains(); -protected slots: - void anItemAsBeenFired(); - void updateSIL(); -protected: - /// populate widgets with properties from the server manager - virtual void linkServerManagerProperties(); - class pqUI; - pqUI* UI; -}; - -#endif diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqExtractGroupFieldsWidget.cxx b/src/Plugins/MEDReader/ParaViewPlugin/pqExtractGroupFieldsWidget.cxx new file mode 100644 index 00000000..80e2751d --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqExtractGroupFieldsWidget.cxx @@ -0,0 +1,202 @@ +// Copyright (C) 2010-2015 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "pqExtractGroupFieldsWidget.h" + +#include "vtkMEDReader.h" +#include "vtkExtractGroup.h" +#include "vtkPVMetaDataInformation.h" + +#include "pqTreeWidget.h" +#include "pqTreeWidgetItemObject.h" +#include "vtkGraph.h" +#include "vtkNew.h" +#include "vtkStringArray.h" +#include "vtkDataSetAttributes.h" +#include "vtkTree.h" + +#include + +//----------------------------------------------------------------------------- +pqExtractGroupFieldsWidget::pqExtractGroupFieldsWidget( + vtkSMProxy *smproxy, vtkSMProperty *smproperty, QWidget *parentObject) +: Superclass(smproxy, smproperty, parentObject) +{ + this->TreeWidget->setHeaderLabel("Groups And Families"); + this->initializeTreeWidget(smproxy, smproperty); +} + +//----------------------------------------------------------------------------- +pqExtractGroupFieldsWidget::~pqExtractGroupFieldsWidget() +{ +} + +//----------------------------------------------------------------------------- +void pqExtractGroupFieldsWidget::loadTreeWidgetItems() +{ + // Recover Graph + vtkPVMetaDataInformation *info(vtkPVMetaDataInformation::New()); + this->proxy()->GatherInformation(info); + vtkGraph* graph = vtkGraph::SafeDownCast(info->GetInformationData()); + if(!graph) + { + return; + } + + // Clear Tree Widget + this->TreeWidget->clear(); + + // Clear Item Map + this->ItemMap.clear(); + + // Create a tree + vtkNew tree; + tree->CheckedShallowCopy(graph); + vtkStringArray* names = vtkStringArray::SafeDownCast(tree->GetVertexData()->GetAbstractArray("Names")); + + vtkIdType root = tree->GetRoot(); + vtkIdType mfg = tree->GetChild(root, 1); // MeshesFamsGrps + + vtkIdType mesh = tree->GetChild(mfg, 0); // mesh + QString meshName = QString(names->GetValue(mesh)); + + this->NItems = 0; + + vtkIdType grps = tree->GetChild(mesh, 0); // grps + pqTreeWidgetItemObject* grpsItem = new pqTreeWidgetItemObject(this->TreeWidget, QStringList()); + this->NItems++; + grpsItem->setText(0, QString("Groups of \"" + meshName + "\"")); + + vtkIdType fams = tree->GetChild(mesh, 1); // fams + pqTreeWidgetItemObject* famsItem = new pqTreeWidgetItemObject(this->TreeWidget, QStringList()); + this->NItems++; + famsItem->setText(0, QString("Families of \"" + meshName + "\"")); + + std::map famDataTypeMap; + + for (int i = 0; i < tree->GetNumberOfChildren(fams); i++) + { + // Familly Item + vtkIdType fam = tree->GetChild(fams, i); + pqTreeWidgetItemObject *famItem = new pqTreeWidgetItemObject(famsItem, QStringList()); + this->NItems++; + + // Familly name + std::string str = names->GetValue(fam); + const char* separator = vtkMEDReader::GetSeparator(); + size_t pos = str.find(separator); + std::string name = str.substr(0, pos); + famItem->setText(0, QString(name.c_str())); + + // Property Name + QString propertyName = QString(vtkExtractGroup::GetFamStart()) + QString(str.c_str()); + this->ItemMap[propertyName] = famItem; + + // Datatype flag + int dataTypeFlag = atoi(str.substr(pos + strlen(separator)).c_str()); + famDataTypeMap[name] = dataTypeFlag; + + // Checkbox + famItem->setFlags(famItem->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable); + famItem->setChecked(true); + + // Tooltip + QString famToolTip(QString("%1 (%2)").arg(QString(name.c_str())).arg(dataTypeFlag)); + famItem->setData(0, Qt::ToolTipRole, famToolTip); + + // Pixmap + if (dataTypeFlag<0) + { + famItem->setData(0, Qt::DecorationRole, + QPixmap(":/ParaViewResources/Icons/pqCellData16.png")); + } + if (dataTypeFlag>0) + { + famItem->setData(0, Qt::DecorationRole, + QPixmap(":/ParaViewResources/Icons/pqPointData16.png")); + } + } + + for (int i = 0; i < tree->GetNumberOfChildren(grps); i++) + { + // Grp Item + vtkIdType grp = tree->GetChild(grps, i); + pqTreeWidgetItemObject *grpItem = new pqTreeWidgetItemObject(grpsItem, QStringList()); + this->NItems++; + + // Group name + QString name = QString(names->GetValue(grp)); + grpItem->setText(0, name); + + // Property Name + QString propertyName = QString(vtkExtractGroup::GetGrpStart()) + name; + this->ItemMap[propertyName] = grpItem; + + // Datatype flag + bool hasPoint = false; + bool hasCell = false; + int dataTypeFlag = 0; + for (int j = 0; j < tree->GetNumberOfChildren(grp); j++) + { + dataTypeFlag = famDataTypeMap[names->GetValue(tree->GetChild(grp, j))]; + if (dataTypeFlag > 0) + { + hasPoint = true; + } + else if (dataTypeFlag < 0) + { + hasCell = true; + } + else + { + dataTypeFlag = 0; + break; + } + + if (hasPoint && hasCell) + { + dataTypeFlag = 0; + break; + } + } + + // Checkbox + grpItem->setFlags(grpItem->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable); + grpItem->setChecked(true); + + // Tooltip + grpItem->setData(0, Qt::ToolTipRole, name); + + // Pixmap + if (dataTypeFlag<0) + { + grpItem->setData(0, Qt::DecorationRole, + QPixmap(":/ParaViewResources/Icons/pqCellData16.png")); + } + if (dataTypeFlag>0) + { + grpItem->setData(0, Qt::DecorationRole, + QPixmap(":/ParaViewResources/Icons/pqPointData16.png")); + } + } + + // Expand Widget + this->TreeWidget->expandAll(); +} diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqExtractGroupFieldsWidget.h b/src/Plugins/MEDReader/ParaViewPlugin/pqExtractGroupFieldsWidget.h new file mode 100644 index 00000000..0ea16dd8 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqExtractGroupFieldsWidget.h @@ -0,0 +1,48 @@ +// Copyright (C) 2010-2015 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#ifndef __pqExtractGroupFieldsWidget_h +#define __pqExtractGroupFieldsWidget_h + +#include "pqAbstractFieldsWidget.h" + +class vtkSMProxy; +class vtkSMProperty; + +class pqExtractGroupFieldsWidget : public pqAbstractFieldsWidget +{ + typedef pqAbstractFieldsWidget Superclass; + Q_OBJECT + +public: + pqExtractGroupFieldsWidget( + vtkSMProxy *smproxy, vtkSMProperty *smproperty, QWidget *parentObject = 0); + virtual ~pqExtractGroupFieldsWidget(); + +protected: + // Description + // Load the tree widget using recovered meta data graph + void loadTreeWidgetItems(); + +private: + Q_DISABLE_COPY(pqExtractGroupFieldsWidget); +}; + +#endif diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqExtractGroupPanel.cxx b/src/Plugins/MEDReader/ParaViewPlugin/pqExtractGroupPanel.cxx deleted file mode 100644 index f07387e3..00000000 --- a/src/Plugins/MEDReader/ParaViewPlugin/pqExtractGroupPanel.cxx +++ /dev/null @@ -1,374 +0,0 @@ -// Copyright (C) 2010-2015 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// Author : Anthony Geay - -#include "pqExtractGroupPanel.h" -#include "ui_ExtractGroupPanel.h" - -#include "vtkProcessModule.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkInformation.h" -#include "vtkIntArray.h" -#include "vtkSMDoubleVectorProperty.h" -#include "vtkSMIntVectorProperty.h" -#include "vtkSMStringVectorProperty.h" -#include "vtkSMProxy.h" -#include "vtkSMSourceProxy.h" -#include "vtkEventQtSlotConnect.h" -#include "vtkPVSILInformation.h" -#include "vtkGraph.h" -#include "vtkMutableDirectedGraph.h" -#include "vtkAdjacentVertexIterator.h" -#include "vtkSMPropertyHelper.h" -#include "vtkStringArray.h" -#include "vtkDataSetAttributes.h" -#include "vtkExtractGroup.h" - -#include "pqTreeWidgetItemObject.h" -#include "pqSMAdaptor.h" -#include "pqProxy.h" -#include "pqPropertyManager.h" -#include "pqSILModel.h" -#include "pqProxySILModel.h" -#include "pqTreeViewSelectionHelper.h" -#include "pqTreeWidgetSelectionHelper.h" -#include "pqPropertyLinks.h" - -#include - -#include - -static const char ZE_SEP[]="@@][@@"; - -class PixSingleExtractPanel -{ -public: - static const PixSingleExtractPanel &GetInstance(); - QPixmap getPixFromStr(int pos) const; - PixSingleExtractPanel(); -private: - static const int NB_OF_DISCR=4; - static PixSingleExtractPanel *UNIQUE_INSTANCE; - QPixmap _pixmaps[NB_OF_DISCR]; -}; - -PixSingleExtractPanel *PixSingleExtractPanel::UNIQUE_INSTANCE=0; - -const PixSingleExtractPanel &PixSingleExtractPanel::GetInstance() -{ - if(!UNIQUE_INSTANCE) - UNIQUE_INSTANCE=new PixSingleExtractPanel; - return *UNIQUE_INSTANCE; -} - -PixSingleExtractPanel::PixSingleExtractPanel() -{ - _pixmaps[0]=QPixmap(":/ParaViewResources/Icons/pqCellData16.png"); - _pixmaps[1]=QPixmap(":/ParaViewResources/Icons/pqPointData16.png"); -} - -QPixmap PixSingleExtractPanel::getPixFromStr(int pos) const -{ - if(pos>=0 && pos<=1) - return _pixmaps[pos]; - else - return QPixmap(); -} - -class pqExtractGroupPanel::pqUI: public QObject, public Ui::ExtractGroupPanel -{ -public: - pqUI(pqExtractGroupPanel* p):QObject(p) - { - this->VTKConnect = vtkSmartPointer::New(); - this->SILUpdateStamp = -1; - } - - ~pqUI() { } - - pqSILModel SILModel; - vtkSmartPointer VTKConnect; - pqPropertyLinks Links; - QMap TreeItemToPropMap; - int SILUpdateStamp; -}; - -pqExtractGroupPanel::pqExtractGroupPanel(pqProxy* object_proxy, QWidget* p):Superclass(object_proxy, p) -{ - this->UI=new pqUI(this); - this->UI->setupUi(this); - pqProxySILModel*proxyModel2 = new pqProxySILModel("GroupsFlagsStatusTree", &this->UI->SILModel); - proxyModel2->setSourceModel(&this->UI->SILModel); - this->UI->Fields->setHeaderHidden(true); - this->updateSIL(); - this->linkServerManagerProperties(); - //////////////////// - vtkSMProperty *SMProperty(this->proxy()->GetProperty("GroupsFlagsStatus")); - //////////////////// - vtkSMProxy* reader = this->referenceProxy()->getProxy(); - vtkPVSILInformation* info=vtkPVSILInformation::New(); - reader->GatherInformation(info); - vtkGraph *g(info->GetSIL()); - //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 ? - vtkMutableDirectedGraph *g2(static_cast(g)); - int idNames(0); - if(!g2) - return ; - vtkAbstractArray *verticesNames(g2->GetVertexData()->GetAbstractArray("Names",idNames)); - vtkStringArray *verticesNames2(vtkStringArray::SafeDownCast(verticesNames)); - vtkIdType id0; - bool found(false); - for(int i=0;iGetNumberOfValues();i++) - { - vtkStdString &st(verticesNames2->GetValue(i)); - if(st=="MeshesFamsGrps") - { - id0=i; - found=true; - } - } - if(!found) - std::cerr << "There is an internal error ! The tree on server side has not the expected look !" << std::endl; - vtkAdjacentVertexIterator *it0(vtkAdjacentVertexIterator::New()); - g2->GetAdjacentVertices(id0,it0); - int kk(0),ll(0); - while(it0->HasNext()) - { - vtkIdType id1(it0->Next()); - QString meshName(QString::fromStdString((const char *)verticesNames2->GetValue(id1))); - vtkAdjacentVertexIterator *it1(vtkAdjacentVertexIterator::New()); - g2->GetAdjacentVertices(id1,it1); - vtkIdType idZeGrps(it1->Next());//zeGroups - QList strs0; strs0.append(QString("Groups of \"%1\"").arg(meshName)); - pqTreeWidgetItemObject *item0(new pqTreeWidgetItemObject(this->UI->Fields,strs0)); - std::map famIds(DeduceMapOfFamilyFromSIL(g2)); - //item0->setData(0,Qt::CheckStateRole,0); - vtkAdjacentVertexIterator *itGrps(vtkAdjacentVertexIterator::New()); - g2->GetAdjacentVertices(idZeGrps,itGrps); - while(itGrps->HasNext()) - { - vtkIdType idg(itGrps->Next()); - QString name0(QString::fromStdString((const char *)verticesNames2->GetValue(idg))); QList strs0; strs0.append(name0); - QString toolTipName0(name0); - pqTreeWidgetItemObject *item1(new pqTreeWidgetItemObject(item0,strs0)); - // - vtkAdjacentVertexIterator *itFamsOnGrp(vtkAdjacentVertexIterator::New()); - g2->GetAdjacentVertices(idg,itFamsOnGrp); - bool isOnCell(true),isOnPoint(true); - while(itFamsOnGrp->HasNext()) - { - vtkIdType idfg(itFamsOnGrp->Next()); - std::string namefg((const char *)verticesNames2->GetValue(idfg)); - std::map::const_iterator ittt(famIds.find(namefg)); - if(ittt==famIds.end()) - { isOnCell=false; isOnPoint=false; break; } - int zeId((*ittt).second); - if(zeId<0) - { - if(!isOnCell) - { isOnCell=false; isOnPoint=false; break; } - else - isOnPoint=false; - } - if(zeId>0) - { - if(!isOnPoint) - { isOnCell=false; isOnPoint=false; break; } - else - isOnCell=false; - } - } - itFamsOnGrp->Delete(); - item1->setData(0,Qt::UserRole,name0); - item1->setData(0,Qt::ToolTipRole,toolTipName0); - item1->setData(0,Qt::CheckStateRole,0); - if(isOnCell && !isOnPoint) - item1->setData(0,Qt::DecorationRole,PixSingleExtractPanel::GetInstance().getPixFromStr(0)); - if(!isOnCell && isOnPoint) - item1->setData(0,Qt::DecorationRole,PixSingleExtractPanel::GetInstance().getPixFromStr(1)); - item1->setProperty("PosInStringVector",QVariant(ll++)); - connect(item1,SIGNAL(checkedStateChanged(bool)),this,SLOT(anItemAsBeenFired())); - } - itGrps->Delete(); - // families - vtkIdType idZeFams(it1->Next());//zeFams - strs0.clear(); strs0.append(QString("Families of \"%1\"").arg(meshName)); - pqTreeWidgetItemObject *item00(new pqTreeWidgetItemObject(this->UI->Fields,strs0)); - //item00->setData(0,Qt::CheckStateRole,0); - vtkAdjacentVertexIterator *itFams(vtkAdjacentVertexIterator::New()); - g2->GetAdjacentVertices(idZeFams,itFams); - while(itFams->HasNext()) - { - vtkIdType idf(itFams->Next()); - std::string crudeFamName((const char *)verticesNames2->GetValue(idf)); - std::size_t pos(crudeFamName.find_first_of(ZE_SEP)); - std::string famName(crudeFamName.substr(0,pos)); std::string idStr(crudeFamName.substr(pos+strlen(ZE_SEP))); - int idInt(QString(idStr.c_str()).toInt()); - famIds[famName]=idInt; - QString name0(famName.c_str()); QList strs0; strs0.append(name0); - QString toolTipName0(QString("%1 (%2)").arg(QString(famName.c_str())).arg(QString(idStr.c_str()))); - pqTreeWidgetItemObject *item1(new pqTreeWidgetItemObject(item00,strs0)); - item1->setData(0,Qt::UserRole,name0); - item1->setData(0,Qt::ToolTipRole,toolTipName0); - item1->setData(0,Qt::CheckStateRole,0); - if(idInt<0) - item1->setData(0,Qt::DecorationRole,PixSingleExtractPanel::GetInstance().getPixFromStr(0)); - if(idInt>0) - item1->setData(0,Qt::DecorationRole,PixSingleExtractPanel::GetInstance().getPixFromStr(1)); - item1->setProperty("PosInStringVector",QVariant(ll++)); - connect(item1,SIGNAL(checkedStateChanged(bool)),this,SLOT(anItemAsBeenFired())); - } - itFams->Delete(); - } - it0->Delete(); - this->UI->Fields->header()->setStretchLastSection(true); - this->UI->Fields->expandAll(); - info->Delete(); - //////////////////// - vtkSMProperty *SMPropertyExtractComp(this->proxy()->GetProperty("InsideOut")); - this->propertyManager()->registerLink(this->UI->ExtractComplementary,"checked",SIGNAL(stateChanged(int)),this->proxy(),SMPropertyExtractComp); - //////////////////// - this->UI->VTKConnect->Connect(this->proxy(),vtkCommand::UpdateInformationEvent, this, SLOT(updateSIL())); -} - -pqExtractGroupPanel::~pqExtractGroupPanel() -{ -} - -void pqExtractGroupPanel::linkServerManagerProperties() -{ - this->Superclass::linkServerManagerProperties(); -} - -void pqExtractGroupPanel::updateSIL() -{ - vtkSMProxy* reader = this->referenceProxy()->getProxy(); - reader->UpdatePropertyInformation(reader->GetProperty("SILUpdateStamp")); - int stamp = vtkSMPropertyHelper(reader, "SILUpdateStamp").GetAsInt(); - if (stamp != this->UI->SILUpdateStamp) - { - this->UI->SILUpdateStamp = stamp; - vtkPVSILInformation* info = vtkPVSILInformation::New(); - reader->GatherInformation(info); - vtkGraph *sil(info->GetSIL()); - if(sil) - { - this->UI->SILModel.update(sil); - this->UI->Fields->expandAll(); - info->Delete(); - } - } -} - -void pqExtractGroupPanel::anItemAsBeenFired() -{ - /// - vtkSMProxy *proxy(this->proxy()); - vtkSMProperty *SMProperty(proxy->GetProperty("GroupsFlagsStatus")); - vtkSMStringVectorProperty *sm(dynamic_cast(SMProperty)); - unsigned int nb(sm->GetNumberOfElements()); - std::vector sts(nb); - for(unsigned int i=0;iGetElement(i); - /// - pqTreeWidget *sc(this->UI->Fields); - for(int i0=0;i0topLevelItemCount();i0++) - { - QTreeWidgetItem *lev0(sc->topLevelItem(i0));//Group and Fam - for(int i1=0;i1childCount();i1++) - { - QTreeWidgetItem *lev1(lev0->child(i1)); - pqTreeWidgetItemObject *scc(dynamic_cast(lev1)); - int ll(scc->property("PosInStringVector").toInt()); - int v(scc->isChecked()); - std::ostringstream oss; oss << v; - sts[2*ll+1]=oss.str(); - } - } - /// - const char **args=new const char *[nb]; - for(unsigned int i=0;iGetImmediateUpdate()); - //sm->SetNumberOfElements(0); - sm->SetElements(args,nb); - proxy->UpdateVTKObjects(); - sm->SetImmediateUpdate(iup); - } - delete [] args; - // - ((vtkSMSourceProxy *)proxy)->UpdatePipelineInformation(); - setModified(); -} - -std::map pqExtractGroupPanel::DeduceMapOfFamilyFromSIL(vtkMutableDirectedGraph *graph) -{ - std::map ret; - int idNames(0); - vtkAbstractArray *verticesNames(graph->GetVertexData()->GetAbstractArray("Names",idNames)); - vtkStringArray *verticesNames2(vtkStringArray::SafeDownCast(verticesNames)); - vtkAdjacentVertexIterator *it0(vtkAdjacentVertexIterator::New()); - vtkIdType id0; - bool found(false); - for(int i=0;iGetNumberOfValues();i++) - { - vtkStdString &st(verticesNames2->GetValue(i)); - if(st=="MeshesFamsGrps") - { - id0=i; - found=true; - } - } - if(!found) - std::cerr << "There is an internal error ! The tree on server side has not the expected look !" << std::endl; - graph->GetAdjacentVertices(id0,it0); - while(it0->HasNext()) - { - vtkIdType id1(it0->Next());//meshName - vtkAdjacentVertexIterator *it1(vtkAdjacentVertexIterator::New()); - graph->GetAdjacentVertices(id1,it1); - it1->Next();//zeGroups - vtkIdType idZeFams(it1->Next());//zeFams - vtkAdjacentVertexIterator *itFams(vtkAdjacentVertexIterator::New()); - graph->GetAdjacentVertices(idZeFams,itFams); - while(itFams->HasNext()) - { - vtkIdType idf(itFams->Next()); - std::string crudeFamName((const char *)verticesNames2->GetValue(idf)); - std::size_t pos(crudeFamName.find_first_of(ZE_SEP)); - std::string famName(crudeFamName.substr(0,pos)); std::string idStr(crudeFamName.substr(pos+strlen(ZE_SEP))); - int idInt(QString(idStr.c_str()).toInt()); - ret[famName]=idInt; - } - it1->Delete(); - } - it0->Delete(); - return ret; -} - -void pqExtractGroupPanel::updateInformationAndDomains() -{ - pqNamedObjectPanel::updateInformationAndDomains(); - vtkSMProxy *proxy(this->proxy()); - vtkSMProperty *SMProperty(proxy->GetProperty("GroupsFlagsStatus")); - SMProperty->Modified();// agy : THE LINE FOR 7.5.1 ! -} diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqExtractGroupPanel.h b/src/Plugins/MEDReader/ParaViewPlugin/pqExtractGroupPanel.h deleted file mode 100644 index ac244349..00000000 --- a/src/Plugins/MEDReader/ParaViewPlugin/pqExtractGroupPanel.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2010-2015 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// Author : Anthony Geay - -#ifndef _pqExtractGroupPanel_h -#define _pqExtractGroupPanel_h - -#include "pqNamedObjectPanel.h" - -#include - -class pqTreeWidgetItemObject; - -class vtkSMProperty; -class vtkMutableDirectedGraph; - -class pqExtractGroupPanel: public pqNamedObjectPanel -{ -Q_OBJECT - typedef pqNamedObjectPanel Superclass; -public: - pqExtractGroupPanel(pqProxy* proxy, QWidget* p = NULL); - ~pqExtractGroupPanel(); - void updateInformationAndDomains(); -protected slots: - void updateSIL(); - void anItemAsBeenFired(); -private: - static std::map DeduceMapOfFamilyFromSIL(vtkMutableDirectedGraph *graph); -protected: - /// populate widgets with properties from the server manager - virtual void linkServerManagerProperties(); - class pqUI; - pqUI* UI; -}; - -#endif diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderFieldsWidget.cxx b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderFieldsWidget.cxx new file mode 100644 index 00000000..1009a770 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderFieldsWidget.cxx @@ -0,0 +1,273 @@ +// Copyright (C) 2010-2015 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "pqMEDReaderFieldsWidget.h" + +#include "vtkMEDReader.h" +#include "vtkPVMetaDataInformation.h" + +#include "pqTreeWidget.h" +#include "pqTreeWidgetItemObject.h" +#include "vtkDataSetAttributes.h" +#include "vtkGraph.h" +#include "vtkNew.h" +#include "vtkStringArray.h" +#include "vtkTree.h" + +#include +#include + +//----------------------------------------------------------------------------- +pqMEDReaderFieldsWidget::pqMEDReaderFieldsWidget( + vtkSMProxy *smproxy, vtkSMProperty *smproperty, QWidget *parentObject) +: Superclass(smproxy, smproperty, parentObject) +{ + this->TreeWidget->header()->hide(); + this->visibleHeader = false; + this->TransmitToParent = true; + this->initializeTreeWidget(smproxy, smproperty); +} + +//----------------------------------------------------------------------------- +pqMEDReaderFieldsWidget::~pqMEDReaderFieldsWidget() +{ +} + +//----------------------------------------------------------------------------- +void pqMEDReaderFieldsWidget::loadTreeWidgetItems() +{ + //Clear Item Map + this->ItemMap.clear(); + + // Clear tree + this->TreeWidget->clear(); + + // Clear unique checked item vector + this->UniqueCheckedItems.clear(); + + // Recover meta data graph + vtkPVMetaDataInformation *info(vtkPVMetaDataInformation::New()); + this->proxy()->GatherInformation(info); + vtkGraph* graph = vtkGraph::SafeDownCast(info->GetInformationData()); + + // Create a tree + vtkNew tree; + tree->CheckedShallowCopy(graph); + vtkStringArray* names = + vtkStringArray::SafeDownCast(tree->GetVertexData()->GetAbstractArray("Names")); + + vtkIdType root = tree->GetRoot(); + vtkIdType fst = tree->GetChild(root, 0); // FieldsStatusTree + + this->NItems = 0; + int nLeaves = 0; + for (int i = 1; i < tree->GetNumberOfChildren(fst); i += 2) + { + // Browse all interessting tree node + + // TSX Node + vtkIdType tsxId = tree->GetChild(fst, i); + vtkIdType tsId = tree->GetChild(fst, i - 1); + pqTreeWidgetItemObject *ts = new pqTreeWidgetItemObject(this->TreeWidget, QStringList()); + this->NItems++; + QString tsxName = QString(names->GetValue(tsxId)); + ts->setText(0, tsxName); + ts->setData(0, Qt::ToolTipRole, QString(names->GetValue(tsId))); + + // MAIL Node + vtkIdType mailId = tree->GetChild(tsxId, 0); + pqTreeWidgetItemObject *mail = new pqTreeWidgetItemObject(ts, QStringList()); + this->NItems++; + QString mailName = QString(names->GetValue(mailId)); + mail->setText(0, mailName); + mail->setData(0, Qt::ToolTipRole, QString(names->GetValue(mailId))); + + QString propertyBaseName = tsxName + "/" + mailName + "/"; + + // ComsupX node + for (int comsupi = 0; comsupi < tree->GetNumberOfChildren(mailId); comsupi++) + { + vtkIdType comSupId = tree->GetChild(mailId, comsupi); + pqTreeWidgetItemObject *comsup = new pqTreeWidgetItemObject(mail, QStringList()); + this->NItems++; + QString comsupName = QString(names->GetValue(comSupId)); + comsup->setText(0, comsupName); + + // ComSup tooltip + vtkIdType geoTypeId = tree->GetChild(comSupId, 1); + QString comSupToolTipName(names->GetValue(comSupId)); + for (int geoi = 0; geoi < tree->GetNumberOfChildren(geoTypeId); geoi++) + { + comSupToolTipName += QString("\n- %1").arg( + QString(names->GetValue(tree->GetChild(geoTypeId, geoi)))); + } + comsup->setData(0, Qt::ToolTipRole, comSupToolTipName); + + comsup->setFlags(comsup->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable); + comsup->setChecked(true); + QObject::connect(comsup, SIGNAL(checkedStateChanged(bool)), this, SLOT(updateChecks())); + this->UniqueCheckedItems.push_back(comsup); + + QString fullComsupName = propertyBaseName + comsupName + "/"; + // Arrs node + vtkIdType arrId = tree->GetChild(comSupId, 0); + for (int arri = 0; arri < tree->GetNumberOfChildren(arrId); arri++) + { + pqTreeWidgetItemObject *array = new pqTreeWidgetItemObject(comsup, QStringList()); + this->NItems++; + + vtkIdType arrayId = tree->GetChild(arrId, arri); + std::string str = names->GetValue(arrayId); + this->ItemMap[fullComsupName + QString(str.c_str())] = array; + + const char* separator = vtkMEDReader::GetSeparator(); + size_t pos = str.find(separator); + std::string name = str.substr(0, pos); + + array->setText(0, QString(name.c_str())); + array->setFlags(array->flags() | Qt::ItemIsUserCheckable); + array->setChecked(true); + + // Special Field + if (tree->GetNumberOfChildren(arrayId) != 0) + { + QFont font; + font.setItalic(true); + font.setUnderline(true); + array->setData(0, Qt::FontRole, QVariant(font)); + + array->setData(0, Qt::ToolTipRole, + QString("Whole \" %1\" mesh").arg(name.c_str())); + array->setData(0, Qt::DecorationRole, + QPixmap(":/ParaViewResources/Icons/pqCellDataForWholeMesh16.png")); + } + // Standard Field + else + { + std::string spatialDiscr = str.substr(pos + strlen(separator)); + QString tooltip = QString(name.c_str() + QString(" (") + + spatialDiscr.c_str() + QString(")")); + array->setData(0, Qt::ToolTipRole, tooltip); + + QPixmap pix; + if (spatialDiscr == "P0") + { + pix.load(":/ParaViewResources/Icons/pqCellData16.png"); + } + else if (spatialDiscr == "P1") + { + pix.load(":/ParaViewResources/Icons/pqPointData16.png"); + } + else if (spatialDiscr == "GAUSS") + { + pix.load(":/ParaViewResources/Icons/pqQuadratureData16.png"); + } + else if (spatialDiscr == "GSSNE") + { + pix.load(":/ParaViewResources/Icons/pqElnoData16.png"); + } + array->setData(0, Qt::DecorationRole, pix); + } + + // Connection and updating checks for each item + QObject::connect(array, SIGNAL(checkedStateChanged(bool)), this, SLOT(updateChecks())); + nLeaves++; + } + } + } + + // Expand tree + this->TreeWidget->expandAll(); +} + +//----------------------------------------------------------------------------- +void pqMEDReaderFieldsWidget::uncheckOtherUniqueItems(pqTreeWidgetItemObject* item) +{ + // Uncheck all other items in vector + foreach (pqTreeWidgetItemObject* otherItems, this->UniqueCheckedItems) + { + if (otherItems != item) + { + otherItems->setCheckState(0, Qt::Unchecked); + } + } +} + +//----------------------------------------------------------------------------- +void pqMEDReaderFieldsWidget::updateChecks() +{ + // Call updateCheck on the sender + pqTreeWidgetItemObject* item = qobject_cast(QObject::sender()); + this->updateChecks(item); +} + +//----------------------------------------------------------------------------- +void pqMEDReaderFieldsWidget::updateChecks(pqTreeWidgetItemObject* item) +{ + // When a Leaf item is checked, the parent will be checked (partially or not). + // Then other parents will be unchecked using uncheckOtherUniqueItems + // Then other parent leaf will be unchecked using updateChecks(parent) + // + // When a Parent item is checked, the leaf will be checked + // Then other parents will be unchecked using uncheckOtherUniqueItems + // Then other parent leaf will be unchecked using updateChecks(parent) + + if (item->childCount() == 0) + { + // Only first level leaf will transmit checks to parent + if (this->TransmitToParent) + { + // Recover correct parent state + Qt::CheckState state = item->checkState(0); + pqTreeWidgetItemObject* parent = + dynamic_cast(item->QTreeWidgetItem::parent()); + for (int i = 0; i < parent->childCount(); i++) + { + if (parent->child(i)->checkState(0) != state) + { + state = Qt::PartiallyChecked; + } + } + // Set Parent State + parent->setCheckState(0, state); + } + } + else + { + // Check/Uncheck childs, blocking looped call to slot + if (item->checkState(0) != Qt::PartiallyChecked) + { + this->TransmitToParent = false; + for (int i = 0; i < item->childCount(); i++) + { + pqTreeWidgetItemObject* leaf = + dynamic_cast(item->child(i)); + leaf->setCheckState(0, item->checkState(0)); + } + this->TransmitToParent = true; + } + + // Uncheck other unique checked items + if (item->checkState(0) != Qt::Unchecked) + { + this->uncheckOtherUniqueItems(item); + } + } +} diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderFieldsWidget.h b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderFieldsWidget.h new file mode 100644 index 00000000..be3140ce --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderFieldsWidget.h @@ -0,0 +1,70 @@ +// Copyright (C) 2010-2015 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#ifndef __pqMEDReaderFieldsWidget_h +#define __pqMEDReaderFieldsWidget_h + +#include "pqAbstractFieldsWidget.h" + +class vtkSMProxy; +class vtkSMProperty; +class pqMEDReaderFieldsWidget : public pqAbstractFieldsWidget +{ + typedef pqAbstractFieldsWidget Superclass; + Q_OBJECT + +public: + pqMEDReaderFieldsWidget( + vtkSMProxy *smproxy, vtkSMProperty *smproperty, QWidget *parentObject = 0); + virtual ~pqMEDReaderFieldsWidget(); + +protected: + // Descritpion + // Load the tree widget using recovered meta data graph + // and connect each item to indexed property + void loadTreeWidgetItems(); + + // Description + // Uncheck other unique checked item + void uncheckOtherUniqueItems(pqTreeWidgetItemObject* item); + + // Description + // Update check state of other items using provided item + void updateChecks(pqTreeWidgetItemObject* item); + + // Description + // Vector of unique checked items + std::vector UniqueCheckedItems; + + // Description + // Flag indicating if updateCheck method is recursivelly called, + // to avoid infinite loop + bool TransmitToParent; + +protected slots: + // Description + // Update check state of other items using the sender object + void updateChecks(); + +private: + Q_DISABLE_COPY(pqMEDReaderFieldsWidget); +}; + +#endif diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderGraphUtils.cxx b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderGraphUtils.cxx new file mode 100644 index 00000000..06bc8486 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderGraphUtils.cxx @@ -0,0 +1,77 @@ +// Copyright (C) 2010-2015 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "pqMEDReaderGraphUtils.h" + +#include "vtkGraph.h" +#include "vtkTree.h" +#include "vtkNew.h" +#include "vtkStringArray.h" +#include "vtkDataSetAttributes.h" + +namespace pqMedReaderGraphUtils +{ +void getCurrentTS(vtkGraph* graph, vtkIdType id, QStringList& dts, QStringList& its, + QStringList& tts) +{ + vtkNew tree; + tree->CheckedShallowCopy(graph); + vtkStringArray* names = vtkStringArray::SafeDownCast( + tree->GetVertexData()->GetAbstractArray("Names")); + vtkIdType root = tree->GetRoot(); + vtkIdType fst = tree->GetChild(root, 0); // FieldsStatusTree + vtkIdType tsr = tree->GetChild(tree->GetChild(fst, id*2), 0); //Time Step root node + vtkIdType tmp; + for (int i = 0; i < tree->GetNumberOfChildren(tsr); i++) + { + // Each Time Step + // Recover step + tmp = tree->GetChild(tsr, i); + dts << QString(names->GetValue(tmp)); + + // Recover mode + tmp = tree->GetChild(tmp, 0); + its << QString(names->GetValue(tmp)); + + // Recover value + tmp = tree->GetChild(tmp, 0); + tts << QString(names->GetValue(tmp)); + } +} + +int getMaxNumberOfTS(vtkGraph* graph) +{ + vtkNew tree; + tree->CheckedShallowCopy(graph); + vtkStringArray* names = vtkStringArray::SafeDownCast( + tree->GetVertexData()->GetAbstractArray("Names")); + vtkIdType root = tree->GetRoot(); + vtkIdType fst = tree->GetChild(root, 0); // FieldsStatusTree + vtkIdType tmp; + int nbTS = 0; + for (int i = 0; i < tree->GetNumberOfChildren(fst); i += 2) + { + // Look for max time steps + tmp = tree->GetChild(tree->GetChild(fst, i), 0); + nbTS = std::max(nbTS, names->GetVariantValue(tmp).ToInt()); + } + return nbTS; +} +} diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderGraphUtils.h b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderGraphUtils.h new file mode 100644 index 00000000..f9060968 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderGraphUtils.h @@ -0,0 +1,43 @@ +// Copyright (C) 2010-2015 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#ifndef _pqMEDReaderGraphUtils_h +#define _pqMEDReaderGraphUtils_h + +#include "vtkType.h" + +#include + +class vtkGraph; +class pqTreeWidget; + +namespace pqMedReaderGraphUtils +{ + // Description + // Extract Current Time Step from a meta data graph + void getCurrentTS(vtkGraph* graph, vtkIdType id, QStringList& dts, + QStringList& its, QStringList& tts); + + // Description + // Extract the maximum number of timestep from a meta data graph + int getMaxNumberOfTS(vtkGraph* graph); +} + +#endif diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderPanel.cxx b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderPanel.cxx deleted file mode 100644 index 00b7dd62..00000000 --- a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderPanel.cxx +++ /dev/null @@ -1,647 +0,0 @@ -// Copyright (C) 2010-2015 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// Author : Anthony Geay - -#include "pqMEDReaderPanel.h" -#include "ui_MEDReaderPanel.h" -#include "VectBoolWidget.h" - -#include "vtkProcessModule.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkInformation.h" -#include "vtkIntArray.h" -#include "vtkSMDoubleVectorProperty.h" -#include "vtkSMIntVectorProperty.h" -#include "vtkSMStringVectorProperty.h" -#include "vtkSMProxy.h" -#include "vtkEventQtSlotConnect.h" -#include "vtkPVSILInformation.h" -#include "vtkGraph.h" -#include "vtkMutableDirectedGraph.h" -#include "vtkAdjacentVertexIterator.h" -#include "vtkSMPropertyHelper.h" -#include "vtkStringArray.h" -#include "vtkDataSetAttributes.h" -#include "vtkMEDReader.h" -#include "vtkSMSourceProxy.h" - -#include "pqTreeWidgetItemObject.h" -#include "pqSMAdaptor.h" -#include "pqProxy.h" -#include "pqPropertyManager.h" -#include "pqSILModel.h" -#include "pqProxySILModel.h" -#include "pqTreeViewSelectionHelper.h" -#include "pqTreeWidgetSelectionHelper.h" - -#include - -#include - -static const char ZE_SEP[]="@@][@@"; - -class PixSingle -{ -public: - static const PixSingle &GetInstance(); - QPixmap getPixFromStr(const std::string& st) const; - QPixmap getWholeMeshPix() const; - PixSingle(); -private: - static const int NB_OF_DISCR=4; - static PixSingle *UNIQUE_PIX_SINGLE; - QPixmap _pixmaps[NB_OF_DISCR]; - std::map _ze_map; - QPixmap _whole_mesh; -}; - -PixSingle *PixSingle::UNIQUE_PIX_SINGLE=0; - -const PixSingle &PixSingle::GetInstance() -{ - if(!UNIQUE_PIX_SINGLE) - UNIQUE_PIX_SINGLE=new PixSingle; - return *UNIQUE_PIX_SINGLE; -} - -PixSingle::PixSingle() -{ - _pixmaps[0]=QPixmap(":/ParaViewResources/Icons/pqCellData16.png"); - _pixmaps[1]=QPixmap(":/ParaViewResources/Icons/pqPointData16.png"); - _pixmaps[2]=QPixmap(":/ParaViewResources/Icons/pqQuadratureData16.png"); - _pixmaps[3]=QPixmap(":/ParaViewResources/Icons/pqElnoData16.png"); - _ze_map[std::string("P0")]=0; - _ze_map[std::string("P1")]=1; - _ze_map[std::string("GAUSS")]=2; - _ze_map[std::string("GSSNE")]=3; - _whole_mesh=QPixmap(":/ParaViewResources/Icons/pqCellDataForWholeMesh16.png"); -} - -QPixmap PixSingle::getPixFromStr(const std::string& st) const -{ - std::map::const_iterator it(_ze_map.find(st)); - if(it!=_ze_map.end()) - return _pixmaps[(*it).second]; - else - return QPixmap(); -} - -QPixmap PixSingle::getWholeMeshPix() const -{ - return _whole_mesh; -} - -class pqMEDReaderPanel::pqUI: public QObject, public Ui::MEDReaderPanel -{ -public: - pqUI(pqMEDReaderPanel *p):QObject(p) - { - this->VTKConnect = vtkSmartPointer::New(); - } - - ~pqUI() { } - - vtkSmartPointer VTKConnect; - QMap TreeItemToPropMap; -}; - -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) -{ - initAll(); -} - -// VSR, 16/03/2015, PAL22921 -// Below is the helper class which is implemented a workaround about ugly pqTreeWidgetItemObject class. -// We use this helper class to make 1st and 2nd level tree items uncheckable. -class pqMyTreeWidgetItemObject : public pqTreeWidgetItemObject -{ -public: - pqMyTreeWidgetItemObject(const QStringList& t, int type=QTreeWidgetItem::UserType): pqTreeWidgetItemObject(t, type){} - pqMyTreeWidgetItemObject(QTreeWidget* p, const QStringList& t, int type=QTreeWidgetItem::UserType): pqTreeWidgetItemObject(p, t, type){} - pqMyTreeWidgetItemObject(QTreeWidgetItem* p, const QStringList& t, int type=QTreeWidgetItem::UserType): pqTreeWidgetItemObject(p, t, type){} - virtual void setData ( int column, int role, const QVariant & value ) - { - if ( role != Qt::CheckStateRole) - pqTreeWidgetItemObject::setData(column, role, value ); - } -}; - -void pqMEDReaderPanel::initAll() -{ - _all_lev4.clear(); - this->UI=new pqUI(this); - 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); - vtkGraph *g(info->GetSIL()); - if(!g)//something wrong server side... - return ; - //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 ? - vtkMutableDirectedGraph *g2(static_cast(g)); - int idNames(0); - vtkAbstractArray *verticesNames(g2->GetVertexData()->GetAbstractArray("Names",idNames)); - vtkStringArray *verticesNames2(vtkStringArray::SafeDownCast(verticesNames)); - vtkIdType id0; - bool found(false); - for(int i=0;iGetNumberOfValues();i++) - { - vtkStdString &st(verticesNames2->GetValue(i)); - if(st=="FieldsStatusTree") - { - id0=i; - found=true; - } - } - if(!found) - std::cerr << "There is an internal error ! The tree on server side has not the expected look !" << std::endl; - vtkAdjacentVertexIterator *it0(vtkAdjacentVertexIterator::New()); - g2->GetAdjacentVertices(id0,it0); - int kk(0),ll(0); - while(it0->HasNext()) - { - vtkIdType idToolTipForTS(it0->Next()); - QString toolTipName0(QString::fromStdString((const char *)verticesNames2->GetValue(idToolTipForTS))); - QString nbTS; - QList dts,its,tts; - { - vtkAdjacentVertexIterator *itForTS(vtkAdjacentVertexIterator::New()); - g2->GetAdjacentVertices(idToolTipForTS,itForTS); - vtkIdType idForNbTS(itForTS->Next()); - nbTS=QString::fromStdString((const char *)verticesNames2->GetValue(idForNbTS)); - itForTS->Delete(); - int nbTSInt(nbTS.toInt()); - for(int ii=0;iiGetValue(idForNbTS+3*ii+1))); - its.push_back(QString::fromStdString((const char *)verticesNames2->GetValue(idForNbTS+3*ii+2))); - tts.push_back(QString::fromStdString((const char *)verticesNames2->GetValue(idForNbTS+3*ii+3))); - } - } - 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); - pqTreeWidgetItemObject *item0(new pqMyTreeWidgetItemObject(this->UI->Fields,strs0)); - item0->setData(0,Qt::UserRole,name0); - item0->setData(0,Qt::ToolTipRole,toolTipName0); - // - QList modulesAct; - for(int i=0;isetProperty("NbOfTS",nbTS); - item0->setProperty("DTS",QVariant(dts)); - item0->setProperty("ITS",QVariant(its)); - item0->setProperty("TTS",QVariant(tts)); - item0->setProperty("ChosenTS",QVariant(modulesAct)); - // - vtkAdjacentVertexIterator *it1(vtkAdjacentVertexIterator::New());//mesh - g2->GetAdjacentVertices(id1,it1); - while(it1->HasNext()) - { - vtkIdType id2(it1->Next()); - QString name1(QString::fromStdString((const char *)verticesNames2->GetValue(id2))); QList strs1; strs1.append(name1); - QString toolTipName1(name1); - pqTreeWidgetItemObject *item1(new pqMyTreeWidgetItemObject(item0,strs1)); - item1->setData(0,Qt::UserRole,name1); - item1->setData(0,Qt::ToolTipRole,toolTipName1); - vtkAdjacentVertexIterator *it2(vtkAdjacentVertexIterator::New());//common support - g2->GetAdjacentVertices(id2,it2); - while(it2->HasNext()) - { - vtkIdType id3(it2->Next()); - QString name2(QString::fromStdString((const char *)verticesNames2->GetValue(id3))); QList strs2; strs2.append(name2); - pqTreeWidgetItemObject *item2(new pqTreeWidgetItemObject(item1,strs2)); - item2->setData(0,Qt::UserRole,name2); - item2->setChecked(false); - vtkAdjacentVertexIterator *it3(vtkAdjacentVertexIterator::New());//fields ! - g2->GetAdjacentVertices(id3,it3); - vtkIdType id3Arrs(it3->Next()); - vtkAdjacentVertexIterator *it3Arrs(vtkAdjacentVertexIterator::New());//arrs in fields ! - g2->GetAdjacentVertices(id3Arrs,it3Arrs); - while(it3Arrs->HasNext()) - { - vtkIdType id4(it3Arrs->Next()); - std::string name3CppFull((const char *)verticesNames2->GetValue(id4)); - std::size_t pos(name3CppFull.find(ZE_SEP)); - std::string name3Only(name3CppFull.substr(0,pos)); std::string spatialDiscr(name3CppFull.substr(pos+sizeof(ZE_SEP)-1)); - QString name3(QString::fromStdString(name3Only)); QList strs3; strs3.append(name3); - QString toolTipName3(name3+QString(" (")+spatialDiscr.c_str()+QString(")")); - // - vtkAdjacentVertexIterator *it4(vtkAdjacentVertexIterator::New());// is it a special field ? A field mesh ? - g2->GetAdjacentVertices(id4,it4); - bool isSpecial(it4->HasNext()); - it4->Delete(); - // - pqTreeWidgetItemObject *item3(new pqTreeWidgetItemObject(item2,strs3)); - _all_lev4.push_back(item3); - item3->setData(0,Qt::UserRole,name3); - if(isSpecial) - { - QFont font; font.setItalic(true); font.setUnderline(true); - item3->setData(0,Qt::FontRole,QVariant(font)); - item3->setData(0,Qt::ToolTipRole,QString("Whole \"%1\" mesh").arg(name3)); - item3->setData(0,Qt::DecorationRole,PixSingle::GetInstance().getWholeMeshPix()); - } - else - { - item3->setData(0,Qt::ToolTipRole,toolTipName3); - item3->setData(0,Qt::DecorationRole,PixSingle::GetInstance().getPixFromStr(spatialDiscr)); - } - _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()); - 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++; - } - connect(item2,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev3HasBeenFired(bool))); - vtkIdType id3Gts(it3->Next()); - vtkAdjacentVertexIterator *it3Gts(vtkAdjacentVertexIterator::New());//geo types in fields ! - g2->GetAdjacentVertices(id3Gts,it3Gts); - QString toolTipName2(name2); - while(it3Gts->HasNext()) - { - vtkIdType idGt(it3Gts->Next()); - std::string gtName((const char *)verticesNames2->GetValue(idGt)); - toolTipName2=QString("%1\n- %2").arg(toolTipName2).arg(QString(gtName.c_str())); - } - item2->setData(0,Qt::ToolTipRole,toolTipName2); - it3Gts->Delete(); - it3->Delete(); - it3Arrs->Delete(); - kk++; - } - it2->Delete(); - } - it1->Delete(); - } - it0->Delete(); - this->UI->Fields->header()->setStretchLastSection(true); - this->UI->Fields->expandAll(); - info->Delete(); - this->UI->stdMode->setChecked(true); - this->UI->VTKConnect->Connect(this->proxy(),vtkCommand::UpdateInformationEvent, this, SLOT(updateSIL())); - /// - this->UI->Reload->setProperty("NbOfReloadDynProp",QVariant(1)); - vtkSMProperty *SMProperty(this->proxy()->GetProperty("ReloadReq")); - connect(this->UI->Reload,SIGNAL(pressed()),this,SLOT(reloadFired())); - this->propertyManager()->registerLink(this->UI->Reload,"NbOfReloadDynProp",SIGNAL(pressed()),this->proxy(),SMProperty); - /// - vtkSMProperty *SMProperty0(this->proxy()->GetProperty("GenerateVectors")); - this->propertyManager()->registerLink(this->UI->GenerateVects,"checked",SIGNAL(stateChanged(int)),this->proxy(),SMProperty0); - /// - vtkSMProperty *SMProperty2(this->proxy()->GetProperty("TimeOrModal")); - SMProperty2->ResetToDefault();//this line is very important ! - this->propertyManager()->registerLink(this->UI->modeMode,"checked",SIGNAL(toggled(bool)),this->proxy(),SMProperty2); - /// - delete _optional_widget; - _optional_widget=new VectBoolWidget(this->UI->timeStepsInspector,getMaxNumberOfTS()); - _optional_widget->hide(); - this->UI->timeStepsInspector->setMinimumSize(QSize(0,0)); - connect(this->UI->modeMode,SIGNAL(toggled(bool)),this,SLOT(vectOfBoolWidgetRequested(bool))); - vtkSMProperty *SMProperty3(this->proxy()->GetProperty("TimesFlagsStatus")); - SMProperty3->ResetToDefault(); - const QVector& items(_optional_widget->getItems()); - int itt(0); - foreach(VectBoolItem *item,items) - { - this->propertyManager()->registerLink(item,"activated",SIGNAL(changed()),this->proxy(),SMProperty3,itt++); - } -} - -pqMEDReaderPanel::~pqMEDReaderPanel() -{ - delete _optional_widget; -} - -void pqMEDReaderPanel::linkServerManagerProperties() -{ - this->Superclass::linkServerManagerProperties(); -} - -void pqMEDReaderPanel::updateSIL() -{ - if(_reload_req) - { - _reload_req=false; - this->UI->geometryGroupBox->hide(); - delete this->UI; - foreach(QObject *child,children()) - { - QLayout *layout(qobject_cast(child)); - if(layout) - delete layout; - } - initAll(); - } -} - -void pqMEDReaderPanel::aLev3HasBeenFired(bool v) -{ - pqTreeWidgetItemObject *zeItem(qobject_cast(sender())); - if(!zeItem) - return; - for(int i=0;ichildCount();i++) - { - QTreeWidgetItem *elt(zeItem->child(i)); - pqTreeWidgetItemObject *eltC(dynamic_cast(elt)); - if(eltC) - { - eltC->setChecked(v); - aLev4HasBeenFiredBy(eltC); - } - } - putLev3InOrder(); - somethingChangedInFieldRepr(); -} - -void pqMEDReaderPanel::aLev4HasBeenFired() -{ - pqTreeWidgetItemObject *zeItem(qobject_cast(sender())); - if(zeItem) - aLev4HasBeenFiredBy(zeItem); - putLev3InOrder(); - somethingChangedInFieldRepr(); -} - -void pqMEDReaderPanel::aLev4HasBeenFiredBy(pqTreeWidgetItemObject *zeItem) -{ - pqTreeWidgetItemObject *father(dynamic_cast(zeItem->QTreeWidgetItem::parent())); - QTreeWidgetItem *godFather(father->QTreeWidgetItem::parent()->parent()); - if(!father) - return ; - if(zeItem->isChecked()) - { - bool isActivatedTSChanged(false); - // This part garantees that all leaves having not the same father than zeItem are desactivated - foreach(pqTreeWidgetItemObject* elt,this->_all_lev4) - { - QTreeWidgetItem *testFath(elt->QTreeWidgetItem::parent()); - if(testFath!=father) - if(elt->isChecked()) - { - { - disconnect(elt,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev4HasBeenFired())); - elt->setChecked(false); - connect(elt,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev4HasBeenFired())); - } - if(godFather!=testFath->parent()->parent()) - isActivatedTSChanged=true; - } - } - // the user by clicking to a new entry has changed of TimeStepSeries -> notify it to thee time step selector widget - if(isActivatedTSChanged) - { - QStringList its,dts,tts; - getCurrentTS(its,dts,tts); - _optional_widget->setItems(its,dts,tts); - } - } - else - { - // if all are unchecked - check it again - bool allItemsAreUnChked(true); - foreach(pqTreeWidgetItemObject* elt,this->_all_lev4) - { - if(elt && elt->isChecked()) - allItemsAreUnChked=false; - } - if(allItemsAreUnChked) - { - disconnect(zeItem,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev4HasBeenFired())); - zeItem->setChecked(true);// OK zeItem was required to be unchecked but as it is the last one. Recheck it ! - connect(zeItem,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev4HasBeenFired())); - } - } -} - -void pqMEDReaderPanel::putLev3InOrder() -{ - std::vector::iterator it0(_all_lev4.begin()),it1; - while(it0!=_all_lev4.end()) - { - QTreeWidgetItem *curFather((*it0)->QTreeWidgetItem::parent()); - for(it1=it0+1;it1!=_all_lev4.end() && (*it1)->QTreeWidgetItem::parent()==curFather;it1++); - bool isAllFalse(true),isAllTrue(true); - for(std::vector::iterator it=it0;it!=it1;it++) - { - if((*it)->isChecked()) - isAllFalse=false; - else - isAllTrue=false; - } - if(isAllFalse || isAllTrue) - { - pqTreeWidgetItemObject *father(dynamic_cast(curFather)); - if(father) - { - disconnect(father,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev3HasBeenFired(bool))); - father->setChecked(isAllTrue); - connect(father,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev3HasBeenFired(bool))); - } - } - it0=it1; - } -} - -void pqMEDReaderPanel::reloadFired() -{ - static int iii(1); - QVariant v(iii++); - this->UI->Reload->setProperty("NbOfReloadDynProp",v); - _reload_req=true; - for(std::set >::const_iterator it=_leaves.begin();it!=_leaves.end();it++) - ((*it).first)->disconnect(SIGNAL(checkedStateChanged(bool))); - // - vtkSMProperty *SMProperty(this->proxy()->GetProperty("FieldsStatus")); - for(std::set >::const_iterator it=_leaves.begin();it!=_leaves.end();it++) - this->propertyManager()->unregisterLink((*it).first,"checked",SIGNAL(checkedStateChanged(bool)),this->proxy(),SMProperty,(*it).second); - this->propertyManager()->propertyChanged(); - vtkSMProperty *SMProperty3(this->proxy()->GetProperty("TimeOrModal")); - this->propertyManager()->unregisterLink(this->UI->modeMode,"checked",SIGNAL(toggled(bool)),this->proxy(),SMProperty3); -} - -void pqMEDReaderPanel::vectOfBoolWidgetRequested(bool isMode) -{ - if(isMode) - { - this->UI->timeStepsInspector->setMinimumSize(QSize(200,250)); - _optional_widget->show(); - QStringList its,dts,tts; - getCurrentTS(its,dts,tts); - _optional_widget->setItems(its,dts,tts); - } - else - { - _optional_widget->hide(); - this->UI->timeStepsInspector->setMinimumSize(QSize(0,0)); - } -} - -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 -{ - - for(std::vector::const_iterator it=_all_lev4.begin();it!=_all_lev4.end();it++) - { - if((*it)->property("checked").toInt()) - { - QTreeWidgetItem *obj((*it)->QTreeWidgetItem::parent()->QTreeWidgetItem::parent()->QTreeWidgetItem::parent()); - pqTreeWidgetItemObject *objC(dynamic_cast(obj)); - its=objC->property("ITS").toStringList(); - dts=objC->property("DTS").toStringList(); - tts=objC->property("TTS").toStringList(); - return; - } - } - std::cerr << "pqMEDReaderPanel::getCurrentTS : internal error ! Something is going wrong !" << std::endl; -} - -int pqMEDReaderPanel::getMaxNumberOfTS() const -{ - int ret(0); - for(std::vector::const_iterator it=_all_lev4.begin();it!=_all_lev4.end();it++) - { - QTreeWidgetItem *obj((*it)->QTreeWidgetItem::parent()->QTreeWidgetItem::parent()->QTreeWidgetItem::parent()); - pqTreeWidgetItemObject *objC(dynamic_cast(obj)); - ret=std::max(ret,objC->property("NbOfTS").toInt()); - } - return ret; -} - -void pqMEDReaderPanel::updateInformationAndDomains() -{ - //std::cerr << "updateInformationAndDomains called !" << std::endl; - pqNamedObjectPanel::updateInformationAndDomains(); - 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; - } - } - // now force modification of FieldsStatus property to appear in trace as AllArrays. - vtkSMProxy *proxy(this->proxy()); - vtkSMProperty *SMProperty(proxy->GetProperty("FieldsStatus")); - SMProperty->Modified();// agy : THE LINE FOR 7.5.1 ! -} - -/*! - * This slot is called by this->UI->Fields when one/several leaves have been modified. - */ -void pqMEDReaderPanel::somethingChangedInFieldRepr() -{ - /// - vtkSMProxy *proxy(this->proxy()); - vtkSMProperty *SMProperty(proxy->GetProperty("FieldsStatus")); - vtkSMStringVectorProperty *sm(dynamic_cast(SMProperty)); - unsigned int nb(sm->GetNumberOfElements()); - std::vector sts(nb); - /// - pqExodusIIVariableSelectionWidget *sc(this->UI->Fields); - for(int i0=0;i0topLevelItemCount();i0++) - { - QTreeWidgetItem *lev0(sc->topLevelItem(i0));//TS - for(int i1=0;i1childCount();i1++) - { - QTreeWidgetItem *lev1(lev0->child(i1));//Mesh - for(int i2=0;i2childCount();i2++) - { - QTreeWidgetItem *lev2(lev1->child(i2));//Comp - for(int i3=0;i3childCount();i3++) - { - QTreeWidgetItem *lev3(lev2->child(i3)); - pqTreeWidgetItemObject *scc(dynamic_cast(lev3)); - 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;iGetImmediateUpdate()); - //sm->SetNumberOfElements(0); - sm->SetElements(args,nb); - proxy->UpdateVTKObjects(); // push properties states abroad - sm->SetImmediateUpdate(iup); - } - delete [] args; - // - ((vtkSMSourceProxy *)proxy)->UpdatePipelineInformation();//performs an update of all properties of proxy and proxy itself - // here wonderful proxy is declared modified right after FieldsStatus and FieldsTreeInfo -> IMPORTANT : The updated MTime of proxy will be the ref - // 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 ? - setModified(); -} - diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderPanel.h b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderPanel.h deleted file mode 100644 index f7d07f3d..00000000 --- a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderPanel.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (C) 2010-2015 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// Author : Anthony Geay - -#ifndef _pqMEDReaderPanel_h -#define _pqMEDReaderPanel_h - -#include "pqNamedObjectPanel.h" - -#include - -class pqTreeWidgetItemObject; -class VectBoolWidget; - -class vtkSMProperty; -class vtkSMIntVectorProperty; - -class pqMEDReaderPanel: public pqNamedObjectPanel -{ -Q_OBJECT - typedef pqNamedObjectPanel Superclass; -public: - pqMEDReaderPanel(pqProxy* proxy, QWidget* p = NULL); - ~pqMEDReaderPanel(); - void updateInformationAndDomains(); - void aLev4HasBeenFiredBy(pqTreeWidgetItemObject *zeItem); -protected slots: - void aLev4HasBeenFired(); - void aLev3HasBeenFired(bool); - // - void updateSIL(); - void reloadFired(); - void vectOfBoolWidgetRequested(bool isMode); - void updateCheckStatusOfLev4FromServerState(); -private: - int getMaxNumberOfTS() const; - void getCurrentTS(QStringList& its, QStringList& dts, QStringList& tts) const; -protected: - void putLev3InOrder(); - void somethingChangedInFieldRepr(); - /// populate widgets with properties from the server manager - virtual void linkServerManagerProperties(); - void initAll(); - class pqUI; - pqUI* UI; - std::vector _all_lev4; -private: - bool _reload_req; - std::set > _leaves; - VectBoolWidget *_optional_widget; - int _my_mtime; - vtkSMIntVectorProperty *_sm_prop_remote_mtime; -}; - -#endif diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderReloadWidget.cxx b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderReloadWidget.cxx new file mode 100644 index 00000000..2dc10653 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderReloadWidget.cxx @@ -0,0 +1,96 @@ +// Copyright (C) 2010-2015 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "pqMEDReaderReloadWidget.h" + +#include "vtkSMProxy.h" +#include "vtkSMSourceProxy.h" +#include "vtkSMProperty.h" + +#include "pqPropertiesPanel.h" + +#include +#include + +pqMEDReaderReloadWidget::pqMEDReaderReloadWidget(vtkSMProxy *smProxy, + vtkSMProperty *proxyProperty, + QWidget *pWidget) +: pqPropertyWidget(smProxy, pWidget), + Property(proxyProperty) +{ + this->setShowLabel(false); + + // Grid Layout + QGridLayout* gridLayout = new QGridLayout(this); + gridLayout->setAlignment(Qt::AlignRight); + + // Reload Button + QPushButton *button = new QPushButton(); + button->setIcon(QIcon(":/ParaViewResources/Icons/pqReloadFile16.png")); + button->setFixedSize(button->sizeHint()); + gridLayout->addWidget(button); + + // Connection + connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked())); +} + +pqMEDReaderReloadWidget::~pqMEDReaderReloadWidget() +{ +} + +void pqMEDReaderReloadWidget::buttonClicked() +{ + // Recovering Property Panel + pqPropertiesPanel* panel = NULL; + QObject* tmp = this; + while (panel == NULL) + { + tmp = tmp->parent(); + if (!tmp) + { + break; + } + panel = qobject_cast(tmp); + } + + if (!panel) + { + qDebug() << "Cannot find pqPropertiesPanel, reload may not work"; + } + else + { + // Restoring property to defaults, necessary when unchecked property are not applied + panel->propertiesRestoreDefaults(); + } + + // Reloading the data and associated properties + this->Property->Modified(); + this->proxy()->UpdateProperty(this->proxy()->GetPropertyName(this->Property)); + vtkSMSourceProxy::SafeDownCast(this->proxy())->UpdatePipelineInformation(); + + // Restting properties to dufault using domains and XML values + this->proxy()->ResetPropertiesToDefault(); + + if (panel) + { + // Disabled apply button inderectly + panel->propertiesRestoreDefaults(); + } +} diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderReloadWidget.h b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderReloadWidget.h new file mode 100644 index 00000000..cae0f3c1 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderReloadWidget.h @@ -0,0 +1,46 @@ +// Copyright (C) 2010-2015 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#ifndef _pqMEDReaderReloadWidget_h +#define _pqMEDReaderReloadWidget_h + +#include "pqPropertyWidget.h" + +class pqMEDReaderReloadWidget : public pqPropertyWidget +{ + Q_OBJECT + +public: + explicit pqMEDReaderReloadWidget(vtkSMProxy *proxy, + vtkSMProperty *property, + QWidget *parent = 0); + ~pqMEDReaderReloadWidget(); + +private slots: + // Description + // Called when button is clicked + // Reload the med reader + void buttonClicked(); + +private: + vtkSMProperty* Property; +}; + +#endif // _pqMEDReaderReloadWidget_h diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderTimeModeWidget.cxx b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderTimeModeWidget.cxx new file mode 100644 index 00000000..b5df7bee --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderTimeModeWidget.cxx @@ -0,0 +1,67 @@ +// Copyright (C) 2010-2015 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "ui_MEDReaderTimeModeWidget.h" +#include "pqMEDReaderTimeModeWidget.h" + +#include "pqCoreUtilities.h" +//----------------------------------------------------------------------------- +// Internals +class pqMEDReaderTimeModeWidget::pqInternals : public Ui::MEDReaderTimeModeWidget +{ +public: + pqInternals(pqMEDReaderTimeModeWidget* self) + { + this->setupUi(self); + } +}; + +//----------------------------------------------------------------------------- +pqMEDReaderTimeModeWidget::pqMEDReaderTimeModeWidget( + vtkSMProxy *smproxy, vtkSMProperty *smproperty, QWidget *parentObject) +: Superclass(smproxy, parentObject), Internals(new pqMEDReaderTimeModeWidget::pqInternals(this)) +{ + this->setShowLabel(false); + this->ModeEnabled = false; + + this->addPropertyLink(this, "ModeEnabled" , SIGNAL(modeEnabled(bool)), smproperty); + QObject::connect(this->Internals->modeMode, SIGNAL(toggled(bool)), + this, SLOT(setModeEnabled(bool))); +} + +//----------------------------------------------------------------------------- +pqMEDReaderTimeModeWidget::~pqMEDReaderTimeModeWidget() +{ +} + +//----------------------------------------------------------------------------- +bool pqMEDReaderTimeModeWidget::isModeEnabled() const +{ + return this->ModeEnabled; +} + +//----------------------------------------------------------------------------- +void pqMEDReaderTimeModeWidget::setModeEnabled(bool enable) +{ + this->ModeEnabled = enable; + this->Internals->modeMode->setChecked(enable); + this->Internals->stdMode->setChecked(!enable); + emit modeEnabled(enable); +} diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderTimeModeWidget.h b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderTimeModeWidget.h new file mode 100644 index 00000000..6f53763b --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderTimeModeWidget.h @@ -0,0 +1,66 @@ +// Copyright (C) 2010-2015 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#ifndef __pqMEDReaderTimeModeWidget_h +#define __pqMEDReaderTimeModeWidget_h + +#include "pqPropertyWidget.h" + +class pqMEDReaderTimeModeWidget : public pqPropertyWidget +{ + Q_OBJECT + + // Qt property to link to vtk property + Q_PROPERTY(bool ModeEnabled READ isModeEnabled WRITE setModeEnabled) + + typedef pqPropertyWidget Superclass; +public: + pqMEDReaderTimeModeWidget( + vtkSMProxy *smproxy, vtkSMProperty *smproperty, QWidget *parentObject = 0); + virtual ~pqMEDReaderTimeModeWidget(); + + // Description + // Qt property getter + bool isModeEnabled() const; + +public slots: + // Description + // Qt Property setter + void setModeEnabled(bool enable); + +signals: + // Description + // Qt Property signal + void modeEnabled(bool enable); + +private: + Q_DISABLE_COPY(pqMEDReaderTimeModeWidget); + + // Description + // Qt property value + bool ModeEnabled; + + // Description + // UI Internals + class pqInternals; + pqInternals* Internals; +}; + +#endif diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderTimesFlagsWidget.cxx b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderTimesFlagsWidget.cxx new file mode 100644 index 00000000..25113c76 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderTimesFlagsWidget.cxx @@ -0,0 +1,213 @@ +// Copyright (C) 2010-2015 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "pqMEDReaderTimesFlagsWidget.h" + +#include "VectBoolWidget.h" +#include "pqMEDReaderGraphUtils.h" +#include "vtkMEDReader.h" +#include "vtkPVMetaDataInformation.h" + +#include "pqCoreUtilities.h" +#include "pqArrayListDomain.h" +#include "pqPropertiesPanel.h" +#include "vtkGraph.h" +#include "vtkGraphWriter.h" +#include "vtkInformationDataObjectMetaDataKey.h" +#include "vtkNew.h" +#include "vtkSMDoubleVectorProperty.h" +#include "vtkSMStringVectorProperty.h" +#include "vtkTree.h" + +#include +#include + +//----------------------------------------------------------------------------- +pqMEDReaderTimesFlagsWidget::pqMEDReaderTimesFlagsWidget( + vtkSMProxy *smproxy, vtkSMProperty *smproperty, QWidget *parentObject) +: Superclass(smproxy, parentObject) +{ + this->CachedTsId = -1; + this->TimesVectWidget = NULL; + this->setShowLabel(false); + + // Grid Layout + this->TimesVectLayout = new QGridLayout(this); + + // VectBoolWidget + this->CreateTimesVectWidget(); + this->UpdateTimeSteps(); + + // Connect timeStepStatus property to update time steps method + vtkSMProperty* prop = smproxy? smproxy->GetProperty("FieldsStatus") : NULL; + if (!prop) + { + qDebug("Could not locate property named 'FieldsStatus'. " + "pqMEDReaderTimesFlagsWidget will have no updated labels."); + } + else + { + pqCoreUtilities::connect(prop, vtkCommand::UncheckedPropertyModifiedEvent, + this, SLOT(UpdateTimeSteps())); + } + + // Connect Property Domain to the timeStepDomain property, + // so setTimeStepDomain is called when the domain changes. + vtkSMDomain* arraySelectionDomain = smproperty->GetDomain("array_list"); + new pqArrayListDomain(this,"timeStepsDomain", smproxy, smproperty, arraySelectionDomain); + + // Connect property to timeStep QProperty using a biderectionnal property link + this->addPropertyLink(this, "timeSteps", SIGNAL(timeStepsChanged()), + smproxy, smproperty); + + const QMap& items(this->TimesVectWidget->getItems()); + QMap::const_iterator it; + for (it = items.begin(); it != items.end(); it++) + { + QObject::connect(it.value(), SIGNAL(changed()), this, SLOT(onItemChanged())); + } +} + +//----------------------------------------------------------------------------- +pqMEDReaderTimesFlagsWidget::~pqMEDReaderTimesFlagsWidget() +{ + delete this->TimesVectWidget; +} + +//----------------------------------------------------------------------------- +void pqMEDReaderTimesFlagsWidget::onItemChanged() const +{ + emit timeStepsChanged(); +} + +//----------------------------------------------------------------------------- +QList< QList< QVariant> > pqMEDReaderTimesFlagsWidget::getTimeSteps() const +{ + // Put together a TimeStep list, using ItemMap + QList< QList< QVariant> > ret; + QList< QVariant > timeStep; + const QMap& items(this->TimesVectWidget->getItems()); + QMap::const_iterator it; + for (it = items.begin(); it != items.end(); it++) + { + timeStep.clear(); + timeStep.append(it.key()); + timeStep.append(it.value()->isActivated()); + ret.append(timeStep); + } + return ret; +} + +//----------------------------------------------------------------------------- +void pqMEDReaderTimesFlagsWidget::setTimeSteps(QList< QList< QVariant> > timeSteps) +{ + // Update each item checkboxes, using timeSteps names and ItemMap + const QMap& items(this->TimesVectWidget->getItems()); + QMap::const_iterator it; + foreach (QList< QVariant> timeStep, timeSteps) + { + it = items.find(timeStep[0].toString()); + if (it == items.end()) + { + qDebug("Found an unknow TimeStep in pqMEDReaderTimesFlagsWidget::setTimeSteps, ignoring"); + continue; + } + it.value()->activated(timeStep[1].toBool()); + } +} + +//----------------------------------------------------------------------------- +void pqMEDReaderTimesFlagsWidget::setTimeStepsDomain(QList< QList< QVariant> > timeSteps) +{ + cout<<"TimeStepsDomai"<blockSignals(true); + + // Load the tree widget + this->CreateTimesVectWidget(); + + // Set timeSteps checkboxes + this->setTimeSteps(timeSteps); + + // Restore signals + this->blockSignals(false); +} + +//----------------------------------------------------------------------------- +void pqMEDReaderTimesFlagsWidget::CreateTimesVectWidget() +{ + // Recover Graph + vtkPVMetaDataInformation *info(vtkPVMetaDataInformation::New()); + this->proxy()->GatherInformation(info); + vtkGraph* graph = vtkGraph::SafeDownCast(info->GetInformationData()); + + // Delete the widget + if (this->TimesVectWidget != NULL) + { + delete this->TimesVectWidget; + } + + // (Re)cretate widget + this->TimesVectWidget = new VectBoolWidget(this, + pqMedReaderGraphUtils::getMaxNumberOfTS(graph)); + this->TimesVectLayout->addWidget(this->TimesVectWidget); +} + +//----------------------------------------------------------------------------- +void pqMEDReaderTimesFlagsWidget::UpdateTimeSteps() +{ + // Recover property + vtkSMStringVectorProperty* prop = this->proxy()? + vtkSMStringVectorProperty::SafeDownCast(this->proxy()->GetProperty("FieldsStatus")) : NULL; + vtkIdType tsId = -1; + if (prop) + { + // Searching first activated leaf id + for (int i = 1; i < prop->GetNumberOfElements(); i += 2) + { + if (prop->GetElement(i)[0] == '1') + { + const char* leafString = prop->GetElement(i - 1); + const char* tmp = strchr(leafString, '/'); + size_t num = tmp - leafString; + char dest[num]; + strncpy(dest, leafString, num); + dest[num] = '\0'; + tsId = strtol(dest + 2, NULL, 10); + break; + } + } + } + + if (tsId != -1 && tsId != this->CachedTsId) + { + // Recovering graph + this->CachedTsId = tsId; + vtkPVMetaDataInformation *info(vtkPVMetaDataInformation::New()); + this->proxy()->GatherInformation(info); + vtkGraph* g = vtkGraph::SafeDownCast(info->GetInformationData()); + + // Updating times steps using leaf id + QStringList dts, its, tts; + pqMedReaderGraphUtils::getCurrentTS(g, tsId, dts, its, tts); + this->TimesVectWidget->setItems(dts, its, tts); + } +} diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderTimesFlagsWidget.h b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderTimesFlagsWidget.h new file mode 100644 index 00000000..e6fb06e5 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderTimesFlagsWidget.h @@ -0,0 +1,91 @@ +// Copyright (C) 2010-2015 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#ifndef __pqMEDReaderTimesFlagsWidget_h +#define __pqMEDReaderTimesFlagsWidget_h + +#include "pqPropertyWidget.h" + +class VectBoolWidget; +class QGridLayout; + +class pqMEDReaderTimesFlagsWidget : public pqPropertyWidget +{ + + typedef pqPropertyWidget Superclass; + Q_OBJECT + // Description + // Property Qt used to set/get the times steps with the property link + Q_PROPERTY(QList< QList< QVariant> > timeSteps READ getTimeSteps WRITE setTimeSteps) + // Description + // Property Qt used to set the gorup time steps domain with the property link + Q_PROPERTY(QList< QList< QVariant> > timeStepsDomain READ getTimeSteps WRITE setTimeStepsDomain) +public: + pqMEDReaderTimesFlagsWidget( + vtkSMProxy *smproxy, vtkSMProperty *smproperty, QWidget *parentObject = 0); + virtual ~pqMEDReaderTimesFlagsWidget(); + +signals: + // Description + // Signal emited when selected field changed + void timeStepsChanged() const; + +protected slots: + // Description + // Slot called when item is changed + virtual void onItemChanged() const; + +protected slots: + // Description + // bidrectionnal property link setter/getter + virtual QList< QList< QVariant> > getTimeSteps() const; + virtual void setTimeSteps(QList< QList< QVariant> > timeSteps); + + // Description + // Update the domain, eg: reload + virtual void setTimeStepsDomain(QList< QList< QVariant> > timeSteps); + + + // Description + // Called when field status changed and reload the time steps + void UpdateTimeSteps(); + + // Description + // Called to create the vect widget, on creation or for a reload + void CreateTimesVectWidget(); + +protected: + // Description + // The Vect time widget + VectBoolWidget* TimesVectWidget; + + // Description + // The grid layout contian the vect times widget + QGridLayout* TimesVectLayout; + + // Description + // Id of current time step, for caching purpose + vtkIdType CachedTsId; + +private: + Q_DISABLE_COPY(pqMEDReaderTimesFlagsWidget); +}; + +#endif diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderVectorsWidget.cxx b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderVectorsWidget.cxx new file mode 100644 index 00000000..f7bf0e26 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderVectorsWidget.cxx @@ -0,0 +1,48 @@ +// Copyright (C) 2010-2015 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "pqMEDReaderVectorsWidget.h" +#include "ui_MEDReaderVectorsWidget.h" + +//----------------------------------------------------------------------------- +// Internals +class pqMEDReaderVectorsWidget::pqInternals : public Ui::MEDReaderVectorsWidget +{ +public: + pqInternals(pqMEDReaderVectorsWidget* self) + { + this->setupUi(self); + } +}; + +//----------------------------------------------------------------------------- +pqMEDReaderVectorsWidget::pqMEDReaderVectorsWidget( + vtkSMProxy *smproxy, vtkSMProperty *smproperty, QWidget *parentObject) +: Superclass(smproxy, parentObject), Internals(new pqMEDReaderVectorsWidget::pqInternals(this)) +{ + this->setShowLabel(false); + this->addPropertyLink(this->Internals->GenerateVects, "checked" , + SIGNAL(toggled(bool)), smproperty); +} + +//----------------------------------------------------------------------------- +pqMEDReaderVectorsWidget::~pqMEDReaderVectorsWidget() +{ +} diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderVectorsWidget.h b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderVectorsWidget.h new file mode 100644 index 00000000..834274bd --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderVectorsWidget.h @@ -0,0 +1,42 @@ +// Copyright (C) 2010-2015 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#ifndef __pqMEDReaderVectorsWidget_h +#define __pqMEDReaderVectorsWidget_h + +#include "pqPropertyWidget.h" + +class pqMEDReaderVectorsWidget : public pqPropertyWidget +{ + Q_OBJECT + typedef pqPropertyWidget Superclass; +public: + pqMEDReaderVectorsWidget( + vtkSMProxy *smproxy, vtkSMProperty *smproperty, QWidget *parentObject = 0); + virtual ~pqMEDReaderVectorsWidget(); + +private: + Q_DISABLE_COPY(pqMEDReaderVectorsWidget); + + class pqInternals; + pqInternals* Internals; +}; + +#endif diff --git a/src/Plugins/MEDReader/ParaViewPlugin/vtkPVMetaDataInformation.cxx b/src/Plugins/MEDReader/ParaViewPlugin/vtkPVMetaDataInformation.cxx new file mode 100644 index 00000000..a498d685 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/vtkPVMetaDataInformation.cxx @@ -0,0 +1,138 @@ +// Copyright (C) 2010-2015 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "vtkPVMetaDataInformation.h" + +#include "vtkAlgorithm.h" +#include "vtkAlgorithmOutput.h" +#include "vtkClientServerStream.h" +#include "vtkExecutive.h" +#include "vtkDataObject.h" +#include "vtkGenericDataObjectReader.h" +#include "vtkGenericDataObjectWriter.h" +#include "vtkInformationDataObjectMetaDataKey.h" +#include "vtkInformation.h" +#include "vtkObjectFactory.h" + +#include "vtkMEDReader.h" + +vtkStandardNewMacro(vtkPVMetaDataInformation); +vtkCxxSetObjectMacro(vtkPVMetaDataInformation, InformationData, vtkDataObject); + +//---------------------------------------------------------------------------- +vtkPVMetaDataInformation::vtkPVMetaDataInformation() +{ + this->InformationData = NULL; +} + +//---------------------------------------------------------------------------- +vtkPVMetaDataInformation::~vtkPVMetaDataInformation() +{ + this->SetInformationData(NULL); +} + +//---------------------------------------------------------------------------- +void vtkPVMetaDataInformation::CopyFromObject(vtkObject* obj) +{ + this->SetInformationData(NULL); + + vtkAlgorithmOutput* algOutput = vtkAlgorithmOutput::SafeDownCast(obj); + if (!algOutput) + { + vtkAlgorithm* alg = vtkAlgorithm::SafeDownCast(obj); + if (alg) + { + algOutput = alg->GetOutputPort(0); + } + + } + if (!algOutput) + { + vtkErrorMacro("Information can only be gathered from a vtkAlgorithmOutput."); + return; + } + + vtkAlgorithm* reader = algOutput->GetProducer(); + vtkInformation* info = reader->GetExecutive()->GetOutputInformation( + algOutput->GetIndex()); + + if (info && info->Has(vtkMEDReader::META_DATA())) + { + this->SetInformationData(vtkDataObject::SafeDownCast(info->Get(vtkMEDReader::META_DATA()))); + } +} + +//---------------------------------------------------------------------------- +void vtkPVMetaDataInformation::CopyToStream(vtkClientServerStream* css) +{ + css->Reset(); + if (!this->InformationData) + { + *css << vtkClientServerStream::Reply + << vtkClientServerStream::InsertArray( + static_cast(NULL), 0) + << vtkClientServerStream::End; + return; + } + + vtkDataObject* clone = this->InformationData->NewInstance(); + clone->ShallowCopy(this->InformationData); + + vtkGenericDataObjectWriter* writer = vtkGenericDataObjectWriter::New(); + writer->SetFileTypeToBinary(); + writer->WriteToOutputStringOn(); + writer->SetInputData(clone); + writer->Write(); + + *css << vtkClientServerStream::Reply + << vtkClientServerStream::InsertArray( + writer->GetBinaryOutputString(), + writer->GetOutputStringLength()) + << vtkClientServerStream::End; + writer->RemoveAllInputs(); + writer->Delete(); + clone->Delete(); +} + +//---------------------------------------------------------------------------- +void vtkPVMetaDataInformation::CopyFromStream(const vtkClientServerStream* css) +{ + this->SetInformationData(0); + vtkTypeUInt32 length; + if (css->GetArgumentLength(0, 0, &length) && length > 0) + { + unsigned char* raw_data = new unsigned char[length]; + css->GetArgument(0, 0, raw_data, length); + vtkGenericDataObjectReader* reader = vtkGenericDataObjectReader::New(); + reader->SetBinaryInputString(reinterpret_cast(raw_data), length); + reader->ReadFromInputStringOn(); + delete []raw_data; + reader->Update(); + this->SetInformationData(reader->GetOutput()); + reader->Delete(); + } +} + +//---------------------------------------------------------------------------- +void vtkPVMetaDataInformation::PrintSelf(ostream& os, vtkIndent indent) +{ + this->Superclass::PrintSelf(os, indent); + os << indent << "InformationData: " << this->InformationData << endl; +} diff --git a/src/Plugins/MEDReader/ParaViewPlugin/vtkPVMetaDataInformation.h b/src/Plugins/MEDReader/ParaViewPlugin/vtkPVMetaDataInformation.h new file mode 100644 index 00000000..879d11eb --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/vtkPVMetaDataInformation.h @@ -0,0 +1,64 @@ +// Copyright (C) 2010-2015 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#ifndef __vtkPVMetaDataInformation_h +#define __vtkPVMetaDataInformation_h + +#include "vtkPVInformation.h" + +class vtkDataObject; +class vtkInformationDataObjectKey; + +class vtkPVMetaDataInformation : public vtkPVInformation +{ +public: + static vtkPVMetaDataInformation* New(); + vtkTypeMacro(vtkPVMetaDataInformation, vtkPVInformation); + void PrintSelf(ostream& os, vtkIndent indent); + + // Description: + // Transfer information about a single object into this object. + virtual void CopyFromObject(vtkObject*); + + //BTX + // Description: + // Manage a serialized version of the information. + virtual void CopyToStream(vtkClientServerStream*); + virtual void CopyFromStream(const vtkClientServerStream*); + //ETX + + // Description: + // Returns the Information Data. + vtkGetObjectMacro(InformationData, vtkDataObject); + +//BTX +protected: + vtkPVMetaDataInformation(); + ~vtkPVMetaDataInformation(); + void SetInformationData(vtkDataObject*); + vtkDataObject* InformationData; + +private: + vtkPVMetaDataInformation(const vtkPVMetaDataInformation&); // Not implemented + void operator=(const vtkPVMetaDataInformation&); // Not implemented +//ETX +}; + +#endif diff --git a/src/Plugins/MEDReader/Test/CMakeLists.txt b/src/Plugins/MEDReader/Test/CMakeLists.txt index 05bb227b..9b1e06d9 100644 --- a/src/Plugins/MEDReader/Test/CMakeLists.txt +++ b/src/Plugins/MEDReader/Test/CMakeLists.txt @@ -17,23 +17,93 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) - SET(TEST_NUMBERS 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18) +SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test/MEDReader) + +IF(KW_TESTING_PLATFORM) + FOREACH(tfile ${TEST_NUMBERS}) - ADD_TEST(testMEDReader${tfile} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader${tfile}.py) - SET_TESTS_PROPERTIES(testMEDReader${tfile} PROPERTIES ENVIRONMENT "${tests_env}") + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader${tfile}.py + DESTINATION ${TEST_INSTALL_DIRECTORY}) ENDFOREACH() + INSTALL(FILES CTestTestfileInstall.cmake + DESTINATION ${TEST_INSTALL_DIRECTORY} + RENAME CTestTestfile.cmake) + +cmake_minimum_required(VERSION 2.7) + +find_package(ParaView REQUIRED) +include(${PARAVIEW_USE_FILE}) + +include(ParaViewTestingMacros) +include(FindPythonModules) + +include(${PROJECT_SOURCE_DIR}/testing/testFunctions.cmake) +set(PV_PLUGIN_PATH "${CMAKE_BINARY_DIR}/lib/") + +include(CTest) + +enable_testing() + +set(PARAVIEW_BIN_DIR "${ParaView_DIR}/bin" CACHE PATH "ParaView binary path") + +set(PVTEST_DRIVER "${PARAVIEW_BIN_DIR}/smTestDriver") +set(PARAVIEW_CLIENT "${PARAVIEW_BIN_DIR}/paraview") +set(PARAVIEW_SERVER "${PARAVIEW_BIN_DIR}/pvserver") +set(PVPYTHON "${PARAVIEW_BIN_DIR}/pvpython") + +set(BASELINES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Baselines") +set(PYTHON_SCRIPTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +set(TEMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/Testing/Temporary") + # Application tests SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test/MEDReader) -FOREACH(tfile ${TEST_NUMBERS}) - INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader${tfile}.py +if(NOT EXISTS ${TEMP_DIR}) + file(MAKE_DIRECTORY ${TEMP_DIR}) +endif() + +# Override vtk_add_test_* variables for use with ParaView. +macro (_myy_override_vtk_dirs) + set(VTK_TEST_DATA_DIR ${PYTHON_SCRIPTS_DIR}) + set(VTK_BASELINE_DIR ${BASELINES_DIR}) + set(VTK_TEST_OUTPUT_DIR ${TEMP_DIR}) + set(VTK_TEST_DATA_TARGET ParaViewData) +endmacro () + +function (myy_add_python_test) + message(STATUS "Add Python test for ${ARGV2}") + set(VTK_PYTHON_EXE "${PVPYTHON}") + list(APPEND VTK_PYTHON_ARGS -dr + ${PARAVIEW_PYTHON_ARGS}) + _myy_override_vtk_dirs() + myvtk_add_test_python(${ARGN}) +endfunction () + +# Test all python scripts +file(GLOB scripts "${PYTHON_SCRIPTS_DIR}/*py") +foreach(file ${scripts}) + get_filename_component(fname ${file} NAME) + myy_add_python_test( + NO_DATA NO_RT + ${fname}) + INSTALL(FILES ${file} DESTINATION ${TEST_INSTALL_DIRECTORY}) +endforeach() + +ELSE(KW_TESTING_PLATFORM) + +SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) + +FOREACH(tfile ${TEST_NUMBERS}) + ADD_TEST(testMEDReader${tfile} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader${tfile}.py -B ${CMAKE_CURRENT_SOURCE_DIR}/Baselines ) + SET_TESTS_PROPERTIES(testMEDReader${tfile} PROPERTIES ENVIRONMENT ${tests_env}) ENDFOREACH() +ENDIF(KW_TESTING_PLATFORM) + INSTALL(FILES CTestTestfileInstall.cmake DESTINATION ${TEST_INSTALL_DIRECTORY} RENAME CTestTestfile.cmake) diff --git a/src/Plugins/MEDReader/Test/CTestTestfileInstall.cmake b/src/Plugins/MEDReader/Test/CTestTestfileInstall.cmake index 588e3429..293b2ae4 100644 --- a/src/Plugins/MEDReader/Test/CTestTestfileInstall.cmake +++ b/src/Plugins/MEDReader/Test/CTestTestfileInstall.cmake @@ -25,7 +25,7 @@ SET(TEST_NUMBERS 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18) FOREACH(tfile ${TEST_NUMBERS}) SET(TEST_NAME MEDREADER_${tfile}) - #ADD_TEST(${TEST_NAME} python testMEDReader${tfile}.py) - ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} testMEDReader${tfile}.py) + ADD_TEST(${TEST_NAME} python testMEDReader${tfile}.py) + #ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} testMEDReader${tfile}.py) SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") ENDFOREACH() diff --git a/src/Plugins/MEDReader/Test/testMEDReader0.py b/src/Plugins/MEDReader/Test/testMEDReader0.py index 8c1142af..371de599 100644 --- a/src/Plugins/MEDReader/Test/testMEDReader0.py +++ b/src/Plugins/MEDReader/Test/testMEDReader0.py @@ -20,7 +20,6 @@ # Author : Anthony Geay from MEDLoader import * - fname="testMEDReader0.med" outImgName="testMEDReader0.png" ######### @@ -87,10 +86,8 @@ arr_name_with_dis=[elt.split("/")[-1] for elt in keys] arr_name=[elt.split(myMedReader.GetProperty("Separator").GetData())[0] for elt in arr_name_with_dis] myMedReader.AllArrays=keys RenderView1 = GetRenderView() -ELNOMesh1=ELNOMesh() -ELNOMesh1.Input=myMedReader -ExtractGroup1=ExtractGroup() -ExtractGroup1.Input=ELNOMesh1 +ELNOMesh1=ELNOMesh(Input=myMedReader) +ExtractGroup1=ExtractGroup(Input=ELNOMesh1) ExtractGroup1.UpdatePipelineInformation() ExtractGroup1.AllGroups=['GRP_ba2','GRP_to1','GRP_web'] assert(isinstance(ExtractGroup1.GetProperty("MeshName")[0],str)) @@ -108,8 +105,7 @@ DataRepresentation3.ColorArrayName = 'SolutionSIEQ_ELNO' DataRepresentation3.LookupTable = a2_SolutionSIEQ_ELNO_PVLookupTable DataRepresentation3.Visibility = 1 # -GaussPoints1=GaussPoints() -GaussPoints1.Input=ELNOMesh1 +GaussPoints1=GaussPoints(Input=ELNOMesh1) GaussPoints1.SelectSourceArray=['CELLS','ELGA@0'] DataRepresentation4 = Show() DataRepresentation4.ScaleFactor = 0.008999999705702066 @@ -122,5 +118,20 @@ RenderView1.CameraPosition = [0.11797550069274401, 0.20119836056342144, 0.208854 RenderView1.CameraClippingRange = [0.14700465306315827, 0.40712447273162633] RenderView1.CameraFocalPoint = [1.0170565790969026e-18, 0.0599999981932342, 0.022500000894069675] RenderView1.ViewSize =[300,300] -WriteImage(outImgName) +Render() +# compare with baseline image +import os +import sys +try: + baselineIndex = sys.argv.index('-B')+1 + baselinePath = sys.argv[baselineIndex] +except: + print "Could not get baseline directory. Test failed." + exit(1) +baseline_file = os.path.join(baselinePath, "testMEDReader0.png") +import vtk.test.Testing +vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir() +vtk.test.Testing.compareImage(GetActiveView().GetRenderWindow(), baseline_file, + threshold=25) +vtk.test.Testing.interact() diff --git a/src/Plugins/MEDReader/Test/testMEDReader1.py b/src/Plugins/MEDReader/Test/testMEDReader1.py index 970f67db..35eb88c6 100644 --- a/src/Plugins/MEDReader/Test/testMEDReader1.py +++ b/src/Plugins/MEDReader/Test/testMEDReader1.py @@ -22,7 +22,7 @@ from MEDLoader import * """ -This test focused on ELNO. Here a 2 QUAD4 cells and a single ELNO field +This test focused on ELNO. Here a 2 QUAD4 cells and a single ELNO field is defined. """ fname="testMEDReader1.med" diff --git a/src/Plugins/MEDReader/Test/testMEDReader10.py b/src/Plugins/MEDReader/Test/testMEDReader10.py index 0507071b..e1e96a6e 100644 --- a/src/Plugins/MEDReader/Test/testMEDReader10.py +++ b/src/Plugins/MEDReader/Test/testMEDReader10.py @@ -109,4 +109,20 @@ RenderView1.CameraClippingRange = [4.164482329590951, 9.24583527085017] RenderView1.CameraFocalPoint = [1.4999999999999996, 0.49999999999999944, 0.4999999999999996] # RenderView1.ViewSize =[300,300] -WriteImage(outImgName) +Render() + +# compare with baseline image +import os +import sys +try: + baselineIndex = sys.argv.index('-B')+1 + baselinePath = sys.argv[baselineIndex] +except: + print "Could not get baseline directory. Test failed." + exit(1) +baseline_file = os.path.join(baselinePath, "testMEDReader10.png") +import vtk.test.Testing +vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir() +vtk.test.Testing.compareImage(GetActiveView().GetRenderWindow(), baseline_file, + threshold=25) +vtk.test.Testing.interact() diff --git a/src/Plugins/MEDReader/Test/testMEDReader11.py b/src/Plugins/MEDReader/Test/testMEDReader11.py index c223bb13..944abb26 100644 --- a/src/Plugins/MEDReader/Test/testMEDReader11.py +++ b/src/Plugins/MEDReader/Test/testMEDReader11.py @@ -192,6 +192,21 @@ RenderView1.CameraClippingRange = [2.404636927989219, 7.163736971217594] RenderView1.CameraFocalPoint = [2.4191999999999996, 2.4191999999999996, 4.32745] RenderView1.ViewTime = 2.0 -Render() RenderView1.ViewSize =[300,300] -WriteImage(outImgName) +Render() + +# compare with baseline image +import os +import sys +try: + baselineIndex = sys.argv.index('-B')+1 + baselinePath = sys.argv[baselineIndex] +except: + print "Could not get baseline directory. Test failed." + exit(1) +baseline_file = os.path.join(baselinePath, "testMEDReader11.png") +import vtk.test.Testing +vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir() +vtk.test.Testing.compareImage(GetActiveView().GetRenderWindow(), baseline_file, + threshold=25) +vtk.test.Testing.interact() diff --git a/src/Plugins/MEDReader/Test/testMEDReader12.py b/src/Plugins/MEDReader/Test/testMEDReader12.py index ec76ed3a..d41de3ae 100644 --- a/src/Plugins/MEDReader/Test/testMEDReader12.py +++ b/src/Plugins/MEDReader/Test/testMEDReader12.py @@ -89,6 +89,21 @@ DataRepresentation2.ScalarOpacityFunction = a1_POROSITE_PiecewiseFunction DataRepresentation2.ColorArrayName = ('CELLS', 'POROSITE') DataRepresentation2.LookupTable = a1_POROSITE_PVLookupTable -Render() RenderView1.ViewSize =[300,300] -WriteImage(outImgName) +Render() + +# compare with baseline image +import os +import sys +try: + baselineIndex = sys.argv.index('-B')+1 + baselinePath = sys.argv[baselineIndex] +except: + print "Could not get baseline directory. Test failed." + exit(1) +baseline_file = os.path.join(baselinePath, "testMEDReader12.png") +import vtk.test.Testing +vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir() +vtk.test.Testing.compareImage(GetActiveView().GetRenderWindow(), baseline_file, + threshold=25) +vtk.test.Testing.interact() diff --git a/src/Plugins/MEDReader/Test/testMEDReader13.py b/src/Plugins/MEDReader/Test/testMEDReader13.py index c94b92d1..362be950 100644 --- a/src/Plugins/MEDReader/Test/testMEDReader13.py +++ b/src/Plugins/MEDReader/Test/testMEDReader13.py @@ -74,6 +74,21 @@ a3_fieldELNO_Vector_PVLookupTable = GetLookupTableForArray( "fieldELNO_Vector", a3_fieldELNO_Vector_PiecewiseFunction = CreatePiecewiseFunction( Points=[0.3464101615137755, 0.0, 0.5, 0.0, 1.9052558883257653, 1.0, 0.5, 0.0] ) -Render() RenderView1.ViewSize =[300,300] -WriteImage(outImgName) +Render() + +# compare with baseline image +import os +import sys +try: + baselineIndex = sys.argv.index('-B')+1 + baselinePath = sys.argv[baselineIndex] +except: + print "Could not get baseline directory. Test failed." + exit(1) +baseline_file = os.path.join(baselinePath, "testMEDReader13.png") +import vtk.test.Testing +vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir() +vtk.test.Testing.compareImage(GetActiveView().GetRenderWindow(), baseline_file, + threshold=25) +vtk.test.Testing.interact() diff --git a/src/Plugins/MEDReader/Test/testMEDReader14.py b/src/Plugins/MEDReader/Test/testMEDReader14.py index 38f9646b..cbd947d0 100644 --- a/src/Plugins/MEDReader/Test/testMEDReader14.py +++ b/src/Plugins/MEDReader/Test/testMEDReader14.py @@ -154,6 +154,23 @@ renderView1.InteractionMode = '2D' renderView1.CameraPosition = [3.0, 2.0, 10000.0] renderView1.CameraFocalPoint = [3.0, 2.0, 0.0] renderView1.ViewSize =[300,300] +renderView1.GetRenderWindow().DoubleBufferOff() # + Render() -WriteImage(outImgName) + +# compare with baseline image +import os +import sys +try: + baselineIndex = sys.argv.index('-B')+1 + baselinePath = sys.argv[baselineIndex] +except: + print "Could not get baseline directory. Test failed." + exit(1) +baseline_file = os.path.join(baselinePath, "testMEDReader14.png") +import vtk.test.Testing +vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir() +vtk.test.Testing.compareImage(renderView1.GetRenderWindow(), baseline_file, + threshold=25) +vtk.test.Testing.interact() diff --git a/src/Plugins/MEDReader/Test/testMEDReader15.py b/src/Plugins/MEDReader/Test/testMEDReader15.py index 3adc65ea..0f8ece63 100644 --- a/src/Plugins/MEDReader/Test/testMEDReader15.py +++ b/src/Plugins/MEDReader/Test/testMEDReader15.py @@ -48,7 +48,6 @@ reader=MEDReader(FileName=fname) ExpectedEntries=['TS0/zeName/ComSup0/zeName@@][@@P1','TS0/zeName/ComSup0/MESH@zeName@@][@@P1'] assert(reader.GetProperty("FieldsTreeInfo")[::2]==ExpectedEntries) - # glyph1=Glyph(Input=reader,GlyphType='Arrow',Scalars='FamilyIdNode',Vectors='zeName',GlyphMode='All Points',ScaleFactor=0.1,GlyphTransform='Transform2') @@ -62,13 +61,6 @@ zeNameLUT.VectorMode = 'Component' glyph1Display=Show(glyph1,renderView1) glyph1Display.ColorArrayName = ['POINTS', 'FamilyIdNode'] glyph1Display.LookupTable = zeNameLUT -glyph1Display.OpacityArray = [None, ''] -glyph1Display.RadiusArray = [None, ''] -glyph1Display.RadiusRange = [-0.0707106813788414, 1.0099999904632568] -glyph1Display.ConstantRadius = 1.0099999904632568 -glyph1Display.PointSpriteDefaultsInitialized = 1 -glyph1Display.SelectInputVectors = ['POINTS', 'GlyphVector'] -glyph1Display.WriteLog = '' # show color bar/color legend glyph1Display.SetScalarBarVisibility(renderView1, True) # set scalar coloring @@ -78,5 +70,22 @@ glyph1Display.RescaleTransferFunctionToDataRange(True) # show color bar/color legend glyph1Display.SetScalarBarVisibility(renderView1, True) # +renderView1.ViewSize =[300,300] +renderView1.GetRenderWindow().DoubleBufferOff() Render() -WriteImage(outImgName) + +# compare with baseline image +import os +import sys +try: + baselineIndex = sys.argv.index('-B')+1 + baselinePath = sys.argv[baselineIndex] +except: + print "Could not get baseline directory. Test failed." + exit(1) +baseline_file = os.path.join(baselinePath, "testMEDReader15.png") +import vtk.test.Testing +vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir() +vtk.test.Testing.compareImage(GetActiveView().GetRenderWindow(), baseline_file, + threshold=25) +vtk.test.Testing.interact() diff --git a/src/Plugins/MEDReader/Test/testMEDReader2.py b/src/Plugins/MEDReader/Test/testMEDReader2.py index e33e4954..78d8f819 100644 --- a/src/Plugins/MEDReader/Test/testMEDReader2.py +++ b/src/Plugins/MEDReader/Test/testMEDReader2.py @@ -57,16 +57,13 @@ f1ts.write(fname,0) from paraview.simple import * - - testMEDReader1=MEDReader(FileName=fname) testMEDReader1.AllArrays=['TS0/mesh/ComSup0/ACellField@@][@@P0'] testMEDReader2=MEDReader(FileName=fname) testMEDReader2.AllArrays=['TS0/mesh/ComSup1/mesh@@][@@P0'] GroupDatasets1=GroupDatasets(Input=[testMEDReader1,testMEDReader2]) -Clip1 = Clip(ClipType="Plane") -Clip1.Input=GroupDatasets1 +Clip1 = Clip(ClipType="Plane",Input=GroupDatasets1) Clip1.Scalars=['FamilyIdCell'] Clip1.ClipType.Origin=[3.0, 3.0, 3.0] Clip1.InsideOut=1 @@ -82,9 +79,8 @@ DataRepresentation4.ScaleFactor = 0.6000000000000001 DataRepresentation4.Visibility = 1 DataRepresentation4.Representation = 'Wireframe' -ExtractBlock1 = ExtractBlock() +ExtractBlock1 = ExtractBlock(Input=Clip1) ExtractBlock1.BlockIndices=[1, 2] -ExtractBlock1.Input=Clip1 DataRepresentation5 = Show() DataRepresentation5.EdgeColor = [0.0, 0.0, 0.5000076295109483] @@ -105,6 +101,22 @@ RenderView1.CameraClippingRange = [0.026023957813772633, 26.023957813772633] RenderView1.CameraFocalPoint = [2.9999999999999996, 2.9999999999999987, 2.9999999999999982] RenderView1.ViewSize =[300,300] -WriteImage(outImgName) - - +Render() + +#WriteImage(outImgName) + +# compare with baseline image +import os +import sys +try: + baselineIndex = sys.argv.index('-B')+1 + baselinePath = sys.argv[baselineIndex] +except: + print "Could not get baseline directory. Test failed." + exit(1) +baseline_file = os.path.join(baselinePath, "testMEDReader2.png") +import vtk.test.Testing +vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir() +vtk.test.Testing.compareImage(GetActiveView().GetRenderWindow(), baseline_file, + threshold=25) +vtk.test.Testing.interact() diff --git a/src/Plugins/MEDReader/Test/testMEDReader3.py b/src/Plugins/MEDReader/Test/testMEDReader3.py index 014d1976..be1515d8 100644 --- a/src/Plugins/MEDReader/Test/testMEDReader3.py +++ b/src/Plugins/MEDReader/Test/testMEDReader3.py @@ -115,7 +115,30 @@ a1_ANodeField_PVLookupTable.ScalarOpacityFunction=a1_ANodeField_PiecewiseFunctio DataRepresentation2.ScalarOpacityFunction=a1_ANodeField_PiecewiseFunction DataRepresentation2.ColorArrayName='ANodeField' DataRepresentation2.LookupTable=a1_ANodeField_PVLookupTable -### -WriteImage(outImgName) +# Triangulate so rendring always the same with different gpu or graphic backend. +extSurf = ExtractSurface(Input=testMEDReader3) +triangulate = Triangulate(Input=extSurf) +Hide(testMEDReader3, RenderView1) +Show(triangulate, RenderView1) +triangulate1Display = GetDisplayProperties(triangulate, view=RenderView1) +ColorBy(triangulate1Display, ('POINTS', 'ANodeField')) + +Render() +### +# compare with baseline image +import os +import sys +try: + baselineIndex = sys.argv.index('-B')+1 + baselinePath = sys.argv[baselineIndex] +except: + print "Could not get baseline directory. Test failed." + exit(1) +baseline_file = os.path.join(baselinePath, "testMEDReader3.png") +import vtk.test.Testing +vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir() +vtk.test.Testing.compareImage(GetActiveView().GetRenderWindow(), baseline_file, + threshold=25) +vtk.test.Testing.interact() diff --git a/src/Plugins/MEDReader/Test/testMEDReader4.py b/src/Plugins/MEDReader/Test/testMEDReader4.py index f943e470..4b0541ed 100644 --- a/src/Plugins/MEDReader/Test/testMEDReader4.py +++ b/src/Plugins/MEDReader/Test/testMEDReader4.py @@ -92,4 +92,20 @@ RenderView1.CameraFocalPoint = [0.8087292125440382, 1.3325993334207897, 0.0] RenderView1.CameraParallelScale = 3.712804729456109 RenderView1.ViewSize =[300,300] -WriteImage(outImgName) +Render() + +# compare with baseline image +import os +import sys +try: + baselineIndex = sys.argv.index('-B')+1 + baselinePath = sys.argv[baselineIndex] +except: + print "Could not get baseline directory. Test failed." + exit(1) +baseline_file = os.path.join(baselinePath, "testMEDReader4.png") +import vtk.test.Testing +vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir() +vtk.test.Testing.compareImage(GetActiveView().GetRenderWindow(), baseline_file, + threshold=25) +vtk.test.Testing.interact() diff --git a/src/Plugins/MEDReader/Test/testMEDReader5.py b/src/Plugins/MEDReader/Test/testMEDReader5.py index b27349bc..71b61df7 100644 --- a/src/Plugins/MEDReader/Test/testMEDReader5.py +++ b/src/Plugins/MEDReader/Test/testMEDReader5.py @@ -78,8 +78,7 @@ myMedReader=MEDReader(FileName=fname) myMedReader.AllArrays = ['TS0/mesh/ComSup1/fNode@@][@@P1'] myMedReader.AllTimeSteps = ['0000'] -Clip1=Clip(ClipType="Plane") -Clip1.Input=myMedReader +Clip1=Clip(ClipType="Plane",Input=myMedReader) Clip1.Scalars = ['POINTS', 'FamilyIdNode'] Clip1.ClipType.Origin = [2.0, 2.0, 2.0] Clip1.ClipType = "Plane" @@ -109,6 +108,21 @@ DataRepresentation2.ScaleFactor = 0.4 DataRepresentation2.ColorArrayName=('POINTS','fNode') DataRepresentation2.LookupTable=LookupTable - RenderView1.ViewSize=[300,300] -WriteImage(outImgName) +Render() + +# compare with baseline image +import os +import sys +try: + baselineIndex = sys.argv.index('-B')+1 + baselinePath = sys.argv[baselineIndex] +except: + print "Could not get baseline directory. Test failed." + exit(1) +baseline_file = os.path.join(baselinePath, "testMEDReader5.png") +import vtk.test.Testing +vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir() +vtk.test.Testing.compareImage(GetActiveView().GetRenderWindow(), baseline_file, + threshold=25) +vtk.test.Testing.interact() diff --git a/src/Plugins/MEDReader/Test/testMEDReader6.py b/src/Plugins/MEDReader/Test/testMEDReader6.py index acdb1f56..1a76bfe9 100644 --- a/src/Plugins/MEDReader/Test/testMEDReader6.py +++ b/src/Plugins/MEDReader/Test/testMEDReader6.py @@ -93,7 +93,21 @@ DataRepresentation4.ColorArrayName = 'fGauss' DataRepresentation4.LookupTable = a1_fGauss_PVLookupTable a1_fGauss_PVLookupTable.ScalarOpacityFunction = a1_fGauss_PiecewiseFunction - RenderView1.ViewSize=[300,300] -WriteImage(outImgName) +Render() +# compare with baseline image +import os +import sys +try: + baselineIndex = sys.argv.index('-B')+1 + baselinePath = sys.argv[baselineIndex] +except: + print "Could not get baseline directory. Test failed." + exit(1) +baseline_file = os.path.join(baselinePath, "testMEDReader6.png") +import vtk.test.Testing +vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir() +vtk.test.Testing.compareImage(GetActiveView().GetRenderWindow(), baseline_file, + threshold=25) +vtk.test.Testing.interact() diff --git a/src/Plugins/MEDReader/Test/testMEDReader7.py b/src/Plugins/MEDReader/Test/testMEDReader7.py index e79dffc4..dbbf2baf 100644 --- a/src/Plugins/MEDReader/Test/testMEDReader7.py +++ b/src/Plugins/MEDReader/Test/testMEDReader7.py @@ -66,7 +66,6 @@ fmts.write(fname,0) ################### MED write is done -> Go to MEDReader from paraview.simple import * - myMedReader=MEDReader(FileName=fname) myMedReader.AllArrays = ['TS0/mesh/ComSup0/fNode@@][@@P1'] assert(list(myMedReader.TimestepValues)==[0.,1.,2.,3.]) @@ -95,4 +94,20 @@ RenderView1.ViewTime = 1.0 #### Important # red is in right bottom RenderView1.CacheKey = 1.0 RenderView1.UseCache = 1 RenderView1.ViewSize=[300,300] -WriteImage(outImgName) +Render() + +# compare with baseline image +import os +import sys +try: + baselineIndex = sys.argv.index('-B')+1 + baselinePath = sys.argv[baselineIndex] +except: + print "Could not get baseline directory. Test failed." + exit(1) +baseline_file = os.path.join(baselinePath, "testMEDReader7.png") +import vtk.test.Testing +vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir() +vtk.test.Testing.compareImage(GetActiveView().GetRenderWindow(), baseline_file, + threshold=25) +vtk.test.Testing.interact() diff --git a/src/Plugins/MEDReader/Test/testMEDReader8.py b/src/Plugins/MEDReader/Test/testMEDReader8.py index 048f50be..58d263a7 100644 --- a/src/Plugins/MEDReader/Test/testMEDReader8.py +++ b/src/Plugins/MEDReader/Test/testMEDReader8.py @@ -70,14 +70,12 @@ myMedReader.AllArrays = ['TS0/mesh/ComSup0/fNode@@][@@P1'] assert(list(myMedReader.TimestepValues)==[0.,1.,2.,3.]) myMedReader.UpdatePipeline() -extractCT=ExtractCellType() -extractCT.Input=myMedReader +extractCT=ExtractCellType(Input=myMedReader) extractCT.UpdatePipelineInformation() assert(list(extractCT.GetProperty("GeoTypesInfo"))==['TRI3','0','QUAD4','0']) extractCT.AllGeoTypes=['TRI3'] -extGrp=ExtractGroup() -extGrp.Input=extractCT +extGrp=ExtractGroup(Input=extractCT) extGrp.UpdatePipelineInformation() assert(filter(lambda x:x[:4]=="GRP_",list(extGrp.GetProperty("GroupsFlagsInfo")[::2]))==['GRP_grp0']) extGrp.AllGroups="GRP_grp0" @@ -106,4 +104,20 @@ RenderView1.ViewTime = 1.0 #### Important # red is in right bottom RenderView1.CacheKey = 1.0 RenderView1.UseCache = 1 RenderView1.ViewSize=[300,300] -WriteImage(outImgName) +Render() + +# compare with baseline image +import os +import sys +try: + baselineIndex = sys.argv.index('-B')+1 + baselinePath = sys.argv[baselineIndex] +except: + print "Could not get baseline directory. Test failed." + exit(1) +baseline_file = os.path.join(baselinePath, "testMEDReader8.png") +import vtk.test.Testing +vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir() +vtk.test.Testing.compareImage(GetActiveView().GetRenderWindow(), baseline_file, + threshold=25) +vtk.test.Testing.interact() diff --git a/src/Plugins/ParaMEDCorba/vtkParaMEDCorbaSource.cxx b/src/Plugins/ParaMEDCorba/vtkParaMEDCorbaSource.cxx index b8a65b9e..62906d31 100644 --- a/src/Plugins/ParaMEDCorba/vtkParaMEDCorbaSource.cxx +++ b/src/Plugins/ParaMEDCorba/vtkParaMEDCorbaSource.cxx @@ -35,9 +35,9 @@ #include "vtkObjectFactory.h" #include "vtkInformation.h" // -#include "vtksys/stl/string" -#include "vtksys/ios/fstream" -#include "vtksys/stl/algorithm" +#include "string" +#include "fstream" +#include "algorithm" #include "VTKMEDCouplingMeshClient.hxx" #include "VTKMEDCouplingFieldClient.hxx" @@ -85,7 +85,7 @@ void vtkParaMEDCorbaSource::SetIORCorba(char *ior) return; int length=strlen(ior); IOR.resize(length+1); - vtksys_stl::copy(ior,ior+length+1,&IOR[0]); + std::copy(ior,ior+length+1,&IOR[0]); this->Modified(); } diff --git a/src/Plugins/ParaMEDCorba/vtkParaMEDCorbaSource.h b/src/Plugins/ParaMEDCorba/vtkParaMEDCorbaSource.h index d4f07887..feb5d39e 100644 --- a/src/Plugins/ParaMEDCorba/vtkParaMEDCorbaSource.h +++ b/src/Plugins/ParaMEDCorba/vtkParaMEDCorbaSource.h @@ -23,7 +23,7 @@ #include "ParaMEDMEM2VTK_defines.hxx" #include "vtkUnstructuredGridAlgorithm.h" -#include +#include class vtkDoubleArray; class vtkUnstructuredGrid; @@ -60,7 +60,7 @@ protected: int EndPiece; int BufferingPolicy; vtkUnstructuredGrid *MyDataSet; - vtksys_stl::vector IOR; + std::vector IOR; ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher *mfieldsFetcher; //not clean but to avoid to include CORBA.h in this *.h static void *Orb; diff --git a/test/standalone/gui/CMakeLists.txt b/test/standalone/gui/CMakeLists.txt index a1a77cc7..eea2c6e5 100644 --- a/test/standalone/gui/CMakeLists.txt +++ b/test/standalone/gui/CMakeLists.txt @@ -71,6 +71,6 @@ ADD_EXECUTABLE(paraLight ${pl_FORMS_HEADERS} ${rcs_sources}) -TARGET_LINK_LIBRARIES(paraLight ${QT_LIBRARIES} pqApplicationComponents vtkRenderingFreeTypeOpenGL) +TARGET_LINK_LIBRARIES(paraLight ${QT_LIBRARIES} pqApplicationComponents )#vtkRenderingFreeTypeOpenGL) #INSTALL(TARGET paraLight bin)