r23413 by jghali - Move clip update code for line items to a proper PageItem_Line function

scribus-commit scribus-commit at lists.scribus.net
Tue Dec 10 08:02:17 UTC 2019


Author: jghali
Date: Tue Dec 10 08:02:16 2019
New Revision: 23413

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23413
Log:
Move clip update code for line items to a proper PageItem_Line function 

Modified:
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pageitem_line.cpp
    trunk/Scribus/scribus/pageitem_line.h
    trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
    trunk/Scribus/scribus/scribusdoc.cpp

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23413&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp	(original)
+++ trunk/Scribus/scribus/pageitem.cpp	Tue Dec 10 08:02:16 2019
@@ -50,6 +50,7 @@
 #include "pageitem_arc.h"
 #include "pageitem_group.h"
 #include "pageitem_latexframe.h"
+#include "pageitem_line.h"
 #include "pageitem_noteframe.h"
 #include "pageitem_regularpolygon.h"
 #include "pageitem_spiral.h"
@@ -537,11 +538,11 @@
 	switch (m_itemType)
 	{
 		case Polygon:
-			Clip.setPoints(4, static_cast<int>(w/2), 0, static_cast<int>(w), static_cast<int>(h/2),
-								static_cast<int>(w/2), static_cast<int>(h), 0,static_cast<int>(h/2));
+			Clip.setPoints(4, static_cast<int>(w / 2), 0, static_cast<int>(w), static_cast<int>(h / 2),
+								static_cast<int>(w / 2), static_cast<int>(h), 0, static_cast<int>(h / 2));
 			break;
 		default:
-			Clip.setPoints(4, 0,0, static_cast<int>(w),0, static_cast<int>(w), static_cast<int>(h), 0,static_cast<int>(h));
+			Clip.setPoints(4, 0, 0, static_cast<int>(w), 0, static_cast<int>(w), static_cast<int>(h), 0, static_cast<int>(h));
 			break;
 	}
 	PoLine.resize(0);
@@ -10271,9 +10272,11 @@
 	switch (itemType())
 	{
 	case PageItem::Line:
-		Clip.setPoints(4, -ph,-ph, static_cast<int>(width() + ph),-ph,
-		                  static_cast<int>(width() + ph), static_cast<int>(height() + ph),
-		                  -ph, static_cast<int>(height() + ph));
+		{
+			PageItem_Line* lineItem = asLine();
+			if (lineItem)
+				lineItem->setLineClip();
+		}
 		break;
 	default:
 		if (((!ClipEdited) || (FrameType < 3)) && !(asPathText()))

Modified: trunk/Scribus/scribus/pageitem_line.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23413&path=/trunk/Scribus/scribus/pageitem_line.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_line.cpp	(original)
+++ trunk/Scribus/scribus/pageitem_line.cpp	Tue Dec 10 08:02:16 2019
@@ -174,6 +174,15 @@
 	return QPointF(x, y);
 }
 
+void PageItem_Line::setLineClip()
+{
+	int ph = static_cast<int>(qMax(1.0, m_lineWidth / 2.0));
+	Clip.setPoints(4, -ph,-ph,
+	                  static_cast<int>(width() + ph), -ph,
+	                  static_cast<int>(width() + ph), static_cast<int>(height() + ph),
+	                  -ph, static_cast<int>(height() + ph));
+}
+
 void PageItem_Line::getBoundingRect(double *x1, double *y1, double *x2, double *y2) const
 {
 	double minx =  std::numeric_limits<double>::max();

Modified: trunk/Scribus/scribus/pageitem_line.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23413&path=/trunk/Scribus/scribus/pageitem_line.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_line.h	(original)
+++ trunk/Scribus/scribus/pageitem_line.h	Tue Dec 10 08:02:16 2019
@@ -49,6 +49,8 @@
 	QPointF startPoint();
 	QPointF endPoint();
 
+	void setLineClip();
+
 	void getBoundingRect(double *x1, double *y1, double *x2, double *y2) const override;
 	void getOldBoundingRect(double *x1, double *y1, double *x2, double *y2) const override;
 	void getVisualBoundingRect(double *x1, double *y1, double *x2, double *y2) const override;

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23413&path=/trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp	(original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp	Tue Dec 10 08:02:16 2019
@@ -13,6 +13,7 @@
 #include "ui/missing.h"
 #include "prefsmanager.h"
 #include "pageitem_latexframe.h"
+#include "pageitem_line.h"
 #include "pageitem_group.h"
 #include "qtiocompressor.h"
 #include "scconfig.h"
@@ -543,10 +544,8 @@
 		int ph = static_cast<int>(qMax(1.0, currItem->lineWidth() / 2.0));
 		currItem->Segments.clear();
 		currItem->PoLine.resize(0);
-		currItem->Clip.setPoints(4, -ph,-ph, static_cast<int>(currItem->width()+ph),-ph,
-		                  static_cast<int>(currItem->width()+ph),static_cast<int>(currItem->height()+ph),
-		                  -ph,static_cast<int>(currItem->height()+ph));
 		currItem->setHeight(1.0);
+		currItem->asLine()->setLineClip();
 	}
 	// OBSOLETE CR 2005-02-06
 	if (currItem->itemType() == PageItem::ItemType1)

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23413&path=/trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp	(original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp	Tue Dec 10 08:02:16 2019
@@ -15,6 +15,7 @@
 #include "ui/missing.h"
 #include "hyphenator.h"
 #include "pageitem_latexframe.h"
+#include "pageitem_line.h"
 #include "pageitem_table.h"
 #include "prefsmanager.h"
 #include "qtiocompressor.h"
@@ -3011,10 +3012,8 @@
 		int ph = static_cast<int>(qMax(1.0, currItem->lineWidth() / 2.0));
 		currItem->Segments.clear();
 		currItem->PoLine.resize(0);
-		currItem->Clip.setPoints(4, -ph,-ph, static_cast<int>(currItem->width()+ph),-ph,
-		                  static_cast<int>(currItem->width()+ph),static_cast<int>(currItem->height()+ph),
-		                  -ph,static_cast<int>(currItem->height()+ph));
 		currItem->setHeight(1.0);
+		currItem->asLine()->setLineClip();
 	}
 
 	if (currItem->asPathText())

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23413&path=/trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp	(original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp	Tue Dec 10 08:02:16 2019
@@ -10,16 +10,17 @@
 #include "../../formatidlist.h"
 #include "commonstrings.h"
 #include "langmgr.h"
-#include "ui/missing.h"
 #include "pageitem_group.h"
+#include "pageitem_line.h"
 #include "prefsmanager.h"
 #include "qtiocompressor.h"
+
 #include "scconfig.h"
+#include "scclocale.h"
+#include "sccolorengine.h"
+#include "scribuscore.h"
 #include "scribusdoc.h"
-
 #include "sctextstream.h"
-#include "sccolorengine.h"
-#include "ui/scmessagebox.h"
 #include "undomanager.h"
 #include "units.h"
 #include "util.h"
@@ -27,8 +28,10 @@
 #include "util_layer.h"
 #include "util_math.h"
 #include "util_text.h"
-#include "scclocale.h"
-#include "scribuscore.h"
+
+#include "ui/missing.h"
+#include "ui/scmessagebox.h"
+
 #include <QCursor>
 // #include <QDebug>
 #include <QFileInfo>
@@ -36,7 +39,6 @@
 #include <QDataStream>
 #include <QApplication>
 #include <QMessageBox>
-
 
 // See scplugin.h and pluginmanager.{cpp,h} for detail on what these methods
 // do. That documentatation is not duplicated here.
@@ -1941,10 +1943,8 @@
 		int ph = static_cast<int>(qMax(1.0, currItem->lineWidth() / 2.0));
 		currItem->Segments.clear();
 		currItem->PoLine.resize(0);
-		currItem->Clip.setPoints(4, -ph,-ph, static_cast<int>(currItem->width()+ph),-ph,
-		                  static_cast<int>(currItem->width()+ph),static_cast<int>(currItem->height()+ph),
-		                  -ph,static_cast<int>(currItem->height()+ph));
 		currItem->setHeight(1.0);
+		currItem->asLine()->setLineClip();
 	}
 	if (currItem->asImageFrame())
 		currItem->adjustPictScale();

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23413&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp	(original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp	Tue Dec 10 08:02:16 2019
@@ -16,6 +16,7 @@
 #include "langmgr.h"
 #include "notesstyles.h"
 #include "pageitem_latexframe.h"
+#include "pageitem_line.h"
 #include "pageitem_noteframe.h"
 #include "pagesize.h"
 #include "prefsmanager.h"
@@ -5465,10 +5466,8 @@
 		int ph = static_cast<int>(qMax(1.0, currItem->lineWidth() / 2.0));
 		currItem->Segments.clear();
 		currItem->PoLine.resize(0);
-		currItem->Clip.setPoints(4, -ph,-ph, static_cast<int>(currItem->width()+ph),-ph,
-		                  static_cast<int>(currItem->width()+ph),static_cast<int>(currItem->height()+ph),
-		                  -ph,static_cast<int>(currItem->height()+ph));
 		currItem->setHeight(1.0);
+		currItem->asLine()->setLineClip();
 	}
 
 	if (currItem->asPathText())

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23413&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp	(original)
+++ trunk/Scribus/scribus/scribusdoc.cpp	Tue Dec 10 08:02:16 2019
@@ -7716,12 +7716,7 @@
 		if (currItem->asPolyLine() || currItem->asSpiral())
 			currItem->setPolyClip(qRound(qMax(currItem->lineWidth() / 2, 1.0)));
 		if (currItem->asLine())
-		{
-			int ph = static_cast<int>(qMax(1.0, w / 2.0));
-			currItem->Clip.setPoints(4, -ph,-ph, static_cast<int>(currItem->width() + ph),-ph,
-									 static_cast<int>(currItem->width() + ph),static_cast<int>(currItem->height() + ph),
-									 -ph, static_cast<int>(currItem->height() + ph));
-		}
+			currItem->asLine()->setLineClip();
 		QRectF newRect = currItem->getVisualBoundingRect();
 		//currItem->update();
 		currItem->invalidateLayout();
@@ -14391,9 +14386,7 @@
 			currItem->setWidthHeight( sqrt(pow(t.x(), 2) + pow(t.y(), 2)), 1.0);
 			//currItem->setXYPos(currItem->xPos(), currItem->yPos());
 		}
-		currItem->Clip.setPoints(4, -ph,-ph, static_cast<int>(currItem->width() + ph), -ph,
-		                  static_cast<int>(currItem->width() + ph), static_cast<int>(currItem->height() + ph),
-		                  -ph, static_cast<int>(currItem->height() + ph));
+		currItem->asLine()->setLineClip();
 	}
 	// In the future, it may be good to adjust embedded group items position here
 	/*if (currItem->isGroup() || currItem->isSymbol())




More information about the scribus-commit mailing list