Some style cleanup to libglabels.
This commit is contained in:
@@ -19,3 +19,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Category.h"
|
#include "Category.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
Category::Category( const QString &id, const QString &name )
|
||||||
|
: mId(id), mName(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+11
-6
@@ -30,19 +30,24 @@ namespace libglabels
|
|||||||
|
|
||||||
class Category
|
class Category
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
Category( const QString &id, const QString &name ) : mId(id), mName(name)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const QString &id() const { return mId; }
|
public:
|
||||||
inline const QString &name() const { return mName; }
|
Category( const QString& id, const QString& name );
|
||||||
|
|
||||||
|
const QString& id() const;
|
||||||
|
const QString& name() const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString mId;
|
QString mId;
|
||||||
QString mName;
|
QString mName;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "Category.inl"
|
||||||
|
|
||||||
|
|
||||||
#endif // libglabels_Category_h
|
#endif // libglabels_Category_h
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/* Category.inl
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||||
|
*
|
||||||
|
* This file is part of gLabels-qt.
|
||||||
|
*
|
||||||
|
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gLabels-qt is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
inline const QString& Category::id() const
|
||||||
|
{
|
||||||
|
return mId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const QString& Category::name() const
|
||||||
|
{
|
||||||
|
return mName;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -67,6 +67,19 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Db::init()
|
||||||
|
{
|
||||||
|
instance();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Db* Db::instance()
|
||||||
|
{
|
||||||
|
static Db* db = new Db();
|
||||||
|
return db;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Db::registerPaper( Paper *paper )
|
void Db::registerPaper( Paper *paper )
|
||||||
{
|
{
|
||||||
if ( !isPaperIdKnown( paper->id() ) )
|
if ( !isPaperIdKnown( paper->id() ) )
|
||||||
|
|||||||
+19
-13
@@ -44,22 +44,22 @@ namespace libglabels
|
|||||||
Db();
|
Db();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void init() { instance(); }
|
static void init();
|
||||||
static Db *instance() { static Db *db = new Db(); return db; }
|
static Db* instance();
|
||||||
|
|
||||||
|
|
||||||
static const QList<Paper*> &papers() { return mPapers; }
|
static const QList<Paper*>& papers();
|
||||||
static const QStringList &paperIds() { return mPaperIds; }
|
static const QStringList& paperIds();
|
||||||
static const QStringList &paperNames() { return mPaperNames; }
|
static const QStringList& paperNames();
|
||||||
|
|
||||||
static const QList<Category*> &categories() { return mCategories; }
|
static const QList<Category*>& categories();
|
||||||
static const QStringList &categoryIds() { return mCategoryIds; }
|
static const QStringList& categoryIds();
|
||||||
static const QStringList &categoryNames() { return mCategoryNames; }
|
static const QStringList& categoryNames();
|
||||||
|
|
||||||
static const QList<Vendor*> &vendors() { return mVendors; }
|
static const QList<Vendor*>& vendors();
|
||||||
static const QStringList &vendorNames() { return mVendorNames; }
|
static const QStringList& vendorNames();
|
||||||
|
|
||||||
static const QList<Template*> &templates() { return mTemplates; }
|
static const QList<Template*>& templates();
|
||||||
|
|
||||||
|
|
||||||
static void registerPaper( Paper *paper );
|
static void registerPaper( Paper *paper );
|
||||||
@@ -84,13 +84,15 @@ namespace libglabels
|
|||||||
|
|
||||||
static void registerTemplate( Template *tmplate );
|
static void registerTemplate( Template *tmplate );
|
||||||
static const Template *lookupTemplateFromName( const QString &name );
|
static const Template *lookupTemplateFromName( const QString &name );
|
||||||
static const Template *lookupTemplateFromBrandPart( const QString &brand, const QString &part );
|
static const Template *lookupTemplateFromBrandPart( const QString &brand,
|
||||||
|
const QString &part );
|
||||||
static bool isTemplateKnown( const QString &brand, const QString &part );
|
static bool isTemplateKnown( const QString &brand, const QString &part );
|
||||||
static QStringList getNameListOfSimilarTemplates( const QString &name );
|
static QStringList getNameListOfSimilarTemplates( const QString &name );
|
||||||
|
|
||||||
static void registerUserTemplate( Template *tmplate );
|
static void registerUserTemplate( Template *tmplate );
|
||||||
static void deleteUserTemplateByName( const QString &name );
|
static void deleteUserTemplateByName( const QString &name );
|
||||||
static void deleteUserTemplateByBrandPart( const QString &brand, const QString &part );
|
static void deleteUserTemplateByBrandPart( const QString &brand,
|
||||||
|
const QString &part );
|
||||||
|
|
||||||
static void printKnownPapers();
|
static void printKnownPapers();
|
||||||
static void printKnownCategories();
|
static void printKnownCategories();
|
||||||
@@ -134,4 +136,8 @@ namespace libglabels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "Db.inl"
|
||||||
|
|
||||||
|
|
||||||
#endif // libglabels_Db_h
|
#endif // libglabels_Db_h
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
/* Db.inl
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||||
|
*
|
||||||
|
* This file is part of gLabels-qt.
|
||||||
|
*
|
||||||
|
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gLabels-qt is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
inline const QList<Paper*>& Db::papers()
|
||||||
|
{
|
||||||
|
return mPapers;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const QStringList& Db::paperIds()
|
||||||
|
{
|
||||||
|
return mPaperIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const QStringList& Db::paperNames()
|
||||||
|
{
|
||||||
|
return mPaperNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const QList<Category*>& Db::categories()
|
||||||
|
{
|
||||||
|
return mCategories;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const QStringList& Db::categoryIds()
|
||||||
|
{
|
||||||
|
return mCategoryIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const QStringList& Db::categoryNames()
|
||||||
|
{
|
||||||
|
return mCategoryNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const QList<Vendor*>& Db::vendors()
|
||||||
|
{
|
||||||
|
return mVendors;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const QStringList& Db::vendorNames()
|
||||||
|
{
|
||||||
|
return mVendorNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const QList<Template*>& Db::templates()
|
||||||
|
{
|
||||||
|
return mTemplates;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -26,7 +26,13 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
Frame::Frame( const Frame &other )
|
Frame::Frame( const QString& id )
|
||||||
|
: mId(id), mNLabels(0), mLayoutDescription("")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Frame::Frame( const Frame& other )
|
||||||
{
|
{
|
||||||
mId = other.mId;
|
mId = other.mId;
|
||||||
mNLabels = 0;
|
mNLabels = 0;
|
||||||
|
|||||||
+18
-16
@@ -43,34 +43,32 @@ namespace libglabels
|
|||||||
Q_DECLARE_TR_FUNCTIONS(Frame)
|
Q_DECLARE_TR_FUNCTIONS(Frame)
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Frame( const QString &id = "0" ) : mId(id), mNLabels(0), mLayoutDescription("")
|
Frame( const QString& id = "0" );
|
||||||
{
|
Frame( const Frame& other );
|
||||||
}
|
|
||||||
|
|
||||||
Frame( const Frame &other );
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual Frame *dup() const = 0;
|
virtual Frame* dup() const = 0;
|
||||||
|
|
||||||
inline const QString &id() const { return mId; }
|
const QString& id() const;
|
||||||
inline int nLabels() const { return mNLabels; }
|
int nLabels() const;
|
||||||
inline const QString &layoutDescription() const { return mLayoutDescription; }
|
const QString& layoutDescription() const;
|
||||||
inline const QList<Layout*> &layouts() const { return mLayouts; }
|
const QList<Layout*>& layouts() const;
|
||||||
inline const QList<Markup*> &markups() const { return mMarkups; }
|
const QList<Markup*>& markups() const;
|
||||||
|
|
||||||
QVector<Point> getOrigins() const;
|
QVector<Point> getOrigins() const;
|
||||||
|
|
||||||
void addLayout( Layout *layout );
|
void addLayout( Layout* layout );
|
||||||
void addMarkup( Markup *markup );
|
void addMarkup( Markup* markup );
|
||||||
|
|
||||||
virtual double w() const = 0;
|
virtual double w() const = 0;
|
||||||
virtual double h() const = 0;
|
virtual double h() const = 0;
|
||||||
|
|
||||||
virtual const QString sizeDescription( const Units *units ) const = 0;
|
virtual const QString sizeDescription( const Units* units ) const = 0;
|
||||||
virtual bool isSimilarTo( Frame *other ) const = 0;
|
virtual bool isSimilarTo( Frame* other ) const = 0;
|
||||||
|
|
||||||
virtual const QPainterPath &path( bool isRotated = false ) const = 0;
|
virtual const QPainterPath &path( bool isRotated = false ) const = 0;
|
||||||
virtual QGraphicsItem* createMarginGraphicsItem( double size, const QPen& pen ) const = 0;
|
virtual QGraphicsItem* createMarginGraphicsItem( double size,
|
||||||
|
const QPen& pen ) const = 0;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -84,4 +82,8 @@ namespace libglabels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "Frame.inl"
|
||||||
|
|
||||||
|
|
||||||
#endif // libglabels_Frame_h
|
#endif // libglabels_Frame_h
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/* Frame.inl
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||||
|
*
|
||||||
|
* This file is part of gLabels-qt.
|
||||||
|
*
|
||||||
|
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gLabels-qt is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
inline const QString& Frame::id() const
|
||||||
|
{
|
||||||
|
return mId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline int Frame::nLabels() const
|
||||||
|
{
|
||||||
|
return mNLabels;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const QString& Frame::layoutDescription() const
|
||||||
|
{
|
||||||
|
return mLayoutDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const QList<Layout*>& Frame::layouts() const
|
||||||
|
{
|
||||||
|
return mLayouts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const QList<Markup*>& Frame::markups() const
|
||||||
|
{
|
||||||
|
return mMarkups;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+76
-44
@@ -29,6 +29,80 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
FrameCd::FrameCd( double r1, double r2, double w, double h, double waste, QString id )
|
||||||
|
: mR1(r1), mR2(r2), mW(w), mH(h), mWaste(waste), Frame(id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// First, initialize the un-rotated path
|
||||||
|
//
|
||||||
|
{
|
||||||
|
// 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.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( mR1-mR2, mR1-mR2, 2*mR2, 2*mR2 );
|
||||||
|
|
||||||
|
// Translate to account for offset with clipped business card CDs
|
||||||
|
mPath.translate( w/2 - mR1, h/2 - mR1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Next, initialize the rotated path
|
||||||
|
//
|
||||||
|
{
|
||||||
|
// Outer path (may be clipped in the case business card type CD)
|
||||||
|
double theta1 = acos( h / (2*mR1) ) * 180/M_PI;
|
||||||
|
double theta2 = asin( w / (2*mR1) ) * 180/M_PI;
|
||||||
|
|
||||||
|
mRotatedPath.arcMoveTo( 0, 0, 2*mR1, 2*mR1, theta1 );
|
||||||
|
mRotatedPath.arcTo( 0, 0, 2*mR1, 2*mR1, theta1, theta2-theta1 );
|
||||||
|
mRotatedPath.arcTo( 0, 0, 2*mR1, 2*mR1, 180-theta2, theta2-theta1 );
|
||||||
|
mRotatedPath.arcTo( 0, 0, 2*mR1, 2*mR1, 180+theta1, theta2-theta1 );
|
||||||
|
mRotatedPath.arcTo( 0, 0, 2*mR1, 2*mR1, 360-theta2, theta2-theta1 );
|
||||||
|
mRotatedPath.closeSubpath();
|
||||||
|
|
||||||
|
// Inner path (hole)
|
||||||
|
mRotatedPath.addEllipse( mR1-mR2, mR1-mR2, 2*mR2, 2*mR2 );
|
||||||
|
|
||||||
|
// Translate to account for offset with clipped business card CDs
|
||||||
|
mRotatedPath.translate( h/2 - mR1, w/2 - mR1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FrameCd::FrameCd( const FrameCd& other )
|
||||||
|
: mR1(other.mR1), mR2(other.mR2), mW(other.mW), mH(other.mH), mWaste(other.mWaste),
|
||||||
|
mPath(other.mPath), Frame(other)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Frame* FrameCd::dup() const
|
||||||
|
{
|
||||||
|
return new FrameCd( *this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double FrameCd::w() const
|
||||||
|
{
|
||||||
|
return (mW == 0) ? 2*mR1 : mW;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double FrameCd::h() const
|
||||||
|
{
|
||||||
|
return (mH == 0) ? 2*mR1 : mH;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const QString FrameCd::sizeDescription( const Units *units ) const
|
const QString FrameCd::sizeDescription( const Units *units ) const
|
||||||
{
|
{
|
||||||
if ( units->id() == "in" )
|
if ( units->id() == "in" )
|
||||||
@@ -66,51 +140,9 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FrameCd::initPath()
|
const QPainterPath& FrameCd::path( bool isRotated ) const
|
||||||
{
|
{
|
||||||
//
|
return isRotated ? mRotatedPath : mPath;
|
||||||
// First the un-rotated path
|
|
||||||
//
|
|
||||||
{
|
|
||||||
// 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.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( mR1-mR2, mR1-mR2, 2*mR2, 2*mR2 );
|
|
||||||
|
|
||||||
// Translate to account for offset with clipped business card CDs
|
|
||||||
mPath.translate( w()/2 - mR1, h()/2 - mR1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Next, the rotated path
|
|
||||||
//
|
|
||||||
{
|
|
||||||
// Outer path (may be clipped in the case business card type CD)
|
|
||||||
double theta1 = acos( h() / (2*mR1) ) * 180/M_PI;
|
|
||||||
double theta2 = asin( w() / (2*mR1) ) * 180/M_PI;
|
|
||||||
|
|
||||||
mRotatedPath.arcMoveTo( 0, 0, 2*mR1, 2*mR1, theta1 );
|
|
||||||
mRotatedPath.arcTo( 0, 0, 2*mR1, 2*mR1, theta1, theta2-theta1 );
|
|
||||||
mRotatedPath.arcTo( 0, 0, 2*mR1, 2*mR1, 180-theta2, theta2-theta1 );
|
|
||||||
mRotatedPath.arcTo( 0, 0, 2*mR1, 2*mR1, 180+theta1, theta2-theta1 );
|
|
||||||
mRotatedPath.arcTo( 0, 0, 2*mR1, 2*mR1, 360-theta2, theta2-theta1 );
|
|
||||||
mRotatedPath.closeSubpath();
|
|
||||||
|
|
||||||
// Inner path (hole)
|
|
||||||
mRotatedPath.addEllipse( mR1-mR2, mR1-mR2, 2*mR2, 2*mR2 );
|
|
||||||
|
|
||||||
// Translate to account for offset with clipped business card CDs
|
|
||||||
mRotatedPath.translate( h()/2 - mR1, w()/2 - mR1 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+13
-24
@@ -30,42 +30,27 @@ namespace libglabels
|
|||||||
class FrameCd : public Frame
|
class FrameCd : public Frame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FrameCd( double r1,
|
FrameCd( double r1, double r2, double w, double h, double waste, QString id = "0" );
|
||||||
double r2,
|
|
||||||
double w,
|
|
||||||
double h,
|
|
||||||
double waste,
|
|
||||||
QString id = "0" )
|
|
||||||
: mR1(r1), mR2(r2), mW(w), mH(h), mWaste(waste), Frame(id)
|
|
||||||
{
|
|
||||||
initPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
FrameCd( const FrameCd &other )
|
FrameCd( const FrameCd &other );
|
||||||
: mR1(other.mR1), mR2(other.mR2), mW(other.mW), mH(other.mH), mWaste(other.mWaste),
|
|
||||||
mPath(other.mPath), Frame(other)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Frame *dup() const { return new FrameCd( *this ); }
|
Frame *dup() const;
|
||||||
|
|
||||||
inline double r1() const { return mR1; }
|
double r1() const;
|
||||||
inline double r2() const { return mR2; }
|
double r2() const;
|
||||||
inline double waste() const { return mWaste; }
|
double waste() const;
|
||||||
|
|
||||||
double w() const { return (mW == 0) ? 2*mR1 : mW; }
|
double w() const;
|
||||||
double h() const { return (mH == 0) ? 2*mR1 : mH; }
|
double h() const;
|
||||||
|
|
||||||
const QString sizeDescription( const Units *units ) const;
|
const QString sizeDescription( const Units *units ) const;
|
||||||
bool isSimilarTo( Frame *other ) const;
|
bool isSimilarTo( Frame *other ) const;
|
||||||
|
|
||||||
const QPainterPath &path( bool isRotated ) const { return isRotated ? mRotatedPath : mPath; }
|
const QPainterPath &path( bool isRotated ) const;
|
||||||
QGraphicsItem* createMarginGraphicsItem( double size, const QPen& pen ) const;
|
QGraphicsItem* createMarginGraphicsItem( double size, const QPen& pen ) const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initPath();
|
|
||||||
|
|
||||||
double mR1;
|
double mR1;
|
||||||
double mR2;
|
double mR2;
|
||||||
double mW;
|
double mW;
|
||||||
@@ -79,4 +64,8 @@ namespace libglabels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "FrameCd.inl"
|
||||||
|
|
||||||
|
|
||||||
#endif // libglabels_FrameCd_h
|
#endif // libglabels_FrameCd_h
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/* FrameCd.inl
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||||
|
*
|
||||||
|
* This file is part of gLabels-qt.
|
||||||
|
*
|
||||||
|
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gLabels-qt is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
inline double FrameCd::r1() const
|
||||||
|
{
|
||||||
|
return mR1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline double FrameCd::r2() const
|
||||||
|
{
|
||||||
|
return mR2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline double FrameCd::waste() const
|
||||||
|
{
|
||||||
|
return mWaste;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -29,6 +29,37 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
FrameEllipse::FrameEllipse( double w, double h, double waste, QString id )
|
||||||
|
: mW(w), mH(h), mWaste(waste), Frame(id)
|
||||||
|
{
|
||||||
|
mPath.addEllipse( 0, 0, mW, mH );
|
||||||
|
mRotatedPath.addEllipse( 0, 0, mH, mW );
|
||||||
|
}
|
||||||
|
|
||||||
|
FrameEllipse::FrameEllipse( const FrameEllipse& other )
|
||||||
|
: mW(other.mW), mH(other.mH), mWaste(other.mWaste), mPath(other.mPath), Frame(other)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Frame* FrameEllipse::dup() const
|
||||||
|
{
|
||||||
|
return new FrameEllipse( *this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double FrameEllipse::w() const
|
||||||
|
{
|
||||||
|
return mW;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double FrameEllipse::h() const
|
||||||
|
{
|
||||||
|
return mH;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const QString FrameEllipse::sizeDescription( const Units *units ) const
|
const QString FrameEllipse::sizeDescription( const Units *units ) const
|
||||||
{
|
{
|
||||||
if ( units->id() == "in" )
|
if ( units->id() == "in" )
|
||||||
@@ -51,9 +82,9 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool FrameEllipse::isSimilarTo( Frame *other ) const
|
bool FrameEllipse::isSimilarTo( Frame* other ) const
|
||||||
{
|
{
|
||||||
if ( FrameEllipse *otherEllipse = dynamic_cast<FrameEllipse*>(other) )
|
if ( FrameEllipse* otherEllipse = dynamic_cast<FrameEllipse*>(other) )
|
||||||
{
|
{
|
||||||
if ( (fabs( mW - otherEllipse->mW ) <= Constants::EPSILON) &&
|
if ( (fabs( mW - otherEllipse->mW ) <= Constants::EPSILON) &&
|
||||||
(fabs( mH - otherEllipse->mH ) <= Constants::EPSILON) )
|
(fabs( mH - otherEllipse->mH ) <= Constants::EPSILON) )
|
||||||
@@ -65,6 +96,12 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QPainterPath& FrameEllipse::path( bool isRotated ) const
|
||||||
|
{
|
||||||
|
return isRotated ? mRotatedPath : mPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QGraphicsItem* FrameEllipse::createMarginGraphicsItem( double size, const QPen& pen ) const
|
QGraphicsItem* FrameEllipse::createMarginGraphicsItem( double size, const QPen& pen ) const
|
||||||
{
|
{
|
||||||
double w = mW - 2*size;
|
double w = mW - 2*size;
|
||||||
|
|||||||
+14
-20
@@ -29,33 +29,23 @@ namespace libglabels
|
|||||||
|
|
||||||
class FrameEllipse : public Frame
|
class FrameEllipse : public Frame
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FrameEllipse( double w,
|
FrameEllipse( double w, double h, double waste, QString id = "0" );
|
||||||
double h,
|
|
||||||
double waste,
|
|
||||||
QString id = "0" )
|
|
||||||
: mW(w), mH(h), mWaste(waste), Frame(id)
|
|
||||||
{
|
|
||||||
mPath.addEllipse( 0, 0, mW, mH );
|
|
||||||
mRotatedPath.addEllipse( 0, 0, mH, mW );
|
|
||||||
}
|
|
||||||
|
|
||||||
FrameEllipse( const FrameEllipse &other )
|
FrameEllipse( const FrameEllipse& other );
|
||||||
: mW(other.mW), mH(other.mH), mWaste(other.mWaste), mPath(other.mPath), Frame(other)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Frame *dup() const { return new FrameEllipse( *this ); }
|
Frame* dup() const;
|
||||||
|
|
||||||
inline double waste() const { return mWaste; }
|
double waste() const;
|
||||||
|
|
||||||
double w() const { return mW; }
|
double w() const;
|
||||||
double h() const { return mH; }
|
double h() const;
|
||||||
|
|
||||||
const QString sizeDescription( const Units *units ) const;
|
const QString sizeDescription( const Units* units ) const;
|
||||||
bool isSimilarTo( Frame *other ) const;
|
bool isSimilarTo( Frame* other ) const;
|
||||||
|
|
||||||
const QPainterPath &path( bool isRotated ) const { return isRotated ? mRotatedPath : mPath; }
|
const QPainterPath& path( bool isRotated ) const;
|
||||||
QGraphicsItem* createMarginGraphicsItem( double size, const QPen& pen ) const;
|
QGraphicsItem* createMarginGraphicsItem( double size, const QPen& pen ) const;
|
||||||
|
|
||||||
|
|
||||||
@@ -71,4 +61,8 @@ namespace libglabels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "FrameEllipse.inl"
|
||||||
|
|
||||||
|
|
||||||
#endif // libglabels_FrameEllipse_h
|
#endif // libglabels_FrameEllipse_h
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/* FrameEllipse.inl
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||||
|
*
|
||||||
|
* This file is part of gLabels-qt.
|
||||||
|
*
|
||||||
|
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gLabels-qt is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
inline double FrameEllipse::waste() const
|
||||||
|
{
|
||||||
|
return mWaste;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -29,6 +29,39 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
FrameRect::FrameRect( double w, double h, double r, double xWaste, double yWaste, QString id )
|
||||||
|
: mW(w), mH(h), mR(r), mXWaste(xWaste), mYWaste(yWaste), Frame(id)
|
||||||
|
{
|
||||||
|
mPath.addRoundedRect( 0, 0, mW, mH, mR, mR );
|
||||||
|
mRotatedPath.addRoundedRect( 0, 0, mH, mW, mR, mR );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FrameRect::FrameRect( const FrameRect &other )
|
||||||
|
: mW(other.mW), mH(other.mH), mR(other.mR), mXWaste(other.mXWaste),
|
||||||
|
mYWaste(other.mYWaste), mPath(other.mPath), Frame(other)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Frame* FrameRect::dup() const
|
||||||
|
{
|
||||||
|
return new FrameRect( *this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double FrameRect::w() const
|
||||||
|
{
|
||||||
|
return mW;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double FrameRect::h() const
|
||||||
|
{
|
||||||
|
return mH;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const QString FrameRect::sizeDescription( const Units *units ) const
|
const QString FrameRect::sizeDescription( const Units *units ) const
|
||||||
{
|
{
|
||||||
if ( units->id() == "in" )
|
if ( units->id() == "in" )
|
||||||
@@ -65,6 +98,12 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QPainterPath& FrameRect::path( bool isRotated ) const
|
||||||
|
{
|
||||||
|
return isRotated ? mRotatedPath : mPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QGraphicsItem* FrameRect::createMarginGraphicsItem( double size, const QPen& pen ) const
|
QGraphicsItem* FrameRect::createMarginGraphicsItem( double size, const QPen& pen ) const
|
||||||
{
|
{
|
||||||
double w = mW - 2*size;
|
double w = mW - 2*size;
|
||||||
@@ -80,5 +119,6 @@ namespace libglabels
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+14
-18
@@ -35,32 +35,24 @@ namespace libglabels
|
|||||||
double r,
|
double r,
|
||||||
double xWaste,
|
double xWaste,
|
||||||
double yWaste,
|
double yWaste,
|
||||||
QString id = "0" )
|
QString id = "0" );
|
||||||
: mW(w), mH(h), mR(r), mXWaste(xWaste), mYWaste(yWaste), Frame(id)
|
|
||||||
{
|
|
||||||
mPath.addRoundedRect( 0, 0, mW, mH, mR, mR );
|
|
||||||
mRotatedPath.addRoundedRect( 0, 0, mH, mW, mR, mR );
|
|
||||||
}
|
|
||||||
|
|
||||||
FrameRect( const FrameRect &other )
|
FrameRect( const FrameRect& other );
|
||||||
: mW(other.mW), mH(other.mH), mR(other.mR), mXWaste(other.mXWaste), mYWaste(other.mYWaste),
|
|
||||||
mPath(other.mPath), Frame(other)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Frame *dup() const { return new FrameRect( *this ); }
|
Frame* dup() const;
|
||||||
|
|
||||||
inline double r() const { return mR; }
|
double r() const;
|
||||||
inline double xWaste() const { return mXWaste; }
|
double xWaste() const;
|
||||||
inline double yWaste() const { return mYWaste; }
|
double yWaste() const;
|
||||||
|
|
||||||
double w() const { return mW; }
|
double w() const;
|
||||||
double h() const { return mH; }
|
double h() const;
|
||||||
|
|
||||||
const QString sizeDescription( const Units *units ) const;
|
const QString sizeDescription( const Units *units ) const;
|
||||||
|
|
||||||
bool isSimilarTo( Frame *other ) const;
|
bool isSimilarTo( Frame *other ) const;
|
||||||
|
|
||||||
const QPainterPath &path( bool isRotated ) const { return isRotated ? mRotatedPath : mPath; }
|
const QPainterPath& path( bool isRotated ) const;
|
||||||
QGraphicsItem* createMarginGraphicsItem( double size, const QPen& pen ) const;
|
QGraphicsItem* createMarginGraphicsItem( double size, const QPen& pen ) const;
|
||||||
|
|
||||||
|
|
||||||
@@ -78,4 +70,8 @@ namespace libglabels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "FrameRect.inl"
|
||||||
|
|
||||||
|
|
||||||
#endif // libglabels_FrameRect_h
|
#endif // libglabels_FrameRect_h
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/* FrameRect.inl
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||||
|
*
|
||||||
|
* This file is part of gLabels-qt.
|
||||||
|
*
|
||||||
|
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gLabels-qt is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
inline double FrameRect::r() const
|
||||||
|
{
|
||||||
|
return mR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline double FrameRect::xWaste() const
|
||||||
|
{
|
||||||
|
return mXWaste;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline double FrameRect::yWaste() const
|
||||||
|
{
|
||||||
|
return mYWaste;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -29,6 +29,37 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
FrameRound::FrameRound( double r, double waste, QString id )
|
||||||
|
: mR(r), mWaste(waste), Frame(id)
|
||||||
|
{
|
||||||
|
mPath.addEllipse( 0, 0, 2*mR, 2*mR );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FrameRound::FrameRound( const FrameRound& other )
|
||||||
|
: mR(other.mR), mWaste(other.mWaste), mPath(other.mPath), Frame(other)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Frame* FrameRound::dup() const
|
||||||
|
{
|
||||||
|
return new FrameRound( *this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double FrameRound::w() const
|
||||||
|
{
|
||||||
|
return 2*mR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double FrameRound::h() const
|
||||||
|
{
|
||||||
|
return 2*mR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const QString FrameRound::sizeDescription( const Units *units ) const
|
const QString FrameRound::sizeDescription( const Units *units ) const
|
||||||
{
|
{
|
||||||
if ( units->id() == "in" )
|
if ( units->id() == "in" )
|
||||||
@@ -63,6 +94,12 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QPainterPath& FrameRound::path( bool isRotated ) const
|
||||||
|
{
|
||||||
|
return mPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QGraphicsItem* FrameRound::createMarginGraphicsItem( double size, const QPen& pen ) const
|
QGraphicsItem* FrameRound::createMarginGraphicsItem( double size, const QPen& pen ) const
|
||||||
{
|
{
|
||||||
double r = mR - size;
|
double r = mR - size;
|
||||||
|
|||||||
+13
-17
@@ -29,32 +29,24 @@ namespace libglabels
|
|||||||
|
|
||||||
class FrameRound : public Frame
|
class FrameRound : public Frame
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FrameRound( double r,
|
FrameRound( double r, double waste, QString id = "0" );
|
||||||
double waste,
|
|
||||||
QString id = "0" )
|
|
||||||
: mR(r), mWaste(waste), Frame(id)
|
|
||||||
{
|
|
||||||
mPath.addEllipse( 0, 0, 2*mR, 2*mR );
|
|
||||||
}
|
|
||||||
|
|
||||||
FrameRound( const FrameRound &other )
|
FrameRound( const FrameRound &other );
|
||||||
: mR(other.mR), mWaste(other.mWaste), mPath(other.mPath), Frame(other)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Frame *dup() const { return new FrameRound( *this ); }
|
Frame *dup() const;
|
||||||
|
|
||||||
inline double r() const { return mR; }
|
double r() const;
|
||||||
inline double waste() const { return mWaste; }
|
double waste() const;
|
||||||
|
|
||||||
double w() const { return 2*mR; }
|
double w() const;
|
||||||
double h() const { return 2*mR; }
|
double h() const;
|
||||||
|
|
||||||
const QString sizeDescription( const Units *units ) const;
|
const QString sizeDescription( const Units *units ) const;
|
||||||
bool isSimilarTo( Frame *other ) const;
|
bool isSimilarTo( Frame *other ) const;
|
||||||
|
|
||||||
const QPainterPath &path( bool isRotated ) const { return mPath; }
|
const QPainterPath &path( bool isRotated ) const;
|
||||||
QGraphicsItem* createMarginGraphicsItem( double size, const QPen& pen ) const;
|
QGraphicsItem* createMarginGraphicsItem( double size, const QPen& pen ) const;
|
||||||
|
|
||||||
|
|
||||||
@@ -68,4 +60,8 @@ namespace libglabels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "FrameRound.inl"
|
||||||
|
|
||||||
|
|
||||||
#endif // libglabels_FrameRound_h
|
#endif // libglabels_FrameRound_h
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/* FrameRound.inl
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||||
|
*
|
||||||
|
* This file is part of gLabels-qt.
|
||||||
|
*
|
||||||
|
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gLabels-qt is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
inline double FrameRound::r() const
|
||||||
|
{
|
||||||
|
return mR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline double FrameRound::waste() const
|
||||||
|
{
|
||||||
|
return mWaste;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -28,6 +28,19 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Layout::Layout( int nx, int ny, double x0, double y0, double dx, double dy )
|
||||||
|
: mNx(nx), mNy(ny), mX0(x0), mY0(y0), mDx(dx), mDy(dy)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Layout::Layout( const Layout& other )
|
||||||
|
: mNx(other.mNx), mNy(other.mNy), mX0(other.mX0), mY0(other.mY0),
|
||||||
|
mDx(other.mDx), mDy(other.mDy)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Layout::isSimilarTo( const Layout *other )
|
bool Layout::isSimilarTo( const Layout *other )
|
||||||
{
|
{
|
||||||
return ( (mNx == other->mNx) &&
|
return ( (mNx == other->mNx) &&
|
||||||
@@ -38,4 +51,11 @@ namespace libglabels
|
|||||||
(fabs(mDy - other->mDy) < Constants::EPSILON) );
|
(fabs(mDy - other->mDy) < Constants::EPSILON) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Layout* Layout::dup() const
|
||||||
|
{
|
||||||
|
Layout *other = new Layout( *this );
|
||||||
|
return other;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-19
@@ -27,33 +27,24 @@ namespace libglabels
|
|||||||
|
|
||||||
class Layout
|
class Layout
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Layout( int nx, int ny, double x0, double y0, double dx, double dy )
|
Layout( int nx, int ny, double x0, double y0, double dx, double dy );
|
||||||
: mNx(nx), mNy(ny), mX0(x0), mY0(y0), mDx(dx), mDy(dy)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Layout( const Layout &other )
|
Layout( const Layout &other );
|
||||||
: mNx(other.mNx), mNy(other.mNy), mX0(other.mX0), mY0(other.mY0), mDx(other.mDx), mDy(other.mDy)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int nx() const { return mNx; }
|
int nx() const;
|
||||||
inline int ny() const { return mNy; }
|
int ny() const;
|
||||||
|
|
||||||
inline double x0() const { return mX0; }
|
double x0() const;
|
||||||
inline double y0() const { return mY0; }
|
double y0() const;
|
||||||
|
|
||||||
inline double dx() const { return mDx; }
|
double dx() const;
|
||||||
inline double dy() const { return mDy; }
|
double dy() const;
|
||||||
|
|
||||||
bool isSimilarTo( const Layout *other );
|
bool isSimilarTo( const Layout *other );
|
||||||
|
|
||||||
inline Layout *dup() const
|
Layout* dup() const;
|
||||||
{
|
|
||||||
Layout *other = new Layout( *this );
|
|
||||||
return other;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -63,8 +54,13 @@ namespace libglabels
|
|||||||
double mY0;
|
double mY0;
|
||||||
double mDx;
|
double mDx;
|
||||||
double mDy;
|
double mDy;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "Layout.inl"
|
||||||
|
|
||||||
|
|
||||||
#endif // libglabels_Layout_h
|
#endif // libglabels_Layout_h
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/* Layout.inl
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||||
|
*
|
||||||
|
* This file is part of gLabels-qt.
|
||||||
|
*
|
||||||
|
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gLabels-qt is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
inline int Layout::nx() const
|
||||||
|
{
|
||||||
|
return mNx;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline int Layout::ny() const
|
||||||
|
{
|
||||||
|
return mNy;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline double Layout::x0() const
|
||||||
|
{
|
||||||
|
return mX0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline double Layout::y0() const
|
||||||
|
{
|
||||||
|
return mY0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline double Layout::dx() const
|
||||||
|
{
|
||||||
|
return mDx;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline double Layout::dy() const
|
||||||
|
{
|
||||||
|
return mDy;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -20,3 +20,111 @@
|
|||||||
|
|
||||||
#include "Markup.h"
|
#include "Markup.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
MarkupMargin::MarkupMargin( double size )
|
||||||
|
: mSize(size)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Markup* MarkupMargin::dup() const
|
||||||
|
{
|
||||||
|
return new MarkupMargin( mSize );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QGraphicsItem* MarkupMargin::createGraphicsItem( const Frame* frame, const QPen& pen ) const
|
||||||
|
{
|
||||||
|
return frame->createMarginGraphicsItem( mSize, pen );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MarkupLine::MarkupLine( double x1, double y1, double x2, double y2 )
|
||||||
|
: mX1(x1), mY1(y1), mX2(x2), mY2(y2)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Markup* MarkupLine::dup() const
|
||||||
|
{
|
||||||
|
return new MarkupLine( mX1, mY1, mX2, mY2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QGraphicsItem* MarkupLine::createGraphicsItem( const Frame* frame, const QPen& pen ) const
|
||||||
|
{
|
||||||
|
QGraphicsLineItem* item = new QGraphicsLineItem( mX1, mY1, mX2, mY2 );
|
||||||
|
item->setPen( pen );
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MarkupRect::MarkupRect( double x1, double y1, double w, double h, double r )
|
||||||
|
: mX1(x1), mY1(y1), mW(w), mH(h), mR(r)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Markup* MarkupRect::dup() const
|
||||||
|
{
|
||||||
|
return new MarkupRect( mX1, mY1, mW, mH, mR );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QGraphicsItem* MarkupRect::createGraphicsItem( const Frame* frame, const QPen& pen ) const
|
||||||
|
{
|
||||||
|
QPainterPath path;
|
||||||
|
path.addRoundedRect( mX1, mY1, mW, mH, mR, mR );
|
||||||
|
|
||||||
|
QGraphicsPathItem* item = new QGraphicsPathItem( path );
|
||||||
|
item->setPen( pen );
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MarkupEllipse::MarkupEllipse( double x1, double y1, double w, double h )
|
||||||
|
: mX1(x1), mY1(y1), mW(w), mH(h)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Markup* MarkupEllipse::dup() const
|
||||||
|
{
|
||||||
|
return new MarkupEllipse( mX1, mY1, mW, mH );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QGraphicsItem* MarkupEllipse::createGraphicsItem( const Frame* frame, const QPen& pen ) const
|
||||||
|
{
|
||||||
|
QGraphicsEllipseItem* item = new QGraphicsEllipseItem( mX1, mY1, mW, mH );
|
||||||
|
item->setPen( pen );
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MarkupCircle::MarkupCircle( double x0, double y0, double r )
|
||||||
|
: mX0(x0), mY0(y0), mR(r)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Markup* MarkupCircle::dup() const
|
||||||
|
{
|
||||||
|
return new MarkupCircle( mX0, mY0, mR );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QGraphicsItem* MarkupCircle::createGraphicsItem( const Frame* frame, const QPen& pen ) const
|
||||||
|
{
|
||||||
|
QGraphicsEllipseItem* item = new QGraphicsEllipseItem( mX0-mR, mY0-mR, 2*mR, 2*mR );
|
||||||
|
item->setPen( pen );
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
+37
-76
@@ -33,7 +33,7 @@ namespace libglabels
|
|||||||
class Markup
|
class Markup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual Markup *dup() const = 0;
|
virtual Markup* dup() const = 0;
|
||||||
virtual QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const = 0;
|
virtual QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -41,18 +41,13 @@ namespace libglabels
|
|||||||
class MarkupMargin : public Markup
|
class MarkupMargin : public Markup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MarkupMargin( double size ) : mSize(size)
|
MarkupMargin( double size );
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline double size() const { return mSize; }
|
double size() const;
|
||||||
|
|
||||||
Markup *dup() const { return new MarkupMargin( mSize ); }
|
Markup* dup() const;
|
||||||
|
|
||||||
QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const
|
QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const;
|
||||||
{
|
|
||||||
return frame->createMarginGraphicsItem( mSize, pen );
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double mSize;
|
double mSize;
|
||||||
@@ -62,24 +57,16 @@ namespace libglabels
|
|||||||
class MarkupLine : public Markup
|
class MarkupLine : public Markup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MarkupLine( double x1, double y1, double x2, double y2 ) : mX1(x1), mY1(y1), mX2(x2), mY2(y2)
|
MarkupLine( double x1, double y1, double x2, double y2 );
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline double x1() const { return mX1; }
|
double x1() const;
|
||||||
inline double y1() const { return mY1; }
|
double y1() const;
|
||||||
inline double x2() const { return mX2; }
|
double x2() const;
|
||||||
inline double y2() const { return mY2; }
|
double y2() const;
|
||||||
|
|
||||||
Markup *dup() const { return new MarkupLine( mX1, mY1, mX2, mY2 ); }
|
Markup* dup() const;
|
||||||
|
|
||||||
QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const
|
QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const;
|
||||||
{
|
|
||||||
QGraphicsLineItem* item = new QGraphicsLineItem( mX1, mY1, mX2, mY2 );
|
|
||||||
item->setPen( pen );
|
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double mX1;
|
double mX1;
|
||||||
@@ -92,29 +79,17 @@ namespace libglabels
|
|||||||
class MarkupRect : public Markup
|
class MarkupRect : public Markup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MarkupRect( double x1, double y1, double w, double h, double r )
|
MarkupRect( double x1, double y1, double w, double h, double r );
|
||||||
: mX1(x1), mY1(y1), mW(w), mH(h), mR(r)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline double x1() const { return mX1; }
|
double x1() const;
|
||||||
inline double y1() const { return mY1; }
|
double y1() const;
|
||||||
inline double w() const { return mW; }
|
double w() const;
|
||||||
inline double h() const { return mH; }
|
double h() const;
|
||||||
inline double r() const { return mR; }
|
double r() const;
|
||||||
|
|
||||||
Markup *dup() const { return new MarkupRect( mX1, mY1, mW, mH, mR ); }
|
Markup* dup() const;
|
||||||
|
|
||||||
QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const
|
QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const;
|
||||||
{
|
|
||||||
QPainterPath path;
|
|
||||||
path.addRoundedRect( mX1, mY1, mW, mH, mR, mR );
|
|
||||||
|
|
||||||
QGraphicsPathItem* item = new QGraphicsPathItem( path );
|
|
||||||
item->setPen( pen );
|
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double mX1;
|
double mX1;
|
||||||
@@ -128,25 +103,16 @@ namespace libglabels
|
|||||||
class MarkupEllipse : public Markup
|
class MarkupEllipse : public Markup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MarkupEllipse( double x1, double y1, double w, double h )
|
MarkupEllipse( double x1, double y1, double w, double h );
|
||||||
: mX1(x1), mY1(y1), mW(w), mH(h)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline double x1() const { return mX1; }
|
double x1() const;
|
||||||
inline double y1() const { return mY1; }
|
double y1() const;
|
||||||
inline double w() const { return mW; }
|
double w() const;
|
||||||
inline double h() const { return mH; }
|
double h() const;
|
||||||
|
|
||||||
Markup *dup() const { return new MarkupEllipse( mX1, mY1, mW, mH ); }
|
Markup* dup() const;
|
||||||
|
|
||||||
QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const
|
QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const;
|
||||||
{
|
|
||||||
QGraphicsEllipseItem* item = new QGraphicsEllipseItem( mX1, mY1, mW, mH );
|
|
||||||
item->setPen( pen );
|
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double mX1;
|
double mX1;
|
||||||
@@ -159,24 +125,15 @@ namespace libglabels
|
|||||||
class MarkupCircle : public Markup
|
class MarkupCircle : public Markup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MarkupCircle( double x0, double y0, double r )
|
MarkupCircle( double x0, double y0, double r );
|
||||||
: mX0(x0), mY0(y0), mR(r)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline double x0() const { return mX0; }
|
double x0() const;
|
||||||
inline double y0() const { return mY0; }
|
double y0() const;
|
||||||
inline double r() const { return mR; }
|
double r() const;
|
||||||
|
|
||||||
Markup *dup() const { return new MarkupCircle( mX0, mY0, mR ); }
|
Markup* dup() const;
|
||||||
|
|
||||||
QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const
|
QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const;
|
||||||
{
|
|
||||||
QGraphicsEllipseItem* item = new QGraphicsEllipseItem( mX0-mR, mY0-mR, 2*mR, 2*mR );
|
|
||||||
item->setPen( pen );
|
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double mX0;
|
double mX0;
|
||||||
@@ -187,4 +144,8 @@ namespace libglabels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "Markup.inl"
|
||||||
|
|
||||||
|
|
||||||
#endif // libglabels_Markup_h
|
#endif // libglabels_Markup_h
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/* Markup.inl
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||||
|
*
|
||||||
|
* This file is part of gLabels-qt.
|
||||||
|
*
|
||||||
|
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gLabels-qt is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
inline double MarkupMargin::size() const { return mSize; }
|
||||||
|
|
||||||
|
inline double MarkupLine::x1() const { return mX1; }
|
||||||
|
inline double MarkupLine::y1() const { return mY1; }
|
||||||
|
inline double MarkupLine::x2() const { return mX2; }
|
||||||
|
inline double MarkupLine::y2() const { return mY2; }
|
||||||
|
|
||||||
|
inline double MarkupRect::x1() const { return mX1; }
|
||||||
|
inline double MarkupRect::y1() const { return mY1; }
|
||||||
|
inline double MarkupRect::w() const { return mW; }
|
||||||
|
inline double MarkupRect::h() const { return mH; }
|
||||||
|
inline double MarkupRect::r() const { return mR; }
|
||||||
|
|
||||||
|
inline double MarkupEllipse::x1() const { return mX1; }
|
||||||
|
inline double MarkupEllipse::y1() const { return mY1; }
|
||||||
|
inline double MarkupEllipse::w() const { return mW; }
|
||||||
|
inline double MarkupEllipse::h() const { return mH; }
|
||||||
|
|
||||||
|
inline double MarkupCircle::x0() const { return mX0; }
|
||||||
|
inline double MarkupCircle::y0() const { return mY0; }
|
||||||
|
inline double MarkupCircle::r() const { return mR; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -38,6 +38,18 @@ namespace
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
MiniPreviewPixmap::MiniPreviewPixmap()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MiniPreviewPixmap::MiniPreviewPixmap( const Template *tmplate, int width, int height )
|
||||||
|
: QPixmap( width, height )
|
||||||
|
{
|
||||||
|
draw( tmplate, width, height );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MiniPreviewPixmap::draw( const Template *tmplate, int width, int height )
|
void MiniPreviewPixmap::draw( const Template *tmplate, int width, int height )
|
||||||
{
|
{
|
||||||
fill( Qt::transparent );
|
fill( Qt::transparent );
|
||||||
|
|||||||
@@ -34,22 +34,19 @@ namespace libglabels
|
|||||||
|
|
||||||
class MiniPreviewPixmap : public QPixmap
|
class MiniPreviewPixmap : public QPixmap
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
MiniPreviewPixmap()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
MiniPreviewPixmap( const Template *tmplate, int width, int height )
|
public:
|
||||||
: QPixmap( width, height )
|
MiniPreviewPixmap();
|
||||||
{
|
|
||||||
draw( tmplate, width, height );
|
MiniPreviewPixmap( const Template *tmplate, int width, int height );
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void draw( const Template *tmplate, int width, int height );
|
void draw( const Template *tmplate, int width, int height );
|
||||||
void drawPaper( QPainter &painter, const Template *tmplate, double scale );
|
void drawPaper( QPainter &painter, const Template *tmplate, double scale );
|
||||||
void drawLabelOutlines( QPainter &painter, const Template *tmplate, double scale );
|
void drawLabelOutlines( QPainter &painter, const Template *tmplate, double scale );
|
||||||
void drawLabelOutline( QPainter &painter, const Frame *frame, double x0, double y0 );
|
void drawLabelOutline( QPainter &painter, const Frame *frame, double x0, double y0 );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,3 +19,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Paper.h"
|
#include "Paper.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
Paper::Paper( const QString& id, const QString& name, double width, double height, const QString& pwgSize )
|
||||||
|
: mId(id), mName(name), mWidth(width), mHeight(height), mPwgSize(pwgSize)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
+12
-15
@@ -31,29 +31,22 @@ namespace libglabels
|
|||||||
class Paper
|
class Paper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Paper( const QString &id,
|
Paper( const QString& id, const QString& name, double width, double height, const QString& pwgSize );
|
||||||
const QString &name,
|
|
||||||
double width,
|
|
||||||
double height,
|
|
||||||
const QString &pwgSize ) : mId(id), mName(name), mWidth(width), mHeight(height), mPwgSize(pwgSize)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const QString &id() const { return mId; }
|
inline const QString& id() const;
|
||||||
|
inline const QString& name() const;
|
||||||
inline const QString &name() const { return mName; }
|
|
||||||
|
|
||||||
/* Width (in points) */
|
/* Width (in points) */
|
||||||
inline double width() const { return mWidth; }
|
inline double width() const;
|
||||||
|
|
||||||
/* Height (in points) */
|
/* Height (in points) */
|
||||||
inline double height() const { return mHeight; }
|
inline double height() const;
|
||||||
|
|
||||||
/* PWG 5101.1-2002 size name */
|
/* PWG 5101.1-2002 size name */
|
||||||
inline QString pwgSize() const { return mPwgSize; }
|
inline QString pwgSize() const;
|
||||||
|
|
||||||
inline bool isSizeIso() const { return mPwgSize.startsWith( "iso_" ); }
|
inline bool isSizeIso() const;
|
||||||
inline bool isSizeUs() const { return mPwgSize.startsWith( "na_" ); }
|
inline bool isSizeUs() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString mId;
|
QString mId;
|
||||||
@@ -65,4 +58,8 @@ namespace libglabels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "Paper.inl"
|
||||||
|
|
||||||
|
|
||||||
#endif // libglabels_Paper_h
|
#endif // libglabels_Paper_h
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/* Paper.inl
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||||
|
*
|
||||||
|
* This file is part of gLabels-qt.
|
||||||
|
*
|
||||||
|
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gLabels-qt is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
inline const QString& Paper::id() const { return mId; }
|
||||||
|
inline const QString& Paper::name() const { return mName; }
|
||||||
|
|
||||||
|
inline double Paper::width() const { return mWidth; }
|
||||||
|
inline double Paper::height() const { return mHeight; }
|
||||||
|
|
||||||
|
inline QString Paper::pwgSize() const { return mPwgSize; }
|
||||||
|
|
||||||
|
inline bool Paper::isSizeIso() const { return mPwgSize.startsWith( "iso_" ); }
|
||||||
|
inline bool Paper::isSizeUs() const { return mPwgSize.startsWith( "na_" ); }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -24,6 +24,16 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Point::Point() : mX(0), mY(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Point::Point( double x, double y ) : mX(x), mY(y)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Point::operator<( const Point &other ) const
|
bool Point::operator<( const Point &other ) const
|
||||||
{
|
{
|
||||||
if ( mY < other.mY )
|
if ( mY < other.mY )
|
||||||
|
|||||||
+8
-8
@@ -28,16 +28,12 @@ namespace libglabels
|
|||||||
class Point
|
class Point
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Point() : mX(0), mY(0)
|
Point();
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Point( double x, double y ) : mX(x), mY(y)
|
Point( double x, double y );
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline double x() const { return mX; }
|
double x() const;
|
||||||
inline double y() const { return mY; }
|
double y() const;
|
||||||
|
|
||||||
bool operator<( const Point &other ) const;
|
bool operator<( const Point &other ) const;
|
||||||
|
|
||||||
@@ -49,4 +45,8 @@ namespace libglabels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "Point.inl"
|
||||||
|
|
||||||
|
|
||||||
#endif // libglabels_Point_h
|
#endif // libglabels_Point_h
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
/* Point.inl
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||||
|
*
|
||||||
|
* This file is part of gLabels-qt.
|
||||||
|
*
|
||||||
|
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gLabels-qt is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
inline double Point::x() const { return mX; }
|
||||||
|
inline double Point::y() const { return mY; }
|
||||||
|
|
||||||
|
}
|
||||||
+28
-22
@@ -28,10 +28,10 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
Template::Template( const QString &brand,
|
Template::Template( const QString& brand,
|
||||||
const QString &part,
|
const QString& part,
|
||||||
const QString &description,
|
const QString& description,
|
||||||
const QString &paperId,
|
const QString& paperId,
|
||||||
double pageWidth = 0,
|
double pageWidth = 0,
|
||||||
double pageHeight = 0 )
|
double pageHeight = 0 )
|
||||||
: mBrand(brand),
|
: mBrand(brand),
|
||||||
@@ -48,14 +48,14 @@ namespace libglabels
|
|||||||
|
|
||||||
if ( Db::isPaperIdKnown( paperId ) )
|
if ( Db::isPaperIdKnown( paperId ) )
|
||||||
{
|
{
|
||||||
const Paper *paper = Db::lookupPaperFromId( paperId );
|
const Paper* paper = Db::lookupPaperFromId( paperId );
|
||||||
mIsSizeIso = paper->isSizeIso();
|
mIsSizeIso = paper->isSizeIso();
|
||||||
mIsSizeUs = paper->isSizeUs();
|
mIsSizeUs = paper->isSizeUs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Template::Template( const Template &other )
|
Template::Template( const Template& other )
|
||||||
{
|
{
|
||||||
mBrand = other.mBrand;
|
mBrand = other.mBrand;
|
||||||
mPart = other.mPart;
|
mPart = other.mPart;
|
||||||
@@ -69,7 +69,7 @@ namespace libglabels
|
|||||||
mName = other.mName;
|
mName = other.mName;
|
||||||
mProductUrl = other.mProductUrl;
|
mProductUrl = other.mProductUrl;
|
||||||
|
|
||||||
foreach ( Frame *frame, other.mFrames )
|
foreach ( Frame* frame, other.mFrames )
|
||||||
{
|
{
|
||||||
addFrame( frame );
|
addFrame( frame );
|
||||||
}
|
}
|
||||||
@@ -81,8 +81,14 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Template* Template::dup() const
|
||||||
|
{
|
||||||
|
return new Template( *this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Generic full page template
|
// Generic full page template
|
||||||
Template *Template::fullPage( const QString &paperId )
|
Template* Template::fullPage( const QString& paperId )
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -90,14 +96,14 @@ namespace libglabels
|
|||||||
|
|
||||||
|
|
||||||
// From equivalent part number
|
// From equivalent part number
|
||||||
Template *Template::fromEquiv( const QString &brand,
|
Template* Template::fromEquiv( const QString& brand,
|
||||||
const QString &part,
|
const QString& part,
|
||||||
const QString &equivPart )
|
const QString& equivPart )
|
||||||
{
|
{
|
||||||
const Template *other = Db::lookupTemplateFromBrandPart( brand, equivPart );
|
const Template* other = Db::lookupTemplateFromBrandPart( brand, equivPart );
|
||||||
if ( other != NULL )
|
if ( other != NULL )
|
||||||
{
|
{
|
||||||
Template *tmplate = other->dup();
|
Template* tmplate = other->dup();
|
||||||
|
|
||||||
tmplate->mPart = part;
|
tmplate->mPart = part;
|
||||||
tmplate->mEquivPart = equivPart;
|
tmplate->mEquivPart = equivPart;
|
||||||
@@ -117,13 +123,13 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Template::addCategory( const QString &categoryId )
|
void Template::addCategory( const QString& categoryId )
|
||||||
{
|
{
|
||||||
mCategoryIds << categoryId;
|
mCategoryIds << categoryId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Template::addFrame( Frame *frame )
|
void Template::addFrame( Frame* frame )
|
||||||
{
|
{
|
||||||
mFrames << frame;
|
mFrames << frame;
|
||||||
}
|
}
|
||||||
@@ -135,13 +141,13 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Template::operator==( const Template &other ) const
|
bool Template::operator==( const Template& other ) const
|
||||||
{
|
{
|
||||||
return (mBrand == other.mBrand) && (mPart == other.mPart);
|
return (mBrand == other.mBrand) && (mPart == other.mPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Template::hasCategory( const QString &categoryId ) const
|
bool Template::hasCategory( const QString& categoryId ) const
|
||||||
{
|
{
|
||||||
foreach ( QString testCategoryId, mCategoryIds )
|
foreach ( QString testCategoryId, mCategoryIds )
|
||||||
{
|
{
|
||||||
@@ -155,7 +161,7 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Template::isSimilarTo( const Template *other ) const
|
bool Template::isSimilarTo( const Template* other ) const
|
||||||
{
|
{
|
||||||
// Does page size match?
|
// Does page size match?
|
||||||
if ( (mPaperId != other->mPaperId) ||
|
if ( (mPaperId != other->mPaperId) ||
|
||||||
@@ -166,18 +172,18 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Are frames similar
|
// Are frames similar
|
||||||
Frame *frame1 = mFrames.first();
|
Frame* frame1 = mFrames.first();
|
||||||
Frame *frame2 = other->mFrames.first();
|
Frame* frame2 = other->mFrames.first();
|
||||||
if ( !frame1->isSimilarTo( frame2 ) )
|
if ( !frame1->isSimilarTo( frame2 ) )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Are they layed out similarly?
|
// Are they layed out similarly?
|
||||||
foreach ( Layout *layout1, frame1->layouts() )
|
foreach ( Layout* layout1, frame1->layouts() )
|
||||||
{
|
{
|
||||||
bool matchFound = false;
|
bool matchFound = false;
|
||||||
foreach ( Layout *layout2, frame2->layouts() )
|
foreach ( Layout* layout2, frame2->layouts() )
|
||||||
{
|
{
|
||||||
if ( layout1->isSimilarTo(layout2) )
|
if ( layout1->isSimilarTo(layout2) )
|
||||||
{
|
{
|
||||||
|
|||||||
+35
-32
@@ -46,58 +46,57 @@ namespace libglabels
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Template( const QString &brand,
|
Template( const QString& brand,
|
||||||
const QString &part,
|
const QString& part,
|
||||||
const QString &description,
|
const QString& description,
|
||||||
const QString &paperId,
|
const QString& paperId,
|
||||||
double pageWidth,
|
double pageWidth,
|
||||||
double pageHeight );
|
double pageHeight );
|
||||||
|
|
||||||
Template( const Template &other );
|
Template( const Template& other );
|
||||||
|
|
||||||
inline Template *dup() const { return new Template( *this ); }
|
|
||||||
|
|
||||||
|
Template* dup() const;
|
||||||
|
|
||||||
// Generic full page template
|
// Generic full page template
|
||||||
static Template *fullPage( const QString &paperId );
|
static Template* fullPage( const QString& paperId );
|
||||||
|
|
||||||
// From equivalent part number
|
// From equivalent part number
|
||||||
static Template *fromEquiv( const QString &brand,
|
static Template* fromEquiv( const QString& brand,
|
||||||
const QString &part,
|
const QString& part,
|
||||||
const QString &equivPart );
|
const QString& equivPart );
|
||||||
|
|
||||||
|
|
||||||
inline const QString &brand() const { return mBrand; }
|
const QString& brand() const;
|
||||||
inline const QString &part() const { return mPart; }
|
const QString& part() const;
|
||||||
inline const QString &description() const { return mDescription; }
|
const QString& description() const;
|
||||||
|
|
||||||
inline const QString &paperId() const { return mPaperId; }
|
const QString& paperId() const;
|
||||||
inline double pageWidth() const { return mPageWidth; }
|
double pageWidth() const;
|
||||||
inline double pageHeight() const { return mPageHeight; }
|
double pageHeight() const;
|
||||||
inline bool isSizeIso() const { return mIsSizeIso; }
|
bool isSizeIso() const;
|
||||||
inline bool isSizeUs() const { return mIsSizeUs; }
|
bool isSizeUs() const;
|
||||||
inline bool isSizeOther() const { return !mIsSizeIso && !mIsSizeUs; }
|
bool isSizeOther() const;
|
||||||
|
|
||||||
inline const QString &equivPart() const { return mEquivPart; }
|
const QString& equivPart() const;
|
||||||
inline void setEquivPart( const QString &value ) { mEquivPart = value; }
|
void setEquivPart( const QString& value );
|
||||||
|
|
||||||
inline const QString &productUrl() const { return mProductUrl; }
|
const QString& productUrl() const;
|
||||||
inline void setProductUrl( const QString &value ) { mProductUrl = value; }
|
void setProductUrl( const QString& value );
|
||||||
|
|
||||||
inline const QString &name() const { return mName; }
|
const QString& name() const;
|
||||||
|
|
||||||
void addCategory( const QString &categoryId );
|
void addCategory( const QString& categoryId );
|
||||||
void addFrame( Frame *frame );
|
void addFrame( Frame* frame );
|
||||||
|
|
||||||
void initPreview();
|
void initPreview();
|
||||||
inline const MiniPreviewPixmap &preview() const { return mPreview; }
|
const MiniPreviewPixmap& preview() const;
|
||||||
|
|
||||||
inline const QList<Frame*> &frames() const { return mFrames; }
|
const QList<Frame*>& frames() const;
|
||||||
|
|
||||||
bool operator==( const Template &other ) const;
|
bool operator==( const Template& other ) const;
|
||||||
|
|
||||||
bool hasCategory( const QString &categoryId ) const;
|
bool hasCategory( const QString& categoryId ) const;
|
||||||
bool isSimilarTo( const Template *other ) const;
|
bool isSimilarTo( const Template* other ) const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -124,4 +123,8 @@ namespace libglabels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "Template.inl"
|
||||||
|
|
||||||
|
|
||||||
#endif // libglabels_Template_h
|
#endif // libglabels_Template_h
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/* Template.inl
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||||
|
*
|
||||||
|
* This file is part of gLabels-qt.
|
||||||
|
*
|
||||||
|
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gLabels-qt is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
inline const QString& Template::brand() const { return mBrand; }
|
||||||
|
inline const QString& Template::part() const { return mPart; }
|
||||||
|
inline const QString& Template::description() const { return mDescription; }
|
||||||
|
|
||||||
|
inline const QString& Template::paperId() const { return mPaperId; }
|
||||||
|
inline double Template::pageWidth() const { return mPageWidth; }
|
||||||
|
inline double Template::pageHeight() const { return mPageHeight; }
|
||||||
|
inline bool Template::isSizeIso() const { return mIsSizeIso; }
|
||||||
|
inline bool Template::isSizeUs() const { return mIsSizeUs; }
|
||||||
|
inline bool Template::isSizeOther() const { return !mIsSizeIso && !mIsSizeUs; }
|
||||||
|
|
||||||
|
inline const QString& Template::equivPart() const { return mEquivPart; }
|
||||||
|
inline void Template::setEquivPart( const QString& value ) { mEquivPart = value; }
|
||||||
|
|
||||||
|
inline const QString& Template::productUrl() const { return mProductUrl; }
|
||||||
|
inline void Template::setProductUrl( const QString& value ) { mProductUrl = value; }
|
||||||
|
|
||||||
|
inline const QString& Template::name() const { return mName; }
|
||||||
|
|
||||||
|
inline const MiniPreviewPixmap& Template::preview() const { return mPreview; }
|
||||||
|
|
||||||
|
inline const QList<Frame*>& Template::frames() const { return mFrames; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -36,6 +36,13 @@ namespace
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Units::Units( const QString &id, const QString &name, double pointsPerUnit )
|
||||||
|
: mId(id), mName(name), mPointsPerUnit(pointsPerUnit)
|
||||||
|
{
|
||||||
|
mUnitsPerPoint = 1.0 / mPointsPerUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Units *Units::fromId( const QString &id )
|
Units *Units::fromId( const QString &id )
|
||||||
{
|
{
|
||||||
if ( id == "pt" )
|
if ( id == "pt" )
|
||||||
|
|||||||
+9
-13
@@ -36,22 +36,14 @@ namespace libglabels
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Units( const QString &id, const QString &name, double pointsPerUnit )
|
Units( const QString &id, const QString &name, double pointsPerUnit );
|
||||||
: mId(id), mName(name), mPointsPerUnit(pointsPerUnit)
|
|
||||||
{
|
|
||||||
mUnitsPerPoint = 1.0 / mPointsPerUnit;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline QString id() const { return mId; }
|
QString id() const;
|
||||||
|
QString name() const;
|
||||||
inline QString name() const { return mName; }
|
|
||||||
|
|
||||||
inline double pointsPerUnit() const { return mPointsPerUnit; }
|
|
||||||
|
|
||||||
inline double unitsPerPoint() const { return mUnitsPerPoint; }
|
|
||||||
|
|
||||||
|
double pointsPerUnit() const;
|
||||||
|
double unitsPerPoint() const;
|
||||||
|
|
||||||
static Units *fromId( const QString &id );
|
static Units *fromId( const QString &id );
|
||||||
|
|
||||||
@@ -78,4 +70,8 @@ namespace libglabels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "Units.inl"
|
||||||
|
|
||||||
|
|
||||||
#endif // libglabels_Units_h
|
#endif // libglabels_Units_h
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/* Units.inl
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||||
|
*
|
||||||
|
* This file is part of gLabels-qt.
|
||||||
|
*
|
||||||
|
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gLabels-qt is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
inline QString Units::id() const { return mId; }
|
||||||
|
|
||||||
|
inline QString Units::name() const { return mName; }
|
||||||
|
|
||||||
|
inline double Units::pointsPerUnit() const { return mPointsPerUnit; }
|
||||||
|
|
||||||
|
inline double Units::unitsPerPoint() const { return mUnitsPerPoint; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -19,3 +19,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Vendor.h"
|
#include "Vendor.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
Vendor::Vendor( const QString &name, const QString &url ) : mName(name), mUrl(url)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
+7
-6
@@ -31,13 +31,10 @@ namespace libglabels
|
|||||||
class Vendor
|
class Vendor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Vendor( const QString &name, const QString &url ) : mName(name), mUrl(url)
|
Vendor( const QString &name, const QString &url );
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const QString &name() const { return mName; }
|
const QString& name() const;
|
||||||
|
const QString& url() const;
|
||||||
inline const QString &url() const { return mUrl; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString mName;
|
QString mName;
|
||||||
@@ -46,4 +43,8 @@ namespace libglabels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "Vendor.inl"
|
||||||
|
|
||||||
|
|
||||||
#endif // libglabels_Vendor_h
|
#endif // libglabels_Vendor_h
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
/* Vendor.inl
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||||
|
*
|
||||||
|
* This file is part of gLabels-qt.
|
||||||
|
*
|
||||||
|
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gLabels-qt is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
inline const QString& Vendor::name() const { return mName; }
|
||||||
|
inline const QString& Vendor::url() const { return mUrl; }
|
||||||
|
|
||||||
|
}
|
||||||
+27
-3
@@ -27,7 +27,31 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
Units *XmlUtil::mDefaultUnits;
|
Units* XmlUtil::mDefaultUnits;
|
||||||
|
|
||||||
|
|
||||||
|
XmlUtil::XmlUtil()
|
||||||
|
{
|
||||||
|
mDefaultUnits = Units::point();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void XmlUtil::init()
|
||||||
|
{
|
||||||
|
static XmlUtil* xmlUtil = new XmlUtil();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Units* XmlUtil::defaultUnits()
|
||||||
|
{
|
||||||
|
return mDefaultUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void XmlUtil::setDefaultUnits( Units* defaultUnits )
|
||||||
|
{
|
||||||
|
mDefaultUnits = defaultUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString XmlUtil::getStringAttr( const QDomElement& node,
|
QString XmlUtil::getStringAttr( const QDomElement& node,
|
||||||
@@ -186,9 +210,9 @@ namespace libglabels
|
|||||||
return default_value;
|
return default_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Units *units = Units::fromId( unitsString );
|
Units* units = Units::fromId( unitsString );
|
||||||
|
|
||||||
return value * units->pointsPerUnit();
|
return value* units->pointsPerUnit();
|
||||||
}
|
}
|
||||||
|
|
||||||
return default_value;
|
return default_value;
|
||||||
|
|||||||
+6
-15
@@ -34,24 +34,15 @@ namespace libglabels
|
|||||||
class XmlUtil
|
class XmlUtil
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
XmlUtil()
|
XmlUtil();
|
||||||
{
|
|
||||||
mDefaultUnits = Units::point();
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static void init()
|
static void init();
|
||||||
{
|
|
||||||
static XmlUtil *xmlUtil = new XmlUtil();
|
|
||||||
}
|
|
||||||
|
|
||||||
static const Units *defaultUnits() { return mDefaultUnits; }
|
static const Units* defaultUnits();
|
||||||
|
static void setDefaultUnits( Units* defaultUnits );
|
||||||
static void setDefaultUnits( Units *defaultUnits )
|
|
||||||
{
|
|
||||||
mDefaultUnits = defaultUnits;
|
|
||||||
}
|
|
||||||
|
|
||||||
static QString getStringAttr( const QDomElement& node,
|
static QString getStringAttr( const QDomElement& node,
|
||||||
const QString& name,
|
const QString& name,
|
||||||
@@ -106,7 +97,7 @@ namespace libglabels
|
|||||||
double value );
|
double value );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Units *mDefaultUnits;
|
static Units* mDefaultUnits;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user