added a ruler for measuring

added support for meta-data editing
improved element selection
changed zooming
fixed some issues with layer events
fixed issue with 3D outline
fixed loading issue for old maps
some interface changes
This commit is contained in:
2017-03-10 13:44:17 +01:00
parent 2297a76c53
commit f40fc9a823
32 changed files with 809 additions and 198 deletions

View File

@@ -5,6 +5,8 @@
#include <vector>
#include <algorithm>
#include "MapLayerListener.h"
class MapModelElement;
@@ -27,14 +29,17 @@ enum class MapLayerType {
class MapLayer {
/** this layer's elements */
std::vector<MapModelElement*> elements;
/** attached listeners (if any) */
std::vector<MapLayerListener*> listeners;
protected:
/** this layer's parent */
MapLayer* parent;
/** this layer's elements */
std::vector<MapModelElement*> elements;
/** this layer's sublayers */
std::vector<MapLayer*> sublayers;
@@ -59,6 +64,11 @@ public:
/** dtor */
virtual ~MapLayer() {;}
/** attach a listener to this layer [usually only added to the root layer] */
void addListener(MapLayerListener* listener) {
listeners.push_back(listener);
}
/** get the layer's parent */
MapLayer* getParent() const {return parent;}
@@ -76,7 +86,16 @@ public:
size_t getNumElements() const {return elements.size();}
/** remove the given element from the elements list */
void removeElement(const MapModelElement* elem) { elements.erase(std::remove(elements.begin(), elements.end(), elem), elements.end()); }
void removeElement(const MapModelElement* elem) {
elements.erase(std::remove(elements.begin(), elements.end(), elem), elements.end());
onElemRemoved(elem);
}
/** add a new element to this layer */
void addElement(MapModelElement* el) {
elements.push_back(el);
onElemAdded(el);
}
/** remove the given sublayer from this layer */
void removeSublayer(const MapLayer* layer) { sublayers.erase(std::remove(sublayers.begin(), sublayers.end(), layer), sublayers.end()); }
@@ -85,7 +104,10 @@ public:
bool isVisible() const {return visible;}
/** make this layer visible */
void setVisible(const bool visible) {this->visible = visible;}
void setVisible(const bool visible) {
this->visible = visible;
onVisibilityChanged(visible);
}
/** get all sub-layers within this layer */
@@ -95,7 +117,7 @@ public:
/** helper method to get all elements and those of all sub-layers */
void getVisibleElementsRecursive(std::vector<MapModelElement*>& el) {
if (isVisible()) {
std::vector<MapModelElement*> local = getElements();
const std::vector<MapModelElement*> local = getElements();
el.insert(el.end(), local.begin(), local.end());
for (MapLayer* sub : getSubLayers()) {
sub->getVisibleElementsRecursive(el);
@@ -105,8 +127,6 @@ public:
public:
/** add a new sublayer to this layer */
void addSublayer(MapLayer* ml) {
@@ -116,8 +136,35 @@ public:
}
private:
void onElemAdded(MapModelElement* e) {
if (parent) {parent->onElemAdded(e);}
for (MapLayerListener* listener : listeners) {
listener->onLayerChanged(this);
listener->onLayerElementAdded(this, e);
}
}
void onElemRemoved(const MapModelElement* e) {
if (parent) {parent->onElemRemoved(e);}
for (MapLayerListener* listener : listeners) {
listener->onLayerChanged(this);
listener->onLayerElementRemoved(this, e);
}
}
void onVisibilityChanged(const bool visibile) {
if (parent) {parent->onVisibilityChanged(visibile);}
for (MapLayerListener* listener : listeners) {
listener->onLayerChanged(this);
listener->onLayerVisibilityChanged(this, visibile);
}
}
};
class MapLayerRoot : public MapLayer {
public: