Added unit-independent distance type.
This commit is contained in:
+1
-1
@@ -24,7 +24,7 @@ find_package(Qt4 4.8.4 REQUIRED QtCore QtGui QtXml)
|
|||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
|
|
||||||
|
|
||||||
add_definitions (-g)
|
add_definitions (-std=c++11 -g)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
+10
-4
@@ -76,11 +76,15 @@ glabels::Handle::Location glabels::Handle::location() const
|
|||||||
///
|
///
|
||||||
/// Draw Handle at x,y
|
/// Draw Handle at x,y
|
||||||
///
|
///
|
||||||
void glabels::Handle::drawAt( QPainter* painter, double scale, double x, double y, QColor color ) const
|
void glabels::Handle::drawAt( QPainter* painter,
|
||||||
|
double scale,
|
||||||
|
const libglabels::Distance& x,
|
||||||
|
const libglabels::Distance& y,
|
||||||
|
QColor color ) const
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
painter->translate( x, y );
|
painter->translate( x.pt(), y.pt() );
|
||||||
|
|
||||||
double s = 1.0 / scale;
|
double s = 1.0 / scale;
|
||||||
|
|
||||||
@@ -100,14 +104,16 @@ void glabels::Handle::drawAt( QPainter* painter, double scale, double x, double
|
|||||||
///
|
///
|
||||||
/// Create Handle path at x,y
|
/// Create Handle path at x,y
|
||||||
///
|
///
|
||||||
QPainterPath glabels::Handle::pathAt( double scale, double x, double y ) const
|
QPainterPath glabels::Handle::pathAt( double scale,
|
||||||
|
const libglabels::Distance& x,
|
||||||
|
const libglabels::Distance& y ) const
|
||||||
{
|
{
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
|
|
||||||
double s = 1/scale;
|
double s = 1/scale;
|
||||||
|
|
||||||
path.addRect( -s*handlePixels/2, -s*handlePixels/2, s*handlePixels, s*handlePixels );
|
path.addRect( -s*handlePixels/2, -s*handlePixels/2, s*handlePixels, s*handlePixels );
|
||||||
path.translate( x, y );
|
path.translate( x.pt(), y.pt() );
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-2
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
|
#include "libglabels/Distance.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
@@ -67,8 +68,15 @@ namespace glabels
|
|||||||
virtual void draw( QPainter* painter, double scale ) const = 0;
|
virtual void draw( QPainter* painter, double scale ) const = 0;
|
||||||
virtual QPainterPath path( double scale ) const = 0;
|
virtual QPainterPath path( double scale ) const = 0;
|
||||||
protected:
|
protected:
|
||||||
void drawAt( QPainter* painter, double scale, double x, double y, QColor color ) const;
|
void drawAt( QPainter* painter,
|
||||||
QPainterPath pathAt( double scale, double x, double y ) const;
|
double scale,
|
||||||
|
const libglabels::Distance& x,
|
||||||
|
const libglabels::Distance& y,
|
||||||
|
QColor color ) const;
|
||||||
|
|
||||||
|
QPainterPath pathAt( double scale,
|
||||||
|
const libglabels::Distance& x,
|
||||||
|
const libglabels::Distance& y ) const;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
|
|||||||
+39
-35
@@ -1,6 +1,6 @@
|
|||||||
/* LabelModel.cpp
|
/* LabelModel.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -116,7 +116,9 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Object at x,y
|
/// Object at x,y
|
||||||
///
|
///
|
||||||
LabelModelObject* LabelModel::objectAt( double scale, double x, double y ) const
|
LabelModelObject* LabelModel::objectAt( double scale,
|
||||||
|
const libglabels::Distance& x,
|
||||||
|
const libglabels::Distance& y ) const
|
||||||
{
|
{
|
||||||
/* Search object list in reverse order. I.e. from top to bottom. */
|
/* Search object list in reverse order. I.e. from top to bottom. */
|
||||||
QList<LabelModelObject*>::const_iterator it = mObjectList.end();
|
QList<LabelModelObject*>::const_iterator it = mObjectList.end();
|
||||||
@@ -137,7 +139,9 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Handle at x,y
|
/// Handle at x,y
|
||||||
///
|
///
|
||||||
Handle* LabelModel::handleAt( double scale, double x, double y ) const
|
Handle* LabelModel::handleAt( double scale,
|
||||||
|
const libglabels::Distance& x,
|
||||||
|
const libglabels::Distance& y ) const
|
||||||
{
|
{
|
||||||
foreach( LabelModelObject* object, mObjectList )
|
foreach( LabelModelObject* object, mObjectList )
|
||||||
{
|
{
|
||||||
@@ -234,10 +238,10 @@ namespace glabels
|
|||||||
using std::min;
|
using std::min;
|
||||||
using std::max;
|
using std::max;
|
||||||
|
|
||||||
double rX1 = min( region.x1(), region.x2() );
|
libglabels::Distance rX1 = min( region.x1(), region.x2() );
|
||||||
double rY1 = min( region.y1(), region.y2() );
|
libglabels::Distance rY1 = min( region.y1(), region.y2() );
|
||||||
double rX2 = max( region.x1(), region.x2() );
|
libglabels::Distance rX2 = max( region.x1(), region.x2() );
|
||||||
double rY2 = max( region.y1(), region.y2() );
|
libglabels::Distance rY2 = max( region.y1(), region.y2() );
|
||||||
|
|
||||||
foreach ( LabelModelObject* object, mObjectList )
|
foreach ( LabelModelObject* object, mObjectList )
|
||||||
{
|
{
|
||||||
@@ -559,7 +563,7 @@ namespace glabels
|
|||||||
QList<LabelModelObject*> selectedList = getSelection();
|
QList<LabelModelObject*> selectedList = getSelection();
|
||||||
|
|
||||||
/// Find left-most edge.
|
/// Find left-most edge.
|
||||||
double x1_min = 7200; /// Start with a very large value: 7200pts = 100in
|
libglabels::Distance x1_min = 7200; /// Start with a very large value: 7200pts = 100in
|
||||||
foreach ( LabelModelObject* object, selectedList )
|
foreach ( LabelModelObject* object, selectedList )
|
||||||
{
|
{
|
||||||
LabelRegion r = object->getExtent();
|
LabelRegion r = object->getExtent();
|
||||||
@@ -570,7 +574,7 @@ namespace glabels
|
|||||||
foreach ( LabelModelObject* object, selectedList )
|
foreach ( LabelModelObject* object, selectedList )
|
||||||
{
|
{
|
||||||
LabelRegion r = object->getExtent();
|
LabelRegion r = object->getExtent();
|
||||||
double dx = x1_min - r.x1();
|
libglabels::Distance dx = x1_min - r.x1();
|
||||||
object->setPositionRelative( dx, 0 );
|
object->setPositionRelative( dx, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -594,7 +598,7 @@ namespace glabels
|
|||||||
QList<LabelModelObject*> selectedList = getSelection();
|
QList<LabelModelObject*> selectedList = getSelection();
|
||||||
|
|
||||||
/// Find right-most edge.
|
/// Find right-most edge.
|
||||||
double x1_max = -7200; /// Start with a very large negative value: 7200pts = 100in
|
libglabels::Distance x1_max = -7200; /// Start with a very large negative value: 7200pts = 100in
|
||||||
foreach ( LabelModelObject* object, selectedList )
|
foreach ( LabelModelObject* object, selectedList )
|
||||||
{
|
{
|
||||||
LabelRegion r = object->getExtent();
|
LabelRegion r = object->getExtent();
|
||||||
@@ -605,7 +609,7 @@ namespace glabels
|
|||||||
foreach ( LabelModelObject* object, selectedList )
|
foreach ( LabelModelObject* object, selectedList )
|
||||||
{
|
{
|
||||||
LabelRegion r = object->getExtent();
|
LabelRegion r = object->getExtent();
|
||||||
double dx = x1_max - r.x1();
|
libglabels::Distance dx = x1_max - r.x1();
|
||||||
object->setPositionRelative( dx, 0 );
|
object->setPositionRelative( dx, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -629,7 +633,7 @@ namespace glabels
|
|||||||
QList<LabelModelObject*> selectedList = getSelection();
|
QList<LabelModelObject*> selectedList = getSelection();
|
||||||
|
|
||||||
/// Find average center of objects.
|
/// Find average center of objects.
|
||||||
double xsum = 0;
|
libglabels::Distance xsum = 0;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
foreach ( LabelModelObject* object, selectedList )
|
foreach ( LabelModelObject* object, selectedList )
|
||||||
{
|
{
|
||||||
@@ -637,15 +641,15 @@ namespace glabels
|
|||||||
xsum += (r.x1() + r.x2()) / 2.0;
|
xsum += (r.x1() + r.x2()) / 2.0;
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
double xavg = xsum / n;
|
libglabels::Distance xavg = xsum / n;
|
||||||
|
|
||||||
/// Find object closest to average center of objects.
|
/// Find object closest to average center of objects.
|
||||||
double xcenter = 7200; /// Start with very large value.
|
libglabels::Distance xcenter = 7200; /// Start with very large value.
|
||||||
double dxmin = fabs( xavg - xcenter );
|
libglabels::Distance dxmin = fabs( xavg - xcenter );
|
||||||
foreach ( LabelModelObject* object, selectedList )
|
foreach ( LabelModelObject* object, selectedList )
|
||||||
{
|
{
|
||||||
LabelRegion r = object->getExtent();
|
LabelRegion r = object->getExtent();
|
||||||
double dx = fabs( xavg - (r.x1() + r.x2())/2.0 );
|
libglabels::Distance dx = fabs( xavg - (r.x1() + r.x2())/2.0 );
|
||||||
if ( dx < dxmin )
|
if ( dx < dxmin )
|
||||||
{
|
{
|
||||||
dxmin = dx;
|
dxmin = dx;
|
||||||
@@ -657,7 +661,7 @@ namespace glabels
|
|||||||
foreach ( LabelModelObject* object, selectedList )
|
foreach ( LabelModelObject* object, selectedList )
|
||||||
{
|
{
|
||||||
LabelRegion r = object->getExtent();
|
LabelRegion r = object->getExtent();
|
||||||
double dx = xcenter - (r.x1() + r.x2())/2.0;
|
libglabels::Distance dx = xcenter - (r.x1() + r.x2())/2.0;
|
||||||
object->setPositionRelative( dx, 0 );
|
object->setPositionRelative( dx, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -681,7 +685,7 @@ namespace glabels
|
|||||||
QList<LabelModelObject*> selectedList = getSelection();
|
QList<LabelModelObject*> selectedList = getSelection();
|
||||||
|
|
||||||
/// Find top-most edge.
|
/// Find top-most edge.
|
||||||
double y1_min = 7200; /// Start with a very large value: 7200pts = 100in
|
libglabels::Distance y1_min = 7200; /// Start with a very large value: 7200pts = 100in
|
||||||
foreach ( LabelModelObject* object, selectedList )
|
foreach ( LabelModelObject* object, selectedList )
|
||||||
{
|
{
|
||||||
LabelRegion r = object->getExtent();
|
LabelRegion r = object->getExtent();
|
||||||
@@ -692,7 +696,7 @@ namespace glabels
|
|||||||
foreach ( LabelModelObject* object, selectedList )
|
foreach ( LabelModelObject* object, selectedList )
|
||||||
{
|
{
|
||||||
LabelRegion r = object->getExtent();
|
LabelRegion r = object->getExtent();
|
||||||
double dy = y1_min - r.y1();
|
libglabels::Distance dy = y1_min - r.y1();
|
||||||
object->setPositionRelative( 0, dy );
|
object->setPositionRelative( 0, dy );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -716,7 +720,7 @@ namespace glabels
|
|||||||
QList<LabelModelObject*> selectedList = getSelection();
|
QList<LabelModelObject*> selectedList = getSelection();
|
||||||
|
|
||||||
/// Find bottom-most edge.
|
/// Find bottom-most edge.
|
||||||
double y1_max = -7200; /// Start with a very large negative value: 7200pts = 100in
|
libglabels::Distance y1_max = -7200; /// Start with a very large negative value: 7200pts = 100in
|
||||||
foreach ( LabelModelObject* object, selectedList )
|
foreach ( LabelModelObject* object, selectedList )
|
||||||
{
|
{
|
||||||
LabelRegion r = object->getExtent();
|
LabelRegion r = object->getExtent();
|
||||||
@@ -727,7 +731,7 @@ namespace glabels
|
|||||||
foreach ( LabelModelObject* object, selectedList )
|
foreach ( LabelModelObject* object, selectedList )
|
||||||
{
|
{
|
||||||
LabelRegion r = object->getExtent();
|
LabelRegion r = object->getExtent();
|
||||||
double dy = y1_max - r.y1();
|
libglabels::Distance dy = y1_max - r.y1();
|
||||||
object->setPositionRelative( 0, dy );
|
object->setPositionRelative( 0, dy );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -751,7 +755,7 @@ namespace glabels
|
|||||||
QList<LabelModelObject*> selectedList = getSelection();
|
QList<LabelModelObject*> selectedList = getSelection();
|
||||||
|
|
||||||
/// Find average center of objects.
|
/// Find average center of objects.
|
||||||
double ysum = 0;
|
libglabels::Distance ysum = 0;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
foreach ( LabelModelObject* object, selectedList )
|
foreach ( LabelModelObject* object, selectedList )
|
||||||
{
|
{
|
||||||
@@ -759,15 +763,15 @@ namespace glabels
|
|||||||
ysum += (r.y1() + r.y2()) / 2.0;
|
ysum += (r.y1() + r.y2()) / 2.0;
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
double yavg = ysum / n;
|
libglabels::Distance yavg = ysum / n;
|
||||||
|
|
||||||
/// Find object closest to average center of objects.
|
/// Find object closest to average center of objects.
|
||||||
double ycenter = 7200; /// Start with very large value.
|
libglabels::Distance ycenter = 7200; /// Start with very large value.
|
||||||
double dymin = fabs( yavg - ycenter );
|
libglabels::Distance dymin = fabs( yavg - ycenter );
|
||||||
foreach ( LabelModelObject* object, selectedList )
|
foreach ( LabelModelObject* object, selectedList )
|
||||||
{
|
{
|
||||||
LabelRegion r = object->getExtent();
|
LabelRegion r = object->getExtent();
|
||||||
double dy = fabs( yavg - (r.y1() + r.y2())/2.0 );
|
libglabels::Distance dy = fabs( yavg - (r.y1() + r.y2())/2.0 );
|
||||||
if ( dy < dymin )
|
if ( dy < dymin )
|
||||||
{
|
{
|
||||||
dymin = dy;
|
dymin = dy;
|
||||||
@@ -779,7 +783,7 @@ namespace glabels
|
|||||||
foreach ( LabelModelObject* object, selectedList )
|
foreach ( LabelModelObject* object, selectedList )
|
||||||
{
|
{
|
||||||
LabelRegion r = object->getExtent();
|
LabelRegion r = object->getExtent();
|
||||||
double dy = ycenter - (r.y1() + r.y2())/2.0;
|
libglabels::Distance dy = ycenter - (r.y1() + r.y2())/2.0;
|
||||||
object->setPositionRelative( 0, dy );
|
object->setPositionRelative( 0, dy );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -795,15 +799,15 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void LabelModel::centerSelectionHoriz()
|
void LabelModel::centerSelectionHoriz()
|
||||||
{
|
{
|
||||||
double xLabelCenter = w() / 2.0;
|
libglabels::Distance xLabelCenter = w() / 2.0;
|
||||||
|
|
||||||
foreach ( LabelModelObject* object, mObjectList )
|
foreach ( LabelModelObject* object, mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
LabelRegion r = object->getExtent();
|
LabelRegion r = object->getExtent();
|
||||||
double xObjectCenter = (r.x1() + r.x2()) / 2.0;
|
libglabels::Distance xObjectCenter = (r.x1() + r.x2()) / 2.0;
|
||||||
double dx = xLabelCenter - xObjectCenter;
|
libglabels::Distance dx = xLabelCenter - xObjectCenter;
|
||||||
object->setPositionRelative( dx, 0 );
|
object->setPositionRelative( dx, 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -820,15 +824,15 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void LabelModel::centerSelectionVert()
|
void LabelModel::centerSelectionVert()
|
||||||
{
|
{
|
||||||
double yLabelCenter = h() / 2.0;
|
libglabels::Distance yLabelCenter = h() / 2.0;
|
||||||
|
|
||||||
foreach ( LabelModelObject* object, mObjectList )
|
foreach ( LabelModelObject* object, mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
LabelRegion r = object->getExtent();
|
LabelRegion r = object->getExtent();
|
||||||
double yObjectCenter = (r.y1() + r.y2()) / 2.0;
|
libglabels::Distance yObjectCenter = (r.y1() + r.y2()) / 2.0;
|
||||||
double dy = yLabelCenter - yObjectCenter;
|
libglabels::Distance dy = yLabelCenter - yObjectCenter;
|
||||||
object->setPositionRelative( 0, dy );
|
object->setPositionRelative( 0, dy );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -843,7 +847,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Move Selected Objects By dx,dy
|
/// Move Selected Objects By dx,dy
|
||||||
///
|
///
|
||||||
void LabelModel::moveSelection( double dx, double dy )
|
void LabelModel::moveSelection( const libglabels::Distance& dx, const libglabels::Distance& dy )
|
||||||
{
|
{
|
||||||
foreach ( LabelModelObject* object, mObjectList )
|
foreach ( LabelModelObject* object, mObjectList )
|
||||||
{
|
{
|
||||||
@@ -1023,7 +1027,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Set Line Width Of Selected Objects
|
/// Set Line Width Of Selected Objects
|
||||||
///
|
///
|
||||||
void LabelModel::setSelectionLineWidth( double lineWidth )
|
void LabelModel::setSelectionLineWidth( const libglabels::Distance& lineWidth )
|
||||||
{
|
{
|
||||||
foreach ( LabelModelObject* object, mObjectList )
|
foreach ( LabelModelObject* object, mObjectList )
|
||||||
{
|
{
|
||||||
|
|||||||
+14
-9
@@ -1,6 +1,6 @@
|
|||||||
/* LabelModel.h
|
/* LabelModel.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -88,8 +88,8 @@ namespace glabels
|
|||||||
inline bool rotate() const;
|
inline bool rotate() const;
|
||||||
inline void setRotate( bool rotate );
|
inline void setRotate( bool rotate );
|
||||||
|
|
||||||
inline double w() const;
|
inline libglabels::Distance w() const;
|
||||||
inline double h() const;
|
inline libglabels::Distance h() const;
|
||||||
|
|
||||||
inline const QList<LabelModelObject*>& objectList() const;
|
inline const QList<LabelModelObject*>& objectList() const;
|
||||||
|
|
||||||
@@ -101,8 +101,13 @@ namespace glabels
|
|||||||
void addObject( LabelModelObject* object );
|
void addObject( LabelModelObject* object );
|
||||||
void deleteObject( LabelModelObject* object );
|
void deleteObject( LabelModelObject* object );
|
||||||
|
|
||||||
LabelModelObject* objectAt( double scale, double x, double y ) const;
|
LabelModelObject* objectAt( double scale,
|
||||||
Handle* handleAt( double scale, double x, double y ) const;
|
const libglabels::Distance& x,
|
||||||
|
const libglabels::Distance& y ) const;
|
||||||
|
|
||||||
|
Handle* handleAt( double scale,
|
||||||
|
const libglabels::Distance& x,
|
||||||
|
const libglabels::Distance& y ) const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
@@ -156,7 +161,7 @@ namespace glabels
|
|||||||
void alignSelectionVCenter();
|
void alignSelectionVCenter();
|
||||||
void centerSelectionHoriz();
|
void centerSelectionHoriz();
|
||||||
void centerSelectionVert();
|
void centerSelectionVert();
|
||||||
void moveSelection( double dx, double dy );
|
void moveSelection( const libglabels::Distance& dx, const libglabels::Distance& dy );
|
||||||
void setSelectionFontFamily( const QString& fontFamily );
|
void setSelectionFontFamily( const QString& fontFamily );
|
||||||
void setSelectionFontSize( double fontSize );
|
void setSelectionFontSize( double fontSize );
|
||||||
void setSelectionFontWeight( QFont::Weight fontWeight );
|
void setSelectionFontWeight( QFont::Weight fontWeight );
|
||||||
@@ -165,7 +170,7 @@ namespace glabels
|
|||||||
void setSelectionTextVAlign( Qt::Alignment textVAlign );
|
void setSelectionTextVAlign( Qt::Alignment textVAlign );
|
||||||
void setSelectionTextLineSpacing( double textLineSpacing );
|
void setSelectionTextLineSpacing( double textLineSpacing );
|
||||||
void setSelectionTextColorNode( ColorNode textColorNode );
|
void setSelectionTextColorNode( ColorNode textColorNode );
|
||||||
void setSelectionLineWidth( double lineWidth );
|
void setSelectionLineWidth( const libglabels::Distance& lineWidth );
|
||||||
void setSelectionLineColorNode( ColorNode lineColorNode );
|
void setSelectionLineColorNode( ColorNode lineColorNode );
|
||||||
void setSelectionFillColorNode( ColorNode fillColorNode );
|
void setSelectionFillColorNode( ColorNode fillColorNode );
|
||||||
|
|
||||||
@@ -284,13 +289,13 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double LabelModel::w() const
|
inline libglabels::Distance LabelModel::w() const
|
||||||
{
|
{
|
||||||
return mRotate ? mFrame->h() : mFrame->w();
|
return mRotate ? mFrame->h() : mFrame->w();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double LabelModel::h() const
|
inline libglabels::Distance LabelModel::h() const
|
||||||
{
|
{
|
||||||
return mRotate ? mFrame->w() : mFrame->h();
|
return mRotate ? mFrame->w() : mFrame->h();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* LabelModelBoxObject.cpp
|
/* LabelModelBoxObject.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -70,12 +70,15 @@ namespace glabels
|
|||||||
if ( lineColor.alpha() )
|
if ( lineColor.alpha() )
|
||||||
{
|
{
|
||||||
/* Has FILL and OUTLINE: adjust size to account for line width. */
|
/* Has FILL and OUTLINE: adjust size to account for line width. */
|
||||||
painter->drawRect( QRectF( -mLineWidth/2, -mLineWidth/2, mW+mLineWidth, mH+mLineWidth ) );
|
painter->drawRect( QRectF( -mLineWidth.pt()/2,
|
||||||
|
-mLineWidth.pt()/2,
|
||||||
|
(mW + mLineWidth).pt(),
|
||||||
|
(mH + mLineWidth).pt() ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Has FILL, but no OUTLINE. */
|
/* Has FILL, but no OUTLINE. */
|
||||||
painter->drawRect( QRectF( 0, 0, mW, mH ) );
|
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -83,10 +86,10 @@ namespace glabels
|
|||||||
if ( lineColor.alpha() )
|
if ( lineColor.alpha() )
|
||||||
{
|
{
|
||||||
/* Has only OUTLINE. */
|
/* Has only OUTLINE. */
|
||||||
painter->setPen( QPen( shadowColor, mLineWidth ) );
|
painter->setPen( QPen( shadowColor, mLineWidth.pt() ) );
|
||||||
painter->setBrush( Qt::NoBrush );
|
painter->setBrush( Qt::NoBrush );
|
||||||
|
|
||||||
painter->drawRect( QRectF( 0, 0, mW, mH ) );
|
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,10 +106,10 @@ namespace glabels
|
|||||||
QColor lineColor = mLineColorNode.color();
|
QColor lineColor = mLineColorNode.color();
|
||||||
QColor fillColor = mFillColorNode.color();
|
QColor fillColor = mFillColorNode.color();
|
||||||
|
|
||||||
painter->setPen( QPen( lineColor, mLineWidth ) );
|
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
||||||
painter->setBrush( fillColor );
|
painter->setBrush( fillColor );
|
||||||
|
|
||||||
painter->drawRect( QRectF( 0, 0, mW, mH ) );
|
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -121,21 +124,26 @@ namespace glabels
|
|||||||
|
|
||||||
if ( mFillColorNode.color().alpha() && mLineColorNode.color().alpha() )
|
if ( mFillColorNode.color().alpha() && mLineColorNode.color().alpha() )
|
||||||
{
|
{
|
||||||
path.addRect( -mLineWidth/2, -mLineWidth/2, mW+mLineWidth, mH+mLineWidth );
|
path.addRect( -mLineWidth.pt()/2, -mLineWidth.pt()/2, (mW+mLineWidth).pt(), (mH+mLineWidth).pt() );
|
||||||
}
|
}
|
||||||
else if ( mFillColorNode.color().alpha() && !(mLineColorNode.color().alpha()) )
|
else if ( mFillColorNode.color().alpha() && !(mLineColorNode.color().alpha()) )
|
||||||
{
|
{
|
||||||
path.addRect( 0, 0, mW, mH );
|
path.addRect( 0, 0, mW.pt(), mH.pt() );
|
||||||
}
|
}
|
||||||
else if ( mLineColorNode.color().alpha() )
|
else if ( mLineColorNode.color().alpha() )
|
||||||
{
|
{
|
||||||
path.addRect( (-mLineWidth/2)-s*slopPixels, (-mLineWidth/2)-s*slopPixels,
|
path.addRect( (-mLineWidth.pt()/2) - s*slopPixels,
|
||||||
mW+mLineWidth+s*2*slopPixels, mH+mLineWidth+s*2*slopPixels );
|
(-mLineWidth.pt()/2) - s*slopPixels,
|
||||||
|
(mW + mLineWidth).pt() + s*2*slopPixels,
|
||||||
|
(mH + mLineWidth).pt() + s*2*slopPixels );
|
||||||
path.closeSubpath();
|
path.closeSubpath();
|
||||||
path.addRect( mLineWidth/2+s*slopPixels, mLineWidth/2+s*slopPixels,
|
path.addRect( mLineWidth.pt()/2 + s*slopPixels,
|
||||||
mW-mLineWidth-s*2*slopPixels, mH-mLineWidth-s*2*slopPixels );
|
mLineWidth.pt()/2 + s*slopPixels,
|
||||||
|
(mW - mLineWidth).pt() - s*2*slopPixels,
|
||||||
|
(mH - mLineWidth).pt() - s*2*slopPixels );
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* LabelModelBoxObject.h
|
/* LabelModelBoxObject.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// X0 Property Getter
|
/// X0 Property Getter
|
||||||
///
|
///
|
||||||
double LabelModelObject::x0() const
|
libglabels::Distance LabelModelObject::x0() const
|
||||||
{
|
{
|
||||||
return mX0;
|
return mX0;
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// X0 Property Setter
|
/// X0 Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelObject::setX0( double value )
|
void LabelModelObject::setX0( const libglabels::Distance& value )
|
||||||
{
|
{
|
||||||
if ( mX0 != value )
|
if ( mX0 != value )
|
||||||
{
|
{
|
||||||
@@ -135,7 +135,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Y0 Property Getter
|
/// Y0 Property Getter
|
||||||
///
|
///
|
||||||
double LabelModelObject::y0() const
|
libglabels::Distance LabelModelObject::y0() const
|
||||||
{
|
{
|
||||||
return mY0;
|
return mY0;
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Y0 Property Setter
|
/// Y0 Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelObject::setY0( double value )
|
void LabelModelObject::setY0( const libglabels::Distance& value )
|
||||||
{
|
{
|
||||||
if ( mY0 != value )
|
if ( mY0 != value )
|
||||||
{
|
{
|
||||||
@@ -157,7 +157,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// W (Width) Property Getter
|
/// W (Width) Property Getter
|
||||||
///
|
///
|
||||||
double LabelModelObject::w() const
|
libglabels::Distance LabelModelObject::w() const
|
||||||
{
|
{
|
||||||
return mW;
|
return mW;
|
||||||
}
|
}
|
||||||
@@ -166,7 +166,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// W (Width) Property Setter
|
/// W (Width) Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelObject::setW( double value )
|
void LabelModelObject::setW( const libglabels::Distance& value )
|
||||||
{
|
{
|
||||||
if ( mW != value )
|
if ( mW != value )
|
||||||
{
|
{
|
||||||
@@ -179,7 +179,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// H (Height) Property Getter
|
/// H (Height) Property Getter
|
||||||
///
|
///
|
||||||
double LabelModelObject::h() const
|
libglabels::Distance LabelModelObject::h() const
|
||||||
{
|
{
|
||||||
return mH;
|
return mH;
|
||||||
}
|
}
|
||||||
@@ -188,7 +188,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// H (Height) Property Setter
|
/// H (Height) Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelObject::setH( double value )
|
void LabelModelObject::setH( const libglabels::Distance& value )
|
||||||
{
|
{
|
||||||
if ( mH != value )
|
if ( mH != value )
|
||||||
{
|
{
|
||||||
@@ -245,7 +245,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Shadow X Property Getter
|
/// Shadow X Property Getter
|
||||||
///
|
///
|
||||||
double LabelModelObject::shadowX() const
|
libglabels::Distance LabelModelObject::shadowX() const
|
||||||
{
|
{
|
||||||
return mShadowX;
|
return mShadowX;
|
||||||
}
|
}
|
||||||
@@ -254,7 +254,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Shadow X Property Setter
|
/// Shadow X Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelObject::setShadowX( double value )
|
void LabelModelObject::setShadowX( const libglabels::Distance& value )
|
||||||
{
|
{
|
||||||
if ( mShadowX != value )
|
if ( mShadowX != value )
|
||||||
{
|
{
|
||||||
@@ -267,7 +267,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Shadow Y Property Getter
|
/// Shadow Y Property Getter
|
||||||
///
|
///
|
||||||
double LabelModelObject::shadowY() const
|
libglabels::Distance LabelModelObject::shadowY() const
|
||||||
{
|
{
|
||||||
return mShadowY;
|
return mShadowY;
|
||||||
}
|
}
|
||||||
@@ -276,7 +276,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Shadow Y Property Setter
|
/// Shadow Y Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelObject::setShadowY( double value )
|
void LabelModelObject::setShadowY( const libglabels::Distance& value )
|
||||||
{
|
{
|
||||||
if ( mShadowY != value )
|
if ( mShadowY != value )
|
||||||
{
|
{
|
||||||
@@ -524,7 +524,7 @@ namespace glabels
|
|||||||
/// Virtual Line Width Property Default Getter
|
/// Virtual Line Width Property Default Getter
|
||||||
/// (Overridden by concrete class)
|
/// (Overridden by concrete class)
|
||||||
///
|
///
|
||||||
double LabelModelObject::lineWidth() const
|
libglabels::Distance LabelModelObject::lineWidth() const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -534,7 +534,7 @@ namespace glabels
|
|||||||
/// Virtual Line Width Property Default Setter
|
/// Virtual Line Width Property Default Setter
|
||||||
/// (Overridden by concrete class)
|
/// (Overridden by concrete class)
|
||||||
///
|
///
|
||||||
void LabelModelObject::setLineWidth( double value )
|
void LabelModelObject::setLineWidth( const libglabels::Distance& value )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -734,7 +734,8 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Set Absolute Position
|
/// Set Absolute Position
|
||||||
///
|
///
|
||||||
void LabelModelObject::setPosition( double x0, double y0 )
|
void LabelModelObject::setPosition( const libglabels::Distance& x0,
|
||||||
|
const libglabels::Distance& y0 )
|
||||||
{
|
{
|
||||||
if ( ( mX0 != x0 ) || ( mY0 != y0 ) )
|
if ( ( mX0 != x0 ) || ( mY0 != y0 ) )
|
||||||
{
|
{
|
||||||
@@ -749,7 +750,8 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Set Relative Position
|
/// Set Relative Position
|
||||||
///
|
///
|
||||||
void LabelModelObject::setPositionRelative( double dx, double dy )
|
void LabelModelObject::setPositionRelative( const libglabels::Distance& dx,
|
||||||
|
const libglabels::Distance& dy )
|
||||||
{
|
{
|
||||||
if ( ( dx != 0 ) || ( dy != 0 ) )
|
if ( ( dx != 0 ) || ( dy != 0 ) )
|
||||||
{
|
{
|
||||||
@@ -764,7 +766,8 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Set Size
|
/// Set Size
|
||||||
///
|
///
|
||||||
void LabelModelObject::setSize( double w, double h )
|
void LabelModelObject::setSize( const libglabels::Distance& w,
|
||||||
|
const libglabels::Distance& h )
|
||||||
{
|
{
|
||||||
mW = w;
|
mW = w;
|
||||||
mH = h;
|
mH = h;
|
||||||
@@ -776,30 +779,33 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Set Size (But Maintain Current Aspect Ratio)
|
/// Set Size (But Maintain Current Aspect Ratio)
|
||||||
///
|
///
|
||||||
void LabelModelObject::setSizeHonorAspect( double w, double h )
|
void LabelModelObject::setSizeHonorAspect( const libglabels::Distance& w,
|
||||||
|
const libglabels::Distance& h )
|
||||||
{
|
{
|
||||||
double aspectRatio = mH / mW;
|
double aspectRatio = mH / mW;
|
||||||
|
libglabels::Distance wNew = w;
|
||||||
|
libglabels::Distance hNew = h;
|
||||||
|
|
||||||
if ( h > (w*aspectRatio) )
|
if ( h > (w*aspectRatio) )
|
||||||
{
|
{
|
||||||
h = w*aspectRatio;
|
hNew = w*aspectRatio;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
w = h/aspectRatio;
|
wNew = h/aspectRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
setSize( w, h );
|
setSize( wNew, hNew );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set Width (But Maintain Current Aspect Ratio)
|
/// Set Width (But Maintain Current Aspect Ratio)
|
||||||
///
|
///
|
||||||
void LabelModelObject::setWHonorAspect( double w )
|
void LabelModelObject::setWHonorAspect( const libglabels::Distance& w )
|
||||||
{
|
{
|
||||||
double aspectRatio = mH / mW;
|
double aspectRatio = mH / mW;
|
||||||
double h = w * aspectRatio;
|
libglabels::Distance h = w * aspectRatio;
|
||||||
|
|
||||||
if ( ( mW != w ) || ( mH != h ) )
|
if ( ( mW != w ) || ( mH != h ) )
|
||||||
{
|
{
|
||||||
@@ -814,10 +820,10 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Set Height (But Maintain Current Aspect Ratio)
|
/// Set Height (But Maintain Current Aspect Ratio)
|
||||||
///
|
///
|
||||||
void LabelModelObject::setHHonorAspect( double h )
|
void LabelModelObject::setHHonorAspect( const libglabels::Distance& h )
|
||||||
{
|
{
|
||||||
double aspectRatio = mH / mW;
|
double aspectRatio = mH / mW;
|
||||||
double w = h / aspectRatio;
|
libglabels::Distance w = h / aspectRatio;
|
||||||
|
|
||||||
if ( ( mW != w ) || ( mH != h ) )
|
if ( ( mW != w ) || ( mH != h ) )
|
||||||
{
|
{
|
||||||
@@ -837,10 +843,10 @@ namespace glabels
|
|||||||
using std::min;
|
using std::min;
|
||||||
using std::max;
|
using std::max;
|
||||||
|
|
||||||
QPointF a1( - lineWidth()/2, - lineWidth()/2 );
|
QPointF a1( ( - lineWidth()/2).pt(), ( - lineWidth()/2).pt() );
|
||||||
QPointF a2( mW + lineWidth()/2, - lineWidth()/2 );
|
QPointF a2( (mW + lineWidth()/2).pt(), ( - lineWidth()/2).pt() );
|
||||||
QPointF a3( mW + lineWidth()/2, mH + lineWidth()/2 );
|
QPointF a3( (mW + lineWidth()/2).pt(), (mH + lineWidth()/2).pt() );
|
||||||
QPointF a4( - lineWidth()/2, mH + lineWidth()/2 );
|
QPointF a4( ( - lineWidth()/2).pt(), (mH + lineWidth()/2).pt() );
|
||||||
|
|
||||||
a1 = mMatrix.map( a1 );
|
a1 = mMatrix.map( a1 );
|
||||||
a2 = mMatrix.map( a2 );
|
a2 = mMatrix.map( a2 );
|
||||||
@@ -848,10 +854,10 @@ namespace glabels
|
|||||||
a4 = mMatrix.map( a4 );
|
a4 = mMatrix.map( a4 );
|
||||||
|
|
||||||
LabelRegion region;
|
LabelRegion region;
|
||||||
region.setX1( min( a1.x(), min( a2.x(), min( a3.x(), a4.x() ) ) ) + mX0 );
|
region.setX1( libglabels::Distance(min( a1.x(), min( a2.x(), min( a3.x(), a4.x() ) ) )) + mX0 );
|
||||||
region.setY1( min( a1.y(), min( a2.y(), min( a3.y(), a4.y() ) ) ) + mY0 );
|
region.setY1( libglabels::Distance(min( a1.y(), min( a2.y(), min( a3.y(), a4.y() ) ) )) + mY0 );
|
||||||
region.setX2( max( a1.x(), max( a2.x(), max( a3.x(), a4.x() ) ) ) + mX0 );
|
region.setX2( libglabels::Distance(max( a1.x(), max( a2.x(), max( a3.x(), a4.x() ) ) )) + mX0 );
|
||||||
region.setY2( max( a1.y(), max( a2.y(), max( a3.y(), a4.y() ) ) ) + mY0 );
|
region.setY2( libglabels::Distance(max( a1.y(), max( a2.y(), max( a3.y(), a4.y() ) ) )) + mY0 );
|
||||||
|
|
||||||
return region;
|
return region;
|
||||||
}
|
}
|
||||||
@@ -902,14 +908,16 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Is this object located at x,y?
|
/// Is this object located at x,y?
|
||||||
///
|
///
|
||||||
bool LabelModelObject::isLocatedAt( double scale, double x, double y ) const
|
bool LabelModelObject::isLocatedAt( double scale,
|
||||||
|
const libglabels::Distance& x,
|
||||||
|
const libglabels::Distance& y ) const
|
||||||
{
|
{
|
||||||
QPointF p( x, y );
|
QPointF p( x.pt(), y.pt() );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Change point to object relative coordinates
|
* Change point to object relative coordinates
|
||||||
*/
|
*/
|
||||||
p -= QPointF( mX0, mY0 ); // Translate point to x0,y0
|
p -= QPointF( mX0.pt(), mY0.pt() ); // Translate point to x0,y0
|
||||||
p = mMatrix.inverted().map( p );
|
p = mMatrix.inverted().map( p );
|
||||||
|
|
||||||
if ( hoverPath( scale ).contains( p ) )
|
if ( hoverPath( scale ).contains( p ) )
|
||||||
@@ -931,12 +939,14 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Is one of this object's handles locate at x,y? If so, return it.
|
/// Is one of this object's handles locate at x,y? If so, return it.
|
||||||
///
|
///
|
||||||
Handle* LabelModelObject::handleAt( double scale, double x, double y ) const
|
Handle* LabelModelObject::handleAt( double scale,
|
||||||
|
const libglabels::Distance& x,
|
||||||
|
const libglabels::Distance& y ) const
|
||||||
{
|
{
|
||||||
if ( mSelectedFlag )
|
if ( mSelectedFlag )
|
||||||
{
|
{
|
||||||
QPointF p( x, y );
|
QPointF p( x.pt(), y.pt() );
|
||||||
p -= QPointF( mX0, mY0 ); // Translate point to x0,y0
|
p -= QPointF( mX0.pt(), mY0.pt() ); // Translate point to x0,y0
|
||||||
|
|
||||||
foreach ( Handle* handle, mHandles )
|
foreach ( Handle* handle, mHandles )
|
||||||
{
|
{
|
||||||
@@ -958,12 +968,12 @@ namespace glabels
|
|||||||
void LabelModelObject::draw( QPainter* painter, bool inEditor, MergeRecord* record ) const
|
void LabelModelObject::draw( QPainter* painter, bool inEditor, MergeRecord* record ) const
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->translate( mX0, mY0 );
|
painter->translate( mX0.pt(), mY0.pt() );
|
||||||
|
|
||||||
if ( mShadowState )
|
if ( mShadowState )
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->translate( mShadowX, mShadowY );
|
painter->translate( mShadowX.pt(), mShadowY.pt() );
|
||||||
painter->setMatrix( mMatrix, true );
|
painter->setMatrix( mMatrix, true );
|
||||||
drawShadow( painter, inEditor, record );
|
drawShadow( painter, inEditor, record );
|
||||||
painter->restore();
|
painter->restore();
|
||||||
@@ -983,7 +993,7 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
painter->translate( mX0, mY0 );
|
painter->translate( mX0.pt(), mY0.pt() );
|
||||||
painter->setMatrix( mMatrix, true );
|
painter->setMatrix( mMatrix, true );
|
||||||
|
|
||||||
if ( mOutline )
|
if ( mOutline )
|
||||||
@@ -1000,7 +1010,5 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+36
-97
@@ -1,6 +1,6 @@
|
|||||||
/* LabelModelObject.h
|
/* LabelModelObject.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <QMatrix>
|
#include <QMatrix>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
#include "libglabels/Distance.h"
|
||||||
#include "ColorNode.h"
|
#include "ColorNode.h"
|
||||||
#include "TextNode.h"
|
#include "TextNode.h"
|
||||||
#include "BarcodeStyle.h"
|
#include "BarcodeStyle.h"
|
||||||
@@ -70,15 +71,11 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// ID Property.
|
// ID Property.
|
||||||
//
|
//
|
||||||
Q_PROPERTY( int id READ id )
|
|
||||||
|
|
||||||
int id() const;
|
int id() const;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Selected Property.
|
// Selected Property.
|
||||||
//
|
//
|
||||||
Q_PROPERTY( bool selected READ isSelected WRITE select RESET unselect )
|
|
||||||
|
|
||||||
bool isSelected() const;
|
bool isSelected() const;
|
||||||
void select( bool value = true );
|
void select( bool value = true );
|
||||||
void unselect();
|
void unselect();
|
||||||
@@ -87,44 +84,34 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// x0 Property ( x coordinate of origin )
|
// x0 Property ( x coordinate of origin )
|
||||||
//
|
//
|
||||||
Q_PROPERTY( double x0 READ x0 WRITE setX0 );
|
libglabels::Distance x0() const;
|
||||||
|
void setX0( const libglabels::Distance& value );
|
||||||
double x0() const;
|
|
||||||
void setX0( double value );
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// y0 Property ( y coordinate of origin )
|
// y0 Property ( y coordinate of origin )
|
||||||
//
|
//
|
||||||
Q_PROPERTY( double y0 READ y0 WRITE setY0 );
|
libglabels::Distance y0() const;
|
||||||
|
void setY0( const libglabels::Distance& value );
|
||||||
double y0() const;
|
|
||||||
void setY0( double value );
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// w Property ( width of bounding box )
|
// w Property ( width of bounding box )
|
||||||
//
|
//
|
||||||
Q_PROPERTY( double w READ w WRITE setW );
|
libglabels::Distance w() const;
|
||||||
|
void setW( const libglabels::Distance& value );
|
||||||
double w() const;
|
|
||||||
void setW( double value );
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// h Property ( height of bounding box )
|
// h Property ( height of bounding box )
|
||||||
//
|
//
|
||||||
Q_PROPERTY( double h READ h WRITE setH );
|
libglabels::Distance h() const;
|
||||||
|
void setH( const libglabels::Distance& value );
|
||||||
double h() const;
|
|
||||||
void setH( double value );
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Transformation Matrix Property
|
// Transformation Matrix Property
|
||||||
//
|
//
|
||||||
Q_PROPERTY( QMatrix matrix READ matrix WRITE setMatrix );
|
|
||||||
|
|
||||||
QMatrix matrix() const;
|
QMatrix matrix() const;
|
||||||
void setMatrix( const QMatrix& value );
|
void setMatrix( const QMatrix& value );
|
||||||
|
|
||||||
@@ -132,8 +119,6 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Shadow State Property
|
// Shadow State Property
|
||||||
//
|
//
|
||||||
Q_PROPERTY( bool shadow READ shadow WRITE setShadow );
|
|
||||||
|
|
||||||
bool shadow() const;
|
bool shadow() const;
|
||||||
void setShadow( bool value );
|
void setShadow( bool value );
|
||||||
|
|
||||||
@@ -141,26 +126,20 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Shadow x Offset Property
|
// Shadow x Offset Property
|
||||||
//
|
//
|
||||||
Q_PROPERTY( double shadowX READ shadowX WRITE setShadowX );
|
libglabels::Distance shadowX() const;
|
||||||
|
void setShadowX( const libglabels::Distance& value );
|
||||||
double shadowX() const;
|
|
||||||
void setShadowX( double value );
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Shadow y Offset Property
|
// Shadow y Offset Property
|
||||||
//
|
//
|
||||||
Q_PROPERTY( double shadowY READ shadowY WRITE setShadowY );
|
libglabels::Distance shadowY() const;
|
||||||
|
void setShadowY( const libglabels::Distance& value );
|
||||||
double shadowY() const;
|
|
||||||
void setShadowY( double value );
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Shadow opacity Property
|
// Shadow opacity Property
|
||||||
//
|
//
|
||||||
Q_PROPERTY( double shadowOpacity READ shadowOpacity WRITE setShadowOpacity );
|
|
||||||
|
|
||||||
double shadowOpacity() const;
|
double shadowOpacity() const;
|
||||||
void setShadowOpacity( double value );
|
void setShadowOpacity( double value );
|
||||||
|
|
||||||
@@ -168,8 +147,6 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Shadow Color Property
|
// Shadow Color Property
|
||||||
//
|
//
|
||||||
Q_PROPERTY( ColorNode shadowColorNode READ shadowColorNode WRITE setShadowColorNode );
|
|
||||||
|
|
||||||
ColorNode shadowColorNode() const;
|
ColorNode shadowColorNode() const;
|
||||||
void setShadowColorNode( const ColorNode& value );
|
void setShadowColorNode( const ColorNode& value );
|
||||||
|
|
||||||
@@ -181,8 +158,6 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Virtual Text Property: fontFamily
|
// Virtual Text Property: fontFamily
|
||||||
//
|
//
|
||||||
Q_PROPERTY( QString fontFamily READ fontFamily WRITE setFontFamily );
|
|
||||||
|
|
||||||
virtual QString fontFamily() const;
|
virtual QString fontFamily() const;
|
||||||
virtual void setFontFamily( const QString &value );
|
virtual void setFontFamily( const QString &value );
|
||||||
|
|
||||||
@@ -190,8 +165,6 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Virtual Text Property: fontSize
|
// Virtual Text Property: fontSize
|
||||||
//
|
//
|
||||||
Q_PROPERTY( double fontSize READ fontSize WRITE setFontSize );
|
|
||||||
|
|
||||||
virtual double fontSize() const;
|
virtual double fontSize() const;
|
||||||
virtual void setFontSize( double value );
|
virtual void setFontSize( double value );
|
||||||
|
|
||||||
@@ -199,8 +172,6 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Virtual Text Property: fontWeight
|
// Virtual Text Property: fontWeight
|
||||||
//
|
//
|
||||||
Q_PROPERTY( QFont::Weight fontWeight READ fontWeight WRITE setFontWeight );
|
|
||||||
|
|
||||||
virtual QFont::Weight fontWeight() const;
|
virtual QFont::Weight fontWeight() const;
|
||||||
virtual void setFontWeight( QFont::Weight value );
|
virtual void setFontWeight( QFont::Weight value );
|
||||||
|
|
||||||
@@ -208,8 +179,6 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Virtual Text Property: fontItalicFlag
|
// Virtual Text Property: fontItalicFlag
|
||||||
//
|
//
|
||||||
Q_PROPERTY( bool fontItalicFlag READ fontItalicFlag WRITE setFontItalicFlag );
|
|
||||||
|
|
||||||
virtual bool fontItalicFlag() const;
|
virtual bool fontItalicFlag() const;
|
||||||
virtual void setFontItalicFlag( bool value );
|
virtual void setFontItalicFlag( bool value );
|
||||||
|
|
||||||
@@ -217,8 +186,6 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Virtual Text Property: fontUnderlineFlag
|
// Virtual Text Property: fontUnderlineFlag
|
||||||
//
|
//
|
||||||
Q_PROPERTY( bool fontUnderlineFlag READ fontUnderlineFlag WRITE setFontUnderlineFlag );
|
|
||||||
|
|
||||||
virtual bool fontUnderlineFlag() const;
|
virtual bool fontUnderlineFlag() const;
|
||||||
virtual void setFontUnderlineFlag( bool value );
|
virtual void setFontUnderlineFlag( bool value );
|
||||||
|
|
||||||
@@ -226,8 +193,6 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Virtual Text Property: textColorNode
|
// Virtual Text Property: textColorNode
|
||||||
//
|
//
|
||||||
Q_PROPERTY( ColorNode textColorNode READ textColorNode WRITE setTextColorNode );
|
|
||||||
|
|
||||||
virtual ColorNode textColorNode() const;
|
virtual ColorNode textColorNode() const;
|
||||||
virtual void setTextColorNode( const ColorNode &value );
|
virtual void setTextColorNode( const ColorNode &value );
|
||||||
|
|
||||||
@@ -235,8 +200,6 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Virtual Text Property: textHAlign
|
// Virtual Text Property: textHAlign
|
||||||
//
|
//
|
||||||
Q_PROPERTY( Qt::Alignment textHAlign READ textHAlign WRITE setTextHAlign );
|
|
||||||
|
|
||||||
virtual Qt::Alignment textHAlign() const;
|
virtual Qt::Alignment textHAlign() const;
|
||||||
virtual void setTextHAlign( Qt::Alignment value );
|
virtual void setTextHAlign( Qt::Alignment value );
|
||||||
|
|
||||||
@@ -244,8 +207,6 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Virtual Text Property: textVAlign
|
// Virtual Text Property: textVAlign
|
||||||
//
|
//
|
||||||
Q_PROPERTY( Qt::Alignment textVAlign READ textVAlign WRITE setTextVAlign );
|
|
||||||
|
|
||||||
virtual Qt::Alignment textVAlign() const;
|
virtual Qt::Alignment textVAlign() const;
|
||||||
virtual void setTextVAlign( Qt::Alignment value );
|
virtual void setTextVAlign( Qt::Alignment value );
|
||||||
|
|
||||||
@@ -253,8 +214,6 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Virtual Text Property: textLineSpacing
|
// Virtual Text Property: textLineSpacing
|
||||||
//
|
//
|
||||||
Q_PROPERTY( double textLineSpacing READ textLineSpacing WRITE setTextLineSpacing );
|
|
||||||
|
|
||||||
virtual double textLineSpacing() const;
|
virtual double textLineSpacing() const;
|
||||||
virtual void setTextLineSpacing( double value );
|
virtual void setTextLineSpacing( double value );
|
||||||
|
|
||||||
@@ -266,8 +225,6 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Virtual Image Property: filenameNode
|
// Virtual Image Property: filenameNode
|
||||||
//
|
//
|
||||||
Q_PROPERTY( TextNode filenameNode READ filenameNode WRITE setFilenameNode );
|
|
||||||
|
|
||||||
virtual TextNode filenameNode() const;
|
virtual TextNode filenameNode() const;
|
||||||
virtual void setFilenameNode( const TextNode &value );
|
virtual void setFilenameNode( const TextNode &value );
|
||||||
|
|
||||||
@@ -279,17 +236,13 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Virtual Shape Property: lineWidth
|
// Virtual Shape Property: lineWidth
|
||||||
//
|
//
|
||||||
Q_PROPERTY( double lineWidth READ lineWidth WRITE setLineWidth );
|
virtual libglabels::Distance lineWidth() const;
|
||||||
|
virtual void setLineWidth( const libglabels::Distance& value );
|
||||||
virtual double lineWidth() const;
|
|
||||||
virtual void setLineWidth( double value );
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Virtual Shape Property: lineColorNode
|
// Virtual Shape Property: lineColorNode
|
||||||
//
|
//
|
||||||
Q_PROPERTY( ColorNode lineColorNode READ lineColorNode WRITE setLineColorNode );
|
|
||||||
|
|
||||||
virtual ColorNode lineColorNode() const;
|
virtual ColorNode lineColorNode() const;
|
||||||
virtual void setLineColorNode( const ColorNode &value );
|
virtual void setLineColorNode( const ColorNode &value );
|
||||||
|
|
||||||
@@ -297,8 +250,6 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Virtual Shape Property: fillColorNode
|
// Virtual Shape Property: fillColorNode
|
||||||
//
|
//
|
||||||
Q_PROPERTY( ColorNode fillColorNode READ fillColorNode WRITE setFillColorNode );
|
|
||||||
|
|
||||||
virtual ColorNode fillColorNode() const;
|
virtual ColorNode fillColorNode() const;
|
||||||
virtual void setFillColorNode( const ColorNode &value );
|
virtual void setFillColorNode( const ColorNode &value );
|
||||||
|
|
||||||
@@ -310,8 +261,6 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Virtual Barcode Property: bcDataNode
|
// Virtual Barcode Property: bcDataNode
|
||||||
//
|
//
|
||||||
Q_PROPERTY( TextNode bcDataNode READ bcDataNode WRITE setBcDataNode );
|
|
||||||
|
|
||||||
virtual TextNode bcDataNode() const;
|
virtual TextNode bcDataNode() const;
|
||||||
virtual void setBcDataNode( const TextNode &value );
|
virtual void setBcDataNode( const TextNode &value );
|
||||||
|
|
||||||
@@ -319,8 +268,6 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Virtual Barcode Property: bcTextFlag
|
// Virtual Barcode Property: bcTextFlag
|
||||||
//
|
//
|
||||||
Q_PROPERTY( bool bcTextFlag READ bcTextFlag WRITE setBcTextFlag );
|
|
||||||
|
|
||||||
virtual bool bcTextFlag() const;
|
virtual bool bcTextFlag() const;
|
||||||
virtual void setBcTextFlag( bool value );
|
virtual void setBcTextFlag( bool value );
|
||||||
|
|
||||||
@@ -328,8 +275,6 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Virtual Barcode Property: bcChecksumFlag
|
// Virtual Barcode Property: bcChecksumFlag
|
||||||
//
|
//
|
||||||
Q_PROPERTY( bool bcChecksumFlag READ bcChecksumFlag WRITE setBcChecksumFlag );
|
|
||||||
|
|
||||||
virtual bool bcChecksumFlag() const;
|
virtual bool bcChecksumFlag() const;
|
||||||
virtual void setBcChecksumFlag( bool value );
|
virtual void setBcChecksumFlag( bool value );
|
||||||
|
|
||||||
@@ -337,8 +282,6 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Virtual Barcode Property: bcColorNode
|
// Virtual Barcode Property: bcColorNode
|
||||||
//
|
//
|
||||||
Q_PROPERTY( ColorNode bcColorNode READ bcColorNode WRITE setBcColorNode );
|
|
||||||
|
|
||||||
virtual ColorNode bcColorNode() const;
|
virtual ColorNode bcColorNode() const;
|
||||||
virtual void setBcColorNode( const ColorNode &value );
|
virtual void setBcColorNode( const ColorNode &value );
|
||||||
|
|
||||||
@@ -346,8 +289,6 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Virtual Barcode Property: bcStyle
|
// Virtual Barcode Property: bcStyle
|
||||||
//
|
//
|
||||||
Q_PROPERTY( BarcodeStyle bcStyle READ bcStyle WRITE setBcStyle );
|
|
||||||
|
|
||||||
virtual BarcodeStyle bcStyle() const;
|
virtual BarcodeStyle bcStyle() const;
|
||||||
virtual void setBcStyle( const BarcodeStyle &value );
|
virtual void setBcStyle( const BarcodeStyle &value );
|
||||||
|
|
||||||
@@ -355,8 +296,6 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Virtual Barcode Property: bcFormatDigits
|
// Virtual Barcode Property: bcFormatDigits
|
||||||
//
|
//
|
||||||
Q_PROPERTY( int bcFormatDigits READ bcFormatDigits WRITE setBcFormatDigits );
|
|
||||||
|
|
||||||
virtual int bcFormatDigits() const;
|
virtual int bcFormatDigits() const;
|
||||||
virtual void setBcFormatDigits( int value );
|
virtual void setBcFormatDigits( int value );
|
||||||
|
|
||||||
@@ -375,18 +314,18 @@ namespace glabels
|
|||||||
// Position and Size methods
|
// Position and Size methods
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void setPosition( double x0, double y0 );
|
void setPosition( const libglabels::Distance& x0, const libglabels::Distance& y0 );
|
||||||
void setPositionRelative( double dx, double dy );
|
void setPositionRelative( const libglabels::Distance& dx, const libglabels::Distance& dy );
|
||||||
void setSize( double w, double h );
|
void setSize( const libglabels::Distance& w, const libglabels::Distance& h );
|
||||||
void setSizeHonorAspect( double w, double h );
|
void setSizeHonorAspect( const libglabels::Distance& w, const libglabels::Distance& h );
|
||||||
void setWHonorAspect( double w );
|
void setWHonorAspect( const libglabels::Distance& w );
|
||||||
void setHHonorAspect( double h );
|
void setHHonorAspect( const libglabels::Distance& h );
|
||||||
LabelRegion getExtent();
|
LabelRegion getExtent();
|
||||||
void rotate( double thetaDegs );
|
void rotate( double thetaDegs );
|
||||||
void flipHoriz();
|
void flipHoriz();
|
||||||
void flipVert();
|
void flipVert();
|
||||||
bool isLocatedAt( double scale, double x, double y ) const;
|
bool isLocatedAt( double scale, const libglabels::Distance& x, const libglabels::Distance& y ) const;
|
||||||
Handle* handleAt( double scale, double x, double y ) const;
|
Handle* handleAt( double scale, const libglabels::Distance& x, const libglabels::Distance& y ) const;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
@@ -406,21 +345,21 @@ namespace glabels
|
|||||||
// Protected Members
|
// Protected Members
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
bool mSelectedFlag;
|
bool mSelectedFlag;
|
||||||
|
|
||||||
double mX0;
|
libglabels::Distance mX0;
|
||||||
double mY0;
|
libglabels::Distance mY0;
|
||||||
double mW;
|
libglabels::Distance mW;
|
||||||
double mH;
|
libglabels::Distance mH;
|
||||||
|
|
||||||
bool mShadowState;
|
bool mShadowState;
|
||||||
double mShadowX;
|
libglabels::Distance mShadowX;
|
||||||
double mShadowY;
|
libglabels::Distance mShadowY;
|
||||||
double mShadowOpacity;
|
double mShadowOpacity;
|
||||||
ColorNode mShadowColorNode;
|
ColorNode mShadowColorNode;
|
||||||
|
|
||||||
QList<Handle*> mHandles;
|
QList<Handle*> mHandles;
|
||||||
Outline* mOutline;
|
Outline* mOutline;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* LabelModelShapeObject.cpp
|
/* LabelModelShapeObject.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -67,7 +67,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Line Width Property Getter
|
/// Line Width Property Getter
|
||||||
///
|
///
|
||||||
double LabelModelShapeObject::lineWidth( void ) const
|
libglabels::Distance LabelModelShapeObject::lineWidth( void ) const
|
||||||
{
|
{
|
||||||
return mLineWidth;
|
return mLineWidth;
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Line Width Property Setter
|
/// Line Width Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelShapeObject::setLineWidth( double value )
|
void LabelModelShapeObject::setLineWidth( const libglabels::Distance& value )
|
||||||
{
|
{
|
||||||
if ( mLineWidth != value )
|
if ( mLineWidth != value )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* LabelModelShapeObject.h
|
/* LabelModelShapeObject.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -50,8 +50,8 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// Shape Property: lineWidth
|
// Shape Property: lineWidth
|
||||||
//
|
//
|
||||||
virtual double lineWidth( void ) const;
|
virtual libglabels::Distance lineWidth( void ) const;
|
||||||
virtual void setLineWidth( double value );
|
virtual void setLineWidth( const libglabels::Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -81,9 +81,9 @@ namespace glabels
|
|||||||
// Private Members
|
// Private Members
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
double mLineWidth;
|
libglabels::Distance mLineWidth;
|
||||||
ColorNode mLineColorNode;
|
ColorNode mLineColorNode;
|
||||||
ColorNode mFillColorNode;
|
ColorNode mFillColorNode;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* LabelRegion.cpp
|
/* LabelRegion.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -34,10 +34,10 @@ namespace glabels
|
|||||||
|
|
||||||
QRectF r;
|
QRectF r;
|
||||||
|
|
||||||
r.setX( min( mX1, mX2 ) );
|
r.setX( min( mX1, mX2 ).pt() );
|
||||||
r.setY( min( mY1, mY2 ) );
|
r.setY( min( mY1, mY2 ).pt() );
|
||||||
r.setWidth( fabs( mX2 - mX1 ) );
|
r.setWidth( fabs( mX2 - mX1 ).pt() );
|
||||||
r.setHeight( fabs( mY2 - mY1 ) );
|
r.setHeight( fabs( mY2 - mY1 ).pt() );
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-20
@@ -22,6 +22,7 @@
|
|||||||
#define glabels_LabelRegion_h
|
#define glabels_LabelRegion_h
|
||||||
|
|
||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
|
#include "libglabels/Distance.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
@@ -40,30 +41,30 @@ namespace glabels
|
|||||||
//
|
//
|
||||||
// X1 Property
|
// X1 Property
|
||||||
//
|
//
|
||||||
inline double x1( void ) const;
|
libglabels::Distance x1( void ) const;
|
||||||
inline void setX1( double value );
|
void setX1( const libglabels::Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Y1 Property
|
// Y1 Property
|
||||||
//
|
//
|
||||||
inline double y1( void ) const;
|
libglabels::Distance y1( void ) const;
|
||||||
inline void setY1( double value );
|
void setY1( const libglabels::Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// X2 Property
|
// X2 Property
|
||||||
//
|
//
|
||||||
inline double x2( void ) const;
|
libglabels::Distance x2( void ) const;
|
||||||
inline void setX2( double value );
|
void setX2( const libglabels::Distance& value );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Y2 Property
|
// Y2 Property
|
||||||
//
|
//
|
||||||
inline double y2( void ) const;
|
libglabels::Distance y2( void ) const;
|
||||||
inline void setY2( double value );
|
void setY2( const libglabels::Distance& value );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
@@ -77,59 +78,59 @@ namespace glabels
|
|||||||
// Private Data
|
// Private Data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
double mX1;
|
libglabels::Distance mX1;
|
||||||
double mY1;
|
libglabels::Distance mY1;
|
||||||
double mX2;
|
libglabels::Distance mX2;
|
||||||
double mY2;
|
libglabels::Distance mY2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// INLINE METHODS
|
// INLINE METHODS
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
double LabelRegion::x1( void ) const
|
inline libglabels::Distance LabelRegion::x1( void ) const
|
||||||
{
|
{
|
||||||
return mX1;
|
return mX1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LabelRegion::setX1( double value )
|
inline void LabelRegion::setX1( const libglabels::Distance& value )
|
||||||
{
|
{
|
||||||
mX1 = value;
|
mX1 = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double LabelRegion::y1( void ) const
|
inline libglabels::Distance LabelRegion::y1( void ) const
|
||||||
{
|
{
|
||||||
return mY1;
|
return mY1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LabelRegion::setY1( double value )
|
inline void LabelRegion::setY1( const libglabels::Distance& value )
|
||||||
{
|
{
|
||||||
mY1 = value;
|
mY1 = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double LabelRegion::x2( void ) const
|
inline libglabels::Distance LabelRegion::x2( void ) const
|
||||||
{
|
{
|
||||||
return mX2;
|
return mX2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LabelRegion::setX2( double value )
|
inline void LabelRegion::setX2( const libglabels::Distance& value )
|
||||||
{
|
{
|
||||||
mX2 = value;
|
mX2 = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double LabelRegion::y2( void ) const
|
inline libglabels::Distance LabelRegion::y2( void ) const
|
||||||
{
|
{
|
||||||
return mY2;
|
return mY2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LabelRegion::setY2( double value )
|
inline void LabelRegion::setY2( const libglabels::Distance& value )
|
||||||
{
|
{
|
||||||
mY2 = value;
|
mY2 = value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* NewLabelDialog.cpp
|
/* NewLabelDialog.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -165,7 +165,7 @@ namespace glabels
|
|||||||
QString pgSizeString = libglabels::Db::lookupPaperNameFromId( tmplate->paperId() );
|
QString pgSizeString = libglabels::Db::lookupPaperNameFromId( tmplate->paperId() );
|
||||||
pageSizeLabel->setText( pgSizeString );
|
pageSizeLabel->setText( pgSizeString );
|
||||||
|
|
||||||
QString labelSizeString = frame->sizeDescription( libglabels::Units::inch() );
|
QString labelSizeString = frame->sizeDescription( libglabels::Distance::Units::IN );
|
||||||
labelSizeLabel->setText( labelSizeString );
|
labelSizeLabel->setText( labelSizeString );
|
||||||
|
|
||||||
QString layoutString = frame->layoutDescription();
|
QString layoutString = frame->layoutDescription();
|
||||||
|
|||||||
+22
-22
@@ -1,6 +1,6 @@
|
|||||||
/* ObjectEditor.cpp
|
/* ObjectEditor.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -78,7 +78,7 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
mBlocked = true;
|
mBlocked = true;
|
||||||
|
|
||||||
lineWidthSpin->setValue( mObject->lineWidth() );
|
lineWidthSpin->setValue( mObject->lineWidth().pt() );
|
||||||
lineColorButton->setColorNode( mObject->lineColorNode() );
|
lineColorButton->setColorNode( mObject->lineColorNode() );
|
||||||
fillColorButton->setColorNode( mObject->fillColorNode() );
|
fillColorButton->setColorNode( mObject->fillColorNode() );
|
||||||
|
|
||||||
@@ -93,8 +93,8 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
mBlocked = true;
|
mBlocked = true;
|
||||||
|
|
||||||
posXSpin->setValue( mObject->x0() );
|
posXSpin->setValue( mObject->x0().in() );
|
||||||
posYSpin->setValue( mObject->y0() );
|
posYSpin->setValue( mObject->y0().in() );
|
||||||
|
|
||||||
mBlocked = false;
|
mBlocked = false;
|
||||||
}
|
}
|
||||||
@@ -107,8 +107,8 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
mBlocked = true;
|
mBlocked = true;
|
||||||
|
|
||||||
sizeWSpin->setValue( mObject->w() );
|
sizeWSpin->setValue( mObject->w().in() );
|
||||||
sizeHSpin->setValue( mObject->h() );
|
sizeHSpin->setValue( mObject->h().in() );
|
||||||
|
|
||||||
mBlocked = false;
|
mBlocked = false;
|
||||||
}
|
}
|
||||||
@@ -122,8 +122,8 @@ namespace glabels
|
|||||||
mBlocked = true;
|
mBlocked = true;
|
||||||
|
|
||||||
shadowEnableCheck->setChecked( mObject->shadow() );
|
shadowEnableCheck->setChecked( mObject->shadow() );
|
||||||
shadowXSpin->setValue( mObject->shadowX() );
|
shadowXSpin->setValue( mObject->shadowX().in() );
|
||||||
shadowYSpin->setValue( mObject->shadowY() );
|
shadowYSpin->setValue( mObject->shadowY().in() );
|
||||||
shadowColorButton->setColorNode( mObject->shadowColorNode() );
|
shadowColorButton->setColorNode( mObject->shadowColorNode() );
|
||||||
shadowOpacitySpin->setValue( 100*mObject->shadowOpacity() );
|
shadowOpacitySpin->setValue( 100*mObject->shadowOpacity() );
|
||||||
|
|
||||||
@@ -138,12 +138,12 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
mBlocked = true;
|
mBlocked = true;
|
||||||
|
|
||||||
double whMax = std::max( mModel->w(), mModel->h() );
|
libglabels::Distance whMax = std::max( mModel->w(), mModel->h() );
|
||||||
|
|
||||||
posXSpin->setRange( -whMax, 2*whMax );
|
posXSpin->setRange( -whMax.in(), 2*whMax.in() );
|
||||||
posYSpin->setRange( -whMax, 2*whMax );
|
posYSpin->setRange( -whMax.in(), 2*whMax.in() );
|
||||||
sizeWSpin->setRange( 0, 2*whMax );
|
sizeWSpin->setRange( 0, 2*whMax.in() );
|
||||||
sizeHSpin->setRange( 0, 2*whMax );
|
sizeHSpin->setRange( 0, 2*whMax.in() );
|
||||||
|
|
||||||
mBlocked = false;
|
mBlocked = false;
|
||||||
}
|
}
|
||||||
@@ -236,7 +236,7 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
mBlocked = true;
|
mBlocked = true;
|
||||||
|
|
||||||
mObject->setLineWidth( lineWidthSpin->value() );
|
mObject->setLineWidth( libglabels::Distance::pt(lineWidthSpin->value()) );
|
||||||
mObject->setLineColorNode( lineColorButton->colorNode() );
|
mObject->setLineColorNode( lineColorButton->colorNode() );
|
||||||
|
|
||||||
mBlocked = false;
|
mBlocked = false;
|
||||||
@@ -276,25 +276,25 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
mBlocked = true;
|
mBlocked = true;
|
||||||
|
|
||||||
|
libglabels::Distance spinW = libglabels::Distance::in(sizeWSpin->value());
|
||||||
|
libglabels::Distance spinH = libglabels::Distance::in(sizeHSpin->value());
|
||||||
|
|
||||||
if ( sizeAspectCheck->isChecked() )
|
if ( sizeAspectCheck->isChecked() )
|
||||||
{
|
{
|
||||||
double spinW = sizeWSpin->value();
|
|
||||||
double spinH = sizeHSpin->value();
|
|
||||||
|
|
||||||
if ( fabs(spinW - mObject->w()) > fabs(spinH - mObject->h()) )
|
if ( fabs(spinW - mObject->w()) > fabs(spinH - mObject->h()) )
|
||||||
{
|
{
|
||||||
mObject->setWHonorAspect( spinW );
|
mObject->setWHonorAspect( spinW );
|
||||||
sizeHSpin->setValue( mObject->h() );
|
sizeHSpin->setValue( mObject->h().in() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mObject->setHHonorAspect( spinH );
|
mObject->setHHonorAspect( spinH );
|
||||||
sizeWSpin->setValue( mObject->w() );
|
sizeWSpin->setValue( mObject->w().in() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mObject->setSize( sizeWSpin->value(), sizeHSpin->value() );
|
mObject->setSize( spinW, spinH );
|
||||||
}
|
}
|
||||||
|
|
||||||
mBlocked = false;
|
mBlocked = false;
|
||||||
@@ -309,8 +309,8 @@ namespace glabels
|
|||||||
mBlocked = true;
|
mBlocked = true;
|
||||||
|
|
||||||
mObject->setShadow( shadowEnableCheck->isChecked() );
|
mObject->setShadow( shadowEnableCheck->isChecked() );
|
||||||
mObject->setShadowX( shadowXSpin->value() );
|
mObject->setShadowX( libglabels::Distance::in(shadowXSpin->value()) );
|
||||||
mObject->setShadowY( shadowYSpin->value() );
|
mObject->setShadowY( libglabels::Distance::in(shadowYSpin->value()) );
|
||||||
mObject->setShadowColorNode( shadowColorButton->colorNode() );
|
mObject->setShadowColorNode( shadowColorButton->colorNode() );
|
||||||
mObject->setShadowOpacity( shadowOpacitySpin->value()/100.0 );
|
mObject->setShadowOpacity( shadowOpacitySpin->value()/100.0 );
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -1,6 +1,6 @@
|
|||||||
/* Outline.cpp
|
/* Outline.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -78,10 +78,10 @@ void glabels::Outline::draw( QPainter* painter ) const
|
|||||||
painter->setBrush( Qt::NoBrush );
|
painter->setBrush( Qt::NoBrush );
|
||||||
|
|
||||||
painter->setPen( mPen1 );
|
painter->setPen( mPen1 );
|
||||||
painter->drawRect( QRectF( 0, 0, mOwner->w(), mOwner->h() ) );
|
painter->drawRect( QRectF( 0, 0, mOwner->w().pt(), mOwner->h().pt() ) );
|
||||||
|
|
||||||
painter->setPen( mPen2 );
|
painter->setPen( mPen2 );
|
||||||
painter->drawRect( QRectF( 0, 0, mOwner->w(), mOwner->h() ) );
|
painter->drawRect( QRectF( 0, 0, mOwner->w().pt(), mOwner->h().pt() ) );
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
@@ -97,10 +97,10 @@ QPainterPath glabels::Outline::hoverPath( double scale ) const
|
|||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
|
|
||||||
path.addRect( -s*slopPixels, -s*slopPixels,
|
path.addRect( -s*slopPixels, -s*slopPixels,
|
||||||
mOwner->w()+s*2*slopPixels, mOwner->h()+s*2*slopPixels );
|
mOwner->w().pt()+s*2*slopPixels, mOwner->h().pt()+s*2*slopPixels );
|
||||||
path.closeSubpath();
|
path.closeSubpath();
|
||||||
path.addRect( s*slopPixels, s*slopPixels,
|
path.addRect( s*slopPixels, s*slopPixels,
|
||||||
mOwner->w()-s*2*slopPixels, mOwner->h()-s*2*slopPixels );
|
mOwner->w().pt()-s*2*slopPixels, mOwner->h().pt()-s*2*slopPixels );
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
/* Outline.h
|
/* Outline.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* PageRenderer.cpp
|
/* PageRenderer.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2014 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -104,7 +104,7 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
if ( mModel )
|
if ( mModel )
|
||||||
{
|
{
|
||||||
return QRectF( 0, 0, mModel->tmplate()->pageWidth(), mModel->tmplate()->pageHeight() );
|
return QRectF( 0, 0, mModel->tmplate()->pageWidth().pt(), mModel->tmplate()->pageHeight().pt() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -178,7 +178,7 @@ namespace glabels
|
|||||||
for ( int i = iStart; i < iEnd; i++ )
|
for ( int i = iStart; i < iEnd; i++ )
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->translate( mOrigins[i].x(), mOrigins[i].y() );
|
painter->translate( mOrigins[i].x().pt(), mOrigins[i].y().pt() );
|
||||||
|
|
||||||
painter->save();
|
painter->save();
|
||||||
clipLabel( painter );
|
clipLabel( painter );
|
||||||
@@ -238,12 +238,12 @@ namespace glabels
|
|||||||
if ( mModel->rotate() )
|
if ( mModel->rotate() )
|
||||||
{
|
{
|
||||||
painter->rotate( 90.0 );
|
painter->rotate( 90.0 );
|
||||||
painter->translate( 0, mModel->h() );
|
painter->translate( 0, mModel->h().pt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( mPrintReverse )
|
if ( mPrintReverse )
|
||||||
{
|
{
|
||||||
painter->translate( mModel->w(), 0 );
|
painter->translate( mModel->w().pt(), 0 );
|
||||||
painter->scale( -1, 1 );
|
painter->scale( -1, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* PageRenderer.h
|
/* PageRenderer.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
|
|||||||
+12
-10
@@ -1,6 +1,6 @@
|
|||||||
/* Preview.cpp
|
/* Preview.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -79,12 +79,12 @@ namespace glabels
|
|||||||
if ( mModel != NULL )
|
if ( mModel != NULL )
|
||||||
{
|
{
|
||||||
// Set scene up with a 5% margin around paper
|
// Set scene up with a 5% margin around paper
|
||||||
double x = -0.05 * mModel->tmplate()->pageWidth();
|
libglabels::Distance x = -0.05 * mModel->tmplate()->pageWidth();
|
||||||
double y = -0.05 * mModel->tmplate()->pageHeight();
|
libglabels::Distance y = -0.05 * mModel->tmplate()->pageHeight();
|
||||||
double w = 1.10 * mModel->tmplate()->pageWidth();
|
libglabels::Distance w = 1.10 * mModel->tmplate()->pageWidth();
|
||||||
double h = 1.10 * mModel->tmplate()->pageHeight();
|
libglabels::Distance h = 1.10 * mModel->tmplate()->pageHeight();
|
||||||
|
|
||||||
mScene->setSceneRect( x, y, w, h );
|
mScene->setSceneRect( x.pt(), y.pt(), w.pt(), h.pt() );
|
||||||
fitInView( mScene->sceneRect(), Qt::KeepAspectRatio );
|
fitInView( mScene->sceneRect(), Qt::KeepAspectRatio );
|
||||||
|
|
||||||
drawPaper( mModel->tmplate()->pageWidth(), mModel->tmplate()->pageHeight() );
|
drawPaper( mModel->tmplate()->pageWidth(), mModel->tmplate()->pageHeight() );
|
||||||
@@ -128,7 +128,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Draw Paper
|
/// Draw Paper
|
||||||
///
|
///
|
||||||
void Preview::drawPaper( double pw, double ph )
|
void Preview::drawPaper( const libglabels::Distance& pw, const libglabels::Distance& ph )
|
||||||
{
|
{
|
||||||
QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect();
|
QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect();
|
||||||
shadowEffect->setColor( shadowColor );
|
shadowEffect->setColor( shadowColor );
|
||||||
@@ -140,7 +140,7 @@ namespace glabels
|
|||||||
pen.setCosmetic( true );
|
pen.setCosmetic( true );
|
||||||
pen.setWidthF( paperOutlineWidthPixels );
|
pen.setWidthF( paperOutlineWidthPixels );
|
||||||
|
|
||||||
QGraphicsRectItem *pageItem = new QGraphicsRectItem( 0, 0, pw, ph );
|
QGraphicsRectItem *pageItem = new QGraphicsRectItem( 0, 0, pw.pt(), ph.pt() );
|
||||||
pageItem->setBrush( brush );
|
pageItem->setBrush( brush );
|
||||||
pageItem->setPen( pen );
|
pageItem->setPen( pen );
|
||||||
pageItem->setGraphicsEffect( shadowEffect );
|
pageItem->setGraphicsEffect( shadowEffect );
|
||||||
@@ -166,7 +166,9 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Draw a Single Label at x,y
|
/// Draw a Single Label at x,y
|
||||||
///
|
///
|
||||||
void Preview::drawLabel( double x, double y, const QPainterPath &path )
|
void Preview::drawLabel( const libglabels::Distance& x,
|
||||||
|
const libglabels::Distance& y,
|
||||||
|
const QPainterPath& path )
|
||||||
{
|
{
|
||||||
QBrush brush( Qt::NoBrush );
|
QBrush brush( Qt::NoBrush );
|
||||||
QPen pen( labelOutlineColor );
|
QPen pen( labelOutlineColor );
|
||||||
@@ -177,7 +179,7 @@ namespace glabels
|
|||||||
QGraphicsPathItem *labelOutlineItem = new QGraphicsPathItem( path );
|
QGraphicsPathItem *labelOutlineItem = new QGraphicsPathItem( path );
|
||||||
labelOutlineItem->setBrush( brush );
|
labelOutlineItem->setBrush( brush );
|
||||||
labelOutlineItem->setPen( pen );
|
labelOutlineItem->setPen( pen );
|
||||||
labelOutlineItem->setPos( x, y );
|
labelOutlineItem->setPos( x.pt(), y.pt() );
|
||||||
|
|
||||||
mScene->addItem( labelOutlineItem );
|
mScene->addItem( labelOutlineItem );
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-3
@@ -1,6 +1,6 @@
|
|||||||
/* Preview.h
|
/* Preview.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -67,9 +67,12 @@ namespace glabels
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
void clearScene();
|
void clearScene();
|
||||||
void drawPaper( double pw, double ph );
|
void drawPaper( const libglabels::Distance& pw, const libglabels::Distance& ph );
|
||||||
void drawLabels();
|
void drawLabels();
|
||||||
void drawLabel( double x, double y, const QPainterPath &path );
|
void drawLabel( const libglabels::Distance& x,
|
||||||
|
const libglabels::Distance& y,
|
||||||
|
const QPainterPath& path );
|
||||||
|
|
||||||
void drawPreviewOverlay();
|
void drawPreviewOverlay();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* PrintView.cpp
|
/* PrintView.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -138,7 +138,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void PrintView::onPrintButtonClicked()
|
void PrintView::onPrintButtonClicked()
|
||||||
{
|
{
|
||||||
QSizeF pageSize( mModel->tmplate()->pageWidth(), mModel->tmplate()->pageHeight() );
|
QSizeF pageSize( mModel->tmplate()->pageWidth().pt(), mModel->tmplate()->pageHeight().pt() );
|
||||||
mPrinter->setPaperSize( pageSize, QPrinter::Point );
|
mPrinter->setPaperSize( pageSize, QPrinter::Point );
|
||||||
mPrinter->setFullPage( true );
|
mPrinter->setFullPage( true );
|
||||||
mPrinter->setPageMargins( 0, 0, 0, 0, QPrinter::Point );
|
mPrinter->setPageMargins( 0, 0, 0, 0, QPrinter::Point );
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
/* PrintView.h
|
/* PrintView.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
|
|||||||
+28
-26
@@ -1,6 +1,6 @@
|
|||||||
/* SimplePreview.cpp
|
/* SimplePreview.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -110,12 +110,12 @@ namespace glabels
|
|||||||
if ( mTmplate != NULL )
|
if ( mTmplate != NULL )
|
||||||
{
|
{
|
||||||
// Set scene up with a 5% margin around paper
|
// Set scene up with a 5% margin around paper
|
||||||
double x = -0.05 * mTmplate->pageWidth();
|
libglabels::Distance x = -0.05 * mTmplate->pageWidth();
|
||||||
double y = -0.05 * mTmplate->pageHeight();
|
libglabels::Distance y = -0.05 * mTmplate->pageHeight();
|
||||||
double w = 1.10 * mTmplate->pageWidth();
|
libglabels::Distance w = 1.10 * mTmplate->pageWidth();
|
||||||
double h = 1.10 * mTmplate->pageHeight();
|
libglabels::Distance h = 1.10 * mTmplate->pageHeight();
|
||||||
|
|
||||||
mScene->setSceneRect( x, y, w, h );
|
mScene->setSceneRect( x.pt(), y.pt(), w.pt(), h.pt() );
|
||||||
fitInView( mScene->sceneRect(), Qt::KeepAspectRatio );
|
fitInView( mScene->sceneRect(), Qt::KeepAspectRatio );
|
||||||
|
|
||||||
drawPaper( mTmplate->pageWidth(), mTmplate->pageHeight() );
|
drawPaper( mTmplate->pageWidth(), mTmplate->pageHeight() );
|
||||||
@@ -141,7 +141,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Draw Paper
|
/// Draw Paper
|
||||||
///
|
///
|
||||||
void SimplePreview::drawPaper( double pw, double ph )
|
void SimplePreview::drawPaper( const libglabels::Distance& pw, const libglabels::Distance& ph )
|
||||||
{
|
{
|
||||||
QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect();
|
QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect();
|
||||||
shadowEffect->setColor( shadowColor );
|
shadowEffect->setColor( shadowColor );
|
||||||
@@ -153,7 +153,7 @@ namespace glabels
|
|||||||
pen.setCosmetic( true );
|
pen.setCosmetic( true );
|
||||||
pen.setWidthF( paperOutlineWidthPixels );
|
pen.setWidthF( paperOutlineWidthPixels );
|
||||||
|
|
||||||
QGraphicsRectItem *pageItem = new QGraphicsRectItem( 0, 0, pw, ph );
|
QGraphicsRectItem *pageItem = new QGraphicsRectItem( 0, 0, pw.pt(), ph.pt() );
|
||||||
pageItem->setBrush( brush );
|
pageItem->setBrush( brush );
|
||||||
pageItem->setPen( pen );
|
pageItem->setPen( pen );
|
||||||
pageItem->setGraphicsEffect( shadowEffect );
|
pageItem->setGraphicsEffect( shadowEffect );
|
||||||
@@ -179,7 +179,9 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Draw a Single Label at x,y
|
/// Draw a Single Label at x,y
|
||||||
///
|
///
|
||||||
void SimplePreview::drawLabel( double x, double y, const QPainterPath &path )
|
void SimplePreview::drawLabel( const libglabels::Distance& x,
|
||||||
|
const libglabels::Distance& y,
|
||||||
|
const QPainterPath& path )
|
||||||
{
|
{
|
||||||
QBrush brush( labelColor );
|
QBrush brush( labelColor );
|
||||||
QPen pen( labelOutlineColor );
|
QPen pen( labelOutlineColor );
|
||||||
@@ -189,7 +191,7 @@ namespace glabels
|
|||||||
QGraphicsPathItem *labelItem = new QGraphicsPathItem( path );
|
QGraphicsPathItem *labelItem = new QGraphicsPathItem( path );
|
||||||
labelItem->setBrush( brush );
|
labelItem->setBrush( brush );
|
||||||
labelItem->setPen( pen );
|
labelItem->setPen( pen );
|
||||||
labelItem->setPos( x, y );
|
labelItem->setPos( x.pt(), y.pt() );
|
||||||
|
|
||||||
mScene->addItem( labelItem );
|
mScene->addItem( labelItem );
|
||||||
}
|
}
|
||||||
@@ -202,32 +204,32 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
libglabels::Frame *frame = mTmplate->frames().first();
|
libglabels::Frame *frame = mTmplate->frames().first();
|
||||||
|
|
||||||
double w = frame->w();
|
libglabels::Distance w = frame->w();
|
||||||
double h = frame->h();
|
libglabels::Distance h = frame->h();
|
||||||
|
|
||||||
double min = ( w < h ) ? w : h;
|
libglabels::Distance min = libglabels::min( w, h );
|
||||||
|
|
||||||
QPen pen( arrowColor );
|
QPen pen( arrowColor );
|
||||||
pen.setWidthF( 0.25*min*arrowScale );
|
pen.setWidthF( 0.25*min.pt()*arrowScale );
|
||||||
pen.setCapStyle( Qt::FlatCap );
|
pen.setCapStyle( Qt::FlatCap );
|
||||||
pen.setJoinStyle( Qt::MiterJoin );
|
pen.setJoinStyle( Qt::MiterJoin );
|
||||||
|
|
||||||
QBrush brush( upColor );
|
QBrush brush( upColor );
|
||||||
|
|
||||||
libglabels::Point origin = frame->getOrigins().first();
|
libglabels::Point origin = frame->getOrigins().first();
|
||||||
double x0 = origin.x();
|
libglabels::Distance x0 = origin.x();
|
||||||
double y0 = origin.y();
|
libglabels::Distance y0 = origin.y();
|
||||||
|
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
path.moveTo( 0, min*arrowScale/3 );
|
path.moveTo( 0, min.pt()*arrowScale/3 );
|
||||||
path.lineTo( 0, -min*arrowScale );
|
path.lineTo( 0, -min.pt()*arrowScale );
|
||||||
path.moveTo( -min*arrowScale/2, -min*arrowScale/2 );
|
path.moveTo( -min.pt()*arrowScale/2, -min.pt()*arrowScale/2 );
|
||||||
path.lineTo( 0, -min*arrowScale );
|
path.lineTo( 0, -min.pt()*arrowScale );
|
||||||
path.lineTo( min*arrowScale/2, -min*arrowScale/2 );
|
path.lineTo( min.pt()*arrowScale/2, -min.pt()*arrowScale/2 );
|
||||||
|
|
||||||
QGraphicsPathItem *arrowItem = new QGraphicsPathItem( path );
|
QGraphicsPathItem *arrowItem = new QGraphicsPathItem( path );
|
||||||
arrowItem->setPen( pen );
|
arrowItem->setPen( pen );
|
||||||
arrowItem->setPos( x0+w/2, y0+h/2 );
|
arrowItem->setPos( (x0+w/2).pt(), (y0+h/2).pt() );
|
||||||
if ( mRotateFlag )
|
if ( mRotateFlag )
|
||||||
{
|
{
|
||||||
arrowItem->setRotation( 90 );
|
arrowItem->setRotation( 90 );
|
||||||
@@ -235,17 +237,17 @@ namespace glabels
|
|||||||
|
|
||||||
QGraphicsSimpleTextItem *upItem = new QGraphicsSimpleTextItem( tr("Up") );
|
QGraphicsSimpleTextItem *upItem = new QGraphicsSimpleTextItem( tr("Up") );
|
||||||
upItem->setBrush( brush );
|
upItem->setBrush( brush );
|
||||||
upItem->setFont( QFont( upFontFamily, min*upScale, QFont::Bold ) );
|
upItem->setFont( QFont( upFontFamily, min.pt()*upScale, QFont::Bold ) );
|
||||||
upItem->setPos( x0+w/2, y0+h/2 );
|
upItem->setPos( (x0+w/2).pt(), (y0+h/2).pt() );
|
||||||
QRectF rect = upItem->boundingRect();
|
QRectF rect = upItem->boundingRect();
|
||||||
if ( mRotateFlag )
|
if ( mRotateFlag )
|
||||||
{
|
{
|
||||||
upItem->setPos( upItem->x()-min/8, upItem->y()-rect.width()/2 );
|
upItem->setPos( upItem->x()-min.pt()/8, upItem->y()-rect.width()/2 );
|
||||||
upItem->setRotation( 90 );
|
upItem->setRotation( 90 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
upItem->setPos( upItem->x()-rect.width()/2, upItem->y()+min/8 );
|
upItem->setPos( upItem->x()-rect.width()/2, upItem->y()+min.pt()/8 );
|
||||||
}
|
}
|
||||||
|
|
||||||
mScene->addItem( arrowItem );
|
mScene->addItem( arrowItem );
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* SimplePreview.h
|
/* SimplePreview.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -68,9 +68,11 @@ namespace glabels
|
|||||||
private:
|
private:
|
||||||
void update();
|
void update();
|
||||||
void clearScene();
|
void clearScene();
|
||||||
void drawPaper( double pw, double ph );
|
void drawPaper( const libglabels::Distance& pw, const libglabels::Distance& ph );
|
||||||
void drawLabels();
|
void drawLabels();
|
||||||
void drawLabel( double x, double y, const QPainterPath &path );
|
void drawLabel( const libglabels::Distance& x,
|
||||||
|
const libglabels::Distance& y,
|
||||||
|
const QPainterPath& path );
|
||||||
void drawArrow();
|
void drawArrow();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+49
-43
@@ -1,6 +1,6 @@
|
|||||||
/* View.cpp
|
/* View.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -59,7 +59,7 @@ namespace
|
|||||||
|
|
||||||
const QColor gridLineColor( 192, 192, 192 );
|
const QColor gridLineColor( 192, 192, 192 );
|
||||||
const double gridLineWidthPixels = 1;
|
const double gridLineWidthPixels = 1;
|
||||||
const double gridSpacing = 9; // TODO: determine from locale.
|
const libglabels::Distance gridSpacing = libglabels::Distance::pt(9); // TODO: determine from locale.
|
||||||
|
|
||||||
const QColor markupLineColor( 240, 99, 99 );
|
const QColor markupLineColor( 240, 99, 99 );
|
||||||
const double markupLineWidthPixels = 1;
|
const double markupLineWidthPixels = 1;
|
||||||
@@ -235,8 +235,8 @@ glabels::View::zoomToFit()
|
|||||||
double wPixels = mScrollArea->maximumViewportSize().width();
|
double wPixels = mScrollArea->maximumViewportSize().width();
|
||||||
double hPixels = mScrollArea->maximumViewportSize().height();
|
double hPixels = mScrollArea->maximumViewportSize().height();
|
||||||
|
|
||||||
double x_scale = ( wPixels - ZOOM_TO_FIT_PAD ) / mModel->w();
|
double x_scale = ( wPixels - ZOOM_TO_FIT_PAD ) / mModel->w().pt();
|
||||||
double y_scale = ( hPixels - ZOOM_TO_FIT_PAD ) / mModel->h();
|
double y_scale = ( hPixels - ZOOM_TO_FIT_PAD ) / mModel->h().pt();
|
||||||
double newZoom = min( x_scale, y_scale ) * PTS_PER_INCH / physicalDpiX();
|
double newZoom = min( x_scale, y_scale ) * PTS_PER_INCH / physicalDpiX();
|
||||||
|
|
||||||
// Limits
|
// Limits
|
||||||
@@ -279,7 +279,8 @@ glabels::View::setZoomReal( double zoom, bool zoomToFitFlag )
|
|||||||
/* Actual scale depends on DPI of display (assume DpiX == DpiY). */
|
/* Actual scale depends on DPI of display (assume DpiX == DpiY). */
|
||||||
mScale = zoom * physicalDpiX() / PTS_PER_INCH;
|
mScale = zoom * physicalDpiX() / PTS_PER_INCH;
|
||||||
|
|
||||||
setMinimumSize( mScale*mModel->w() + ZOOM_TO_FIT_PAD, mScale*mModel->h() + ZOOM_TO_FIT_PAD );
|
setMinimumSize( mScale*mModel->w().pt() + ZOOM_TO_FIT_PAD,
|
||||||
|
mScale*mModel->h().pt() + ZOOM_TO_FIT_PAD );
|
||||||
|
|
||||||
/* Adjust origin to center label in widget. */
|
/* Adjust origin to center label in widget. */
|
||||||
mX0 = (width()/mScale - mModel->w()) / 2;
|
mX0 = (width()/mScale - mModel->w()) / 2;
|
||||||
@@ -354,11 +355,11 @@ glabels::View::mousePressEvent( QMouseEvent* event )
|
|||||||
QTransform transform;
|
QTransform transform;
|
||||||
|
|
||||||
transform.scale( mScale, mScale );
|
transform.scale( mScale, mScale );
|
||||||
transform.translate( mX0, mY0 );
|
transform.translate( mX0.pt(), mY0.pt() );
|
||||||
|
|
||||||
QPointF pWorld = transform.inverted().map( event->posF() );
|
QPointF pWorld = transform.inverted().map( event->posF() );
|
||||||
double xWorld = pWorld.x();
|
libglabels::Distance xWorld = libglabels::Distance::pt( pWorld.x() );
|
||||||
double yWorld = pWorld.y();
|
libglabels::Distance yWorld = libglabels::Distance::pt( pWorld.y() );
|
||||||
|
|
||||||
|
|
||||||
if ( event->button() & Qt::LeftButton )
|
if ( event->button() & Qt::LeftButton )
|
||||||
@@ -523,11 +524,11 @@ glabels::View::mouseMoveEvent( QMouseEvent* event )
|
|||||||
QTransform transform;
|
QTransform transform;
|
||||||
|
|
||||||
transform.scale( mScale, mScale );
|
transform.scale( mScale, mScale );
|
||||||
transform.translate( mX0, mY0 );
|
transform.translate( mX0.pt(), mY0.pt() );
|
||||||
|
|
||||||
QPointF pWorld = transform.inverted().map( event->posF() );
|
QPointF pWorld = transform.inverted().map( event->posF() );
|
||||||
double xWorld = pWorld.x();
|
libglabels::Distance xWorld = libglabels::Distance::pt( pWorld.x() );
|
||||||
double yWorld = pWorld.y();
|
libglabels::Distance yWorld = libglabels::Distance::pt( pWorld.y() );
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -624,11 +625,11 @@ glabels::View::mouseReleaseEvent( QMouseEvent* event )
|
|||||||
QTransform transform;
|
QTransform transform;
|
||||||
|
|
||||||
transform.scale( mScale, mScale );
|
transform.scale( mScale, mScale );
|
||||||
transform.translate( mX0, mY0 );
|
transform.translate( mX0.pt(), mY0.pt() );
|
||||||
|
|
||||||
QPointF pWorld = transform.inverted().map( event->posF() );
|
QPointF pWorld = transform.inverted().map( event->posF() );
|
||||||
double xWorld = pWorld.x();
|
libglabels::Distance xWorld = libglabels::Distance::pt( pWorld.x() );
|
||||||
double yWorld = pWorld.y();
|
libglabels::Distance yWorld = libglabels::Distance::pt( pWorld.y() );
|
||||||
|
|
||||||
|
|
||||||
if ( event->button() & Qt::LeftButton )
|
if ( event->button() & Qt::LeftButton )
|
||||||
@@ -703,15 +704,16 @@ glabels::View::leaveEvent( QEvent* event )
|
|||||||
/// Handle resize motion
|
/// Handle resize motion
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
glabels::View::handleResizeMotion( double xWorld, double yWorld )
|
glabels::View::handleResizeMotion( const libglabels::Distance& xWorld,
|
||||||
|
const libglabels::Distance& yWorld )
|
||||||
{
|
{
|
||||||
QPointF p( xWorld, yWorld );
|
QPointF p( xWorld.pt(), yWorld.pt() );
|
||||||
Handle::Location location = mResizeHandle->location();
|
Handle::Location location = mResizeHandle->location();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Change point to object relative coordinates
|
* Change point to object relative coordinates
|
||||||
*/
|
*/
|
||||||
p -= QPointF( mResizeObject->x0(), mResizeObject->y0() );
|
p -= QPointF( mResizeObject->x0().pt(), mResizeObject->y0().pt() );
|
||||||
p = mResizeObject->matrix().inverted().map( p );
|
p = mResizeObject->matrix().inverted().map( p );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -723,8 +725,8 @@ glabels::View::handleResizeMotion( double xWorld, double yWorld )
|
|||||||
double x1 = 0.0;
|
double x1 = 0.0;
|
||||||
double y1 = 0.0;
|
double y1 = 0.0;
|
||||||
|
|
||||||
double x2 = mResizeObject->w();
|
double x2 = mResizeObject->w().pt();
|
||||||
double y2 = mResizeObject->h();
|
double y2 = mResizeObject->h().pt();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calculate new size
|
* Calculate new size
|
||||||
@@ -793,20 +795,22 @@ glabels::View::handleResizeMotion( double xWorld, double yWorld )
|
|||||||
{
|
{
|
||||||
case Handle::E:
|
case Handle::E:
|
||||||
case Handle::W:
|
case Handle::W:
|
||||||
mResizeObject->setWHonorAspect( w );
|
mResizeObject->setWHonorAspect( libglabels::Distance::pt(w) );
|
||||||
break;
|
break;
|
||||||
case Handle::N:
|
case Handle::N:
|
||||||
case Handle::S:
|
case Handle::S:
|
||||||
mResizeObject->setHHonorAspect( h );
|
mResizeObject->setHHonorAspect( libglabels::Distance::pt(h) );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mResizeObject->setSizeHonorAspect( w, h );
|
mResizeObject->setSizeHonorAspect( libglabels::Distance::pt(w),
|
||||||
|
libglabels::Distance::pt(h) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mResizeObject->setSize( w, h );
|
mResizeObject->setSize( libglabels::Distance::pt(w),
|
||||||
|
libglabels::Distance::pt(h) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -815,16 +819,16 @@ glabels::View::handleResizeMotion( double xWorld, double yWorld )
|
|||||||
switch ( location )
|
switch ( location )
|
||||||
{
|
{
|
||||||
case Handle::NW:
|
case Handle::NW:
|
||||||
x0 += x2 - mResizeObject->w();
|
x0 += x2 - mResizeObject->w().pt();
|
||||||
y0 += y2 - mResizeObject->h();
|
y0 += y2 - mResizeObject->h().pt();
|
||||||
break;
|
break;
|
||||||
case Handle::N:
|
case Handle::N:
|
||||||
case Handle::NE:
|
case Handle::NE:
|
||||||
y0 += y2 - mResizeObject->h();
|
y0 += y2 - mResizeObject->h().pt();
|
||||||
break;
|
break;
|
||||||
case Handle::W:
|
case Handle::W:
|
||||||
case Handle::SW:
|
case Handle::SW:
|
||||||
x0 += x2 - mResizeObject->w();
|
x0 += x2 - mResizeObject->w().pt();
|
||||||
break;
|
break;
|
||||||
defaule:
|
defaule:
|
||||||
break;
|
break;
|
||||||
@@ -832,7 +836,8 @@ glabels::View::handleResizeMotion( double xWorld, double yWorld )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mResizeObject->setSize( w, h );
|
mResizeObject->setSize( libglabels::Distance::pt(w),
|
||||||
|
libglabels::Distance::pt(h) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -840,8 +845,9 @@ glabels::View::handleResizeMotion( double xWorld, double yWorld )
|
|||||||
*/
|
*/
|
||||||
QPointF p0( x0, y0 );
|
QPointF p0( x0, y0 );
|
||||||
p0 = mResizeObject->matrix().map( p0 );
|
p0 = mResizeObject->matrix().map( p0 );
|
||||||
p0 += QPointF( mResizeObject->x0(), mResizeObject->y0() );
|
p0 += QPointF( mResizeObject->x0().pt(), mResizeObject->y0().pt() );
|
||||||
mResizeObject->setPosition( p0.x(), p0.y() );
|
mResizeObject->setPosition( libglabels::Distance::pt(p0.x()),
|
||||||
|
libglabels::Distance::pt(p0.y()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -866,7 +872,7 @@ glabels::View::paintEvent( QPaintEvent* event )
|
|||||||
|
|
||||||
/* Transform. */
|
/* Transform. */
|
||||||
painter.scale( mScale, mScale );
|
painter.scale( mScale, mScale );
|
||||||
painter.translate( mX0, mY0 );
|
painter.translate( mX0.pt(), mY0.pt() );
|
||||||
|
|
||||||
/* Now draw from the bottom layer up. */
|
/* Now draw from the bottom layer up. */
|
||||||
drawBgLayer( &painter );
|
drawBgLayer( &painter );
|
||||||
@@ -899,7 +905,7 @@ glabels::View::drawBgLayer( QPainter* painter )
|
|||||||
if ( mModel->rotate() )
|
if ( mModel->rotate() )
|
||||||
{
|
{
|
||||||
painter->rotate( -90 );
|
painter->rotate( -90 );
|
||||||
painter->translate( -mModel->frame()->w(), 0 );
|
painter->translate( -mModel->frame()->w().pt(), 0 );
|
||||||
}
|
}
|
||||||
painter->drawPath( mModel->frame()->path() );
|
painter->drawPath( mModel->frame()->path() );
|
||||||
|
|
||||||
@@ -917,7 +923,7 @@ glabels::View::drawBgLayer( QPainter* painter )
|
|||||||
if ( mModel->rotate() )
|
if ( mModel->rotate() )
|
||||||
{
|
{
|
||||||
painter->rotate( -90 );
|
painter->rotate( -90 );
|
||||||
painter->translate( -mModel->frame()->w(), 0 );
|
painter->translate( -mModel->frame()->w().pt(), 0 );
|
||||||
}
|
}
|
||||||
painter->drawPath( mModel->frame()->path() );
|
painter->drawPath( mModel->frame()->path() );
|
||||||
|
|
||||||
@@ -933,10 +939,10 @@ glabels::View::drawGridLayer( QPainter* painter )
|
|||||||
{
|
{
|
||||||
if ( mGridVisible )
|
if ( mGridVisible )
|
||||||
{
|
{
|
||||||
double w = mModel->frame()->w();
|
libglabels::Distance w = mModel->frame()->w();
|
||||||
double h = mModel->frame()->h();
|
libglabels::Distance h = mModel->frame()->h();
|
||||||
|
|
||||||
double x0, y0;
|
libglabels::Distance x0, y0;
|
||||||
if ( dynamic_cast<const libglabels::FrameRect*>( mModel->frame() ) )
|
if ( dynamic_cast<const libglabels::FrameRect*>( mModel->frame() ) )
|
||||||
{
|
{
|
||||||
x0 = gridSpacing;
|
x0 = gridSpacing;
|
||||||
@@ -953,7 +959,7 @@ glabels::View::drawGridLayer( QPainter* painter )
|
|||||||
if ( mModel->rotate() )
|
if ( mModel->rotate() )
|
||||||
{
|
{
|
||||||
painter->rotate( -90 );
|
painter->rotate( -90 );
|
||||||
painter->translate( -mModel->frame()->w(), 0 );
|
painter->translate( -mModel->frame()->w().pt(), 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->setClipPath( mModel->frame()->path() );
|
painter->setClipPath( mModel->frame()->path() );
|
||||||
@@ -962,14 +968,14 @@ glabels::View::drawGridLayer( QPainter* painter )
|
|||||||
pen.setCosmetic( true );
|
pen.setCosmetic( true );
|
||||||
painter->setPen( pen );
|
painter->setPen( pen );
|
||||||
|
|
||||||
for ( double x = x0; x < w; x += gridSpacing )
|
for ( libglabels::Distance x = x0; x < w; x += gridSpacing )
|
||||||
{
|
{
|
||||||
painter->drawLine( x, 0, x, h );
|
painter->drawLine( x.pt(), 0, x.pt(), h.pt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( double y = y0; y < h; y += gridSpacing )
|
for ( libglabels::Distance y = y0; y < h; y += gridSpacing )
|
||||||
{
|
{
|
||||||
painter->drawLine( 0, y, w, y );
|
painter->drawLine( 0, y.pt(), w.pt(), y.pt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
@@ -993,7 +999,7 @@ glabels::View::drawMarkupLayer( QPainter* painter )
|
|||||||
if ( mModel->rotate() )
|
if ( mModel->rotate() )
|
||||||
{
|
{
|
||||||
painter->rotate( -90 );
|
painter->rotate( -90 );
|
||||||
painter->translate( -mModel->frame()->w(), 0 );
|
painter->translate( -mModel->frame()->w().pt(), 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach( libglabels::Markup* markup, mModel->frame()->markups() )
|
foreach( libglabels::Markup* markup, mModel->frame()->markups() )
|
||||||
@@ -1035,7 +1041,7 @@ glabels::View::drawFgLayer( QPainter* painter )
|
|||||||
if ( mModel->rotate() )
|
if ( mModel->rotate() )
|
||||||
{
|
{
|
||||||
painter->rotate( -90 );
|
painter->rotate( -90 );
|
||||||
painter->translate( -mModel->frame()->w(), 0 );
|
painter->translate( -mModel->frame()->w().pt(), 0 );
|
||||||
}
|
}
|
||||||
painter->drawPath( mModel->frame()->path() );
|
painter->drawPath( mModel->frame()->path() );
|
||||||
|
|
||||||
|
|||||||
+26
-25
@@ -1,6 +1,6 @@
|
|||||||
/* View.h
|
/* View.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -56,7 +56,7 @@ namespace glabels
|
|||||||
signals:
|
signals:
|
||||||
void contextMenuActivate();
|
void contextMenuActivate();
|
||||||
void zoomChanged();
|
void zoomChanged();
|
||||||
void pointerMoved( double x, double y );
|
void pointerMoved( const libglabels::Distance& x, const libglabels::Distance& y );
|
||||||
void pointerExited();
|
void pointerExited();
|
||||||
void modeChanged();
|
void modeChanged();
|
||||||
|
|
||||||
@@ -128,7 +128,8 @@ namespace glabels
|
|||||||
// Private methods
|
// Private methods
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
private:
|
private:
|
||||||
void handleResizeMotion( double xWorld, double yWorld );
|
void handleResizeMotion( const libglabels::Distance& xWorld,
|
||||||
|
const libglabels::Distance& yWorld );
|
||||||
|
|
||||||
void drawBgLayer( QPainter* painter );
|
void drawBgLayer( QPainter* painter );
|
||||||
void drawGridLayer( QPainter* painter );
|
void drawGridLayer( QPainter* painter );
|
||||||
@@ -169,41 +170,41 @@ namespace glabels
|
|||||||
Barcode
|
Barcode
|
||||||
};
|
};
|
||||||
|
|
||||||
QScrollArea* mScrollArea;
|
QScrollArea* mScrollArea;
|
||||||
|
|
||||||
double mZoom;
|
double mZoom;
|
||||||
bool mZoomToFitFlag;
|
bool mZoomToFitFlag;
|
||||||
double mScale;
|
double mScale;
|
||||||
double mX0;
|
libglabels::Distance mX0;
|
||||||
double mY0;
|
libglabels::Distance mY0;
|
||||||
|
|
||||||
bool mMarkupVisible;
|
bool mMarkupVisible;
|
||||||
bool mGridVisible;
|
bool mGridVisible;
|
||||||
|
|
||||||
double mGridSpacing;
|
double mGridSpacing;
|
||||||
|
|
||||||
LabelModel* mModel;
|
LabelModel* mModel;
|
||||||
|
|
||||||
State mState;
|
State mState;
|
||||||
|
|
||||||
/* ArrowSelectRegion state */
|
/* ArrowSelectRegion state */
|
||||||
bool mSelectRegionVisible;
|
bool mSelectRegionVisible;
|
||||||
LabelRegion mSelectRegion;
|
LabelRegion mSelectRegion;
|
||||||
|
|
||||||
/* ArrowMove state */
|
/* ArrowMove state */
|
||||||
double mMoveLastX;
|
libglabels::Distance mMoveLastX;
|
||||||
double mMoveLastY;
|
libglabels::Distance mMoveLastY;
|
||||||
|
|
||||||
/* ArrowResize state */
|
/* ArrowResize state */
|
||||||
LabelModelObject* mResizeObject;
|
LabelModelObject* mResizeObject;
|
||||||
Handle* mResizeHandle;
|
Handle* mResizeHandle;
|
||||||
bool mResizeHonorAspect;
|
bool mResizeHonorAspect;
|
||||||
|
|
||||||
/* CreateDrag state */
|
/* CreateDrag state */
|
||||||
CreateType mCreateObjectType;
|
CreateType mCreateObjectType;
|
||||||
LabelModelObject* mCreateObject;
|
LabelModelObject* mCreateObject;
|
||||||
double mCreateX0;
|
libglabels::Distance mCreateX0;
|
||||||
double mCreateY0;
|
libglabels::Distance mCreateY0;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* XmlLabelParser.cpp
|
/* XmlLabelParser.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2014-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -374,7 +374,7 @@ glabels::XmlLabelParser::parseShadowAttrs( const QDomElement &node, LabelModelOb
|
|||||||
|
|
||||||
object->setShadowColorNode( ColorNode( field_flag, color, key ) );
|
object->setShadowColorNode( ColorNode( field_flag, color, key ) );
|
||||||
|
|
||||||
object->setShadowOpacity( XmlUtil::getLengthAttr( node, "shadow_y", 1.0 ) );
|
object->setShadowOpacity( XmlUtil::getDoubleAttr( node, "shadow_opacity", 1.0 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* XmlLabelParser.h
|
/* XmlLabelParser.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2014-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ set (libglabels_sources
|
|||||||
Category.cpp
|
Category.cpp
|
||||||
Paper.cpp
|
Paper.cpp
|
||||||
Vendor.cpp
|
Vendor.cpp
|
||||||
Units.cpp
|
|
||||||
Point.cpp
|
Point.cpp
|
||||||
Layout.cpp
|
Layout.cpp
|
||||||
Markup.cpp
|
Markup.cpp
|
||||||
@@ -27,6 +26,7 @@ set (libglabels_sources
|
|||||||
XmlTemplateCreator.cpp
|
XmlTemplateCreator.cpp
|
||||||
XmlUtil.cpp
|
XmlUtil.cpp
|
||||||
MiniPreviewPixmap.cpp
|
MiniPreviewPixmap.cpp
|
||||||
|
Distance.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set (libglabels_qobject_headers
|
set (libglabels_qobject_headers
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* Units.inl
|
/* Constants.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -18,16 +18,19 @@
|
|||||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef libglabels_Constants_h
|
||||||
|
#define libglabels_Constants_h
|
||||||
|
|
||||||
|
|
||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
inline QString Units::id() const { return mId; }
|
const double PTS_PER_PT = 1.0;
|
||||||
|
const double PTS_PER_INCH = 72.0;
|
||||||
inline QString Units::name() const { return mName; }
|
const double PTS_PER_MM = 2.83464566929;
|
||||||
|
const double PTS_PER_CM = (10.0*PTS_PER_MM);
|
||||||
inline double Units::pointsPerUnit() const { return mPointsPerUnit; }
|
const double PTS_PER_PICA = (1.0/12.0);
|
||||||
|
|
||||||
inline double Units::unitsPerPoint() const { return mUnitsPerPoint; }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // libglabels_Constants_h
|
||||||
+5
-5
@@ -1,6 +1,6 @@
|
|||||||
/* Db.cpp
|
/* Db.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -483,10 +483,10 @@ namespace libglabels
|
|||||||
foreach ( Paper *paper, mPapers )
|
foreach ( Paper *paper, mPapers )
|
||||||
{
|
{
|
||||||
qDebug() << "paper "
|
qDebug() << "paper "
|
||||||
<< "id=" << paper->id() << ", "
|
<< "id=" << paper->id() << ", "
|
||||||
<< "name=" << paper->name() << ", "
|
<< "name=" << paper->name() << ", "
|
||||||
<< "width=" << paper->width() << "pts, "
|
<< "width=" << paper->width().pt() << "pts, "
|
||||||
<< "height=" << paper->height() << "pts, "
|
<< "height=" << paper->height().pt() << "pts, "
|
||||||
<< "pwg_size=" << paper->pwgSize();
|
<< "pwg_size=" << paper->pwgSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,255 @@
|
|||||||
|
/* Distance.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 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 "Distance.h"
|
||||||
|
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
QString Distance::toId( Units units )
|
||||||
|
{
|
||||||
|
QString idString;
|
||||||
|
|
||||||
|
switch (units)
|
||||||
|
{
|
||||||
|
case Units::PT:
|
||||||
|
idString = "pt";
|
||||||
|
break;
|
||||||
|
case Units::IN:
|
||||||
|
idString = "in";
|
||||||
|
break;
|
||||||
|
case Units::MM:
|
||||||
|
idString = "mm";
|
||||||
|
break;
|
||||||
|
case Units::CM:
|
||||||
|
idString = "cm";
|
||||||
|
break;
|
||||||
|
case Units::PC:
|
||||||
|
idString = "pc";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return idString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Distance::toTrName( Units units )
|
||||||
|
{
|
||||||
|
QString nameString;
|
||||||
|
|
||||||
|
switch (units)
|
||||||
|
{
|
||||||
|
case Units::PT:
|
||||||
|
nameString = tr("points");
|
||||||
|
break;
|
||||||
|
case Units::IN:
|
||||||
|
nameString = tr("inches");
|
||||||
|
break;
|
||||||
|
case Units::MM:
|
||||||
|
nameString = tr("mm");
|
||||||
|
break;
|
||||||
|
case Units::CM:
|
||||||
|
nameString = tr("cm");
|
||||||
|
break;
|
||||||
|
case Units::PC:
|
||||||
|
nameString = tr("picas");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nameString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Distance::isIdValid( const QString& unitsId )
|
||||||
|
{
|
||||||
|
bool retValue = false;
|
||||||
|
|
||||||
|
if ( unitsId == "pt" )
|
||||||
|
{
|
||||||
|
retValue = true;
|
||||||
|
}
|
||||||
|
else if ( unitsId == "in" )
|
||||||
|
{
|
||||||
|
retValue = true;
|
||||||
|
}
|
||||||
|
else if ( unitsId == "mm" )
|
||||||
|
{
|
||||||
|
retValue = true;
|
||||||
|
}
|
||||||
|
else if ( unitsId == "cm" )
|
||||||
|
{
|
||||||
|
retValue = true;
|
||||||
|
}
|
||||||
|
else if ( unitsId == "pc" )
|
||||||
|
{
|
||||||
|
retValue = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return retValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance::Units Distance::toUnits( const QString& unitsId )
|
||||||
|
{
|
||||||
|
Units units;
|
||||||
|
|
||||||
|
if ( unitsId == "pt" )
|
||||||
|
{
|
||||||
|
units = Units::PT;
|
||||||
|
}
|
||||||
|
else if ( unitsId == "in" )
|
||||||
|
{
|
||||||
|
units = Units::IN;
|
||||||
|
}
|
||||||
|
else if ( unitsId == "mm" )
|
||||||
|
{
|
||||||
|
units = Units::MM;
|
||||||
|
}
|
||||||
|
else if ( unitsId == "cm" )
|
||||||
|
{
|
||||||
|
units = Units::CM;
|
||||||
|
}
|
||||||
|
else if ( unitsId == "pc" )
|
||||||
|
{
|
||||||
|
units = Units::PC;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
units = Units::PT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return units;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance::Distance( double d, Units units )
|
||||||
|
{
|
||||||
|
switch (units)
|
||||||
|
{
|
||||||
|
case Units::PT:
|
||||||
|
mDPts = d;
|
||||||
|
break;
|
||||||
|
case Units::IN:
|
||||||
|
mDPts = d * PTS_PER_INCH;
|
||||||
|
break;
|
||||||
|
case Units::MM:
|
||||||
|
mDPts = d * PTS_PER_MM;
|
||||||
|
break;
|
||||||
|
case Units::CM:
|
||||||
|
mDPts = d * PTS_PER_CM;
|
||||||
|
break;
|
||||||
|
case Units::PC:
|
||||||
|
mDPts = d * PTS_PER_PICA;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance::Distance( double d, const QString& unitsId )
|
||||||
|
{
|
||||||
|
Units units = toUnits( unitsId );
|
||||||
|
|
||||||
|
switch (units)
|
||||||
|
{
|
||||||
|
case Units::PT:
|
||||||
|
mDPts = d;
|
||||||
|
break;
|
||||||
|
case Units::IN:
|
||||||
|
mDPts = d * PTS_PER_INCH;
|
||||||
|
break;
|
||||||
|
case Units::MM:
|
||||||
|
mDPts = d * PTS_PER_MM;
|
||||||
|
break;
|
||||||
|
case Units::CM:
|
||||||
|
mDPts = d * PTS_PER_CM;
|
||||||
|
break;
|
||||||
|
case Units::PC:
|
||||||
|
mDPts = d * PTS_PER_PICA;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance Distance::fromString( const QString& string )
|
||||||
|
{
|
||||||
|
QString stringCopy = string;
|
||||||
|
QTextStream valueStream( &stringCopy, QIODevice::ReadOnly );
|
||||||
|
|
||||||
|
double value;
|
||||||
|
QString unitsString;
|
||||||
|
valueStream >> value >> unitsString;
|
||||||
|
|
||||||
|
if ( !unitsString.isEmpty() && !isIdValid( unitsString ) )
|
||||||
|
{
|
||||||
|
qWarning() << "Error: invalid Distance::Units \"" << string << "\"";
|
||||||
|
}
|
||||||
|
|
||||||
|
return Distance( value, unitsString );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double Distance::inUnits( Units units ) const
|
||||||
|
{
|
||||||
|
double d;
|
||||||
|
|
||||||
|
switch (units)
|
||||||
|
{
|
||||||
|
case Units::PT:
|
||||||
|
d = pt();
|
||||||
|
break;
|
||||||
|
case Units::IN:
|
||||||
|
d = in();
|
||||||
|
break;
|
||||||
|
case Units::MM:
|
||||||
|
d = mm();
|
||||||
|
break;
|
||||||
|
case Units::CM:
|
||||||
|
d = cm();
|
||||||
|
break;
|
||||||
|
case Units::PC:
|
||||||
|
d = pc();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double Distance::inUnits( const QString& unitsId ) const
|
||||||
|
{
|
||||||
|
return inUnits( toUnits( unitsId ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Distance::toString( Units units ) const
|
||||||
|
{
|
||||||
|
return QString::number( inUnits(units) ) + toId(units);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Distance::toString( const QString& unitsId ) const
|
||||||
|
{
|
||||||
|
return QString::number( inUnits(unitsId) ) + unitsId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
/* Distance.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 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_Distance_h
|
||||||
|
#define libglabels_Distance_h
|
||||||
|
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QString>
|
||||||
|
#include "Constants.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
class Distance
|
||||||
|
{
|
||||||
|
Q_DECLARE_TR_FUNCTIONS(Distance)
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum class Units { PT, IN, MM, CM, PC };
|
||||||
|
|
||||||
|
static QString toId( Units units );
|
||||||
|
static QString toTrName( Units units );
|
||||||
|
static bool isIdValid( const QString& unitsId );
|
||||||
|
static Units toUnits( const QString& unitsId );
|
||||||
|
|
||||||
|
|
||||||
|
Distance();
|
||||||
|
Distance( double d, Units units = Units::PT );
|
||||||
|
Distance( double d, const QString& unitsId );
|
||||||
|
|
||||||
|
static Distance pt( double dPts );
|
||||||
|
static Distance in( double dInches );
|
||||||
|
static Distance mm( double dMm );
|
||||||
|
static Distance cm( double dCm );
|
||||||
|
static Distance pc( double dPicas );
|
||||||
|
static Distance fromString( const QString& string );
|
||||||
|
|
||||||
|
|
||||||
|
double pt() const;
|
||||||
|
double in() const;
|
||||||
|
double mm() const;
|
||||||
|
double cm() const;
|
||||||
|
double pc() const;
|
||||||
|
double inUnits( Units units ) const;
|
||||||
|
double inUnits( const QString& unitsId ) const;
|
||||||
|
|
||||||
|
|
||||||
|
QString toString( Units units ) const;
|
||||||
|
QString toString( const QString& unitsId ) const;
|
||||||
|
|
||||||
|
|
||||||
|
Distance& operator+=( const Distance& d );
|
||||||
|
Distance& operator-=( const Distance& d );
|
||||||
|
Distance operator-();
|
||||||
|
|
||||||
|
friend inline Distance operator+( const Distance& d1, const Distance& d2 );
|
||||||
|
friend inline Distance operator-( const Distance& d1, const Distance& d2 );
|
||||||
|
friend inline Distance operator*( double x, const Distance& d );
|
||||||
|
friend inline Distance operator*( const Distance& d, double x );
|
||||||
|
friend inline double operator/( const Distance& d1, const Distance& d2 );
|
||||||
|
friend inline Distance operator/( const Distance& d, double x );
|
||||||
|
|
||||||
|
friend inline bool operator<( const Distance& d1, const Distance& d2 );
|
||||||
|
friend inline bool operator<=( const Distance& d1, const Distance& d2 );
|
||||||
|
friend inline bool operator>( const Distance& d1, const Distance& d2 );
|
||||||
|
friend inline bool operator>=( const Distance& d1, const Distance& d2 );
|
||||||
|
friend inline bool operator==( const Distance& d1, const Distance& d2 );
|
||||||
|
friend inline bool operator!=( const Distance& d1, const Distance& d2 );
|
||||||
|
|
||||||
|
friend inline Distance fabs( const Distance& d );
|
||||||
|
friend inline Distance min( const Distance& d1, const Distance& d2 );
|
||||||
|
friend inline Distance max( const Distance& d1, const Distance& d2 );
|
||||||
|
friend inline Distance fmod( const Distance& d1, const Distance& d2 );
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
double mDPts;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "Distance.inl"
|
||||||
|
|
||||||
|
|
||||||
|
#endif // libglabels_Distance_h
|
||||||
@@ -0,0 +1,218 @@
|
|||||||
|
/* Distance.inl
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 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 <cmath>
|
||||||
|
|
||||||
|
|
||||||
|
namespace libglabels
|
||||||
|
{
|
||||||
|
|
||||||
|
inline Distance::Distance() : mDPts(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Distance Distance::pt( double dPts )
|
||||||
|
{
|
||||||
|
Distance d;
|
||||||
|
d.mDPts = dPts;
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Distance Distance::in( double dInches )
|
||||||
|
{
|
||||||
|
Distance d;
|
||||||
|
d.mDPts = dInches * PTS_PER_INCH;
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Distance Distance::mm( double dMm )
|
||||||
|
{
|
||||||
|
Distance d;
|
||||||
|
d.mDPts = dMm * PTS_PER_MM;
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Distance Distance::cm( double dCm )
|
||||||
|
{
|
||||||
|
Distance d;
|
||||||
|
d.mDPts = dCm * PTS_PER_CM;
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Distance Distance::pc( double dPicas )
|
||||||
|
{
|
||||||
|
Distance d;
|
||||||
|
d.mDPts = dPicas * PTS_PER_PICA;
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline double Distance::pt() const
|
||||||
|
{
|
||||||
|
return mDPts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline double Distance::in() const
|
||||||
|
{
|
||||||
|
return mDPts / PTS_PER_INCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline double Distance::mm() const
|
||||||
|
{
|
||||||
|
return mDPts / PTS_PER_MM;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline double Distance::cm() const
|
||||||
|
{
|
||||||
|
return mDPts / PTS_PER_CM;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline double Distance::pc() const
|
||||||
|
{
|
||||||
|
return mDPts / PTS_PER_PICA;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Distance& Distance::operator+=( const Distance& d )
|
||||||
|
{
|
||||||
|
mDPts += d.mDPts;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Distance& Distance::operator-=( const Distance& d )
|
||||||
|
{
|
||||||
|
mDPts -= d.mDPts;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Distance Distance::operator-()
|
||||||
|
{
|
||||||
|
return Distance::pt( -mDPts );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Distance operator+( const Distance& d1, const Distance& d2 )
|
||||||
|
{
|
||||||
|
return Distance::pt( d1.mDPts + d2.mDPts );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Distance operator-( const Distance& d1, const Distance& d2 )
|
||||||
|
{
|
||||||
|
return Distance::pt( d1.mDPts - d2.mDPts );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Distance operator*( double x, const Distance& d )
|
||||||
|
{
|
||||||
|
return Distance::pt( x * d.mDPts );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Distance operator*( const Distance& d, double x )
|
||||||
|
{
|
||||||
|
return Distance::pt( d.mDPts * x );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline double operator/( const Distance& d1, const Distance& d2 )
|
||||||
|
{
|
||||||
|
return d1.mDPts / d2.mDPts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Distance operator/( const Distance& d, double x )
|
||||||
|
{
|
||||||
|
return Distance::pt( d.mDPts / x );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool operator<( const Distance& d1, const Distance& d2 )
|
||||||
|
{
|
||||||
|
return d1.mDPts < d2.mDPts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool operator<=( const Distance& d1, const Distance& d2 )
|
||||||
|
{
|
||||||
|
return d1.mDPts <= d2.mDPts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool operator>( const Distance& d1, const Distance& d2 )
|
||||||
|
{
|
||||||
|
return d1.mDPts > d2.mDPts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool operator>=( const Distance& d1, const Distance& d2 )
|
||||||
|
{
|
||||||
|
return d1.mDPts >= d2.mDPts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool operator==( const Distance& d1, const Distance& d2 )
|
||||||
|
{
|
||||||
|
return d1.mDPts == d2.mDPts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool operator!=( const Distance& d1, const Distance& d2 )
|
||||||
|
{
|
||||||
|
return d1.mDPts != d2.mDPts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Distance fabs( const Distance& d )
|
||||||
|
{
|
||||||
|
return Distance::pt( std::fabs( d.mDPts ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Distance min( const Distance& d1, const Distance& d2 )
|
||||||
|
{
|
||||||
|
return (d1.mDPts < d2.mDPts) ? d1 : d2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Distance max( const Distance& d1, const Distance& d2 )
|
||||||
|
{
|
||||||
|
return (d1.mDPts > d2.mDPts) ? d1 : d2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Distance fmod( const Distance& d1, const Distance& d2 )
|
||||||
|
{
|
||||||
|
return Distance::pt( std::fmod( d1.mDPts, d2.mDPts ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+5
-5
@@ -27,7 +27,7 @@
|
|||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
#include "Units.h"
|
#include "Distance.h"
|
||||||
#include "Point.h"
|
#include "Point.h"
|
||||||
#include "Layout.h"
|
#include "Layout.h"
|
||||||
|
|
||||||
@@ -59,14 +59,14 @@ namespace libglabels
|
|||||||
void addLayout( Layout* layout );
|
void addLayout( Layout* layout );
|
||||||
void addMarkup( Markup* markup );
|
void addMarkup( Markup* markup );
|
||||||
|
|
||||||
virtual double w() const = 0;
|
virtual Distance w() const = 0;
|
||||||
virtual double h() const = 0;
|
virtual Distance h() const = 0;
|
||||||
|
|
||||||
virtual const QString sizeDescription( const Units& units ) const = 0;
|
virtual const QString sizeDescription( Distance::Units units ) const = 0;
|
||||||
virtual bool isSimilarTo( Frame* other ) const = 0;
|
virtual bool isSimilarTo( Frame* other ) const = 0;
|
||||||
|
|
||||||
virtual const QPainterPath& path() const = 0;
|
virtual const QPainterPath& path() const = 0;
|
||||||
virtual QPainterPath marginPath( double size ) const = 0;
|
virtual QPainterPath marginPath( const Distance& size ) const = 0;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
+28
-23
@@ -1,6 +1,6 @@
|
|||||||
/* FrameCd.cpp
|
/* FrameCd.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -30,20 +30,25 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
FrameCd::FrameCd( double r1, double r2, double w, double h, double waste, QString id )
|
FrameCd::FrameCd( const Distance& r1,
|
||||||
|
const Distance& r2,
|
||||||
|
const Distance& w,
|
||||||
|
const Distance& h,
|
||||||
|
const Distance& waste,
|
||||||
|
const QString& id )
|
||||||
: mR1(r1), mR2(r2), mW(w), mH(h), mWaste(waste), Frame(id)
|
: mR1(r1), mR2(r2), mW(w), mH(h), mWaste(waste), Frame(id)
|
||||||
{
|
{
|
||||||
double wReal = (mW == 0) ? 2*mR1 : mW;
|
Distance wReal = (mW == 0) ? 2*mR1 : mW;
|
||||||
double hReal = (mH == 0) ? 2*mR1 : mH;
|
Distance hReal = (mH == 0) ? 2*mR1 : mH;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Construct outer subpath (may be clipped if it's a business card CD)
|
* Construct outer subpath (may be clipped if it's a business card CD)
|
||||||
*/
|
*/
|
||||||
QPainterPath outerPath;
|
QPainterPath outerPath;
|
||||||
outerPath.addEllipse( wReal/2 - r1, hReal/2 - r1, 2*r1, 2*r1 );
|
outerPath.addEllipse( (wReal/2 - r1).pt(), (hReal/2 - r1).pt(), 2*r1.pt(), 2*r1.pt() );
|
||||||
|
|
||||||
QPainterPath clipPath;
|
QPainterPath clipPath;
|
||||||
clipPath.addRect( 0, 0, wReal, hReal );
|
clipPath.addRect( 0, 0, wReal.pt(), hReal.pt() );
|
||||||
|
|
||||||
mPath.addPath( outerPath & clipPath );
|
mPath.addPath( outerPath & clipPath );
|
||||||
mPath.closeSubpath();
|
mPath.closeSubpath();
|
||||||
@@ -51,7 +56,7 @@ namespace libglabels
|
|||||||
/*
|
/*
|
||||||
* Add inner subpath
|
* Add inner subpath
|
||||||
*/
|
*/
|
||||||
mPath.addEllipse( wReal/2 - r2, hReal/2 - r2, 2*r2, 2*r2 );
|
mPath.addEllipse( (wReal/2 - r2).pt(), (hReal/2 - r2).pt(), 2*r2.pt(), 2*r2.pt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -68,34 +73,34 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double FrameCd::w() const
|
Distance FrameCd::w() const
|
||||||
{
|
{
|
||||||
return (mW == 0) ? 2*mR1 : mW;
|
return (mW == 0) ? 2*mR1 : mW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double FrameCd::h() const
|
Distance FrameCd::h() const
|
||||||
{
|
{
|
||||||
return (mH == 0) ? 2*mR1 : mH;
|
return (mH == 0) ? 2*mR1 : mH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const QString FrameCd::sizeDescription( const Units& units ) const
|
const QString FrameCd::sizeDescription( Distance::Units units ) const
|
||||||
{
|
{
|
||||||
if ( units.id() == "in" )
|
if ( units == Distance::Units::IN )
|
||||||
{
|
{
|
||||||
QString dStr = StrUtil::formatFraction( 2 * mR1 * units.unitsPerPoint() );
|
QString dStr = StrUtil::formatFraction( 2 * mR1.in() );
|
||||||
|
|
||||||
return QString().sprintf( "%s %s %s",
|
return QString().sprintf( "%s %s %s",
|
||||||
qPrintable(dStr),
|
qPrintable(dStr),
|
||||||
qPrintable(units.name()),
|
qPrintable(Distance::toTrName(units)),
|
||||||
qPrintable(tr("diameter")) );
|
qPrintable(tr("diameter")) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return QString().sprintf( "%.5g %s %s",
|
return QString().sprintf( "%.5g %s %s",
|
||||||
2 * mR1 * units.unitsPerPoint(),
|
2 * mR1.inUnits(units),
|
||||||
qPrintable(units.name()),
|
qPrintable(Distance::toTrName(units)),
|
||||||
qPrintable(tr("diameter")) );
|
qPrintable(tr("diameter")) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,13 +128,13 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QPainterPath FrameCd::marginPath( double size ) const
|
QPainterPath FrameCd::marginPath( const Distance& size ) const
|
||||||
{
|
{
|
||||||
double wReal = (mW == 0) ? 2*mR1 : mW;
|
Distance wReal = (mW == 0) ? 2*mR1 : mW;
|
||||||
double hReal = (mH == 0) ? 2*mR1 : mH;
|
Distance hReal = (mH == 0) ? 2*mR1 : mH;
|
||||||
|
|
||||||
double r1 = mR1 - size;
|
Distance r1 = mR1 - size;
|
||||||
double r2 = mR2 + size;
|
Distance r2 = mR2 + size;
|
||||||
|
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
|
|
||||||
@@ -137,10 +142,10 @@ namespace libglabels
|
|||||||
* Construct outer subpath (may be clipped if it's a business card CD)
|
* Construct outer subpath (may be clipped if it's a business card CD)
|
||||||
*/
|
*/
|
||||||
QPainterPath outerPath;
|
QPainterPath outerPath;
|
||||||
outerPath.addEllipse( wReal/2 - r1, hReal/2 - r1, 2*r1, 2*r1 );
|
outerPath.addEllipse( (wReal/2 - r1).pt(), (hReal/2 - r1).pt(), 2*r1.pt(), 2*r1.pt() );
|
||||||
|
|
||||||
QPainterPath clipPath;
|
QPainterPath clipPath;
|
||||||
clipPath.addRect( size, size, wReal-2*size, hReal-2*size );
|
clipPath.addRect( size.pt(), size.pt(), (wReal-2*size).pt(), (hReal-2*size).pt() );
|
||||||
|
|
||||||
path.addPath( outerPath & clipPath );
|
path.addPath( outerPath & clipPath );
|
||||||
path.closeSubpath();
|
path.closeSubpath();
|
||||||
@@ -148,7 +153,7 @@ namespace libglabels
|
|||||||
/*
|
/*
|
||||||
* Add inner subpath
|
* Add inner subpath
|
||||||
*/
|
*/
|
||||||
path.addEllipse( wReal/2 - r2, hReal/2 - r2, 2*r2, 2*r2 );
|
path.addEllipse( (wReal/2 - r2).pt(), (hReal/2 - r2).pt(), 2*r2.pt(), 2*r2.pt() );
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-14
@@ -1,6 +1,6 @@
|
|||||||
/* FrameCd.h
|
/* FrameCd.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -30,32 +30,37 @@ namespace libglabels
|
|||||||
class FrameCd : public Frame
|
class FrameCd : public Frame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FrameCd( double r1, double r2, double w, double h, double waste, QString id = "0" );
|
FrameCd( const Distance& r1,
|
||||||
|
const Distance& r2,
|
||||||
|
const Distance& w,
|
||||||
|
const Distance& h,
|
||||||
|
const Distance& waste,
|
||||||
|
const QString& id = "0" );
|
||||||
|
|
||||||
FrameCd( const FrameCd &other );
|
FrameCd( const FrameCd &other );
|
||||||
|
|
||||||
Frame *dup() const;
|
Frame *dup() const;
|
||||||
|
|
||||||
double r1() const;
|
Distance r1() const;
|
||||||
double r2() const;
|
Distance r2() const;
|
||||||
double waste() const;
|
Distance waste() const;
|
||||||
|
|
||||||
double w() const;
|
Distance w() const;
|
||||||
double h() const;
|
Distance h() const;
|
||||||
|
|
||||||
const QString sizeDescription( const Units& units ) const;
|
const QString sizeDescription( Distance::Units units ) const;
|
||||||
bool isSimilarTo( Frame* other ) const;
|
bool isSimilarTo( Frame* other ) const;
|
||||||
|
|
||||||
const QPainterPath& path() const;
|
const QPainterPath& path() const;
|
||||||
QPainterPath marginPath( double size ) const;
|
QPainterPath marginPath( const Distance& size ) const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double mR1;
|
Distance mR1;
|
||||||
double mR2;
|
Distance mR2;
|
||||||
double mW;
|
Distance mW;
|
||||||
double mH;
|
Distance mH;
|
||||||
double mWaste;
|
Distance mWaste;
|
||||||
|
|
||||||
QPainterPath mPath;
|
QPainterPath mPath;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* FrameCd.inl
|
/* FrameCd.inl
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -22,19 +22,19 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
inline double FrameCd::r1() const
|
inline Distance FrameCd::r1() const
|
||||||
{
|
{
|
||||||
return mR1;
|
return mR1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double FrameCd::r2() const
|
inline Distance FrameCd::r2() const
|
||||||
{
|
{
|
||||||
return mR2;
|
return mR2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double FrameCd::waste() const
|
inline Distance FrameCd::waste() const
|
||||||
{
|
{
|
||||||
return mWaste;
|
return mWaste;
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-17
@@ -1,6 +1,6 @@
|
|||||||
/* FrameEllipse.cpp
|
/* FrameEllipse.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -29,10 +29,13 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
FrameEllipse::FrameEllipse( double w, double h, double waste, QString id )
|
FrameEllipse::FrameEllipse( const Distance& w,
|
||||||
|
const Distance& h,
|
||||||
|
const Distance& waste,
|
||||||
|
const QString& id )
|
||||||
: mW(w), mH(h), mWaste(waste), Frame(id)
|
: mW(w), mH(h), mWaste(waste), Frame(id)
|
||||||
{
|
{
|
||||||
mPath.addEllipse( 0, 0, mW, mH );
|
mPath.addEllipse( 0, 0, mW.pt(), mH.pt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameEllipse::FrameEllipse( const FrameEllipse& other )
|
FrameEllipse::FrameEllipse( const FrameEllipse& other )
|
||||||
@@ -47,36 +50,36 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double FrameEllipse::w() const
|
Distance FrameEllipse::w() const
|
||||||
{
|
{
|
||||||
return mW;
|
return mW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double FrameEllipse::h() const
|
Distance FrameEllipse::h() const
|
||||||
{
|
{
|
||||||
return mH;
|
return mH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const QString FrameEllipse::sizeDescription( const Units& units ) const
|
const QString FrameEllipse::sizeDescription( Distance::Units units ) const
|
||||||
{
|
{
|
||||||
if ( units.id() == "in" )
|
if ( units == Distance::Units::IN )
|
||||||
{
|
{
|
||||||
QString wStr = StrUtil::formatFraction( mW * units.unitsPerPoint() );
|
QString wStr = StrUtil::formatFraction( mW.in() );
|
||||||
QString hStr = StrUtil::formatFraction( mH * units.unitsPerPoint() );
|
QString hStr = StrUtil::formatFraction( mH.in() );
|
||||||
|
|
||||||
return QString().sprintf( "%s x %s %s",
|
return QString().sprintf( "%s x %s %s",
|
||||||
qPrintable(wStr),
|
qPrintable(wStr),
|
||||||
qPrintable(hStr),
|
qPrintable(hStr),
|
||||||
qPrintable(units.name()) );
|
qPrintable(Distance::toTrName(units)) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return QString().sprintf( "%.5g x %.5g %s",
|
return QString().sprintf( "%.5g x %.5g %s",
|
||||||
mW * units.unitsPerPoint(),
|
mW.inUnits(units),
|
||||||
mH * units.unitsPerPoint(),
|
mH.inUnits(units),
|
||||||
qPrintable(units.name()) );
|
qPrintable(Distance::toTrName(units)) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,13 +104,13 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QPainterPath FrameEllipse::marginPath( double size ) const
|
QPainterPath FrameEllipse::marginPath( const Distance& size ) const
|
||||||
{
|
{
|
||||||
double w = mW - 2*size;
|
Distance w = mW - 2*size;
|
||||||
double h = mH - 2*size;
|
Distance h = mH - 2*size;
|
||||||
|
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
path.addEllipse( size, size, w, h );
|
path.addEllipse( size.pt(), size.pt(), w.pt(), h.pt() );
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-10
@@ -1,6 +1,6 @@
|
|||||||
/* FrameEllipse.h
|
/* FrameEllipse.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -31,28 +31,31 @@ namespace libglabels
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FrameEllipse( double w, double h, double waste, QString id = "0" );
|
FrameEllipse( const Distance& w,
|
||||||
|
const Distance& h,
|
||||||
|
const Distance& waste,
|
||||||
|
const QString& id = "0" );
|
||||||
|
|
||||||
FrameEllipse( const FrameEllipse& other );
|
FrameEllipse( const FrameEllipse& other );
|
||||||
|
|
||||||
Frame* dup() const;
|
Frame* dup() const;
|
||||||
|
|
||||||
double waste() const;
|
Distance waste() const;
|
||||||
|
|
||||||
double w() const;
|
Distance w() const;
|
||||||
double h() const;
|
Distance h() const;
|
||||||
|
|
||||||
const QString sizeDescription( const Units& units ) const;
|
const QString sizeDescription( Distance::Units units ) const;
|
||||||
bool isSimilarTo( Frame* other ) const;
|
bool isSimilarTo( Frame* other ) const;
|
||||||
|
|
||||||
const QPainterPath& path() const;
|
const QPainterPath& path() const;
|
||||||
QPainterPath marginPath( double size ) const;
|
QPainterPath marginPath( const Distance& size ) const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double mW;
|
Distance mW;
|
||||||
double mH;
|
Distance mH;
|
||||||
double mWaste;
|
Distance mWaste;
|
||||||
|
|
||||||
QPainterPath mPath;
|
QPainterPath mPath;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* FrameEllipse.inl
|
/* FrameEllipse.inl
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
inline double FrameEllipse::waste() const
|
inline Distance FrameEllipse::waste() const
|
||||||
{
|
{
|
||||||
return mWaste;
|
return mWaste;
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-18
@@ -1,6 +1,6 @@
|
|||||||
/* FrameRect.cpp
|
/* FrameRect.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -29,10 +29,15 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
FrameRect::FrameRect( double w, double h, double r, double xWaste, double yWaste, QString id )
|
FrameRect::FrameRect( const Distance& w,
|
||||||
|
const Distance& h,
|
||||||
|
const Distance& r,
|
||||||
|
const Distance& xWaste,
|
||||||
|
const Distance& yWaste,
|
||||||
|
const QString& id )
|
||||||
: mW(w), mH(h), mR(r), mXWaste(xWaste), mYWaste(yWaste), Frame(id)
|
: mW(w), mH(h), mR(r), mXWaste(xWaste), mYWaste(yWaste), Frame(id)
|
||||||
{
|
{
|
||||||
mPath.addRoundedRect( 0, 0, mW, mH, mR, mR );
|
mPath.addRoundedRect( 0, 0, mW.pt(), mH.pt(), mR.pt(), mR.pt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -49,36 +54,36 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double FrameRect::w() const
|
Distance FrameRect::w() const
|
||||||
{
|
{
|
||||||
return mW;
|
return mW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double FrameRect::h() const
|
Distance FrameRect::h() const
|
||||||
{
|
{
|
||||||
return mH;
|
return mH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const QString FrameRect::sizeDescription( const Units& units ) const
|
const QString FrameRect::sizeDescription( Distance::Units units ) const
|
||||||
{
|
{
|
||||||
if ( units.id() == "in" )
|
if ( units == Distance::Units::IN )
|
||||||
{
|
{
|
||||||
QString wStr = StrUtil::formatFraction( mW * units.unitsPerPoint() );
|
QString wStr = StrUtil::formatFraction( mW.in() );
|
||||||
QString hStr = StrUtil::formatFraction( mH * units.unitsPerPoint() );
|
QString hStr = StrUtil::formatFraction( mH.in() );
|
||||||
|
|
||||||
return QString().sprintf( "%s x %s %s",
|
return QString().sprintf( "%s x %s %s",
|
||||||
qPrintable(wStr),
|
qPrintable(wStr),
|
||||||
qPrintable(hStr),
|
qPrintable(hStr),
|
||||||
qPrintable(units.name()) );
|
qPrintable(Distance::toTrName(units)) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return QString().sprintf( "%.5g x %.5g %s",
|
return QString().sprintf( "%.5g x %.5g %s",
|
||||||
mW * units.unitsPerPoint(),
|
mW.inUnits(units),
|
||||||
mH * units.unitsPerPoint(),
|
mH.inUnits(units),
|
||||||
qPrintable(units.name()) );
|
qPrintable(Distance::toTrName(units)) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,14 +108,14 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QPainterPath FrameRect::marginPath( double size ) const
|
QPainterPath FrameRect::marginPath( const Distance& size ) const
|
||||||
{
|
{
|
||||||
double w = mW - 2*size;
|
Distance w = mW - 2*size;
|
||||||
double h = mH - 2*size;
|
Distance h = mH - 2*size;
|
||||||
double r = std::max( mR - size, 0.0 );
|
Distance r = std::max( mR - size, Distance(0.0) );
|
||||||
|
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
path.addRoundedRect( size, size, w, h, r, r );
|
path.addRoundedRect( size.pt(), size.pt(), w.pt(), h.pt(), r.pt(), r.pt() );
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-18
@@ -30,38 +30,38 @@ namespace libglabels
|
|||||||
class FrameRect : public Frame
|
class FrameRect : public Frame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FrameRect( double w,
|
FrameRect( const Distance& w,
|
||||||
double h,
|
const Distance& h,
|
||||||
double r,
|
const Distance& r,
|
||||||
double xWaste,
|
const Distance& xWaste,
|
||||||
double yWaste,
|
const Distance& yWaste,
|
||||||
QString id = "0" );
|
const QString& id = "0" );
|
||||||
|
|
||||||
FrameRect( const FrameRect& other );
|
FrameRect( const FrameRect& other );
|
||||||
|
|
||||||
Frame* dup() const;
|
Frame* dup() const;
|
||||||
|
|
||||||
double r() const;
|
Distance r() const;
|
||||||
double xWaste() const;
|
Distance xWaste() const;
|
||||||
double yWaste() const;
|
Distance yWaste() const;
|
||||||
|
|
||||||
double w() const;
|
Distance w() const;
|
||||||
double h() const;
|
Distance h() const;
|
||||||
|
|
||||||
const QString sizeDescription( const Units& units ) const;
|
const QString sizeDescription( Distance::Units units ) const;
|
||||||
|
|
||||||
bool isSimilarTo( Frame* other ) const;
|
bool isSimilarTo( Frame* other ) const;
|
||||||
|
|
||||||
const QPainterPath& path() const;
|
const QPainterPath& path() const;
|
||||||
QPainterPath marginPath( double size ) const;
|
QPainterPath marginPath( const Distance& size ) const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double mW;
|
Distance mW;
|
||||||
double mH;
|
Distance mH;
|
||||||
double mR;
|
Distance mR;
|
||||||
double mXWaste;
|
Distance mXWaste;
|
||||||
double mYWaste;
|
Distance mYWaste;
|
||||||
|
|
||||||
QPainterPath mPath;
|
QPainterPath mPath;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* FrameRect.inl
|
/* FrameRect.inl
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -22,19 +22,19 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
inline double FrameRect::r() const
|
inline Distance FrameRect::r() const
|
||||||
{
|
{
|
||||||
return mR;
|
return mR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double FrameRect::xWaste() const
|
inline Distance FrameRect::xWaste() const
|
||||||
{
|
{
|
||||||
return mXWaste;
|
return mXWaste;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double FrameRect::yWaste() const
|
inline Distance FrameRect::yWaste() const
|
||||||
{
|
{
|
||||||
return mYWaste;
|
return mYWaste;
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-14
@@ -1,6 +1,6 @@
|
|||||||
/* FrameRound.cpp
|
/* FrameRound.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -29,10 +29,12 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
FrameRound::FrameRound( double r, double waste, QString id )
|
FrameRound::FrameRound( const Distance& r,
|
||||||
|
const Distance& waste,
|
||||||
|
const QString& id )
|
||||||
: mR(r), mWaste(waste), Frame(id)
|
: mR(r), mWaste(waste), Frame(id)
|
||||||
{
|
{
|
||||||
mPath.addEllipse( 0, 0, 2*mR, 2*mR );
|
mPath.addEllipse( 0, 0, 2*mR.pt(), 2*mR.pt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -48,34 +50,34 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double FrameRound::w() const
|
Distance FrameRound::w() const
|
||||||
{
|
{
|
||||||
return 2*mR;
|
return 2*mR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double FrameRound::h() const
|
Distance FrameRound::h() const
|
||||||
{
|
{
|
||||||
return 2*mR;
|
return 2*mR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const QString FrameRound::sizeDescription( const Units& units ) const
|
const QString FrameRound::sizeDescription( Distance::Units units ) const
|
||||||
{
|
{
|
||||||
if ( units.id() == "in" )
|
if ( units == Distance::Units::IN )
|
||||||
{
|
{
|
||||||
QString dStr = StrUtil::formatFraction( 2 * mR * units.unitsPerPoint() );
|
QString dStr = StrUtil::formatFraction( 2 * mR.in() );
|
||||||
|
|
||||||
return QString().sprintf( "%s %s %s",
|
return QString().sprintf( "%s %s %s",
|
||||||
qPrintable(dStr),
|
qPrintable(dStr),
|
||||||
qPrintable(units.name()),
|
qPrintable(Distance::toTrName(units)),
|
||||||
qPrintable(tr("diameter")) );
|
qPrintable(tr("diameter")) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return QString().sprintf( "%.5g %s %s",
|
return QString().sprintf( "%.5g %s %s",
|
||||||
2 * mR * units.unitsPerPoint(),
|
2 * mR.inUnits(units),
|
||||||
qPrintable(units.name()),
|
qPrintable(Distance::toTrName(units)),
|
||||||
qPrintable(tr("diameter")) );
|
qPrintable(tr("diameter")) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,12 +102,12 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QPainterPath FrameRound::marginPath( double size ) const
|
QPainterPath FrameRound::marginPath( const Distance& size ) const
|
||||||
{
|
{
|
||||||
double r = mR - size;
|
Distance r = mR - size;
|
||||||
|
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
path.addEllipse( size, size, 2*r, 2*r );
|
path.addEllipse( size.pt(), size.pt(), 2*r.pt(), 2*r.pt() );
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-10
@@ -1,6 +1,6 @@
|
|||||||
/* FrameRound.h
|
/* FrameRound.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -31,28 +31,30 @@ namespace libglabels
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FrameRound( double r, double waste, QString id = "0" );
|
FrameRound( const Distance& r,
|
||||||
|
const Distance& waste,
|
||||||
|
const QString& id = "0" );
|
||||||
|
|
||||||
FrameRound( const FrameRound &other );
|
FrameRound( const FrameRound &other );
|
||||||
|
|
||||||
Frame *dup() const;
|
Frame *dup() const;
|
||||||
|
|
||||||
double r() const;
|
Distance r() const;
|
||||||
double waste() const;
|
Distance waste() const;
|
||||||
|
|
||||||
double w() const;
|
Distance w() const;
|
||||||
double h() const;
|
Distance h() const;
|
||||||
|
|
||||||
const QString sizeDescription( const Units& units ) const;
|
const QString sizeDescription( Distance::Units units ) const;
|
||||||
bool isSimilarTo( Frame* other ) const;
|
bool isSimilarTo( Frame* other ) const;
|
||||||
|
|
||||||
const QPainterPath& path() const;
|
const QPainterPath& path() const;
|
||||||
QPainterPath marginPath( double size ) const;
|
QPainterPath marginPath( const Distance& size ) const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double mR;
|
Distance mR;
|
||||||
double mWaste;
|
Distance mWaste;
|
||||||
|
|
||||||
QPainterPath mPath;
|
QPainterPath mPath;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* FrameRound.inl
|
/* FrameRound.inl
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -22,13 +22,13 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
inline double FrameRound::r() const
|
inline Distance FrameRound::r() const
|
||||||
{
|
{
|
||||||
return mR;
|
return mR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double FrameRound::waste() const
|
inline Distance FrameRound::waste() const
|
||||||
{
|
{
|
||||||
return mWaste;
|
return mWaste;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* Layout.cpp
|
/* Layout.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -28,7 +28,12 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
Layout::Layout( int nx, int ny, double x0, double y0, double dx, double dy )
|
Layout::Layout( int nx,
|
||||||
|
int ny,
|
||||||
|
const Distance& x0,
|
||||||
|
const Distance& y0,
|
||||||
|
const Distance& dx,
|
||||||
|
const Distance& dy )
|
||||||
: mNx(nx), mNy(ny), mX0(x0), mY0(y0), mDx(dx), mDy(dy)
|
: mNx(nx), mNy(ny), mX0(x0), mY0(y0), mDx(dx), mDy(dy)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-12
@@ -1,6 +1,6 @@
|
|||||||
/* Layout.h
|
/* Layout.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -21,6 +21,8 @@
|
|||||||
#ifndef libglabels_Layout_h
|
#ifndef libglabels_Layout_h
|
||||||
#define libglabels_Layout_h
|
#define libglabels_Layout_h
|
||||||
|
|
||||||
|
#include "Distance.h"
|
||||||
|
|
||||||
|
|
||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
@@ -29,18 +31,23 @@ namespace libglabels
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Layout( int nx, int ny, double x0, double y0, double dx, double dy );
|
Layout( int nx,
|
||||||
|
int ny,
|
||||||
|
const Distance& x0,
|
||||||
|
const Distance& y0,
|
||||||
|
const Distance& dx,
|
||||||
|
const Distance& dy );
|
||||||
|
|
||||||
Layout( const Layout &other );
|
Layout( const Layout &other );
|
||||||
|
|
||||||
int nx() const;
|
int nx() const;
|
||||||
int ny() const;
|
int ny() const;
|
||||||
|
|
||||||
double x0() const;
|
Distance x0() const;
|
||||||
double y0() const;
|
Distance y0() const;
|
||||||
|
|
||||||
double dx() const;
|
Distance dx() const;
|
||||||
double dy() const;
|
Distance dy() const;
|
||||||
|
|
||||||
bool isSimilarTo( const Layout *other );
|
bool isSimilarTo( const Layout *other );
|
||||||
|
|
||||||
@@ -48,12 +55,12 @@ namespace libglabels
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int mNx;
|
int mNx;
|
||||||
int mNy;
|
int mNy;
|
||||||
double mX0;
|
Distance mX0;
|
||||||
double mY0;
|
Distance mY0;
|
||||||
double mDx;
|
Distance mDx;
|
||||||
double mDy;
|
Distance mDy;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* Layout.inl
|
/* Layout.inl
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -34,25 +34,25 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double Layout::x0() const
|
inline Distance Layout::x0() const
|
||||||
{
|
{
|
||||||
return mX0;
|
return mX0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double Layout::y0() const
|
inline Distance Layout::y0() const
|
||||||
{
|
{
|
||||||
return mY0;
|
return mY0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double Layout::dx() const
|
inline Distance Layout::dx() const
|
||||||
{
|
{
|
||||||
return mDx;
|
return mDx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double Layout::dy() const
|
inline Distance Layout::dy() const
|
||||||
{
|
{
|
||||||
return mDy;
|
return mDy;
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-11
@@ -1,6 +1,6 @@
|
|||||||
/* Markup.cpp
|
/* Markup.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -30,7 +30,8 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MarkupMargin::MarkupMargin( const Frame* frame, double size )
|
MarkupMargin::MarkupMargin( const Frame* frame,
|
||||||
|
const Distance& size )
|
||||||
: mFrame(frame), mSize(size)
|
: mFrame(frame), mSize(size)
|
||||||
{
|
{
|
||||||
mPath = frame->marginPath( size );
|
mPath = frame->marginPath( size );
|
||||||
@@ -43,11 +44,14 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MarkupLine::MarkupLine( double x1, double y1, double x2, double y2 )
|
MarkupLine::MarkupLine( const Distance& x1,
|
||||||
|
const Distance& y1,
|
||||||
|
const Distance& x2,
|
||||||
|
const Distance& y2 )
|
||||||
: mX1(x1), mY1(y1), mX2(x2), mY2(y2)
|
: mX1(x1), mY1(y1), mX2(x2), mY2(y2)
|
||||||
{
|
{
|
||||||
mPath.moveTo( x1, y1 );
|
mPath.moveTo( x1.pt(), y1.pt() );
|
||||||
mPath.lineTo( x2, y2 );
|
mPath.lineTo( x2.pt(), y2.pt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -57,10 +61,14 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MarkupRect::MarkupRect( double x1, double y1, double w, double h, double r )
|
MarkupRect::MarkupRect( const Distance& x1,
|
||||||
|
const Distance& y1,
|
||||||
|
const Distance& w,
|
||||||
|
const Distance& h,
|
||||||
|
const Distance& r )
|
||||||
: mX1(x1), mY1(y1), mW(w), mH(h), mR(r)
|
: mX1(x1), mY1(y1), mW(w), mH(h), mR(r)
|
||||||
{
|
{
|
||||||
mPath.addRoundedRect( x1, y1, w, h, r, r );
|
mPath.addRoundedRect( x1.pt(), y1.pt(), w.pt(), h.pt(), r.pt(), r.pt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -70,10 +78,13 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MarkupEllipse::MarkupEllipse( double x1, double y1, double w, double h )
|
MarkupEllipse::MarkupEllipse( const Distance& x1,
|
||||||
|
const Distance& y1,
|
||||||
|
const Distance& w,
|
||||||
|
const Distance& h )
|
||||||
: mX1(x1), mY1(y1), mW(w), mH(h)
|
: mX1(x1), mY1(y1), mW(w), mH(h)
|
||||||
{
|
{
|
||||||
mPath.addEllipse( x1, y1, w, h );
|
mPath.addEllipse( x1.pt(), y1.pt(), w.pt(), h.pt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -83,10 +94,12 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MarkupCircle::MarkupCircle( double x0, double y0, double r )
|
MarkupCircle::MarkupCircle( const Distance& x0,
|
||||||
|
const Distance& y0,
|
||||||
|
const Distance& r )
|
||||||
: mX0(x0), mY0(y0), mR(r)
|
: mX0(x0), mY0(y0), mR(r)
|
||||||
{
|
{
|
||||||
mPath.addEllipse( x0-r, y0-r, 2*r, 2*r );
|
mPath.addEllipse( (x0-r).pt(), (y0-r).pt(), 2*r.pt(), 2*r.pt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
Markup* MarkupCircle::dup() const
|
Markup* MarkupCircle::dup() const
|
||||||
|
|||||||
+53
-40
@@ -1,6 +1,6 @@
|
|||||||
/* Markup.h
|
/* Markup.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -44,95 +44,108 @@ namespace libglabels
|
|||||||
class MarkupMargin : public Markup
|
class MarkupMargin : public Markup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MarkupMargin( const Frame* frame, double size );
|
MarkupMargin( const Frame* frame,
|
||||||
|
const Distance& size );
|
||||||
|
|
||||||
double size() const;
|
Distance size() const;
|
||||||
|
|
||||||
Markup* dup() const;
|
Markup* dup() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Frame* mFrame;
|
const Frame* mFrame;
|
||||||
double mSize;
|
Distance mSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class MarkupLine : public Markup
|
class MarkupLine : public Markup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MarkupLine( double x1, double y1, double x2, double y2 );
|
MarkupLine( const Distance& x1,
|
||||||
|
const Distance& y1,
|
||||||
|
const Distance& x2,
|
||||||
|
const Distance& y2 );
|
||||||
|
|
||||||
double x1() const;
|
Distance x1() const;
|
||||||
double y1() const;
|
Distance y1() const;
|
||||||
double x2() const;
|
Distance x2() const;
|
||||||
double y2() const;
|
Distance y2() const;
|
||||||
|
|
||||||
Markup* dup() const;
|
Markup* dup() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double mX1;
|
Distance mX1;
|
||||||
double mY1;
|
Distance mY1;
|
||||||
double mX2;
|
Distance mX2;
|
||||||
double mY2;
|
Distance mY2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class MarkupRect : public Markup
|
class MarkupRect : public Markup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MarkupRect( double x1, double y1, double w, double h, double r );
|
MarkupRect( const Distance& x1,
|
||||||
|
const Distance& y1,
|
||||||
|
const Distance& w,
|
||||||
|
const Distance& h,
|
||||||
|
const Distance& r );
|
||||||
|
|
||||||
double x1() const;
|
Distance x1() const;
|
||||||
double y1() const;
|
Distance y1() const;
|
||||||
double w() const;
|
Distance w() const;
|
||||||
double h() const;
|
Distance h() const;
|
||||||
double r() const;
|
Distance r() const;
|
||||||
|
|
||||||
Markup* dup() const;
|
Markup* dup() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double mX1;
|
Distance mX1;
|
||||||
double mY1;
|
Distance mY1;
|
||||||
double mW;
|
Distance mW;
|
||||||
double mH;
|
Distance mH;
|
||||||
double mR;
|
Distance mR;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class MarkupEllipse : public Markup
|
class MarkupEllipse : public Markup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MarkupEllipse( double x1, double y1, double w, double h );
|
MarkupEllipse( const Distance& x1,
|
||||||
|
const Distance& y1,
|
||||||
|
const Distance& w,
|
||||||
|
const Distance& h );
|
||||||
|
|
||||||
double x1() const;
|
Distance x1() const;
|
||||||
double y1() const;
|
Distance y1() const;
|
||||||
double w() const;
|
Distance w() const;
|
||||||
double h() const;
|
Distance h() const;
|
||||||
|
|
||||||
Markup* dup() const;
|
Markup* dup() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double mX1;
|
Distance mX1;
|
||||||
double mY1;
|
Distance mY1;
|
||||||
double mW;
|
Distance mW;
|
||||||
double mH;
|
Distance mH;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class MarkupCircle : public Markup
|
class MarkupCircle : public Markup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MarkupCircle( double x0, double y0, double r );
|
MarkupCircle( const Distance& x0,
|
||||||
|
const Distance& y0,
|
||||||
|
const Distance& r );
|
||||||
|
|
||||||
double x0() const;
|
Distance x0() const;
|
||||||
double y0() const;
|
Distance y0() const;
|
||||||
double r() const;
|
Distance r() const;
|
||||||
|
|
||||||
Markup* dup() const;
|
Markup* dup() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double mX0;
|
Distance mX0;
|
||||||
double mY0;
|
Distance mY0;
|
||||||
double mR;
|
Distance mR;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+18
-18
@@ -1,6 +1,6 @@
|
|||||||
/* Markup.inl
|
/* Markup.inl
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -22,26 +22,26 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
inline double MarkupMargin::size() const { return mSize; }
|
inline Distance MarkupMargin::size() const { return mSize; }
|
||||||
|
|
||||||
inline double MarkupLine::x1() const { return mX1; }
|
inline Distance MarkupLine::x1() const { return mX1; }
|
||||||
inline double MarkupLine::y1() const { return mY1; }
|
inline Distance MarkupLine::y1() const { return mY1; }
|
||||||
inline double MarkupLine::x2() const { return mX2; }
|
inline Distance MarkupLine::x2() const { return mX2; }
|
||||||
inline double MarkupLine::y2() const { return mY2; }
|
inline Distance MarkupLine::y2() const { return mY2; }
|
||||||
|
|
||||||
inline double MarkupRect::x1() const { return mX1; }
|
inline Distance MarkupRect::x1() const { return mX1; }
|
||||||
inline double MarkupRect::y1() const { return mY1; }
|
inline Distance MarkupRect::y1() const { return mY1; }
|
||||||
inline double MarkupRect::w() const { return mW; }
|
inline Distance MarkupRect::w() const { return mW; }
|
||||||
inline double MarkupRect::h() const { return mH; }
|
inline Distance MarkupRect::h() const { return mH; }
|
||||||
inline double MarkupRect::r() const { return mR; }
|
inline Distance MarkupRect::r() const { return mR; }
|
||||||
|
|
||||||
inline double MarkupEllipse::x1() const { return mX1; }
|
inline Distance MarkupEllipse::x1() const { return mX1; }
|
||||||
inline double MarkupEllipse::y1() const { return mY1; }
|
inline Distance MarkupEllipse::y1() const { return mY1; }
|
||||||
inline double MarkupEllipse::w() const { return mW; }
|
inline Distance MarkupEllipse::w() const { return mW; }
|
||||||
inline double MarkupEllipse::h() const { return mH; }
|
inline Distance MarkupEllipse::h() const { return mH; }
|
||||||
|
|
||||||
inline double MarkupCircle::x0() const { return mX0; }
|
inline Distance MarkupCircle::x0() const { return mX0; }
|
||||||
inline double MarkupCircle::y0() const { return mY0; }
|
inline Distance MarkupCircle::y0() const { return mY0; }
|
||||||
inline double MarkupCircle::r() const { return mR; }
|
inline Distance MarkupCircle::r() const { return mR; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* MiniPreviewPixmap.cpp
|
/* MiniPreviewPixmap.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -43,14 +43,14 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MiniPreviewPixmap::MiniPreviewPixmap( const Template *tmplate, int width, int height )
|
MiniPreviewPixmap::MiniPreviewPixmap( const Template* tmplate, int width, int height )
|
||||||
: QPixmap( width, height )
|
: QPixmap( width, height )
|
||||||
{
|
{
|
||||||
draw( tmplate, 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 );
|
||||||
|
|
||||||
@@ -62,26 +62,26 @@ namespace libglabels
|
|||||||
double w = width - 1;
|
double w = width - 1;
|
||||||
double h = height - 1;
|
double h = height - 1;
|
||||||
double scale;
|
double scale;
|
||||||
if ( (w/tmplate->pageWidth()) > (h/tmplate->pageHeight()) )
|
if ( (w/tmplate->pageWidth().pt()) > (h/tmplate->pageHeight().pt()) )
|
||||||
{
|
{
|
||||||
scale = h / tmplate->pageHeight();
|
scale = h / tmplate->pageHeight().pt();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
scale = w / tmplate->pageWidth();
|
scale = w / tmplate->pageWidth().pt();
|
||||||
}
|
}
|
||||||
painter.scale( scale, scale );
|
painter.scale( scale, scale );
|
||||||
|
|
||||||
double xOffset = ( width/scale - tmplate->pageWidth() ) / 2;
|
Distance xOffset = ( Distance::pt(width/scale) - tmplate->pageWidth() ) / 2;
|
||||||
double yOffset = ( height/scale - tmplate->pageHeight() ) / 2;
|
Distance yOffset = ( Distance::pt(height/scale) - tmplate->pageHeight() ) / 2;
|
||||||
painter.translate( xOffset, yOffset );
|
painter.translate( xOffset.pt(), yOffset.pt() );
|
||||||
|
|
||||||
drawPaper( painter, tmplate, scale );
|
drawPaper( painter, tmplate, scale );
|
||||||
drawLabelOutlines( painter, tmplate, scale );
|
drawLabelOutlines( painter, tmplate, scale );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MiniPreviewPixmap::drawPaper( QPainter &painter, const Template *tmplate, double scale )
|
void MiniPreviewPixmap::drawPaper( QPainter& painter, const Template* tmplate, double scale )
|
||||||
{
|
{
|
||||||
QBrush brush( paperColor );
|
QBrush brush( paperColor );
|
||||||
QPen pen( paperOutlineColor );
|
QPen pen( paperOutlineColor );
|
||||||
@@ -91,13 +91,13 @@ namespace libglabels
|
|||||||
|
|
||||||
painter.setBrush( brush );
|
painter.setBrush( brush );
|
||||||
painter.setPen( pen );
|
painter.setPen( pen );
|
||||||
painter.drawRect( 0, 0, tmplate->pageWidth(), tmplate->pageHeight() );
|
painter.drawRect( 0, 0, tmplate->pageWidth().pt(), tmplate->pageHeight().pt() );
|
||||||
|
|
||||||
painter.restore();
|
painter.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MiniPreviewPixmap::drawLabelOutlines( QPainter &painter, const Template *tmplate, double scale )
|
void MiniPreviewPixmap::drawLabelOutlines( QPainter& painter, const Template* tmplate, double scale )
|
||||||
{
|
{
|
||||||
QBrush brush( labelColor );
|
QBrush brush( labelColor );
|
||||||
QPen pen( labelOutlineColor );
|
QPen pen( labelOutlineColor );
|
||||||
@@ -111,20 +111,20 @@ namespace libglabels
|
|||||||
Frame *frame = tmplate->frames().first();
|
Frame *frame = tmplate->frames().first();
|
||||||
QVector<Point> origins = frame->getOrigins();
|
QVector<Point> origins = frame->getOrigins();
|
||||||
|
|
||||||
foreach ( Point point, origins )
|
foreach ( Point p0, origins )
|
||||||
{
|
{
|
||||||
drawLabelOutline( painter, frame, point.x(), point.y() );
|
drawLabelOutline( painter, frame, p0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
painter.restore();
|
painter.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MiniPreviewPixmap::drawLabelOutline( QPainter &painter, const Frame *frame, double x0, double y0 )
|
void MiniPreviewPixmap::drawLabelOutline( QPainter& painter, const Frame* frame, const Point& p0 )
|
||||||
{
|
{
|
||||||
painter.save();
|
painter.save();
|
||||||
|
|
||||||
painter.translate( x0, y0 );
|
painter.translate( p0.x().pt(), p0.y().pt() );
|
||||||
painter.drawPath( frame->path() );
|
painter.drawPath( frame->path() );
|
||||||
|
|
||||||
painter.restore();
|
painter.restore();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* MiniPreviewPixmap.h
|
/* MiniPreviewPixmap.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include "Point.h"
|
||||||
|
|
||||||
|
|
||||||
namespace libglabels
|
namespace libglabels
|
||||||
@@ -38,14 +39,14 @@ namespace libglabels
|
|||||||
public:
|
public:
|
||||||
MiniPreviewPixmap();
|
MiniPreviewPixmap();
|
||||||
|
|
||||||
MiniPreviewPixmap( const Template *tmplate, int width, int 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, const Point& point0 );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* Paper.cpp
|
/* Paper.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -24,7 +24,11 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
Paper::Paper( const QString& id, const QString& name, double width, double height, const QString& pwgSize )
|
Paper::Paper( const QString& id,
|
||||||
|
const QString& name,
|
||||||
|
const Distance& width,
|
||||||
|
const Distance& height,
|
||||||
|
const QString& pwgSize )
|
||||||
: mId(id), mName(name), mWidth(width), mHeight(height), mPwgSize(pwgSize)
|
: mId(id), mName(name), mWidth(width), mHeight(height), mPwgSize(pwgSize)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-11
@@ -1,6 +1,6 @@
|
|||||||
/* Paper.h
|
/* Paper.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include "Distance.h"
|
||||||
|
|
||||||
|
|
||||||
namespace libglabels
|
namespace libglabels
|
||||||
@@ -31,16 +32,20 @@ namespace libglabels
|
|||||||
class Paper
|
class Paper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Paper( const QString& id, const QString& name, double width, double height, const QString& pwgSize );
|
Paper( const QString& id,
|
||||||
|
const QString& name,
|
||||||
|
const Distance& width,
|
||||||
|
const Distance& height,
|
||||||
|
const QString& pwgSize );
|
||||||
|
|
||||||
inline const QString& id() const;
|
inline const QString& id() const;
|
||||||
inline const QString& name() const;
|
inline const QString& name() const;
|
||||||
|
|
||||||
/* Width (in points) */
|
/* Width */
|
||||||
inline double width() const;
|
inline Distance width() const;
|
||||||
|
|
||||||
/* Height (in points) */
|
/* Height */
|
||||||
inline double height() const;
|
inline Distance height() const;
|
||||||
|
|
||||||
/* PWG 5101.1-2002 size name */
|
/* PWG 5101.1-2002 size name */
|
||||||
inline QString pwgSize() const;
|
inline QString pwgSize() const;
|
||||||
@@ -49,11 +54,11 @@ namespace libglabels
|
|||||||
inline bool isSizeUs() const;
|
inline bool isSizeUs() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString mId;
|
QString mId;
|
||||||
QString mName;
|
QString mName;
|
||||||
double mWidth;
|
Distance mWidth;
|
||||||
double mHeight;
|
Distance mHeight;
|
||||||
QString mPwgSize;
|
QString mPwgSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ namespace libglabels
|
|||||||
inline const QString& Paper::id() const { return mId; }
|
inline const QString& Paper::id() const { return mId; }
|
||||||
inline const QString& Paper::name() const { return mName; }
|
inline const QString& Paper::name() const { return mName; }
|
||||||
|
|
||||||
inline double Paper::width() const { return mWidth; }
|
inline Distance Paper::width() const { return mWidth; }
|
||||||
inline double Paper::height() const { return mHeight; }
|
inline Distance Paper::height() const { return mHeight; }
|
||||||
|
|
||||||
inline QString Paper::pwgSize() const { return mPwgSize; }
|
inline QString Paper::pwgSize() const { return mPwgSize; }
|
||||||
|
|
||||||
|
|||||||
@@ -24,12 +24,12 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
Point::Point() : mX(0), mY(0)
|
Point::Point() : mX(Distance(0)), mY(Distance(0))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Point::Point( double x, double y ) : mX(x), mY(y)
|
Point::Point( Distance x, Distance y ) : mX(x), mY(y)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-6
@@ -1,6 +1,6 @@
|
|||||||
/* Point.h
|
/* Point.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -21,6 +21,8 @@
|
|||||||
#ifndef libglabels_Point_h
|
#ifndef libglabels_Point_h
|
||||||
#define libglabels_Point_h
|
#define libglabels_Point_h
|
||||||
|
|
||||||
|
#include "Distance.h"
|
||||||
|
|
||||||
|
|
||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
@@ -30,17 +32,17 @@ namespace libglabels
|
|||||||
public:
|
public:
|
||||||
Point();
|
Point();
|
||||||
|
|
||||||
Point( double x, double y );
|
Point( Distance x, Distance y );
|
||||||
|
|
||||||
double x() const;
|
Distance x() const;
|
||||||
double y() const;
|
Distance y() const;
|
||||||
|
|
||||||
bool operator<( const Point &other ) const;
|
bool operator<( const Point &other ) const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double mX;
|
Distance mX;
|
||||||
double mY;
|
Distance mY;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-3
@@ -1,6 +1,6 @@
|
|||||||
/* Point.inl
|
/* Point.inl
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -22,7 +22,15 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
inline double Point::x() const { return mX; }
|
inline Distance Point::x() const
|
||||||
inline double Point::y() const { return mY; }
|
{
|
||||||
|
return mX;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Distance Point::y() const
|
||||||
|
{
|
||||||
|
return mY;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* Template.cpp
|
/* Template.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -28,12 +28,12 @@
|
|||||||
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,
|
const Distance& pageWidth,
|
||||||
double pageHeight = 0 )
|
const Distance& pageHeight )
|
||||||
: mBrand(brand),
|
: mBrand(brand),
|
||||||
mPart(part),
|
mPart(part),
|
||||||
mDescription(description),
|
mDescription(description),
|
||||||
|
|||||||
+15
-15
@@ -1,6 +1,6 @@
|
|||||||
/* Template.h
|
/* Template.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Units.h"
|
#include "Distance.h"
|
||||||
#include "Point.h"
|
#include "Point.h"
|
||||||
#include "Frame.h"
|
#include "Frame.h"
|
||||||
#include "MiniPreviewPixmap.h"
|
#include "MiniPreviewPixmap.h"
|
||||||
@@ -46,12 +46,12 @@ 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,
|
const Distance& pageWidth,
|
||||||
double pageHeight );
|
const Distance& pageHeight );
|
||||||
|
|
||||||
Template( const Template& other );
|
Template( const Template& other );
|
||||||
|
|
||||||
@@ -71,8 +71,8 @@ namespace libglabels
|
|||||||
const QString& description() const;
|
const QString& description() const;
|
||||||
|
|
||||||
const QString& paperId() const;
|
const QString& paperId() const;
|
||||||
double pageWidth() const;
|
Distance pageWidth() const;
|
||||||
double pageHeight() const;
|
Distance pageHeight() const;
|
||||||
bool isSizeIso() const;
|
bool isSizeIso() const;
|
||||||
bool isSizeUs() const;
|
bool isSizeUs() const;
|
||||||
bool isSizeOther() const;
|
bool isSizeOther() const;
|
||||||
@@ -104,11 +104,11 @@ namespace libglabels
|
|||||||
QString mPart;
|
QString mPart;
|
||||||
QString mDescription;
|
QString mDescription;
|
||||||
|
|
||||||
QString mPaperId;
|
QString mPaperId;
|
||||||
double mPageWidth;
|
Distance mPageWidth;
|
||||||
double mPageHeight;
|
Distance mPageHeight;
|
||||||
bool mIsSizeIso;
|
bool mIsSizeIso;
|
||||||
bool mIsSizeUs;
|
bool mIsSizeUs;
|
||||||
|
|
||||||
QString mEquivPart;
|
QString mEquivPart;
|
||||||
QString mName;
|
QString mName;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* Template.inl
|
/* Template.inl
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -27,8 +27,8 @@ namespace libglabels
|
|||||||
inline const QString& Template::description() const { return mDescription; }
|
inline const QString& Template::description() const { return mDescription; }
|
||||||
|
|
||||||
inline const QString& Template::paperId() const { return mPaperId; }
|
inline const QString& Template::paperId() const { return mPaperId; }
|
||||||
inline double Template::pageWidth() const { return mPageWidth; }
|
inline Distance Template::pageWidth() const { return mPageWidth; }
|
||||||
inline double Template::pageHeight() const { return mPageHeight; }
|
inline Distance Template::pageHeight() const { return mPageHeight; }
|
||||||
inline bool Template::isSizeIso() const { return mIsSizeIso; }
|
inline bool Template::isSizeIso() const { return mIsSizeIso; }
|
||||||
inline bool Template::isSizeUs() const { return mIsSizeUs; }
|
inline bool Template::isSizeUs() const { return mIsSizeUs; }
|
||||||
inline bool Template::isSizeOther() const { return !mIsSizeIso && !mIsSizeUs; }
|
inline bool Template::isSizeOther() const { return !mIsSizeIso && !mIsSizeUs; }
|
||||||
|
|||||||
@@ -1,123 +0,0 @@
|
|||||||
/* 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( const QString &id, const QString &name, double pointsPerUnit )
|
|
||||||
: mId(id), mName(name), mPointsPerUnit(pointsPerUnit)
|
|
||||||
{
|
|
||||||
mUnitsPerPoint = 1.0 / mPointsPerUnit;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Units::Units()
|
|
||||||
: mId("pt"), mName(tr("points")), mPointsPerUnit(POINTS_PER_POINT)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Units Units::fromId( 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()
|
|
||||||
{
|
|
||||||
return Units( "pt", tr("points"), POINTS_PER_POINT );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Units Units::inch()
|
|
||||||
{
|
|
||||||
return Units( "in", tr("inches"), POINTS_PER_INCH );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Units Units::mm()
|
|
||||||
{
|
|
||||||
return Units( "mm", tr("mm"), POINTS_PER_MM );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Units Units::cm()
|
|
||||||
{
|
|
||||||
return Units( "cm", tr("cm"), POINTS_PER_CM );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Units Units::pica()
|
|
||||||
{
|
|
||||||
return Units( "pc", tr("picas"), POINTS_PER_PICA );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Units::isIdValid( QString id )
|
|
||||||
{
|
|
||||||
return ( (id == "pt") || (id == "in") || (id == "mm") || (id == "cm") || (id == "pc") || (id == "") );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
/* 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 );
|
|
||||||
|
|
||||||
public:
|
|
||||||
Units();
|
|
||||||
|
|
||||||
QString id() const;
|
|
||||||
QString name() const;
|
|
||||||
|
|
||||||
double pointsPerUnit() const;
|
|
||||||
double unitsPerPoint() const;
|
|
||||||
|
|
||||||
static Units fromId( const QString &id );
|
|
||||||
|
|
||||||
static Units point();
|
|
||||||
|
|
||||||
static Units inch();
|
|
||||||
|
|
||||||
static Units mm();
|
|
||||||
|
|
||||||
static Units cm();
|
|
||||||
|
|
||||||
static Units pica();
|
|
||||||
|
|
||||||
static bool isIdValid( QString id );
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString mId;
|
|
||||||
QString mName;
|
|
||||||
double mPointsPerUnit;
|
|
||||||
double mUnitsPerPoint;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#include "Units.inl"
|
|
||||||
|
|
||||||
|
|
||||||
#endif // libglabels_Units_h
|
|
||||||
@@ -93,8 +93,8 @@ namespace libglabels
|
|||||||
QString id = XmlUtil::getStringAttr( node, "id", "" );
|
QString id = XmlUtil::getStringAttr( node, "id", "" );
|
||||||
QString name = XmlUtil::getI18nAttr( node, "name", "" );
|
QString name = XmlUtil::getI18nAttr( node, "name", "" );
|
||||||
|
|
||||||
double width = XmlUtil::getLengthAttr( node, "width", 0 );
|
Distance width = XmlUtil::getLengthAttr( node, "width", Distance(0) );
|
||||||
double height = XmlUtil::getLengthAttr( node, "height", 0 );
|
Distance height = XmlUtil::getLengthAttr( node, "height", Distance(0) );
|
||||||
|
|
||||||
QString pwgSize = XmlUtil::getStringAttr( node, "pwg_size", "" );
|
QString pwgSize = XmlUtil::getStringAttr( node, "pwg_size", "" );
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* XmlTemplateCreator.cpp
|
/* XmlTemplateCreator.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -203,11 +203,11 @@ namespace libglabels
|
|||||||
XmlUtil::setLengthAttr( node, "radius", frame->r1() );
|
XmlUtil::setLengthAttr( node, "radius", frame->r1() );
|
||||||
XmlUtil::setLengthAttr( node, "hole", frame->r2() );
|
XmlUtil::setLengthAttr( node, "hole", frame->r2() );
|
||||||
XmlUtil::setLengthAttr( node, "waste", frame->waste() );
|
XmlUtil::setLengthAttr( node, "waste", frame->waste() );
|
||||||
if ( frame->w() )
|
if ( frame->w() != Distance(0) )
|
||||||
{
|
{
|
||||||
XmlUtil::setLengthAttr( node, "width", frame->w() );
|
XmlUtil::setLengthAttr( node, "width", frame->w() );
|
||||||
}
|
}
|
||||||
if ( frame->h() )
|
if ( frame->h() != Distance(0) )
|
||||||
{
|
{
|
||||||
XmlUtil::setLengthAttr( node, "height", frame->h() );
|
XmlUtil::setLengthAttr( node, "height", frame->h() );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* XmlTemplateParser.cpp
|
/* XmlTemplateParser.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -165,8 +165,8 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double width = XmlUtil::getLengthAttr( node, "width", 0 );
|
Distance width = XmlUtil::getLengthAttr( node, "width", Distance(0) );
|
||||||
double height = XmlUtil::getLengthAttr( node, "height", 0 );
|
Distance height = XmlUtil::getLengthAttr( node, "height", Distance(0) );
|
||||||
|
|
||||||
tmplate = new Template( brand, part, description, paperId, width, height );
|
tmplate = new Template( brand, part, description, paperId, width, height );
|
||||||
}
|
}
|
||||||
@@ -226,22 +226,22 @@ namespace libglabels
|
|||||||
{
|
{
|
||||||
QString id = XmlUtil::getStringAttr( node, "id", "0" );
|
QString id = XmlUtil::getStringAttr( node, "id", "0" );
|
||||||
|
|
||||||
double w = XmlUtil::getLengthAttr( node, "width", 0 );
|
Distance w = XmlUtil::getLengthAttr( node, "width", Distance(0) );
|
||||||
double h = XmlUtil::getLengthAttr( node, "height", 0 );
|
Distance h = XmlUtil::getLengthAttr( node, "height", Distance(0) );
|
||||||
double r = XmlUtil::getLengthAttr( node, "round", 0 );
|
Distance r = XmlUtil::getLengthAttr( node, "round", Distance(0) );
|
||||||
|
|
||||||
double xWaste, yWaste;
|
Distance xWaste, yWaste;
|
||||||
|
|
||||||
double waste = XmlUtil::getLengthAttr( node, "waste", -1 );
|
Distance waste = XmlUtil::getLengthAttr( node, "waste", Distance(-1) );
|
||||||
if ( waste >= 0 )
|
if ( waste >= Distance(0) )
|
||||||
{
|
{
|
||||||
xWaste = waste;
|
xWaste = waste;
|
||||||
yWaste = waste;
|
yWaste = waste;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xWaste = XmlUtil::getLengthAttr( node, "x_waste", 0 );
|
xWaste = XmlUtil::getLengthAttr( node, "x_waste", Distance(0) );
|
||||||
yWaste = XmlUtil::getLengthAttr( node, "y_waste", 0 );
|
yWaste = XmlUtil::getLengthAttr( node, "y_waste", Distance(0) );
|
||||||
}
|
}
|
||||||
|
|
||||||
Frame *frame = new FrameRect( w, h, r, xWaste, yWaste, id );
|
Frame *frame = new FrameRect( w, h, r, xWaste, yWaste, id );
|
||||||
@@ -256,9 +256,9 @@ namespace libglabels
|
|||||||
{
|
{
|
||||||
QString id = XmlUtil::getStringAttr( node, "id", "0" );
|
QString id = XmlUtil::getStringAttr( node, "id", "0" );
|
||||||
|
|
||||||
double w = XmlUtil::getLengthAttr( node, "width", 0 );
|
Distance w = XmlUtil::getLengthAttr( node, "width", Distance(0) );
|
||||||
double h = XmlUtil::getLengthAttr( node, "height", 0 );
|
Distance h = XmlUtil::getLengthAttr( node, "height", Distance(0) );
|
||||||
double waste = XmlUtil::getLengthAttr( node, "waste", -1 );
|
Distance waste = XmlUtil::getLengthAttr( node, "waste", Distance(0) );
|
||||||
|
|
||||||
Frame *frame = new FrameEllipse( w, h, waste, id );
|
Frame *frame = new FrameEllipse( w, h, waste, id );
|
||||||
|
|
||||||
@@ -272,8 +272,8 @@ namespace libglabels
|
|||||||
{
|
{
|
||||||
QString id = XmlUtil::getStringAttr( node, "id", "0" );
|
QString id = XmlUtil::getStringAttr( node, "id", "0" );
|
||||||
|
|
||||||
double r = XmlUtil::getLengthAttr( node, "radius", 0 );
|
Distance r = XmlUtil::getLengthAttr( node, "radius", Distance(0) );
|
||||||
double waste = XmlUtil::getLengthAttr( node, "waste", -1 );
|
Distance waste = XmlUtil::getLengthAttr( node, "waste", Distance(0) );
|
||||||
|
|
||||||
Frame *frame = new FrameRound( r, waste, id );
|
Frame *frame = new FrameRound( r, waste, id );
|
||||||
|
|
||||||
@@ -287,11 +287,11 @@ namespace libglabels
|
|||||||
{
|
{
|
||||||
QString id = XmlUtil::getStringAttr( node, "id", "0" );
|
QString id = XmlUtil::getStringAttr( node, "id", "0" );
|
||||||
|
|
||||||
double r1 = XmlUtil::getLengthAttr( node, "radius", 0 );
|
Distance r1 = XmlUtil::getLengthAttr( node, "radius", Distance(0) );
|
||||||
double r2 = XmlUtil::getLengthAttr( node, "hole", 0 );
|
Distance r2 = XmlUtil::getLengthAttr( node, "hole", Distance(0) );
|
||||||
double w = XmlUtil::getLengthAttr( node, "width", 0 );
|
Distance w = XmlUtil::getLengthAttr( node, "width", Distance(0) );
|
||||||
double h = XmlUtil::getLengthAttr( node, "height", 0 );
|
Distance h = XmlUtil::getLengthAttr( node, "height", Distance(0) );
|
||||||
double waste = XmlUtil::getLengthAttr( node, "waste", -1 );
|
Distance waste = XmlUtil::getLengthAttr( node, "waste", Distance(0) );
|
||||||
|
|
||||||
Frame *frame = new FrameCd( r1, r2, w, h, waste, id );
|
Frame *frame = new FrameCd( r1, r2, w, h, waste, id );
|
||||||
|
|
||||||
@@ -341,14 +341,14 @@ namespace libglabels
|
|||||||
|
|
||||||
void XmlTemplateParser::parseLayoutNode( const QDomElement &node, Frame *frame )
|
void XmlTemplateParser::parseLayoutNode( const QDomElement &node, Frame *frame )
|
||||||
{
|
{
|
||||||
int nX = XmlUtil::getIntAttr( node, "nx", 1 );
|
int nX = XmlUtil::getIntAttr( node, "nx", 1 );
|
||||||
int nY = XmlUtil::getIntAttr( node, "ny", 1 );
|
int nY = XmlUtil::getIntAttr( node, "ny", 1 );
|
||||||
|
|
||||||
double x0 = XmlUtil::getLengthAttr( node, "x0", 0 );
|
Distance x0 = XmlUtil::getLengthAttr( node, "x0", Distance(0) );
|
||||||
double y0 = XmlUtil::getLengthAttr( node, "y0", 0 );
|
Distance y0 = XmlUtil::getLengthAttr( node, "y0", Distance(0) );
|
||||||
|
|
||||||
double dX = XmlUtil::getLengthAttr( node, "dx", 0 );
|
Distance dX = XmlUtil::getLengthAttr( node, "dx", Distance(0) );
|
||||||
double dY = XmlUtil::getLengthAttr( node, "dy", 0 );
|
Distance dY = XmlUtil::getLengthAttr( node, "dy", Distance(0) );
|
||||||
|
|
||||||
frame->addLayout( new Layout( nX, nY, x0, y0, dX, dY ) );
|
frame->addLayout( new Layout( nX, nY, x0, y0, dX, dY ) );
|
||||||
}
|
}
|
||||||
@@ -356,7 +356,7 @@ namespace libglabels
|
|||||||
|
|
||||||
void XmlTemplateParser::parseMarkupMarginNode( const QDomElement &node, Frame *frame )
|
void XmlTemplateParser::parseMarkupMarginNode( const QDomElement &node, Frame *frame )
|
||||||
{
|
{
|
||||||
double size = XmlUtil::getLengthAttr( node, "size", 0 );
|
Distance size = XmlUtil::getLengthAttr( node, "size", Distance(0) );
|
||||||
|
|
||||||
frame->addMarkup( new MarkupMargin( frame, size ) );
|
frame->addMarkup( new MarkupMargin( frame, size ) );
|
||||||
}
|
}
|
||||||
@@ -364,10 +364,10 @@ namespace libglabels
|
|||||||
|
|
||||||
void XmlTemplateParser::parseMarkupLineNode( const QDomElement &node, Frame *frame )
|
void XmlTemplateParser::parseMarkupLineNode( const QDomElement &node, Frame *frame )
|
||||||
{
|
{
|
||||||
double x1 = XmlUtil::getLengthAttr( node, "x1", 0 );
|
Distance x1 = XmlUtil::getLengthAttr( node, "x1", Distance(0) );
|
||||||
double y1 = XmlUtil::getLengthAttr( node, "y1", 0 );
|
Distance y1 = XmlUtil::getLengthAttr( node, "y1", Distance(0) );
|
||||||
double x2 = XmlUtil::getLengthAttr( node, "x2", 0 );
|
Distance x2 = XmlUtil::getLengthAttr( node, "x2", Distance(0) );
|
||||||
double y2 = XmlUtil::getLengthAttr( node, "y2", 0 );
|
Distance y2 = XmlUtil::getLengthAttr( node, "y2", Distance(0) );
|
||||||
|
|
||||||
frame->addMarkup( new MarkupLine( x1, y1, x2, y2 ) );
|
frame->addMarkup( new MarkupLine( x1, y1, x2, y2 ) );
|
||||||
}
|
}
|
||||||
@@ -375,9 +375,9 @@ namespace libglabels
|
|||||||
|
|
||||||
void XmlTemplateParser::parseMarkupCircleNode( const QDomElement &node, Frame *frame )
|
void XmlTemplateParser::parseMarkupCircleNode( const QDomElement &node, Frame *frame )
|
||||||
{
|
{
|
||||||
double x0 = XmlUtil::getLengthAttr( node, "x0", 0 );
|
Distance x0 = XmlUtil::getLengthAttr( node, "x0", Distance(0) );
|
||||||
double y0 = XmlUtil::getLengthAttr( node, "y0", 0 );
|
Distance y0 = XmlUtil::getLengthAttr( node, "y0", Distance(0) );
|
||||||
double r = XmlUtil::getLengthAttr( node, "radius", 0 );
|
Distance r = XmlUtil::getLengthAttr( node, "radius", Distance(0) );
|
||||||
|
|
||||||
frame->addMarkup( new MarkupCircle( x0, y0, r ) );
|
frame->addMarkup( new MarkupCircle( x0, y0, r ) );
|
||||||
}
|
}
|
||||||
@@ -385,11 +385,11 @@ namespace libglabels
|
|||||||
|
|
||||||
void XmlTemplateParser::parseMarkupRectNode( const QDomElement &node, Frame *frame )
|
void XmlTemplateParser::parseMarkupRectNode( const QDomElement &node, Frame *frame )
|
||||||
{
|
{
|
||||||
double x1 = XmlUtil::getLengthAttr( node, "x1", 0 );
|
Distance x1 = XmlUtil::getLengthAttr( node, "x1", Distance(0) );
|
||||||
double y1 = XmlUtil::getLengthAttr( node, "y1", 0 );
|
Distance y1 = XmlUtil::getLengthAttr( node, "y1", Distance(0) );
|
||||||
double w = XmlUtil::getLengthAttr( node, "w", 0 );
|
Distance w = XmlUtil::getLengthAttr( node, "w", Distance(0) );
|
||||||
double h = XmlUtil::getLengthAttr( node, "h", 0 );
|
Distance h = XmlUtil::getLengthAttr( node, "h", Distance(0) );
|
||||||
double r = XmlUtil::getLengthAttr( node, "r", 0 );
|
Distance r = XmlUtil::getLengthAttr( node, "r", Distance(0) );
|
||||||
|
|
||||||
frame->addMarkup( new MarkupRect( x1, y1, w, h, r ) );
|
frame->addMarkup( new MarkupRect( x1, y1, w, h, r ) );
|
||||||
}
|
}
|
||||||
@@ -397,10 +397,10 @@ namespace libglabels
|
|||||||
|
|
||||||
void XmlTemplateParser::parseMarkupEllipseNode( const QDomElement &node, Frame *frame )
|
void XmlTemplateParser::parseMarkupEllipseNode( const QDomElement &node, Frame *frame )
|
||||||
{
|
{
|
||||||
double x1 = XmlUtil::getLengthAttr( node, "x1", 0 );
|
Distance x1 = XmlUtil::getLengthAttr( node, "x1", Distance(0) );
|
||||||
double y1 = XmlUtil::getLengthAttr( node, "y1", 0 );
|
Distance y1 = XmlUtil::getLengthAttr( node, "y1", Distance(0) );
|
||||||
double w = XmlUtil::getLengthAttr( node, "w", 0 );
|
Distance w = XmlUtil::getLengthAttr( node, "w", Distance(0) );
|
||||||
double h = XmlUtil::getLengthAttr( node, "h", 0 );
|
Distance h = XmlUtil::getLengthAttr( node, "h", Distance(0) );
|
||||||
|
|
||||||
frame->addMarkup( new MarkupEllipse( x1, y1, w, h ) );
|
frame->addMarkup( new MarkupEllipse( x1, y1, w, h ) );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* XmlTemplateParser.h
|
/* XmlTemplateParser.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
|
|||||||
+17
-21
@@ -1,6 +1,6 @@
|
|||||||
/* XmlUtil.cpp
|
/* XmlUtil.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -27,12 +27,12 @@
|
|||||||
namespace libglabels
|
namespace libglabels
|
||||||
{
|
{
|
||||||
|
|
||||||
Units XmlUtil::mDefaultUnits;
|
Distance::Units XmlUtil::mUnits;
|
||||||
|
|
||||||
|
|
||||||
XmlUtil::XmlUtil()
|
XmlUtil::XmlUtil()
|
||||||
{
|
{
|
||||||
mDefaultUnits = Units::point();
|
mUnits = Distance::Units::PT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -42,25 +42,25 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Units XmlUtil::defaultUnits()
|
Distance::Units XmlUtil::units()
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
|
||||||
return mDefaultUnits;
|
return mUnits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void XmlUtil::setDefaultUnits( const Units& defaultUnits )
|
void XmlUtil::setUnits( Distance::Units units )
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
|
||||||
mDefaultUnits = defaultUnits;
|
mUnits = units;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString XmlUtil::getStringAttr( const QDomElement& node,
|
QString XmlUtil::getStringAttr( const QDomElement& node,
|
||||||
const QString& name,
|
const QString& name,
|
||||||
const QString& default_value )
|
const QString& default_value )
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
|
||||||
@@ -200,9 +200,9 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double XmlUtil::getLengthAttr( const QDomElement& node,
|
Distance XmlUtil::getLengthAttr( const QDomElement& node,
|
||||||
const QString& name,
|
const QString& name,
|
||||||
double default_value )
|
const Distance& default_value )
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
|
||||||
@@ -215,16 +215,13 @@ namespace libglabels
|
|||||||
|
|
||||||
valueStream >> value >> unitsString;
|
valueStream >> value >> unitsString;
|
||||||
|
|
||||||
if ( !Units::isIdValid( unitsString ) )
|
if ( !unitsString.isEmpty() && !Distance::isIdValid( unitsString ) )
|
||||||
{
|
{
|
||||||
qWarning() << "Error: bad length value in attribute "
|
qWarning() << "Error: bad length value in attribute "
|
||||||
<< node.tagName() << ":" << name << "=" << valueString;
|
<< node.tagName() << ":" << name << "=" << valueString;
|
||||||
return default_value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Units units = Units::fromId( unitsString );
|
return Distance( value, unitsString );
|
||||||
|
|
||||||
return value * units.pointsPerUnit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return default_value;
|
return default_value;
|
||||||
@@ -281,14 +278,13 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void XmlUtil::setLengthAttr( QDomElement& node,
|
void XmlUtil::setLengthAttr( QDomElement& node,
|
||||||
const QString& name,
|
const QString& name,
|
||||||
double value )
|
const Distance& value )
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
|
||||||
value *= mDefaultUnits.unitsPerPoint();
|
node.setAttribute( name, QString::number(value.inUnits(mUnits)) + Distance::toId(mUnits) );
|
||||||
node.setAttribute( name, QString::number(value) + mDefaultUnits.id() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-10
@@ -1,6 +1,6 @@
|
|||||||
/* XmlUtil.h
|
/* XmlUtil.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
#include <QDomElement>
|
#include <QDomElement>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "Units.h"
|
#include "Distance.h"
|
||||||
|
|
||||||
|
|
||||||
namespace libglabels
|
namespace libglabels
|
||||||
@@ -41,8 +41,8 @@ namespace libglabels
|
|||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
|
|
||||||
static Units defaultUnits();
|
static Distance::Units units();
|
||||||
static void setDefaultUnits( const Units& defaultUnits );
|
static void setUnits( Distance::Units units );
|
||||||
|
|
||||||
static QString getStringAttr( const QDomElement& node,
|
static QString getStringAttr( const QDomElement& node,
|
||||||
const QString& name,
|
const QString& name,
|
||||||
@@ -68,9 +68,9 @@ namespace libglabels
|
|||||||
const QString& name,
|
const QString& name,
|
||||||
const QString& default_value );
|
const QString& default_value );
|
||||||
|
|
||||||
static double getLengthAttr( const QDomElement& node,
|
static Distance getLengthAttr( const QDomElement& node,
|
||||||
const QString& name,
|
const QString& name,
|
||||||
double default_value );
|
const Distance& default_value );
|
||||||
|
|
||||||
static void setStringAttr( QDomElement& node,
|
static void setStringAttr( QDomElement& node,
|
||||||
const QString& name,
|
const QString& name,
|
||||||
@@ -92,12 +92,12 @@ namespace libglabels
|
|||||||
const QString& name,
|
const QString& name,
|
||||||
uint32_t value );
|
uint32_t value );
|
||||||
|
|
||||||
static void setLengthAttr( QDomElement& node,
|
static void setLengthAttr( QDomElement& node,
|
||||||
const QString& name,
|
const QString& name,
|
||||||
double value );
|
const Distance& value );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Units mDefaultUnits;
|
static Distance::Units mUnits;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#define libglabels_privateConstants_h
|
#define libglabels_privateConstants_h
|
||||||
|
|
||||||
|
|
||||||
#include <QString>
|
#include "Distance.h"
|
||||||
|
|
||||||
|
|
||||||
namespace libglabels
|
namespace libglabels
|
||||||
@@ -31,7 +31,8 @@ namespace libglabels
|
|||||||
namespace Constants
|
namespace Constants
|
||||||
{
|
{
|
||||||
|
|
||||||
const double EPSILON = 0.5; /* Allowed error when comparing dimensions. (0.5pts ~= .007in ~= .2mm) */
|
const Distance EPSILON( 0.5, Distance::Units::PT );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user