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++ )
|
for ( int i = iStart; i < iEnd; i++ )
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
painter->translate( mOrigins[i].x().pt(), mOrigins[i].y().pt() );
|
painter->translate( mOrigins[i].x().pt(), mOrigins[i].y().pt() );
|
||||||
|
|
||||||
painter->save();
|
painter->save();
|
||||||
clipLabel( painter );
|
|
||||||
|
|
||||||
|
clipLabel( painter );
|
||||||
printLabel( painter, 0 );
|
printLabel( painter, 0 );
|
||||||
|
|
||||||
painter->restore(); // From before clip
|
painter->restore(); // From before clip
|
||||||
@@ -224,7 +225,7 @@ void PageRenderer::printOutline( QPainter* painter ) const
|
|||||||
|
|
||||||
void PageRenderer::clipLabel( 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 bool isSimilarTo( Frame* other ) const = 0;
|
||||||
|
|
||||||
virtual const QPainterPath& path() const = 0;
|
virtual const QPainterPath& path() const = 0;
|
||||||
|
virtual const QPainterPath& clipPath() const = 0;
|
||||||
virtual QPainterPath marginPath( const Distance& size ) const = 0;
|
virtual QPainterPath marginPath( const Distance& size ) const = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+51
-13
@@ -41,22 +41,54 @@ namespace glabels
|
|||||||
Distance wReal = (mW == 0) ? 2*mR1 : mW;
|
Distance wReal = (mW == 0) ? 2*mR1 : mW;
|
||||||
Distance hReal = (mH == 0) ? 2*mR1 : mH;
|
Distance hReal = (mH == 0) ? 2*mR1 : mH;
|
||||||
|
|
||||||
/*
|
//
|
||||||
* Construct outer subpath (may be clipped if it's a business card CD)
|
// Create path
|
||||||
*/
|
//
|
||||||
QPainterPath outerPath;
|
{
|
||||||
outerPath.addEllipse( (wReal/2 - r1).pt(), (hReal/2 - r1).pt(), 2*r1.pt(), 2*r1.pt() );
|
/*
|
||||||
|
* Construct outer subpath (may be clipped if it's a business card CD)
|
||||||
|
*/
|
||||||
|
QPainterPath outerPath;
|
||||||
|
outerPath.addEllipse( (wReal/2 - r1).pt(), (hReal/2 - r1).pt(), 2*r1.pt(), 2*r1.pt() );
|
||||||
|
|
||||||
QPainterPath clipPath;
|
QPainterPath clipPath;
|
||||||
clipPath.addRect( 0, 0, wReal.pt(), hReal.pt() );
|
clipPath.addRect( 0, 0, wReal.pt(), hReal.pt() );
|
||||||
|
|
||||||
mPath.addPath( outerPath & clipPath );
|
mPath.addPath( outerPath & clipPath );
|
||||||
mPath.closeSubpath();
|
mPath.closeSubpath();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add inner subpath
|
* Add inner subpath
|
||||||
*/
|
*/
|
||||||
mPath.addEllipse( (wReal/2 - r2).pt(), (hReal/2 - r2).pt(), 2*r2.pt(), 2*r2.pt() );
|
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() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -128,6 +160,12 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QPainterPath& FrameCd::clipPath() const
|
||||||
|
{
|
||||||
|
return mClipPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QPainterPath FrameCd::marginPath( const Distance& size ) const
|
QPainterPath FrameCd::marginPath( const Distance& size ) const
|
||||||
{
|
{
|
||||||
Distance wReal = (mW == 0) ? 2*mR1 : mW;
|
Distance wReal = (mW == 0) ? 2*mR1 : mW;
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ namespace glabels
|
|||||||
bool isSimilarTo( Frame* other ) const;
|
bool isSimilarTo( Frame* other ) const;
|
||||||
|
|
||||||
const QPainterPath& path() const;
|
const QPainterPath& path() const;
|
||||||
|
const QPainterPath& clipPath() const;
|
||||||
QPainterPath marginPath( const Distance& size ) const;
|
QPainterPath marginPath( const Distance& size ) const;
|
||||||
|
|
||||||
|
|
||||||
@@ -63,6 +64,7 @@ namespace glabels
|
|||||||
Distance mWaste;
|
Distance mWaste;
|
||||||
|
|
||||||
QPainterPath mPath;
|
QPainterPath mPath;
|
||||||
|
QPainterPath mClipPath;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ namespace glabels
|
|||||||
: mW(w), mH(h), mWaste(waste), Frame(id)
|
: mW(w), mH(h), mWaste(waste), Frame(id)
|
||||||
{
|
{
|
||||||
mPath.addEllipse( 0, 0, mW.pt(), mH.pt() );
|
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 )
|
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
|
QPainterPath FrameEllipse::marginPath( const Distance& size ) const
|
||||||
{
|
{
|
||||||
Distance w = mW - 2*size;
|
Distance w = mW - 2*size;
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ namespace glabels
|
|||||||
bool isSimilarTo( Frame* other ) const;
|
bool isSimilarTo( Frame* other ) const;
|
||||||
|
|
||||||
const QPainterPath& path() const;
|
const QPainterPath& path() const;
|
||||||
|
const QPainterPath& clipPath() const;
|
||||||
QPainterPath marginPath( const Distance& size ) const;
|
QPainterPath marginPath( const Distance& size ) const;
|
||||||
|
|
||||||
|
|
||||||
@@ -58,6 +59,7 @@ namespace glabels
|
|||||||
Distance mWaste;
|
Distance mWaste;
|
||||||
|
|
||||||
QPainterPath mPath;
|
QPainterPath mPath;
|
||||||
|
QPainterPath mClipPath;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ namespace glabels
|
|||||||
: mW(w), mH(h), mR(r), mXWaste(xWaste), mYWaste(yWaste), Frame(id)
|
: mW(w), mH(h), mR(r), mXWaste(xWaste), mYWaste(yWaste), Frame(id)
|
||||||
{
|
{
|
||||||
mPath.addRoundedRect( 0, 0, mW.pt(), mH.pt(), mR.pt(), mR.pt() );
|
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
|
QPainterPath FrameRect::marginPath( const Distance& size ) const
|
||||||
{
|
{
|
||||||
Distance w = mW - 2*size;
|
Distance w = mW - 2*size;
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ namespace glabels
|
|||||||
bool isSimilarTo( Frame* other ) const;
|
bool isSimilarTo( Frame* other ) const;
|
||||||
|
|
||||||
const QPainterPath& path() const;
|
const QPainterPath& path() const;
|
||||||
|
const QPainterPath& clipPath() const;
|
||||||
QPainterPath marginPath( const Distance& size ) const;
|
QPainterPath marginPath( const Distance& size ) const;
|
||||||
|
|
||||||
|
|
||||||
@@ -64,6 +65,7 @@ namespace glabels
|
|||||||
Distance mYWaste;
|
Distance mYWaste;
|
||||||
|
|
||||||
QPainterPath mPath;
|
QPainterPath mPath;
|
||||||
|
QPainterPath mClipPath;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ namespace glabels
|
|||||||
: mR(r), mWaste(waste), Frame(id)
|
: mR(r), mWaste(waste), Frame(id)
|
||||||
{
|
{
|
||||||
mPath.addEllipse( 0, 0, 2*mR.pt(), 2*mR.pt() );
|
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
|
QPainterPath FrameRound::marginPath( const Distance& size ) const
|
||||||
{
|
{
|
||||||
Distance r = mR - size;
|
Distance r = mR - size;
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ namespace glabels
|
|||||||
bool isSimilarTo( Frame* other ) const;
|
bool isSimilarTo( Frame* other ) const;
|
||||||
|
|
||||||
const QPainterPath& path() const;
|
const QPainterPath& path() const;
|
||||||
|
const QPainterPath& clipPath() const;
|
||||||
QPainterPath marginPath( const Distance& size ) const;
|
QPainterPath marginPath( const Distance& size ) const;
|
||||||
|
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ namespace glabels
|
|||||||
Distance mWaste;
|
Distance mWaste;
|
||||||
|
|
||||||
QPainterPath mPath;
|
QPainterPath mPath;
|
||||||
|
QPainterPath mClipPath;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user