Skip to content
Snippets Groups Projects
Commit ed0ca248 authored by Riccardo Maria Bianchi's avatar Riccardo Maria Bianchi :sunny:
Browse files

Drop Qt5 from GeoModelWrite and from the GeoModelDBManager API

parent c285c0d0
No related branches found
No related tags found
1 merge request!10Drop the use of Qt5 in GeoModelIO
Pipeline #1683227 failed
...@@ -37,7 +37,7 @@ public: ...@@ -37,7 +37,7 @@ public:
* Constructor sets up connection with db and opens it * Constructor sets up connection with db and opens it
* @param path - absolute path to db file * @param path - absolute path to db file
*/ */
GMDBManager(const QString& path); GMDBManager(const std::string &path);
/** /**
* @brief Destructor * @brief Destructor
...@@ -142,7 +142,7 @@ public: ...@@ -142,7 +142,7 @@ public:
QVariant addFullPhysVol(const QVariant &logVolId, const QVariant &parentPhysVolId, bool isRootVolume = false); QVariant addFullPhysVol(const QVariant &logVolId, const QVariant &parentPhysVolId, bool isRootVolume = false);
QVariant addSerialDenominator(const QString &baseName); QVariant addSerialDenominator(const QString &baseName);
QVariant addFunction(const QString expression); QVariant addFunction(const QString expression);
QVariant addSerialTransformer(const QVariant &funcId, const QVariant &physvolId, const QString volType, const unsigned int &copies); QVariant addSerialTransformer(const unsigned int &funcId, const unsigned int &physvolId, const std::string &volType, const unsigned int &copies);
QVariant addTransform(QVector<double> parameters); QVariant addTransform(QVector<double> parameters);
QVariant addAlignableTransform(QVector<double> parameters); QVariant addAlignableTransform(QVector<double> parameters);
QVariant addNameTag(const QString &name); QVariant addNameTag(const QString &name);
...@@ -154,34 +154,31 @@ public: ...@@ -154,34 +154,31 @@ public:
bool addListOfRecordsToTable(const QString tableName, const std::vector<QStringList> records); bool addListOfRecordsToTable(const QString tableName, const std::vector<QStringList> records);
bool addListOfRecordsToTable(const std::string tableName, const std::vector<std::vector<std::string>> records); bool addListOfRecordsToTable(const std::string tableName, const std::vector<std::vector<std::string>> records);
bool addListOfRecordsToTableOld(const QString tableName, const std::vector<QStringList> records); // bool addListOfRecordsToTableOld(const QString tableName, const std::vector<QStringList> records); // for the old SQlite only
bool addListOfChildrenPositions(const std::vector<QStringList> records); bool addListOfChildrenPositions(const std::vector<std::vector<std::string>> &records);
bool addRootVolume(const QStringList); bool addRootVolume(const std::vector<std::string> &values);
void addChildPosition(const QVariant parentId, const QString parentType, const QVariant childId, const unsigned int parentCopyNumber, const unsigned int childPos, const QString childType, const unsigned int childCopyN); void addChildPosition(const unsigned int &parentId, const std::string &parentType, const unsigned int &childId, const unsigned int &parentCopyNumber, const unsigned int &childPos, const std::string &childType, const unsigned int &childCopyN);
void addDBversion(const QString); void addDBversion(const QString);
// GET methods // GET methods
QString getDBFilePath(); std::string getDBFilePath();
QStringList getRootPhysVol(); std::vector<std::string> getRootPhysVol();
std::vector<std::string> getRootPhysVolStd();
QStringList getItem(QString geoType, unsigned int id); std::vector<std::string> getItem(std::string geoType, unsigned int id);
QStringList getItem(unsigned int tableId, unsigned int id); std::vector<std::string> getItem(unsigned int tableId, unsigned int id);
QStringList getItemFromTableName(QString tableName, unsigned int id); std::vector<std::string> getItemFromTableName(std::string tableName, unsigned int id);
std::vector<std::string> getItemFromTableNameStd(QString tableName, unsigned int id);
QStringList getItemAndType(unsigned int tableId, unsigned int id); std::vector<std::string> getItemAndType(unsigned int tableId, unsigned int id);
std::vector<std::string> getItemAndTypeStd(unsigned int tableId, unsigned int id);
QString getNodeTypeFromTableId(unsigned int id); std::string getNodeTypeFromTableId(unsigned int id);
std::string getNodeTypeFromTableIdStd(unsigned int id);
QMap<unsigned int, QStringList> getVPhysVolChildren(const unsigned int id, const QString nodeType, const unsigned int copyN); QMap<unsigned int, QStringList> getVPhysVolChildren(const unsigned int &id, const std::string &nodeType, const unsigned int &copyN);
/// methods to dump the DB /// methods to dump the DB
QHash<QString, QMap<unsigned int, QStringList>> getChildrenTable(); QHash<QString, QMap<unsigned int, QStringList>> getChildrenTable();
...@@ -190,10 +187,10 @@ public: ...@@ -190,10 +187,10 @@ public:
QHash<unsigned int, QStringList> getTableFromNodeType(QString nodeType); QHash<unsigned int, QStringList> getTableFromNodeType(QString nodeType);
std::vector<std::vector<std::string>> getTableFromNodeTypeStd(std::string nodeType); std::vector<std::vector<std::string>> getTableFromNodeTypeStd(std::string nodeType);
QHash<unsigned int, QString> getAll_TableIDsNodeTypes(); // QHash<unsigned int, QString> getAll_TableIDsNodeTypes();
QHash<QString, unsigned int> getAll_NodeTypesTableIDs(); // QHash<QString, unsigned int> getAll_NodeTypesTableIDs();
std::unordered_map<unsigned int, std::string> getAll_TableIDsNodeTypesStd(); std::unordered_map<unsigned int, std::string> getAll_TableIDsNodeTypes();
std::unordered_map<std::string, unsigned int> getAll_NodeTypesTableIDsStd(); std::unordered_map<std::string, unsigned int> getAll_NodeTypesTableIDs();
...@@ -205,34 +202,38 @@ private: ...@@ -205,34 +202,38 @@ private:
void loadTestData(); // for debug only void loadTestData(); // for debug only
void loadTableNamesFromDB(); void loadTableNamesFromDB();
QStringList getTableColNamesFromDB(QString tableName) const; std::vector<std::string> getTableColNamesFromDB(std::string tableName) const;
QString getTableNameFromTableId(unsigned int tabId); // QString getTableNameFromTableId(unsigned int tabId);
std::string getTableNameFromTableIdStd(unsigned int tabId); std::string getTableNameFromTableId(unsigned int tabId);
QVariant getTableIdFromNodeType(QString nodeType); unsigned int getTableIdFromNodeType(const std::string &nodeType);
void storeNodeType(QString nodeType, QString tableName); void storeNodeType(std::string nodeType, std::string tableName);
QString getTableNameFromNodeType(QString nodeType);
QString getTableNameFromNodeType(QString nodeType); // TODO: to be removed
std::string getTableNameFromNodeType(std::string nodeType);
QSqlQuery selectAllFromTable(QString tableName) const;
QSqlQuery selectAllFromTableSortBy(QString tableName, std::string sortColumn="") const; // QSqlQuery selectAllFromTable(QString tableName) const;
QSqlQuery selectAllFromTable(std::string tableName) const;
QSqlQuery selectAllFromTableSortBy(std::string tableName, std::string sortColumn="") const;
// void storeTableColumnNames(QStringList input); // void storeTableColumnNames(QStringList input);
void storeTableColumnNames(std::vector<std::string> input); void storeTableColumnNames(std::vector<std::string> input);
QStringList getTableColumnNames(QString tableName); std::vector<std::string> getTableColumnNames(const std::string &tableName);
void printTableColNamesFromDB(QString tableName) const; void printTableColNamesFromDB(const std::string &tableName) const;
void printAllRecords(QString tableName) const; void printAllRecords(const std::string &tableName) const;
int getTableColIndex(QString tableName, QString colName); int getTableColIndex(const std::string &tableName, const std::string &colName);
bool storeRootVolume(QVariant id, QString nodeType); bool storeRootVolume(const unsigned int &id, const std::string &nodeType);
void showError(const QSqlError &err) const; void showError(const QSqlError &err) const;
QString m_dbpath; std::string m_dbpath;
QSqlDatabase m_db; QSqlDatabase m_db;
bool m_dbIsOK; bool m_dbIsOK;
......
This diff is collapsed.
/* /*
* author: Riccardo.Maria.Bianchi@cern.ch, 2017 * author: Riccardo.Maria.Bianchi@cern.ch, 2017
* *
* major updates: Aug 2018 rbianchi * major updates:
* Feb 2019 rbianchi * - Aug 2018 - R.M.Bianchi
* - Feb 2019 - R.M.Bianchi
* - May 2020 - R.M.Bianchi
*/ */
#ifndef GeoModelWrite_WriteGeoModel_H #ifndef GeoModelWrite_WriteGeoModel_H
...@@ -22,16 +24,10 @@ ...@@ -22,16 +24,10 @@
#include "GeoModelKernel/GeoAlignableTransform.h" #include "GeoModelKernel/GeoAlignableTransform.h"
#include "GeoModelKernel/GeoDefinitions.h" #include "GeoModelKernel/GeoDefinitions.h"
// Qt includes
//#include <QSqlDatabase>
#include <QStringList>
#include <QVariant>
#include <QString>
#include <QMap>
// C++ includes // C++ includes
#include <vector> #include <vector>
#include <string> #include <string>
#include <unordered_map>
namespace GeoModelIO { namespace GeoModelIO {
...@@ -81,83 +77,82 @@ private: ...@@ -81,83 +77,82 @@ private:
void showMemoryMap(); void showMemoryMap();
QStringList getParentNode(); std::vector<std::string> getParentNode();
QVariant storeShape(const GeoShape* shape); unsigned int storeShape(const GeoShape* shape);
QVariant storeMaterial(const GeoMaterial* mat); unsigned int storeMaterial(const GeoMaterial* mat);
QVariant storeElement(const GeoElement* el); unsigned int storeElement(const GeoElement* el);
QVariant storeTranform(const GeoTransform* node); unsigned int storeTranform(const GeoTransform* node);
QVariant storeObj(const GeoMaterial* pointer, const QString name, const QString density, const QString elements); unsigned int storeObj(const GeoMaterial* pointer, const std::string &name, const double &density, const std::string &elements);
QVariant storeObj(const GeoElement* pointer, const QString name, const QString symbol, const QString elZ, const QString elA); unsigned int storeObj(const GeoElement* pointer, const std::string &name, const std::string &symbol, const double &elZ, const double &elA);
QVariant storeObj(const GeoShape* pointer, const std::string type, const std::string parameters); unsigned int storeObj(const GeoShape* pointer, const std::string &type, const std::string &parameters);
QVariant storeObj(const GeoLogVol* pointer, const QString name, const QVariant shapeId, const QVariant materialId); unsigned int storeObj(const GeoLogVol* pointer, const std::string &name, const unsigned int &shapeId, const unsigned int &materialId);
QVariant storeObj(const GeoPhysVol* pointer, const QVariant logvolId, const QVariant parentId = QVariant(), bool isRootVolume = false ); unsigned int storeObj(const GeoPhysVol* pointer, const unsigned int &logvolId, const unsigned int parentId = 0, const bool isRootVolume = false );
QVariant storeObj(const GeoFullPhysVol* pointer, const QVariant logvolId, const QVariant parentId = QVariant(), bool isRootVolume = false ); unsigned int storeObj(const GeoFullPhysVol* pointer, const unsigned int &logvolId, const unsigned int parentId = 0, const bool isRootVolume = false );
QVariant storeObj(const GeoSerialDenominator* pointer, const QString baseName); unsigned int storeObj(const GeoSerialDenominator* pointer, const std::string &baseName);
QVariant storeObj(const GeoSerialTransformer* pointer, const QVariant functionId, const QVariant volId, const QString volType, const unsigned int copies); unsigned int storeObj(const GeoSerialTransformer* pointer, const unsigned int &functionId, const unsigned int &volId, const std::string &volType, const unsigned int &copies);
QVariant storeObj(const GeoXF::Function* pointer, const QString expression); unsigned int storeObj(const GeoXF::Function* pointer, const std::string &expression);
QVariant storeObj(const GeoTransform* pointer, const std::vector<double> parameters); unsigned int storeObj(const GeoTransform* pointer, const std::vector<double> &parameters);
QVariant storeObj(const GeoAlignableTransform* pointer, const std::vector<double> parameters); unsigned int storeObj(const GeoAlignableTransform* pointer, const std::vector<double> &parameters);
QVariant storeObj(const GeoNameTag* pointer, const QString name); unsigned int storeObj(const GeoNameTag* pointer, const std::string &name);
unsigned int addRecord(std::vector<QStringList>* container, const QStringList values) const;
unsigned int addRecord(std::vector<std::vector<std::string>>* container, const std::vector<std::string> values) const; unsigned int addRecord(std::vector<std::vector<std::string>>* container, const std::vector<std::string> values) const;
QVariant addMaterial(const QString name, const QString density, const QString elements); unsigned int addMaterial(const std::string &name, const double &density, const std::string &elements);
QVariant addElement(const QString name, const QString symbol, const QString elZ, const QString elA); unsigned int addElement(const std::string &name, const std::string &symbol, const double &elZ, const double &elA);
QVariant addNameTag(const QString name); unsigned int addNameTag(const std::string &name);
QVariant addAlignableTransform(const std::vector<double> params); unsigned int addAlignableTransform(const std::vector<double> &params);
QVariant addTransform(const std::vector<double> params); unsigned int addTransform(const std::vector<double> &params);
QVariant addFunction(const QString expression); unsigned int addFunction(const std::string &expression);
QVariant addSerialTransformer(const QVariant &funcId, const QVariant &physvolId, const QString volType, const unsigned int &copies); unsigned int addSerialTransformer(const unsigned int &funcId, const unsigned int &physvolId, const std::string volType, const unsigned int &copies);
QVariant addShape(const std::string &type, const std::string &parameters); unsigned int addShape(const std::string &type, const std::string &parameters);
QVariant addSerialDenominator(const QString &baseName); unsigned int addSerialDenominator(const std::string &baseName);
QVariant addPhysVol(const QVariant &logVolId, const QVariant &parentPhysVolId, bool isRootVolume = false); unsigned int addPhysVol(const unsigned int &logVolId, const unsigned int &parentPhysVolId, const bool &isRootVolume);
QVariant addFullPhysVol(const QVariant &logVolId, const QVariant &parentPhysVolId, bool isRootVolume = false); unsigned int addFullPhysVol(const unsigned int &logVolId, const unsigned int &parentPhysVolId, const bool &isRootVolume);
QVariant addLogVol(const QString &name, const QVariant &shapeId, const QVariant &materialId); unsigned int addLogVol(const std::string &name, const unsigned int &shapeId, const unsigned int &materialId);
void addChildPosition(const QVariant parentId, const QString parentType, const QVariant childId, const unsigned int parentCopyNumber, const unsigned int childPos, const QString childType, const unsigned int childCopyN); void addChildPosition(const unsigned int &parentId, const std::string &parentType, const unsigned int &childId, const unsigned int &parentCopyNumber, const unsigned int &childPos, const std::string &childType, const unsigned int &childCopyN);
unsigned int getChildPosition(QString parentId, QString parentType, unsigned int copyN); unsigned int getChildPosition(const unsigned int &parentId, const std::string &parentType, const unsigned int &copyN);
unsigned int setVolumeCopyNumber(QString volId, QString volType); unsigned int setVolumeCopyNumber(const unsigned int& volId, const std::string& volType);
unsigned int getLatestParentCopyNumber(QString parentId, QString parentType); unsigned int getLatestParentCopyNumber(const unsigned int& parentId, const std::string& parentType);
void storeChildPosition(const QVariant parentId, const QString parentType, const QVariant childVol, const unsigned int parentCopyNumber, const unsigned int childPos, const QString childType, const unsigned int childCopyN); void storeChildPosition(const unsigned int& parentId, const std::string& parentType, const unsigned int& childVol, const unsigned int& parentCopyNumber, const unsigned int& childPos, const std::string& childType, const unsigned int& childCopyN);
bool isAddressStored(const QString address); bool isAddressStored(const std::string &address);
void storeAddress(const QString address, QVariant id); void storeAddress(const std::string &address, const unsigned int &id);
QVariant getStoredIdFromAddress(QString address); unsigned int getStoredIdFromAddress(const std::string &address);
QString getAddressStringFromPointer(const GeoMaterial* pointer); std::string getAddressStringFromPointer(const GeoMaterial* pointer);
QString getAddressStringFromPointer(const GeoElement* pointer); std::string getAddressStringFromPointer(const GeoElement* pointer);
QString getAddressStringFromPointer(const GeoShape* pointer); std::string getAddressStringFromPointer(const GeoShape* pointer);
QString getAddressStringFromPointer(const GeoLogVol* pointer); std::string getAddressStringFromPointer(const GeoLogVol* pointer);
QString getAddressStringFromPointer(const GeoPhysVol* pointer); std::string getAddressStringFromPointer(const GeoPhysVol* pointer);
QString getAddressStringFromPointer(const GeoVPhysVol* pointer); std::string getAddressStringFromPointer(const GeoVPhysVol* pointer);
QString getAddressStringFromPointer(const GeoSerialDenominator* pointer); std::string getAddressStringFromPointer(const GeoSerialDenominator* pointer);
QString getAddressStringFromPointer(const GeoSerialTransformer* pointer); std::string getAddressStringFromPointer(const GeoSerialTransformer* pointer);
QString getAddressStringFromPointer(const GeoXF::Function* pointer); std::string getAddressStringFromPointer(const GeoXF::Function* pointer);
QString getAddressStringFromPointer(const GeoTransform* pointer); std::string getAddressStringFromPointer(const GeoTransform* pointer);
QString getAddressStringFromPointer(const GeoNameTag* pointer); std::string getAddressStringFromPointer(const GeoNameTag* pointer);
QString getQStringFromOss(std::ostringstream &oss); std::string getQStringFromOss(std::ostringstream &oss);
std::vector<double> getTransformParameters(GeoTrf::Transform3D); // TODO: to be moved to Eigen (GeoTrf) and to be moved to an Utility class, so we can use it from TransFunctionRecorder as well. std::vector<double> getTransformParameters(GeoTrf::Transform3D); // TODO: to be moved to Eigen (GeoTrf) and to be moved to an Utility class, so we can use it from TransFunctionRecorder as well.
std::string getShapeParameters(const GeoShape*); std::string getShapeParameters(const GeoShape*);
QString getGeoTypeFromVPhysVol(const GeoVPhysVol* vol); std::string getGeoTypeFromVPhysVol(const GeoVPhysVol* vol);
QString getIdFromNodeType(QString nodeType); unsigned int getIdFromNodeType(const std::string &nodeType);
QString m_dbpath; std::string m_dbpath;
GMDBManager* m_dbManager; GMDBManager* m_dbManager;
QMap<QString, QVariant> m_memMap; // TODO: maybe move to QHash?? std::unordered_map<std::string, unsigned int> m_parentChildrenMap;
QHash<QString, unsigned int> m_memMap_Tables; std::unordered_map<std::string, unsigned int> m_volumeCopiesMap;
QMap<QString, unsigned int> m_parentChildrenMap2; // TODO: clean name! std::unordered_map<std::string, unsigned int> m_memMap;
QMap<QString, unsigned int> m_volumeCopiesMap; std::unordered_map<std::string, unsigned int> m_memMap_Tables;
// keep track of the number of visited tree nodes // keep track of the number of visited tree nodes
unsigned int m_len; unsigned int m_len;
...@@ -166,26 +161,21 @@ private: ...@@ -166,26 +161,21 @@ private:
bool m_rootVolumeFound; bool m_rootVolumeFound;
bool m_unconnectedTree; bool m_unconnectedTree;
std::vector<QStringList> m_logVols; std::vector<std::vector<std::string>> m_logVols;
std::vector<QStringList> m_physVols; std::vector<std::vector<std::string>> m_physVols;
std::vector<QStringList> m_fullPhysVols; std::vector<std::vector<std::string>> m_fullPhysVols;
// std::vector<QStringList> m_shapes; std::vector<std::vector<std::string>> m_materials;
std::vector<QStringList> m_materials; std::vector<std::vector<std::string>> m_elements;
std::vector<QStringList> m_elements; std::vector<std::vector<std::string>> m_transforms;
std::vector<QStringList> m_transforms; std::vector<std::vector<std::string>> m_alignableTransforms;
std::vector<QStringList> m_alignableTransforms; std::vector<std::vector<std::string>> m_serialDenominators;
std::vector<QStringList> m_serialDenominators; std::vector<std::vector<std::string>> m_serialTransformers;
std::vector<QStringList> m_serialTransformers; std::vector<std::vector<std::string>> m_functions;
std::vector<QStringList> m_functions; std::vector<std::vector<std::string>> m_nameTags;
std::vector<QStringList> m_nameTags; std::vector<std::vector<std::string>> m_childrenPositions;
std::vector<QStringList> m_childrenPositions;
std::vector<std::vector<std::string>> m_shapes; std::vector<std::vector<std::string>> m_shapes;
std::vector<std::string> m_rootVolume;
QStringList m_rootVolume;
// QStringList m_objectsNotPersistified;
std::vector<std::string> m_objectsNotPersistified; std::vector<std::string> m_objectsNotPersistified;
}; };
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment