r16891 by fschmid - More work on editing patch meshes, now you can snap points to other patches points.
scribus-commit
scribus-commit at lists.scribus.net
Sat Oct 8 10:33:04 UTC 2011
Author: fschmid
Date: Sat Oct 8 10:33:04 2011
New Revision: 16891
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=16891
Log:
More work on editing patch meshes, now you can snap points to other patches points.
Save only used patch points.
Modified:
trunk/Scribus/scribus/canvasmode_editmeshpatch.cpp
trunk/Scribus/scribus/canvasmode_editmeshpatch.h
trunk/Scribus/scribus/pageitem.cpp
trunk/Scribus/scribus/pageitem.h
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
trunk/Scribus/scribus/ui/cpalette.cpp
trunk/Scribus/scribus/ui/cpalette.h
trunk/Scribus/scribus/ui/gradientvectorbase.ui
trunk/Scribus/scribus/ui/gradientvectordialog.cpp
trunk/Scribus/scribus/ui/gradientvectordialog.h
Modified: trunk/Scribus/scribus/canvasmode_editmeshpatch.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16891&path=/trunk/Scribus/scribus/canvasmode_editmeshpatch.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editmeshpatch.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_editmeshpatch.cpp Sat Oct 8 10:33:04 2011
@@ -260,6 +260,8 @@
{
psx->setPen(p1bd);
psx->drawLine(m_clickPointPolygon.value(m_clickPointPolygon.count() - 1), m_currentPoint);
+ if (m_clickPointPolygon.size() == 3)
+ psx->drawLine(m_clickPointPolygon.value(0), m_currentPoint);
}
psx->setPen(p8r);
psx->drawPoint(m_currentPoint);
@@ -299,6 +301,7 @@
{
m_view->update();
}
+ currItem->snapToPatchGrid = false;
}
void CanvasMode_EditMeshPatch::deactivate(bool forGesture)
@@ -311,6 +314,7 @@
currItem->selectedMeshPointY = m_patchPoint;
currItem->selectedMeshControlPoint = m_gradientPoint;
m_ScMW->propertiesPalette->updateColorSpecialGradient();
+ currItem->snapToPatchGrid = false;
}
void CanvasMode_EditMeshPatch::keyPressEvent(QKeyEvent *e)
@@ -629,13 +633,41 @@
if (m_view->editStrokeGradient == 9)
{
if (m_patchPoint == useTL)
- currItem->meshGradientPatches[currItem->selectedMeshPointX].TL.moveRel(-npx.x(), -npx.y());
+ {
+ FPoint mp = currItem->meshGradientPatches[currItem->selectedMeshPointX].TL.gridPoint - npx;
+ double xx = mp.x();
+ double yy = mp.y();
+ if (currItem->snapToPatchGrid)
+ snapToOtherPatch(xx, yy);
+ currItem->meshGradientPatches[currItem->selectedMeshPointX].TL.moveAbs(xx, yy);
+ }
if (m_patchPoint == useTR)
- currItem->meshGradientPatches[currItem->selectedMeshPointX].TR.moveRel(-npx.x(), -npx.y());
+ {
+ FPoint mp = currItem->meshGradientPatches[currItem->selectedMeshPointX].TR.gridPoint - npx;
+ double xx = mp.x();
+ double yy = mp.y();
+ if (currItem->snapToPatchGrid)
+ snapToOtherPatch(xx, yy);
+ currItem->meshGradientPatches[currItem->selectedMeshPointX].TR.moveAbs(xx, yy);
+ }
if (m_patchPoint == useBR)
- currItem->meshGradientPatches[currItem->selectedMeshPointX].BR.moveRel(-npx.x(), -npx.y());
+ {
+ FPoint mp = currItem->meshGradientPatches[currItem->selectedMeshPointX].BR.gridPoint - npx;
+ double xx = mp.x();
+ double yy = mp.y();
+ if (currItem->snapToPatchGrid)
+ snapToOtherPatch(xx, yy);
+ currItem->meshGradientPatches[currItem->selectedMeshPointX].BR.moveAbs(xx, yy);
+ }
if (m_patchPoint == useBL)
- currItem->meshGradientPatches[currItem->selectedMeshPointX].BL.moveRel(-npx.x(), -npx.y());
+ {
+ FPoint mp = currItem->meshGradientPatches[currItem->selectedMeshPointX].BL.gridPoint - npx;
+ double xx = mp.x();
+ double yy = mp.y();
+ if (currItem->snapToPatchGrid)
+ snapToOtherPatch(xx, yy);
+ currItem->meshGradientPatches[currItem->selectedMeshPointX].BL.moveAbs(xx, yy);
+ }
}
}
else if (m_view->editStrokeGradient == 10)
@@ -906,3 +938,43 @@
upRect.translate(currItem->xPos(), currItem->yPos());
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_EditMeshPatch::snapToOtherPatch(double &x, double &y)
+{
+ int radius = m_doc->guidesPrefs().grabRadius;
+ for (int col = 0; col < currItem->meshGradientPatches.count(); col++)
+ {
+ if (col != currItem->selectedMeshPointX)
+ {
+ meshGradientPatch patch = currItem->meshGradientPatches[col];
+ QPointF mp1 = QPointF(patch.TL.gridPoint.x(), patch.TL.gridPoint.y());
+ QPointF mp2 = QPointF(patch.TR.gridPoint.x(), patch.TR.gridPoint.y());
+ QPointF mp3 = QPointF(patch.BR.gridPoint.x(), patch.BR.gridPoint.y());
+ QPointF mp4 = QPointF(patch.BL.gridPoint.x(), patch.BL.gridPoint.y());
+ if (qAbs(mp1.x() - x) < radius && qAbs(mp1.y() - y) < radius)
+ {
+ x = mp1.x();
+ y = mp1.y();
+ return;
+ }
+ if (qAbs(mp2.x() - x) < radius && qAbs(mp2.y() - y) < radius)
+ {
+ x = mp2.x();
+ y = mp2.y();
+ return;
+ }
+ if (qAbs(mp3.x() - x) < radius && qAbs(mp3.y() - y) < radius)
+ {
+ x = mp3.x();
+ y = mp3.y();
+ return;
+ }
+ if (qAbs(mp4.x() - x) < radius && qAbs(mp4.y() - y) < radius)
+ {
+ x = mp4.x();
+ y = mp4.y();
+ return;
+ }
+ }
+ }
+}
Modified: trunk/Scribus/scribus/canvasmode_editmeshpatch.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16891&path=/trunk/Scribus/scribus/canvasmode_editmeshpatch.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editmeshpatch.h (original)
+++ trunk/Scribus/scribus/canvasmode_editmeshpatch.h Sat Oct 8 10:33:04 2011
@@ -61,7 +61,7 @@
void drawControlsMeshPatch(QPainter* pp, PageItem* currItem);
private:
-
+ void snapToOtherPatch(double &x, double &y);
typedef enum
{
noPointDefined,
Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16891&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Sat Oct 8 10:33:04 2011
@@ -122,6 +122,7 @@
selectedMeshPointX(other.selectedMeshPointX),
selectedMeshPointY(other.selectedMeshPointY),
selectedMeshControlPoint(other.selectedMeshControlPoint),
+ snapToPatchGrid(other.snapToPatchGrid),
Cols(other.Cols),
ColGap(other.ColGap),
PLineArt(other.PLineArt),
@@ -2864,29 +2865,68 @@
switch (y)
{
case 1:
+ mp = meshGradientPatches[x].TL;
meshGradientPatches[x].TL.colorName = MColor;
meshGradientPatches[x].TL.color = MQColor;
meshGradientPatches[x].TL.shade = shade;
meshGradientPatches[x].TL.transparency = transparency;
break;
case 2:
+ mp = meshGradientPatches[x].TR;
meshGradientPatches[x].TR.colorName = MColor;
meshGradientPatches[x].TR.color = MQColor;
meshGradientPatches[x].TR.shade = shade;
meshGradientPatches[x].TR.transparency = transparency;
break;
case 3:
+ mp = meshGradientPatches[x].BR;
meshGradientPatches[x].BR.colorName = MColor;
meshGradientPatches[x].BR.color = MQColor;
meshGradientPatches[x].BR.shade = shade;
meshGradientPatches[x].BR.transparency = transparency;
break;
case 4:
+ mp = meshGradientPatches[x].BL;
meshGradientPatches[x].BL.colorName = MColor;
meshGradientPatches[x].BL.color = MQColor;
meshGradientPatches[x].BL.shade = shade;
meshGradientPatches[x].BL.transparency = transparency;
break;
+ }
+ FPoint xx = mp.gridPoint;
+ for (int col = 0; col < meshGradientPatches.count(); col++)
+ {
+ if (col != x)
+ {
+ if (meshGradientPatches[col].TL.gridPoint == xx)
+ {
+ meshGradientPatches[col].TL.colorName = MColor;
+ meshGradientPatches[col].TL.color = MQColor;
+ meshGradientPatches[col].TL.shade = shade;
+ meshGradientPatches[col].TL.transparency = transparency;
+ }
+ if (meshGradientPatches[col].TR.gridPoint == xx)
+ {
+ meshGradientPatches[col].TR.colorName = MColor;
+ meshGradientPatches[col].TR.color = MQColor;
+ meshGradientPatches[col].TR.shade = shade;
+ meshGradientPatches[col].TR.transparency = transparency;
+ }
+ if (meshGradientPatches[col].BR.gridPoint == xx)
+ {
+ meshGradientPatches[col].BR.colorName = MColor;
+ meshGradientPatches[col].BR.color = MQColor;
+ meshGradientPatches[col].BR.shade = shade;
+ meshGradientPatches[col].BR.transparency = transparency;
+ }
+ if (meshGradientPatches[col].BL.gridPoint == xx)
+ {
+ meshGradientPatches[col].BL.colorName = MColor;
+ meshGradientPatches[col].BL.color = MQColor;
+ meshGradientPatches[col].BL.shade = shade;
+ meshGradientPatches[col].BL.transparency = transparency;
+ }
+ }
}
}
Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16891&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h (original)
+++ trunk/Scribus/scribus/pageitem.h Sat Oct 8 10:33:04 2011
@@ -415,6 +415,7 @@
int selectedMeshPointX;
int selectedMeshPointY;
int selectedMeshControlPoint;
+ bool snapToPatchGrid;
int Cols;
double ColGap;
double gridOffset_;
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16891&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 Sat Oct 8 10:33:04 2011
@@ -2720,10 +2720,10 @@
mp.shade = tAtt.valueAsInt("SHADE", 100);
mp.transparency = tAtt.valueAsDouble("TRANS", 1.0);
mp.gridPoint = FPoint(tAtt.valueAsDouble("GX", 0.0), tAtt.valueAsDouble("GY", 0.0));
- mp.controlTop = FPoint(tAtt.valueAsDouble("CTX", 0.0), tAtt.valueAsDouble("CTY", 0.0));
- mp.controlBottom = FPoint(tAtt.valueAsDouble("CBX", 0.0), tAtt.valueAsDouble("CBY", 0.0));
- mp.controlLeft = FPoint(tAtt.valueAsDouble("CLX", 0.0), tAtt.valueAsDouble("CLY", 0.0));
- mp.controlRight = FPoint(tAtt.valueAsDouble("CRX", 0.0), tAtt.valueAsDouble("CRY", 0.0));
+ mp.controlTop = FPoint(tAtt.valueAsDouble("CTX", mp.gridPoint.x()), tAtt.valueAsDouble("CTY", mp.gridPoint.y()));
+ mp.controlBottom = FPoint(tAtt.valueAsDouble("CBX", mp.gridPoint.x()), tAtt.valueAsDouble("CBY", mp.gridPoint.y()));
+ mp.controlLeft = FPoint(tAtt.valueAsDouble("CLX", mp.gridPoint.x()), tAtt.valueAsDouble("CLY", mp.gridPoint.y()));
+ mp.controlRight = FPoint(tAtt.valueAsDouble("CRX", mp.gridPoint.x()), tAtt.valueAsDouble("CRY", mp.gridPoint.y()));
mp.controlColor = FPoint(tAtt.valueAsDouble("CCX", mp.gridPoint.x()), tAtt.valueAsDouble("CCY", mp.gridPoint.y()));
mp.color = SetColor(doc, mp.colorName, mp.shade);
mp.color.setAlphaF(mp.transparency);
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16891&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp Sat Oct 8 10:33:04 2011
@@ -1635,25 +1635,41 @@
for (int gcol = 0; gcol < 4; gcol++)
{
meshPoint mp;
+ docu.writeStartElement("PMPoint");
if (gcol == 0)
+ {
mp = patch.TL;
+ docu.writeAttribute("CBX", mp.controlBottom.x());
+ docu.writeAttribute("CBY", mp.controlBottom.y());
+ docu.writeAttribute("CRX", mp.controlRight.x());
+ docu.writeAttribute("CRY", mp.controlRight.y());
+ }
else if (gcol == 1)
+ {
mp = patch.TR;
+ docu.writeAttribute("CBX", mp.controlBottom.x());
+ docu.writeAttribute("CBY", mp.controlBottom.y());
+ docu.writeAttribute("CLX", mp.controlLeft.x());
+ docu.writeAttribute("CLY", mp.controlLeft.y());
+ }
else if (gcol == 2)
+ {
mp = patch.BR;
+ docu.writeAttribute("CTX", mp.controlTop.x());
+ docu.writeAttribute("CTY", mp.controlTop.y());
+ docu.writeAttribute("CLX", mp.controlLeft.x());
+ docu.writeAttribute("CLY", mp.controlLeft.y());
+ }
else if (gcol == 3)
+ {
mp = patch.BL;
- docu.writeStartElement("PMPoint");
+ docu.writeAttribute("CTX", mp.controlTop.x());
+ docu.writeAttribute("CTY", mp.controlTop.y());
+ docu.writeAttribute("CRX", mp.controlRight.x());
+ docu.writeAttribute("CRY", mp.controlRight.y());
+ }
docu.writeAttribute("GX", mp.gridPoint.x());
docu.writeAttribute("GY", mp.gridPoint.y());
- docu.writeAttribute("CTX", mp.controlTop.x());
- docu.writeAttribute("CTY", mp.controlTop.y());
- docu.writeAttribute("CBX", mp.controlBottom.x());
- docu.writeAttribute("CBY", mp.controlBottom.y());
- docu.writeAttribute("CLX", mp.controlLeft.x());
- docu.writeAttribute("CLY", mp.controlLeft.y());
- docu.writeAttribute("CRX", mp.controlRight.x());
- docu.writeAttribute("CRY", mp.controlRight.y());
docu.writeAttribute("CCX", mp.controlColor.x());
docu.writeAttribute("CCY", mp.controlColor.y());
docu.writeAttribute("NAME", mp.colorName);
Modified: trunk/Scribus/scribus/ui/cpalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16891&path=/trunk/Scribus/scribus/ui/cpalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/cpalette.cpp (original)
+++ trunk/Scribus/scribus/ui/cpalette.cpp Sat Oct 8 10:33:04 2011
@@ -113,6 +113,7 @@
connect(CGradDia, SIGNAL(reset1Control()), this, SLOT(resetOneControlPoint()));
connect(CGradDia, SIGNAL(resetAllControl()), this, SLOT(resetAllControlPoints()));
connect(CGradDia, SIGNAL(removePatch()), this, SLOT(handleRemovePatch()));
+ connect(CGradDia, SIGNAL(snapToMGrid(bool)), this, SLOT(snapToPatchGrid(bool)));
connect(gradientType, SIGNAL(activated(int)), this, SLOT(slotGradType(int)));
connect(gradEdit, SIGNAL(gradientChanged()) , this, SLOT(handleFillGradient()));
connect(editPatternProps, SIGNAL(clicked()) , this, SLOT(changePatternProps()));
@@ -1397,6 +1398,11 @@
CGradDia->endPAddButton();
}
+void Cpalette::snapToPatchGrid(bool val)
+{
+ currentItem->snapToPatchGrid = val;
+}
+
void Cpalette::handleRemovePatch()
{
if ((currentItem->selectedMeshPointX > -1) && (currentItem->meshGradientPatches.count() > 1))
Modified: trunk/Scribus/scribus/ui/cpalette.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16891&path=/trunk/Scribus/scribus/ui/cpalette.h
==============================================================================
--- trunk/Scribus/scribus/ui/cpalette.h (original)
+++ trunk/Scribus/scribus/ui/cpalette.h Sat Oct 8 10:33:04 2011
@@ -119,6 +119,7 @@
void setSpecialGradient(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk, double cx, double cy);
void setMeshPoint();
void endPatchAdd();
+ void snapToPatchGrid(bool val);
void handleRemovePatch();
void setMeshPatch();
void setMeshPatchPoint();
Modified: trunk/Scribus/scribus/ui/gradientvectorbase.ui
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16891&path=/trunk/Scribus/scribus/ui/gradientvectorbase.ui
==============================================================================
--- trunk/Scribus/scribus/ui/gradientvectorbase.ui (original)
+++ trunk/Scribus/scribus/ui/gradientvectorbase.ui Sat Oct 8 10:33:04 2011
@@ -872,6 +872,13 @@
</layout>
</item>
<item>
+ <widget class="QCheckBox" name="snapToGrid">
+ <property name="text">
+ <string>Snap to other Mesh Points</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QPushButton" name="buttonAddPatch">
Modified: trunk/Scribus/scribus/ui/gradientvectordialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16891&path=/trunk/Scribus/scribus/ui/gradientvectordialog.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/gradientvectordialog.cpp (original)
+++ trunk/Scribus/scribus/ui/gradientvectordialog.cpp Sat Oct 8 10:33:04 2011
@@ -77,6 +77,7 @@
connect(buttonRemovePatch, SIGNAL(clicked()), this, SIGNAL(removePatch()));
connect(resetPControlPoint, SIGNAL(clicked()), this, SIGNAL(reset1Control()));
connect(resetAllPControlPoints, SIGNAL(clicked()), this, SIGNAL(resetAllControl()));
+ connect(snapToGrid, SIGNAL(clicked()), this, SLOT(handleSnapToGridBox()));
QSize iconSize = QSize(22, 22);
editPoints->setIcon(QIcon(loadIcon("MoveNode.png")));
editPoints->setIconSize(iconSize);
@@ -153,6 +154,8 @@
{
stackedWidget->setCurrentIndex(5);
editPPoint->setChecked(true);
+ snapToGrid->setChecked(false);
+ snapToGrid->setEnabled(true);
resize(minimumSizeHint());
}
@@ -186,6 +189,7 @@
{
if (editPPoint->isChecked())
{
+ snapToGrid->setEnabled(true);
resetAllPControlPoints->setEnabled(false);
resetPControlPoint->setEnabled(false);
emit editGradient(9);
@@ -196,10 +200,16 @@
{
if (editPControlPoints->isChecked())
{
+ snapToGrid->setEnabled(false);
resetAllPControlPoints->setEnabled(true);
resetPControlPoint->setEnabled(true);
emit editGradient(10);
}
+}
+
+void GradientVectorDialog::handleSnapToGridBox()
+{
+ emit snapToMGrid(snapToGrid->isChecked());
}
void GradientVectorDialog::handlePAddButton()
Modified: trunk/Scribus/scribus/ui/gradientvectordialog.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16891&path=/trunk/Scribus/scribus/ui/gradientvectordialog.h
==============================================================================
--- trunk/Scribus/scribus/ui/gradientvectordialog.h (original)
+++ trunk/Scribus/scribus/ui/gradientvectordialog.h Sat Oct 8 10:33:04 2011
@@ -60,6 +60,7 @@
void handlePEditButton();
void handlePEditControlButton();
void handlePAddButton();
+ void handleSnapToGridBox();
void endPAddButton();
void changebuttonRemovePatch(bool val);
void setValues(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk, double cx, double cy);
@@ -78,6 +79,7 @@
void reset1Control();
void resetAllControl();
void removePatch();
+ void snapToMGrid(bool);
};
#endif
More information about the scribus-commit
mailing list