Skip to content
Snippets Groups Projects
Commit 0f12eb3e authored by Karsten Rink's avatar Karsten Rink
Browse files

changed xml project interface back to using project as parameter

parent 4b245f99
No related branches found
No related tags found
No related merge requests found
...@@ -38,15 +38,10 @@ ...@@ -38,15 +38,10 @@
namespace FileIO namespace FileIO
{ {
XmlGspInterface::XmlGspInterface(
GeoLib::GEOObjects& geoObjects, XmlGspInterface::XmlGspInterface(DataExplorerProject& project)
std::vector<MeshLib::Mesh*> const& mesh_vector, : XMLInterface(), XMLQtInterface(BaseLib::FileFinder().getPath("OpenGeoSysProject.xsd")),
std::function<void(MeshLib::Mesh* const)>&& add_mesh_callback) _project(project)
: XMLInterface(),
XMLQtInterface(BaseLib::FileFinder().getPath("OpenGeoSysProject.xsd")),
_geoObjects(geoObjects),
_mesh_vector(mesh_vector),
_add_mesh_callback(std::move(add_mesh_callback))
{ {
} }
...@@ -74,7 +69,7 @@ int XmlGspInterface::readFile(const QString &fileName) ...@@ -74,7 +69,7 @@ int XmlGspInterface::readFile(const QString &fileName)
const QString file_node(fileList.at(i).nodeName()); const QString file_node(fileList.at(i).nodeName());
if (file_node.compare("geo") == 0) if (file_node.compare("geo") == 0)
{ {
XmlGmlInterface gml(_geoObjects); XmlGmlInterface gml(*(_project.getGEOObjects()));
const QDomNodeList childList = fileList.at(i).childNodes(); const QDomNodeList childList = fileList.at(i).childNodes();
for(int j = 0; j < childList.count(); j++) for(int j = 0; j < childList.count(); j++)
{ {
...@@ -91,7 +86,7 @@ int XmlGspInterface::readFile(const QString &fileName) ...@@ -91,7 +86,7 @@ int XmlGspInterface::readFile(const QString &fileName)
} }
else if (file_node.compare("stn") == 0) else if (file_node.compare("stn") == 0)
{ {
XmlStnInterface stn(_geoObjects); XmlStnInterface stn(*(_project.getGEOObjects()));
const QDomNodeList childList = fileList.at(i).childNodes(); const QDomNodeList childList = fileList.at(i).childNodes();
for(int j = 0; j < childList.count(); j++) for(int j = 0; j < childList.count(); j++)
if (childList.at(j).nodeName().compare("file") == 0) if (childList.at(j).nodeName().compare("file") == 0)
...@@ -103,7 +98,8 @@ int XmlGspInterface::readFile(const QString &fileName) ...@@ -103,7 +98,8 @@ int XmlGspInterface::readFile(const QString &fileName)
const std::string msh_name = path.toStdString() + const std::string msh_name = path.toStdString() +
fileList.at(i).toElement().text().toStdString(); fileList.at(i).toElement().text().toStdString();
MeshLib::Mesh* msh = FileIO::readMeshFromFile(msh_name); MeshLib::Mesh* msh = FileIO::readMeshFromFile(msh_name);
if (msh) _add_mesh_callback(msh); if (msh)
_project.addMesh(msh);
} }
} }
...@@ -118,6 +114,7 @@ int XmlGspInterface::writeToFile(const std::string& filename) ...@@ -118,6 +114,7 @@ int XmlGspInterface::writeToFile(const std::string& filename)
bool XmlGspInterface::write() bool XmlGspInterface::write()
{ {
GeoLib::GEOObjects& geoObjects = *_project.getGEOObjects();
QFileInfo fi(QString::fromStdString(_filename)); QFileInfo fi(QString::fromStdString(_filename));
std::string path((fi.absolutePath()).toStdString() + "/"); std::string path((fi.absolutePath()).toStdString() + "/");
...@@ -135,11 +132,11 @@ bool XmlGspInterface::write() ...@@ -135,11 +132,11 @@ bool XmlGspInterface::write()
// GML // GML
std::vector<std::string> geoNames; std::vector<std::string> geoNames;
_geoObjects.getGeometryNames(geoNames); geoObjects.getGeometryNames(geoNames);
for (std::vector<std::string>::const_iterator it(geoNames.begin()); it != geoNames.end(); ++it) for (std::vector<std::string>::const_iterator it(geoNames.begin()); it != geoNames.end(); ++it)
{ {
// write GLI file // write GLI file
XmlGmlInterface gml(_geoObjects); XmlGmlInterface gml(geoObjects);
std::string name(*it); std::string name(*it);
gml.setNameForExport(name); gml.setNameForExport(name);
if (gml.writeToFile(std::string(path + name + ".gml"))) if (gml.writeToFile(std::string(path + name + ".gml")))
...@@ -156,6 +153,7 @@ bool XmlGspInterface::write() ...@@ -156,6 +153,7 @@ bool XmlGspInterface::write()
} }
// MSH // MSH
const std::vector<MeshLib::Mesh*> _mesh_vector = _project.getMeshObjects();
for (auto const& mesh : _mesh_vector) for (auto const& mesh : _mesh_vector)
{ {
// write mesh file // write mesh file
...@@ -175,11 +173,11 @@ bool XmlGspInterface::write() ...@@ -175,11 +173,11 @@ bool XmlGspInterface::write()
// STN // STN
std::vector<std::string> stnNames; std::vector<std::string> stnNames;
_geoObjects.getStationVectorNames(stnNames); geoObjects.getStationVectorNames(stnNames);
for (std::vector<std::string>::const_iterator it(stnNames.begin()); it != stnNames.end(); ++it) for (std::vector<std::string>::const_iterator it(stnNames.begin()); it != stnNames.end(); ++it)
{ {
// write STN file // write STN file
XmlStnInterface stn(_geoObjects); XmlStnInterface stn(geoObjects);
std::string name(*it); std::string name(*it);
stn.setNameForExport(name); stn.setNameForExport(name);
...@@ -202,4 +200,5 @@ bool XmlGspInterface::write() ...@@ -202,4 +200,5 @@ bool XmlGspInterface::write()
_out << xml; _out << xml;
return true; return true;
} }
} }
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#ifndef XMLGSPINTERFACE_H #ifndef XMLGSPINTERFACE_H
#define XMLGSPINTERFACE_H #define XMLGSPINTERFACE_H
#include <functional>
#include <vector> #include <vector>
#include <string> #include <string>
...@@ -24,15 +23,7 @@ ...@@ -24,15 +23,7 @@
#include "../XMLInterface.h" #include "../XMLInterface.h"
#include "XMLQtInterface.h" #include "XMLQtInterface.h"
namespace MeshLib #include "DataHolderLib/DataExplorerProject.h"
{
class Mesh;
}
namespace GeoLib
{
class GEOObjects;
}
namespace FileIO namespace FileIO
{ {
...@@ -43,10 +34,7 @@ namespace FileIO ...@@ -43,10 +34,7 @@ namespace FileIO
class XmlGspInterface : public XMLInterface, public XMLQtInterface class XmlGspInterface : public XMLInterface, public XMLQtInterface
{ {
public: public:
XmlGspInterface( XmlGspInterface(DataExplorerProject& project);
GeoLib::GEOObjects& geoObjects,
std::vector<MeshLib::Mesh*> const& mesh_vector,
std::function<void(MeshLib::Mesh* const)>&& add_mesh_callback);
virtual ~XmlGspInterface() {} virtual ~XmlGspInterface() {}
...@@ -63,9 +51,7 @@ protected: ...@@ -63,9 +51,7 @@ protected:
private: private:
std::string _filename; std::string _filename;
GeoLib::GEOObjects& _geoObjects; DataExplorerProject& _project;
std::vector<MeshLib::Mesh*> const& _mesh_vector;
std::function<void(MeshLib::Mesh* const)> _add_mesh_callback;
}; };
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment