r17462 by jghali - #10677: snap are of by 0.353 mm on horizontal guides

scribus-commit scribus-commit at lists.scribus.net
Thu Apr 19 21:22:12 UTC 2012


Author: jghali
Date: Thu Apr 19 21:22:11 2012
New Revision: 17462

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17462
Log:
#10677: snap are of by 0.353 mm on horizontal guides

Modified:
    branches/Version14x/Scribus/scribus/canvasmode_normal.cpp
    branches/Version14x/Scribus/scribus/pageitem_line.cpp
    branches/Version14x/Scribus/scribus/pageitem_line.h

Modified: branches/Version14x/Scribus/scribus/canvasmode_normal.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17462&path=/branches/Version14x/Scribus/scribus/canvasmode_normal.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/canvasmode_normal.cpp (original)
+++ branches/Version14x/Scribus/scribus/canvasmode_normal.cpp Thu Apr 19 21:22:11 2012
@@ -41,6 +41,7 @@
 #include "fpointarray.h"
 #include "hyphenator.h"
 #include "insertTable.h"
+#include "pageitem_line.h"
 #include "pageitem_textframe.h"
 #include "pageselector.h"
 #include "prefscontext.h"
@@ -395,6 +396,18 @@
 							m_objectDeltaPos.setXY(dX, dY);
 							m_doc->m_Selection->setGroupRect();
 							m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
+							// #10677 : temporary hack : we need to introduce the
+							// concept of item snapping points to handle better
+							// the various types of items
+							if (currItem->isLine())
+							{
+								QPointF startPoint = currItem->asLine()->startPoint();
+								QPointF endPoint   = currItem->asLine()->endPoint();
+								gx = qMin(startPoint.x(), endPoint.x());
+								gy = qMin(startPoint.y(), endPoint.y());
+								gw = fabs(startPoint.x() - endPoint.x());
+								gh = fabs(startPoint.y() - endPoint.y());
+							}
 							if (m_doc->SnapGuides)
 							{
 								double nx = gx + m_objectDeltaPos.x();

Modified: branches/Version14x/Scribus/scribus/pageitem_line.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17462&path=/branches/Version14x/Scribus/scribus/pageitem_line.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/pageitem_line.cpp (original)
+++ branches/Version14x/Scribus/scribus/pageitem_line.cpp Thu Apr 19 21:22:11 2012
@@ -21,6 +21,9 @@
  *                                                                         *
  ***************************************************************************/
 
+#if defined(_MSC_VER)
+#define _USE_MATH_DEFINES
+#endif
 #include <cmath>
 #include <cassert>
 
@@ -101,3 +104,16 @@
 {
 	return QString();
 }
+
+QPointF PageItem_Line::startPoint()
+{
+	return QPointF(Xpos, Ypos);
+}
+
+QPointF PageItem_Line::endPoint()
+{
+	double rot = this->rotation();
+	double x = Xpos + Width * cos(rot * M_PI / 180.0);
+	double y = Ypos + Width * sin(rot * M_PI / 180.0);
+	return QPointF(x, y);
+}

Modified: branches/Version14x/Scribus/scribus/pageitem_line.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17462&path=/branches/Version14x/Scribus/scribus/pageitem_line.h
==============================================================================
--- branches/Version14x/Scribus/scribus/pageitem_line.h (original)
+++ branches/Version14x/Scribus/scribus/pageitem_line.h Thu Apr 19 21:22:11 2012
@@ -22,8 +22,9 @@
 #ifndef PAGEITEMLINE_H
 #define PAGEITEMLINE_H
 
+#include <QPointF>
+#include <QRectF>
 #include <QString>
-#include <QRectF>
 
 #include "scribusapi.h"
 #include "pageitem.h"
@@ -44,6 +45,9 @@
 	
 	virtual void applicableActions(QStringList& actionList);
 	virtual QString infoDescription();
+
+	QPointF startPoint();
+	QPointF endPoint();
 	
 protected:
 	virtual void DrawObj_Item(ScPainter *p, QRectF e, double sc);




More information about the scribus-commit mailing list