Commit ed41c2e2 authored by Enrico Ros's avatar Enrico Ros
Browse files

Using line width property. Line width follows scaling.

svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=405443
parent ee4908bf
......@@ -2,7 +2,7 @@
<!--
Engine/Annotation Types [specific attributes]:
[color]
SmoothLine [lowPassFilter{true,false}]
SmoothLine [lowPassFilter{true,false}] [orthoSnap{true,false}]
[color]
[opacity]
Highlight
......@@ -17,39 +17,41 @@ Engine/Annotation Types [specific attributes]:
Geom
-->
<annotatingTools>
<tool id="1" name="Yellow Highlighter" pixmap="tool_hl_yellow">
<tooltip>this ..</tooltip>
<engine type="SmoothLine" color="#FFFF00">
<annotation type="Highlight" color="#FFFF00" />
</engine>
<shortcut>1</shortcut>
<tool id="1" name="Pink Highlighter" pixmap="tool_ink_green">
<tooltip>.. is ..</tooltip>
<engine type="SmoothLine" color="#00FF00">
<annotation type="Ink" color="#00FF00" width="2" />
</engine>
<shortcut>1</shortcut>
</tool>
<tool id="2" name="Pink Highlighter" pixmap="tool_hl_pink">
<tooltip>.. is ..</tooltip>
<engine type="SmoothLine" color="#FF0080">
<annotation type="Ink" color="#FF0080" />
</engine>
<shortcut>2</shortcut>
<tool id="2" name="Pink Highlighter" pixmap="tool_ink_green">
<tooltip>.. is ..</tooltip>
<engine type="SmoothLine" color="#FF0080">
<annotation type="Ink" color="#FF0080" width="4" />
</engine>
<shortcut>2</shortcut>
</tool>
<tool id="3" name="Yellow Highlighter" pixmap="tool_hl_yellow">
<tooltip>this ..</tooltip>
<engine type="SmoothLine" color="#FFFF00">
<annotation type="Highlight" color="#FFFF00" />
</engine>
<shortcut>3</shortcut>
</tool>
<tool id="3" name="note" pixmap="pinnote">
<tool id="4" name="note" pixmap="pinnote">
<tooltip>.. tooltip ..</tooltip>
<engine type="PickPoint" color="#FF00FF" hoverIcon="too_note">
<annotation type="Text" color="#FF00FF" />
</engine>
<shortcut>4</shortcut>
</tool>
<tool id="4" name="Straight Yellow Line" pixmap="tool_ink_green">
<tool id="5" name="Straight Yellow Line" pixmap="tool_ink_green">
<tooltip>.. test</tooltip>
<engine type="TwoPoints" color="#FFE000">
<annotation type="Line" width="4" color="#FFE000" />
</engine>
<shortcut>5</shortcut>
</tool>
<tool id="5" name="Arrowed Black Line" pixmap="color_line">
<engine type="TwoPoints">
<annotation type="Line" />
</engine>
<shortcut>6</shortcut>
</tool>
<tool id="6" name="Warning Stamp" pixmap="messagebox_warning">
<engine type="PickPoint" hoverIcon="messagebox_warning">
<annotation type="Stamp" icon="messagebox_warning" />
......
......@@ -242,10 +242,11 @@ void PagePainter::paintPageOnPainter( QPainter * destPainter, const KPDFPage * p
if ( bufferedAnnotations )
{
// precalc costants for normalizing the quads to the image
double xOffset = (float)limits.left() / (float)scaledWidth,
xScale = (float)scaledWidth / (float)limits.width(),
yOffset = (float)limits.top() / (float)scaledHeight,
yScale = (float)scaledHeight / (float)limits.height();
double pageScale = (double)scaledWidth / page->width();
double xOffset = (double)limits.left() / (double)scaledWidth,
xScale = (double)scaledWidth / (double)limits.width(),
yOffset = (double)limits.top() / (double)scaledHeight,
yScale = (double)scaledHeight / (double)limits.height();
// paint all buffered annotations in the page
QValueList< Annotation * >::const_iterator aIt = bufferedAnnotations->begin(), aEnd = bufferedAnnotations->end();
......@@ -274,7 +275,7 @@ void PagePainter::paintPageOnPainter( QPainter * destPainter, const KPDFPage * p
point.y = (inkPoint.y - yOffset) * yScale;
path.append( point );
// draw the normalized path into image
drawShapeOnImage( backImage, path, false, QPen( a->style.color ), QBrush() );
drawShapeOnImage( backImage, path, false, QPen( a->style.color ), QBrush(), pageScale );
*/
}
// draw GeomAnnotation MISSING: all
......@@ -308,7 +309,7 @@ void PagePainter::paintPageOnPainter( QPainter * destPainter, const KPDFPage * p
{
// highlight the whole rect
case HighlightAnnotation::Highlight:
drawShapeOnImage( backImage, path, true, QPen(), a->style.color, Multiply );
drawShapeOnImage( backImage, path, true, QPen(), a->style.color, pageScale, Multiply );
break;
// highlight the bottom part of the rect
case HighlightAnnotation::Squiggly:
......@@ -316,7 +317,7 @@ void PagePainter::paintPageOnPainter( QPainter * destPainter, const KPDFPage * p
path[ 0 ].y = ( path[ 0 ].y + path[ 3 ].y ) / 2.0;
path[ 1 ].x = ( path[ 1 ].x + path[ 2 ].x ) / 2.0;
path[ 1 ].y = ( path[ 1 ].y + path[ 2 ].y ) / 2.0;
drawShapeOnImage( backImage, path, true, QPen(), a->style.color, Multiply );
drawShapeOnImage( backImage, path, true, QPen(), a->style.color, pageScale, Multiply );
break;
// make a line at 3/4 of the height
case HighlightAnnotation::Underline:
......@@ -326,7 +327,7 @@ void PagePainter::paintPageOnPainter( QPainter * destPainter, const KPDFPage * p
path[ 1 ].y = ( path[ 1 ].y + 3*path[ 2 ].y ) / 4.0;
path.pop_back();
path.pop_back();
drawShapeOnImage( backImage, path, false, QPen( a->style.color, 2 ), QBrush() );
drawShapeOnImage( backImage, path, false, QPen( a->style.color, 2 ), QBrush(), pageScale );
break;
// make a line at 1/2 of the height
case HighlightAnnotation::StrikeOut:
......@@ -336,7 +337,7 @@ void PagePainter::paintPageOnPainter( QPainter * destPainter, const KPDFPage * p
path[ 1 ].y = ( path[ 1 ].y + path[ 2 ].y ) / 2.0;
path.pop_back();
path.pop_back();
drawShapeOnImage( backImage, path, false, QPen( a->style.color, 2 ), QBrush() );
drawShapeOnImage( backImage, path, false, QPen( a->style.color, 2 ), QBrush(), pageScale );
break;
}
}
......@@ -365,7 +366,7 @@ void PagePainter::paintPageOnPainter( QPainter * destPainter, const KPDFPage * p
path.append( point );
}
// draw the normalized path into image
drawShapeOnImage( backImage, path, false, QPen( a->style.color, 2 ), QBrush() );
drawShapeOnImage( backImage, path, false, QPen( a->style.color, a->style.width ), QBrush(), pageScale );
}
}
} // end current annotation drawing
......@@ -644,6 +645,7 @@ void PagePainter::drawShapeOnImage(
bool closeShape,
const QPen & pen,
const QBrush & brush,
double penWidthMultiplier,
RasterOperation op
//float antiAliasRadius
)
......@@ -701,12 +703,13 @@ void PagePainter::drawShapeOnImage(
}
// stroke outline
if ( pen.width() != 0 )
double penWidth = (double)pen.width() * penWidthMultiplier;
if ( penWidth > 0.1 )
{
const QColor & penColor = pen.color();
render.color( agg::rgba8( penColor.red(), penColor.green(), penColor.blue() ) );
agg::conv_stroke< agg::path_storage > strokedPath( path );
strokedPath.width( pen.width() );
strokedPath.width( penWidth );
rasterizer.add_path( strokedPath );
agg::render_scanlines( rasterizer, scanline, render );
}
......
......@@ -60,6 +60,7 @@ class PagePainter
bool closeShape = true,
const QPen & pen = QPen(),
const QBrush & brush = QBrush(),
double penWidthMultiplier = 1.0,
RasterOperation op = Normal
//float antiAliasRadius = 1.0
);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment