r17461 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:21:36 UTC 2012


Author: jghali
Date: Thu Apr 19 21:21:36 2012
New Revision: 17461

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

Modified:
    trunk/Scribus/scribus/canvasmode_normal.cpp
    trunk/Scribus/scribus/pageitem_line.cpp
    trunk/Scribus/scribus/pageitem_line.h

Modified: trunk/Scribus/scribus/canvasmode_normal.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17461&path=/trunk/Scribus/scribus/canvasmode_normal.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_normal.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_normal.cpp Thu Apr 19 21:21:36 2012
@@ -40,6 +40,7 @@
 #include "fpointarray.h"
 #include "hyphenator.h"
 #include "loadsaveplugin.h"
+#include "pageitem_line.h"
 #include "pageitem_textframe.h"
 #include "pageitem_regularpolygon.h"
 #include "pageitem_arc.h"
@@ -462,6 +463,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: trunk/Scribus/scribus/pageitem_line.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17461&path=/trunk/Scribus/scribus/pageitem_line.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_line.cpp (original)
+++ trunk/Scribus/scribus/pageitem_line.cpp Thu Apr 19 21:21:36 2012
@@ -21,6 +21,9 @@
  *                                                                         *
  ***************************************************************************/
 
+#if defined(_MSC_VER)
+#define _USE_MATH_DEFINES
+#endif
 #include <cmath>
 #include <cassert>
 
@@ -154,3 +157,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: trunk/Scribus/scribus/pageitem_line.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17461&path=/trunk/Scribus/scribus/pageitem_line.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_line.h (original)
+++ trunk/Scribus/scribus/pageitem_line.h Thu Apr 19 21:21:36 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);




More information about the scribus-commit mailing list