r18969 by jghali - some code cleanup
scribus-commit
scribus-commit at lists.scribus.net
Mon Mar 31 23:27:32 UTC 2014
Author: jghali
Date: Mon Mar 31 23:27:32 2014
New Revision: 18969
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18969
Log:
some code cleanup
Modified:
branches/Version14x/Scribus/scribus/canvasmode_nodeedit.cpp
Modified: branches/Version14x/Scribus/scribus/canvasmode_nodeedit.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18969&path=/branches/Version14x/Scribus/scribus/canvasmode_nodeedit.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/canvasmode_nodeedit.cpp (original)
+++ branches/Version14x/Scribus/scribus/canvasmode_nodeedit.cpp Mon Mar 31 23:27:32 2014
@@ -37,8 +37,6 @@
CanvasMode_NodeEdit::CanvasMode_NodeEdit(ScribusView* view) : CanvasMode(view), m_rectangleSelect(NULL)
{
-// SeRx = -1; // selected pos
-// SeRy = -1;
Mxp = -1; // last mouse position
Myp = -1;
Dxp = -1; // last mouse press position for rectangle select
@@ -49,12 +47,8 @@
m_ScMW = m_view->m_ScMW;
}
-
-
void CanvasMode_NodeEdit::drawControls(QPainter* p)
{
-// qDebug() << "NodeEdit::drawControls";
-// void Canvas::MarkClip(QPainter *p, PageItem *currItem, FPointArray cli, bool)
double x, y;
if (m_doc->m_Selection->count() == 0)
return;
@@ -160,7 +154,6 @@
{
m_canvas->m_viewMode.m_MouseButtonPressed = false;
// handle rectangle select
-// double sc = m_canvas->scale();
PageItem* currItem = m_doc->m_Selection->itemAt(0);
m_doc->nodeEdit.SelNode.clear();
QRectF Sele = m_rectangleSelect->result(); //QRect(Dxp, Dyp, SeRx-Dxp, SeRy-Dyp).normalized();
@@ -188,11 +181,7 @@
m_doc->nodeEdit.update(Clip.pointQF(a));
}
}
-// m_canvas->setScale(sc);
-// m_view->HaveSelRect = false;
-// m_view->redrawMarker->hide();
currItem->update();
-// m_view->updateContents();
m_doc->nodeEdit.finishTransaction(currItem);
delete m_rectangleSelect;
m_rectangleSelect = NULL;
@@ -247,7 +236,6 @@
m->accept();
m_canvas->m_viewMode.m_MouseButtonPressed = false;
m_canvas->resetRenderMode();
-// m_view->stopDragTimer();
m_view->requestMode(submodeEndNodeEdit);
}
@@ -260,27 +248,6 @@
double sc = m_canvas->scale();
m->accept();
npf = m_canvas->globalToCanvas(m->globalPos());
-#ifdef MODEDEBUG
-// qDebug() << "nodedit move event:" << m->x() << m->y() << "canvas:" << npf.x() << npf.y() << "@" << m_canvas->scale();
-#endif
-/* if (m_doc->guidesSettings.guidesShown)
- {
- if (MoveGY)
- {
- m_view->FromHRuler(m);
- return;
- }
- if (MoveGX)
- {
- m_view->FromVRuler(m);
- return;
- }
- }
- */
-// if (m_canvas->m_viewMode.m_MouseButtonPressed && (m->buttons() & Qt::RightButton) && (m->modifiers() & Qt::ControlModifier))
-// {
-// m_ScMW->setAppMode(modePanning);
-// }
if (GetItem(&currItem))
{
if (m_doc->DragP)
@@ -290,24 +257,17 @@
if (m_view->moveTimerElapsed() && m_canvas->m_viewMode.m_MouseButtonPressed
&& (m->buttons() & Qt::LeftButton) && (!currItem->locked()))
{
-#ifdef MODEDEBUG
-// qDebug() << "node edit drag 1";
-#endif
-// m_view->stopDragTimer();
handleNodeEditDrag(m, currItem);
}
else if (!m_canvas->m_viewMode.m_MouseButtonPressed)
{
if (!currItem->locked())
{
- QMatrix p; // = currItem->getTransform();
- QRect mpo; // = QRect(m->globalX()-m_doc->guidesSettings.grabRad, m->globalY()-m_doc->guidesSettings.grabRad, m_doc->guidesSettings.grabRad*2, m_doc->guidesSettings.grabRad*2);
- // mpo.moveBy(qRound(m_doc->minCanvasCoordinate.x() * m_canvas->scale()), qRound(m_doc->minCanvasCoordinate.y() * m_canvas->scale()));
+ QMatrix p;
+ QRect mpo;
handleNodeEditMove(m, mpo, currItem, p);
}
}
-// else
-// qDebug() << "node edit drag 9:" << (m->buttons() & Qt::LeftButton);
}
else // shouldnt be in nodeedit mode now, should it??
@@ -315,12 +275,6 @@
npf = m_canvas->globalToCanvas(m->globalPos());
if ((m_canvas->m_viewMode.m_MouseButtonPressed) && (m->buttons() & Qt::LeftButton) && (GyM == -1) && (GxM == -1))
{
-// SeRx = qRound(npf.x());
-// SeRy = qRound(npf.y());
-// m_view->redrawMarker->setGeometry(QRect(Mxp, Myp, m->x() - Mxp, m->y() - Myp).normalized());
-// if (!m_view->redrawMarker->isVisible())
-// m_view->redrawMarker->show();
-// m_view->HaveSelRect = true;
if (!m_rectangleSelect)
{
m_rectangleSelect = new RectSelect(this);
@@ -349,7 +303,6 @@
return;
}
}
-// qApp->setOverrideCursor(QCursor(Qt::ArrowCursor), true);
tmpGuides = m_doc->currentPage()->guides.verticals(GuideManagerCore::Standard);
for (it = tmpGuides.begin(); it!= tmpGuides.end(); ++it)
{
@@ -373,51 +326,14 @@
void CanvasMode_NodeEdit::mousePressEvent(QMouseEvent *m)
{
-// double Rxp = 0;
-// double Ryp = 0;
-// double Rxpd = 0;
-// double Rypd = 0;
- QPainter p;
-// m_canvas->PaintSizeRect(QRect());
-// FPoint npf, npf2;
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;
MoveGX = MoveGY = false;
-// oldClip = 0;
m->accept();
m_view->registerMousePress(m->globalPos());
-// npf = m_canvas->globalToCanvas(m->globalPos());
-// Mxp = qRound(npf.x()); // WTF? FIXME:av
-// Myp = qRound(npf.y());
- QRect mpo; //(m->globalX()-m_doc->guidesSettings.grabRad, m->globalY()-m_doc->guidesSettings.grabRad, m_doc->guidesSettings.grabRad*2, m_doc->guidesSettings.grabRad*2);
-// mpo.moveBy(qRound(m_doc->minCanvasCoordinate.x() * m_canvas->scale()), qRound(m_doc->minCanvasCoordinate.y() * m_canvas->scale()));
-/* if (m_doc->appMode != modeEdit)
- {
- Rxp = m_doc->ApplyGrid(QPoint(Mxp, Myp)).x();
- Rxpd = Mxp - Rxp;
- Mxp = qRound(Rxp);
- Ryp = m_doc->ApplyGrid(QPoint(Mxp, Myp)).y();
- Rypd = Myp - Ryp;
- Myp = qRound(Ryp);
- }*/
-// SeRx = Mxp;
-// SeRy = Myp;
-/* if (m->button() == Qt::MidButton)
- {
- m_view->MidButt = true;
- m_view->DrawNew();
- return;
- }*/
-// npf = m_canvas->globalToCanvas(m->globalPos());
-// Mxp = qRound(npf.x()); // WTF?
-// Myp = qRound(npf.y());
-// SeRx = Mxp;
-// SeRy = Myp;
-
- // this has to be:
+ QRect mpo;
Mxp = m->x();
Myp = m->y();
@@ -437,113 +353,12 @@
void CanvasMode_NodeEdit::mouseReleaseEvent(QMouseEvent *m)
{
-// QMenu* pmen3 = NULL;
PageItem *currItem;
m_canvas->m_viewMode.m_MouseButtonPressed = false;
m_canvas->resetRenderMode();
m->accept();
-// m_view->stopDragTimer();
-/* if (m_doc->guidesSettings.guidesShown)
- {
- bool foundGuide = false;
- FPoint np = m_canvas->globalToCanvas(m->globalPos());
- double nx = np.x();
- double ny = np.y();
- double grabRadScale = m_doc->guidesSettings.grabRad / m_canvas->scale();
- if (0 <= m_doc->currentPage()->guides.isMouseOnHorizontal(ny + grabRadScale, ny - grabRadScale, GuideManagerCore::Standard)
- || 0 <= m_doc->currentPage()->guides.isMouseOnVertical(nx + grabRadScale, nx - grabRadScale, GuideManagerCore::Standard))
- foundGuide = true;
- if ((foundGuide) && (m->button() == Qt::RightButton) && (!GetItem(&currItem)))
- {
- m_view->setCursor(QCursor(Qt::ArrowCursor));
- MoveGY = false;
- MoveGX = false;
- return;
- }
- if (MoveGY)
- {
- m_view->SetYGuide(m, GyM);
- MoveGY = false;
- m_view->redrawMarker->hide();
- m_view->setCursor(QCursor(Qt::ArrowCursor));
- m_view->updateContents();
- GyM = -1;
- return;
- }
- if (MoveGX)
- {
- m_view->SetXGuide(m, GxM);
- MoveGX = false;
- m_view->redrawMarker->hide();
- m_view->setCursor(QCursor(Qt::ArrowCursor));
- m_view->updateContents();
- GxM = -1;
- return;
- }
- }*/
- /* see activated()
- if (!m_doc->nodeEdit.hasNodeSelected() && (m_view->HaveSelRect))
- {
- double sc = m_canvas->scale();
- currItem = m_doc->m_Selection->itemAt(0);
- m_doc->nodeEdit.SelNode.clear();
- QRect Sele = QRect(Dxp, Dyp, SeRx-Dxp, SeRy-Dyp).normalized();
- FPointArray Clip;
- m_canvas->setScale(1.0);
- if (m_doc->nodeEdit.isContourLine)
- Clip = currItem->ContourLine;
- else
- Clip = currItem->PoLine;
- for (uint a = 0; a < Clip.size(); ++a)
- {
- if (Clip.point(a).x() > 900000)
- continue;
- FPoint np = Clip.point(a);
- FPoint npf2 = np.transformPoint(currItem->xPos(), currItem->yPos(), currItem->rotation(), 1.0, 1.0, false);
- QPoint npf = QPoint(qRound(npf2.x()), qRound(npf2.y()));
- if ((Sele.contains(npf)) && ((a == 0) || (((a-2) % 4) == 0)))
- {
- m_doc->nodeEdit.ClRe = a;
- m_doc->nodeEdit.SelNode.append(a);
- m_doc->nodeEdit.update(QPointF(Clip.point(a).x(), Clip.point(a).y()));
- }
- }
- m_canvas->setScale(sc);
- m_view->HaveSelRect = false;
- m_view->redrawMarker->hide();
- currItem->update();
- m_doc->nodeEdit.finishTransaction(currItem);
- return;
- }
- */
-/* if (m_view->moveTimerElapsed() && (m_doc->appMode == modeEditClip) && (SegP1 == -1) && (SegP2 == -1))
- {
- currItem = m_doc->m_Selection->itemAt(0);
- if (operItemMoving)
- {
- currItem->OldB2 = currItem->width();
- currItem->OldH2 = currItem->height();
- double nx = m->x()/m_canvas->scale() + m_doc->minCanvasCoordinate.x();
- double ny = m->y()/m_canvas->scale() + m_doc->minCanvasCoordinate.y();
- if (!m_doc->ApplyGuides(&nx, &ny))
- {
- FPoint npg(ApplyGridF(FPoint(nx, ny)));
- nx = npg.x();
- ny = npg.y();
- }
- FPoint np(nx, ny, currItem->xPos(), currItem->yPos(), currItem->rotation(), 1, 1, true);
- m_doc->nodeEdit.moveClipPoint(currItem, np);
- }
- m_doc->AdjustItemSize(currItem);
- emit DocChanged();
- updateContents();
- operItemMoving = false;
- return;
- }
- if (m_view->moveTimerElapsed() && (m_doc->appMode == modeEditClip) && (SegP1 != -1) && (SegP2 != -1)) */
if (m_view->moveTimerElapsed())
{
-// m_view->stopDragTimer();
if (m_doc->nodeEdit.SegP1 != -1 && m_doc->nodeEdit.SegP2 != -1)
{
m_doc->nodeEdit.deselect();
@@ -556,7 +371,6 @@
double yposOrig = currItem->yPos();
ItemState<QPair<FPointArray, FPointArray> > *state = NULL;
-
state = m_doc->nodeEdit.finishTransaction1(currItem);
xposOrig = currItem->xPos();
yposOrig = currItem->yPos();
@@ -564,9 +378,6 @@
{
//FIXME:av
FPoint newP = m_canvas->globalToCanvas(m->globalPos());
-// double newX = newP.x();
-// double newY = newP.y();
-// FPoint np(newX, newY, 0, 0, currItem->rotation(), 1, 1, true);
currItem->OldB2 = currItem->width();
currItem->OldH2 = currItem->height();
FPointArray Clip;
@@ -574,11 +385,6 @@
Clip = currItem->ContourLine;
else
Clip = currItem->PoLine;
-// FPoint npf = FPoint(Clip.point(m_doc->nodeEdit.ClRe).x() + np.x() / m_canvas->scale(), Clip.point(m_doc->nodeEdit.ClRe).y() + np.y() / m_canvas->scale());
-// double nx = npf.x();
-// double ny = npf.y();
-// nx += currItem->xPos();
-// ny += currItem->yPos();
FPoint npf;
double nx = newP.x();
double ny = newP.y();
@@ -586,7 +392,6 @@
npf = m_doc->ApplyGridF(FPoint(nx, ny));
else
npf = FPoint(nx, ny);
-// npf = FPoint(npf.x() - currItem->xPos(), npf.y() - currItem->yPos());
npf = FPoint(npf.x(), npf.y(), currItem->xPos(), currItem->yPos(), currItem->rotation(), 1, 1, true);
m_doc->nodeEdit.moveClipPoint(currItem, npf);
}
@@ -594,10 +399,7 @@
m_doc->AdjustItemSize(currItem);
if (!m_doc->nodeEdit.isContourLine)
currItem->ContourLine.translate(xposOrig - currItem->xPos(), yposOrig - currItem->yPos());
-// currItem->update();
m_doc->regionsChanged()->update(QRectF());
-// emit DocChanged();
-// m_view->updateContents();
if (state)
{
m_doc->nodeEdit.finishTransaction2(currItem, state);
@@ -611,17 +413,12 @@
m_canvas->m_viewMode.operItemMoving = false;
m_canvas->m_viewMode.operItemResizing = false;
m_view->MidButt = false;
-// m_doc->SubMode = -1;
if (m_view->groupTransactionStarted())
{
for (int i = 0; i < m_doc->m_Selection->count(); ++i)
m_doc->m_Selection->itemAt(i)->checkChanges(true);
m_view->endGroupTransaction();
}
-
-//??? for (int i = 0; i < m_doc->m_Selection->count(); ++i)
-//??? av m_doc->m_Selection->itemAt(i)->checkChanges(true);
-
//Commit drag created items to undo manager.
if (m_doc->m_Selection->itemAt(0)!=NULL)
{
@@ -634,11 +431,6 @@
{
currItem = m_doc->m_Selection->itemAt(0);
m_doc->nodeEdit.finishTransaction(currItem);
- }
- else
- {
- //delete oldClip;
- //oldClip = 0;
}
}
@@ -652,24 +444,15 @@
FPointArray Clip = m_doc->nodeEdit.beginTransaction(currItem);
bool edited = false;
bool pfound = false;
-// QMatrix pm;
-// pm.translate(-m_doc->minCanvasCoordinate.x()*m_canvas->scale(), -m_doc->minCanvasCoordinate.y()*m_canvas->scale());
-// m_canvas->Transform(currItem, pm);
-// npf2 = FPoint(m->pos() * pm.inverted());
npf2 = m_canvas->globalToCanvas(m->globalPos()).transformPoint(currItem->xPos(), currItem->yPos(), currItem->rotation(), 1.0, 1.0, true);
QMatrix pm2 = currItem->getTransform();
for (int a=0; a < signed(Clip.size()); ++a)
{
if (((m_doc->nodeEdit.EdPoints) && (a % 2 != 0)) || ((!m_doc->nodeEdit.EdPoints) && (a % 2 == 0)))
- continue;
+ continue;
QPointF npf = pm2.map(Clip.pointQF(a));
-// QRect tx = QRect(static_cast<int>(npf.x()-3), static_cast<int>(npf.y()-3), 6, 6);
-// if (tx.intersects(mpo))
if (m_canvas->hitsCanvasPoint(m->globalPos(), npf))
{
-#ifdef MODEDEBUG
- qDebug() << "nodeedit: selecting point" << a << "at" << npf.x() << npf.y();
-#endif
m_doc->nodeEdit.ClRe = a;
if ((m_doc->nodeEdit.EdPoints) && (m_doc->nodeEdit.SelNode.contains(a) == 0))
{
@@ -1073,10 +856,6 @@
}
else
{
- /*
- m_view->redrawMarker->setGeometry(m->x(), m->y(), 1, 1);
- m_view->redrawMarker->show();
- */
Mxp = m->x();
Myp = m->y();
Dxp = qRound(m->x()/m_canvas->scale());
@@ -1102,9 +881,6 @@
Clip = currItem->ContourLine;
else
Clip = currItem->PoLine;
-#ifdef MODEDEBUG
-// qDebug() << "handle nodeedit move:" << m_doc->nodeEdit.submode << m_doc->nodeEdit.EdPoints;
-#endif
if ((m_doc->nodeEdit.submode == NodeEditContext::DEL_POINT) ||
(m_doc->nodeEdit.submode == NodeEditContext::MOVE_POINT) ||
(m_doc->nodeEdit.submode == NodeEditContext::SPLIT_PATH))
@@ -1113,9 +889,6 @@
{
if (((m_doc->nodeEdit.EdPoints) && (a % 2 != 0)) || ((!m_doc->nodeEdit.EdPoints) && (a % 2 == 0)))
continue;
- //QPoint np = p.map(Clip.pointQ(a));
- //QRect tx = QRect(np.x()-3, np.y()-3, 6, 6);
- //if (tx.intersects(mpo))
QPointF point = Clip.pointQF(a);
if (m_canvas->hitsCanvasPoint(m->globalPos(), itemPos.map(point)))
{
@@ -1133,7 +906,6 @@
(m_doc->nodeEdit.submode == NodeEditContext::MOVE_POINT) ||
(m_doc->nodeEdit.submode == NodeEditContext::SPLIT_PATH && m_doc->nodeEdit.EdPoints))
{
- //FPoint mousePoint = m_canvas->globalToCanvas(m->globalPos());
for (uint poi=0; poi<Clip.size()-3; poi += 4)
{
// create bezier curve in canvas coords
@@ -1166,25 +938,6 @@
}
}
}
- // as polygon
-// QPolygonF cli = Bez.toSubpathPolygons().first();
-// for (int clp = 0; clp < cli.size()-1; ++clp)
-// {
- // project mousepoint on line
-// FPoint pointOnLine = projectPointOnLine(mousePoint, cli.at(clp), cli.at(clp+1));
- //if (m_view->PointOnLine(cli.point(clp), cli.point(clp+1), p.inverted().mapRect(mpo)))
-// if (m_canvas->hitsCanvasPoint(m->globalPos(), pointOnLine))
-// {
-// if (m_doc->nodeEdit.submode == NodeEditContext::MOVE_POINT)
-// m_view->setCursor(QCursor(loadIcon("HandC.xpm")));
-// if (m_doc->nodeEdit.submode == NodeEditContext::ADD_POINT)
-// m_view->setCursor(QCursor(loadIcon("AddPoint.png"), 1, 1));
-// if (m_doc->nodeEdit.submode == NodeEditContext::SPLIT_PATH)
-// m_view->setCursor(QCursor(loadIcon("Split.png"), 1, 1));
-// m_doc->nodeEdit.ClRe2 = poi;
-// return true;
-// }
-// }
}
}
m_view->setCursor(QCursor(Qt::ArrowCursor));
More information about the scribus-commit
mailing list