Hi,
I’m implementing my first custom application using QT, a few objects will be loaded into Paraview using the code and I have to change some properties, like color, size, position, etc.
I loaded the object with this code, it worked and the properties changed, but might crash.
I do not understand how the representation object and the view object work. Should I maintain a view object to load all the things in it? And is there some wrong with my code(except the empty check)?
pqAutoApplyReaction::setAutoApply(true);
QVector<pqPipelineSource *> QSourcePointer = pqLoadDataReaction::loadFilesForSupportedTypes(filelist);
pqDataRepresentation* representation = this->QSourcePointer->getRepresentation(this->QSourcePointer->getViews().at(0));
vtkSMPropertyHelper(representation->getProxy(), "Opacity").Set(0.25);
pqShowHideAllReaction::act(pqShowHideAllReaction::ActionType::Show);
The second thing is that sometimes I get an empty view object after loading one data object, so I can’t change any property of it in the same way.
QString filePath = this->cylinderPath;
if(FileTools::fileExist(filePath)){
QStringList filePathList;
QList<QStringList> fileList;
filePathList << filePath;
//If add the filePath twice, the size of the view object will be 1.
//filePathList << filePath;
fileList << filePathList;
this->QSourcePointer = pqLoadDataReaction::loadFilesForSupportedTypes(fileList);
// empty view object
QList<pqView *> views = QSourcePointer.at(0)->getViews();
pqDataRepresentation* representation = QSourcePointer.at(0)->getRepresentation(views.at(0));
}