Rev 121 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3 | paul | 1 | /*************************************************************************** |
2 | page.cpp - description |
||
3 | ------------------- |
||
4 | begin : Sat Apr 7 2001 |
||
5 | copyright : (C) 2001 by Franz Schmid |
||
6 | email : Franz.Schmid@altmuehlnet.de |
||
7 | ***************************************************************************/ |
||
8 | |||
9 | /*************************************************************************** |
||
10 | * * |
||
11 | * This program is free software; you can redistribute it and/or modify * |
||
12 | * it under the terms of the GNU General Public License as published by * |
||
13 | * the Free Software Foundation; either version 2 of the License, or * |
||
14 | * (at your option) any later version. * |
||
15 | * * |
||
16 | ***************************************************************************/ |
||
17 | |||
18 | #include "page.h" |
||
19 | #include "page.moc" |
||
20 | #include "pageitem.h" |
||
21 | #include "serializer.h" |
||
22 | #include "scribusXml.h" |
||
122 | Franz | 23 | #include "config.h" |
3 | paul | 24 | #include <qapplication.h> |
25 | #include <qcolor.h> |
||
26 | #include <qrect.h> |
||
27 | #include <qpointarray.h> |
||
28 | #include <qregion.h> |
||
29 | #include <qcursor.h> |
||
30 | #include <qimage.h> |
||
31 | #include <qfileinfo.h> |
||
32 | #include <qfile.h> |
||
33 | #include <qtextstream.h> |
||
34 | #include <qcstring.h> |
||
35 | #include <qdragobject.h> |
||
36 | #include <qurl.h> |
||
37 | #include <cmath> |
||
38 | #include <cstdio> |
||
39 | #include <cstdlib> |
||
40 | #include <qbitmap.h> |
||
41 | #include <qwmatrix.h> |
||
42 | #include <qpopupmenu.h> |
||
43 | |||
44 | #ifdef HAVE_TIFF |
||
45 | #include <tiffio.h> |
||
46 | #endif |
||
47 | #ifdef HAVE_CMS |
||
44 | Franz | 48 | #include CMS_INC |
3 | paul | 49 | #endif |
50 | extern int PolyC; |
||
51 | extern int PolyFd; |
||
80 | Franz | 52 | extern double PolyF; |
3 | paul | 53 | extern bool PolyS; |
80 | Franz | 54 | extern double PolyR; |
3 | paul | 55 | extern ProfilesL InputProfiles; |
56 | extern QPixmap loadIcon(QString nam); |
||
80 | Franz | 57 | extern double Cwidth(ScribusDoc *doc, QString name, QString ch, int Siz, QString ch2 = " "); |
3 | paul | 58 | #ifdef HAVE_CMS |
59 | QImage ProofPict(QImage *Im, QString Prof, int Rend, cmsHPROFILE emPr=0); |
||
60 | #else |
||
61 | QImage ProofPict(QImage *Im, QString Prof, int Rend); |
||
62 | #endif |
||
80 | Franz | 63 | extern FPointArray RegularPolygonF(double w, double h, uint c, bool star, double factor, double rota); |
3 | paul | 64 | extern QPointArray FlattenPath(FPointArray ina, QValueList<uint> &Segs); |
80 | Franz | 65 | extern double xy2Deg(double x, double y); |
3 | paul | 66 | extern void BezierPoints(QPointArray *ar, QPoint n1, QPoint n2, QPoint n3, QPoint n4); |
67 | extern void Level2Layer(ScribusDoc *doc, struct Layer *ll, int Level); |
||
95 | Franz | 68 | extern FPoint GetMaxClipF(FPointArray Clip); |
3 | paul | 69 | |
70 | Page::Page(QWidget *pa, int x, int y, int b, int h, ScribusDoc *doc, QScrollView *view) |
||
68 | Franz | 71 | : QWidget(pa, "ps", WRepaintNoErase) |
3 | paul | 72 | { |
73 | resize(b, h); |
||
74 | move(x, y); |
||
75 | setEraseColor(doc->papColor); |
||
76 | doku = doc; |
||
77 | Anz = view; |
||
78 | Items.clear(); |
||
79 | Items.setAutoDelete(true); |
||
80 | Margins.Top = 9; |
||
81 | Margins.Left = 9; |
||
82 | Margins.Right = 9; |
||
83 | Margins.Bottom = 40; |
||
84 | SelItem.clear(); |
||
85 | ClRe = -1; |
||
86 | ClRe2 = -1; |
||
87 | setAcceptDrops(true); |
||
88 | emit DocChanged(); |
||
89 | doku->DragP = false; |
||
90 | Imoved = false; |
||
91 | Mpressed = false; |
||
92 | MidButt = false; |
||
93 | HaveSelRect = false; |
||
94 | PageNam = ""; |
||
95 | LeftPg = false; |
||
96 | Magnify = false; |
||
97 | FirstPoly = true; |
||
98 | EdPoints = true; |
||
99 | MoveSym = false; |
||
100 | GroupSel = false; |
||
101 | DraggedGroup = false; |
||
102 | GroupX = 0; |
||
103 | GroupY = 0; |
||
104 | GroupW = 0; |
||
105 | GroupH = 0; |
||
106 | DrHY = -1; |
||
107 | DrVX = -1; |
||
108 | XGuides.clear(); |
||
109 | YGuides.clear(); |
||
110 | GyM = 0; |
||
111 | MoveGY = false; |
||
112 | GxM = 0; |
||
113 | MoveGX = false; |
||
114 | } |
||
115 | |||
116 | void Page::dragLeaveEvent(QDragLeaveEvent *e) |
||
117 | { |
||
118 | if (DraggedGroup) |
||
119 | { |
||
80 | Franz | 120 | double gx, gy, gw, gh; |
3 | paul | 121 | getGroupRectScreen(&gx, &gy, &gw, &gh); |
122 | repaint(static_cast<int>(gx), static_cast<int>(gy), static_cast<int>(gw), static_cast<int>(gh)); |
||
123 | DraggedGroup = false; |
||
124 | } |
||
125 | } |
||
126 | |||
127 | void Page::dragEnterEvent(QDragEnterEvent *e) |
||
128 | { |
||
129 | QString text; |
||
130 | e->accept(QTextDrag::canDecode(e)); |
||
131 | if (QTextDrag::decode(e, text)) |
||
132 | { |
||
80 | Franz | 133 | double gx, gy, gw, gh; |
3 | paul | 134 | QUrl ur(text); |
135 | QFileInfo fi = QFileInfo(ur.path()); |
||
136 | ScriXmlDoc *ss = new ScriXmlDoc(); |
||
137 | if (fi.exists()) |
||
138 | text = ur.path(); |
||
139 | if(ss->ReadElemHeader(text,fi.exists(), &gx, &gy, &gw, &gh)) |
||
140 | { |
||
141 | GroupX = e->pos().x() / doku->Scale; |
||
142 | GroupY = e->pos().y() / doku->Scale; |
||
143 | GroupW = gw; |
||
144 | GroupH = gh; |
||
145 | DraggedGroup = true; |
||
146 | GroupSel = false; |
||
147 | } |
||
148 | delete ss; |
||
149 | setActiveWindow(); |
||
150 | raise(); |
||
151 | SeleItemPos(e->pos()); |
||
152 | } |
||
153 | } |
||
154 | |||
155 | void Page::dragMoveEvent(QDragMoveEvent *e) |
||
156 | { |
||
157 | QString text; |
||
158 | PageItem *b; |
||
159 | bool img; |
||
160 | e->accept(QTextDrag::canDecode(e)); |
||
161 | if (QTextDrag::decode(e, text)) |
||
162 | { |
||
163 | if (DraggedGroup) |
||
164 | { |
||
80 | Franz | 165 | double gx, gy, gw, gh; |
3 | paul | 166 | getGroupRectScreen(&gx, &gy, &gw, &gh); |
167 | repaint(static_cast<int>(gx), static_cast<int>(gy), static_cast<int>(gw), static_cast<int>(gh)); |
||
168 | GroupX = e->pos().x() / doku->Scale; |
||
169 | GroupY = e->pos().y() / doku->Scale; |
||
170 | paintGroupRect(false); |
||
171 | emit MousePos(GroupX, GroupY); |
||
172 | emit Hrule(e->pos().x()+Anz->childX(parentWidget())); |
||
173 | emit Vrule(e->pos().y()+Anz->childY(parentWidget())); |
||
174 | return; |
||
175 | } |
||
176 | QUrl ur(text); |
||
177 | QFileInfo fi = QFileInfo(ur.path()); |
||
178 | QString ext = fi.extension(false).upper(); |
||
179 | QStrList imfo = QImageIO::inputFormats(); |
||
180 | if (ext == "JPG") |
||
181 | ext = "JPEG"; |
||
182 | img = ((imfo.contains(ext))||(ext=="PS")||(ext=="EPS")||(ext=="TIF")); |
||
183 | if (!SeleItemPos(e->pos())) |
||
184 | { |
||
185 | if (SelItem.count() != 0) |
||
186 | Deselect(true); |
||
187 | } |
||
188 | else |
||
189 | { |
||
190 | b = SelItem.at(0); |
||
191 | if (img) |
||
192 | { |
||
193 | if (b->PType != 2) |
||
194 | Deselect(true); |
||
195 | } |
||
196 | else |
||
197 | { |
||
198 | if (b->PType != 4) |
||
199 | Deselect(true); |
||
200 | } |
||
201 | } |
||
202 | } |
||
203 | } |
||
204 | |||
205 | void Page::dropEvent(QDropEvent *e) |
||
206 | { |
||
207 | QString text; |
||
208 | PageItem *b; |
||
75 | Franz | 209 | bool img = false; |
3 | paul | 210 | struct Pti *hg; |
211 | uint a; |
||
212 | int re; |
||
213 | if (QTextDrag::decode(e, text)) |
||
214 | { |
||
215 | QUrl ur(text); |
||
216 | QFileInfo fi = QFileInfo(ur.path()); |
||
217 | QString ext = fi.extension(false).upper(); |
||
218 | QStrList imfo = QImageIO::inputFormats(); |
||
219 | if (ext == "JPG") |
||
220 | ext = "JPEG"; |
||
98 | Franz | 221 | img = ((imfo.contains(ext))||(ext=="PS")||(ext=="EPS")||(ext=="PDF")||(ext=="TIF")); |
97 | Franz | 222 | if ((fi.exists()) && (img) && (!SeleItemPos(e->pos()))) |
223 | { |
||
224 | int z = PaintPict(qRound(e->pos().x()/doku->Scale), qRound(e->pos().y()/doku->Scale), 1, 1); |
||
225 | b = Items.at(z); |
||
226 | LoadPict(ur.path(), b->ItemNr); |
||
227 | b->Width = static_cast<double>(b->pixm.width()); |
||
228 | b->Height = static_cast<double>(b->pixm.height()); |
||
229 | b->OldB2 = b->Width; |
||
230 | b->OldH2 = b->Height; |
||
231 | UpdateClip(b); |
||
232 | emit DocChanged(); |
||
233 | update(); |
||
234 | return; |
||
235 | } |
||
3 | paul | 236 | if ((SeleItemPos(e->pos())) && (!text.startsWith("<SCRIBUSELEM"))) |
237 | { |
||
238 | b = SelItem.at(0); |
||
239 | if (b->PType == 2) |
||
240 | { |
||
241 | if ((fi.exists()) && (img)) |
||
242 | { |
||
243 | LoadPict(ur.path(), b->ItemNr); |
||
244 | update(); |
||
245 | } |
||
246 | } |
||
247 | if (b->PType == 4) |
||
248 | { |
||
249 | if ((b->BackBox != 0) && (b->Ptext.count() == 0)) |
||
250 | return; |
||
251 | if ((fi.exists()) && (!img) && (fi.size() < 500000)) |
||
252 | { |
||
253 | Serializer *ss = new Serializer(ur.path()); |
||
254 | if (ss->Read()) |
||
255 | { |
||
24 | Franz | 256 | int st = doku->CurrentABStil; |
257 | ss->GetText(b, st, doku->Vorlagen[st].Font, doku->Vorlagen[st].FontSize); |
||
3 | paul | 258 | emit DocChanged(); |
259 | } |
||
260 | delete ss; |
||
261 | update(); |
||
262 | } |
||
263 | else |
||
264 | { |
||
265 | slotDoCurs(false); |
||
266 | slotSetCurs(e->pos().x(), e->pos().y()); |
||
267 | if (text.startsWith("<SCRIBUSELEM")) |
||
268 | return; |
||
269 | for (a=0; a<text.length(); ++a) |
||
270 | { |
||
271 | hg = new Pti; |
||
272 | hg->ch = text.at(a); |
||
68 | Franz | 273 | if (hg->ch == QChar(10)) |
274 | hg->ch = QChar(13); |
||
275 | if (hg->ch == QChar(9)) |
||
276 | hg->ch = " "; |
||
3 | paul | 277 | if (hg->ch == QChar(5)) |
68 | Franz | 278 | hg->ch = QChar(13); |
3 | paul | 279 | hg->cfont = b->IFont; |
280 | hg->csize = b->ISize; |
||
68 | Franz | 281 | hg->ccolor = b->TxtFill; |
282 | hg->cshade = b->ShTxtFill; |
||
283 | hg->cstroke = b->TxtStroke; |
||
284 | hg->cshade2 = b->ShTxtStroke; |
||
285 | hg->cselect = false; |
||
286 | hg->cscale = b->TxtScale; |
||
3 | paul | 287 | hg->cextra = 0; |
288 | hg->cstyle = 0; |
||
289 | hg->cab = 0; |
||
290 | hg->xp = 0; |
||
291 | hg->yp = 0; |
||
292 | hg->PRot = 0; |
||
293 | hg->PtransX = 0; |
||
294 | hg->PtransY = 0; |
||
295 | b->Ptext.insert(b->CPos, hg); |
||
296 | b->CPos += 1; |
||
297 | } |
||
298 | b->Dirty = true; |
||
299 | emit DocChanged(); |
||
300 | update(); |
||
301 | } |
||
302 | } |
||
303 | } |
||
304 | else |
||
305 | { |
||
306 | if ((fi.exists()) && (!img)) |
||
307 | { |
||
308 | emit LoadElem(QString(ur.path()), qRound(e->pos().x()/doku->Scale), qRound(e->pos().y()/doku->Scale), true, false, doku); |
||
309 | } |
||
310 | else |
||
311 | { |
||
312 | if (doku->DraggedElem != 0) |
||
80 | Franz | 313 | { |
3 | paul | 314 | QPopupMenu *pmen = new QPopupMenu(); |
315 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
112 | Franz | 316 | pmen->insertItem( tr("Copy Here")); |
317 | pmen->insertItem( tr("Move Here")); |
||
318 | pmen->insertItem( tr("Cancel")); |
||
3 | paul | 319 | re = pmen->indexOf(pmen->exec(QCursor::pos())); |
320 | delete pmen; |
||
321 | if (re == 1) |
||
322 | { |
||
323 | doku->DraggedElem->OwnPage->SelItem.clear(); |
||
324 | for (uint dre=0; dre<doku->DragElements.count(); ++dre) |
||
325 | { |
||
326 | doku->DraggedElem->OwnPage->SelItem.append(doku->DraggedElem->OwnPage->Items.at(doku->DragElements[dre])); |
||
327 | } |
||
328 | doku->DraggedElem->OwnPage->DeleteItem(); |
||
329 | } |
||
330 | } |
||
331 | else |
||
332 | re = 1; |
||
333 | if ((!img) && ((re == 0) || (re == 1))) |
||
334 | emit LoadElem(QString(text), qRound(e->pos().x()/doku->Scale), qRound(e->pos().y()/doku->Scale), false, false, doku); |
||
75 | Franz | 335 | // Deselect(true); |
3 | paul | 336 | doku->DraggedElem = 0; |
337 | doku->DragElements.clear(); |
||
338 | } |
||
339 | } |
||
340 | } |
||
341 | } |
||
342 | |||
68 | Franz | 343 | /** No descriptions */ |
344 | void Page::paintEvent(QPaintEvent *e) |
||
3 | paul | 345 | { |
68 | Franz | 346 | QRect vr = ViewReg().boundingRect().intersect(e->rect()); |
347 | if ((vr.width() < 1) || (vr.height() < 1)) |
||
348 | return; |
||
349 | QPixmap pgPix(vr.width(), vr.height()); |
||
350 | ScPainter *painter = new ScPainter(&pgPix, pgPix.width(), pgPix.height()); |
||
351 | painter->translate(0.5, 0.5); |
||
352 | if (doku->Before) |
||
108 | Franz | 353 | DrawPageMarks(painter, vr); |
68 | Franz | 354 | // QTime tim; |
355 | // tim.start(); |
||
108 | Franz | 356 | DrawPageItems(painter, vr); |
68 | Franz | 357 | // qDebug( "Time elapsed: %d ms", tim.elapsed() ); |
358 | if (!doku->Before) |
||
108 | Franz | 359 | DrawPageMarks(painter, vr); |
68 | Franz | 360 | painter->end(); |
361 | bitBlt( this, vr.x(), vr.y(), &pgPix, 0, 0, pgPix.width(), pgPix.height() ); |
||
3 | paul | 362 | QPainter p; |
68 | Franz | 363 | p.begin(this); |
364 | p.setPen(QColor(0, 0, 0)); |
||
365 | p.setBrush(NoBrush); |
||
366 | p.drawRect(0, 0, width(), height()); |
||
367 | p.end(); |
||
368 | if (SelItem.count() != 0) |
||
369 | { |
||
370 | PageItem *b = SelItem.at(0); |
||
371 | b->paintObj(e->rect()); |
||
372 | if ((doku->EditClip) && (b->Select)) |
||
373 | MarkClip(b); |
||
374 | if (GroupSel) |
||
375 | { |
||
376 | setGroupRect(); |
||
377 | paintGroupRect(); |
||
378 | } |
||
379 | } |
||
380 | delete painter; |
||
381 | } |
||
382 | |||
108 | Franz | 383 | void Page::DrawPageMarks(ScPainter *p, QRect rd) |
68 | Franz | 384 | { |
80 | Franz | 385 | double b; |
68 | Franz | 386 | if ((rd.width() == 0) || (rd.height() == 0)) |
387 | return; |
||
80 | Franz | 388 | double lw = 1.0 / doku->Scale; |
68 | Franz | 389 | p->setZoomFactor(doku->Scale); |
390 | QWMatrix ma = p->worldMatrix(); |
||
391 | QWMatrix ma2 = p->worldMatrix(); |
||
392 | ma.translate(-rd.x(), -rd.y()); |
||
393 | p->setWorldMatrix(ma); |
||
394 | p->setLineWidth(lw); |
||
3 | paul | 395 | if (doku->Marks) |
396 | { |
||
68 | Franz | 397 | p->setPen(doku->margColor); |
3 | paul | 398 | if (doku->RandFarbig) |
399 | { |
||
68 | Franz | 400 | p->setBrush(doku->margColor); |
401 | p->drawRect(0, 0, width()/doku->Scale, Margins.Top); |
||
402 | p->drawRect(0, Margins.Top, Margins.Left, height()/doku->Scale-Margins.Top); |
||
403 | p->drawRect(Margins.Left, height()/doku->Scale-Margins.Bottom, width()/doku->Scale-Margins.Right-Margins.Left, Margins.Bottom); |
||
404 | p->drawRect(width()/doku->Scale-Margins.Right, Margins.Top, Margins.Right, height()/doku->Scale); |
||
3 | paul | 405 | } |
68 | Franz | 406 | p->setPen(doku->margColor); |
407 | p->drawLine(FPoint(0, Margins.Top), FPoint(width()/doku->Scale, Margins.Top)); |
||
408 | p->drawLine(FPoint(0, height()/doku->Scale-Margins.Bottom), FPoint(width()/doku->Scale, height()/doku->Scale-Margins.Bottom)); |
||
409 | p->drawLine(FPoint(Margins.Left, 0), FPoint(Margins.Left, height()/doku->Scale)); |
||
410 | p->drawLine(FPoint(width()/doku->Scale-Margins.Right, 0), FPoint(width()/doku->Scale-Margins.Right, height()/doku->Scale)); |
||
3 | paul | 411 | } |
412 | if (doku->Raster) |
||
413 | { |
||
108 | Franz | 414 | double stx = rd.x()/doku->Scale; |
415 | double endx = rd.x()/doku->Scale+rd.width()/doku->Scale; |
||
416 | double sty = rd.y()/doku->Scale; |
||
417 | double endy = rd.y()/doku->Scale+rd.height()/doku->Scale; |
||
3 | paul | 418 | if (doku->Scale > 0.49) |
419 | { |
||
80 | Franz | 420 | double i,start; |
3 | paul | 421 | i=doku->majorGrid*doku->Scale; |
68 | Franz | 422 | p->setPen(doku->majorColor, lw, SolidLine, FlatCap, MiterJoin); |
3 | paul | 423 | start=floor(sty/i); |
424 | start*=i; |
||
425 | for (b = start; b < endy; b+=i) |
||
68 | Franz | 426 | p->drawLine(FPoint(0, b), FPoint(width()/doku->Scale, b)); |
3 | paul | 427 | start=floor(stx/i); |
428 | start*=i; |
||
429 | for (b = start; b <= endx; b+=i) |
||
68 | Franz | 430 | p->drawLine(FPoint(b, 0), FPoint(b, height()/doku->Scale)); |
3 | paul | 431 | i=doku->minorGrid*doku->Scale; |
68 | Franz | 432 | p->setPen(doku->minorColor, lw, DotLine, FlatCap, MiterJoin); |
3 | paul | 433 | start=floor(sty/i); |
434 | start*=i; |
||
435 | for (b = start; b < endy; b+=i) |
||
68 | Franz | 436 | p->drawLine(FPoint(0, b), FPoint(width()/doku->Scale, b)); |
3 | paul | 437 | start=floor(stx/i); |
438 | start*=i; |
||
439 | for (b = start; b <= endx; b+=i) |
||
68 | Franz | 440 | p->drawLine(FPoint(b, 0), FPoint(b, height()/doku->Scale)); |
3 | paul | 441 | } |
442 | } |
||
443 | if (doku->Guides) |
||
444 | { |
||
445 | if (XGuides.count() != 0) |
||
446 | { |
||
68 | Franz | 447 | p->setPen(doku->guideColor, lw, SolidLine, FlatCap, MiterJoin); |
3 | paul | 448 | for (uint xg = 0; xg < XGuides.count(); ++xg) |
449 | { |
||
68 | Franz | 450 | p->drawLine(FPoint(XGuides[xg], 0), FPoint(XGuides[xg], doku->PageH)); |
3 | paul | 451 | } |
452 | } |
||
453 | if (YGuides.count() != 0) |
||
454 | { |
||
68 | Franz | 455 | p->setPen(doku->guideColor, lw, SolidLine, FlatCap, MiterJoin); |
3 | paul | 456 | for (uint yg = 0; yg < YGuides.count(); ++yg) |
457 | { |
||
68 | Franz | 458 | p->drawLine(FPoint(0, YGuides[yg]), FPoint(doku->PageB, YGuides[yg])); |
3 | paul | 459 | } |
460 | } |
||
461 | } |
||
68 | Franz | 462 | p->setWorldMatrix(ma2); |
3 | paul | 463 | } |
464 | |||
108 | Franz | 465 | void Page::DrawPageItems(ScPainter *painter, QRect rd) |
3 | paul | 466 | { |
467 | QPainter p; |
||
468 | uint a; |
||
469 | int Lnr; |
||
470 | struct Layer ll; |
||
471 | PageItem* b; |
||
472 | ll.Sichtbar = false; |
||
473 | ll.LNr = 0; |
||
474 | ScribusView* vi = (ScribusView*)Anz; |
||
68 | Franz | 475 | if ((rd.width() == 0) || (rd.height() == 0)) |
476 | return; |
||
3 | paul | 477 | if (MPageNam != "") |
478 | { |
||
479 | Page* Mp = vi->MasterPages.at(vi->MasterNames[MPageNam]); |
||
480 | QWidget* Opa; |
||
481 | Page* Opa2; |
||
482 | if (Mp->Items.count() != 0) |
||
483 | { |
||
484 | Lnr = 0; |
||
485 | for (uint la = 0; la < doku->Layers.count(); ++la) |
||
486 | { |
||
487 | Level2Layer(doku, &ll, Lnr); |
||
488 | if (ll.Sichtbar) |
||
489 | { |
||
490 | for (a = 0; a < Mp->Items.count(); ++a) |
||
491 | { |
||
492 | b = Mp->Items.at(a); |
||
493 | if (b->LayerNr != ll.LNr) |
||
494 | continue; |
||
495 | Opa = b->Parent; |
||
496 | Opa2 = b->OwnPage; |
||
497 | b->Parent = this; |
||
498 | b->OwnPage = this; |
||
68 | Franz | 499 | b->DrawObj(painter, rd); |
3 | paul | 500 | b->Parent = Opa; |
501 | b->OwnPage = Opa2; |
||
502 | } |
||
503 | } |
||
504 | Lnr++; |
||
505 | } |
||
506 | } |
||
507 | } |
||
508 | if (Items.count() != 0) |
||
509 | { |
||
510 | Lnr = 0; |
||
511 | for (uint la2 = 0; la2 < doku->Layers.count(); ++la2) |
||
512 | { |
||
513 | Level2Layer(doku, &ll, Lnr); |
||
514 | if (ll.Sichtbar) |
||
515 | { |
||
516 | for (a = 0; a < Items.count(); ++a) |
||
517 | { |
||
518 | b = Items.at(a); |
||
519 | if (b->LayerNr != ll.LNr) |
||
520 | continue; |
||
521 | QPainter p; |
||
522 | p.begin(this); |
||
523 | Transform(b, &p); |
||
524 | QRegion apr = QRegion(p.xForm(b->Clip)); |
||
525 | QRegion apr2 = QRegion(p.xForm(QRect(-1, -1, static_cast<int>(b->Width), static_cast<int>(b->Height)))); |
||
526 | p.end(); |
||
68 | Franz | 527 | if ((rd.intersects(apr.boundingRect())) || (rd.intersects(apr2.boundingRect()))) |
3 | paul | 528 | { |
74 | Franz | 529 | b->DrawObj(painter, rd); |
530 | b->Redrawn = true; |
||
3 | paul | 531 | if ((doku->AppMode == 7) && (b->Select)) |
532 | slotDoCurs(true); |
||
533 | } |
||
534 | } |
||
535 | } |
||
536 | Lnr++; |
||
537 | } |
||
538 | } |
||
539 | } |
||
540 | |||
541 | void Page::setGroupRect() |
||
542 | { |
||
543 | PageItem* b; |
||
80 | Franz | 544 | double minx = 99999.9; |
545 | double miny = 99999.9; |
||
546 | double maxx = -99999.9; |
||
547 | double maxy = -99999.9; |
||
3 | paul | 548 | for (uint gc = 0; gc < SelItem.count(); ++gc) |
549 | { |
||
550 | b = SelItem.at(gc); |
||
75 | Franz | 551 | if (b->Rot != 0) |
552 | { |
||
553 | QPainter p; |
||
554 | p.begin(this); |
||
555 | p.translate(static_cast<int>(b->Xpos), static_cast<int>(b->Ypos)); |
||
556 | p.rotate(b->Rot); |
||
557 | QRect apr = QRegion(p.xForm(QRect(0, 0, static_cast<int>(b->Width), static_cast<int>(QMAX(b->Height, 1))))).boundingRect(); |
||
558 | p.end(); |
||
559 | minx = QMIN(minx, apr.x()); |
||
560 | miny = QMIN(miny, apr.y()); |
||
561 | maxx = QMAX(maxx, apr.x() + apr.width()); |
||
562 | maxy = QMAX(maxy, apr.y() + apr.height()); |
||
563 | } |
||
564 | else |
||
565 | { |
||
566 | minx = QMIN(minx, b->Xpos); |
||
567 | miny = QMIN(miny, b->Ypos); |
||
568 | maxx = QMAX(maxx, b->Xpos + b->Width); |
||
569 | maxy = QMAX(maxy, b->Ypos + b->Height); |
||
570 | } |
||
3 | paul | 571 | } |
572 | GroupX = minx; |
||
573 | GroupY = miny; |
||
574 | GroupW = maxx - minx; |
||
575 | GroupH = maxy - miny; |
||
576 | GroupSel = true; |
||
577 | } |
||
578 | |||
80 | Franz | 579 | void Page::moveGroup(double x, double y, bool fromMP) |
3 | paul | 580 | { |
581 | PageItem* b; |
||
80 | Franz | 582 | double gx, gy, gw, gh; |
3 | paul | 583 | if (GroupSel) |
584 | getGroupRectScreen(&gx, &gy, &gw, &gh); |
||
585 | for (uint a = 0; a < SelItem.count(); ++a) |
||
586 | { |
||
587 | b = SelItem.at(a); |
||
588 | MoveItem(x, y, b, fromMP); |
||
589 | } |
||
590 | if (GroupSel) |
||
591 | repaint(QRect(static_cast<int>(gx-5), static_cast<int>(gy-5), static_cast<int>(gw+10), static_cast<int>(gh+10))); |
||
592 | } |
||
593 | |||
80 | Franz | 594 | void Page::getGroupRect(double *x, double *y, double *w, double *h) |
3 | paul | 595 | { |
596 | *x = GroupX; |
||
597 | *y = GroupY; |
||
598 | *w = GroupW; |
||
599 | *h = GroupH; |
||
600 | } |
||
601 | |||
80 | Franz | 602 | void Page::getGroupRectScreen(double *x, double *y, double *w, double *h) |
3 | paul | 603 | { |
80 | Franz | 604 | double sc = doku->Scale; |
3 | paul | 605 | *x = GroupX*sc; |
606 | *y = GroupY*sc; |
||
607 | *w = GroupW*sc; |
||
608 | *h = GroupH*sc; |
||
609 | } |
||
610 | |||
611 | void Page::paintGroupRect(bool norm) |
||
612 | { |
||
80 | Franz | 613 | double x, y, w, h; |
3 | paul | 614 | getGroupRectScreen(&x, &y, &w, &h); |
615 | QPainter pgc; |
||
616 | pgc.begin(this); |
||
617 | if (norm) |
||
618 | pgc.setPen(QPen(red, 1, DotLine, FlatCap, MiterJoin)); |
||
619 | else |
||
620 | pgc.setPen(QPen(black, 1, DotLine, FlatCap, MiterJoin)); |
||
621 | pgc.setBrush(NoBrush); |
||
622 | pgc.drawRect(static_cast<int>(x), static_cast<int>(y), static_cast<int>(w), static_cast<int>(h)); |
||
623 | pgc.setBrush(red); |
||
624 | if (norm) |
||
625 | { |
||
626 | pgc.setPen(QPen(red, 1, SolidLine, FlatCap, MiterJoin)); |
||
627 | pgc.drawRect(static_cast<int>(x+w-6), static_cast<int>(y+h-6), 6, 6); |
||
628 | } |
||
629 | // pgc.drawRect(int(x), int(y), 6, 6); |
||
630 | /* pgc.drawRect(int(x+w-6), int(y), 6, 6); |
||
631 | pgc.drawRect(int(x), int(y+h-6), 6, 6); |
||
632 | if (w > 6) |
||
633 | { |
||
634 | pgc.drawRect(int(x+w/2 - 3), int(y+h-6), 6, 6); |
||
635 | pgc.drawRect(int(x+w/2 - 3), int(y), 6, 6); |
||
636 | } |
||
637 | if (h > 6) |
||
638 | { |
||
639 | pgc.drawRect(int(x+w-6), int(y+h/2 - 3), 6, 6); |
||
640 | pgc.drawRect(int(x), int(y+h/2 - 3), 6, 6); |
||
641 | } */ |
||
642 | pgc.end(); |
||
643 | } |
||
644 | |||
645 | void Page::storeUndoInf(PageItem* b) |
||
646 | { |
||
647 | if ((doku->UnData.UnCode == 0) && (doku->UnDoValid)) |
||
648 | delete doku->UnData.Item; |
||
649 | doku->UnDoValid = false; |
||
650 | doku->UnData.Xpos = b->Xpos; |
||
651 | doku->UnData.Ypos = b->Ypos; |
||
652 | doku->UnData.Width = b->Width; |
||
653 | doku->UnData.Height = b->Height; |
||
654 | doku->UnData.Rot = b->Rot; |
||
655 | doku->UnData.Item = b; |
||
656 | doku->UnData.PageNr = PageNr; |
||
657 | doku->UnData.ItemNr = b->ItemNr; |
||
658 | } |
||
659 | |||
660 | QRegion Page::ViewReg() |
||
661 | { |
||
68 | Franz | 662 | int cx = Anz->contentsX() - Anz->childX(parentWidget()); |
663 | int cy = Anz->contentsY() - Anz->childY(parentWidget()); |
||
3 | paul | 664 | int cw = Anz->visibleWidth(); |
665 | int ch = Anz->visibleHeight(); |
||
666 | return QRegion(QRect(cx, cy, cw, ch)); |
||
667 | } |
||
668 | |||
669 | void Page::Transform(PageItem *b, QPainter *p) |
||
670 | { |
||
49 | paul | 671 | p->translate(static_cast<int>(b->Xpos*doku->Scale), |
672 | static_cast<int>(b->Ypos*doku->Scale)); |
||
3 | paul | 673 | p->scale(doku->Scale, doku->Scale); |
674 | p->rotate(b->Rot); |
||
675 | } |
||
676 | |||
677 | bool Page::GetItem(PageItem **b, int nr) |
||
678 | { |
||
679 | if (SelItem.count() != 0) |
||
680 | { |
||
681 | if (nr == -1) |
||
682 | *(b) = SelItem.at(0); |
||
683 | else |
||
684 | *(b) = SelItem.at(nr); |
||
685 | return true; |
||
686 | } |
||
687 | else |
||
688 | { |
||
689 | *(b) = 0; |
||
690 | return false; |
||
691 | } |
||
692 | } |
||
693 | |||
694 | void Page::TransformM(PageItem *b, QPainter *p) |
||
695 | { |
||
696 | if (b->flippedH % 2 != 0) |
||
697 | { |
||
698 | p->translate(b->Width, 0); |
||
699 | p->scale(-1, 1); |
||
700 | } |
||
701 | if (b->flippedV % 2 != 0) |
||
702 | { |
||
703 | p->translate(0, b->Height); |
||
704 | p->scale(1, -1); |
||
705 | } |
||
706 | } |
||
707 | |||
708 | void Page::PaintSizeRect(QPainter *p, QRect alt, QRect neu) |
||
709 | { |
||
710 | p->setRasterOp(XorROP); |
||
711 | p->setBrush(NoBrush); |
||
712 | p->setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin)); |
||
713 | p->drawRect(alt); |
||
714 | p->drawRect(neu); |
||
715 | } |
||
716 | |||
717 | QPoint Page::ApplyGrid(QPoint in) |
||
718 | { |
||
719 | QPoint np; |
||
720 | if (doku->useRaster) |
||
721 | { |
||
722 | np.setX(static_cast<int>(qRound(in.x() / doku->minorGrid) * doku->minorGrid)); |
||
723 | np.setY(static_cast<int>(qRound(in.y() / doku->minorGrid) * doku->minorGrid)); |
||
724 | } |
||
725 | else |
||
726 | np = in; |
||
727 | return np; |
||
728 | } |
||
729 | |||
80 | Franz | 730 | void Page::ApplyGuides(double *x, double *y) |
3 | paul | 731 | { |
732 | if (doku->SnapGuides) |
||
733 | { |
||
734 | if (YGuides.count() != 0) |
||
735 | { |
||
736 | for (uint yg = 0; yg < YGuides.count(); ++yg) |
||
737 | { |
||
738 | if ((YGuides[yg] < (*y+doku->GuideRad)) && (YGuides[yg] > (*y-doku->GuideRad))) |
||
739 | { |
||
740 | *y= YGuides[yg]; |
||
741 | break; |
||
742 | } |
||
743 | } |
||
744 | } |
||
745 | if (XGuides.count() != 0) |
||
746 | { |
||
747 | for (uint xg = 0; xg < XGuides.count(); ++xg) |
||
748 | { |
||
749 | if ((XGuides[xg] < (*x+doku->GuideRad)) && (XGuides[xg] > (*x-doku->GuideRad))) |
||
750 | { |
||
751 | *x = XGuides[xg]; |
||
752 | break; |
||
753 | } |
||
754 | } |
||
755 | } |
||
756 | } |
||
757 | } |
||
758 | |||
759 | FPoint Page::ApplyGridF(FPoint in) |
||
760 | { |
||
761 | FPoint np; |
||
762 | if (doku->useRaster) |
||
763 | { |
||
764 | np.setX(qRound(in.x() / doku->minorGrid) * doku->minorGrid); |
||
765 | np.setY(qRound(in.y() / doku->minorGrid) * doku->minorGrid); |
||
766 | } |
||
767 | else |
||
768 | np = in; |
||
769 | return np; |
||
770 | } |
||
771 | |||
74 | Franz | 772 | void Page::RefreshItem(PageItem *b, bool single) |
3 | paul | 773 | { |
774 | QPainter p; |
||
775 | p.begin(this); |
||
776 | Transform(b, &p); |
||
74 | Franz | 777 | if (single) |
122 | Franz | 778 | RepaintTextRegion(b, QRegion(p.xForm(QRect(static_cast<int>(-b->Pwidth / 2.0), static_cast<int>(-b->Pwidth / 2.0), static_cast<int>(b->Width+(b->Pwidth / 2.0)), static_cast<int>(b->Height+(b->Pwidth / 2.0))))), true); |
3 | paul | 779 | else |
122 | Franz | 780 | update(QRegion(p.xForm(QRect(static_cast<int>(-b->Pwidth / 2.0), static_cast<int>(-b->Pwidth / 2.0), static_cast<int>(b->Width+(b->Pwidth / 2.0)), static_cast<int>(b->Height+(b->Pwidth / 2.0))))).intersect(ViewReg()).boundingRect()); |
3 | paul | 781 | p.end(); |
782 | } |
||
783 | |||
75 | Franz | 784 | void Page::RepaintTextRegion(PageItem *b, QRegion alt, bool single) |
3 | paul | 785 | { |
786 | QPainter p; |
||
787 | QRegion neu; |
||
74 | Franz | 788 | if (!isUpdatesEnabled()) |
789 | return; |
||
3 | paul | 790 | p.begin(this); |
791 | Transform(b, &p); |
||
792 | neu = QRegion(p.xForm(QRect(0, 0, static_cast<int>(b->Width+1), static_cast<int>(b->Height+1)))).unite(alt); |
||
793 | p.end(); |
||
794 | b->Dirty = true; |
||
795 | QRect g = neu.boundingRect(); |
||
122 | Franz | 796 | g.setX(g.x()-static_cast<int>(b->Pwidth / 2.0)); |
797 | g.setY(g.y()-static_cast<int>(b->Pwidth / 2.0)); |
||
798 | g.setWidth(g.width()+static_cast<int>(b->Pwidth / 2.0)); |
||
799 | g.setHeight(g.height()+static_cast<int>(b->Pwidth / 2.0)); |
||
75 | Franz | 800 | if (single) |
3 | paul | 801 | { |
75 | Franz | 802 | QRect rd = ViewReg().boundingRect().intersect(g); |
803 | if ((rd.width() < 1) || (rd.height() < 1)) |
||
804 | return; |
||
805 | QPixmap pgPix(rd.width(), rd.height()); |
||
806 | ScPainter *painter = new ScPainter(&pgPix, pgPix.width(), pgPix.height()); |
||
807 | painter->translate(0.5, 0.5); |
||
108 | Franz | 808 | if (doku->Before) |
809 | DrawPageMarks(painter, rd); |
||
75 | Franz | 810 | b->DrawObj(painter, rd); |
108 | Franz | 811 | if (!doku->Before) |
812 | DrawPageMarks(painter, rd); |
||
75 | Franz | 813 | painter->end(); |
814 | bitBlt( this, rd.x(), rd.y(), &pgPix, 0, 0, pgPix.width(), pgPix.height() ); |
||
815 | QPainter px; |
||
816 | px.begin(this); |
||
817 | px.setPen(QColor(0, 0, 0)); |
||
818 | px.setBrush(NoBrush); |
||
819 | px.drawRect(0, 0, width(), height()); |
||
820 | px.end(); |
||
821 | b->paintObj(rd); |
||
822 | if ((doku->EditClip) && (b->Select)) |
||
823 | MarkClip(b); |
||
824 | if (GroupSel) |
||
825 | { |
||
826 | setGroupRect(); |
||
827 | paintGroupRect(); |
||
828 | } |
||
829 | delete painter; |
||
3 | paul | 830 | } |
75 | Franz | 831 | else |
832 | { |
||
833 | neu = QRegion(g); |
||
834 | update(neu.intersect(ViewReg()).boundingRect()); |
||
835 | } |
||
3 | paul | 836 | } |
837 | |||
838 | void Page::AdjustPreview(PageItem *b) |
||
839 | { |
||
840 | int neww, newh, fho, fvo; |
||
63 | Franz | 841 | bool savF; |
3 | paul | 842 | if ((b->LocalViewX < 1.0) || (b->LocalViewY < 1.0)) |
843 | { |
||
844 | if ((b->Pfile != "") && (b->PicAvail)) |
||
845 | { |
||
846 | if (!b->Sizing) |
||
847 | { |
||
848 | fho = b->flippedH; |
||
849 | fvo = b->flippedV; |
||
63 | Franz | 850 | savF = b->PicArt; |
3 | paul | 851 | LoadPict(b->Pfile, b->ItemNr); |
852 | b->flippedH = fho; |
||
853 | b->flippedV = fvo; |
||
63 | Franz | 854 | b->PicArt = savF; |
3 | paul | 855 | } |
856 | neww = qRound(b->pixm.width() * b->LocalViewX); |
||
857 | newh = qRound(b->pixm.height() * b->LocalViewY); |
||
858 | b->pixm = b->pixm.smoothScale(neww, newh); |
||
859 | b->LocalViewX = 1; |
||
860 | b->LocalViewY = 1; |
||
861 | } |
||
862 | } |
||
863 | } |
||
864 | |||
865 | void Page::AdjustPictScale(PageItem *b) |
||
866 | { |
||
867 | int fho, fvo; |
||
63 | Franz | 868 | bool savF; |
3 | paul | 869 | if (b->ScaleType) |
870 | return; |
||
871 | b->LocalX = 0; |
||
872 | b->LocalY = 0; |
||
873 | if ((b->OrigW == 0) || (b->OrigH == 0)) |
||
874 | return; |
||
80 | Franz | 875 | double xs = b->Width / static_cast<double>(b->OrigW); |
876 | double ys = b->Height / static_cast<double>(b->OrigH); |
||
3 | paul | 877 | if (!b->Sizing) |
878 | { |
||
879 | fho = b->flippedH; |
||
880 | fvo = b->flippedV; |
||
63 | Franz | 881 | savF = b->PicArt; |
3 | paul | 882 | LoadPict(b->Pfile, b->ItemNr); |
883 | b->flippedH = fho; |
||
884 | b->flippedV = fvo; |
||
63 | Franz | 885 | b->PicArt = savF; |
3 | paul | 886 | } |
887 | if (b->AspectRatio) |
||
888 | { |
||
889 | b->LocalScX = QMIN(xs, ys); |
||
890 | b->LocalScY = QMIN(xs, ys); |
||
891 | b->LocalViewX = QMIN(xs, ys); |
||
892 | b->LocalViewY = QMIN(xs, ys); |
||
893 | } |
||
894 | else |
||
895 | { |
||
896 | b->LocalScX = xs; |
||
897 | b->LocalScY = ys; |
||
898 | b->LocalViewX = xs; |
||
899 | b->LocalViewY = ys; |
||
900 | } |
||
901 | emit SetLocalValues(b->LocalScX, b->LocalScY, b->LocalX, b->LocalY ); |
||
902 | } |
||
903 | |||
904 | bool Page::MoveSizeItem(FPoint newX, FPoint newY, int ite) |
||
905 | { |
||
906 | QRegion alt; |
||
907 | QPainter p; |
||
908 | PageItem *b = Items.at(ite); |
||
909 | p.begin(this); |
||
910 | Transform(b, &p); |
||
911 | alt = QRegion(p.xForm(QRect(0, 0, static_cast<int>(b->Width), static_cast<int>(b->Height)))); |
||
912 | p.end(); |
||
913 | if (b->PType == 5) |
||
914 | { |
||
915 | QWMatrix ma; |
||
916 | ma.translate(b->Xpos, b->Ypos); |
||
917 | ma.rotate(b->Rot); |
||
80 | Franz | 918 | double mx = ma.m11() * b->Width + ma.m21() * b->Height + ma.dx(); |
919 | double my = ma.m22() * b->Height + ma.m12() * b->Width + ma.dy(); |
||
3 | paul | 920 | MoveItem(newX.x(), newX.y(), b); |
921 | b->Rot = xy2Deg(mx - b->Xpos, my - b->Ypos); |
||
922 | b->Width = sqrt(pow(mx - b->Xpos,2)+pow(my - b->Ypos,2)); |
||
923 | b->Height = 0; |
||
924 | UpdateClip(b); |
||
925 | RepaintTextRegion(b, alt); |
||
926 | emit ItemPos(b->Xpos, b->Ypos); |
||
927 | emit ItemGeom(b->Width, b->Height); |
||
928 | emit SetAngle(b->Rot); |
||
929 | } |
||
930 | else |
||
931 | { |
||
932 | if (b->Rot != 0) |
||
933 | { |
||
934 | FPoint npv = FPoint(newX.x(), newX.y()); |
||
935 | QWMatrix ma3; |
||
936 | ma3.translate(b->Xpos, b->Ypos); |
||
937 | ma3.rotate(b->Rot); |
||
80 | Franz | 938 | double mxc3 = b->Xpos - (ma3.m11() * npv.x() + ma3.m21() * npv.y() + ma3.dx()); |
939 | double myc3 = b->Ypos - (ma3.m22() * npv.y() + ma3.m12() * npv.x() + ma3.dy()); |
||
3 | paul | 940 | SizeItem(b->Width - newY.x(), b->Height - newY.y(), ite); |
941 | MoveItem(-mxc3, -myc3, b); |
||
942 | } |
||
943 | else |
||
944 | { |
||
945 | SizeItem(b->Width - newY.x(), b->Height - newY.y(), ite); |
||
946 | MoveItem(newX.x(), newX.y(), b); |
||
947 | } |
||
948 | } |
||
949 | return true; |
||
950 | } |
||
951 | |||
952 | void Page::UpdateClip(PageItem* b) |
||
953 | { |
||
954 | int ph = static_cast<int>(QMAX(1.0, b->Pwidth / 2.0)); |
||
955 | switch (b->PType) |
||
956 | { |
||
957 | case 5: |
||
958 | b->Clip.setPoints(4, -ph,-ph, static_cast<int>(b->Width+ph),-ph, static_cast<int>(b->Width+ph),static_cast<int>(b->Height+ph), -ph,static_cast<int>(b->Height+ph)); |
||
959 | break; |
||
960 | default: |
||
961 | if (!b->ClipEdited) |
||
962 | { |
||
963 | switch (b->FrameType) |
||
964 | { |
||
965 | case 0: |
||
966 | SetRectFrame(b); |
||
967 | break; |
||
968 | case 1: |
||
969 | SetOvalFrame(b); |
||
970 | break; |
||
971 | case 2: |
||
972 | SetFrameRound(b); |
||
973 | break; |
||
974 | } |
||
975 | b->OldB2 = b->Width; |
||
976 | b->OldH2 = b->Height; |
||
977 | } |
||
978 | else |
||
80 | Franz | 979 | { |
3 | paul | 980 | if ((b->OldB2 == 0) || (b->OldH2 == 0)) |
981 | return; |
||
80 | Franz | 982 | double scx = b->Width / b->OldB2; |
983 | double scy = b->Height / b->OldH2; |
||
3 | paul | 984 | QWMatrix ma; |
985 | ma.scale(scx, scy); |
||
986 | b->PoLine.map(ma); |
||
987 | if (b->PType == 8) |
||
988 | UpdatePolyClip(b); |
||
989 | else |
||
990 | b->Clip = FlattenPath(b->PoLine, b->Segments); |
||
991 | b->OldB2 = b->Width; |
||
992 | b->OldH2 = b->Height; |
||
993 | } |
||
994 | break; |
||
995 | } |
||
996 | } |
||
997 | |||
80 | Franz | 998 | bool Page::SizeItem(double newX, double newY, int ite, bool fromMP, bool DoUpdateClip) |
3 | paul | 999 | { |
1000 | QRegion alt, neu; |
||
1001 | QPainter p; |
||
1002 | PageItem *b = Items.at(ite); |
||
1003 | if (b->Locked) |
||
1004 | return false; |
||
1005 | if (b->PType != 5) |
||
68 | Franz | 1006 | { |
1007 | newX = QMAX(newX, 1); |
||
1008 | newY = QMAX(newY, 1); |
||
1009 | } |
||
3 | paul | 1010 | int ph = static_cast<int>(QMAX(1.0, b->Pwidth / 2.0)); |
1011 | p.begin(this); |
||
1012 | Transform(b, &p); |
||
1013 | alt = QRegion(p.xForm(QRect(0, 0, static_cast<int>(b->Width), static_cast<int>(b->Height)))); |
||
1014 | p.end(); |
||
1015 | b->Width = newX; |
||
1016 | b->Height = newY; |
||
1017 | b->RadRect = QMIN(b->RadRect, QMIN(b->Width,b->Height)/2); |
||
1018 | if ((b->PType == 2) && (!b->Sizing) && (!doku->EditClip)) |
||
1019 | { |
||
1020 | AdjustPictScale(b); |
||
1021 | AdjustPreview(b); |
||
1022 | } |
||
1023 | if (b->PType == 5) |
||
1024 | { |
||
1025 | if (!fromMP) |
||
1026 | { |
||
1027 | b->Rot = atan2(b->Height,b->Width)*(180.0/3.1415927); |
||
1028 | b->Width = sqrt(pow(b->Width,2)+pow(b->Height,2)); |
||
1029 | b->Height = 0; |
||
1030 | emit SetAngle(b->Rot); |
||
1031 | } |
||
1032 | b->Clip.setPoints(4, -ph,-ph, static_cast<int>(b->Width+ph),-ph, static_cast<int>(b->Width+ph),static_cast<int>(b->Height+ph), -ph,static_cast<int>(b->Height+ph)); |
||
1033 | } |
||
1034 | if (b->Sizing) |
||
1035 | { |
||
1036 | b->FrameOnly = true; |
||
1037 | b->Tinput = true; |
||
1038 | if ((HowTo == 1) && (b->PType != 5)) |
||
1039 | b->paintObj(); |
||
1040 | emit ItemGeom(b->Width, b->Height); |
||
1041 | emit ItemRadius(b->RadRect); |
||
1042 | return true; |
||
1043 | } |
||
1044 | if (DoUpdateClip) |
||
1045 | { |
||
1046 | if (fromMP) |
||
1047 | { |
||
1048 | if (b->flippedH % 2 != 0) |
||
1049 | MoveItemI(-(b->Width - b->OldB2)/b->LocalScX, 0, b->ItemNr); |
||
1050 | if (b->flippedV % 2 != 0) |
||
1051 | MoveItemI(0, -(b->Height - b->OldH2)/b->LocalScY, b->ItemNr); |
||
1052 | } |
||
1053 | else |
||
1054 | { |
||
1055 | if (b->flippedH % 2 == 0) |
||
1056 | MoveItemI((b->Width - b->OldB2)/b->LocalScX, 0, b->ItemNr); |
||
1057 | if (b->flippedV % 2 == 0) |
||
1058 | MoveItemI(0, (b->Height - b->OldH2)/b->LocalScY, b->ItemNr); |
||
1059 | } |
||
1060 | UpdateClip(b); |
||
1061 | } |
||
1062 | RepaintTextRegion(b, alt); |
||
1063 | if (!fromMP) |
||
1064 | { |
||
1065 | if (GroupSel) |
||
1066 | { |
||
80 | Franz | 1067 | double gx, gy, gh, gw; |
3 | paul | 1068 | setGroupRect(); |
1069 | getGroupRect(&gx, &gy, &gw, &gh); |
||
1070 | emit ItemGeom(gw, gh); |
||
1071 | } |
||
1072 | else |
||
1073 | emit ItemGeom(b->Width, b->Height); |
||
1074 | } |
||
1075 | emit ItemRadius(b->RadRect); |
||
80 | Franz | 1076 | return true; |
3 | paul | 1077 | } |
1078 | |||
80 | Franz | 1079 | void Page::MoveItemI(double newX, double newY, int ite) |
3 | paul | 1080 | { |
1081 | QPainter p; |
||
1082 | PageItem *b = Items.at(ite); |
||
1083 | if (b->Locked) |
||
1084 | return; |
||
1085 | if (!b->ScaleType) |
||
1086 | return; |
||
1087 | p.begin(this); |
||
1088 | Transform(b, &p); |
||
1089 | TransformM(b, &p); |
||
1090 | QRegion alt = QRegion(p.xForm(QRect(0, 0, static_cast<int>(b->Width), static_cast<int>(b->Height)))); |
||
1091 | p.end(); |
||
1092 | if (b->flippedH % 2 != 0) |
||
1093 | b->LocalX -= newX; |
||
1094 | else |
||
1095 | b->LocalX += newX; |
||
1096 | if (b->flippedV % 2 != 0) |
||
1097 | b->LocalY -= newY; |
||
1098 | else |
||
1099 | b->LocalY += newY; |
||
1100 | repaint(alt); |
||
80 | Franz | 1101 | emit SetLocalValues(b->LocalScX, b->LocalScY, b->LocalX, b->LocalY); |
3 | paul | 1102 | } |
1103 | |||
80 | Franz | 1104 | bool Page::MoveItem(double newX, double newY, PageItem* b, bool fromMP) |
3 | paul | 1105 | { |
1106 | QRegion alt; |
||
1107 | bool retw = false; |
||
1108 | if (b->Locked) |
||
1109 | return false; |
||
80 | Franz | 1110 | double oldx = b->Xpos; |
1111 | double oldy = b->Ypos; |
||
3 | paul | 1112 | if (!Imoved) |
1113 | { |
||
1114 | QPainter p; |
||
1115 | p.begin(this); |
||
1116 | Transform(b, &p); |
||
1117 | alt = QRegion(p.xForm(QRect(0, 0, static_cast<int>(b->Width), static_cast<int>(b->Height)))); |
||
1118 | p.end(); |
||
1119 | } |
||
1120 | b->Xpos += newX; |
||
1121 | b->Ypos += newY; |
||
1122 | if ((doku->useRaster) && (!Imoved)) |
||
1123 | { |
||
1124 | b->Xpos = qRound(b->Xpos / doku->minorGrid) * doku->minorGrid; |
||
1125 | b->Ypos = qRound(b->Ypos / doku->minorGrid) * doku->minorGrid; |
||
1126 | } |
||
1127 | if ((doku->SnapGuides) && (!Imoved) && (doku->AppMode == 1) && (!doku->EditClip)) |
||
1128 | SnapToGuides(b); |
||
1129 | if ((b->Xpos != oldx) || (b->Ypos != oldy)) |
||
1130 | retw = true; |
||
1131 | if ((!Imoved) && (!b->Sizing)) |
||
1132 | RepaintTextRegion(b, alt); |
||
1133 | if (!fromMP) |
||
1134 | { |
||
1135 | if (GroupSel) |
||
1136 | { |
||
80 | Franz | 1137 | double gx, gy, gh, gw; |
3 | paul | 1138 | setGroupRect(); |
1139 | getGroupRect(&gx, &gy, &gw, &gh); |
||
1140 | emit ItemPos(gx, gy); |
||
1141 | } |
||
1142 | else |
||
1143 | emit ItemPos(b->Xpos, b->Ypos); |
||
1144 | } |
||
91 | Franz | 1145 | if (!doku->loading) |
1146 | emit UpdtObj(PageNr, b->ItemNr); |
||
80 | Franz | 1147 | return retw; |
3 | paul | 1148 | } |
1149 | |||
80 | Franz | 1150 | void Page::RotateItem(double win, int ite) |
3 | paul | 1151 | { |
1152 | QRegion alt, neu; |
||
1153 | QPainter p; |
||
1154 | PageItem *b; |
||
1155 | FPoint n; |
||
1156 | b = Items.at(ite); |
||
1157 | if (b->Locked) |
||
1158 | return; |
||
1159 | p.begin(this); |
||
1160 | Transform(b, &p); |
||
1161 | alt = QRegion(p.xForm(QRect(0, 0, static_cast<int>(b->Width), static_cast<int>(b->Height)))); |
||
1162 | p.end(); |
||
1163 | if ((doku->RotMode != 0) && (b->PType != 5)) |
||
1164 | { |
||
1165 | QWMatrix ma; |
||
1166 | ma.translate(b->Xpos, b->Ypos); |
||
1167 | ma.scale(1, 1); |
||
1168 | ma.rotate(b->Rot); |
||
80 | Franz | 1169 | double ro = win-b->Rot; |
3 | paul | 1170 | b->Rot = win; |
1171 | switch (doku->RotMode) |
||
1172 | { |
||
1173 | case 2: |
||
1174 | ma.translate(b->Width/2, b->Height/2); |
||
1175 | n = FPoint(-b->Width/2, -b->Height/2); |
||
1176 | break; |
||
1177 | case 4: |
||
1178 | ma.translate(b->Width, b->Height); |
||
1179 | n = FPoint(-b->Width, -b->Height); |
||
1180 | break; |
||
1181 | case 3: |
||
1182 | ma.translate(0, b->Height); |
||
1183 | n = FPoint(0, -b->Height); |
||
1184 | break; |
||
1185 | case 1: |
||
1186 | ma.translate(b->Width, 0); |
||
1187 | n = FPoint(-b->Width, 0); |
||
1188 | break; |
||
1189 | } |
||
1190 | ma.rotate(ro); |
||
80 | Franz | 1191 | double x = ma.m11() * n.x() + ma.m21() * n.y() + ma.dx(); |
1192 | double y = ma.m22() * n.y() + ma.m12() * n.x() + ma.dy(); |
||
3 | paul | 1193 | MoveItem(x-b->Xpos, y-b->Ypos, b); |
1194 | } |
||
1195 | else |
||
1196 | b->Rot = win; |
||
1197 | RepaintTextRegion(b, alt); |
||
1198 | emit SetAngle(b->Rot); |
||
1199 | } |
||
1200 | |||
1201 | void Page::SnapToGuides(PageItem* b) |
||
1202 | { |
||
1203 | if (YGuides.count() != 0) |
||
1204 | { |
||
1205 | for (uint yg = 0; yg < YGuides.count(); ++yg) |
||
1206 | { |
||
1207 | if ((YGuides[yg] < (b->Ypos+doku->GuideRad)) && (YGuides[yg] > (b->Ypos-doku->GuideRad))) |
||
1208 | { |
||
1209 | b->Ypos = YGuides[yg]; |
||
1210 | break; |
||
1211 | } |
||
1212 | if (b->PType == 5) |
||
1213 | { |
||
1214 | QWMatrix ma; |
||
1215 | ma.translate(b->Xpos, b->Ypos); |
||
1216 | ma.rotate(b->Rot); |
||
80 | Franz | 1217 | double my = ma.m22() * b->Height + ma.m12() * b->Width + ma.dy(); |
3 | paul | 1218 | if ((YGuides[yg] < (my+doku->GuideRad)) && (YGuides[yg] > (my-doku->GuideRad))) |
1219 | { |
||
1220 | b->Ypos = b->Ypos + YGuides[yg] - my; |
||
1221 | break; |
||
1222 | } |
||
1223 | } |
||
1224 | else |
||
1225 | { |
||
1226 | if ((YGuides[yg] < (b->Ypos+b->Height+doku->GuideRad)) && (YGuides[yg] > ((b->Ypos+b->Height)-doku->GuideRad))) |
||
1227 | { |
||
1228 | b->Ypos = YGuides[yg]-b->Height; |
||
1229 | break; |
||
1230 | } |
||
1231 | } |
||
1232 | } |
||
1233 | } |
||
1234 | if (XGuides.count() != 0) |
||
1235 | { |
||
1236 | for (uint xg = 0; xg < XGuides.count(); ++xg) |
||
1237 | { |
||
1238 | if ((XGuides[xg] < (b->Xpos+doku->GuideRad)) && (XGuides[xg] > (b->Xpos-doku->GuideRad))) |
||
1239 | { |
||
1240 | b->Xpos = XGuides[xg]; |
||
1241 | break; |
||
1242 | } |
||
1243 | if (b->PType == 5) |
||
1244 | { |
||
1245 | QWMatrix ma; |
||
1246 | ma.translate(b->Xpos, b->Ypos); |
||
1247 | ma.rotate(b->Rot); |
||
80 | Franz | 1248 | double mx = ma.m11() * b->Width + ma.m21() * b->Height + ma.dx(); |
3 | paul | 1249 | if ((XGuides[xg] < (mx+doku->GuideRad)) && (XGuides[xg] > (mx-doku->GuideRad))) |
1250 | { |
||
1251 | b->Xpos = b->Xpos + XGuides[xg] - mx; |
||
1252 | break; |
||
1253 | } |
||
1254 | } |
||
1255 | else |
||
1256 | { |
||
1257 | if ((XGuides[xg] < (b->Xpos+b->Width+doku->GuideRad)) && (XGuides[xg] > ((b->Xpos+b->Width)-doku->GuideRad))) |
||
1258 | { |
||
1259 | b->Xpos = XGuides[xg]-b->Width; |
||
1260 | break; |
||
1261 | } |
||
1262 | } |
||
1263 | } |
||
1264 | } |
||
1265 | } |
||
1266 | |||
1267 | void Page::sentToScrap() |
||
1268 | { |
||
1269 | ScriXmlDoc *ss = new ScriXmlDoc(); |
||
1270 | emit ToScrap(ss->WriteElem(&SelItem, doku)); |
||
1271 | delete ss; |
||
1272 | } |
||
1273 | |||
1274 | void Page::sentToLayer(int id) |
||
80 | Franz | 1275 | { |
3 | paul | 1276 | int d = pmen3->indexOf(id); |
1277 | PageItem *b = SelItem.at(0); |
||
1278 | b->LayerNr = d; |
||
1279 | Deselect(true); |
||
1280 | update(); |
||
1281 | } |
||
1282 | |||
1283 | bool Page::PointOnLine(QPoint Start, QPoint Ende, QRect MArea) |
||
1284 | { |
||
1285 | QPoint an, en; |
||
1286 | if (Start.x() == Ende.x()) |
||
1287 | { |
||
1288 | if (Start.y() > Ende.y()) |
||
1289 | { |
||
1290 | an = Ende; |
||
1291 | en = Start; |
||
1292 | } |
||
1293 | else |
||
1294 | { |
||
1295 | en = Ende; |
||
1296 | an = Start; |
||
1297 | } |
||
1298 | for (int a=an.y(); a<en.y(); ++a) |
||
1299 | { |
||
1300 | if (MArea.contains(QPoint(an.x(), a))) |
||
1301 | return true; |
||
1302 | } |
||
1303 | } |
||
1304 | if (Start.y() == Ende.y()) |
||
1305 | { |
||
1306 | if (Start.x() > Ende.x()) |
||
1307 | { |
||
1308 | an = Ende; |
||
1309 | en = Start; |
||
1310 | } |
||
1311 | else |
||
1312 | { |
||
1313 | en = Ende; |
||
1314 | an = Start; |
||
1315 | } |
||
1316 | for (int a=an.x(); a<en.x(); ++a) |
||
1317 | { |
||
1318 | if (MArea.contains(QPoint(a, an.y()))) |
||
1319 | return true; |
||
1320 | } |
||
1321 | } |
||
1322 | if (Start.x() > Ende.x()) |
||
1323 | { |
||
1324 | an = Ende; |
||
1325 | en = Start; |
||
1326 | } |
||
1327 | else |
||
1328 | { |
||
1329 | en = Ende; |
||
1330 | an = Start; |
||
1331 | } |
||
80 | Franz | 1332 | double stg = (en.y() - an.y()) / static_cast<double>((en.x() - an.x())); |
3 | paul | 1333 | for (int a = an.x(); a < en.x(); ++a) |
1334 | { |
||
1335 | if (MArea.contains(QPoint(a, an.y()+qRound((a-an.x())*stg)))) |
||
1336 | return true; |
||
1337 | } |
||
1338 | return false; |
||
1339 | } |
||
1340 | |||
1341 | void Page::MoveRotated(PageItem *b, FPoint npv) |
||
1342 | { |
||
1343 | QWMatrix ma; |
||
1344 | ma.translate(b->Xpos, b->Ypos); |
||
1345 | ma.rotate(b->Rot); |
||
80 | Franz | 1346 | double mxc = b->Xpos - (ma.m11() * npv.x() + ma.m21() * npv.y() + ma.dx()); |
1347 | double myc = b->Ypos - (ma.m22() * npv.y() + ma.m12() * npv.x() + ma.dy()); |
||
3 | paul | 1348 | MoveItem(-mxc, -myc, b); |
1349 | } |
||
1350 | |||
1351 | void Page::AdjustItemSize(PageItem *b) |
||
1352 | { |
||
1353 | FPointArray Clip; |
||
1354 | Clip = b->PoLine; |
||
1355 | FPoint tp2 = GetMinClipF(Clip); |
||
1356 | SizeItem(b->Width - tp2.x(), b->Height - tp2.y(), b->ItemNr, false, false); |
||
1357 | Clip.translate(-tp2.x(), -tp2.y()); |
||
1358 | if (b->Rot != 0) |
||
1359 | { |
||
1360 | FPoint npv = FPoint(tp2.x(), tp2.y()); |
||
1361 | MoveRotated(b, npv); |
||
1362 | } |
||
1363 | else |
||
1364 | MoveItem(tp2.x(), tp2.y(), b); |
||
1365 | if (b->flippedH % 2 == 0) |
||
1366 | MoveItemI(-tp2.x()/b->LocalScX, 0, b->ItemNr); |
||
1367 | if (b->flippedV % 2 == 0) |
||
1368 | MoveItemI(0, -tp2.y()/b->LocalScY, b->ItemNr); |
||
1369 | FPoint tp = GetMaxClipF(Clip); |
||
1370 | if (b->flippedH % 2 != 0) |
||
1371 | MoveItemI((b->Width - tp.x())/b->LocalScX, 0, b->ItemNr); |
||
1372 | if (b->flippedV % 2 != 0) |
||
1373 | MoveItemI(0, (b->Height - tp.y())/b->LocalScY, b->ItemNr); |
||
1374 | SizeItem(tp.x(), tp.y(), b->ItemNr, false, false); |
||
1375 | b->ClipEdited = true; |
||
1376 | b->PoLine = Clip.copy(); |
||
1377 | if (b->PType == 7) |
||
1378 | SetPolyClip(b, qRound(QMAX(b->Pwidth / 2, 1)), qRound(QMAX(b->Pwidth / 2, 1))); |
||
1379 | else |
||
1380 | b->Clip = FlattenPath(b->PoLine, b->Segments); |
||
1381 | } |
||
1382 | |||
1383 | void Page::MirrorPolyH() |
||
1384 | { |
||
1385 | PageItem *b = SelItem.at(0); |
||
1386 | QWMatrix ma; |
||
1387 | ma.scale(-1, 1); |
||
1388 | b->PoLine.map(ma); |
||
1389 | b->PoLine.translate(b->Width, 0); |
||
1390 | if (b->PType == 8) |
||
1391 | UpdatePolyClip(b); |
||
1392 | else |
||
1393 | b->Clip = FlattenPath(b->PoLine, b->Segments); |
||
1394 | RefreshItem(b); |
||
1395 | MarkClip(b); |
||
1396 | } |
||
1397 | |||
1398 | void Page::MirrorPolyV() |
||
1399 | { |
||
1400 | PageItem *b = SelItem.at(0); |
||
1401 | QWMatrix ma; |
||
1402 | ma.scale(1, -1); |
||
1403 | b->PoLine.map(ma); |
||
1404 | b->PoLine.translate(0, b->Height); |
||
1405 | if (b->PType == 8) |
||
1406 | UpdatePolyClip(b); |
||
1407 | else |
||
1408 | b->Clip = FlattenPath(b->PoLine, b->Segments); |
||
1409 | RefreshItem(b); |
||
1410 | MarkClip(b); |
||
1411 | } |
||
1412 | |||
13 | Franz | 1413 | void Page::ShearPolyHR() |
1414 | { |
||
1415 | PageItem *b = SelItem.at(0); |
||
1416 | QWMatrix ma; |
||
1417 | ma.shear(-0.017455, 0); |
||
1418 | b->PoLine.map(ma); |
||
1419 | AdjustItemSize(b); |
||
1420 | if (b->PType == 8) |
||
1421 | UpdatePolyClip(b); |
||
1422 | RefreshItem(b); |
||
1423 | MarkClip(b); |
||
38 | Franz | 1424 | b->FrameType = 3; |
13 | Franz | 1425 | } |
1426 | |||
1427 | void Page::ShearPolyHL() |
||
1428 | { |
||
1429 | PageItem *b = SelItem.at(0); |
||
1430 | QWMatrix ma; |
||
1431 | ma.shear(0.017455, 0); |
||
1432 | b->PoLine.map(ma); |
||
1433 | AdjustItemSize(b); |
||
1434 | if (b->PType == 8) |
||
1435 | UpdatePolyClip(b); |
||
1436 | RefreshItem(b); |
||
1437 | MarkClip(b); |
||
38 | Franz | 1438 | b->FrameType = 3; |
13 | Franz | 1439 | } |
1440 | |||
1441 | void Page::ShearPolyVU() |
||
1442 | { |
||
1443 | PageItem *b = SelItem.at(0); |
||
1444 | QWMatrix ma; |
||
1445 | ma.shear(0, -0.017455); |
||
1446 | b->PoLine.map(ma); |
||
1447 | AdjustItemSize(b); |
||
1448 | if (b->PType == 8) |
||
1449 | UpdatePolyClip(b); |
||
1450 | RefreshItem(b); |
||
1451 | MarkClip(b); |
||
38 | Franz | 1452 | b->FrameType = 3; |
13 | Franz | 1453 | } |
1454 | |||
1455 | void Page::ShearPolyVD() |
||
1456 | { |
||
1457 | PageItem *b = SelItem.at(0); |
||
1458 | QWMatrix ma; |
||
1459 | ma.shear(0, 0.017455); |
||
1460 | b->PoLine.map(ma); |
||
1461 | AdjustItemSize(b); |
||
1462 | if (b->PType == 8) |
||
1463 | UpdatePolyClip(b); |
||
1464 | RefreshItem(b); |
||
1465 | MarkClip(b); |
||
38 | Franz | 1466 | b->FrameType = 3; |
13 | Franz | 1467 | } |
1468 | |||
3 | paul | 1469 | void Page::Reset1Control() |
1470 | { |
||
1471 | PageItem *b = SelItem.at(0); |
||
1472 | FPoint np = b->PoLine.point(ClRe-1); |
||
1473 | b->OldB2 = b->Width; |
||
1474 | b->OldH2 = b->Height; |
||
1475 | b->PoLine.setPoint(ClRe, np); |
||
1476 | AdjustItemSize(b); |
||
1477 | MarkClip(b); |
||
1478 | } |
||
1479 | |||
1480 | void Page::ResetControl() |
||
1481 | { |
||
1482 | PageItem *b = SelItem.at(0); |
||
1483 | FPoint np = b->PoLine.point(ClRe); |
||
1484 | b->OldB2 = b->Width; |
||
1485 | b->OldH2 = b->Height; |
||
1486 | if ((ClRe == 0) || (ClRe == static_cast<int>(b->PoLine.size()-2))) |
||
1487 | b->PoLine.setPoint(ClRe+1, np); |
||
1488 | else |
||
1489 | { |
||
1490 | b->PoLine.setPoint(ClRe+1, np); |
||
1491 | if (ClRe % 4 != 0) |
||
1492 | b->PoLine.setPoint(ClRe+3, np); |
||
1493 | else |
||
1494 | b->PoLine.setPoint(ClRe-1, np); |
||
1495 | } |
||
1496 | AdjustItemSize(b); |
||
1497 | MarkClip(b); |
||
1498 | } |
||
1499 | |||
1500 | void Page::MoveClipPoint(PageItem *b, FPoint ip) |
||
1501 | { |
||
1502 | FPointArray Clip; |
||
1503 | Clip = b->PoLine; |
||
38 | Franz | 1504 | b->FrameType = 3; |
3 | paul | 1505 | if ((EdPoints) && (ClRe % 2 != 0)) |
1506 | return; |
||
1507 | if ((!EdPoints) && (ClRe % 2 == 0)) |
||
1508 | return; |
||
1509 | uint EndInd = Clip.size(); |
||
1510 | uint StartInd = 0; |
||
1511 | for (uint n = ClRe; n < Clip.size(); n++) |
||
1512 | { |
||
1513 | if (Clip.point(n).x() > 900000) |
||
1514 | { |
||
1515 | EndInd = n; |
||
1516 | break; |
||
1517 | } |
||
1518 | } |
||
1519 | if (ClRe > 0) |
||
1520 | { |
||
1521 | for (uint n2 = ClRe; n2 > 0; n2--) |
||
1522 | { |
||
1523 | if (n2 == 0) |
||
1524 | break; |
||
1525 | if (Clip.point(n2).x() > 900000) |
||
1526 | { |
||
1527 | StartInd = n2 + 1; |
||
1528 | break; |
||
1529 | } |
||
1530 | } |
||
1531 | } |
||
1532 | // FPoint np = ApplyGridF(ip); |
||
1533 | FPoint np = ip; |
||
1534 | if (ClRe != -1) |
||
1535 | { |
||
1536 | if (np.x() < 0) |
||
1537 | { |
||
1538 | SizeItem(b->Width - np.x(), b->Height, b->ItemNr, false, false); |
||
1539 | if (b->Rot != 0) |
||
1540 | { |
||
1541 | FPoint npv = FPoint(np.x(), 0); |
||
1542 | MoveRotated(b, npv); |
||
1543 | } |
||
1544 | else |
||
1545 | MoveItem(np.x(), 0, b); |
||
1546 | Clip.translate(-np.x(), 0); |
||
1547 | if (b->flippedH % 2 == 0) |
||
1548 | MoveItemI(-np.x()/b->LocalScX, 0, b->ItemNr); |
||
1549 | np.setX(0); |
||
1550 | } |
||
1551 | if (np.y() < 0) |
||
1552 | { |
||
1553 | SizeItem(b->Width, b->Height - np.y(), b->ItemNr, false, false); |
||
1554 | if (b->Rot != 0) |
||
1555 | { |
||
1556 | FPoint npv = FPoint(0, np.y()); |
||
1557 | MoveRotated(b, npv); |
||
1558 | } |
||
1559 | else |
||
1560 | MoveItem(0, np.y(), b); |
||
1561 | Clip.translate(0, -np.y()); |
||
1562 | if (b->flippedV % 2 == 0) |
||
1563 | MoveItemI(0, -np.y()/b->LocalScY, b->ItemNr); |
||
1564 | np.setY(0); |
||
1565 | } |
||
1566 | emit ClipPo(np.x(), np.y()); |
||
1567 | if ((ClRe+1 < static_cast<int>(EndInd)) && (ClRe % 2 == 0)) |
||
1568 | { |
||
1569 | FPoint ap = Clip.point(ClRe); |
||
1570 | FPoint ap2 = Clip.point(ClRe+1); |
||
1571 | ap2.setX(ap2.x() - (ap.x() - np.x())); |
||
1572 | ap2.setY(ap2.y() - (ap.y() - np.y())); |
||
1573 | Clip.setPoint(ClRe+1, ap2); |
||
1574 | } |
||
1575 | Clip.setPoint(ClRe, np); |
||
1576 | if (((ClRe % 4 != 0) && (ClRe % 2 == 0)) && (ClRe+3 < static_cast<int>(EndInd)) && (ClRe != static_cast<int>(StartInd))) |
||
1577 | { |
||
1578 | FPoint ap = Clip.point(ClRe+2); |
||
1579 | FPoint ap2 = Clip.point(ClRe+3); |
||
1580 | ap2.setX(ap2.x() - (ap.x() - np.x())); |
||
1581 | ap2.setY(ap2.y() - (ap.y() - np.y())); |
||
1582 | Clip.setPoint(ClRe+3, ap2); |
||
1583 | Clip.setPoint(ClRe+2, np); |
||
1584 | } |
||
1585 | if ((ClRe % 4 == 0) && (ClRe+3 < static_cast<int>(EndInd)) && (ClRe != static_cast<int>(StartInd))) |
||
1586 | { |
||
1587 | FPoint ap = Clip.point(ClRe-2); |
||
1588 | FPoint ap2 = Clip.point(ClRe-1); |
||
1589 | ap2.setX(ap2.x() - (ap.x() - np.x())); |
||
1590 | ap2.setY(ap2.y() - (ap.y() - np.y())); |
||
1591 | Clip.setPoint(ClRe-1, ap2); |
||
1592 | Clip.setPoint(ClRe-2, np); |
||
1593 | } |
||
1594 | if (((ClRe == static_cast<int>(StartInd)) || (ClRe == static_cast<int>(EndInd-2))) && ((b->PType == 6) || (b->PType == 4) || (b->PType == 2))) |
||
1595 | { |
||
1596 | if (ClRe == static_cast<int>(StartInd)) |
||
1597 | { |
||
1598 | FPoint ap = Clip.point(EndInd-2); |
||
1599 | FPoint ap2 = Clip.point(EndInd-1); |
||
1600 | ap2.setX(ap2.x() - (ap.x() - np.x())); |
||
1601 | ap2.setY(ap2.y() - (ap.y() - np.y())); |
||
1602 | Clip.setPoint(EndInd-2, Clip.point(StartInd)); |
||
1603 | Clip.setPoint(EndInd-1, ap2); |
||
1604 | } |
||
1605 | else |
||
1606 | { |
||
1607 | FPoint ap = Clip.point(StartInd); |
||
1608 | FPoint ap2 = Clip.point(StartInd + 1); |
||
1609 | ap2.setX(ap2.x() - (ap.x() - np.x())); |
||
1610 | ap2.setY(ap2.y() - (ap.y() - np.y())); |
||
1611 | Clip.setPoint(StartInd, Clip.point(EndInd-2)); |
||
1612 | Clip.setPoint(StartInd + 1, ap2); |
||
1613 | } |
||
1614 | } |
||
1615 | if (((ClRe == static_cast<int>(StartInd+1)) || (ClRe == static_cast<int>(EndInd-1))) && ((b->PType == 6) || (b->PType == 4) || (b->PType == 2)) && (MoveSym)) |
||
1616 | { |
||
1617 | uint kon = 0; |
||
1618 | if (ClRe == static_cast<int>(StartInd+1)) |
||
1619 | kon = EndInd-1; |
||
1620 | else |
||
1621 | kon = StartInd + 1; |
||
1622 | FPoint lxy = Clip.point(ClRe-1); |
||
1623 | FPoint lk = Clip.point(ClRe); |
||
80 | Franz | 1624 | double dx = lxy.x() - lk.x(); |
1625 | double dy = lxy.y() - lk.y(); |
||
3 | paul | 1626 | lk.setX(lk.x() + dx*2); |
1627 | lk.setY(lk.y() + dy*2); |
||
1628 | Clip.setPoint(kon, lk); |
||
1629 | } |
||
1630 | if ((ClRe % 2 != 0) && (MoveSym) && (ClRe != static_cast<int>(StartInd + 1)) && (ClRe != static_cast<int>(EndInd-1))) |
||
1631 | { |
||
1632 | uint kon = 0; |
||
1633 | if ((ClRe+1) % 4 == 0) |
||
1634 | kon = ClRe + 2; |
||
1635 | else |
||
1636 | kon = ClRe - 2; |
||
1637 | FPoint lxy = Clip.point(ClRe-1); |
||
1638 | FPoint lk = Clip.point(ClRe); |
||
80 | Franz | 1639 | double dx = lxy.x() - lk.x(); |
1640 | double dy = lxy.y() - lk.y(); |
||
3 | paul | 1641 | lk.setX(lk.x() + dx*2); |
1642 | lk.setY(lk.y() + dy*2); |
||
1643 | Clip.setPoint(kon, lk); |
||
1644 | } |
||
1645 | b->PoLine = Clip.copy(); |
||
1646 | b->Clip = FlattenPath(b->PoLine, b->Segments); |
||
1647 | AdjustItemSize(b); |
||
1648 | // emit DocChanged(); |
||
1649 | } |
||
1650 | } |
||
1651 | void Page::ConvertClip(PageItem *b) |
||
1652 | { |
||
1653 | if (b->Clip.count() != 0) |
||
1654 | { |
||
1655 | FPoint np = FPoint(b->Clip.point(0)); |
||
1656 | b->PoLine.resize(2); |
||
1657 | b->PoLine.setPoint(0, np); |
||
1658 | b->PoLine.setPoint(1, np); |
||
1659 | for (uint a = 1; a < b->Clip.size(); ++a) |
||
1660 | { |
||
1661 | np = FPoint(b->Clip.point(a)); |
||
1662 | b->PoLine.putPoints(b->PoLine.size(), 4, np.x(), np.y(), np.x(), np.y(), np.x(), np.y(), np.x(), np.y()); |
||
1663 | } |
||
1664 | np = FPoint(b->Clip.point(0)); |
||
1665 | b->PoLine.putPoints(b->PoLine.size(), 2, np.x(), np.y(), np.x(), np.y()); |
||
1666 | b->Clip = FlattenPath(b->PoLine, b->Segments); |
||
1667 | } |
||
1668 | else |
||
1669 | SetRectFrame(b); |
||
1670 | } |
||
1671 | |||
17 | Franz | 1672 | void Page::mouseDoubleClickEvent(QMouseEvent *m) |
3 | paul | 1673 | { |
17 | Franz | 1674 | m->accept(); |
1675 | Mpressed = false; |
||
19 | Franz | 1676 | if ((GroupSel) || (doku->AppMode != 1) || (doku->EditClip)) |
1677 | { |
||
1678 | mousePressEvent(m); |
||
3 | paul | 1679 | return; |
19 | Franz | 1680 | } |
3 | paul | 1681 | PageItem *b = 0; |
1682 | if (GetItem(&b)) |
||
1683 | { |
||
1684 | if ((b->PType == 6) || (b->PType == 7) || (b->PType == 2) || (b->PType == 8)) |
||
1685 | { |
||
19 | Franz | 1686 | if ((b->Locked) || (!b->ScaleType)) |
1687 | { |
||
1688 | mousePressEvent(m); |
||
3 | paul | 1689 | return; |
19 | Franz | 1690 | } |
3 | paul | 1691 | emit Amode(7); |
1692 | } |
||
1693 | else |
||
1694 | { |
||
1695 | if (b->PType == 4) |
||
1696 | { |
||
1697 | if (b->isAnnotation) |
||
1698 | emit AnnotProps(); |
||
1699 | else |
||
1700 | emit Amode(7); |
||
1701 | } |
||
1702 | } |
||
1703 | } |
||
1704 | } |
||
1705 | |||
80 | Franz | 1706 | FPoint Page::transformPointI(FPoint in, double dx, double dy, double rot, double sx, double sy) |
3 | paul | 1707 | { |
1708 | QWMatrix ma; |
||
1709 | ma.translate(dx, dy); |
||
1710 | ma.scale(sx, sy); |
||
1711 | ma.rotate(rot); |
||
1712 | ma = ma.invert(); |
||
80 | Franz | 1713 | double x = ma.m11() * in.x() + ma.m21() * in.y() + ma.dx(); |
1714 | double y = ma.m22() * in.y() + ma.m12() * in.x() + ma.dy(); |
||
3 | paul | 1715 | return FPoint(x, y); |
1716 | } |
||
1717 | |||
80 | Franz | 1718 | FPoint Page::transformPoint(FPoint in, double dx, double dy, double rot, double sx, double sy) |
3 | paul | 1719 | { |
1720 | QWMatrix ma; |
||
1721 | ma.translate(dx, dy); |
||
1722 | ma.scale(sx, sy); |
||
1723 | ma.rotate(rot); |
||
80 | Franz | 1724 | double x = ma.m11() * in.x() + ma.m21() * in.y() + ma.dx(); |
1725 | double y = ma.m22() * in.y() + ma.m12() * in.x() + ma.dy(); |
||
3 | paul | 1726 | return FPoint(x, y); |
1727 | } |
||
1728 | |||
80 | Franz | 1729 | void Page::scaleGroup(double scx, double scy) |
3 | paul | 1730 | { |
1731 | PageItem *bb; |
||
80 | Franz | 1732 | double gx, gy, gh, gw; |
3 | paul | 1733 | uint aa; |
1734 | getGroupRect(&gx, &gy, &gw, &gh); |
||
1735 | for (uint a = 0; a < SelItem.count(); ++a) |
||
1736 | { |
||
1737 | bb = SelItem.at(a); |
||
1738 | bb->OldB = bb->Width; |
||
1739 | bb->OldH = bb->Height; |
||
1740 | bb->OldB2 = bb->Width; |
||
1741 | bb->OldH2 = bb->Height; |
||
1742 | bb->Sizing = false; |
||
1743 | FPoint b, b1, t, t1, h, h1, g, tes, tes2; |
||
80 | Franz | 1744 | double oldRot; |
3 | paul | 1745 | switch (HowTo) |
1746 | { |
||
1747 | case 1: |
||
1748 | oldRot = bb->Rot; |
||
1749 | g = FPoint(gx, gy); |
||
1750 | b = transformPoint(FPoint(0, 0), bb->Xpos, bb->Ypos, bb->Rot, 1, 1); |
||
1751 | b -= g; |
||
1752 | b1 = transformPoint(b, 0, 0, 0, scx, scy); |
||
1753 | t = transformPoint(FPoint(bb->Width, 0), bb->Xpos, bb->Ypos, bb->Rot, 1, 1); |
||
1754 | t -= g; |
||
1755 | t1 = transformPoint(t, 0, 0, 0, scx, scy); |
||
1756 | h = transformPoint(FPoint(0, bb->Height), bb->Xpos, bb->Ypos, bb->Rot, 1, 1); |
||
1757 | h -= g; |
||
1758 | h1 = transformPoint(h, 0, 0, 0, scx, scy); |
||
1759 | bb->Pwidth = QMAX(bb->Pwidth*((scx+scy)/2), 0.01); |
||
1760 | MoveItem(b1.x()-b.x(), b1.y()-b.y(), bb); |
||
1761 | SizeItem(sqrt(pow(t1.x()-b1.x(),2)+pow(t1.y()-b1.y(),2)), sqrt(pow(h1.x()-b1.x(),2)+pow(h1.y()-b1.y(),2)), bb->ItemNr, true); |
||
1762 | if (bb->Rot != 0) |
||
1763 | bb->Rot = atan2(t1.y()-b1.y(),t1.x()-b1.x())*(180.0/M_PI); |
||
1764 | bb->ISize = QMAX(qRound(bb->ISize*((scx+scy)/2)), 1); |
||
1765 | if (bb->Ptext.count() != 0) |
||
1766 | { |
||
111 | Franz | 1767 | bb->LineSp = ((bb->ISize / 10.0) * static_cast<double>(doku->AutoLine) / 100) + (bb->ISize / 10.0); |
3 | paul | 1768 | for (aa = 0; aa < bb->Ptext.count(); ++aa) |
1769 | { |
||
1770 | bb->Ptext.at(aa)->csize = QMAX(qRound(bb->Ptext.at(aa)->csize*((scx+scy)/2)), 1); |
||
1771 | } |
||
1772 | if (bb->PType == 8) |
||
1773 | { |
||
1774 | UpdatePolyClip(bb); |
||
1775 | } |
||
1776 | } |
||
1777 | break; |
||
1778 | } |
||
1779 | } |
||
1780 | setGroupRect(); |
||
1781 | update(); |
||
1782 | emit DocChanged(); |
||
1783 | } |
||
1784 | |||
1785 | void Page::mouseReleaseEvent(QMouseEvent *m) |
||
1786 | { |
||
1787 | PageItem *b; |
||
1788 | Mpressed = false; |
||
1789 | if (doku->Guides) |
||
1790 | { |
||
1791 | bool fg = false; |
||
80 | Franz | 1792 | double nx = m->x()/doku->Scale; |
1793 | double ny = m->y()/doku->Scale; |
||
3 | paul | 1794 | if (YGuides.count() != 0) |
1795 | { |
||
1796 | for (uint yg = 0; yg < YGuides.count(); ++yg) |
||
1797 | { |
||
1798 | if ((YGuides[yg] < (ny+doku->GrabRad)) && (YGuides[yg] > (ny-doku->GrabRad))) |
||
1799 | { |
||
1800 | fg = true; |
||
1801 | break; |
||
1802 | } |
||
1803 | } |
||
1804 | } |
||
1805 | if (XGuides.count() != 0) |
||
1806 | { |
||
1807 | for (uint xg = 0; xg < XGuides.count(); ++xg) |
||
1808 | { |
||
1809 | if ((XGuides[xg] < (nx+doku->GrabRad)) && (XGuides[xg] > (nx-doku->GrabRad))) |
||
1810 | { |
||
1811 | fg = true; |
||
1812 | break; |
||
1813 | } |
||
1814 | } |
||
1815 | } |
||
1816 | if ((fg) && (m->button() == RightButton)) |
||
1817 | { |
||
1818 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
1819 | MoveGY = false; |
||
1820 | MoveGX = false; |
||
1821 | emit EditGuides(); |
||
1822 | return; |
||
1823 | } |
||
1824 | if (MoveGY) |
||
1825 | { |
||
1826 | YGuides.remove(YGuides[GyM]); |
||
1827 | SetYGuide(m); |
||
1828 | MoveGY = false; |
||
1829 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
1830 | update(); |
||
1831 | return; |
||
1832 | } |
||
1833 | if (MoveGX) |
||
1834 | { |
||
1835 | XGuides.remove(XGuides[GxM]); |
||
1836 | SetXGuide(m); |
||
1837 | MoveGX = false; |
||
1838 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
1839 | update(); |
||
1840 | return; |
||
1841 | } |
||
1842 | } |
||
1843 | if ((doku->EditClip) && (ClRe == -1) && (HaveSelRect)) |
||
1844 | { |
||
80 | Franz | 1845 | double sc = doku->Scale; |
3 | paul | 1846 | QPainter p; |
1847 | p.begin(this); |
||
1848 | p.setRasterOp(XorROP); |
||
1849 | p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin)); |
||
1850 | p.drawRect(static_cast<int>(Mxp*sc), static_cast<int>(Myp*sc), static_cast<int>(SeRx-(Mxp*sc)), static_cast<int>(SeRy-(Myp*sc))); |
||
1851 | p.end(); |
||
1852 | if((Mxp*sc) > SeRx) |
||
1853 | { |
||
80 | Franz | 1854 | double tmp=SeRx; |
3 | paul | 1855 | SeRx=static_cast<int>(Mxp*sc); |
1856 | Mxp=static_cast<int>(tmp/sc); |
||
1857 | } |
||
1858 | if((Myp*sc) > SeRy) |
||
1859 | { |
||
80 | Franz | 1860 | double tmp=SeRy; |
3 | paul | 1861 | SeRy=static_cast<int>(Myp*sc); |
1862 | Myp=static_cast<int>(tmp/sc); |
||
1863 | } |
||
1864 | b = SelItem.at(0); |
||
1865 | SelNode.clear(); |
||
1866 | QRect Sele = QRect(static_cast<int>(Mxp*sc), static_cast<int>(Myp*sc), static_cast<int>(SeRx-(Mxp*sc)), static_cast<int>(SeRy-(Myp*sc))); |
||
1867 | for (uint a = 0; a < b->PoLine.count(); ++a) |
||
1868 | { |
||
1869 | if (b->PoLine.point(a).x() > 900000) |
||
1870 | continue; |
||
1871 | p.begin(this); |
||
1872 | Transform(b, &p); |
||
1873 | QPoint npf = p.xForm(b->PoLine.pointQ(a)); |
||
1874 | p.end(); |
||
1875 | if ((Sele.contains(npf)) && ((a == 0) || (((a-2) % 4) == 0))) |
||
1876 | { |
||
1877 | ClRe = a; |
||
1878 | SelNode.append(a); |
||
1879 | emit ClipPo(b->PoLine.point(a).x(), b->PoLine.point(a).y()); |
||
1880 | } |
||
1881 | } |
||
1882 | HaveSelRect = false; |
||
1883 | MarkClip(b); |
||
1884 | return; |
||
1885 | } |
||
1886 | if ((doku->EditClip) && (SegP1 == -1) && (SegP2 == -1)) |
||
1887 | { |
||
1888 | if (Imoved) |
||
1889 | { |
||
1890 | b = SelItem.at(0); |
||
1891 | b->OldB2 = b->Width; |
||
1892 | b->OldH2 = b->Height; |
||
80 | Franz | 1893 | double nx = m->x()/doku->Scale; |
1894 | double ny = m->y()/doku->Scale; |
||
3 | paul | 1895 | FPoint npg = ApplyGridF(FPoint(nx, ny)); |
1896 | nx = npg.x(); |
||
1897 | ny = npg.y(); |
||
1898 | ApplyGuides(&nx, &ny); |
||
1899 | FPoint np = transformPointI(FPoint(nx, ny), b->Xpos, b->Ypos, b->Rot, 1, 1); |
||
1900 | MoveClipPoint(b, np); |
||
1901 | } |
||
1902 | Imoved = false; |
||
1903 | return; |
||
1904 | } |
||
63 | Franz | 1905 | if ((doku->EditClip) && (SegP1 != -1) && (SegP2 != -1)) |
1906 | { |
||
1907 | SegP1 = -1; |
||
1908 | SegP2 = -1; |
||
1909 | b = SelItem.at(0); |
||
1910 | Imoved = false; |
||
1911 | b->paintObj(); |
||
1912 | MarkClip(b); |
||
1913 | return; |
||
1914 | } |
||
3 | paul | 1915 | if ((doku->AppMode != 6) /* && (doku->AppMode != 7) */ && (!doku->EditClip) && (doku->AppMode != 13)) |
1916 | { |
||
1917 | if ((GetItem(&b)) && (m->button() == RightButton) && (!doku->DragP)) |
||
1918 | { |
||
1919 | QPopupMenu *pmen = new QPopupMenu(); |
||
1920 | QPopupMenu *pmen2 = new QPopupMenu(); |
||
1921 | pmen3 = new QPopupMenu(); |
||
1922 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
1923 | if (b->PType == 2) |
||
1924 | { |
||
112 | Franz | 1925 | pmen->insertItem( tr("Get Picture..."), this, SIGNAL(LoadPic())); |
1926 | int px = pmen->insertItem( tr("Image Visible"), this, SLOT(TogglePic())); |
||
3 | paul | 1927 | pmen->setItemChecked(px, b->PicArt); |
1928 | } |
||
1929 | if (b->PType == 4) |
||
1930 | { |
||
112 | Franz | 1931 | pmen->insertItem( tr("Get Text..."), this, SIGNAL(LoadPic())); |
1932 | pmen->insertItem( tr("Edit Text..."), this, SIGNAL(EditText())); |
||
3 | paul | 1933 | if (PageNam == "") |
1934 | { |
||
112 | Franz | 1935 | int pxb = pmen->insertItem( tr("Is PDF-Bookmark"), this, SLOT(ToggleBookmark())); |
3 | paul | 1936 | pmen->setItemChecked(pxb, b->isBookmark); |
112 | Franz | 1937 | pxb = pmen->insertItem( tr("Is PDF-Annotation"), this, SLOT(ToggleAnnotation())); |
3 | paul | 1938 | pmen->setItemChecked(pxb, b->isAnnotation); |
1939 | if (b->isAnnotation) |
||
1940 | { |
||
1941 | if ((b->AnType == 0) || (b->AnType == 1) || (b->AnType > 9)) |
||
112 | Franz | 1942 | pmen->insertItem( tr("Annotation Properties"), this, SIGNAL(AnnotProps())); |
3 | paul | 1943 | else |
112 | Franz | 1944 | pmen->insertItem( tr("Field Properties"), this, SIGNAL(AnnotProps())); |
3 | paul | 1945 | } |
1946 | } |
||
1947 | } |
||
107 | Franz | 1948 | if (b->PType == 8) |
112 | Franz | 1949 | pmen->insertItem( tr("Edit Text..."), this, SIGNAL(EditText())); |
3 | paul | 1950 | if (!b->Locked) |
1951 | { |
||
111 | Franz | 1952 | if (SelItem.count() > 1) |
112 | Franz | 1953 | pmen->insertItem( tr("Group"), this, SIGNAL(DoGroup())); |
111 | Franz | 1954 | if (b->Groups.count() != 0) |
112 | Franz | 1955 | pmen->insertItem( tr("Un-group"), this, SIGNAL(DoUnGroup())); |
1956 | pmen->insertItem( tr("Lock"), this, SLOT(ToggleLock())); |
||
1957 | pmen->insertItem( tr("Send to Back"), this, SLOT(ToBack())); |
||
1958 | pmen->insertItem( tr("Bring to Front"), this, SLOT(ToFront())); |
||
1959 | pmen->insertItem( tr("Lower"), this, SLOT(LowerItem())); |
||
1960 | pmen->insertItem( tr("Raise"), this, SLOT(RaiseItem())); |
||
3 | paul | 1961 | } |
1962 | else |
||
112 | Franz | 1963 | pmen->insertItem( tr("Unlock"), this, SLOT(ToggleLock())); |
1964 | pmen->insertItem( tr("Send to Scrapbook"), this, SLOT(sentToScrap())); |
||
3 | paul | 1965 | if (doku->Layers.count() > 1) |
1966 | { |
||
1967 | for (uint lam=0; lam < doku->Layers.count(); ++lam) |
||
1968 | { |
||
1969 | int lai = pmen3->insertItem(doku->Layers[lam].Name); |
||
1970 | if (static_cast<int>(lam) == doku->ActiveLayer) |
||
1971 | pmen3->setItemEnabled(lai, 0); |
||
1972 | } |
||
112 | Franz | 1973 | pmen->insertItem( tr("Send to Layer"), pmen3); |
3 | paul | 1974 | } |
1975 | connect(pmen3, SIGNAL(activated(int)), this, SLOT(sentToLayer(int))); |
||
1976 | if ((b->PType == 4) || (b->PType == 2) || (b->PType == 6)) |
||
1977 | { |
||
1978 | if (b->PType == 4) |
||
1979 | { |
||
112 | Franz | 1980 | pmen2->insertItem( tr("Picture Frame"), this, SLOT(ToPicFrame())); |
1981 | pmen2->insertItem( tr("Polygon"), this, SLOT(ToPolyFrame())); |
||
121 | Franz | 1982 | pmen2->insertItem( tr("Outlines"), this, SLOT(TextToPath())); |
3 | paul | 1983 | } |
1984 | if (b->PType == 2) |
||
1985 | { |
||
112 | Franz | 1986 | pmen2->insertItem( tr("Text Frame"), this, SLOT(ToTextFrame())); |
1987 | pmen2->insertItem( tr("Polygon"), this, SLOT(ToPolyFrame())); |
||
3 | paul | 1988 | } |
1989 | if (b->PType == 6) |
||
1990 | { |
||
112 | Franz | 1991 | pmen2->insertItem( tr("Text Frame"), this, SLOT(ToTextFrame())); |
1992 | pmen2->insertItem( tr("Picture Frame"), this, SLOT(ToPicFrame())); |
||
1993 | pmen2->insertItem( tr("Bezier Curve"), this, SLOT(ToBezierFrame())); |
||
3 | paul | 1994 | } |
112 | Franz | 1995 | pmen->insertItem( tr("Convert to"), pmen2); |
3 | paul | 1996 | } |
1997 | pmen->insertSeparator(); |
||
1998 | if (!b->Locked) |
||
112 | Franz | 1999 | pmen->insertItem( tr("Cut"), this, SIGNAL(CutItem())); |
2000 | pmen->insertItem( tr("Copy"), this, SIGNAL(CopyItem())); |
||
3 | paul | 2001 | if ((!b->Locked) && (doku->AppMode != 7)) |
112 | Franz | 2002 | pmen->insertItem( tr("Delete"), this, SLOT(DeleteItem())); |
3 | paul | 2003 | pmen->exec(QCursor::pos()); |
2004 | delete pmen; |
||
2005 | delete pmen2; |
||
2006 | disconnect(pmen3, SIGNAL(activated(int)), this, SLOT(sentToLayer(int))); |
||
2007 | delete pmen3; |
||
2008 | } |
||
2009 | if (doku->AppMode == 10) |
||
2010 | update(); |
||
2011 | if (doku->AppMode == 12) |
||
2012 | { |
||
2013 | b = SelItem.at(0); |
||
2014 | QPainter p; |
||
2015 | FPointArray cli; |
||
2016 | p.begin(this); |
||
2017 | Transform(b, &p); |
||
2018 | QPoint np1 = p.xFormDev(m->pos()); |
||
2019 | p.end(); |
||
2020 | np1 = ApplyGrid(np1); |
||
2021 | b->Width = np1.x(); |
||
2022 | b->Height = np1.y(); |
||
2023 | cli = RegularPolygonF(b->Width, b->Height, PolyC, PolyS, PolyF, PolyR); |
||
2024 | FPoint np = FPoint(cli.point(0)); |
||
2025 | b->PoLine.resize(2); |
||
2026 | b->PoLine.setPoint(0, np); |
||
2027 | b->PoLine.setPoint(1, np); |
||
2028 | for (uint ax = 1; ax < cli.size(); ++ax) |
||
2029 | { |
||
2030 | np = FPoint(cli.point(ax)); |
||
2031 | b->PoLine.putPoints(b->PoLine.size(), 4, np.x(), np.y(), np.x(), np.y(), np.x(), np.y(), np.x(), np.y()); |
||
2032 | } |
||
2033 | np = FPoint(cli.point(0)); |
||
2034 | b->PoLine.putPoints(b->PoLine.size(), 2, np.x(), np.y(), np.x(), np.y()); |
||
2035 | FPoint tp2 = GetMinClipF(b->PoLine); |
||
2036 | if ((tp2.x() > -1) || (tp2.y() > -1)) |
||
2037 | { |
||
2038 | SizeItem(b->Width - tp2.x(), b->Height - tp2.y(), b->ItemNr, false, false); |
||
2039 | } |
||
2040 | FPoint tp = GetMaxClipF(b->PoLine); |
||
2041 | SizeItem(tp.x(), tp.y(), b->ItemNr, false, false); |
||
2042 | b->Clip = FlattenPath(b->PoLine, b->Segments); |
||
2043 | update(); |
||
2044 | } |
||
2045 | if (doku->AppMode == 8) |
||
2046 | { |
||
2047 | b = SelItem.at(0); |
||
2048 | QPainter p; |
||
2049 | p.begin(this); |
||
2050 | Transform(b, &p); |
||
2051 | QPoint np = p.xFormDev(m->pos()); |
||
2052 | p.end(); |
||
2053 | np = ApplyGrid(np); |
||
2054 | b->Rot = xy2Deg(np.x(), np.y()); |
||
2055 | b->Width = sqrt(pow(np.x(),2)+pow(np.y(),2)); |
||
2056 | b->Height = 0; |
||
2057 | b->Sizing = false; |
||
2058 | UpdateClip(b); |
||
2059 | update(); |
||
2060 | } |
||
2061 | if (GetItem(&b)) |
||
2062 | { |
||
2063 | if (GroupSel) |
||
2064 | { |
||
2065 | if (mCG) |
||
2066 | { |
||
80 | Franz | 2067 | double gx, gy, gh, gw, mx, my, scx, scy; |
3 | paul | 2068 | mx = Mxp; |
2069 | my = Myp; |
||
2070 | getGroupRect(&gx, &gy, &gw, &gh); |
||
2071 | scx = fabs(mx-gx) / gw; |
||