Changeset View
Changeset View
Standalone View
Standalone View
commands/imagelib/transforms/kpTransformRotateCommand.cpp
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | |||||
66 | } | 66 | } | ||
67 | 67 | | |||
68 | 68 | | |||
69 | // public virtual [base kpCommand] | 69 | // public virtual [base kpCommand] | ||
70 | QString kpTransformRotateCommand::name () const | 70 | QString kpTransformRotateCommand::name () const | ||
71 | { | 71 | { | ||
72 | QString opName = i18n ("Rotate"); | 72 | QString opName = i18n ("Rotate"); | ||
73 | 73 | | |||
74 | if (m_actOnSelection) | 74 | return (m_actOnSelection) ? i18n ("Selection: %1", opName) : opName; | ||
75 | return i18n ("Selection: %1", opName); | | |||
76 | else | | |||
77 | return opName; | | |||
78 | } | 75 | } | ||
79 | 76 | | |||
80 | 77 | | |||
81 | // public virtual [base kpCommand] | 78 | // public virtual [base kpCommand] | ||
82 | kpCommandSize::SizeType kpTransformRotateCommand::size () const | 79 | kpCommandSize::SizeType kpTransformRotateCommand::size () const | ||
83 | { | 80 | { | ||
84 | return ImageSize (m_oldImage) + | 81 | return ImageSize (m_oldImage) + | ||
85 | SelectionSize (m_oldSelectionPtr); | 82 | SelectionSize (m_oldSelectionPtr); | ||
86 | } | 83 | } | ||
87 | 84 | | |||
88 | 85 | | |||
89 | // public virtual [base kpCommand] | 86 | // public virtual [base kpCommand] | ||
90 | void kpTransformRotateCommand::execute () | 87 | void kpTransformRotateCommand::execute () | ||
91 | { | 88 | { | ||
92 | kpDocument *doc = document (); | 89 | kpDocument *doc = document (); | ||
93 | Q_ASSERT (doc); | 90 | Q_ASSERT (doc); | ||
94 | 91 | | |||
95 | 92 | | |||
96 | QApplication::setOverrideCursor (Qt::WaitCursor); | 93 | QApplication::setOverrideCursor (Qt::WaitCursor); | ||
97 | 94 | | |||
98 | 95 | | |||
99 | if (!m_losslessRotation) | 96 | if (!m_losslessRotation) { | ||
100 | m_oldImage = doc->image (m_actOnSelection); | 97 | m_oldImage = doc->image (m_actOnSelection); | ||
98 | } | ||||
101 | 99 | | |||
102 | 100 | | |||
103 | kpImage newImage = kpPixmapFX::rotate (doc->image (m_actOnSelection), | 101 | kpImage newImage = kpPixmapFX::rotate (doc->image (m_actOnSelection), | ||
104 | m_angle, | 102 | m_angle, | ||
105 | m_backgroundColor); | 103 | m_backgroundColor); | ||
106 | 104 | | |||
107 | if (!m_actOnSelection) | 105 | if (!m_actOnSelection) { | ||
108 | doc->setImage (newImage); | 106 | doc->setImage (newImage); | ||
109 | else | 107 | } | ||
110 | { | 108 | else { | ||
111 | kpAbstractImageSelection *sel = doc->imageSelection (); | 109 | kpAbstractImageSelection *sel = doc->imageSelection (); | ||
112 | Q_ASSERT (sel); | 110 | Q_ASSERT (sel); | ||
113 | 111 | | |||
114 | // Save old selection | 112 | // Save old selection | ||
115 | m_oldSelectionPtr = sel->clone (); | 113 | m_oldSelectionPtr = sel->clone (); | ||
116 | 114 | | |||
117 | // Conserve memmory: | 115 | // Conserve memmory: | ||
118 | // | 116 | // | ||
Show All 39 Lines | 155 | { | |||
158 | // TODO: fix the latter "victim of" problem in kpAbstractImageSelection by | 156 | // TODO: fix the latter "victim of" problem in kpAbstractImageSelection by | ||
159 | // allowing the border width & height != pixmap width & height | 157 | // allowing the border width & height != pixmap width & height | ||
160 | // Or maybe autocrop? | 158 | // Or maybe autocrop? | ||
161 | #if DEBUG_KP_TOOL_ROTATE | 159 | #if DEBUG_KP_TOOL_ROTATE | ||
162 | qCDebug(kpLogCommands) << "kpTransformRotateCommand::execute() currentPoints.boundingRect=" | 160 | qCDebug(kpLogCommands) << "kpTransformRotateCommand::execute() currentPoints.boundingRect=" | ||
163 | << currentPoints.boundingRect () | 161 | << currentPoints.boundingRect () | ||
164 | << " newPixmap: w=" << newImage.width () | 162 | << " newPixmap: w=" << newImage.width () | ||
165 | << " h=" << newImage.height () | 163 | << " h=" << newImage.height () | ||
166 | << " (victim of rounding error and/or rotated-a-(rectangular)-pixmap-that-was-transparent-in-the-corners-making-sel-uselessly-bigger-than-needs-be)" | 164 | << " (victim of rounding error and/or rotated-a-(rectangular)-pixmap-that-was-transparent-in-the-corners-making-sel-uselessly-bigger-than-needs-be)"; | ||
167 | << endl; | | |||
168 | #endif | 165 | #endif | ||
169 | doc->setSelection ( | 166 | doc->setSelection ( | ||
170 | kpRectangularImageSelection ( | 167 | kpRectangularImageSelection ( | ||
171 | QRect (newTopLeft.x (), newTopLeft.y (), | 168 | QRect (newTopLeft.x (), newTopLeft.y (), | ||
172 | newImage.width (), newImage.height ()), | 169 | newImage.width (), newImage.height ()), | ||
173 | newImage, | 170 | newImage, | ||
174 | m_oldSelectionPtr->transparency ())); | 171 | m_oldSelectionPtr->transparency ())); | ||
175 | } | 172 | } | ||
Show All 25 Lines | 183 | { | |||
201 | else | 198 | else | ||
202 | { | 199 | { | ||
203 | oldImage = kpPixmapFX::rotate (doc->image (m_actOnSelection), | 200 | oldImage = kpPixmapFX::rotate (doc->image (m_actOnSelection), | ||
204 | 360 - m_angle, | 201 | 360 - m_angle, | ||
205 | m_backgroundColor); | 202 | m_backgroundColor); | ||
206 | } | 203 | } | ||
207 | 204 | | |||
208 | 205 | | |||
209 | if (!m_actOnSelection) | 206 | if (!m_actOnSelection) { | ||
210 | doc->setImage (oldImage); | 207 | doc->setImage (oldImage); | ||
211 | else | 208 | } | ||
212 | { | 209 | else { | ||
213 | m_oldSelectionPtr->setBaseImage (oldImage); | 210 | m_oldSelectionPtr->setBaseImage (oldImage); | ||
214 | doc->setSelection (*m_oldSelectionPtr); | 211 | doc->setSelection (*m_oldSelectionPtr); | ||
215 | delete m_oldSelectionPtr; m_oldSelectionPtr = nullptr; | 212 | delete m_oldSelectionPtr; m_oldSelectionPtr = nullptr; | ||
216 | 213 | | |||
217 | environ ()->somethingBelowTheCursorChanged (); | 214 | environ ()->somethingBelowTheCursorChanged (); | ||
218 | } | 215 | } | ||
219 | 216 | | |||
220 | 217 | | |||
221 | QApplication::restoreOverrideCursor (); | 218 | QApplication::restoreOverrideCursor (); | ||
222 | } | 219 | } | ||
223 | 220 | |