diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj
index 4d9e8c2..5e66811 100644
--- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj
+++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj
@@ -212,7 +212,7 @@
-
+
diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
index 75a8390..4092917 100644
--- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
+++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
@@ -329,6 +329,9 @@
Header Files
+
+ Header Files\Editor\Element
+
@@ -519,9 +522,6 @@
Header Files\Editor\util
-
- Header Files\Editor\Element
-
Header Files\Editor\Element
diff --git a/ArchitectureColoredPainting/src/Editor/ElementManager.cpp b/ArchitectureColoredPainting/src/Editor/ElementManager.cpp
index 2f601aa..5c46d99 100644
--- a/ArchitectureColoredPainting/src/Editor/ElementManager.cpp
+++ b/ArchitectureColoredPainting/src/Editor/ElementManager.cpp
@@ -18,6 +18,14 @@ ElementManager::ElementManager(QJsonObject source, QString fileHome)
}
for (auto element : elements)
element->index = index++;
+ timer = new QTimer();
+ timer->setInterval(30000);
+ connect(timer, &QTimer::timeout, this, [this]() {
+ for (auto element : elements)
+ if (typeid(*element) == typeid(SimpleElement))
+ ((SimpleElement*)element)->forceRefresh = true;
+ });
+ timer->start();
}
void ElementManager::addElement(GraphicElement *element)
diff --git a/ArchitectureColoredPainting/src/Editor/ElementManager.h b/ArchitectureColoredPainting/src/Editor/ElementManager.h
index 7cb3839..17803b4 100644
--- a/ArchitectureColoredPainting/src/Editor/ElementManager.h
+++ b/ArchitectureColoredPainting/src/Editor/ElementManager.h
@@ -4,17 +4,20 @@
#include
#include "../Renderer/Preview/ElementRenderer.h"
#include
+#include
using std::vector;
class LayerManager;
class GraphicElement;
class Renderer::ElementRenderer;
class FolderLayerWrapper;
-class ElementManager
+class ElementManager : public QObject
{
+ Q_OBJECT
public:
vector elements;
QString fileHome;
+ QTimer* timer;
public:
ElementManager(QJsonObject source, QString fileHome);
diff --git a/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp b/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp
index 580d3a3..bcee199 100644
--- a/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp
+++ b/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp
@@ -112,12 +112,12 @@ void SimpleElement::paint(QPainter* painter, QTransform transform, const LayerSt
maxScale = std::max(fabs(transform.m11() / cos(angle)), fabs(transform.m22() / cos(angle)));
else
maxScale = std::max(fabs(transform.m12() / sin(angle)), fabs(transform.m21() / sin(angle)));
- //double pixelRatio = maxScale * QGuiApplication::primaryScreen()->devicePixelRatio();
- double pixelRatio = 5;
- if (painterPath == painterPathPrev && styles.getHash() == stylesHashValue && fabs(pixelRatio - pixelRatioPrev) < 1e-3)
+ double pixelRatio = maxScale * QGuiApplication::primaryScreen()->devicePixelRatio();
+ //double pixelRatio = 5;
+ if (painterPath == painterPathPrev && styles.getHash() == stylesHashValue && pixelRatioPrev >= pixelRatio && !forceRefresh)
{
transform.translate(movPrev.x(), movPrev.y());
- painter->setTransform(transform.scale(1 / pixelRatio, 1 / pixelRatio));
+ painter->setTransform(transform.scale(1 / pixelRatioPrev, 1 / pixelRatioPrev));
painter->drawImage(0, 0, imagePrev);
}
else
@@ -131,6 +131,7 @@ void SimpleElement::paint(QPainter* painter, QTransform transform, const LayerSt
imagePrev = img;
movPrev = mov;
pixelRatioPrev = pixelRatio;
+ forceRefresh = false;
}
}
diff --git a/ArchitectureColoredPainting/src/Editor/GraphicElement.h b/ArchitectureColoredPainting/src/Editor/GraphicElement.h
index 6e6c301..7962d5c 100644
--- a/ArchitectureColoredPainting/src/Editor/GraphicElement.h
+++ b/ArchitectureColoredPainting/src/Editor/GraphicElement.h
@@ -61,6 +61,7 @@ public:
void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) override;
bool isClosed() const override;
void paintPreview(QPainter* painter) override;
+ bool forceRefresh = false;
};
class GroupElement : public GraphicElement