r16203 by fschmid - Added an "Outer Curvature" option to the "Regular Polygon" tool.

scribus-commit scribus-commit at lists.scribus.net
Sun Jan 2 18:26:30 CET 2011


Author: fschmid
Date: Sun Jan  2 17:26:30 2011
New Revision: 16203

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16203
Log:
Added an "Outer Curvature" option to the "Regular Polygon" tool.

Modified:
    trunk/Scribus/scribus/canvasmode_create.cpp
    trunk/Scribus/scribus/canvasmode_normal.cpp
    trunk/Scribus/scribus/pageitem_regularpolygon.cpp
    trunk/Scribus/scribus/ui/modetoolbar.cpp
    trunk/Scribus/scribus/ui/polygonwidget.cpp
    trunk/Scribus/scribus/ui/polygonwidget.h
    trunk/Scribus/scribus/ui/polygonwidgetbase.ui
    trunk/Scribus/scribus/ui/polyprops.cpp
    trunk/Scribus/scribus/ui/polyprops.h
    trunk/Scribus/scribus/ui/propertiespalette.cpp
    trunk/Scribus/scribus/util_math.cpp
    trunk/Scribus/scribus/util_math.h

Modified: trunk/Scribus/scribus/canvasmode_create.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16203&path=/trunk/Scribus/scribus/canvasmode_create.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_create.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_create.cpp Sun Jan  2 17:26:30 2011
@@ -104,7 +104,7 @@
 		}
 		else if (createObjectMode == modeDrawRegularPolygon)
 		{
-			QPainterPath path = RegularPolygonPath(localRect.width(), localRect.height(), m_doc->itemToolPrefs().polyCorners, m_doc->itemToolPrefs().polyUseFactor, m_doc->itemToolPrefs().polyFactor, m_doc->itemToolPrefs().polyRotation, m_doc->itemToolPrefs().polyCurvature, m_doc->itemToolPrefs().polyInnerRot);
+			QPainterPath path = RegularPolygonPath(localRect.width(), localRect.height(), m_doc->itemToolPrefs().polyCorners, m_doc->itemToolPrefs().polyUseFactor, m_doc->itemToolPrefs().polyFactor, m_doc->itemToolPrefs().polyRotation, m_doc->itemToolPrefs().polyCurvature, m_doc->itemToolPrefs().polyInnerRot, m_doc->itemToolPrefs().polyOuterCurvature);
 			p->translate(localRect.left(), localRect.top());
 			p->drawPath(path);
 		}

Modified: trunk/Scribus/scribus/canvasmode_normal.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16203&path=/trunk/Scribus/scribus/canvasmode_normal.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_normal.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_normal.cpp Sun Jan  2 17:26:30 2011
@@ -243,10 +243,10 @@
 		else if (currItem->asRegularPolygon())
 		{
 			PageItem_RegularPolygon* item = currItem->asRegularPolygon();
-			PolygonProps* dia = new PolygonProps(m_ScMW, item->polyCorners, item->polyFactorGuiVal, item->polyFactor, item->polyUseFactor, item->polyRotation, item->polyCurvature, item->polyInnerRot);
+			PolygonProps* dia = new PolygonProps(m_ScMW, item->polyCorners, item->polyFactorGuiVal, item->polyFactor, item->polyUseFactor, item->polyRotation, item->polyCurvature, item->polyInnerRot, item->polyOuterCurvature);
 			if (dia->exec())
 			{
-				dia->getValues(&item->polyCorners, &item->polyFactorGuiVal, &item->polyFactor, &item->polyUseFactor, &item->polyRotation, &item->polyCurvature, &item->polyInnerRot);
+				dia->getValues(&item->polyCorners, &item->polyFactorGuiVal, &item->polyFactor, &item->polyUseFactor, &item->polyRotation, &item->polyCurvature, &item->polyInnerRot, &item->polyOuterCurvature);
 				item->recalcPath();
 			}
 			delete dia;

Modified: trunk/Scribus/scribus/pageitem_regularpolygon.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16203&path=/trunk/Scribus/scribus/pageitem_regularpolygon.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_regularpolygon.cpp (original)
+++ trunk/Scribus/scribus/pageitem_regularpolygon.cpp Sun Jan  2 17:26:30 2011
@@ -58,7 +58,7 @@
 	polyCurvature = m_Doc->itemToolPrefs().polyCurvature;
 	polyInnerRot = m_Doc->itemToolPrefs().polyInnerRot;
 	polyOuterCurvature = m_Doc->itemToolPrefs().polyOuterCurvature;
-	QPainterPath path = RegularPolygonPath(w, h, polyCorners, polyUseFactor, polyFactor, polyRotation, polyCurvature, polyInnerRot);
+	QPainterPath path = RegularPolygonPath(w, h, polyCorners, polyUseFactor, polyFactor, polyRotation, polyCurvature, polyInnerRot, polyOuterCurvature);
 	PoLine.fromQPainterPath(path);
 	Clip = FlattenPath(PoLine, Segments);
 }
@@ -74,7 +74,7 @@
 
 void PageItem_RegularPolygon::recalcPath()
 {
-	QPainterPath path = RegularPolygonPath(width(), height(), polyCorners, polyUseFactor, polyFactor, polyRotation, polyCurvature, polyInnerRot);
+	QPainterPath path = RegularPolygonPath(width(), height(), polyCorners, polyUseFactor, polyFactor, polyRotation, polyCurvature, polyInnerRot, polyOuterCurvature);
 	PoLine.fromQPainterPath(path);
 	Clip = FlattenPath(PoLine, Segments);
 }

Modified: trunk/Scribus/scribus/ui/modetoolbar.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16203&path=/trunk/Scribus/scribus/ui/modetoolbar.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/modetoolbar.cpp (original)
+++ trunk/Scribus/scribus/ui/modetoolbar.cpp Sun Jan  2 17:26:30 2011
@@ -123,10 +123,10 @@
 
 void ModeToolBar::GetPolyProps()
 {
-	PolygonProps* dia = new PolygonProps(this, m_ScMW->doc->itemToolPrefs().polyCorners, m_ScMW->doc->itemToolPrefs().polyFactorGuiVal, m_ScMW->doc->itemToolPrefs().polyFactor, m_ScMW->doc->itemToolPrefs().polyUseFactor, m_ScMW->doc->itemToolPrefs().polyRotation, m_ScMW->doc->itemToolPrefs().polyCurvature, m_ScMW->doc->itemToolPrefs().polyInnerRot);
+	PolygonProps* dia = new PolygonProps(this, m_ScMW->doc->itemToolPrefs().polyCorners, m_ScMW->doc->itemToolPrefs().polyFactorGuiVal, m_ScMW->doc->itemToolPrefs().polyFactor, m_ScMW->doc->itemToolPrefs().polyUseFactor, m_ScMW->doc->itemToolPrefs().polyRotation, m_ScMW->doc->itemToolPrefs().polyCurvature, m_ScMW->doc->itemToolPrefs().polyInnerRot, m_ScMW->doc->itemToolPrefs().polyOuterCurvature);
 	if (dia->exec())
 	{
-		dia->getValues(&m_ScMW->doc->itemToolPrefs().polyCorners, &m_ScMW->doc->itemToolPrefs().polyFactorGuiVal, &m_ScMW->doc->itemToolPrefs().polyFactor, &m_ScMW->doc->itemToolPrefs().polyUseFactor, &m_ScMW->doc->itemToolPrefs().polyRotation, &m_ScMW->doc->itemToolPrefs().polyCurvature, &m_ScMW->doc->itemToolPrefs().polyInnerRot);
+		dia->getValues(&m_ScMW->doc->itemToolPrefs().polyCorners, &m_ScMW->doc->itemToolPrefs().polyFactorGuiVal, &m_ScMW->doc->itemToolPrefs().polyFactor, &m_ScMW->doc->itemToolPrefs().polyUseFactor, &m_ScMW->doc->itemToolPrefs().polyRotation, &m_ScMW->doc->itemToolPrefs().polyCurvature, &m_ScMW->doc->itemToolPrefs().polyInnerRot, &m_ScMW->doc->itemToolPrefs().polyOuterCurvature);
 		m_ScMW->scrActions["toolsInsertPolygon"]->trigger();
 	}
 	delete dia;

Modified: trunk/Scribus/scribus/ui/polygonwidget.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16203&path=/trunk/Scribus/scribus/ui/polygonwidget.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/polygonwidget.cpp (original)
+++ trunk/Scribus/scribus/ui/polygonwidget.cpp Sun Jan  2 17:26:30 2011
@@ -21,17 +21,16 @@
 
 using namespace std;
 
-PolygonWidget::PolygonWidget(QWidget* parent)
-		 : QWidget( parent )
+PolygonWidget::PolygonWidget(QWidget* parent) : QWidget( parent )
 {
 	setupUi(this);
 }
 
 
-PolygonWidget::PolygonWidget(QWidget* parent, int polyCorners, int polyFd, double polyF, bool polyUseConvexFactor, double polyRotation, double polyCurvature, double polyInnerRot) : QWidget( parent )
+PolygonWidget::PolygonWidget(QWidget* parent, int polyCorners, int polyFd, double polyF, bool polyUseConvexFactor, double polyRotation, double polyCurvature, double polyInnerRot, double polyOuterCurvature) : QWidget( parent )
 {
 	setupUi(this);
-	setValues(polyCorners, polyFd, polyF, polyUseConvexFactor, polyRotation, polyCurvature, polyInnerRot);
+	setValues(polyCorners, polyFd, polyF, polyUseConvexFactor, polyRotation, polyCurvature, polyInnerRot, polyOuterCurvature);
 	updatePreview();
 	// signals and slots connections
 	connectSignals(true);
@@ -56,6 +55,9 @@
 		connect(innerRotationSlider, SIGNAL(valueChanged(int)), innerRotationspinBox, SLOT(setValue(int)));
 		connect(innerRotationSlider, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
 		connect(innerRotationspinBox, SIGNAL(valueChanged(int)), this, SLOT(setInnerRotationSlider(int)));
+		connect(OuterCurvatureSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setOuterCurvatureSlider(int)));
+		connect(OuterCurvatureSlider, SIGNAL(valueChanged(int)), OuterCurvatureSpinBox, SLOT(setValue(int)));
+		connect(OuterCurvatureSlider, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
 	}
 	else
 	{
@@ -73,6 +75,9 @@
 		disconnect(innerRotationSlider, SIGNAL(valueChanged(int)), innerRotationspinBox, SLOT(setValue(int)));
 		disconnect(innerRotationSlider, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
 		disconnect(innerRotationspinBox, SIGNAL(valueChanged(int)), this, SLOT(setInnerRotationSlider(int)));
+		disconnect(OuterCurvatureSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setOuterCurvatureSlider(int)));
+		disconnect(OuterCurvatureSlider, SIGNAL(valueChanged(int)), OuterCurvatureSpinBox, SLOT(setValue(int)));
+		disconnect(OuterCurvatureSlider, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
 	}
 }
 
@@ -90,6 +95,8 @@
 	applyConvexGroupBox->setChecked(prefsData->polyUseFactor);
 	curvatureSpinBox->setValue(qRound(prefsData->polyCurvature * 100));
 	curvatureSlider->setValue(qRound(prefsData->polyCurvature * 100));
+	OuterCurvatureSpinBox->setValue(qRound(prefsData->polyOuterCurvature * 100));
+	OuterCurvatureSlider->setValue(qRound(prefsData->polyOuterCurvature * 100));
 	innerRotationspinBox->setValue(static_cast<int>(prefsData->polyInnerRot));
 	innerRotationSlider->setValue(static_cast<int>(prefsData->polyInnerRot));
 	updatePreview();
@@ -105,9 +112,10 @@
 	prefsData->polyRotation = rotationSpinBox->value();
 	prefsData->polyInnerRot = innerRotationspinBox->value();
 	prefsData->polyCurvature = curvatureSpinBox->value() / 100.0;
-}
-
-void PolygonWidget::setValues(int polyCorners, int polyFd, double polyF, bool polyUseConvexFactor, double polyRotation, double polyCurvature, double polyInnerRot)
+	prefsData->polyOuterCurvature = OuterCurvatureSpinBox->value() / 100.0;
+}
+
+void PolygonWidget::setValues(int polyCorners, int polyFd, double polyF, bool polyUseConvexFactor, double polyRotation, double polyCurvature, double polyInnerRot, double polyOuterCurvature)
 {
 	PFactor = polyF;
 	cornersSpinBox->setValue(polyCorners);
@@ -121,9 +129,11 @@
 	applyConvexGroupBox->setChecked(polyUseConvexFactor);
 	curvatureSpinBox->setValue(qRound(polyCurvature * 100));
 	curvatureSlider->setValue(qRound(polyCurvature * 100));
-}
-
-void PolygonWidget::getValues(int* polyCorners, int* polyFd, double* polyF, bool* polyUseConvexFactor, double* polyRotation, double* polyCurvature, double* polyInnerRot)
+	OuterCurvatureSpinBox->setValue(qRound(polyOuterCurvature * 100));
+	OuterCurvatureSlider->setValue(qRound(polyOuterCurvature * 100));
+}
+
+void PolygonWidget::getValues(int* polyCorners, int* polyFd, double* polyF, bool* polyUseConvexFactor, double* polyRotation, double* polyCurvature, double* polyInnerRot, double* polyOuterCurvature)
 {
 	*polyCorners = cornersSpinBox->value();
 	*polyF = PFactor;
@@ -132,6 +142,7 @@
 	*polyRotation = rotationSpinBox->value();
 	*polyInnerRot = innerRotationspinBox->value();
 	*polyCurvature = curvatureSpinBox->value() / 100.0;
+	*polyOuterCurvature = OuterCurvatureSpinBox->value() / 100.0;
 }
 
 void PolygonWidget::setFactorSlider(int a)
@@ -162,16 +173,24 @@
 	connect(curvatureSlider, SIGNAL(valueChanged(int)), curvatureSpinBox, SLOT(setValue(int)));
 }
 
+void PolygonWidget::setOuterCurvatureSlider(int a)
+{
+	disconnect(OuterCurvatureSlider, SIGNAL(valueChanged(int)), OuterCurvatureSpinBox, SLOT(setValue(int)));
+	OuterCurvatureSlider->setValue(a);
+	connect(OuterCurvatureSlider, SIGNAL(valueChanged(int)), OuterCurvatureSpinBox, SLOT(setValue(int)));
+}
+
 void PolygonWidget::updatePreview()
 {
 	double roundness = curvatureSpinBox->value() / 100.0;
+	double innerround = OuterCurvatureSpinBox->value() / 100.0;
 	QPixmap pm = QPixmap(Preview->width() - 5, Preview->height() - 5);
 	pm.fill(Qt::white);
 	QPainter p;
 	p.begin(&pm);
 	p.setBrush(Qt::NoBrush);
 	p.setPen(Qt::black);
-	QPainterPath pp = RegularPolygonPath(Preview->width() - 6, Preview->height() - 6, cornersSpinBox->value(), applyConvexGroupBox->isChecked(), GetFactor(), rotationSlider->value(), roundness, innerRotationspinBox->value());
+	QPainterPath pp = RegularPolygonPath(Preview->width() - 6, Preview->height() - 6, cornersSpinBox->value(), applyConvexGroupBox->isChecked(), GetFactor(), rotationSlider->value(), roundness, innerRotationspinBox->value(), innerround);
 	QRectF br = pp.boundingRect();
 	if (br.x() < 0)
 	{

Modified: trunk/Scribus/scribus/ui/polygonwidget.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16203&path=/trunk/Scribus/scribus/ui/polygonwidget.h
==============================================================================
--- trunk/Scribus/scribus/ui/polygonwidget.h (original)
+++ trunk/Scribus/scribus/ui/polygonwidget.h Sun Jan  2 17:26:30 2011
@@ -17,11 +17,11 @@
 
 	public:
 		PolygonWidget(QWidget* parent);
-		PolygonWidget(QWidget* parent, int polyCorners, int polyFd, double polyF, bool polyUseConvexFactor, double polyRotation, double polyCurvature, double polyInnerRot);
+		PolygonWidget(QWidget* parent, int polyCorners, int polyFd, double polyF, bool polyUseConvexFactor, double polyRotation, double polyCurvature, double polyInnerRot, double polyOuterCurvature);
 		~PolygonWidget() {};
 
-		void setValues(int polyCorners, int polyFd, double polyF, bool polyUseConvexFactor, double polyRotation, double polyCurvature, double polyInnerRot);
-		void getValues(int* polyCorners, int* polyFd, double* polyF, bool* polyUseConvexFactor, double* polyRotation, double* polyCurvature, double* polyInnerRot);
+		void setValues(int polyCorners, int polyFd, double polyF, bool polyUseConvexFactor, double polyRotation, double polyCurvature, double polyInnerRot, double polyOuterCurvature);
+		void getValues(int* polyCorners, int* polyFd, double* polyF, bool* polyUseConvexFactor, double* polyRotation, double* polyCurvature, double* polyInnerRot, double* polyOuterCurvature);
 		void restoreDefaults(struct ItemToolPrefs *prefsData);
 		void saveGuiToPrefs(struct ItemToolPrefs *prefsData);
 
@@ -30,6 +30,7 @@
 		void setRotationSlider(int a);
 		void setInnerRotationSlider(int a);
 		void setCurvatureSlider(int a);
+		void setOuterCurvatureSlider(int a);
 		void updatePreview();
 		double GetZeroFactor();
 		double GetMaxFactor();

Modified: trunk/Scribus/scribus/ui/polygonwidgetbase.ui
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16203&path=/trunk/Scribus/scribus/ui/polygonwidgetbase.ui
==============================================================================
--- trunk/Scribus/scribus/ui/polygonwidgetbase.ui (original)
+++ trunk/Scribus/scribus/ui/polygonwidgetbase.ui Sun Jan  2 17:26:30 2011
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>458</width>
-    <height>307</height>
+    <width>470</width>
+    <height>353</height>
    </rect>
   </property>
   <property name="sizePolicy">
@@ -19,253 +19,301 @@
   <property name="windowTitle">
    <string>Form</string>
   </property>
-  <layout class="QGridLayout" name="gridLayout_3">
-   <item row="0" column="0">
-    <layout class="QGridLayout" name="gridLayout">
-     <item row="0" column="0">
-      <widget class="QLabel" name="label">
-       <property name="text">
-        <string>Corn&amp;ers:</string>
-       </property>
-       <property name="buddy">
-        <cstring>cornersSpinBox</cstring>
-       </property>
-      </widget>
+  <layout class="QHBoxLayout" name="horizontalLayout">
+   <property name="margin">
+    <number>0</number>
+   </property>
+   <item>
+    <layout class="QVBoxLayout" name="verticalLayout">
+     <item>
+      <layout class="QGridLayout" name="gridLayout">
+       <item row="0" column="0">
+        <widget class="QLabel" name="label">
+         <property name="text">
+          <string>Corn&amp;ers:</string>
+         </property>
+         <property name="buddy">
+          <cstring>cornersSpinBox</cstring>
+         </property>
+        </widget>
+       </item>
+       <item row="0" column="1">
+        <widget class="QSpinBox" name="cornersSpinBox">
+         <property name="toolTip">
+          <string>Number of corners for polygons</string>
+         </property>
+         <property name="minimum">
+          <number>3</number>
+         </property>
+         <property name="maximum">
+          <number>999</number>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="0">
+        <widget class="QLabel" name="label_2">
+         <property name="text">
+          <string>&amp;Rotation:</string>
+         </property>
+         <property name="buddy">
+          <cstring>rotationSpinBox</cstring>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="1">
+        <widget class="QSpinBox" name="rotationSpinBox">
+         <property name="toolTip">
+          <string>Degrees of rotation for polygons</string>
+         </property>
+         <property name="minimum">
+          <number>-180</number>
+         </property>
+         <property name="maximum">
+          <number>180</number>
+         </property>
+        </widget>
+       </item>
+       <item row="2" column="0" colspan="2">
+        <widget class="QSlider" name="rotationSlider">
+         <property name="toolTip">
+          <string>Degrees of rotation for polygons</string>
+         </property>
+         <property name="minimum">
+          <number>-180</number>
+         </property>
+         <property name="maximum">
+          <number>180</number>
+         </property>
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
+         </property>
+         <property name="tickPosition">
+          <enum>QSlider::TicksBelow</enum>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="0">
+        <widget class="QLabel" name="label_4">
+         <property name="text">
+          <string>Inner Rotation:</string>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="1">
+        <widget class="QSpinBox" name="innerRotationspinBox">
+         <property name="minimum">
+          <number>-180</number>
+         </property>
+         <property name="maximum">
+          <number>180</number>
+         </property>
+        </widget>
+       </item>
+       <item row="4" column="0" colspan="2">
+        <widget class="QSlider" name="innerRotationSlider">
+         <property name="minimum">
+          <number>-180</number>
+         </property>
+         <property name="maximum">
+          <number>180</number>
+         </property>
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
+         </property>
+         <property name="tickPosition">
+          <enum>QSlider::TicksBelow</enum>
+         </property>
+        </widget>
+       </item>
+      </layout>
      </item>
-     <item row="0" column="1">
-      <widget class="QSpinBox" name="cornersSpinBox">
+     <item>
+      <widget class="QGroupBox" name="applyConvexGroupBox">
        <property name="toolTip">
-        <string>Number of corners for polygons</string>
-       </property>
-       <property name="minimum">
-        <number>3</number>
-       </property>
-       <property name="maximum">
-        <number>999</number>
-       </property>
-      </widget>
-     </item>
-     <item row="1" column="0">
-      <widget class="QLabel" name="label_2">
-       <property name="text">
-        <string>&amp;Rotation:</string>
-       </property>
-       <property name="buddy">
-        <cstring>rotationSpinBox</cstring>
-       </property>
-      </widget>
-     </item>
-     <item row="1" column="1">
-      <widget class="QSpinBox" name="rotationSpinBox">
-       <property name="toolTip">
-        <string>Degrees of rotation for polygons</string>
-       </property>
-       <property name="minimum">
-        <number>-180</number>
-       </property>
-       <property name="maximum">
-        <number>180</number>
-       </property>
-      </widget>
-     </item>
-     <item row="2" column="0" colspan="2">
-      <widget class="QSlider" name="rotationSlider">
-       <property name="toolTip">
-        <string>Degrees of rotation for polygons</string>
-       </property>
-       <property name="minimum">
-        <number>-180</number>
-       </property>
-       <property name="maximum">
-        <number>180</number>
-       </property>
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="tickPosition">
-        <enum>QSlider::TicksBelow</enum>
-       </property>
-      </widget>
-     </item>
-     <item row="3" column="0">
-      <widget class="QLabel" name="label_4">
-       <property name="text">
-        <string>Inner Rotation:</string>
-       </property>
-      </widget>
-     </item>
-     <item row="3" column="1">
-      <widget class="QSpinBox" name="innerRotationspinBox">
-       <property name="minimum">
-        <number>-180</number>
-       </property>
-       <property name="maximum">
-        <number>180</number>
-       </property>
-      </widget>
-     </item>
-     <item row="4" column="0" colspan="2">
-      <widget class="QSlider" name="innerRotationSlider">
-       <property name="minimum">
-        <number>-180</number>
-       </property>
-       <property name="maximum">
-        <number>180</number>
-       </property>
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="tickPosition">
-        <enum>QSlider::TicksBelow</enum>
-       </property>
+        <string>Apply Convex/Concave Factor to change shape of Polygons</string>
+       </property>
+       <property name="title">
+        <string>Apply &amp;Factor</string>
+       </property>
+       <property name="checkable">
+        <bool>true</bool>
+       </property>
+       <layout class="QGridLayout" name="gridLayout_2">
+        <item row="0" column="0">
+         <widget class="QLabel" name="label_3">
+          <property name="text">
+           <string>&amp;Factor:</string>
+          </property>
+          <property name="buddy">
+           <cstring>factorSpinBox</cstring>
+          </property>
+         </widget>
+        </item>
+        <item row="0" column="1">
+         <widget class="QSpinBox" name="factorSpinBox">
+          <property name="toolTip">
+           <string>A negative value will make the polygon concave (or star shaped), a positive value will make it convex</string>
+          </property>
+          <property name="suffix">
+           <string> %</string>
+          </property>
+          <property name="minimum">
+           <number>-100</number>
+          </property>
+          <property name="maximum">
+           <number>100</number>
+          </property>
+         </widget>
+        </item>
+        <item row="1" column="0" colspan="2">
+         <widget class="QSlider" name="factorSlider">
+          <property name="toolTip">
+           <string>A negative value will make the polygon concave (or star shaped), a positive value will make it convex</string>
+          </property>
+          <property name="minimum">
+           <number>-100</number>
+          </property>
+          <property name="maximum">
+           <number>100</number>
+          </property>
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="tickPosition">
+           <enum>QSlider::TicksBelow</enum>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="0">
+         <widget class="QLabel" name="label_5">
+          <property name="text">
+           <string>Inner C&amp;urvature:</string>
+          </property>
+          <property name="buddy">
+           <cstring>curvatureSpinBox</cstring>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="1">
+         <widget class="QSpinBox" name="curvatureSpinBox">
+          <property name="suffix">
+           <string> %</string>
+          </property>
+          <property name="maximum">
+           <number>100</number>
+          </property>
+         </widget>
+        </item>
+        <item row="3" column="0" colspan="2">
+         <widget class="QSlider" name="curvatureSlider">
+          <property name="maximum">
+           <number>100</number>
+          </property>
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="tickPosition">
+           <enum>QSlider::TicksBelow</enum>
+          </property>
+         </widget>
+        </item>
+        <item row="4" column="0">
+         <widget class="QLabel" name="label_6">
+          <property name="text">
+           <string>Outer Curvature:</string>
+          </property>
+         </widget>
+        </item>
+        <item row="4" column="1">
+         <widget class="QSpinBox" name="OuterCurvatureSpinBox">
+          <property name="suffix">
+           <string> %</string>
+          </property>
+          <property name="maximum">
+           <number>100</number>
+          </property>
+         </widget>
+        </item>
+        <item row="5" column="0" colspan="2">
+         <widget class="QSlider" name="OuterCurvatureSlider">
+          <property name="maximum">
+           <number>100</number>
+          </property>
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="tickPosition">
+           <enum>QSlider::TicksBelow</enum>
+          </property>
+         </widget>
+        </item>
+       </layout>
       </widget>
      </item>
     </layout>
    </item>
-   <item row="0" column="1" rowspan="2">
-    <widget class="QLabel" name="Preview">
-     <property name="sizePolicy">
-      <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
-       <horstretch>0</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
-     </property>
-     <property name="minimumSize">
-      <size>
-       <width>280</width>
-       <height>280</height>
-      </size>
-     </property>
-     <property name="maximumSize">
-      <size>
-       <width>280</width>
-       <height>280</height>
-      </size>
-     </property>
-     <property name="sizeIncrement">
-      <size>
-       <width>0</width>
-       <height>0</height>
-      </size>
-     </property>
-     <property name="toolTip">
-      <string>Sample Polygon</string>
-     </property>
-     <property name="frameShape">
-      <enum>QFrame::Panel</enum>
-     </property>
-     <property name="frameShadow">
-      <enum>QFrame::Sunken</enum>
-     </property>
-     <property name="lineWidth">
-      <number>2</number>
-     </property>
-     <property name="text">
-      <string/>
-     </property>
-     <property name="alignment">
-      <set>Qt::AlignCenter</set>
-     </property>
-    </widget>
-   </item>
-   <item row="1" column="0">
-    <widget class="QGroupBox" name="applyConvexGroupBox">
-     <property name="toolTip">
-      <string>Apply Convex/Concave Factor to change shape of Polygons</string>
-     </property>
-     <property name="title">
-      <string>Apply &amp;Factor</string>
-     </property>
-     <property name="checkable">
-      <bool>true</bool>
-     </property>
-     <layout class="QGridLayout" name="gridLayout_2">
-      <property name="margin">
-       <number>10</number>
-      </property>
-      <property name="spacing">
-       <number>5</number>
-      </property>
-      <item row="0" column="0">
-       <widget class="QLabel" name="label_3">
-        <property name="text">
-         <string>&amp;Factor:</string>
-        </property>
-        <property name="buddy">
-         <cstring>factorSpinBox</cstring>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="1">
-       <widget class="QSpinBox" name="factorSpinBox">
-        <property name="toolTip">
-         <string>A negative value will make the polygon concave (or star shaped), a positive value will make it convex</string>
-        </property>
-        <property name="suffix">
-         <string> %</string>
-        </property>
-        <property name="minimum">
-         <number>-100</number>
-        </property>
-        <property name="maximum">
-         <number>100</number>
-        </property>
-       </widget>
-      </item>
-      <item row="1" column="0" colspan="2">
-       <widget class="QSlider" name="factorSlider">
-        <property name="toolTip">
-         <string>A negative value will make the polygon concave (or star shaped), a positive value will make it convex</string>
-        </property>
-        <property name="minimum">
-         <number>-100</number>
-        </property>
-        <property name="maximum">
-         <number>100</number>
-        </property>
-        <property name="orientation">
-         <enum>Qt::Horizontal</enum>
-        </property>
-        <property name="tickPosition">
-         <enum>QSlider::TicksBelow</enum>
-        </property>
-       </widget>
-      </item>
-      <item row="2" column="0">
-       <widget class="QLabel" name="label_5">
-        <property name="text">
-         <string>C&amp;urvature:</string>
-        </property>
-        <property name="buddy">
-         <cstring>curvatureSpinBox</cstring>
-        </property>
-       </widget>
-      </item>
-      <item row="2" column="1">
-       <widget class="QSpinBox" name="curvatureSpinBox">
-        <property name="suffix">
-         <string> %</string>
-        </property>
-        <property name="maximum">
-         <number>100</number>
-        </property>
-       </widget>
-      </item>
-      <item row="3" column="0" colspan="2">
-       <widget class="QSlider" name="curvatureSlider">
-        <property name="maximum">
-         <number>100</number>
-        </property>
-        <property name="orientation">
-         <enum>Qt::Horizontal</enum>
-        </property>
-        <property name="tickPosition">
-         <enum>QSlider::TicksBelow</enum>
-        </property>
-       </widget>
-      </item>
-     </layout>
-    </widget>
+   <item>
+    <layout class="QVBoxLayout" name="verticalLayout_2">
+     <item>
+      <widget class="QLabel" name="Preview">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="minimumSize">
+        <size>
+         <width>280</width>
+         <height>280</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>280</width>
+         <height>280</height>
+        </size>
+       </property>
+       <property name="sizeIncrement">
+        <size>
+         <width>0</width>
+         <height>0</height>
+        </size>
+       </property>
+       <property name="toolTip">
+        <string>Sample Polygon</string>
+       </property>
+       <property name="frameShape">
+        <enum>QFrame::Panel</enum>
+       </property>
+       <property name="frameShadow">
+        <enum>QFrame::Sunken</enum>
+       </property>
+       <property name="lineWidth">
+        <number>2</number>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+       <property name="alignment">
+        <set>Qt::AlignCenter</set>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="verticalSpacer">
+       <property name="orientation">
+        <enum>Qt::Vertical</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>20</width>
+         <height>40</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
    </item>
   </layout>
  </widget>

Modified: trunk/Scribus/scribus/ui/polyprops.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16203&path=/trunk/Scribus/scribus/ui/polyprops.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/polyprops.cpp (original)
+++ trunk/Scribus/scribus/ui/polyprops.cpp Sun Jan  2 17:26:30 2011
@@ -14,7 +14,7 @@
 #include "commonstrings.h"
 #include "util_icon.h"
 
-PolygonProps::PolygonProps(QWidget* parent, int polyC, int polyFd, double polyF, bool polyS, double polyR, double polyCurvature, double polyInnerRot) : QDialog( parent )
+PolygonProps::PolygonProps(QWidget* parent, int polyC, int polyFd, double polyF, bool polyS, double polyR, double polyCurvature, double polyInnerRot, double polyOuterCurvature) : QDialog( parent )
 {
 	setModal(true);
 	setWindowTitle( tr( "Polygon Properties" ) );
@@ -22,7 +22,7 @@
 	PolygonPropsLayout = new QVBoxLayout( this );
 	PolygonPropsLayout->setMargin(10);
 	PolygonPropsLayout->setSpacing(5);
-	polyWidget = new PolygonWidget(this, polyC, polyFd, polyF, polyS, polyR, polyCurvature, polyInnerRot);
+	polyWidget = new PolygonWidget(this, polyC, polyFd, polyF, polyS, polyR, polyCurvature, polyInnerRot, polyOuterCurvature);
 	PolygonPropsLayout->addWidget( polyWidget );
 	Layout1 = new QHBoxLayout;
 	Layout1->setMargin(0);
@@ -42,7 +42,7 @@
 	connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
 }
 
-void PolygonProps::getValues(int* polyC, int* polyFd, double* polyF, bool* polyS, double* polyR, double* polyCurvature, double* polyInnerRot)
+void PolygonProps::getValues(int* polyC, int* polyFd, double* polyF, bool* polyS, double* polyR, double* polyCurvature, double* polyInnerRot, double* polyOuterCurvature)
 {
-	polyWidget->getValues(polyC, polyFd, polyF, polyS, polyR, polyCurvature, polyInnerRot);
+	polyWidget->getValues(polyC, polyFd, polyF, polyS, polyR, polyCurvature, polyInnerRot, polyOuterCurvature);
 }

Modified: trunk/Scribus/scribus/ui/polyprops.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16203&path=/trunk/Scribus/scribus/ui/polyprops.h
==============================================================================
--- trunk/Scribus/scribus/ui/polyprops.h (original)
+++ trunk/Scribus/scribus/ui/polyprops.h Sun Jan  2 17:26:30 2011
@@ -20,9 +20,9 @@
 	Q_OBJECT
 
 public:
-	PolygonProps(QWidget* parent, int polyC, int polyFd, double polyF, bool polyS, double polyR, double polyCurvature, double polyInnerRot);
+	PolygonProps(QWidget* parent, int polyC, int polyFd, double polyF, bool polyS, double polyR, double polyCurvature, double polyInnerRot, double polyOuterCurvature);
 	~PolygonProps() {};
-	void getValues(int* polyC, int* polyFd, double* polyF, bool* polyS, double* polyR, double* polyCurvature, double* polyInnerRot);
+	void getValues(int* polyC, int* polyFd, double* polyF, bool* polyS, double* polyR, double* polyCurvature, double* polyInnerRot, double* polyOuterCurvature);
 	PolygonWidget* polyWidget;
 	QPushButton* okButton;
 	QPushButton* cancelButton;

Modified: trunk/Scribus/scribus/ui/propertiespalette.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16203&path=/trunk/Scribus/scribus/ui/propertiespalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette.cpp Sun Jan  2 17:26:30 2011
@@ -4127,10 +4127,10 @@
 		if (CurItem->asRegularPolygon())
 		{
 			PageItem_RegularPolygon* item = CurItem->asRegularPolygon();
-			PolygonProps* dia = new PolygonProps(m_ScMW, item->polyCorners, item->polyFactorGuiVal, item->polyFactor, item->polyUseFactor, item->polyRotation, item->polyCurvature, item->polyInnerRot);
+			PolygonProps* dia = new PolygonProps(m_ScMW, item->polyCorners, item->polyFactorGuiVal, item->polyFactor, item->polyUseFactor, item->polyRotation, item->polyCurvature, item->polyInnerRot, item->polyOuterCurvature);
 			if (dia->exec())
 			{
-				dia->getValues(&item->polyCorners, &item->polyFactorGuiVal, &item->polyFactor, &item->polyUseFactor, &item->polyRotation, &item->polyCurvature, &item->polyInnerRot);
+				dia->getValues(&item->polyCorners, &item->polyFactorGuiVal, &item->polyFactor, &item->polyUseFactor, &item->polyRotation, &item->polyCurvature, &item->polyInnerRot, &item->polyOuterCurvature);
 				item->recalcPath();
 			}
 			delete dia;

Modified: trunk/Scribus/scribus/util_math.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16203&path=/trunk/Scribus/scribus/util_math.cpp
==============================================================================
--- trunk/Scribus/scribus/util_math.cpp (original)
+++ trunk/Scribus/scribus/util_math.cpp Sun Jan  2 17:26:30 2011
@@ -65,7 +65,7 @@
 	return ret;
 }
 
-QPainterPath RegularPolygonPath(double w, double h, uint c, bool star, double factor, double rota, double factor2, double innerRot)
+QPainterPath RegularPolygonPath(double w, double h, uint c, bool star, double factor, double rota, double factor2, double innerRot, double factor3)
 {
 	uint cx = star ? c * 2 : c;
 	double seg = 360.0 / cx;
@@ -73,9 +73,10 @@
 	double di = factor;
 	double mx = 0;
 	double my = 0;
-	bool first = true;
 	double trueLength = sqrt(pow(sin(seg / 180.0 * M_PI) * (w / 2.0), 2) + pow(cos(seg / 180.0 * M_PI) * (h / 2.0) + (h/2.0) - h, 2));
 	QPainterPath pts;
+	// calculate corner Points first
+	QList<QPointF> cornerPoints;
 	for (uint x = 0; x < cx; ++x)
 	{
 		sc = seg * x + 180.0 + rota;
@@ -91,53 +92,72 @@
 			}
 			mx = sin(sc / 180.0 * M_PI) * (wf) + (w/2.0);
 			my = cos(sc / 180.0 * M_PI) * (hf) + (h/2.0);
-			if (first)
-				pts.moveTo(mx, my);
-			else
-			{
-				if (factor2 != 0.0)
-				{
-					if (x % 2 != 0)
-					{
-						QPointF curr = pts.currentPosition();
-						double mxc = sin((sc + 90.0) / 180.0 * M_PI) * (-trueLength * factor2) + mx;
-						double myc = cos((sc + 90.0) / 180.0 * M_PI) * (-trueLength * factor2) + my;
-						pts.cubicTo(curr, QPointF(mxc, myc), QPointF(mx, my));
-					}
-					else
-					{
-						QPointF curr = pts.currentPosition();
-						double mxc = sin((sc - seg + 90.0) / 180.0 * M_PI) * (trueLength * factor2) + curr.x();
-						double myc = cos((sc - seg + 90.0) / 180.0 * M_PI) * (trueLength * factor2) + curr.y();
-						pts.cubicTo(QPointF(mxc, myc), QPointF(mx, my), QPointF(mx, my));
-					}
-				}
-				else
-					pts.lineTo(mx, my);
-			}
 		}
 		else
 		{
 			mx = sin(sc / 180.0 * M_PI) * (w/2.0) + (w/2.0);
 			my = cos(sc / 180.0 * M_PI) * (h/2.0) + (h/2.0);
-			if (first)
-				pts.moveTo(mx, my);
+		}
+		cornerPoints.append(QPointF(mx, my));
+	}
+	// now calculate bezier control points if needed;
+	if (star)
+	{
+		pts.moveTo(cornerPoints[0]);
+		double mxc1, myc1, mxc2, myc2;
+		for (int a = 0; a < cornerPoints.count() - 2; a++)
+		{
+			sc = seg * a + 180.0 + rota;
+			if (a % 2 != 0)
+			{
+				// outer control point
+				QLineF oline = QLineF(cornerPoints[a+1], cornerPoints[a-1]);
+				mxc1 = oline.pointAt(factor3).x();
+				myc1 = oline.pointAt(factor3).y();
+				// inner control point
+				mxc2 = sin((sc + 90.0) / 180.0 * M_PI) * (trueLength * factor2) + cornerPoints[a].x();
+				myc2 = cos((sc + 90.0) / 180.0 * M_PI) * (trueLength * factor2) + cornerPoints[a].y();
+				pts.cubicTo(QPointF(mxc2, myc2), QPointF(mxc1, myc1), cornerPoints[a+1]);
+			}
 			else
-				pts.lineTo(mx, my);
-		}
-		first = false;
-	}
-	if ((star) && (factor2 != 0.0))
-	{
-		sc = 360.0 + 180.0 + rota;
-		mx = sin(sc / 180.0 * M_PI) * (w / 2.0) + (w/2.0);
-		my = cos(sc / 180.0 * M_PI) * (h / 2.0) + (h/2.0);
-		QPointF curr = pts.currentPosition();
-		double mxc = sin((sc - seg + 90.0) / 180.0 * M_PI) * (trueLength * factor2) + curr.x();
-		double myc = cos((sc - seg + 90.0) / 180.0 * M_PI) * (trueLength * factor2) + curr.y();
-		pts.cubicTo(QPointF(mxc, myc), QPointF(mx, my), QPointF(mx, my));
-	}
-	pts.closeSubpath();
+			{
+				// outer control point
+				QLineF oline = QLineF(cornerPoints[a], cornerPoints[a+2]);
+				mxc1 = oline.pointAt(factor3).x();
+				myc1 = oline.pointAt(factor3).y();
+				// inner control point
+				mxc2 = sin((sc - 90.0 + seg) / 180.0 * M_PI) * (trueLength * factor2) + cornerPoints[a+1].x();
+				myc2 = cos((sc - 90.0 + seg) / 180.0 * M_PI) * (trueLength * factor2) + cornerPoints[a+1].y();
+				pts.cubicTo(QPointF(mxc1, myc1), QPointF(mxc2, myc2), cornerPoints[a+1]);
+			}
+		}
+		// outer control point
+		QLineF oline = QLineF(cornerPoints[cornerPoints.count()-2], cornerPoints[0]);
+		mxc1 = oline.pointAt(factor3).x();
+		myc1 = oline.pointAt(factor3).y();
+		// inner control point
+		sc = seg * (cornerPoints.count()-1) + 180.0 + rota;
+		mxc2 = sin((sc - 90.0) / 180.0 * M_PI) * (trueLength * factor2) + cornerPoints[cornerPoints.count()-1].x();
+		myc2 = cos((sc - 90.0) / 180.0 * M_PI) * (trueLength * factor2) + cornerPoints[cornerPoints.count()-1].y();
+		pts.cubicTo(QPointF(mxc1, myc1), QPointF(mxc2, myc2), cornerPoints[cornerPoints.count()-1]);
+		oline = QLineF(cornerPoints[0], cornerPoints[cornerPoints.count()-2]);
+		mxc1 = oline.pointAt(factor3).x();
+		myc1 = oline.pointAt(factor3).y();
+		// inner control point
+		mxc2 = sin((sc + 90.0) / 180.0 * M_PI) * (trueLength * factor2) + cornerPoints[cornerPoints.count()-1].x();
+		myc2 = cos((sc + 90.0) / 180.0 * M_PI) * (trueLength * factor2) + cornerPoints[cornerPoints.count()-1].y();
+		pts.cubicTo(QPointF(mxc2, myc2), QPointF(mxc1, myc1), cornerPoints[0]);
+		pts.closeSubpath();
+	}
+	else
+	{
+		pts.moveTo(cornerPoints[0]);
+		for (int a = 1; a < cornerPoints.count(); a++)
+		{
+			pts.lineTo(cornerPoints[a]);
+		}
+		pts.closeSubpath();
+	}
 	return pts;
 }
 

Modified: trunk/Scribus/scribus/util_math.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16203&path=/trunk/Scribus/scribus/util_math.h
==============================================================================
--- trunk/Scribus/scribus/util_math.h (original)
+++ trunk/Scribus/scribus/util_math.h Sun Jan  2 17:26:30 2011
@@ -34,7 +34,7 @@
 FPoint SCRIBUS_API projectPointOnLine(FPoint p, QPointF lineStart, QPointF lineEnd);
 QPolygon SCRIBUS_API FlattenPath(const FPointArray& ina, QList<uint> &Segs);
 QList<QPainterPath> SCRIBUS_API decomposePath(QPainterPath &path);
-QPainterPath SCRIBUS_API RegularPolygonPath(double w, double h, uint c, bool star, double factor, double rota, double factor2 = 0.0, double innerRot = 0.0);
+QPainterPath SCRIBUS_API RegularPolygonPath(double w, double h, uint c, bool star, double factor, double rota, double factor2 = 0.0, double innerRot = 0.0, double factor3 = 0.0);
 uint SCRIBUS_API getDouble(QString in, bool raw);
 inline double SCRIBUS_API sind(double);
 inline double SCRIBUS_API cosd(double);




More information about the scribus-commit mailing list