From 1c726805839771a2fdd3dc23d613cd5e63ff3d46 Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Fri, 10 Sep 2021 21:50:03 +0300 Subject: [PATCH] ref #97 Fixing methon darwSquare, added a new the method drawLine. --- src/Core/Crawl/controlpos.cpp | 42 ++++++++++++++++++++++------------- src/Core/Crawl/controlpos.h | 5 +++++ 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/Core/Crawl/controlpos.cpp b/src/Core/Crawl/controlpos.cpp index 696a2b7..33d1ed5 100644 --- a/src/Core/Crawl/controlpos.cpp +++ b/src/Core/Crawl/controlpos.cpp @@ -51,6 +51,7 @@ void ControlPos::updatePosition() { break; case LINE: + drawLine(); break; default: @@ -62,7 +63,7 @@ void ControlPos::updatePosition() { void ControlPos::drawCircle() { if (objects().size() == 0) { - QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object.", QuasarAppUtils::Error)); + QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object."), QuasarAppUtils::Error); return; } @@ -83,29 +84,40 @@ void ControlPos::drawCircle() { void ControlPos::drawSquare() { if (objects().size() == 0) { - QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object.")); + QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object."), QuasarAppUtils::Error); return; } int height = qFloor(qSqrt(objects().size())); - int width = qCeil(qSqrt(objects().size())); - int coutObj = 0; - for (int y = 0; y < height; y++) { + int indObject = 0; + for (auto idObj = objects().keyBegin(); idObj != objects().keyEnd(); idObj++) { - coutObj = coutObj+y; - for (int x = 0; x < width; x++) { + int x = indObject % height; + int y = qCeil(indObject / height); + + GroupObject::updatePosition(idObj, {x + _distance, + y + _distance, + 0}); + indObject++; - if (coutObj == objects().size()) { - return; - } - GroupObject::updatePosition(objects()[coutObj]->guiId(), {float(x + _distance), - float(y + _distance), - 0}); - coutObj++; - } } } +void ControlPos::drawLine() { + + if (objects().size() == 0) { + QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object."), QuasarAppUtils::Error); + return; + } + + float xObject = 0; + for (ClasterItem* object: objects()) { + GroupObject::updatePosition(object->guiId(), {xObject + _distance, 0, 0}); + + xObject++; + } +} + } diff --git a/src/Core/Crawl/controlpos.h b/src/Core/Crawl/controlpos.h index c0af58f..c1c6d95 100644 --- a/src/Core/Crawl/controlpos.h +++ b/src/Core/Crawl/controlpos.h @@ -63,6 +63,11 @@ private: * @brief drawSquare This method updates the coordinates to a square shape. */ void drawSquare(); + + /** + * @brief drawLine This method updates the coordinates to a line shape. + */ + void drawLine(); int _distance; Refresh _shape;