From 5ac556f71cac6ff1a3d0e11b3a82757304d99241 Mon Sep 17 00:00:00 2001 From: Jan Schuffenhauer Date: Mon, 3 Feb 2020 16:04:01 +0100 Subject: [PATCH] Update Gradient und UML @DerAnonymos @AshBastian --- docs/UML.uxf | 419 ++++++++++++++++--------- src/IntelliHelper/IntelliDatamanager.h | 2 +- src/Tool/IntelliToolGradient.cpp | 51 ++- src/Tool/IntelliToolGradient.h | 12 +- 4 files changed, 287 insertions(+), 197 deletions(-) diff --git a/docs/UML.uxf b/docs/UML.uxf index 01eb3ce..7b6c53b 100644 --- a/docs/UML.uxf +++ b/docs/UML.uxf @@ -1,17 +1,18 @@ - 10 + 6 UMLClass - 2220 - 90 - 320 - 180 + 1338 + 84 + 192 + 120 /*IntelliImage*/ -- #imageData: QImage +-isFastRendering: Boolean -- #resizeImage(image, newSize): void +drawPixel(p1, color): void @@ -26,10 +27,10 @@ UMLClass - 2230 - 400 - 310 - 80 + 1344 + 270 + 186 + 48 *IntelliRasterImage* -- @@ -42,10 +43,10 @@ UMLClass - 2220 - 680 - 320 - 150 + 1338 + 438 + 192 + 90 *IntelliShapedImage* -- @@ -62,10 +63,10 @@ UMLClass - 380 - 90 - 290 - 230 + 744 + 366 + 174 + 150 /*IntelliTool*/ -- @@ -74,6 +75,7 @@ #Active: LayerObject #Canvas: LayerObject #drawing: Boolean +#ActiveType: Tooltype -- /+onMouseRightPressed(x,y): void/ /+onMouseLeftPressed(x,y): void/ @@ -87,21 +89,21 @@ Relation - 2310 - 260 - 30 - 160 + 1392 + 198 + 18 + 84 lt=<<- - 10.0;10.0;10.0;140.0 + 10.0;10.0;10.0;120.0 Relation - 2310 - 470 - 30 - 230 + 1392 + 312 + 18 + 138 lt=<<- 10.0;10.0;10.0;210.0 @@ -109,10 +111,10 @@ UMLClass - 1440 - 200 - 240 - 80 + 870 + 210 + 144 + 48 <<Enumeration>> *ImageType* @@ -124,10 +126,10 @@ UMLClass - 140 - 940 - 250 - 150 + 432 + 810 + 150 + 90 *IntelliToolFloodFill* -- @@ -144,10 +146,10 @@ UMLClass - 140 - 480 - 250 - 150 + 432 + 564 + 150 + 90 *IntelliToolPlain* -- @@ -164,15 +166,16 @@ UMLClass - 1020 - 480 - 240 - 180 + 876 + 774 + 144 + 120 - *IntelliToolPen* + *IntelliToolGradient* -- --penWidth: Integer --point: QPoint +-startPoint: QPoint +-endPoint: QPoint +-LineColor: QColor -- +onMouseRightPressed(x,y): void +onMouseLeftPressed(x,y): void @@ -186,10 +189,10 @@ UMLClass - 1020 - 960 - 250 - 180 + 1122 + 780 + 150 + 108 *IntelliToolRectangle* -- @@ -208,10 +211,10 @@ UMLClass - 1020 - 700 - 240 - 200 + 1128 + 642 + 144 + 120 *IntelliToolLine* -- @@ -231,15 +234,15 @@ UMLClass - 490 - 670 - 250 - 210 + 672 + 768 + 150 + 126 *IntelliToolPolygon* -- -lineWidth: Integer --isDrawing: Boolean +-isDrawingOfPolygon: Boolean -PointIsNearStart: Boolean -alphaInner: Integer -- @@ -255,76 +258,76 @@ Relation - 640 - 310 - 400 - 190 + 816 + 510 + 210 + 276 lt=<<- - 10.0;10.0;380.0;170.0 + 10.0;10.0;330.0;440.0 Relation - 380 - 310 - 100 - 650 + 576 + 510 + 228 + 312 lt=<<- - 80.0;10.0;10.0;630.0 + 360.0;10.0;10.0;500.0 Relation - 250 - 310 - 160 - 190 + 498 + 510 + 264 + 66 lt=<<- - 140.0;10.0;10.0;170.0 + 420.0;10.0;10.0;90.0 Relation - 510 - 310 - 540 - 670 + 834 + 510 + 306 + 282 lt=<<- - 10.0;10.0;520.0;650.0 + 10.0;10.0;490.0;450.0 Relation - 560 - 310 - 480 - 410 + 858 + 510 + 282 + 144 lt=<<- - 10.0;10.0;460.0;390.0 + 10.0;10.0;450.0;220.0 Relation - 480 - 310 - 140 - 380 + 732 + 510 + 90 + 270 lt=<<- - 10.0;10.0;120.0;360.0 + 130.0;10.0;10.0;430.0 UMLClass - 140 - 680 - 250 - 200 + 432 + 684 + 150 + 120 *IntelliToolCircle* -- @@ -344,21 +347,21 @@ Relation - 380 - 310 - 80 - 390 + 576 + 510 + 216 + 186 lt=<<- - 60.0;10.0;10.0;370.0 + 340.0;10.0;10.0;290.0 UMLClass - 1930 - 90 - 280 - 410 + 1164 + 84 + 168 + 246 *PaintingArea* -- @@ -394,10 +397,10 @@ group=1 UMLClass - 1690 - 90 - 230 - 150 + 1020 + 84 + 138 + 90 <<dataType>> *LayerObject* @@ -414,42 +417,30 @@ group=1 UMLClass - 830 - 90 - 320 + 324 + 150 + 192 + 78 + + /*IntelliToolSetttings*/ +-- +-lineWidth: Integer +-innerAlpha: Integer +-- ++getInnerAlpha(): Integer ++setInnerAlpha( innerAlpha): void ++getLineWidth(): Integer ++setLineWidth( LineWidth): void + + + + UMLClass + + 522 + 84 + 150 90 - /*IntelliHelper*/ --- --- -+isInTriangle(tri, P): Boolean -+calculateTriangles(polyPoints): vector<Triangle> -+isInPolygon(triangles, point): Boolean - - - - UMLClass - - 1440 - 90 - 240 - 80 - - <<Enumeration>> -*LineStyle* --- - SOLID - DOTTED - - - - UMLClass - - 1180 - 90 - 250 - 150 - /*IntelliColorPicker*/ -- -firstColor: QColor @@ -465,10 +456,10 @@ group=1 UMLClass - 1690 - 250 - 230 - 100 + 1020 + 180 + 138 + 60 <<dataType>> *Triangle* @@ -482,10 +473,10 @@ group=1 UMLClass - 1690 - 360 - 230 - 70 + 1020 + 246 + 138 + 42 <<dataType>> *QImage* @@ -498,10 +489,10 @@ group=1 UMLClass - 1690 - 440 - 230 - 70 + 1020 + 294 + 138 + 42 <<dataType>> *QPoint* @@ -514,10 +505,81 @@ group=1 UMLClass - 1690 - 530 - 230 - 90 + 1020 + 348 + 138 + 42 + + <<dataType>> +*QColor* +-- +-- +-- + Cotains RGBA Color Data. + + + + UMLClass + + 1128 + 516 + 144 + 108 + + *IntelliToolPen* +-- +-penWidth: Integer +-point: QPoint +-- ++onMouseRightPressed(x,y): void ++onMouseLeftPressed(x,y): void ++onMouseRightReleased(x,y): void ++onMousLeftReleased(x,y): void ++onWheelScrolled(value): void ++onMouseMoved(x,y): void +... + + + + Relation + + 912 + 498 + 228 + 30 + + lt=<<- + 10.0;10.0;360.0;30.0 + + + UMLClass + + 870 + 84 + 144 + 114 + + <<Enumeration>> +*Tooltype* +-- + CIRCLE + FLOODFILL + GRADIENT + LINE + PEN + PLAIN + POLYGON + RECTANGLE + NONE + + + + UMLClass + + 1020 + 408 + 138 + 54 <<dataType>> *vector<T>* @@ -528,4 +590,51 @@ group=1 data with equal type as type T. + + UMLClass + + 324 + 84 + 192 + 54 + + /*IntelliRenderSettings*/ +-- +-fastRendering: Boolean +-- ++isFastRendering(): Boolean ++setFastRendering(Updatesetting): void + + + + UMLClass + + 324 + 240 + 192 + 54 + + /*IntelliTriangulation*/ +-- +-- ++isInTriangle(tri, P): Boolean ++calculateTriangles(polyPoints): vector<Triangle> ++isInPolygon(triangles, point): Boolean + + + + UMLClass + + 684 + 84 + 174 + 48 + + <<NAMESPACE>> +*IntelliDatamanager* +-- + ::loadProject(Canvas, filePath): Boolean + ::saveProject(Canvas, filePath): Boolean + + diff --git a/src/IntelliHelper/IntelliDatamanager.h b/src/IntelliHelper/IntelliDatamanager.h index 9da93a4..e3c1683 100644 --- a/src/IntelliHelper/IntelliDatamanager.h +++ b/src/IntelliHelper/IntelliDatamanager.h @@ -1,4 +1,4 @@ -#ifndef INTELLIDATAMANAGER_H + #ifndef INTELLIDATAMANAGER_H #define INTELLIDATAMANAGER_H #include diff --git a/src/Tool/IntelliToolGradient.cpp b/src/Tool/IntelliToolGradient.cpp index 9639710..79a2b9a 100644 --- a/src/Tool/IntelliToolGradient.cpp +++ b/src/Tool/IntelliToolGradient.cpp @@ -44,11 +44,6 @@ void IntelliToolGradient::onMouseMoved(int x, int y){ if(this->isDrawing) { hasMoved = true; endPoint = QPoint(x,y); - VectorStartEnd[0] = static_cast(endPoint.x() - startPoint.x()); - VectorStartEnd[1] = static_cast(endPoint.y() - startPoint.y()); - NormalVector[0] = VectorStartEnd[1]; - NormalVector[1] = (-1 * VectorStartEnd[0]); - NormalDotNormal = dotProduct(NormalVector,NormalVector); this->Canvas->image->drawPlain(Qt::transparent); computeGradientLayer(); Canvas->image->drawLine(startPoint,endPoint,LineColor,1); @@ -60,7 +55,7 @@ void IntelliToolGradient::onWheelScrolled(int value){ IntelliTool::onWheelScrolled(value); } -void IntelliToolGradient::computeAndDrawPixelColor(QPoint Point){ +void IntelliToolGradient::computeAndDrawPixelColor(QPoint Point, int FirstColor[4], int SecondColor[4], double NormalVector[2], double NormalDotNormal){ double doublePoint[2]; doublePoint[0] = static_cast(Point.x()); doublePoint[1] = static_cast(Point.y()); @@ -88,20 +83,10 @@ void IntelliToolGradient::computeAndDrawPixelColor(QPoint Point){ computedColor = colorPicker->getSecondColor(); } else{ - int red; - int green; - int blue; - int alpha; - int red2; - int green2; - int blue2; - int alpha2; - colorPicker->getFirstColor().getRgb(&red,&green,&blue,&alpha); - colorPicker->getSecondColor().getRgb(&red2,&green2,&blue2,&alpha2); - computedColor.setRed(static_cast(ratio * red2 + (1 - ratio) * red)); - computedColor.setGreen(static_cast(ratio * green2 + (1 - ratio) * green)); - computedColor.setBlue(static_cast(ratio * blue2 + (1 - ratio) * blue)); - computedColor.setAlpha(static_cast(ratio * alpha2 + (1 - ratio) * alpha)); + computedColor.setRed(static_cast(ratio * SecondColor[0] + (1 - ratio) * FirstColor[0])); + computedColor.setGreen(static_cast(ratio * SecondColor[1] + (1 - ratio) * FirstColor[1])); + computedColor.setBlue(static_cast(ratio * SecondColor[2] + (1 - ratio) * FirstColor[2])); + computedColor.setAlpha(static_cast(ratio * SecondColor[3] + (1 - ratio) * FirstColor[3])); } Canvas->image->drawPixel(Point,computedColor); } @@ -115,17 +100,23 @@ double IntelliToolGradient::lenghtVector(double Vector[2]){ } void IntelliToolGradient::computeGradientLayer(){ - bool switched = false; - if(Canvas->image->isFastRendering()) { - switched = true; - Canvas->image->updateRendererSetting(false); - } - for(int i = 0; i < activeLayer->height; i++) { + int FirstColor[4]; + colorPicker->getFirstColor().getRgb(&FirstColor[0],&FirstColor[1],&FirstColor[2],&FirstColor[3]); + int SecondColor[4]; + colorPicker->getSecondColor().getRgb(&SecondColor[0],&SecondColor[1],&SecondColor[2],&SecondColor[3]); + + double NormalVector[2]; + double NormalDotNormal; + + VectorStartEnd[0] = static_cast(endPoint.x() - startPoint.x()); + VectorStartEnd[1] = static_cast(endPoint.y() - startPoint.y()); + NormalVector[0] = VectorStartEnd[1]; + NormalVector[1] = (-1 * VectorStartEnd[0]); + NormalDotNormal = dotProduct(NormalVector,NormalVector); + + for(int i = 0; i < activeLayer->height; i++) { for(int j = 0; j < activeLayer->width; j++) { - computeAndDrawPixelColor(QPoint(j,i)); + computeAndDrawPixelColor(QPoint(j,i), FirstColor, SecondColor, NormalVector, NormalDotNormal); } } - if(switched) { - Canvas->image->updateRendererSetting(true); - } } diff --git a/src/Tool/IntelliToolGradient.h b/src/Tool/IntelliToolGradient.h index 7547a61..35021bd 100644 --- a/src/Tool/IntelliToolGradient.h +++ b/src/Tool/IntelliToolGradient.h @@ -82,16 +82,6 @@ double doubleStartPoint[2]; */ double VectorStartEnd[2]; -/*! - * \brief NormalVector of the VectorStartEnd - */ -double NormalVector[2]; - -/*! - * \brief NormalDotNormal dot product of Normal*Normal - */ -double NormalDotNormal; - /*! * \brief LineColor color of th line. */ @@ -106,7 +96,7 @@ bool hasMoved; * \brief computeAndDrawPixelColor computes the pixelcolor for a given point and sets it to the image. * \param Point the point which shoud be computed */ -void computeAndDrawPixelColor(QPoint Point); +void computeAndDrawPixelColor(QPoint Point, int FirstColor[4], int SecondColor[4], double NormalVector[2], double NormalDotNormal); /*! * \brief dotProduct calculates the dot product of 2 vetors.