Last active
October 18, 2016 22:42
-
-
Save gogo40/0a9d60e409cba4f2c219b5f7de319537 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Mining Control | |
MINING FLOWCHART INFO | |
(c) 2015-2016, Escrito por Péricles Lopes Machado <[email protected]> | |
*/ | |
#pragma once | |
#include <QDebug> | |
#include <QJsonObject> | |
#include <QJsonArray> | |
#include <QString> | |
#include <QList> | |
#include <QtSql/QSql> | |
#include <QSqlError> | |
#include <QVariant> | |
#include <QSqlQuery> | |
#include <QSqlDatabase> | |
#include <map> | |
#include <set> | |
#include <vector> | |
#include "common/geometry/point_in_polygon_test.h" | |
/*======================================= | |
Flowchart Info | |
=======================================*/ | |
struct MiningFlowchartPosition { | |
MiningFlowchartPosition(double x = 0, double y = 0, double r = 0) | |
: x_(x), y_(y), r_(r) {} | |
~MiningFlowchartPosition() {} | |
void set(double x, double y, double r) { x_ = x; y_ = y; r_ = r; } | |
double x() { return x_; } | |
double y() { return y_; } | |
double r() { return r_; } | |
void setX(double x) { x_ = x; } | |
void setY(double y) { y_ = y; } | |
void setRange(double r) { r_ = r; } | |
double x_, y_, r_; | |
}; | |
class MiningFlowchartInfo { | |
public: | |
MiningFlowchartInfo(); | |
virtual ~MiningFlowchartInfo(); | |
void addElement(int id, const QString& name, int type); | |
void addElementPosition(int id, double x, double y, double r); | |
void addPoint(int id_element, int id_point, const QString& point_name); | |
void addConnection(int id_origin, int id_destination); | |
void addPolygonPoint(int id_element, int id_point, double x, double y); | |
double getElementRange(int id_element); | |
int getElementId(const double& latitude, | |
const double& longitude, | |
const double& altitude); | |
int getPointId(int element_id, | |
const double& latitude, | |
const double& longitude, | |
const double& altitude); | |
QList<QString> getElements() const; | |
QList<QString> getElements(int type) const; | |
QList<QString> getPoints(const QString& element) const; | |
MiningPolygon getPolygon(const QString& element, const QString& point) const; | |
QList<QString> getDestinations(const QString& element) const; | |
bool existElement(const QString& element) const; | |
bool existElement(int id) const; | |
bool existPolygon(const QString& element, const QString& point) const; | |
int getElementId(const QString& element) const; | |
int getPointId(const QString& origin, const QString& name) const; | |
QString getElementName(int id) const; | |
QString getPointName(int id_element, int id_point) const; | |
MiningFlowchartPosition getElementPosition(const QString& element); | |
MiningFlowchartPosition getElementPosition(int id); | |
void clear(); | |
QJsonObject serialize(); | |
void unserialize(const QJsonObject& json); | |
static MiningFlowchartInfo* load(QSqlDatabase& db, bool only_active); | |
private: | |
std::map<QString, int> elements_ids_; | |
std::map<int, QString> ids_elements_; | |
std::map<int, int> types_elements_; | |
std::map<int, MiningFlowchartPosition> pos_elements_; | |
std::map<int, std::map<QString, int> > points_ids_; | |
std::map<int, std::map<int, QString> > ids_points_; | |
std::map<int, std::set<int> > connections_; | |
std::map<int, std::map<int, MiningPolygon> > polygons_; | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment