added option for underlay opacity change

adjusted interface [removed invalid const]
This commit is contained in:
2017-03-20 15:25:54 +01:00
parent 61bd64d9b0
commit 92e279aefc
15 changed files with 29 additions and 18 deletions

View File

@@ -20,6 +20,7 @@ private:
std::string tmpFile;
Floorplan::UnderlayImage* underlay;
BBox2 bbox;
float opacity = 0.5;
int selPoint = -1;
@@ -55,6 +56,9 @@ public:
selPoint = -1; // clear selection
}
float getOpacity() const {return opacity;}
void setOpacity(const float o) {this->opacity = o;}
void paint(Painter& p) override {
(void) p;
@@ -101,9 +105,9 @@ public:
imgScaled = QImage();
}
float opacity = p.p->opacity();
p.p->setOpacity(0.50f);
// current opacity?
float _oldOpacity = p.p->opacity();
p.p->setOpacity(opacity);
// render downscaled image from cache? or use live-upscaling (faster, eats up less memory, ...)
if (imgScaled.width() > 0) {
@@ -113,7 +117,8 @@ public:
p.p->drawImage(QRectF(sx1, sy1-sh, sw, sh), img, QRectF(0,0,img.width(),img.height()));
}
p.p->setOpacity(opacity);
// reset
p.p->setOpacity(_oldOpacity);
// selected endpoint(s)?
if (hasFocus()) {

View File

@@ -282,6 +282,7 @@ private:
(void) m;
// currently: only accept keys when something is focused
if (focused) {
// pass it to the element which may consume this event

View File

@@ -104,7 +104,7 @@ public:
virtual ParamValue getParamValue(const int idx) const = 0;
/** set the idx-th param's value */
virtual void setParamValue(const int idx, const ParamValue& val) const = 0;
virtual void setParamValue(const int idx, const ParamValue& val) = 0;
};

View File

@@ -83,7 +83,7 @@ public:
throw 1;
}
virtual void setParamValue(const int idx, const ParamValue& val) const override {
virtual void setParamValue(const int idx, const ParamValue& val) override {
switch(idx) {
case 0: floor->name = val.toString(); break;
case 1: floor->height = val.toFloat(); break;

View File

@@ -54,7 +54,7 @@ public:
throw 1;
}
virtual void setParamValue(const int idx, const ParamValue& val) const override {
virtual void setParamValue(const int idx, const ParamValue& val) override {
switch(idx) {
case 0: ap->name = val.toString(); break;
case 1: ap->mac = val.toString(); break;

View File

@@ -56,7 +56,7 @@ public:
throw 1;
}
virtual void setParamValue(const int idx, const ParamValue& val) const override {
virtual void setParamValue(const int idx, const ParamValue& val) override {
switch(idx) {
case 0: b->name = val.toString(); break;
case 1: b->pos = val.toPoint3(); break;

View File

@@ -47,7 +47,7 @@ public:
throw 1;
}
virtual void setParamValue(const int idx, const ParamValue& val) const override {
virtual void setParamValue(const int idx, const ParamValue& val) override {
switch(idx) {
case 0: elevator->width = val.toFloat(); break;
case 1: elevator->depth = val.toFloat(); break;

View File

@@ -49,7 +49,7 @@ public:
throw 1;
}
virtual void setParamValue(const int idx, const ParamValue& val) const override {
virtual void setParamValue(const int idx, const ParamValue& val) override {
switch(idx) {
case 0: fpl->name = val.toString(); break;
case 1: fpl->posOnFloor = val.toPoint2(); break;

View File

@@ -42,7 +42,7 @@ public:
throw 1;
}
virtual void setParamValue(const int idx, const ParamValue& val) const override {
virtual void setParamValue(const int idx, const ParamValue& val) override {
switch(idx) {
case 0: gtp->id = val.toInt(); break;
case 1: gtp->pos = val.toPoint3(); break;

View File

@@ -70,7 +70,7 @@ public:
}
/** set the idx-th param's value */
virtual void setParamValue(const int idx, const ParamValue& val) const override {
virtual void setParamValue(const int idx, const ParamValue& val) override {
switch (idx) {
case 0: break;
case 1: fo->height = val.toFloat(); break;

View File

@@ -63,7 +63,7 @@ public:
throw 1;
}
virtual void setParamValue(const int idx, const ParamValue& val) const override {
virtual void setParamValue(const int idx, const ParamValue& val) override {
switch(idx) {
case 0: break;
}

View File

@@ -57,7 +57,7 @@ public:
throw 1;
}
virtual void setParamValue(const int idx, const ParamValue& val) const override {
virtual void setParamValue(const int idx, const ParamValue& val) override {
switch(idx) {
case 0: fo->name = val.toString(); break;
case 1: fo->outdoor = val.toBool(); break;

View File

@@ -44,7 +44,7 @@ public:
throw 1;
}
virtual void setParamValue(const int idx, const ParamValue& val) const override {
virtual void setParamValue(const int idx, const ParamValue& val) override {
switch(idx) {
case 0: poi->name = val.toString(); break;
case 1: poi->type = (Floorplan::POIType) val.toInt(); break;

View File

@@ -66,7 +66,7 @@ public:
throw 1;
}
virtual void setParamValue(const int idx, const ParamValue& val) const override {
virtual void setParamValue(const int idx, const ParamValue& val) override {
const int selPart = mv2d.getSelPart();
const int selNode = mv2d.getSelNode();
switch(idx) {

View File

@@ -39,7 +39,9 @@ public:
;
}
int getNumParams() const override {return 4;}
int getNumParams() const override {
return 5;
}
virtual Param getParamDesc(const int idx) const override {
switch (idx) {
@@ -47,6 +49,7 @@ public:
case 1: return Param("scale X", ParamType::FLOAT);
case 2: return Param("scale Y", ParamType::FLOAT);
case 3: return Param("Anchor", ParamType::POINT2);
case 4: return Param("opacity", ParamType::FLOAT);
default: throw 1;
}
}
@@ -57,16 +60,18 @@ public:
case 1: return ParamValue(img->scaleX);
case 2: return ParamValue(img->scaleY);
case 3: return ParamValue(img->anchor);
case 4: return ParamValue(mv2d.getOpacity());
default: throw 1;
}
}
virtual void setParamValue(const int idx, const ParamValue& val) const override {
virtual void setParamValue(const int idx, const ParamValue& val) override {
switch (idx) {
case 0: img->filename = val.toString(); break;
case 1: img->scaleX = val.toFloat(); break;
case 2: img->scaleY = val.toFloat(); break;
case 3: img->anchor = val.toPoint2(); break;
case 4: mv2d.setOpacity(val.toFloat()); break;
default: throw 1;
}
}