This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
IndoorMap/mapview/model/MMFloorUnderlayImage.h
2016-05-24 16:55:19 +02:00

79 lines
2.1 KiB
C++

#ifndef MMFLOORUNDERLAYIMAGE_H
#define MMFLOORUNDERLAYIMAGE_H
#include "IHasFile.h"
#include "IHasParams.h"
#include "MapModelElement.h"
#include "../elements/MV2DElementFloorUnderlay.h"
#include <Indoor/floorplan/v2/Floorplan.h>
/**
* add an external image file as underlay (to copy it onto the map)
*/
class MMFloorUnderlayImage : public MapModelElement, public MapLayer, public IHasFile, public IHasParams {
private:
Floorplan::Floor* floor;
Floorplan::UnderlayImage* img;
MV2DElementFloorUnderlay mv2d;
std::string fileName;
public:
/** ctor */
MMFloorUnderlayImage(MapLayer* parent, Floorplan::Floor* floor, Floorplan::UnderlayImage* img) : MapModelElement(parent), MapLayer(parent, MapLayerType::FLOOR_UNDERLAY), floor(floor), img(img), mv2d(img) {
setFileName(img->filename);
}
virtual void setFileName(const std::string& file) {img->filename = file;}
virtual const std::string& getFileName() const {return img->filename;}
void setAnchor(const Point2 anchor) {img->anchor = anchor;}
Point2 getAnchor() const {return img->anchor;}
void setScale(const float x, const float y) {img->scaleX = x; img->scaleY = y;}
virtual std::string getLayerName() const override {return "underlay";}
MV2DElement* getMV2D() const override {return (MV2DElement*) &mv2d;}
void deleteMe() const override {
;
}
int getNumParams() const override {return 3;}
virtual Param getParamDesc(const int idx) const override {
switch (idx) {
case 0: return Param("file", ParamType::FILE);
case 1: return Param("scale X", ParamType::FLOAT);
case 2: return Param("scale Y", ParamType::FLOAT);
default: throw 1;
}
}
virtual ParamValue getParamValue(const int idx) const override {
switch(idx) {
case 0: return ParamValue(img->filename);
case 1: return ParamValue(img->scaleX);
case 2: return ParamValue(img->scaleY);
default: throw 1;
}
}
virtual void setParamValue(const int idx, const ParamValue& val) const override {
switch (idx) {
case 0: img->filename = val.toString();
case 1: img->scaleX = val.toFloat();
case 2: img->scaleY = val.toFloat();
default: throw 1;
}
}
};
#endif // MMFLOORUNDERLAYIMAGE_H