From eeceedab8ce5357bf9d5743c4f0e9beb0e05465e Mon Sep 17 00:00:00 2001 From: Jonas Mucke Date: Sun, 26 Jan 2020 19:10:45 +0100 Subject: [PATCH] =?UTF-8?q?hotfix,=20rechtsklick=20bringte=20das=20program?= =?UTF-8?q?m=20zum=20abst=C3=BCrzen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Tool/IntelliToolGradient.cpp | 27 +++++----- src/Tool/IntelliToolGradient.h | 93 ++++++++++++++++---------------- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/Tool/IntelliToolGradient.cpp b/src/Tool/IntelliToolGradient.cpp index 2b36494..216e5f2 100644 --- a/src/Tool/IntelliToolGradient.cpp +++ b/src/Tool/IntelliToolGradient.cpp @@ -29,13 +29,10 @@ void IntelliToolGradient::onMouseRightPressed(int x, int y){ } void IntelliToolGradient::onMouseLeftReleased(int x, int y){ - if(hasMoved){ + if(hasMoved && this->isDrawing){ computeGradientLayer(); IntelliTool::onMouseLeftReleased(x,y); } - else{ - IntelliTool::onMouseRightPressed(x,y); - } } void IntelliToolGradient::onMouseRightReleased(int x, int y){ @@ -43,16 +40,18 @@ void IntelliToolGradient::onMouseRightReleased(int x, int y){ } void IntelliToolGradient::onMouseMoved(int x, int y){ - hasMoved = true; - B = QPoint(x,y); - VectorAB[0] = static_cast(B.x() - A.x()); - VectorAB[1] = static_cast(B.y() - A.y()); - NormalVector[0] = VectorAB[1]; - NormalVector[1] = (-1*VectorAB[0]); - NormalDotNormal = dotProduct(NormalVector,NormalVector); - this->Canvas->image->drawPlain(Qt::transparent); - computeGradientLayer(); - Canvas->image->drawLine(A,B,LineColor,1); + if(this->isDrawing){ + hasMoved = true; + B = QPoint(x,y); + VectorAB[0] = static_cast(B.x() - A.x()); + VectorAB[1] = static_cast(B.y() - A.y()); + NormalVector[0] = VectorAB[1]; + NormalVector[1] = (-1*VectorAB[0]); + NormalDotNormal = dotProduct(NormalVector,NormalVector); + this->Canvas->image->drawPlain(Qt::transparent); + computeGradientLayer(); + Canvas->image->drawLine(A,B,LineColor,1); + } IntelliTool::onMouseMoved(x,y); } diff --git a/src/Tool/IntelliToolGradient.h b/src/Tool/IntelliToolGradient.h index 50ee96b..01b0159 100644 --- a/src/Tool/IntelliToolGradient.h +++ b/src/Tool/IntelliToolGradient.h @@ -3,6 +3,53 @@ #include "IntelliTool.h" class IntelliToolGradient : public IntelliTool{ + +public: + IntelliToolGradient(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings); + + virtual ~IntelliToolGradient() override; + + /*! + * \brief A function managing the right click Pressed of a Mouse. Constructing the Canvas to draw on. Call this in child classes! + * \param x - The x coordinate relative to the active/canvas layer. + * \param y - The y coordinate relative to the active/canvas layer. + */ + virtual void onMouseRightPressed(int x, int y) override; + + /*! + * \brief A function managing the right click Released of a Mouse. Merging the Canvas to Active. Call this in child classes! + * \param x - The x coordinate relative to the active/canvas layer. + * \param y - The y coordinate relative to the active/canvas layer. + */ + virtual void onMouseRightReleased(int x, int y) override; + + /*! + * \brief A function managing the left click Pressed of a Mouse. Resetting the current draw. Call this in child classes! + * \param x - The x coordinate relative to the active/canvas layer. + * \param y - The y coordinate relative to the active/canvas layer. + */ + virtual void onMouseLeftPressed(int x, int y) override; + + /*! + * \brief A function managing the left click Released of a Mouse. Call this in child classes! + * \param x - The x coordinate relative to the active/canvas layer. + * \param y - The y coordinate relative to the active/canvas layer. + */ + virtual void onMouseLeftReleased(int x, int y) override; + + /*! + * \brief A function managing the scroll event. A positive value means scrolling outwards. Call this in child classes! + * \param value - The absolute the scroll has changed. + */ + virtual void onWheelScrolled(int value) override; + + /*! + * \brief A function managing the mouse moved event. Call this in child classes! + * \param x - The x coordinate of the new mouse position. + * \param y - The y coordinate of the new mouse position. + */ + virtual void onMouseMoved(int x, int y) override; + private: QPoint A; QPoint B; @@ -13,52 +60,6 @@ private: QColor LineColor; bool hasMoved; -public: - IntelliToolGradient(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings); - - ~IntelliToolGradient(); - - /*! - * \brief A function managing the right click Pressed of a Mouse. Constructing the Canvas to draw on. Call this in child classes! - * \param x - The x coordinate relative to the active/canvas layer. - * \param y - The y coordinate relative to the active/canvas layer. - */ - virtual void onMouseRightPressed(int x, int y); - - /*! - * \brief A function managing the right click Released of a Mouse. Merging the Canvas to Active. Call this in child classes! - * \param x - The x coordinate relative to the active/canvas layer. - * \param y - The y coordinate relative to the active/canvas layer. - */ - virtual void onMouseRightReleased(int x, int y); - - /*! - * \brief A function managing the left click Pressed of a Mouse. Resetting the current draw. Call this in child classes! - * \param x - The x coordinate relative to the active/canvas layer. - * \param y - The y coordinate relative to the active/canvas layer. - */ - virtual void onMouseLeftPressed(int x, int y); - - /*! - * \brief A function managing the left click Released of a Mouse. Call this in child classes! - * \param x - The x coordinate relative to the active/canvas layer. - * \param y - The y coordinate relative to the active/canvas layer. - */ - virtual void onMouseLeftReleased(int x, int y); - - /*! - * \brief A function managing the scroll event. A positive value means scrolling outwards. Call this in child classes! - * \param value - The absolute the scroll has changed. - */ - virtual void onWheelScrolled(int value); - - /*! - * \brief A function managing the mouse moved event. Call this in child classes! - * \param x - The x coordinate of the new mouse position. - * \param y - The y coordinate of the new mouse position. - */ - virtual void onMouseMoved(int x, int y); - void computePixelColor(QPoint Point); double dotProduct(double Vector1[2], double Vector2[2]);