r16289 by fschmid - Update item correctly when flipping from the Properties Palette in edit mode.

scribus-commit scribus-commit at lists.scribus.net
Fri Jan 21 21:12:06 CET 2011


Author: fschmid
Date: Fri Jan 21 20:12:06 2011
New Revision: 16289

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16289
Log:
Update item correctly when flipping from the Properties Palette in edit mode.

Modified:
    trunk/Scribus/scribus/CMakeLists.txt
    trunk/Scribus/scribus/canvasmode_editarc.cpp
    trunk/Scribus/scribus/canvasmode_editarc.h
    trunk/Scribus/scribus/canvasmode_editpolygon.cpp
    trunk/Scribus/scribus/canvasmode_editpolygon.h
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/scribusdoc.h

Modified: trunk/Scribus/scribus/CMakeLists.txt
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16289&path=/trunk/Scribus/scribus/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/CMakeLists.txt Fri Jan 21 20:12:06 2011
@@ -148,6 +148,7 @@
   canvasmode.h
   canvasmode_edit.h
   canvasmode_editarc.h
+  canvasmode_editpolygon.h
   canvasmode_measurements.h
   canvasmode_normal.h
   chartablemodel.h

Modified: trunk/Scribus/scribus/canvasmode_editarc.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16289&path=/trunk/Scribus/scribus/canvasmode_editarc.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editarc.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_editarc.cpp Fri Jan 21 20:12:06 2011
@@ -185,6 +185,24 @@
 	connect(VectorDialog, SIGNAL(NewVectors(double, double, double, double)), this, SLOT(applyValues(double, double, double, double)));
 	connect(VectorDialog, SIGNAL(endEdit()), this, SLOT(endEditing()));
 	connect(VectorDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool)));
+	connect(m_doc, SIGNAL(updateEditItem()), this, SLOT(updateFromItem()));
+}
+
+void CanvasMode_EditArc::updateFromItem()
+{
+	PageItem *currItem = m_doc->m_Selection->itemAt(0);
+	PageItem_Arc* item = currItem->asArc();
+	centerPoint = currItem->PoLine.pointQF(0);
+	startPoint = currItem->PoLine.pointQF(3);
+	endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 4);
+	widthPoint = QPointF(centerPoint.x() - item->arcWidth / 2.0, centerPoint.y());
+	heightPoint = QPointF(centerPoint.x(), centerPoint.y() - item->arcHeight / 2.0);
+	startAngle = item->arcStartAngle;
+	endAngle = startAngle + item->arcSweepAngle;
+	QLineF res = QLineF(centerPoint, startPoint);
+	QLineF swe = QLineF(centerPoint, endPoint);
+	VectorDialog->setValues(res.angle(), swe.angle(), item->arcHeight, item->arcWidth);
+	m_view->update();
 }
 
 void CanvasMode_EditArc::endEditing(bool active)
@@ -243,6 +261,7 @@
 	delete VectorDialog;
 	m_view->redrawMarker->hide();
 	m_arcPoint = noPointDefined;
+	disconnect(m_doc, SIGNAL(updateEditItem()), this, SLOT(updateFromItem()));
 }
 
 void CanvasMode_EditArc::mouseDoubleClickEvent(QMouseEvent *m)

Modified: trunk/Scribus/scribus/canvasmode_editarc.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16289&path=/trunk/Scribus/scribus/canvasmode_editarc.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editarc.h (original)
+++ trunk/Scribus/scribus/canvasmode_editarc.h Fri Jan 21 20:12:06 2011
@@ -82,6 +82,9 @@
 	eArcPoint m_arcPoint;
 	ArcVectorDialog* VectorDialog;
 
+public slots:
+	void updateFromItem();
+
 private slots:
 	void endEditing(bool active);
 	void endEditing();

Modified: trunk/Scribus/scribus/canvasmode_editpolygon.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16289&path=/trunk/Scribus/scribus/canvasmode_editpolygon.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editpolygon.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_editpolygon.cpp Fri Jan 21 20:12:06 2011
@@ -141,6 +141,32 @@
 		qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
 }
 
+void CanvasMode_EditPolygon::updateFromItem()
+{
+	PageItem *currItem = m_doc->m_Selection->itemAt(0);
+	PageItem_RegularPolygon* item = currItem->asRegularPolygon();
+	centerPoint = QPointF(currItem->width() / 2.0, currItem->height() / 2.0);
+	startPoint = currItem->PoLine.pointQF(0);
+	endPoint = currItem->PoLine.pointQF(2);
+	polyCorners = item->polyCorners;
+	polyUseFactor = item->polyUseFactor;
+	polyFactor = item->polyFactor;
+	polyRotation = item->polyRotation;
+	polyCurvature = item->polyCurvature;
+	polyInnerRot = item->polyInnerRot;
+	polyOuterCurvature = item->polyOuterCurvature;
+	uint cx = polyUseFactor ? polyCorners * 2 : polyCorners;
+	double seg = 360.0 / cx;
+	double trueLength = sqrt(pow(sin(seg / 180.0 * M_PI) * (item->width() / 2.0), 2) + pow(cos(seg / 180.0 * M_PI) * (item->height() / 2.0) + (item->height()/2.0) - item->height(), 2));
+	QLineF innerLine = QLineF(endPoint, centerPoint);
+	innerLine.setAngle(innerLine.angle() + 90);
+	innerLine.setLength(trueLength * polyCurvature);
+	innerCPoint = innerLine.p2();
+	QLineF outerLine = QLineF(startPoint, currItem->PoLine.pointQF(6));
+	outerLine.setLength(outerLine.length() * polyOuterCurvature);
+	outerCPoint = outerLine.p2();
+	m_view->update();
+}
 
 void CanvasMode_EditPolygon::activate(bool fromGesture)
 {
@@ -178,12 +204,14 @@
 	setModeCursor();
 	if (fromGesture)
 		m_view->update();
+	connect(m_doc, SIGNAL(updateEditItem()), this, SLOT(updateFromItem()));
 }
 
 void CanvasMode_EditPolygon::deactivate(bool forGesture)
 {
 	m_view->redrawMarker->hide();
 	m_polygonPoint = noPointDefined;
+	disconnect(m_doc, SIGNAL(updateEditItem()), this, SLOT(updateFromItem()));
 }
 
 double CanvasMode_EditPolygon::getUserValFromFactor(double factor)

Modified: trunk/Scribus/scribus/canvasmode_editpolygon.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16289&path=/trunk/Scribus/scribus/canvasmode_editpolygon.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editpolygon.h (original)
+++ trunk/Scribus/scribus/canvasmode_editpolygon.h Fri Jan 21 20:12:06 2011
@@ -37,7 +37,8 @@
 // This class encapsulate the old code for mouse interaction from scribusview.cpp
 
 class CanvasMode_EditPolygon :  public CanvasMode
-{	
+{
+	Q_OBJECT
 public:
 	CanvasMode_EditPolygon(ScribusView* view);
 
@@ -86,6 +87,9 @@
 	double polyInnerRot;
 	double polyOuterCurvature;
 	ePolygonPoint m_polygonPoint;
+
+public slots:
+	void updateFromItem();
 };
 
 

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16289&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Fri Jan 21 20:12:06 2011
@@ -8286,6 +8286,7 @@
 				FPoint tp2(getMinClipF(&currItem->PoLine));
 				currItem->PoLine.translate(-tp2.x(), -tp2.y());
 				AdjustItemSize(currItem);
+				emit updateEditItem();
 			}
 			else if (currItem->isRegularPolygon())
 			{
@@ -8293,6 +8294,7 @@
 				ar->polyRotation *= -1;
 				ar->polyInnerRot *= -1;
 				ar->recalcPath();
+				emit updateEditItem();
 			}
 			currItem->setRedrawBounding();
 		}
@@ -8331,6 +8333,7 @@
 				FPoint tp2(getMinClipF(&currItem->PoLine));
 				currItem->PoLine.translate(-tp2.x(), -tp2.y());
 				AdjustItemSize(currItem);
+				emit updateEditItem();
 			}
 			else if (currItem->isRegularPolygon())
 			{
@@ -8338,6 +8341,7 @@
 				ar->polyRotation *= -1;
 				ar->polyInnerRot *= -1;
 				ar->recalcPath();
+				emit updateEditItem();
 			}
 		}
 	}
@@ -8391,6 +8395,7 @@
 				FPoint tp2(getMinClipF(&currItem->PoLine));
 				currItem->PoLine.translate(-tp2.x(), -tp2.y());
 				AdjustItemSize(currItem);
+				emit updateEditItem();
 			}
 			else if (currItem->isRegularPolygon())
 			{
@@ -8399,6 +8404,7 @@
 				ar->polyRotation *= -1;
 				ar->polyInnerRot *= -1;
 				ar->recalcPath();
+				emit updateEditItem();
 			}
 			currItem->setRedrawBounding();
 		}
@@ -8439,6 +8445,7 @@
 				FPoint tp2(getMinClipF(&currItem->PoLine));
 				currItem->PoLine.translate(-tp2.x(), -tp2.y());
 				AdjustItemSize(currItem);
+				emit updateEditItem();
 			}
 			else if (currItem->isRegularPolygon())
 			{
@@ -8447,6 +8454,7 @@
 				ar->polyRotation *= -1;
 				ar->polyInnerRot *= -1;
 				ar->recalcPath();
+				emit updateEditItem();
 			}
 		}
 		regionsChanged()->update(QRectF());

Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16289&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h (original)
+++ trunk/Scribus/scribus/scribusdoc.h Fri Jan 21 20:12:06 2011
@@ -1229,6 +1229,7 @@
 
 	//! Signal a change in rotation mode (aka basepoint)
 	void rotationMode(int);
+	void updateEditItem();
 	
 public slots:
 	void selectionChanged();




More information about the scribus-commit mailing list