Commit fc51ace7 authored by Cedric Robert's avatar Cedric Robert
Browse files

bug fix : issues # 2, 3, 7

destructor management
parent 876e147c
......@@ -17,7 +17,8 @@
#include <exception>
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#ifndef MPICH_IGNORE_CXX_SEEK
#define MPICH_IGNORE_CXX_SEEK
......@@ -37,7 +38,6 @@ Fespp::Fespp()
loadedFile = false;
this->subFileList = vtkDataArraySelection::New();
this->uuidList = vtkDataArraySelection::New();
this->Controller = NULL;
......@@ -53,55 +53,35 @@ Fespp::Fespp()
}
countTest = 0;
vtkEpcDocumentSet = nullptr;
}
//----------------------------------------------------------------------------
Fespp::~Fespp()
{
SetFileName(NULL);
this->SetController(NULL);
for (std::pair<std::string, VtkEpcDocument*> element : vtkEpcDocuments)
delete element.second;
}
//----------------------------------------------------------------------------
int Fespp::GetsubFileListArrayStatus(const char* name)
{
return (this->subFileList->ArrayIsEnabled(name));
}
//----------------------------------------------------------------------------
void Fespp::SetSubFileList(const char* name, int status)
{
if (status)
{
this->subFileList->EnableArray(name);
}
else
{
if (this->subFileList != nullptr)
{
this->subFileList->EnableArray(name);
}
else
this->subFileList = vtkDataArraySelection::New();
SetController(NULL);
fileNameSet.clear();
uuidList->Delete();
idProc = 0;
nbProc = 0;
if (vtkEpcDocumentSet != nullptr) {
delete vtkEpcDocumentSet;
vtkEpcDocumentSet = nullptr;
}
this->subFileList->Modified();
openEpcDocument(name);
this->Modified();
}
//----------------------------------------------------------------------------
int Fespp::GetNumberOfsubFileListArrays()
{
return this->subFileList->GetNumberOfArrays();
countTest = 0;
}
//----------------------------------------------------------------------------
const char* Fespp::GetsubFileListArrayName(int index)
void Fespp::SetSubFileName(const char* name)
{
return this->subFileList->GetArrayName(index);
if (std::find(fileNameSet.begin(), fileNameSet.end(),std::string(name))==fileNameSet.end())
{
fileNameSet.push_back(std::string(name));
openEpcDocument(name);
}
}
//----------------------------------------------------------------------------
......@@ -184,10 +164,13 @@ int Fespp::RequestInformation(
auto extension = stringFileName.substr(lengthFileName -3, lengthFileName);
vtkEpcDocumentSet = new VtkEpcDocumentSet(idProc, nbProc, false, true);
openEpcDocument(FileName);
if (extension=="epc")
if (stringFileName != "EpcDocument")
{
vtkEpcDocumentSet->visualizeFull();
if (extension=="epc")
{
openEpcDocument(FileName);
vtkEpcDocumentSet->visualizeFull();
}
}
}
return 1;
......
......@@ -40,6 +40,7 @@ knowledge of the CeCILL license and that you accept its terms.
// include system
#include <string>
#include <unordered_map>
#include <vector>
#include <common/EpcDocument.h>
......@@ -64,18 +65,15 @@ public:
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
void SetSubFileName(const char* name);
vtkGetStringMacro(SubFileName);
// Description:
// Get/set the multi process controller to use for coordinated reads. By
// default, set to the global controller.
vtkGetObjectMacro(Controller, vtkMultiProcessController);
virtual void SetController(vtkMultiProcessController *);
vtkGetObjectMacro(subFileList, vtkDataArraySelection);
int GetsubFileListArrayStatus(const char* name);
int GetNumberOfsubFileListArrays();
const char* GetsubFileListArrayName(int index);
void SetSubFileList(const char* name, int status);
vtkGetObjectMacro(uuidList, vtkDataArraySelection);
int GetuuidListArrayStatus(const char* name);
int GetNumberOfuuidListArrays();
......@@ -95,7 +93,8 @@ protected:
void openEpcDocument(const std::string & fileName);
char* FileName;
vtkDataArraySelection* subFileList;
char* SubFileName;
vtkDataArraySelection* uuidList;
vtkMultiProcessController* Controller;
......@@ -106,11 +105,6 @@ private:
bool loadedFile;
// mapping between file name & vtkEpcDocument
std::unordered_map<std::string, VtkEpcDocument*> vtkEpcDocuments;
// mapping between uuid & file name
std::unordered_map<std::string, std::string> uuidToFileName;
// id of process
int idProc;
// number of process
......@@ -122,6 +116,7 @@ private:
int countTest;
std::vector<std::string> fileNameSet;
};
#endif
......@@ -10,7 +10,6 @@
</Documentation>
<!-- -->
<StringVectorProperty
name="FileName"
animateable="0"
......@@ -27,25 +26,12 @@
</Hints>
<!-- -->
<StringVectorProperty
name="subFileInfo"
information_only="1"
default = "1">
<ArraySelectionInformationHelper attribute_name="subFileList"/>
</StringVectorProperty>
<StringVectorProperty name="subFileList"
command="SetSubFileList" number_of_elements="0" repeat_command="1"
number_of_elements_per_command="2" element_types="2 0"
information_property="subFileInfo" label="epc subfiles list"
panel_visibility="advanced">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property name="subFileInfo"
function="ArrayList" />
</RequiredProperties>
</ArraySelectionDomain>
<Documentation>List epc subfile.</Documentation>
name="SubFileName"
animateable="0"
command="SetSubFileName"
number_of_elements="1"
panel_visibility="never">
</StringVectorProperty>
<!-- -->
......
......@@ -28,21 +28,21 @@ class PQDataLoadManager::pqUI : public Ui::PQDataLoadManager
namespace
{
pqPropertiesPanel* getpqPropertiesPanel()
pqPropertiesPanel* getpqPropertiesPanel()
{
// get multi-block inspector panel
pqPropertiesPanel *panel = 0;
foreach(QWidget *widget, qApp->topLevelWidgets())
{
// get multi-block inspector panel
pqPropertiesPanel *panel = 0;
foreach(QWidget *widget, qApp->topLevelWidgets())
{
panel = widget->findChild<pqPropertiesPanel *>();
panel = widget->findChild<pqPropertiesPanel *>();
if (panel)
{
break;
}
if (panel)
{
break;
}
return panel;
}
return panel;
}
}
//=============================================================================
......@@ -95,13 +95,15 @@ void PQDataLoadManager::setupPipeline()
pqPipelineSource* fesppReader;
if (!manager->existPipe()){
if (manager->existPipe())
{
fesppReader = manager->getFesppReader();
}
else
{
fesppReader = builder->createReader("sources", "Fespp", QStringList("EpcDocument"), this->Server);
manager->existPipe(true);
}
else{
fesppReader = manager->getFesppReader();
}
QString epcFiles = this->ui->epcFile->filenames().join("*");
......@@ -117,10 +119,10 @@ void PQDataLoadManager::setupPipeline()
// add file to property
vtkSMProxy* fesppReaderProxy = fesppReader->getProxy();
// vtkSMPropertyHelper( fesppReaderProxy, "subFileList" ).SetStatus(epcFiles.toStdString().c_str(),1);
vtkSMPropertyHelper( fesppReaderProxy, "SubFileName" ).Set(epcFiles.toStdString().c_str());
vtkSMPropertyHelper( fesppReaderProxy, "subFileList" ).SetStatus(epcFiles.toStdString().c_str(),1);
fesppReaderProxy->UpdateSelfAndAllInputs();
fesppReaderProxy->UpdateSelfAndAllInputs();
}
}
END_UNDO_SET();
......
......@@ -106,8 +106,6 @@ void PQSelectionPanel::constructor()
connect(ui.treeWidget, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(clicSelection(QTreeWidgetItem*, int)));
connect(ui.treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(onItemCheckedUnchecked(QTreeWidgetItem*, int)));
connect(getpqPropertiesPanel(), SIGNAL(deleteRequested(pqPipelineSource*)), this, SLOT(deletePipelineSource(pqPipelineSource*)));
radioButtonCount = 0;
indexFile = 0;
......@@ -120,18 +118,21 @@ void PQSelectionPanel::constructor()
//----------------------------------------------------------------------------
void PQSelectionPanel::clicSelection(QTreeWidgetItem* item, int column)
{
unsigned int cpt;
pickedBlocks = itemUuid[item];
QFileInfo file(uuidToFilename[pickedBlocks].c_str());
pqPipelineSource * source = findPipelineSource("EpcDocument");
if (source)
{
pqActiveObjects *activeObjects = &pqActiveObjects::instance();
activeObjects->setActiveSource(source);
}
if (!(uuidToFilename[pickedBlocks] == pickedBlocks))
if (pickedBlocks!="root")
{
emit selectionName(uuidToFilename[pickedBlocks], pickedBlocks, pcksave[uuidToFilename[pickedBlocks]]);
QFileInfo file(uuidToFilename[pickedBlocks].c_str());
pqPipelineSource * source = findPipelineSource("EpcDocument");
if (source)
{
pqActiveObjects *activeObjects = &pqActiveObjects::instance();
activeObjects->setActiveSource(source);
}
if (!(uuidToFilename[pickedBlocks] == pickedBlocks))
{
emit selectionName(uuidToFilename[pickedBlocks], pickedBlocks, pcksave[uuidToFilename[pickedBlocks]]);
}
}
}
......@@ -175,19 +176,43 @@ void PQSelectionPanel::onItemCheckedUnchecked(QTreeWidgetItem * item, int column
}
//----------------------------------------------------------------------------
void PQSelectionPanel::deletePipelineSource(pqPipelineSource* pipe)
void PQSelectionPanel::deleteTreeView()
{
for (unsigned int fileNameInd = 0; fileNameInd < allFileName.size(); ++fileNameInd)
{
QFileInfo file(allFileName[fileNameInd].c_str());
const char* toto = file.fileName().toStdString().c_str();
pqPipelineSource * source = findPipelineSource(file.fileName().toStdString().c_str());
if (!source)
{
this->deleteFileName(allFileName[fileNameInd]);
cout << "void PQSelectionPanel::deleteTreeView()· IN\n";
treeWidget->clear();
indexFile = 0;
radioButtonCount = 0;
allFileName.clear();
uuidToFilename.clear();
filenameToUuids.clear();
filenameToUuidsPartial.clear();
uuidItem.clear();
itemUuid.clear();
uuidParentItem.clear();
mapUuidProperty.clear();
mapUuidWithProperty.clear();
displayUuid.clear();
mapRadioButtonNo.clear();
mapUuidParentButtonInvisible.clear();
std::string pickedBlocks = "";
uuidVisible.clear();
uuidCheckable.clear();
pcksave.clear();
uuidParentGroupButton.clear();
radioButtonToUuid.clear();
addTreeRoot("root", "epcdocument");
cout << "void PQSelectionPanel::deleteTreeView()· OUT\n";
}
}
}
//----------------------------------------------------------------------------
......@@ -226,66 +251,65 @@ bool PQSelectionPanel::canAddFile(const char* fileName)
//----------------------------------------------------------------------------
void PQSelectionPanel::addFileName(const std::string & fileName)
{
common::EpcDocument *pck = nullptr;
try{
pck = new common::EpcDocument(fileName, common::EpcDocument::READ_ONLY);
}
catch (const std::exception & e)
if (std::find(allFileName.begin(), allFileName.end(),fileName)==allFileName.end())
{
cout << "EXCEPTION in fesapi when reading file: " << fileName << " : " << e.what();
}
std::string result = "";
try{
result = pck->deserialize();
}
catch (const std::exception & e)
{
cout << "EXCEPTION in fesapi when deserialize file: " << fileName << " : " << e.what();
}
if (result.empty())
{
allFileName.push_back(fileName);
uuidToFilename[fileName] = fileName;
common::EpcDocument *pck = nullptr;
try{
pck = new common::EpcDocument(fileName, common::EpcDocument::READ_ONLY);
}
catch (const std::exception & e)
{
cout << "EXCEPTION in fesapi when reading file: " << fileName << " : " << e.what();
}
std::string result = "";
try{
result = pck->deserialize();
}
catch (const std::exception & e)
{
cout << "EXCEPTION in fesapi when deserialize file: " << fileName << " : " << e.what();
}
if (result.empty())
{
allFileName.push_back(fileName);
uuidToFilename[fileName] = fileName;
pcksave[fileName] = pck;
pcksave[fileName] = pck;
// add treeView polylines representation
addTreePolylines(fileName, pck->getFaultPolylineSetRepSet());
addTreePolylines(fileName, pck->getHorizonPolylineSetRepSet());
// add treeView polylines representation
addTreePolylines(fileName, pck->getFaultPolylineSetRepSet());
addTreePolylines(fileName, pck->getHorizonPolylineSetRepSet());
// add treeView triangulated representation
addTreeTriangulated(fileName, pck->getAllTriangulatedSetRepSet());
// add treeView triangulated representation
addTreeTriangulated(fileName, pck->getAllTriangulatedSetRepSet());
// add treeView Grid2D representation
addTreeGrid2D(fileName, pck->getHorizonGrid2dRepSet());
// add treeView Grid2D representation
addTreeGrid2D(fileName, pck->getHorizonGrid2dRepSet());
// add treeView ijkGrid representation
addTreeIjkGrid(fileName, pck->getIjkGridRepresentationSet());
// add treeView ijkGrid representation
addTreeIjkGrid(fileName, pck->getIjkGridRepresentationSet());
// add treeView UnstrucutredGrid representation
addTreeUnstructuredGrid(fileName, pck->getUnstructuredGridRepresentationSet());
// add treeView UnstrucutredGrid representation
addTreeUnstructuredGrid(fileName, pck->getUnstructuredGridRepresentationSet());
// add treeView UnstrucutredGrid representation
addTreeWellboreTrajectory(fileName, pck->getWellboreTrajectoryRepresentationSet());
// add treeView UnstrucutredGrid representation
addTreeWellboreTrajectory(fileName, pck->getWellboreTrajectoryRepresentationSet());
// add treeView Sub-representation
addTreeSubRepresentation(fileName, pck->getSubRepresentationSet());
// add treeView Sub-representation
addTreeSubRepresentation(fileName, pck->getSubRepresentationSet());
++indexFile;
++indexFile;
}
else
{
try{
pck->close();
}
catch (const std::exception & e)
else
{
cout << "EXCEPTION in fesapi when closing file " << fileName << " : " << e.what();
try{
pck->close();
}
catch (const std::exception & e)
{
cout << "EXCEPTION in fesapi when closing file " << fileName << " : " << e.what();
}
}
}
}
......@@ -366,7 +390,7 @@ void PQSelectionPanel::addTreePolylines(const std::string & fileName, std::vecto
{
QIcon icon;
icon.addFile(QString::fromUtf8(":Polyline.png"), QSize(), QIcon::Normal, QIcon::Off);
for (unsigned int polylineIter = 0; polylineIter < polylines.size(); ++polylineIter)
for (size_t polylineIter = 0; polylineIter < polylines.size(); ++polylineIter)
{
bool propertyTreeView = false;
......@@ -405,7 +429,7 @@ void PQSelectionPanel::addTreeTriangulated(const std::string & fileName, std::ve
{
QIcon icon;
icon.addFile(QString::fromUtf8(":Triangulated.png"), QSize(), QIcon::Normal, QIcon::Off);
for (unsigned int triangulatedIter = 0; triangulatedIter < triangulated.size(); ++triangulatedIter)
for (size_t triangulatedIter = 0; triangulatedIter < triangulated.size(); ++triangulatedIter)
{
bool propertyTreeView = false;
......@@ -446,7 +470,7 @@ void PQSelectionPanel::addTreeGrid2D(const std::string & fileName, std::vector<r
{
QIcon icon;
icon.addFile(QString::fromUtf8(":Grid2D.png"), QSize(), QIcon::Normal, QIcon::Off);
for (unsigned int grid2DIter = 0; grid2DIter < grid2D.size(); ++grid2DIter)
for (size_t grid2DIter = 0; grid2DIter < grid2D.size(); ++grid2DIter)
{
bool propertyTreeView = false;
......@@ -486,29 +510,30 @@ void PQSelectionPanel::addTreeIjkGrid(const std::string & fileName, std::vector<
{
QIcon icon;
icon.addFile(QString::fromUtf8(":IjkGrid.png"), QSize(), QIcon::Normal, QIcon::Off);
for (unsigned int ijkGridIter = 0; ijkGridIter < ijkGrid.size(); ++ijkGridIter)
for (size_t ijkGridIter = 0; ijkGridIter < ijkGrid.size(); ++ijkGridIter)
{
bool propertyTreeView = false;
if (ijkGrid[ijkGridIter]->getGeometryKind() != resqml2_0_1::AbstractIjkGridRepresentation::NO_GEOMETRY)
{
std::string uuidParent = addFeatInterp(fileName, ijkGrid[ijkGridIter]->getInterpretation());
if (ijkGrid[ijkGridIter]->isPartial()){
if (uuidItem.count(ijkGrid[ijkGridIter]->getUuid())>0){
if (ijkGrid[ijkGridIter]->isPartial())
{
if (uuidItem.count(ijkGrid[ijkGridIter]->getUuid())>0)
{
filenameToUuidsPartial[fileName].push_back(ijkGrid[ijkGridIter]->getUuid());
propertyTreeView = true;
}
else{
else
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(QString(("Partial UUID: " + ijkGrid[ijkGridIter]->getUuid() + " and the complete UUID not found.").c_str()));
msgBox.exec();
}
}
else{
else
{
uuidToFilename[ijkGrid[ijkGridIter]->getUuid()] = fileName;
addTreeRepresentation(uuidItem[uuidParent],
ijkGrid[ijkGridIter]->getTitle().c_str(),
ijkGrid[ijkGridIter]->getUuid(),
......@@ -516,7 +541,8 @@ void PQSelectionPanel::addTreeIjkGrid(const std::string & fileName, std::vector<
);
propertyTreeView = true;
}
if (propertyTreeView){
if (propertyTreeView)
{
std::vector<resqml2::AbstractValuesProperty*> valuesPropertySet = ijkGrid[ijkGridIter]->getValuesPropertySet();
addTreeProperty(uuidItem[ijkGrid[ijkGridIter]->getUuid()], valuesPropertySet);
}
......@@ -529,7 +555,7 @@ void PQSelectionPanel::addTreeUnstructuredGrid(const std::string & fileName, std
{
QIcon icon;
icon.addFile(QString::fromUtf8(":UnstructuredGrid.png"), QSize(), QIcon::Normal, QIcon::Off);
for (unsigned int unstructuredGridIter = 0; unstructuredGridIter < unstructuredGrid.size(); ++unstructuredGridIter)
for (size_t unstructuredGridIter = 0; unstructuredGridIter < unstructuredGrid.size(); ++unstructuredGridIter)
{
bool propertyTreeView = false;
......@@ -569,7 +595,7 @@ void PQSelectionPanel::addTreeWellboreTrajectory(const std::string & fileName, s
{
QIcon icon;
icon.addFile(QString::fromUtf8(":WellTraj.png"), QSize(), QIcon::Normal, QIcon::Off);
for (unsigned int WellboreTrajectoryIter = 0; WellboreTrajectoryIter < WellboreTrajectory.size(); ++WellboreTrajectoryIter)
for (size_t WellboreTrajectoryIter = 0; WellboreTrajectoryIter < WellboreTrajectory.size(); ++WellboreTrajectoryIter)
{
bool propertyTreeView = false;
......@@ -669,8 +695,8 @@ void PQSelectionPanel::addTreeRepresentation(QTreeWidgetItem *parent,
sstm << " already exists: uuid (" << uuid << ")";
auto test = fespp[epcDocument[uuid]];
fespp[epcDocument[uuid]]->displayWarning(sstm.str());
*/
*/
}
}
......@@ -691,7 +717,7 @@ void PQSelectionPanel::addTreeProperty(QTreeWidgetItem *parent, std::vector<resq
radioButtonCount++;
mapUuidParentButtonInvisible[itemUuid[parent]] = radioButtonInvisible;
for (unsigned int i = 0; i < valuesPropertySet.size(); ++i)
for (size_t i = 0; i < valuesPropertySet.size(); ++i)
{
resqml2::AbstractValuesProperty* valuesProperty = valuesPropertySet[i];
if (valuesProperty->getXmlTag() == "ContinuousProperty" ||
......@@ -736,58 +762,79 @@ void PQSelectionPanel::addTreeProperty(QTreeWidgetItem *parent, std::vector<resq
//----------------------------------------------------------------------------
void PQSelectionPanel::deleteFileName(const std::string & fileName)
{
cout << "PQSelectionPanel::deleteFileName("<< fileName << ") IN\n";
std::vector<std::string> uuids = filenameToUuids[fileName];
for (unsigned int i = 0; i < uuids.size(); ++i)
for (size_t i = 0; i < uuids.size(); ++i)
{
cout << " uuid " << i << " = " << uuids[i] << "\n";
auto uuidTest = uuids[i];
cout << " 1\n";
std::vector<std::string>::iterator uuidCheckable_iterator = std::find(uuidCheckable.begin(), uuidCheckable.end(), uuids[i]);
cout << " 2\n";
if (uuidCheckable_iterator != uuidCheckable.end())
{
cout << " 3\n";
uuidCheckable.erase(uuidCheckable_iterator);
}
cout << " 4\n";
std::vector<std::string>::iterator uuidVisible_iterator = std::find(uuidVisible.begin(), uuidVisible.end(), uuids[i]);
cout << " 5\n";
if (uuidVisible_iterator != uuidVisible.end())
{
cout << " 6\n";
uuidVisible.erase(uuidVisible_iterator);
}
cout << " 7\n";
itemUuid.remove(uuidItem[uuids[i]]);
if (uuidItem[uuids[i]]->childCount() > 0) { deleteUUID(uuidItem[uuids[i]]); }
else { uuidItem[uuids[i]]->setHidden(true); }
cout << " 8\n";