r18935 by fschmid - Implemented "real" hatching, gives much better quality than the previous solution with patterns.
scribus-commit
scribus-commit at lists.scribus.net
Sun Mar 23 07:24:17 UTC 2014
Author: fschmid
Date: Sun Mar 23 07:24:17 2014
New Revision: 18935
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18935
Log:
Implemented "real" hatching, gives much better quality than the previous solution with patterns.
Modified:
trunk/Scribus/scribus/pageitem.cpp
trunk/Scribus/scribus/pageitem.h
trunk/Scribus/scribus/pdflib_core.cpp
trunk/Scribus/scribus/pdflib_core.h
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
trunk/Scribus/scribus/plugins/import/odg/importodg.cpp
trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp
trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.h
trunk/Scribus/scribus/plugins/xpsexport/xpsexplugin.cpp
trunk/Scribus/scribus/plugins/xpsexport/xpsexplugin.h
trunk/Scribus/scribus/pslib.cpp
trunk/Scribus/scribus/pslib.h
trunk/Scribus/scribus/scpainter.cpp
trunk/Scribus/scribus/scpainter.h
trunk/Scribus/scribus/ui/colorpalette.ui
trunk/Scribus/scribus/ui/cpalette.cpp
trunk/Scribus/scribus/ui/cpalette.h
Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18935&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Sun Mar 23 07:24:17 2014
@@ -285,6 +285,12 @@
patternMaskMirrorY(other.patternMaskMirrorY),
patternMaskVal(other.patternMaskVal),
mask_gradient(other.mask_gradient),
+ hatchAngle(other.hatchAngle),
+ hatchDistance(other.hatchDistance),
+ hatchType(other.hatchType),
+ hatchUseBackground(other.hatchUseBackground),
+ hatchBackground(other.hatchBackground),
+ hatchForeground(other.hatchForeground),
// protected
undoManager(other.undoManager),
BackBox(NULL), // otherwise other.BackBox->NextBox would be inconsistent
@@ -344,7 +350,9 @@
m_imageRotation(other.m_imageRotation),
m_isReversed(other.m_isReversed),
firstLineOffsetP(other.firstLineOffsetP),
- m_groupClips(other.m_groupClips)
+ m_groupClips(other.m_groupClips),
+ hatchBackgroundQ(other.hatchBackgroundQ),
+ hatchForegroundQ(other.hatchForegroundQ)
{
QString tmp;
m_Doc->TotalItems++;
@@ -846,6 +854,14 @@
m_softShadowOpacity = 0.0;
m_softShadowBlendMode = 0;
m_groupClips = true;
+ hatchAngle = 0;
+ hatchDistance = 2;
+ hatchType = 0;
+ hatchUseBackground = false;
+ hatchBackground = CommonStrings::None;
+ hatchBackgroundQ = QColor();
+ hatchForeground = "Black";
+ hatchForegroundQ = qcol;
}
PageItem::~PageItem()
@@ -1721,6 +1737,13 @@
FPoint pG4 = FPoint(0, height());
p->set4ColorGeometry(pG1, pG2, pG3, pG4, GrControl1, GrControl2, GrControl3, GrControl4);
p->set4ColorColors(GrColorP1QColor, GrColorP2QColor, GrColorP3QColor, GrColorP4QColor);
+ }
+ else if (GrType == 14)
+ {
+ if (fillColor() != CommonStrings::None)
+ p->setBrush(fillQColor);
+ p->setFillMode(ScPainter::Hatch);
+ p->setHatchParameters(hatchType, hatchDistance, hatchAngle, hatchUseBackground, hatchBackgroundQ, hatchForegroundQ, width(), height());
}
else
{
@@ -4158,6 +4181,46 @@
{
VisionDefectColor defect;
fillQColor = defect.convertDefect(fillQColor, m_Doc->previewVisual);
+ }
+}
+
+void PageItem::setHatchParameters(int mode, double distance, double angle, bool useBackground, QString background, QString foreground)
+{
+ hatchType = mode;
+ hatchDistance = distance;
+ hatchAngle = angle;
+ hatchUseBackground = useBackground;
+ hatchBackground = background;
+ hatchForeground = foreground;
+ if (background != CommonStrings::None)
+ {
+ if (!m_Doc->PageColors.contains(background))
+ hatchBackgroundQ = QColor();
+ else
+ {
+ const ScColor& col = m_Doc->PageColors[background];
+ hatchBackgroundQ = ScColorEngine::getShadeColorProof(col, m_Doc, 100);
+ if (m_Doc->viewAsPreview)
+ {
+ VisionDefectColor defect;
+ hatchBackgroundQ = defect.convertDefect(hatchBackgroundQ, m_Doc->previewVisual);
+ }
+ }
+ }
+ if (foreground != CommonStrings::None)
+ {
+ if (!m_Doc->PageColors.contains(foreground))
+ hatchForegroundQ = QColor();
+ else
+ {
+ const ScColor& col = m_Doc->PageColors[foreground];
+ hatchForegroundQ = ScColorEngine::getShadeColorProof(col, m_Doc, 100);
+ if (m_Doc->viewAsPreview)
+ {
+ VisionDefectColor defect;
+ hatchForegroundQ = defect.convertDefect(hatchForegroundQ, m_Doc->previewVisual);
+ }
+ }
}
}
Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18935&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h (original)
+++ trunk/Scribus/scribus/pageitem.h Sun Mar 23 07:24:17 2014
@@ -844,6 +844,8 @@
*/
void setLineTransparency(double newTransparency);
+ void setHatchParameters(int mode, double distance, double angle, bool useBackground, QString background, QString foreground);
+
/** @brief Get the name of the stroke pattern of the object */
QString strokePattern() const { return patternStrokeVal; }
@@ -1187,7 +1189,7 @@
double gYpos;
double gWidth;
double gHeight;
- int GrType; ///< used values 6 = linear, 7 = radial, 8 = pattern, 9 = 4 color gradient, 10 = diamond, 11 = mesh gradient
+ int GrType; ///< used values 6 = linear, 7 = radial, 8 = pattern, 9 = 4 color gradient, 10 = diamond, 11,12,13 = mesh gradient, 14 = hatch
double GrStartX;
double GrStartY;
double GrEndX;
@@ -1429,6 +1431,12 @@
int weldID;
};
QList<weldingInfo> weldList;
+ double hatchAngle;
+ double hatchDistance;
+ int hatchType; // 0 = single 1 = double 2 = triple
+ bool hatchUseBackground;
+ QString hatchBackground;
+ QString hatchForeground;
// End public variables
@@ -1773,6 +1781,8 @@
bool m_isReversed; ///< Is the frame is reversed?
FirstLineOffsetPolicy firstLineOffsetP;
bool m_groupClips;
+ QColor hatchBackgroundQ;
+ QColor hatchForegroundQ;
// End protected variables
Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18935&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp (original)
+++ trunk/Scribus/scribus/pdflib_core.cpp Sun Mar 23 07:24:17 2014
@@ -2127,15 +2127,27 @@
if (!PDF_PatternFillStroke(tmpOut, ite))
return false;
}
+ else if (ite->GrType == 14)
+ {
+ if (!PDF_HatchFill(tmpOut, ite))
+ return false;
+ }
else
{
if (!PDF_GradientFillStroke(tmpOut, ite))
return false;
}
- PutPage(tmpOut);
+ if (ite->GrType != 14)
+ PutPage(tmpOut);
}
- PutPage(SetClipPath(ite));
- PutPage(ite->fillRule ? "h\nf*\n" : "h\nf\n");
+ else
+ {
+ if (ite->fillColor() != CommonStrings::None)
+ {
+ PutPage(SetClipPath(ite));
+ PutPage(ite->fillRule ? "h\nf*\n" : "h\nf\n");
+ }
+ }
}
PutPage("q\n");
if (ite->imageFlippedH())
@@ -2295,6 +2307,11 @@
if (!PDF_PatternFillStroke(tmpOut, ite))
return false;
}
+ else if (ite->GrType == 14)
+ {
+ if (!PDF_HatchFill(tmpOut, ite))
+ return false;
+ }
else
{
if (!PDF_GradientFillStroke(tmpOut, ite))
@@ -2302,9 +2319,14 @@
}
if (!tmpOut.isEmpty())
{
- PutPage(tmpOut);
- PutPage(SetClipPath(ite));
- PutPage(ite->fillRule ? "h\nf*\n" : "h\nf\n");
+ if (ite->GrType == 14)
+ PutPage(tmpOut);
+ else
+ {
+ PutPage(tmpOut);
+ PutPage(SetClipPath(ite));
+ PutPage(ite->fillRule ? "h\nf*\n" : "h\nf\n");
+ }
}
}
else
@@ -2384,6 +2406,11 @@
if (!PDF_PatternFillStroke(tmpOut, ite))
return false;
}
+ else if (ite->GrType == 14)
+ {
+ if (!PDF_HatchFill(tmpOut, ite))
+ return false;
+ }
else
{
if (!PDF_GradientFillStroke(tmpOut, ite))
@@ -2391,9 +2418,14 @@
}
if (!tmpOut.isEmpty())
{
- PutPage(tmpOut);
- PutPage(SetClipPath(ite));
- PutPage(ite->fillRule ? "h\nf*\n" : "h\nf\n");
+ if (ite->GrType == 14)
+ PutPage(tmpOut);
+ else
+ {
+ PutPage(tmpOut);
+ PutPage(SetClipPath(ite));
+ PutPage(ite->fillRule ? "h\nf*\n" : "h\nf\n");
+ }
}
}
else
@@ -3741,6 +3773,11 @@
if (!PDF_PatternFillStroke(tmpOut, ite))
return false;
}
+ else if (ite->GrType == 14)
+ {
+ if (!PDF_HatchFill(tmpOut, ite))
+ return false;
+ }
else
{
if (!PDF_GradientFillStroke(tmpOut, ite))
@@ -3748,15 +3785,23 @@
}
if (!tmpOut.isEmpty())
{
- tmp += tmpOut;
+ if (ite->GrType == 14)
+ tmp += tmpOut;
+ else
+ {
+ tmp += tmpOut;
+ tmp += SetClipPath(ite);
+ tmp += (ite->fillRule ? "h\nf*\n" : "h\nf\n");
+ }
+ }
+ }
+ else
+ {
+ if (ite->fillColor() != CommonStrings::None)
+ {
tmp += SetClipPath(ite);
tmp += (ite->fillRule ? "h\nf*\n" : "h\nf\n");
}
- }
- else
- {
- tmp += SetClipPath(ite);
- tmp += (ite->fillRule ? "h\nf*\n" : "h\nf\n");
}
}
tmp += "q\n";
@@ -3854,6 +3899,11 @@
if (!PDF_PatternFillStroke(tmpOut, ite))
return false;
}
+ else if (ite->GrType == 14)
+ {
+ if (!PDF_HatchFill(tmpOut, ite))
+ return false;
+ }
else
{
if (!PDF_GradientFillStroke(tmpOut, ite))
@@ -3861,15 +3911,23 @@
}
if (!tmpOut.isEmpty())
{
- tmp += tmpOut;
+ if (ite->GrType == 14)
+ tmp += tmpOut;
+ else
+ {
+ tmp += tmpOut;
+ tmp += SetClipPath(ite);
+ tmp += (ite->fillRule ? "h\nf*\n" : "h\nf\n");
+ }
+ }
+ }
+ else
+ {
+ if (ite->fillColor() != CommonStrings::None)
+ {
tmp += SetClipPath(ite);
tmp += (ite->fillRule ? "h\nf*\n" : "h\nf\n");
}
- }
- else
- {
- tmp += SetClipPath(ite);
- tmp += (ite->fillRule ? "h\nf*\n" : "h\nf\n");
}
}
tmp += "q\n";
@@ -4021,6 +4079,11 @@
if (!PDF_PatternFillStroke(tmpOut, ite))
return false;
}
+ else if (ite->GrType == 14)
+ {
+ if (!PDF_HatchFill(tmpOut, ite))
+ return false;
+ }
else
{
if (!PDF_GradientFillStroke(tmpOut, ite))
@@ -4028,9 +4091,14 @@
}
if (!tmpOut.isEmpty())
{
- tmp += tmpOut;
- tmp += SetClipPath(ite);
- tmp += (ite->fillRule ? "h\nf*\n" : "h\nf\n");
+ if (ite->GrType == 14)
+ tmp += tmpOut;
+ else
+ {
+ tmp += tmpOut;
+ tmp += SetClipPath(ite);
+ tmp += (ite->fillRule ? "h\nf*\n" : "h\nf\n");
+ }
}
}
else
@@ -4111,6 +4179,11 @@
if (!PDF_PatternFillStroke(tmpOut, ite))
return false;
}
+ else if (ite->GrType == 14)
+ {
+ if (!PDF_HatchFill(tmpOut, ite))
+ return false;
+ }
else
{
if (!PDF_GradientFillStroke(tmpOut, ite))
@@ -4118,9 +4191,14 @@
}
if (!tmpOut.isEmpty())
{
- tmp += tmpOut;
- tmp += SetClipPath(ite);
- tmp += (ite->fillRule ? "h\nf*\n" : "h\nf\n");
+ if (ite->GrType == 14)
+ tmp += tmpOut;
+ else
+ {
+ tmp += tmpOut;
+ tmp += SetClipPath(ite);
+ tmp += (ite->fillRule ? "h\nf*\n" : "h\nf\n");
+ }
}
}
else
@@ -6338,6 +6416,89 @@
+ "/BM /" + blendMode(currItem->lineBlendmode()) + "\n");
QString tmp("/"+ShName+" gs\n");
return tmp;
+}
+
+bool PDFLibCore::PDF_HatchFill(QString& output, PageItem *currItem)
+{
+ output += "q\n1 w\n[] 0 d\n0 J\n0 j\n";
+ if ((currItem->hatchBackground != CommonStrings::None) && (currItem->hatchUseBackground))
+ {
+ output += putColor(currItem->hatchBackground, 100, true);
+ output += SetClipPath(currItem);
+ output += (currItem->fillRule ? "h\nf*\n" : "h\nf\n");
+ }
+ if (currItem->hatchForeground != CommonStrings::None)
+ output += putColor(currItem->hatchForeground, 100, false);
+ output += SetPathAndClip(currItem);
+ QTransform mpa;
+ mpa.translate(currItem->width() / 2.0, -currItem->height() / 2.0);
+ output += FToStr(mpa.m11())+" "+FToStr(mpa.m12())+" "+FToStr(mpa.m21())+" "+FToStr(mpa.m22())+" "+FToStr(mpa.dx())+" "+FToStr(mpa.dy())+" cm\n";
+ double lineLen = sqrt((currItem->width() / 2.0) * (currItem->width() / 2.0) + (currItem->height() / 2.0) * (currItem->height() / 2.0));
+ double dist = 0.0;
+ output += "q\n";
+ QTransform mp;
+ mp.rotate(currItem->hatchAngle);
+ output += FToStr(mp.m11())+" "+FToStr(mp.m12())+" "+FToStr(mp.m21())+" "+FToStr(mp.m22())+" "+FToStr(mp.dx())+" "+FToStr(mp.dy())+" cm\n";
+ while (dist < lineLen)
+ {
+ output += FToStr(-lineLen) + " " + FToStr(dist) + " m\n";
+ output += FToStr(lineLen)+ " " + FToStr(dist) + " l\n";
+ output += "S\n";
+ if (dist > 0)
+ {
+ output += FToStr(-lineLen) + " " + FToStr(-dist) + " m\n";
+ output += FToStr(lineLen)+ " " + FToStr(-dist) + " l\n";
+ output += "S\n";
+ }
+ dist += currItem->hatchDistance;
+ }
+ output += "Q\n";
+ dist = 0;
+ if ((currItem->hatchType == 1) || (currItem->hatchType == 2))
+ {
+ output += "q\n";
+ QTransform mp;
+ mp.rotate(currItem->hatchAngle + 90);
+ output += FToStr(mp.m11())+" "+FToStr(mp.m12())+" "+FToStr(mp.m21())+" "+FToStr(mp.m22())+" "+FToStr(mp.dx())+" "+FToStr(mp.dy())+" cm\n";
+ while (dist < lineLen)
+ {
+ output += FToStr(-lineLen) + " " + FToStr(dist) + " m\n";
+ output += FToStr(lineLen)+ " " + FToStr(dist) + " l\n";
+ output += "S\n";
+ if (dist > 0)
+ {
+ output += FToStr(-lineLen) + " " + FToStr(-dist) + " m\n";
+ output += FToStr(lineLen)+ " " + FToStr(-dist) + " l\n";
+ output += "S\n";
+ }
+ dist += currItem->hatchDistance;
+ }
+ output += "Q\n";
+ }
+ if (currItem->hatchType == 2)
+ {
+ dist = 0;
+ output += "q\n";
+ QTransform mp;
+ mp.rotate(currItem->hatchAngle - 45);
+ output += FToStr(mp.m11())+" "+FToStr(mp.m12())+" "+FToStr(mp.m21())+" "+FToStr(mp.m22())+" "+FToStr(mp.dx())+" "+FToStr(mp.dy())+" cm\n";
+ while (dist < lineLen)
+ {
+ output += FToStr(-lineLen) + " " + FToStr(dist * sqrt(2.0)) + " m\n";
+ output += FToStr(lineLen)+ " " + FToStr(dist * sqrt(2.0)) + " l\n";
+ output += "S\n";
+ if (dist > 0)
+ {
+ output += FToStr(-lineLen) + " " + FToStr(-dist * sqrt(2.0)) + " m\n";
+ output += FToStr(lineLen)+ " " + FToStr(-dist * sqrt(2.0)) + " l\n";
+ output += "S\n";
+ }
+ dist += currItem->hatchDistance;
+ }
+ output += "Q\n";
+ }
+ output += "Q\n";
+ return true;
}
bool PDFLibCore::PDF_PatternFillStroke(QString& output, PageItem *currItem, int kind, bool forArrow)
Modified: trunk/Scribus/scribus/pdflib_core.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18935&path=/trunk/Scribus/scribus/pdflib_core.h
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.h (original)
+++ trunk/Scribus/scribus/pdflib_core.h Sun Mar 23 07:24:17 2014
@@ -157,6 +157,7 @@
QString PDF_PutSoftShadow(PageItem* ite, const ScPage* pag);
bool PDF_ProcessItem(QString& output, PageItem* ite, const ScPage* pag, uint PNr, bool embedded = false, bool pattern = false);
void PDF_Bookmark(PageItem *currItem, double ypos);
+ bool PDF_HatchFill(QString& output, PageItem *currItem);
bool PDF_PatternFillStroke(QString& output, PageItem *currItem, int kind = 0, bool forArrow = false);
bool PDF_MeshGradientFill(QString& output, PageItem *currItem);
bool PDF_PatchMeshGradientFill(QString& output, PageItem *c);
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18935&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 Sun Mar 23 07:24:17 2014
@@ -5314,6 +5314,16 @@
currItem->meshGradientPatches.append(patchM);
}
}
+ else if (currItem->GrType == 14)
+ {
+ int hatchType = attrs.valueAsInt("HatchMode", 0);
+ double hatchDistance = attrs.valueAsDouble("HatchDist", 2);
+ double hatchAngle = attrs.valueAsDouble("HatchAngle", 0);
+ bool hatchUseBackground = attrs.valueAsBool("HatchSolidB", false);
+ QString hatchBackground = attrs.valueAsString("HatchBackG", CommonStrings::None);
+ QString hatchForeground = attrs.valueAsString("HatchForeC", CommonStrings::None);
+ currItem->setHatchParameters(hatchType, hatchDistance, hatchAngle, hatchUseBackground, hatchBackground, hatchForeground);
+ }
else
{
currItem->GrStartX = attrs.valueAsDouble("GRSTARTX", 0.0);
@@ -5358,7 +5368,7 @@
}
}
}
- if (((currItem->GrType != 0) && (currItem->GrType != 8)) && (currItem->gradient().isEmpty()))
+ if (((currItem->GrType != 0) && (currItem->GrType != 8) && (currItem->GrType != 14)) && (currItem->gradient().isEmpty()))
{
currItem->fill_gradient.clearStops();
if ((!GrColor.isEmpty()) && (!GrColor2.isEmpty()))
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18935&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 Sun Mar 23 07:24:17 2014
@@ -1785,6 +1785,15 @@
{
docu.writeAttribute("GMAX", item->meshGradientPatches.count());
}
+ else if (item->GrType == 14)
+ {
+ docu.writeAttribute("HatchMode", item->hatchType);
+ docu.writeAttribute("HatchDist", item->hatchDistance);
+ docu.writeAttribute("HatchAngle", item->hatchAngle);
+ docu.writeAttribute("HatchSolidB", item->hatchUseBackground);
+ docu.writeAttribute("HatchBackG", item->hatchBackground);
+ docu.writeAttribute("HatchForeC", item->hatchForeground);
+ }
else
{
docu.writeAttribute("GRSTARTX", item->GrStartX);
@@ -1919,7 +1928,7 @@
if (item->isWelded())
{
- bool isWelded = false;
+ // bool isWelded = false;
for (int i = 0 ; i < item->weldList.count(); i++)
{
PageItem::weldingInfo wInf = item->weldList.at(i);
@@ -1972,7 +1981,7 @@
docu.writeAttribute("Fill", tabCh);
}
}
- if (((item->GrType > 0) && (item->GrType != 8) && (item->GrType != 9) && (item->GrType != 11)) && (item->gradient().isEmpty()))
+ if (((item->GrType > 0) && (item->GrType != 8) && (item->GrType != 9) && (item->GrType != 11) && (item->GrType != 14)) && (item->gradient().isEmpty()))
{
QList<VColorStop*> cstops = item->fill_gradient.colorStops();
for (uint cst = 0; cst < item->fill_gradient.Stops(); ++cst)
Modified: trunk/Scribus/scribus/plugins/import/odg/importodg.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18935&path=/trunk/Scribus/scribus/plugins/import/odg/importodg.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/odg/importodg.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/odg/importodg.cpp Sun Mar 23 07:24:17 2014
@@ -3583,7 +3583,7 @@
FPoint cp = FPoint(item->width() * gStyle.gradientCenterX, item->height()* gStyle.gradientCenterY);
double gLenW = item->width() / 2.0;
double gLenH = item->height() / 2.0;
-/*
+
QPointF P1 = QPointF(0.0, 0.0);
QPointF P2 = QPointF(item->width(), 0.0);
QPointF P3 = QPointF(item->width(), item->height());
@@ -3608,6 +3608,25 @@
P4 = pPoints[3];
P5 = pPoints[4];
P6 = pPoints[5];
+/*
+ QPointF cpL = QPointF(item->width() * gStyle.gradientCenterX, item->height()* gStyle.gradientCenterY);
+ double lineLen = sqrt(gLenW * gLenW + gLenH * gLenH) * 2.0;
+ QLineF iLineP1 = QLineF(cpL, P1);
+ iLineP1.setLength(lineLen);
+ P1 = intersectBoundingRect(item, iLineP1);
+ QLineF iLineP2 = QLineF(cpL, P2);
+ iLineP2.setLength(lineLen);
+ P2 = intersectBoundingRect(item, iLineP2);
+ QLineF iLineP3 = QLineF(cpL, P3);
+ iLineP3.setLength(lineLen);
+ P3 = intersectBoundingRect(item, iLineP3);
+ QLineF iLineP4 = QLineF(cpL, P4);
+ iLineP4.setLength(lineLen);
+ P4 = intersectBoundingRect(item, iLineP4);
+ item->setDiamondGeometry(FPoint(P1.x(), P1.y()), FPoint(P2.x(), P2.y()), FPoint(P3.x(), P3.y()), FPoint(P4.x(), P4.y()), cp);
+ item->GrType = 10;
+*/
+/*
item->meshGradientPatches.clear();
meshGradientPatch patch1;
meshPoint outer;
@@ -3659,6 +3678,7 @@
item->meshGradientPatches.append(patch1);
item->GrType = 12;
*/
+
QLineF p1 = QLineF(cp.x(), cp.y(), cp.x() - gLenW, cp.y() - gLenH);
p1.setAngle(p1.angle() + gStyle.gradientAngle);
QLineF p2 = QLineF(cp.x(), cp.y(), cp.x() + gLenW, cp.y() - gLenH);
@@ -3891,7 +3911,14 @@
{
ObjStyle gStyle;
resovleStyle(gStyle, obState.hatchName);
- QString patternName = "Hatch_" + obState.hatchName;
+ int hatchS = 0;
+ if (gStyle.hatchStyle == "double")
+ hatchS = 1;
+ else if (gStyle.hatchStyle == "triple")
+ hatchS = 2;
+ item->setHatchParameters(hatchS, gStyle.hatchDistance, gStyle.hatchRotation, obState.hatchSolidFill, obState.CurrColorFill, gStyle.hatchColor);
+ item->GrType = 14;
+ /* QString patternName = "Hatch_" + obState.hatchName;
if (m_Doc->docPatterns.contains(patternName))
{
item->setPattern(patternName);
@@ -4001,7 +4028,7 @@
}
}
delete tempFile;
- }
+ } */
}
if (!obState.opacityName.isEmpty())
{
Modified: trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18935&path=/trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp Sun Mar 23 07:24:17 2014
@@ -715,6 +715,113 @@
return "filter:url(#"+ID+");";
}
+QDomElement SVGExPlug::processHatchFill(PageItem *Item, QString transl)
+{
+ QDomElement ob;
+ ob = docu.createElement("g");
+ if (!transl.isEmpty())
+ ob.setAttribute("transform", transl);
+ QDomElement obc = createClipPathElement(&Item->PoLine);
+ if (!obc.isNull())
+ ob.setAttribute("clip-path", "url(#"+ obc.attribute("id") + ")");
+ if (Item->fillRule)
+ ob.setAttribute("clip-rule", "evenodd");
+ else
+ ob.setAttribute("clip-rule", "nonzero");
+ if (Item->hatchUseBackground)
+ {
+ QDomElement ob2 = docu.createElement("path");
+ ob2.setAttribute("d", SetClipPath(&Item->PoLine, true));
+ ob2.setAttribute("fill", SetColor(Item->hatchBackground, 100));
+ ob.appendChild(ob2);
+ }
+ QString stroke = "";
+ stroke += "stroke-width:1;";
+ stroke += " stroke-linecap:butt;";
+ stroke += " stroke-linejoin:miter;";
+ double lineLen = sqrt((Item->width() / 2.0) * (Item->width() / 2.0) + (Item->height() / 2.0) * (Item->height() / 2.0));
+ double dist = 0.0;
+ while (dist < lineLen)
+ {
+ QTransform mpx;
+ mpx.translate(Item->width() / 2.0, Item->height() / 2.0);
+ if (Item->hatchAngle != 0.0)
+ mpx.rotate(-Item->hatchAngle);
+ QDomElement ob3 = docu.createElement("path");
+ ob3.setAttribute("transform", MatrixToStr(mpx));
+ ob3.setAttribute("d", QString("M %1, %2 L %3, %4").arg(-lineLen).arg(dist).arg(lineLen).arg(dist));
+ ob3.setAttribute("stroke", SetColor(Item->hatchForeground, 100));
+ ob3.setAttribute("style", stroke);
+ ob.appendChild(ob3);
+ if (dist > 0)
+ {
+ QDomElement ob4 = docu.createElement("path");
+ ob4.setAttribute("transform", MatrixToStr(mpx));
+ ob4.setAttribute("d", QString("M %1, %2 L %3, %4").arg(-lineLen).arg(-dist).arg(lineLen).arg(-dist));
+ ob4.setAttribute("stroke", SetColor(Item->hatchForeground, 100));
+ ob4.setAttribute("style", stroke);
+ ob.appendChild(ob4);
+ }
+ dist += Item->hatchDistance;
+ }
+ if ((Item->hatchType == 1) || (Item->hatchType == 2))
+ {
+ dist = 0.0;
+ while (dist < lineLen)
+ {
+ QTransform mpx;
+ mpx.translate(Item->width() / 2.0, Item->height() / 2.0);
+ if (Item->hatchAngle != 0.0)
+ mpx.rotate(-Item->hatchAngle + 90);
+ QDomElement ob3 = docu.createElement("path");
+ ob3.setAttribute("transform", MatrixToStr(mpx));
+ ob3.setAttribute("d", QString("M %1, %2 L %3, %4").arg(-lineLen).arg(dist).arg(lineLen).arg(dist));
+ ob3.setAttribute("stroke", SetColor(Item->hatchForeground, 100));
+ ob3.setAttribute("style", stroke);
+ ob.appendChild(ob3);
+ if (dist > 0)
+ {
+ QDomElement ob4 = docu.createElement("path");
+ ob4.setAttribute("transform", MatrixToStr(mpx));
+ ob4.setAttribute("d", QString("M %1, %2 L %3, %4").arg(-lineLen).arg(-dist).arg(lineLen).arg(-dist));
+ ob4.setAttribute("stroke", SetColor(Item->hatchForeground, 100));
+ ob4.setAttribute("style", stroke);
+ ob.appendChild(ob4);
+ }
+ dist += Item->hatchDistance;
+ }
+ }
+ if (Item->hatchType == 2)
+ {
+ dist = 0.0;
+ while (dist < lineLen)
+ {
+ double dDist = dist * sqrt(2.0);
+ QTransform mpx;
+ mpx.translate(Item->width() / 2.0, Item->height() / 2.0);
+ if (Item->hatchAngle != 0.0)
+ mpx.rotate(-Item->hatchAngle + 45);
+ QDomElement ob3 = docu.createElement("path");
+ ob3.setAttribute("transform", MatrixToStr(mpx));
+ ob3.setAttribute("d", QString("M %1, %2 L %3, %4").arg(-lineLen).arg(dDist).arg(lineLen).arg(dDist));
+ ob3.setAttribute("stroke", SetColor(Item->hatchForeground, 100));
+ ob3.setAttribute("style", stroke);
+ ob.appendChild(ob3);
+ if (dist > 0)
+ {
+ QDomElement ob4 = docu.createElement("path");
+ ob4.setAttribute("transform", MatrixToStr(mpx));
+ ob4.setAttribute("d", QString("M %1, %2 L %3, %4").arg(-lineLen).arg(-dDist).arg(lineLen).arg(-dDist));
+ ob4.setAttribute("stroke", SetColor(Item->hatchForeground, 100));
+ ob4.setAttribute("style", stroke);
+ ob.appendChild(ob4);
+ }
+ dist += Item->hatchDistance;
+ }
+ }
+ return ob;
+}
+
QDomElement SVGExPlug::processSymbolStroke(PageItem *Item, QString trans)
{
QDomElement ob;
@@ -794,28 +901,66 @@
if ((!Item->strokePattern().isEmpty()) && (Item->patternStrokePath))
{
ob = docu.createElement("g");
+ if (Item->GrType == 14)
+ {
+ QDomElement ob1 = processHatchFill(Item, trans);
+ ob.appendChild(ob1);
+ }
QDomElement ob2 = docu.createElement("path");
ob2.setAttribute("d", SetClipPath(&Item->PoLine, closedPath));
ob2.setAttribute("transform", trans);
- ob2.setAttribute("style", fill);
+ if (Item->GrType != 14)
+ ob2.setAttribute("style", fill);
+ else
+ {
+ QString drS = processDropShadow(Item);
+ if (!drS.isEmpty())
+ ob2.setAttribute("style", "fill:none;" + drS);
+ }
ob.appendChild(ob2);
ob.appendChild(processSymbolStroke(Item, trans));
}
else
{
- ob = docu.createElement("path");
- ob.setAttribute("d", SetClipPath(&Item->PoLine, closedPath));
- ob.setAttribute("transform", trans);
- ob.setAttribute("style", fill + stroke);
+ if (Item->GrType == 14)
+ {
+ ob = docu.createElement("g");
+ ob.setAttribute("transform", trans);
+ QDomElement ob1 = processHatchFill(Item);
+ ob.appendChild(ob1);
+ QDomElement ob2 = docu.createElement("path");
+ ob2.setAttribute("d", SetClipPath(&Item->PoLine, closedPath));
+ ob2.setAttribute("style", stroke + "fill:none;" + processDropShadow(Item));
+ ob.appendChild(ob2);
+ }
+ else
+ {
+ ob = docu.createElement("path");
+ ob.setAttribute("d", SetClipPath(&Item->PoLine, closedPath));
+ ob.setAttribute("transform", trans);
+ ob.setAttribute("style", fill + stroke);
+ }
}
}
else
{
ob = docu.createElement("g");
ob.setAttribute("transform", trans);
+ if (Item->GrType == 14)
+ {
+ QDomElement ob1 = processHatchFill(Item);
+ ob.appendChild(ob1);
+ }
QDomElement ob2 = docu.createElement("path");
ob2.setAttribute("d", SetClipPath(&Item->PoLine, closedPath));
- ob2.setAttribute("style", fill);
+ if (Item->GrType != 14)
+ ob2.setAttribute("style", fill);
+ else
+ {
+ QString drS = processDropShadow(Item);
+ if (!drS.isEmpty())
+ ob2.setAttribute("style", "fill:none;" + drS);
+ }
ob.appendChild(ob2);
multiLine ml = m_Doc->MLineStyles[Item->NamedLStyle];
for (int it = ml.size()-1; it > -1; it--)
@@ -868,10 +1013,21 @@
ob.setAttribute("transform", trans);
if ((Item->fillColor() != CommonStrings::None) || (Item->GrType != 0))
{
- QDomElement ob1 = docu.createElement("path");
- ob1.setAttribute("d", SetClipPath(&Item->PoLine, true));
- ob1.setAttribute("style", fill);
- ob.appendChild(ob1);
+ if (Item->GrType == 14)
+ {
+ QDomElement ob1 = processHatchFill(Item);
+ ob.appendChild(ob1);
+ QString drS = processDropShadow(Item);
+ if (!drS.isEmpty())
+ ob.setAttribute("style", "fill:none;" + drS);
+ }
+ else
+ {
+ QDomElement ob1 = docu.createElement("path");
+ ob1.setAttribute("d", SetClipPath(&Item->PoLine, true));
+ ob1.setAttribute("style", fill);
+ ob.appendChild(ob1);
+ }
}
if ((Item->PictureIsAvailable) && (!Item->Pfile.isEmpty()))
{
@@ -992,10 +1148,21 @@
ob.setAttribute("transform", trans);
if ((Item->fillColor() != CommonStrings::None) || (Item->GrType != 0))
{
- QDomElement ob1 = docu.createElement("path");
- ob1.setAttribute("d", SetClipPath(&Item->PoLine, true));
- ob1.setAttribute("style", fill);
- ob.appendChild(ob1);
+ if (Item->GrType == 14)
+ {
+ QDomElement ob1 = processHatchFill(Item);
+ ob.appendChild(ob1);
+ QString drS = processDropShadow(Item);
+ if (!drS.isEmpty())
+ ob.setAttribute("style", "fill:none;" + drS);
+ }
+ else
+ {
+ QDomElement ob1 = docu.createElement("path");
+ ob1.setAttribute("d", SetClipPath(&Item->PoLine, true));
+ ob1.setAttribute("style", fill);
+ ob.appendChild(ob1);
+ }
}
double x, y, wide;
QString chstr;
Modified: trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18935&path=/trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.h
==============================================================================
--- trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.h (original)
+++ trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.h Sun Mar 23 07:24:17 2014
@@ -83,6 +83,7 @@
void ProcessItemOnPage(double xOffset, double yOffset, PageItem *Item, QDomElement *parentElem);
void paintBorder(const TableBorder& border, const QPointF& start, const QPointF& end, const QPointF& startOffsetFactors, const QPointF& endOffsetFactors, QDomElement &ob);
QString processDropShadow(PageItem *Item);
+ QDomElement processHatchFill(PageItem *Item, QString transl = "");
QDomElement processSymbolStroke(PageItem *Item, QString trans);
QDomElement processSymbolItem(PageItem *Item, QString trans);
QDomElement processPolyItem(PageItem *Item, QString trans, QString fill, QString stroke);
Modified: trunk/Scribus/scribus/plugins/xpsexport/xpsexplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18935&path=/trunk/Scribus/scribus/plugins/xpsexport/xpsexplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/xpsexport/xpsexplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/xpsexport/xpsexplugin.cpp Sun Mar 23 07:24:17 2014
@@ -562,6 +562,8 @@
{
if (((Item->GrType != 0) || (Item->fillColor() != CommonStrings::None)) || ((Item->GrTypeStroke != 0) || (Item->lineColor() != CommonStrings::None) || !Item->NamedLStyle.isEmpty()))
{
+ if (Item->GrType == 14)
+ processHatchFill(xOffset, yOffset, Item, parentElem, rel_root);
bool closedPath;
if ((Item->itemType() == PageItem::Polygon) || (Item->itemType() == PageItem::RegularPolygon) || (Item->itemType() == PageItem::Arc))
closedPath = true;
@@ -584,9 +586,12 @@
else
pa.prepend("F 1 ");
ob.setAttribute("Data", pa);
- if (Item->GrMask > 0)
- handleMask(3, Item, ob, rel_root, xOffset, yOffset);
- getFillStyle(Item, ob, rel_root, xOffset, yOffset);
+ if (Item->GrType != 14)
+ {
+ if (Item->GrMask > 0)
+ handleMask(3, Item, ob, rel_root, xOffset, yOffset);
+ getFillStyle(Item, ob, rel_root, xOffset, yOffset);
+ }
if (Item->NamedLStyle.isEmpty())
{
if ((!Item->strokePattern().isEmpty()) && (Item->patternStrokePath))
@@ -666,6 +671,8 @@
void XPSExPlug::processImageItem(double xOffset, double yOffset, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root)
{
+ if (Item->GrType == 14)
+ processHatchFill(xOffset, yOffset, Item, parentElem, rel_root);
FPointArray path = Item->PoLine.copy();
path.translate(xOffset, yOffset);
path.scale(conversionFactor, conversionFactor);
@@ -683,19 +690,22 @@
mpx.translate(-xOffset * conversionFactor, -yOffset * conversionFactor);
grp.setAttribute("RenderTransform", MatrixToStr(mpx));
}
- if (Item->GrMask > 0)
- handleMask(1, Item, grp, rel_root, xOffset, yOffset);
- else
- {
- if (Item->fillTransparency() != 0)
- grp.setAttribute("Opacity", FToStr(1.0 - Item->fillTransparency()));
- }
- if ((Item->GrType != 0) || (Item->fillColor() != CommonStrings::None))
- {
- QDomElement ob = p_docu.createElement("Path");
- ob.setAttribute("Data", pa);
- getFillStyle(Item, ob, rel_root, xOffset, yOffset, false);
- grp.appendChild(ob);
+ if (Item->GrType != 14)
+ {
+ if (Item->GrMask > 0)
+ handleMask(1, Item, grp, rel_root, xOffset, yOffset);
+ else
+ {
+ if (Item->fillTransparency() != 0)
+ grp.setAttribute("Opacity", FToStr(1.0 - Item->fillTransparency()));
+ }
+ if ((Item->GrType != 0) || (Item->fillColor() != CommonStrings::None))
+ {
+ QDomElement ob = p_docu.createElement("Path");
+ ob.setAttribute("Data", pa);
+ getFillStyle(Item, ob, rel_root, xOffset, yOffset, false);
+ grp.appendChild(ob);
+ }
}
if ((Item->PictureIsAvailable) && (!Item->Pfile.isEmpty()))
{
@@ -793,6 +803,8 @@
{
if (Item->isAnnotation())
return;
+ if (Item->GrType == 14)
+ processHatchFill(xOffset, yOffset, Item, parentElem, rel_root);
FPointArray path = Item->PoLine.copy();
path.scale(conversionFactor, conversionFactor);
QString pa = SetClipPath(&path, true);
@@ -823,41 +835,44 @@
grp.setAttribute("RenderTransform", MatrixToStr(mpx));
if (Item->isBookmark)
grp.setAttribute("Name", Item->itemName());
- if (Item->GrMask > 0)
- handleMask(1, Item, grp, rel_root, xOffset, yOffset);
- else
- {
- if (Item->fillTransparency() != 0)
- grp.setAttribute("Opacity", FToStr(1.0 - Item->fillTransparency()));
- }
- if ((Item->GrType != 0) || (Item->fillColor() != CommonStrings::None))
- {
- FPointArray pathi = Item->PoLine.copy();
- if (Item->imageFlippedH() || Item->imageFlippedV())
- {
- QTransform mpi;
- if (Item->imageFlippedH())
- {
- mpi.translate(Item->width(), 0);
- mpi.scale(-1, 1);
- }
- if (Item->imageFlippedV())
- {
- mpi.translate(0, Item->height());
- mpi.scale(1, -1);
- }
- pathi.map(mpi);
- }
- pathi.scale(conversionFactor, conversionFactor);
- QString pai = SetClipPath(&pathi, true);
- if (Item->fillRule)
- pai.prepend("F 0 ");
+ if (Item->GrType != 14)
+ {
+ if (Item->GrMask > 0)
+ handleMask(1, Item, grp, rel_root, xOffset, yOffset);
else
- pai.prepend("F 1 ");
- QDomElement ob = p_docu.createElement("Path");
- ob.setAttribute("Data", pai);
- getFillStyle(Item, ob, rel_root, xOffset, yOffset, false);
- grp.appendChild(ob);
+ {
+ if (Item->fillTransparency() != 0)
+ grp.setAttribute("Opacity", FToStr(1.0 - Item->fillTransparency()));
+ }
+ if ((Item->GrType != 0) || (Item->fillColor() != CommonStrings::None))
+ {
+ FPointArray pathi = Item->PoLine.copy();
+ if (Item->imageFlippedH() || Item->imageFlippedV())
+ {
+ QTransform mpi;
+ if (Item->imageFlippedH())
+ {
+ mpi.translate(Item->width(), 0);
+ mpi.scale(-1, 1);
+ }
+ if (Item->imageFlippedV())
+ {
+ mpi.translate(0, Item->height());
+ mpi.scale(1, -1);
+ }
+ pathi.map(mpi);
+ }
+ pathi.scale(conversionFactor, conversionFactor);
+ QString pai = SetClipPath(&pathi, true);
+ if (Item->fillRule)
+ pai.prepend("F 0 ");
+ else
+ pai.prepend("F 1 ");
+ QDomElement ob = p_docu.createElement("Path");
+ ob.setAttribute("Data", pai);
+ getFillStyle(Item, ob, rel_root, xOffset, yOffset, false);
+ grp.appendChild(ob);
+ }
}
for (uint ll=0; ll < Item->itemText.lines(); ++ll)
{
@@ -1719,6 +1734,147 @@
}
}
+void XPSExPlug::processHatchFill(double xOffset, double yOffset, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root)
+{
+ QDomElement obC = p_docu.createElement("Canvas");
+ FPointArray path = Item->PoLine.copy();
+ path.scale(conversionFactor, conversionFactor);
+ SetClipAttr(obC, &path, Item->fillRule);
+ if (Item->GrMask > 0)
+ handleMask(1, Item, obC, rel_root, xOffset, yOffset);
+ else
+ {
+ if (Item->fillTransparency() != 0)
+ obC.setAttribute("Opacity", FToStr(1.0 - Item->fillTransparency()));
+ }
+ QTransform mpo;
+ mpo.translate(xOffset * conversionFactor, yOffset * conversionFactor);
+ if (Item->rotation() != 0.0)
+ mpo.rotate(Item->rotation());
+ obC.setAttribute("RenderTransform", MatrixToStr(mpo));
+ if (Item->hatchUseBackground)
+ {
+ FPointArray path;
+ path.svgInit();
+ path.svgMoveTo(0, 0);
+ path.svgLineTo(Item->width(), 0);
+ path.svgLineTo(Item->width(), Item->height());
+ path.svgLineTo(0, Item->height());
+ path.svgClosePath();
+ path.scale(conversionFactor, conversionFactor);
+ QString pa = SetClipPath(&path, true);
+ QDomElement cl = p_docu.createElement("Path");
+ cl.setAttribute("Data", pa);
+ cl.setAttribute("Fill", SetColor(Item->hatchBackground, 100, 0));
+ obC.appendChild(cl);
+ }
+ double lineLen = sqrt((Item->width() / 2.0) * (Item->width() / 2.0) + (Item->height() / 2.0) * (Item->height() / 2.0)) * conversionFactor;
+ double dist = 0.0;
+ while (dist < lineLen)
+ {
+ QTransform mpx;
+ mpx.translate((Item->width() / 2.0) * conversionFactor, (Item->height() / 2.0) * conversionFactor);
+ if (Item->hatchAngle != 0.0)
+ mpx.rotate(-Item->hatchAngle);
+ QDomElement ob = p_docu.createElement("Path");
+ ob.setAttribute("StrokeThickness", FToStr(conversionFactor));
+ ob.setAttribute("StrokeDashCap", "Flat");
+ ob.setAttribute("StrokeEndLineCap", "Flat");
+ ob.setAttribute("StrokeStartLineCap", "Flat");
+ ob.setAttribute("StrokeLineJoin", "Miter");
+ ob.setAttribute("Stroke", SetColor(Item->hatchForeground, 100, 0));
+ ob.setAttribute("Data", QString("M %1, %2 L %3, %4").arg(-lineLen).arg(dist).arg(lineLen).arg(dist));
+ ob.setAttribute("RenderTransform", MatrixToStr(mpx));
+ obC.appendChild(ob);
+ if (dist > 0)
+ {
+ QDomElement ob = p_docu.createElement("Path");
+ ob.setAttribute("StrokeThickness", FToStr(conversionFactor));
+ ob.setAttribute("StrokeDashCap", "Flat");
+ ob.setAttribute("StrokeEndLineCap", "Flat");
+ ob.setAttribute("StrokeStartLineCap", "Flat");
+ ob.setAttribute("StrokeLineJoin", "Miter");
+ ob.setAttribute("Stroke", SetColor(Item->hatchForeground, 100, 0));
+ ob.setAttribute("Data", QString("M %1, %2 L %3, %4").arg(-lineLen).arg(-dist).arg(lineLen).arg(-dist));
+ ob.setAttribute("RenderTransform", MatrixToStr(mpx));
+ obC.appendChild(ob);
+ }
+ dist += Item->hatchDistance * conversionFactor;
+ }
+ if ((Item->hatchType == 1) || (Item->hatchType == 2))
+ {
+ dist = 0.0;
+ while (dist < lineLen)
+ {
+ QTransform mpx;
+ mpx.translate((Item->width() / 2.0) * conversionFactor, (Item->height() / 2.0) * conversionFactor);
+ if (Item->hatchAngle != 0.0)
+ mpx.rotate(-Item->hatchAngle + 90);
+ QDomElement ob = p_docu.createElement("Path");
+ ob.setAttribute("StrokeThickness", FToStr(conversionFactor));
+ ob.setAttribute("StrokeDashCap", "Flat");
+ ob.setAttribute("StrokeEndLineCap", "Flat");
+ ob.setAttribute("StrokeStartLineCap", "Flat");
+ ob.setAttribute("StrokeLineJoin", "Miter");
+ ob.setAttribute("Stroke", SetColor(Item->hatchForeground, 100, 0));
+ ob.setAttribute("Data", QString("M %1, %2 L %3, %4").arg(-lineLen).arg(dist).arg(lineLen).arg(dist));
+ ob.setAttribute("RenderTransform", MatrixToStr(mpx));
+ obC.appendChild(ob);
+ if (dist > 0)
+ {
+ QDomElement ob = p_docu.createElement("Path");
+ ob.setAttribute("StrokeThickness", FToStr(conversionFactor));
+ ob.setAttribute("StrokeDashCap", "Flat");
+ ob.setAttribute("StrokeEndLineCap", "Flat");
+ ob.setAttribute("StrokeStartLineCap", "Flat");
+ ob.setAttribute("StrokeLineJoin", "Miter");
+ ob.setAttribute("Stroke", SetColor(Item->hatchForeground, 100, 0));
+ ob.setAttribute("Data", QString("M %1, %2 L %3, %4").arg(-lineLen).arg(-dist).arg(lineLen).arg(-dist));
+ ob.setAttribute("RenderTransform", MatrixToStr(mpx));
+ obC.appendChild(ob);
+ }
+ dist += Item->hatchDistance * conversionFactor;
+ }
+ }
+ if (Item->hatchType == 2)
+ {
+ dist = 0.0;
+ while (dist < lineLen)
+ {
+ double dDist = dist * sqrt(2.0);
+ QTransform mpx;
+ mpx.translate((Item->width() / 2.0) * conversionFactor, (Item->height() / 2.0) * conversionFactor);
+ if (Item->hatchAngle != 0.0)
+ mpx.rotate(-Item->hatchAngle + 45);
+ QDomElement ob = p_docu.createElement("Path");
+ ob.setAttribute("StrokeThickness", FToStr(conversionFactor));
+ ob.setAttribute("StrokeDashCap", "Flat");
+ ob.setAttribute("StrokeEndLineCap", "Flat");
+ ob.setAttribute("StrokeStartLineCap", "Flat");
+ ob.setAttribute("StrokeLineJoin", "Miter");
+ ob.setAttribute("Stroke", SetColor(Item->hatchForeground, 100, 0));
+ ob.setAttribute("Data", QString("M %1, %2 L %3, %4").arg(-lineLen).arg(dDist).arg(lineLen).arg(dDist));
+ ob.setAttribute("RenderTransform", MatrixToStr(mpx));
+ obC.appendChild(ob);
+ if (dist > 0)
+ {
+ QDomElement ob = p_docu.createElement("Path");
+ ob.setAttribute("StrokeThickness", FToStr(conversionFactor));
+ ob.setAttribute("StrokeDashCap", "Flat");
+ ob.setAttribute("StrokeEndLineCap", "Flat");
+ ob.setAttribute("StrokeStartLineCap", "Flat");
+ ob.setAttribute("StrokeLineJoin", "Miter");
+ ob.setAttribute("Stroke", SetColor(Item->hatchForeground, 100, 0));
+ ob.setAttribute("Data", QString("M %1, %2 L %3, %4").arg(-lineLen).arg(-dDist).arg(lineLen).arg(-dDist));
+ ob.setAttribute("RenderTransform", MatrixToStr(mpx));
+ obC.appendChild(ob);
+ }
+ dist += Item->hatchDistance * conversionFactor;
+ }
+ }
+ parentElem.appendChild(obC);
+}
+
void XPSExPlug::processSymbolStroke(double xOffset, double yOffset, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root)
{
QDomElement ob = p_docu.createElement("Canvas");
Modified: trunk/Scribus/scribus/plugins/xpsexport/xpsexplugin.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18935&path=/trunk/Scribus/scribus/plugins/xpsexport/xpsexplugin.h
==============================================================================
--- trunk/Scribus/scribus/plugins/xpsexport/xpsexplugin.h (original)
+++ trunk/Scribus/scribus/plugins/xpsexport/xpsexplugin.h Sun Mar 23 07:24:17 2014
@@ -85,6 +85,7 @@
void processSymbolItem(double xOffset, double yOffset, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root);
void processTableItem(double xOffset, double yOffset, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root);
void paintBorder(const TableBorder &border, const QPointF &start, const QPointF &end, const QPointF &startOffsetFactors, const QPointF &endOffsetFactors, QDomElement &ob);
+ void processHatchFill(double xOffset, double yOffset, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root);
void processSymbolStroke(double xOffset, double yOffset, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root);
void processArrows(double xOffset, double yOffset, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root);
void drawArrow(double xOffset, double yOffset, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root, FPointArray &arrow);
Modified: trunk/Scribus/scribus/pslib.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18935&path=/trunk/Scribus/scribus/pslib.cpp
==============================================================================
--- trunk/Scribus/scribus/pslib.cpp (original)
+++ trunk/Scribus/scribus/pslib.cpp Sun Mar 23 07:24:17 2014
@@ -1714,7 +1714,9 @@
{
SetClipPath(&c->PoLine);
PS_closepath();
- if ((c->GrType != 0) && (master == false))
+ if (c->GrType == 14)
+ PS_HatchFill(c, gcr);
+ else if ((c->GrType != 0) && (master == false))
HandleGradientFillStroke(c, gcr, false);
else
putColor(c->fillColor(), c->fillShade(), true);
@@ -1828,7 +1830,9 @@
{
SetClipPath(&c->PoLine);
PS_closepath();
- if ((c->GrType != 0) && (master == false))
+ if (c->GrType == 14)
+ PS_HatchFill(c, gcr);
+ else if ((c->GrType != 0) && (master == false))
HandleGradientFillStroke(c, gcr, false);
else
putColor(c->fillColor(), c->fillShade(), true);
@@ -1971,7 +1975,9 @@
SetClipPath(&c->PoLine);
PS_closepath();
fillRule = c->fillRule;
- if (c->GrType != 0)
+ if (c->GrType == 14)
+ PS_HatchFill(c, gcr);
+ else if (c->GrType != 0)
HandleGradientFillStroke(c, gcr, false);
else
putColor(c->fillColor(), c->fillShade(), true);
@@ -2024,7 +2030,9 @@
SetClipPath(&c->PoLine);
PS_closepath();
fillRule = c->fillRule;
- if (c->GrType != 0)
+ if (c->GrType == 14)
+ PS_HatchFill(c, gcr);
+ else if (c->GrType != 0)
HandleGradientFillStroke(c, gcr, false);
else
putColor(c->fillColor(), c->fillShade(), true);
@@ -3137,7 +3145,9 @@
{
SetClipPath(&ite->PoLine);
PS_closepath();
- if (ite->GrType != 0)
+ if (ite->GrType == 14)
+ PS_HatchFill(ite, gcr);
+ else if (ite->GrType != 0)
HandleGradientFillStroke(ite, gcr, false);
else
putColor(ite->fillColor(), ite->fillShade(), true);
@@ -4780,6 +4790,95 @@
}
}
+void PSLib::PS_HatchFill(PageItem *currItem, bool gcr)
+{
+ PS_save();
+ QVector<double> dum;
+ int h, s, v, k;
+ PS_setlinewidth(1);
+ PS_setcapjoin(Qt::FlatCap, Qt::MiterJoin);
+ PS_setdash(Qt::SolidLine, 0, dum);
+ if ((currItem->hatchBackground != CommonStrings::None) && (currItem->hatchUseBackground))
+ {
+ SetColor(currItem->hatchBackground, 100, &h, &s, &v, &k, gcr);
+ PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
+ putColor(currItem->hatchBackground, 100, true);
+ SetPathAndClip(currItem->PoLine, currItem->fillRule);
+ }
+ else
+ PS_clip(currItem->fillRule);
+ if (currItem->hatchForeground != CommonStrings::None)
+ {
+ SetColor(currItem->hatchForeground, 100, &h, &s, &v, &k, gcr);
+ PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
+ }
+ PS_translate(currItem->width() / 2.0, -currItem->height() / 2.0);
+ double lineLen = sqrt((currItem->width() / 2.0) * (currItem->width() / 2.0) + (currItem->height() / 2.0) * (currItem->height() / 2.0));
+ double dist = 0.0;
+ PS_save();
+ PS_rotate(currItem->hatchAngle);
+ while (dist < lineLen)
+ {
+ PS_moveto(-lineLen, dist);
+ PS_lineto(lineLen, dist);
+ putColor(currItem->hatchForeground, 100, false);
+ if (dist > 0)
+ {
+ PS_moveto(-lineLen, -dist);
+ PS_lineto(lineLen, -dist);
+ putColor(currItem->hatchForeground, 100, false);
+ }
+ dist += currItem->hatchDistance;
+ }
+ PS_restore();
+ dist = 0.0;
+ if ((currItem->hatchType == 1) || (currItem->hatchType == 2))
+ {
+ PS_save();
+ PS_rotate(currItem->hatchAngle + 90);
+ while (dist < lineLen)
+ {
+ PS_moveto(-lineLen, dist);
+ PS_lineto(lineLen, dist);
+ putColor(currItem->hatchForeground, 100, false);
+ if (dist > 0)
+ {
+ PS_moveto(-lineLen, -dist);
+ PS_lineto(lineLen, -dist);
+ putColor(currItem->hatchForeground, 100, false);
+ }
+ dist += currItem->hatchDistance;
+ }
+ PS_restore();
+ }
+ dist = 0.0;
+ if (currItem->hatchType == 2)
+ {
+ PS_save();
+ PS_rotate(currItem->hatchAngle - 45);
+ while (dist < lineLen)
+ {
+ PS_moveto(-lineLen, dist * sqrt(2.0));
+ PS_lineto(lineLen, dist * sqrt(2.0));
+ putColor(currItem->hatchForeground, 100, false);
+ if (dist > 0)
+ {
+ PS_moveto(-lineLen, -dist * sqrt(2.0));
+ PS_lineto(lineLen, -dist * sqrt(2.0));
+ putColor(currItem->hatchForeground, 100, false);
+ }
+ dist += currItem->hatchDistance;
+ }
+ PS_restore();
+ }
+ PS_restore();
+ if (currItem->lineColor() != CommonStrings::None)
+ {
+ SetColor(currItem->lineColor(), currItem->lineShade(), &h, &s, &v, &k, gcr);
+ PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
+ }
+}
+
void PSLib::drawArrow(PageItem *ite, QTransform &arrowTrans, int arrowIndex, bool gcr)
{
int h, s, v, k;
Modified: trunk/Scribus/scribus/pslib.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18935&path=/trunk/Scribus/scribus/pslib.h
==============================================================================
--- trunk/Scribus/scribus/pslib.h (original)
+++ trunk/Scribus/scribus/pslib.h Sun Mar 23 07:24:17 2014
@@ -122,6 +122,7 @@
virtual void ProcessPage(ScribusDoc* Doc, ScPage* a, uint PNr, bool sep = false, bool farb = true, bool ic = false, bool gcr = true);
virtual bool ProcessMasterPageLayer(ScribusDoc* Doc, ScPage* a, ScLayer& ll, uint PNr, bool sep = false, bool farb = true, bool ic = false, bool gcr = true);
virtual bool ProcessPageLayer(ScribusDoc* Doc, ScPage* a, ScLayer& ll, uint PNr, bool sep = false, bool farb = true, bool ic = false, bool gcr = true);
+ virtual void PS_HatchFill(PageItem *currItem, bool gcr);
virtual void drawArrow(PageItem *ite, QTransform &arrowTrans, int arrowIndex, bool gcr);
virtual void putColor(const QString& color, double shade, bool fill);
virtual void putColorNoDraw(const QString& color, double shade, bool gcr);
Modified: trunk/Scribus/scribus/scpainter.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18935&path=/trunk/Scribus/scribus/scpainter.cpp
==============================================================================
--- trunk/Scribus/scribus/scpainter.cpp (original)
+++ trunk/Scribus/scribus/scpainter.cpp Sun Mar 23 07:24:17 2014
@@ -42,6 +42,7 @@
PLineJoin = Qt::MiterJoin;
fill_gradient = VGradient(VGradient::linear);
stroke_gradient = VGradient(VGradient::linear);
+ setHatchParameters(0, 2, 0, false, QColor(), QColor(), 0.0, 0.0);
m_zoomFactor = 1;
layeredMode = true;
imageMode = true;
@@ -389,6 +390,18 @@
gradPatchP2 = p2;
gradPatchP3 = p3;
gradPatchP4 = p4;
+}
+
+void ScPainter::setHatchParameters(int mode, double distance, double angle, bool useBackground, QColor background, QColor foreground, double width, double height)
+{
+ hatchType = mode;
+ hatchDistance = distance;
+ hatchAngle = angle;
+ hatchUseBackground = useBackground;
+ hatchBackground = background;
+ hatchForeground = foreground;
+ hatchWidth = width;
+ hatchHeight = height;
}
void ScPainter::fillPath()
@@ -1455,6 +1468,96 @@
cairo_surface_destroy (image2);
cairo_set_antialias(m_cr, CAIRO_ANTIALIAS_DEFAULT);
}
+ else if (fillMode == 4)
+ {
+ cairo_path_t *path;
+ path = cairo_copy_path(m_cr);
+ cairo_push_group(m_cr);
+ if (hatchUseBackground && hatchBackground.isValid())
+ {
+ double r2, g2, b2;
+ hatchBackground.getRgbF(&r2, &g2, &b2);
+ cairo_set_source_rgb(m_cr, r2, g2, b2);
+ cairo_fill_preserve(m_cr);
+ }
+ double r, g, b;
+ hatchForeground.getRgbF(&r, &g, &b);
+ cairo_clip_preserve (m_cr);
+ cairo_set_line_width( m_cr, 1 );
+ cairo_set_source_rgb(m_cr, r, g, b);
+ translate(hatchWidth / 2.0, hatchHeight / 2.0);
+ double lineLen = sqrt((hatchWidth / 2.0) * (hatchWidth / 2.0) + (hatchHeight / 2.0) * (hatchHeight / 2.0));
+ double dist = 0.0;
+ while (dist < lineLen)
+ {
+ cairo_save( m_cr );
+ rotate(-hatchAngle);
+ newPath();
+ moveTo(-lineLen, dist);
+ lineTo(lineLen, dist);
+ cairo_stroke( m_cr );
+ if (dist > 0)
+ {
+ newPath();
+ moveTo(-lineLen, -dist);
+ lineTo(lineLen, -dist);
+ cairo_stroke( m_cr );
+ }
+ cairo_restore( m_cr );
+ if ((hatchType == 1) || (hatchType == 2))
+ {
+ cairo_save( m_cr );
+ rotate(-hatchAngle + 90);
+ newPath();
+ moveTo(-lineLen, dist);
+ lineTo(lineLen, dist);
+ cairo_stroke( m_cr );
+ if (dist > 0)
+ {
+ newPath();
+ moveTo(-lineLen, -dist);
+ lineTo(lineLen, -dist);
+ cairo_stroke( m_cr );
+ }
+ cairo_restore( m_cr );
+ }
+ if (hatchType == 2)
+ {
+ cairo_save( m_cr );
+ rotate(-hatchAngle + 45);
+ double dDist = dist * sqrt(2.0);
+ newPath();
+ moveTo(-lineLen, dDist);
+ lineTo(lineLen, dDist);
+ cairo_stroke( m_cr );
+ if (dist > 0)
+ {
+ newPath();
+ moveTo(-lineLen, -dDist);
+ lineTo(lineLen, -dDist);
+ cairo_stroke( m_cr );
+ }
+ cairo_restore( m_cr );
+ }
+ dist += hatchDistance;
+ }
+ cairo_pop_group_to_source (m_cr);
+ setRasterOp(m_blendModeFill);
+ if (maskMode > 0)
+ {
+ cairo_pattern_t *patM = getMaskPattern();
+ cairo_pattern_set_filter(patM, CAIRO_FILTER_FAST);
+ cairo_mask(m_cr, patM);
+ if ((maskMode == 2) || (maskMode == 4) || (maskMode == 5) || (maskMode == 6))
+ cairo_surface_destroy(imageMask);
+ cairo_pattern_destroy(patM);
+ }
+ else
+ cairo_paint_with_alpha (m_cr, fill_trans);
+ newPath();
+ cairo_append_path(m_cr, path);
+ cairo_path_destroy(path);
+ }
cairo_restore( m_cr );
cairo_set_operator(m_cr, CAIRO_OPERATOR_OVER);
}
Modified: trunk/Scribus/scribus/scpainter.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18935&path=/trunk/Scribus/scribus/scpainter.h
==============================================================================
--- trunk/Scribus/scribus/scpainter.h (original)
+++ trunk/Scribus/scribus/scpainter.h Sun Mar 23 07:24:17 2014
@@ -34,7 +34,7 @@
public:
ScPainter( QImage *target, unsigned int w, unsigned int h, double transparency = 1.0, int blendmode = 0 );
virtual ~ScPainter();
- enum FillMode { None, Solid, Gradient, Pattern };
+ enum FillMode { None, Solid, Gradient, Pattern, Hatch };
virtual void beginLayer(double transparency, int blendmode, FPointArray *clipArray = 0);
virtual void endLayer();
virtual void setAntialiasing(bool enable);
@@ -77,6 +77,8 @@
virtual void setDiamondGeometry(FPoint p1, FPoint p2, FPoint p3, FPoint p4, FPoint c1, FPoint c2, FPoint c3, FPoint c4, FPoint c5);
virtual void setMeshGradient(FPoint p1, FPoint p2, FPoint p3, FPoint p4, QList<QList<meshPoint> > meshArray);
virtual void setMeshGradient(FPoint p1, FPoint p2, FPoint p3, FPoint p4, QList<meshGradientPatch> meshPatches);
+
+ virtual void setHatchParameters(int mode, double distance, double angle, bool useBackground, QColor background, QColor foreground, double width, double height);
virtual void setClipPath();
@@ -179,7 +181,7 @@
QColor m_fill;
double fill_trans;
bool m_fillRule;
- int fillMode; // 0 = none, 1 = solid, 2 = gradient 3 = pattern
+ int fillMode; // 0 = none, 1 = solid, 2 = gradient 3 = pattern 4 = hatch
int gradientMode; // 1 = linear, 2 = radial, 3 = 4colour
double patternScaleX;
double patternScaleY;
@@ -207,6 +209,14 @@
QColor gradPatchColor4;
QList<QList<meshPoint> > meshGradientArray;
QList<meshGradientPatch> meshGradientPatches;
+ double hatchAngle;
+ double hatchDistance;
+ int hatchType; // 0 = single 1 = double 2 = triple
+ bool hatchUseBackground;
+ QColor hatchBackground;
+ QColor hatchForeground;
+ double hatchWidth;
+ double hatchHeight;
/*! \brief Stroking */
QColor m_stroke;
double stroke_trans;
Modified: trunk/Scribus/scribus/ui/colorpalette.ui
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18935&path=/trunk/Scribus/scribus/ui/colorpalette.ui
==============================================================================
--- trunk/Scribus/scribus/ui/colorpalette.ui (original)
+++ trunk/Scribus/scribus/ui/colorpalette.ui Sun Mar 23 07:24:17 2014
@@ -14,7 +14,16 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
- <property name="margin">
+ <property name="leftMargin">
+ <number>5</number>
+ </property>
+ <property name="topMargin">
+ <number>5</number>
+ </property>
+ <property name="rightMargin">
+ <number>5</number>
+ </property>
+ <property name="bottomMargin">
<number>5</number>
</property>
<item>
@@ -30,7 +39,16 @@
<property name="spacing">
<number>2</number>
</property>
- <property name="margin">
+ <property name="leftMargin">
+ <number>2</number>
+ </property>
+ <property name="topMargin">
+ <number>2</number>
+ </property>
+ <property name="rightMargin">
+ <number>2</number>
+ </property>
+ <property name="bottomMargin">
<number>2</number>
</property>
<item>
@@ -64,7 +82,16 @@
<property name="spacing">
<number>2</number>
</property>
- <property name="margin">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
<number>0</number>
</property>
<item>
@@ -101,7 +128,16 @@
<property name="spacing">
<number>2</number>
</property>
- <property name="margin">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
<number>0</number>
</property>
<item>
@@ -164,7 +200,16 @@
</property>
<widget class="QWidget" name="page_3">
<layout class="QVBoxLayout" name="verticalLayout_4">
- <property name="margin">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
<number>0</number>
</property>
<item>
@@ -184,7 +229,16 @@
</widget>
<widget class="QWidget" name="page_4">
<layout class="QVBoxLayout" name="verticalLayout_8">
- <property name="margin">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
<number>0</number>
</property>
<item>
@@ -534,12 +588,108 @@
</item>
</layout>
</widget>
+ <widget class="QWidget" name="page">
+ <layout class="QVBoxLayout" name="verticalLayout_12">
+ <item>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_8">
+ <property name="text">
+ <string>Distance:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="ScrSpinBox" name="hatchDist"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_10">
+ <property name="text">
+ <string>Angle:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="ScrSpinBox" name="hatchAngle"/>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_11">
+ <property name="text">
+ <string>Type:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QComboBox" name="hatchType">
+ <item>
+ <property name="text">
+ <string>Single</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Double</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Triple</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_12">
+ <property name="text">
+ <string>Line Color:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="ColorCombo" name="hatchLineColor"/>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_13">
+ <property name="text">
+ <string>Background</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="ColorCombo" name="hatchBackground"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>75</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
<widget class="QWidget" name="patternFillPage">
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="spacing">
<number>2</number>
</property>
- <property name="margin">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
<number>0</number>
</property>
<item>
@@ -605,7 +755,16 @@
<property name="spacing">
<number>2</number>
</property>
- <property name="margin">
+ <property name="leftMargin">
+ <number>2</number>
+ </property>
+ <property name="topMargin">
+ <number>2</number>
+ </property>
+ <property name="rightMargin">
+ <number>2</number>
+ </property>
+ <property name="bottomMargin">
<number>2</number>
</property>
<item>
@@ -639,7 +798,16 @@
<property name="spacing">
<number>2</number>
</property>
- <property name="margin">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
<number>0</number>
</property>
<item>
@@ -676,7 +844,16 @@
<property name="spacing">
<number>2</number>
</property>
- <property name="margin">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
<number>0</number>
</property>
<item>
@@ -733,7 +910,16 @@
<property name="spacing">
<number>2</number>
</property>
- <property name="margin">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
<number>0</number>
</property>
<item>
Modified: trunk/Scribus/scribus/ui/cpalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18935&path=/trunk/Scribus/scribus/ui/cpalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/cpalette.cpp (original)
+++ trunk/Scribus/scribus/ui/cpalette.cpp Sun Mar 23 07:24:17 2014
@@ -78,6 +78,7 @@
setupUi(this);
fillModeCombo->addItem( tr("Solid") );
fillModeCombo->addItem( tr("Gradient") );
+ fillModeCombo->addItem( tr("Hatch") );
fillShade->setDecimals(0);
strokeShade->setDecimals(0);
color1Alpha->setDecimals(0);
@@ -106,6 +107,11 @@
tabFillStroke->setCurrentIndex(0);
setCurrentItem(0);
+ hatchAngle->setDecimals(0);
+ hatchAngle->setNewUnit(6);
+ hatchDist->setDecimals(0);
+ hatchDist->setNewUnit(0);
+ hatchDist->setValues(1, 1000, 0, 1);
/*editFillColorSelector->setChecked(true);
editFillColorSelectorButton();*/
}
@@ -161,6 +167,11 @@
connect(strokeModeCombo , SIGNAL(currentIndexChanged(int)), this, SLOT(slotGradStroke(int)));
connect(tabFillStroke , SIGNAL(currentChanged(int)), this, SLOT(fillStrokeSelector(int)));
connect(transparencyMeshPoint, SIGNAL(valueChanged(double)), this, SLOT(updateMeshPoint()));
+ connect(hatchAngle, SIGNAL(valueChanged(double)), this, SLOT(changeHatchProps()));
+ connect(hatchDist, SIGNAL(valueChanged(double)), this, SLOT(changeHatchProps()));
+ connect(hatchType, SIGNAL(activated(int)), this, SLOT(changeHatchProps()));
+ connect(hatchBackground, SIGNAL(activated(int)), this, SLOT(changeHatchProps()));
+ connect(hatchLineColor, SIGNAL(activated(int)), this, SLOT(changeHatchProps()));
}
void Cpalette::disconnectSignals()
@@ -214,6 +225,11 @@
disconnect(strokeShade , SIGNAL(valueChanged(double)), this, SIGNAL(NewPenShade(double)));
disconnect(tabFillStroke , SIGNAL(currentChanged(int)), this, SLOT(fillStrokeSelector(int)));
disconnect(transparencyMeshPoint, SIGNAL(valueChanged(double)), this, SLOT(updateMeshPoint()));
+ disconnect(hatchAngle, SIGNAL(valueChanged(double)), this, SLOT(changeHatchProps()));
+ disconnect(hatchDist, SIGNAL(valueChanged(double)), this, SLOT(changeHatchProps()));
+ disconnect(hatchType, SIGNAL(activated(int)), this, SLOT(changeHatchProps()));
+ disconnect(hatchBackground, SIGNAL(activated(int)), this, SLOT(changeHatchProps()));
+ disconnect(hatchLineColor, SIGNAL(activated(int)), this, SLOT(changeHatchProps()));
}
void Cpalette::setCurrentItem(PageItem* item)
@@ -392,15 +408,15 @@
{
if (enable)
{
- if (fillModeCombo->count() < 3)
+ if (fillModeCombo->count() < 4)
fillModeCombo->addItem( tr("Pattern") );
if (strokeModeCombo->count() < 3)
strokeModeCombo->addItem( tr("Pattern") );
}
else
{
- if (fillModeCombo->count() == 3)
- fillModeCombo->removeItem(2);
+ if (fillModeCombo->count() == 4)
+ fillModeCombo->removeItem(3);
if (strokeModeCombo->count() == 3)
strokeModeCombo->removeItem(2);
}
@@ -458,6 +474,8 @@
colorListFill->currentItem()->setSelected(false);
if (colorListStroke->currentItem())
colorListStroke->currentItem()->setSelected(false);
+ hatchLineColor->updateBox(colorList, ColorCombo::fancyPixmaps, false);
+ hatchBackground->updateBox(colorList, ColorCombo::fancyPixmaps, true);
colorListStroke->blockSignals(sigBlocked1);
colorListFill->blockSignals(sigBlocked2);
@@ -984,6 +1002,22 @@
}
fillModeCombo->setCurrentIndex(1);
}
+ else if (number == 14)
+ {
+ fillModeCombo->setCurrentIndex(2);
+ hatchAngle->setValue(currentItem->hatchAngle);
+ hatchDist->setValue(currentItem->hatchDistance * unitGetRatioFromIndex(currentUnit));
+ hatchType->setCurrentIndex(currentItem->hatchType);
+ if ((currentItem->hatchForeground != CommonStrings::None) && (!currentItem->hatchForeground.isEmpty()))
+ setCurrentComboItem(hatchLineColor, currentItem->hatchForeground);
+ if (currentItem->hatchUseBackground)
+ {
+ if (!currentItem->hatchBackground.isEmpty())
+ setCurrentComboItem(hatchBackground, currentItem->hatchBackground);
+ }
+ else
+ setCurrentComboItem(hatchBackground, CommonStrings::None);
+ }
else
{
if (patternList->count() == 0)
@@ -992,7 +1026,7 @@
emit NewGradient(0);
}
else
- fillModeCombo->setCurrentIndex(2);
+ fillModeCombo->setCurrentIndex(3);
}
fillModeStack->setCurrentIndex( fillModeCombo->currentIndex() );
fillModeCombo->blockSignals(sigBlocked);
@@ -1115,6 +1149,22 @@
namedGradient->blockSignals(sigBlocked3);
}
else if (number == 2)
+ {
+ hatchAngle->setValue(currentItem->hatchAngle);
+ hatchDist->setValue(currentItem->hatchDistance * unitGetRatioFromIndex(currentUnit));
+ hatchType->setCurrentIndex(currentItem->hatchType);
+ if ((currentItem->hatchForeground != CommonStrings::None) && (!currentItem->hatchForeground.isEmpty()))
+ setCurrentComboItem(hatchLineColor, currentItem->hatchForeground);
+ if (currentItem->hatchUseBackground)
+ {
+ if (!currentItem->hatchBackground.isEmpty())
+ setCurrentComboItem(hatchBackground, currentItem->hatchBackground);
+ }
+ else
+ setCurrentComboItem(hatchBackground, CommonStrings::None);
+ emit NewGradient(14);
+ }
+ else if (number == 3)
emit NewGradient(8);
else
emit NewGradient(0);
@@ -1692,7 +1742,7 @@
m_Pattern_mirrorX = dia->FlipH->isChecked();
m_Pattern_mirrorY = dia->FlipV->isChecked();
delete dia;
- fillModeCombo->setCurrentIndex(2);
+ fillModeCombo->setCurrentIndex(3);
emit NewGradient(8);
}
@@ -1751,6 +1801,22 @@
delete dia;
}
+void Cpalette::changeHatchProps()
+{
+ QString color1 = hatchLineColor->currentText();
+ if (color1 == CommonStrings::tr_NoneColor)
+ color1 = CommonStrings::None;
+ QString color2 = hatchBackground->currentText();
+ if (color2 == CommonStrings::tr_NoneColor)
+ color2 = CommonStrings::None;
+ bool useB = (color2 != CommonStrings::None);
+ double angle = hatchAngle->value();
+ double dist = hatchDist->value() / unitGetRatioFromIndex(currentUnit);
+ currentItem->setHatchParameters(hatchType->currentIndex(), dist, angle, useB, color2, color1);
+ currentItem->update();
+ currentDoc->regionsChanged()->update(QRect());
+}
+
void Cpalette::toggleStrokePattern()
{
emit NewPatternTypeS(followsPath->isChecked());
@@ -1760,5 +1826,6 @@
{
if (CGradDia)
CGradDia->unitChange(unitIndex);
+ hatchDist->setNewUnit(unitIndex);
currentUnit = unitIndex;
}
Modified: trunk/Scribus/scribus/ui/cpalette.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18935&path=/trunk/Scribus/scribus/ui/cpalette.h
==============================================================================
--- trunk/Scribus/scribus/ui/cpalette.h (original)
+++ trunk/Scribus/scribus/ui/cpalette.h Sun Mar 23 07:24:17 2014
@@ -126,6 +126,7 @@
void changePatternProps();
void changePatternPropsStroke();
void toggleStrokePattern();
+ void changeHatchProps();
void unitChange(double, double, int unitIndex);
signals:
void NewPen(QString);
More information about the scribus-commit
mailing list