hotfix, rechtsklick bringte das programm zum abstürzen

This commit is contained in:
Jonas Mucke
2020-01-26 19:10:45 +01:00
parent 657eba80f2
commit eeceedab8c
2 changed files with 60 additions and 60 deletions

View File

@@ -29,13 +29,10 @@ void IntelliToolGradient::onMouseRightPressed(int x, int y){
} }
void IntelliToolGradient::onMouseLeftReleased(int x, int y){ void IntelliToolGradient::onMouseLeftReleased(int x, int y){
if(hasMoved){ if(hasMoved && this->isDrawing){
computeGradientLayer(); computeGradientLayer();
IntelliTool::onMouseLeftReleased(x,y); IntelliTool::onMouseLeftReleased(x,y);
} }
else{
IntelliTool::onMouseRightPressed(x,y);
}
} }
void IntelliToolGradient::onMouseRightReleased(int x, int 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){ void IntelliToolGradient::onMouseMoved(int x, int y){
hasMoved = true; if(this->isDrawing){
B = QPoint(x,y); hasMoved = true;
VectorAB[0] = static_cast<float>(B.x() - A.x()); B = QPoint(x,y);
VectorAB[1] = static_cast<float>(B.y() - A.y()); VectorAB[0] = static_cast<float>(B.x() - A.x());
NormalVector[0] = VectorAB[1]; VectorAB[1] = static_cast<float>(B.y() - A.y());
NormalVector[1] = (-1*VectorAB[0]); NormalVector[0] = VectorAB[1];
NormalDotNormal = dotProduct(NormalVector,NormalVector); NormalVector[1] = (-1*VectorAB[0]);
this->Canvas->image->drawPlain(Qt::transparent); NormalDotNormal = dotProduct(NormalVector,NormalVector);
computeGradientLayer(); this->Canvas->image->drawPlain(Qt::transparent);
Canvas->image->drawLine(A,B,LineColor,1); computeGradientLayer();
Canvas->image->drawLine(A,B,LineColor,1);
}
IntelliTool::onMouseMoved(x,y); IntelliTool::onMouseMoved(x,y);
} }

View File

@@ -3,6 +3,53 @@
#include "IntelliTool.h" #include "IntelliTool.h"
class IntelliToolGradient : public IntelliTool{ 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: private:
QPoint A; QPoint A;
QPoint B; QPoint B;
@@ -13,52 +60,6 @@ private:
QColor LineColor; QColor LineColor;
bool hasMoved; 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); void computePixelColor(QPoint Point);
double dotProduct(double Vector1[2], double Vector2[2]); double dotProduct(double Vector1[2], double Vector2[2]);