Initial implementation of TemplatePicker. Debugged mini previews.

This commit is contained in:
Jim Evins
2013-11-05 23:51:48 -05:00
parent fe4595bde0
commit ba83204445
11 changed files with 149 additions and 18 deletions
+15 -1
View File
@@ -43,11 +43,25 @@ namespace libglabels
private:
Db();
public:
static void init() { instance(); }
static Db *instance() { static Db *db = new Db(); return db; }
static const QList<Paper*> &papers() { return mPapers; }
static const QStringList &paperIds() { return mPaperIds; }
static const QStringList &paperNames() { return mPaperNames; }
static const QList<Category*> &categories() { return mCategories; }
static const QStringList &categoryIds() { return mCategoryIds; }
static const QStringList &categoryNames() { return mCategoryNames; }
static const QList<Vendor*> &vendors() { return mVendors; }
static const QStringList &vendorNames() { return mVendorNames; }
static const QList<Template*> &templates() { return mTemplates; }
static void registerPaper( Paper *paper );
static const Paper *lookupPaperFromName( const QString &name );
static const Paper *lookupPaperFromId( const QString &id );
+2 -1
View File
@@ -45,13 +45,14 @@ namespace libglabels
{
QVector<Point> origins( nLabels() );
int i = 0;
foreach ( Layout *layout, mLayouts )
{
for ( int iy = 0; iy < layout->ny(); iy++ )
{
for ( int ix = 0; ix < layout->nx(); ix++ )
{
origins << Point( ix*layout->dx() + layout->x0(), iy*layout->dy() + layout->y0() );
origins[i++] = Point( ix*layout->dx() + layout->x0(), iy*layout->dy() + layout->y0() );
}
}
}
+9 -8
View File
@@ -70,21 +70,22 @@ namespace libglabels
void FrameCd::initPath()
{
double xc = w()/2;
double yc = h()/2;
// Outer path (may be clipped in the case business card type CD)
double theta1 = acos( w() / (2*mR1) ) * 180/M_PI;
double theta2 = asin( h() / (2*mR1) ) * 180/M_PI;
mPath.arcTo( 0, 0, 2*mR1, 2*mR1, theta1, theta2 );
mPath.arcTo( 0, 0, 2*mR1, 2*mR1, 180-theta2, 180-theta1 );
mPath.arcTo( 0, 0, 2*mR1, 2*mR1, 180+theta1, 180+theta2 );
mPath.arcTo( 0, 0, 2*mR1, 2*mR1, 360-theta2, 360-theta1 );
mPath.arcMoveTo( 0, 0, 2*mR1, 2*mR1, theta1 );
mPath.arcTo( 0, 0, 2*mR1, 2*mR1, theta1, theta2-theta1 );
mPath.arcTo( 0, 0, 2*mR1, 2*mR1, 180-theta2, theta2-theta1 );
mPath.arcTo( 0, 0, 2*mR1, 2*mR1, 180+theta1, theta2-theta1 );
mPath.arcTo( 0, 0, 2*mR1, 2*mR1, 360-theta2, theta2-theta1 );
mPath.closeSubpath();
// Inner path (hole)
mPath.addEllipse( xc-mR2, yc-mR2, 2*mR2, 2*mR2 );
mPath.addEllipse( mR1-mR2, mR1-mR2, 2*mR2, 2*mR2 );
// Translate to account for offset with clipped business card CDs (applies to element already drawn)
mPath.translate( w()/2 - mR1, h()/2 - mR1 );
}
}
+3 -1
View File
@@ -40,10 +40,12 @@ namespace libglabels
void MiniPreviewPixmap::draw( const Template *tmplate, int width, int height )
{
fill( Qt::transparent );
QPainter painter( this );
painter.setBackgroundMode( Qt::TransparentMode );
painter.setRenderHint( QPainter::Antialiasing );
painter.setRenderHint( QPainter::Antialiasing, true );
double w = width - 1;
double h = height - 1;
+1 -4
View File
@@ -23,9 +23,6 @@
#include <iostream>
#include "Db.h"
#include "privateConstants.h"
using namespace libglabels::Constants;
namespace libglabels
@@ -103,7 +100,7 @@ namespace libglabels
void Template::initPreview()
{
mPreview = MiniPreviewPixmap( this, PREVIEW_PIXMAP_SIZE, PREVIEW_PIXMAP_SIZE );
mPreview = MiniPreviewPixmap( this, TEMPLATE_PREVIEW_SIZE, TEMPLATE_PREVIEW_SIZE );
}
+4
View File
@@ -37,11 +37,15 @@
namespace libglabels
{
const int TEMPLATE_PREVIEW_SIZE = 80;
class Template
{
Q_DECLARE_TR_FUNCTIONS(Template)
public:
Template( const QString &brand,
const QString &part,
const QString &description,
-2
View File
@@ -32,8 +32,6 @@ namespace libglabels
{
const double EPSILON = 0.5; /* Allowed error when comparing dimensions. (0.5pts ~= .007in ~= .2mm) */
const int PREVIEW_PIXMAP_SIZE = 72;
}
}