Skip to content

Commit b751f0d

Browse files
authored
Merge branch 'master' into MinyazevR-thickness-patch
2 parents a9a3614 + cb3e098 commit b751f0d

40 files changed

Lines changed: 403 additions & 222 deletions

File tree

.github/workflows/setup_environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ jobs:
208208

209209
- name: Clang-tidy
210210
if: ${{ inputs.lint_clazy }}
211-
uses: cpp-linter/cpp-linter-action@v2.17.0
211+
uses: cpp-linter/cpp-linter-action@v2.18.0
212212
id: linter
213213
with:
214214
style: ''

buildScripts/github/install.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ case "$(uname)" in
4848
libudev-devel libGL-devel libGLX-mesa python3-dev zlib-devel make ccache python3-module-pip time \
4949
qt5-multimedia-devel qt5-svg-devel qt5-script-devel qt5-tools qt5-serialport-devel
5050
elif [ "$ID" = "ubuntu" ]; then
51-
sudo apt-get update && sudo apt-get install -y --no-install-recommends ccache curl libusb-1.0-0-dev \
52-
make qtscript5-dev qttools5-dev-tools qtmultimedia5-dev libqt5serialport5-dev libqt5svg5-dev \
53-
libudev-dev "$TRIK_PYTHON"-dev qtbase5-private-dev qtwayland5 libqscintilla2-qt5-dev libquazip5-dev bear
51+
sudo apt-get update && sudo apt-get install -y --no-install-recommends ccache curl make bear libusb-1.0-0-dev \
52+
qtscript5-dev qttools5-dev-tools qtmultimedia5-dev libqt5serialport5-dev libqt5svg5-dev qtdeclarative5-dev \
53+
libudev-dev "$TRIK_PYTHON"-dev qtbase5-private-dev qtquickcontrols2-5-dev qtwayland5 libqscintilla2-qt5-dev libquazip5-dev
5454
elif [[ "$ID" = "rocky" || "$ID" = '"rocky"' ]]; then
5555
GCC_VERSION=${GCC_VERSION:-13}
5656
sudo yum update -y && sudo yum install -y --setopt=install_weak_deps=False epel-release
@@ -65,7 +65,7 @@ case "$(uname)" in
6565
echo $INSTALL_INSTALLER_ENVIRONMENT
6666
if [ "$INSTALL_INSTALLER_ENVIRONMENT" != "true" ]; then
6767
sudo yum install -y --setopt=install_weak_deps=False qt5-qtscript-devel qt5-qttools-devel qt5-qtmultimedia-devel qt5-qtserialport-devel \
68-
qt5-qtsvg-devel qt5-qtbase-devel qt5-qtbase-private-devel qt5-qtwayland
68+
qt5-qtsvg-devel qt5-qtbase-devel qt5-qtbase-private-devel qt5-qtquickcontrols2 qt5-qtdeclarative-devel qt5-qtwayland
6969
else
7070
sudo yum install -y --setopt=install_weak_deps=False libX11-xcb libXext libxkbcommon-x11 fontconfig freetype libXrender
7171
#libQt5WaylandCompositor.so.5.15: libQt5Quick.so.5 libQt5Qml.so.5 libQt5QmlModels.so.5
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
pyinstaller==6.19.0
2-
numpy==2.4.3; python_version >= "3.11"
2+
numpy==2.4.4; python_version >= "3.11"
33
numpy==2.0.1; python_version < "3.11"

plugins/robots/common/twoDModel/src/engine/items/ellipseItem.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "ellipseItem.h"
1616

1717
#include <QtWidgets/QAction>
18+
#include <qrkernel/settingsManager.h>
1819

1920
using namespace twoDModel::items;
2021
using namespace graphicsUtils;
@@ -28,6 +29,7 @@ EllipseItem::EllipseItem(graphicsUtils::AbstractCoordinateSystem *metricSystem,
2829
setX2(end.x());
2930
setY2(end.y());
3031
setPrivateData();
32+
connect(this, &AbstractItem::mouseInteractionStarted, this, [this]() {mEstimatedPos = pos(); });
3133
}
3234

3335
AbstractItem *EllipseItem::clone() const
@@ -53,11 +55,21 @@ void EllipseItem::setPrivateData()
5355
setPen(pen);
5456
}
5557

58+
void EllipseItem::resizeItem(QGraphicsSceneMouseEvent *event)
59+
{
60+
const auto showGrid = qReal::SettingsManager::value("2dShowGrid").toBool();
61+
const auto gridSize = qReal::SettingsManager::value("2dDoubleGridCellSize").toReal();
62+
AbstractItem::resizeItemCommon(event, mEstimatedPos, showGrid, gridSize);
63+
}
64+
65+
void EllipseItem::reshapeRectWithShift()
66+
{
67+
AbstractItem::reshapeToIsotropic();
68+
}
69+
5670
QRectF EllipseItem::calcNecessaryBoundingRect() const
5771
{
58-
qreal penWidth = pen().widthF();
59-
return QRectF(qMin(x1(), x2()), qMin(y1(), y2()), qAbs(x2() - x1()),
60-
qAbs(y2() - y1())).adjusted(-penWidth, -penWidth, penWidth, penWidth);
72+
return {qMin(x1(), x2()), qMin(y1(), y2()), qAbs(x2() - x1()), qAbs(y2() - y1())};
6173
}
6274

6375
QRectF EllipseItem::boundingRect() const

plugins/robots/common/twoDModel/src/engine/items/ellipseItem.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,16 @@ class EllipseItem : public ColorFieldItem
4545
void deserialize(const QDomElement &element) override;
4646
QPainterPath shapeWihoutResizeArea() const;
4747
QPainterPath shape() const override;
48-
48+
void resizeItem(QGraphicsSceneMouseEvent *event) override;
49+
void reshapeRectWithShift() override;
4950
/// Returns true if ellipse is filled with its pen color or false if it is "empty".
5051
bool filled() const;
5152

5253
/// Fills ellipse with its pen color if true is passed or makes it "empty".
5354
void setFilled(bool filled);
5455

5556
private:
57+
QPointF mEstimatedPos;
5658
void setPrivateData();
5759
};
5860

plugins/robots/common/twoDModel/src/engine/items/imageItem.cpp

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ QPainterPath ImageItem::shape() const
108108
return result;
109109
}
110110

111+
void ImageItem::reshapeRectWithShift()
112+
{
113+
}
114+
111115
QDomElement ImageItem::serialize(QDomElement &parent) const
112116
{
113117
QDomElement imageNode = AbstractItem::serialize(parent);
@@ -240,31 +244,7 @@ QRectF ImageItem::deserializeRect(const QString &string) const
240244

241245
void ImageItem::resizeItem(QGraphicsSceneMouseEvent *event)
242246
{
243-
mEstimatedPos += event->scenePos() - event->lastScenePos();
244-
const auto showGrid = SettingsManager::value("2dShowGrid").toBool();
245-
if (!showGrid || event->modifiers() == Qt::ControlModifier) {
246-
if (dragState() != None) {
247-
calcResizeItem(event);
248-
} else {
249-
setPos(mEstimatedPos);
250-
}
251-
} else if (dragState() != None) {
252-
setFlag(QGraphicsItem::ItemIsMovable, false);
253-
const auto gridSize = SettingsManager::value("2dDoubleGridCellSize").toReal();
254-
const auto x = alignedCoordinate(event->scenePos().x(), gridSize);
255-
const auto y = alignedCoordinate(event->scenePos().y(), gridSize);
256-
setXYWithDragState(mapFromScene(x, y));
257-
} else {
258-
setFlag(QGraphicsItem::ItemIsMovable, false);
259-
// move
260-
setPos(mEstimatedPos);
261-
// and align top left corner to grid
262-
QRectF itemBoundingRect = calcNecessaryBoundingRect();
263-
const auto topLeft = mapToScene(QPointF(itemBoundingRect.left(), itemBoundingRect.top()));
264-
const auto gridSize = SettingsManager::value("2dDoubleGridCellSize").toReal();
265-
const auto x = alignedCoordinate(topLeft.x(), gridSize);
266-
const auto y = alignedCoordinate(topLeft.y(), gridSize);
267-
auto delta = QPointF(x, y) - topLeft;
268-
moveBy(delta.x(), delta.y());
269-
}
247+
const auto showGrid = qReal::SettingsManager::value("2dShowGrid").toBool();
248+
const auto gridSize = qReal::SettingsManager::value("2dDoubleGridCellSize").toReal();
249+
AbstractItem::resizeItemCommon(event, mEstimatedPos, showGrid, gridSize);
270250
}

plugins/robots/common/twoDModel/src/engine/items/imageItem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ImageItem : public graphicsUtils::AbstractItem
4949
void drawExtractionForItem(QPainter* painter) override;
5050
QPainterPath resizeArea() const override;
5151
void resizeItem(QGraphicsSceneMouseEvent *event) override;
52-
52+
void reshapeRectWithShift() override;
5353
QDomElement serialize(QDomElement &parent) const override;
5454
void deserialize(const QDomElement &element) override;
5555

plugins/robots/common/twoDModel/src/engine/items/lineItem.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ LineItem::LineItem(graphicsUtils::AbstractCoordinateSystem *metricSystem,
3434
setX2(end.x());
3535
setY2(end.y());
3636
setPrivateData();
37+
connect(this, &AbstractItem::mouseInteractionStarted, this, [this]() {mEstimatedPos = pos(); });
3738
}
3839

3940
AbstractItem *LineItem::clone() const
@@ -45,7 +46,7 @@ AbstractItem *LineItem::clone() const
4546

4647
QAction *LineItem::lineTool()
4748
{
48-
QAction * const result = new QAction(QIcon(":/icons/2d_ruler.png"), tr("Line (L)"), nullptr);
49+
auto * const result = new QAction(QIcon(":/icons/2d_ruler.png"), tr("Line (L)"), nullptr);
4950
result->setShortcuts({QKeySequence(Qt::Key_L), QKeySequence(Qt::Key_5)});
5051
result->setCheckable(true);
5152
return result;
@@ -65,6 +66,11 @@ QRectF LineItem::boundingRect() const
6566
return mLineImpl.boundingRect(x1(), y1(), x2(), y2(), pen().width(), drift);
6667
}
6768

69+
QRectF LineItem::calcNecessaryBoundingRect() const
70+
{
71+
return {qMin(x1(), x2()), qMin(y1(), y2()), qAbs(x2() - x1()), qAbs(y2() - y1())};
72+
}
73+
6874
void LineItem::drawItem(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
6975
{
7076
Q_UNUSED(option);
@@ -96,15 +102,9 @@ QPainterPath LineItem::resizeArea() const
96102

97103
void LineItem::resizeItem(QGraphicsSceneMouseEvent *event)
98104
{
99-
const bool isResizing = dragState() == TopLeft || dragState() == BottomRight;
100-
if (event->modifiers() & Qt::ShiftModifier && isResizing) {
101-
AbstractItem::resizeItem(event);
102-
reshapeRectWithShift();
103-
} else if (isResizing) {
104-
AbstractItem::resizeItem(event);
105-
} else {
106-
setFlag(QGraphicsItem::ItemIsMovable, true);
107-
}
105+
const auto showGrid = qReal::SettingsManager::value("2dShowGrid").toBool();
106+
const auto gridSize = qReal::SettingsManager::value("2dDoubleGridCellSize").toReal();
107+
AbstractItem::resizeItemCommon(event, mEstimatedPos, showGrid, gridSize);
108108
}
109109

110110
void LineItem::reshapeRectWithShift()
@@ -113,7 +113,7 @@ void LineItem::reshapeRectWithShift()
113113
const qreal differenceY = qAbs(y2() - y1());
114114
const qreal differenceXY = qAbs(differenceX - differenceY);
115115
const qreal size = qMax(differenceX, differenceY);
116-
const int delta = size / 2;
116+
const int delta = static_cast<int>(size / 2);
117117
if (differenceXY > delta) {
118118
const qreal corner1X = dragState() == TopLeft ? x2() : x1();
119119
const qreal corner1Y = dragState() == TopLeft ? y2() : y1();

plugins/robots/common/twoDModel/src/engine/items/lineItem.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class LineItem : public ColorFieldItem
3838
QPainterPath shape() const override;
3939

4040
QRectF boundingRect() const override;
41-
void drawItem(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override;
41+
QRectF calcNecessaryBoundingRect() const override;
42+
void drawItem(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override;
4243
void drawExtractionForItem(QPainter* painter) override;
4344

4445
void resizeItem(QGraphicsSceneMouseEvent *event) override;
@@ -53,6 +54,7 @@ class LineItem : public ColorFieldItem
5354
void setSerializeName(const QString &name);
5455

5556
protected:
57+
QPointF mEstimatedPos;
5658
void setPrivateData();
5759

5860
graphicsUtils::LineImpl mLineImpl;

plugins/robots/common/twoDModel/src/engine/items/rectangleItem.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "rectangleItem.h"
1616
#include <QMenu>
1717
#include <QtWidgets/QAction>
18+
#include <qrkernel/settingsManager.h>
1819

1920
using namespace twoDModel::items;
2021
using namespace graphicsUtils;
@@ -28,6 +29,7 @@ RectangleItem::RectangleItem(graphicsUtils::AbstractCoordinateSystem *metricSyst
2829
setX2(end.x());
2930
setY2(end.y());
3031
setPrivateData();
32+
connect(this, &AbstractItem::mouseInteractionStarted, this, [this]() {mEstimatedPos = pos(); });
3133
}
3234

3335
AbstractItem *RectangleItem::clone() const
@@ -53,11 +55,14 @@ void RectangleItem::setPrivateData()
5355
setPen(pen);
5456
}
5557

58+
void RectangleItem::reshapeRectWithShift()
59+
{
60+
AbstractItem::reshapeToIsotropic();
61+
}
62+
5663
QRectF RectangleItem::calcNecessaryBoundingRect() const
5764
{
58-
qreal penWidth = pen().widthF();
59-
return QRectF(qMin(x1(), x2()), qMin(y1(), y2()), qAbs(x2() - x1()),
60-
qAbs(y2() - y1())).adjusted(-penWidth, -penWidth, penWidth, penWidth);
65+
return {qMin(x1(), x2()), qMin(y1(), y2()), qAbs(x2() - x1()), qAbs(y2() - y1())};
6166
}
6267

6368
QRectF RectangleItem::boundingRect() const
@@ -135,6 +140,13 @@ QPainterPath RectangleItem::shapeWihoutResizeArea() const
135140
return result;
136141
}
137142

143+
void RectangleItem::resizeItem(QGraphicsSceneMouseEvent *event)
144+
{
145+
const auto showGrid = qReal::SettingsManager::value("2dShowGrid").toBool();
146+
const auto gridSize = qReal::SettingsManager::value("2dDoubleGridCellSize").toReal();
147+
AbstractItem::resizeItemCommon(event, mEstimatedPos, showGrid, gridSize);
148+
}
149+
138150
QPainterPath RectangleItem::shape() const
139151
{
140152
QPainterPath result;

0 commit comments

Comments
 (0)