r19547 by craig - Add FPoint::isNull like QPoint has

scribus-commit scribus-commit at lists.scribus.net
Thu Oct 2 21:12:09 UTC 2014


Author: craig
Date: Thu Oct  2 21:12:09 2014
New Revision: 19547

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19547
Log:
Add FPoint::isNull like QPoint has

Modified:
    trunk/Scribus/scribus/canvasgesture_rulermove.cpp
    trunk/Scribus/scribus/canvasgesture_rulermove.h
    trunk/Scribus/scribus/canvasmode.cpp
    trunk/Scribus/scribus/canvasmode.h
    trunk/Scribus/scribus/fpoint.cpp
    trunk/Scribus/scribus/fpoint.h
    trunk/Scribus/scribus/plugins/import/revenge/rawpainter.cpp
    trunk/Scribus/scribus/scribusview.cpp
    trunk/Scribus/scribus/scribusview.h

Modified: trunk/Scribus/scribus/canvasgesture_rulermove.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19547&path=/trunk/Scribus/scribus/canvasgesture_rulermove.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasgesture_rulermove.cpp (original)
+++ trunk/Scribus/scribus/canvasgesture_rulermove.cpp Thu Oct  2 21:12:09 2014
@@ -33,7 +33,8 @@
 	m_ScMW(m_view->m_ScMW),
 	m_mode(mode), m_haveGuide(false),
 	m_haveCursor(false),
-	m_xy(0,0)
+	m_xy(0,0),
+	m_mousePoint(0,0)
 {
 
 }
@@ -41,13 +42,24 @@
 
 void RulerGesture::drawControls(QPainter* p)
 {
-	ScPage* page = m_doc->currentPage();
+	int page = -1;
+	if (!m_mousePoint.isNull())
+		page = m_doc->OnPage(m_mousePoint.x(), m_mousePoint.y());
+	//m_doc->OnPage(m_view->m_mousePointDoc.x(), m_view->m_mousePointDoc.y());
+	if (page == -1)
+		return;
+	qDebug()<<page;
+	ScPage* dragToPage;
+	//=m_doc->Pages->at(page);
+	dragToPage=m_doc->currentPage();
+	if (!dragToPage)
+		return;
 	if (m_haveGuide)
-		page = m_doc->Pages->at(m_page);
+		dragToPage = m_doc->Pages->at(m_page);
 	QColor color(m_doc->guidesPrefs().guideColor);
 	p->save();
-	QPoint pageOrigin = m_canvas->canvasToLocal(QPointF(page->xOffset(), page->yOffset()));
-	QSize pageSize = (QSizeF(page->width(), page->height()) * m_canvas->scale()).toSize();
+	QPoint pageOrigin = m_canvas->canvasToLocal(QPointF(dragToPage->xOffset(), dragToPage->yOffset()));
+	QSize pageSize = (QSizeF(dragToPage->width(), dragToPage->height()) * m_canvas->scale()).toSize();
 	switch (m_mode)
 	{
 		case HORIZONTAL:
@@ -300,6 +312,7 @@
 
 void RulerGesture::mouseMoveEvent(QMouseEvent* m)
 {
+	m_mousePoint=m_canvas->globalToCanvas(m->globalPos());
 	m->accept();
 	if (m_view->moveTimerElapsed())
 	{
@@ -330,6 +343,7 @@
 		m_canvas->setForcedRedraw(true);
 	m_canvas->repaint();
 	m_view->stopGesture();
+	m_mousePoint=QPoint(0,0);
 	if (m_ScMW->doc->guidesPrefs().guidesShown)
 		emit guideInfo(m_mode, m_currentGuide);
 }

Modified: trunk/Scribus/scribus/canvasgesture_rulermove.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19547&path=/trunk/Scribus/scribus/canvasgesture_rulermove.h
==============================================================================
--- trunk/Scribus/scribus/canvasgesture_rulermove.h (original)
+++ trunk/Scribus/scribus/canvasgesture_rulermove.h Thu Oct  2 21:12:09 2014
@@ -35,6 +35,7 @@
 #include "canvas.h"
 #include "canvasgesture.h"
 #include "canvasmode.h"
+#include "fpoint.h"
 
 class ScribusMainWindow;
 class ScribusView;
@@ -89,6 +90,7 @@
 	bool m_haveCursor;
 	QCursor m_cursor;
 	QPoint m_xy;
+	FPoint m_mousePoint;
 	void movePoint(QMouseEvent *m, bool mouseRelease);
 	
 	signals:

Modified: trunk/Scribus/scribus/canvasmode.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19547&path=/trunk/Scribus/scribus/canvasmode.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode.cpp (original)
+++ trunk/Scribus/scribus/canvasmode.cpp Thu Oct  2 21:12:09 2014
@@ -101,7 +101,7 @@
 
 	m_keyRepeat = false;
 	m_arrowKeyDown = false;
-	m_mousePointDoc = FPoint(0,0);
+	//m_mousePointDoc = FPoint(0,0);
 }
 
 CanvasMode::~CanvasMode()
@@ -923,7 +923,7 @@
 		return;
 	if (xSnap == 0.0 && ySnap == 0.0)
 		return;
-	int page = m_doc->OnPage(m_mousePointDoc.x(), m_mousePointDoc.y());
+	int page = m_doc->OnPage(m_view->m_mousePointDoc.x(), m_view->m_mousePointDoc.y());
 	if (page == -1)
 		return;
 	MarginStruct bleedValues;
@@ -980,7 +980,7 @@
 
 bool CanvasMode::commonMouseMove(QMouseEvent *m)
 {
-	m_mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
+	//m_mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
 	if ((m_canvas->m_viewMode.m_MouseButtonPressed && (m->buttons() & Qt::RightButton) && (m->modifiers() & Qt::ControlModifier)) || ((!(m->modifiers() & Qt::ControlModifier)) && (m->buttons() & Qt::MidButton)))
 	{
 		if (!m_panGesture)

Modified: trunk/Scribus/scribus/canvasmode.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19547&path=/trunk/Scribus/scribus/canvasmode.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode.h (original)
+++ trunk/Scribus/scribus/canvasmode.h Thu Oct  2 21:12:09 2014
@@ -169,7 +169,7 @@
 
 	bool m_keyRepeat;
 	bool m_arrowKeyDown;	
-	FPoint m_mousePointDoc;
+	//FPoint m_mousePointDoc;
 };
 
 

Modified: trunk/Scribus/scribus/fpoint.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19547&path=/trunk/Scribus/scribus/fpoint.cpp
==============================================================================
--- trunk/Scribus/scribus/fpoint.cpp (original)
+++ trunk/Scribus/scribus/fpoint.cpp Thu Oct  2 21:12:09 2014
@@ -81,3 +81,10 @@
 	double y = ma.m22() * yp + ma.m12() * xp + ma.dy();
 	return FPoint(x, y);
 }
+
+bool FPoint::isNull() const
+{
+	if (xp == 0.0 && yp == 0.0)
+		return true;
+	return false;
+}

Modified: trunk/Scribus/scribus/fpoint.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19547&path=/trunk/Scribus/scribus/fpoint.h
==============================================================================
--- trunk/Scribus/scribus/fpoint.h (original)
+++ trunk/Scribus/scribus/fpoint.h Thu Oct  2 21:12:09 2014
@@ -73,6 +73,7 @@
 	/// Returns a copy of the point as a QPointF.
 	QPointF toQPointF() const { return QPointF(xp, yp); }
 	friend class FPointArray;
+	bool isNull() const;
 
 private:
 	double xp;

Modified: trunk/Scribus/scribus/plugins/import/revenge/rawpainter.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19547&path=/trunk/Scribus/scribus/plugins/import/revenge/rawpainter.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/revenge/rawpainter.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/revenge/rawpainter.cpp Thu Oct  2 21:12:09 2014
@@ -3092,7 +3092,7 @@
 					EndArrow.map(m);
 					refP = m.map(refP);
 					QPainterPath pa2 = EndArrow.toQPainterPath(true);
-					QRectF br2 = pa2.boundingRect();
+					//QRectF br2 = pa2.boundingRect();
 					QTransform m2;
 					FPoint grOffset2(getMinClipF(&EndArrow));
 					m2.translate(-grOffset2.x(), -grOffset2.y());
@@ -3143,7 +3143,7 @@
 					EndArrow.map(m);
 					refP = m.map(refP);
 					QPainterPath pa2 = EndArrow.toQPainterPath(true);
-					QRectF br2 = pa2.boundingRect();
+					//QRectF br2 = pa2.boundingRect();
 					QTransform m2;
 					FPoint grOffset2(getMinClipF(&EndArrow));
 					m2.translate(-grOffset2.x(), -grOffset2.y());

Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19547&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp (original)
+++ trunk/Scribus/scribus/scribusview.cpp Thu Oct  2 21:12:09 2014
@@ -216,7 +216,7 @@
 	m_canvas->resetRenderMode();
 	m_ScMW->scrActions["viewPreviewMode"]->setChecked(m_canvas->m_viewMode.viewAsPreview);
 //	m_SnapCounter = 0;
-
+	m_mousePointDoc = FPoint(0,0);
 	Doc->regionsChanged()->connectObserver(this);
 	connect(this, SIGNAL(HaveSel()), Doc, SLOT(selectionChanged()));
 // Commented out to fix bug #7865
@@ -4089,6 +4089,8 @@
 	if (obj == widget() && event->type() == QEvent::MouseMove)
 	{
 		QMouseEvent* m = static_cast<QMouseEvent*> (event);
+		m_mousePointDoc=m_canvas->globalToCanvas(m->globalPos());
+		qDebug()<<"boo"<<m_mousePointDoc.x();
 		FPoint p = m_canvas->localToCanvas(QPoint(m->x(),m->y()));
 		emit MousePos(p.x(),p.y());
 		horizRuler->Draw(m->x() + qRound(Doc->minCanvasCoordinate.x() * m_canvas->scale())); //  - 2 * contentsX());

Modified: trunk/Scribus/scribus/scribusview.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19547&path=/trunk/Scribus/scribus/scribusview.h
==============================================================================
--- trunk/Scribus/scribus/scribusview.h (original)
+++ trunk/Scribus/scribus/scribusview.h Thu Oct  2 21:12:09 2014
@@ -155,6 +155,7 @@
 	PageItem *redrawItem;
 	SelectionRubberBand *redrawMarker;
 	FPoint RCenter;
+	FPoint m_mousePointDoc;
 	void updatesOn(bool on);
 	//CB This MUST now be called AFTER a call to doc->addPage or doc->addMasterPage as it
 	//does NOT create a page anymore.




More information about the scribus-commit mailing list