Added label clip path to page renderer.
This commit is contained in:
@@ -175,11 +175,12 @@ void PageRenderer::printSimplePage( QPainter* painter, int iPage ) const
|
||||
for ( int i = iStart; i < iEnd; i++ )
|
||||
{
|
||||
painter->save();
|
||||
|
||||
painter->translate( mOrigins[i].x().pt(), mOrigins[i].y().pt() );
|
||||
|
||||
painter->save();
|
||||
clipLabel( painter );
|
||||
|
||||
clipLabel( painter );
|
||||
printLabel( painter, 0 );
|
||||
|
||||
painter->restore(); // From before clip
|
||||
@@ -224,7 +225,7 @@ void PageRenderer::printOutline( QPainter* painter ) const
|
||||
|
||||
void PageRenderer::clipLabel( QPainter* painter ) const
|
||||
{
|
||||
// TODO: add clipPath() method to frame
|
||||
painter->setClipPath( mModel->frame()->clipPath() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ namespace glabels
|
||||
virtual bool isSimilarTo( Frame* other ) const = 0;
|
||||
|
||||
virtual const QPainterPath& path() const = 0;
|
||||
virtual const QPainterPath& clipPath() const = 0;
|
||||
virtual QPainterPath marginPath( const Distance& size ) const = 0;
|
||||
|
||||
|
||||
|
||||
@@ -41,6 +41,10 @@ namespace glabels
|
||||
Distance wReal = (mW == 0) ? 2*mR1 : mW;
|
||||
Distance hReal = (mH == 0) ? 2*mR1 : mH;
|
||||
|
||||
//
|
||||
// Create path
|
||||
//
|
||||
{
|
||||
/*
|
||||
* Construct outer subpath (may be clipped if it's a business card CD)
|
||||
*/
|
||||
@@ -59,6 +63,34 @@ namespace glabels
|
||||
mPath.addEllipse( (wReal/2 - r2).pt(), (hReal/2 - r2).pt(), 2*r2.pt(), 2*r2.pt() );
|
||||
}
|
||||
|
||||
//
|
||||
// Create clip path
|
||||
//
|
||||
{
|
||||
Distance r1Clip = mR1 + mWaste;
|
||||
Distance r2Clip = mR2 - mWaste;
|
||||
Distance wClip = (mW == 0) ? 2*r1Clip : mW + 2*mWaste;
|
||||
Distance hClip = (mH == 0) ? 2*r1Clip : mH + 2*mWaste;
|
||||
|
||||
/*
|
||||
* Construct outer subpath (may be clipped if it's a business card CD)
|
||||
*/
|
||||
QPainterPath outerPath;
|
||||
outerPath.addEllipse( (wReal/2 - r1Clip).pt(), (hReal/2 - r1Clip).pt(), 2*r1Clip.pt(), 2*r1Clip.pt() );
|
||||
|
||||
QPainterPath clipPath;
|
||||
clipPath.addRect( -mWaste.pt(), -mWaste.pt(), wClip.pt(), hClip.pt() );
|
||||
|
||||
mClipPath.addPath( outerPath & clipPath );
|
||||
mClipPath.closeSubpath();
|
||||
|
||||
/*
|
||||
* Add inner subpath
|
||||
*/
|
||||
mClipPath.addEllipse( (wReal/2 - r2Clip).pt(), (hReal/2 - r2Clip).pt(), 2*r2Clip.pt(), 2*r2Clip.pt() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FrameCd::FrameCd( const FrameCd& other )
|
||||
: mR1(other.mR1), mR2(other.mR2), mW(other.mW), mH(other.mH), mWaste(other.mWaste),
|
||||
@@ -128,6 +160,12 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
const QPainterPath& FrameCd::clipPath() const
|
||||
{
|
||||
return mClipPath;
|
||||
}
|
||||
|
||||
|
||||
QPainterPath FrameCd::marginPath( const Distance& size ) const
|
||||
{
|
||||
Distance wReal = (mW == 0) ? 2*mR1 : mW;
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace glabels
|
||||
bool isSimilarTo( Frame* other ) const;
|
||||
|
||||
const QPainterPath& path() const;
|
||||
const QPainterPath& clipPath() const;
|
||||
QPainterPath marginPath( const Distance& size ) const;
|
||||
|
||||
|
||||
@@ -63,6 +64,7 @@ namespace glabels
|
||||
Distance mWaste;
|
||||
|
||||
QPainterPath mPath;
|
||||
QPainterPath mClipPath;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace glabels
|
||||
: mW(w), mH(h), mWaste(waste), Frame(id)
|
||||
{
|
||||
mPath.addEllipse( 0, 0, mW.pt(), mH.pt() );
|
||||
mClipPath.addEllipse( -mWaste.pt(), -mWaste.pt(), (mW+2*mWaste).pt(), (mH+2*mWaste).pt() );
|
||||
}
|
||||
|
||||
FrameEllipse::FrameEllipse( const FrameEllipse& other )
|
||||
@@ -104,6 +105,12 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
const QPainterPath& FrameEllipse::clipPath() const
|
||||
{
|
||||
return mClipPath;
|
||||
}
|
||||
|
||||
|
||||
QPainterPath FrameEllipse::marginPath( const Distance& size ) const
|
||||
{
|
||||
Distance w = mW - 2*size;
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace glabels
|
||||
bool isSimilarTo( Frame* other ) const;
|
||||
|
||||
const QPainterPath& path() const;
|
||||
const QPainterPath& clipPath() const;
|
||||
QPainterPath marginPath( const Distance& size ) const;
|
||||
|
||||
|
||||
@@ -58,6 +59,7 @@ namespace glabels
|
||||
Distance mWaste;
|
||||
|
||||
QPainterPath mPath;
|
||||
QPainterPath mClipPath;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -38,6 +38,10 @@ namespace glabels
|
||||
: mW(w), mH(h), mR(r), mXWaste(xWaste), mYWaste(yWaste), Frame(id)
|
||||
{
|
||||
mPath.addRoundedRect( 0, 0, mW.pt(), mH.pt(), mR.pt(), mR.pt() );
|
||||
|
||||
mClipPath.addRoundedRect( -mXWaste.pt(), -mYWaste.pt(),
|
||||
mW.pt() + 2*mXWaste.pt(), mH.pt() + 2*mYWaste.pt(),
|
||||
mR.pt(), mR.pt() );
|
||||
}
|
||||
|
||||
|
||||
@@ -108,6 +112,12 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
const QPainterPath& FrameRect::clipPath() const
|
||||
{
|
||||
return mClipPath;
|
||||
}
|
||||
|
||||
|
||||
QPainterPath FrameRect::marginPath( const Distance& size ) const
|
||||
{
|
||||
Distance w = mW - 2*size;
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace glabels
|
||||
bool isSimilarTo( Frame* other ) const;
|
||||
|
||||
const QPainterPath& path() const;
|
||||
const QPainterPath& clipPath() const;
|
||||
QPainterPath marginPath( const Distance& size ) const;
|
||||
|
||||
|
||||
@@ -64,6 +65,7 @@ namespace glabels
|
||||
Distance mYWaste;
|
||||
|
||||
QPainterPath mPath;
|
||||
QPainterPath mClipPath;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace glabels
|
||||
: mR(r), mWaste(waste), Frame(id)
|
||||
{
|
||||
mPath.addEllipse( 0, 0, 2*mR.pt(), 2*mR.pt() );
|
||||
mClipPath.addEllipse( -mWaste.pt(), -mWaste.pt(), 2*(mR+mWaste).pt(), 2*(mR+mWaste).pt() );
|
||||
}
|
||||
|
||||
|
||||
@@ -102,6 +103,12 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
const QPainterPath& FrameRound::clipPath() const
|
||||
{
|
||||
return mClipPath;
|
||||
}
|
||||
|
||||
|
||||
QPainterPath FrameRound::marginPath( const Distance& size ) const
|
||||
{
|
||||
Distance r = mR - size;
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace glabels
|
||||
bool isSimilarTo( Frame* other ) const;
|
||||
|
||||
const QPainterPath& path() const;
|
||||
const QPainterPath& clipPath() const;
|
||||
QPainterPath marginPath( const Distance& size ) const;
|
||||
|
||||
|
||||
@@ -57,6 +58,7 @@ namespace glabels
|
||||
Distance mWaste;
|
||||
|
||||
QPainterPath mPath;
|
||||
QPainterPath mClipPath;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user