VS fixes
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
QT += core gui opengl
|
||||
|
||||
CONFIG += c++11 -g3 -O0
|
||||
CONFIG += c++17 -g3 -O0
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets svg
|
||||
|
||||
@@ -16,13 +16,18 @@ TEMPLATE = app
|
||||
DEFINES += WITH_ASSERTIONS
|
||||
DEFINES += WITH_DEBUG_LOG
|
||||
|
||||
win32 {
|
||||
DEFINES += _USE_MATH_DEFINES
|
||||
|
||||
LIBS+= -llibGLESV2d
|
||||
}
|
||||
|
||||
INCLUDEPATH += \
|
||||
../
|
||||
|
||||
|
||||
|
||||
SOURCES += \
|
||||
lib/gpc/gpc.cpp \
|
||||
main.cpp \
|
||||
MainWindow.cpp \
|
||||
MainController.cpp \
|
||||
|
||||
@@ -103,7 +103,7 @@ MainController::MainController() {
|
||||
connect(mw, &MainWindow::onGridNodeColorType, [&] () {mw->getMapView3D()->getGridRenderer()->setNodeColorMode(GridRendererColorMode::SHOW_NODE_TYPE);} );
|
||||
connect(mw, &MainWindow::onGridShowEdges, [&] (const bool show) {mw->getMapView3D()->getGridRenderer()->setShowEdges(show);} );
|
||||
|
||||
Ray3D::OBJPool::get().init("/mnt/vm/paper/diss/code/IndoorMap/res/mdl/");
|
||||
Ray3D::OBJPool::get().init("C:/Temp/");
|
||||
|
||||
//mapModel->load("../IndoorMap/maps/SHL36_noel.xml");
|
||||
//mapModel->load("../IndoorMap/maps/SHL38_no_elev.xml");
|
||||
|
||||
@@ -232,7 +232,7 @@ private:
|
||||
|
||||
const float g = m->getScaler().sm(15); // increase each BBox by 15 px (needed mainly for hor/ver lines)
|
||||
|
||||
#warning "which elements to select? among all currently visible? or only among the selected layer?"
|
||||
#pragma message "which elements to select? among all currently visible? or only among the selected layer?"
|
||||
// get all elements with bounding-box matchings
|
||||
std::vector<MapModelElement*> possible;
|
||||
// for (MapModelElement* el : m->getModel()->getSelectedLayerElements()) {
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
#define MV3DELEMENTFLOOROUTLINE_H
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
#include <Indoor/wifi/estimate/ray3/ModelFactoryHelper.h>
|
||||
|
||||
#include "misc/Cube.h"
|
||||
#include "MV3DElement.h"
|
||||
|
||||
#include "../../lib/gpc/gpc.h"
|
||||
#include "misc/Polygon.h"
|
||||
#include "misc/Outline.h"
|
||||
|
||||
class MV3DElementFloorOutline : public MV3DElement {
|
||||
@@ -17,7 +17,7 @@ class MV3DElementFloorOutline : public MV3DElement {
|
||||
|
||||
struct Temp {
|
||||
Point2 cacheSum;
|
||||
Polygon* pol = nullptr;
|
||||
Ray3D::Polygon* pol = nullptr;
|
||||
std::vector<std::vector<Point3>> trias;
|
||||
};
|
||||
|
||||
@@ -80,7 +80,7 @@ protected:
|
||||
std::vector<gpc_polygon> add;
|
||||
std::vector<gpc_polygon> rem;
|
||||
if (tmp.pol) {delete tmp.pol;}
|
||||
tmp.pol = new Polygon();
|
||||
tmp.pol = new Ray3D::Polygon();
|
||||
|
||||
// all to-be-added polygons (filter!)
|
||||
for (Floorplan::FloorOutlinePolygon* poly : polys) {
|
||||
|
||||
@@ -295,7 +295,7 @@ void MapView3D::draw() {
|
||||
V.rotate(rot.z, 0.0, 0.0, 1.0);
|
||||
V.translate(center.x, center.y, center.z);
|
||||
|
||||
float far = 200; // TODO
|
||||
float farPlane = 200; // TODO
|
||||
|
||||
// projection
|
||||
QMatrix4x4 P;
|
||||
@@ -306,14 +306,14 @@ void MapView3D::draw() {
|
||||
float h = height() / 30;
|
||||
viewport.size.x = w;
|
||||
viewport.size.y = h;
|
||||
P.perspective(45.0f, aspect, 0.01, far);
|
||||
P.perspective(45.0f, aspect, 0.01, farPlane);
|
||||
} else {
|
||||
// default size: 50 * 50/aspect meters
|
||||
float w = 50.0f;
|
||||
float h = 50.0f * height() / width();
|
||||
viewport.size.x = w;
|
||||
viewport.size.y = h;
|
||||
P.ortho(-w, +w, -h, +h, 0.1f, +far);
|
||||
P.ortho(-w, +w, -h, +h, 0.1f, +farPlane);
|
||||
}
|
||||
|
||||
rs.shader->bind();
|
||||
|
||||
@@ -10,17 +10,17 @@ class RenderTriangle {
|
||||
struct Vertex{
|
||||
float x,y,z;
|
||||
Vertex(const float x, const float y, const float z) : x(x), y(y), z(z) {;}
|
||||
} __attribute__((packed));
|
||||
};
|
||||
|
||||
struct Normal {
|
||||
float x,y,z;
|
||||
Normal(const float x, const float y, const float z) : x(x), y(y), z(z) {;}
|
||||
} __attribute__((packed));
|
||||
};
|
||||
|
||||
struct RGBA {
|
||||
float r,g,b,a;
|
||||
RGBA(const float r, const float g, const float b, const float a) : r(r), g(g), b(b), a(a) {;}
|
||||
} __attribute__((packed));
|
||||
};
|
||||
|
||||
std::vector<Vertex> vertices;
|
||||
std::vector<Normal> normals;
|
||||
|
||||
@@ -1,110 +1,112 @@
|
||||
#ifndef POLYGON_H
|
||||
#define POLYGON_H
|
||||
// Duplicated file with Indoor/wifi/estimate/ray3/ModelFactoryHelper.h
|
||||
|
||||
//#ifndef POLYGON_H
|
||||
//#define POLYGON_H
|
||||
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
#include "../../../lib/gpc/gpc.h"
|
||||
//#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
//#include "../../../lib/gpc/gpc.h"
|
||||
|
||||
class Polygon {
|
||||
//class Polygon_ {
|
||||
|
||||
struct GPCPolygon : gpc_polygon {
|
||||
GPCPolygon() {
|
||||
// contour = (gpc_vertex_list*) calloc(0, 1024);
|
||||
// contour->num_vertices = 0;
|
||||
// contour->vertex = (gpc_vertex*) calloc(0, 1024);
|
||||
// hole = (int*) calloc(0, 1024);
|
||||
num_contours = 0;
|
||||
contour = nullptr;
|
||||
hole = nullptr;
|
||||
}
|
||||
~GPCPolygon() {
|
||||
if (contour) {
|
||||
gpc_free_polygon(this);
|
||||
//free(contour->vertex); contour->vertex = nullptr;
|
||||
}
|
||||
free(contour); contour = nullptr;
|
||||
free(hole); hole = nullptr;
|
||||
// struct GPCPolygon : gpc_polygon {
|
||||
// GPCPolygon() {
|
||||
//// contour = (gpc_vertex_list*) calloc(0, 1024);
|
||||
//// contour->num_vertices = 0;
|
||||
//// contour->vertex = (gpc_vertex*) calloc(0, 1024);
|
||||
//// hole = (int*) calloc(0, 1024);
|
||||
// num_contours = 0;
|
||||
// contour = nullptr;
|
||||
// hole = nullptr;
|
||||
// }
|
||||
// ~GPCPolygon() {
|
||||
// if (contour) {
|
||||
// gpc_free_polygon(this);
|
||||
// //free(contour->vertex); contour->vertex = nullptr;
|
||||
// }
|
||||
// free(contour); contour = nullptr;
|
||||
// free(hole); hole = nullptr;
|
||||
|
||||
}
|
||||
GPCPolygon& operator = (const GPCPolygon& o) = delete;
|
||||
GPCPolygon& operator = (GPCPolygon& o) {
|
||||
this->contour = o.contour;
|
||||
this->hole = o.hole;
|
||||
this->num_contours = o.num_contours;
|
||||
o.contour = nullptr;
|
||||
o.hole = nullptr;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
// }
|
||||
// GPCPolygon& operator = (const GPCPolygon& o) = delete;
|
||||
// GPCPolygon& operator = (GPCPolygon& o) {
|
||||
// this->contour = o.contour;
|
||||
// this->hole = o.hole;
|
||||
// this->num_contours = o.num_contours;
|
||||
// o.contour = nullptr;
|
||||
// o.hole = nullptr;
|
||||
// return *this;
|
||||
// }
|
||||
// };
|
||||
|
||||
private:
|
||||
//private:
|
||||
|
||||
GPCPolygon state;
|
||||
// GPCPolygon state;
|
||||
|
||||
public:
|
||||
//public:
|
||||
|
||||
void add(const Floorplan::Polygon2& poly) {
|
||||
GPCPolygon cur = toGPC(poly);
|
||||
//GPCPolygon out;
|
||||
gpc_polygon_clip(GPC_UNION, &state, &cur, &state);
|
||||
//state = out;
|
||||
}
|
||||
// void add(const Floorplan::Polygon2& poly) {
|
||||
// GPCPolygon cur = toGPC(poly);
|
||||
// //GPCPolygon out;
|
||||
// gpc_polygon_clip(GPC_UNION, &state, &cur, &state);
|
||||
// //state = out;
|
||||
// }
|
||||
|
||||
void remove(const Floorplan::Polygon2& poly) {
|
||||
GPCPolygon cur = toGPC(poly);
|
||||
//GPCPolygon out;
|
||||
gpc_polygon_clip(GPC_DIFF, &state, &cur, &state);
|
||||
//state = out;
|
||||
}
|
||||
// void remove(const Floorplan::Polygon2& poly) {
|
||||
// GPCPolygon cur = toGPC(poly);
|
||||
// //GPCPolygon out;
|
||||
// gpc_polygon_clip(GPC_DIFF, &state, &cur, &state);
|
||||
// //state = out;
|
||||
// }
|
||||
|
||||
std::vector<std::vector<Point3>> get(float z) {
|
||||
// std::vector<std::vector<Point3>> get(float z) {
|
||||
|
||||
gpc_tristrip res;
|
||||
res.num_strips = 0;
|
||||
res.strip = nullptr;
|
||||
// gpc_tristrip res;
|
||||
// res.num_strips = 0;
|
||||
// res.strip = nullptr;
|
||||
|
||||
//res.strip = (gpc_vertex_list*) malloc(1024);
|
||||
gpc_polygon_to_tristrip(&state, &res);
|
||||
// //res.strip = (gpc_vertex_list*) malloc(1024);
|
||||
// gpc_polygon_to_tristrip(&state, &res);
|
||||
|
||||
std::vector<std::vector<Point3>> trias;
|
||||
// std::vector<std::vector<Point3>> trias;
|
||||
|
||||
for (int i = 0; i < res.num_strips; ++i) {
|
||||
gpc_vertex_list lst = res.strip[i];
|
||||
std::vector<Point3> tria;
|
||||
for (int j = 0; j < lst.num_vertices; ++j) {
|
||||
gpc_vertex& vert = lst.vertex[j];
|
||||
Point3 p3(vert.x, vert.y, z);
|
||||
tria.push_back(p3);
|
||||
}
|
||||
trias.push_back(tria);
|
||||
}
|
||||
// for (int i = 0; i < res.num_strips; ++i) {
|
||||
// gpc_vertex_list lst = res.strip[i];
|
||||
// std::vector<Point3> tria;
|
||||
// for (int j = 0; j < lst.num_vertices; ++j) {
|
||||
// gpc_vertex& vert = lst.vertex[j];
|
||||
// Point3 p3(vert.x, vert.y, z);
|
||||
// tria.push_back(p3);
|
||||
// }
|
||||
// trias.push_back(tria);
|
||||
// }
|
||||
|
||||
gpc_free_tristrip(&res);
|
||||
// gpc_free_tristrip(&res);
|
||||
|
||||
return std::move(trias);
|
||||
// return std::move(trias);
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
private:
|
||||
//private:
|
||||
|
||||
GPCPolygon toGPC(Floorplan::Polygon2 poly) {
|
||||
// GPCPolygon toGPC(Floorplan::Polygon2 poly) {
|
||||
|
||||
std::vector<gpc_vertex> verts;
|
||||
for (Point2 p2 : poly.points) {
|
||||
gpc_vertex vert; vert.x = p2.x; vert.y = p2.y;
|
||||
verts.push_back(vert);
|
||||
}
|
||||
// std::vector<gpc_vertex> verts;
|
||||
// for (Point2 p2 : poly.points) {
|
||||
// gpc_vertex vert; vert.x = p2.x; vert.y = p2.y;
|
||||
// verts.push_back(vert);
|
||||
// }
|
||||
|
||||
GPCPolygon gpol;
|
||||
gpc_vertex_list list;
|
||||
list.num_vertices = verts.size();
|
||||
list.vertex = verts.data();
|
||||
gpc_add_contour(&gpol, &list, 0);
|
||||
// GPCPolygon gpol;
|
||||
// gpc_vertex_list list;
|
||||
// list.num_vertices = verts.size();
|
||||
// list.vertex = verts.data();
|
||||
// gpc_add_contour(&gpol, &list, 0);
|
||||
|
||||
return gpol;
|
||||
// return gpol;
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
};
|
||||
//};
|
||||
|
||||
#endif // POLYGON_H
|
||||
//#endif // POLYGON_H
|
||||
|
||||
@@ -41,8 +41,11 @@ public:
|
||||
_parent = static_cast<MapLayer*>(parent.internalPointer());
|
||||
}
|
||||
|
||||
if (_parent->getSubLayers().size() > 0) {
|
||||
return createIndex(row, column, _parent->getSubLayers().at(row));
|
||||
|
||||
} else {
|
||||
return createIndex(0, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
virtual QModelIndex parent(const QModelIndex& child) const override {
|
||||
|
||||
Reference in New Issue
Block a user