View Issue Details

IDProjectCategoryView StatusLast Update
0016071ScribusGraphics / Image Framespublic2020-04-05 19:37
ReporterPontobart Assigned Tojghali  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.5.6.svn 
Fixed in Version1.5.6.svn 
Summary0016071: Outline node movement changes contour, reset fails
DescriptionSee the following video: https://photos.app.goo.gl/Hzf7JpPHcjv2cFKY7
(The videos uses the 1.5.5 AppImage. It might make sense to replay the steps to see changes to the contour line)

I have an image frame that is rotated. I have enabled the contour line. While I am in the outline editor the contour moves if I change the overall bounding box of the outline. Resetting changes or aborting the dialog causes some additional changes. This is because
a) outline box position changes do not adjust the contour in image frame coordinates but in the page coordinates.
b) cancelling the dialog does not revert the changes to the image offsets (and maybe more).

I have attached a patch that fixes the issues that I have seen. To fix a) it transforms the page coordinates to get the item space coordinates before changing the contour. To fix b) it uses the trick to move the outline such that it matches the original one and then let adjustImageSize move everything in the item space.

I am wondering about one thing: moveClipPoint is repeatedly called while the mouse cursor moves updating the Pageitem without the updated item being shown. Is this necessary?
Steps To ReproduceSee the video: Take an image rotate it, use the contour and then edit the clip. Try the reset and cancel buttons.
TagsNo tags attached.
PatchYes

Activities

Pontobart

2020-03-22 17:14

reporter  

clip_and_contour_edits_rotated_images.diff (4,005 bytes)   
Index: scribus/canvasmode_nodeedit.cpp
===================================================================
--- scribus/canvasmode_nodeedit.cpp	(Revision 23527)
+++ scribus/canvasmode_nodeedit.cpp	(Arbeitskopie)
@@ -451,8 +451,12 @@
 			m_doc->nodeEdit.moveClipPoint(currItem, npf);
 		}
 		m_doc->adjustItemSize(currItem, true);
-		if (!m_doc->nodeEdit.isContourLine())
-			currItem->ContourLine.translate(xposOrig - currItem->xPos(), yposOrig - currItem->yPos());
+		if (!m_doc->nodeEdit.isContourLine()) {
+			// Move the contour accordingly in the item's coordinate space
+			QTransform m = QTransform().rotate(-currItem->rotation());
+			QPointF delta = m.map(QPointF(xposOrig, yposOrig)) - m.map(QPointF(currItem->xPos(), currItem->yPos()));
+			currItem->ContourLine.translate(delta.x(), delta.y());
+		}
 		m_doc->regionsChanged()->update(QRectF());
 		if (state)
 			m_doc->nodeEdit.finishTransaction2(currItem, state);
Index: scribus/nodeeditcontext.cpp
===================================================================
--- scribus/nodeeditcontext.cpp	(Revision 23527)
+++ scribus/nodeeditcontext.cpp	(Arbeitskopie)
@@ -351,8 +351,12 @@
 			currItem->PoLine = Clip.copy();
 		currItem->Clip = flattenPath(currItem->PoLine, currItem->Segments);
 	}
-	if (!m_isContourLine)
-		currItem->ContourLine.translate(xposOrig - currItem->xPos(), yposOrig - currItem->yPos());
+	if (!m_isContourLine) {
+		// Move the contour accordingly in the item's coordinate space
+		QTransform m = QTransform().rotate(-currItem->rotation());
+		QPointF delta = m.map(QPointF(xposOrig, yposOrig)) - m.map(QPointF(currItem->xPos(), currItem->yPos()));
+		currItem->ContourLine.translate(delta.x(), delta.y());
+	}
 }
 
 
Index: scribus/ui/nodeeditpalette.cpp
===================================================================
--- scribus/ui/nodeeditpalette.cpp	(Revision 23527)
+++ scribus/ui/nodeeditpalette.cpp	(Arbeitskopie)
@@ -971,9 +971,20 @@
 		EditCont->setChecked(false);
 		ToggleConMode();
 		PageItem *currItem = m_doc->m_Selection->itemAt(0);
-		currItem->setXYPos(xPos, yPos, true);
+
+		// Calculate the difference of the current position and the original
+		// position in the item's coordinate space (which is rotated and translated,
+		// but the translation does not matter for the delta)
+		QTransform m = QTransform().rotate(-currItem->rotation());
+		QPointF delta = m.map(QPointF(xPos, yPos)) - m.map(QPointF(currItem->xPos(), currItem->yPos()));
+		// During operation the image offsets and possibly other values are changed.
+		// To not remember everything we move the clip path to the original position
+		// relative to the current position (in the item's coordinate space).
+		// adjustItemSize will then take care of moving the position and changing
+		// image offsets, etc.
+		currItem->PoLine = itemPath.copy();
+		currItem->PoLine.translate(delta.x(), delta.y());
 		currItem->ContourLine = itemContourPath.copy();
-		currItem->PoLine = itemPath.copy();
 		m_doc->adjustItemSize(currItem);
 		if (currItem->itemType() == PageItem::PathText)
 			currItem->updatePolyClip();
@@ -997,12 +1008,19 @@
 	m_doc->nodeEdit.selNode().clear();
 	m_doc->nodeEdit.setPreviewMode(false);
 	PageItem *currItem = m_doc->m_Selection->itemAt(0);
-	if (EditCont->isChecked())
+
+	// See comment in NodePalette::CancelEdit
+	QTransform m = QTransform().rotate(-currItem->rotation());
+	QPointF delta = m.map(QPointF(xPos, yPos)) - m.map(QPointF(currItem->xPos(), currItem->yPos()));
+	if (EditCont->isChecked()) {
 		currItem->ContourLine = itemContourPath.copy();
-	else
+		currItem->ContourLine.translate(delta.x(), delta.y());
+	} else
 	{
-		currItem->setXYPos(xPos, yPos, true);
-		currItem->PoLine = itemPath.copy();
+		// See comment in NodePalette::CancelEdit
+		currItem->PoLine = itemPath;
+ 		currItem->PoLine.translate(delta.x(), delta.y());
+ 		currItem->ContourLine = itemContourPath;
 		m_doc->adjustItemSize(currItem);
 	}
 	if (currItem->itemType() == PageItem::PathText)

jghali

2020-03-22 17:42

administrator   ~0047452

Applied, thanks!

Issue History

Date Modified Username Field Change
2020-03-22 17:14 Pontobart New Issue
2020-03-22 17:14 Pontobart File Added: clip_and_contour_edits_rotated_images.diff
2020-03-22 17:42 jghali Assigned To => jghali
2020-03-22 17:42 jghali Status new => resolved
2020-03-22 17:42 jghali Resolution open => fixed
2020-03-22 17:42 jghali Fixed in Version => 1.5.6.svn
2020-03-22 17:42 jghali Note Added: 0047452
2020-04-05 19:37 cbradney Status resolved => closed