Rev 21026 | Rev 21304 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
16546 | jghali | 1 | /* |
2 | For general Scribus (>=1.3.2) copyright and licensing information please refer |
||
3 | to the COPYING file provided with the program. Following this notice may exist |
||
4 | a copyright and/or license notice that predates the release of Scribus 1.3.2 |
||
5 | for which a new license (GPL+exception) is in place. |
||
6 | */ |
||
7 | |||
8 | |||
9 | #include "propertiespalette_image.h" |
||
10 | |||
17539 | jghali | 11 | #if defined(_MSC_VER) && !defined(_USE_MATH_DEFINES) |
16546 | jghali | 12 | #define _USE_MATH_DEFINES |
13 | #endif |
||
14 | #include <cmath> |
||
15 | #include "commonstrings.h" |
||
16 | #include "sccolorengine.h" |
||
17 | #include "pageitem.h" |
||
18 | #include "propertiespalette_utils.h" |
||
19 | #include "sccombobox.h" |
||
19080 | craig | 20 | |
16546 | jghali | 21 | #include "scribuscore.h" |
22 | #include "scraction.h" |
||
23 | #include "scribusview.h" |
||
24 | #include "selection.h" |
||
25 | #include "units.h" |
||
26 | #include "undomanager.h" |
||
27 | #include "util.h" |
||
28 | #include "util_math.h" |
||
29 | |||
30 | PropertiesPalette_Image::PropertiesPalette_Image( QWidget* parent) : QWidget(parent) |
||
31 | { |
||
32 | m_ScMW = 0; |
||
33 | m_doc = 0; |
||
34 | m_haveDoc = false; |
||
35 | m_haveItem = false; |
||
20730 | jghali | 36 | m_item = 0; |
16546 | jghali | 37 | m_unitRatio = 1.0; |
20730 | jghali | 38 | m_unitIndex = 0; |
16546 | jghali | 39 | |
40 | m_userActionOn = false; |
||
41 | userActionSniffer = new UserActionSniffer(this); |
||
42 | connect(userActionSniffer, SIGNAL(actionStart()), this, SLOT(spinboxStartUserAction())); |
||
43 | connect(userActionSniffer, SIGNAL(actionEnd()), this, SLOT(spinboxFinishUserAction())); |
||
44 | |||
45 | setupUi(this); |
||
17383 | fschmid | 46 | setSizePolicy( QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum)); |
16546 | jghali | 47 | |
48 | imagePageNumber->setMinimum(0); |
||
19395 | jghali | 49 | imagePageNumber->setSpecialValueText( tr( "Auto" )); |
17420 | fschmid | 50 | imagePageNumber->setDecimals(0); |
17613 | jghali | 51 | imagePageNumber->setSuffix(""); |
16546 | jghali | 52 | imagePageNumberLabel->setBuddy(imagePageNumber); |
17290 | fschmid | 53 | installSniffer(imagePageNumber); |
16546 | jghali | 54 | |
55 | // freeScale = new QRadioButton( "&Free Scaling", this ); |
||
56 | // freeScale->setChecked( true ); |
||
57 | // pageLayout_4->addWidget( freeScale ); |
||
58 | |||
59 | xposImgLabel->setBuddy(imageXOffsetSpinBox); |
||
60 | yposImgLabel->setBuddy(imageYOffsetSpinBox); |
||
61 | |||
62 | imageRotation->setWrapping( true ); |
||
17045 | fschmid | 63 | imageRotation->setNewUnit(6); |
16546 | jghali | 64 | installSniffer(imageRotation); |
65 | imageRotationLabel->setBuddy(imageRotation); |
||
66 | |||
67 | freeScale->setChecked( true ); |
||
68 | |||
69 | installSniffer(imageXScaleSpinBox); |
||
70 | xscaleLabel->setBuddy(imageXScaleSpinBox); |
||
71 | installSniffer(imageYScaleSpinBox); |
||
72 | yscaleLabel->setBuddy(imageYScaleSpinBox); |
||
73 | |||
74 | keepImageWHRatioButton->setCheckable( true ); |
||
75 | keepImageWHRatioButton->setAutoRaise( true ); |
||
76 | |||
17613 | jghali | 77 | imgDpiX->setSuffix(""); |
16546 | jghali | 78 | installSniffer(imgDpiX); |
79 | imgDPIXLabel->setBuddy(imgDpiX); |
||
80 | |||
17613 | jghali | 81 | imgDpiY->setSuffix(""); |
16546 | jghali | 82 | installSniffer(imgDpiY); |
83 | imgDPIYLabel->setBuddy(imgDpiY); |
||
84 | |||
85 | keepImageDPIRatioButton->setCheckable( true ); |
||
86 | keepImageDPIRatioButton->setAutoRaise( true ); |
||
87 | |||
19395 | jghali | 88 | frameScale->setText( tr("&To Frame Size")); |
16546 | jghali | 89 | |
90 | cbProportional->setEnabled( false ); |
||
91 | cbProportional->setText( "P&roportional" ); |
||
92 | cbProportional->setChecked( true ); |
||
93 | |||
94 | languageChange(); |
||
95 | |||
17420 | fschmid | 96 | connect(imagePageNumber , SIGNAL(valueChanged(double)) , this, SLOT(handleImagePageNumber())); |
16546 | jghali | 97 | connect(imageXScaleSpinBox , SIGNAL(valueChanged(double)), this, SLOT(handleXScale())); |
98 | connect(imageYScaleSpinBox , SIGNAL(valueChanged(double)), this, SLOT(handleYScale())); |
||
99 | connect(imageXOffsetSpinBox, SIGNAL(valueChanged(double)), this, SLOT(handleLocalXY())); |
||
100 | connect(imageYOffsetSpinBox, SIGNAL(valueChanged(double)), this, SLOT(handleLocalXY())); |
||
101 | connect(imageRotation , SIGNAL(valueChanged(double)), this, SLOT(handleLocalRotation())); |
||
102 | connect(imgDpiX , SIGNAL(valueChanged(double)), this, SLOT(handleDpiX())); |
||
103 | connect(imgDpiY , SIGNAL(valueChanged(double)), this, SLOT(handleDpiY())); |
||
104 | connect(keepImageWHRatioButton , SIGNAL(clicked()) , this, SLOT(handleImageWHRatio())); |
||
105 | connect(keepImageDPIRatioButton, SIGNAL(clicked()) , this, SLOT(handleImageDPIRatio())); |
||
106 | connect(freeScale , SIGNAL(clicked()) , this, SLOT(handleScaling())); |
||
107 | connect(frameScale , SIGNAL(clicked()) , this, SLOT(handleScaling())); |
||
17747 | craig | 108 | connect(cbProportional , SIGNAL(stateChanged(int)) , this, SLOT(handleScaling())); |
16546 | jghali | 109 | connect(imgEffectsButton , SIGNAL(clicked()) , this, SLOT(handleImageEffects())); |
110 | connect(imgExtProperties , SIGNAL(clicked()) , this, SLOT(handleExtImgProperties())); |
||
111 | connect(inputProfiles , SIGNAL(activated(const QString&)), this, SLOT(handleProfile(const QString&))); |
||
112 | connect(renderIntent , SIGNAL(activated(int)) , this, SLOT(handleIntent())); |
||
113 | connect(compressionMethod , SIGNAL(activated(int)) , this, SLOT(handleCompressionMethod())); |
||
114 | connect(compressionQuality , SIGNAL(activated(int)) , this, SLOT(handleCompressionQuality())); |
||
115 | } |
||
116 | |||
20506 | jghali | 117 | void PropertiesPalette_Image::updateSpinBoxConstants() |
118 | { |
||
119 | if (!m_haveDoc) |
||
120 | return; |
||
121 | if(m_doc->m_Selection->count()==0) |
||
122 | return; |
||
123 | imageXOffsetSpinBox->setConstants(&m_doc->constants()); |
||
124 | imageYOffsetSpinBox->setConstants(&m_doc->constants()); |
||
125 | } |
||
126 | |||
16546 | jghali | 127 | void PropertiesPalette_Image::changeEvent(QEvent *e) |
128 | { |
||
129 | if (e->type() == QEvent::LanguageChange) |
||
130 | { |
||
131 | languageChange(); |
||
132 | return; |
||
133 | } |
||
134 | QWidget::changeEvent(e); |
||
135 | } |
||
136 | |||
137 | void PropertiesPalette_Image::setMainWindow(ScribusMainWindow* mw) |
||
138 | { |
||
139 | m_ScMW = mw; |
||
140 | |||
141 | connect(m_ScMW, SIGNAL(UpdateRequest(int)), this , SLOT(handleUpdateRequest(int))); |
||
142 | } |
||
143 | |||
144 | void PropertiesPalette_Image::setDoc(ScribusDoc *d) |
||
145 | { |
||
146 | if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning())) |
||
147 | return; |
||
148 | |||
149 | if (m_doc) |
||
150 | { |
||
151 | disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); |
||
152 | disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); |
||
153 | } |
||
154 | |||
155 | m_doc = d; |
||
156 | m_item = NULL; |
||
157 | m_unitRatio = m_doc->unitRatio(); |
||
158 | m_unitIndex = m_doc->unitIndex(); |
||
159 | int precision = unitGetPrecisionFromIndex(m_unitIndex); |
||
160 | double maxXYWHVal = 16777215 * m_unitRatio; |
||
161 | |||
162 | m_haveDoc = true; |
||
163 | m_haveItem = false; |
||
164 | |||
165 | imageXOffsetSpinBox->setValues( -16777215, maxXYWHVal, precision, 0); |
||
166 | imageYOffsetSpinBox->setValues( -16777215, maxXYWHVal, precision, 0); |
||
167 | |||
168 | imageRotation->setValues( 0, 359.99, 1, 0); |
||
169 | |||
170 | imageXScaleSpinBox->setValues( 1, 30000, 2, 1); |
||
171 | imageYScaleSpinBox->setValues( 1, 30000, 2, 1); |
||
172 | imgDpiX->setValues( 1, 30000, 2, 1); |
||
173 | imgDpiY->setValues( 1, 30000, 2, 1); |
||
20506 | jghali | 174 | updateSpinBoxConstants(); |
16546 | jghali | 175 | |
176 | connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); |
||
177 | connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); |
||
178 | } |
||
179 | |||
180 | void PropertiesPalette_Image::unsetDoc() |
||
181 | { |
||
182 | if (m_doc) |
||
183 | { |
||
184 | disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); |
||
185 | disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); |
||
186 | } |
||
187 | |||
188 | m_haveDoc = false; |
||
189 | m_haveItem = false; |
||
190 | m_doc = NULL; |
||
191 | m_item = NULL; |
||
192 | |||
193 | setEnabled(false); |
||
194 | } |
||
195 | |||
196 | void PropertiesPalette_Image::unsetItem() |
||
197 | { |
||
198 | m_haveItem = false; |
||
199 | m_item = NULL; |
||
200 | handleSelectionChanged(); |
||
201 | } |
||
202 | |||
203 | PageItem* PropertiesPalette_Image::currentItemFromSelection() |
||
204 | { |
||
205 | PageItem *currentItem = NULL; |
||
206 | |||
207 | if (m_doc) |
||
208 | { |
||
209 | if (m_doc->m_Selection->count() > 1) |
||
210 | { |
||
211 | currentItem = m_doc->m_Selection->itemAt(0); |
||
212 | } |
||
213 | else if (m_doc->m_Selection->count() == 1) |
||
214 | { |
||
215 | currentItem = m_doc->m_Selection->itemAt(0); |
||
216 | } |
||
217 | } |
||
218 | |||
219 | return currentItem; |
||
220 | } |
||
221 | |||
222 | void PropertiesPalette_Image::installSniffer(ScrSpinBox *spinBox) |
||
223 | { |
||
224 | const QList<QObject*> list = spinBox->children(); |
||
225 | if (!list.isEmpty()) |
||
226 | { |
||
227 | QListIterator<QObject*> it(list); |
||
228 | QObject *obj; |
||
229 | while (it.hasNext()) |
||
230 | { |
||
231 | obj = it.next(); |
||
232 | obj->installEventFilter(userActionSniffer); |
||
233 | } |
||
234 | } |
||
235 | } |
||
236 | |||
17290 | fschmid | 237 | void PropertiesPalette_Image::installSniffer(QSpinBox *spinBox) |
238 | { |
||
239 | const QList<QObject*> list = spinBox->children(); |
||
240 | if (!list.isEmpty()) |
||
241 | { |
||
242 | QListIterator<QObject*> it(list); |
||
243 | QObject *obj; |
||
244 | while (it.hasNext()) |
||
245 | { |
||
246 | obj = it.next(); |
||
247 | obj->installEventFilter(userActionSniffer); |
||
248 | } |
||
249 | } |
||
250 | } |
||
251 | |||
16546 | jghali | 252 | void PropertiesPalette_Image::updateProfileList() |
253 | { |
||
254 | if (!m_ScMW || m_ScMW->scriptIsRunning()) |
||
255 | return; |
||
256 | if (m_haveDoc) |
||
257 | { |
||
258 | if (ScCore->haveCMS() && m_doc->cmsSettings().CMSinUse) |
||
259 | colorMgmtGroup->show(); |
||
260 | else |
||
261 | { |
||
262 | colorMgmtGroup->hide(); |
||
263 | return; |
||
264 | } |
||
265 | |||
266 | inputProfiles->blockSignals(true); |
||
267 | renderIntent->blockSignals(true); |
||
268 | |||
269 | inputProfiles->clear(); |
||
270 | if (m_haveItem) |
||
271 | { |
||
272 | if (m_item->pixm.imgInfo.colorspace == ColorSpaceCMYK) |
||
273 | { |
||
274 | ProfilesL::Iterator itP; |
||
275 | ProfilesL::Iterator itPend = ScCore->InputProfilesCMYK.end(); |
||
276 | for (itP = ScCore->InputProfilesCMYK.begin(); itP != itPend; ++itP) |
||
277 | { |
||
278 | inputProfiles->addItem(itP.key()); |
||
279 | if (itP.key() == m_item->IProfile) |
||
280 | inputProfiles->setCurrentIndex(inputProfiles->count()-1); |
||
281 | } |
||
282 | if (!ScCore->InputProfilesCMYK.contains(m_item->IProfile)) |
||
283 | { |
||
284 | inputProfiles->addItem(m_item->IProfile); |
||
285 | inputProfiles->setCurrentIndex(inputProfiles->count()-1); |
||
286 | } |
||
287 | else |
||
288 | { |
||
289 | if (!m_item->EmProfile.isEmpty()) |
||
290 | inputProfiles->addItem(m_item->EmProfile); |
||
291 | } |
||
292 | } |
||
293 | else |
||
294 | { |
||
295 | ProfilesL::Iterator itP; |
||
296 | ProfilesL::Iterator itPend=ScCore->InputProfiles.end(); |
||
297 | for (itP = ScCore->InputProfiles.begin(); itP != itPend; ++itP) |
||
298 | { |
||
299 | inputProfiles->addItem(itP.key()); |
||
300 | if (itP.key() == m_item->IProfile) |
||
301 | inputProfiles->setCurrentIndex(inputProfiles->count()-1); |
||
302 | } |
||
303 | if (!ScCore->InputProfiles.contains(m_item->IProfile)) |
||
304 | { |
||
305 | inputProfiles->addItem(m_item->IProfile); |
||
306 | inputProfiles->setCurrentIndex(inputProfiles->count()-1); |
||
307 | } |
||
308 | else |
||
309 | { |
||
310 | if (!m_item->EmProfile.isEmpty()) |
||
311 | inputProfiles->addItem(m_item->EmProfile); |
||
312 | } |
||
313 | } |
||
314 | renderIntent->setCurrentIndex(m_item->IRender); |
||
315 | } |
||
316 | |||
317 | inputProfiles->blockSignals(false); |
||
318 | renderIntent->blockSignals(false); |
||
319 | } |
||
320 | } |
||
321 | |||
322 | void PropertiesPalette_Image::showCMSOptions() |
||
323 | { |
||
324 | if (!m_ScMW || m_ScMW->scriptIsRunning()) |
||
325 | return; |
||
326 | if (m_haveItem) |
||
327 | updateProfileList(); |
||
328 | else if (m_doc) |
||
329 | colorMgmtGroup->setVisible(ScCore->haveCMS() && m_doc->cmsSettings().CMSinUse); |
||
330 | } |
||
331 | |||
18795 | jghali | 332 | void PropertiesPalette_Image::showImageRotation(double rot) |
16546 | jghali | 333 | { |
334 | if (!m_ScMW || m_ScMW->scriptIsRunning()) |
||
335 | return; |
||
336 | double rrR = rot; |
||
337 | if (rot > 0) |
||
338 | rrR = 360 - rrR; |
||
339 | imageRotation->showValue(fabs(rrR)); |
||
340 | } |
||
341 | |||
18795 | jghali | 342 | void PropertiesPalette_Image::showScaleAndOffset(double scx, double scy, double x, double y) |
16546 | jghali | 343 | { |
344 | if (!m_ScMW || m_ScMW->scriptIsRunning()) |
||
345 | return; |
||
20967 | jghali | 346 | bool whRatioBlocked = keepImageWHRatioButton->blockSignals(true); |
347 | bool dpiRatioBlocked = keepImageDPIRatioButton->blockSignals(true); |
||
16546 | jghali | 348 | if (fabs(scx - scy) > 0.0002) |
349 | { |
||
350 | keepImageWHRatioButton->setChecked(false); |
||
351 | keepImageDPIRatioButton->setChecked(false); |
||
352 | } |
||
353 | if (m_haveItem) |
||
354 | { |
||
355 | imageXOffsetSpinBox->showValue(x * m_unitRatio * m_item->imageXScale()); |
||
356 | imageYOffsetSpinBox->showValue(y * m_unitRatio * m_item->imageYScale()); |
||
357 | imageXScaleSpinBox->showValue(scx * 100 / 72.0 * m_item->pixm.imgInfo.xres); |
||
358 | imageYScaleSpinBox->showValue(scy * 100 / 72.0 * m_item->pixm.imgInfo.yres); |
||
359 | imgDpiX->showValue(qRound(720.0 / m_item->imageXScale()) / 10.0); |
||
360 | imgDpiY->showValue(qRound(720.0 / m_item->imageYScale()) / 10.0); |
||
361 | } |
||
362 | else |
||
363 | { |
||
364 | imageXOffsetSpinBox->showValue(x * m_unitRatio); |
||
365 | imageYOffsetSpinBox->showValue(y * m_unitRatio); |
||
366 | imageXScaleSpinBox->showValue(scx * 100); |
||
367 | imageYScaleSpinBox->showValue(scy * 100); |
||
368 | imgDpiX->showValue(72); |
||
369 | imgDpiY->showValue(72); |
||
370 | } |
||
20967 | jghali | 371 | keepImageWHRatioButton->blockSignals(whRatioBlocked); |
372 | keepImageDPIRatioButton->blockSignals(dpiRatioBlocked); |
||
16546 | jghali | 373 | } |
374 | |||
375 | void PropertiesPalette_Image::handleSelectionChanged() |
||
376 | { |
||
377 | if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning()) |
||
378 | return; |
||
379 | |||
380 | PageItem* currItem = currentItemFromSelection(); |
||
381 | if (m_doc->m_Selection->count() > 1) |
||
382 | { |
||
383 | setEnabled(false); |
||
384 | } |
||
385 | else |
||
386 | { |
||
387 | int itemType = currItem ? (int) currItem->itemType() : -1; |
||
388 | m_haveItem = (itemType != -1); |
||
389 | |||
390 | switch (itemType) |
||
391 | { |
||
392 | case -1: |
||
393 | setEnabled(false); |
||
394 | break; |
||
395 | case PageItem::ImageFrame: |
||
396 | case PageItem::LatexFrame: |
||
397 | case PageItem::OSGFrame: |
||
398 | setEnabled(currItem->asOSGFrame() == NULL); |
||
399 | break; |
||
400 | case PageItem::TextFrame: |
||
401 | setEnabled(false); |
||
402 | break; |
||
403 | case PageItem::Line: |
||
404 | setEnabled(false); |
||
405 | break; |
||
406 | case PageItem::Arc: |
||
407 | case PageItem::ItemType1: |
||
408 | case PageItem::ItemType3: |
||
409 | case PageItem::Polygon: |
||
410 | case PageItem::RegularPolygon: |
||
411 | setEnabled(false); |
||
412 | break; |
||
413 | case PageItem::PolyLine: |
||
414 | setEnabled(false); |
||
415 | break; |
||
416 | case PageItem::PathText: |
||
417 | setEnabled(false); |
||
418 | break; |
||
419 | case PageItem::Symbol: |
||
420 | setEnabled(false); |
||
421 | break; |
||
422 | } |
||
423 | } |
||
424 | if (currItem) |
||
425 | { |
||
426 | setCurrentItem(currItem); |
||
427 | } |
||
428 | updateGeometry(); |
||
18480 | jghali | 429 | //repaint(); |
16546 | jghali | 430 | } |
431 | |||
432 | void PropertiesPalette_Image::handleUpdateRequest(int updateFlags) |
||
433 | { |
||
434 | if (updateFlags & reqCmsOptionsUpdate) |
||
435 | showCMSOptions(); |
||
436 | } |
||
437 | |||
438 | void PropertiesPalette_Image::setCurrentItem(PageItem *item) |
||
439 | { |
||
440 | if (!m_ScMW || m_ScMW->scriptIsRunning()) |
||
441 | return; |
||
21026 | craig | 442 | //CB We shouldn't really need to process this if our item is the same one |
16546 | jghali | 443 | //maybe we do if the item has been changed by scripter.. but that should probably |
444 | //set some status if so. |
||
21026 | craig | 445 | //FIXME: This won't work until when a canvas deselect happens, m_item must be NULL. |
16546 | jghali | 446 | //if (m_item == i) |
447 | // return; |
||
448 | |||
449 | if (!m_doc) |
||
450 | setDoc(item->doc()); |
||
451 | |||
452 | m_haveItem = false; |
||
453 | m_item = item; |
||
454 | |||
455 | if (m_item->asImageFrame()) |
||
456 | { |
||
457 | imagePageNumber->blockSignals(true); |
||
19834 | craig | 458 | if(m_item->imageIsAvailable) |
17285 | craig | 459 | { |
460 | imagePageNumber->setMaximum(m_item->pixm.imgInfo.numberOfPages); |
||
461 | imagePageNumber->setEnabled(true); |
||
462 | } |
||
463 | else |
||
464 | imagePageNumber->setEnabled(false); |
||
16546 | jghali | 465 | imagePageNumber->setValue(m_item->pixm.imgInfo.actualPageNumber); |
17285 | craig | 466 | |
16546 | jghali | 467 | compressionMethod->setCurrentIndex(m_item->OverrideCompressionMethod ? m_item->CompressionMethodIndex + 1 : 0); |
468 | compressionQuality->setCurrentIndex(m_item->OverrideCompressionQuality ? m_item->CompressionQualityIndex + 1 : 0); |
||
469 | imagePageNumber->blockSignals(false); |
||
470 | |||
471 | imageXScaleSpinBox->blockSignals(true); |
||
472 | imageYScaleSpinBox->blockSignals(true); |
||
473 | imageXOffsetSpinBox->blockSignals(true); |
||
474 | imageYOffsetSpinBox->blockSignals(true); |
||
475 | imageRotation->blockSignals(true); |
||
476 | |||
19834 | craig | 477 | imgEffectsButton->setVisible(m_item->imageIsAvailable && m_item->isRaster); |
478 | imgExtProperties->setVisible(m_item->imageIsAvailable && m_item->pixm.imgInfo.valid); |
||
16546 | jghali | 479 | bool setter = m_item->ScaleType; |
480 | freeScale->setChecked(setter); |
||
481 | frameScale->setChecked(!setter); |
||
482 | if ((m_item->asLatexFrame()) || (m_item->asOSGFrame())) |
||
483 | { |
||
484 | freeScale->setEnabled(false); |
||
485 | frameScale->setEnabled(false); |
||
486 | cbProportional->setEnabled(false); |
||
487 | imageXScaleSpinBox->setEnabled(false); |
||
488 | imageYScaleSpinBox->setEnabled(false); |
||
489 | imgDpiX->setEnabled(false); |
||
490 | imgDpiY->setEnabled(false); |
||
491 | } |
||
492 | else |
||
493 | { |
||
494 | imageXScaleSpinBox->setEnabled(setter); |
||
495 | imageYScaleSpinBox->setEnabled(setter); |
||
496 | imgDpiX->setEnabled(setter); |
||
497 | imgDpiY->setEnabled(setter); |
||
498 | cbProportional->setEnabled(!setter); |
||
499 | cbProportional->setChecked(m_item->AspectRatio); |
||
500 | freeScale->setEnabled(true); |
||
501 | frameScale->setEnabled(true); |
||
17709 | craig | 502 | //Necessary for undo action |
503 | keepImageWHRatioButton->setEnabled(setter); |
||
504 | keepImageDPIRatioButton->setEnabled(setter); |
||
17747 | craig | 505 | keepImageWHRatioButton->setChecked(m_item->AspectRatio); |
506 | keepImageDPIRatioButton->setChecked(m_item->AspectRatio); |
||
16546 | jghali | 507 | } |
508 | //CB Why do we need this? Setting it too much here |
||
509 | // if (setter == true) |
||
510 | // { |
||
511 | // keepImageWHRatioButton->setChecked(setter); |
||
512 | // keepImageDPIRatioButton->setChecked(setter); |
||
513 | // } |
||
514 | //imageXOffsetSpinBox->setEnabled(setter); |
||
515 | //imageYOffsetSpinBox->setEnabled(setter); |
||
516 | //imageRotation->setEnabled(setter); |
||
517 | |||
518 | imageXScaleSpinBox->blockSignals(false); |
||
519 | imageYScaleSpinBox->blockSignals(false); |
||
520 | imageXOffsetSpinBox->blockSignals(false); |
||
521 | imageYOffsetSpinBox->blockSignals(false); |
||
522 | imageRotation->blockSignals(false); |
||
523 | } |
||
524 | m_haveItem = true; |
||
525 | |||
18795 | jghali | 526 | showScaleAndOffset(m_item->imageXScale(), m_item->imageYScale(), m_item->imageXOffset(), m_item->imageYOffset()); |
16546 | jghali | 527 | double rrR = m_item->imageRotation(); |
528 | if (m_item->imageRotation() > 0) |
||
529 | rrR = 360 - rrR; |
||
530 | imageRotation->showValue(fabs(rrR)); |
||
531 | |||
532 | if (m_item->asImageFrame()) |
||
533 | { |
||
534 | updateProfileList(); |
||
535 | } |
||
536 | if (m_item->asOSGFrame()) |
||
537 | { |
||
538 | setEnabled(false); |
||
539 | } |
||
540 | if (m_item->asSymbolFrame()) |
||
541 | { |
||
542 | setEnabled(false); |
||
543 | } |
||
20506 | jghali | 544 | updateSpinBoxConstants(); |
16546 | jghali | 545 | } |
546 | |||
547 | void PropertiesPalette_Image::handleLocalXY() |
||
548 | { |
||
549 | if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) |
||
550 | return; |
||
551 | m_doc->itemSelection_SetImageOffset(imageXOffsetSpinBox->value() / m_unitRatio / m_item->imageXScale(), imageYOffsetSpinBox->value() / m_unitRatio / m_item->imageYScale()); |
||
552 | } |
||
553 | |||
554 | void PropertiesPalette_Image::handleLocalScale() |
||
555 | { |
||
556 | if (!m_ScMW || m_ScMW->scriptIsRunning()) |
||
557 | return; |
||
558 | if ((m_haveDoc) && (m_haveItem)) |
||
559 | { |
||
21026 | craig | 560 | //CB Don't pass in the scale to the offset change as its taken from the new scale |
16546 | jghali | 561 | m_doc->itemSelection_SetImageScaleAndOffset(imageXScaleSpinBox->value() / 100.0 / m_item->pixm.imgInfo.xres * 72.0, imageYScaleSpinBox->value() / 100.0 / m_item->pixm.imgInfo.yres * 72.0, imageXOffsetSpinBox->value() / m_unitRatio, imageYOffsetSpinBox->value() / m_unitRatio); |
562 | imgDpiX->showValue(qRound(720.0 / m_item->imageXScale()) / 10.0); |
||
563 | imgDpiY->showValue(qRound(720.0 / m_item->imageYScale()) / 10.0); |
||
564 | } |
||
565 | } |
||
566 | |||
567 | void PropertiesPalette_Image::handleLocalDpi() |
||
568 | { |
||
569 | if (!m_ScMW || m_ScMW->scriptIsRunning()) |
||
570 | return; |
||
571 | if ((m_haveDoc) && (m_haveItem)) |
||
572 | { |
||
21026 | craig | 573 | //CB Don't pass in the scale to the offset change as its taken from the new scale |
16546 | jghali | 574 | m_doc->itemSelection_SetImageScaleAndOffset(72.0 / imgDpiX->value(), 72.0 / imgDpiY->value(), imageXOffsetSpinBox->value() / m_unitRatio, imageYOffsetSpinBox->value() / m_unitRatio); |
575 | |||
576 | imageXScaleSpinBox->showValue(m_item->imageXScale() * 100 / 72.0 * m_item->pixm.imgInfo.xres); |
||
577 | imageYScaleSpinBox->showValue(m_item->imageYScale() * 100 / 72.0 * m_item->pixm.imgInfo.yres); |
||
578 | } |
||
579 | } |
||
580 | |||
581 | void PropertiesPalette_Image::handleLocalRotation() |
||
582 | { |
||
583 | if (!m_ScMW || m_ScMW->scriptIsRunning()) |
||
584 | return; |
||
585 | if ((m_haveDoc) && (m_haveItem)) |
||
17045 | fschmid | 586 | { |
16546 | jghali | 587 | m_doc->itemSelection_SetImageRotation(360 - imageRotation->value()); |
17045 | fschmid | 588 | if (frameScale->isChecked()) |
589 | m_item->AdjustPictScale(); |
||
590 | } |
||
16546 | jghali | 591 | } |
592 | |||
593 | void PropertiesPalette_Image::handleScaling() |
||
594 | { |
||
595 | if (!m_ScMW || m_ScMW->scriptIsRunning()) |
||
596 | return; |
||
597 | |||
598 | if (freeScale == sender()) |
||
599 | { |
||
600 | frameScale->setChecked(false); |
||
601 | freeScale->setChecked(true); |
||
602 | cbProportional->setEnabled(false); |
||
603 | // imageXOffsetSpinBox->setEnabled(true); |
||
604 | // imageYOffsetSpinBox->setEnabled(true); |
||
605 | imageXScaleSpinBox->setEnabled(true); |
||
606 | imageYScaleSpinBox->setEnabled(true); |
||
607 | imgDpiX->setEnabled(true); |
||
608 | imgDpiY->setEnabled(true); |
||
609 | // imageRotation->setEnabled(true); |
||
610 | keepImageWHRatioButton->setEnabled(true); |
||
611 | keepImageDPIRatioButton->setEnabled(true); |
||
612 | } |
||
613 | if (frameScale == sender()) |
||
614 | { |
||
615 | frameScale->setChecked(true); |
||
616 | freeScale->setChecked(false); |
||
617 | cbProportional->setEnabled(true); |
||
618 | // imageXOffsetSpinBox->setEnabled(false); |
||
619 | // imageYOffsetSpinBox->setEnabled(false); |
||
620 | imageXScaleSpinBox->setEnabled(false); |
||
621 | imageYScaleSpinBox->setEnabled(false); |
||
622 | imgDpiX->setEnabled(false); |
||
623 | imgDpiY->setEnabled(false); |
||
624 | // imageRotation->setEnabled(false); |
||
625 | keepImageWHRatioButton->setEnabled(false); |
||
626 | keepImageDPIRatioButton->setEnabled(false); |
||
627 | } |
||
628 | |||
629 | if ((m_haveDoc) && (m_haveItem)) |
||
630 | { |
||
631 | m_item->setImageScalingMode(freeScale->isChecked(), cbProportional->isChecked()); |
||
17099 | jghali | 632 | m_doc->changed(); |
16546 | jghali | 633 | emit UpdtGui(PageItem::ImageFrame); |
634 | } |
||
635 | } |
||
636 | |||
637 | void PropertiesPalette_Image::handleXScale() |
||
638 | { |
||
20967 | jghali | 639 | bool xscaleBlocked = imageXScaleSpinBox->blockSignals(true); |
640 | bool yscaleBlocked = imageYScaleSpinBox->blockSignals(true); |
||
16546 | jghali | 641 | if (keepImageWHRatioButton->isChecked()) |
642 | imageYScaleSpinBox->setValue(imageXScaleSpinBox->value()); |
||
643 | handleLocalScale(); |
||
20967 | jghali | 644 | imageXScaleSpinBox->blockSignals(xscaleBlocked); |
645 | imageYScaleSpinBox->blockSignals(yscaleBlocked); |
||
16546 | jghali | 646 | } |
647 | |||
648 | void PropertiesPalette_Image::handleYScale() |
||
649 | { |
||
20967 | jghali | 650 | bool xscaleBlocked = imageXScaleSpinBox->blockSignals(true); |
651 | bool yscaleBlocked = imageYScaleSpinBox->blockSignals(true); |
||
16546 | jghali | 652 | if (keepImageWHRatioButton->isChecked()) |
653 | imageXScaleSpinBox->setValue(imageYScaleSpinBox->value()); |
||
654 | handleLocalScale(); |
||
20967 | jghali | 655 | imageXScaleSpinBox->blockSignals(xscaleBlocked); |
656 | imageYScaleSpinBox->blockSignals(yscaleBlocked); |
||
16546 | jghali | 657 | } |
658 | |||
659 | void PropertiesPalette_Image::handleDpiX() |
||
660 | { |
||
20967 | jghali | 661 | bool dpiXBlocked = imgDpiX->blockSignals(true); |
662 | bool dpiYBlocked = imgDpiY->blockSignals(true); |
||
16546 | jghali | 663 | if (keepImageDPIRatioButton->isChecked()) |
664 | imgDpiY->setValue(imgDpiX->value()); |
||
665 | handleLocalDpi(); |
||
20967 | jghali | 666 | imgDpiX->blockSignals(dpiXBlocked); |
667 | imgDpiY->blockSignals(dpiYBlocked); |
||
16546 | jghali | 668 | } |
669 | |||
670 | void PropertiesPalette_Image::handleDpiY() |
||
671 | { |
||
20967 | jghali | 672 | bool dpiXBlocked = imgDpiX->blockSignals(true); |
673 | bool dpiYBlocked = imgDpiY->blockSignals(true); |
||
16546 | jghali | 674 | if (keepImageDPIRatioButton->isChecked()) |
675 | imgDpiX->setValue(imgDpiY->value()); |
||
676 | handleLocalDpi(); |
||
20967 | jghali | 677 | imgDpiX->blockSignals(dpiXBlocked); |
678 | imgDpiY->blockSignals(dpiYBlocked); |
||
16546 | jghali | 679 | } |
680 | |||
681 | void PropertiesPalette_Image::handleImageDPIRatio() |
||
682 | { |
||
683 | if (!m_ScMW || m_ScMW->scriptIsRunning()) |
||
684 | return; |
||
20967 | jghali | 685 | bool dpiXBlocked = imgDpiX->blockSignals(true); |
686 | bool dpiYBlocked = imgDpiY->blockSignals(true); |
||
16546 | jghali | 687 | if (keepImageDPIRatioButton->isChecked()) |
688 | { |
||
20580 | jghali | 689 | double minXY = qMin(imgDpiX->value(), imgDpiY->value()); |
690 | imgDpiX->setValue(minXY); |
||
691 | imgDpiY->setValue(minXY); |
||
16546 | jghali | 692 | handleLocalDpi(); |
693 | keepImageWHRatioButton->setChecked(true); |
||
17747 | craig | 694 | cbProportional->setChecked(true); |
16546 | jghali | 695 | } |
696 | else |
||
17747 | craig | 697 | { |
16546 | jghali | 698 | keepImageWHRatioButton->setChecked(false); |
17747 | craig | 699 | cbProportional->setChecked(false); |
700 | } |
||
20967 | jghali | 701 | imgDpiX->blockSignals(dpiXBlocked); |
702 | imgDpiY->blockSignals(dpiYBlocked); |
||
16546 | jghali | 703 | } |
704 | |||
705 | void PropertiesPalette_Image::handleImageWHRatio() |
||
706 | { |
||
707 | if (!m_ScMW || m_ScMW->scriptIsRunning()) |
||
708 | return; |
||
20967 | jghali | 709 | bool xscaleBlocked = imageXScaleSpinBox->blockSignals(true); |
710 | bool yscaleBlocked = imageYScaleSpinBox->blockSignals(true); |
||
16546 | jghali | 711 | if (keepImageWHRatioButton->isChecked()) |
712 | { |
||
20580 | jghali | 713 | double maxXY = qMax(imageXScaleSpinBox->value(), imageYScaleSpinBox->value()); |
714 | imageXScaleSpinBox->setValue(maxXY); |
||
715 | imageYScaleSpinBox->setValue(maxXY); |
||
16546 | jghali | 716 | handleLocalScale(); |
717 | keepImageDPIRatioButton->setChecked(true); |
||
17747 | craig | 718 | cbProportional->setChecked(true); |
16546 | jghali | 719 | } |
720 | else |
||
17747 | craig | 721 | { |
16546 | jghali | 722 | keepImageDPIRatioButton->setChecked(false); |
17747 | craig | 723 | cbProportional->setChecked(false); |
724 | } |
||
20967 | jghali | 725 | imageXScaleSpinBox->blockSignals(xscaleBlocked); |
726 | imageYScaleSpinBox->blockSignals(yscaleBlocked); |
||
16546 | jghali | 727 | } |
728 | |||
729 | void PropertiesPalette_Image::handleImageEffects() |
||
730 | { |
||
731 | if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) |
||
732 | return; |
||
733 | m_ScMW->ImageEffects(); |
||
734 | } |
||
735 | |||
736 | void PropertiesPalette_Image::handleExtImgProperties() |
||
737 | { |
||
738 | if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) |
||
739 | return; |
||
740 | m_ScMW->view->editExtendedImageProperties(); |
||
17099 | jghali | 741 | m_doc->changed(); |
16546 | jghali | 742 | } |
743 | |||
744 | void PropertiesPalette_Image::handleImagePageNumber() |
||
745 | { |
||
746 | if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) |
||
747 | return; |
||
748 | bool reallynew = (m_item->pixm.imgInfo.actualPageNumber != imagePageNumber->value()); |
||
17747 | craig | 749 | if(UndoManager::undoEnabled()) |
750 | { |
||
751 | SimpleState *ss = new SimpleState(Um::PageNmbr.arg(static_cast<int>(imagePageNumber->value())),"",Um::IImageFrame); |
||
20807 | jghali | 752 | ss->set("IMAGE_NBR"); |
753 | ss->set("OLD", m_item->pixm.imgInfo.actualPageNumber); |
||
754 | ss->set("NEW", imagePageNumber->value()); |
||
17747 | craig | 755 | UndoManager::instance()->action(m_item,ss); |
756 | } |
||
17420 | fschmid | 757 | m_item->pixm.imgInfo.actualPageNumber = static_cast<int>(imagePageNumber->value()); |
16546 | jghali | 758 | if (reallynew) |
759 | m_item->loadImage(m_item->externalFile(), true); |
||
760 | m_item->update(); |
||
761 | } |
||
762 | |||
763 | void PropertiesPalette_Image::handleProfile(const QString& prn) |
||
764 | { |
||
765 | if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) |
||
766 | return; |
||
767 | m_doc->itemSelection_SetColorProfile(inputProfiles->currentText()); |
||
768 | } |
||
769 | |||
770 | void PropertiesPalette_Image::handleIntent() |
||
771 | { |
||
772 | if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) |
||
773 | return; |
||
774 | m_doc->itemSelection_SetRenderIntent(renderIntent->currentIndex()); |
||
775 | } |
||
776 | |||
777 | void PropertiesPalette_Image::handleCompressionMethod() |
||
778 | { |
||
779 | if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) |
||
780 | return; |
||
781 | m_doc->itemSelection_SetCompressionMethod(compressionMethod->currentIndex() - 1); |
||
782 | } |
||
783 | |||
784 | void PropertiesPalette_Image::handleCompressionQuality() |
||
785 | { |
||
786 | if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) |
||
787 | return; |
||
788 | m_doc->itemSelection_SetCompressionQuality(compressionQuality->currentIndex() - 1); |
||
789 | } |
||
790 | |||
791 | void PropertiesPalette_Image::languageChange() |
||
792 | { |
||
21035 | jghali | 793 | retranslateUi(this); |
794 | |||
20429 | jghali | 795 | imagePageNumber->setSpecialValueText( tr( "Auto" )); |
796 | |||
16546 | jghali | 797 | int oldMonitorI=renderIntent->currentIndex(); |
798 | renderIntent->clear(); |
||
799 | renderIntent->addItem( tr("Perceptual")); |
||
800 | renderIntent->addItem( tr("Relative Colorimetric")); |
||
801 | renderIntent->addItem( tr("Saturation")); |
||
802 | renderIntent->addItem( tr("Absolute Colorimetric")); |
||
803 | renderIntent->setCurrentIndex(oldMonitorI); |
||
804 | |||
805 | int oldCompressionMethod=compressionMethod->currentIndex(); |
||
806 | compressionMethod->clear(); |
||
807 | compressionMethod->addItem( tr( "Global" ) ); |
||
808 | compressionMethod->addItem( tr( "Automatic" ) ); |
||
809 | compressionMethod->addItem( tr( "Lossy - JPEG" ) ); |
||
810 | compressionMethod->addItem( tr( "Lossless - Zip" ) ); |
||
811 | compressionMethod->addItem( tr( "None" ) ); |
||
812 | compressionMethod->setCurrentIndex(oldCompressionMethod); |
||
813 | |||
814 | int oldCompressionQuality=compressionQuality->currentIndex(); |
||
815 | compressionQuality->clear(); |
||
816 | compressionQuality->addItem( tr( "Global" ) ); |
||
817 | compressionQuality->addItem( tr( "Maximum" ) ); |
||
818 | compressionQuality->addItem( tr( "High" ) ); |
||
819 | compressionQuality->addItem( tr( "Medium" ) ); |
||
820 | compressionQuality->addItem( tr( "Low" ) ); |
||
821 | compressionQuality->addItem( tr( "Minimum" ) ); |
||
822 | compressionQuality->setCurrentIndex(oldCompressionQuality); |
||
823 | |||
824 | QString pctSuffix = tr(" %"); |
||
825 | imageXScaleSpinBox->setSuffix(pctSuffix); |
||
826 | imageYScaleSpinBox->setSuffix(pctSuffix); |
||
827 | |||
828 | QString ptSuffix = tr(" pt"); |
||
829 | QString suffix = (m_haveDoc) ? unitGetSuffixFromIndex(m_doc->unitIndex()) : ptSuffix; |
||
830 | |||
831 | imageXOffsetSpinBox->setSuffix(suffix); |
||
832 | imageYOffsetSpinBox->setSuffix(suffix); |
||
833 | } |
||
834 | |||
835 | void PropertiesPalette_Image::unitChange() |
||
836 | { |
||
837 | if (!m_doc) |
||
838 | return; |
||
839 | |||
840 | m_unitRatio = m_doc->unitRatio(); |
||
841 | m_unitIndex = m_doc->unitIndex(); |
||
842 | |||
843 | imageXOffsetSpinBox->blockSignals(true); |
||
844 | imageXOffsetSpinBox->setNewUnit( m_unitIndex ); |
||
845 | imageXOffsetSpinBox->blockSignals(false); |
||
846 | |||
847 | imageYOffsetSpinBox->blockSignals(true); |
||
848 | imageYOffsetSpinBox->setNewUnit( m_unitIndex ); |
||
849 | imageYOffsetSpinBox->blockSignals(false); |
||
850 | } |
||
851 | |||
852 | bool PropertiesPalette_Image::userActionOn() |
||
853 | { |
||
854 | return m_userActionOn;; |
||
855 | } |
||
856 | |||
857 | void PropertiesPalette_Image::spinboxStartUserAction() |
||
858 | { |
||
859 | m_userActionOn = true; |
||
860 | } |
||
861 | |||
862 | void PropertiesPalette_Image::spinboxFinishUserAction() |
||
863 | { |
||
864 | m_userActionOn = false; |
||
865 | |||
866 | for (int i = 0; i < m_doc->m_Selection->count(); ++i) |
||
867 | m_doc->m_Selection->itemAt(i)->checkChanges(true); |
||
868 | if (m_ScMW->view->groupTransactionStarted()) |
||
869 | { |
||
870 | m_ScMW->view->endGroupTransaction(); |
||
871 | } |
||
872 | } |
||
873 | |||
874 |