r16268 by fschmid - First version of an "Edit Arc" dialog

scribus-commit scribus-commit at lists.scribus.net
Mon Jan 17 23:36:06 CET 2011


Author: fschmid
Date: Mon Jan 17 22:36:05 2011
New Revision: 16268

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16268
Log:
First version of an "Edit Arc" dialog

Added:
    trunk/Scribus/scribus/ui/arcvectorbase.ui
Modified:
    trunk/Scribus/scribus/CMakeLists.txt
    trunk/Scribus/scribus/canvasmode_editarc.cpp
    trunk/Scribus/scribus/canvasmode_editarc.h

Modified: trunk/Scribus/scribus/CMakeLists.txt
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16268&path=/trunk/Scribus/scribus/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/CMakeLists.txt Mon Jan 17 22:36:05 2011
@@ -67,6 +67,7 @@
 SET(SCRIBUS_UI_SRC
   ui/aboutplugins.ui
   ui/aligndistribute.ui
+  ui/arcvectorbase.ui
   ui/charselect.ui
   ui/charselectenhanced.ui
   ui/cmsprefsbase.ui
@@ -146,6 +147,7 @@
   canvasgesture_rulermove.h
   canvasmode.h
   canvasmode_edit.h
+  canvasmode_editarc.h
   canvasmode_measurements.h
   canvasmode_normal.h
   chartablemodel.h
@@ -217,6 +219,7 @@
   ui/annot.h
   ui/annota.h
   ui/applytemplatedialog.h
+  ui/arcvectordialog.h
   ui/arrowchooser.h
   ui/autoform.h
   ui/autoformbuttongroup.h
@@ -594,6 +597,7 @@
   ui/annot.cpp
   ui/annota.cpp
   ui/applytemplatedialog.cpp
+  ui/arcvectordialog.cpp
   ui/arrowchooser.cpp
   ui/autoform.cpp
   ui/autoformbuttongroup.cpp

Modified: trunk/Scribus/scribus/canvasmode_editarc.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16268&path=/trunk/Scribus/scribus/canvasmode_editarc.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editarc.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_editarc.cpp Mon Jan 17 22:36:05 2011
@@ -155,6 +155,7 @@
 
 void CanvasMode_EditArc::activate(bool fromGesture)
 {
+	VectorDialog = new ArcVectorDialog(m_ScMW);
 	m_canvas->m_viewMode.m_MouseButtonPressed = false;
 	m_canvas->resetRenderMode();
 	m_doc->DragP = false;
@@ -172,15 +173,64 @@
 	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);
+	double nSweep = swe.angle() - res.angle();
+	if (nSweep < 0)
+		nSweep += 360;
+	VectorDialog->setValues(res.angle(), nSweep, item->arcHeight, item->arcWidth);
+	VectorDialog->show();
 	setModeCursor();
 	if (fromGesture)
 	{
 		m_view->update();
 	}
+	connect(VectorDialog, SIGNAL(NewVectors(double, double, double, double)), this, SLOT(applyValues(double, double, double, double)));
+}
+
+void CanvasMode_EditArc::applyValues(double start, double end, double height, double width)
+{
+	PageItem *currItem = m_doc->m_Selection->itemAt(0);
+	PageItem_Arc *item = currItem->asArc();
+	QPointF mPoint = item->PoLine.pointQF(0);
+	QRectF upRect = QRectF(QPointF(0, 0), QPointF(currItem->width(), currItem->height())).normalized();
+	QRectF upRect2 = QRectF(mPoint.x() - item->arcWidth / 2.0, mPoint.y() - item->arcHeight / 2.0, item->arcWidth, item->arcHeight);
+	upRect = upRect2.united(upRect);
+	upRect.translate(currItem->xPos(), currItem->yPos());
+	item->arcWidth = width;
+	item->arcHeight = height;
+	QTransform bb;
+	bb.scale(item->arcHeight / item->arcWidth, 1.0);
+	QLineF inp = QLineF(QPointF(width / 2.0, height / 2.0), QPointF(width, height / 2.0));
+	inp.setAngle(start);
+	QLineF res = bb.map(inp);
+	inp.setAngle(start + end);
+	QLineF ena = bb.map(inp);
+	startAngle = res.angle();
+	endAngle = ena.angle();
+	double nSweep = endAngle - startAngle;
+	if (nSweep < 0)
+		nSweep += 360;
+	QPainterPath pp;
+	pp.moveTo(mPoint);
+	pp.arcTo(QRectF(mPoint.x() - item->arcWidth / 2.0, mPoint.y() - item->arcHeight / 2.0, item->arcWidth, item->arcHeight), startAngle, nSweep);
+	pp.closeSubpath();
+	currItem->PoLine.fromQPainterPath(pp);
+	m_doc->AdjustItemSize(currItem);
+	item->arcStartAngle = startAngle;
+	item->arcSweepAngle = endAngle - startAngle;
+	startPoint = currItem->PoLine.pointQF(2);
+	endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 4);
+	centerPoint = currItem->PoLine.pointQF(0);
+	widthPoint = QPointF(centerPoint.x() - item->arcWidth / 2.0, centerPoint.y());
+	heightPoint = QPointF(centerPoint.x(), centerPoint.y() - item->arcHeight / 2.0);
+	m_doc->regionsChanged()->update(upRect.adjusted(-10.0 - currItem->width() / 2.0, -10.0 - currItem->height() / 2.0, 10.0 + currItem->width() / 2.0, 10.0 + currItem->height() / 2.0));
 }
 
 void CanvasMode_EditArc::deactivate(bool forGesture)
 {
+	VectorDialog->close();
+	delete VectorDialog;
 	m_view->redrawMarker->hide();
 	m_arcPoint = noPointDefined;
 }
@@ -272,6 +322,12 @@
 			QLineF stLinA = QLineF(smPoint, itemMatrix.map(endPoint));
 			m_canvas->displayRotHUD(m->globalPos(), 360.0 - stLinA.angle());
 		}
+		QLineF res = QLineF(centerPoint, startPoint);
+		QLineF swe = QLineF(centerPoint, endPoint);
+		nSweep = swe.angle() - res.angle();
+		if (nSweep < 0)
+			nSweep += 360;
+		VectorDialog->setValues(res.angle(), nSweep, nHeight * 2, nWidth * 2);
 		currItem->update();
 		QRectF upRect;
 		upRect = QRectF(QPointF(0, 0), QPointF(currItem->width(), currItem->height())).normalized();

Modified: trunk/Scribus/scribus/canvasmode_editarc.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16268&path=/trunk/Scribus/scribus/canvasmode_editarc.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editarc.h (original)
+++ trunk/Scribus/scribus/canvasmode_editarc.h Mon Jan 17 22:36:05 2011
@@ -28,6 +28,7 @@
 
 #include "canvasmode.h"
 #include "fpointarray.h"
+#include "ui/arcvectordialog.h"
 
 class PageItem;
 class ScribusMainWindow;
@@ -38,6 +39,7 @@
 
 class CanvasMode_EditArc :  public CanvasMode
 {	
+	Q_OBJECT
 public:
 	CanvasMode_EditArc(ScribusView* view);
 
@@ -78,6 +80,10 @@
 	double startAngle;
 	double endAngle;
 	eArcPoint m_arcPoint;
+	ArcVectorDialog* VectorDialog;
+
+private slots:
+	void applyValues(double start, double end, double height, double width);
 };
 
 




More information about the scribus-commit mailing list