# Specific to ParaVis:
FIND_PACKAGE(SalomeParaView)
-IF(TARGET vtkTools)
- message("bli !!")
-endif()
# GUI has to be loaded AFTER ParaView: the ParaView config doesn't mix
# well with the VTK one (and GUI loads VTK):
FIND_PACKAGE(SalomeMEDFile REQUIRED)
# TODO: the below requires ParaView in the PYTHONPATH ... not so nice:
-MESSAGE(STATUS "Generating wrapped class list (??) ...")
+MESSAGE(STATUS "Generating list of wrapped VTK classes ...")
LIST(GET PARAVIEW_INCLUDE_DIRS 0 PARAVIEW_INCLUDE_DIR0)
EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/getwrapclasses.py ${PARAVIEW_INCLUDE_DIR0}
RESULT_VARIABLE _res)
OPTION(BUILD_TESTING "Build ParaVis Testing" ON)
IF(BUILD_TESTING)
SET(PARAVIS_TEST_DIR ${ParaVis_BINARY_DIR}/Test/Temporary)
- MAKE_DIRECTORY(${PARAVIS_TEST_DIR})
+ MAKE_DIRECTORY(${PARAVIS_TEST_DIR}) # TODO: replace with FILE(MAKE_DIRECTORY ...)
ENABLE_TESTING()
INCLUDE (CTest)
ADD_SUBDIRECTORY(test)
#ifdef MedReader_HAVE_PARALLEL_INFRASTRUCTURE
// the following code opens the file in parallel
vtkMultiProcessController* controller =
- vtkMultiProcessController::GetGlobalController();
+ vtkMultiProcessController::GetGlobalController();
int lpID = 0;
if (controller == NULL)
{
int numProc = 1;
vtkMultiProcessController* controller =
- vtkMultiProcessController::GetGlobalController();
+ vtkMultiProcessController::GetGlobalController();
if (controller != NULL)
{
numProc = controller->GetNumberOfProcesses();
else
{
vtkMultiProcessController* controller =
- vtkMultiProcessController::GetGlobalController();
+ vtkMultiProcessController::GetGlobalController();
if(controller)
{
this->Internal->NumberOfPieces=controller->GetNumberOfProcesses();
{
this->Internal->CurrentPieceNumber=0;
vtkMultiProcessController* controller =
- vtkMultiProcessController::GetGlobalController();
+ vtkMultiProcessController::GetGlobalController();
if(controller)
{
this->Internal->CurrentPieceNumber= controller->GetLocalProcessId();
{
if(vtkfield.DataArray->GetNumberOfTuples()!=ds->GetNumberOfPoints())
{
- vtkDebugMacro("the data array " << vtkfield.DataArray->GetName()
+ vtkDebugMacro("the data array " << vtkfield.DataArray->GetName()
<< " do not have the good number of tuples");
return;
}
//-----------------------------------------------------------------------------
pqSetModeStarter::pqSetModeStarter(QObject* p/*=0*/)
- : QObject(p)
+: QObject(p)
{
}
// Copy default settings, make changes for Ctrl+MB and MB modes
for(int i=0; i<9; i++)
- {
- manips[i] = default3DManips[i];
-
- // Ctrl+MB
- if (manips[i].Shift == 0 && manips[i].Control == 1) {
- if (manips[i].Mouse == 1)
- manips[i].Name = QByteArray("Zoom");
- else if (manips[i].Mouse == 2)
- manips[i].Name = QByteArray("Pan");
- else if (manips[i].Mouse == 3)
- manips[i].Name = QByteArray("Rotate");
- }
-
- // MB only
- if (manips[i].Shift == 0 && manips[i].Control == 0) {
- if (manips[i].Mouse == 1)
- manips[i].Name = QByteArray("Rotate");
- else if (manips[i].Mouse == 2)
- manips[i].Name = QByteArray("Pan");
- else if (manips[i].Mouse == 3)
- manips[i].Name = QByteArray("Zoom");
- }
+ {
+ manips[i] = default3DManips[i];
+
+ // Ctrl+MB
+ if (manips[i].Shift == 0 && manips[i].Control == 1) {
+ if (manips[i].Mouse == 1)
+ manips[i].Name = QByteArray("Zoom");
+ else if (manips[i].Mouse == 2)
+ manips[i].Name = QByteArray("Pan");
+ else if (manips[i].Mouse == 3)
+ manips[i].Name = QByteArray("Rotate");
+ }
+
+ // MB only
+ if (manips[i].Shift == 0 && manips[i].Control == 0) {
+ if (manips[i].Mouse == 1)
+ manips[i].Name = QByteArray("Rotate");
+ else if (manips[i].Mouse == 2)
+ manips[i].Name = QByteArray("Pan");
+ else if (manips[i].Mouse == 3)
+ manips[i].Name = QByteArray("Zoom");
}
+ }
// Save settings
for(int i=0; i<9; i++)
- {
- strs << QString("Manipulator%1Mouse%2Shift%3Control%4Name%5")
- .arg(i+1)
- .arg(manips[i].Mouse)
- .arg(manips[i].Shift)
- .arg(manips[i].Control)
- .arg(QString(manips[i].Name));
- }
-
+ {
+ strs << QString("Manipulator%1Mouse%2Shift%3Control%4Name%5")
+ .arg(i+1)
+ .arg(manips[i].Mouse)
+ .arg(manips[i].Shift)
+ .arg(manips[i].Control)
+ .arg(QString(manips[i].Name));
+ }
+
settings->setValue("InteractorStyle/CameraManipulators", strs);
}
settings->endGroup();
// Loop through render views and apply the settings
QList<pqRenderViewBase*> views =
- pqApplicationCore::instance()->getServerManagerModel()->
- findItems<pqRenderViewBase*>();
+ pqApplicationCore::instance()->getServerManagerModel()->
+ findItems<pqRenderViewBase*>();
foreach(pqRenderViewBase* view, views) {
view->restoreSettings(true);
const double ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::EPS_TIME=1e-7;
ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::MEDCouplingMultiFieldsFetcher(int bufferingPolicy,
- SALOME_MED::MEDCouplingMultiFieldsCorbaInterface_ptr mfieldsPtr):_effective_pol(bufferingPolicy),_mfields_ptr_released(false)
+ SALOME_MED::MEDCouplingMultiFieldsCorbaInterface_ptr mfieldsPtr):_effective_pol(bufferingPolicy),_mfields_ptr_released(false)
{
_mfields_ptr=SALOME_MED::MEDCouplingMultiFieldsCorbaInterface::_duplicate(mfieldsPtr);
_mfields_ptr->Register();
ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::~MEDCouplingMultiFieldsFetcher()
{
for(std::vector<vtkDataSet *>::iterator it=_meshes.begin();it!=_meshes.end();it++)
- {
- if(*it)
- (*it)->Delete();
- }
+ {
+ if(*it)
+ (*it)->Delete();
+ }
for(std::vector<vtkDoubleArray *>::iterator it2=_arrays.begin();it2!=_arrays.end();it2++)
- {
- if(*it2)
- (*it2)->Delete();
- }
+ {
+ if(*it2)
+ (*it2)->Delete();
+ }
if(!_mfields_ptr_released)
_mfields_ptr->UnRegister();
}
_time_label_per_field.resize(nbOfFields);
SALOME_MED::MEDCouplingFieldOverTimeCorbaInterface_var fotPtr=SALOME_MED::MEDCouplingFieldOverTimeCorbaInterface::_narrow(_mfields_ptr);
if(CORBA::is_nil(fotPtr))
- {
- for(CORBA::Long i=0;i<nbOfFields;i++)
- _time_label_per_field[i]=(double)i;
- }
+ {
+ for(CORBA::Long i=0;i<nbOfFields;i++)
+ _time_label_per_field[i]=(double)i;
+ }
else
+ {
+ double tmp=0.;
+ for(CORBA::Long i=0;i<nbOfFields;i++)
{
- double tmp=0.;
- for(CORBA::Long i=0;i<nbOfFields;i++)
- {
- if(!_time_def_per_field[i].empty())
- _time_label_per_field[i]=_time_def_per_field[i].front();
- else
- _time_label_per_field[i]=tmp++;
- }
+ if(!_time_def_per_field[i].empty())
+ _time_label_per_field[i]=_time_def_per_field[i].front();
+ else
+ _time_label_per_field[i]=tmp++;
}
+ }
return _time_label_per_field;
}
void ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::fetchRegardingPolicy()
{
if(_effective_pol>=10)
- {
- fetchAll();
- return ;
- }
+ {
+ fetchAll();
+ return ;
+ }
if(_effective_pol>=1 && _effective_pol<=9)
- {
- fetchMeshes();
- return ;
- }
+ {
+ fetchMeshes();
+ return ;
+ }
}
vtkDataSet *ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::buildDataSetOnTime(double time)
vtkDataSet *ret0=_meshes[meshId];
std::string clsName=ret0->GetClassName();
if(clsName=="vtkUnstructuredGrid")
- {
- vtkUnstructuredGrid *ret1=vtkUnstructuredGrid::New();
- ret1->DeepCopy(ret0);
- if(_is_meshes_polyhedron[meshId])//bug VTK polyhedron
- {//bug VTK polyhedron part
- ret1->Faces->UnRegister(ret1);
- ret1->Faces=vtkIdTypeArray::New();
- ret1->Faces->DeepCopy(((vtkUnstructuredGrid *)ret0)->GetFaces());
- ret1->Faces->Register(ret1);
- ret1->Faces->Delete();
- ret1->FaceLocations->UnRegister(ret1);
- ret1->FaceLocations=vtkIdTypeArray::New();
- ret1->FaceLocations->DeepCopy(((vtkUnstructuredGrid *)ret0)->GetFaceLocations());
- ret1->FaceLocations->Register(ret1);
- ret1->FaceLocations->Delete();
- }//end bug VTK polyhedron part
- appendFieldValueOnAlreadyFetchedData(ret1,fieldId);
- applyBufferingPolicy();
- return ret1;
- }
+ {
+ vtkUnstructuredGrid *ret1=vtkUnstructuredGrid::New();
+ ret1->DeepCopy(ret0);
+ if(_is_meshes_polyhedron[meshId])//bug VTK polyhedron
+ {//bug VTK polyhedron part
+ ret1->Faces->UnRegister(ret1);
+ ret1->Faces=vtkIdTypeArray::New();
+ ret1->Faces->DeepCopy(((vtkUnstructuredGrid *)ret0)->GetFaces());
+ ret1->Faces->Register(ret1);
+ ret1->Faces->Delete();
+ ret1->FaceLocations->UnRegister(ret1);
+ ret1->FaceLocations=vtkIdTypeArray::New();
+ ret1->FaceLocations->DeepCopy(((vtkUnstructuredGrid *)ret0)->GetFaceLocations());
+ ret1->FaceLocations->Register(ret1);
+ ret1->FaceLocations->Delete();
+ }//end bug VTK polyhedron part
+ appendFieldValueOnAlreadyFetchedData(ret1,fieldId);
+ applyBufferingPolicy();
+ return ret1;
+ }
if(clsName=="vtkRectilinearGrid")
- {
- vtkRectilinearGrid *ret1=vtkRectilinearGrid::New();
- ret1->DeepCopy(ret0);
- appendFieldValueOnAlreadyFetchedData(ret1,fieldId);
- applyBufferingPolicy();
- return ret1;
- }
+ {
+ vtkRectilinearGrid *ret1=vtkRectilinearGrid::New();
+ ret1->DeepCopy(ret0);
+ appendFieldValueOnAlreadyFetchedData(ret1,fieldId);
+ applyBufferingPolicy();
+ return ret1;
+ }
return 0;
}
int offsetTime=0;
int offsetArrays=0;
for(int i=0;i<sz;i++)
- {
- _mesh_id_per_field[i]=(*tinyL)[3+i];
- int nbOfArrayForCurField=(*tinyL)[sz+3+i];
- _array_ids_per_field[i].resize(nbOfArrayForCurField);
- for(int k=0;k<nbOfArrayForCurField;k++)
- _array_ids_per_field[i][k]=(*tinyL)[5*sz+3+offsetArrays+k];
- _time_discr_per_field[i]=(*tinyL)[2*sz+3+i];
- int nbOfTimeSpot=(*tinyL)[3*sz+3+i]-1;//-1 because time precision is not useful here.
- _time_def_per_field[i].resize(nbOfTimeSpot);
- for(int j=0;j<nbOfTimeSpot;j++)
- _time_def_per_field[i][j]=(*tinyD)[offsetTime+1+j];
- offsetTime+=nbOfTimeSpot+1;
- offsetArrays+=nbOfArrayForCurField;
- }
+ {
+ _mesh_id_per_field[i]=(*tinyL)[3+i];
+ int nbOfArrayForCurField=(*tinyL)[sz+3+i];
+ _array_ids_per_field[i].resize(nbOfArrayForCurField);
+ for(int k=0;k<nbOfArrayForCurField;k++)
+ _array_ids_per_field[i][k]=(*tinyL)[5*sz+3+offsetArrays+k];
+ _time_discr_per_field[i]=(*tinyL)[2*sz+3+i];
+ int nbOfTimeSpot=(*tinyL)[3*sz+3+i]-1;//-1 because time precision is not useful here.
+ _time_def_per_field[i].resize(nbOfTimeSpot);
+ for(int j=0;j<nbOfTimeSpot;j++)
+ _time_def_per_field[i][j]=(*tinyD)[offsetTime+1+j];
+ offsetTime+=nbOfTimeSpot+1;
+ offsetArrays+=nbOfArrayForCurField;
+ }
delete tinyL;
delete tinyD;
//
//
_info_per_field.resize(nbOfFields);
for(int i=0;i<nbOfFields;i++)
- {
- _mfields_ptr->getTinyInfo(i,tinyL,tinyD,tinyS);
- _info_per_field[i]._type=(*tinyL)[0];
- _info_per_field[i]._name=(*tinyS)[0];
- delete tinyL;
- delete tinyD;
- delete tinyS;
- }
+ {
+ _mfields_ptr->getTinyInfo(i,tinyL,tinyD,tinyS);
+ _info_per_field[i]._type=(*tinyL)[0];
+ _info_per_field[i]._name=(*tinyS)[0];
+ delete tinyL;
+ delete tinyD;
+ delete tinyS;
+ }
}
void ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::fetchAll()
fetchMeshes();
int nbOfArrays=_arrays.size();
for(int i=0;i<nbOfArrays;i++)
- {
- SALOME_MED::DataArrayDoubleCorbaInterface_var daPtr=_mfields_ptr->getArray(i);
- if(_arrays[i])
- _arrays[i]->Delete();
- _arrays[i]=ParaMEDMEM2VTK::BuildFromMEDCouplingFieldDoubleArr(daPtr);
- daPtr->UnRegister();
- }
+ {
+ SALOME_MED::DataArrayDoubleCorbaInterface_var daPtr=_mfields_ptr->getArray(i);
+ if(_arrays[i])
+ _arrays[i]->Delete();
+ _arrays[i]=ParaMEDMEM2VTK::BuildFromMEDCouplingFieldDoubleArr(daPtr);
+ daPtr->UnRegister();
+ }
unregisterRemoteServantIfAllFetched();
}
{
int nbOfMeshes=_meshes.size();
for(int i=0;i<nbOfMeshes;i++)
- {
- SALOME_MED::MEDCouplingMeshCorbaInterface_var mPtr=_mfields_ptr->getMeshWithId(i);
- if(_meshes[i])
- _meshes[i]->Delete();
- bool polyh=false;//bug VTK
- _meshes[i]=ParaMEDMEM2VTK::BuildFromMEDCouplingMeshInstance(mPtr,polyh);//bug VTK
- _is_meshes_polyhedron[i]=polyh;//bug VTK
- mPtr->UnRegister();
- }
+ {
+ SALOME_MED::MEDCouplingMeshCorbaInterface_var mPtr=_mfields_ptr->getMeshWithId(i);
+ if(_meshes[i])
+ _meshes[i]->Delete();
+ bool polyh=false;//bug VTK
+ _meshes[i]=ParaMEDMEM2VTK::BuildFromMEDCouplingMeshInstance(mPtr,polyh);//bug VTK
+ _is_meshes_polyhedron[i]=polyh;//bug VTK
+ mPtr->UnRegister();
+ }
unregisterRemoteServantIfAllFetched();
}
std::vector<int> arrayIds=_array_ids_per_field[fieldId];
int meshId=_mesh_id_per_field[fieldId];
if(!_meshes[meshId])
- {
- SALOME_MED::MEDCouplingMeshCorbaInterface_var mPtr=_mfields_ptr->getMeshWithId(meshId);
- bool polyh=false;//bug VTK
- _meshes[meshId]=ParaMEDMEM2VTK::BuildFromMEDCouplingMeshInstance(mPtr,polyh);//bug VTK
- _is_meshes_polyhedron[meshId]=polyh;//bug VTK
- mPtr->UnRegister();
- }
+ {
+ SALOME_MED::MEDCouplingMeshCorbaInterface_var mPtr=_mfields_ptr->getMeshWithId(meshId);
+ bool polyh=false;//bug VTK
+ _meshes[meshId]=ParaMEDMEM2VTK::BuildFromMEDCouplingMeshInstance(mPtr,polyh);//bug VTK
+ _is_meshes_polyhedron[meshId]=polyh;//bug VTK
+ mPtr->UnRegister();
+ }
for(std::vector<int>::const_iterator it=arrayIds.begin();it!=arrayIds.end();it++)
+ {
+ if(!_arrays[*it])
{
- if(!_arrays[*it])
- {
- SALOME_MED::DataArrayDoubleCorbaInterface_var daPtr=_mfields_ptr->getArray(*it);
- _arrays[*it]=ParaMEDMEM2VTK::BuildFromMEDCouplingFieldDoubleArr(daPtr);
- daPtr->UnRegister();
- }
+ SALOME_MED::DataArrayDoubleCorbaInterface_var daPtr=_mfields_ptr->getArray(*it);
+ _arrays[*it]=ParaMEDMEM2VTK::BuildFromMEDCouplingFieldDoubleArr(daPtr);
+ daPtr->UnRegister();
}
+ }
unregisterRemoteServantIfAllFetched();
}
void ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::unregisterRemoteServantIfAllFetched()
{
for(std::vector<vtkDataSet *>::iterator it=_meshes.begin();it!=_meshes.end();it++)
- {
- if((*it)==0)
- return ;
- }
+ {
+ if((*it)==0)
+ return ;
+ }
for(std::vector<vtkDoubleArray *>::iterator it2=_arrays.begin();it2!=_arrays.end();it2++)
- {
- if((*it2)==0)
- return ;
- }
+ {
+ if((*it2)==0)
+ return ;
+ }
if(!_mfields_ptr_released)
- {
- _mfields_ptr_released=true;
- _mfields_ptr->UnRegister();
- }
+ {
+ _mfields_ptr_released=true;
+ _mfields_ptr->UnRegister();
+ }
}
void ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::applyBufferingPolicy()
{
if(_effective_pol==0)
- {//
- for(std::vector<vtkDataSet *>::iterator it=_meshes.begin();it!=_meshes.end();it++)
- {
- if(*it)
- {
- (*it)->Delete();
- *it=0;
- }
- }
- for(std::vector<vtkDoubleArray *>::iterator it2=_arrays.begin();it2!=_arrays.end();it2++)
- {
- if(*it2)
- {
- (*it2)->Delete();
- *it2=0;
- }
- }
+ {//
+ for(std::vector<vtkDataSet *>::iterator it=_meshes.begin();it!=_meshes.end();it++)
+ {
+ if(*it)
+ {
+ (*it)->Delete();
+ *it=0;
+ }
+ }
+ for(std::vector<vtkDoubleArray *>::iterator it2=_arrays.begin();it2!=_arrays.end();it2++)
+ {
+ if(*it2)
+ {
+ (*it2)->Delete();
+ *it2=0;
+ }
}
+ }
//else nothing to do let the plugin bufferize
}
vtkDoubleArray *arr=_arrays[_array_ids_per_field[fieldId].front()];
arr->SetName(info._name.c_str());
if(info._type==0)//ON_CELLS
- {
- ds->GetCellData()->AddArray(arr);
- return ;
- }
+ {
+ ds->GetCellData()->AddArray(arr);
+ return ;
+ }
if(info._type==1)//ON_NODES
- {
- ds->GetPointData()->AddArray(arr);
- return ;
- }
+ {
+ ds->GetPointData()->AddArray(arr);
+ return ;
+ }
}
int ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::getPosGivenTimeLabel(double t)
return i;
//2nd chance
std::vector<double>::iterator it=std::find_if(_time_label_per_field.begin(),_time_label_per_field.end(),
- std::bind2nd(std::greater<double>(),t));
+ std::bind2nd(std::greater<double>(),t));
if(it!=_time_label_per_field.end() && it!=_time_label_per_field.end())
return std::distance(_time_label_per_field.begin(),it);
//
{
this->MyDataSet=0;
if(!Orb)
- {
- CORBA::ORB_var *OrbC=new CORBA::ORB_var;
- int argc=0;
- *OrbC=CORBA::ORB_init(argc,0);
- this->Orb=OrbC;
- }
+ {
+ CORBA::ORB_var *OrbC=new CORBA::ORB_var;
+ int argc=0;
+ *OrbC=CORBA::ORB_init(argc,0);
+ this->Orb=OrbC;
+ }
this->SetNumberOfInputPorts(0);
this->SetNumberOfOutputPorts(1);
}
return BufferingPolicy;
}
- //int vtkParaMEDCorbaSource::RequestUpdateExtent( vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outInfo )
- //{
- //return this->Superclass::RequestUpdateExtent(request,inInfo,outInfo);
+//int vtkParaMEDCorbaSource::RequestUpdateExtent( vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outInfo )
+//{
+//return this->Superclass::RequestUpdateExtent(request,inInfo,outInfo);
- /*vtkParaMEDCorbaDataSet* output = vtkParaMEDCorbaDataSet::SafeDownCast( info->Get( vtkDataObject::DATA_OBJECT() ) );
+/*vtkParaMEDCorbaDataSet* output = vtkParaMEDCorbaDataSet::SafeDownCast( info->Get( vtkDataObject::DATA_OBJECT() ) );
if ( ! output )
{
output = vtkParaMEDCorbaDataSet::New();
this->GetOutputPortInformation( 0 )->Set( vtkDataObject::DATA_EXTENT_TYPE(), output->GetExtentType() );
}*/
- // return 1;
- //}
+// return 1;
+//}
int vtkParaMEDCorbaSource::ProcessRequest(vtkInformation* request,
- vtkInformationVector** inputVector,
- vtkInformationVector* outputVector)
+ vtkInformationVector** inputVector,
+ vtkInformationVector* outputVector)
{
// generate the data
if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA()))
- {
+ {
return this->RequestData(request, inputVector, outputVector);
- }
+ }
if(request->Has(vtkDemandDrivenPipeline::REQUEST_INFORMATION()))
- {
+ {
return this->RequestInformation(request, inputVector, outputVector);
- }
+ }
return this->Superclass::ProcessRequest(request, inputVector, outputVector);
}
vtkInformation* myInfo=outInfo->GetInformationObject(0);
//myInfo->Set(vtkDataObject::DATA_TYPE_NAME(),"vtkUnstructuredGrid");
if(!IOR.empty())
+ {
+ //myInfo->Remove(vtkDataObject::DATA_TYPE_NAME());
+ //myInfo->Remove(PORT_REQUIREMENTS_FILLED());
+ //myInfo->Set(vtkDataObject::DATA_TYPE_NAME(),"vtkUnstructuredGrid");
+ //myInfo->Set(PORT_REQUIREMENTS_FILLED(),1);
+ //vtkUnstructuredGrid *tony=vtkUnstructuredGrid::New();
+ //tony->SetInformation(myInfo);
+ //myInfo->Set(vtkDataObject::DATA_OBJECT(),tony);
+ //
+ CORBA::ORB_var *OrbC=(CORBA::ORB_var *)this->Orb;
+ CORBA::Object_var obj=(*OrbC)->string_to_object(&IOR[0]);
+ //
+ Engines::MPIObject_ptr objPara=Engines::MPIObject::_narrow(obj);
+ if(CORBA::is_nil(objPara))
+ {//sequential
+ this->TotalNumberOfPieces=1;
+ SALOME_MED::MEDCouplingMultiFieldsCorbaInterface_var multiPtr=SALOME_MED::MEDCouplingMultiFieldsCorbaInterface::_narrow(obj);
+ if(!CORBA::is_nil(multiPtr))
+ {//Request for multiFields
+ delete mfieldsFetcher;
+ mfieldsFetcher=new ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher(BufferingPolicy,multiPtr);
+ std::vector<double> tsteps=mfieldsFetcher->getTimeStepsForPV();
+ double timeRange[2];
+ timeRange[0]=tsteps.front();
+ timeRange[1]=tsteps.back();
+ myInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),&tsteps[0],tsteps.size());
+ myInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(),timeRange,2);
+ }
+ }
+ else
{
- //myInfo->Remove(vtkDataObject::DATA_TYPE_NAME());
- //myInfo->Remove(PORT_REQUIREMENTS_FILLED());
- //myInfo->Set(vtkDataObject::DATA_TYPE_NAME(),"vtkUnstructuredGrid");
- //myInfo->Set(PORT_REQUIREMENTS_FILLED(),1);
- //vtkUnstructuredGrid *tony=vtkUnstructuredGrid::New();
- //tony->SetInformation(myInfo);
- //myInfo->Set(vtkDataObject::DATA_OBJECT(),tony);
- //
- CORBA::ORB_var *OrbC=(CORBA::ORB_var *)this->Orb;
- CORBA::Object_var obj=(*OrbC)->string_to_object(&IOR[0]);
- //
- Engines::MPIObject_ptr objPara=Engines::MPIObject::_narrow(obj);
- if(CORBA::is_nil(objPara))
- {//sequential
- this->TotalNumberOfPieces=1;
- SALOME_MED::MEDCouplingMultiFieldsCorbaInterface_var multiPtr=SALOME_MED::MEDCouplingMultiFieldsCorbaInterface::_narrow(obj);
- if(!CORBA::is_nil(multiPtr))
- {//Request for multiFields
- delete mfieldsFetcher;
- mfieldsFetcher=new ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher(BufferingPolicy,multiPtr);
- std::vector<double> tsteps=mfieldsFetcher->getTimeStepsForPV();
- double timeRange[2];
- timeRange[0]=tsteps.front();
- timeRange[1]=tsteps.back();
- myInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),&tsteps[0],tsteps.size());
- myInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(),timeRange,2);
- }
- }
- else
- {
- Engines::IORTab *iorTab=objPara->tior();
- this->TotalNumberOfPieces=iorTab->length();
- delete iorTab;
- CORBA::release(objPara);
- }
- myInfo->Set(vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES(),this->TotalNumberOfPieces);
+ Engines::IORTab *iorTab=objPara->tior();
+ this->TotalNumberOfPieces=iorTab->length();
+ delete iorTab;
+ CORBA::release(objPara);
}
+ myInfo->Set(vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES(),this->TotalNumberOfPieces);
+ }
return 1;
}
//
Engines::MPIObject_var objPara=Engines::MPIObject::_narrow(obj);
if(CORBA::is_nil(objPara))
- {//sequential
- SALOME_MED::MEDCouplingMeshCorbaInterface_var meshPtr=SALOME_MED::MEDCouplingMeshCorbaInterface::_narrow(obj);
- if(!CORBA::is_nil(meshPtr))
- {
- bool dummy;//bug VTK
- vtkDataSet *ret=ParaMEDMEM2VTK::BuildFromMEDCouplingMeshInstance(meshPtr,dummy);//bug VTK
- if(!ret)
- return 0;
- ret0->SetBlock(0,ret);
- ret->Delete();
- return 1;
- }
- SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_var fieldPtr=SALOME_MED::MEDCouplingFieldDoubleCorbaInterface::_narrow(obj);
- if(!CORBA::is_nil(fieldPtr))
- {
- std::vector<double> ret2;
- vtkDataSet *ret=ParaMEDMEM2VTK::BuildFullyFilledFromMEDCouplingFieldDoubleInstance(fieldPtr,ret2);
- if(!ret)
- {
- vtkErrorMacro("On single field CORBA fetching an error occurs !");
- return 0;
- }
- ret0->SetBlock(0,ret);
- ret->Delete();
- //
- double timeRange[2];
- timeRange[0]=ret2[0];
- timeRange[1]=ret2[0];
- outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),&ret2[0],1);
- outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(),timeRange,2);
- ret0->GetInformation()->Set(vtkDataObject::DATA_TIME_STEP(),ret2[0]);
- return 1;
- }
- SALOME_MED::MEDCouplingMultiFieldsCorbaInterface_var multiPtr=SALOME_MED::MEDCouplingMultiFieldsCorbaInterface::_narrow(obj);
- if(!CORBA::is_nil(multiPtr))
- {
- vtkDataSet *ret=mfieldsFetcher->buildDataSetOnTime(reqTS);
- if(!ret)
- {
- vtkErrorMacro("On multi fields CORBA fetching an error occurs !");
- return 0;
- }
- ret0->SetBlock(0,ret);
- ret->Delete();
- ret0->GetInformation()->Set(vtkDataObject::DATA_TIME_STEP(),reqTS);
- return 1;
- }
- vtkErrorMacro("Unrecognized sequential CORBA reference !");
- return 0;
+ {//sequential
+ SALOME_MED::MEDCouplingMeshCorbaInterface_var meshPtr=SALOME_MED::MEDCouplingMeshCorbaInterface::_narrow(obj);
+ if(!CORBA::is_nil(meshPtr))
+ {
+ bool dummy;//bug VTK
+ vtkDataSet *ret=ParaMEDMEM2VTK::BuildFromMEDCouplingMeshInstance(meshPtr,dummy);//bug VTK
+ if(!ret)
+ return 0;
+ ret0->SetBlock(0,ret);
+ ret->Delete();
+ return 1;
+ }
+ SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_var fieldPtr=SALOME_MED::MEDCouplingFieldDoubleCorbaInterface::_narrow(obj);
+ if(!CORBA::is_nil(fieldPtr))
+ {
+ std::vector<double> ret2;
+ vtkDataSet *ret=ParaMEDMEM2VTK::BuildFullyFilledFromMEDCouplingFieldDoubleInstance(fieldPtr,ret2);
+ if(!ret)
+ {
+ vtkErrorMacro("On single field CORBA fetching an error occurs !");
+ return 0;
+ }
+ ret0->SetBlock(0,ret);
+ ret->Delete();
+ //
+ double timeRange[2];
+ timeRange[0]=ret2[0];
+ timeRange[1]=ret2[0];
+ outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),&ret2[0],1);
+ outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(),timeRange,2);
+ ret0->GetInformation()->Set(vtkDataObject::DATA_TIME_STEP(),ret2[0]);
+ return 1;
+ }
+ SALOME_MED::MEDCouplingMultiFieldsCorbaInterface_var multiPtr=SALOME_MED::MEDCouplingMultiFieldsCorbaInterface::_narrow(obj);
+ if(!CORBA::is_nil(multiPtr))
+ {
+ vtkDataSet *ret=mfieldsFetcher->buildDataSetOnTime(reqTS);
+ if(!ret)
+ {
+ vtkErrorMacro("On multi fields CORBA fetching an error occurs !");
+ return 0;
+ }
+ ret0->SetBlock(0,ret);
+ ret->Delete();
+ ret0->GetInformation()->Set(vtkDataObject::DATA_TIME_STEP(),reqTS);
+ return 1;
}
+ vtkErrorMacro("Unrecognized sequential CORBA reference !");
+ return 0;
+ }
else
+ {
+ SALOME_MED::ParaMEDCouplingFieldDoubleCorbaInterface_var paraFieldCorba=SALOME_MED::ParaMEDCouplingFieldDoubleCorbaInterface::_narrow(obj);
+ if(!CORBA::is_nil(paraFieldCorba))
{
- SALOME_MED::ParaMEDCouplingFieldDoubleCorbaInterface_var paraFieldCorba=SALOME_MED::ParaMEDCouplingFieldDoubleCorbaInterface::_narrow(obj);
- if(!CORBA::is_nil(paraFieldCorba))
- {
- ParaMEDMEM2VTK::FillMEDCouplingParaFieldDoubleInstanceFrom(paraFieldCorba,this->StartPiece,this->EndPiece,ret0);
- return 1;
- }
- vtkErrorMacro("Unrecognized parallel CORBA reference !");
- return 0;
+ ParaMEDMEM2VTK::FillMEDCouplingParaFieldDoubleInstanceFrom(paraFieldCorba,this->StartPiece,this->EndPiece,ret0);
+ return 1;
}
+ vtkErrorMacro("Unrecognized parallel CORBA reference !");
+ return 0;
+ }
}
void vtkParaMEDCorbaSource::PrintSelf(ostream& os, vtkIndent indent)
//not clean but to avoid to include CORBA.h in this *.h
static void *Orb;
//ETX
- private:
+private:
/*void traduceMedMeshToUnstructuredDataset(vtkUnstructuredGrid *ret, int nbOfCells, int nbOfNodes,
- int nbOfTypes, const int *types, const int *nbOfEltsPerTypes, const int *nodalConnectivity,
- const double *coords, int spaceDim);
+ int nbOfTypes, const int *types, const int *nbOfEltsPerTypes, const int *nodalConnectivity,
+ const double *coords, int spaceDim);
vtkDoubleArray *buildDataArrayFromMedCoords(const double *coords, int nbOfNodes, int spaceDim);
void reorganizeCellConnectivity(int vtkType, int nbOfNodes, const int *medConn, int *vtkConn);
int transformMedGeomEltType2VtkType(int typeMed, int *nbOfNodesPerCell);*/
pqCustomChartDisplayPanelImplementation::pqCustomChartDisplayPanelImplementation(QObject* p):
QObject(p)
- {
- }
+{
+}
bool pqCustomChartDisplayPanelImplementation::canCreatePanel(pqRepresentation* repr) const
{
if(!repr || !repr->getProxy() ||
- (repr->getProxy()->GetXMLName() != QString("XYChartRepresentation")))
- {
- return false;
- }
+ (repr->getProxy()->GetXMLName() != QString("XYChartRepresentation")))
+ {
+ return false;
+ }
pqDataRepresentation* dataRepr = qobject_cast<pqDataRepresentation*>(repr);
if(dataRepr)
+ {
+ pqPipelineSource* input = dataRepr->getInput();
+ QString name = input->getProxy()->GetXMLName();
+ if (name == "TableReader")
{
- pqPipelineSource* input = dataRepr->getInput();
- QString name = input->getProxy()->GetXMLName();
- if (name == "TableReader")
- {
- return true;
- }
+ return true;
}
-
+ }
+
return false;
}
pqDisplayPanel* pqCustomChartDisplayPanelImplementation::createPanel(pqRepresentation* repr, QWidget* p)
{
if(!repr || !repr->getProxy() ||
- (repr->getProxy()->GetXMLName() != QString("XYChartRepresentation")))
- {
- return NULL;
- }
+ (repr->getProxy()->GetXMLName() != QString("XYChartRepresentation")))
+ {
+ return NULL;
+ }
pqDataRepresentation* dataRepr = qobject_cast<pqDataRepresentation*>(repr);
if(dataRepr)
- {
- pqPipelineSource* input = dataRepr->getInput();
- QString name=input->getProxy()->GetXMLName();
+ {
+ pqPipelineSource* input = dataRepr->getInput();
+ QString name=input->getProxy()->GetXMLName();
- if (name == "TableReader")
- {
- return new pqCustomXYChartDisplayPanel(repr, p);
- }
+ if (name == "TableReader")
+ {
+ return new pqCustomXYChartDisplayPanel(repr, p);
}
-
+ }
+
return NULL;
}
{
public:
pqImplementation()
- {
- }
+{
+}
vtkWeakPointer<vtkSMChartRepresentationProxy> RepresentationProxy;
QPointer<pqDataRepresentation> Representation;
};
pqCustomPlotSettingsModel::pqCustomPlotSettingsModel(QObject* parentObject) :
- Superclass(parentObject), Implementation(new pqImplementation())
+ Superclass(parentObject), Implementation(new pqImplementation())
{
}
Superclass::setRepresentation(rep);
if (!rep || rep == this->Implementation->Representation)
- {
+ {
return;
- }
+ }
if (this->Implementation->Representation)
- {
+ {
QObject::disconnect(this->Implementation->Representation, 0, this, 0);
- }
+ }
this->Implementation->RepresentationProxy =
- vtkSMChartRepresentationProxy::SafeDownCast(rep->getProxy());
+ vtkSMChartRepresentationProxy::SafeDownCast(rep->getProxy());
this->Implementation->Representation = rep;
}
//-----------------------------------------------------------------------------
bool pqCustomPlotSettingsModel::setData(const QModelIndex &idx, const QVariant &value,
- int role)
+ int role)
{
bool result = false;
if (idx.isValid() && idx.model() == this)
- {
+ {
if (idx.column() == 1 && (role == Qt::DisplayRole || role == Qt::EditRole))
- {
+ {
QString name = value.toString();
if (!name.isEmpty())
- {
+ {
this->setSeriesLabel(idx.row(), name);
- }
}
+ }
else if(idx.column() == 0 && role == Qt::CheckStateRole)
- {
+ {
result = true;
int checkstate = value.toInt();
this->setSeriesEnabled(idx.row(), checkstate == Qt::Checked);
- }
}
+ }
return result;
}
void pqCustomPlotSettingsModel::setSeriesEnabled(int row, bool enabled)
{
if (row >= 0 && row < this->rowCount(QModelIndex()))
+ {
+ int minRow = row;
+ int maxRow = row;
+
+ if (enabled && !(this->IgnoreUnitsModeOn))
{
- int minRow = row;
- int maxRow = row;
-
- if (enabled && !(this->IgnoreUnitsModeOn))
- {
- QString unit = getUnit(QString(this->getSeriesName(row)));
-
- for (int i = 0; i < rowCount(QModelIndex()); i++)
- {
- if (i == row)
- {
- continue;
- }
-
- bool rowChanged = false;
- QString seriesName = QString(this->getSeriesName(i));
- QString seriesUnit = getUnit(seriesName);
-
- if ((seriesUnit != unit) && getSeriesEnabled(i))
- {
- vtkSMPropertyHelper(this->Implementation->RepresentationProxy,
- "SeriesVisibility").SetStatus(this->getSeriesName(i), 0);
- rowChanged = true;
- }
-
- if (!seriesUnit.isEmpty() && this->AutoSelectModeOn &&
- (seriesUnit == unit) && !getSeriesEnabled(i))
- {
- vtkSMPropertyHelper(this->Implementation->RepresentationProxy,
- "SeriesVisibility").SetStatus(this->getSeriesName(i), 1);
- rowChanged = true;
- }
-
- if (rowChanged)
- {
- if (i < minRow)
- {
- minRow = i;
- }
- else if (i > maxRow)
- {
- maxRow = i;
- }
- }
- }
- }
-
- vtkSMPropertyHelper(this->Implementation->RepresentationProxy,
- "SeriesVisibility").SetStatus(this->getSeriesName(row), enabled ? 1 : 0);
- this->Implementation->RepresentationProxy->UpdateVTKObjects();
-
- this->setSeriesColor(row, this->getSeriesColor(row));
- QModelIndex topLeft = this->createIndex(minRow, 0);
- QModelIndex bottomRight = this->createIndex(maxRow, 0);
- emit this->dataChanged(topLeft, bottomRight);
- emit this->redrawChart();
- this->updateCheckState(0, Qt::Horizontal);
+ QString unit = getUnit(QString(this->getSeriesName(row)));
+
+ for (int i = 0; i < rowCount(QModelIndex()); i++)
+ {
+ if (i == row)
+ {
+ continue;
+ }
+
+ bool rowChanged = false;
+ QString seriesName = QString(this->getSeriesName(i));
+ QString seriesUnit = getUnit(seriesName);
+
+ if ((seriesUnit != unit) && getSeriesEnabled(i))
+ {
+ vtkSMPropertyHelper(this->Implementation->RepresentationProxy,
+ "SeriesVisibility").SetStatus(this->getSeriesName(i), 0);
+ rowChanged = true;
+ }
+
+ if (!seriesUnit.isEmpty() && this->AutoSelectModeOn &&
+ (seriesUnit == unit) && !getSeriesEnabled(i))
+ {
+ vtkSMPropertyHelper(this->Implementation->RepresentationProxy,
+ "SeriesVisibility").SetStatus(this->getSeriesName(i), 1);
+ rowChanged = true;
+ }
+
+ if (rowChanged)
+ {
+ if (i < minRow)
+ {
+ minRow = i;
+ }
+ else if (i > maxRow)
+ {
+ maxRow = i;
+ }
+ }
+ }
}
+
+ vtkSMPropertyHelper(this->Implementation->RepresentationProxy,
+ "SeriesVisibility").SetStatus(this->getSeriesName(row), enabled ? 1 : 0);
+ this->Implementation->RepresentationProxy->UpdateVTKObjects();
+
+ this->setSeriesColor(row, this->getSeriesColor(row));
+ QModelIndex topLeft = this->createIndex(minRow, 0);
+ QModelIndex bottomRight = this->createIndex(maxRow, 0);
+ emit this->dataChanged(topLeft, bottomRight);
+ emit this->redrawChart();
+ this->updateCheckState(0, Qt::Horizontal);
+ }
}
//-----------------------------------------------------------------------------
this->IgnoreUnitsModeOn = enabled;
if (this->IgnoreUnitsModeOn)
- {
- this->setCheckable(0, Qt::Horizontal, true);
- this->setCheckState(0, Qt::Horizontal, Qt::Unchecked);
- }
+ {
+ this->setCheckable(0, Qt::Horizontal, true);
+ this->setCheckState(0, Qt::Horizontal, Qt::Unchecked);
+ }
else
- {
- this->setCheckState(0, Qt::Horizontal, Qt::Unchecked);
- this->setCheckable(0, Qt::Horizontal, false);
- }
+ {
+ this->setCheckState(0, Qt::Horizontal, Qt::Unchecked);
+ this->setCheckable(0, Qt::Horizontal, false);
+ }
}
//-----------------------------------------------------------------------------
{
this->AutoSelectModeOn = enabled;
if (enabled && !this->IgnoreUnitsModeOn)
+ {
+ for (int i = 0; i < rowCount(QModelIndex()); i++)
{
- for (int i = 0; i < rowCount(QModelIndex()); i++)
- {
- if (getSeriesEnabled(i))
- {
- setSeriesEnabled(i, true);
- break;
- }
- }
+ if (getSeriesEnabled(i))
+ {
+ setSeriesEnabled(i, true);
+ break;
+ }
}
+ }
}
//-----------------------------------------------------------------------------
QString pqCustomPlotSettingsModel::getUnit(const QString& seriesName)
{
QString unit("");
-
+
int index1 = seriesName.lastIndexOf("]");
if (index1 == seriesName.size() - 1)
+ {
+ int index2 = seriesName.lastIndexOf(" [");
+ if (index2 > 0)
{
- int index2 = seriesName.lastIndexOf(" [");
- if (index2 > 0)
- {
- int start = index2 + 2;
- unit = seriesName.mid(index2 + 2, index1 - start);
- }
+ int start = index2 + 2;
+ unit = seriesName.mid(index2 + 2, index1 - start);
}
+ }
return unit;
}
{
public:
pqInternal()
- {
+{
this->SettingsModel = 0;
this->XAxisArrayDomain = 0;
this->XAxisArrayAdaptor = 0;
this->VTKConnect = vtkSmartPointer<vtkEventQtSlotConnect>::New();
- }
+}
~pqInternal()
- {
+ {
delete this->SettingsModel;
delete this->XAxisArrayDomain;
delete this->XAxisArrayAdaptor;
- }
+ }
vtkWeakPointer<vtkSMChartRepresentationProxy> ChartRepresentation;
pqCustomPlotSettingsModel* SettingsModel;
//-----------------------------------------------------------------------------
pqCustomXYChartDisplayPanel::pqCustomXYChartDisplayPanel(
- pqRepresentation* display,QWidget* p)
+ pqRepresentation* display,QWidget* p)
: pqDisplayPanel(display, p)
{
this->Internal = new pqCustomXYChartDisplayPanel::pqInternal();
this->Internal->SeriesList->setModel(this->Internal->SettingsModel);
this->Internal->XAxisArrayAdaptor = new pqSignalAdaptorComboBox(
- this->Internal->XAxisArray);
+ this->Internal->XAxisArray);
QObject::connect(
- this->Internal->SeriesList, SIGNAL(activated(const QModelIndex &)),
- this, SLOT(activateItem(const QModelIndex &)));
+ this->Internal->SeriesList, SIGNAL(activated(const QModelIndex &)),
+ this, SLOT(activateItem(const QModelIndex &)));
QItemSelectionModel *model = this->Internal->SeriesList->selectionModel();
QObject::connect(model,
- SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
- this, SLOT(updateOptionsWidgets()));
+ SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
+ this, SLOT(updateOptionsWidgets()));
QObject::connect(model,
- SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
- this, SLOT(updateOptionsWidgets()));
+ SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
+ this, SLOT(updateOptionsWidgets()));
QObject::connect(this->Internal->SettingsModel, SIGNAL(modelReset()),
- this, SLOT(updateOptionsWidgets()));
+ this, SLOT(updateOptionsWidgets()));
QObject::connect(this->Internal->SettingsModel, SIGNAL(redrawChart()),
- this, SLOT(updateAllViews()));
+ this, SLOT(updateAllViews()));
QObject::connect(this->Internal->XAxisArray, SIGNAL(currentIndexChanged(int)),
- this, SLOT(updateAllViews()));
+ this, SLOT(updateAllViews()));
QObject::connect(this->Internal->UseArrayIndex, SIGNAL(toggled(bool)),
- this, SLOT(useArrayIndexToggled(bool)));
+ this, SLOT(useArrayIndexToggled(bool)));
QObject::connect(this->Internal->UseDataArray, SIGNAL(toggled(bool)),
- this, SLOT(useDataArrayToggled(bool)));
+ this, SLOT(useDataArrayToggled(bool)));
QObject::connect(
- this->Internal->ColorButton, SIGNAL(chosenColorChanged(const QColor &)),
- this, SLOT(setCurrentSeriesColor(const QColor &)));
+ this->Internal->ColorButton, SIGNAL(chosenColorChanged(const QColor &)),
+ this, SLOT(setCurrentSeriesColor(const QColor &)));
QObject::connect(this->Internal->Thickness, SIGNAL(valueChanged(int)),
- this, SLOT(setCurrentSeriesThickness(int)));
+ this, SLOT(setCurrentSeriesThickness(int)));
QObject::connect(this->Internal->StyleList, SIGNAL(currentIndexChanged(int)),
- this, SLOT(setCurrentSeriesStyle(int)));
+ this, SLOT(setCurrentSeriesStyle(int)));
QObject::connect(this->Internal->AxisList, SIGNAL(currentIndexChanged(int)),
- this, SLOT(setCurrentSeriesAxes(int)));
+ this, SLOT(setCurrentSeriesAxes(int)));
QObject::connect(this->Internal->MarkerStyleList, SIGNAL(currentIndexChanged(int)),
- this, SLOT(setCurrentSeriesMarkerStyle(int)));
+ this, SLOT(setCurrentSeriesMarkerStyle(int)));
QObject::connect(
- this->Internal->AutoSelect, SIGNAL(toggled(bool)),
- this, SLOT(autoSelectToggled(bool)));
+ this->Internal->AutoSelect, SIGNAL(toggled(bool)),
+ this, SLOT(autoSelectToggled(bool)));
QObject::connect(
- this->Internal->IgnoreUnits, SIGNAL(toggled(bool)),
- this, SLOT(ignoreUnitsToggled(bool)));
+ this->Internal->IgnoreUnits, SIGNAL(toggled(bool)),
+ this, SLOT(ignoreUnitsToggled(bool)));
QObject::connect(
- this->Internal->GenerateAxesTitles, SIGNAL(toggled(bool)),
- this, SLOT(updateViewOptions()));
+ this->Internal->GenerateAxesTitles, SIGNAL(toggled(bool)),
+ this, SLOT(updateViewOptions()));
QObject::connect(this->Internal->SettingsModel, SIGNAL(redrawChart()),
- this, SLOT(updateViewOptions()));
+ this, SLOT(updateViewOptions()));
resetUnitsControls();
this->setDisplay(display);
QObject::connect(&this->Internal->Links, SIGNAL(qtWidgetChanged()),
- this, SLOT(reloadSeries()), Qt::QueuedConnection);
+ this, SLOT(reloadSeries()), Qt::QueuedConnection);
QObject::connect(&this->Internal->Links, SIGNAL(qtWidgetChanged()),
- this->Internal->SettingsModel, SLOT(reload()));
+ this->Internal->SettingsModel, SLOT(reload()));
}
//-----------------------------------------------------------------------------
void pqCustomXYChartDisplayPanel::reloadSeries()
{
updateViewOptions();
-
+
this->updateAllViews();
this->updateOptionsWidgets();
}
this->setEnabled(false);
vtkSMChartRepresentationProxy* proxy =
- vtkSMChartRepresentationProxy::SafeDownCast(disp->getProxy());
+ vtkSMChartRepresentationProxy::SafeDownCast(disp->getProxy());
this->Internal->ChartRepresentation = proxy;
if (!this->Internal->ChartRepresentation)
- {
+ {
qWarning() << "pqCustomXYChartDisplayPanel given a representation proxy "
- "that is not an XYChartRepresentation. Cannot edit.";
+ "that is not an XYChartRepresentation. Cannot edit.";
return;
- }
+ }
// this is essential to ensure that when you undo-redo, the representation is
// indeed update-to-date, thus ensuring correct domains etc.
// Link to set whether the index is used for the x axis
this->Internal->Links.addPropertyLink(
- this->Internal->UseArrayIndex, "checked",
- SIGNAL(toggled(bool)),
- proxy, proxy->GetProperty("UseIndexForXAxis"));
+ this->Internal->UseArrayIndex, "checked",
+ SIGNAL(toggled(bool)),
+ proxy, proxy->GetProperty("UseIndexForXAxis"));
// Proxy changed
this->Internal->VTKConnect->Connect(proxy->GetProperty("SeriesNamesInfo"),
- vtkCommand::PropertyModifiedEvent, this, SLOT(resetUnitsControls()));
+ vtkCommand::PropertyModifiedEvent, this, SLOT(resetUnitsControls()));
this->changeDialog(disp);
void pqCustomXYChartDisplayPanel::changeDialog(pqRepresentation* disp)
{
vtkSMChartRepresentationProxy* proxy =
- vtkSMChartRepresentationProxy::SafeDownCast(disp->getProxy());
+ vtkSMChartRepresentationProxy::SafeDownCast(disp->getProxy());
bool visible = true;
if (QString("Bar") == vtkSMPropertyHelper(proxy,"ChartType").GetAsString())
- {
- visible = false;
- }
-
+ {
+ visible = false;
+ }
+
this->Internal->Thickness->setVisible(visible);
this->Internal->ThicknessLabel->setVisible(visible);
this->Internal->StyleList->setVisible(visible);
{
if(!this->Internal->ChartRepresentation
|| !index.isValid() || index.column() != 1)
- {
+ {
// We are interested in clicks on the color swab alone.
return;
- }
+ }
// Get current color
QColor color = this->Internal->SettingsModel->getSeriesColor(index.row());
// Show color selector dialog to get a new color
color = QColorDialog::getColor(color, this);
if (color.isValid())
- {
+ {
// Set the new color
this->Internal->SettingsModel->setSeriesColor(index.row(), color);
this->Internal->ColorButton->blockSignals(true);
this->Internal->ColorButton->setChosenColor(color);
this->Internal->ColorButton->blockSignals(false);
this->updateAllViews();
- }
+ }
}
//-----------------------------------------------------------------------------
{
QItemSelectionModel *model = this->Internal->SeriesList->selectionModel();
if(model)
- {
+ {
// Show the options for the current item.
QModelIndex current = model->currentIndex();
QModelIndexList indexes = model->selectedIndexes();
if((!current.isValid() || !model->isSelected(current)) &&
indexes.size() > 0)
- {
+ {
current = indexes.last();
- }
+ }
this->Internal->ColorButton->blockSignals(true);
this->Internal->Thickness->blockSignals(true);
this->Internal->MarkerStyleList->blockSignals(true);
this->Internal->AxisList->blockSignals(true);
if (current.isValid())
- {
+ {
int seriesIndex = current.row();
QColor color = this->Internal->SettingsModel->getSeriesColor(seriesIndex);
this->Internal->ColorButton->setChosenColor(color);
this->Internal->Thickness->setValue(
- this->Internal->SettingsModel->getSeriesThickness(seriesIndex));
+ this->Internal->SettingsModel->getSeriesThickness(seriesIndex));
this->Internal->StyleList->setCurrentIndex(
- this->Internal->SettingsModel->getSeriesStyle(seriesIndex));
+ this->Internal->SettingsModel->getSeriesStyle(seriesIndex));
this->Internal->MarkerStyleList->setCurrentIndex(
- this->Internal->SettingsModel->getSeriesMarkerStyle(seriesIndex));
+ this->Internal->SettingsModel->getSeriesMarkerStyle(seriesIndex));
this->Internal->AxisList->setCurrentIndex(
- this->Internal->SettingsModel->getSeriesAxisCorner(seriesIndex));
- }
+ this->Internal->SettingsModel->getSeriesAxisCorner(seriesIndex));
+ }
else
- {
+ {
this->Internal->ColorButton->setChosenColor(Qt::white);
this->Internal->Thickness->setValue(1);
this->Internal->StyleList->setCurrentIndex(0);
this->Internal->MarkerStyleList->setCurrentIndex(0);
this->Internal->AxisList->setCurrentIndex(0);
- }
+ }
this->Internal->ColorButton->blockSignals(false);
this->Internal->Thickness->blockSignals(false);
this->Internal->StyleList->setEnabled(hasItems);
this->Internal->MarkerStyleList->setEnabled(hasItems);
this->Internal->AxisList->setEnabled(hasItems);
- }
+ }
}
//-----------------------------------------------------------------------------
{
QItemSelectionModel *model = this->Internal->SeriesList->selectionModel();
if(model)
- {
+ {
this->Internal->InChange = true;
QModelIndexList indexes = model->selectedIndexes();
QModelIndexList::Iterator iter = indexes.begin();
for( ; iter != indexes.end(); ++iter)
- {
+ {
this->Internal->SettingsModel->setSeriesColor(iter->row(), color);
- }
- this->Internal->InChange = false;
}
+ this->Internal->InChange = false;
+ }
}
//-----------------------------------------------------------------------------
{
QItemSelectionModel *model = this->Internal->SeriesList->selectionModel();
if (model)
- {
+ {
this->Internal->InChange = true;
QModelIndexList indexes = model->selectedIndexes();
QModelIndexList::Iterator iter = indexes.begin();
for( ; iter != indexes.end(); ++iter)
- {
+ {
this->Internal->SettingsModel->setSeriesThickness(iter->row(), thickness);
- }
- this->Internal->InChange = false;
}
+ this->Internal->InChange = false;
+ }
}
//-----------------------------------------------------------------------------
{
QItemSelectionModel *model = this->Internal->SeriesList->selectionModel();
if (model)
- {
+ {
this->Internal->InChange = true;
QModelIndexList indexes = model->selectedIndexes();
QModelIndexList::Iterator iter = indexes.begin();
for( ; iter != indexes.end(); ++iter)
- {
+ {
this->Internal->SettingsModel->setSeriesStyle(iter->row(), style);
- }
- this->Internal->InChange = false;
}
+ this->Internal->InChange = false;
+ }
}
//-----------------------------------------------------------------------------
{
QItemSelectionModel *model = this->Internal->SeriesList->selectionModel();
if (model)
- {
+ {
this->Internal->InChange = true;
QModelIndexList indexes = model->selectedIndexes();
QModelIndexList::Iterator iter = indexes.begin();
for( ; iter != indexes.end(); ++iter)
- {
+ {
this->Internal->SettingsModel->setSeriesMarkerStyle(iter->row(), style);
- }
- this->Internal->InChange = false;
}
+ this->Internal->InChange = false;
+ }
}
//-----------------------------------------------------------------------------
this->Internal->AutoSelect->setEnabled(!checked);
this->Internal->SettingsModel->SetIgnoreUnitsModeOn(checked);
this->Internal->SettingsModel->SetAutoSelectModeOn(!checked &&
- this->Internal->AutoSelect->isChecked());
+ this->Internal->AutoSelect->isChecked());
}
//-----------------------------------------------------------------------------
{
pqRepresentation* disp = this->getRepresentation();
if (!disp || !this->Internal->ChartRepresentation)
+ {
+ return;
+ }
+
+ pqXYChartView* view = qobject_cast<pqXYChartView*>(disp->getView());
+ if (view && view->getProxy())
+ {
+ vtkSMProxy* proxy = view->getProxy();
+
+ QList<QVariant> values =
+ pqSMAdaptor::getMultipleElementProperty(proxy->GetProperty("AxisTitle"));
+ if (values.size() < 2)
{
return;
}
- pqXYChartView* view = qobject_cast<pqXYChartView*>(disp->getView());
- if (view && view->getProxy())
+ if (!this->Internal->GenerateAxesTitles->isChecked())
{
- vtkSMProxy* proxy = view->getProxy();
-
- QList<QVariant> values =
- pqSMAdaptor::getMultipleElementProperty(proxy->GetProperty("AxisTitle"));
- if (values.size() < 2)
- {
- return;
- }
-
- if (!this->Internal->GenerateAxesTitles->isChecked())
- {
- values.insert(0, QVariant(""));
- values.insert(1, QVariant(""));
- }
- else
- {
- // Set X axis title
- int useIndexForXAxis = vtkSMPropertyHelper(
- this->Internal->ChartRepresentation, "UseIndexForXAxis").GetAsInt();
-
- QString xTitle("");
- if (!useIndexForXAxis)
- {
- xTitle = vtkSMPropertyHelper(this->Internal->ChartRepresentation, "XArrayName")
- .GetAsString();
- }
-
- // Set Y axis title
- int nbRows = this->Internal->SettingsModel->rowCount(QModelIndex());
- int nbEnabled = 0;
- int row = 0;
- for (int i = 0; i < nbRows && nbEnabled < 2; i++)
- {
- if (this->Internal->SettingsModel->getSeriesEnabled(i))
- {
- nbEnabled++;
- row = i;
- }
- }
-
- QString yTitle("");
- if (nbEnabled == 1)
- {
- yTitle = this->Internal->SettingsModel->getSeriesName(row);
- }
- values.insert(0, QVariant(yTitle));
- values.insert(1, QVariant(xTitle));
- }
-
- pqSMAdaptor::setMultipleElementProperty(proxy->GetProperty("AxisTitle"), values);
-
- view->getProxy()->UpdateVTKObjects();
- view->render();
+ values.insert(0, QVariant(""));
+ values.insert(1, QVariant(""));
+ }
+ else
+ {
+ // Set X axis title
+ int useIndexForXAxis = vtkSMPropertyHelper(
+ this->Internal->ChartRepresentation, "UseIndexForXAxis").GetAsInt();
+
+ QString xTitle("");
+ if (!useIndexForXAxis)
+ {
+ xTitle = vtkSMPropertyHelper(this->Internal->ChartRepresentation, "XArrayName").GetAsString();
+ }
+
+ // Set Y axis title
+ int nbRows = this->Internal->SettingsModel->rowCount(QModelIndex());
+ int nbEnabled = 0;
+ int row = 0;
+ for (int i = 0; i < nbRows && nbEnabled < 2; i++)
+ {
+ if (this->Internal->SettingsModel->getSeriesEnabled(i))
+ {
+ nbEnabled++;
+ row = i;
+ }
+ }
+
+ QString yTitle("");
+ if (nbEnabled == 1)
+ {
+ yTitle = this->Internal->SettingsModel->getSeriesName(row);
+ }
+ values.insert(0, QVariant(yTitle));
+ values.insert(1, QVariant(xTitle));
}
+
+ pqSMAdaptor::setMultipleElementProperty(proxy->GetProperty("AxisTitle"), values);
+
+ view->getProxy()->UpdateVTKObjects();
+ view->render();
+ }
}
{
public:
pqUI(pqTableReaderPanel* p) : QObject(p)
- {
- }
+{
+}
~pqUI()
{
pqTableReaderPanel::pqTableReaderPanel(pqProxy* proxy, QWidget* p) :
- Superclass(proxy, p)
+ Superclass(proxy, p)
{
this->UI = new pqUI(this);
this->UI->setupUi(this);
-
+
this->linkServerManagerProperties();
this->updateAvailableTables(false);
this->connect(this->UI->ValueDelimiter, SIGNAL(textChanged(const QString&)),
- this, SLOT(onDelimiterChanged(const QString&)));
+ this, SLOT(onDelimiterChanged(const QString&)));
this->connect(this->UI->TableNames, SIGNAL(currentIndexChanged(int)),
- this, SLOT(onCurrentTableChanged(int)));
+ this, SLOT(onCurrentTableChanged(int)));
}
pqTableReaderPanel::~pqTableReaderPanel()
void pqTableReaderPanel::linkServerManagerProperties()
{
this->UI->Links.addPropertyLink(this->UI->TableNames, "currentIndex",
- SIGNAL(currentIndexChanged(int)), this->proxy(),
- this->proxy()->GetProperty("TableNumber"));
+ SIGNAL(currentIndexChanged(int)), this->proxy(),
+ this->proxy()->GetProperty("TableNumber"));
// To hook up the rest widgets
this->Superclass::linkServerManagerProperties();
void pqTableReaderPanel::updateAvailableTables(const bool keepCurrent)
{
vtkSMStringVectorProperty* prop = vtkSMStringVectorProperty::SafeDownCast(
- this->proxy()->GetProperty("AvailableTables"));
-
+ this->proxy()->GetProperty("AvailableTables"));
+
int currentIndex = this->UI->TableNames->currentIndex();
QString currentText = this->UI->TableNames->currentText();
this->UI->TableNames->clear();
-
+
for(int id = 0; id < prop->GetNumberOfElements(); id++)
+ {
+ QString text(prop->GetElement(id));
+ if (text.isEmpty())
{
- QString text(prop->GetElement(id));
- if (text.isEmpty())
- {
- text = QString("Table:%1").arg(id);
- }
- this->UI->TableNames->addItem(text);
+ text = QString("Table:%1").arg(id);
}
+ this->UI->TableNames->addItem(text);
+ }
if (keepCurrent &&
currentIndex < this->UI->TableNames->maxCount() &&
currentText == this->UI->TableNames->itemText(currentIndex))
- {
- this->UI->TableNames->setCurrentIndex(currentIndex);
- }
+ {
+ this->UI->TableNames->setCurrentIndex(currentIndex);
+ }
}
#include <QComboBox>
pqTableTo3DPanel::pqTableTo3DPanel(pqProxy* proxy, QWidget* p) :
- Superclass(proxy, p)
+Superclass(proxy, p)
{
QLineEdit* scaleFactor = this->findChild<QLineEdit*>("ScaleFactor");
QCheckBox* useOptimusScale = this->findChild<QCheckBox*>("UseOptimusScale");
QComboBox* presentationType = this->findChild<QComboBox*>("PresentationType");
QWidget* numberContours = this->findChild<QWidget*>("NumberOfContours");
-
+
if (scaleFactor && useOptimusScale)
- {
- this->connect(useOptimusScale, SIGNAL(toggled(bool)),
- this, SLOT(onScaleModeChanged(bool)));
- onScaleModeChanged(useOptimusScale->isChecked());
- }
+ {
+ this->connect(useOptimusScale, SIGNAL(toggled(bool)),
+ this, SLOT(onScaleModeChanged(bool)));
+ onScaleModeChanged(useOptimusScale->isChecked());
+ }
if (presentationType && numberContours)
- {
- this->connect(presentationType, SIGNAL(currentIndexChanged(const QString &)),
- this, SLOT(onPrsTypeChanged(const QString &)));
- onPrsTypeChanged(presentationType->currentText());
- }
+ {
+ this->connect(presentationType, SIGNAL(currentIndexChanged(const QString &)),
+ this, SLOT(onPrsTypeChanged(const QString &)));
+ onPrsTypeChanged(presentationType->currentText());
+ }
}
pqTableTo3DPanel::~pqTableTo3DPanel()
{
QLineEdit* scaleFactor = this->findChild<QLineEdit*>("ScaleFactor");
if (scaleFactor)
- {
- scaleFactor->setEnabled(!checked);
- }
+ {
+ scaleFactor->setEnabled(!checked);
+ }
}
void pqTableTo3DPanel::onPrsTypeChanged(const QString& type)
{
QWidget* numberContours = this->findChild<QWidget*>("NumberOfContours");
if (numberContours)
- {
- numberContours->setEnabled(type == "Contour");
- }
+ {
+ numberContours->setEnabled(type == "Contour");
+ }
}
{
char tmp;
std::ostringstream streamOut;
-
+
while (streamIn.get(tmp)) {
streamOut<<tmp;
if (tmp == '\n')
break;
}
-
+
streamOut<<std::ends;
str = streamOut.str().c_str();
-
+
return !streamIn.eof();
}
int iEnd = myRows[0].myValues.size();
if (iEnd == 0)
- {
- return false;
- }
+ {
+ return false;
+ }
if (myColumnTitles.size() != iEnd)
- {
- myColumnTitles.resize(iEnd);
- }
+ {
+ myColumnTitles.resize(iEnd);
+ }
if (myColumnUnits.size() != iEnd)
- {
- myColumnUnits.resize(iEnd);
- }
+ {
+ myColumnUnits.resize(iEnd);
+ }
int jEnd = myRows.size();
for (int j = 0; j < jEnd; j++)
+ {
+ if (myRows[j].myValues.size() != iEnd)
{
- if (myRows[j].myValues.size() != iEnd)
- {
- return false;
- }
+ return false;
}
-
+ }
+
return true;
}
std::vector<std::string> GetTableNames(const char* fname, const char* separator,
- const bool firstStringAsTitles)
-{
+ const bool firstStringAsTitles)
+ {
Table2D table;
std::vector<std::string> tableTitles;
tableTitles.push_back(table.myTitle);
table = GetTable(fname, separator, ++nb, firstStringAsTitles);
}
-
+
return tableTitles;
-}
+ }
Table2D GetTable(const char* fname, const char* separator, const int tableNb,
- const bool firstStringAsTitles)
+ const bool firstStringAsTitles)
{
std::ifstream streamIn(fname);
-
+
if(!streamIn.good())
- {
- throw std::runtime_error("Unable to open input Post-Pro table file.");
- }
-
+ {
+ throw std::runtime_error("Unable to open input Post-Pro table file.");
+ }
+
QString tmp;
int count = 0;
do {
bool isFirst = true;
while (!streamIn.eof() && tmp.trimmed() != "")
+ {
+ QString data = tmp.trimmed();
+ QString cmt = "";
+ QString keyword = "";
+
+ // Split string to data and comment (comment starts from '#' symbol)
+ int index = tmp.indexOf("#");
+ if (index >= 0)
{
- QString data = tmp.trimmed();
- QString cmt = "";
- QString keyword = "";
-
- // Split string to data and comment (comment starts from '#' symbol)
- int index = tmp.indexOf("#");
- if (index >= 0)
- {
- data = tmp.left(index).trimmed();
- cmt = tmp.mid(index+1).trimmed();
- }
-
- // If comment is not empty, try to get keyword from it (separated by ':' symbol)
- if (!cmt.isEmpty())
- {
- int index1 = cmt.indexOf(":");
-
- if (index1 >= 0)
- {
- QString tmpstr = cmt.left(index1).trimmed();
- if (tmpstr == QString("TITLE") ||
- tmpstr == QString("COLUMN_TITLES") ||
- tmpstr == QString("COLUMN_UNITS") ||
- tmpstr == QString("COMMENT"))
- {
- keyword = tmpstr;
- cmt = cmt.mid(index1+1).trimmed();
- }
- }
- }
-
- // If data is empty, process only comment
- if (data.isEmpty())
- {
- // If keyword is found, try to process it
- // elsewise it is a simple comment, just ignore it
- if (!keyword.isEmpty())
- {
- if (keyword == QString( "TITLE" ))
- {
- QString title = cmt;
- if (table2D.myTitle != "") {
- title = QString(table2D.myTitle.c_str()) + QString(" ") + title;
- }
- table2D.myTitle = title.toLatin1().constData();
- }
- else if (keyword == QString("COLUMN_TITLES"))
- {
- // Comment may contain column headers
- QStringList strList = cmt.split("|", QString::SkipEmptyParts);
-
- for ( int i = 0; i < strList.count(); i++ )
- {
- QString tmpstr = strList[i].trimmed();
- table2D.myColumnTitles.push_back(tmpstr.toLatin1().constData());
- }
- }
- else if (keyword == QString("COLUMN_UNITS"))
- {
- // Comment may contain column units
- QStringList strList = cmt.split( " ", QString::SkipEmptyParts );
-
- for (int i = 0; i < strList.count(); i++)
- {
- QString tmpstr = strList[i].trimmed();
- table2D.myColumnUnits.push_back(tmpstr.toLatin1().constData());
- }
- }
- else if (keyword == QString("COMMENT"))
- {
- // Keyword 'COMMENT' processing can be here,
- // currently it is ignored
- }
- }
- else {
- // Simple comment processing can be here,
- // currently it is ignored
- }
- }
- // If data is not empty, try to process it
- else {
- Table2D::Row row;
-
- QString datar1 = data.replace(QRegExp("\t"), " ");
- QStringList valList = datar1.split(separator, QString::SkipEmptyParts);
- if(table2D.myColumnTitles.size() == 0 && isFirst && firstStringAsTitles)
- {
- for ( int i = 0; i < valList.count(); i++ )
- {
- QString tmpstr = valList[i].trimmed();
- table2D.myColumnTitles.push_back(tmpstr.toLatin1().constData());
- }
- }
- else
- {
- if (!cmt.isEmpty())
- {
- row.myTitle = cmt.toLatin1().constData();
- }
-
- for (int i = 0; i < valList.count(); i++)
- {
- if (valList[i].trimmed() != "")
- {
- Table2D::Value val = valList[i].trimmed().toLatin1().constData();
- row.myValues.push_back(val);
- }
- }
-
- if(row.myValues.size() > 0)
- {
- table2D.myRows.push_back(row);
- }
- }
-
- isFirst = false;
- }
- getLine(streamIn, tmp);
+ data = tmp.left(index).trimmed();
+ cmt = tmp.mid(index+1).trimmed();
+ }
+
+ // If comment is not empty, try to get keyword from it (separated by ':' symbol)
+ if (!cmt.isEmpty())
+ {
+ int index1 = cmt.indexOf(":");
+
+ if (index1 >= 0)
+ {
+ QString tmpstr = cmt.left(index1).trimmed();
+ if (tmpstr == QString("TITLE") ||
+ tmpstr == QString("COLUMN_TITLES") ||
+ tmpstr == QString("COLUMN_UNITS") ||
+ tmpstr == QString("COMMENT"))
+ {
+ keyword = tmpstr;
+ cmt = cmt.mid(index1+1).trimmed();
+ }
+ }
}
-
-
+
+ // If data is empty, process only comment
+ if (data.isEmpty())
+ {
+ // If keyword is found, try to process it
+ // elsewise it is a simple comment, just ignore it
+ if (!keyword.isEmpty())
+ {
+ if (keyword == QString( "TITLE" ))
+ {
+ QString title = cmt;
+ if (table2D.myTitle != "") {
+ title = QString(table2D.myTitle.c_str()) + QString(" ") + title;
+ }
+ table2D.myTitle = title.toLatin1().constData();
+ }
+ else if (keyword == QString("COLUMN_TITLES"))
+ {
+ // Comment may contain column headers
+ QStringList strList = cmt.split("|", QString::SkipEmptyParts);
+
+ for ( int i = 0; i < strList.count(); i++ )
+ {
+ QString tmpstr = strList[i].trimmed();
+ table2D.myColumnTitles.push_back(tmpstr.toLatin1().constData());
+ }
+ }
+ else if (keyword == QString("COLUMN_UNITS"))
+ {
+ // Comment may contain column units
+ QStringList strList = cmt.split( " ", QString::SkipEmptyParts );
+
+ for (int i = 0; i < strList.count(); i++)
+ {
+ QString tmpstr = strList[i].trimmed();
+ table2D.myColumnUnits.push_back(tmpstr.toLatin1().constData());
+ }
+ }
+ else if (keyword == QString("COMMENT"))
+ {
+ // Keyword 'COMMENT' processing can be here,
+ // currently it is ignored
+ }
+ }
+ else {
+ // Simple comment processing can be here,
+ // currently it is ignored
+ }
+ }
+ // If data is not empty, try to process it
+ else {
+ Table2D::Row row;
+
+ QString datar1 = data.replace(QRegExp("\t"), " ");
+ QStringList valList = datar1.split(separator, QString::SkipEmptyParts);
+ if(table2D.myColumnTitles.size() == 0 && isFirst && firstStringAsTitles)
+ {
+ for ( int i = 0; i < valList.count(); i++ )
+ {
+ QString tmpstr = valList[i].trimmed();
+ table2D.myColumnTitles.push_back(tmpstr.toLatin1().constData());
+ }
+ }
+ else
+ {
+ if (!cmt.isEmpty())
+ {
+ row.myTitle = cmt.toLatin1().constData();
+ }
+
+ for (int i = 0; i < valList.count(); i++)
+ {
+ if (valList[i].trimmed() != "")
+ {
+ Table2D::Value val = valList[i].trimmed().toLatin1().constData();
+ row.myValues.push_back(val);
+ }
+ }
+
+ if(row.myValues.size() > 0)
+ {
+ table2D.myRows.push_back(row);
+ }
+ }
+
+ isFirst = false;
+ }
+ getLine(streamIn, tmp);
+ }
+
+
if(table2D.Check())
+ {
+ if (count == tableNb)
{
- if (count == tableNb)
- {
- if (QString::fromStdString(table2D.myTitle).isEmpty())
- {
- table2D.myTitle = QString("Table:%1").arg(tableNb).toStdString();
- }
- return table2D;
- }
- count++;
+ if (QString::fromStdString(table2D.myTitle).isEmpty())
+ {
+ table2D.myTitle = QString("Table:%1").arg(tableNb).toStdString();
+ }
+ return table2D;
}
-
+ count++;
+ }
+
} while (!streamIn.eof());
-
+
streamIn.close();
-
+
// Return empty table
Table2D emptyTable;
return emptyTable;
};
std::vector<std::string> GetTableNames(const char* fname, const char* separator,
- const bool firstStringAsTitles);
+ const bool firstStringAsTitles);
Table2D GetTable(const char* fname, const char* separator, const int tableNb,
- const bool firstStringAsTitles);
+ const bool firstStringAsTitles);
#endif //__TableParser_h_
vtkStandardNewMacro(vtkVisuTableReader);
vtkVisuTableReader::vtkVisuTableReader():
- FileName(0)
+ FileName(0)
{
this->SetNumberOfInputPorts(0);
this->SetNumberOfOutputPorts(1);
this->FileName = NULL;
-
+
this->DetectNumericColumns = true;
this->FirstStringAsTitles = false;
this->ValueDelimiter = 0;
this->SetValueDelimiter(" ");
-
+
this->AvailableTables = vtkStringArray::New();
}
{
this->Superclass::PrintSelf(os, indent);
os << indent << "FileName: "
- << (this->FileName ? this->FileName : "(none)") << endl;
+ << (this->FileName ? this->FileName : "(none)") << endl;
os << indent << "DetectNumericColumns: "
- << (this->DetectNumericColumns? "true" : "false") << endl;
+ << (this->DetectNumericColumns? "true" : "false") << endl;
os << indent << "ValueDelimiter: "
- << (this->ValueDelimiter ? this->ValueDelimiter : "(none)") << endl;
+ << (this->ValueDelimiter ? this->ValueDelimiter : "(none)") << endl;
os << indent << "TableNumber: " << this->TableNumber<< endl;
}
int vtkVisuTableReader::RequestData(vtkInformation*,
- vtkInformationVector**,
- vtkInformationVector* outputVector)
+ vtkInformationVector**,
+ vtkInformationVector* outputVector)
{
vtkTable* const output_table = vtkTable::GetData(outputVector);
try
+ {
+ vtkInformation* const outInfo = outputVector->GetInformationObject(0);
+ if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) &&
+ outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) > 0)
{
- vtkInformation* const outInfo = outputVector->GetInformationObject(0);
- if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) &&
- outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) > 0)
- {
- return 1;
- }
-
- // If the filename is not defined
- if(!this->FileName || this->TableNumber < 0)
- {
- return 1;
- }
-
- // Read table with the given number from the file
- Table2D table = GetTable(this->FileName, this->ValueDelimiter,
- this->TableNumber, this->FirstStringAsTitles);
-
- // Set table name
- output_table->GetInformation()->Set(vtkDataObject::FIELD_NAME(),
- table.myTitle.c_str());
-
- int nbRows = table.myRows.size();
- int nbCols = table.myRows[0].myValues.size();
-
- for (int col=0; col < nbCols; col++)
- {
- vtkStringArray* newCol = vtkStringArray::New();
- newCol->SetNumberOfValues(nbRows);
-
- // Set value
- for (int row=0; row < nbRows; row++)
- {
- newCol->SetValue(row, table.myRows[row].myValues[col].c_str());
- }
-
- // Set title
- bool hasUnit = !table.myColumnUnits[col].empty();
-
- if (table.myColumnTitles[col].empty())
- {
- vtksys_ios::stringstream buffer;
- if (hasUnit)
- {
- buffer << col <<" [" << table.myColumnUnits[col].c_str() << "]";
- }
- else
- {
- buffer << col;
- }
- newCol->SetName(buffer.str().c_str());
- }
- else
- {
- if (hasUnit)
- {
- vtksys_ios::stringstream buffer;
- buffer << table.myColumnTitles[col].c_str()
- <<" [" << table.myColumnUnits[col].c_str() << "]";
- newCol->SetName(buffer.str().c_str());
- }
- else
- {
- newCol->SetName(table.myColumnTitles[col].c_str());
- }
- }
-
- output_table->AddColumn(newCol);
- newCol->Delete();
- }
-
- // Detect numeric columns if needed
- if (this->DetectNumericColumns)
- {
- vtkStringToNumeric* convertor = vtkStringToNumeric::New();
- vtkTable* clone = output_table->NewInstance();
- clone->ShallowCopy(output_table);
- convertor->SetInputData(clone);
- convertor->Update();
- clone->Delete();
- output_table->ShallowCopy(convertor->GetOutputDataObject(0));
- convertor->Delete();
- }
- }
- catch(vtksys_stl::exception& e)
+ return 1;
+ }
+
+ // If the filename is not defined
+ if(!this->FileName || this->TableNumber < 0)
{
- vtkErrorMacro(<< "caught exception: " << e.what() << endl);
- output_table->Initialize();
+ return 1;
}
- catch(...)
+
+ // Read table with the given number from the file
+ Table2D table = GetTable(this->FileName, this->ValueDelimiter,
+ this->TableNumber, this->FirstStringAsTitles);
+
+ // Set table name
+ output_table->GetInformation()->Set(vtkDataObject::FIELD_NAME(),
+ table.myTitle.c_str());
+
+ int nbRows = table.myRows.size();
+ int nbCols = table.myRows[0].myValues.size();
+
+ for (int col=0; col < nbCols; col++)
{
- vtkErrorMacro(<< "caught unknown exception." << endl);
- output_table->Initialize();
+ vtkStringArray* newCol = vtkStringArray::New();
+ newCol->SetNumberOfValues(nbRows);
+
+ // Set value
+ for (int row=0; row < nbRows; row++)
+ {
+ newCol->SetValue(row, table.myRows[row].myValues[col].c_str());
+ }
+
+ // Set title
+ bool hasUnit = !table.myColumnUnits[col].empty();
+
+ if (table.myColumnTitles[col].empty())
+ {
+ vtksys_ios::stringstream buffer;
+ if (hasUnit)
+ {
+ buffer << col <<" [" << table.myColumnUnits[col].c_str() << "]";
+ }
+ else
+ {
+ buffer << col;
+ }
+ newCol->SetName(buffer.str().c_str());
+ }
+ else
+ {
+ if (hasUnit)
+ {
+ vtksys_ios::stringstream buffer;
+ buffer << table.myColumnTitles[col].c_str()
+ <<" [" << table.myColumnUnits[col].c_str() << "]";
+ newCol->SetName(buffer.str().c_str());
+ }
+ else
+ {
+ newCol->SetName(table.myColumnTitles[col].c_str());
+ }
+ }
+
+ output_table->AddColumn(newCol);
+ newCol->Delete();
}
-
+
+ // Detect numeric columns if needed
+ if (this->DetectNumericColumns)
+ {
+ vtkStringToNumeric* convertor = vtkStringToNumeric::New();
+ vtkTable* clone = output_table->NewInstance();
+ clone->ShallowCopy(output_table);
+ convertor->SetInputData(clone);
+ convertor->Update();
+ clone->Delete();
+ output_table->ShallowCopy(convertor->GetOutputDataObject(0));
+ convertor->Delete();
+ }
+ }
+ catch(vtksys_stl::exception& e)
+ {
+ vtkErrorMacro(<< "caught exception: " << e.what() << endl);
+ output_table->Initialize();
+ }
+ catch(...)
+ {
+ vtkErrorMacro(<< "caught unknown exception." << endl);
+ output_table->Initialize();
+ }
+
return 1;
}
vtkStringArray* vtkVisuTableReader::GetAvailableTables()
{
this->AvailableTables->Initialize();
-
+
vector<string> titles =
- GetTableNames(this->FileName, this->ValueDelimiter,
- this->FirstStringAsTitles);
-
+ GetTableNames(this->FileName, this->ValueDelimiter,
+ this->FirstStringAsTitles);
+
for(int i = 0; i < titles.size(); i++)
- {
- this->AvailableTables->InsertNextValue(titles[i].c_str());
- }
-
+ {
+ this->AvailableTables->InsertNextValue(titles[i].c_str());
+ }
+
return this->AvailableTables;
}
}
int vtkTableTo3D::FillInputPortInformation(
- int vtkNotUsed(port), vtkInformation* info)
+ int vtkNotUsed(port), vtkInformation* info)
{
info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkTable");
return 1;
}
int vtkTableTo3D::RequestData(vtkInformation* vtkNotUsed(request),
- vtkInformationVector** inputVector, vtkInformationVector* outputVector)
+ vtkInformationVector** inputVector, vtkInformationVector* outputVector)
{
vtkTable* input = vtkTable::GetData(inputVector[0], 0);
vtkPolyData* output = vtkPolyData::GetData(outputVector, 0);
if (input->GetNumberOfRows() == 0 ||input->GetNumberOfColumns() < 2)
- {
- return 1;
- }
-
+ {
+ return 1;
+ }
+
vtkIdType xSize = input->GetNumberOfRows();
vtkIdType ySize = input->GetNumberOfColumns() - 1;
vtkIdType nbPoints = xSize * ySize;
vtkDataArray* xAxis = vtkDataArray::SafeDownCast(input->GetColumn(0));
if (!xAxis)
- {
- vtkErrorMacro("The first column is not numeric.");
- return 1;
- }
-
+ {
+ vtkErrorMacro("The first column is not numeric.");
+ return 1;
+ }
+
double xRange = xAxis->GetTuple1(xSize - 1) - xAxis->GetTuple1(0);
double yDelta = xRange / ySize;
-
+
vtkSmartPointer<vtkDoubleArray> yAxis =
- vtkSmartPointer<vtkDoubleArray>::New();
+ vtkSmartPointer<vtkDoubleArray>::New();
yAxis->SetNumberOfValues(ySize);
for (vtkIdType i = 0; i < ySize; i++ )
- {
- yAxis->SetValue(i, i*yDelta);
- }
+ {
+ yAxis->SetValue(i, i*yDelta);
+ }
vtkSmartPointer<vtkPoints> points =
- vtkSmartPointer<vtkPoints>::New();
+ vtkSmartPointer<vtkPoints>::New();
points->SetNumberOfPoints(nbPoints);
vtkSmartPointer<vtkIntArray> pointsIdMapper =
- vtkSmartPointer<vtkIntArray>::New();
+ vtkSmartPointer<vtkIntArray>::New();
pointsIdMapper->SetName("POINTS_ID_MAPPER");
pointsIdMapper->SetNumberOfComponents(2);
pointsIdMapper->SetNumberOfTuples(nbPoints);
int *pointsIdMapperPtr = pointsIdMapper->GetPointer(0);
for (vtkIdType i = 0, pntId = 0; i < ySize; i++)
+ {
+ for (vtkIdType j = 0; j < xSize; j++, pntId++)
{
- for (vtkIdType j = 0; j < xSize; j++, pntId++)
- {
- points->SetPoint(pntId, xAxis->GetTuple1(j),
- yAxis->GetValue(i),
- 0.0);
-
- *pointsIdMapperPtr++ = pntId;
- *pointsIdMapperPtr++ = 0;
- }
+ points->SetPoint(pntId, xAxis->GetTuple1(j),
+ yAxis->GetValue(i),
+ 0.0);
+
+ *pointsIdMapperPtr++ = pntId;
+ *pointsIdMapperPtr++ = 0;
}
+ }
vtkSmartPointer<vtkDoubleArray> scalars =
- vtkSmartPointer<vtkDoubleArray>::New();
+ vtkSmartPointer<vtkDoubleArray>::New();
scalars->SetNumberOfComponents(1);
scalars->SetNumberOfTuples(nbPoints);
double *scalarsPtr = scalars->GetPointer(0);
for (vtkIdType i = 0; i < ySize; i++)
+ {
+ vtkDataArray* col =
+ vtkDataArray::SafeDownCast(input->GetColumn(i + 1));
+
+ if (!col)
+ {
+ vtkErrorMacro("Column "<< i <<"is not numeric.");
+ return 1;
+ }
+
+ for ( vtkIdType j = 0; j < xSize; j++ )
{
- vtkDataArray* col =
- vtkDataArray::SafeDownCast(input->GetColumn(i + 1));
-
- if (!col)
- {
- vtkErrorMacro("Column "<< i <<"is not numeric.");
- return 1;
- }
-
- for ( vtkIdType j = 0; j < xSize; j++ )
- {
- double value = col->GetTuple1(j);
- *scalarsPtr++ = value;
- }
+ double value = col->GetTuple1(j);
+ *scalarsPtr++ = value;
}
+ }
vtkSmartPointer<vtkStructuredGrid> structuredGrid =
- vtkSmartPointer<vtkStructuredGrid>::New();
+ vtkSmartPointer<vtkStructuredGrid>::New();
structuredGrid->SetPoints(points);
structuredGrid->SetDimensions(xSize, ySize, 1);
// structuredGrid->GetPointData()->AddArray(pointsIdMapper);
if (input->GetInformation()->Has(vtkDataObject::FIELD_NAME()))
- {
- scalars->SetName(input->GetInformation()->Get(vtkDataObject::FIELD_NAME()));
- }
+ {
+ scalars->SetName(input->GetInformation()->Get(vtkDataObject::FIELD_NAME()));
+ }
else
- {
- scalars->SetName("Table");
- }
+ {
+ scalars->SetName("Table");
+ }
structuredGrid->GetPointData()->SetScalars(scalars);
vtkSmartPointer<vtkStructuredGridGeometryFilter> geomFilter =
- vtkSmartPointer<vtkStructuredGridGeometryFilter>::New();
+ vtkSmartPointer<vtkStructuredGridGeometryFilter>::New();
geomFilter->SetInputData(structuredGrid);
geomFilter->Update();
-
+
vtkSmartPointer<vtkWarpScalar> warpScalar =
- vtkSmartPointer<vtkWarpScalar>::New();
-
+ vtkSmartPointer<vtkWarpScalar>::New();
+
double scaleFactor = this->ScaleFactor;
if (this->UseOptimusScale)
+ {
+ double range[2];
+ geomFilter->GetOutput()->GetScalarRange(range);
+ double length = geomFilter->GetOutput()->GetLength();
+ if (range[1] > 0)
{
- double range[2];
- geomFilter->GetOutput()->GetScalarRange(range);
- double length = geomFilter->GetOutput()->GetLength();
- if (range[1] > 0)
- {
- scaleFactor = length / range[1] * 0.3;
- }
- else
- {
- scaleFactor = 0;
- }
+ scaleFactor = length / range[1] * 0.3;
}
-
- if (this->PresentationType == TABLETO3D_SURFACE)
+ else
{
- warpScalar->SetInputConnection(geomFilter->GetOutputPort(0));
- warpScalar->SetScaleFactor(scaleFactor);
+ scaleFactor = 0;
}
+ }
+
+ if (this->PresentationType == TABLETO3D_SURFACE)
+ {
+ warpScalar->SetInputConnection(geomFilter->GetOutputPort(0));
+ warpScalar->SetScaleFactor(scaleFactor);
+ }
else
- {
- vtkSmartPointer<vtkContourFilter> contourFilter =
- vtkSmartPointer<vtkContourFilter>::New();
- contourFilter->SetInputConnection(geomFilter->GetOutputPort(0));
- contourFilter->GenerateValues(this->NumberOfContours,
- geomFilter->GetOutput()->GetScalarRange());
- warpScalar->SetInputConnection(contourFilter->GetOutputPort(0));
- warpScalar->SetScaleFactor(scaleFactor);
- }
+ {
+ vtkSmartPointer<vtkContourFilter> contourFilter =
+ vtkSmartPointer<vtkContourFilter>::New();
+ contourFilter->SetInputConnection(geomFilter->GetOutputPort(0));
+ contourFilter->GenerateValues(this->NumberOfContours,
+ geomFilter->GetOutput()->GetScalarRange());
+ warpScalar->SetInputConnection(contourFilter->GetOutputPort(0));
+ warpScalar->SetScaleFactor(scaleFactor);
+ }
warpScalar->Update();
output->ShallowCopy(warpScalar->GetPolyDataOutput());
-
+
return 1;
}
os << indent << "ScaleFactor: " << this->ScaleFactor << endl;
os << indent << "UseOptimusScale: "
- << (this->UseOptimusScale? "true" : "false") << endl;
+ << (this->UseOptimusScale? "true" : "false") << endl;
os << indent << "PresentationType: "
- << ((this->PresentationType == TABLETO3D_SURFACE)? "Surface" : "Contour")
- << endl;
+ << ((this->PresentationType == TABLETO3D_SURFACE)? "Surface" : "Contour")
+ << endl;
os << indent << "NumberOfContours: " << this->NumberOfContours << endl;
}
// Description:
// Specify type of presentation: surface of contour.
vtkSetClampMacro(PresentationType, int,
- TABLETO3D_SURFACE, TABLETO3D_CONTOUR);
+ TABLETO3D_SURFACE, TABLETO3D_CONTOUR);
vtkGetMacro(PresentationType, int);
// Description: