Changeset View
Changeset View
Standalone View
Standalone View
tools/flow/kpToolColorEraser.cpp
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 49 | : kpToolFlowBase (i18n ("Color Eraser"), | |||
---|---|---|---|---|---|
51 | Qt::Key_O, | 51 | Qt::Key_O, | ||
52 | environ, parent, | 52 | environ, parent, | ||
53 | "tool_color_eraser") | 53 | "tool_color_eraser") | ||
54 | { | 54 | { | ||
55 | } | 55 | } | ||
56 | 56 | | |||
57 | //-------------------------------------------------------------------------------- | 57 | //-------------------------------------------------------------------------------- | ||
58 | 58 | | |||
59 | kpToolColorEraser::~kpToolColorEraser () | 59 | kpToolColorEraser::~kpToolColorEraser () = default; | ||
60 | { | | |||
61 | } | | |||
62 | 60 | | |||
63 | //-------------------------------------------------------------------------------- | 61 | //-------------------------------------------------------------------------------- | ||
64 | // public virtual [base kpTool] | 62 | // public virtual [base kpTool] | ||
65 | 63 | | |||
66 | void kpToolColorEraser::globalDraw () | 64 | void kpToolColorEraser::globalDraw () | ||
67 | { | 65 | { | ||
68 | qCDebug(kpLogTools) << "kpToolColorEraser::globalDraw()"; | 66 | qCDebug(kpLogTools) << "kpToolColorEraser::globalDraw()"; | ||
69 | if (!drawShouldProceed (QPoint ()/*unused*/, QPoint ()/*unused*/, QRect ()/*unused*/)) | 67 | if (!drawShouldProceed (QPoint ()/*unused*/, QPoint ()/*unused*/, QRect ()/*unused*/)) { | ||
70 | return; | 68 | return; | ||
69 | } | ||||
71 | 70 | | |||
72 | QApplication::setOverrideCursor (Qt::WaitCursor); | 71 | QApplication::setOverrideCursor (Qt::WaitCursor); | ||
73 | 72 | | |||
74 | environ ()->flashColorSimilarityToolBarItem (); | 73 | environ ()->flashColorSimilarityToolBarItem (); | ||
75 | 74 | | |||
76 | kpToolFlowCommand *cmd = new kpToolFlowCommand ( | 75 | kpToolFlowCommand *cmd = new kpToolFlowCommand ( | ||
77 | i18n ("Color Eraser"), environ ()->commandEnvironment ()); | 76 | i18n ("Color Eraser"), environ ()->commandEnvironment ()); | ||
78 | 77 | | |||
Show All 34 Lines | |||||
113 | } | 112 | } | ||
114 | 113 | | |||
115 | //-------------------------------------------------------------------------------- | 114 | //-------------------------------------------------------------------------------- | ||
116 | 115 | | |||
117 | bool kpToolColorEraser::drawShouldProceed (const QPoint & /*thisPoint*/, | 116 | bool kpToolColorEraser::drawShouldProceed (const QPoint & /*thisPoint*/, | ||
118 | const QPoint & /*lastPoint*/, | 117 | const QPoint & /*lastPoint*/, | ||
119 | const QRect & /*normalizedRect*/) | 118 | const QRect & /*normalizedRect*/) | ||
120 | { | 119 | { | ||
121 | if (foregroundColor () == backgroundColor () && | 120 | return !(foregroundColor () == backgroundColor () && | ||
122 | processedColorSimilarity () == 0) | 121 | processedColorSimilarity () == 0); | ||
123 | { | | |||
124 | return false; | | |||
125 | } | | |||
126 | | ||||
127 | return true; | | |||
128 | } | 122 | } | ||
129 | 123 | | |||
130 | //-------------------------------------------------------------------------------- | 124 | //-------------------------------------------------------------------------------- | ||
131 | 125 | | |||
132 | QRect kpToolColorEraser::drawLine (const QPoint &thisPoint, const QPoint &lastPoint) | 126 | QRect kpToolColorEraser::drawLine (const QPoint &thisPoint, const QPoint &lastPoint) | ||
133 | { | 127 | { | ||
134 | qCDebug(kpLogTools) << "kpToolColorEraser::drawLine(thisPoint=" << thisPoint | 128 | qCDebug(kpLogTools) << "kpToolColorEraser::drawLine(thisPoint=" << thisPoint | ||
135 | << ",lastPoint=" << lastPoint << ")" << endl; | 129 | << ",lastPoint=" << lastPoint << ")"; | ||
136 | 130 | | |||
137 | environ ()->flashColorSimilarityToolBarItem (); | 131 | environ ()->flashColorSimilarityToolBarItem (); | ||
138 | 132 | | |||
139 | const QRect dirtyRect = kpPainter::washLine (document ()->imagePointer (), | 133 | const QRect dirtyRect = kpPainter::washLine (document ()->imagePointer (), | ||
140 | lastPoint.x (), lastPoint.y (), | 134 | lastPoint.x (), lastPoint.y (), | ||
141 | thisPoint.x (), thisPoint.y (), | 135 | thisPoint.x (), thisPoint.y (), | ||
142 | color (mouseButton ())/*color to draw in*/, | 136 | color (mouseButton ())/*color to draw in*/, | ||
143 | brushWidth (), brushHeight (), | 137 | brushWidth (), brushHeight (), | ||
144 | color (1 - mouseButton ())/*color to replace*/, | 138 | color (1 - mouseButton ())/*color to replace*/, | ||
145 | processedColorSimilarity ()); | 139 | processedColorSimilarity ()); | ||
146 | 140 | | |||
147 | qCDebug(kpLogTools) << "\tdirtyRect=" << dirtyRect; | 141 | qCDebug(kpLogTools) << "\tdirtyRect=" << dirtyRect; | ||
148 | 142 | | |||
149 | if (!dirtyRect.isEmpty ()) | 143 | if (!dirtyRect.isEmpty ()) | ||
150 | { | 144 | { | ||
151 | document ()->slotContentsChanged (dirtyRect); | 145 | document ()->slotContentsChanged (dirtyRect); | ||
152 | return dirtyRect; | 146 | return dirtyRect; | ||
153 | } | 147 | } | ||
154 | 148 | | |||
155 | return QRect (); | 149 | return {}; | ||
156 | } | 150 | } | ||
157 | 151 | | |||
158 | //-------------------------------------------------------------------------------- | 152 | //-------------------------------------------------------------------------------- |