r20593 by jghali -
scribus-commit
scribus-commit at lists.scribus.net
Fri Nov 27 23:35:43 UTC 2015
Author: jghali
Date: Fri Nov 27 23:35:43 2015
New Revision: 20593
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20593
Log:
#13556: Apply patch to rename private member veriables of several classes <aliyousuf>
Modified:
trunk/Scribus/scribus/canvasmode_editgradient.cpp
trunk/Scribus/scribus/canvasmode_editgradient.h
trunk/Scribus/scribus/canvasmode_editmeshgradient.cpp
trunk/Scribus/scribus/canvasmode_editmeshgradient.h
trunk/Scribus/scribus/canvasmode_editmeshpatch.cpp
trunk/Scribus/scribus/canvasmode_editmeshpatch.h
trunk/Scribus/scribus/canvasmode_editpolygon.cpp
trunk/Scribus/scribus/canvasmode_editpolygon.h
trunk/Scribus/scribus/canvasmode_editspiral.cpp
trunk/Scribus/scribus/canvasmode_editspiral.h
trunk/Scribus/scribus/canvasmode_editweldpoint.cpp
trunk/Scribus/scribus/canvasmode_editweldpoint.h
trunk/Scribus/scribus/canvasmode_framelinks.cpp
trunk/Scribus/scribus/canvasmode_framelinks.h
trunk/Scribus/scribus/canvasmode_imageimport.cpp
trunk/Scribus/scribus/canvasmode_imageimport.h
trunk/Scribus/scribus/canvasmode_magnifier.cpp
trunk/Scribus/scribus/canvasmode_magnifier.h
trunk/Scribus/scribus/canvasmode_nodeedit.cpp
trunk/Scribus/scribus/canvasmode_nodeedit.h
trunk/Scribus/scribus/canvasmode_normal.cpp
trunk/Scribus/scribus/canvasmode_normal.h
trunk/Scribus/scribus/canvasmode_objimport.cpp
trunk/Scribus/scribus/canvasmode_objimport.h
trunk/Scribus/scribus/colorblind.cpp
trunk/Scribus/scribus/colorblind.h
trunk/Scribus/scribus/fileloader.cpp
trunk/Scribus/scribus/fileloader.h
trunk/Scribus/scribus/filewatcher.cpp
trunk/Scribus/scribus/filewatcher.h
Modified: trunk/Scribus/scribus/canvasmode_editgradient.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_editgradient.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editgradient.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_editgradient.cpp Fri Nov 27 23:35:43 2015
@@ -1,1001 +1,1001 @@
-/*
- For general Scribus (>=1.3.2) copyright and licensing information please refer
- to the COPYING file provided with the program. Following this notice may exist
- a copyright and/or license notice that predates the release of Scribus 1.3.2
- for which a new license (GPL+exception) is in place.
- */
-/***************************************************************************
-* *
-* This program is free software; you can redistribute it and/or modify *
-* it under the terms of the GNU General Public License as published by *
-* the Free Software Foundation; either version 2 of the License, or *
-* (at your option) any later version. *
-* *
-***************************************************************************/
-
-
-#include "canvasmode_editgradient.h"
-
-#include <QApplication>
-#include <QButtonGroup>
-#include <QCheckBox>
-#include <QCursor>
-#include <QEvent>
-#include <QMessageBox>
-#include <QMouseEvent>
-#include <QPainterPath>
-#include <QPoint>
-#include <QRect>
-#include <QTimer>
-#include <QWidgetAction>
-#include <QDebug>
-
-#include "appmodes.h"
-#include "canvas.h"
-#include "fpoint.h"
-#include "fpointarray.h"
-#include "hyphenator.h"
-#include "pageitem_textframe.h"
-#include "prefscontext.h"
-#include "prefsfile.h"
-#include "prefsmanager.h"
-#include "scribus.h"
-#include "scribusXml.h"
-#include "scribusdoc.h"
-#include "scribusview.h"
-#include "selection.h"
-#include "ui/aligndistribute.h"
-#include "ui/contextmenu.h"
-#include "ui/pageselector.h"
-#include "ui/propertiespalette.h"
-#include "undomanager.h"
-#include "units.h"
-#include "util.h"
-#include "util_math.h"
-
-
-CanvasMode_EditGradient::CanvasMode_EditGradient(ScribusView* view) : CanvasMode(view), m_ScMW(view->m_ScMW)
-{
- Mxp = Myp = -1;
- m_gradientPoint = noPointDefined;
-}
-
-inline bool CanvasMode_EditGradient::GetItem(PageItem** pi)
-{
- *pi = m_doc->m_Selection->itemAt(0);
- return (*pi) != NULL;
-}
-
-void CanvasMode_EditGradient::drawControls(QPainter* p)
-{
- if (m_canvas->m_viewMode.operItemMoving)
- {
- drawOutline(p);
- }
- else
- {
- drawSelection(p, false);
- }
- if (m_doc->appMode == modeEditGradientVectors)
- {
- drawControlsGradientVectors(p, m_doc->m_Selection->itemAt(0));
- }
-}
-
-void CanvasMode_EditGradient::drawControlsGradientVectors(QPainter* psx, PageItem *currItem)
-{
- psx->setTransform(currItem->getTransform(), true);
- psx->setPen(QPen(Qt::blue, 1.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
- psx->setBrush(Qt::NoBrush);
- if (m_view->editStrokeGradient == 1)
- {
- psx->drawLine(QPointF(currItem->GrStrokeStartX, currItem->GrStrokeStartY), QPointF(currItem->GrStrokeEndX, currItem->GrStrokeEndY));
- psx->setPen(QPen(Qt::magenta, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
- psx->drawPoint(QPointF(currItem->GrStrokeStartX, currItem->GrStrokeStartY));
- psx->drawPoint(QPointF(currItem->GrStrokeEndX, currItem->GrStrokeEndY));
- double radEnd = distance(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
- double rotEnd = xy2Deg(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
- QTransform qmatrix;
- qmatrix.translate(currItem->GrStrokeStartX, currItem->GrStrokeStartY);
- qmatrix.rotate(rotEnd);
- double mask_gradientSkew = 0.0;
- if (currItem->GrStrokeSkew == 90)
- mask_gradientSkew = 1;
- else if (currItem->GrStrokeSkew == 180)
- mask_gradientSkew = 0;
- else if (currItem->GrStrokeSkew == 270)
- mask_gradientSkew = -1;
- else if (currItem->GrStrokeSkew == 390)
- mask_gradientSkew = 0;
- else
- mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrStrokeSkew);
- qmatrix.shear(mask_gradientSkew, 0);
- qmatrix.translate(0, currItem->GrStrokeStartY * (1.0 - currItem->GrStrokeScale));
- qmatrix.translate(-currItem->GrStrokeStartX, -currItem->GrStrokeStartY);
- qmatrix.scale(1, currItem->GrStrokeScale);
- if (currItem->GrTypeStroke == 7)
- psx->drawPoint(qmatrix.map(QPointF(currItem->GrStrokeFocalX, currItem->GrStrokeFocalY)));
- QTransform m;
- m.translate(currItem->GrStrokeStartX, currItem->GrStrokeStartY);
- m.rotate(rotEnd);
- m.rotate(-90);
- m.rotate(currItem->GrStrokeSkew);
- m.translate(radEnd * currItem->GrStrokeScale, 0);
- QPointF shP = m.map(QPointF(0,0));
- psx->setPen(QPen(Qt::blue, 1.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
- psx->drawLine(QPointF(currItem->GrStrokeStartX, currItem->GrStrokeStartY), shP);
- psx->setPen(QPen(Qt::magenta, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
- psx->drawPoint(shP);
- }
- else if (m_view->editStrokeGradient == 2)
- {
- psx->drawLine(QPointF(currItem->GrMaskStartX, currItem->GrMaskStartY), QPointF(currItem->GrMaskEndX, currItem->GrMaskEndY));
- psx->setPen(QPen(Qt::magenta, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
- psx->drawPoint(QPointF(currItem->GrMaskStartX, currItem->GrMaskStartY));
- psx->drawPoint(QPointF(currItem->GrMaskEndX, currItem->GrMaskEndY));
- double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
- double rotEnd = xy2Deg(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
- QTransform qmatrix;
- qmatrix.translate(currItem->GrMaskStartX, currItem->GrMaskStartY);
- qmatrix.rotate(rotEnd);
- double mask_gradientSkew = 0.0;
- if (currItem->GrMaskSkew == 90)
- mask_gradientSkew = 1;
- else if (currItem->GrMaskSkew == 180)
- mask_gradientSkew = 0;
- else if (currItem->GrMaskSkew == 270)
- mask_gradientSkew = -1;
- else if (currItem->GrMaskSkew == 390)
- mask_gradientSkew = 0;
- else
- mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrMaskSkew);
- qmatrix.shear(mask_gradientSkew, 0);
- qmatrix.translate(0, currItem->GrMaskStartY * (1.0 - currItem->GrMaskScale));
- qmatrix.translate(-currItem->GrMaskStartX, -currItem->GrMaskStartY);
- qmatrix.scale(1, currItem->GrMaskScale);
- if ((currItem->GrMask == 2) || (currItem->GrMask == 5))
- psx->drawPoint(qmatrix.map(QPointF(currItem->GrMaskFocalX, currItem->GrMaskFocalY)));
- QTransform m;
- m.translate(currItem->GrMaskStartX, currItem->GrMaskStartY);
- m.rotate(rotEnd);
- m.rotate(-90);
- m.rotate(currItem->GrMaskSkew);
- m.translate(radEnd * currItem->GrMaskScale, 0);
- QPointF shP = m.map(QPointF(0,0));
- psx->setPen(QPen(Qt::blue, 1.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
- psx->drawLine(QPointF(currItem->GrMaskStartX, currItem->GrMaskStartY), shP);
- psx->setPen(QPen(Qt::magenta, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
- psx->drawPoint(shP);
- }
- else if (m_view->editStrokeGradient == 0)
- {
- psx->drawLine(QPointF(currItem->GrStartX, currItem->GrStartY), QPointF(currItem->GrEndX, currItem->GrEndY));
- psx->setPen(QPen(Qt::magenta, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
- psx->drawPoint(QPointF(currItem->GrStartX, currItem->GrStartY));
- psx->drawPoint(QPointF(currItem->GrEndX, currItem->GrEndY));
- double radEnd = distance(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
- double rotEnd = xy2Deg(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
- QTransform qmatrix;
- qmatrix.translate(currItem->GrStartX, currItem->GrStartY);
- qmatrix.rotate(rotEnd);
- if (currItem->GrType != 13)
- {
- double mask_gradientSkew = 0.0;
- if (currItem->GrSkew == 90)
- mask_gradientSkew = 1;
- else if (currItem->GrSkew == 180)
- mask_gradientSkew = 0;
- else if (currItem->GrSkew == 270)
- mask_gradientSkew = -1;
- else if (currItem->GrSkew == 390)
- mask_gradientSkew = 0;
- else
- mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrSkew);
- qmatrix.shear(mask_gradientSkew, 0);
- }
- qmatrix.translate(0, currItem->GrStartY * (1.0 - currItem->GrScale));
- qmatrix.translate(-currItem->GrStartX, -currItem->GrStartY);
- qmatrix.scale(1, currItem->GrScale);
- if ((currItem->GrType == 7) || (currItem->GrType == 13))
- psx->drawPoint(qmatrix.map(QPointF(currItem->GrFocalX, currItem->GrFocalY)));
- QTransform m;
- m.translate(currItem->GrStartX, currItem->GrStartY);
- m.rotate(rotEnd);
- m.rotate(-90);
- m.rotate(currItem->GrSkew);
- m.translate(radEnd * currItem->GrScale, 0);
- QPointF shP = m.map(QPointF(0,0));
- psx->setPen(QPen(Qt::blue, 1.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
- psx->drawLine(QPointF(currItem->GrStartX, currItem->GrStartY), shP);
- psx->setPen(QPen(Qt::magenta, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
- psx->drawPoint(shP);
- }
- else if (m_view->editStrokeGradient == 3)
- {
- psx->setPen(QPen(Qt::magenta, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
- psx->drawPoint(QPointF(currItem->GrControl1.x(), currItem->GrControl1.y()));
- psx->drawPoint(QPointF(currItem->GrControl2.x(), currItem->GrControl2.y()));
- psx->drawPoint(QPointF(currItem->GrControl3.x(), currItem->GrControl3.y()));
- psx->drawPoint(QPointF(currItem->GrControl4.x(), currItem->GrControl4.y()));
- }
- else if (m_view->editStrokeGradient == 4)
- {
- psx->setPen(QPen(Qt::magenta, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
- psx->drawPoint(QPointF(currItem->GrControl1.x(), currItem->GrControl1.y()));
- psx->drawPoint(QPointF(currItem->GrControl2.x(), currItem->GrControl2.y()));
- psx->drawPoint(QPointF(currItem->GrControl3.x(), currItem->GrControl3.y()));
- psx->drawPoint(QPointF(currItem->GrControl4.x(), currItem->GrControl4.y()));
- psx->drawPoint(QPointF(currItem->GrControl5.x(), currItem->GrControl5.y()));
- }
-}
-
-void CanvasMode_EditGradient::enterEvent(QEvent *)
-{
- if (!m_canvas->m_viewMode.m_MouseButtonPressed)
- {
- setModeCursor();
- }
-}
-
-void CanvasMode_EditGradient::leaveEvent(QEvent *e)
-{
-}
-
-
-void CanvasMode_EditGradient::activate(bool fromGesture)
-{
-// qDebug() << "CanvasMode_EditGradient::activate" << fromGesture;
- m_canvas->m_viewMode.m_MouseButtonPressed = false;
- m_canvas->resetRenderMode();
- m_doc->DragP = false;
- m_doc->leaveDrag = false;
- m_canvas->m_viewMode.operItemMoving = false;
- m_canvas->m_viewMode.operItemResizing = false;
- m_view->MidButt = false;
- Mxp = Myp = -1;
- setModeCursor();
- if (fromGesture)
- {
- m_view->update();
- }
-}
-
-void CanvasMode_EditGradient::deactivate(bool forGesture)
-{
-// qDebug() << "CanvasMode_EditGradient::deactivate" << forGesture;
- m_view->setRedrawMarkerShown(false);
-}
-
-void CanvasMode_EditGradient::mouseDoubleClickEvent(QMouseEvent *m)
-{
- m->accept();
- m_canvas->m_viewMode.m_MouseButtonPressed = false;
- m_canvas->resetRenderMode();
-// m_view->stopDragTimer();
- PageItem *currItem = 0;
- if ((m_doc->m_Selection->isMultipleSelection()) || (m_doc->appMode != modeNormal))
- {
- if ((m_doc->m_Selection->isMultipleSelection()) && (m_doc->appMode == modeNormal))
- {
- if (GetItem(&currItem))
- {
- /* CB: old code, removing this as shift-alt select on an unselected table selects a cell now.
- //#6789 is closed by sorting this.
- if (currItem->isTableItem)
- {
- m_view->Deselect(false);
- m_doc->m_Selection->addItem(currItem);
- currItem->isSingleSel = true;
- //CB FIXME dont call this if the added item is item 0
- if (!m_doc->m_Selection->primarySelectionIs(currItem))
- currItem->emitAllToGUI();
- m_view->updateContents(currItem->getRedrawBounding(m_canvas->scale()));
- }*/
- }
- return;
- }
- else
- {
- if (!(GetItem(&currItem) && (m_doc->appMode == modeEdit) && currItem->asTextFrame()))
- {
- mousePressEvent(m);
- return;
- }
- }
- }
-}
-
-
-void CanvasMode_EditGradient::mouseMoveEvent(QMouseEvent *m)
-{
- const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
- m->accept();
- if (m_gradientPoint == noPointDefined)
- return;
-
- if (m_canvas->m_viewMode.m_MouseButtonPressed)
- {
- PageItem *currItem = m_doc->m_Selection->itemAt(0);
- double newX = mousePointDoc.x(); //m->x();
- double newY = mousePointDoc.y(); //m->y();
- FPoint npx(Mxp - newX, Myp - newY, 0, 0, currItem->rotation(), 1, 1, true);
- QPointF np = QPointF(npx.x(), npx.y());
- if (m_view->editStrokeGradient == 1)
- {
- if (m_gradientPoint == useGradientStart)
- {
- currItem->GrStrokeStartX -= np.x(); // (Mxp - newX); // / m_canvas->scale();
- currItem->GrStrokeStartY -= np.y(); // (Myp - newY); // / m_canvas->scale();
- currItem->GrStrokeFocalX -= np.x();
- currItem->GrStrokeFocalY -= np.y();
- if (currItem->strokeGradientType() == 7)
- {
- double radEnd = distance(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
- double radFoc = distance(currItem->GrStrokeFocalX - currItem->GrStrokeStartX, currItem->GrStrokeFocalY - currItem->GrStrokeStartY);
- if (radFoc >= radEnd)
- {
- currItem->GrStrokeStartX += np.x(); // (Mxp - newX); // / m_canvas->scale();
- currItem->GrStrokeStartY += np.y(); // (Myp - newY); // / m_canvas->scale();
- currItem->GrStrokeFocalX += np.x(); // (Mxp - newX); // / m_canvas->scale();
- currItem->GrStrokeFocalY += np.y(); // (Myp - newY); // / m_canvas->scale();
- }
- }
- }
- if (m_gradientPoint == useGradientFocal)
- {
- double rotEnd = xy2Deg(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
- QTransform qmatrix;
- qmatrix.translate(currItem->GrStrokeStartX, currItem->GrStrokeStartY);
- qmatrix.rotate(rotEnd);
- double mask_gradientSkew = 0.0;
- if (currItem->GrStrokeSkew == 90)
- mask_gradientSkew = 1;
- else if (currItem->GrStrokeSkew == 180)
- mask_gradientSkew = 0;
- else if (currItem->GrStrokeSkew == 270)
- mask_gradientSkew = -1;
- else if (currItem->GrStrokeSkew == 390)
- mask_gradientSkew = 0;
- else
- mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrStrokeSkew);
- qmatrix.shear(mask_gradientSkew, 0);
- qmatrix.translate(0, currItem->GrStrokeStartY * (1.0 - currItem->GrStrokeScale));
- qmatrix.translate(-currItem->GrStrokeStartX, -currItem->GrStrokeStartY);
- qmatrix.scale(1, currItem->GrStrokeScale);
- QTransform m = qmatrix.inverted();
- QPointF shR = qmatrix.map(QPointF(currItem->GrStrokeFocalX, currItem->GrStrokeFocalY));
- QPointF shRe = m.map(shR - np);
- currItem->GrStrokeFocalX = shRe.x();
- currItem->GrStrokeFocalY = shRe.y();
- if (currItem->strokeGradientType() == 7)
- {
- double radEnd = distance(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
- double radFoc = distance(currItem->GrStrokeFocalX - currItem->GrStrokeStartX, currItem->GrStrokeFocalY - currItem->GrStrokeStartY);
- if (radFoc >= radEnd)
- {
- QPointF shR = qmatrix.map(QPointF(currItem->GrStrokeFocalX, currItem->GrStrokeFocalY));
- QPointF shRe = m.map(shR + np);
- currItem->GrStrokeFocalX = shRe.x();
- currItem->GrStrokeFocalY = shRe.y();
- }
- }
- }
- if (m_gradientPoint == useGradientSkew)
- {
- double radEnd = distance(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
- double rotEnd = xy2Deg(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
- QTransform m;
- m.translate(currItem->GrStrokeStartX, currItem->GrStrokeStartY);
- m.rotate(rotEnd);
- m.rotate(-90);
- m.rotate(currItem->GrStrokeSkew);
- m.translate(radEnd * currItem->GrStrokeScale, 0);
- QPointF shP = m.map(QPointF(0,0));
- QPointF shR = QPointF(shP.x() -np.x(), shP.y() - np.y());
- double radNew = distance(shR.x() - currItem->GrStrokeStartX, shR.y() - currItem->GrStrokeStartY);
- double rotNew = xy2Deg(shR.x() - currItem->GrStrokeStartX, shR.y() - currItem->GrStrokeStartY) + 90;
- currItem->GrStrokeSkew = rotNew - rotEnd;
- double newScale = radNew / radEnd;
- if ((newScale > 0) && (newScale <= 1))
- currItem->GrStrokeScale = newScale;
- }
- if (m_gradientPoint == useGradientEnd)
- {
- currItem->GrStrokeEndX -= np.x(); // (Mxp - newX); // / m_canvas->scale();
- currItem->GrStrokeEndY -= np.y(); // (Myp - newY); // / m_canvas->scale();
- if (currItem->strokeGradientType() == 7)
- {
- double radEnd = distance(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
- double radFoc = distance(currItem->GrStrokeFocalX - currItem->GrStrokeStartX, currItem->GrStrokeFocalY - currItem->GrStrokeStartY);
- if (radFoc >= radEnd)
- {
- currItem->GrStrokeEndX += np.x(); // (Mxp - newX); // / m_canvas->scale();
- currItem->GrStrokeEndY += np.y(); // (Myp - newY); // / m_canvas->scale();
- }
- }
- }
- }
- else if (m_view->editStrokeGradient == 2)
- {
- if (m_gradientPoint == useGradientStart)
- {
- currItem->GrMaskStartX -= np.x();
- currItem->GrMaskStartY -= np.y();
- currItem->GrMaskFocalX -= np.x();
- currItem->GrMaskFocalY -= np.y();
- if ((currItem->GrMask == 2) || (currItem->GrMask == 5))
- {
- double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
- double radFoc = distance(currItem->GrMaskFocalX - currItem->GrMaskStartX, currItem->GrMaskFocalY - currItem->GrMaskStartY);
- if (radFoc >= radEnd)
- {
- currItem->GrMaskStartX += np.x(); // (Mxp - newX); // / m_canvas->scale();
- currItem->GrMaskStartY += np.y(); // (Myp - newY); // / m_canvas->scale();
- currItem->GrMaskFocalX += np.x(); // (Mxp - newX); // / m_canvas->scale();
- currItem->GrMaskFocalY += np.y(); // (Myp - newY); // / m_canvas->scale();
- }
- }
- }
- if (m_gradientPoint == useGradientFocal)
- {
- double rotEnd = xy2Deg(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
- QTransform qmatrix;
- qmatrix.translate(currItem->GrMaskStartX, currItem->GrMaskStartY);
- qmatrix.rotate(rotEnd);
- double mask_gradientSkew = 0.0;
- if (currItem->GrMaskSkew == 90)
- mask_gradientSkew = 1;
- else if (currItem->GrMaskSkew == 180)
- mask_gradientSkew = 0;
- else if (currItem->GrMaskSkew == 270)
- mask_gradientSkew = -1;
- else if (currItem->GrMaskSkew == 390)
- mask_gradientSkew = 0;
- else
- mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrMaskSkew);
- qmatrix.shear(mask_gradientSkew, 0);
- qmatrix.translate(0, currItem->GrMaskStartY * (1.0 - currItem->GrMaskScale));
- qmatrix.translate(-currItem->GrMaskStartX, -currItem->GrMaskStartY);
- qmatrix.scale(1, currItem->GrMaskScale);
- QTransform m = qmatrix.inverted();
- QPointF shR = qmatrix.map(QPointF(currItem->GrMaskFocalX, currItem->GrMaskFocalY));
- QPointF shRe = m.map(shR - np);
- currItem->GrMaskFocalX = shRe.x();
- currItem->GrMaskFocalY = shRe.y();
- if ((currItem->GrMask == 2) || (currItem->GrMask == 5))
- {
- double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
- double radFoc = distance(currItem->GrMaskFocalX - currItem->GrMaskStartX, currItem->GrMaskFocalY - currItem->GrMaskStartY);
- if (radFoc >= radEnd)
- {
- QPointF shR = qmatrix.map(QPointF(currItem->GrMaskFocalX, currItem->GrMaskFocalY));
- QPointF shRe = m.map(shR + np);
- currItem->GrMaskFocalX = shRe.x();
- currItem->GrMaskFocalY = shRe.y();
- }
- }
- }
- if (m_gradientPoint == useGradientSkew)
- {
- double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
- double rotEnd = xy2Deg(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
- QTransform m;
- m.translate(currItem->GrMaskStartX, currItem->GrMaskStartY);
- m.rotate(rotEnd);
- m.rotate(-90);
- m.rotate(currItem->GrMaskSkew);
- m.translate(radEnd * currItem->GrMaskScale, 0);
- QPointF shP = m.map(QPointF(0,0));
- QPointF shR = QPointF(shP.x() -np.x(), shP.y() - np.y());
- double radNew = distance(shR.x() - currItem->GrMaskStartX, shR.y() - currItem->GrMaskStartY);
- double rotNew = xy2Deg(shR.x() - currItem->GrMaskStartX, shR.y() - currItem->GrMaskStartY) + 90;
- currItem->GrMaskSkew = rotNew - rotEnd;
- double newScale = radNew / radEnd;
- if ((newScale > 0) && (newScale <= 1))
- currItem->GrMaskScale = newScale;
- }
- if (m_gradientPoint == useGradientEnd)
- {
- currItem->GrMaskEndX -= np.x();
- currItem->GrMaskEndY -= np.y();
- if ((currItem->GrMask == 2) || (currItem->GrMask == 5))
- {
- double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
- double radFoc = distance(currItem->GrMaskFocalX - currItem->GrMaskStartX, currItem->GrMaskFocalY - currItem->GrMaskStartY);
- if (radFoc >= radEnd)
- {
- currItem->GrMaskEndX += np.x(); // (Mxp - newX); // / m_canvas->scale();
- currItem->GrMaskEndY += np.y(); // (Myp - newY); // / m_canvas->scale();
- }
- }
- }
- }
- else if (m_view->editStrokeGradient == 0)
- {
- if (m_gradientPoint == useGradientStart)
- {
- currItem->GrStartX -= np.x();
- currItem->GrStartY -= np.y();
- currItem->GrFocalX -= np.x();
- currItem->GrFocalY -= np.y();
- if ((currItem->gradientType() == 7) || (currItem->gradientType() == 13))
- {
- double radEnd = distance(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
- double radFoc = distance(currItem->GrFocalX - currItem->GrStartX, currItem->GrFocalY - currItem->GrStartY);
- if (radFoc >= radEnd)
- {
- currItem->GrStartX += np.x(); // (Mxp - newX); // / m_canvas->scale();
- currItem->GrStartY += np.y(); // (Myp - newY); // / m_canvas->scale();
- currItem->GrFocalX += np.x(); // (Mxp - newX); // / m_canvas->scale();
- currItem->GrFocalY += np.y(); // (Myp - newY); // / m_canvas->scale();
- }
- }
- }
- if (m_gradientPoint == useGradientFocal)
- {
- double rotEnd = xy2Deg(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
- QTransform qmatrix;
- qmatrix.translate(currItem->GrStartX, currItem->GrStartY);
- qmatrix.rotate(rotEnd);
- if (currItem->GrType != 13)
- {
- double mask_gradientSkew = 0.0;
- if (currItem->GrSkew == 90)
- mask_gradientSkew = 1;
- else if (currItem->GrSkew == 180)
- mask_gradientSkew = 0;
- else if (currItem->GrSkew == 270)
- mask_gradientSkew = -1;
- else if (currItem->GrSkew == 390)
- mask_gradientSkew = 0;
- else
- mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrSkew);
- qmatrix.shear(mask_gradientSkew, 0);
- }
- qmatrix.translate(0, currItem->GrStartY * (1.0 - currItem->GrScale));
- qmatrix.translate(-currItem->GrStartX, -currItem->GrStartY);
- qmatrix.scale(1, currItem->GrScale);
- QTransform m = qmatrix.inverted();
- QPointF shR = qmatrix.map(QPointF(currItem->GrFocalX, currItem->GrFocalY));
- QPointF shRe = m.map(shR - np);
- currItem->GrFocalX = shRe.x();
- currItem->GrFocalY = shRe.y();
- if ((currItem->GrType == 7) || (currItem->GrType == 13))
- {
- double radEnd = distance(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
- double radFoc = distance(currItem->GrFocalX - currItem->GrStartX, currItem->GrFocalY - currItem->GrStartY);
- if (radFoc >= radEnd)
- {
- QPointF shR = qmatrix.map(QPointF(currItem->GrFocalX, currItem->GrFocalY));
- QPointF shRe = m.map(shR + np);
- currItem->GrFocalX = shRe.x();
- currItem->GrFocalY = shRe.y();
- }
- }
- }
- if (m_gradientPoint == useGradientSkew)
- {
- double radEnd = distance(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
- double rotEnd = xy2Deg(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
- QTransform m;
- m.translate(currItem->GrStartX, currItem->GrStartY);
- m.rotate(rotEnd);
- m.rotate(-90);
- if (currItem->GrType != 13)
- m.rotate(currItem->GrSkew);
- m.translate(radEnd * currItem->GrScale, 0);
- QPointF shP = m.map(QPointF(0,0));
- QPointF shR = QPointF(shP.x() -np.x(), shP.y() - np.y());
- double radNew = distance(shR.x() - currItem->GrStartX, shR.y() - currItem->GrStartY);
- double rotNew = xy2Deg(shR.x() - currItem->GrStartX, shR.y() - currItem->GrStartY) + 90;
- if (currItem->GrType != 13)
- currItem->GrSkew = rotNew - rotEnd;
- else
- currItem->GrSkew = 0;
- double newScale = radNew / radEnd;
- if ((newScale > 0) && (newScale <= 1))
- currItem->GrScale = newScale;
- }
- if (m_gradientPoint == useGradientEnd)
- {
- currItem->GrEndX -= np.x();
- currItem->GrEndY -= np.y();
- if ((currItem->GrType == 7) || (currItem->GrType == 13))
- {
- double radEnd = distance(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
- double radFoc = distance(currItem->GrFocalX - currItem->GrStartX, currItem->GrFocalY - currItem->GrStartY);
- if (radFoc >= radEnd)
- {
- currItem->GrEndX += np.x(); // (Mxp - newX); // / m_canvas->scale();
- currItem->GrEndY += np.y(); // (Myp - newY); // / m_canvas->scale();
- }
- }
- }
- }
- else if (m_view->editStrokeGradient == 3)
- {
- if (m_gradientPoint == useControl1)
- currItem->GrControl1 -= npx;
- else if (m_gradientPoint == useControl2)
- currItem->GrControl2 -= npx;
- else if (m_gradientPoint == useControl3)
- currItem->GrControl3 -= npx;
- else if (m_gradientPoint == useControl4)
- currItem->GrControl4 -= npx;
- }
- else if (m_view->editStrokeGradient == 4)
- {
- if (m_gradientPoint == useControl1)
- currItem->GrControl1 -= npx;
- else if (m_gradientPoint == useControl2)
- currItem->GrControl2 -= npx;
- else if (m_gradientPoint == useControl3)
- currItem->GrControl3 -= npx;
- else if (m_gradientPoint == useControl4)
- currItem->GrControl4 -= npx;
- else if (m_gradientPoint == useControl5)
- currItem->GrControl5 -= npx;
- }
- Mxp = newX;
- Myp = newY;
-// m_view->RefreshGradient(currItem, dx * m_canvas->scale(), dy * m_canvas->scale());
- m_ScMW->propertiesPalette->updateColorSpecialGradient();
- currItem->update();
- QRectF upRect;
- if (m_view->editStrokeGradient == 1)
- {
- upRect = QRectF(QPointF(currItem->GrStrokeStartX, currItem->GrStrokeStartY), QPointF(currItem->GrStrokeEndX, currItem->GrStrokeEndY));
- double radEnd = distance(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
- double rotEnd = xy2Deg(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
- QTransform m;
- m.translate(currItem->GrStrokeStartX, currItem->GrStrokeStartY);
- m.rotate(rotEnd);
- m.rotate(-90);
- m.rotate(currItem->GrStrokeSkew);
- m.translate(radEnd * currItem->GrStrokeScale, 0);
- QPointF shP = m.map(QPointF(0,0));
- upRect |= upRect.united(QRectF(shP, QPointF(currItem->GrStrokeEndX, currItem->GrStrokeEndY)).normalized());
- upRect |= upRect.united(QRectF(shP, QPointF(currItem->GrStrokeStartX, currItem->GrStrokeStartY)).normalized());
- upRect |= QRectF(shP, QPointF(0, 0)).normalized();
- upRect |= QRectF(shP, QPointF(currItem->width(), currItem->height())).normalized();
- }
- else if (m_view->editStrokeGradient == 2)
- {
- upRect = QRectF(QPointF(currItem->GrMaskStartX, currItem->GrMaskStartY), QPointF(currItem->GrMaskEndX, currItem->GrMaskEndY));
- double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
- double rotEnd = xy2Deg(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
- QTransform m;
- m.translate(currItem->GrMaskStartX, currItem->GrMaskStartY);
- m.rotate(rotEnd);
- m.rotate(-90);
- m.rotate(currItem->GrMaskSkew);
- m.translate(radEnd * currItem->GrMaskScale, 0);
- QPointF shP = m.map(QPointF(0,0));
- upRect |= upRect.united(QRectF(shP, QPointF(currItem->GrMaskEndX, currItem->GrMaskEndY)).normalized());
- upRect |= upRect.united(QRectF(shP, QPointF(currItem->GrMaskStartX, currItem->GrMaskStartY)).normalized());
- upRect |= QRectF(shP, QPointF(0, 0)).normalized();
- upRect |= QRectF(shP, QPointF(currItem->width(), currItem->height())).normalized();
- }
- else if (m_view->editStrokeGradient == 0)
- {
- upRect = QRectF(QPointF(currItem->GrStartX, currItem->GrStartY), QPointF(currItem->GrEndX, currItem->GrEndY));
- double radEnd = distance(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
- double rotEnd = xy2Deg(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
- QTransform m;
- m.translate(currItem->GrStartX, currItem->GrStartY);
- m.rotate(rotEnd);
- m.rotate(-90);
- m.rotate(currItem->GrSkew);
- m.translate(radEnd * currItem->GrScale, 0);
- QPointF shP = m.map(QPointF(0,0));
- upRect |= QRectF(shP, QPointF(currItem->GrEndX, currItem->GrEndY)).normalized();
- upRect |= QRectF(shP, QPointF(currItem->GrStartX, currItem->GrStartY)).normalized();
- upRect |= QRectF(shP, QPointF(0, 0)).normalized();
- upRect |= QRectF(shP, QPointF(currItem->width(), currItem->height())).normalized();
- }
- else if ((m_view->editStrokeGradient == 3) || (m_view->editStrokeGradient == 4))
- {
- upRect = QRectF(QPointF(-currItem->width(), -currItem->height()), QPointF(currItem->width() * 2, currItem->height() * 2)).normalized();
- }
- QTransform itemMatrix = currItem->getTransform();
- upRect = itemMatrix.mapRect(upRect);
- if (currItem->GrType == 13)
- currItem->createConicalMesh();
- m_doc->regionsChanged()->update(upRect.adjusted(-10.0, -10.0, 10.0, 10.0));
- }
-}
-
-void CanvasMode_EditGradient::mousePressEvent(QMouseEvent *m)
-{
- const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
-
- m_canvas->PaintSizeRect(QRect());
- m_canvas->m_viewMode.m_MouseButtonPressed = true;
- m_canvas->m_viewMode.operItemMoving = false;
- m_view->HaveSelRect = false;
- m_doc->DragP = false;
- m_doc->leaveDrag = false;
- m->accept();
- m_view->registerMousePress(m->globalPos());
- m_gradientPoint = noPointDefined;
- Mxp = mousePointDoc.x(); //m->x();
- Myp = mousePointDoc.y(); //m->y();
- if (m->button() == Qt::MidButton)
- {
- m_view->MidButt = true;
- if (m->modifiers() & Qt::ControlModifier)
- m_view->DrawNew();
- return;
- }
- PageItem *currItem = m_doc->m_Selection->itemAt(0);
- QTransform itemMatrix = currItem->getTransform();
- QPointF gradientStart, gradientEnd, gradientFocal, gradientScale, gradientCenter;
- if (m_view->editStrokeGradient == 1)
- {
- gradientStart = QPointF(currItem->GrStrokeStartX, currItem->GrStrokeStartY);
- gradientEnd = QPointF(currItem->GrStrokeEndX, currItem->GrStrokeEndY);
- double radEnd = distance(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
- double rotEnd = xy2Deg(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
- QTransform m;
- m.translate(currItem->GrStrokeStartX, currItem->GrStrokeStartY);
- m.rotate(rotEnd);
- m.rotate(-90);
- m.rotate(currItem->GrStrokeSkew);
- m.translate(radEnd * currItem->GrStrokeScale, 0);
- gradientScale = m.map(QPointF(0,0));
- QTransform qmatrix;
- qmatrix.translate(currItem->GrStrokeStartX, currItem->GrStrokeStartY);
- qmatrix.rotate(rotEnd);
- double mask_gradientSkew = 0.0;
- if (currItem->GrStrokeSkew == 90)
- mask_gradientSkew = 1;
- else if (currItem->GrStrokeSkew == 180)
- mask_gradientSkew = 0;
- else if (currItem->GrStrokeSkew == 270)
- mask_gradientSkew = -1;
- else if (currItem->GrStrokeSkew == 390)
- mask_gradientSkew = 0;
- else
- mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrStrokeSkew);
- qmatrix.shear(mask_gradientSkew, 0);
- qmatrix.translate(0, currItem->GrStrokeStartY * (1.0 - currItem->GrStrokeScale));
- qmatrix.translate(-currItem->GrStrokeStartX, -currItem->GrStrokeStartY);
- qmatrix.scale(1, currItem->GrStrokeScale);
- gradientFocal = qmatrix.map(QPointF(currItem->GrStrokeFocalX, currItem->GrStrokeFocalY));
- }
- else if (m_view->editStrokeGradient == 2)
- {
- gradientStart = QPointF(currItem->GrMaskStartX, currItem->GrMaskStartY);
- gradientEnd = QPointF(currItem->GrMaskEndX, currItem->GrMaskEndY);
- double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
- double rotEnd = xy2Deg(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
- QTransform m;
- m.translate(currItem->GrMaskStartX, currItem->GrMaskStartY);
- m.rotate(rotEnd);
- m.rotate(-90);
- m.rotate(currItem->GrMaskSkew);
- m.translate(radEnd * currItem->GrMaskScale, 0);
- gradientScale = m.map(QPointF(0,0));
- QTransform qmatrix;
- qmatrix.translate(currItem->GrMaskStartX, currItem->GrMaskStartY);
- qmatrix.rotate(rotEnd);
- double mask_gradientSkew = 0.0;
- if (currItem->GrMaskSkew == 90)
- mask_gradientSkew = 1;
- else if (currItem->GrMaskSkew == 180)
- mask_gradientSkew = 0;
- else if (currItem->GrMaskSkew == 270)
- mask_gradientSkew = -1;
- else if (currItem->GrMaskSkew == 390)
- mask_gradientSkew = 0;
- else
- mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrMaskSkew);
- qmatrix.shear(mask_gradientSkew, 0);
- qmatrix.translate(0, currItem->GrMaskStartY * (1.0 - currItem->GrMaskScale));
- qmatrix.translate(-currItem->GrMaskStartX, -currItem->GrMaskStartY);
- qmatrix.scale(1, currItem->GrMaskScale);
- gradientFocal = qmatrix.map(QPointF(currItem->GrMaskFocalX, currItem->GrMaskFocalY));
- }
- else if (m_view->editStrokeGradient == 0)
- {
- gradientStart = QPointF(currItem->GrStartX, currItem->GrStartY);
- gradientEnd = QPointF(currItem->GrEndX, currItem->GrEndY);
- double radEnd = distance(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
- double rotEnd = xy2Deg(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
- QTransform m;
- m.translate(currItem->GrStartX, currItem->GrStartY);
- m.rotate(rotEnd);
- m.rotate(-90);
- m.rotate(currItem->GrSkew);
- m.translate(radEnd * currItem->GrScale, 0);
- gradientScale = m.map(QPointF(0,0));
- QTransform qmatrix;
- qmatrix.translate(currItem->GrStartX, currItem->GrStartY);
- qmatrix.rotate(rotEnd);
- if (currItem->GrType != 13)
- {
- double mask_gradientSkew = 0.0;
- if (currItem->GrSkew == 90)
- mask_gradientSkew = 1;
- else if (currItem->GrSkew == 180)
- mask_gradientSkew = 0;
- else if (currItem->GrSkew == 270)
- mask_gradientSkew = -1;
- else if (currItem->GrSkew == 390)
- mask_gradientSkew = 0;
- else
- mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrSkew);
- qmatrix.shear(mask_gradientSkew, 0);
- }
- qmatrix.translate(0, currItem->GrStartY * (1.0 - currItem->GrScale));
- qmatrix.translate(-currItem->GrStartX, -currItem->GrStartY);
- qmatrix.scale(1, currItem->GrScale);
- gradientFocal = qmatrix.map(QPointF(currItem->GrFocalX, currItem->GrFocalY));
- }
- else if (m_view->editStrokeGradient == 3)
- {
- gradientStart = QPointF(currItem->GrControl1.x(), currItem->GrControl1.y());
- gradientEnd = QPointF(currItem->GrControl2.x(), currItem->GrControl2.y());
- gradientFocal = QPointF(currItem->GrControl3.x(), currItem->GrControl3.y());
- gradientScale = QPointF(currItem->GrControl4.x(), currItem->GrControl4.y());
- }
- else if (m_view->editStrokeGradient == 4)
- {
- gradientStart = QPointF(currItem->GrControl1.x(), currItem->GrControl1.y());
- gradientEnd = QPointF(currItem->GrControl2.x(), currItem->GrControl2.y());
- gradientFocal = QPointF(currItem->GrControl3.x(), currItem->GrControl3.y());
- gradientScale = QPointF(currItem->GrControl4.x(), currItem->GrControl4.y());
- gradientCenter = QPointF(currItem->GrControl5.x(), currItem->GrControl5.y());
- }
- gradientStart = itemMatrix.map(gradientStart);
- gradientEnd = itemMatrix.map(gradientEnd);
- gradientFocal = itemMatrix.map(gradientFocal);
- gradientScale = itemMatrix.map(gradientScale);
- gradientCenter = itemMatrix.map(gradientCenter);
- if (m_view->editStrokeGradient == 3)
- {
- if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientStart))
- m_gradientPoint = useControl1;
- else if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientEnd))
- m_gradientPoint = useControl2;
- else if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientFocal))
- m_gradientPoint = useControl3;
- else if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientScale))
- m_gradientPoint = useControl4;
- }
- else if (m_view->editStrokeGradient == 4)
- {
- if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientStart))
- m_gradientPoint = useControl1;
- else if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientEnd))
- m_gradientPoint = useControl2;
- else if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientFocal))
- m_gradientPoint = useControl3;
- else if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientScale))
- m_gradientPoint = useControl4;
- else if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientCenter))
- m_gradientPoint = useControl5;
- }
- else
- {
- if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientStart))
- m_gradientPoint = useGradientStart;
- else if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientEnd))
- m_gradientPoint = useGradientEnd;
- else if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientFocal))
- m_gradientPoint = useGradientFocal;
- else if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientScale))
- m_gradientPoint = useGradientSkew;
- }
- m_canvas->m_viewMode.m_MouseButtonPressed = true;
- if(m_gradientPoint != noPointDefined){
- OldGrStartX = currItem->gradientStartX();
- OldGrStartY = currItem->gradientStartY();
- OldGrEndX = currItem->gradientEndX();
- OldGrEndY = currItem->gradientEndY();
- OldGrFocalX = currItem->gradientFocalX();
- OldGrFocalY = currItem->gradientFocalY();
- OldGrScale = currItem->gradientScale();
- OldGrSkew = currItem->gradientSkew();
- OldGrControl1 = currItem->gradientControl1();
- OldGrControl2 = currItem->gradientControl2();
- OldGrControl3 = currItem->gradientControl3();
- OldGrControl4 = currItem->gradientControl4();
- OldGrControl5 = currItem->gradientControl5();
- OldGrStrokeStartX = currItem->gradientStrokeStartX();
- OldGrStrokeStartY = currItem->gradientStrokeStartY();
- OldGrStrokeEndX = currItem->gradientStrokeEndX();
- OldGrStrokeEndY = currItem->gradientStrokeEndY();
- OldGrStrokeFocalX = currItem->gradientStrokeFocalX();
- OldGrStrokeFocalY = currItem->gradientStrokeFocalY();
- OldGrStrokeScale = currItem->gradientStrokeScale();
- OldGrStrokeSkew = currItem->gradientStrokeSkew();
- OldGrMaskStartX = currItem->GrMaskStartX;
- OldGrMaskStartY = currItem->GrMaskStartY;
- OldGrMaskEndX = currItem->GrMaskEndX;
- OldGrMaskEndY = currItem->GrMaskEndY;
- OldGrMaskFocalX = currItem->GrMaskFocalX;
- OldGrMaskFocalY = currItem->GrMaskFocalY;
- OldGrMaskScale = currItem->GrMaskScale;
- OldGrMaskSkew = currItem->GrMaskSkew;
- }
- m_view->setCursor(QCursor(Qt::CrossCursor));
-}
-
-void CanvasMode_EditGradient::mouseReleaseEvent(QMouseEvent *m)
-{
-#ifdef GESTURE_FRAME_PREVIEW
- clearPixmapCache();
-#endif // GESTURE_FRAME_PREVIEW
- m_canvas->m_viewMode.m_MouseButtonPressed = false;
- m_canvas->resetRenderMode();
- m->accept();
- PageItem* currItem = m_doc->m_Selection->itemAt(0);
- if(m_gradientPoint != noPointDefined && UndoManager::undoEnabled()){
- QList<FPoint> tmp;
- ScItemState<QList<FPoint> > *is = new ScItemState<QList<FPoint> >(Um::GradPos + "i");
- is->set("GRAD_POS","grad_pos");
- is->set("OLDSTARTX",OldGrStartX);
- is->set("STARTX",currItem->gradientStartX());
- is->set("OLDSTARTY",OldGrStartY);
- is->set("STARTY",currItem->gradientStartY());
- is->set("OLDENDX",OldGrEndX);
- is->set("ENDX",currItem->gradientEndX());
- is->set("OLDENDY",OldGrEndY);
- is->set("ENDY",currItem->gradientEndY());
- is->set("OLDFOCALX",OldGrFocalX);
- is->set("FOCALX",currItem->gradientFocalX());
- is->set("OLDFOCALY",OldGrFocalY);
- is->set("FOCALY",currItem->gradientFocalY());
- is->set("OLDSCALE",OldGrScale);
- is->set("SCALE",currItem->gradientScale());
- is->set("OLDSKEW",OldGrSkew);
- is->set("SKEW",currItem->gradientSkew());
- tmp.append(OldGrControl1);
- tmp.append(currItem->gradientControl1());
- tmp.append(OldGrControl2);
- tmp.append(currItem->gradientControl2());
- tmp.append(OldGrControl3);
- tmp.append(currItem->gradientControl3());
- tmp.append(OldGrControl4);
- tmp.append(currItem->gradientControl4());
- tmp.append(OldGrControl5);
- tmp.append(currItem->gradientControl5());
- is->setItem(tmp);
- is->set("OLDSTROKESTARTX",OldGrStrokeStartX);
- is->set("STROKESTARTX",currItem->gradientStrokeStartX());
- is->set("OLDSTROKESTARTY",OldGrStrokeStartY);
- is->set("STROKESTARTY",currItem->gradientStrokeStartY());
- is->set("OLDSTROKEENDX",OldGrStrokeEndX);
- is->set("STROKEENDX",currItem->gradientStrokeEndX());
- is->set("OLDSTROKEENDY",OldGrStrokeEndY);
- is->set("STROKEENDY",currItem->gradientStrokeEndY());
- is->set("OLDSTROKEFOCALX",OldGrStrokeFocalX);
- is->set("STROKEFOCALX",currItem->gradientStrokeFocalX());
- is->set("OLDSTROKEFOCALY",OldGrStrokeFocalY);
- is->set("STROKEFOCALY",currItem->gradientStrokeFocalY());
- is->set("OLDSTROKESCALE",OldGrStrokeScale);
- is->set("STROKESCALE",currItem->gradientStrokeScale());
- is->set("OLDSTROKESKEW",OldGrStrokeSkew);
- is->set("STROKESKEW",currItem->gradientStrokeSkew());
- is->set("OLDMARKSTARTX",OldGrMaskStartX);
- is->set("MARKSTARTX",currItem->GrMaskStartX);
- is->set("OLDMARKSTARTY",OldGrMaskStartY);
- is->set("MARKSTARTY",currItem->GrMaskStartY);
- is->set("OLDMARKENDX",OldGrMaskEndX);
- is->set("MARKENDX",currItem->GrMaskEndX);
- is->set("OLDMARKENDY",OldGrMaskEndY);
- is->set("MARKENDY",currItem->GrMaskEndY);
- is->set("OLDMARKFOCALX",OldGrMaskFocalX);
- is->set("MARKFOCALX",currItem->GrMaskFocalX);
- is->set("OLDMARKFOCALY",OldGrMaskFocalY);
- is->set("MARKFOCALY",currItem->GrMaskFocalY);
- is->set("OLDMARKSCALE",OldGrMaskScale);
- is->set("MARKSCALE",currItem->GrMaskScale);
- is->set("OLDMARKSKEW",OldGrMaskSkew);
- is->set("MARKSKEW",currItem->GrMaskSkew);
- undoManager->action(currItem,is);
- }
- m_gradientPoint = noPointDefined;
-// m_view->stopDragTimer();
-}
+/*
+ For general Scribus (>=1.3.2) copyright and licensing information please refer
+ to the COPYING file provided with the program. Following this notice may exist
+ a copyright and/or license notice that predates the release of Scribus 1.3.2
+ for which a new license (GPL+exception) is in place.
+ */
+/***************************************************************************
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+***************************************************************************/
+
+
+#include "canvasmode_editgradient.h"
+
+#include <QApplication>
+#include <QButtonGroup>
+#include <QCheckBox>
+#include <QCursor>
+#include <QEvent>
+#include <QMessageBox>
+#include <QMouseEvent>
+#include <QPainterPath>
+#include <QPoint>
+#include <QRect>
+#include <QTimer>
+#include <QWidgetAction>
+#include <QDebug>
+
+#include "appmodes.h"
+#include "canvas.h"
+#include "fpoint.h"
+#include "fpointarray.h"
+#include "hyphenator.h"
+#include "pageitem_textframe.h"
+#include "prefscontext.h"
+#include "prefsfile.h"
+#include "prefsmanager.h"
+#include "scribus.h"
+#include "scribusXml.h"
+#include "scribusdoc.h"
+#include "scribusview.h"
+#include "selection.h"
+#include "ui/aligndistribute.h"
+#include "ui/contextmenu.h"
+#include "ui/pageselector.h"
+#include "ui/propertiespalette.h"
+#include "undomanager.h"
+#include "units.h"
+#include "util.h"
+#include "util_math.h"
+
+
+CanvasMode_EditGradient::CanvasMode_EditGradient(ScribusView* view) : CanvasMode(view), m_ScMW(view->m_ScMW)
+{
+ m_Mxp = m_Myp = -1;
+ m_gradientPoint = noPointDefined;
+}
+
+inline bool CanvasMode_EditGradient::GetItem(PageItem** pi)
+{
+ *pi = m_doc->m_Selection->itemAt(0);
+ return (*pi) != NULL;
+}
+
+void CanvasMode_EditGradient::drawControls(QPainter* p)
+{
+ if (m_canvas->m_viewMode.operItemMoving)
+ {
+ drawOutline(p);
+ }
+ else
+ {
+ drawSelection(p, false);
+ }
+ if (m_doc->appMode == modeEditGradientVectors)
+ {
+ drawControlsGradientVectors(p, m_doc->m_Selection->itemAt(0));
+ }
+}
+
+void CanvasMode_EditGradient::drawControlsGradientVectors(QPainter* psx, PageItem *currItem)
+{
+ psx->setTransform(currItem->getTransform(), true);
+ psx->setPen(QPen(Qt::blue, 1.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
+ psx->setBrush(Qt::NoBrush);
+ if (m_view->editStrokeGradient == 1)
+ {
+ psx->drawLine(QPointF(currItem->GrStrokeStartX, currItem->GrStrokeStartY), QPointF(currItem->GrStrokeEndX, currItem->GrStrokeEndY));
+ psx->setPen(QPen(Qt::magenta, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
+ psx->drawPoint(QPointF(currItem->GrStrokeStartX, currItem->GrStrokeStartY));
+ psx->drawPoint(QPointF(currItem->GrStrokeEndX, currItem->GrStrokeEndY));
+ double radEnd = distance(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
+ double rotEnd = xy2Deg(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
+ QTransform qmatrix;
+ qmatrix.translate(currItem->GrStrokeStartX, currItem->GrStrokeStartY);
+ qmatrix.rotate(rotEnd);
+ double mask_gradientSkew = 0.0;
+ if (currItem->GrStrokeSkew == 90)
+ mask_gradientSkew = 1;
+ else if (currItem->GrStrokeSkew == 180)
+ mask_gradientSkew = 0;
+ else if (currItem->GrStrokeSkew == 270)
+ mask_gradientSkew = -1;
+ else if (currItem->GrStrokeSkew == 390)
+ mask_gradientSkew = 0;
+ else
+ mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrStrokeSkew);
+ qmatrix.shear(mask_gradientSkew, 0);
+ qmatrix.translate(0, currItem->GrStrokeStartY * (1.0 - currItem->GrStrokeScale));
+ qmatrix.translate(-currItem->GrStrokeStartX, -currItem->GrStrokeStartY);
+ qmatrix.scale(1, currItem->GrStrokeScale);
+ if (currItem->GrTypeStroke == 7)
+ psx->drawPoint(qmatrix.map(QPointF(currItem->GrStrokeFocalX, currItem->GrStrokeFocalY)));
+ QTransform m;
+ m.translate(currItem->GrStrokeStartX, currItem->GrStrokeStartY);
+ m.rotate(rotEnd);
+ m.rotate(-90);
+ m.rotate(currItem->GrStrokeSkew);
+ m.translate(radEnd * currItem->GrStrokeScale, 0);
+ QPointF shP = m.map(QPointF(0,0));
+ psx->setPen(QPen(Qt::blue, 1.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
+ psx->drawLine(QPointF(currItem->GrStrokeStartX, currItem->GrStrokeStartY), shP);
+ psx->setPen(QPen(Qt::magenta, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
+ psx->drawPoint(shP);
+ }
+ else if (m_view->editStrokeGradient == 2)
+ {
+ psx->drawLine(QPointF(currItem->GrMaskStartX, currItem->GrMaskStartY), QPointF(currItem->GrMaskEndX, currItem->GrMaskEndY));
+ psx->setPen(QPen(Qt::magenta, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
+ psx->drawPoint(QPointF(currItem->GrMaskStartX, currItem->GrMaskStartY));
+ psx->drawPoint(QPointF(currItem->GrMaskEndX, currItem->GrMaskEndY));
+ double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
+ double rotEnd = xy2Deg(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
+ QTransform qmatrix;
+ qmatrix.translate(currItem->GrMaskStartX, currItem->GrMaskStartY);
+ qmatrix.rotate(rotEnd);
+ double mask_gradientSkew = 0.0;
+ if (currItem->GrMaskSkew == 90)
+ mask_gradientSkew = 1;
+ else if (currItem->GrMaskSkew == 180)
+ mask_gradientSkew = 0;
+ else if (currItem->GrMaskSkew == 270)
+ mask_gradientSkew = -1;
+ else if (currItem->GrMaskSkew == 390)
+ mask_gradientSkew = 0;
+ else
+ mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrMaskSkew);
+ qmatrix.shear(mask_gradientSkew, 0);
+ qmatrix.translate(0, currItem->GrMaskStartY * (1.0 - currItem->GrMaskScale));
+ qmatrix.translate(-currItem->GrMaskStartX, -currItem->GrMaskStartY);
+ qmatrix.scale(1, currItem->GrMaskScale);
+ if ((currItem->GrMask == 2) || (currItem->GrMask == 5))
+ psx->drawPoint(qmatrix.map(QPointF(currItem->GrMaskFocalX, currItem->GrMaskFocalY)));
+ QTransform m;
+ m.translate(currItem->GrMaskStartX, currItem->GrMaskStartY);
+ m.rotate(rotEnd);
+ m.rotate(-90);
+ m.rotate(currItem->GrMaskSkew);
+ m.translate(radEnd * currItem->GrMaskScale, 0);
+ QPointF shP = m.map(QPointF(0,0));
+ psx->setPen(QPen(Qt::blue, 1.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
+ psx->drawLine(QPointF(currItem->GrMaskStartX, currItem->GrMaskStartY), shP);
+ psx->setPen(QPen(Qt::magenta, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
+ psx->drawPoint(shP);
+ }
+ else if (m_view->editStrokeGradient == 0)
+ {
+ psx->drawLine(QPointF(currItem->GrStartX, currItem->GrStartY), QPointF(currItem->GrEndX, currItem->GrEndY));
+ psx->setPen(QPen(Qt::magenta, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
+ psx->drawPoint(QPointF(currItem->GrStartX, currItem->GrStartY));
+ psx->drawPoint(QPointF(currItem->GrEndX, currItem->GrEndY));
+ double radEnd = distance(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
+ double rotEnd = xy2Deg(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
+ QTransform qmatrix;
+ qmatrix.translate(currItem->GrStartX, currItem->GrStartY);
+ qmatrix.rotate(rotEnd);
+ if (currItem->GrType != 13)
+ {
+ double mask_gradientSkew = 0.0;
+ if (currItem->GrSkew == 90)
+ mask_gradientSkew = 1;
+ else if (currItem->GrSkew == 180)
+ mask_gradientSkew = 0;
+ else if (currItem->GrSkew == 270)
+ mask_gradientSkew = -1;
+ else if (currItem->GrSkew == 390)
+ mask_gradientSkew = 0;
+ else
+ mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrSkew);
+ qmatrix.shear(mask_gradientSkew, 0);
+ }
+ qmatrix.translate(0, currItem->GrStartY * (1.0 - currItem->GrScale));
+ qmatrix.translate(-currItem->GrStartX, -currItem->GrStartY);
+ qmatrix.scale(1, currItem->GrScale);
+ if ((currItem->GrType == 7) || (currItem->GrType == 13))
+ psx->drawPoint(qmatrix.map(QPointF(currItem->GrFocalX, currItem->GrFocalY)));
+ QTransform m;
+ m.translate(currItem->GrStartX, currItem->GrStartY);
+ m.rotate(rotEnd);
+ m.rotate(-90);
+ m.rotate(currItem->GrSkew);
+ m.translate(radEnd * currItem->GrScale, 0);
+ QPointF shP = m.map(QPointF(0,0));
+ psx->setPen(QPen(Qt::blue, 1.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
+ psx->drawLine(QPointF(currItem->GrStartX, currItem->GrStartY), shP);
+ psx->setPen(QPen(Qt::magenta, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
+ psx->drawPoint(shP);
+ }
+ else if (m_view->editStrokeGradient == 3)
+ {
+ psx->setPen(QPen(Qt::magenta, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
+ psx->drawPoint(QPointF(currItem->GrControl1.x(), currItem->GrControl1.y()));
+ psx->drawPoint(QPointF(currItem->GrControl2.x(), currItem->GrControl2.y()));
+ psx->drawPoint(QPointF(currItem->GrControl3.x(), currItem->GrControl3.y()));
+ psx->drawPoint(QPointF(currItem->GrControl4.x(), currItem->GrControl4.y()));
+ }
+ else if (m_view->editStrokeGradient == 4)
+ {
+ psx->setPen(QPen(Qt::magenta, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
+ psx->drawPoint(QPointF(currItem->GrControl1.x(), currItem->GrControl1.y()));
+ psx->drawPoint(QPointF(currItem->GrControl2.x(), currItem->GrControl2.y()));
+ psx->drawPoint(QPointF(currItem->GrControl3.x(), currItem->GrControl3.y()));
+ psx->drawPoint(QPointF(currItem->GrControl4.x(), currItem->GrControl4.y()));
+ psx->drawPoint(QPointF(currItem->GrControl5.x(), currItem->GrControl5.y()));
+ }
+}
+
+void CanvasMode_EditGradient::enterEvent(QEvent *)
+{
+ if (!m_canvas->m_viewMode.m_MouseButtonPressed)
+ {
+ setModeCursor();
+ }
+}
+
+void CanvasMode_EditGradient::leaveEvent(QEvent *e)
+{
+}
+
+
+void CanvasMode_EditGradient::activate(bool fromGesture)
+{
+// qDebug() << "CanvasMode_EditGradient::activate" << fromGesture;
+ m_canvas->m_viewMode.m_MouseButtonPressed = false;
+ m_canvas->resetRenderMode();
+ m_doc->DragP = false;
+ m_doc->leaveDrag = false;
+ m_canvas->m_viewMode.operItemMoving = false;
+ m_canvas->m_viewMode.operItemResizing = false;
+ m_view->MidButt = false;
+ m_Mxp = m_Myp = -1;
+ setModeCursor();
+ if (fromGesture)
+ {
+ m_view->update();
+ }
+}
+
+void CanvasMode_EditGradient::deactivate(bool forGesture)
+{
+// qDebug() << "CanvasMode_EditGradient::deactivate" << forGesture;
+ m_view->setRedrawMarkerShown(false);
+}
+
+void CanvasMode_EditGradient::mouseDoubleClickEvent(QMouseEvent *m)
+{
+ m->accept();
+ m_canvas->m_viewMode.m_MouseButtonPressed = false;
+ m_canvas->resetRenderMode();
+// m_view->stopDragTimer();
+ PageItem *currItem = 0;
+ if ((m_doc->m_Selection->isMultipleSelection()) || (m_doc->appMode != modeNormal))
+ {
+ if ((m_doc->m_Selection->isMultipleSelection()) && (m_doc->appMode == modeNormal))
+ {
+ if (GetItem(&currItem))
+ {
+ /* CB: old code, removing this as shift-alt select on an unselected table selects a cell now.
+ //#6789 is closed by sorting this.
+ if (currItem->isTableItem)
+ {
+ m_view->Deselect(false);
+ m_doc->m_Selection->addItem(currItem);
+ currItem->isSingleSel = true;
+ //CB FIXME dont call this if the added item is item 0
+ if (!m_doc->m_Selection->primarySelectionIs(currItem))
+ currItem->emitAllToGUI();
+ m_view->updateContents(currItem->getRedrawBounding(m_canvas->scale()));
+ }*/
+ }
+ return;
+ }
+ else
+ {
+ if (!(GetItem(&currItem) && (m_doc->appMode == modeEdit) && currItem->asTextFrame()))
+ {
+ mousePressEvent(m);
+ return;
+ }
+ }
+ }
+}
+
+
+void CanvasMode_EditGradient::mouseMoveEvent(QMouseEvent *m)
+{
+ const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
+ m->accept();
+ if (m_gradientPoint == noPointDefined)
+ return;
+
+ if (m_canvas->m_viewMode.m_MouseButtonPressed)
+ {
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ double newX = mousePointDoc.x(); //m->x();
+ double newY = mousePointDoc.y(); //m->y();
+ FPoint npx(m_Mxp - newX, m_Myp - newY, 0, 0, currItem->rotation(), 1, 1, true);
+ QPointF np = QPointF(npx.x(), npx.y());
+ if (m_view->editStrokeGradient == 1)
+ {
+ if (m_gradientPoint == useGradientStart)
+ {
+ currItem->GrStrokeStartX -= np.x(); // (Mxp - newX); // / m_canvas->scale();
+ currItem->GrStrokeStartY -= np.y(); // (Myp - newY); // / m_canvas->scale();
+ currItem->GrStrokeFocalX -= np.x();
+ currItem->GrStrokeFocalY -= np.y();
+ if (currItem->strokeGradientType() == 7)
+ {
+ double radEnd = distance(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
+ double radFoc = distance(currItem->GrStrokeFocalX - currItem->GrStrokeStartX, currItem->GrStrokeFocalY - currItem->GrStrokeStartY);
+ if (radFoc >= radEnd)
+ {
+ currItem->GrStrokeStartX += np.x(); // (Mxp - newX); // / m_canvas->scale();
+ currItem->GrStrokeStartY += np.y(); // (Myp - newY); // / m_canvas->scale();
+ currItem->GrStrokeFocalX += np.x(); // (Mxp - newX); // / m_canvas->scale();
+ currItem->GrStrokeFocalY += np.y(); // (Myp - newY); // / m_canvas->scale();
+ }
+ }
+ }
+ if (m_gradientPoint == useGradientFocal)
+ {
+ double rotEnd = xy2Deg(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
+ QTransform qmatrix;
+ qmatrix.translate(currItem->GrStrokeStartX, currItem->GrStrokeStartY);
+ qmatrix.rotate(rotEnd);
+ double mask_gradientSkew = 0.0;
+ if (currItem->GrStrokeSkew == 90)
+ mask_gradientSkew = 1;
+ else if (currItem->GrStrokeSkew == 180)
+ mask_gradientSkew = 0;
+ else if (currItem->GrStrokeSkew == 270)
+ mask_gradientSkew = -1;
+ else if (currItem->GrStrokeSkew == 390)
+ mask_gradientSkew = 0;
+ else
+ mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrStrokeSkew);
+ qmatrix.shear(mask_gradientSkew, 0);
+ qmatrix.translate(0, currItem->GrStrokeStartY * (1.0 - currItem->GrStrokeScale));
+ qmatrix.translate(-currItem->GrStrokeStartX, -currItem->GrStrokeStartY);
+ qmatrix.scale(1, currItem->GrStrokeScale);
+ QTransform m = qmatrix.inverted();
+ QPointF shR = qmatrix.map(QPointF(currItem->GrStrokeFocalX, currItem->GrStrokeFocalY));
+ QPointF shRe = m.map(shR - np);
+ currItem->GrStrokeFocalX = shRe.x();
+ currItem->GrStrokeFocalY = shRe.y();
+ if (currItem->strokeGradientType() == 7)
+ {
+ double radEnd = distance(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
+ double radFoc = distance(currItem->GrStrokeFocalX - currItem->GrStrokeStartX, currItem->GrStrokeFocalY - currItem->GrStrokeStartY);
+ if (radFoc >= radEnd)
+ {
+ QPointF shR = qmatrix.map(QPointF(currItem->GrStrokeFocalX, currItem->GrStrokeFocalY));
+ QPointF shRe = m.map(shR + np);
+ currItem->GrStrokeFocalX = shRe.x();
+ currItem->GrStrokeFocalY = shRe.y();
+ }
+ }
+ }
+ if (m_gradientPoint == useGradientSkew)
+ {
+ double radEnd = distance(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
+ double rotEnd = xy2Deg(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
+ QTransform m;
+ m.translate(currItem->GrStrokeStartX, currItem->GrStrokeStartY);
+ m.rotate(rotEnd);
+ m.rotate(-90);
+ m.rotate(currItem->GrStrokeSkew);
+ m.translate(radEnd * currItem->GrStrokeScale, 0);
+ QPointF shP = m.map(QPointF(0,0));
+ QPointF shR = QPointF(shP.x() -np.x(), shP.y() - np.y());
+ double radNew = distance(shR.x() - currItem->GrStrokeStartX, shR.y() - currItem->GrStrokeStartY);
+ double rotNew = xy2Deg(shR.x() - currItem->GrStrokeStartX, shR.y() - currItem->GrStrokeStartY) + 90;
+ currItem->GrStrokeSkew = rotNew - rotEnd;
+ double newScale = radNew / radEnd;
+ if ((newScale > 0) && (newScale <= 1))
+ currItem->GrStrokeScale = newScale;
+ }
+ if (m_gradientPoint == useGradientEnd)
+ {
+ currItem->GrStrokeEndX -= np.x(); // (Mxp - newX); // / m_canvas->scale();
+ currItem->GrStrokeEndY -= np.y(); // (Myp - newY); // / m_canvas->scale();
+ if (currItem->strokeGradientType() == 7)
+ {
+ double radEnd = distance(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
+ double radFoc = distance(currItem->GrStrokeFocalX - currItem->GrStrokeStartX, currItem->GrStrokeFocalY - currItem->GrStrokeStartY);
+ if (radFoc >= radEnd)
+ {
+ currItem->GrStrokeEndX += np.x(); // (Mxp - newX); // / m_canvas->scale();
+ currItem->GrStrokeEndY += np.y(); // (Myp - newY); // / m_canvas->scale();
+ }
+ }
+ }
+ }
+ else if (m_view->editStrokeGradient == 2)
+ {
+ if (m_gradientPoint == useGradientStart)
+ {
+ currItem->GrMaskStartX -= np.x();
+ currItem->GrMaskStartY -= np.y();
+ currItem->GrMaskFocalX -= np.x();
+ currItem->GrMaskFocalY -= np.y();
+ if ((currItem->GrMask == 2) || (currItem->GrMask == 5))
+ {
+ double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
+ double radFoc = distance(currItem->GrMaskFocalX - currItem->GrMaskStartX, currItem->GrMaskFocalY - currItem->GrMaskStartY);
+ if (radFoc >= radEnd)
+ {
+ currItem->GrMaskStartX += np.x(); // (Mxp - newX); // / m_canvas->scale();
+ currItem->GrMaskStartY += np.y(); // (Myp - newY); // / m_canvas->scale();
+ currItem->GrMaskFocalX += np.x(); // (Mxp - newX); // / m_canvas->scale();
+ currItem->GrMaskFocalY += np.y(); // (Myp - newY); // / m_canvas->scale();
+ }
+ }
+ }
+ if (m_gradientPoint == useGradientFocal)
+ {
+ double rotEnd = xy2Deg(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
+ QTransform qmatrix;
+ qmatrix.translate(currItem->GrMaskStartX, currItem->GrMaskStartY);
+ qmatrix.rotate(rotEnd);
+ double mask_gradientSkew = 0.0;
+ if (currItem->GrMaskSkew == 90)
+ mask_gradientSkew = 1;
+ else if (currItem->GrMaskSkew == 180)
+ mask_gradientSkew = 0;
+ else if (currItem->GrMaskSkew == 270)
+ mask_gradientSkew = -1;
+ else if (currItem->GrMaskSkew == 390)
+ mask_gradientSkew = 0;
+ else
+ mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrMaskSkew);
+ qmatrix.shear(mask_gradientSkew, 0);
+ qmatrix.translate(0, currItem->GrMaskStartY * (1.0 - currItem->GrMaskScale));
+ qmatrix.translate(-currItem->GrMaskStartX, -currItem->GrMaskStartY);
+ qmatrix.scale(1, currItem->GrMaskScale);
+ QTransform m = qmatrix.inverted();
+ QPointF shR = qmatrix.map(QPointF(currItem->GrMaskFocalX, currItem->GrMaskFocalY));
+ QPointF shRe = m.map(shR - np);
+ currItem->GrMaskFocalX = shRe.x();
+ currItem->GrMaskFocalY = shRe.y();
+ if ((currItem->GrMask == 2) || (currItem->GrMask == 5))
+ {
+ double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
+ double radFoc = distance(currItem->GrMaskFocalX - currItem->GrMaskStartX, currItem->GrMaskFocalY - currItem->GrMaskStartY);
+ if (radFoc >= radEnd)
+ {
+ QPointF shR = qmatrix.map(QPointF(currItem->GrMaskFocalX, currItem->GrMaskFocalY));
+ QPointF shRe = m.map(shR + np);
+ currItem->GrMaskFocalX = shRe.x();
+ currItem->GrMaskFocalY = shRe.y();
+ }
+ }
+ }
+ if (m_gradientPoint == useGradientSkew)
+ {
+ double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
+ double rotEnd = xy2Deg(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
+ QTransform m;
+ m.translate(currItem->GrMaskStartX, currItem->GrMaskStartY);
+ m.rotate(rotEnd);
+ m.rotate(-90);
+ m.rotate(currItem->GrMaskSkew);
+ m.translate(radEnd * currItem->GrMaskScale, 0);
+ QPointF shP = m.map(QPointF(0,0));
+ QPointF shR = QPointF(shP.x() -np.x(), shP.y() - np.y());
+ double radNew = distance(shR.x() - currItem->GrMaskStartX, shR.y() - currItem->GrMaskStartY);
+ double rotNew = xy2Deg(shR.x() - currItem->GrMaskStartX, shR.y() - currItem->GrMaskStartY) + 90;
+ currItem->GrMaskSkew = rotNew - rotEnd;
+ double newScale = radNew / radEnd;
+ if ((newScale > 0) && (newScale <= 1))
+ currItem->GrMaskScale = newScale;
+ }
+ if (m_gradientPoint == useGradientEnd)
+ {
+ currItem->GrMaskEndX -= np.x();
+ currItem->GrMaskEndY -= np.y();
+ if ((currItem->GrMask == 2) || (currItem->GrMask == 5))
+ {
+ double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
+ double radFoc = distance(currItem->GrMaskFocalX - currItem->GrMaskStartX, currItem->GrMaskFocalY - currItem->GrMaskStartY);
+ if (radFoc >= radEnd)
+ {
+ currItem->GrMaskEndX += np.x(); // (Mxp - newX); // / m_canvas->scale();
+ currItem->GrMaskEndY += np.y(); // (Myp - newY); // / m_canvas->scale();
+ }
+ }
+ }
+ }
+ else if (m_view->editStrokeGradient == 0)
+ {
+ if (m_gradientPoint == useGradientStart)
+ {
+ currItem->GrStartX -= np.x();
+ currItem->GrStartY -= np.y();
+ currItem->GrFocalX -= np.x();
+ currItem->GrFocalY -= np.y();
+ if ((currItem->gradientType() == 7) || (currItem->gradientType() == 13))
+ {
+ double radEnd = distance(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
+ double radFoc = distance(currItem->GrFocalX - currItem->GrStartX, currItem->GrFocalY - currItem->GrStartY);
+ if (radFoc >= radEnd)
+ {
+ currItem->GrStartX += np.x(); // (Mxp - newX); // / m_canvas->scale();
+ currItem->GrStartY += np.y(); // (Myp - newY); // / m_canvas->scale();
+ currItem->GrFocalX += np.x(); // (Mxp - newX); // / m_canvas->scale();
+ currItem->GrFocalY += np.y(); // (Myp - newY); // / m_canvas->scale();
+ }
+ }
+ }
+ if (m_gradientPoint == useGradientFocal)
+ {
+ double rotEnd = xy2Deg(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
+ QTransform qmatrix;
+ qmatrix.translate(currItem->GrStartX, currItem->GrStartY);
+ qmatrix.rotate(rotEnd);
+ if (currItem->GrType != 13)
+ {
+ double mask_gradientSkew = 0.0;
+ if (currItem->GrSkew == 90)
+ mask_gradientSkew = 1;
+ else if (currItem->GrSkew == 180)
+ mask_gradientSkew = 0;
+ else if (currItem->GrSkew == 270)
+ mask_gradientSkew = -1;
+ else if (currItem->GrSkew == 390)
+ mask_gradientSkew = 0;
+ else
+ mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrSkew);
+ qmatrix.shear(mask_gradientSkew, 0);
+ }
+ qmatrix.translate(0, currItem->GrStartY * (1.0 - currItem->GrScale));
+ qmatrix.translate(-currItem->GrStartX, -currItem->GrStartY);
+ qmatrix.scale(1, currItem->GrScale);
+ QTransform m = qmatrix.inverted();
+ QPointF shR = qmatrix.map(QPointF(currItem->GrFocalX, currItem->GrFocalY));
+ QPointF shRe = m.map(shR - np);
+ currItem->GrFocalX = shRe.x();
+ currItem->GrFocalY = shRe.y();
+ if ((currItem->GrType == 7) || (currItem->GrType == 13))
+ {
+ double radEnd = distance(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
+ double radFoc = distance(currItem->GrFocalX - currItem->GrStartX, currItem->GrFocalY - currItem->GrStartY);
+ if (radFoc >= radEnd)
+ {
+ QPointF shR = qmatrix.map(QPointF(currItem->GrFocalX, currItem->GrFocalY));
+ QPointF shRe = m.map(shR + np);
+ currItem->GrFocalX = shRe.x();
+ currItem->GrFocalY = shRe.y();
+ }
+ }
+ }
+ if (m_gradientPoint == useGradientSkew)
+ {
+ double radEnd = distance(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
+ double rotEnd = xy2Deg(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
+ QTransform m;
+ m.translate(currItem->GrStartX, currItem->GrStartY);
+ m.rotate(rotEnd);
+ m.rotate(-90);
+ if (currItem->GrType != 13)
+ m.rotate(currItem->GrSkew);
+ m.translate(radEnd * currItem->GrScale, 0);
+ QPointF shP = m.map(QPointF(0,0));
+ QPointF shR = QPointF(shP.x() -np.x(), shP.y() - np.y());
+ double radNew = distance(shR.x() - currItem->GrStartX, shR.y() - currItem->GrStartY);
+ double rotNew = xy2Deg(shR.x() - currItem->GrStartX, shR.y() - currItem->GrStartY) + 90;
+ if (currItem->GrType != 13)
+ currItem->GrSkew = rotNew - rotEnd;
+ else
+ currItem->GrSkew = 0;
+ double newScale = radNew / radEnd;
+ if ((newScale > 0) && (newScale <= 1))
+ currItem->GrScale = newScale;
+ }
+ if (m_gradientPoint == useGradientEnd)
+ {
+ currItem->GrEndX -= np.x();
+ currItem->GrEndY -= np.y();
+ if ((currItem->GrType == 7) || (currItem->GrType == 13))
+ {
+ double radEnd = distance(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
+ double radFoc = distance(currItem->GrFocalX - currItem->GrStartX, currItem->GrFocalY - currItem->GrStartY);
+ if (radFoc >= radEnd)
+ {
+ currItem->GrEndX += np.x(); // (Mxp - newX); // / m_canvas->scale();
+ currItem->GrEndY += np.y(); // (Myp - newY); // / m_canvas->scale();
+ }
+ }
+ }
+ }
+ else if (m_view->editStrokeGradient == 3)
+ {
+ if (m_gradientPoint == useControl1)
+ currItem->GrControl1 -= npx;
+ else if (m_gradientPoint == useControl2)
+ currItem->GrControl2 -= npx;
+ else if (m_gradientPoint == useControl3)
+ currItem->GrControl3 -= npx;
+ else if (m_gradientPoint == useControl4)
+ currItem->GrControl4 -= npx;
+ }
+ else if (m_view->editStrokeGradient == 4)
+ {
+ if (m_gradientPoint == useControl1)
+ currItem->GrControl1 -= npx;
+ else if (m_gradientPoint == useControl2)
+ currItem->GrControl2 -= npx;
+ else if (m_gradientPoint == useControl3)
+ currItem->GrControl3 -= npx;
+ else if (m_gradientPoint == useControl4)
+ currItem->GrControl4 -= npx;
+ else if (m_gradientPoint == useControl5)
+ currItem->GrControl5 -= npx;
+ }
+ m_Mxp = newX;
+ m_Myp = newY;
+// m_view->RefreshGradient(currItem, dx * m_canvas->scale(), dy * m_canvas->scale());
+ m_ScMW->propertiesPalette->updateColorSpecialGradient();
+ currItem->update();
+ QRectF upRect;
+ if (m_view->editStrokeGradient == 1)
+ {
+ upRect = QRectF(QPointF(currItem->GrStrokeStartX, currItem->GrStrokeStartY), QPointF(currItem->GrStrokeEndX, currItem->GrStrokeEndY));
+ double radEnd = distance(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
+ double rotEnd = xy2Deg(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
+ QTransform m;
+ m.translate(currItem->GrStrokeStartX, currItem->GrStrokeStartY);
+ m.rotate(rotEnd);
+ m.rotate(-90);
+ m.rotate(currItem->GrStrokeSkew);
+ m.translate(radEnd * currItem->GrStrokeScale, 0);
+ QPointF shP = m.map(QPointF(0,0));
+ upRect |= upRect.united(QRectF(shP, QPointF(currItem->GrStrokeEndX, currItem->GrStrokeEndY)).normalized());
+ upRect |= upRect.united(QRectF(shP, QPointF(currItem->GrStrokeStartX, currItem->GrStrokeStartY)).normalized());
+ upRect |= QRectF(shP, QPointF(0, 0)).normalized();
+ upRect |= QRectF(shP, QPointF(currItem->width(), currItem->height())).normalized();
+ }
+ else if (m_view->editStrokeGradient == 2)
+ {
+ upRect = QRectF(QPointF(currItem->GrMaskStartX, currItem->GrMaskStartY), QPointF(currItem->GrMaskEndX, currItem->GrMaskEndY));
+ double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
+ double rotEnd = xy2Deg(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
+ QTransform m;
+ m.translate(currItem->GrMaskStartX, currItem->GrMaskStartY);
+ m.rotate(rotEnd);
+ m.rotate(-90);
+ m.rotate(currItem->GrMaskSkew);
+ m.translate(radEnd * currItem->GrMaskScale, 0);
+ QPointF shP = m.map(QPointF(0,0));
+ upRect |= upRect.united(QRectF(shP, QPointF(currItem->GrMaskEndX, currItem->GrMaskEndY)).normalized());
+ upRect |= upRect.united(QRectF(shP, QPointF(currItem->GrMaskStartX, currItem->GrMaskStartY)).normalized());
+ upRect |= QRectF(shP, QPointF(0, 0)).normalized();
+ upRect |= QRectF(shP, QPointF(currItem->width(), currItem->height())).normalized();
+ }
+ else if (m_view->editStrokeGradient == 0)
+ {
+ upRect = QRectF(QPointF(currItem->GrStartX, currItem->GrStartY), QPointF(currItem->GrEndX, currItem->GrEndY));
+ double radEnd = distance(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
+ double rotEnd = xy2Deg(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
+ QTransform m;
+ m.translate(currItem->GrStartX, currItem->GrStartY);
+ m.rotate(rotEnd);
+ m.rotate(-90);
+ m.rotate(currItem->GrSkew);
+ m.translate(radEnd * currItem->GrScale, 0);
+ QPointF shP = m.map(QPointF(0,0));
+ upRect |= QRectF(shP, QPointF(currItem->GrEndX, currItem->GrEndY)).normalized();
+ upRect |= QRectF(shP, QPointF(currItem->GrStartX, currItem->GrStartY)).normalized();
+ upRect |= QRectF(shP, QPointF(0, 0)).normalized();
+ upRect |= QRectF(shP, QPointF(currItem->width(), currItem->height())).normalized();
+ }
+ else if ((m_view->editStrokeGradient == 3) || (m_view->editStrokeGradient == 4))
+ {
+ upRect = QRectF(QPointF(-currItem->width(), -currItem->height()), QPointF(currItem->width() * 2, currItem->height() * 2)).normalized();
+ }
+ QTransform itemMatrix = currItem->getTransform();
+ upRect = itemMatrix.mapRect(upRect);
+ if (currItem->GrType == 13)
+ currItem->createConicalMesh();
+ m_doc->regionsChanged()->update(upRect.adjusted(-10.0, -10.0, 10.0, 10.0));
+ }
+}
+
+void CanvasMode_EditGradient::mousePressEvent(QMouseEvent *m)
+{
+ const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
+
+ m_canvas->PaintSizeRect(QRect());
+ m_canvas->m_viewMode.m_MouseButtonPressed = true;
+ m_canvas->m_viewMode.operItemMoving = false;
+ m_view->HaveSelRect = false;
+ m_doc->DragP = false;
+ m_doc->leaveDrag = false;
+ m->accept();
+ m_view->registerMousePress(m->globalPos());
+ m_gradientPoint = noPointDefined;
+ m_Mxp = mousePointDoc.x(); //m->x();
+ m_Myp = mousePointDoc.y(); //m->y();
+ if (m->button() == Qt::MidButton)
+ {
+ m_view->MidButt = true;
+ if (m->modifiers() & Qt::ControlModifier)
+ m_view->DrawNew();
+ return;
+ }
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ QTransform itemMatrix = currItem->getTransform();
+ QPointF gradientStart, gradientEnd, gradientFocal, gradientScale, gradientCenter;
+ if (m_view->editStrokeGradient == 1)
+ {
+ gradientStart = QPointF(currItem->GrStrokeStartX, currItem->GrStrokeStartY);
+ gradientEnd = QPointF(currItem->GrStrokeEndX, currItem->GrStrokeEndY);
+ double radEnd = distance(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
+ double rotEnd = xy2Deg(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
+ QTransform m;
+ m.translate(currItem->GrStrokeStartX, currItem->GrStrokeStartY);
+ m.rotate(rotEnd);
+ m.rotate(-90);
+ m.rotate(currItem->GrStrokeSkew);
+ m.translate(radEnd * currItem->GrStrokeScale, 0);
+ gradientScale = m.map(QPointF(0,0));
+ QTransform qmatrix;
+ qmatrix.translate(currItem->GrStrokeStartX, currItem->GrStrokeStartY);
+ qmatrix.rotate(rotEnd);
+ double mask_gradientSkew = 0.0;
+ if (currItem->GrStrokeSkew == 90)
+ mask_gradientSkew = 1;
+ else if (currItem->GrStrokeSkew == 180)
+ mask_gradientSkew = 0;
+ else if (currItem->GrStrokeSkew == 270)
+ mask_gradientSkew = -1;
+ else if (currItem->GrStrokeSkew == 390)
+ mask_gradientSkew = 0;
+ else
+ mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrStrokeSkew);
+ qmatrix.shear(mask_gradientSkew, 0);
+ qmatrix.translate(0, currItem->GrStrokeStartY * (1.0 - currItem->GrStrokeScale));
+ qmatrix.translate(-currItem->GrStrokeStartX, -currItem->GrStrokeStartY);
+ qmatrix.scale(1, currItem->GrStrokeScale);
+ gradientFocal = qmatrix.map(QPointF(currItem->GrStrokeFocalX, currItem->GrStrokeFocalY));
+ }
+ else if (m_view->editStrokeGradient == 2)
+ {
+ gradientStart = QPointF(currItem->GrMaskStartX, currItem->GrMaskStartY);
+ gradientEnd = QPointF(currItem->GrMaskEndX, currItem->GrMaskEndY);
+ double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
+ double rotEnd = xy2Deg(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
+ QTransform m;
+ m.translate(currItem->GrMaskStartX, currItem->GrMaskStartY);
+ m.rotate(rotEnd);
+ m.rotate(-90);
+ m.rotate(currItem->GrMaskSkew);
+ m.translate(radEnd * currItem->GrMaskScale, 0);
+ gradientScale = m.map(QPointF(0,0));
+ QTransform qmatrix;
+ qmatrix.translate(currItem->GrMaskStartX, currItem->GrMaskStartY);
+ qmatrix.rotate(rotEnd);
+ double mask_gradientSkew = 0.0;
+ if (currItem->GrMaskSkew == 90)
+ mask_gradientSkew = 1;
+ else if (currItem->GrMaskSkew == 180)
+ mask_gradientSkew = 0;
+ else if (currItem->GrMaskSkew == 270)
+ mask_gradientSkew = -1;
+ else if (currItem->GrMaskSkew == 390)
+ mask_gradientSkew = 0;
+ else
+ mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrMaskSkew);
+ qmatrix.shear(mask_gradientSkew, 0);
+ qmatrix.translate(0, currItem->GrMaskStartY * (1.0 - currItem->GrMaskScale));
+ qmatrix.translate(-currItem->GrMaskStartX, -currItem->GrMaskStartY);
+ qmatrix.scale(1, currItem->GrMaskScale);
+ gradientFocal = qmatrix.map(QPointF(currItem->GrMaskFocalX, currItem->GrMaskFocalY));
+ }
+ else if (m_view->editStrokeGradient == 0)
+ {
+ gradientStart = QPointF(currItem->GrStartX, currItem->GrStartY);
+ gradientEnd = QPointF(currItem->GrEndX, currItem->GrEndY);
+ double radEnd = distance(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
+ double rotEnd = xy2Deg(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
+ QTransform m;
+ m.translate(currItem->GrStartX, currItem->GrStartY);
+ m.rotate(rotEnd);
+ m.rotate(-90);
+ m.rotate(currItem->GrSkew);
+ m.translate(radEnd * currItem->GrScale, 0);
+ gradientScale = m.map(QPointF(0,0));
+ QTransform qmatrix;
+ qmatrix.translate(currItem->GrStartX, currItem->GrStartY);
+ qmatrix.rotate(rotEnd);
+ if (currItem->GrType != 13)
+ {
+ double mask_gradientSkew = 0.0;
+ if (currItem->GrSkew == 90)
+ mask_gradientSkew = 1;
+ else if (currItem->GrSkew == 180)
+ mask_gradientSkew = 0;
+ else if (currItem->GrSkew == 270)
+ mask_gradientSkew = -1;
+ else if (currItem->GrSkew == 390)
+ mask_gradientSkew = 0;
+ else
+ mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrSkew);
+ qmatrix.shear(mask_gradientSkew, 0);
+ }
+ qmatrix.translate(0, currItem->GrStartY * (1.0 - currItem->GrScale));
+ qmatrix.translate(-currItem->GrStartX, -currItem->GrStartY);
+ qmatrix.scale(1, currItem->GrScale);
+ gradientFocal = qmatrix.map(QPointF(currItem->GrFocalX, currItem->GrFocalY));
+ }
+ else if (m_view->editStrokeGradient == 3)
+ {
+ gradientStart = QPointF(currItem->GrControl1.x(), currItem->GrControl1.y());
+ gradientEnd = QPointF(currItem->GrControl2.x(), currItem->GrControl2.y());
+ gradientFocal = QPointF(currItem->GrControl3.x(), currItem->GrControl3.y());
+ gradientScale = QPointF(currItem->GrControl4.x(), currItem->GrControl4.y());
+ }
+ else if (m_view->editStrokeGradient == 4)
+ {
+ gradientStart = QPointF(currItem->GrControl1.x(), currItem->GrControl1.y());
+ gradientEnd = QPointF(currItem->GrControl2.x(), currItem->GrControl2.y());
+ gradientFocal = QPointF(currItem->GrControl3.x(), currItem->GrControl3.y());
+ gradientScale = QPointF(currItem->GrControl4.x(), currItem->GrControl4.y());
+ gradientCenter = QPointF(currItem->GrControl5.x(), currItem->GrControl5.y());
+ }
+ gradientStart = itemMatrix.map(gradientStart);
+ gradientEnd = itemMatrix.map(gradientEnd);
+ gradientFocal = itemMatrix.map(gradientFocal);
+ gradientScale = itemMatrix.map(gradientScale);
+ gradientCenter = itemMatrix.map(gradientCenter);
+ if (m_view->editStrokeGradient == 3)
+ {
+ if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientStart))
+ m_gradientPoint = useControl1;
+ else if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientEnd))
+ m_gradientPoint = useControl2;
+ else if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientFocal))
+ m_gradientPoint = useControl3;
+ else if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientScale))
+ m_gradientPoint = useControl4;
+ }
+ else if (m_view->editStrokeGradient == 4)
+ {
+ if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientStart))
+ m_gradientPoint = useControl1;
+ else if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientEnd))
+ m_gradientPoint = useControl2;
+ else if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientFocal))
+ m_gradientPoint = useControl3;
+ else if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientScale))
+ m_gradientPoint = useControl4;
+ else if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientCenter))
+ m_gradientPoint = useControl5;
+ }
+ else
+ {
+ if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientStart))
+ m_gradientPoint = useGradientStart;
+ else if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientEnd))
+ m_gradientPoint = useGradientEnd;
+ else if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientFocal))
+ m_gradientPoint = useGradientFocal;
+ else if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientScale))
+ m_gradientPoint = useGradientSkew;
+ }
+ m_canvas->m_viewMode.m_MouseButtonPressed = true;
+ if(m_gradientPoint != noPointDefined){
+ OldGrStartX = currItem->gradientStartX();
+ OldGrStartY = currItem->gradientStartY();
+ OldGrEndX = currItem->gradientEndX();
+ OldGrEndY = currItem->gradientEndY();
+ OldGrFocalX = currItem->gradientFocalX();
+ OldGrFocalY = currItem->gradientFocalY();
+ OldGrScale = currItem->gradientScale();
+ OldGrSkew = currItem->gradientSkew();
+ OldGrControl1 = currItem->gradientControl1();
+ OldGrControl2 = currItem->gradientControl2();
+ OldGrControl3 = currItem->gradientControl3();
+ OldGrControl4 = currItem->gradientControl4();
+ OldGrControl5 = currItem->gradientControl5();
+ OldGrStrokeStartX = currItem->gradientStrokeStartX();
+ OldGrStrokeStartY = currItem->gradientStrokeStartY();
+ OldGrStrokeEndX = currItem->gradientStrokeEndX();
+ OldGrStrokeEndY = currItem->gradientStrokeEndY();
+ OldGrStrokeFocalX = currItem->gradientStrokeFocalX();
+ OldGrStrokeFocalY = currItem->gradientStrokeFocalY();
+ OldGrStrokeScale = currItem->gradientStrokeScale();
+ OldGrStrokeSkew = currItem->gradientStrokeSkew();
+ OldGrMaskStartX = currItem->GrMaskStartX;
+ OldGrMaskStartY = currItem->GrMaskStartY;
+ OldGrMaskEndX = currItem->GrMaskEndX;
+ OldGrMaskEndY = currItem->GrMaskEndY;
+ OldGrMaskFocalX = currItem->GrMaskFocalX;
+ OldGrMaskFocalY = currItem->GrMaskFocalY;
+ OldGrMaskScale = currItem->GrMaskScale;
+ OldGrMaskSkew = currItem->GrMaskSkew;
+ }
+ m_view->setCursor(QCursor(Qt::CrossCursor));
+}
+
+void CanvasMode_EditGradient::mouseReleaseEvent(QMouseEvent *m)
+{
+#ifdef GESTURE_FRAME_PREVIEW
+ clearPixmapCache();
+#endif // GESTURE_FRAME_PREVIEW
+ m_canvas->m_viewMode.m_MouseButtonPressed = false;
+ m_canvas->resetRenderMode();
+ m->accept();
+ PageItem* currItem = m_doc->m_Selection->itemAt(0);
+ if(m_gradientPoint != noPointDefined && UndoManager::undoEnabled()){
+ QList<FPoint> tmp;
+ ScItemState<QList<FPoint> > *is = new ScItemState<QList<FPoint> >(Um::GradPos + "i");
+ is->set("GRAD_POS","grad_pos");
+ is->set("OLDSTARTX",OldGrStartX);
+ is->set("STARTX",currItem->gradientStartX());
+ is->set("OLDSTARTY",OldGrStartY);
+ is->set("STARTY",currItem->gradientStartY());
+ is->set("OLDENDX",OldGrEndX);
+ is->set("ENDX",currItem->gradientEndX());
+ is->set("OLDENDY",OldGrEndY);
+ is->set("ENDY",currItem->gradientEndY());
+ is->set("OLDFOCALX",OldGrFocalX);
+ is->set("FOCALX",currItem->gradientFocalX());
+ is->set("OLDFOCALY",OldGrFocalY);
+ is->set("FOCALY",currItem->gradientFocalY());
+ is->set("OLDSCALE",OldGrScale);
+ is->set("SCALE",currItem->gradientScale());
+ is->set("OLDSKEW",OldGrSkew);
+ is->set("SKEW",currItem->gradientSkew());
+ tmp.append(OldGrControl1);
+ tmp.append(currItem->gradientControl1());
+ tmp.append(OldGrControl2);
+ tmp.append(currItem->gradientControl2());
+ tmp.append(OldGrControl3);
+ tmp.append(currItem->gradientControl3());
+ tmp.append(OldGrControl4);
+ tmp.append(currItem->gradientControl4());
+ tmp.append(OldGrControl5);
+ tmp.append(currItem->gradientControl5());
+ is->setItem(tmp);
+ is->set("OLDSTROKESTARTX",OldGrStrokeStartX);
+ is->set("STROKESTARTX",currItem->gradientStrokeStartX());
+ is->set("OLDSTROKESTARTY",OldGrStrokeStartY);
+ is->set("STROKESTARTY",currItem->gradientStrokeStartY());
+ is->set("OLDSTROKEENDX",OldGrStrokeEndX);
+ is->set("STROKEENDX",currItem->gradientStrokeEndX());
+ is->set("OLDSTROKEENDY",OldGrStrokeEndY);
+ is->set("STROKEENDY",currItem->gradientStrokeEndY());
+ is->set("OLDSTROKEFOCALX",OldGrStrokeFocalX);
+ is->set("STROKEFOCALX",currItem->gradientStrokeFocalX());
+ is->set("OLDSTROKEFOCALY",OldGrStrokeFocalY);
+ is->set("STROKEFOCALY",currItem->gradientStrokeFocalY());
+ is->set("OLDSTROKESCALE",OldGrStrokeScale);
+ is->set("STROKESCALE",currItem->gradientStrokeScale());
+ is->set("OLDSTROKESKEW",OldGrStrokeSkew);
+ is->set("STROKESKEW",currItem->gradientStrokeSkew());
+ is->set("OLDMARKSTARTX",OldGrMaskStartX);
+ is->set("MARKSTARTX",currItem->GrMaskStartX);
+ is->set("OLDMARKSTARTY",OldGrMaskStartY);
+ is->set("MARKSTARTY",currItem->GrMaskStartY);
+ is->set("OLDMARKENDX",OldGrMaskEndX);
+ is->set("MARKENDX",currItem->GrMaskEndX);
+ is->set("OLDMARKENDY",OldGrMaskEndY);
+ is->set("MARKENDY",currItem->GrMaskEndY);
+ is->set("OLDMARKFOCALX",OldGrMaskFocalX);
+ is->set("MARKFOCALX",currItem->GrMaskFocalX);
+ is->set("OLDMARKFOCALY",OldGrMaskFocalY);
+ is->set("MARKFOCALY",currItem->GrMaskFocalY);
+ is->set("OLDMARKSCALE",OldGrMaskScale);
+ is->set("MARKSCALE",currItem->GrMaskScale);
+ is->set("OLDMARKSKEW",OldGrMaskSkew);
+ is->set("MARKSKEW",currItem->GrMaskSkew);
+ undoManager->action(currItem,is);
+ }
+ m_gradientPoint = noPointDefined;
+// m_view->stopDragTimer();
+}
Modified: trunk/Scribus/scribus/canvasmode_editgradient.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_editgradient.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editgradient.h (original)
+++ trunk/Scribus/scribus/canvasmode_editgradient.h Fri Nov 27 23:35:43 2015
@@ -1,108 +1,108 @@
-/*
- For general Scribus (>=1.3.2) copyright and licensing information please refer
- to the COPYING file provided with the program. Following this notice may exist
- a copyright and/or license notice that predates the release of Scribus 1.3.2
- for which a new license (GPL+exception) is in place.
- */
-/***************************************************************************
-* *
-* This program is free software; you can redistribute it and/or modify *
-* it under the terms of the GNU General Public License as published by *
-* the Free Software Foundation; either version 2 of the License, or *
-* (at your option) any later version. *
-* *
-***************************************************************************/
-
-
-
-#ifndef CANVAS_MODE_EDITGRADIENT_H
-#define CANVAS_MODE_EDITGRADIENT_H
-
-#include <QObject>
-#include <QTime>
-
-#include "canvasmode.h"
-#include "fpointarray.h"
-
-class PageItem;
-class PageItem_TextFrame;
-class ScribusMainWindow;
-class ScribusView;
-
-
-// This class encapsulate the old code for mouse interaction from scribusview.cpp
-
-class CanvasMode_EditGradient : public CanvasMode
-{
-public:
- explicit CanvasMode_EditGradient(ScribusView* view);
- virtual ~CanvasMode_EditGradient() {}
-
- virtual void enterEvent(QEvent *);
- virtual void leaveEvent(QEvent *);
-
- virtual void activate(bool);
- virtual void deactivate(bool);
- virtual void mouseDoubleClickEvent(QMouseEvent *m);
- virtual void mouseReleaseEvent(QMouseEvent *m);
- virtual void mouseMoveEvent(QMouseEvent *m);
- virtual void mousePressEvent(QMouseEvent *m);
- virtual void drawControls(QPainter* p);
- void drawControlsGradientVectors(QPainter* psx, PageItem *currItem);
-
-private:
-
- typedef enum
- {
- noPointDefined,
- useGradientStart,
- useGradientEnd,
- useGradientFocal,
- useGradientSkew,
- useControl1,
- useControl2,
- useControl3,
- useControl4,
- useControl5
- } eGradientPoint;
-
- inline bool GetItem(PageItem** pi);
-
- double Mxp, Myp;
- ScribusMainWindow* m_ScMW;
- eGradientPoint m_gradientPoint;
-
- //save of previous state
- double OldGrStartX;
- double OldGrStartY;
- double OldGrEndX;
- double OldGrEndY;
- double OldGrFocalX;
- double OldGrFocalY;
- double OldGrScale;
- double OldGrSkew;
- FPoint OldGrControl1;
- FPoint OldGrControl2;
- FPoint OldGrControl3;
- FPoint OldGrControl4;
- FPoint OldGrControl5;
- double OldGrStrokeStartX;
- double OldGrStrokeStartY;
- double OldGrStrokeEndX;
- double OldGrStrokeEndY;
- double OldGrStrokeFocalX;
- double OldGrStrokeFocalY;
- double OldGrStrokeScale;
- double OldGrStrokeSkew;
- double OldGrMaskStartX;
- double OldGrMaskStartY;
- double OldGrMaskEndX;
- double OldGrMaskEndY;
- double OldGrMaskFocalX;
- double OldGrMaskFocalY;
- double OldGrMaskScale;
- double OldGrMaskSkew;
-};
-
-
-#endif
+/*
+ For general Scribus (>=1.3.2) copyright and licensing information please refer
+ to the COPYING file provided with the program. Following this notice may exist
+ a copyright and/or license notice that predates the release of Scribus 1.3.2
+ for which a new license (GPL+exception) is in place.
+ */
+/***************************************************************************
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+***************************************************************************/
+
+
+
+#ifndef CANVAS_MODE_EDITGRADIENT_H
+#define CANVAS_MODE_EDITGRADIENT_H
+
+#include <QObject>
+#include <QTime>
+
+#include "canvasmode.h"
+#include "fpointarray.h"
+
+class PageItem;
+class PageItem_TextFrame;
+class ScribusMainWindow;
+class ScribusView;
+
+
+// This class encapsulate the old code for mouse interaction from scribusview.cpp
+
+class CanvasMode_EditGradient : public CanvasMode
+{
+public:
+ explicit CanvasMode_EditGradient(ScribusView* view);
+ virtual ~CanvasMode_EditGradient() {}
+
+ virtual void enterEvent(QEvent *);
+ virtual void leaveEvent(QEvent *);
+
+ virtual void activate(bool);
+ virtual void deactivate(bool);
+ virtual void mouseDoubleClickEvent(QMouseEvent *m);
+ virtual void mouseReleaseEvent(QMouseEvent *m);
+ virtual void mouseMoveEvent(QMouseEvent *m);
+ virtual void mousePressEvent(QMouseEvent *m);
+ virtual void drawControls(QPainter* p);
+ void drawControlsGradientVectors(QPainter* psx, PageItem *currItem);
+
+private:
+
+ typedef enum
+ {
+ noPointDefined,
+ useGradientStart,
+ useGradientEnd,
+ useGradientFocal,
+ useGradientSkew,
+ useControl1,
+ useControl2,
+ useControl3,
+ useControl4,
+ useControl5
+ } eGradientPoint;
+
+ inline bool GetItem(PageItem** pi);
+
+ double m_Mxp, m_Myp;
+ ScribusMainWindow* m_ScMW;
+ eGradientPoint m_gradientPoint;
+
+ //save of previous state
+ double OldGrStartX;
+ double OldGrStartY;
+ double OldGrEndX;
+ double OldGrEndY;
+ double OldGrFocalX;
+ double OldGrFocalY;
+ double OldGrScale;
+ double OldGrSkew;
+ FPoint OldGrControl1;
+ FPoint OldGrControl2;
+ FPoint OldGrControl3;
+ FPoint OldGrControl4;
+ FPoint OldGrControl5;
+ double OldGrStrokeStartX;
+ double OldGrStrokeStartY;
+ double OldGrStrokeEndX;
+ double OldGrStrokeEndY;
+ double OldGrStrokeFocalX;
+ double OldGrStrokeFocalY;
+ double OldGrStrokeScale;
+ double OldGrStrokeSkew;
+ double OldGrMaskStartX;
+ double OldGrMaskStartY;
+ double OldGrMaskEndX;
+ double OldGrMaskEndY;
+ double OldGrMaskFocalX;
+ double OldGrMaskFocalY;
+ double OldGrMaskScale;
+ double OldGrMaskSkew;
+};
+
+
+#endif
Modified: trunk/Scribus/scribus/canvasmode_editmeshgradient.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_editmeshgradient.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editmeshgradient.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_editmeshgradient.cpp Fri Nov 27 23:35:43 2015
@@ -1,994 +1,994 @@
-/*
- For general Scribus (>=1.3.2) copyright and licensing information please refer
- to the COPYING file provided with the program. Following this notice may exist
- a copyright and/or license notice that predates the release of Scribus 1.3.2
- for which a new license (GPL+exception) is in place.
- */
-/***************************************************************************
-* *
-* This program is free software; you can redistribute it and/or modify *
-* it under the terms of the GNU General Public License as published by *
-* the Free Software Foundation; either version 2 of the License, or *
-* (at your option) any later version. *
-* *
-***************************************************************************/
-/***************************************************************************
- canvasmode_editmeshgradient.cpp - description
- -------------------
- begin : Sat Apr 24 2010
- copyright : (C) 2010 by Franz Schmid
- email : Franz.Schmid at altmuehlnet.de
- ***************************************************************************/
-
-
-#include "canvasmode_editmeshgradient.h"
-
-#include <QApplication>
-#include <QButtonGroup>
-#include <QCheckBox>
-#include <QCursor>
-#include <QEvent>
-#include <QMessageBox>
-#include <QMouseEvent>
-#include <QPainterPath>
-#include <QPoint>
-#include <QRect>
-#include <QTimer>
-#include <QWidgetAction>
-#include <QDebug>
-
-#include "appmodes.h"
-#include "canvas.h"
-#include "fpoint.h"
-#include "fpointarray.h"
-#include "hyphenator.h"
-#include "pageitem_textframe.h"
-#include "prefscontext.h"
-#include "prefsfile.h"
-#include "prefsmanager.h"
-#include "scribus.h"
-#include "scribusXml.h"
-#include "scribusdoc.h"
-#include "scribusview.h"
-#include "selection.h"
-#include "ui/aligndistribute.h"
-#include "ui/contextmenu.h"
-#include "ui/pageselector.h"
-#include "ui/propertiespalette.h"
-#include "undomanager.h"
-#include "units.h"
-#include "util.h"
-#include "util_math.h"
-
-
-CanvasMode_EditMeshGradient::CanvasMode_EditMeshGradient(ScribusView* view) : CanvasMode(view), m_ScMW(view->m_ScMW)
-{
- Mxp = Myp = -1;
- selectedMeshPoints.clear();
- m_gradientPoint = noPointDefined;
- old_mesh = new meshPoint();
-}
-
-CanvasMode_EditMeshGradient::~CanvasMode_EditMeshGradient()
-{
- delete old_mesh;
- old_mesh = NULL;
-}
-
-inline bool CanvasMode_EditMeshGradient::GetItem(PageItem** pi)
-{
- *pi = m_doc->m_Selection->itemAt(0);
- return (*pi) != NULL;
-}
-
-void CanvasMode_EditMeshGradient::drawControls(QPainter* p)
-{
- p->save();
- if (m_canvas->m_viewMode.operItemMoving)
- {
- drawOutline(p);
- }
- else
- {
- drawSelection(p, false);
- }
- if (m_doc->appMode == modeEditMeshGradient)
- {
- drawControlsMeshGradient(p, m_doc->m_Selection->itemAt(0));
- }
- p->restore();
-}
-
-void CanvasMode_EditMeshGradient::drawControlsMeshGradient(QPainter* psx, PageItem* currItem)
-{
- QPen p1b = QPen(Qt::blue, 1.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
- QPen p1bd = QPen(Qt::blue, 1.0 / m_canvas->m_viewMode.scale, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin);
- QPen p8b = QPen(Qt::blue, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin);
- QPen p8r = QPen(Qt::red, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin);
- QPen p8m = QPen(Qt::magenta, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin);
- QPen p14r = QPen(Qt::red, 18.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin);
- QPen p14w = QPen(Qt::white, 18.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin);
- psx->setTransform(currItem->getTransform(), true);
- psx->setPen(p1b);
- psx->setBrush(Qt::NoBrush);
- for (int grow = 0; grow < currItem->meshGradientArray.count()-1; grow++)
- {
- for (int gcol = 0; gcol < currItem->meshGradientArray[grow].count()-1; gcol++)
- {
- meshPoint mp1 = currItem->meshGradientArray[grow][gcol];
- meshPoint mp2 = currItem->meshGradientArray[grow][gcol+1];
- meshPoint mp3 = currItem->meshGradientArray[grow+1][gcol+1];
- meshPoint mp4 = currItem->meshGradientArray[grow+1][gcol];
- QPainterPath Bez;
- Bez.moveTo(mp1.gridPoint.x(), mp1.gridPoint.y());
- Bez.cubicTo(mp1.controlRight.x(), mp1.controlRight.y(), mp2.controlLeft.x(), mp2.controlLeft.y(), mp2.gridPoint.x(), mp2.gridPoint.y());
- Bez.cubicTo(mp2.controlBottom.x(), mp2.controlBottom.y(), mp3.controlTop.x(), mp3.controlTop.y(), mp3.gridPoint.x(), mp3.gridPoint.y());
- Bez.cubicTo(mp3.controlLeft.x(), mp3.controlLeft.y(), mp4.controlRight.x(), mp4.controlRight.y(), mp4.gridPoint.x(), mp4.gridPoint.y());
- Bez.cubicTo(mp4.controlTop.x(), mp4.controlTop.y(), mp1.controlBottom.x(), mp1.controlBottom.y(), mp1.gridPoint.x(), mp1.gridPoint.y());
- psx->setPen(p1b);
- psx->drawPath(Bez);
- }
- }
- for (int grow = 0; grow < currItem->meshGradientArray.count(); grow++)
- {
- for (int gcol = 0; gcol < currItem->meshGradientArray[grow].count(); gcol++)
- {
- bool isSelected = false;
- for (int se = 0; se < selectedMeshPoints.count(); se++)
- {
- if ((grow == selectedMeshPoints[se].first) && (gcol == selectedMeshPoints[se].second))
- {
- isSelected = true;
- break;
- }
- }
- meshPoint mp1 = currItem->meshGradientArray[grow][gcol];
- if (m_view->editStrokeGradient == 5)
- {
- if (isSelected)
- psx->setPen(p8r);
- else
- psx->setPen(p8m);
- psx->drawPoint(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()));
- }
- else if (m_view->editStrokeGradient == 6)
- {
- if (isSelected)
- psx->setPen(p14r);
- else
- psx->setPen(p14w);
- psx->drawPoint(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()));
- psx->setPen(QPen(mp1.color, 14.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
- psx->drawPoint(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()));
- if (isSelected)
- psx->setPen(p8r);
- else
- psx->setPen(p8m);
- psx->drawPoint(QPointF(mp1.controlColor.x(), mp1.controlColor.y()));
- }
- else if (m_view->editStrokeGradient == 7)
- {
- psx->setPen(p8b);
- psx->drawPoint(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()));
- }
- }
- }
- if ((selectedMeshPoints.count() > 0) && (m_view->editStrokeGradient == 7))
- {
- int grow = selectedMeshPoints[0].first;
- int gcol = selectedMeshPoints[0].second;
- meshPoint mp1 = currItem->meshGradientArray[grow][gcol];
- psx->setPen(p8m);
- if (grow == 0)
- {
- if (gcol == 0)
- {
- psx->setPen(p1bd);
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlR)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlB)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
- }
- else if (gcol == currItem->meshGradientArray[grow].count()-1)
- {
- psx->setPen(p1bd);
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlL)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlB)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
- }
- else
- {
- psx->setPen(p1bd);
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlL)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlB)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
- if (m_gradientPoint == useControlR)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
- }
- }
- else if (grow == currItem->meshGradientArray.count()-1)
- {
- if (gcol == 0)
- {
- psx->setPen(p1bd);
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlR)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlT)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
- }
- else if (gcol == currItem->meshGradientArray[grow].count()-1)
- {
- psx->setPen(p1bd);
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlL)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlT)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
- }
- else
- {
- psx->setPen(p1bd);
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlL)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlT)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
- if (m_gradientPoint == useControlR)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
- }
- }
- else
- {
- if (gcol == 0)
- {
- psx->setPen(p1bd);
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlR)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlT)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlB)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
- }
- else if (gcol == currItem->meshGradientArray[grow].count()-1)
- {
- psx->setPen(p1bd);
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlL)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlT)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlB)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
- }
- else
- {
- psx->setPen(p1bd);
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
- psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlL)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlT)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlB)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
- psx->setPen(p8m);
- if (m_gradientPoint == useControlR)
- psx->setPen(p8r);
- psx->drawPoint(QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
- }
- }
- }
-}
-
-void CanvasMode_EditMeshGradient::enterEvent(QEvent *)
-{
- if (!m_canvas->m_viewMode.m_MouseButtonPressed)
- {
- setModeCursor();
- }
-}
-
-void CanvasMode_EditMeshGradient::leaveEvent(QEvent *e)
-{
-}
-
-
-void CanvasMode_EditMeshGradient::activate(bool fromGesture)
-{
- m_canvas->m_viewMode.m_MouseButtonPressed = false;
- m_canvas->resetRenderMode();
- m_doc->DragP = false;
- m_doc->leaveDrag = false;
- m_canvas->m_viewMode.operItemMoving = false;
- m_canvas->m_viewMode.operItemResizing = false;
- m_view->MidButt = false;
- selectedMeshPoints.clear();
- m_keyRepeat = false;
- Mxp = Myp = -1;
- setModeCursor();
- if (fromGesture)
- {
- m_view->update();
- }
-}
-
-void CanvasMode_EditMeshGradient::deactivate(bool forGesture)
-{
- m_view->setRedrawMarkerShown(false);
- selectedMeshPoints.clear();
- m_gradientPoint = noPointDefined;
- m_ScMW->propertiesPalette->updateColorSpecialGradient();
-}
-
-void CanvasMode_EditMeshGradient::keyPressEvent(QKeyEvent *e)
-{
- if (selectedMeshPoints.count() == 0)
- return;
- int kk = e->key();
- if (m_keyRepeat)
- return;
- m_keyRepeat = true;
- e->accept();
- Qt::KeyboardModifiers buttonModifiers = e->modifiers();
- if ((!m_view->m_ScMW->zoomSpinBox->hasFocus()) && (!m_view->m_ScMW->pageSelector->hasFocus()))
- {
- if (m_doc->m_Selection->count() != 0)
- {
- double moveBy = 1.0;
- double moveX = 0.0;
- double moveY = 0.0;
- bool isMoving = false;
- bool doUpdate = false;
- if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
- moveBy=0.1;
- else if (!(buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
- moveBy=10.0;
- else if ((buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
- moveBy=0.01;
- moveBy/=m_doc->unitRatio();//Lets allow movement by the current doc ratio, not only points
- moveBy /= m_canvas->m_viewMode.scale;
- PageItem *currItem = m_doc->m_Selection->itemAt(0);
- switch (kk)
- {
- case Qt::Key_7:
- moveX = -moveBy;
- moveY = -moveBy;
- isMoving = true;
- doUpdate = true;
- break;
- case Qt::Key_9:
- moveX = moveBy;
- moveY = -moveBy;
- isMoving = true;
- doUpdate = true;
- break;
- case Qt::Key_3:
- moveX = moveBy;
- moveY = moveBy;
- isMoving = true;
- doUpdate = true;
- break;
- case Qt::Key_1:
- moveX = -moveBy;
- moveY = moveBy;
- isMoving = true;
- doUpdate = true;
- break;
- case Qt::Key_Left:
- case Qt::Key_4:
- moveX = -moveBy;
- isMoving = true;
- doUpdate = true;
- break;
- case Qt::Key_Right:
- case Qt::Key_6:
- moveX = moveBy;
- isMoving = true;
- doUpdate = true;
- break;
- case Qt::Key_Up:
- case Qt::Key_8:
- moveY = -moveBy;
- isMoving = true;
- doUpdate = true;
- break;
- case Qt::Key_Down:
- case Qt::Key_2:
- moveY = moveBy;
- isMoving = true;
- doUpdate = true;
- break;
- case Qt::Key_5:
- if (m_view->editStrokeGradient == 6)
- {
- QPair<int, int> selP = selectedMeshPoints[0];
- currItem->meshGradientArray[selP.first][selP.second].controlColor = currItem->meshGradientArray[selP.first][selP.second].gridPoint;
- doUpdate = true;
- }
- else if (m_view->editStrokeGradient == 7)
- {
- QPair<int, int> selP = selectedMeshPoints[0];
- if (m_gradientPoint == useControlT)
- currItem->meshGradientArray[selP.first][selP.second].controlTop = currItem->meshGradientArray[selP.first][selP.second].gridPoint;
- else if (m_gradientPoint == useControlB)
- currItem->meshGradientArray[selP.first][selP.second].controlBottom = currItem->meshGradientArray[selP.first][selP.second].gridPoint;
- else if (m_gradientPoint == useControlL)
- currItem->meshGradientArray[selP.first][selP.second].controlLeft = currItem->meshGradientArray[selP.first][selP.second].gridPoint;
- else if (m_gradientPoint == useControlR)
- currItem->meshGradientArray[selP.first][selP.second].controlRight = currItem->meshGradientArray[selP.first][selP.second].gridPoint;
- doUpdate = true;
- }
- break;
- }
- if (isMoving)
- {
- if (m_view->editStrokeGradient == 5)
- {
- for (int mo = 0; mo < selectedMeshPoints.count(); mo++)
- {
- QPair<int, int> selP = selectedMeshPoints[mo];
- currItem->meshGradientArray[selP.first][selP.second].moveRel(moveX, moveY);
- }
- }
- else if (m_view->editStrokeGradient == 6)
- {
- QPair<int, int> selP = selectedMeshPoints[0];
- currItem->meshGradientArray[selP.first][selP.second].controlColor += FPoint(moveX, moveY);
- }
- else if (m_view->editStrokeGradient == 7)
- {
- QPair<int, int> selP = selectedMeshPoints[0];
- if (m_gradientPoint == useControlT)
- currItem->meshGradientArray[selP.first][selP.second].controlTop += FPoint(moveX, moveY);
- else if (m_gradientPoint == useControlB)
- currItem->meshGradientArray[selP.first][selP.second].controlBottom += FPoint(moveX, moveY);
- else if (m_gradientPoint == useControlL)
- currItem->meshGradientArray[selP.first][selP.second].controlLeft += FPoint(moveX, moveY);
- else if (m_gradientPoint == useControlR)
- currItem->meshGradientArray[selP.first][selP.second].controlRight += FPoint(moveX, moveY);
- }
- }
- if (doUpdate)
- {
- currItem->update();
- QRectF upRect;
- upRect = QRectF(QPointF(0, 0), QPointF(currItem->width(), currItem->height())).normalized();
- upRect.translate(currItem->xPos(), currItem->yPos());
- m_doc->regionsChanged()->update(upRect.adjusted(-10.0 - currItem->width() / 2.0, -10.0 - currItem->height() / 2.0, 10.0 + currItem->width() / 2.0, 10.0 + currItem->height() / 2.0));
- }
- }
- }
- m_keyRepeat = false;
-}
-
-void CanvasMode_EditMeshGradient::mouseDoubleClickEvent(QMouseEvent *m)
-{
- m->accept();
- m_canvas->m_viewMode.m_MouseButtonPressed = false;
- m_canvas->resetRenderMode();
- PageItem *currItem = 0;
- if ((m_doc->m_Selection->isMultipleSelection()) || (m_doc->appMode != modeNormal))
- {
- if ((m_doc->m_Selection->isMultipleSelection()) && (m_doc->appMode == modeNormal))
- {
- if (GetItem(&currItem))
- {
- /* CB: old code, removing this as shift-alt select on an unselected table selects a cell now.
- //#6789 is closed by sorting this.
- if (currItem->isTableItem)
- {
- m_view->Deselect(false);
- m_doc->m_Selection->addItem(currItem);
- currItem->isSingleSel = true;
- //CB FIXME dont call this if the added item is item 0
- if (!m_doc->m_Selection->primarySelectionIs(currItem))
- currItem->emitAllToGUI();
- m_view->updateContents(currItem->getRedrawBounding(m_canvas->scale()));
- }*/
- }
- return;
- }
- else
- {
- if (!(GetItem(&currItem) && (m_doc->appMode == modeEdit) && currItem->asTextFrame()))
- {
- mousePressEvent(m);
- return;
- }
- }
- }
-}
-
-void CanvasMode_EditMeshGradient::mouseMoveEvent(QMouseEvent *m)
-{
- const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
- m->accept();
- if (selectedMeshPoints.count() == 0)
- return;
- if (m_canvas->m_viewMode.m_MouseButtonPressed && m_view->moveTimerElapsed())
- {
- FPoint npfN;
- double nx = mousePointDoc.x();
- double ny = mousePointDoc.y();
- if (!m_doc->ApplyGuides(&nx, &ny) && !m_doc->ApplyGuides(&nx, &ny,true))
- npfN = m_doc->ApplyGridF(FPoint(nx, ny));
- else
- npfN = FPoint(nx, ny);
- PageItem *currItem = m_doc->m_Selection->itemAt(0);
- QTransform pp = currItem->getTransform();
- FPoint npf = npfN.transformPoint(pp, true);
- if (m_view->editStrokeGradient == 6)
- {
- if (selectedMeshPoints.count() > 0)
- {
- QPair<int, int> selP = selectedMeshPoints[0];
- FPoint cP = currItem->meshGradientArray[selP.first][selP.second].controlColor;
- FPoint gP = currItem->meshGradientArray[selP.first][selP.second].gridPoint;
- m_canvas->displayXYHUD(m->globalPos(), cP.x() - gP.x(), cP.y() - gP.y());
- }
- }
- else
- m_canvas->displayXYHUD(m->globalPos(), npf.x(), npf.y());
- FPoint npx(Mxp - npfN.x(), Myp - npfN.y(), 0, 0, currItem->rotation(), 1, 1, true);
- if (selectedMeshPoints.count() > 0)
- {
- if (m_view->editStrokeGradient == 5)
- {
- for (int mo = 0; mo < selectedMeshPoints.count(); mo++)
- {
- QPair<int, int> selP = selectedMeshPoints[mo];
- currItem->meshGradientArray[selP.first][selP.second].moveRel(-npx.x(), -npx.y());
- }
- }
- else if (m_view->editStrokeGradient == 6)
- {
- QPair<int, int> selP = selectedMeshPoints[0];
- currItem->meshGradientArray[selP.first][selP.second].controlColor -= npx;
- }
- else if (m_view->editStrokeGradient == 7)
- {
- QPair<int, int> selP = selectedMeshPoints[0];
- if (m_gradientPoint == useControlT)
- currItem->meshGradientArray[selP.first][selP.second].controlTop -= npx;
- else if (m_gradientPoint == useControlB)
- currItem->meshGradientArray[selP.first][selP.second].controlBottom -= npx;
- else if (m_gradientPoint == useControlL)
- currItem->meshGradientArray[selP.first][selP.second].controlLeft -= npx;
- else if (m_gradientPoint == useControlR)
- currItem->meshGradientArray[selP.first][selP.second].controlRight -= npx;
- }
- currItem->update();
- QTransform itemMatrix = currItem->getTransform();
- m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-currItem->width() / 2.0, -currItem->height() / 2.0, currItem->width(), currItem->height()));
- }
- Mxp = npfN.x();
- Myp = npfN.y();
- }
-}
-
-void CanvasMode_EditMeshGradient::mousePressEvent(QMouseEvent *m)
-{
- const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
-
- m_canvas->PaintSizeRect(QRect());
- m_canvas->m_viewMode.m_MouseButtonPressed = true;
- m_canvas->m_viewMode.operItemMoving = false;
- m_view->HaveSelRect = false;
- m_doc->DragP = false;
- m_doc->leaveDrag = false;
- m->accept();
- m_view->registerMousePress(m->globalPos());
- Mxp = mousePointDoc.x(); //m->x();
- Myp = mousePointDoc.y(); //m->y();
- if (m->button() == Qt::MidButton)
- {
- m_view->MidButt = true;
- if (m->modifiers() & Qt::ControlModifier)
- m_view->DrawNew();
- return;
- }
- PageItem *currItem = m_doc->m_Selection->itemAt(0);
- QTransform itemMatrix = currItem->getTransform();
- bool found = false;
- QPair<int, int> selPoint;
- if (m_view->editStrokeGradient == 5)
- {
- m_gradientPoint = noPointDefined;
- for (int grow = 0; grow < currItem->meshGradientArray.count(); grow++)
- {
- for (int gcol = 0; gcol < currItem->meshGradientArray[grow].count(); gcol++)
- {
- meshPoint mp = currItem->meshGradientArray[grow][gcol];
- QPointF gradientPoint = QPointF(mp.gridPoint.x(), mp.gridPoint.y());
- gradientPoint = itemMatrix.map(gradientPoint);
- if (m_canvas->hitsCanvasPoint(mousePointDoc, gradientPoint))
- {
- selPoint.first = grow;
- selPoint.second = gcol;
- found = true;
- *old_mesh = mp;
- break;
- }
- }
- if (found)
- break;
- }
- }
- else if (m_view->editStrokeGradient == 6)
- {
- m_gradientPoint = noPointDefined;
- selectedMeshPoints.clear();
- for (int grow = 0; grow < currItem->meshGradientArray.count(); grow++)
- {
- for (int gcol = 0; gcol < currItem->meshGradientArray[grow].count(); gcol++)
- {
- meshPoint mp = currItem->meshGradientArray[grow][gcol];
- QPointF gradientPoint = QPointF(mp.gridPoint.x(), mp.gridPoint.y());
- gradientPoint = itemMatrix.map(gradientPoint);
- QPointF gradientColorPoint = QPointF(mp.controlColor.x(), mp.controlColor.y());
- gradientColorPoint = itemMatrix.map(gradientColorPoint);
- if (m_canvas->hitsCanvasPoint(mousePointDoc, gradientPoint) || m_canvas->hitsCanvasPoint(mousePointDoc, gradientColorPoint))
- {
- selPoint.first = grow;
- selPoint.second = gcol;
- currItem->selectedMeshPointX = grow;
- currItem->selectedMeshPointY = gcol;
- *old_mesh = mp;
- found = true;
- break;
- }
- }
- if (found)
- break;
- }
- }
- else if (m_view->editStrokeGradient == 7)
- {
- for (int grow = 0; grow < currItem->meshGradientArray.count(); grow++)
- {
- for (int gcol = 0; gcol < currItem->meshGradientArray[grow].count(); gcol++)
- {
- meshPoint mp1 = currItem->meshGradientArray[grow][gcol];
- QPointF gradientPoint;
- if (grow == 0)
- {
- if (gcol == 0)
- {
- gradientPoint = QPointF(mp1.controlRight.x(), mp1.controlRight.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlR;
- found = true;
- }
- gradientPoint = QPointF(mp1.controlBottom.x(), mp1.controlBottom.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlB;
- found = true;
- }
- }
- else if (gcol == currItem->meshGradientArray[grow].count()-1)
- {
- gradientPoint = QPointF(mp1.controlLeft.x(), mp1.controlLeft.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlL;
- found = true;
- }
- gradientPoint = QPointF(mp1.controlBottom.x(), mp1.controlBottom.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlB;
- found = true;
- }
- }
- else
- {
- gradientPoint = QPointF(mp1.controlLeft.x(), mp1.controlLeft.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlL;
- found = true;
- }
- gradientPoint = QPointF(mp1.controlRight.x(), mp1.controlRight.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlR;
- found = true;
- }
- gradientPoint = QPointF(mp1.controlBottom.x(), mp1.controlBottom.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlB;
- found = true;
- }
- }
- }
- else if (grow == currItem->meshGradientArray.count()-1)
- {
- if (gcol == 0)
- {
- gradientPoint = QPointF(mp1.controlRight.x(), mp1.controlRight.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlR;
- found = true;
- }
- gradientPoint = QPointF(mp1.controlTop.x(), mp1.controlTop.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlT;
- found = true;
- }
- }
- else if (gcol == currItem->meshGradientArray[grow].count()-1)
- {
- gradientPoint = QPointF(mp1.controlTop.x(), mp1.controlTop.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlT;
- found = true;
- }
- gradientPoint = QPointF(mp1.controlLeft.x(), mp1.controlLeft.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlL;
- found = true;
- }
- }
- else
- {
- gradientPoint = QPointF(mp1.controlTop.x(), mp1.controlTop.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlT;
- found = true;
- }
- gradientPoint = QPointF(mp1.controlLeft.x(), mp1.controlLeft.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlL;
- found = true;
- }
- gradientPoint = QPointF(mp1.controlRight.x(), mp1.controlRight.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlR;
- found = true;
- }
- }
- }
- else
- {
- if (gcol == 0)
- {
- gradientPoint = QPointF(mp1.controlBottom.x(), mp1.controlBottom.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlB;
- found = true;
- }
- gradientPoint = QPointF(mp1.controlTop.x(), mp1.controlTop.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlT;
- found = true;
- }
- gradientPoint = QPointF(mp1.controlRight.x(), mp1.controlRight.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlR;
- found = true;
- }
- }
- else if (gcol == currItem->meshGradientArray[grow].count()-1)
- {
- gradientPoint = QPointF(mp1.controlBottom.x(), mp1.controlBottom.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlB;
- found = true;
- }
- gradientPoint = QPointF(mp1.controlTop.x(), mp1.controlTop.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlT;
- found = true;
- }
- gradientPoint = QPointF(mp1.controlLeft.x(), mp1.controlLeft.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlL;
- found = true;
- }
- }
- else
- {
- gradientPoint = QPointF(mp1.controlBottom.x(), mp1.controlBottom.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlB;
- found = true;
- }
- gradientPoint = QPointF(mp1.controlTop.x(), mp1.controlTop.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlT;
- found = true;
- }
- gradientPoint = QPointF(mp1.controlLeft.x(), mp1.controlLeft.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlL;
- found = true;
- }
- gradientPoint = QPointF(mp1.controlRight.x(), mp1.controlRight.y());
- if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
- {
- m_gradientPoint = useControlR;
- found = true;
- }
- }
- }
- if (found)
- {
- selPoint.first = grow;
- selPoint.second = gcol;
- *old_mesh = mp1;
- break;
- }
- }
- if (found)
- break;
- }
- if (!found)
- {
- for (int grow = 0; grow < currItem->meshGradientArray.count(); grow++)
- {
- for (int gcol = 0; gcol < currItem->meshGradientArray[grow].count(); gcol++)
- {
- meshPoint mp = currItem->meshGradientArray[grow][gcol];
- QPointF gradientPoint = QPointF(mp.gridPoint.x(), mp.gridPoint.y());
- gradientPoint = itemMatrix.map(gradientPoint);
- if (m_canvas->hitsCanvasPoint(mousePointDoc, gradientPoint))
- {
- selPoint.first = grow;
- selPoint.second = gcol;
- m_gradientPoint = noPointDefined;
- found = true;
- break;
- }
- }
- if (found)
- break;
- }
- }
- }
- if (!found)
- {
- if (!(m->modifiers() & Qt::ShiftModifier))
- {
- m_gradientPoint = noPointDefined;
- selectedMeshPoints.clear();
- currItem->selectedMeshPointX = -1;
- currItem->selectedMeshPointY = -1;
- currItem->selectedMeshControlPoint = static_cast<int>(m_gradientPoint);
- }
- }
- else
- {
- bool isSelected = false;
- for (int se = 0; se < selectedMeshPoints.count(); se++)
- {
- if ((selPoint.first == selectedMeshPoints[se].first) && (selPoint.second == selectedMeshPoints[se].second))
- {
- isSelected = true;
- break;
- }
- }
- if ((!(m->modifiers() & Qt::ShiftModifier)) && (!isSelected))
- selectedMeshPoints.clear();
- if (!isSelected)
- selectedMeshPoints.append(selPoint);
- currItem->selectedMeshPointX = selectedMeshPoints[0].first;
- currItem->selectedMeshPointY = selectedMeshPoints[0].second;
- currItem->selectedMeshControlPoint = static_cast<int>(m_gradientPoint);
- }
- m_canvas->m_viewMode.m_MouseButtonPressed = true;
- m_ScMW->propertiesPalette->updateColorSpecialGradient();
- m_view->setCursor(QCursor(Qt::CrossCursor));
- m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-currItem->width() / 2.0, -currItem->height() / 2.0, currItem->width(), currItem->height()));
-}
-
-void CanvasMode_EditMeshGradient::mouseReleaseEvent(QMouseEvent *m)
-{
- m_canvas->m_viewMode.m_MouseButtonPressed = false;
- m_canvas->resetRenderMode();
- m->accept();
- PageItem *currItem = m_doc->m_Selection->itemAt(0);
- if (currItem->selectedMeshPointX >=0 && currItem->selectedMeshPointY >=0 && UndoManager::undoEnabled())
- {
- ScItemState<QPair<meshPoint,meshPoint> > *ss = new ScItemState<QPair<meshPoint,meshPoint> >(Um::GradPos);
- ss->set("MOVE_MESH_PATCH","move_mesh_patch");
- ss->set("ARRAY",true);
- ss->set("X",currItem->selectedMeshPointX);
- ss->set("Y",currItem->selectedMeshPointY);
- if((*old_mesh) == currItem->meshGradientArray[currItem->selectedMeshPointX][currItem->selectedMeshPointY])
- {
- delete ss;
- ss=NULL;
- }
- else
- ss->setItem(qMakePair(*old_mesh,currItem->meshGradientArray[currItem->selectedMeshPointX][currItem->selectedMeshPointY]));
- if(ss)
- undoManager->action(currItem,ss);
- }
- currItem->update();
- QTransform itemMatrix = currItem->getTransform();
- m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-currItem->width() / 2.0, -currItem->height() / 2.0, currItem->width(), currItem->height()));
-}
+/*
+ For general Scribus (>=1.3.2) copyright and licensing information please refer
+ to the COPYING file provided with the program. Following this notice may exist
+ a copyright and/or license notice that predates the release of Scribus 1.3.2
+ for which a new license (GPL+exception) is in place.
+ */
+/***************************************************************************
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+***************************************************************************/
+/***************************************************************************
+ canvasmode_editmeshgradient.cpp - description
+ -------------------
+ begin : Sat Apr 24 2010
+ copyright : (C) 2010 by Franz Schmid
+ email : Franz.Schmid at altmuehlnet.de
+ ***************************************************************************/
+
+
+#include "canvasmode_editmeshgradient.h"
+
+#include <QApplication>
+#include <QButtonGroup>
+#include <QCheckBox>
+#include <QCursor>
+#include <QEvent>
+#include <QMessageBox>
+#include <QMouseEvent>
+#include <QPainterPath>
+#include <QPoint>
+#include <QRect>
+#include <QTimer>
+#include <QWidgetAction>
+#include <QDebug>
+
+#include "appmodes.h"
+#include "canvas.h"
+#include "fpoint.h"
+#include "fpointarray.h"
+#include "hyphenator.h"
+#include "pageitem_textframe.h"
+#include "prefscontext.h"
+#include "prefsfile.h"
+#include "prefsmanager.h"
+#include "scribus.h"
+#include "scribusXml.h"
+#include "scribusdoc.h"
+#include "scribusview.h"
+#include "selection.h"
+#include "ui/aligndistribute.h"
+#include "ui/contextmenu.h"
+#include "ui/pageselector.h"
+#include "ui/propertiespalette.h"
+#include "undomanager.h"
+#include "units.h"
+#include "util.h"
+#include "util_math.h"
+
+
+CanvasMode_EditMeshGradient::CanvasMode_EditMeshGradient(ScribusView* view) : CanvasMode(view), m_ScMW(view->m_ScMW)
+{
+ m_Mxp = m_Myp = -1;
+ m_selectedMeshPoints.clear();
+ m_gradientPoint = noPointDefined;
+ m_old_mesh = new meshPoint();
+}
+
+CanvasMode_EditMeshGradient::~CanvasMode_EditMeshGradient()
+{
+ delete m_old_mesh;
+ m_old_mesh = NULL;
+}
+
+inline bool CanvasMode_EditMeshGradient::GetItem(PageItem** pi)
+{
+ *pi = m_doc->m_Selection->itemAt(0);
+ return (*pi) != NULL;
+}
+
+void CanvasMode_EditMeshGradient::drawControls(QPainter* p)
+{
+ p->save();
+ if (m_canvas->m_viewMode.operItemMoving)
+ {
+ drawOutline(p);
+ }
+ else
+ {
+ drawSelection(p, false);
+ }
+ if (m_doc->appMode == modeEditMeshGradient)
+ {
+ drawControlsMeshGradient(p, m_doc->m_Selection->itemAt(0));
+ }
+ p->restore();
+}
+
+void CanvasMode_EditMeshGradient::drawControlsMeshGradient(QPainter* psx, PageItem* currItem)
+{
+ QPen p1b = QPen(Qt::blue, 1.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+ QPen p1bd = QPen(Qt::blue, 1.0 / m_canvas->m_viewMode.scale, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin);
+ QPen p8b = QPen(Qt::blue, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin);
+ QPen p8r = QPen(Qt::red, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin);
+ QPen p8m = QPen(Qt::magenta, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin);
+ QPen p14r = QPen(Qt::red, 18.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin);
+ QPen p14w = QPen(Qt::white, 18.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin);
+ psx->setTransform(currItem->getTransform(), true);
+ psx->setPen(p1b);
+ psx->setBrush(Qt::NoBrush);
+ for (int grow = 0; grow < currItem->meshGradientArray.count()-1; grow++)
+ {
+ for (int gcol = 0; gcol < currItem->meshGradientArray[grow].count()-1; gcol++)
+ {
+ meshPoint mp1 = currItem->meshGradientArray[grow][gcol];
+ meshPoint mp2 = currItem->meshGradientArray[grow][gcol+1];
+ meshPoint mp3 = currItem->meshGradientArray[grow+1][gcol+1];
+ meshPoint mp4 = currItem->meshGradientArray[grow+1][gcol];
+ QPainterPath Bez;
+ Bez.moveTo(mp1.gridPoint.x(), mp1.gridPoint.y());
+ Bez.cubicTo(mp1.controlRight.x(), mp1.controlRight.y(), mp2.controlLeft.x(), mp2.controlLeft.y(), mp2.gridPoint.x(), mp2.gridPoint.y());
+ Bez.cubicTo(mp2.controlBottom.x(), mp2.controlBottom.y(), mp3.controlTop.x(), mp3.controlTop.y(), mp3.gridPoint.x(), mp3.gridPoint.y());
+ Bez.cubicTo(mp3.controlLeft.x(), mp3.controlLeft.y(), mp4.controlRight.x(), mp4.controlRight.y(), mp4.gridPoint.x(), mp4.gridPoint.y());
+ Bez.cubicTo(mp4.controlTop.x(), mp4.controlTop.y(), mp1.controlBottom.x(), mp1.controlBottom.y(), mp1.gridPoint.x(), mp1.gridPoint.y());
+ psx->setPen(p1b);
+ psx->drawPath(Bez);
+ }
+ }
+ for (int grow = 0; grow < currItem->meshGradientArray.count(); grow++)
+ {
+ for (int gcol = 0; gcol < currItem->meshGradientArray[grow].count(); gcol++)
+ {
+ bool isSelected = false;
+ for (int se = 0; se < m_selectedMeshPoints.count(); se++)
+ {
+ if ((grow == m_selectedMeshPoints[se].first) && (gcol == m_selectedMeshPoints[se].second))
+ {
+ isSelected = true;
+ break;
+ }
+ }
+ meshPoint mp1 = currItem->meshGradientArray[grow][gcol];
+ if (m_view->editStrokeGradient == 5)
+ {
+ if (isSelected)
+ psx->setPen(p8r);
+ else
+ psx->setPen(p8m);
+ psx->drawPoint(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()));
+ }
+ else if (m_view->editStrokeGradient == 6)
+ {
+ if (isSelected)
+ psx->setPen(p14r);
+ else
+ psx->setPen(p14w);
+ psx->drawPoint(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()));
+ psx->setPen(QPen(mp1.color, 14.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
+ psx->drawPoint(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()));
+ if (isSelected)
+ psx->setPen(p8r);
+ else
+ psx->setPen(p8m);
+ psx->drawPoint(QPointF(mp1.controlColor.x(), mp1.controlColor.y()));
+ }
+ else if (m_view->editStrokeGradient == 7)
+ {
+ psx->setPen(p8b);
+ psx->drawPoint(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()));
+ }
+ }
+ }
+ if ((m_selectedMeshPoints.count() > 0) && (m_view->editStrokeGradient == 7))
+ {
+ int grow = m_selectedMeshPoints[0].first;
+ int gcol = m_selectedMeshPoints[0].second;
+ meshPoint mp1 = currItem->meshGradientArray[grow][gcol];
+ psx->setPen(p8m);
+ if (grow == 0)
+ {
+ if (gcol == 0)
+ {
+ psx->setPen(p1bd);
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlR)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlB)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
+ }
+ else if (gcol == currItem->meshGradientArray[grow].count()-1)
+ {
+ psx->setPen(p1bd);
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlL)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlB)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
+ }
+ else
+ {
+ psx->setPen(p1bd);
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlL)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlB)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
+ if (m_gradientPoint == useControlR)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
+ }
+ }
+ else if (grow == currItem->meshGradientArray.count()-1)
+ {
+ if (gcol == 0)
+ {
+ psx->setPen(p1bd);
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlR)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlT)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
+ }
+ else if (gcol == currItem->meshGradientArray[grow].count()-1)
+ {
+ psx->setPen(p1bd);
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlL)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlT)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
+ }
+ else
+ {
+ psx->setPen(p1bd);
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlL)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlT)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
+ if (m_gradientPoint == useControlR)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
+ }
+ }
+ else
+ {
+ if (gcol == 0)
+ {
+ psx->setPen(p1bd);
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlR)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlT)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlB)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
+ }
+ else if (gcol == currItem->meshGradientArray[grow].count()-1)
+ {
+ psx->setPen(p1bd);
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlL)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlT)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlB)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
+ }
+ else
+ {
+ psx->setPen(p1bd);
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
+ psx->drawLine(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()), QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlL)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlLeft.x(), mp1.controlLeft.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlT)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlTop.x(), mp1.controlTop.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlB)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlBottom.x(), mp1.controlBottom.y()));
+ psx->setPen(p8m);
+ if (m_gradientPoint == useControlR)
+ psx->setPen(p8r);
+ psx->drawPoint(QPointF(mp1.controlRight.x(), mp1.controlRight.y()));
+ }
+ }
+ }
+}
+
+void CanvasMode_EditMeshGradient::enterEvent(QEvent *)
+{
+ if (!m_canvas->m_viewMode.m_MouseButtonPressed)
+ {
+ setModeCursor();
+ }
+}
+
+void CanvasMode_EditMeshGradient::leaveEvent(QEvent *e)
+{
+}
+
+
+void CanvasMode_EditMeshGradient::activate(bool fromGesture)
+{
+ m_canvas->m_viewMode.m_MouseButtonPressed = false;
+ m_canvas->resetRenderMode();
+ m_doc->DragP = false;
+ m_doc->leaveDrag = false;
+ m_canvas->m_viewMode.operItemMoving = false;
+ m_canvas->m_viewMode.operItemResizing = false;
+ m_view->MidButt = false;
+ m_selectedMeshPoints.clear();
+ m_keyRepeat = false;
+ m_Mxp = m_Myp = -1;
+ setModeCursor();
+ if (fromGesture)
+ {
+ m_view->update();
+ }
+}
+
+void CanvasMode_EditMeshGradient::deactivate(bool forGesture)
+{
+ m_view->setRedrawMarkerShown(false);
+ m_selectedMeshPoints.clear();
+ m_gradientPoint = noPointDefined;
+ m_ScMW->propertiesPalette->updateColorSpecialGradient();
+}
+
+void CanvasMode_EditMeshGradient::keyPressEvent(QKeyEvent *e)
+{
+ if (m_selectedMeshPoints.count() == 0)
+ return;
+ int kk = e->key();
+ if (m_keyRepeat)
+ return;
+ m_keyRepeat = true;
+ e->accept();
+ Qt::KeyboardModifiers buttonModifiers = e->modifiers();
+ if ((!m_view->m_ScMW->zoomSpinBox->hasFocus()) && (!m_view->m_ScMW->pageSelector->hasFocus()))
+ {
+ if (m_doc->m_Selection->count() != 0)
+ {
+ double moveBy = 1.0;
+ double moveX = 0.0;
+ double moveY = 0.0;
+ bool isMoving = false;
+ bool doUpdate = false;
+ if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
+ moveBy=0.1;
+ else if (!(buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
+ moveBy=10.0;
+ else if ((buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
+ moveBy=0.01;
+ moveBy/=m_doc->unitRatio();//Lets allow movement by the current doc ratio, not only points
+ moveBy /= m_canvas->m_viewMode.scale;
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ switch (kk)
+ {
+ case Qt::Key_7:
+ moveX = -moveBy;
+ moveY = -moveBy;
+ isMoving = true;
+ doUpdate = true;
+ break;
+ case Qt::Key_9:
+ moveX = moveBy;
+ moveY = -moveBy;
+ isMoving = true;
+ doUpdate = true;
+ break;
+ case Qt::Key_3:
+ moveX = moveBy;
+ moveY = moveBy;
+ isMoving = true;
+ doUpdate = true;
+ break;
+ case Qt::Key_1:
+ moveX = -moveBy;
+ moveY = moveBy;
+ isMoving = true;
+ doUpdate = true;
+ break;
+ case Qt::Key_Left:
+ case Qt::Key_4:
+ moveX = -moveBy;
+ isMoving = true;
+ doUpdate = true;
+ break;
+ case Qt::Key_Right:
+ case Qt::Key_6:
+ moveX = moveBy;
+ isMoving = true;
+ doUpdate = true;
+ break;
+ case Qt::Key_Up:
+ case Qt::Key_8:
+ moveY = -moveBy;
+ isMoving = true;
+ doUpdate = true;
+ break;
+ case Qt::Key_Down:
+ case Qt::Key_2:
+ moveY = moveBy;
+ isMoving = true;
+ doUpdate = true;
+ break;
+ case Qt::Key_5:
+ if (m_view->editStrokeGradient == 6)
+ {
+ QPair<int, int> selP = m_selectedMeshPoints[0];
+ currItem->meshGradientArray[selP.first][selP.second].controlColor = currItem->meshGradientArray[selP.first][selP.second].gridPoint;
+ doUpdate = true;
+ }
+ else if (m_view->editStrokeGradient == 7)
+ {
+ QPair<int, int> selP = m_selectedMeshPoints[0];
+ if (m_gradientPoint == useControlT)
+ currItem->meshGradientArray[selP.first][selP.second].controlTop = currItem->meshGradientArray[selP.first][selP.second].gridPoint;
+ else if (m_gradientPoint == useControlB)
+ currItem->meshGradientArray[selP.first][selP.second].controlBottom = currItem->meshGradientArray[selP.first][selP.second].gridPoint;
+ else if (m_gradientPoint == useControlL)
+ currItem->meshGradientArray[selP.first][selP.second].controlLeft = currItem->meshGradientArray[selP.first][selP.second].gridPoint;
+ else if (m_gradientPoint == useControlR)
+ currItem->meshGradientArray[selP.first][selP.second].controlRight = currItem->meshGradientArray[selP.first][selP.second].gridPoint;
+ doUpdate = true;
+ }
+ break;
+ }
+ if (isMoving)
+ {
+ if (m_view->editStrokeGradient == 5)
+ {
+ for (int mo = 0; mo < m_selectedMeshPoints.count(); mo++)
+ {
+ QPair<int, int> selP = m_selectedMeshPoints[mo];
+ currItem->meshGradientArray[selP.first][selP.second].moveRel(moveX, moveY);
+ }
+ }
+ else if (m_view->editStrokeGradient == 6)
+ {
+ QPair<int, int> selP = m_selectedMeshPoints[0];
+ currItem->meshGradientArray[selP.first][selP.second].controlColor += FPoint(moveX, moveY);
+ }
+ else if (m_view->editStrokeGradient == 7)
+ {
+ QPair<int, int> selP = m_selectedMeshPoints[0];
+ if (m_gradientPoint == useControlT)
+ currItem->meshGradientArray[selP.first][selP.second].controlTop += FPoint(moveX, moveY);
+ else if (m_gradientPoint == useControlB)
+ currItem->meshGradientArray[selP.first][selP.second].controlBottom += FPoint(moveX, moveY);
+ else if (m_gradientPoint == useControlL)
+ currItem->meshGradientArray[selP.first][selP.second].controlLeft += FPoint(moveX, moveY);
+ else if (m_gradientPoint == useControlR)
+ currItem->meshGradientArray[selP.first][selP.second].controlRight += FPoint(moveX, moveY);
+ }
+ }
+ if (doUpdate)
+ {
+ currItem->update();
+ QRectF upRect;
+ upRect = QRectF(QPointF(0, 0), QPointF(currItem->width(), currItem->height())).normalized();
+ upRect.translate(currItem->xPos(), currItem->yPos());
+ m_doc->regionsChanged()->update(upRect.adjusted(-10.0 - currItem->width() / 2.0, -10.0 - currItem->height() / 2.0, 10.0 + currItem->width() / 2.0, 10.0 + currItem->height() / 2.0));
+ }
+ }
+ }
+ m_keyRepeat = false;
+}
+
+void CanvasMode_EditMeshGradient::mouseDoubleClickEvent(QMouseEvent *m)
+{
+ m->accept();
+ m_canvas->m_viewMode.m_MouseButtonPressed = false;
+ m_canvas->resetRenderMode();
+ PageItem *currItem = 0;
+ if ((m_doc->m_Selection->isMultipleSelection()) || (m_doc->appMode != modeNormal))
+ {
+ if ((m_doc->m_Selection->isMultipleSelection()) && (m_doc->appMode == modeNormal))
+ {
+ if (GetItem(&currItem))
+ {
+ /* CB: old code, removing this as shift-alt select on an unselected table selects a cell now.
+ //#6789 is closed by sorting this.
+ if (currItem->isTableItem)
+ {
+ m_view->Deselect(false);
+ m_doc->m_Selection->addItem(currItem);
+ currItem->isSingleSel = true;
+ //CB FIXME dont call this if the added item is item 0
+ if (!m_doc->m_Selection->primarySelectionIs(currItem))
+ currItem->emitAllToGUI();
+ m_view->updateContents(currItem->getRedrawBounding(m_canvas->scale()));
+ }*/
+ }
+ return;
+ }
+ else
+ {
+ if (!(GetItem(&currItem) && (m_doc->appMode == modeEdit) && currItem->asTextFrame()))
+ {
+ mousePressEvent(m);
+ return;
+ }
+ }
+ }
+}
+
+void CanvasMode_EditMeshGradient::mouseMoveEvent(QMouseEvent *m)
+{
+ const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
+ m->accept();
+ if (m_selectedMeshPoints.count() == 0)
+ return;
+ if (m_canvas->m_viewMode.m_MouseButtonPressed && m_view->moveTimerElapsed())
+ {
+ FPoint npfN;
+ double nx = mousePointDoc.x();
+ double ny = mousePointDoc.y();
+ if (!m_doc->ApplyGuides(&nx, &ny) && !m_doc->ApplyGuides(&nx, &ny,true))
+ npfN = m_doc->ApplyGridF(FPoint(nx, ny));
+ else
+ npfN = FPoint(nx, ny);
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ QTransform pp = currItem->getTransform();
+ FPoint npf = npfN.transformPoint(pp, true);
+ if (m_view->editStrokeGradient == 6)
+ {
+ if (m_selectedMeshPoints.count() > 0)
+ {
+ QPair<int, int> selP = m_selectedMeshPoints[0];
+ FPoint cP = currItem->meshGradientArray[selP.first][selP.second].controlColor;
+ FPoint gP = currItem->meshGradientArray[selP.first][selP.second].gridPoint;
+ m_canvas->displayXYHUD(m->globalPos(), cP.x() - gP.x(), cP.y() - gP.y());
+ }
+ }
+ else
+ m_canvas->displayXYHUD(m->globalPos(), npf.x(), npf.y());
+ FPoint npx(m_Mxp - npfN.x(), m_Myp - npfN.y(), 0, 0, currItem->rotation(), 1, 1, true);
+ if (m_selectedMeshPoints.count() > 0)
+ {
+ if (m_view->editStrokeGradient == 5)
+ {
+ for (int mo = 0; mo < m_selectedMeshPoints.count(); mo++)
+ {
+ QPair<int, int> selP = m_selectedMeshPoints[mo];
+ currItem->meshGradientArray[selP.first][selP.second].moveRel(-npx.x(), -npx.y());
+ }
+ }
+ else if (m_view->editStrokeGradient == 6)
+ {
+ QPair<int, int> selP = m_selectedMeshPoints[0];
+ currItem->meshGradientArray[selP.first][selP.second].controlColor -= npx;
+ }
+ else if (m_view->editStrokeGradient == 7)
+ {
+ QPair<int, int> selP = m_selectedMeshPoints[0];
+ if (m_gradientPoint == useControlT)
+ currItem->meshGradientArray[selP.first][selP.second].controlTop -= npx;
+ else if (m_gradientPoint == useControlB)
+ currItem->meshGradientArray[selP.first][selP.second].controlBottom -= npx;
+ else if (m_gradientPoint == useControlL)
+ currItem->meshGradientArray[selP.first][selP.second].controlLeft -= npx;
+ else if (m_gradientPoint == useControlR)
+ currItem->meshGradientArray[selP.first][selP.second].controlRight -= npx;
+ }
+ currItem->update();
+ QTransform itemMatrix = currItem->getTransform();
+ m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-currItem->width() / 2.0, -currItem->height() / 2.0, currItem->width(), currItem->height()));
+ }
+ m_Mxp = npfN.x();
+ m_Myp = npfN.y();
+ }
+}
+
+void CanvasMode_EditMeshGradient::mousePressEvent(QMouseEvent *m)
+{
+ const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
+
+ m_canvas->PaintSizeRect(QRect());
+ m_canvas->m_viewMode.m_MouseButtonPressed = true;
+ m_canvas->m_viewMode.operItemMoving = false;
+ m_view->HaveSelRect = false;
+ m_doc->DragP = false;
+ m_doc->leaveDrag = false;
+ m->accept();
+ m_view->registerMousePress(m->globalPos());
+ m_Mxp = mousePointDoc.x(); //m->x();
+ m_Myp = mousePointDoc.y(); //m->y();
+ if (m->button() == Qt::MidButton)
+ {
+ m_view->MidButt = true;
+ if (m->modifiers() & Qt::ControlModifier)
+ m_view->DrawNew();
+ return;
+ }
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ QTransform itemMatrix = currItem->getTransform();
+ bool found = false;
+ QPair<int, int> selPoint;
+ if (m_view->editStrokeGradient == 5)
+ {
+ m_gradientPoint = noPointDefined;
+ for (int grow = 0; grow < currItem->meshGradientArray.count(); grow++)
+ {
+ for (int gcol = 0; gcol < currItem->meshGradientArray[grow].count(); gcol++)
+ {
+ meshPoint mp = currItem->meshGradientArray[grow][gcol];
+ QPointF gradientPoint = QPointF(mp.gridPoint.x(), mp.gridPoint.y());
+ gradientPoint = itemMatrix.map(gradientPoint);
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, gradientPoint))
+ {
+ selPoint.first = grow;
+ selPoint.second = gcol;
+ found = true;
+ *m_old_mesh = mp;
+ break;
+ }
+ }
+ if (found)
+ break;
+ }
+ }
+ else if (m_view->editStrokeGradient == 6)
+ {
+ m_gradientPoint = noPointDefined;
+ m_selectedMeshPoints.clear();
+ for (int grow = 0; grow < currItem->meshGradientArray.count(); grow++)
+ {
+ for (int gcol = 0; gcol < currItem->meshGradientArray[grow].count(); gcol++)
+ {
+ meshPoint mp = currItem->meshGradientArray[grow][gcol];
+ QPointF gradientPoint = QPointF(mp.gridPoint.x(), mp.gridPoint.y());
+ gradientPoint = itemMatrix.map(gradientPoint);
+ QPointF gradientColorPoint = QPointF(mp.controlColor.x(), mp.controlColor.y());
+ gradientColorPoint = itemMatrix.map(gradientColorPoint);
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, gradientPoint) || m_canvas->hitsCanvasPoint(mousePointDoc, gradientColorPoint))
+ {
+ selPoint.first = grow;
+ selPoint.second = gcol;
+ currItem->selectedMeshPointX = grow;
+ currItem->selectedMeshPointY = gcol;
+ *m_old_mesh = mp;
+ found = true;
+ break;
+ }
+ }
+ if (found)
+ break;
+ }
+ }
+ else if (m_view->editStrokeGradient == 7)
+ {
+ for (int grow = 0; grow < currItem->meshGradientArray.count(); grow++)
+ {
+ for (int gcol = 0; gcol < currItem->meshGradientArray[grow].count(); gcol++)
+ {
+ meshPoint mp1 = currItem->meshGradientArray[grow][gcol];
+ QPointF gradientPoint;
+ if (grow == 0)
+ {
+ if (gcol == 0)
+ {
+ gradientPoint = QPointF(mp1.controlRight.x(), mp1.controlRight.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlR;
+ found = true;
+ }
+ gradientPoint = QPointF(mp1.controlBottom.x(), mp1.controlBottom.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlB;
+ found = true;
+ }
+ }
+ else if (gcol == currItem->meshGradientArray[grow].count()-1)
+ {
+ gradientPoint = QPointF(mp1.controlLeft.x(), mp1.controlLeft.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlL;
+ found = true;
+ }
+ gradientPoint = QPointF(mp1.controlBottom.x(), mp1.controlBottom.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlB;
+ found = true;
+ }
+ }
+ else
+ {
+ gradientPoint = QPointF(mp1.controlLeft.x(), mp1.controlLeft.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlL;
+ found = true;
+ }
+ gradientPoint = QPointF(mp1.controlRight.x(), mp1.controlRight.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlR;
+ found = true;
+ }
+ gradientPoint = QPointF(mp1.controlBottom.x(), mp1.controlBottom.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlB;
+ found = true;
+ }
+ }
+ }
+ else if (grow == currItem->meshGradientArray.count()-1)
+ {
+ if (gcol == 0)
+ {
+ gradientPoint = QPointF(mp1.controlRight.x(), mp1.controlRight.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlR;
+ found = true;
+ }
+ gradientPoint = QPointF(mp1.controlTop.x(), mp1.controlTop.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlT;
+ found = true;
+ }
+ }
+ else if (gcol == currItem->meshGradientArray[grow].count()-1)
+ {
+ gradientPoint = QPointF(mp1.controlTop.x(), mp1.controlTop.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlT;
+ found = true;
+ }
+ gradientPoint = QPointF(mp1.controlLeft.x(), mp1.controlLeft.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlL;
+ found = true;
+ }
+ }
+ else
+ {
+ gradientPoint = QPointF(mp1.controlTop.x(), mp1.controlTop.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlT;
+ found = true;
+ }
+ gradientPoint = QPointF(mp1.controlLeft.x(), mp1.controlLeft.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlL;
+ found = true;
+ }
+ gradientPoint = QPointF(mp1.controlRight.x(), mp1.controlRight.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlR;
+ found = true;
+ }
+ }
+ }
+ else
+ {
+ if (gcol == 0)
+ {
+ gradientPoint = QPointF(mp1.controlBottom.x(), mp1.controlBottom.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlB;
+ found = true;
+ }
+ gradientPoint = QPointF(mp1.controlTop.x(), mp1.controlTop.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlT;
+ found = true;
+ }
+ gradientPoint = QPointF(mp1.controlRight.x(), mp1.controlRight.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlR;
+ found = true;
+ }
+ }
+ else if (gcol == currItem->meshGradientArray[grow].count()-1)
+ {
+ gradientPoint = QPointF(mp1.controlBottom.x(), mp1.controlBottom.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlB;
+ found = true;
+ }
+ gradientPoint = QPointF(mp1.controlTop.x(), mp1.controlTop.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlT;
+ found = true;
+ }
+ gradientPoint = QPointF(mp1.controlLeft.x(), mp1.controlLeft.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlL;
+ found = true;
+ }
+ }
+ else
+ {
+ gradientPoint = QPointF(mp1.controlBottom.x(), mp1.controlBottom.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlB;
+ found = true;
+ }
+ gradientPoint = QPointF(mp1.controlTop.x(), mp1.controlTop.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlT;
+ found = true;
+ }
+ gradientPoint = QPointF(mp1.controlLeft.x(), mp1.controlLeft.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlL;
+ found = true;
+ }
+ gradientPoint = QPointF(mp1.controlRight.x(), mp1.controlRight.y());
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
+ {
+ m_gradientPoint = useControlR;
+ found = true;
+ }
+ }
+ }
+ if (found)
+ {
+ selPoint.first = grow;
+ selPoint.second = gcol;
+ *m_old_mesh = mp1;
+ break;
+ }
+ }
+ if (found)
+ break;
+ }
+ if (!found)
+ {
+ for (int grow = 0; grow < currItem->meshGradientArray.count(); grow++)
+ {
+ for (int gcol = 0; gcol < currItem->meshGradientArray[grow].count(); gcol++)
+ {
+ meshPoint mp = currItem->meshGradientArray[grow][gcol];
+ QPointF gradientPoint = QPointF(mp.gridPoint.x(), mp.gridPoint.y());
+ gradientPoint = itemMatrix.map(gradientPoint);
+ if (m_canvas->hitsCanvasPoint(mousePointDoc, gradientPoint))
+ {
+ selPoint.first = grow;
+ selPoint.second = gcol;
+ m_gradientPoint = noPointDefined;
+ found = true;
+ break;
+ }
+ }
+ if (found)
+ break;
+ }
+ }
+ }
+ if (!found)
+ {
+ if (!(m->modifiers() & Qt::ShiftModifier))
+ {
+ m_gradientPoint = noPointDefined;
+ m_selectedMeshPoints.clear();
+ currItem->selectedMeshPointX = -1;
+ currItem->selectedMeshPointY = -1;
+ currItem->selectedMeshControlPoint = static_cast<int>(m_gradientPoint);
+ }
+ }
+ else
+ {
+ bool isSelected = false;
+ for (int se = 0; se < m_selectedMeshPoints.count(); se++)
+ {
+ if ((selPoint.first == m_selectedMeshPoints[se].first) && (selPoint.second == m_selectedMeshPoints[se].second))
+ {
+ isSelected = true;
+ break;
+ }
+ }
+ if ((!(m->modifiers() & Qt::ShiftModifier)) && (!isSelected))
+ m_selectedMeshPoints.clear();
+ if (!isSelected)
+ m_selectedMeshPoints.append(selPoint);
+ currItem->selectedMeshPointX = m_selectedMeshPoints[0].first;
+ currItem->selectedMeshPointY = m_selectedMeshPoints[0].second;
+ currItem->selectedMeshControlPoint = static_cast<int>(m_gradientPoint);
+ }
+ m_canvas->m_viewMode.m_MouseButtonPressed = true;
+ m_ScMW->propertiesPalette->updateColorSpecialGradient();
+ m_view->setCursor(QCursor(Qt::CrossCursor));
+ m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-currItem->width() / 2.0, -currItem->height() / 2.0, currItem->width(), currItem->height()));
+}
+
+void CanvasMode_EditMeshGradient::mouseReleaseEvent(QMouseEvent *m)
+{
+ m_canvas->m_viewMode.m_MouseButtonPressed = false;
+ m_canvas->resetRenderMode();
+ m->accept();
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ if (currItem->selectedMeshPointX >=0 && currItem->selectedMeshPointY >=0 && UndoManager::undoEnabled())
+ {
+ ScItemState<QPair<meshPoint,meshPoint> > *ss = new ScItemState<QPair<meshPoint,meshPoint> >(Um::GradPos);
+ ss->set("MOVE_MESH_PATCH","move_mesh_patch");
+ ss->set("ARRAY",true);
+ ss->set("X",currItem->selectedMeshPointX);
+ ss->set("Y",currItem->selectedMeshPointY);
+ if((*m_old_mesh) == currItem->meshGradientArray[currItem->selectedMeshPointX][currItem->selectedMeshPointY])
+ {
+ delete ss;
+ ss=NULL;
+ }
+ else
+ ss->setItem(qMakePair(*m_old_mesh,currItem->meshGradientArray[currItem->selectedMeshPointX][currItem->selectedMeshPointY]));
+ if(ss)
+ undoManager->action(currItem,ss);
+ }
+ currItem->update();
+ QTransform itemMatrix = currItem->getTransform();
+ m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-currItem->width() / 2.0, -currItem->height() / 2.0, currItem->width(), currItem->height()));
+}
Modified: trunk/Scribus/scribus/canvasmode_editmeshgradient.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_editmeshgradient.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editmeshgradient.h (original)
+++ trunk/Scribus/scribus/canvasmode_editmeshgradient.h Fri Nov 27 23:35:43 2015
@@ -1,83 +1,83 @@
-/*
- For general Scribus (>=1.3.2) copyright and licensing information please refer
- to the COPYING file provided with the program. Following this notice may exist
- a copyright and/or license notice that predates the release of Scribus 1.3.2
- for which a new license (GPL+exception) is in place.
- */
-/***************************************************************************
-* *
-* This program is free software; you can redistribute it and/or modify *
-* it under the terms of the GNU General Public License as published by *
-* the Free Software Foundation; either version 2 of the License, or *
-* (at your option) any later version. *
-* *
-***************************************************************************/
-/***************************************************************************
- canvasmode_editmeshgradient.h - description
- -------------------
- begin : Sat Apr 24 2010
- copyright : (C) 2010 by Franz Schmid
- email : Franz.Schmid at altmuehlnet.de
- ***************************************************************************/
-
-#ifndef CANVAS_MODE_EDITMESHGRADIENT_H
-#define CANVAS_MODE_EDITMESHGRADIENT_H
-
-#include <QObject>
-#include <QTime>
-
-#include "canvasmode.h"
-#include "fpointarray.h"
-
-class PageItem;
-class PageItem_TextFrame;
-class ScribusMainWindow;
-class ScribusView;
-class meshPoint;
-
-
-// This class encapsulate the old code for mouse interaction from scribusview.cpp
-
-class CanvasMode_EditMeshGradient : public CanvasMode
-{
-public:
- explicit CanvasMode_EditMeshGradient(ScribusView* view);
- virtual ~CanvasMode_EditMeshGradient();
-
- virtual void enterEvent(QEvent *);
- virtual void leaveEvent(QEvent *);
-
- virtual void activate(bool);
- virtual void deactivate(bool);
- virtual void mouseDoubleClickEvent(QMouseEvent *m);
- virtual void mouseReleaseEvent(QMouseEvent *m);
- virtual void mouseMoveEvent(QMouseEvent *m);
- virtual void mousePressEvent(QMouseEvent *m);
- virtual void keyPressEvent(QKeyEvent *e);
- virtual bool handleKeyEvents() { return true; }
- virtual void drawControls(QPainter* p);
- void drawControlsMeshGradient(QPainter* pp, PageItem* currItem);
-
-private:
-
- typedef enum
- {
- noPointDefined,
- useControlT,
- useControlB,
- useControlL,
- useControlR
- } eMGradientPoint;
-
- inline bool GetItem(PageItem** pi);
-
- meshPoint *old_mesh;
- double Mxp, Myp;
- ScribusMainWindow* m_ScMW;
- eMGradientPoint m_gradientPoint;
- QList<QPair<int, int> > selectedMeshPoints;
- bool m_keyRepeat;
-};
-
-
-#endif
+/*
+ For general Scribus (>=1.3.2) copyright and licensing information please refer
+ to the COPYING file provided with the program. Following this notice may exist
+ a copyright and/or license notice that predates the release of Scribus 1.3.2
+ for which a new license (GPL+exception) is in place.
+ */
+/***************************************************************************
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+***************************************************************************/
+/***************************************************************************
+ canvasmode_editmeshgradient.h - description
+ -------------------
+ begin : Sat Apr 24 2010
+ copyright : (C) 2010 by Franz Schmid
+ email : Franz.Schmid at altmuehlnet.de
+ ***************************************************************************/
+
+#ifndef CANVAS_MODE_EDITMESHGRADIENT_H
+#define CANVAS_MODE_EDITMESHGRADIENT_H
+
+#include <QObject>
+#include <QTime>
+
+#include "canvasmode.h"
+#include "fpointarray.h"
+
+class PageItem;
+class PageItem_TextFrame;
+class ScribusMainWindow;
+class ScribusView;
+class meshPoint;
+
+
+// This class encapsulate the old code for mouse interaction from scribusview.cpp
+
+class CanvasMode_EditMeshGradient : public CanvasMode
+{
+public:
+ explicit CanvasMode_EditMeshGradient(ScribusView* view);
+ virtual ~CanvasMode_EditMeshGradient();
+
+ virtual void enterEvent(QEvent *);
+ virtual void leaveEvent(QEvent *);
+
+ virtual void activate(bool);
+ virtual void deactivate(bool);
+ virtual void mouseDoubleClickEvent(QMouseEvent *m);
+ virtual void mouseReleaseEvent(QMouseEvent *m);
+ virtual void mouseMoveEvent(QMouseEvent *m);
+ virtual void mousePressEvent(QMouseEvent *m);
+ virtual void keyPressEvent(QKeyEvent *e);
+ virtual bool handleKeyEvents() { return true; }
+ virtual void drawControls(QPainter* p);
+ void drawControlsMeshGradient(QPainter* pp, PageItem* currItem);
+
+private:
+
+ typedef enum
+ {
+ noPointDefined,
+ useControlT,
+ useControlB,
+ useControlL,
+ useControlR
+ } eMGradientPoint;
+
+ inline bool GetItem(PageItem** pi);
+
+ meshPoint *m_old_mesh;
+ double m_Mxp, m_Myp;
+ ScribusMainWindow* m_ScMW;
+ eMGradientPoint m_gradientPoint;
+ QList<QPair<int, int> > m_selectedMeshPoints;
+ bool m_keyRepeat;
+};
+
+
+#endif
Modified: trunk/Scribus/scribus/canvasmode_editmeshpatch.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_editmeshpatch.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editmeshpatch.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_editmeshpatch.cpp Fri Nov 27 23:35:43 2015
@@ -64,17 +64,17 @@
CanvasMode_EditMeshPatch::CanvasMode_EditMeshPatch(ScribusView* view) : CanvasMode(view), m_ScMW(view->m_ScMW)
{
- Mxp = Myp = -1;
+ m_Mxp = m_Myp = -1;
m_patchPoint = noPointDefined;
m_gradientPoint = noControlPointDefined;
m_click_count = 0;
- old_mesh = new meshPoint();
+ m_old_mesh = new meshPoint();
}
CanvasMode_EditMeshPatch::~CanvasMode_EditMeshPatch()
{
- delete old_mesh;
- old_mesh = NULL;
+ delete m_old_mesh;
+ m_old_mesh = NULL;
}
inline bool CanvasMode_EditMeshPatch::GetItem(PageItem** pi)
@@ -298,15 +298,15 @@
m_canvas->m_viewMode.operItemResizing = false;
m_view->MidButt = false;
m_keyRepeat = false;
- currItem = m_doc->m_Selection->itemAt(0);
- Mxp = Myp = currItem->selectedMeshPointX = -1;
+ m_currItem = m_doc->m_Selection->itemAt(0);
+ m_Mxp = m_Myp = m_currItem->selectedMeshPointX = -1;
m_click_count = 0;
setModeCursor();
if (fromGesture)
{
m_view->update();
}
- currItem->snapToPatchGrid = false;
+ m_currItem->snapToPatchGrid = false;
}
void CanvasMode_EditMeshPatch::deactivate(bool forGesture)
@@ -315,16 +315,16 @@
m_patchPoint = noPointDefined;
m_gradientPoint = noControlPointDefined;
m_click_count = 0;
- currItem->selectedMeshPointX = -1;
- currItem->selectedMeshPointY = m_patchPoint;
- currItem->selectedMeshControlPoint = m_gradientPoint;
+ m_currItem->selectedMeshPointX = -1;
+ m_currItem->selectedMeshPointY = m_patchPoint;
+ m_currItem->selectedMeshControlPoint = m_gradientPoint;
m_ScMW->propertiesPalette->updateColorSpecialGradient();
- currItem->snapToPatchGrid = false;
+ m_currItem->snapToPatchGrid = false;
}
void CanvasMode_EditMeshPatch::keyPressEvent(QKeyEvent *e)
{
- if (currItem->selectedMeshPointX < 0)
+ if (m_currItem->selectedMeshPointX < 0)
return;
int kk = e->key();
if (m_keyRepeat)
@@ -534,7 +534,7 @@
{
if ((m_doc->m_Selection->isMultipleSelection()) && (m_doc->appMode == modeNormal))
{
- if (GetItem(&currItem))
+ if (GetItem(&m_currItem))
{
/* CB: old code, removing this as shift-alt select on an unselected table selects a cell now.
//#6789 is closed by sorting this.
@@ -553,7 +553,7 @@
}
else
{
- if (!(GetItem(&currItem) && (m_doc->appMode == modeEdit) && currItem->asTextFrame()))
+ if (!(GetItem(&m_currItem) && (m_doc->appMode == modeEdit) && m_currItem->asTextFrame()))
{
mousePressEvent(m);
return;
@@ -573,23 +573,23 @@
npfN = m_doc->ApplyGridF(FPoint(nx, ny));
else
npfN = FPoint(nx, ny);
- currItem = m_doc->m_Selection->itemAt(0);
- QTransform pp = currItem->getTransform();
+ m_currItem = m_doc->m_Selection->itemAt(0);
+ QTransform pp = m_currItem->getTransform();
FPoint npf = npfN.transformPoint(pp, true);
- FPoint npx(Mxp - npfN.x(), Myp - npfN.y(), 0, 0, currItem->rotation(), 1, 1, true);
+ FPoint npx(m_Mxp - npfN.x(), m_Myp - npfN.y(), 0, 0, m_currItem->rotation(), 1, 1, true);
if (m_view->editStrokeGradient == 11)
{
m_currentPoint = QPointF(npf.x(), npf.y());
m_canvas->displayXYHUD(m->globalPos(), npf.x(), npf.y());
- currItem->update();
+ m_currItem->update();
QRectF upRect;
- upRect = QRectF(QPointF(0, 0), QPointF(currItem->width(), currItem->height())).normalized();
- upRect.translate(currItem->xPos(), currItem->yPos());
- m_doc->regionsChanged()->update(upRect.adjusted(-10.0 - currItem->width() / 2.0, -10.0 - currItem->height() / 2.0, 10.0 + currItem->width() / 2.0, 10.0 + currItem->height() / 2.0));
+ upRect = QRectF(QPointF(0, 0), QPointF(m_currItem->width(), m_currItem->height())).normalized();
+ upRect.translate(m_currItem->xPos(), m_currItem->yPos());
+ m_doc->regionsChanged()->update(upRect.adjusted(-10.0 - m_currItem->width() / 2.0, -10.0 - m_currItem->height() / 2.0, 10.0 + m_currItem->width() / 2.0, 10.0 + m_currItem->height() / 2.0));
}
if (m_canvas->m_viewMode.m_MouseButtonPressed && m_view->moveTimerElapsed())
{
- if (currItem->selectedMeshPointX >= 0)
+ if (m_currItem->selectedMeshPointX >= 0)
{
if (m_patchPoint != noPointDefined)
{
@@ -599,33 +599,33 @@
FPoint gP;
if (m_patchPoint == useTL)
{
- cP = currItem->meshGradientPatches[currItem->selectedMeshPointX].TL.controlColor;
- gP = currItem->meshGradientPatches[currItem->selectedMeshPointX].TL.gridPoint;
+ cP = m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].TL.controlColor;
+ gP = m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].TL.gridPoint;
}
if (m_patchPoint == useTR)
{
- cP = currItem->meshGradientPatches[currItem->selectedMeshPointX].TR.controlColor;
- gP = currItem->meshGradientPatches[currItem->selectedMeshPointX].TR.gridPoint;
+ cP = m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].TR.controlColor;
+ gP = m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].TR.gridPoint;
}
if (m_patchPoint == useBR)
{
- cP = currItem->meshGradientPatches[currItem->selectedMeshPointX].BR.controlColor;
- gP = currItem->meshGradientPatches[currItem->selectedMeshPointX].BR.gridPoint;
+ cP = m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].BR.controlColor;
+ gP = m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].BR.gridPoint;
}
if (m_patchPoint == useBL)
{
- cP = currItem->meshGradientPatches[currItem->selectedMeshPointX].BL.controlColor;
- gP = currItem->meshGradientPatches[currItem->selectedMeshPointX].BL.gridPoint;
+ cP = m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].BL.controlColor;
+ gP = m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].BL.gridPoint;
}
m_canvas->displayXYHUD(m->globalPos(), cP.x() - gP.x(), cP.y() - gP.y());
if (m_patchPoint == useTL)
- currItem->meshGradientPatches[currItem->selectedMeshPointX].TL.controlColor -= npx;
+ m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].TL.controlColor -= npx;
if (m_patchPoint == useTR)
- currItem->meshGradientPatches[currItem->selectedMeshPointX].TR.controlColor -= npx;
+ m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].TR.controlColor -= npx;
if (m_patchPoint == useBR)
- currItem->meshGradientPatches[currItem->selectedMeshPointX].BR.controlColor -= npx;
+ m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].BR.controlColor -= npx;
if (m_patchPoint == useBL)
- currItem->meshGradientPatches[currItem->selectedMeshPointX].BL.controlColor -= npx;
+ m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].BL.controlColor -= npx;
}
else if (m_view->editStrokeGradient == 9)
{
@@ -636,58 +636,58 @@
double xx, yy;
if (m_patchPoint == useTL)
{
- mp_orig = currItem->meshGradientPatches[currItem->selectedMeshPointX].TL.gridPoint;
+ mp_orig = m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].TL.gridPoint;
mp = mp_orig - npx;
xx = mp.x();
yy = mp.y();
- if (currItem->snapToPatchGrid)
+ if (m_currItem->snapToPatchGrid)
snapToOtherPatch(xx, yy);
- currItem->meshGradientPatches[currItem->selectedMeshPointX].TL.moveAbs(xx, yy);
+ m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].TL.moveAbs(xx, yy);
}
if (m_patchPoint == useTR)
{
- mp_orig = currItem->meshGradientPatches[currItem->selectedMeshPointX].TR.gridPoint;
+ mp_orig = m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].TR.gridPoint;
mp = mp_orig - npx;
xx = mp.x();
yy = mp.y();
- if (currItem->snapToPatchGrid)
+ if (m_currItem->snapToPatchGrid)
snapToOtherPatch(xx, yy);
- currItem->meshGradientPatches[currItem->selectedMeshPointX].TR.moveAbs(xx, yy);
+ m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].TR.moveAbs(xx, yy);
}
if (m_patchPoint == useBR)
{
- mp_orig = currItem->meshGradientPatches[currItem->selectedMeshPointX].BR.gridPoint;
+ mp_orig = m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].BR.gridPoint;
mp = mp_orig - npx;
xx = mp.x();
yy = mp.y();
- if (currItem->snapToPatchGrid)
+ if (m_currItem->snapToPatchGrid)
snapToOtherPatch(xx, yy);
- currItem->meshGradientPatches[currItem->selectedMeshPointX].BR.moveAbs(xx, yy);
+ m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].BR.moveAbs(xx, yy);
}
if (m_patchPoint == useBL)
{
- mp_orig = currItem->meshGradientPatches[currItem->selectedMeshPointX].BL.gridPoint;
+ mp_orig = m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].BL.gridPoint;
mp = mp_orig - npx;
xx = mp.x();
yy = mp.y();
- if (currItem->snapToPatchGrid)
+ if (m_currItem->snapToPatchGrid)
snapToOtherPatch(xx, yy);
- currItem->meshGradientPatches[currItem->selectedMeshPointX].BL.moveAbs(xx, yy);
+ m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].BL.moveAbs(xx, yy);
}
if (m->modifiers() & Qt::ShiftModifier)
{
- for (int col = 0; col < currItem->meshGradientPatches.count(); col++)
+ for (int col = 0; col < m_currItem->meshGradientPatches.count(); col++)
{
- if (col != currItem->selectedMeshPointX)
+ if (col != m_currItem->selectedMeshPointX)
{
- if (currItem->meshGradientPatches[col].TL.gridPoint == mp_orig)
- currItem->meshGradientPatches[col].TL.moveAbs(xx, yy);
- if (currItem->meshGradientPatches[col].TR.gridPoint == mp_orig)
- currItem->meshGradientPatches[col].TR.moveAbs(xx, yy);
- if (currItem->meshGradientPatches[col].BR.gridPoint == mp_orig)
- currItem->meshGradientPatches[col].BR.moveAbs(xx, yy);
- if (currItem->meshGradientPatches[col].BL.gridPoint == mp_orig)
- currItem->meshGradientPatches[col].BL.moveAbs(xx, yy);
+ if (m_currItem->meshGradientPatches[col].TL.gridPoint == mp_orig)
+ m_currItem->meshGradientPatches[col].TL.moveAbs(xx, yy);
+ if (m_currItem->meshGradientPatches[col].TR.gridPoint == mp_orig)
+ m_currItem->meshGradientPatches[col].TR.moveAbs(xx, yy);
+ if (m_currItem->meshGradientPatches[col].BR.gridPoint == mp_orig)
+ m_currItem->meshGradientPatches[col].BR.moveAbs(xx, yy);
+ if (m_currItem->meshGradientPatches[col].BL.gridPoint == mp_orig)
+ m_currItem->meshGradientPatches[col].BL.moveAbs(xx, yy);
}
}
}
@@ -698,40 +698,40 @@
if (m_patchPoint == useTL)
{
if (m_gradientPoint == useControlB)
- currItem->meshGradientPatches[currItem->selectedMeshPointX].TL.controlBottom -= npx;
+ m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].TL.controlBottom -= npx;
else if (m_gradientPoint == useControlR)
- currItem->meshGradientPatches[currItem->selectedMeshPointX].TL.controlRight -= npx;
+ m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].TL.controlRight -= npx;
}
else if (m_patchPoint == useTR)
{
if (m_gradientPoint == useControlB)
- currItem->meshGradientPatches[currItem->selectedMeshPointX].TR.controlBottom -= npx;
+ m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].TR.controlBottom -= npx;
else if (m_gradientPoint == useControlL)
- currItem->meshGradientPatches[currItem->selectedMeshPointX].TR.controlLeft -= npx;
+ m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].TR.controlLeft -= npx;
}
else if (m_patchPoint == useBR)
{
if (m_gradientPoint == useControlT)
- currItem->meshGradientPatches[currItem->selectedMeshPointX].BR.controlTop -= npx;
+ m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].BR.controlTop -= npx;
else if (m_gradientPoint == useControlL)
- currItem->meshGradientPatches[currItem->selectedMeshPointX].BR.controlLeft -= npx;
+ m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].BR.controlLeft -= npx;
}
else if (m_patchPoint == useBL)
{
if (m_gradientPoint == useControlT)
- currItem->meshGradientPatches[currItem->selectedMeshPointX].BL.controlTop -= npx;
+ m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].BL.controlTop -= npx;
else if (m_gradientPoint == useControlR)
- currItem->meshGradientPatches[currItem->selectedMeshPointX].BL.controlRight -= npx;
- }
- }
- currItem->update();
- QTransform itemMatrix = currItem->getTransform();
- m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-currItem->width() / 2.0, -currItem->height() / 2.0, currItem->width(), currItem->height()));
- }
- }
- }
- Mxp = npfN.x();
- Myp = npfN.y();
+ m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].BL.controlRight -= npx;
+ }
+ }
+ m_currItem->update();
+ QTransform itemMatrix = m_currItem->getTransform();
+ m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, m_currItem->width(), m_currItem->height())).adjusted(-m_currItem->width() / 2.0, -m_currItem->height() / 2.0, m_currItem->width(), m_currItem->height()));
+ }
+ }
+ }
+ m_Mxp = npfN.x();
+ m_Myp = npfN.y();
}
void CanvasMode_EditMeshPatch::mousePressEvent(QMouseEvent *m)
@@ -746,8 +746,8 @@
m_doc->leaveDrag = false;
m->accept();
m_view->registerMousePress(m->globalPos());
- Mxp = mousePointDoc.x(); //m->x();
- Myp = mousePointDoc.y(); //m->y();
+ m_Mxp = mousePointDoc.x(); //m->x();
+ m_Myp = mousePointDoc.y(); //m->y();
if (m->button() == Qt::MidButton)
{
m_view->MidButt = true;
@@ -755,8 +755,8 @@
m_view->DrawNew();
return;
}
- currItem = m_doc->m_Selection->itemAt(0);
- QTransform itemMatrix = currItem->getTransform();
+ m_currItem = m_doc->m_Selection->itemAt(0);
+ QTransform itemMatrix = m_currItem->getTransform();
bool found = false;
if (m_view->editStrokeGradient == 11)
{
@@ -764,7 +764,7 @@
m_patchPoint = noPointDefined;
if (m_click_count == 0)
m_clickPointPolygon.clear();
- currItem->selectedMeshPointX = -1;
+ m_currItem->selectedMeshPointX = -1;
QTransform invItemMatrix = itemMatrix.inverted();
QPointF clickPoint = invItemMatrix.map(QPointF(mousePointDoc.x(), mousePointDoc.y()));
m_clickPointPolygon.append(clickPoint);
@@ -787,8 +787,8 @@
patch.BR = mgP;
mgP.resetTo(FPoint(m_clickPointPolygon.value(3).x(), m_clickPointPolygon.value(3).y()));
patch.BL = mgP;
- currItem->meshGradientPatches.append(patch);
- currItem->selectedMeshPointX = currItem->meshGradientPatches.count() - 1;
+ m_currItem->meshGradientPatches.append(patch);
+ m_currItem->selectedMeshPointX = m_currItem->meshGradientPatches.count() - 1;
m_view->editStrokeGradient = 9;
m_click_count = 0;
m_clickPointPolygon.clear();
@@ -797,11 +797,11 @@
}
else
{
- if (currItem->selectedMeshPointX >= 0)
+ if (m_currItem->selectedMeshPointX >= 0)
{
if (m_view->editStrokeGradient == 8)
{
- meshGradientPatch patch = currItem->meshGradientPatches[currItem->selectedMeshPointX];
+ meshGradientPatch patch = m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX];
meshPoint mp1 = patch.TL;
meshPoint mp2 = patch.TR;
meshPoint mp3 = patch.BR;
@@ -809,21 +809,21 @@
if ((m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y())))) || (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(QPointF(mp1.controlColor.x(), mp1.controlColor.y())))))
{
m_patchPoint = useTL;
- *old_mesh = mp1;
+ *m_old_mesh = mp1;
}
else if ((m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(QPointF(mp2.gridPoint.x(), mp2.gridPoint.y())))) || (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(QPointF(mp2.controlColor.x(), mp2.controlColor.y())))))
{
- *old_mesh = mp2;
+ *m_old_mesh = mp2;
m_patchPoint = useTR;
}
else if ((m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(QPointF(mp3.gridPoint.x(), mp3.gridPoint.y())))) || (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(QPointF(mp3.controlColor.x(), mp3.controlColor.y())))))
{
- *old_mesh = mp3;
+ *m_old_mesh = mp3;
m_patchPoint = useBR;
}
else if ((m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(QPointF(mp4.gridPoint.x(), mp4.gridPoint.y())))) || (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(QPointF(mp4.controlColor.x(), mp4.controlColor.y())))))
{
- *old_mesh = mp4;
+ *m_old_mesh = mp4;
m_patchPoint = useBL;
}
else
@@ -831,29 +831,29 @@
}
else if (m_view->editStrokeGradient == 9)
{
- meshGradientPatch patch = currItem->meshGradientPatches[currItem->selectedMeshPointX];
+ meshGradientPatch patch = m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX];
meshPoint mp1 = patch.TL;
meshPoint mp2 = patch.TR;
meshPoint mp3 = patch.BR;
meshPoint mp4 = patch.BL;
if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(QPointF(mp1.gridPoint.x(), mp1.gridPoint.y()))))
{
- *old_mesh = mp1;
+ *m_old_mesh = mp1;
m_patchPoint = useTL;
}
else if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(QPointF(mp2.gridPoint.x(), mp2.gridPoint.y()))))
{
- *old_mesh = mp2;
+ *m_old_mesh = mp2;
m_patchPoint = useTR;
}
else if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(QPointF(mp3.gridPoint.x(), mp3.gridPoint.y()))))
{
- *old_mesh = mp3;
+ *m_old_mesh = mp3;
m_patchPoint = useBR;
}
else if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(QPointF(mp4.gridPoint.x(), mp4.gridPoint.y()))))
{
- *old_mesh = mp4;
+ *m_old_mesh = mp4;
m_patchPoint = useBL;
}
else
@@ -863,7 +863,7 @@
{
if (m_patchPoint != noPointDefined)
{
- meshGradientPatch patch = currItem->meshGradientPatches[currItem->selectedMeshPointX];
+ meshGradientPatch patch = m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX];
meshPoint mp1 = patch.TL;
meshPoint mp2 = patch.TR;
meshPoint mp3 = patch.BR;
@@ -902,9 +902,9 @@
}
if (m_patchPoint == noPointDefined)
{
- for (int col = 0; col < currItem->meshGradientPatches.count(); col++)
- {
- meshGradientPatch patch = currItem->meshGradientPatches[col];
+ for (int col = 0; col < m_currItem->meshGradientPatches.count(); col++)
+ {
+ meshGradientPatch patch = m_currItem->meshGradientPatches[col];
meshPoint mp1 = patch.TL;
meshPoint mp2 = patch.TR;
meshPoint mp3 = patch.BR;
@@ -918,21 +918,21 @@
QPainterPath pat = itemMatrix.map(Bez);
if (pat.contains(QPointF(mousePointDoc.x(), mousePointDoc.y())))
{
- currItem->selectedMeshPointX = col;
+ m_currItem->selectedMeshPointX = col;
found = true;
break;
}
}
m_gradientPoint = noControlPointDefined;
if (!found)
- currItem->selectedMeshPointX = -1;
+ m_currItem->selectedMeshPointX = -1;
}
}
else
{
- for (int col = 0; col < currItem->meshGradientPatches.count(); col++)
- {
- meshGradientPatch patch = currItem->meshGradientPatches[col];
+ for (int col = 0; col < m_currItem->meshGradientPatches.count(); col++)
+ {
+ meshGradientPatch patch = m_currItem->meshGradientPatches[col];
meshPoint mp1 = patch.TL;
meshPoint mp2 = patch.TR;
meshPoint mp3 = patch.BR;
@@ -946,7 +946,7 @@
QPainterPath pat = itemMatrix.map(Bez);
if (pat.contains(QPointF(mousePointDoc.x(), mousePointDoc.y())))
{
- currItem->selectedMeshPointX = col;
+ m_currItem->selectedMeshPointX = col;
found = true;
break;
}
@@ -954,15 +954,15 @@
m_patchPoint = noPointDefined;
m_gradientPoint = noControlPointDefined;
if (!found)
- currItem->selectedMeshPointX = -1;
- }
- currItem->selectedMeshPointY = m_patchPoint;
- currItem->selectedMeshControlPoint = m_gradientPoint;
+ m_currItem->selectedMeshPointX = -1;
+ }
+ m_currItem->selectedMeshPointY = m_patchPoint;
+ m_currItem->selectedMeshControlPoint = m_gradientPoint;
}
m_canvas->m_viewMode.m_MouseButtonPressed = true;
m_ScMW->propertiesPalette->updateColorSpecialGradient();
m_view->setCursor(QCursor(Qt::CrossCursor));
- m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-currItem->width() / 2.0, -currItem->height() / 2.0, currItem->width(), currItem->height()));
+ m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, m_currItem->width(), m_currItem->height())).adjusted(-m_currItem->width() / 2.0, -m_currItem->height() / 2.0, m_currItem->width(), m_currItem->height()));
}
@@ -971,68 +971,68 @@
m_canvas->m_viewMode.m_MouseButtonPressed = false;
m_canvas->resetRenderMode();
m->accept();
- if (m_view->editStrokeGradient != 11 && currItem->selectedMeshPointX >=0 && m_patchPoint != noPointDefined && UndoManager::undoEnabled())
+ if (m_view->editStrokeGradient != 11 && m_currItem->selectedMeshPointX >=0 && m_patchPoint != noPointDefined && UndoManager::undoEnabled())
{
ScItemState<QPair<meshPoint,meshPoint> > *ss = new ScItemState<QPair<meshPoint,meshPoint> >(Um::GradPos);
ss->set("MOVE_MESH_PATCH","move_mesh_patch");
- ss->set("X",currItem->selectedMeshPointX);
- ss->set("Y",currItem->selectedMeshPointY);
+ ss->set("X",m_currItem->selectedMeshPointX);
+ ss->set("Y",m_currItem->selectedMeshPointY);
ss->set("ARRAY",false);
- switch(currItem->selectedMeshPointY){
+ switch(m_currItem->selectedMeshPointY){
case 1:
- if((*old_mesh) == currItem->meshGradientPatches[currItem->selectedMeshPointX].TL)
+ if((*m_old_mesh) == m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].TL)
{
delete ss;
ss=NULL;
}
else
- ss->setItem(qMakePair(*old_mesh,currItem->meshGradientPatches[currItem->selectedMeshPointX].TL));
+ ss->setItem(qMakePair(*m_old_mesh,m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].TL));
break;
case 2:
- if((*old_mesh) == currItem->meshGradientPatches[currItem->selectedMeshPointX].TR)
+ if((*m_old_mesh) == m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].TR)
{
delete ss;
ss=NULL;
}
else
- ss->setItem(qMakePair(*old_mesh,currItem->meshGradientPatches[currItem->selectedMeshPointX].TR));
+ ss->setItem(qMakePair(*m_old_mesh,m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].TR));
break;
case 3:
- if((*old_mesh) == currItem->meshGradientPatches[currItem->selectedMeshPointX].BR)
+ if((*m_old_mesh) == m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].BR)
{
delete ss;
ss=NULL;
}
else
- ss->setItem(qMakePair(*old_mesh,currItem->meshGradientPatches[currItem->selectedMeshPointX].BR));
+ ss->setItem(qMakePair(*m_old_mesh,m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].BR));
break;
case 4:
- if((*old_mesh) == currItem->meshGradientPatches[currItem->selectedMeshPointX].BL)
+ if((*m_old_mesh) == m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].BL)
{
delete ss;
ss=NULL;
}
else
- ss->setItem(qMakePair(*old_mesh,currItem->meshGradientPatches[currItem->selectedMeshPointX].BL));
+ ss->setItem(qMakePair(*m_old_mesh,m_currItem->meshGradientPatches[m_currItem->selectedMeshPointX].BL));
break;
}
if(ss)
- undoManager->action(currItem,ss);
- }
- currItem = m_doc->m_Selection->itemAt(0);
- currItem->update();
- QTransform itemMatrix = currItem->getTransform();
- m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-currItem->width() / 2.0, -currItem->height() / 2.0, currItem->width(), currItem->height()));
+ undoManager->action(m_currItem,ss);
+ }
+ m_currItem = m_doc->m_Selection->itemAt(0);
+ m_currItem->update();
+ QTransform itemMatrix = m_currItem->getTransform();
+ m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, m_currItem->width(), m_currItem->height())).adjusted(-m_currItem->width() / 2.0, -m_currItem->height() / 2.0, m_currItem->width(), m_currItem->height()));
}
void CanvasMode_EditMeshPatch::snapToOtherPatch(double &x, double &y)
{
int radius = m_doc->guidesPrefs().grabRadius;
- for (int col = 0; col < currItem->meshGradientPatches.count(); col++)
- {
- if (col != currItem->selectedMeshPointX)
- {
- meshGradientPatch patch = currItem->meshGradientPatches[col];
+ for (int col = 0; col < m_currItem->meshGradientPatches.count(); col++)
+ {
+ if (col != m_currItem->selectedMeshPointX)
+ {
+ meshGradientPatch patch = m_currItem->meshGradientPatches[col];
QPointF mp1 = QPointF(patch.TL.gridPoint.x(), patch.TL.gridPoint.y());
QPointF mp2 = QPointF(patch.TR.gridPoint.x(), patch.TR.gridPoint.y());
QPointF mp3 = QPointF(patch.BR.gridPoint.x(), patch.BR.gridPoint.y());
Modified: trunk/Scribus/scribus/canvasmode_editmeshpatch.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_editmeshpatch.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editmeshpatch.h (original)
+++ trunk/Scribus/scribus/canvasmode_editmeshpatch.h Fri Nov 27 23:35:43 2015
@@ -1,98 +1,98 @@
-/*
- For general Scribus (>=1.3.2) copyright and licensing information please refer
- to the COPYING file provided with the program. Following this notice may exist
- a copyright and/or license notice that predates the release of Scribus 1.3.2
- for which a new license (GPL+exception) is in place.
- */
-/***************************************************************************
-* *
-* This program is free software; you can redistribute it and/or modify *
-* it under the terms of the GNU General Public License as published by *
-* the Free Software Foundation; either version 2 of the License, or *
-* (at your option) any later version. *
-* *
-***************************************************************************/
-/***************************************************************************
- canvasmode_editmeshpatch.h - description
- -------------------
- begin : Sun Sep 25 2011
- copyright : (C) 2011 by Franz Schmid
- email : Franz.Schmid at altmuehlnet.de
- ***************************************************************************/
-
-#ifndef CANVASMODE_EDITMESHPATCH_H
-#define CANVASMODE_EDITMESHPATCH_H
-
-#include <QObject>
-#include <QTime>
-#include <QPolygonF>
-
-#include "canvasmode.h"
-#include "fpointarray.h"
-
-class meshPoint;
-class PageItem;
-class PageItem_TextFrame;
-class ScribusMainWindow;
-class ScribusView;
-
-
-// This class encapsulate the old code for mouse interaction from scribusview.cpp
-
-class CanvasMode_EditMeshPatch : public CanvasMode
-{
-public:
- explicit CanvasMode_EditMeshPatch(ScribusView* view);
- virtual ~CanvasMode_EditMeshPatch();
-
- virtual void enterEvent(QEvent *);
- virtual void leaveEvent(QEvent *);
-
- virtual void activate(bool);
- virtual void deactivate(bool);
- virtual void mouseDoubleClickEvent(QMouseEvent *m);
- virtual void mouseReleaseEvent(QMouseEvent *m);
- virtual void mouseMoveEvent(QMouseEvent *m);
- virtual void mousePressEvent(QMouseEvent *m);
- virtual void keyPressEvent(QKeyEvent *e);
- virtual bool handleKeyEvents() { return true; }
- virtual void drawControls(QPainter* p);
- void drawControlsMeshPoint(QPainter* psx, meshPoint mp, bool isSelected);
- void drawControlsMeshPatch(QPainter* pp, PageItem* currItem);
-
-private:
- void snapToOtherPatch(double &x, double &y);
- typedef enum
- {
- noPointDefined,
- useTL,
- useTR,
- useBR,
- useBL
- } eMPatchPoint;
-
- typedef enum
- {
- noControlPointDefined,
- useControlT,
- useControlB,
- useControlL,
- useControlR,
- useControlC
- } eMGradientPoint;
-
- inline bool GetItem(PageItem** pi);
-
- meshPoint* old_mesh;
- double Mxp, Myp;
- ScribusMainWindow* m_ScMW;
- eMPatchPoint m_patchPoint;
- eMGradientPoint m_gradientPoint;
- bool m_keyRepeat;
- int m_click_count;
- QPolygonF m_clickPointPolygon;
- QPointF m_currentPoint;
- PageItem *currItem;
-};
-
-#endif
+/*
+ For general Scribus (>=1.3.2) copyright and licensing information please refer
+ to the COPYING file provided with the program. Following this notice may exist
+ a copyright and/or license notice that predates the release of Scribus 1.3.2
+ for which a new license (GPL+exception) is in place.
+ */
+/***************************************************************************
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+***************************************************************************/
+/***************************************************************************
+ canvasmode_editmeshpatch.h - description
+ -------------------
+ begin : Sun Sep 25 2011
+ copyright : (C) 2011 by Franz Schmid
+ email : Franz.Schmid at altmuehlnet.de
+ ***************************************************************************/
+
+#ifndef CANVASMODE_EDITMESHPATCH_H
+#define CANVASMODE_EDITMESHPATCH_H
+
+#include <QObject>
+#include <QTime>
+#include <QPolygonF>
+
+#include "canvasmode.h"
+#include "fpointarray.h"
+
+class meshPoint;
+class PageItem;
+class PageItem_TextFrame;
+class ScribusMainWindow;
+class ScribusView;
+
+
+// This class encapsulate the old code for mouse interaction from scribusview.cpp
+
+class CanvasMode_EditMeshPatch : public CanvasMode
+{
+public:
+ explicit CanvasMode_EditMeshPatch(ScribusView* view);
+ virtual ~CanvasMode_EditMeshPatch();
+
+ virtual void enterEvent(QEvent *);
+ virtual void leaveEvent(QEvent *);
+
+ virtual void activate(bool);
+ virtual void deactivate(bool);
+ virtual void mouseDoubleClickEvent(QMouseEvent *m);
+ virtual void mouseReleaseEvent(QMouseEvent *m);
+ virtual void mouseMoveEvent(QMouseEvent *m);
+ virtual void mousePressEvent(QMouseEvent *m);
+ virtual void keyPressEvent(QKeyEvent *e);
+ virtual bool handleKeyEvents() { return true; }
+ virtual void drawControls(QPainter* p);
+ void drawControlsMeshPoint(QPainter* psx, meshPoint mp, bool isSelected);
+ void drawControlsMeshPatch(QPainter* pp, PageItem* currItem);
+
+private:
+ void snapToOtherPatch(double &x, double &y);
+ typedef enum
+ {
+ noPointDefined,
+ useTL,
+ useTR,
+ useBR,
+ useBL
+ } eMPatchPoint;
+
+ typedef enum
+ {
+ noControlPointDefined,
+ useControlT,
+ useControlB,
+ useControlL,
+ useControlR,
+ useControlC
+ } eMGradientPoint;
+
+ inline bool GetItem(PageItem** pi);
+
+ meshPoint* m_old_mesh;
+ double m_Mxp, m_Myp;
+ ScribusMainWindow* m_ScMW;
+ eMPatchPoint m_patchPoint;
+ eMGradientPoint m_gradientPoint;
+ bool m_keyRepeat;
+ int m_click_count;
+ QPolygonF m_clickPointPolygon;
+ QPointF m_currentPoint;
+ PageItem *m_currItem;
+};
+
+#endif
Modified: trunk/Scribus/scribus/canvasmode_editpolygon.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_editpolygon.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editpolygon.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_editpolygon.cpp Fri Nov 27 23:35:43 2015
@@ -1,520 +1,520 @@
-/*
- For general Scribus (>=1.3.2) copyright and licensing information please refer
- to the COPYING file provided with the program. Following this notice may exist
- a copyright and/or license notice that predates the release of Scribus 1.3.2
- for which a new license (GPL+exception) is in place.
- */
-/***************************************************************************
-* *
-* This program is free software; you can redistribute it and/or modify *
-* it under the terms of the GNU General Public License as published by *
-* the Free Software Foundation; either version 2 of the License, or *
-* (at your option) any later version. *
-* *
-***************************************************************************/
-/***************************************************************************
- canvasmode_editpolygon.cpp - description
- -------------------
- begin : Wed Jan 12 2011
- copyright : (C) 2011 by Franz Schmid
- email : Franz.Schmid at altmuehlnet.de
- ***************************************************************************/
-
-
-#include "canvasmode_editpolygon.h"
-
-#include <QApplication>
-#include <QButtonGroup>
-#include <QCheckBox>
-#include <QCursor>
-#include <QEvent>
-#include <QMessageBox>
-#include <QMouseEvent>
-#include <QPainterPath>
-#include <QPoint>
-#include <QRect>
-#include <QTimer>
-#include <QWidgetAction>
-#include <QDebug>
-
-#include "appmodes.h"
-#include "canvas.h"
-#include "fpoint.h"
-#include "fpointarray.h"
-#include "pageitem_regularpolygon.h"
-#include "prefscontext.h"
-#include "prefsfile.h"
-#include "prefsmanager.h"
-#include "scribus.h"
-#include "scribusXml.h"
-#include "scribusdoc.h"
-#include "scribusview.h"
-#include "selection.h"
-#include "ui/aligndistribute.h"
-#include "ui/contextmenu.h"
-#include "ui/pageselector.h"
-#include "ui/polygonwidget.h"
-#include "ui/propertiespalette.h"
-#include "undomanager.h"
-#include "units.h"
-#include "util.h"
-#include "util_math.h"
-
-
-CanvasMode_EditPolygon::CanvasMode_EditPolygon(ScribusView* view) : CanvasMode(view), m_ScMW(view->m_ScMW)
-{
- Mxp = Myp = -1;
- m_blockUpdateFromItem = 0;
- m_polygonPoint = noPointDefined;
-}
-
-inline bool CanvasMode_EditPolygon::GetItem(PageItem** pi)
-{
- *pi = m_doc->m_Selection->itemAt(0);
- return (*pi) != NULL;
-}
-
-void CanvasMode_EditPolygon::drawControls(QPainter* p)
-{
- p->save();
- if (m_canvas->m_viewMode.operItemMoving)
- drawOutline(p);
- else
- drawSelection(p, false);
- if (m_doc->appMode == modeEditPolygon)
- drawControlsPolygon(p, m_doc->m_Selection->itemAt(0));
- p->restore();
-}
-
-void CanvasMode_EditPolygon::drawControlsPolygon(QPainter* psx, PageItem* currItem)
-{
- QPen p1b = QPen(Qt::blue, 1.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
- QPen p1bd = QPen(Qt::red, 1.0 / m_canvas->m_viewMode.scale, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin);
- QPen p8b = QPen(Qt::blue, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin);
- QPen p8r = QPen(Qt::red, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin);
- psx->setTransform(currItem->getTransform(), true);
- psx->setPen(p1b);
- psx->setBrush(Qt::NoBrush);
- PageItem_RegularPolygon* item = currItem->asRegularPolygon();
- QPainterPath path = RegularPolygonPath(item->width(), item->height(), polyCorners, polyUseFactor, polyFactor, polyRotation, polyCurvature, polyInnerRot, polyOuterCurvature);
- psx->drawPath(path);
- psx->setPen(p1bd);
- psx->drawLine(startPoint, endPoint);
- if (polyUseFactor)
- {
- psx->drawLine(endPoint, innerCPoint);
- psx->drawLine(startPoint, outerCPoint);
- }
- psx->setPen(p8b);
- if (m_polygonPoint == useControlOuter)
- psx->setPen(p8r);
- else
- psx->setPen(p8b);
- psx->drawPoint(startPoint);
- if (m_polygonPoint == useControlInner)
- psx->setPen(p8r);
- else
- psx->setPen(p8b);
- psx->drawPoint(endPoint);
- if (polyUseFactor)
- {
- if (m_polygonPoint == useControlInnerCurve)
- psx->setPen(p8r);
- else
- psx->setPen(p8b);
- psx->drawPoint(innerCPoint);
- if (m_polygonPoint == useControlOuterCurve)
- psx->setPen(p8r);
- else
- psx->setPen(p8b);
- psx->drawPoint(outerCPoint);
- }
-}
-
-void CanvasMode_EditPolygon::enterEvent(QEvent *)
-{
- if (!m_canvas->m_viewMode.m_MouseButtonPressed)
- setModeCursor();
-}
-
-void CanvasMode_EditPolygon::leaveEvent(QEvent *e)
-{
-}
-
-void CanvasMode_EditPolygon::updateFromItem()
-{
- if (updateFromItemBlocked())
- return;
- PageItem *currItem = m_doc->m_Selection->itemAt(0);
- PageItem_RegularPolygon* item = currItem->asRegularPolygon();
- centerPoint = QPointF(currItem->width() / 2.0, currItem->height() / 2.0);
- startPoint = currItem->PoLine.pointQF(0);
- endPoint = currItem->PoLine.pointQF(2);
- polyCorners = item->polyCorners;
- polyUseFactor = item->polyUseFactor;
- polyFactor = item->polyFactor;
- polyRotation = item->polyRotation;
- polyCurvature = item->polyCurvature;
- polyInnerRot = item->polyInnerRot;
- polyOuterCurvature = item->polyOuterCurvature;
- VectorDialog->polyWidget->blockSignals(true);
- VectorDialog->setValues(polyCorners, polyFactor, polyUseFactor, polyRotation, polyCurvature, polyInnerRot, polyOuterCurvature);
- VectorDialog->polyWidget->blockSignals(false);
- uint cx = polyUseFactor ? polyCorners * 2 : polyCorners;
- double seg = 360.0 / cx;
- double trueLength = sqrt(pow(sin(seg / 180.0 * M_PI) * (item->width() / 2.0), 2) + pow(cos(seg / 180.0 * M_PI) * (item->height() / 2.0) + (item->height()/2.0) - item->height(), 2));
- QLineF innerLine = QLineF(endPoint, centerPoint);
- innerLine.setAngle(innerLine.angle() + 90);
- innerLine.setLength(trueLength * polyCurvature);
- innerCPoint = innerLine.p2();
- QLineF outerLine = QLineF(startPoint, currItem->PoLine.pointQF(6));
- outerLine.setLength(outerLine.length() * polyOuterCurvature);
- outerCPoint = outerLine.p2();
- m_view->update();
-}
-
-void CanvasMode_EditPolygon::activate(bool fromGesture)
-{
- m_polygonPoint = noPointDefined;
- m_canvas->m_viewMode.m_MouseButtonPressed = false;
- m_canvas->resetRenderMode();
- m_doc->DragP = false;
- m_doc->leaveDrag = false;
- m_canvas->m_viewMode.operItemMoving = false;
- m_canvas->m_viewMode.operItemResizing = false;
- m_view->MidButt = false;
- Mxp = Myp = -1;
- PageItem *currItem = m_doc->m_Selection->itemAt(0);
- PageItem_RegularPolygon* item = currItem->asRegularPolygon();
- centerPoint = QPointF(currItem->width() / 2.0, currItem->height() / 2.0);
- startPoint = currItem->PoLine.pointQF(0);
- endPoint = currItem->PoLine.pointQF(2);
- polyCorners = item->polyCorners;
- polyUseFactor = item->polyUseFactor;
- polyFactor = item->polyFactor;
- polyRotation = item->polyRotation;
- polyCurvature = item->polyCurvature;
- polyInnerRot = item->polyInnerRot;
- polyOuterCurvature = item->polyOuterCurvature;
- VectorDialog = new PolyVectorDialog(m_ScMW, polyCorners, polyFactor, polyUseFactor, polyRotation, polyCurvature, polyInnerRot, polyOuterCurvature);
- VectorDialog->show();
- uint cx = polyUseFactor ? polyCorners * 2 : polyCorners;
- double seg = 360.0 / cx;
- double trueLength = sqrt(pow(sin(seg / 180.0 * M_PI) * (item->width() / 2.0), 2) + pow(cos(seg / 180.0 * M_PI) * (item->height() / 2.0) + (item->height()/2.0) - item->height(), 2));
- QLineF innerLine = QLineF(endPoint, centerPoint);
- innerLine.setAngle(innerLine.angle() + 90);
- innerLine.setLength(trueLength * polyCurvature);
- innerCPoint = innerLine.p2();
- QLineF outerLine = QLineF(startPoint, currItem->PoLine.pointQF(6));
- outerLine.setLength(outerLine.length() * polyOuterCurvature);
- outerCPoint = outerLine.p2();
- setModeCursor();
- if (fromGesture)
- m_view->update();
- connect(m_doc, SIGNAL(docChanged()), this, SLOT(updateFromItem()));
-
- connect(VectorDialog, SIGNAL(NewVectors(int, double, bool, double, double, double, double)), this, SLOT(applyValues(int, double, bool, double, double, double, double)));
- connect(VectorDialog, SIGNAL(endEdit()), this, SLOT(endEditing()));
- connect(VectorDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool)));
-}
-
-void CanvasMode_EditPolygon::deactivate(bool forGesture)
-{
- disconnect(VectorDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool)));
- VectorDialog->close();
- VectorDialog->deleteLater();
- m_view->setRedrawMarkerShown(false);
- m_polygonPoint = noPointDefined;
- disconnect(m_doc, SIGNAL(docChanged()), this, SLOT(updateFromItem()));
-}
-
-void CanvasMode_EditPolygon::endEditing(bool active)
-{
- if (!active)
- endEditing();
-}
-
-void CanvasMode_EditPolygon::endEditing()
-{
- m_view->requestMode(modeNormal);
-}
-
-void CanvasMode_EditPolygon::applyValues(int polyC, double polyF, bool polyUseCF, double polyR, double polyCur, double polyIRot, double polyOCur)
-{
- PageItem *currItem = m_doc->m_Selection->itemAt(0);
- PageItem_RegularPolygon* item = currItem->asRegularPolygon();
- QRectF oldRect = item->getBoundingRect();
- polyCorners = polyC;
- polyFactor = polyF;
- polyRotation = polyR;
- polyCurvature = polyCur;
- polyInnerRot = polyIRot;
- polyOuterCurvature = polyOCur;
- if (UndoManager::undoEnabled())
- {
- SimpleState *ss = new SimpleState(Um::EditPolygon,"",Um::IPolygon);
- ss->set("POLYGON","polygon");
- ss->set("NEW_CORNER",polyC);
- ss->set("NEW_USEFACTOR",polyUseCF);
- ss->set("NEW_FACTOR",polyFactor);
- ss->set("NEW_ROTATION",polyRotation);
- ss->set("NEW_CURV",polyCurvature);
- ss->set("NEW_INNER",polyInnerRot);
- ss->set("NEW_OUTER",polyOuterCurvature);
- ss->set("OLD_CORNER",item->polyCorners);
- ss->set("OLD_USEFACTOR",item->polyUseFactor);
- ss->set("OLD_FACTOR",item->polyFactor);
- ss->set("OLD_ROTATION",item->polyRotation);
- ss->set("OLD_CURV",item->polyCurvature);
- ss->set("OLD_INNER",item->polyInnerRot);
- ss->set("OLD_OUTER",item->polyOuterCurvature);
- undoManager->action(currItem,ss);
- }
- item->polyCorners = polyC;
- item->polyUseFactor = polyUseCF;
- item->polyFactor = polyFactor;
- item->polyRotation = polyRotation;
- item->polyCurvature = polyCurvature;
- item->polyInnerRot = polyInnerRot;
- item->polyOuterCurvature = polyOuterCurvature;
- item->recalcPath();
- updateFromItem();
- QTransform itemMatrix = currItem->getTransform();
- QPainterPath path = itemMatrix.map(RegularPolygonPath(item->width(), item->height(), polyCorners, polyUseFactor, polyFactor, polyRotation, polyCurvature, polyInnerRot, polyOuterCurvature));
- QRectF updateRect = oldRect.united(path.boundingRect());
- m_doc->regionsChanged()->update(updateRect.adjusted(-5, -5, 10, 10));
-}
-
-double CanvasMode_EditPolygon::getUserValFromFactor(double factor)
-{
- double userVal = 0.0;
- double mi = GetZeroFactor();
- double ma = GetMaxFactor();
- if ((factor / mi * 100.0 - 100.0) > 0)
- userVal = (factor - mi) / (ma - mi) * 100.0;
- else
- userVal = factor / mi * 100.0 - 100.0;
- return userVal;
-}
-
-double CanvasMode_EditPolygon::GetZeroFactor()
-{
- return sqrt(pow(1.0,2.0)-pow(((sin((360.0/(polyCorners*2))/180* M_PI)* 2.0)/2.0),2.0));
-}
-
-double CanvasMode_EditPolygon::GetMaxFactor()
-{
- double win = (360.0/(polyCorners*2)) / 180.0 * M_PI;
- double ret;
- if ((360.0/(polyCorners*2)) > 45)
- ret = 1/sin(win);
- else
- ret = 1/cos(win);
- return ret;
-}
-
-void CanvasMode_EditPolygon::mouseDoubleClickEvent(QMouseEvent *m)
-{
- m->accept();
- m_canvas->m_viewMode.m_MouseButtonPressed = false;
- m_canvas->resetRenderMode();
- m_view->requestMode(modeNormal);
-}
-
-void CanvasMode_EditPolygon::mouseMoveEvent(QMouseEvent *m)
-{
- const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
- m->accept();
- double newX = mousePointDoc.x();
- double newY = mousePointDoc.y();
- if (m_canvas->m_viewMode.m_MouseButtonPressed && m_view->moveTimerElapsed())
- {
- PageItem *currItem = m_doc->m_Selection->itemAt(0);
- QTransform itemMatrix = currItem->getTransform();
- QPointF cPoint = itemMatrix.map(centerPoint);
- QLineF stLinA = QLineF(cPoint, QPointF(newX, newY));
-
- uint cx = polyUseFactor ? polyCorners * 2 : polyCorners;
- double seg = 360.0 / cx;
- double trueLength = sqrt(pow(sin(seg / 180.0 * M_PI) * (currItem->width() / 2.0), 2) + pow(cos(seg / 180.0 * M_PI) * (currItem->height() / 2.0) + (currItem->height()/2.0) - currItem->height(), 2));
-
- if (m_polygonPoint == useControlInner)
- {
- polyInnerRot = stLinA.angle() - 90 - polyRotation - seg;
- double factor = stLinA.length() / sqrt(pow(sin(stLinA.angle() * M_PI / 180.0) * currItem->height() / 2.0, 2) + pow(cos(stLinA.angle() * M_PI / 180.0) * currItem->width() / 2.0, 2));
- int maxF = qRound(getUserValFromFactor(factor));
- if (maxF <= 100)
- polyFactor = factor;
- }
- if (m_polygonPoint == useControlOuter)
- {
- polyRotation = stLinA.angle() - 90;
- if (polyRotation < -180)
- polyRotation += 360;
- if (polyRotation > 180)
- polyRotation -= 360;
- }
- if (m_polygonPoint == useControlInnerCurve)
- {
- QPointF ePoint = itemMatrix.map(endPoint);
- QLineF stLinC = QLineF(ePoint, QPointF(newX, newY));
- polyCurvature = stLinC.length() / trueLength;
- }
- if (m_polygonPoint == useControlOuterCurve)
- {
- QPointF sPoint = itemMatrix.map(startPoint);
- QPointF sPoint2 = itemMatrix.map(currItem->PoLine.pointQF(6));
- QLineF stLinCo = QLineF(sPoint, QPointF(newX, newY));
- QLineF stLinCo2 = QLineF(sPoint, sPoint2);
- polyOuterCurvature = stLinCo.length() / stLinCo2.length();
- }
- QPainterPath path = RegularPolygonPath(currItem->width(), currItem->height(), polyCorners, polyUseFactor, polyFactor, polyRotation, polyCurvature, polyInnerRot, polyOuterCurvature);
- FPointArray ar;
- ar.fromQPainterPath(path);
- endPoint = ar.pointQF(2);
- startPoint = ar.pointQF(0);
- QLineF innerLine = QLineF(endPoint, centerPoint);
- innerLine.setAngle(innerLine.angle() + 90);
- innerLine.setLength(trueLength * polyCurvature);
- innerCPoint = innerLine.p2();
- QLineF outerLine = QLineF(startPoint, ar.pointQF(6));
- outerLine.setLength(outerLine.length() * polyOuterCurvature);
- outerCPoint = outerLine.p2();
- VectorDialog->setValues(polyCorners, polyFactor, polyUseFactor, polyRotation, polyCurvature, polyInnerRot, polyOuterCurvature);
- blockUpdateFromItem(true);
- currItem->update();
- blockUpdateFromItem(false);
- path = itemMatrix.map(path);
- m_doc->regionsChanged()->update(path.boundingRect().adjusted(-5, -5, 10, 10));
- }
- Mxp = newX;
- Myp = newY;
-}
-
-void CanvasMode_EditPolygon::mousePressEvent(QMouseEvent *m)
-{
- const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
-
- m_canvas->PaintSizeRect(QRect());
- m_canvas->m_viewMode.m_MouseButtonPressed = true;
- m_canvas->m_viewMode.operItemMoving = false;
- m_view->HaveSelRect = false;
- m_doc->DragP = false;
- m_doc->leaveDrag = false;
- m->accept();
- m_view->registerMousePress(m->globalPos());
- Mxp = mousePointDoc.x(); //m->x();
- Myp = mousePointDoc.y(); //m->y();
- if (m->button() == Qt::MidButton)
- {
- m_view->MidButt = true;
- if (m->modifiers() & Qt::ControlModifier)
- m_view->DrawNew();
- return;
- }
- PageItem *currItem = m_doc->m_Selection->itemAt(0);
- QTransform itemMatrix = currItem->getTransform();
- QPointF stPoint = startPoint;
- stPoint = itemMatrix.map(stPoint);
- QPointF swPoint = endPoint;
- swPoint = itemMatrix.map(swPoint);
- QPointF shPoint = innerCPoint;
- shPoint = itemMatrix.map(shPoint);
- QPointF sPoint = outerCPoint;
- sPoint = itemMatrix.map(sPoint);
- bool useOuter = m_canvas->hitsCanvasPoint(m->globalPos(), stPoint);
- bool useInner = m_canvas->hitsCanvasPoint(m->globalPos(), swPoint);
- bool useInnerC = m_canvas->hitsCanvasPoint(m->globalPos(), shPoint);
- bool useOuterC = m_canvas->hitsCanvasPoint(m->globalPos(), sPoint);
- if (useOuter && useOuterC)
- {
- if (m->modifiers() == Qt::ShiftModifier)
- m_polygonPoint = useControlOuterCurve;
- else
- m_polygonPoint = useControlOuter;
- }
- else if (useOuter || useOuterC)
- {
- if (useOuterC)
- m_polygonPoint = useControlOuterCurve;
- else
- m_polygonPoint = useControlOuter;
- }
- else if (useInner && useInnerC)
- {
- if (m->modifiers() == Qt::ShiftModifier)
- m_polygonPoint = useControlInnerCurve;
- else
- m_polygonPoint = useControlInner;
- }
- else if (useInner || useInnerC)
- {
- if (useInnerC)
- m_polygonPoint = useControlInnerCurve;
- else
- m_polygonPoint = useControlInner;
- }
- else
- m_polygonPoint = noPointDefined;
- if (m_polygonPoint != noPointDefined && UndoManager::undoEnabled())
- m_transaction = undoManager->beginTransaction(Um::Polygon, Um::IPolygon, Um::EditPolygon, "", Um::IPolygon);
- m_view->setCursor(QCursor(Qt::CrossCursor));
- QPainterPath path = itemMatrix.map(RegularPolygonPath(currItem->width(), currItem->height(), polyCorners, polyUseFactor, polyFactor, polyRotation, polyCurvature, polyInnerRot, polyOuterCurvature));
- m_doc->regionsChanged()->update(path.boundingRect().adjusted(-5, -5, 10, 10));
-}
-
-void CanvasMode_EditPolygon::mouseReleaseEvent(QMouseEvent *m)
-{
- const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
- m_canvas->m_viewMode.m_MouseButtonPressed = false;
- m_canvas->resetRenderMode();
- m->accept();
- PageItem *currItem = m_doc->m_Selection->itemAt(0);
- PageItem_RegularPolygon* item = currItem->asRegularPolygon();
- QTransform itemMatrix = currItem->getTransform();
- if ((m_polygonPoint == useControlInner) || (m_polygonPoint == useControlOuter) || (m_polygonPoint == useControlInnerCurve) || (m_polygonPoint == useControlOuterCurve))
- {
- double newX = mousePointDoc.x();
- double newY = mousePointDoc.y();
- QPointF cPoint = itemMatrix.map(centerPoint);
- QLineF stLinA = QLineF(cPoint, QPointF(newX, newY));
- uint cx = polyUseFactor ? polyCorners * 2 : polyCorners;
- double seg = 360.0 / cx;
- double trueLength = sqrt(pow(sin(seg / 180.0 * M_PI) * (currItem->width() / 2.0), 2) + pow(cos(seg / 180.0 * M_PI) * (currItem->height() / 2.0) + (currItem->height()/2.0) - currItem->height(), 2));
- if (m_polygonPoint == useControlInner)
- {
- polyInnerRot = stLinA.angle() - 90 - polyRotation - seg;
- polyFactor = stLinA.length() / sqrt(pow(sin(stLinA.angle() * M_PI / 180.0) * currItem->height() / 2.0, 2) + pow(cos(stLinA.angle() * M_PI / 180.0) * currItem->width() / 2.0, 2));
- }
- if (m_polygonPoint == useControlOuter)
- polyRotation = stLinA.angle() - 90;
- if (m_polygonPoint == useControlInnerCurve)
- {
- QPointF ePoint = itemMatrix.map(endPoint);
- QLineF stLinC = QLineF(ePoint, QPointF(newX, newY));
- polyCurvature = stLinC.length() / trueLength;
- }
- if (m_polygonPoint == useControlOuterCurve)
- {
- QPointF sPoint = itemMatrix.map(startPoint);
- QPointF sPoint2 = itemMatrix.map(currItem->PoLine.pointQF(6));
- QLineF stLinCo = QLineF(sPoint, QPointF(newX, newY));
- QLineF stLinCo2 = QLineF(sPoint, sPoint2);
- polyOuterCurvature = stLinCo.length() / stLinCo2.length();
- }
- item->polyFactor = polyFactor;
- item->polyRotation = polyRotation;
- item->polyCurvature = polyCurvature;
- item->polyInnerRot = polyInnerRot;
- item->polyOuterCurvature = polyOuterCurvature;
- item->recalcPath();
- VectorDialog->setValues(polyCorners, polyFactor, polyUseFactor, polyRotation, polyCurvature, polyInnerRot, polyOuterCurvature);
- if (m_transaction)
- {
- m_transaction.commit();
- m_transaction.reset();
- }
- }
- QPainterPath path = itemMatrix.map(RegularPolygonPath(item->width(), item->height(), polyCorners, polyUseFactor, polyFactor, polyRotation, polyCurvature, polyInnerRot, polyOuterCurvature));
- m_doc->regionsChanged()->update(path.boundingRect().adjusted(-5, -5, 10, 10));
-}
+/*
+ For general Scribus (>=1.3.2) copyright and licensing information please refer
+ to the COPYING file provided with the program. Following this notice may exist
+ a copyright and/or license notice that predates the release of Scribus 1.3.2
+ for which a new license (GPL+exception) is in place.
+ */
+/***************************************************************************
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+***************************************************************************/
+/***************************************************************************
+ canvasmode_editpolygon.cpp - description
+ -------------------
+ begin : Wed Jan 12 2011
+ copyright : (C) 2011 by Franz Schmid
+ email : Franz.Schmid at altmuehlnet.de
+ ***************************************************************************/
+
+
+#include "canvasmode_editpolygon.h"
+
+#include <QApplication>
+#include <QButtonGroup>
+#include <QCheckBox>
+#include <QCursor>
+#include <QEvent>
+#include <QMessageBox>
+#include <QMouseEvent>
+#include <QPainterPath>
+#include <QPoint>
+#include <QRect>
+#include <QTimer>
+#include <QWidgetAction>
+#include <QDebug>
+
+#include "appmodes.h"
+#include "canvas.h"
+#include "fpoint.h"
+#include "fpointarray.h"
+#include "pageitem_regularpolygon.h"
+#include "prefscontext.h"
+#include "prefsfile.h"
+#include "prefsmanager.h"
+#include "scribus.h"
+#include "scribusXml.h"
+#include "scribusdoc.h"
+#include "scribusview.h"
+#include "selection.h"
+#include "ui/aligndistribute.h"
+#include "ui/contextmenu.h"
+#include "ui/pageselector.h"
+#include "ui/polygonwidget.h"
+#include "ui/propertiespalette.h"
+#include "undomanager.h"
+#include "units.h"
+#include "util.h"
+#include "util_math.h"
+
+
+CanvasMode_EditPolygon::CanvasMode_EditPolygon(ScribusView* view) : CanvasMode(view), m_ScMW(view->m_ScMW)
+{
+ m_Mxp = m_Myp = -1;
+ m_blockUpdateFromItem = 0;
+ m_polygonPoint = noPointDefined;
+}
+
+inline bool CanvasMode_EditPolygon::GetItem(PageItem** pi)
+{
+ *pi = m_doc->m_Selection->itemAt(0);
+ return (*pi) != NULL;
+}
+
+void CanvasMode_EditPolygon::drawControls(QPainter* p)
+{
+ p->save();
+ if (m_canvas->m_viewMode.operItemMoving)
+ drawOutline(p);
+ else
+ drawSelection(p, false);
+ if (m_doc->appMode == modeEditPolygon)
+ drawControlsPolygon(p, m_doc->m_Selection->itemAt(0));
+ p->restore();
+}
+
+void CanvasMode_EditPolygon::drawControlsPolygon(QPainter* psx, PageItem* currItem)
+{
+ QPen p1b = QPen(Qt::blue, 1.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+ QPen p1bd = QPen(Qt::red, 1.0 / m_canvas->m_viewMode.scale, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin);
+ QPen p8b = QPen(Qt::blue, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin);
+ QPen p8r = QPen(Qt::red, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin);
+ psx->setTransform(currItem->getTransform(), true);
+ psx->setPen(p1b);
+ psx->setBrush(Qt::NoBrush);
+ PageItem_RegularPolygon* item = currItem->asRegularPolygon();
+ QPainterPath path = RegularPolygonPath(item->width(), item->height(), m_polyCorners, m_polyUseFactor, m_polyFactor, m_polyRotation, m_polyCurvature, m_polyInnerRot, m_polyOuterCurvature);
+ psx->drawPath(path);
+ psx->setPen(p1bd);
+ psx->drawLine(m_startPoint, m_endPoint);
+ if (m_polyUseFactor)
+ {
+ psx->drawLine(m_endPoint, m_innerCPoint);
+ psx->drawLine(m_startPoint, m_outerCPoint);
+ }
+ psx->setPen(p8b);
+ if (m_polygonPoint == useControlOuter)
+ psx->setPen(p8r);
+ else
+ psx->setPen(p8b);
+ psx->drawPoint(m_startPoint);
+ if (m_polygonPoint == useControlInner)
+ psx->setPen(p8r);
+ else
+ psx->setPen(p8b);
+ psx->drawPoint(m_endPoint);
+ if (m_polyUseFactor)
+ {
+ if (m_polygonPoint == useControlInnerCurve)
+ psx->setPen(p8r);
+ else
+ psx->setPen(p8b);
+ psx->drawPoint(m_innerCPoint);
+ if (m_polygonPoint == useControlOuterCurve)
+ psx->setPen(p8r);
+ else
+ psx->setPen(p8b);
+ psx->drawPoint(m_outerCPoint);
+ }
+}
+
+void CanvasMode_EditPolygon::enterEvent(QEvent *)
+{
+ if (!m_canvas->m_viewMode.m_MouseButtonPressed)
+ setModeCursor();
+}
+
+void CanvasMode_EditPolygon::leaveEvent(QEvent *e)
+{
+}
+
+void CanvasMode_EditPolygon::updateFromItem()
+{
+ if (updateFromItemBlocked())
+ return;
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ PageItem_RegularPolygon* item = currItem->asRegularPolygon();
+ m_centerPoint = QPointF(currItem->width() / 2.0, currItem->height() / 2.0);
+ m_startPoint = currItem->PoLine.pointQF(0);
+ m_endPoint = currItem->PoLine.pointQF(2);
+ m_polyCorners = item->polyCorners;
+ m_polyUseFactor = item->polyUseFactor;
+ m_polyFactor = item->polyFactor;
+ m_polyRotation = item->polyRotation;
+ m_polyCurvature = item->polyCurvature;
+ m_polyInnerRot = item->polyInnerRot;
+ m_polyOuterCurvature = item->polyOuterCurvature;
+ m_VectorDialog->polyWidget->blockSignals(true);
+ m_VectorDialog->setValues(m_polyCorners, m_polyFactor, m_polyUseFactor, m_polyRotation, m_polyCurvature, m_polyInnerRot, m_polyOuterCurvature);
+ m_VectorDialog->polyWidget->blockSignals(false);
+ uint cx = m_polyUseFactor ? m_polyCorners * 2 : m_polyCorners;
+ double seg = 360.0 / cx;
+ double trueLength = sqrt(pow(sin(seg / 180.0 * M_PI) * (item->width() / 2.0), 2) + pow(cos(seg / 180.0 * M_PI) * (item->height() / 2.0) + (item->height()/2.0) - item->height(), 2));
+ QLineF innerLine = QLineF(m_endPoint, m_centerPoint);
+ innerLine.setAngle(innerLine.angle() + 90);
+ innerLine.setLength(trueLength * m_polyCurvature);
+ m_innerCPoint = innerLine.p2();
+ QLineF outerLine = QLineF(m_startPoint, currItem->PoLine.pointQF(6));
+ outerLine.setLength(outerLine.length() * m_polyOuterCurvature);
+ m_outerCPoint = outerLine.p2();
+ m_view->update();
+}
+
+void CanvasMode_EditPolygon::activate(bool fromGesture)
+{
+ m_polygonPoint = noPointDefined;
+ m_canvas->m_viewMode.m_MouseButtonPressed = false;
+ m_canvas->resetRenderMode();
+ m_doc->DragP = false;
+ m_doc->leaveDrag = false;
+ m_canvas->m_viewMode.operItemMoving = false;
+ m_canvas->m_viewMode.operItemResizing = false;
+ m_view->MidButt = false;
+ m_Mxp = m_Myp = -1;
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ PageItem_RegularPolygon* item = currItem->asRegularPolygon();
+ m_centerPoint = QPointF(currItem->width() / 2.0, currItem->height() / 2.0);
+ m_startPoint = currItem->PoLine.pointQF(0);
+ m_endPoint = currItem->PoLine.pointQF(2);
+ m_polyCorners = item->polyCorners;
+ m_polyUseFactor = item->polyUseFactor;
+ m_polyFactor = item->polyFactor;
+ m_polyRotation = item->polyRotation;
+ m_polyCurvature = item->polyCurvature;
+ m_polyInnerRot = item->polyInnerRot;
+ m_polyOuterCurvature = item->polyOuterCurvature;
+ m_VectorDialog = new PolyVectorDialog(m_ScMW, m_polyCorners, m_polyFactor, m_polyUseFactor, m_polyRotation, m_polyCurvature, m_polyInnerRot, m_polyOuterCurvature);
+ m_VectorDialog->show();
+ uint cx = m_polyUseFactor ? m_polyCorners * 2 : m_polyCorners;
+ double seg = 360.0 / cx;
+ double trueLength = sqrt(pow(sin(seg / 180.0 * M_PI) * (item->width() / 2.0), 2) + pow(cos(seg / 180.0 * M_PI) * (item->height() / 2.0) + (item->height()/2.0) - item->height(), 2));
+ QLineF innerLine = QLineF(m_endPoint, m_centerPoint);
+ innerLine.setAngle(innerLine.angle() + 90);
+ innerLine.setLength(trueLength * m_polyCurvature);
+ m_innerCPoint = innerLine.p2();
+ QLineF outerLine = QLineF(m_startPoint, currItem->PoLine.pointQF(6));
+ outerLine.setLength(outerLine.length() * m_polyOuterCurvature);
+ m_outerCPoint = outerLine.p2();
+ setModeCursor();
+ if (fromGesture)
+ m_view->update();
+ connect(m_doc, SIGNAL(docChanged()), this, SLOT(updateFromItem()));
+
+ connect(m_VectorDialog, SIGNAL(NewVectors(int, double, bool, double, double, double, double)), this, SLOT(applyValues(int, double, bool, double, double, double, double)));
+ connect(m_VectorDialog, SIGNAL(endEdit()), this, SLOT(endEditing()));
+ connect(m_VectorDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool)));
+}
+
+void CanvasMode_EditPolygon::deactivate(bool forGesture)
+{
+ disconnect(m_VectorDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool)));
+ m_VectorDialog->close();
+ m_VectorDialog->deleteLater();
+ m_view->setRedrawMarkerShown(false);
+ m_polygonPoint = noPointDefined;
+ disconnect(m_doc, SIGNAL(docChanged()), this, SLOT(updateFromItem()));
+}
+
+void CanvasMode_EditPolygon::endEditing(bool active)
+{
+ if (!active)
+ endEditing();
+}
+
+void CanvasMode_EditPolygon::endEditing()
+{
+ m_view->requestMode(modeNormal);
+}
+
+void CanvasMode_EditPolygon::applyValues(int polyC, double polyF, bool polyUseCF, double polyR, double polyCur, double polyIRot, double polyOCur)
+{
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ PageItem_RegularPolygon* item = currItem->asRegularPolygon();
+ QRectF oldRect = item->getBoundingRect();
+ m_polyCorners = polyC;
+ m_polyFactor = polyF;
+ m_polyRotation = polyR;
+ m_polyCurvature = polyCur;
+ m_polyInnerRot = polyIRot;
+ m_polyOuterCurvature = polyOCur;
+ if (UndoManager::undoEnabled())
+ {
+ SimpleState *ss = new SimpleState(Um::EditPolygon,"",Um::IPolygon);
+ ss->set("POLYGON","polygon");
+ ss->set("NEW_CORNER",polyC);
+ ss->set("NEW_USEFACTOR",polyUseCF);
+ ss->set("NEW_FACTOR",m_polyFactor);
+ ss->set("NEW_ROTATION",m_polyRotation);
+ ss->set("NEW_CURV",m_polyCurvature);
+ ss->set("NEW_INNER",m_polyInnerRot);
+ ss->set("NEW_OUTER",m_polyOuterCurvature);
+ ss->set("OLD_CORNER",item->polyCorners);
+ ss->set("OLD_USEFACTOR",item->polyUseFactor);
+ ss->set("OLD_FACTOR",item->polyFactor);
+ ss->set("OLD_ROTATION",item->polyRotation);
+ ss->set("OLD_CURV",item->polyCurvature);
+ ss->set("OLD_INNER",item->polyInnerRot);
+ ss->set("OLD_OUTER",item->polyOuterCurvature);
+ undoManager->action(currItem,ss);
+ }
+ item->polyCorners = polyC;
+ item->polyUseFactor = polyUseCF;
+ item->polyFactor = m_polyFactor;
+ item->polyRotation = m_polyRotation;
+ item->polyCurvature = m_polyCurvature;
+ item->polyInnerRot = m_polyInnerRot;
+ item->polyOuterCurvature = m_polyOuterCurvature;
+ item->recalcPath();
+ updateFromItem();
+ QTransform itemMatrix = currItem->getTransform();
+ QPainterPath path = itemMatrix.map(RegularPolygonPath(item->width(), item->height(), m_polyCorners, m_polyUseFactor, m_polyFactor, m_polyRotation, m_polyCurvature, m_polyInnerRot, m_polyOuterCurvature));
+ QRectF updateRect = oldRect.united(path.boundingRect());
+ m_doc->regionsChanged()->update(updateRect.adjusted(-5, -5, 10, 10));
+}
+
+double CanvasMode_EditPolygon::getUserValFromFactor(double factor)
+{
+ double userVal = 0.0;
+ double mi = GetZeroFactor();
+ double ma = GetMaxFactor();
+ if ((factor / mi * 100.0 - 100.0) > 0)
+ userVal = (factor - mi) / (ma - mi) * 100.0;
+ else
+ userVal = factor / mi * 100.0 - 100.0;
+ return userVal;
+}
+
+double CanvasMode_EditPolygon::GetZeroFactor()
+{
+ return sqrt(pow(1.0,2.0)-pow(((sin((360.0/(m_polyCorners*2))/180* M_PI)* 2.0)/2.0),2.0));
+}
+
+double CanvasMode_EditPolygon::GetMaxFactor()
+{
+ double win = (360.0/(m_polyCorners*2)) / 180.0 * M_PI;
+ double ret;
+ if ((360.0/(m_polyCorners*2)) > 45)
+ ret = 1/sin(win);
+ else
+ ret = 1/cos(win);
+ return ret;
+}
+
+void CanvasMode_EditPolygon::mouseDoubleClickEvent(QMouseEvent *m)
+{
+ m->accept();
+ m_canvas->m_viewMode.m_MouseButtonPressed = false;
+ m_canvas->resetRenderMode();
+ m_view->requestMode(modeNormal);
+}
+
+void CanvasMode_EditPolygon::mouseMoveEvent(QMouseEvent *m)
+{
+ const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
+ m->accept();
+ double newX = mousePointDoc.x();
+ double newY = mousePointDoc.y();
+ if (m_canvas->m_viewMode.m_MouseButtonPressed && m_view->moveTimerElapsed())
+ {
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ QTransform itemMatrix = currItem->getTransform();
+ QPointF cPoint = itemMatrix.map(m_centerPoint);
+ QLineF stLinA = QLineF(cPoint, QPointF(newX, newY));
+
+ uint cx = m_polyUseFactor ? m_polyCorners * 2 : m_polyCorners;
+ double seg = 360.0 / cx;
+ double trueLength = sqrt(pow(sin(seg / 180.0 * M_PI) * (currItem->width() / 2.0), 2) + pow(cos(seg / 180.0 * M_PI) * (currItem->height() / 2.0) + (currItem->height()/2.0) - currItem->height(), 2));
+
+ if (m_polygonPoint == useControlInner)
+ {
+ m_polyInnerRot = stLinA.angle() - 90 - m_polyRotation - seg;
+ double factor = stLinA.length() / sqrt(pow(sin(stLinA.angle() * M_PI / 180.0) * currItem->height() / 2.0, 2) + pow(cos(stLinA.angle() * M_PI / 180.0) * currItem->width() / 2.0, 2));
+ int maxF = qRound(getUserValFromFactor(factor));
+ if (maxF <= 100)
+ m_polyFactor = factor;
+ }
+ if (m_polygonPoint == useControlOuter)
+ {
+ m_polyRotation = stLinA.angle() - 90;
+ if (m_polyRotation < -180)
+ m_polyRotation += 360;
+ if (m_polyRotation > 180)
+ m_polyRotation -= 360;
+ }
+ if (m_polygonPoint == useControlInnerCurve)
+ {
+ QPointF ePoint = itemMatrix.map(m_endPoint);
+ QLineF stLinC = QLineF(ePoint, QPointF(newX, newY));
+ m_polyCurvature = stLinC.length() / trueLength;
+ }
+ if (m_polygonPoint == useControlOuterCurve)
+ {
+ QPointF sPoint = itemMatrix.map(m_startPoint);
+ QPointF sPoint2 = itemMatrix.map(currItem->PoLine.pointQF(6));
+ QLineF stLinCo = QLineF(sPoint, QPointF(newX, newY));
+ QLineF stLinCo2 = QLineF(sPoint, sPoint2);
+ m_polyOuterCurvature = stLinCo.length() / stLinCo2.length();
+ }
+ QPainterPath path = RegularPolygonPath(currItem->width(), currItem->height(), m_polyCorners, m_polyUseFactor, m_polyFactor, m_polyRotation, m_polyCurvature, m_polyInnerRot, m_polyOuterCurvature);
+ FPointArray ar;
+ ar.fromQPainterPath(path);
+ m_endPoint = ar.pointQF(2);
+ m_startPoint = ar.pointQF(0);
+ QLineF innerLine = QLineF(m_endPoint, m_centerPoint);
+ innerLine.setAngle(innerLine.angle() + 90);
+ innerLine.setLength(trueLength * m_polyCurvature);
+ m_innerCPoint = innerLine.p2();
+ QLineF outerLine = QLineF(m_startPoint, ar.pointQF(6));
+ outerLine.setLength(outerLine.length() * m_polyOuterCurvature);
+ m_outerCPoint = outerLine.p2();
+ m_VectorDialog->setValues(m_polyCorners, m_polyFactor, m_polyUseFactor, m_polyRotation, m_polyCurvature, m_polyInnerRot, m_polyOuterCurvature);
+ blockUpdateFromItem(true);
+ currItem->update();
+ blockUpdateFromItem(false);
+ path = itemMatrix.map(path);
+ m_doc->regionsChanged()->update(path.boundingRect().adjusted(-5, -5, 10, 10));
+ }
+ m_Mxp = newX;
+ m_Myp = newY;
+}
+
+void CanvasMode_EditPolygon::mousePressEvent(QMouseEvent *m)
+{
+ const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
+
+ m_canvas->PaintSizeRect(QRect());
+ m_canvas->m_viewMode.m_MouseButtonPressed = true;
+ m_canvas->m_viewMode.operItemMoving = false;
+ m_view->HaveSelRect = false;
+ m_doc->DragP = false;
+ m_doc->leaveDrag = false;
+ m->accept();
+ m_view->registerMousePress(m->globalPos());
+ m_Mxp = mousePointDoc.x(); //m->x();
+ m_Myp = mousePointDoc.y(); //m->y();
+ if (m->button() == Qt::MidButton)
+ {
+ m_view->MidButt = true;
+ if (m->modifiers() & Qt::ControlModifier)
+ m_view->DrawNew();
+ return;
+ }
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ QTransform itemMatrix = currItem->getTransform();
+ QPointF stPoint = m_startPoint;
+ stPoint = itemMatrix.map(stPoint);
+ QPointF swPoint = m_endPoint;
+ swPoint = itemMatrix.map(swPoint);
+ QPointF shPoint = m_innerCPoint;
+ shPoint = itemMatrix.map(shPoint);
+ QPointF sPoint = m_outerCPoint;
+ sPoint = itemMatrix.map(sPoint);
+ bool useOuter = m_canvas->hitsCanvasPoint(m->globalPos(), stPoint);
+ bool useInner = m_canvas->hitsCanvasPoint(m->globalPos(), swPoint);
+ bool useInnerC = m_canvas->hitsCanvasPoint(m->globalPos(), shPoint);
+ bool useOuterC = m_canvas->hitsCanvasPoint(m->globalPos(), sPoint);
+ if (useOuter && useOuterC)
+ {
+ if (m->modifiers() == Qt::ShiftModifier)
+ m_polygonPoint = useControlOuterCurve;
+ else
+ m_polygonPoint = useControlOuter;
+ }
+ else if (useOuter || useOuterC)
+ {
+ if (useOuterC)
+ m_polygonPoint = useControlOuterCurve;
+ else
+ m_polygonPoint = useControlOuter;
+ }
+ else if (useInner && useInnerC)
+ {
+ if (m->modifiers() == Qt::ShiftModifier)
+ m_polygonPoint = useControlInnerCurve;
+ else
+ m_polygonPoint = useControlInner;
+ }
+ else if (useInner || useInnerC)
+ {
+ if (useInnerC)
+ m_polygonPoint = useControlInnerCurve;
+ else
+ m_polygonPoint = useControlInner;
+ }
+ else
+ m_polygonPoint = noPointDefined;
+ if (m_polygonPoint != noPointDefined && UndoManager::undoEnabled())
+ m_transaction = undoManager->beginTransaction(Um::Polygon, Um::IPolygon, Um::EditPolygon, "", Um::IPolygon);
+ m_view->setCursor(QCursor(Qt::CrossCursor));
+ QPainterPath path = itemMatrix.map(RegularPolygonPath(currItem->width(), currItem->height(), m_polyCorners, m_polyUseFactor, m_polyFactor, m_polyRotation, m_polyCurvature, m_polyInnerRot, m_polyOuterCurvature));
+ m_doc->regionsChanged()->update(path.boundingRect().adjusted(-5, -5, 10, 10));
+}
+
+void CanvasMode_EditPolygon::mouseReleaseEvent(QMouseEvent *m)
+{
+ const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
+ m_canvas->m_viewMode.m_MouseButtonPressed = false;
+ m_canvas->resetRenderMode();
+ m->accept();
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ PageItem_RegularPolygon* item = currItem->asRegularPolygon();
+ QTransform itemMatrix = currItem->getTransform();
+ if ((m_polygonPoint == useControlInner) || (m_polygonPoint == useControlOuter) || (m_polygonPoint == useControlInnerCurve) || (m_polygonPoint == useControlOuterCurve))
+ {
+ double newX = mousePointDoc.x();
+ double newY = mousePointDoc.y();
+ QPointF cPoint = itemMatrix.map(m_centerPoint);
+ QLineF stLinA = QLineF(cPoint, QPointF(newX, newY));
+ uint cx = m_polyUseFactor ? m_polyCorners * 2 : m_polyCorners;
+ double seg = 360.0 / cx;
+ double trueLength = sqrt(pow(sin(seg / 180.0 * M_PI) * (currItem->width() / 2.0), 2) + pow(cos(seg / 180.0 * M_PI) * (currItem->height() / 2.0) + (currItem->height()/2.0) - currItem->height(), 2));
+ if (m_polygonPoint == useControlInner)
+ {
+ m_polyInnerRot = stLinA.angle() - 90 - m_polyRotation - seg;
+ m_polyFactor = stLinA.length() / sqrt(pow(sin(stLinA.angle() * M_PI / 180.0) * currItem->height() / 2.0, 2) + pow(cos(stLinA.angle() * M_PI / 180.0) * currItem->width() / 2.0, 2));
+ }
+ if (m_polygonPoint == useControlOuter)
+ m_polyRotation = stLinA.angle() - 90;
+ if (m_polygonPoint == useControlInnerCurve)
+ {
+ QPointF ePoint = itemMatrix.map(m_endPoint);
+ QLineF stLinC = QLineF(ePoint, QPointF(newX, newY));
+ m_polyCurvature = stLinC.length() / trueLength;
+ }
+ if (m_polygonPoint == useControlOuterCurve)
+ {
+ QPointF sPoint = itemMatrix.map(m_startPoint);
+ QPointF sPoint2 = itemMatrix.map(currItem->PoLine.pointQF(6));
+ QLineF stLinCo = QLineF(sPoint, QPointF(newX, newY));
+ QLineF stLinCo2 = QLineF(sPoint, sPoint2);
+ m_polyOuterCurvature = stLinCo.length() / stLinCo2.length();
+ }
+ item->polyFactor = m_polyFactor;
+ item->polyRotation = m_polyRotation;
+ item->polyCurvature = m_polyCurvature;
+ item->polyInnerRot = m_polyInnerRot;
+ item->polyOuterCurvature = m_polyOuterCurvature;
+ item->recalcPath();
+ m_VectorDialog->setValues(m_polyCorners, m_polyFactor, m_polyUseFactor, m_polyRotation, m_polyCurvature, m_polyInnerRot, m_polyOuterCurvature);
+ if (m_transaction)
+ {
+ m_transaction.commit();
+ m_transaction.reset();
+ }
+ }
+ QPainterPath path = itemMatrix.map(RegularPolygonPath(item->width(), item->height(), m_polyCorners, m_polyUseFactor, m_polyFactor, m_polyRotation, m_polyCurvature, m_polyInnerRot, m_polyOuterCurvature));
+ m_doc->regionsChanged()->update(path.boundingRect().adjusted(-5, -5, 10, 10));
+}
Modified: trunk/Scribus/scribus/canvasmode_editpolygon.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_editpolygon.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editpolygon.h (original)
+++ trunk/Scribus/scribus/canvasmode_editpolygon.h Fri Nov 27 23:35:43 2015
@@ -1,106 +1,106 @@
-/*
- For general Scribus (>=1.3.2) copyright and licensing information please refer
- to the COPYING file provided with the program. Following this notice may exist
- a copyright and/or license notice that predates the release of Scribus 1.3.2
- for which a new license (GPL+exception) is in place.
- */
-/***************************************************************************
-* *
-* This program is free software; you can redistribute it and/or modify *
-* it under the terms of the GNU General Public License as published by *
-* the Free Software Foundation; either version 2 of the License, or *
-* (at your option) any later version. *
-* *
-***************************************************************************/
-/***************************************************************************
- canvasmode_editpolygon.h - description
- -------------------
- begin : Wed Jan 12 2011
- copyright : (C) 2011 by Franz Schmid
- email : Franz.Schmid at altmuehlnet.de
- ***************************************************************************/
-
-#ifndef CANVAS_MODE_EDITPOLYGON_H
-#define CANVAS_MODE_EDITPOLYGON_H
-
-#include <QObject>
-#include <QTime>
-
-#include "canvasmode.h"
-#include "fpointarray.h"
-#include "ui/polyprops.h"
-#include "undotransaction.h"
-
-class PageItem;
-class ScribusMainWindow;
-class ScribusView;
-
-
-// This class encapsulate the old code for mouse interaction from scribusview.cpp
-
-class CanvasMode_EditPolygon : public CanvasMode
-{
- Q_OBJECT
-public:
- explicit CanvasMode_EditPolygon(ScribusView* view);
- virtual ~CanvasMode_EditPolygon() {}
-
- virtual void enterEvent(QEvent *);
- virtual void leaveEvent(QEvent *);
-
- virtual void activate(bool);
- virtual void deactivate(bool);
- virtual void mouseDoubleClickEvent(QMouseEvent *m);
- virtual void mouseReleaseEvent(QMouseEvent *m);
- virtual void mouseMoveEvent(QMouseEvent *m);
- virtual void mousePressEvent(QMouseEvent *m);
- virtual void drawControls(QPainter* p);
- void drawControlsPolygon(QPainter* pp, PageItem* currItem);
-
-private:
-
- typedef enum
- {
- noPointDefined,
- useControlOuter,
- useControlInner,
- useControlInnerCurve,
- useControlOuterCurve
- } ePolygonPoint;
-
- inline bool GetItem(PageItem** pi);
- double GetZeroFactor();
- double GetMaxFactor();
- double getUserValFromFactor(double factor);
-
- double Mxp, Myp;
- ScribusMainWindow* m_ScMW;
- QPointF startPoint;
- QPointF endPoint;
- QPointF centerPoint;
- QPointF innerCPoint;
- QPointF outerCPoint;
- int polyCorners;
- bool polyUseFactor;
- double polyFactor;
- double polyRotation;
- double polyCurvature;
- double polyInnerRot;
- double polyOuterCurvature;
- ePolygonPoint m_polygonPoint;
- PolyVectorDialog *VectorDialog;
- UndoTransaction m_transaction;
-
- int m_blockUpdateFromItem;
- void blockUpdateFromItem(bool block) { if (block) ++m_blockUpdateFromItem; else --m_blockUpdateFromItem; }
- bool updateFromItemBlocked() { return (m_blockUpdateFromItem > 0); }
-
-public slots:
- void applyValues(int polyC, double polyF, bool polyUseCF, double polyR, double polyCur, double polyIRot, double polyOCur);
- void updateFromItem();
- void endEditing(bool active);
- void endEditing();
-};
-
-
-#endif
+/*
+ For general Scribus (>=1.3.2) copyright and licensing information please refer
+ to the COPYING file provided with the program. Following this notice may exist
+ a copyright and/or license notice that predates the release of Scribus 1.3.2
+ for which a new license (GPL+exception) is in place.
+ */
+/***************************************************************************
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+***************************************************************************/
+/***************************************************************************
+ canvasmode_editpolygon.h - description
+ -------------------
+ begin : Wed Jan 12 2011
+ copyright : (C) 2011 by Franz Schmid
+ email : Franz.Schmid at altmuehlnet.de
+ ***************************************************************************/
+
+#ifndef CANVAS_MODE_EDITPOLYGON_H
+#define CANVAS_MODE_EDITPOLYGON_H
+
+#include <QObject>
+#include <QTime>
+
+#include "canvasmode.h"
+#include "fpointarray.h"
+#include "ui/polyprops.h"
+#include "undotransaction.h"
+
+class PageItem;
+class ScribusMainWindow;
+class ScribusView;
+
+
+// This class encapsulate the old code for mouse interaction from scribusview.cpp
+
+class CanvasMode_EditPolygon : public CanvasMode
+{
+ Q_OBJECT
+public:
+ explicit CanvasMode_EditPolygon(ScribusView* view);
+ virtual ~CanvasMode_EditPolygon() {}
+
+ virtual void enterEvent(QEvent *);
+ virtual void leaveEvent(QEvent *);
+
+ virtual void activate(bool);
+ virtual void deactivate(bool);
+ virtual void mouseDoubleClickEvent(QMouseEvent *m);
+ virtual void mouseReleaseEvent(QMouseEvent *m);
+ virtual void mouseMoveEvent(QMouseEvent *m);
+ virtual void mousePressEvent(QMouseEvent *m);
+ virtual void drawControls(QPainter* p);
+ void drawControlsPolygon(QPainter* pp, PageItem* currItem);
+
+private:
+
+ typedef enum
+ {
+ noPointDefined,
+ useControlOuter,
+ useControlInner,
+ useControlInnerCurve,
+ useControlOuterCurve
+ } ePolygonPoint;
+
+ inline bool GetItem(PageItem** pi);
+ double GetZeroFactor();
+ double GetMaxFactor();
+ double getUserValFromFactor(double factor);
+
+ double m_Mxp, m_Myp;
+ ScribusMainWindow* m_ScMW;
+ QPointF m_startPoint;
+ QPointF m_endPoint;
+ QPointF m_centerPoint;
+ QPointF m_innerCPoint;
+ QPointF m_outerCPoint;
+ int m_polyCorners;
+ bool m_polyUseFactor;
+ double m_polyFactor;
+ double m_polyRotation;
+ double m_polyCurvature;
+ double m_polyInnerRot;
+ double m_polyOuterCurvature;
+ ePolygonPoint m_polygonPoint;
+ PolyVectorDialog *m_VectorDialog;
+ UndoTransaction m_transaction;
+
+ int m_blockUpdateFromItem;
+ void blockUpdateFromItem(bool block) { if (block) ++m_blockUpdateFromItem; else --m_blockUpdateFromItem; }
+ bool updateFromItemBlocked() { return (m_blockUpdateFromItem > 0); }
+
+public slots:
+ void applyValues(int polyC, double polyF, bool polyUseCF, double polyR, double polyCur, double polyIRot, double polyOCur);
+ void updateFromItem();
+ void endEditing(bool active);
+ void endEditing();
+};
+
+
+#endif
Modified: trunk/Scribus/scribus/canvasmode_editspiral.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_editspiral.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editspiral.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_editspiral.cpp Fri Nov 27 23:35:43 2015
@@ -1,383 +1,383 @@
-/*
- For general Scribus (>=1.3.2) copyright and licensing information please refer
- to the COPYING file provided with the program. Following this notice may exist
- a copyright and/or license notice that predates the release of Scribus 1.3.2
- for which a new license (GPL+exception) is in place.
- */
-/***************************************************************************
-* *
-* This program is free software; you can redistribute it and/or modify *
-* it under the terms of the GNU General Public License as published by *
-* the Free Software Foundation; either version 2 of the License, or *
-* (at your option) any later version. *
-* *
-***************************************************************************/
-/***************************************************************************
- canvasmode_editspiral.cpp - description
- -------------------
- begin : Wed Jan 27 2011
- copyright : (C) 2011 by Franz Schmid
- email : Franz.Schmid at altmuehlnet.de
- ***************************************************************************/
-
-
-#include "canvasmode_editspiral.h"
-
-#include <QApplication>
-#include <QCursor>
-#include <QEvent>
-#include <QMouseEvent>
-#include <QPainterPath>
-#include <QPoint>
-#include <QRect>
-#include <QTimer>
-#include <QWidgetAction>
-
-#include "appmodes.h"
-#include "canvas.h"
-#include "fpoint.h"
-#include "pageitem_spiral.h"
-#include "scribus.h"
-#include "scribusdoc.h"
-#include "scribusview.h"
-#include "selection.h"
-#include "ui/propertiespalette.h"
-#include "undomanager.h"
-#include "util.h"
-#include "util_math.h"
-
-
-CanvasMode_EditSpiral::CanvasMode_EditSpiral(ScribusView* view) : CanvasMode(view), m_ScMW(view->m_ScMW)
-{
- Mxp = Myp = -1;
- m_blockUpdateFromItem = 0;
- m_arcPoint = noPointDefined;
-}
-
-inline bool CanvasMode_EditSpiral::GetItem(PageItem** pi)
-{
- *pi = m_doc->m_Selection->itemAt(0);
- return (*pi) != NULL;
-}
-
-void CanvasMode_EditSpiral::drawControls(QPainter* p)
-{
- p->save();
- if (m_canvas->m_viewMode.operItemMoving)
- {
- drawOutline(p);
- }
- else
- {
- drawSelection(p, false);
- }
- if (m_doc->appMode == modeEditSpiral)
- {
- drawControlsSpiral(p, m_doc->m_Selection->itemAt(0));
- }
- p->restore();
-}
-
-void CanvasMode_EditSpiral::drawControlsSpiral(QPainter* psx, PageItem* currItem)
-{
- QPen p8b = QPen(Qt::blue, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin);
- QPen p8r = QPen(Qt::red, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin);
- psx->setTransform(currItem->getTransform(), true);
- psx->setBrush(Qt::NoBrush);
- psx->setPen(p8b);
- if (m_arcPoint == useControlStart)
- psx->setPen(p8r);
- else
- psx->setPen(p8b);
- psx->drawPoint(startPoint);
- if (m_arcPoint == useControlEnd)
- psx->setPen(p8r);
- else
- psx->setPen(p8b);
- psx->drawPoint(endPoint);
-}
-
-void CanvasMode_EditSpiral::enterEvent(QEvent *)
-{
- if (!m_canvas->m_viewMode.m_MouseButtonPressed)
- {
- setModeCursor();
- }
-}
-
-void CanvasMode_EditSpiral::leaveEvent(QEvent *e)
-{
-}
-
-
-void CanvasMode_EditSpiral::activate(bool fromGesture)
-{
- VectorDialog = new SpiralVectorDialog(m_ScMW);
- m_canvas->m_viewMode.m_MouseButtonPressed = false;
- m_canvas->resetRenderMode();
- m_doc->DragP = false;
- m_doc->leaveDrag = false;
- m_canvas->m_viewMode.operItemMoving = false;
- m_canvas->m_viewMode.operItemResizing = false;
- m_view->MidButt = false;
- Mxp = Myp = -1;
- PageItem *currItem = m_doc->m_Selection->itemAt(0);
- PageItem_Spiral* item = currItem->asSpiral();
- startPoint = currItem->PoLine.pointQF(0);
- endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 2);
- startAngle = item->spiralStartAngle;
- endAngle = item->spiralEndAngle;
- VectorDialog->setValues(computeRealAngle(startAngle, false), computeRealAngle(endAngle, false), item->spiralFactor);
- VectorDialog->show();
- setModeCursor();
- if (fromGesture)
- {
- m_view->update();
- }
- connect(VectorDialog, SIGNAL(NewVectors(double, double, double)), this, SLOT(applyValues(double, double, double)));
- connect(VectorDialog, SIGNAL(endEdit()), this, SLOT(endEditing()));
- connect(VectorDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool)));
- connect(m_doc, SIGNAL(docChanged()), this, SLOT(updateFromItem()));
-}
-
-void CanvasMode_EditSpiral::updateFromItem()
-{
- if (updateFromItemBlocked())
- return;
- PageItem *currItem = m_doc->m_Selection->itemAt(0);
- PageItem_Spiral* item = currItem->asSpiral();
- startPoint = currItem->PoLine.pointQF(0);
- endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 2);
- startAngle = item->spiralStartAngle;
- endAngle = item->spiralEndAngle;
- VectorDialog->setValues(computeRealAngle(startAngle, false), computeRealAngle(endAngle, false), item->spiralFactor);
- m_view->update();
-}
-
-void CanvasMode_EditSpiral::endEditing(bool active)
-{
- if (!active)
- endEditing();
-}
-
-void CanvasMode_EditSpiral::endEditing()
-{
- m_view->requestMode(modeNormal);
-}
-
-QPointF CanvasMode_EditSpiral::getSegment(double angle)
-{
- PageItem *currItem = m_doc->m_Selection->itemAt(0);
- PageItem_Spiral *item = currItem->asSpiral();
- double ww = item->width();
- double wws = 0.0;
- double wwn = ww;
- double hh = item->height() - (item->height() / (item->spiralFactor + 1.0));
- double segStart = 0.0;
- double segEnd = 180;
- bool segPart = true;
- QPointF ret = QPointF(item->width() / 2.0, item->height() / 2.0);
- if (angle < 0)
- return ret;
- while (true)
- {
- QLineF lin = QLineF(QPointF(wws, hh), QPointF(wwn, hh));
- if ((angle <= segEnd) && (angle >= segStart))
- {
- ret = lin.pointAt(0.5);
- break;
- }
- ww /= item->spiralFactor;
- wws = wwn;
- if (segPart)
- wwn -= ww;
- else
- wwn += ww;
- segPart = !segPart;
- segStart += 180.0;
- segEnd += 180.0;
- }
- return ret;
-}
-
-double CanvasMode_EditSpiral::computeRealAngle(double angle, bool fromDia)
-{
- PageItem *currItem = m_doc->m_Selection->itemAt(0);
- double ret = angle;
- int rev = static_cast<int>(angle / 360.0);
- double part = angle - (rev * 360);
- QTransform bb;
- bb.scale(currItem->width() / currItem->height(), 1.0);
- QLineF inp = QLineF(QPointF(currItem->width() / 2.0, currItem->height() / 2.0), QPointF(currItem->width(), currItem->height() / 2.0));
- inp.setAngle(part);
- if (fromDia)
- {
- QLineF res = bb.map(inp);
- ret = res.angle();
- }
- else
- {
- QTransform bt = bb.inverted();
- QLineF res = bt.map(inp);
- ret = res.angle();
- }
- ret += rev * 360;
- return ret;
-}
-
-void CanvasMode_EditSpiral::applyValues(double start, double end, double factor)
-{
- PageItem *currItem = m_doc->m_Selection->itemAt(0);
- PageItem_Spiral *item = currItem->asSpiral();
- SimpleState *ss = new SimpleState(Um::EditSpiral, "", Um::IPolygon);
- ss->set("SPIRAL","spiral");
- ss->set("OLD_START",item->spiralStartAngle);
- ss->set("OLD_END",item->spiralEndAngle);
- ss->set("OLD_FACTOR",item->spiralFactor);
- item->spiralStartAngle = computeRealAngle(start, true);
- item->spiralEndAngle = computeRealAngle(end, true);
- item->spiralFactor = factor;
- ss->set("NEW_START",item->spiralStartAngle);
- ss->set("NEW_END",item->spiralEndAngle);
- ss->set("NEW_FACTOR",item->spiralFactor);
- undoManager->action(item,ss);
- item->recalcPath();
- startPoint = currItem->PoLine.pointQF(0);
- endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 2);
- startAngle = item->spiralStartAngle;
- endAngle = item->spiralEndAngle;
- QTransform itemMatrix = currItem->getTransform();
- m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-5, -5, 10, 10));
-}
-
-void CanvasMode_EditSpiral::deactivate(bool forGesture)
-{
- disconnect(VectorDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool)));
- VectorDialog->close();
- delete VectorDialog;
- m_view->setRedrawMarkerShown(false);
- m_arcPoint = noPointDefined;
- disconnect(m_doc, SIGNAL(docChanged()), this, SLOT(updateFromItem()));
-}
-
-void CanvasMode_EditSpiral::mouseDoubleClickEvent(QMouseEvent *m)
-{
- m->accept();
- m_canvas->m_viewMode.m_MouseButtonPressed = false;
- m_canvas->resetRenderMode();
- m_view->requestMode(modeNormal);
-}
-
-
-void CanvasMode_EditSpiral::mouseMoveEvent(QMouseEvent *m)
-{
- const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
- m->accept();
- double newX = mousePointDoc.x();
- double newY = mousePointDoc.y();
- if (m_canvas->m_viewMode.m_MouseButtonPressed && m_view->moveTimerElapsed() && (m_arcPoint != noPointDefined))
- {
- PageItem *currItem = m_doc->m_Selection->itemAt(0);
- QTransform itemMatrix = currItem->getTransform();
- PageItem_Spiral *item = currItem->asSpiral();
- QPointF sPoint;
- if (m_arcPoint == useControlStart)
- sPoint = getSegment(startAngle);
- else if (m_arcPoint == useControlEnd)
- sPoint = getSegment(endAngle);
- QPointF smPoint = itemMatrix.map(sPoint);
- QLineF stLinA = QLineF(smPoint, QPointF(Mxp, Myp));
- QLineF stLinM = QLineF(smPoint, QPointF(newX, newY));
- double deltaAngle = stLinM.angle() - stLinA.angle();
- if (deltaAngle < -180)
- deltaAngle = deltaAngle + 360;
- else if (deltaAngle > 180)
- deltaAngle = deltaAngle - 360;
- if (currItem->imageFlippedV())
- deltaAngle *= -1.0;
- if (currItem->imageFlippedH())
- deltaAngle *= -1.0;
- if (m_arcPoint == useControlStart)
- {
- if (startAngle + deltaAngle >= 0)
- {
- startAngle += deltaAngle;
- applyValues(startAngle,endAngle,item->spiralFactor);
- item->recalcPath();
- startPoint = currItem->PoLine.pointQF(0);
- m_canvas->displayRealRotHUD(m->globalPos(), startAngle);
- }
- VectorDialog->setValues(computeRealAngle(startAngle, false), computeRealAngle(endAngle, false), item->spiralFactor);
- }
- else if (m_arcPoint == useControlEnd)
- {
- if (endAngle + deltaAngle > startAngle)
- {
- endAngle += deltaAngle;
- applyValues(startAngle,endAngle,item->spiralFactor);
- item->recalcPath();
- endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 2);
- m_canvas->displayRealRotHUD(m->globalPos(), endAngle);
- }
- VectorDialog->setValues(computeRealAngle(startAngle, false), computeRealAngle(endAngle, false), item->spiralFactor);
- }
- currItem->update();
- m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-5, -5, 10, 10));
- }
- Mxp = newX;
- Myp = newY;
-}
-
-void CanvasMode_EditSpiral::mousePressEvent(QMouseEvent *m)
-{
- const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
- m_canvas->PaintSizeRect(QRect());
- m_canvas->m_viewMode.m_MouseButtonPressed = true;
- m_canvas->m_viewMode.operItemMoving = false;
- m_view->HaveSelRect = false;
- m_doc->DragP = false;
- m_doc->leaveDrag = false;
- m->accept();
- m_view->registerMousePress(m->globalPos());
- Mxp = mousePointDoc.x(); //m->x();
- Myp = mousePointDoc.y(); //m->y();
- if (m->button() == Qt::MidButton)
- {
- m_view->MidButt = true;
- if (m->modifiers() & Qt::ControlModifier)
- m_view->DrawNew();
- return;
- }
- PageItem *currItem = m_doc->m_Selection->itemAt(0);
- QTransform itemMatrix = currItem->getTransform();
- QPointF stPoint = startPoint;
- stPoint = itemMatrix.map(stPoint);
- QPointF swPoint = endPoint;
- swPoint = itemMatrix.map(swPoint);
- if (m_canvas->hitsCanvasPoint(m->globalPos(), stPoint))
- m_arcPoint = useControlStart;
- else if (m_canvas->hitsCanvasPoint(m->globalPos(), swPoint))
- m_arcPoint = useControlEnd;
- else
- m_arcPoint = noPointDefined;
- if (m_arcPoint != noPointDefined)
- m_transaction = undoManager->beginTransaction(Um::Polygon, Um::IPolygon, Um::EditSpiral, "", Um::IPolygon);
- m_canvas->m_viewMode.m_MouseButtonPressed = true;
- m_view->setCursor(QCursor(Qt::CrossCursor));
- m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-5, -5, 10, 10));
-}
-
-void CanvasMode_EditSpiral::mouseReleaseEvent(QMouseEvent *m)
-{
- m_canvas->m_viewMode.m_MouseButtonPressed = false;
- m_canvas->resetRenderMode();
- m->accept();
- PageItem *currItem = m_doc->m_Selection->itemAt(0);
- if (m_transaction)
- {
- m_transaction.commit();
- m_transaction.reset();
- }
- QTransform itemMatrix = currItem->getTransform();
- m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-5, -5, 10, 10));
-}
+/*
+ For general Scribus (>=1.3.2) copyright and licensing information please refer
+ to the COPYING file provided with the program. Following this notice may exist
+ a copyright and/or license notice that predates the release of Scribus 1.3.2
+ for which a new license (GPL+exception) is in place.
+ */
+/***************************************************************************
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+***************************************************************************/
+/***************************************************************************
+ canvasmode_editspiral.cpp - description
+ -------------------
+ begin : Wed Jan 27 2011
+ copyright : (C) 2011 by Franz Schmid
+ email : Franz.Schmid at altmuehlnet.de
+ ***************************************************************************/
+
+
+#include "canvasmode_editspiral.h"
+
+#include <QApplication>
+#include <QCursor>
+#include <QEvent>
+#include <QMouseEvent>
+#include <QPainterPath>
+#include <QPoint>
+#include <QRect>
+#include <QTimer>
+#include <QWidgetAction>
+
+#include "appmodes.h"
+#include "canvas.h"
+#include "fpoint.h"
+#include "pageitem_spiral.h"
+#include "scribus.h"
+#include "scribusdoc.h"
+#include "scribusview.h"
+#include "selection.h"
+#include "ui/propertiespalette.h"
+#include "undomanager.h"
+#include "util.h"
+#include "util_math.h"
+
+
+CanvasMode_EditSpiral::CanvasMode_EditSpiral(ScribusView* view) : CanvasMode(view), m_ScMW(view->m_ScMW)
+{
+ m_Mxp = m_Myp = -1;
+ m_blockUpdateFromItem = 0;
+ m_arcPoint = noPointDefined;
+}
+
+inline bool CanvasMode_EditSpiral::GetItem(PageItem** pi)
+{
+ *pi = m_doc->m_Selection->itemAt(0);
+ return (*pi) != NULL;
+}
+
+void CanvasMode_EditSpiral::drawControls(QPainter* p)
+{
+ p->save();
+ if (m_canvas->m_viewMode.operItemMoving)
+ {
+ drawOutline(p);
+ }
+ else
+ {
+ drawSelection(p, false);
+ }
+ if (m_doc->appMode == modeEditSpiral)
+ {
+ drawControlsSpiral(p, m_doc->m_Selection->itemAt(0));
+ }
+ p->restore();
+}
+
+void CanvasMode_EditSpiral::drawControlsSpiral(QPainter* psx, PageItem* currItem)
+{
+ QPen p8b = QPen(Qt::blue, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin);
+ QPen p8r = QPen(Qt::red, 8.0 / m_canvas->m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin);
+ psx->setTransform(currItem->getTransform(), true);
+ psx->setBrush(Qt::NoBrush);
+ psx->setPen(p8b);
+ if (m_arcPoint == useControlStart)
+ psx->setPen(p8r);
+ else
+ psx->setPen(p8b);
+ psx->drawPoint(m_startPoint);
+ if (m_arcPoint == useControlEnd)
+ psx->setPen(p8r);
+ else
+ psx->setPen(p8b);
+ psx->drawPoint(m_endPoint);
+}
+
+void CanvasMode_EditSpiral::enterEvent(QEvent *)
+{
+ if (!m_canvas->m_viewMode.m_MouseButtonPressed)
+ {
+ setModeCursor();
+ }
+}
+
+void CanvasMode_EditSpiral::leaveEvent(QEvent *e)
+{
+}
+
+
+void CanvasMode_EditSpiral::activate(bool fromGesture)
+{
+ m_VectorDialog = new SpiralVectorDialog(m_ScMW);
+ m_canvas->m_viewMode.m_MouseButtonPressed = false;
+ m_canvas->resetRenderMode();
+ m_doc->DragP = false;
+ m_doc->leaveDrag = false;
+ m_canvas->m_viewMode.operItemMoving = false;
+ m_canvas->m_viewMode.operItemResizing = false;
+ m_view->MidButt = false;
+ m_Mxp = m_Myp = -1;
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ PageItem_Spiral* item = currItem->asSpiral();
+ m_startPoint = currItem->PoLine.pointQF(0);
+ m_endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 2);
+ m_startAngle = item->spiralStartAngle;
+ m_endAngle = item->spiralEndAngle;
+ m_VectorDialog->setValues(computeRealAngle(m_startAngle, false), computeRealAngle(m_endAngle, false), item->spiralFactor);
+ m_VectorDialog->show();
+ setModeCursor();
+ if (fromGesture)
+ {
+ m_view->update();
+ }
+ connect(m_VectorDialog, SIGNAL(NewVectors(double, double, double)), this, SLOT(applyValues(double, double, double)));
+ connect(m_VectorDialog, SIGNAL(endEdit()), this, SLOT(endEditing()));
+ connect(m_VectorDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool)));
+ connect(m_doc, SIGNAL(docChanged()), this, SLOT(updateFromItem()));
+}
+
+void CanvasMode_EditSpiral::updateFromItem()
+{
+ if (updateFromItemBlocked())
+ return;
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ PageItem_Spiral* item = currItem->asSpiral();
+ m_startPoint = currItem->PoLine.pointQF(0);
+ m_endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 2);
+ m_startAngle = item->spiralStartAngle;
+ m_endAngle = item->spiralEndAngle;
+ m_VectorDialog->setValues(computeRealAngle(m_startAngle, false), computeRealAngle(m_endAngle, false), item->spiralFactor);
+ m_view->update();
+}
+
+void CanvasMode_EditSpiral::endEditing(bool active)
+{
+ if (!active)
+ endEditing();
+}
+
+void CanvasMode_EditSpiral::endEditing()
+{
+ m_view->requestMode(modeNormal);
+}
+
+QPointF CanvasMode_EditSpiral::getSegment(double angle)
+{
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ PageItem_Spiral *item = currItem->asSpiral();
+ double ww = item->width();
+ double wws = 0.0;
+ double wwn = ww;
+ double hh = item->height() - (item->height() / (item->spiralFactor + 1.0));
+ double segStart = 0.0;
+ double segEnd = 180;
+ bool segPart = true;
+ QPointF ret = QPointF(item->width() / 2.0, item->height() / 2.0);
+ if (angle < 0)
+ return ret;
+ while (true)
+ {
+ QLineF lin = QLineF(QPointF(wws, hh), QPointF(wwn, hh));
+ if ((angle <= segEnd) && (angle >= segStart))
+ {
+ ret = lin.pointAt(0.5);
+ break;
+ }
+ ww /= item->spiralFactor;
+ wws = wwn;
+ if (segPart)
+ wwn -= ww;
+ else
+ wwn += ww;
+ segPart = !segPart;
+ segStart += 180.0;
+ segEnd += 180.0;
+ }
+ return ret;
+}
+
+double CanvasMode_EditSpiral::computeRealAngle(double angle, bool fromDia)
+{
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ double ret = angle;
+ int rev = static_cast<int>(angle / 360.0);
+ double part = angle - (rev * 360);
+ QTransform bb;
+ bb.scale(currItem->width() / currItem->height(), 1.0);
+ QLineF inp = QLineF(QPointF(currItem->width() / 2.0, currItem->height() / 2.0), QPointF(currItem->width(), currItem->height() / 2.0));
+ inp.setAngle(part);
+ if (fromDia)
+ {
+ QLineF res = bb.map(inp);
+ ret = res.angle();
+ }
+ else
+ {
+ QTransform bt = bb.inverted();
+ QLineF res = bt.map(inp);
+ ret = res.angle();
+ }
+ ret += rev * 360;
+ return ret;
+}
+
+void CanvasMode_EditSpiral::applyValues(double start, double end, double factor)
+{
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ PageItem_Spiral *item = currItem->asSpiral();
+ SimpleState *ss = new SimpleState(Um::EditSpiral, "", Um::IPolygon);
+ ss->set("SPIRAL","spiral");
+ ss->set("OLD_START",item->spiralStartAngle);
+ ss->set("OLD_END",item->spiralEndAngle);
+ ss->set("OLD_FACTOR",item->spiralFactor);
+ item->spiralStartAngle = computeRealAngle(start, true);
+ item->spiralEndAngle = computeRealAngle(end, true);
+ item->spiralFactor = factor;
+ ss->set("NEW_START",item->spiralStartAngle);
+ ss->set("NEW_END",item->spiralEndAngle);
+ ss->set("NEW_FACTOR",item->spiralFactor);
+ undoManager->action(item,ss);
+ item->recalcPath();
+ m_startPoint = currItem->PoLine.pointQF(0);
+ m_endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 2);
+ m_startAngle = item->spiralStartAngle;
+ m_endAngle = item->spiralEndAngle;
+ QTransform itemMatrix = currItem->getTransform();
+ m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-5, -5, 10, 10));
+}
+
+void CanvasMode_EditSpiral::deactivate(bool forGesture)
+{
+ disconnect(m_VectorDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool)));
+ m_VectorDialog->close();
+ delete m_VectorDialog;
+ m_view->setRedrawMarkerShown(false);
+ m_arcPoint = noPointDefined;
+ disconnect(m_doc, SIGNAL(docChanged()), this, SLOT(updateFromItem()));
+}
+
+void CanvasMode_EditSpiral::mouseDoubleClickEvent(QMouseEvent *m)
+{
+ m->accept();
+ m_canvas->m_viewMode.m_MouseButtonPressed = false;
+ m_canvas->resetRenderMode();
+ m_view->requestMode(modeNormal);
+}
+
+
+void CanvasMode_EditSpiral::mouseMoveEvent(QMouseEvent *m)
+{
+ const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
+ m->accept();
+ double newX = mousePointDoc.x();
+ double newY = mousePointDoc.y();
+ if (m_canvas->m_viewMode.m_MouseButtonPressed && m_view->moveTimerElapsed() && (m_arcPoint != noPointDefined))
+ {
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ QTransform itemMatrix = currItem->getTransform();
+ PageItem_Spiral *item = currItem->asSpiral();
+ QPointF sPoint;
+ if (m_arcPoint == useControlStart)
+ sPoint = getSegment(m_startAngle);
+ else if (m_arcPoint == useControlEnd)
+ sPoint = getSegment(m_endAngle);
+ QPointF smPoint = itemMatrix.map(sPoint);
+ QLineF stLinA = QLineF(smPoint, QPointF(m_Mxp, m_Myp));
+ QLineF stLinM = QLineF(smPoint, QPointF(newX, newY));
+ double deltaAngle = stLinM.angle() - stLinA.angle();
+ if (deltaAngle < -180)
+ deltaAngle = deltaAngle + 360;
+ else if (deltaAngle > 180)
+ deltaAngle = deltaAngle - 360;
+ if (currItem->imageFlippedV())
+ deltaAngle *= -1.0;
+ if (currItem->imageFlippedH())
+ deltaAngle *= -1.0;
+ if (m_arcPoint == useControlStart)
+ {
+ if (m_startAngle + deltaAngle >= 0)
+ {
+ m_startAngle += deltaAngle;
+ applyValues(m_startAngle,m_endAngle,item->spiralFactor);
+ item->recalcPath();
+ m_startPoint = currItem->PoLine.pointQF(0);
+ m_canvas->displayRealRotHUD(m->globalPos(), m_startAngle);
+ }
+ m_VectorDialog->setValues(computeRealAngle(m_startAngle, false), computeRealAngle(m_endAngle, false), item->spiralFactor);
+ }
+ else if (m_arcPoint == useControlEnd)
+ {
+ if (m_endAngle + deltaAngle > m_startAngle)
+ {
+ m_endAngle += deltaAngle;
+ applyValues(m_startAngle,m_endAngle,item->spiralFactor);
+ item->recalcPath();
+ m_endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 2);
+ m_canvas->displayRealRotHUD(m->globalPos(), m_endAngle);
+ }
+ m_VectorDialog->setValues(computeRealAngle(m_startAngle, false), computeRealAngle(m_endAngle, false), item->spiralFactor);
+ }
+ currItem->update();
+ m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-5, -5, 10, 10));
+ }
+ m_Mxp = newX;
+ m_Myp = newY;
+}
+
+void CanvasMode_EditSpiral::mousePressEvent(QMouseEvent *m)
+{
+ const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
+ m_canvas->PaintSizeRect(QRect());
+ m_canvas->m_viewMode.m_MouseButtonPressed = true;
+ m_canvas->m_viewMode.operItemMoving = false;
+ m_view->HaveSelRect = false;
+ m_doc->DragP = false;
+ m_doc->leaveDrag = false;
+ m->accept();
+ m_view->registerMousePress(m->globalPos());
+ m_Mxp = mousePointDoc.x(); //m->x();
+ m_Myp = mousePointDoc.y(); //m->y();
+ if (m->button() == Qt::MidButton)
+ {
+ m_view->MidButt = true;
+ if (m->modifiers() & Qt::ControlModifier)
+ m_view->DrawNew();
+ return;
+ }
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ QTransform itemMatrix = currItem->getTransform();
+ QPointF stPoint = m_startPoint;
+ stPoint = itemMatrix.map(stPoint);
+ QPointF swPoint = m_endPoint;
+ swPoint = itemMatrix.map(swPoint);
+ if (m_canvas->hitsCanvasPoint(m->globalPos(), stPoint))
+ m_arcPoint = useControlStart;
+ else if (m_canvas->hitsCanvasPoint(m->globalPos(), swPoint))
+ m_arcPoint = useControlEnd;
+ else
+ m_arcPoint = noPointDefined;
+ if (m_arcPoint != noPointDefined)
+ m_transaction = undoManager->beginTransaction(Um::Polygon, Um::IPolygon, Um::EditSpiral, "", Um::IPolygon);
+ m_canvas->m_viewMode.m_MouseButtonPressed = true;
+ m_view->setCursor(QCursor(Qt::CrossCursor));
+ m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-5, -5, 10, 10));
+}
+
+void CanvasMode_EditSpiral::mouseReleaseEvent(QMouseEvent *m)
+{
+ m_canvas->m_viewMode.m_MouseButtonPressed = false;
+ m_canvas->resetRenderMode();
+ m->accept();
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ if (m_transaction)
+ {
+ m_transaction.commit();
+ m_transaction.reset();
+ }
+ QTransform itemMatrix = currItem->getTransform();
+ m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-5, -5, 10, 10));
+}
Modified: trunk/Scribus/scribus/canvasmode_editspiral.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_editspiral.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editspiral.h (original)
+++ trunk/Scribus/scribus/canvasmode_editspiral.h Fri Nov 27 23:35:43 2015
@@ -1,97 +1,97 @@
-/*
- For general Scribus (>=1.3.2) copyright and licensing information please refer
- to the COPYING file provided with the program. Following this notice may exist
- a copyright and/or license notice that predates the release of Scribus 1.3.2
- for which a new license (GPL+exception) is in place.
- */
-/***************************************************************************
-* *
-* This program is free software; you can redistribute it and/or modify *
-* it under the terms of the GNU General Public License as published by *
-* the Free Software Foundation; either version 2 of the License, or *
-* (at your option) any later version. *
-* *
-***************************************************************************/
-/***************************************************************************
- canvasmode_editspiral.h - description
- -------------------
- begin : Wed Jan 27 2011
- copyright : (C) 2011 by Franz Schmid
- email : Franz.Schmid at altmuehlnet.de
- ***************************************************************************/
-
-#ifndef CANVAS_MODE_EDITSPIRAL_H
-#define CANVAS_MODE_EDITSPIRAL_H
-
-#include <QObject>
-#include <QTime>
-
-#include "canvasmode.h"
-#include "fpointarray.h"
-#include "ui/spiralvectordialog.h"
-#include "undotransaction.h"
-
-class PageItem;
-class ScribusMainWindow;
-class ScribusView;
-
-
-// This class encapsulate the old code for mouse interaction from scribusview.cpp
-
-class CanvasMode_EditSpiral : public CanvasMode
-{
- Q_OBJECT
-public:
- explicit CanvasMode_EditSpiral(ScribusView* view);
- virtual ~CanvasMode_EditSpiral() {}
-
- virtual void enterEvent(QEvent *);
- virtual void leaveEvent(QEvent *);
-
- virtual void activate(bool);
- virtual void deactivate(bool);
- virtual void mouseDoubleClickEvent(QMouseEvent *m);
- virtual void mouseReleaseEvent(QMouseEvent *m);
- virtual void mouseMoveEvent(QMouseEvent *m);
- virtual void mousePressEvent(QMouseEvent *m);
- virtual void drawControls(QPainter* p);
- void drawControlsSpiral(QPainter* pp, PageItem* currItem);
-
-private:
-
- typedef enum
- {
- noPointDefined,
- useControlStart,
- useControlEnd,
- } eSpiralPoint;
-
- inline bool GetItem(PageItem** pi);
- QPointF getSegment(double angle);
- double computeRealAngle(double angle, bool fromDia);
-
- double Mxp, Myp;
- ScribusMainWindow* m_ScMW;
- QPointF startPoint;
- QPointF endPoint;
- double startAngle;
- double endAngle;
- eSpiralPoint m_arcPoint;
- SpiralVectorDialog* VectorDialog;
- UndoTransaction m_transaction;
-
- int m_blockUpdateFromItem;
- void blockUpdateFromItem(bool block) { if (block) ++m_blockUpdateFromItem; else --m_blockUpdateFromItem; }
- bool updateFromItemBlocked() { return (m_blockUpdateFromItem > 0); }
-
-public slots:
- void updateFromItem();
-
-private slots:
- void endEditing(bool active);
- void endEditing();
- void applyValues(double start, double end, double factor);
-};
-
-
-#endif
+/*
+ For general Scribus (>=1.3.2) copyright and licensing information please refer
+ to the COPYING file provided with the program. Following this notice may exist
+ a copyright and/or license notice that predates the release of Scribus 1.3.2
+ for which a new license (GPL+exception) is in place.
+ */
+/***************************************************************************
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+***************************************************************************/
+/***************************************************************************
+ canvasmode_editspiral.h - description
+ -------------------
+ begin : Wed Jan 27 2011
+ copyright : (C) 2011 by Franz Schmid
+ email : Franz.Schmid at altmuehlnet.de
+ ***************************************************************************/
+
+#ifndef CANVAS_MODE_EDITSPIRAL_H
+#define CANVAS_MODE_EDITSPIRAL_H
+
+#include <QObject>
+#include <QTime>
+
+#include "canvasmode.h"
+#include "fpointarray.h"
+#include "ui/spiralvectordialog.h"
+#include "undotransaction.h"
+
+class PageItem;
+class ScribusMainWindow;
+class ScribusView;
+
+
+// This class encapsulate the old code for mouse interaction from scribusview.cpp
+
+class CanvasMode_EditSpiral : public CanvasMode
+{
+ Q_OBJECT
+public:
+ explicit CanvasMode_EditSpiral(ScribusView* view);
+ virtual ~CanvasMode_EditSpiral() {}
+
+ virtual void enterEvent(QEvent *);
+ virtual void leaveEvent(QEvent *);
+
+ virtual void activate(bool);
+ virtual void deactivate(bool);
+ virtual void mouseDoubleClickEvent(QMouseEvent *m);
+ virtual void mouseReleaseEvent(QMouseEvent *m);
+ virtual void mouseMoveEvent(QMouseEvent *m);
+ virtual void mousePressEvent(QMouseEvent *m);
+ virtual void drawControls(QPainter* p);
+ void drawControlsSpiral(QPainter* pp, PageItem* currItem);
+
+private:
+
+ typedef enum
+ {
+ noPointDefined,
+ useControlStart,
+ useControlEnd,
+ } eSpiralPoint;
+
+ inline bool GetItem(PageItem** pi);
+ QPointF getSegment(double angle);
+ double computeRealAngle(double angle, bool fromDia);
+
+ double m_Mxp, m_Myp;
+ ScribusMainWindow* m_ScMW;
+ QPointF m_startPoint;
+ QPointF m_endPoint;
+ double m_startAngle;
+ double m_endAngle;
+ eSpiralPoint m_arcPoint;
+ SpiralVectorDialog* m_VectorDialog;
+ UndoTransaction m_transaction;
+
+ int m_blockUpdateFromItem;
+ void blockUpdateFromItem(bool block) { if (block) ++m_blockUpdateFromItem; else --m_blockUpdateFromItem; }
+ bool updateFromItemBlocked() { return (m_blockUpdateFromItem > 0); }
+
+public slots:
+ void updateFromItem();
+
+private slots:
+ void endEditing(bool active);
+ void endEditing();
+ void applyValues(double start, double end, double factor);
+};
+
+
+#endif
Modified: trunk/Scribus/scribus/canvasmode_editweldpoint.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_editweldpoint.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editweldpoint.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_editweldpoint.cpp Fri Nov 27 23:35:43 2015
@@ -65,9 +65,9 @@
CanvasMode_EditWeldPoint::CanvasMode_EditWeldPoint(ScribusView* view) : CanvasMode(view), m_ScMW(view->m_ScMW)
{
- Mxp = Myp = -1;
- selectedPoint = -1;
- editWeldMode = true;
+ m_Mxp = m_Myp = -1;
+ m_selectedPoint = -1;
+ m_editWeldMode = true;
}
inline bool CanvasMode_EditWeldPoint::GetItem(PageItem** pi)
@@ -102,7 +102,7 @@
for (int i = 0 ; i < currItem->weldList.count(); i++)
{
PageItem::WeldingInfo wInf = currItem->weldList.at(i);
- if (i == selectedPoint)
+ if (i == m_selectedPoint)
psx->setPen(QPen(Qt::red, 8.0 / m_canvas->scale(), Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
else
psx->setPen(QPen(Qt::yellow, 8.0 / m_canvas->scale(), Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
@@ -133,32 +133,32 @@
m_canvas->m_viewMode.operItemResizing = false;
m_view->MidButt = false;
m_keyRepeat = false;
- currItem = m_doc->m_Selection->itemAt(0);
- weldToList = currItem->itemsWeldedTo();
- weldToList.append(currItem);
- Mxp = Myp = -1;
- selectedPoint = -1;
+ m_currItem = m_doc->m_Selection->itemAt(0);
+ m_weldToList = m_currItem->itemsWeldedTo();
+ m_weldToList.append(m_currItem);
+ m_Mxp = m_Myp = -1;
+ m_selectedPoint = -1;
setModeCursor();
if (fromGesture)
{
m_view->update();
}
- ModeDialog = new WeldEditDialog(m_ScMW);
- ModeDialog->show();
- connect(ModeDialog, SIGNAL(endEdit()), this, SLOT(endEditing()));
- connect(ModeDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool)));
- connect(ModeDialog, SIGNAL(modeMoveWeld()), this, SLOT(setWeldMode()));
- connect(ModeDialog, SIGNAL(modeMoveObject()), this, SLOT(setObjectMode()));
+ m_ModeDialog = new WeldEditDialog(m_ScMW);
+ m_ModeDialog->show();
+ connect(m_ModeDialog, SIGNAL(endEdit()), this, SLOT(endEditing()));
+ connect(m_ModeDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool)));
+ connect(m_ModeDialog, SIGNAL(modeMoveWeld()), this, SLOT(setWeldMode()));
+ connect(m_ModeDialog, SIGNAL(modeMoveObject()), this, SLOT(setObjectMode()));
}
void CanvasMode_EditWeldPoint::deactivate(bool forGesture)
{
m_view->setRedrawMarkerShown(false);
- selectedPoint = -1;
- weldToList.clear();
- disconnect(ModeDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool)));
- ModeDialog->close();
- delete ModeDialog;
+ m_selectedPoint = -1;
+ m_weldToList.clear();
+ disconnect(m_ModeDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool)));
+ m_ModeDialog->close();
+ delete m_ModeDialog;
}
void CanvasMode_EditWeldPoint::endEditing(bool active)
@@ -174,17 +174,17 @@
void CanvasMode_EditWeldPoint::setWeldMode()
{
- editWeldMode = true;
+ m_editWeldMode = true;
}
void CanvasMode_EditWeldPoint::setObjectMode()
{
- editWeldMode = false;
+ m_editWeldMode = false;
}
void CanvasMode_EditWeldPoint::keyPressEvent(QKeyEvent *e)
{
- if (selectedPoint < 0)
+ if (m_selectedPoint < 0)
return;
int kk = e->key();
if (m_keyRepeat)
@@ -283,9 +283,9 @@
}
if (isMoving)
{
- if (editWeldMode)
+ if (m_editWeldMode)
{
- currItem->weldList[selectedPoint].weldPoint += FPoint(moveX, moveY);
+ currItem->weldList[m_selectedPoint].weldPoint += FPoint(moveX, moveY);
}
else
{
@@ -313,7 +313,7 @@
{
if ((m_doc->m_Selection->isMultipleSelection()) && (m_doc->appMode == modeNormal))
{
- if (GetItem(&currItem))
+ if (GetItem(&m_currItem))
{
/* CB: old code, removing this as shift-alt select on an unselected table selects a cell now.
//#6789 is closed by sorting this.
@@ -332,7 +332,7 @@
}
else
{
- if (!(GetItem(&currItem) && (m_doc->appMode == modeEdit) && currItem->asTextFrame()))
+ if (!(GetItem(&m_currItem) && (m_doc->appMode == modeEdit) && m_currItem->asTextFrame()))
{
mousePressEvent(m);
return;
@@ -352,36 +352,36 @@
npfN = m_doc->ApplyGridF(FPoint(nx, ny));
else
npfN = FPoint(nx, ny);
- currItem = m_doc->m_Selection->itemAt(0);
- FPoint npf = FPoint(npfN.x(), npfN.y(), currItem->xPos(), currItem->yPos(), currItem->rotation(), 1, 1, true);
- FPoint npx(Mxp - npfN.x(), Myp - npfN.y(), 0, 0, currItem->rotation(), 1, 1, true);
+ m_currItem = m_doc->m_Selection->itemAt(0);
+ FPoint npf = FPoint(npfN.x(), npfN.y(), m_currItem->xPos(), m_currItem->yPos(), m_currItem->rotation(), 1, 1, true);
+ FPoint npx(m_Mxp - npfN.x(), m_Myp - npfN.y(), 0, 0, m_currItem->rotation(), 1, 1, true);
m_canvas->displayXYHUD(m->globalPos(), npf.x(), npf.y());
if (m_canvas->m_viewMode.m_MouseButtonPressed && m_view->moveTimerElapsed())
{
- if (editWeldMode)
- {
- if (selectedPoint != -1)
+ if (m_editWeldMode)
+ {
+ if (m_selectedPoint != -1)
{
m_canvas->displayXYHUD(m->globalPos(), npf.x(), npf.y());
FPoint mp, mp_orig;
- mp_orig = currItem->weldList[selectedPoint].weldPoint;
+ mp_orig = m_currItem->weldList[m_selectedPoint].weldPoint;
mp = mp_orig - npx;
double xx = mp.x();
double yy = mp.y();
snapToEdgePoints(xx, yy);
- currItem->weldList[selectedPoint].weldPoint = FPoint(xx, yy);
+ m_currItem->weldList[m_selectedPoint].weldPoint = FPoint(xx, yy);
}
}
else
{
- currItem->setXYPos(currItem->xPos() - npx.x(), currItem->yPos() - npx.y(), true);
- currItem->setRedrawBounding();
- currItem->OwnPage = m_doc->OnPage(currItem);
+ m_currItem->setXYPos(m_currItem->xPos() - npx.x(), m_currItem->yPos() - npx.y(), true);
+ m_currItem->setRedrawBounding();
+ m_currItem->OwnPage = m_doc->OnPage(m_currItem);
}
m_doc->regionsChanged()->update(getUpdateRect());
}
- Mxp = npfN.x();
- Myp = npfN.y();
+ m_Mxp = npfN.x();
+ m_Myp = npfN.y();
}
void CanvasMode_EditWeldPoint::mousePressEvent(QMouseEvent *m)
@@ -396,8 +396,8 @@
m_doc->leaveDrag = false;
m->accept();
m_view->registerMousePress(m->globalPos());
- Mxp = mousePointDoc.x(); //m->x();
- Myp = mousePointDoc.y(); //m->y();
+ m_Mxp = mousePointDoc.x(); //m->x();
+ m_Myp = mousePointDoc.y(); //m->y();
if (m->button() == Qt::MidButton)
{
m_view->MidButt = true;
@@ -406,16 +406,16 @@
return;
}
QTransform itemMatrix;
- currItem = m_doc->m_Selection->itemAt(0);
- itemMatrix.translate(currItem->xPos(), currItem->yPos());
- itemMatrix.rotate(currItem->rotation());
- selectedPoint = -1;
- for (int i = 0 ; i < currItem->weldList.count(); i++)
- {
- PageItem::WeldingInfo wInf = currItem->weldList.at(i);
+ m_currItem = m_doc->m_Selection->itemAt(0);
+ itemMatrix.translate(m_currItem->xPos(), m_currItem->yPos());
+ itemMatrix.rotate(m_currItem->rotation());
+ m_selectedPoint = -1;
+ for (int i = 0 ; i < m_currItem->weldList.count(); i++)
+ {
+ PageItem::WeldingInfo wInf = m_currItem->weldList.at(i);
if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(QPointF(wInf.weldPoint.x(), wInf.weldPoint.y()))))
{
- selectedPoint = i;
+ m_selectedPoint = i;
break;
}
}
@@ -429,8 +429,8 @@
m_canvas->m_viewMode.m_MouseButtonPressed = false;
m_canvas->resetRenderMode();
m->accept();
- currItem = m_doc->m_Selection->itemAt(0);
- currItem->update();
+ m_currItem = m_doc->m_Selection->itemAt(0);
+ m_currItem->update();
m_doc->regionsChanged()->update(getUpdateRect());
}
@@ -443,52 +443,52 @@
y = 0.0;
return;
}
- else if ((qAbs((currItem->width() / 2.0) - x) < radius) && (qAbs(0.0 - y) < radius))
- {
- x = currItem->width() / 2.0;
+ else if ((qAbs((m_currItem->width() / 2.0) - x) < radius) && (qAbs(0.0 - y) < radius))
+ {
+ x = m_currItem->width() / 2.0;
y = 0.0;
return;
}
- else if ((qAbs(currItem->width() - x) < radius) && (qAbs(0.0 - y) < radius))
- {
- x = currItem->width();
+ else if ((qAbs(m_currItem->width() - x) < radius) && (qAbs(0.0 - y) < radius))
+ {
+ x = m_currItem->width();
y = 0.0;
return;
}
- else if ((qAbs(0.0 - x) < radius) && (qAbs((currItem->height() / 2.0) - y) < radius))
+ else if ((qAbs(0.0 - x) < radius) && (qAbs((m_currItem->height() / 2.0) - y) < radius))
{
x = 0.0;
- y = currItem->height() / 2.0;
- return;
- }
- else if ((qAbs((currItem->width() / 2.0) - x) < radius) && (qAbs((currItem->height() / 2.0) - y) < radius))
- {
- x = currItem->width() / 2.0;
- y = currItem->height() / 2.0;
- return;
- }
- else if ((qAbs(currItem->width() - x) < radius) && (qAbs((currItem->height() / 2.0) - y) < radius))
- {
- x = currItem->width();
- y = currItem->height() / 2.0;
- return;
- }
- else if ((qAbs(0.0 - x) < radius) && (qAbs(currItem->height() - y) < radius))
+ y = m_currItem->height() / 2.0;
+ return;
+ }
+ else if ((qAbs((m_currItem->width() / 2.0) - x) < radius) && (qAbs((m_currItem->height() / 2.0) - y) < radius))
+ {
+ x = m_currItem->width() / 2.0;
+ y = m_currItem->height() / 2.0;
+ return;
+ }
+ else if ((qAbs(m_currItem->width() - x) < radius) && (qAbs((m_currItem->height() / 2.0) - y) < radius))
+ {
+ x = m_currItem->width();
+ y = m_currItem->height() / 2.0;
+ return;
+ }
+ else if ((qAbs(0.0 - x) < radius) && (qAbs(m_currItem->height() - y) < radius))
{
x = 0.0;
- y = currItem->height();
- return;
- }
- else if ((qAbs((currItem->width() / 2.0) - x) < radius) && (qAbs(currItem->height() - y) < radius))
- {
- x = currItem->width() / 2.0;
- y = currItem->height();
- return;
- }
- else if ((qAbs(currItem->width() - x) < radius) && (qAbs(currItem->height() - y) < radius))
- {
- x = currItem->width();
- y = currItem->height();
+ y = m_currItem->height();
+ return;
+ }
+ else if ((qAbs((m_currItem->width() / 2.0) - x) < radius) && (qAbs(m_currItem->height() - y) < radius))
+ {
+ x = m_currItem->width() / 2.0;
+ y = m_currItem->height();
+ return;
+ }
+ else if ((qAbs(m_currItem->width() - x) < radius) && (qAbs(m_currItem->height() - y) < radius))
+ {
+ x = m_currItem->width();
+ y = m_currItem->height();
return;
}
}
@@ -496,7 +496,7 @@
QRectF CanvasMode_EditWeldPoint::getUpdateRect()
{
PageItem *item;
- uint selectedItemCount = weldToList.count();
+ uint selectedItemCount = m_weldToList.count();
if (selectedItemCount == 0)
return QRectF();
double vminx = std::numeric_limits<double>::max();
@@ -506,7 +506,7 @@
for (uint gc = 0; gc < selectedItemCount; ++gc)
{
- item = weldToList.at(gc);
+ item = m_weldToList.at(gc);
if (item->rotation() != 0)
{
QRectF itRect(item->getVisualBoundingRect());
Modified: trunk/Scribus/scribus/canvasmode_editweldpoint.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_editweldpoint.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editweldpoint.h (original)
+++ trunk/Scribus/scribus/canvasmode_editweldpoint.h Fri Nov 27 23:35:43 2015
@@ -1,83 +1,83 @@
-/*
- For general Scribus (>=1.3.2) copyright and licensing information please refer
- to the COPYING file provided with the program. Following this notice may exist
- a copyright and/or license notice that predates the release of Scribus 1.3.2
- for which a new license (GPL+exception) is in place.
- */
-/***************************************************************************
-* *
-* This program is free software; you can redistribute it and/or modify *
-* it under the terms of the GNU General Public License as published by *
-* the Free Software Foundation; either version 2 of the License, or *
-* (at your option) any later version. *
-* *
-***************************************************************************/
-/***************************************************************************
- canvasmode_editweldpoint.h - description
- -------------------
- begin : Sun Okt 23 2011
- copyright : (C) 2011 by Franz Schmid
- email : Franz.Schmid at altmuehlnet.de
- ***************************************************************************/
-
-#ifndef CANVASMODE_EDITWELDPOINT_H
-#define CANVASMODE_EDITWELDPOINT_H
-
-#include <QObject>
-#include <QTime>
-
-#include "canvasmode.h"
-#include "fpointarray.h"
-#include "ui/weldedit.h"
-
-class PageItem;
-class PageItem_TextFrame;
-class ScribusMainWindow;
-class ScribusView;
-
-
-// This class encapsulate the old code for mouse interaction from scribusview.cpp
-
-class CanvasMode_EditWeldPoint : public CanvasMode
-{
- Q_OBJECT
-public:
- explicit CanvasMode_EditWeldPoint(ScribusView* view);
- virtual ~CanvasMode_EditWeldPoint() {}
-
- virtual void enterEvent(QEvent *);
- virtual void leaveEvent(QEvent *);
-
- virtual void activate(bool);
- virtual void deactivate(bool);
- virtual void mouseDoubleClickEvent(QMouseEvent *m);
- virtual void mouseReleaseEvent(QMouseEvent *m);
- virtual void mouseMoveEvent(QMouseEvent *m);
- virtual void mousePressEvent(QMouseEvent *m);
- virtual void keyPressEvent(QKeyEvent *e);
- virtual bool handleKeyEvents() { return true; }
- virtual void drawControls(QPainter* p);
- void drawControlsWeldPoint(QPainter* pp, PageItem* currItem);
-
-private:
- void snapToEdgePoints(double &x, double &y);
- QRectF getUpdateRect();
-
- inline bool GetItem(PageItem** pi);
-
- double Mxp, Myp;
- int selectedPoint;
- ScribusMainWindow* m_ScMW;
- bool m_keyRepeat;
- PageItem *currItem;
- QList<PageItem*> weldToList;
- WeldEditDialog* ModeDialog;
- bool editWeldMode;
-private slots:
- void endEditing(bool active);
- void endEditing();
- void setWeldMode();
- void setObjectMode();
-};
-
-#endif
+/*
+ For general Scribus (>=1.3.2) copyright and licensing information please refer
+ to the COPYING file provided with the program. Following this notice may exist
+ a copyright and/or license notice that predates the release of Scribus 1.3.2
+ for which a new license (GPL+exception) is in place.
+ */
+/***************************************************************************
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+***************************************************************************/
+/***************************************************************************
+ canvasmode_editweldpoint.h - description
+ -------------------
+ begin : Sun Okt 23 2011
+ copyright : (C) 2011 by Franz Schmid
+ email : Franz.Schmid at altmuehlnet.de
+ ***************************************************************************/
+
+#ifndef CANVASMODE_EDITWELDPOINT_H
+#define CANVASMODE_EDITWELDPOINT_H
+
+#include <QObject>
+#include <QTime>
+
+#include "canvasmode.h"
+#include "fpointarray.h"
+#include "ui/weldedit.h"
+
+class PageItem;
+class PageItem_TextFrame;
+class ScribusMainWindow;
+class ScribusView;
+
+
+// This class encapsulate the old code for mouse interaction from scribusview.cpp
+
+class CanvasMode_EditWeldPoint : public CanvasMode
+{
+ Q_OBJECT
+public:
+ explicit CanvasMode_EditWeldPoint(ScribusView* view);
+ virtual ~CanvasMode_EditWeldPoint() {}
+
+ virtual void enterEvent(QEvent *);
+ virtual void leaveEvent(QEvent *);
+
+ virtual void activate(bool);
+ virtual void deactivate(bool);
+ virtual void mouseDoubleClickEvent(QMouseEvent *m);
+ virtual void mouseReleaseEvent(QMouseEvent *m);
+ virtual void mouseMoveEvent(QMouseEvent *m);
+ virtual void mousePressEvent(QMouseEvent *m);
+ virtual void keyPressEvent(QKeyEvent *e);
+ virtual bool handleKeyEvents() { return true; }
+ virtual void drawControls(QPainter* p);
+ void drawControlsWeldPoint(QPainter* pp, PageItem* currItem);
+
+private:
+ void snapToEdgePoints(double &x, double &y);
+ QRectF getUpdateRect();
+
+ inline bool GetItem(PageItem** pi);
+
+ double m_Mxp, m_Myp;
+ int m_selectedPoint;
+ ScribusMainWindow* m_ScMW;
+ bool m_keyRepeat;
+ PageItem *m_currItem;
+ QList<PageItem*> m_weldToList;
+ WeldEditDialog* m_ModeDialog;
+ bool m_editWeldMode;
+private slots:
+ void endEditing(bool active);
+ void endEditing();
+ void setWeldMode();
+ void setObjectMode();
+};
+
+#endif
Modified: trunk/Scribus/scribus/canvasmode_framelinks.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_framelinks.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_framelinks.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_framelinks.cpp Fri Nov 27 23:35:43 2015
@@ -54,9 +54,9 @@
CanvasMode_FrameLinks::CanvasMode_FrameLinks(ScribusView* view) : CanvasMode(view), m_ScMW(view->m_ScMW)
{
- Mxp = Myp = -1;
- Dxp = Dyp = -1;
- frameResizeHandle = -1;
+ m_Mxp = m_Myp = -1;
+ m_Dxp = m_Dyp = -1;
+ m_frameResizeHandle = -1;
}
inline bool CanvasMode_FrameLinks::GetItem(PageItem** pi)
@@ -93,9 +93,9 @@
m_canvas->m_viewMode.operItemMoving = false;
m_canvas->m_viewMode.operItemResizing = false;
m_view->MidButt = false;
- Mxp = Myp = -1;
- Dxp = Dyp = -1;
- frameResizeHandle = -1;
+ m_Mxp = m_Myp = -1;
+ m_Dxp = m_Dyp = -1;
+ m_frameResizeHandle = -1;
setModeCursor();
if (fromGesture)
{
@@ -127,9 +127,9 @@
return;
if ((m_canvas->m_viewMode.m_MouseButtonPressed) && (m->buttons() & Qt::LeftButton))
{
- SeRx = qRound(mousePointDoc.x()); //m_view->translateToDoc(m->x(), m->y()).x());
- SeRy = qRound(mousePointDoc.y()); //m_view->translateToDoc(m->x(), m->y()).y());
- QPoint startP = m_canvas->canvasToGlobal(m_doc->appMode == modeDrawTable2 ? QPointF(Dxp, Dyp) : QPointF(Mxp, Myp));
+ m_SeRx = qRound(mousePointDoc.x()); //m_view->translateToDoc(m->x(), m->y()).x());
+ m_SeRy = qRound(mousePointDoc.y()); //m_view->translateToDoc(m->x(), m->y()).y());
+ QPoint startP = m_canvas->canvasToGlobal(m_doc->appMode == modeDrawTable2 ? QPointF(m_Dxp, m_Dyp) : QPointF(m_Mxp, m_Myp));
m_view->redrawMarker->setGeometry(QRect(m_view->mapFromGlobal(startP), m_view->mapFromGlobal(m->globalPos())).normalized());
m_view->setRedrawMarkerShown(true);
m_view->HaveSelRect = true;
@@ -152,14 +152,14 @@
// oldClip = 0;
m->accept();
m_view->registerMousePress(m->globalPos());
- Mxp = mousePointDoc.x(); //qRound(m->x()/m_canvas->scale() + 0*m_doc->minCanvasCoordinate.x());
- Myp = mousePointDoc.y(); //qRound(m->y()/m_canvas->scale() + 0*m_doc->minCanvasCoordinate.y());
- Rxp = m_doc->ApplyGridF(FPoint(Mxp, Myp)).x();
- Mxp = qRound(Rxp);
- Ryp = m_doc->ApplyGridF(FPoint(Mxp, Myp)).y();
- Myp = qRound(Ryp);
- SeRx = Mxp;
- SeRy = Myp;
+ m_Mxp = mousePointDoc.x(); //qRound(m->x()/m_canvas->scale() + 0*m_doc->minCanvasCoordinate.x());
+ m_Myp = mousePointDoc.y(); //qRound(m->y()/m_canvas->scale() + 0*m_doc->minCanvasCoordinate.y());
+ Rxp = m_doc->ApplyGridF(FPoint(m_Mxp, m_Myp)).x();
+ m_Mxp = qRound(Rxp);
+ Ryp = m_doc->ApplyGridF(FPoint(m_Mxp, m_Myp)).y();
+ m_Myp = qRound(Ryp);
+ m_SeRx = m_Mxp;
+ m_SeRy = m_Myp;
if (m->button() == Qt::MidButton)
{
m_view->MidButt = true;
@@ -326,13 +326,13 @@
{
m_canvas->m_viewMode.m_MouseButtonPressed = true;
FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
- Mxp = mousePointDoc.x(); //static_cast<int>(m->x()/m_canvas->scale());
- Myp = mousePointDoc.y(); //static_cast<int>(m->y()/m_canvas->scale());
+ m_Mxp = mousePointDoc.x(); //static_cast<int>(m->x()/m_canvas->scale());
+ m_Myp = mousePointDoc.y(); //static_cast<int>(m->y()/m_canvas->scale());
m_doc->nodeEdit.deselect();
m_view->Deselect(false);
if (!m_doc->masterPageMode())
{
- int i = m_doc->OnPage(Mxp, Myp);
+ int i = m_doc->OnPage(m_Mxp, m_Myp);
if (i!=-1)
{
uint docCurrPageNo=m_doc->currentPageNumber();
@@ -358,8 +358,8 @@
PageItem *currItem;
m_canvas->m_viewMode.m_MouseButtonPressed = true;
FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
- Mxp = mousePointDoc.x(); //m->x()/m_canvas->scale());
- Myp = mousePointDoc.y(); //m->y()/m_canvas->scale());
+ m_Mxp = mousePointDoc.x(); //m->x()/m_canvas->scale());
+ m_Myp = mousePointDoc.y(); //m->y()/m_canvas->scale());
int MxpS = static_cast<int>(mousePointDoc.x()); //m->x()/m_canvas->scale() + 0*m_doc->minCanvasCoordinate.x());
int MypS = static_cast<int>(mousePointDoc.y()); //m->y()/m_canvas->scale() + 0*m_doc->minCanvasCoordinate.y());
m_doc->nodeEdit.deselect();
@@ -466,8 +466,8 @@
}
if (m_doc->m_Selection->count() == 1)
{
- frameResizeHandle = m_canvas->frameHitTest(QPointF(mousePointDoc.x(),mousePointDoc.y()), currItem);
- if ((frameResizeHandle == Canvas::INSIDE) && (!currItem->locked()))
+ m_frameResizeHandle = m_canvas->frameHitTest(QPointF(mousePointDoc.x(),mousePointDoc.y()), currItem);
+ if ((m_frameResizeHandle == Canvas::INSIDE) && (!currItem->locked()))
m_view->setCursor(QCursor(Qt::SizeAllCursor));
}
else
@@ -487,8 +487,8 @@
{
ContextMenu* cmen=NULL;
m_view->setObjectUndoMode();
- Mxp = mx;
- Myp = my;
+ m_Mxp = mx;
+ m_Myp = my;
if(currItem!=NULL)
{
cmen = new ContextMenu(*(m_doc->m_Selection), m_ScMW, m_doc);
Modified: trunk/Scribus/scribus/canvasmode_framelinks.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_framelinks.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_framelinks.h (original)
+++ trunk/Scribus/scribus/canvasmode_framelinks.h Fri Nov 27 23:35:43 2015
@@ -63,9 +63,9 @@
bool SeleItem(QMouseEvent *m);
void createContextMenu(PageItem *currItem, double mx, double my);
- int frameResizeHandle;
- double Mxp, Myp, Dxp, Dyp;
- double SeRx, SeRy;
+ int m_frameResizeHandle;
+ double m_Mxp, m_Myp, m_Dxp, m_Dyp;
+ double m_SeRx, m_SeRy;
ScribusMainWindow* m_ScMW;
};
Modified: trunk/Scribus/scribus/canvasmode_imageimport.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_imageimport.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_imageimport.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_imageimport.cpp Fri Nov 27 23:35:43 2015
@@ -40,13 +40,13 @@
CanvasMode_ImageImport::CanvasMode_ImageImport(ScribusView *view) : CanvasMode(view), m_ScMW(view->m_ScMW)
{
- Mx=0;
- My=0;
+ m_Mx=0;
+ m_My=0;
}
void CanvasMode_ImageImport::setImageList(QStringList l)
{
- imageList = l;
+ m_imageList = l;
if(l.size()==1)
{
while(!(m_doc->m_Selection->itemAt(0)->isImageFrame()))
@@ -80,11 +80,11 @@
pm.save(&buffer, "PNG");
QByteArray ba = buffer.buffer().toBase64();
buffer.close();
- tipText = "<p align=\"center\"><img src=\"data:image/png;base64," + QString(ba) + "\"></p>";
- }
- else
- tipText = "<p align=\"center\">" + name.right(name.lastIndexOf("/")) + "</p>";
- QToolTip::showText(QPoint(Mx,My), tipText, qApp->activeWindow());
+ m_tipText = "<p align=\"center\"><img src=\"data:image/png;base64," + QString(ba) + "\"></p>";
+ }
+ else
+ m_tipText = "<p align=\"center\">" + name.right(name.lastIndexOf("/")) + "</p>";
+ QToolTip::showText(QPoint(m_Mx,m_My), m_tipText, qApp->activeWindow());
p.end();
}
@@ -109,16 +109,16 @@
switch (kk)
{
case Qt::Key_Tab:
- imageList.prepend(imageList.takeLast());
+ m_imageList.prepend(m_imageList.takeLast());
break;
case Qt::Key_Backtab:
- imageList.append(imageList.takeFirst());
+ m_imageList.append(m_imageList.takeFirst());
break;
case Qt::Key_Backspace:
- imageList.removeFirst();
+ m_imageList.removeFirst();
break;
case Qt::Key_Escape:
- imageList.clear();
+ m_imageList.clear();
break;
}
updateList();
@@ -159,10 +159,10 @@
void CanvasMode_ImageImport::mouseMoveEvent(QMouseEvent *m)
{
- Mx = m->globalPos().x();
- My = m->globalPos().y();
- QToolTip::showText(m->globalPos(), tipText, qApp->activeWindow());
- QToolTip::showText(m->globalPos(), tipText + "<b></b>", qApp->activeWindow());
+ m_Mx = m->globalPos().x();
+ m_My = m->globalPos().y();
+ QToolTip::showText(m->globalPos(), m_tipText, qApp->activeWindow());
+ QToolTip::showText(m->globalPos(), m_tipText + "<b></b>", qApp->activeWindow());
m->accept();
PageItem *item;
if((item = m_canvas->itemUnderCursor(m->globalPos())) != NULL)
@@ -190,7 +190,7 @@
m->accept();
m_view->registerMousePress(m->globalPos());
PageItem *item;
- if(imageList.size()>0)
+ if(m_imageList.size()>0)
{
if((item = m_canvas->itemUnderCursor(m->globalPos())) != NULL)
{
@@ -227,7 +227,7 @@
void CanvasMode_ImageImport::setImage(PageItem *currItem)
{
- QString fileName = imageList.takeFirst();
+ QString fileName = m_imageList.takeFirst();
currItem->EmProfile = "";
currItem->pixm.imgInfo.isRequest = false;
currItem->UseEmbedded = true;
@@ -244,11 +244,11 @@
void CanvasMode_ImageImport::updateList()
{
- if(imageList.isEmpty())
+ if(m_imageList.isEmpty())
{
m_view->requestMode(submodePaintingDone);
QToolTip::hideText();
}
else
- newToolTip(imageList.first());
-}
+ newToolTip(m_imageList.first());
+}
Modified: trunk/Scribus/scribus/canvasmode_imageimport.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_imageimport.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_imageimport.h (original)
+++ trunk/Scribus/scribus/canvasmode_imageimport.h Fri Nov 27 23:35:43 2015
@@ -54,10 +54,10 @@
private:
bool m_keyRepeat;
- QString tipText;
- QStringList imageList;
+ QString m_tipText;
+ QStringList m_imageList;
ScribusMainWindow *m_ScMW;
- double Mx, My;
+ double m_Mx, m_My;
void newToolTip(QString name);
};
Modified: trunk/Scribus/scribus/canvasmode_magnifier.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_magnifier.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_magnifier.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_magnifier.cpp Fri Nov 27 23:35:43 2015
@@ -53,8 +53,8 @@
CanvasMode_Magnifier::CanvasMode_Magnifier(ScribusView* view) : CanvasMode(view)
{
- Mxp = Myp = -1;
- Dxp = Dyp = -1;
+ m_Mxp = m_Myp = -1;
+ m_Dxp = m_Dyp = -1;
}
void CanvasMode_Magnifier::drawControls(QPainter* p)
@@ -86,8 +86,8 @@
m_canvas->m_viewMode.operItemMoving = false;
m_canvas->m_viewMode.operItemResizing = false;
m_view->MidButt = false;
- Mxp = Myp = -1;
- Dxp = Dyp = -1;
+ m_Mxp = m_Myp = -1;
+ m_Dxp = m_Dyp = -1;
setModeCursor();
if (fromGesture)
{
@@ -122,10 +122,10 @@
if ((m_canvas->m_viewMode.m_MouseButtonPressed) && (m->buttons() & Qt::LeftButton))
{
newX = qRound(mousePointDoc.x()); //m_view->translateToDoc(m->x(), m->y()).x());
- newY = qRound(Myp + ((SeRx - Mxp) * m_view->visibleHeight()) / m_view->visibleWidth());
- SeRx = newX;
- SeRy = newY;
- QPoint startP = m_canvas->canvasToGlobal(m_doc->appMode == modeDrawTable2 ? QPointF(Dxp, Dyp) : QPointF(Mxp, Myp));
+ newY = qRound(m_Myp + ((m_SeRx - m_Mxp) * m_view->visibleHeight()) / m_view->visibleWidth());
+ m_SeRx = newX;
+ m_SeRy = newY;
+ QPoint startP = m_canvas->canvasToGlobal(m_doc->appMode == modeDrawTable2 ? QPointF(m_Dxp, m_Dyp) : QPointF(m_Mxp, m_Myp));
m_view->redrawMarker->setGeometry(QRect(m_view->mapFromGlobal(startP), m_view->mapFromGlobal(m->globalPos())).normalized());
m_view->setRedrawMarkerShown(true);
m_view->HaveSelRect = true;
@@ -145,14 +145,14 @@
m_doc->leaveDrag = false;
m->accept();
m_view->registerMousePress(m->globalPos());
- Mxp = mousePointDoc.x(); //qRound(m->x()/m_canvas->scale() + 0*m_doc->minCanvasCoordinate.x());
- Myp = mousePointDoc.y(); //qRound(m->y()/m_canvas->scale() + 0*m_doc->minCanvasCoordinate.y());
- Rxp = m_doc->ApplyGridF(FPoint(Mxp, Myp)).x();
- Mxp = qRound(Rxp);
- Ryp = m_doc->ApplyGridF(FPoint(Mxp, Myp)).y();
- Myp = qRound(Ryp);
- SeRx = Mxp;
- SeRy = Myp;
+ m_Mxp = mousePointDoc.x(); //qRound(m->x()/m_canvas->scale() + 0*m_doc->minCanvasCoordinate.x());
+ m_Myp = mousePointDoc.y(); //qRound(m->y()/m_canvas->scale() + 0*m_doc->minCanvasCoordinate.y());
+ Rxp = m_doc->ApplyGridF(FPoint(m_Mxp, m_Myp)).x();
+ m_Mxp = qRound(Rxp);
+ Ryp = m_doc->ApplyGridF(FPoint(m_Mxp, m_Myp)).y();
+ m_Myp = qRound(Ryp);
+ m_SeRx = m_Mxp;
+ m_SeRy = m_Myp;
if (m->button() == Qt::MidButton)
{
m_view->MidButt = true;
@@ -171,10 +171,10 @@
m_view->Magnify = true;
m_view->setCursor(IconManager::instance()->loadCursor("LupeZ.xpm"));
}
- Mxp = mousePointDoc.x(); //m->globalPos().x();
- Myp = mousePointDoc.y(); //m->globalPos().y();
- SeRx = Mxp;
- SeRy = Myp;
+ m_Mxp = mousePointDoc.x(); //m->globalPos().x();
+ m_Myp = mousePointDoc.y(); //m->globalPos().y();
+ m_SeRx = m_Mxp;
+ m_SeRy = m_Myp;
m_view->redrawMarker->setGeometry(m->globalPos().x(), m->globalPos().y(), 1, 1);
}
Modified: trunk/Scribus/scribus/canvasmode_magnifier.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_magnifier.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_magnifier.h (original)
+++ trunk/Scribus/scribus/canvasmode_magnifier.h Fri Nov 27 23:35:43 2015
@@ -56,8 +56,8 @@
private:
- double Mxp, Myp, Dxp, Dyp;
- double SeRx, SeRy;
+ double m_Mxp, m_Myp, m_Dxp, m_Dyp;
+ double m_SeRx, m_SeRy;
bool m_lastPosWasOverGuide;
};
Modified: trunk/Scribus/scribus/canvasmode_nodeedit.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_nodeedit.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_nodeedit.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_nodeedit.cpp Fri Nov 27 23:35:43 2015
@@ -40,13 +40,13 @@
CanvasMode_NodeEdit::CanvasMode_NodeEdit(ScribusView* view) : CanvasMode(view), m_rectangleSelect(NULL)
{
- Mxp = -1; // last mouse position
- Myp = -1;
- Dxp = -1; // last mouse press position for rectangle select
- Dyp = -1;
- GxM = -1; // guide position
- GyM = -1;
- MoveGX = MoveGY = false;
+ m_Mxp = -1; // last mouse position
+ m_Myp = -1;
+ m_Dxp = -1; // last mouse press position for rectangle select
+ m_Dyp = -1;
+ m_GxM = -1; // guide position
+ m_GyM = -1;
+ m_MoveGX = m_MoveGY = false;
m_ScMW = m_view->m_ScMW;
}
@@ -225,13 +225,13 @@
}
else
{
- Mxp = -1; // last mouse position
- Myp = -1;
- Dxp = -1; // last mouse press position for rectangle select
- Dyp = -1;
- GxM = -1; // guide position
- GyM = -1;
- MoveGX = MoveGY = false;
+ m_Mxp = -1; // last mouse position
+ m_Myp = -1;
+ m_Dxp = -1; // last mouse press position for rectangle select
+ m_Dyp = -1;
+ m_GxM = -1; // guide position
+ m_GyM = -1;
+ m_MoveGX = m_MoveGY = false;
}
}
@@ -307,7 +307,7 @@
else // shouldnt be in nodeedit mode now, should it??
{
npf = m_canvas->globalToCanvas(m->globalPos());
- if ((m_canvas->m_viewMode.m_MouseButtonPressed) && (m->buttons() & Qt::LeftButton) && (GyM == -1) && (GxM == -1))
+ if ((m_canvas->m_viewMode.m_MouseButtonPressed) && (m->buttons() & Qt::LeftButton) && (m_GyM == -1) && (m_GxM == -1))
{
if (!m_rectangleSelect)
{
@@ -327,8 +327,8 @@
if ( (*it) + m_doc->currentPage()->yOffset() < npf.y() + m_doc->guidesPrefs().grabRadius * sc &&
(*it) + m_doc->currentPage()->yOffset() > npf.y() - m_doc->guidesPrefs().grabRadius * sc )
{
- if ((m_canvas->m_viewMode.m_MouseButtonPressed) && (GyM != -1))
- MoveGY = true;
+ if ((m_canvas->m_viewMode.m_MouseButtonPressed) && (m_GyM != -1))
+ m_MoveGY = true;
if (npf.x() < m_doc->currentPage()->xOffset() ||
npf.x() >= m_doc->currentPage()->xOffset() + m_doc->currentPage()->width() - 1)
m_view->setCursor(QCursor(Qt::ArrowCursor));
@@ -343,8 +343,8 @@
if ( (*it) + m_doc->currentPage()->xOffset() < npf.x() + m_doc->guidesPrefs().grabRadius * sc &&
(*it) + m_doc->currentPage()->xOffset() > npf.x() - m_doc->guidesPrefs().grabRadius * sc)
{
- if ((m_canvas->m_viewMode.m_MouseButtonPressed) && (GxM != -1))
- MoveGX = true;
+ if ((m_canvas->m_viewMode.m_MouseButtonPressed) && (m_GxM != -1))
+ m_MoveGX = true;
if (npf.y() < m_doc->currentPage()->yOffset() ||
npf.y() >= m_doc->currentPage()->yOffset() + m_doc->currentPage()->height() - 1)
m_view->setCursor(QCursor(Qt::ArrowCursor));
@@ -364,12 +364,12 @@
m_canvas->m_viewMode.operItemMoving = false;
m_doc->DragP = false;
m_doc->leaveDrag = false;
- MoveGX = MoveGY = false;
+ m_MoveGX = m_MoveGY = false;
m->accept();
m_view->registerMousePress(m->globalPos());
QRect mpo;
- Mxp = m->x();
- Myp = m->y();
+ m_Mxp = m->x();
+ m_Myp = m->y();
if (((m->buttons() & Qt::RightButton) && (m->modifiers() & Qt::ControlModifier)) || ((!(m->modifiers() & Qt::ControlModifier)) && (m->buttons() & Qt::MidButton)))
{
@@ -389,8 +389,8 @@
if ((m_doc->m_Selection->count() != 0) && (m->button() == Qt::RightButton))
{
m_canvas->m_viewMode.m_MouseButtonPressed = true;
- Dxp = Mxp;
- Dyp = Myp;
+ m_Dxp = m_Mxp;
+ m_Dyp = m_Myp;
}
}
@@ -959,16 +959,16 @@
}
if ((m_doc->nodeEdit.selNode().count() != 0) || ((m_doc->nodeEdit.segP1() != -1) && (m_doc->nodeEdit.segP2() != -1)) || (m_doc->nodeEdit.hasNodeSelected() && (!m_doc->nodeEdit.edPoints())))
{
- Mxp = m->x();
- Myp = m->y();
+ m_Mxp = m->x();
+ m_Myp = m->y();
m_canvas->setRenderModeFillBuffer();
}
else
{
- Mxp = m->x();
- Myp = m->y();
- Dxp = qRound(m->x()/m_canvas->scale()); // + m_doc->minCanvasCoordinate.x());
- Dyp = qRound(m->y()/m_canvas->scale()); // + m_doc->minCanvasCoordinate.y());
+ m_Mxp = m->x();
+ m_Myp = m->y();
+ m_Dxp = qRound(m->x()/m_canvas->scale()); // + m_doc->minCanvasCoordinate.x());
+ m_Dyp = qRound(m->y()/m_canvas->scale()); // + m_doc->minCanvasCoordinate.y());
if (!m_rectangleSelect)
m_rectangleSelect = new RectSelect(this);
m_rectangleSelect->prepare(m->globalPos());
@@ -1081,7 +1081,7 @@
}
int newX = m->x();
int newY = m->y();
- FPoint np(newX - Mxp, newY - Myp, 0, 0, currItem->rotation(), 1, 1, true);
+ FPoint np(newX - m_Mxp, newY - m_Myp, 0, 0, currItem->rotation(), 1, 1, true);
np = np * (1.0 / m_canvas->scale());
m_canvas->m_viewMode.operItemMoving = true;
currItem = m_doc->m_Selection->itemAt(0);
@@ -1106,8 +1106,8 @@
npf = currItem->PoLine.point(m_doc->nodeEdit.segP1() ) + np;
m_doc->nodeEdit.setClre(m_doc->nodeEdit.segP1());
m_doc->nodeEdit.moveClipPoint(currItem, npf);
- Mxp = newX;
- Myp = newY;
+ m_Mxp = newX;
+ m_Myp = newY;
}
else
{
@@ -1246,8 +1246,8 @@
m_doc->nodeEdit.moveClipPoint(currItem, npf);
m_canvas->displayXYHUD(m->globalPos(), npf.x(), npf.y());
}
- Mxp = newX;
- Myp = newY;
+ m_Mxp = newX;
+ m_Myp = newY;
}
m_canvas->m_viewMode.operItemMoving = false;
m_doc->regionsChanged()->update(QRectF());
Modified: trunk/Scribus/scribus/canvasmode_nodeedit.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_nodeedit.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_nodeedit.h (original)
+++ trunk/Scribus/scribus/canvasmode_nodeedit.h Fri Nov 27 23:35:43 2015
@@ -69,8 +69,8 @@
ScribusMainWindow* m_ScMW;
RectSelect* m_rectangleSelect;
- int Mxp, Myp, Dxp, Dyp, GxM, GyM;
- bool MoveGX, MoveGY;
+ int m_Mxp, m_Myp, m_Dxp, m_Dyp, m_GxM, m_GyM;
+ bool m_MoveGX, m_MoveGY;
};
Modified: trunk/Scribus/scribus/canvasmode_normal.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_normal.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_normal.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_normal.cpp Fri Nov 27 23:35:43 2015
@@ -74,11 +74,11 @@
CanvasMode_Normal::CanvasMode_Normal(ScribusView* view) : CanvasMode(view), m_ScMW(view->m_ScMW)
{
- frameResizeHandle = -1;
- shiftSelItems = false;
- resizeGesture = NULL;
- lineMoveGesture = NULL;
- guideMoveGesture = NULL;
+ m_frameResizeHandle = -1;
+ m_shiftSelItems = false;
+ m_resizeGesture = NULL;
+ m_lineMoveGesture = NULL;
+ m_guideMoveGesture = NULL;
m_mousePressPoint.setXY(0, 0);
m_mouseCurrentPoint.setXY(0, 0);
m_mouseSavedPoint.setXY(0, 0);
@@ -130,8 +130,8 @@
m_mouseCurrentPoint.setXY(0, 0);
m_mouseSavedPoint.setXY(0, 0);
m_objectDeltaPos.setXY(0,0 );
- frameResizeHandle = -1;
- shiftSelItems = false;
+ m_frameResizeHandle = -1;
+ m_shiftSelItems = false;
m_hoveredItem = NULL;
setModeCursor();
if (fromGesture)
@@ -330,15 +330,15 @@
enableGuideGesture |= ((m_doc->guidesPrefs().renderStackOrder.indexOf(3) > m_doc->guidesPrefs().renderStackOrder.indexOf(4)) && (frameResizeHandle == Canvas::INSIDE));
if (enableGuideGesture)
{
- if (!guideMoveGesture)
- {
- guideMoveGesture = new RulerGesture(m_view, RulerGesture::HORIZONTAL);
- connect(guideMoveGesture,SIGNAL(guideInfo(int, qreal)), m_ScMW->alignDistributePalette,SLOT(setGuide(int, qreal)));
- }
- if (guideMoveGesture->mouseHitsGuide(mousePointDoc))
+ if (!m_guideMoveGesture)
+ {
+ m_guideMoveGesture = new RulerGesture(m_view, RulerGesture::HORIZONTAL);
+ connect(m_guideMoveGesture,SIGNAL(guideInfo(int, qreal)), m_ScMW->alignDistributePalette,SLOT(setGuide(int, qreal)));
+ }
+ if (m_guideMoveGesture->mouseHitsGuide(mousePointDoc))
{
m_lastPosWasOverGuide = true;
- switch (guideMoveGesture->getMode())
+ switch (m_guideMoveGesture->getMode())
{
case RulerGesture::HORIZONTAL:
m_view->setCursor(QCursor(Qt::SplitVCursor));
@@ -454,7 +454,7 @@
if (m_doc->drawAsPreview)
return;
m_mouseCurrentPoint = mousePointDoc;
- if ((GetItem(&currItem)) && (!shiftSelItems))
+ if ((GetItem(&currItem)) && (!m_shiftSelItems))
{
newX = qRound(mousePointDoc.x()); //m_view->translateToDoc(m->x(), m->y()).x());
newY = qRound(mousePointDoc.y()); //m_view->translateToDoc(m->x(), m->y()).y());
@@ -538,8 +538,8 @@
if (abs(dY) > abs(dX))
dX=0;
erf=false;
- dX+=qRound(dragConstrainInitPtX-currItem->xPos());
- dY+=qRound(dragConstrainInitPtY-currItem->yPos());
+ dX+=qRound(m_dragConstrainInitPtX-currItem->xPos());
+ dY+=qRound(m_dragConstrainInitPtY-currItem->yPos());
}
double gx, gy, gh, gw;
m_objectDeltaPos.setXY(dX, dY);
@@ -640,8 +640,8 @@
if (abs(dY)>abs(dX))
dX=0;
erf=false;
- dX+=dragConstrainInitPtX-qRound(gx);
- dY+=dragConstrainInitPtY-qRound(gy);
+ dX+=m_dragConstrainInitPtX-qRound(gx);
+ dY+=m_dragConstrainInitPtY-qRound(gy);
}
m_objectDeltaPos.setXY(dX, dY);
if (m_doc->SnapGuides)
@@ -864,13 +864,13 @@
{
if ((currItem->asLine()) && (!m_doc->m_Selection->isMultipleSelection()) && (!m_doc->drawAsPreview))
{
- if (!lineMoveGesture)
- lineMoveGesture = new LineMove(this);
+ if (!m_lineMoveGesture)
+ m_lineMoveGesture = new LineMove(this);
- lineMoveGesture->mousePressEvent(m);
- if (lineMoveGesture->haveLineItem())
- {
- m_view->startGesture(lineMoveGesture);
+ m_lineMoveGesture->mousePressEvent(m);
+ if (m_lineMoveGesture->haveLineItem())
+ {
+ m_view->startGesture(m_lineMoveGesture);
return;
}
}
@@ -879,13 +879,13 @@
bool isMS=m_doc->m_Selection->isMultipleSelection();
if ((isMS || (!isMS && (!currItem->locked() && !currItem->sizeLocked()))) && (!m_doc->drawAsPreview))
{
- if (!resizeGesture)
- resizeGesture = new ResizeGesture(this);
-
- resizeGesture->mousePressEvent(m);
- if (resizeGesture->frameHandle() > 0)
- {
- m_view->startGesture(resizeGesture);
+ if (!m_resizeGesture)
+ m_resizeGesture = new ResizeGesture(this);
+
+ m_resizeGesture->mousePressEvent(m);
+ if (m_resizeGesture->frameHandle() > 0)
+ {
+ m_view->startGesture(m_resizeGesture);
return;
}
}
@@ -903,13 +903,13 @@
double gx, gy, gh, gw;
bool shiftSel = true;
m_doc->m_Selection->getVisualGroupRect(&gx, &gy, &gw, &gh);
- dragConstrainInitPtX = qRound(gx);
- dragConstrainInitPtY = qRound(gy);
- frameResizeHandle = m_canvas->frameHitTest(QPointF(mousePointDoc.x(),mousePointDoc.y()), QRectF(gx, gy, gw, gh));
- if (frameResizeHandle == Canvas::OUTSIDE ||
- (frameResizeHandle == Canvas::INSIDE && m->modifiers() != Qt::NoModifier))
- {
- frameResizeHandle = 0;
+ m_dragConstrainInitPtX = qRound(gx);
+ m_dragConstrainInitPtY = qRound(gy);
+ m_frameResizeHandle = m_canvas->frameHitTest(QPointF(mousePointDoc.x(),mousePointDoc.y()), QRectF(gx, gy, gw, gh));
+ if (m_frameResizeHandle == Canvas::OUTSIDE ||
+ (m_frameResizeHandle == Canvas::INSIDE && m->modifiers() != Qt::NoModifier))
+ {
+ m_frameResizeHandle = 0;
m_doc->m_Selection->delaySignalsOn();
m_view->updatesOn(false);
shiftSel = SeleItem(m);
@@ -918,34 +918,34 @@
}
if (((m_doc->m_Selection->count() == 0) || (!shiftSel)) && (m->modifiers() == Qt::ShiftModifier))
{
- shiftSelItems = true;
+ m_shiftSelItems = true;
m_mouseCurrentPoint = m_mousePressPoint = m_mouseSavedPoint = mousePointDoc;
}
else
- shiftSelItems = false;
+ m_shiftSelItems = false;
m_canvas->setRenderModeFillBuffer();
}
else // not multiple selection
{
- dragConstrainInitPtX = qRound(currItem->xPos());
- dragConstrainInitPtY = qRound(currItem->yPos());
+ m_dragConstrainInitPtX = qRound(currItem->xPos());
+ m_dragConstrainInitPtY = qRound(currItem->yPos());
// dont call SeleItem() without need here:
- frameResizeHandle = m_canvas->frameHitTest(QPointF(mousePointDoc.x(),mousePointDoc.y()), currItem);
+ m_frameResizeHandle = m_canvas->frameHitTest(QPointF(mousePointDoc.x(),mousePointDoc.y()), currItem);
//#6797
- if (frameResizeHandle <= 0 || m->modifiers() != Qt::NoModifier)
+ if (m_frameResizeHandle <= 0 || m->modifiers() != Qt::NoModifier)
{
m_doc->m_Selection->delaySignalsOn();
m_view->updatesOn(false);
SeleItem(m); //Where we send the mouse press event to select an item
if (GetItem(&currItem) && (!m_doc->drawAsPreview))
- frameResizeHandle = m_canvas->frameHitTest(QPointF(mousePointDoc.x(),mousePointDoc.y()), currItem);
+ m_frameResizeHandle = m_canvas->frameHitTest(QPointF(mousePointDoc.x(),mousePointDoc.y()), currItem);
else
- frameResizeHandle = 0;
+ m_frameResizeHandle = 0;
m_view->updatesOn(true);
m_doc->m_Selection->delaySignalsOff();
}
- if ((currItem && !currItem->locked() && frameResizeHandle > 0) == false && (!m_doc->drawAsPreview))
+ if ((currItem && !currItem->locked() && m_frameResizeHandle > 0) == false && (!m_doc->drawAsPreview))
{
m_mouseCurrentPoint = m_mousePressPoint = m_mouseSavedPoint = mousePointDoc;
}
@@ -1171,7 +1171,7 @@
}
}
//CB Drag selection performed here
- if (((m_doc->m_Selection->count() == 0) && (m_view->HaveSelRect) && (!m_view->MidButt)) || ((shiftSelItems) && (m_view->HaveSelRect) && (!m_view->MidButt)))
+ if (((m_doc->m_Selection->count() == 0) && (m_view->HaveSelRect) && (!m_view->MidButt)) || ((m_shiftSelItems) && (m_view->HaveSelRect) && (!m_view->MidButt)))
{
double dx = m_mouseSavedPoint.x() - m_mousePressPoint.x();
double dy = m_mouseSavedPoint.y() - m_mousePressPoint.y();
@@ -1223,7 +1223,7 @@
}
}
m_view->HaveSelRect = false;
- shiftSelItems = false;
+ m_shiftSelItems = false;
// m_view->redrawMarker->hide();
m_view->updateContents();
}
@@ -1264,7 +1264,7 @@
m_canvas->m_viewMode.operItemMoving = false;
m_canvas->m_viewMode.operItemResizing = false;
m_view->MidButt = false;
- shiftSelItems = false;
+ m_shiftSelItems = false;
if (m_view->groupTransactionStarted())
{
for (int i = 0; i < m_doc->m_Selection->count(); ++i)
@@ -1627,15 +1627,15 @@
}
if (enableGuideGesture)
{
- if (!guideMoveGesture)
- {
- guideMoveGesture = new RulerGesture(m_view, RulerGesture::HORIZONTAL);
- connect(guideMoveGesture,SIGNAL(guideInfo(int, qreal)), m_ScMW->alignDistributePalette,SLOT(setGuide(int, qreal)));
- }
- if ( (!m_doc->GuideLock) && (guideMoveGesture->mouseHitsGuide(mousePointDoc)) )
- {
- m_view->startGesture(guideMoveGesture);
- guideMoveGesture->mouseMoveEvent(m);
+ if (!m_guideMoveGesture)
+ {
+ m_guideMoveGesture = new RulerGesture(m_view, RulerGesture::HORIZONTAL);
+ connect(m_guideMoveGesture,SIGNAL(guideInfo(int, qreal)), m_ScMW->alignDistributePalette,SLOT(setGuide(int, qreal)));
+ }
+ if ( (!m_doc->GuideLock) && (m_guideMoveGesture->mouseHitsGuide(mousePointDoc)) )
+ {
+ m_view->startGesture(m_guideMoveGesture);
+ m_guideMoveGesture->mouseMoveEvent(m);
m_doc->m_Selection->connectItemToGUI();
// qDebug()<<"Out Of SeleItem"<<__LINE__;
return true;
@@ -1645,7 +1645,7 @@
// If we call startGesture now, a new guide is created each time.
// ### could be a weakness to avoid calling it tho.
// m_view->startGesture(guideMoveGesture);
- guideMoveGesture->mouseSelectGuide(m);
+ m_guideMoveGesture->mouseSelectGuide(m);
}
}
}
@@ -1777,15 +1777,15 @@
}
if ((m_doc->guidesPrefs().guidesShown) /*&& (!m_doc->GuideLock)*/ && (m_doc->OnPage(MxpS, MypS) != -1))
{
- if (!guideMoveGesture)
- {
- guideMoveGesture = new RulerGesture(m_view, RulerGesture::HORIZONTAL);
- connect(guideMoveGesture,SIGNAL(guideInfo(int, qreal)), m_ScMW->alignDistributePalette,SLOT(setGuide(int, qreal)));
- }
- if ( (!m_doc->GuideLock) && (guideMoveGesture->mouseHitsGuide(mousePointDoc)) )
- {
- m_view->startGesture(guideMoveGesture);
- guideMoveGesture->mouseMoveEvent(m);
+ if (!m_guideMoveGesture)
+ {
+ m_guideMoveGesture = new RulerGesture(m_view, RulerGesture::HORIZONTAL);
+ connect(m_guideMoveGesture,SIGNAL(guideInfo(int, qreal)), m_ScMW->alignDistributePalette,SLOT(setGuide(int, qreal)));
+ }
+ if ( (!m_doc->GuideLock) && (m_guideMoveGesture->mouseHitsGuide(mousePointDoc)) )
+ {
+ m_view->startGesture(m_guideMoveGesture);
+ m_guideMoveGesture->mouseMoveEvent(m);
m_doc->m_Selection->connectItemToGUI();
return true;
}
@@ -1794,7 +1794,7 @@
// If we call startGesture now, a new guide is created each time.
// ### could be a weakness to avoid calling it tho.
// m_view->startGesture(guideMoveGesture);
- guideMoveGesture->mouseSelectGuide(m);
+ m_guideMoveGesture->mouseSelectGuide(m);
}
}
m_doc->m_Selection->connectItemToGUI();
Modified: trunk/Scribus/scribus/canvasmode_normal.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_normal.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_normal.h (original)
+++ trunk/Scribus/scribus/canvasmode_normal.h Fri Nov 27 23:35:43 2015
@@ -1,99 +1,99 @@
-/*
- For general Scribus (>=1.3.2) copyright and licensing information please refer
- to the COPYING file provided with the program. Following this notice may exist
- a copyright and/or license notice that predates the release of Scribus 1.3.2
- for which a new license (GPL+exception) is in place.
- */
-/***************************************************************************
-* *
-* This program is free software; you can redistribute it and/or modify *
-* it under the terms of the GNU General Public License as published by *
-* the Free Software Foundation; either version 2 of the License, or *
-* (at your option) any later version. *
-* *
-***************************************************************************/
-
-
-
-#ifndef CANVAS_MODE_NORMAL_H
-#define CANVAS_MODE_NORMAL_H
-
-#include <QObject>
-#include <QTime>
-
-#include "canvasmode.h"
-#include "fpointarray.h"
-
-class LineMove;
-class PageItem;
-class ResizeGesture;
-class RulerGesture;
-class ScribusMainWindow;
-class ScribusView;
-
-
-// This class encapsulate the old code for mouse interaction from scribusview.cpp
-
-class CanvasMode_Normal : public CanvasMode
-{
- Q_OBJECT
-
-public:
- explicit CanvasMode_Normal(ScribusView* view);
- virtual ~CanvasMode_Normal() {}
-
- virtual void enterEvent(QEvent *);
- virtual void leaveEvent(QEvent *);
-
- virtual void activate(bool);
- virtual void deactivate(bool);
- virtual void mouseDoubleClickEvent(QMouseEvent *m);
- virtual void mouseReleaseEvent(QMouseEvent *m);
- virtual void mouseMoveEvent(QMouseEvent *m);
- virtual void mousePressEvent(QMouseEvent *m);
- virtual void drawControls(QPainter* p);
-
- virtual void keyPressEvent(QKeyEvent *e);
- virtual void keyReleaseEvent(QKeyEvent *e);
-
- virtual bool handleKeyEvents() { return true; }
-
-private:
- inline bool GetItem(PageItem** pi);
- void handleCheckBoxPress(PageItem* currItem);
- void handlePushButtonPress(PageItem* currItem);
- void handleRadioButtonPress(PageItem* currItem);
- void handleCheckBoxRelease(PageItem* currItem);
- void handlePushButtonRelease(PageItem* currItem);
- void handleRadioButtonRelease(PageItem* currItem);
- void handleJavaAction(PageItem* currItem, int event);
- void handleNamedAction(PageItem* currItem);
- void handleLinkAnnotation(PageItem* currItem);
- void handleFocusOut(PageItem* currItem);
- void handleFocusIn(PageItem* currItem);
- void handleMouseLeave(PageItem* currItem);
- void handleMouseEnter(PageItem* currItem);
- bool SeleItem(QMouseEvent *m);
- void createContextMenu(PageItem *currItem, double mx, double my);
-
- FPoint m_mousePressPoint;
- FPoint m_mouseCurrentPoint;
- FPoint m_mouseSavedPoint;
- FPoint m_objectDeltaPos;
-
- bool shiftSelItems;
- int frameResizeHandle;
- int dragConstrainInitPtX, dragConstrainInitPtY;
- ScribusMainWindow* m_ScMW;
- ResizeGesture* resizeGesture;
- LineMove* lineMoveGesture;
- RulerGesture* guideMoveGesture;
- bool m_lastPosWasOverGuide;
- PageItem* m_hoveredItem;
-
-public slots:
- void importToPage();
-};
-
-
-#endif
+/*
+ For general Scribus (>=1.3.2) copyright and licensing information please refer
+ to the COPYING file provided with the program. Following this notice may exist
+ a copyright and/or license notice that predates the release of Scribus 1.3.2
+ for which a new license (GPL+exception) is in place.
+ */
+/***************************************************************************
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+***************************************************************************/
+
+
+
+#ifndef CANVAS_MODE_NORMAL_H
+#define CANVAS_MODE_NORMAL_H
+
+#include <QObject>
+#include <QTime>
+
+#include "canvasmode.h"
+#include "fpointarray.h"
+
+class LineMove;
+class PageItem;
+class ResizeGesture;
+class RulerGesture;
+class ScribusMainWindow;
+class ScribusView;
+
+
+// This class encapsulate the old code for mouse interaction from scribusview.cpp
+
+class CanvasMode_Normal : public CanvasMode
+{
+ Q_OBJECT
+
+public:
+ explicit CanvasMode_Normal(ScribusView* view);
+ virtual ~CanvasMode_Normal() {}
+
+ virtual void enterEvent(QEvent *);
+ virtual void leaveEvent(QEvent *);
+
+ virtual void activate(bool);
+ virtual void deactivate(bool);
+ virtual void mouseDoubleClickEvent(QMouseEvent *m);
+ virtual void mouseReleaseEvent(QMouseEvent *m);
+ virtual void mouseMoveEvent(QMouseEvent *m);
+ virtual void mousePressEvent(QMouseEvent *m);
+ virtual void drawControls(QPainter* p);
+
+ virtual void keyPressEvent(QKeyEvent *e);
+ virtual void keyReleaseEvent(QKeyEvent *e);
+
+ virtual bool handleKeyEvents() { return true; }
+
+private:
+ inline bool GetItem(PageItem** pi);
+ void handleCheckBoxPress(PageItem* currItem);
+ void handlePushButtonPress(PageItem* currItem);
+ void handleRadioButtonPress(PageItem* currItem);
+ void handleCheckBoxRelease(PageItem* currItem);
+ void handlePushButtonRelease(PageItem* currItem);
+ void handleRadioButtonRelease(PageItem* currItem);
+ void handleJavaAction(PageItem* currItem, int event);
+ void handleNamedAction(PageItem* currItem);
+ void handleLinkAnnotation(PageItem* currItem);
+ void handleFocusOut(PageItem* currItem);
+ void handleFocusIn(PageItem* currItem);
+ void handleMouseLeave(PageItem* currItem);
+ void handleMouseEnter(PageItem* currItem);
+ bool SeleItem(QMouseEvent *m);
+ void createContextMenu(PageItem *currItem, double mx, double my);
+
+ FPoint m_mousePressPoint;
+ FPoint m_mouseCurrentPoint;
+ FPoint m_mouseSavedPoint;
+ FPoint m_objectDeltaPos;
+
+ bool m_shiftSelItems;
+ int m_frameResizeHandle;
+ int m_dragConstrainInitPtX, m_dragConstrainInitPtY;
+ ScribusMainWindow* m_ScMW;
+ ResizeGesture* m_resizeGesture;
+ LineMove* m_lineMoveGesture;
+ RulerGesture* m_guideMoveGesture;
+ bool m_lastPosWasOverGuide;
+ PageItem* m_hoveredItem;
+
+public slots:
+ void importToPage();
+};
+
+
+#endif
Modified: trunk/Scribus/scribus/canvasmode_objimport.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_objimport.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_objimport.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_objimport.cpp Fri Nov 27 23:35:43 2015
@@ -47,7 +47,7 @@
CanvasMode_ObjImport::CanvasMode_ObjImport(ScribusView* view) :
CanvasMode(view)
{
- Mxp = Myp = -1;
+ m_Mxp = m_Myp = -1;
m_mimeData = NULL;
m_trSettings = NULL;
}
@@ -104,7 +104,7 @@
m_canvas->m_viewMode.operItemMoving = false;
m_canvas->m_viewMode.operItemResizing = false;
m_view->MidButt = false;
- Mxp = Myp = -1;
+ m_Mxp = m_Myp = -1;
setModeCursor();
if (fromGesture)
{
@@ -152,12 +152,12 @@
// oldClip = 0;
m->accept();
m_view->registerMousePress(m->globalPos());
- Mxp = mousePointDoc.x();
- Myp = mousePointDoc.y();
- Rxp = m_doc->ApplyGridF(FPoint(Mxp, Myp)).x();
- Mxp = qRound(Rxp);
- Ryp = m_doc->ApplyGridF(FPoint(Mxp, Myp)).y();
- Myp = qRound(Ryp);
+ m_Mxp = mousePointDoc.x();
+ m_Myp = mousePointDoc.y();
+ Rxp = m_doc->ApplyGridF(FPoint(m_Mxp, m_Myp)).x();
+ m_Mxp = qRound(Rxp);
+ Ryp = m_doc->ApplyGridF(FPoint(m_Mxp, m_Myp)).y();
+ m_Myp = qRound(Ryp);
if (m->button() == Qt::MidButton)
{
m_view->MidButt = true;
Modified: trunk/Scribus/scribus/canvasmode_objimport.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/canvasmode_objimport.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_objimport.h (original)
+++ trunk/Scribus/scribus/canvasmode_objimport.h Fri Nov 27 23:35:43 2015
@@ -58,7 +58,7 @@
private:
QMimeData* m_mimeData;
TransactionSettings* m_trSettings;
- double Mxp, Myp;
+ double m_Mxp, m_Myp;
};
Modified: trunk/Scribus/scribus/colorblind.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/colorblind.cpp
==============================================================================
--- trunk/Scribus/scribus/colorblind.cpp (original)
+++ trunk/Scribus/scribus/colorblind.cpp Fri Nov 27 23:35:43 2015
@@ -14,60 +14,60 @@
VisionDefectColor::VisionDefectColor(int r, int g, int b)
{
- red = (double)r;
- green = (double)g;
- blue = (double)b;
- originalColor = QColor(r, g, b);
+ m_red = (double)r;
+ m_green = (double)g;
+ m_blue = (double)b;
+ m_originalColor = QColor(r, g, b);
init();
}
VisionDefectColor::VisionDefectColor(QColor c)
{
- red = (double)c.red();
- green = (double)c.green();
- blue = (double)c.blue();
- originalColor = c;
+ m_red = (double)c.red();
+ m_green = (double)c.green();
+ m_blue = (double)c.blue();
+ m_originalColor = c;
init();
}
VisionDefectColor::VisionDefectColor()
{
- red = 0.0;
- green = 0.0;
- blue = 0.0;
- originalColor = QColor(0, 0, 0);
+ m_red = 0.0;
+ m_green = 0.0;
+ m_blue = 0.0;
+ m_originalColor = QColor(0, 0, 0);
init();
}
void VisionDefectColor::init()
{
- rgb2lms[0] = 0.05059983;
- rgb2lms[1] = 0.08585369;
- rgb2lms[2] = 0.00952420;
-
- rgb2lms[3] = 0.01893033;
- rgb2lms[4] = 0.08925308;
- rgb2lms[5] = 0.01370054;
-
- rgb2lms[6] = 0.00292202;
- rgb2lms[7] = 0.00975732;
- rgb2lms[8] = 0.07145979;
-
- lms2rgb[0] = 30.830854;
- lms2rgb[1] = -29.832659;
- lms2rgb[2] = 1.610474;
-
- lms2rgb[3] = -6.481468;
- lms2rgb[4] = 17.715578;
- lms2rgb[5] = -2.532642;
-
- lms2rgb[6] = -0.375690;
- lms2rgb[7] = -1.199062;
- lms2rgb[8] = 14.273846;
-
- gammaRGB[0] = 2.1;
- gammaRGB[1] = 2.0;
- gammaRGB[2] = 2.1;
+ m_rgb2lms[0] = 0.05059983;
+ m_rgb2lms[1] = 0.08585369;
+ m_rgb2lms[2] = 0.00952420;
+
+ m_rgb2lms[3] = 0.01893033;
+ m_rgb2lms[4] = 0.08925308;
+ m_rgb2lms[5] = 0.01370054;
+
+ m_rgb2lms[6] = 0.00292202;
+ m_rgb2lms[7] = 0.00975732;
+ m_rgb2lms[8] = 0.07145979;
+
+ m_lms2rgb[0] = 30.830854;
+ m_lms2rgb[1] = -29.832659;
+ m_lms2rgb[2] = 1.610474;
+
+ m_lms2rgb[3] = -6.481468;
+ m_lms2rgb[4] = 17.715578;
+ m_lms2rgb[5] = -2.532642;
+
+ m_lms2rgb[6] = -0.375690;
+ m_lms2rgb[7] = -1.199062;
+ m_lms2rgb[8] = 14.273846;
+
+ m_gammaRGB[0] = 2.1;
+ m_gammaRGB[1] = 2.0;
+ m_gammaRGB[2] = 2.1;
}
void VisionDefectColor::convertDefect()
@@ -75,17 +75,17 @@
double tmp;
/* Remove gamma to linearize RGB intensities */
- red = pow(red, 1.0 / gammaRGB[0]);
- green = pow(green, 1.0 / gammaRGB[1]);
- blue = pow(blue, 1.0 / gammaRGB[2]);
+ m_red = pow(m_red, 1.0 / m_gammaRGB[0]);
+ m_green = pow(m_green, 1.0 / m_gammaRGB[1]);
+ m_blue = pow(m_blue, 1.0 / m_gammaRGB[2]);
/* Convert to LMS (dot product with transform matrix) */
- double redOld = red;
- double greenOld = green;
-
- red = redOld * rgb2lms[0] + greenOld * rgb2lms[1] + blue * rgb2lms[2];
- green = redOld * rgb2lms[3] + greenOld * rgb2lms[4] + blue * rgb2lms[5];
- blue = redOld * rgb2lms[6] + greenOld * rgb2lms[7] + blue * rgb2lms[8];
+ double redOld = m_red;
+ double greenOld = m_green;
+
+ m_red = redOld * m_rgb2lms[0] + greenOld * m_rgb2lms[1] + m_blue * m_rgb2lms[2];
+ m_green = redOld * m_rgb2lms[3] + greenOld * m_rgb2lms[4] + m_blue * m_rgb2lms[5];
+ m_blue = redOld * m_rgb2lms[6] + greenOld * m_rgb2lms[7] + m_blue * m_rgb2lms[8];
switch (deficiency)
{
@@ -93,39 +93,39 @@
break;
case deuteranopeVision:
setupDefect();
- tmp = blue / red;
+ tmp = m_blue / m_red;
/* See which side of the inflection line we fall... */
- if (tmp < inflection)
- green = -(a1 * red + c1 * blue) / b1;
+ if (tmp < m_inflection)
+ m_green = -(m_a1 * m_red + m_c1 * m_blue) / m_b1;
else
- green = -(a2 * red + c2 * blue) / b2;
+ m_green = -(m_a2 * m_red + m_c2 * m_blue) / m_b2;
break;
case protanopeVision:
setupDefect();
- tmp = blue / green;
+ tmp = m_blue / m_green;
/* See which side of the inflection line we fall... */
- if (tmp < inflection)
- red = -(b1 * green + c1 * blue) / a1;
+ if (tmp < m_inflection)
+ m_red = -(m_b1 * m_green + m_c1 * m_blue) / m_a1;
else
- red = -(b2 * green + c2 * blue) / a2;
+ m_red = -(m_b2 * m_green + m_c2 * m_blue) / m_a2;
break;
case tritanopeVision:
setupDefect();
- tmp = green / red;
+ tmp = m_green / m_red;
/* See which side of the inflection line we fall... */
- if (tmp < inflection)
- blue = -(a1 * red + b1 * green) / c1;
+ if (tmp < m_inflection)
+ m_blue = -(m_a1 * m_red + m_b1 * m_green) / m_c1;
else
- blue = -(a2 * red + b2 * green) / c2;
+ m_blue = -(m_a2 * m_red + m_b2 * m_green) / m_c2;
break;
case colorBlindnessVision:
{
- double gray = clamp(0.3 * originalColor.red()
- + 0.59 * originalColor.green()
- + 0.11 * originalColor.blue(), 0, 255);
- red = gray;
- green = gray;
- blue = gray;
+ double gray = clamp(0.3 * m_originalColor.red()
+ + 0.59 * m_originalColor.green()
+ + 0.11 * m_originalColor.blue(), 0, 255);
+ m_red = gray;
+ m_green = gray;
+ m_blue = gray;
return; // no other transformations!
}
default:
@@ -133,31 +133,31 @@
}
/* Convert back to RGB (cross product with transform matrix) */
- redOld = red;
- greenOld = green;
-
- red = redOld * lms2rgb[0] + greenOld * lms2rgb[1] + blue * lms2rgb[2];
- green = redOld * lms2rgb[3] + greenOld * lms2rgb[4] + blue * lms2rgb[5];
- blue = redOld * lms2rgb[6] + greenOld * lms2rgb[7] + blue * lms2rgb[8];
+ redOld = m_red;
+ greenOld = m_green;
+
+ m_red = redOld * m_lms2rgb[0] + greenOld * m_lms2rgb[1] + m_blue * m_lms2rgb[2];
+ m_green = redOld * m_lms2rgb[3] + greenOld * m_lms2rgb[4] + m_blue * m_lms2rgb[5];
+ m_blue = redOld * m_lms2rgb[6] + greenOld * m_lms2rgb[7] + m_blue * m_lms2rgb[8];
/* Apply gamma to go back to non-linear intensities */
- red = pow(red, gammaRGB[0]);
- green = pow(green, gammaRGB[1]);
- blue = pow(blue, gammaRGB[2]);
+ m_red = pow(m_red, m_gammaRGB[0]);
+ m_green = pow(m_green, m_gammaRGB[1]);
+ m_blue = pow(m_blue, m_gammaRGB[2]);
/* Ensure that we stay within the RGB gamut */
/* *** FIX THIS: it would be better to desaturate than blindly clip. */
- red = clamp(red, 0.0, 255.0);
- green = clamp(green, 0.0, 255.0);
- blue = clamp(blue, 0.0, 255.0);
+ m_red = clamp(m_red, 0.0, 255.0);
+ m_green = clamp(m_green, 0.0, 255.0);
+ m_blue = clamp(m_blue, 0.0, 255.0);
}
QColor VisionDefectColor::convertDefect(QColor c, int d)
{
- red = (double)c.red();
- green = (double)c.green();
- blue = (double)c.blue();
- originalColor = c;
+ m_red = (double)c.red();
+ m_green = (double)c.green();
+ m_blue = (double)c.blue();
+ m_originalColor = c;
init();
deficiency = d;
convertDefect();
@@ -183,58 +183,58 @@
* our anchors) (we can just peel this out of the rgb2lms transform
* matrix)
*/
- anchor_e[0] = rgb2lms[0] + rgb2lms[1] + rgb2lms[2];
- anchor_e[1] = rgb2lms[3] + rgb2lms[4] + rgb2lms[5];
- anchor_e[2] = rgb2lms[6] + rgb2lms[7] + rgb2lms[8];
+ anchor_e[0] = m_rgb2lms[0] + m_rgb2lms[1] + m_rgb2lms[2];
+ anchor_e[1] = m_rgb2lms[3] + m_rgb2lms[4] + m_rgb2lms[5];
+ anchor_e[2] = m_rgb2lms[6] + m_rgb2lms[7] + m_rgb2lms[8];
switch (deficiency)
{
case deuteranopeVision:
/* find a,b,c for lam=575nm and lam=475 */
- a1 = anchor_e[1] * anchor[8] - anchor_e[2] * anchor[7];
- b1 = anchor_e[2] * anchor[6] - anchor_e[0] * anchor[8];
- c1 = anchor_e[0] * anchor[7] - anchor_e[1] * anchor[6];
- a2 = anchor_e[1] * anchor[2] - anchor_e[2] * anchor[1];
- b2 = anchor_e[2] * anchor[0] - anchor_e[0] * anchor[2];
- c2 = anchor_e[0] * anchor[1] - anchor_e[1] * anchor[0];
- inflection = (anchor_e[2] / anchor_e[0]);
+ m_a1 = anchor_e[1] * anchor[8] - anchor_e[2] * anchor[7];
+ m_b1 = anchor_e[2] * anchor[6] - anchor_e[0] * anchor[8];
+ m_c1 = anchor_e[0] * anchor[7] - anchor_e[1] * anchor[6];
+ m_a2 = anchor_e[1] * anchor[2] - anchor_e[2] * anchor[1];
+ m_b2 = anchor_e[2] * anchor[0] - anchor_e[0] * anchor[2];
+ m_c2 = anchor_e[0] * anchor[1] - anchor_e[1] * anchor[0];
+ m_inflection = (anchor_e[2] / anchor_e[0]);
break;
case protanopeVision:
/* find a,b,c for lam=575nm and lam=475 */
- a1 = anchor_e[1] * anchor[8] - anchor_e[2] * anchor[7];
- b1 = anchor_e[2] * anchor[6] - anchor_e[0] * anchor[8];
- c1 = anchor_e[0] * anchor[7] - anchor_e[1] * anchor[6];
- a2 = anchor_e[1] * anchor[2] - anchor_e[2] * anchor[1];
- b2 = anchor_e[2] * anchor[0] - anchor_e[0] * anchor[2];
- c2 = anchor_e[0] * anchor[1] - anchor_e[1] * anchor[0];
- inflection = (anchor_e[2] / anchor_e[1]);
+ m_a1 = anchor_e[1] * anchor[8] - anchor_e[2] * anchor[7];
+ m_b1 = anchor_e[2] * anchor[6] - anchor_e[0] * anchor[8];
+ m_c1 = anchor_e[0] * anchor[7] - anchor_e[1] * anchor[6];
+ m_a2 = anchor_e[1] * anchor[2] - anchor_e[2] * anchor[1];
+ m_b2 = anchor_e[2] * anchor[0] - anchor_e[0] * anchor[2];
+ m_c2 = anchor_e[0] * anchor[1] - anchor_e[1] * anchor[0];
+ m_inflection = (anchor_e[2] / anchor_e[1]);
break;
case tritanopeVision:
/* Set 1: regions where lambda_a=575, set 2: lambda_a=475 */
- a1 = anchor_e[1] * anchor[11] - anchor_e[2] * anchor[10];
- b1 = anchor_e[2] * anchor[9] - anchor_e[0] * anchor[11];
- c1 = anchor_e[0] * anchor[10] - anchor_e[1] * anchor[9];
- a2 = anchor_e[1] * anchor[5] - anchor_e[2] * anchor[4];
- b2 = anchor_e[2] * anchor[3] - anchor_e[0] * anchor[5];
- c2 = anchor_e[0] * anchor[4] - anchor_e[1] * anchor[3];
- inflection = (anchor_e[1] / anchor_e[0]);
+ m_a1 = anchor_e[1] * anchor[11] - anchor_e[2] * anchor[10];
+ m_b1 = anchor_e[2] * anchor[9] - anchor_e[0] * anchor[11];
+ m_c1 = anchor_e[0] * anchor[10] - anchor_e[1] * anchor[9];
+ m_a2 = anchor_e[1] * anchor[5] - anchor_e[2] * anchor[4];
+ m_b2 = anchor_e[2] * anchor[3] - anchor_e[0] * anchor[5];
+ m_c2 = anchor_e[0] * anchor[4] - anchor_e[1] * anchor[3];
+ m_inflection = (anchor_e[1] / anchor_e[0]);
break;
}
}
uint VisionDefectColor::getRed()
{
- return (uint)red;
+ return (uint)m_red;
}
uint VisionDefectColor::getGreen()
{
- return (uint)green;
+ return (uint)m_green;
}
uint VisionDefectColor::getBlue()
{
- return (uint)blue;
+ return (uint)m_blue;
}
QColor VisionDefectColor::getColor()
Modified: trunk/Scribus/scribus/colorblind.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/colorblind.h
==============================================================================
--- trunk/Scribus/scribus/colorblind.h (original)
+++ trunk/Scribus/scribus/colorblind.h Fri Nov 27 23:35:43 2015
@@ -104,24 +104,24 @@
private:
/*! \brief Convert matrix */
- double rgb2lms[9];
+ double m_rgb2lms[9];
/*! \brief Convert matrix */
- double lms2rgb[9];
+ double m_lms2rgb[9];
/*! \brief Gamma matrix */
- double gammaRGB[3];
+ double m_gammaRGB[3];
/*! \brief cross products with transform matrixes for actual defect */
- double a1, b1, c1;
+ double m_a1, m_b1, m_c1;
/*! \brief cross products with transform matrixes for actual defect */
- double a2, b2, c2;
+ double m_a2, m_b2, m_c2;
/*! \brief Inflection border line */
- double inflection;
+ double m_inflection;
/*! \brief Internal RGB color parts */
- double red, green, blue;
+ double m_red, m_green, m_blue;
/*! \brief original color */
- QColor originalColor;
+ QColor m_originalColor;
/*! \brief Initialization of the internal values. rgb2lms, lms2rgb etc.
For most modern Cathode-Ray Tube monitors (CRTs), the following
Modified: trunk/Scribus/scribus/fileloader.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/fileloader.cpp
==============================================================================
--- trunk/Scribus/scribus/fileloader.cpp (original)
+++ trunk/Scribus/scribus/fileloader.cpp Fri Nov 27 23:35:43 2015
@@ -64,7 +64,7 @@
formatSLA13x(LoadSavePlugin::getFormatById(FORMATID_SLA13XIMPORT)),
formatSLA134(LoadSavePlugin::getFormatById(FORMATID_SLA134IMPORT)),
formatSLA150(LoadSavePlugin::getFormatById(FORMATID_SLA150IMPORT)),
- prefsManager(PrefsManager::instance()),
+ m_prefsManager(PrefsManager::instance()),
m_fileName(fileName),
m_fileType(-1)
{
@@ -180,21 +180,21 @@
{
bool ret = false;
// newReplacement = false;
- ReplacedFonts = currDoc->AllFonts->getSubstitutions();
+ m_ReplacedFonts = currDoc->AllFonts->getSubstitutions();
// dummyScFaces.clear();
QList<FileFormat>::const_iterator it;
if (findFormat(m_fileType, it))
{
if (m_fileType == FORMATID_SLA12XIMPORT)
{
- it->plug->setupTargets(currDoc, currDoc->view(), currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(prefsManager->appPrefs.fontPrefs.AvailFonts));
+ it->plug->setupTargets(currDoc, currDoc->view(), currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(m_prefsManager->appPrefs.fontPrefs.AvailFonts));
ret = it->plug->loadPage(m_fileName, PageToLoad, Mpage, renamedPageName);
// if (ret)
// it->plug->getReplacedFontData(newReplacement, ReplacedFonts, dummyScFaces);
}
if (m_fileType == FORMATID_SLA13XIMPORT || m_fileType == FORMATID_SLA134IMPORT || m_fileType == FORMATID_SLA150IMPORT)
{
- it->plug->setupTargets(currDoc, 0, currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(prefsManager->appPrefs.fontPrefs.AvailFonts));
+ it->plug->setupTargets(currDoc, 0, currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(m_prefsManager->appPrefs.fontPrefs.AvailFonts));
ret = it->plug->loadPage(m_fileName, PageToLoad, Mpage, renamedPageName);
// if (ret)
// it->plug->getReplacedFontData(newReplacement, ReplacedFonts, dummyScFaces);
@@ -216,25 +216,25 @@
*/
bool FileLoader::loadFile(ScribusDoc* currDoc)
{
- newReplacement = false;
- currDoc->guidesPrefs().marginsShown = prefsManager->appPrefs.guidesPrefs.marginsShown;
- currDoc->guidesPrefs().framesShown = prefsManager->appPrefs.guidesPrefs.framesShown;
- currDoc->guidesPrefs().layerMarkersShown = prefsManager->appPrefs.guidesPrefs.layerMarkersShown;
- currDoc->guidesPrefs().gridShown = prefsManager->appPrefs.guidesPrefs.gridShown;
- currDoc->guidesPrefs().guidesShown = prefsManager->appPrefs.guidesPrefs.guidesShown;
- currDoc->guidesPrefs().colBordersShown = prefsManager->appPrefs.guidesPrefs.colBordersShown;
- currDoc->guidesPrefs().baselineGridShown = prefsManager->appPrefs.guidesPrefs.baselineGridShown;
- currDoc->guidesPrefs().linkShown = prefsManager->appPrefs.guidesPrefs.linkShown;
- currDoc->itemToolPrefs().polyCorners = prefsManager->appPrefs.itemToolPrefs.polyCorners;
- currDoc->itemToolPrefs().polyFactor = prefsManager->appPrefs.itemToolPrefs.polyFactor;
- currDoc->itemToolPrefs().polyRotation = prefsManager->appPrefs.itemToolPrefs.polyRotation;
- currDoc->itemToolPrefs().polyCurvature = prefsManager->appPrefs.itemToolPrefs.polyCurvature;
- currDoc->itemToolPrefs().polyOuterCurvature = prefsManager->appPrefs.itemToolPrefs.polyOuterCurvature;
- currDoc->itemToolPrefs().polyInnerRot = prefsManager->appPrefs.itemToolPrefs.polyInnerRot;
- currDoc->itemToolPrefs().polyUseFactor = prefsManager->appPrefs.itemToolPrefs.polyUseFactor;
- currDoc->setAutoSave(prefsManager->appPrefs.docSetupPrefs.AutoSave);
- currDoc->setAutoSaveTime(prefsManager->appPrefs.docSetupPrefs.AutoSaveTime);
- ReplacedFonts = currDoc->AllFonts->getSubstitutions();
+ m_newReplacement = false;
+ currDoc->guidesPrefs().marginsShown = m_prefsManager->appPrefs.guidesPrefs.marginsShown;
+ currDoc->guidesPrefs().framesShown = m_prefsManager->appPrefs.guidesPrefs.framesShown;
+ currDoc->guidesPrefs().layerMarkersShown = m_prefsManager->appPrefs.guidesPrefs.layerMarkersShown;
+ currDoc->guidesPrefs().gridShown = m_prefsManager->appPrefs.guidesPrefs.gridShown;
+ currDoc->guidesPrefs().guidesShown = m_prefsManager->appPrefs.guidesPrefs.guidesShown;
+ currDoc->guidesPrefs().colBordersShown = m_prefsManager->appPrefs.guidesPrefs.colBordersShown;
+ currDoc->guidesPrefs().baselineGridShown = m_prefsManager->appPrefs.guidesPrefs.baselineGridShown;
+ currDoc->guidesPrefs().linkShown = m_prefsManager->appPrefs.guidesPrefs.linkShown;
+ currDoc->itemToolPrefs().polyCorners = m_prefsManager->appPrefs.itemToolPrefs.polyCorners;
+ currDoc->itemToolPrefs().polyFactor = m_prefsManager->appPrefs.itemToolPrefs.polyFactor;
+ currDoc->itemToolPrefs().polyRotation = m_prefsManager->appPrefs.itemToolPrefs.polyRotation;
+ currDoc->itemToolPrefs().polyCurvature = m_prefsManager->appPrefs.itemToolPrefs.polyCurvature;
+ currDoc->itemToolPrefs().polyOuterCurvature = m_prefsManager->appPrefs.itemToolPrefs.polyOuterCurvature;
+ currDoc->itemToolPrefs().polyInnerRot = m_prefsManager->appPrefs.itemToolPrefs.polyInnerRot;
+ currDoc->itemToolPrefs().polyUseFactor = m_prefsManager->appPrefs.itemToolPrefs.polyUseFactor;
+ currDoc->setAutoSave(m_prefsManager->appPrefs.docSetupPrefs.AutoSave);
+ currDoc->setAutoSaveTime(m_prefsManager->appPrefs.docSetupPrefs.AutoSaveTime);
+ m_ReplacedFonts = currDoc->AllFonts->getSubstitutions();
//dummyScFaces.clear();
bool ret = false;
QList<FileFormat>::const_iterator it;
@@ -245,7 +245,7 @@
{
case FORMATID_SLA12XIMPORT:
{
- it->setupTargets(currDoc, currDoc->view(), currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(prefsManager->appPrefs.fontPrefs.AvailFonts));
+ it->setupTargets(currDoc, currDoc->view(), currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(m_prefsManager->appPrefs.fontPrefs.AvailFonts));
ret=it->loadFile(m_fileName, LoadSavePlugin::lfCreateDoc);
// if (ret)
// it->getReplacedFontData(newReplacement, ReplacedFonts, dummyScFaces);
@@ -255,14 +255,14 @@
case FORMATID_SLA134IMPORT:
case FORMATID_SLA150IMPORT:
{
- it->setupTargets(currDoc, 0, currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(prefsManager->appPrefs.fontPrefs.AvailFonts));
+ it->setupTargets(currDoc, 0, currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(m_prefsManager->appPrefs.fontPrefs.AvailFonts));
ret=it->loadFile(m_fileName, LoadSavePlugin::lfCreateDoc);
// if (ret)
// it->getReplacedFontData(newReplacement, ReplacedFonts, dummyScFaces);
}
break;
default:
- it->setupTargets(currDoc, currDoc->view(), currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(prefsManager->appPrefs.fontPrefs.AvailFonts));
+ it->setupTargets(currDoc, currDoc->view(), currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(m_prefsManager->appPrefs.fontPrefs.AvailFonts));
ret = it->loadFile(m_fileName, LoadSavePlugin::lfCreateDoc);
break;
}
@@ -276,7 +276,7 @@
QList<FileFormat>::const_iterator it;
if (findFormat(FORMATID_SLA150EXPORT, it))
{
- it->setupTargets(doc, doc->view(), doc->scMW(), doc->scMW()->mainWindowProgressBar, &(prefsManager->appPrefs.fontPrefs.AvailFonts));
+ it->setupTargets(doc, doc->view(), doc->scMW(), doc->scMW()->mainWindowProgressBar, &(m_prefsManager->appPrefs.fontPrefs.AvailFonts));
ret = it->saveFile(fileName);
if (savedFile)
*savedFile = it->lastSavedFile();
@@ -288,7 +288,7 @@
{
QList<FileFormat>::const_iterator it;
if (findFormat(m_fileType, it)) {
- it->plug->setupTargets(doc, 0, doc->scMW(), doc->scMW()->mainWindowProgressBar, &(prefsManager->appPrefs.fontPrefs.AvailFonts));
+ it->plug->setupTargets(doc, 0, doc->scMW(), doc->scMW()->mainWindowProgressBar, &(m_prefsManager->appPrefs.fontPrefs.AvailFonts));
return it->readStyles(m_fileName, doc, docParagraphStyles);
}
return false;
@@ -298,7 +298,7 @@
{
QList<FileFormat>::const_iterator it;
if (findFormat(m_fileType, it)) {
- it->plug->setupTargets(doc, 0, doc->scMW(), doc->scMW()->mainWindowProgressBar, &(prefsManager->appPrefs.fontPrefs.AvailFonts));
+ it->plug->setupTargets(doc, 0, doc->scMW(), doc->scMW()->mainWindowProgressBar, &(m_prefsManager->appPrefs.fontPrefs.AvailFonts));
return it->readCharStyles(m_fileName, doc, docCharStyles);
}
return false;
@@ -425,26 +425,26 @@
bool FileLoader::postLoad(ScribusDoc* currDoc)
{
- ReplacedFonts = currDoc->AllFonts->getSubstitutions(ReplacedFonts.keys());
- if (ReplacedFonts.isEmpty())
+ m_ReplacedFonts = currDoc->AllFonts->getSubstitutions(m_ReplacedFonts.keys());
+ if (m_ReplacedFonts.isEmpty())
return true;
- if ((prefsManager->appPrefs.fontPrefs.askBeforeSubstitute))
+ if ((m_prefsManager->appPrefs.fontPrefs.askBeforeSubstitute))
{
qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
- FontReplaceDialog dia(0, &ReplacedFonts);
+ FontReplaceDialog dia(0, &m_ReplacedFonts);
if (dia.exec())
{
QMap<QString,QString>::Iterator itfsu;
- for (itfsu = ReplacedFonts.begin(); itfsu != ReplacedFonts.end(); ++itfsu)
+ for (itfsu = m_ReplacedFonts.begin(); itfsu != m_ReplacedFonts.end(); ++itfsu)
{
if (dia.stickyReplacements->isChecked())
- prefsManager->appPrefs.fontPrefs.GFontSub[itfsu.key()] = itfsu.value();
+ m_prefsManager->appPrefs.fontPrefs.GFontSub[itfsu.key()] = itfsu.value();
}
- currDoc->AllFonts->setSubstitutions(ReplacedFonts, currDoc);
+ currDoc->AllFonts->setSubstitutions(m_ReplacedFonts, currDoc);
ResourceCollection repl;
repl.availableFonts = currDoc->AllFonts;
- repl.mapFonts(ReplacedFonts);
+ repl.mapFonts(m_ReplacedFonts);
currDoc->replaceNamedResources(repl);
return true;
}
@@ -459,12 +459,12 @@
void FileLoader::informReplacementFonts()
{
- if (ReplacedFonts.count() != 0)
+ if (m_ReplacedFonts.count() != 0)
{
qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
QString mess = tr("Some fonts used by this document have been substituted:")+"\n\n";
QMap<QString,QString>::Iterator it;
- for (it = ReplacedFonts.begin(); it != ReplacedFonts.end(); ++it)
+ for (it = m_ReplacedFonts.begin(); it != m_ReplacedFonts.end(); ++it)
{
mess += it.key() + tr(" was replaced by: ")+ it.value() +"\n";
}
Modified: trunk/Scribus/scribus/fileloader.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/fileloader.h
==============================================================================
--- trunk/Scribus/scribus/fileloader.h (original)
+++ trunk/Scribus/scribus/fileloader.h Fri Nov 27 23:35:43 2015
@@ -56,11 +56,11 @@
static const QString getLoadFilterString();
private:
- QMap<QString, QString> ReplacedFonts;
- bool newReplacement;
+ QMap<QString, QString> m_ReplacedFonts;
+ bool m_newReplacement;
void readParagraphStyle(ParagraphStyle& vg, const QDomElement& pg, SCFonts &avail, ScribusDoc *doc);
bool findFormat(uint formatId, QList<FileFormat>::const_iterator &it);
- PrefsManager* prefsManager;
+ PrefsManager* m_prefsManager;
QString m_fileName;
int m_fileType;
Modified: trunk/Scribus/scribus/filewatcher.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/filewatcher.cpp
==============================================================================
--- trunk/Scribus/scribus/filewatcher.cpp (original)
+++ trunk/Scribus/scribus/filewatcher.cpp Fri Nov 27 23:35:43 2015
@@ -25,21 +25,21 @@
{
m_stateFlags = 0;
m_timeOut = 10000;
- watchedFiles.clear();
- watchTimer = new QTimer(this);
- watchTimer->setSingleShot(true);
- connect(watchTimer, SIGNAL(timeout()), this, SLOT(checkFiles()));
- watchTimer->start(m_timeOut);
+ m_watchedFiles.clear();
+ m_watchTimer = new QTimer(this);
+ m_watchTimer->setSingleShot(true);
+ connect(m_watchTimer, SIGNAL(timeout()), this, SLOT(checkFiles()));
+ m_watchTimer->start(m_timeOut);
}
FileWatcher::~FileWatcher()
{
m_stateFlags |= Dying;
this->stop();
- disconnect(watchTimer, SIGNAL(timeout()), this, SLOT(checkFiles()));
+ disconnect(m_watchTimer, SIGNAL(timeout()), this, SLOT(checkFiles()));
if (!(m_stateFlags & AddRemoveBlocked))
- watchedFiles.clear();
- delete watchTimer;
+ m_watchedFiles.clear();
+ delete m_watchTimer;
}
void FileWatcher::setTimeOut(const int newTimeOut, const bool restartTimer)
@@ -61,8 +61,8 @@
qDebug()<<"Attempt to add empty filename to filewatcher";
return;
}
- watchTimer->stop();
- if (!watchedFiles.contains(fileName))
+ m_watchTimer->stop();
+ if (!m_watchedFiles.contains(fileName))
{
struct fileMod fi;
fi.info = QFileInfo(fileName);
@@ -73,25 +73,25 @@
fi.isDir = fi.info.isDir();
fi.fast = fast;
fi.doc = doc;
- watchedFiles.insert(fileName, fi);
+ m_watchedFiles.insert(fileName, fi);
}
else
- watchedFiles[fileName].refCount++;
+ m_watchedFiles[fileName].refCount++;
if (!(m_stateFlags & TimerStopped))
- watchTimer->start(m_timeOut);
+ m_watchTimer->start(m_timeOut);
}
void FileWatcher::removeFile(QString fileName)
{
- watchTimer->stop();
- if (watchedFiles.contains(fileName))
- {
- watchedFiles[fileName].refCount--;
- if (watchedFiles[fileName].refCount == 0)
- watchedFiles.remove(fileName);
+ m_watchTimer->stop();
+ if (m_watchedFiles.contains(fileName))
+ {
+ m_watchedFiles[fileName].refCount--;
+ if (m_watchedFiles[fileName].refCount == 0)
+ m_watchedFiles.remove(fileName);
}
if (!(m_stateFlags & TimerStopped))
- watchTimer->start(m_timeOut);
+ m_watchTimer->start(m_timeOut);
}
void FileWatcher::addDir(QString fileName, bool fast)
@@ -106,14 +106,14 @@
void FileWatcher::start()
{
- watchTimer->stop();
+ m_watchTimer->stop();
m_stateFlags &= ~TimerStopped;
- watchTimer->start(m_timeOut);
+ m_watchTimer->start(m_timeOut);
}
void FileWatcher::stop()
{
- watchTimer->stop();
+ m_watchTimer->stop();
m_stateFlags |= StopRequested;
while ((m_stateFlags & FileCheckRunning))
usleep(100);
@@ -133,21 +133,21 @@
QList<QString> FileWatcher::files()
{
- return watchedFiles.keys();
+ return m_watchedFiles.keys();
}
void FileWatcher::checkFiles()
{
m_stateFlags |= AddRemoveBlocked;
m_stateFlags |= FileCheckRunning;
- watchTimer->stop();
+ m_watchTimer->stop();
m_stateFlags |= TimerStopped;
QDateTime time;
QStringList toRemove;
QMap<QString, fileMod>::Iterator it;
// qDebug()<<files();
- for ( it = watchedFiles.begin(); !(m_stateFlags & FileCheckMustStop) && it != watchedFiles.end(); ++it )
+ for ( it = m_watchedFiles.begin(); !(m_stateFlags & FileCheckMustStop) && it != m_watchedFiles.end(); ++it )
{
it.value().info.refresh();
if (!it.value().info.exists())
@@ -238,14 +238,14 @@
}
}
if (m_stateFlags & Dying)
- watchedFiles.clear();
+ m_watchedFiles.clear();
else
{
for( int i=0; i<toRemove.count(); ++i)
- watchedFiles.remove(toRemove[i]);
+ m_watchedFiles.remove(toRemove[i]);
m_stateFlags &= ~AddRemoveBlocked;
m_stateFlags &= ~TimerStopped;
- watchTimer->start(m_timeOut);
+ m_watchTimer->start(m_timeOut);
}
m_stateFlags &= ~FileCheckRunning;
}
Modified: trunk/Scribus/scribus/filewatcher.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20593&path=/trunk/Scribus/scribus/filewatcher.h
==============================================================================
--- trunk/Scribus/scribus/filewatcher.h (original)
+++ trunk/Scribus/scribus/filewatcher.h Fri Nov 27 23:35:43 2015
@@ -73,8 +73,8 @@
FileCheckMustStop = 20 //StopRequested + Dying
} StateFlags;
- QMap<QString, fileMod> watchedFiles;
- QTimer* watchTimer;
+ QMap<QString, fileMod> m_watchedFiles;
+ QTimer* m_watchTimer;
int m_stateFlags;
int m_timeOut; // milliseconds
More information about the scribus-commit
mailing list