Some of the low-hanging fruit in libglabels.
This commit is contained in:
+5
-4
@@ -1,11 +1,11 @@
|
|||||||
cmake_minimum_required (VERSION 2.8)
|
cmake_minimum_required (VERSION 2.8)
|
||||||
|
|
||||||
project (qtLabels)
|
project (glabels-qt)
|
||||||
|
|
||||||
|
|
||||||
set (Package_Name "qtLabels")
|
set (Package_Name "glabels-qt")
|
||||||
set (Short_Name "qtLabels")
|
set (Short_Name "glabels-qt")
|
||||||
set (Package_URL "https://github.com/jimevins/qtLabels")
|
set (Package_URL "https://github.com/jimevins/glabels-qt")
|
||||||
|
|
||||||
set (Major_Version "0")
|
set (Major_Version "0")
|
||||||
set (Minor_Version "0")
|
set (Minor_Version "0")
|
||||||
@@ -26,4 +26,5 @@ add_definitions (-g)
|
|||||||
# Subdirectories
|
# Subdirectories
|
||||||
#
|
#
|
||||||
add_subdirectory (app)
|
add_subdirectory (app)
|
||||||
|
add_subdirectory (libglabels)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
cmake_minimum_required (VERSION 2.8)
|
||||||
|
|
||||||
|
project (libglabels CXX)
|
||||||
|
|
||||||
|
set (libglabels_sources
|
||||||
|
Category.cpp
|
||||||
|
Paper.cpp
|
||||||
|
Vendor.cpp
|
||||||
|
Units.cpp
|
||||||
|
Point.cpp
|
||||||
|
Layout.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set (libglabels_qobject_headers
|
||||||
|
)
|
||||||
|
|
||||||
|
set (libglabels_resource_files
|
||||||
|
)
|
||||||
|
|
||||||
|
qt4_wrap_cpp (libglabels_moc_sources ${libglabels_qobject_headers})
|
||||||
|
qt4_add_resources(libglabels_qrc_sources ${libglabels_resource_files})
|
||||||
|
|
||||||
|
include (${QT_USE_FILE})
|
||||||
|
|
||||||
|
|
||||||
|
include_directories (
|
||||||
|
)
|
||||||
|
|
||||||
|
link_directories (
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library (libglabels ${libglabels_sources} ${libglabels_moc_sources} ${libglabels_qrc_sources})
|
||||||
|
|
||||||
|
install (TARGETS libglabels ARCHIVE DESTINATION lib)
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
/* Category.cpp
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Category.h"
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/* Category.h
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef libglabels_Category_h
|
||||||
|
#define libglabels_Category_h
|
||||||
|
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
class Category
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Category( const QString &id, const QString &value ) : mId(id), mValue(value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QString id() const { return mId; }
|
||||||
|
|
||||||
|
inline QString value() const { return mValue; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString mId;
|
||||||
|
QString mValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // libglabels_Category_h
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/* Layout.cpp
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Layout.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "privateConstants.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
bool Layout::is_similar_to( const Layout &b )
|
||||||
|
{
|
||||||
|
return ( (mNx == b.mNx) &&
|
||||||
|
(mNy == b.mNy) &&
|
||||||
|
(fabs(mX0 - b.mX0) < Constants::EPSILON) &&
|
||||||
|
(fabs(mY0 - b.mY0) < Constants::EPSILON) &&
|
||||||
|
(fabs(mDx - b.mDx) < Constants::EPSILON) &&
|
||||||
|
(fabs(mDy - b.mDy) < Constants::EPSILON) );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/* Layout.h
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef libglabels_Layout_h
|
||||||
|
#define libglabels_Layout_h
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
class Layout
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int nx() const { return mNx; }
|
||||||
|
inline int ny() const { return mNy; }
|
||||||
|
|
||||||
|
inline double x0() const { return mX0; }
|
||||||
|
inline double y0() const { return mY0; }
|
||||||
|
|
||||||
|
inline double dx() const { return mDx; }
|
||||||
|
inline double dy() const { return mDy; }
|
||||||
|
|
||||||
|
bool is_similar_to( const Layout &b );
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
int mNx;
|
||||||
|
int mNy;
|
||||||
|
double mX0;
|
||||||
|
double mY0;
|
||||||
|
double mDx;
|
||||||
|
double mDy;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // libglabels_Layout_h
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
/* Paper.cpp
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Paper.h"
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
/* Paper.h
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef libglabels_Paper_h
|
||||||
|
#define libglabels_Paper_h
|
||||||
|
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
class Paper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Paper( const QString &id,
|
||||||
|
const QString &name,
|
||||||
|
double width,
|
||||||
|
double height,
|
||||||
|
const QString &pwgSize ) : mId(id), mName(name), mWidth(width), mHeight(height), mPwgSize(pwgSize)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QString id() const { return mId; }
|
||||||
|
|
||||||
|
inline QString name() const { return mName; }
|
||||||
|
|
||||||
|
/* Width (in points) */
|
||||||
|
inline double width() const { return mWidth; }
|
||||||
|
|
||||||
|
/* Height (in points) */
|
||||||
|
inline double height() const { return mHeight; }
|
||||||
|
|
||||||
|
/* PWG 5101.1-2002 size name */
|
||||||
|
inline QString pwgSize() const { return mPwgSize; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString mId;
|
||||||
|
QString mName;
|
||||||
|
double mWidth;
|
||||||
|
double mHeight;
|
||||||
|
QString mPwgSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // libglabels_Paper_h
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/* Point.cpp
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Point.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
int Point::compare_to( const Point &b )
|
||||||
|
{
|
||||||
|
if ( mY < b.mY )
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else if ( mY > b.mY )
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( mX < b.mX )
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else if ( mX > b.mX )
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0; /* hopefully 2 label frames won't have the same origin. */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/* Point.h
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef libglabels_Point_h
|
||||||
|
#define libglabels_Point_h
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
class Point
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Point( double x, double y ) : mX(x), mY(y)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline double x() const { return mX; }
|
||||||
|
inline double y() const { return mY; }
|
||||||
|
|
||||||
|
int compare_to( const Point &b );
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
double mX;
|
||||||
|
double mY;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // libglabels_Point_h
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
/* Units.cpp
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Units.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
const double POINTS_PER_POINT = 1.0; /* internal units are points. */
|
||||||
|
const double POINTS_PER_INCH = 72.0;
|
||||||
|
const double POINTS_PER_MM = 2.83464566929;
|
||||||
|
const double POINTS_PER_CM = (10.0*POINTS_PER_MM);
|
||||||
|
const double POINTS_PER_PICA = (1.0/12.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
Units *Units::from_id( const QString &id )
|
||||||
|
{
|
||||||
|
if ( id == "pt" )
|
||||||
|
{
|
||||||
|
return point();
|
||||||
|
}
|
||||||
|
else if ( id == "in" )
|
||||||
|
{
|
||||||
|
return inch();
|
||||||
|
}
|
||||||
|
else if ( id == "mm" )
|
||||||
|
{
|
||||||
|
return mm();
|
||||||
|
}
|
||||||
|
else if ( id == "cm" )
|
||||||
|
{
|
||||||
|
return cm();
|
||||||
|
}
|
||||||
|
else if ( id == "pc" )
|
||||||
|
{
|
||||||
|
return pica();
|
||||||
|
}
|
||||||
|
else if ( id == "" )
|
||||||
|
{
|
||||||
|
/* Missing or empty units id defaults to points. */
|
||||||
|
return point();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qWarning() << "Unknown Units ID \"" << id << "\", defaults to \"pt\"";
|
||||||
|
return point();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Units *Units::point()
|
||||||
|
{
|
||||||
|
static Units *instance = NULL;
|
||||||
|
|
||||||
|
if ( instance == NULL )
|
||||||
|
{
|
||||||
|
instance = new Units( "pt", tr("points"), POINTS_PER_POINT );
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Units *Units::inch()
|
||||||
|
{
|
||||||
|
static Units *instance = NULL;
|
||||||
|
|
||||||
|
if ( instance == NULL )
|
||||||
|
{
|
||||||
|
instance = new Units( "in", tr("inches"), POINTS_PER_INCH );
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Units *Units::mm()
|
||||||
|
{
|
||||||
|
static Units *instance = NULL;
|
||||||
|
|
||||||
|
if ( instance == NULL )
|
||||||
|
{
|
||||||
|
instance = new Units( "mm", tr("mm"), POINTS_PER_MM );
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Units *Units::cm()
|
||||||
|
{
|
||||||
|
static Units *instance = NULL;
|
||||||
|
|
||||||
|
if ( instance == NULL )
|
||||||
|
{
|
||||||
|
instance = new Units( "cm", tr("cm"), POINTS_PER_CM );
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Units *Units::pica()
|
||||||
|
{
|
||||||
|
static Units *instance = NULL;
|
||||||
|
|
||||||
|
if ( instance == NULL )
|
||||||
|
{
|
||||||
|
instance = new Units( "pc", tr("picas"), POINTS_PER_PICA );
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
/* Units.h
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef libglabels_Units_h
|
||||||
|
#define libglabels_Units_h
|
||||||
|
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
class Units
|
||||||
|
{
|
||||||
|
Q_DECLARE_TR_FUNCTIONS(Units)
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
Units( const QString &id, const QString &name, double pointsPerUnit )
|
||||||
|
: mId(id), mName(name), mPointsPerUnit(pointsPerUnit)
|
||||||
|
{
|
||||||
|
mUnitsPerPoint = 1.0 / mPointsPerUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
inline QString id() const { return mId; }
|
||||||
|
|
||||||
|
inline QString name() const { return mName; }
|
||||||
|
|
||||||
|
inline double pointsPerUnit() const { return mPointsPerUnit; }
|
||||||
|
|
||||||
|
inline double unitsPerPoint() const { return mUnitsPerPoint; }
|
||||||
|
|
||||||
|
|
||||||
|
static Units *from_id( const QString &id );
|
||||||
|
|
||||||
|
static Units *point();
|
||||||
|
|
||||||
|
static Units *inch();
|
||||||
|
|
||||||
|
static Units *mm();
|
||||||
|
|
||||||
|
static Units *cm();
|
||||||
|
|
||||||
|
static Units *pica();
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString mId;
|
||||||
|
QString mName;
|
||||||
|
double mPointsPerUnit;
|
||||||
|
double mUnitsPerPoint;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // libglabels_Units_h
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
/* Vendor.cpp
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Vendor.h"
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/* Vendor.h
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef libglabels_Vendor_h
|
||||||
|
#define libglabels_Vendor_h
|
||||||
|
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
class Vendor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Vendor( const QString &name, const QString &url ) : mName(name), mUrl(url)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QString name() const { return mName; }
|
||||||
|
|
||||||
|
inline QString url() const { return mUrl; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString mName;
|
||||||
|
QString mUrl;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // libglabels_Vendor_h
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
/* privateConstants.h
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef libglabels_privateConstants_h
|
||||||
|
#define libglabels_privateConstants_h
|
||||||
|
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Constants
|
||||||
|
{
|
||||||
|
|
||||||
|
const double EPSILON = 0.5; /* Allowed error when comparing dimensions. (0.5pts ~= .007in ~= .2mm) */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // libglabels_privateConstants_h
|
||||||
Reference in New Issue
Block a user