}
// Save camera position to, which is no longer output by the tracer ...
- VTK_PY_GIL_ENSURE
- PyObject * mods(PySys_GetObject(const_cast<char*>("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<char*>("SaveCameras")));
- vtkSmartPyObject camera_trace(PyObject_CallMethod(save_cam, const_cast<char*>("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<char*>("join"),
- const_cast<char*>("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<char*>("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<char*>("SaveCameras")));
+ vtkSmartPyObject camera_trace(PyObject_CallMethod(save_cam, const_cast<char*>("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<char*>("join"),
+ const_cast<char*>("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;
}
#include <vtkStringArray.h>
#include <vtkStringToNumeric.h>
-#include <vtksys/stl/stdexcept>
-#include <vtksys/ios/sstream>
+#include <stdexcept>
+#include <sstream>
vtkStandardNewMacro(vtkJSONReader);
# -DMEDFILE_ROOT_DIR=/where/is/med-3.0.7_install -DMEDCOUPLING_ROOT_DIR=/where/is/medcoupling_install \
# -DParaView_DIR=<PARAVIEW_INSTALL>/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)
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)
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
#include "vtkFieldData.h"
#include "vtkCellData.h"
-#include "vtksys/stl/string"
-#include "vtksys/ios/fstream"
-#include "vtksys/stl/algorithm"
#include "vtkMutableDirectedGraph.h"
using namespace ParaMEDMEM;
vtkIdTypeArray *ELGACmp::createNew(const ParaMEDMEM::MEDFileFieldGlobsReal *globs, const std::vector<std::string>& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds) const
{
- static const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_DELETE;
+ const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_DELETE;
std::vector< std::vector<std::string> > locNames(_loc_names);
std::vector<vtkIdTypeArray *> elgas(_elgas);
std::vector< std::pair< vtkQuadratureSchemeDefinition *, unsigned char > > defs;
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());
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<double>::VTK_DATA_ARRAY_FREE;
- static const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_DELETE;
+ const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_FREE;
+ const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_DELETE;
tr->setNumberOfTS((operator->())->getNumberOfTS());
tr->initIterator();
for(int timeStepId=0;timeStepId<tr->size();timeStepId++,++(*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);
vtkUnstructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolationUnstructured(MEDUMeshMultiLev *mm) const
{
- static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_FREE;
+ const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_FREE;
DataArrayDouble *coordsMC(0);
DataArrayByte *typesMC(0);
DataArrayInt *cellLocationsMC(0),*cellsMC(0),*faceLocationsMC(0),*facesMC(0);
vtkUnsignedCharArray *cellTypes(vtkUnsignedCharArray::New());
cellTypes->SetArray(reinterpret_cast<unsigned char *>(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();
vtkRectilinearGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolationCartesian(ParaMEDMEM::MEDCMeshMultiLev *mm) const
{
- static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_FREE;
+ const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_FREE;
bool isInternal;
std::vector< DataArrayDouble * > arrs(mm->buildVTUArrays(isInternal));
vtkDoubleArray *vtkTmp(0);
vtkStructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolationCurveLinear(ParaMEDMEM::MEDCurveLinearMeshMultiLev *mm) const
{
- static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_FREE;
+ const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_FREE;
int meshStr[3]={1,1,1};
DataArrayDouble *coords(0);
std::vector<int> nodeStrct;
vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolation(const MEDTimeReq *tr, const MEDFileFieldGlobsReal *globs, const ParaMEDMEM::MEDFileMeshes *meshes) const
{
- static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_FREE;
+ const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_FREE;
vtkDataSet *ret(0);
//_fsp->isDataSetSupportEqualToThePreviousOne(i,globs);
MEDCouplingAutoRefCountObjectPtr<MEDMeshMultiLev> mml(_fsp->buildFromScratchDataSetSupport(0,globs));//0=timestep Id. Make the hypothesis that support does not change
this->_data_structure.resize(allFMTSLeavesPerTimeSeriesSafe.size());
for(std::size_t i=0;i<allFMTSLeavesPerTimeSeriesSafe.size();i++)
{
- vtksys_stl::vector< vtksys_stl::string > meshNamesLoc;
+ std::vector< std::string > meshNamesLoc;
std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> > > splitByMeshName;
for(std::size_t j=0;j<allFMTSLeavesPerTimeSeriesSafe[i].size();j++)
{
std::string meshName(allFMTSLeavesPerTimeSeriesSafe[i][j]->getMeshName());
- 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);
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<std::string> fieldNamesAlreadyExisting(ret->getFieldsNames());
*/
std::string MEDFileFieldRepresentationTree::PostProcessFieldName(const std::string& fullFieldName)
{
- static const char SEP('_');
+ const char SEP('_');
std::vector<std::string> v(SplitFieldNameIntoParts(fullFieldName,SEP));
if(v.empty())
return fullFieldName;//should never happen
vtkRenderingCore
vtkTestingRendering
vtkInteractionStyle
- vtkRenderingFreeTypeOpenGL
+ #vtkRenderingFreeTypeOpenGL
EXCLUDE_FROM_WRAP_HIERARCHY
)
vtkDataSet *FilterFamilies(vtkDataSet *input, const std::vector<int>& idsToKeep, bool insideOut)
{
- static const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_DELETE;
- static const char ZE_SELECTION_ARR_NAME[]="@@ZeSelection@@";
+ const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_DELETE;
+ const char ZE_SELECTION_ARR_NAME[]="@@ZeSelection@@";
vtkDataSet *output(input->NewInstance());
output->ShallowCopy(input);
vtkSmartPointer<vtkThreshold> thres(vtkSmartPointer<vtkThreshold>::New());
#include "vtkExtractGroup.h"
#include "MEDFileFieldRepresentationTree.hxx"
+#include "vtkMEDReader.h"
#include "vtkAdjacentVertexIterator.h"
#include "vtkIntArray.h"
#include "vtkThreshold.h"
#include "vtkMultiBlockDataGroupFilter.h"
#include "vtkCompositeDataToUnstructuredGridFilter.h"
+#include "vtkInformationDataObjectMetaDataKey.h"
#include <map>
#include <deque>
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);
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();
}
itFams->Delete();
}
- it0->Delete();
+ it0->Delete();
//
std::size_t szg(_groups.size()),szf(_fams.size());
if(szg==oldGrps.size() && szf==oldFams.size())
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)
{
vtkDataSet *input, const std::set<int>& idsToKeep, bool insideOut, const char *arrNameOfFamilyField,
const char *associationForThreshold, bool& catchAll, bool& catchSmth)
{
- static const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_DELETE;
- static const char ZE_SELECTION_ARR_NAME[]="@@ZeSelection@@";
+ const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_DELETE;
+ const char ZE_SELECTION_ARR_NAME[]="@@ZeSelection@@";
vtkDataSet *output(input->NewInstance());
output->ShallowCopy(input);
thres->SetInputData(output);
//
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));
{
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());
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;
}
// 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();
int RequestData(vtkInformation *request, vtkInformationVector **inputVector,
vtkInformationVector *outputVector);
+
// Description:
// This SIL stores the structure of the mesh/groups/cell types
// that can be selected.
vtkDoubleArray *vtkGenerateVectors::Operate2Compo(vtkDoubleArray *oldArr)
{
- static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_FREE;
+ const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_FREE;
vtkDoubleArray *ret(vtkDoubleArray::New());
std::size_t nbOfTuples(oldArr->GetNumberOfTuples());
const double *inPt(oldArr->GetPointer(0));
vtkDoubleArray *vtkGenerateVectors::OperateMoreThan3Compo(vtkDoubleArray *oldArr)
{
- static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_FREE;
+ const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_FREE;
vtkDoubleArray *ret(vtkDoubleArray::New());
int nbOfCompo(oldArr->GetNumberOfComponents());
std::size_t nbOfTuples(oldArr->GetNumberOfTuples());
#include "vtkCellArray.h"
#include "vtkDoubleArray.h"
#include "vtkObjectFactory.h"
+#include "vtkInformationDataObjectMetaDataKey.h"
+
#ifdef MEDREADER_USE_MPI
#include "vtkMultiProcessController.h"
#endif
/*!
* 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
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)
int MyMTime;
std::set<std::string> _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<std::string,bool> _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))
{
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);
}
//not pvsm mode (general case)
this->Internal->IsStdOrMode=newMode!=0;
- //std::cerr << "vtkMEDReader::ChangeMode : " << this->Internal->IsStdOrMode << std::endl;
this->Modified();
}
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);
}
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)
{
if(!this->Internal)
return 0;
return this->Internal->Tree.getNumberOfLeavesArrays();
- //std::cerr << "vtkMEDReader::GetNumberOfFieldsTreeArrays called ! " << ret << std::endl;
}
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)
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)
{
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
{
#include "vtkMultiBlockDataSetAlgorithm.h"
class vtkMutableDirectedGraph;
+class vtkInformationDataObjectMetaDataKey;
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;
};
--- /dev/null
+// 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 <map>
+#include <string>
+#include <vector>
+#include <sstream>
+#include <algorithm>
+
+/*!
+ * 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<std::string,int> > SetFieldsStatusPairs;
+ // generate vector
+ bool IsGVActivated;
+ int GVValue;
+ // change mode
+ bool IsCMActivated;
+ int CMValue;
+ //
+ std::vector< std::pair<std::string,int> > TimesFlagsStatusPairs;
+ vtkMEDReader *_master;
+};
+
+void PropertyKeeper::assignPropertiesIfNeeded()
+{
+ if(!this->SetFieldsStatusPairs.empty())
+ {
+ for(std::vector< std::pair<std::string,int> >::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<std::string,int> >::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<std::string,int> >::const_iterator it=this->SetFieldsStatusPairs.begin();it!=this->SetFieldsStatusPairs.end() && !found;it++)
+ found=(*it).first==name;
+ if(!found)
+ this->SetFieldsStatusPairs.push_back(std::pair<std::string,int>(name,status));
+}
+
+void PropertyKeeper::pushTimesFlagsStatusEntry(const char* name, int status)
+{
+ bool found(false);
+ for(std::vector< std::pair<std::string,int> >::const_iterator it=this->TimesFlagsStatusPairs.begin();it!=this->TimesFlagsStatusPairs.end() && !found;it++)
+ found=(*it).first==name;
+ if(!found)
+ this->TimesFlagsStatusPairs.push_back(std::pair<std::string,int>(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<std::string> _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<std::string,bool> _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" <<endl;
+/* int ret = this->Internal->ReloadReq;
+ // this->Internal->ReloadReq = 0;
+ return ret;*/
+}
+int vtkMEDReader::GetReloadReq(int a)
+{
+ cout<<"Get Reload Req:"<< a <<endl;
+ /* int ret = this->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<char *>(oss.str().c_str()));
+ else
+ vtkOutputWindowDisplayErrorText(const_cast<char *>(oss.str().c_str()));
+ vtkObject::BreakOnError();
+ }
+}
+
+char *vtkMEDReader::GetFileName()
+{
+ return const_cast<char *>(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<char *>(oss.str().c_str()));
+ else
+ vtkOutputWindowDisplayErrorText(const_cast<char *>(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<vtkVariantArray> childEdge(vtkSmartPointer<vtkVariantArray>::New());
+ childEdge->InsertNextValue(0);
+ vtkSmartPointer<vtkVariantArray> crossEdge(vtkSmartPointer<vtkVariantArray>::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<std::string> 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<std::string>::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<double> 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);
+}
--- /dev/null
+// 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 <string>
+
+#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_
# 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}
# directory.
vtkMEDReader
)
-
+
ENDIF(PARAVIEW_BUILD_QT_GUI)
TARGET_LINK_LIBRARIES(MEDReaderPlugin vtkMEDReader vtkMEDReaderCS)
)
-
-
+++ /dev/null
-<ParaViewFilters>
- <Filter name="ExtractGroup"/>
- <Filter name="ExtractCellType"/>
- <Category name="Mechanics" menu_label="&Mechanics" preserve_order="1">
- <Filter name="ELNOPoints"/>
- <Filter name="ELNOMesh"/>
- <Filter name="ELNOSurface"/>
- <Filter name="GaussPoints"/>
- </Category>
-</ParaViewFilters>
</ReaderFactory>
</Hints>
+ <Property name="Reload"
+ command="Reload"
+ panel_widget="MEDReaderReloadWidgetType"/>
+
<StringVectorProperty
name="FileName"
command="SetFileName"
number_of_elements="1"
+ panel_visibility="never"
animateable="0">
<FileListDomain name="files" />
<Documentation>
This property specifies the file name for the MED reader.
</Documentation>
</StringVectorProperty>
-
- <IntVectorProperty
- name="ReloadReq"
- command="Reload"
- number_of_elements="1"
- default_values="0"
- animateable="0">
- <SimpleIntInformationHelper />
- </IntVectorProperty>
<IntVectorProperty command="GetServerModifTime" information_only="1" name="ServerModifTime">
<SimpleIntInformationHelper />
</IntVectorProperty>
- <IntVectorProperty
- name="GenerateVectors"
- command="GenerateVectors"
- number_of_elements="1"
- default_values="0"
- animateable="0">
- <SimpleIntInformationHelper />
- </IntVectorProperty>
-
- <IntVectorProperty
- name="TimeOrModal"
- command="ChangeMode"
- number_of_elements="1"
- default_values="0"
- animateable="0">
- <SimpleIntInformationHelper />
- </IntVectorProperty>
-
<!-- retrieves using GetNumberOf[FieldsTree]Arrays and GetFieldsTreeArrayName the keys used by FieldsStatus -->
<StringVectorProperty name="FieldsTreeInfo" information_only="1">
<ArraySelectionInformationHelper attribute_name="FieldsTree" />
</StringVectorProperty>
-
+
<StringVectorProperty
name="FieldsStatus"
command="SetFieldsStatus"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
- information_property="FieldsTreeInfo">
+ information_property="FieldsTreeInfo"
+ immediate_update="1"
+ panel_widget="MEDReaderFieldsWidgetType">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property name="FieldsTreeInfo" function="ArrayList" />
</Documentation>
</StringVectorProperty>
- <StringVectorProperty name="TimesFlagsInfo" information_only="1">
- <ArraySelectionInformationHelper attribute_name="TimesFlags" />
- </StringVectorProperty>
-
- <StringVectorProperty name="TimesFlagsStatus" command="SetTimesFlagsStatus"
- label="All TimeSteps"
- number_of_elements="0"
- repeat_command="1"
- number_of_elements_per_command="2"
- element_types="2 0"
- information_property="TimesFlagsInfo">
- <ArraySelectionDomain name="array_list">
- <RequiredProperties>
- <Property name="TimesFlagsInfo" function="ArrayList" />
- </RequiredProperties>
- </ArraySelectionDomain>
- <Documentation>
- This property lists all groups and families to select.
- </Documentation>
- </StringVectorProperty>
+ <IntVectorProperty name="VectorsProperty"
+ label="Generate Vectors"
+ command="GenerateVectors"
+ number_of_elements="1"
+ default_values="0"
+ panel_widget="MEDReaderVectorsWidgetType">
+ <Documentation>
+ This property define if the reader generate vectors.
+ </Documentation>
+ <BooleanDomain name="bool"/>
+ </IntVectorProperty>
+ <IntVectorProperty name="TimeModeProperty"
+ label="Activate Mode"
+ command="ChangeMode"
+ number_of_elements="1"
+ default_values="0"
+ panel_widget="MEDReaderTimeModeWidgetType">
+ <Documentation>
+ This property define if the reader read time steps as modes or not.
+ </Documentation>
+ <BooleanDomain name="bool"/>
+ </IntVectorProperty>
<StringVectorProperty
name="Separator"
</Documentation>
</DoubleVectorProperty>
- </SourceProxy>
+ <StringVectorProperty name="TimesFlagsInfo" information_only="1">
+ <ArraySelectionInformationHelper attribute_name="TimesFlags" />
+ </StringVectorProperty>
+
+ <StringVectorProperty name="TimesFlagsStatus" command="SetTimesFlagsStatus"
+ label="All TimeSteps"
+ number_of_elements="0"
+ repeat_command="1"
+ number_of_elements_per_command="2"
+ element_types="2 0"
+ information_property="TimesFlagsInfo"
+ panel_widget="MEDReaderTimesFlagsWidgetType">
+ <ArraySelectionDomain name="array_list">
+ <RequiredProperties>
+ <Property name="TimesFlagsInfo" function="ArrayList" />
+ </RequiredProperties>
+ </ArraySelectionDomain>
+ <Documentation>
+ This property define which time steps the reader should read.
+ </Documentation>
+ <Hints>
+ <PropertyWidgetDecorator type="ShowWidgetDecorator">
+ <Property name="TimeModeProperty" function="boolean" />
+ </PropertyWidgetDecorator>
+ </Hints>
+ </StringVectorProperty>
+
+ </SourceProxy>
</ProxyGroup>
<ProxyGroup name="filters">
This property specifies the input to the Level Scalars filter.
</Documentation>
</InputProperty>
-
- <IntVectorProperty name="SILUpdateStamp" command="GetSILUpdateStamp" information_only="1">
- <SimpleIntInformationHelper />
- <Documentation>
- Information property indicating the update stamp of the SIL. Every
- time the SIL is rebuild, this
- time stamp is changed.
- </Documentation>
- </IntVectorProperty>
-
+
<StringVectorProperty name="GroupsFlagsInfo" information_only="1">
<ArraySelectionInformationHelper attribute_name="GroupsFlags" />
</StringVectorProperty>
-
+
<StringVectorProperty name="GroupsFlagsStatus" command="SetGroupsFlagsStatus"
label="All Groups"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
- information_property="GroupsFlagsInfo">
+ information_property="GroupsFlagsInfo"
+ panel_widget="ExtractGroupFieldsWidgetType">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property name="GroupsFlagsInfo" function="ArrayList" />
</Documentation>
</StringVectorProperty>
- <IntVectorProperty command="SetInsideOut" default_values="0" name="InsideOut" number_of_elements="1">
+ <IntVectorProperty command="SetInsideOut" default_values="0" name="InsideOut" label="Extract Complementary" number_of_elements="1">
<BooleanDomain name="bool"/>
<Documentation>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.
This property returns the name of the mesh.
</Documentation>
</StringVectorProperty>
+
</SourceProxy>
</ProxyGroup>
-
+
<ProxyGroup name="filters">
<SourceProxy name="ExtractCellType" class="vtkExtractCellType" label="Extract Cell Type">
<InputProperty name="Input" command="SetInputConnection">
This property specifies the input to the Level Scalars filter.
</Documentation>
</InputProperty>
-
- <IntVectorProperty name="SILUpdateStamp" command="GetSILUpdateStamp" information_only="1">
- <SimpleIntInformationHelper />
- <Documentation>
- Information property indicating the update stamp of the SIL. Every
- time the SIL is rebuild, this
- time stamp is changed.
- </Documentation>
- </IntVectorProperty>
-
+
<StringVectorProperty name="GeoTypesInfo" information_only="1">
<ArraySelectionInformationHelper attribute_name="GeoTypes" />
</StringVectorProperty>
-
+
<StringVectorProperty name="GeoTypesStatus" command="SetGeoTypesStatus"
- label="All GeoTypes"
+ label="All Geo Types"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
This property lists all the geometric types to select.
</Documentation>
</StringVectorProperty>
- <IntVectorProperty command="SetInsideOut" default_values="0" name="InsideOut" number_of_elements="1">
+ <IntVectorProperty command="SetInsideOut" label="Extract Complementary" default_values="0" name="InsideOut" number_of_elements="1">
<BooleanDomain name="bool"/>
<Documentation>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.
</RequiredProperties>
</ArrayListDomain>
</StringVectorProperty>
- <Hints>
+ <Hints>
<Property name="SelectSourceArray" show="0"/>
</Hints>
</SourceProxy>
</Hints>
</SourceProxy>
-
+
<SourceProxy name="ELNOPoints" class="vtkELNOFilter" label="ELNO Points">
<Documentation
long_help="Create a point set with data at ELNO points. Cells are shrinked by a given factor towards the cell center."
</Hints>
</SourceProxy>
-
<SourceProxy
name="GenerateStructuralElement"
class="vtkGenerateStructElement"
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>ExtractCellTypePanel</class>
- <widget class="QWidget" name="ExtractCellTypePanel">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>649</width>
- <height>839</height>
- </rect>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="windowTitle">
- <string>Form</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <property name="margin">
- <number>9</number>
- </property>
- <item row="0" column="0" colspan="3">
- <widget class="QGroupBox" name="geometryGroupBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>1</verstretch>
- </sizepolicy>
- </property>
- <property name="title">
- <string>Geometric types available</string>
- </property>
- <layout class="QVBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="margin">
- <number>9</number>
- </property>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="pqTreeWidget" name="Fields">
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>200</height>
- </size>
- </property>
- <column>
- <property name="text">
- <string notr="true">1</string>
- </property>
- </column>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QCheckBox" name="ExtractComplementary">
- <property name="text">
- <string>Extract the complementary</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>pqTreeWidget</class>
- <extends>QTreeWidget</extends>
- <header>pqTreeWidget.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
- <designerdata>
- <property name="gridDeltaX">
- <number>10</number>
- </property>
- <property name="gridDeltaY">
- <number>10</number>
- </property>
- <property name="gridSnapX">
- <bool>false</bool>
- </property>
- <property name="gridSnapY">
- <bool>false</bool>
- </property>
- <property name="gridVisible">
- <bool>true</bool>
- </property>
- </designerdata>
-</ui>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>ExtractGroupPanel</class>
- <widget class="QWidget" name="ExtractGroupPanel">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>649</width>
- <height>839</height>
- </rect>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="windowTitle">
- <string>Form</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <property name="margin">
- <number>9</number>
- </property>
- <item row="0" column="0" colspan="3">
- <widget class="QGroupBox" name="geometryGroupBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>1</verstretch>
- </sizepolicy>
- </property>
- <property name="title">
- <string>Groups And Families</string>
- </property>
- <layout class="QVBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="margin">
- <number>9</number>
- </property>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="pqTreeWidget" name="Fields">
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>200</height>
- </size>
- </property>
- <column>
- <property name="text">
- <string notr="true">1</string>
- </property>
- </column>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QCheckBox" name="ExtractComplementary">
- <property name="text">
- <string>Extract the complementary</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>pqTreeWidget</class>
- <extends>QTreeWidget</extends>
- <header>pqTreeWidget.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
- <designerdata>
- <property name="gridDeltaX">
- <number>10</number>
- </property>
- <property name="gridDeltaY">
- <number>10</number>
- </property>
- <property name="gridSnapX">
- <bool>false</bool>
- </property>
- <property name="gridSnapY">
- <bool>false</bool>
- </property>
- <property name="gridVisible">
- <bool>true</bool>
- </property>
- </designerdata>
-</ui>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>MEDReaderPanel</class>
- <widget class="QWidget" name="MEDReaderPanel">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>649</width>
- <height>839</height>
- </rect>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="windowTitle">
- <string>Form</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout_5">
- <property name="margin">
- <number>9</number>
- </property>
- <item>
- <widget class="QGroupBox" name="geometryGroupBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>1</verstretch>
- </sizepolicy>
- </property>
- <property name="title">
- <string>Representation</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="margin">
- <number>9</number>
- </property>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="Reload">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="toolTip">
- <string>Reload current file</string>
- </property>
- <property name="autoFillBackground">
- <bool>true</bool>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset resource="../pqMEDReader.qrc">
- <normaloff>:/ParaViewResources/Icons/pqReloadFile16.png</normaloff>:/ParaViewResources/Icons/pqReloadFile16.png</iconset>
- </property>
- <property name="checkable">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="pqExodusIIVariableSelectionWidget" name="Fields">
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>200</height>
- </size>
- </property>
- <column>
- <property name="text">
- <string notr="true">1</string>
- </property>
- </column>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox_2">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximumSize">
- <size>
- <width>16777215</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="title">
- <string/>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <property name="spacing">
- <number>0</number>
- </property>
- <property name="margin">
- <number>0</number>
- </property>
- <item>
- <widget class="QCheckBox" name="GenerateVects">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximumSize">
- <size>
- <width>16777215</width>
- <height>25</height>
- </size>
- </property>
- <property name="text">
- <string>GenerateVectors</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="title">
- <string/>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QRadioButton" name="stdMode">
- <property name="text">
- <string>Time</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="modeMode">
- <property name="text">
- <string>Mode</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QWidget" name="timeStepsInspector" native="true">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>250</width>
- <height>400</height>
- </size>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_4"/>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>pqExodusIIVariableSelectionWidget</class>
- <extends>QTreeWidget</extends>
- <header>pqExodusIIVariableSelectionWidget.h</header>
- </customwidget>
- </customwidgets>
- <resources>
- <include location="../pqMEDReader.qrc"/>
- </resources>
- <connections/>
- <designerdata>
- <property name="gridDeltaX">
- <number>10</number>
- </property>
- <property name="gridDeltaY">
- <number>10</number>
- </property>
- <property name="gridSnapX">
- <bool>false</bool>
- </property>
- <property name="gridSnapY">
- <bool>false</bool>
- </property>
- <property name="gridVisible">
- <bool>true</bool>
- </property>
- </designerdata>
-</ui>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MEDReaderTimeModeWidget</class>
+ <widget class="QWidget" name="widget">
+ <layout class="QGridLayout" name="layout">
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="title">
+ <string/>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QRadioButton" name="stdMode">
+ <property name="text">
+ <string>Time</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="modeMode">
+ <property name="text">
+ <string>Mode</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+</ui>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MEDReaderVectorsWidget</class>
+ <widget class="QWidget" name="widgetVectors">
+ <layout class="QGridLayout" name="layoutVectors">
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QGroupBox" name="groupBoxVectors">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="title">
+ <string/>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayoutVectors">
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QCheckBox" name="GenerateVects">
+ <property name="text">
+ <string>GenerateVectors</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+</ui>
<file>Icons/pqCellData16.png</file>
<file>Icons/pqPointData16.png</file>
<file>Icons/pqQuadratureData16.png</file>
- <file>MEDReaderClient2.xml</file>
<file>Icons/pqElnoData16.png</file>
<file>Icons/pqReloadFile16.png</file>
<file>Icons/pqCellDataForWholeMesh16.png</file>
m->setData(ind,QVariant(true),Qt::UserRole);
}
QTableView::selectionChanged(selected,deselected);
+ this->clearSelection();
}
void VectBoolSpreadSheet::nbOfRowsHasChanged(int newNbOfRows)
void VectBoolItem::activated(bool val)
{
- //_model->setStatusAt(_pos,val);
+ _model->setStatusAt(_pos,val);
+ _old_status=val;
}
void VectBoolItem::theModelHasChanged()
_vbm->selectUnselectAll();
_nb_of_rows_selecter->setValue(_nb_of_rows_selecter->maximum());
//
- _items.resize(nbOfItems);
for(int i=0;i<nbOfItems;i++)
{
- _items[i]=new VectBoolItem(this,i,_vbm);
- connect(_vbm,SIGNAL(nbOfTimeStepsOnChanged(int,int)),_items[i],SLOT(theModelHasChanged()));
+ VectBoolItem* item = new VectBoolItem(this,i,_vbm);
+ _items["000"+QString::number(i)]=item;
+ connect(_vbm, SIGNAL(nbOfTimeStepsOnChanged(int,int)), item, SLOT(theModelHasChanged()));
}
}
if(curNbOfItems>getNumberOfBoolItems())
{
std::cerr << "ERROR ! Internal Error in VectBoolWidget::setItems ! Current number of items is bigger than the current one !" << std::endl;
+ std::cerr << curNbOfItems << " "<<getNumberOfBoolItems()<<std::endl;
return ;
}
if(_vbm->setCurrentItems(dts,its,tts))
#include <QFrame>
#include <QLabel>
+#include <QMap>
class QSlider;
class QGroupBox;
~VectBoolWidget();
int getNumberOfBoolItems() const;
void setItems(const QStringList& dts, const QStringList& its, const QStringList& tts);
- const QVector<VectBoolItem *>& getItems() const { return _items; }
+ const QMap<QString, VectBoolItem *>& getItems() const { return _items; }
private:
static int GetMaxTickValueOfSlider(int val);
private:
- QVector<VectBoolItem *> _items;
+ QMap<QString, VectBoolItem *> _items;
QHBoxLayout *_horizontal_layout;
QFrame *_spreadsheet_container;
QGridLayout *_grid_layout;
--- /dev/null
+// 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 <QGridLayout>
+#include <QHeaderView>
+//-----------------------------------------------------------------------------
+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<QString, pqTreeWidgetItemObject*>::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<QString, pqTreeWidgetItemObject*>::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);
+}
--- /dev/null
+// 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
+++ /dev/null
-// 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 <QHeaderView>
-
-#include <sstream>
-
-static const char ZE_SEP[]="@@][@@";
-
-class pqExtractCellTypePanel::pqUI: public QObject, public Ui::ExtractCellTypePanel
-{
-public:
- pqUI(pqExtractCellTypePanel* p):QObject(p)
- {
- this->VTKConnect = vtkSmartPointer<vtkEventQtSlotConnect>::New();
- this->SILUpdateStamp = -1;
- }
-
- ~pqUI() { }
-
- pqSILModel SILModel;
- vtkSmartPointer<vtkEventQtSlotConnect> VTKConnect;
- pqPropertyLinks Links;
- QMap<QTreeWidgetItem*, QString> 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<vtkMutableDirectedGraph *>(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;i<verticesNames2->GetNumberOfValues();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<QString> 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<vtkSMStringVectorProperty *>(SMProperty));
- unsigned int nb(sm->GetNumberOfElements());
- std::vector<std::string> sts(nb);
- for(unsigned int i=0;i<nb;i++)
- sts[i]=sm->GetElement(i);
- ///
- pqTreeWidget *sc(this->UI->Fields);
- for(int i0=0;i0<sc->topLevelItemCount();i0++)
- {
- QTreeWidgetItem *lev0(sc->topLevelItem(i0));
- pqTreeWidgetItemObject *scc(dynamic_cast<pqTreeWidgetItemObject *>(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;i<nb;i++)
- {
- args[i]=sts[i].c_str();
- }
- {
- int iup(sm->GetImmediateUpdate());
- //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 !
-}
+++ /dev/null
-// 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 <map>
-
-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
--- /dev/null
+// 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 <QStringList>
+
+//-----------------------------------------------------------------------------
+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<vtkTree> 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<std::string, int> 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();
+}
--- /dev/null
+// 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
+++ /dev/null
-// 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 <QHeaderView>
-
-#include <sstream>
-
-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<vtkEventQtSlotConnect>::New();
- this->SILUpdateStamp = -1;
- }
-
- ~pqUI() { }
-
- pqSILModel SILModel;
- vtkSmartPointer<vtkEventQtSlotConnect> VTKConnect;
- pqPropertyLinks Links;
- QMap<QTreeWidgetItem*, QString> 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<vtkMutableDirectedGraph *>(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;i<verticesNames2->GetNumberOfValues();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<QString> strs0; strs0.append(QString("Groups of \"%1\"").arg(meshName));
- pqTreeWidgetItemObject *item0(new pqTreeWidgetItemObject(this->UI->Fields,strs0));
- std::map<std::string,int> 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<QString> 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<std::string,int>::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<QString> 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<vtkSMStringVectorProperty *>(SMProperty));
- unsigned int nb(sm->GetNumberOfElements());
- std::vector<std::string> sts(nb);
- for(unsigned int i=0;i<nb;i++)
- sts[i]=sm->GetElement(i);
- ///
- pqTreeWidget *sc(this->UI->Fields);
- for(int i0=0;i0<sc->topLevelItemCount();i0++)
- {
- QTreeWidgetItem *lev0(sc->topLevelItem(i0));//Group and Fam
- for(int i1=0;i1<lev0->childCount();i1++)
- {
- QTreeWidgetItem *lev1(lev0->child(i1));
- pqTreeWidgetItemObject *scc(dynamic_cast<pqTreeWidgetItemObject *>(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;i<nb;i++)
- {
- args[i]=sts[i].c_str();
- }
- {
- int iup(sm->GetImmediateUpdate());
- //sm->SetNumberOfElements(0);
- sm->SetElements(args,nb);
- proxy->UpdateVTKObjects();
- sm->SetImmediateUpdate(iup);
- }
- delete [] args;
- //
- ((vtkSMSourceProxy *)proxy)->UpdatePipelineInformation();
- setModified();
-}
-
-std::map<std::string,int> pqExtractGroupPanel::DeduceMapOfFamilyFromSIL(vtkMutableDirectedGraph *graph)
-{
- std::map<std::string,int> 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;i<verticesNames2->GetNumberOfValues();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 !
-}
+++ /dev/null
-// 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 <map>
-
-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<std::string,int> DeduceMapOfFamilyFromSIL(vtkMutableDirectedGraph *graph);
-protected:
- /// populate widgets with properties from the server manager
- virtual void linkServerManagerProperties();
- class pqUI;
- pqUI* UI;
-};
-
-#endif
--- /dev/null
+// 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 <QStringList>
+#include <QHeaderView>
+
+//-----------------------------------------------------------------------------
+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<vtkTree> 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<pqTreeWidgetItemObject*>(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<pqTreeWidgetItemObject*>(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<pqTreeWidgetItemObject*>(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);
+ }
+ }
+}
--- /dev/null
+// 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<pqTreeWidgetItemObject*> 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
--- /dev/null
+// 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<vtkTree> 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<vtkTree> 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;
+}
+}
--- /dev/null
+// 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 <QStringList>
+
+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
+++ /dev/null
-// 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 <QHeaderView>
-
-#include <sstream>
-
-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<std::string,int> _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<std::string,int>::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<vtkEventQtSlotConnect>::New();
- }
-
- ~pqUI() { }
-
- vtkSmartPointer<vtkEventQtSlotConnect> VTKConnect;
- QMap<QTreeWidgetItem*, QString> 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<vtkSMIntVectorProperty *>(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<vtkMutableDirectedGraph *>(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;i<verticesNames2->GetNumberOfValues();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<QString> 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;ii<nbTSInt;ii++)
- {
- dts.push_back(QString::fromStdString((const char *)verticesNames2->GetValue(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<QString> 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<QVariant> modulesAct;
- for(int i=0;i<nbTS.toInt();i++)
- modulesAct.push_back(QVariant(true));
- item0->setProperty("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<QString> 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<QString> 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<QString> 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<pqTreeWidgetItemObject *,int>(item3,ll));
- std::ostringstream pdm; pdm << name0.toStdString() << "/" << name1.toStdString() << "/" << name2.toStdString() << "/" << name3CppFull;
- (static_cast<vtkSMStringVectorProperty *>(SMProperty))->SetElement(2*ll,pdm.str().c_str());
- const char *tmp((static_cast<vtkSMStringVectorProperty *>(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<VectBoolItem *>& 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<QLayout *>(child));
- if(layout)
- delete layout;
- }
- initAll();
- }
-}
-
-void pqMEDReaderPanel::aLev3HasBeenFired(bool v)
-{
- pqTreeWidgetItemObject *zeItem(qobject_cast<pqTreeWidgetItemObject *>(sender()));
- if(!zeItem)
- return;
- for(int i=0;i<zeItem->childCount();i++)
- {
- QTreeWidgetItem *elt(zeItem->child(i));
- pqTreeWidgetItemObject *eltC(dynamic_cast<pqTreeWidgetItemObject *>(elt));
- if(eltC)
- {
- eltC->setChecked(v);
- aLev4HasBeenFiredBy(eltC);
- }
- }
- putLev3InOrder();
- somethingChangedInFieldRepr();
-}
-
-void pqMEDReaderPanel::aLev4HasBeenFired()
-{
- pqTreeWidgetItemObject *zeItem(qobject_cast<pqTreeWidgetItemObject *>(sender()));
- if(zeItem)
- aLev4HasBeenFiredBy(zeItem);
- putLev3InOrder();
- somethingChangedInFieldRepr();
-}
-
-void pqMEDReaderPanel::aLev4HasBeenFiredBy(pqTreeWidgetItemObject *zeItem)
-{
- pqTreeWidgetItemObject *father(dynamic_cast<pqTreeWidgetItemObject *>(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<pqTreeWidgetItemObject *>::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<pqTreeWidgetItemObject *>::iterator it=it0;it!=it1;it++)
- {
- if((*it)->isChecked())
- isAllFalse=false;
- else
- isAllTrue=false;
- }
- if(isAllFalse || isAllTrue)
- {
- pqTreeWidgetItemObject *father(dynamic_cast<pqTreeWidgetItemObject *>(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<std::pair<pqTreeWidgetItemObject *,int> >::const_iterator it=_leaves.begin();it!=_leaves.end();it++)
- ((*it).first)->disconnect(SIGNAL(checkedStateChanged(bool)));
- //
- vtkSMProperty *SMProperty(this->proxy()->GetProperty("FieldsStatus"));
- for(std::set<std::pair<pqTreeWidgetItemObject *,int> >::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<vtkSMStringVectorProperty *>(this->proxy()->GetProperty("FieldsTreeInfo")));
- for(std::vector<pqTreeWidgetItemObject *>::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<pqTreeWidgetItemObject *>(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<pqTreeWidgetItemObject *>::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<pqTreeWidgetItemObject *>(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<pqTreeWidgetItemObject *>::const_iterator it=_all_lev4.begin();it!=_all_lev4.end();it++)
- {
- QTreeWidgetItem *obj((*it)->QTreeWidgetItem::parent()->QTreeWidgetItem::parent()->QTreeWidgetItem::parent());
- pqTreeWidgetItemObject *objC(dynamic_cast<pqTreeWidgetItemObject *>(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<vtkSMStringVectorProperty *>(SMProperty));
- unsigned int nb(sm->GetNumberOfElements());
- std::vector<std::string> sts(nb);
- ///
- pqExodusIIVariableSelectionWidget *sc(this->UI->Fields);
- for(int i0=0;i0<sc->topLevelItemCount();i0++)
- {
- QTreeWidgetItem *lev0(sc->topLevelItem(i0));//TS
- for(int i1=0;i1<lev0->childCount();i1++)
- {
- QTreeWidgetItem *lev1(lev0->child(i1));//Mesh
- for(int i2=0;i2<lev1->childCount();i2++)
- {
- QTreeWidgetItem *lev2(lev1->child(i2));//Comp
- for(int i3=0;i3<lev2->childCount();i3++)
- {
- QTreeWidgetItem *lev3(lev2->child(i3));
- pqTreeWidgetItemObject *scc(dynamic_cast<pqTreeWidgetItemObject *>(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;i<nb;i++)
- {
- args[i]=sts[i].c_str();
- }
- {//agy : let's go to put info in property FieldsStatus
- int iup(sm->GetImmediateUpdate());
- //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();
-}
-
+++ /dev/null
-// 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 <set>
-
-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<pqTreeWidgetItemObject *> _all_lev4;
-private:
- bool _reload_req;
- std::set<std::pair<pqTreeWidgetItemObject *,int> > _leaves;
- VectBoolWidget *_optional_widget;
- int _my_mtime;
- vtkSMIntVectorProperty *_sm_prop_remote_mtime;
-};
-
-#endif
--- /dev/null
+// 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 <QPushButton>
+#include <QGridLayout>
+
+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<pqPropertiesPanel*>(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();
+ }
+}
--- /dev/null
+// 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
--- /dev/null
+// 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);
+}
--- /dev/null
+// 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
--- /dev/null
+// 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 <QGridLayout>
+#include <QStringList>
+
+//-----------------------------------------------------------------------------
+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<QString, VectBoolItem*>& items(this->TimesVectWidget->getItems());
+ QMap<QString, VectBoolItem*>::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<QString, VectBoolItem*>& items(this->TimesVectWidget->getItems());
+ QMap<QString, VectBoolItem*>::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<QString, VectBoolItem *>& items(this->TimesVectWidget->getItems());
+ QMap<QString, VectBoolItem*>::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"<<endl;
+ // Block signals so the reloading does not trigger
+ // UncheckPropertyModified event
+ this->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);
+ }
+}
--- /dev/null
+// 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
--- /dev/null
+// 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()
+{
+}
--- /dev/null
+// 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
--- /dev/null
+// 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<unsigned char*>(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<const char*>(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;
+}
--- /dev/null
+// 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
# 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)
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()
# Author : Anthony Geay
from MEDLoader import *
-
fname="testMEDReader0.med"
outImgName="testMEDReader0.png"
#########
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))
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
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()
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"
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()
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()
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()
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()
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()
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')
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
# 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()
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
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]
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()
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()
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()
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"
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()
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()
################### 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.])
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()
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"
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()
#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"
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();
}
#include "ParaMEDMEM2VTK_defines.hxx"
#include "vtkUnstructuredGridAlgorithm.h"
-#include <vtksys/stl/vector>
+#include <vector>
class vtkDoubleArray;
class vtkUnstructuredGrid;
int EndPiece;
int BufferingPolicy;
vtkUnstructuredGrid *MyDataSet;
- vtksys_stl::vector<char> IOR;
+ std::vector<char> IOR;
ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher *mfieldsFetcher;
//not clean but to avoid to include CORBA.h in this *.h
static void *Orb;
${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)