Added unit-independent distance type.
This commit is contained in:
+10
-4
@@ -76,11 +76,15 @@ glabels::Handle::Location glabels::Handle::location() const
|
||||
///
|
||||
/// 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->translate( x, y );
|
||||
painter->translate( x.pt(), y.pt() );
|
||||
|
||||
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
|
||||
///
|
||||
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;
|
||||
|
||||
double s = 1/scale;
|
||||
|
||||
path.addRect( -s*handlePixels/2, -s*handlePixels/2, s*handlePixels, s*handlePixels );
|
||||
path.translate( x, y );
|
||||
path.translate( x.pt(), y.pt() );
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
+10
-2
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
#include "libglabels/Distance.h"
|
||||
|
||||
|
||||
namespace glabels
|
||||
@@ -67,8 +68,15 @@ namespace glabels
|
||||
virtual void draw( QPainter* painter, double scale ) const = 0;
|
||||
virtual QPainterPath path( double scale ) const = 0;
|
||||
protected:
|
||||
void drawAt( QPainter* painter, double scale, double x, double y, QColor color ) const;
|
||||
QPainterPath pathAt( double scale, double x, double y ) const;
|
||||
void drawAt( QPainter* painter,
|
||||
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
|
||||
*
|
||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
@@ -116,7 +116,9 @@ namespace glabels
|
||||
///
|
||||
/// 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. */
|
||||
QList<LabelModelObject*>::const_iterator it = mObjectList.end();
|
||||
@@ -137,7 +139,9 @@ namespace glabels
|
||||
///
|
||||
/// 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 )
|
||||
{
|
||||
@@ -234,10 +238,10 @@ namespace glabels
|
||||
using std::min;
|
||||
using std::max;
|
||||
|
||||
double rX1 = min( region.x1(), region.x2() );
|
||||
double rY1 = min( region.y1(), region.y2() );
|
||||
double rX2 = max( region.x1(), region.x2() );
|
||||
double rY2 = max( region.y1(), region.y2() );
|
||||
libglabels::Distance rX1 = min( region.x1(), region.x2() );
|
||||
libglabels::Distance rY1 = min( region.y1(), region.y2() );
|
||||
libglabels::Distance rX2 = max( region.x1(), region.x2() );
|
||||
libglabels::Distance rY2 = max( region.y1(), region.y2() );
|
||||
|
||||
foreach ( LabelModelObject* object, mObjectList )
|
||||
{
|
||||
@@ -559,7 +563,7 @@ namespace glabels
|
||||
QList<LabelModelObject*> selectedList = getSelection();
|
||||
|
||||
/// 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 )
|
||||
{
|
||||
LabelRegion r = object->getExtent();
|
||||
@@ -570,7 +574,7 @@ namespace glabels
|
||||
foreach ( LabelModelObject* object, selectedList )
|
||||
{
|
||||
LabelRegion r = object->getExtent();
|
||||
double dx = x1_min - r.x1();
|
||||
libglabels::Distance dx = x1_min - r.x1();
|
||||
object->setPositionRelative( dx, 0 );
|
||||
}
|
||||
|
||||
@@ -594,7 +598,7 @@ namespace glabels
|
||||
QList<LabelModelObject*> selectedList = getSelection();
|
||||
|
||||
/// 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 )
|
||||
{
|
||||
LabelRegion r = object->getExtent();
|
||||
@@ -605,7 +609,7 @@ namespace glabels
|
||||
foreach ( LabelModelObject* object, selectedList )
|
||||
{
|
||||
LabelRegion r = object->getExtent();
|
||||
double dx = x1_max - r.x1();
|
||||
libglabels::Distance dx = x1_max - r.x1();
|
||||
object->setPositionRelative( dx, 0 );
|
||||
}
|
||||
|
||||
@@ -629,7 +633,7 @@ namespace glabels
|
||||
QList<LabelModelObject*> selectedList = getSelection();
|
||||
|
||||
/// Find average center of objects.
|
||||
double xsum = 0;
|
||||
libglabels::Distance xsum = 0;
|
||||
int n = 0;
|
||||
foreach ( LabelModelObject* object, selectedList )
|
||||
{
|
||||
@@ -637,15 +641,15 @@ namespace glabels
|
||||
xsum += (r.x1() + r.x2()) / 2.0;
|
||||
n++;
|
||||
}
|
||||
double xavg = xsum / n;
|
||||
libglabels::Distance xavg = xsum / n;
|
||||
|
||||
/// Find object closest to average center of objects.
|
||||
double xcenter = 7200; /// Start with very large value.
|
||||
double dxmin = fabs( xavg - xcenter );
|
||||
libglabels::Distance xcenter = 7200; /// Start with very large value.
|
||||
libglabels::Distance dxmin = fabs( xavg - xcenter );
|
||||
foreach ( LabelModelObject* object, selectedList )
|
||||
{
|
||||
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 )
|
||||
{
|
||||
dxmin = dx;
|
||||
@@ -657,7 +661,7 @@ namespace glabels
|
||||
foreach ( LabelModelObject* object, selectedList )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
@@ -681,7 +685,7 @@ namespace glabels
|
||||
QList<LabelModelObject*> selectedList = getSelection();
|
||||
|
||||
/// 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 )
|
||||
{
|
||||
LabelRegion r = object->getExtent();
|
||||
@@ -692,7 +696,7 @@ namespace glabels
|
||||
foreach ( LabelModelObject* object, selectedList )
|
||||
{
|
||||
LabelRegion r = object->getExtent();
|
||||
double dy = y1_min - r.y1();
|
||||
libglabels::Distance dy = y1_min - r.y1();
|
||||
object->setPositionRelative( 0, dy );
|
||||
}
|
||||
|
||||
@@ -716,7 +720,7 @@ namespace glabels
|
||||
QList<LabelModelObject*> selectedList = getSelection();
|
||||
|
||||
/// 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 )
|
||||
{
|
||||
LabelRegion r = object->getExtent();
|
||||
@@ -727,7 +731,7 @@ namespace glabels
|
||||
foreach ( LabelModelObject* object, selectedList )
|
||||
{
|
||||
LabelRegion r = object->getExtent();
|
||||
double dy = y1_max - r.y1();
|
||||
libglabels::Distance dy = y1_max - r.y1();
|
||||
object->setPositionRelative( 0, dy );
|
||||
}
|
||||
|
||||
@@ -751,7 +755,7 @@ namespace glabels
|
||||
QList<LabelModelObject*> selectedList = getSelection();
|
||||
|
||||
/// Find average center of objects.
|
||||
double ysum = 0;
|
||||
libglabels::Distance ysum = 0;
|
||||
int n = 0;
|
||||
foreach ( LabelModelObject* object, selectedList )
|
||||
{
|
||||
@@ -759,15 +763,15 @@ namespace glabels
|
||||
ysum += (r.y1() + r.y2()) / 2.0;
|
||||
n++;
|
||||
}
|
||||
double yavg = ysum / n;
|
||||
libglabels::Distance yavg = ysum / n;
|
||||
|
||||
/// Find object closest to average center of objects.
|
||||
double ycenter = 7200; /// Start with very large value.
|
||||
double dymin = fabs( yavg - ycenter );
|
||||
libglabels::Distance ycenter = 7200; /// Start with very large value.
|
||||
libglabels::Distance dymin = fabs( yavg - ycenter );
|
||||
foreach ( LabelModelObject* object, selectedList )
|
||||
{
|
||||
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 )
|
||||
{
|
||||
dymin = dy;
|
||||
@@ -779,7 +783,7 @@ namespace glabels
|
||||
foreach ( LabelModelObject* object, selectedList )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
@@ -795,15 +799,15 @@ namespace glabels
|
||||
///
|
||||
void LabelModel::centerSelectionHoriz()
|
||||
{
|
||||
double xLabelCenter = w() / 2.0;
|
||||
libglabels::Distance xLabelCenter = w() / 2.0;
|
||||
|
||||
foreach ( LabelModelObject* object, mObjectList )
|
||||
{
|
||||
if ( object->isSelected() )
|
||||
{
|
||||
LabelRegion r = object->getExtent();
|
||||
double xObjectCenter = (r.x1() + r.x2()) / 2.0;
|
||||
double dx = xLabelCenter - xObjectCenter;
|
||||
libglabels::Distance xObjectCenter = (r.x1() + r.x2()) / 2.0;
|
||||
libglabels::Distance dx = xLabelCenter - xObjectCenter;
|
||||
object->setPositionRelative( dx, 0 );
|
||||
}
|
||||
}
|
||||
@@ -820,15 +824,15 @@ namespace glabels
|
||||
///
|
||||
void LabelModel::centerSelectionVert()
|
||||
{
|
||||
double yLabelCenter = h() / 2.0;
|
||||
libglabels::Distance yLabelCenter = h() / 2.0;
|
||||
|
||||
foreach ( LabelModelObject* object, mObjectList )
|
||||
{
|
||||
if ( object->isSelected() )
|
||||
{
|
||||
LabelRegion r = object->getExtent();
|
||||
double yObjectCenter = (r.y1() + r.y2()) / 2.0;
|
||||
double dy = yLabelCenter - yObjectCenter;
|
||||
libglabels::Distance yObjectCenter = (r.y1() + r.y2()) / 2.0;
|
||||
libglabels::Distance dy = yLabelCenter - yObjectCenter;
|
||||
object->setPositionRelative( 0, dy );
|
||||
}
|
||||
}
|
||||
@@ -843,7 +847,7 @@ namespace glabels
|
||||
///
|
||||
/// 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 )
|
||||
{
|
||||
@@ -1023,7 +1027,7 @@ namespace glabels
|
||||
///
|
||||
/// Set Line Width Of Selected Objects
|
||||
///
|
||||
void LabelModel::setSelectionLineWidth( double lineWidth )
|
||||
void LabelModel::setSelectionLineWidth( const libglabels::Distance& lineWidth )
|
||||
{
|
||||
foreach ( LabelModelObject* object, mObjectList )
|
||||
{
|
||||
|
||||
+14
-9
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
@@ -88,8 +88,8 @@ namespace glabels
|
||||
inline bool rotate() const;
|
||||
inline void setRotate( bool rotate );
|
||||
|
||||
inline double w() const;
|
||||
inline double h() const;
|
||||
inline libglabels::Distance w() const;
|
||||
inline libglabels::Distance h() const;
|
||||
|
||||
inline const QList<LabelModelObject*>& objectList() const;
|
||||
|
||||
@@ -101,8 +101,13 @@ namespace glabels
|
||||
void addObject( LabelModelObject* object );
|
||||
void deleteObject( LabelModelObject* object );
|
||||
|
||||
LabelModelObject* objectAt( double scale, double x, double y ) const;
|
||||
Handle* handleAt( double scale, double x, double y ) const;
|
||||
LabelModelObject* objectAt( double scale,
|
||||
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 centerSelectionHoriz();
|
||||
void centerSelectionVert();
|
||||
void moveSelection( double dx, double dy );
|
||||
void moveSelection( const libglabels::Distance& dx, const libglabels::Distance& dy );
|
||||
void setSelectionFontFamily( const QString& fontFamily );
|
||||
void setSelectionFontSize( double fontSize );
|
||||
void setSelectionFontWeight( QFont::Weight fontWeight );
|
||||
@@ -165,7 +170,7 @@ namespace glabels
|
||||
void setSelectionTextVAlign( Qt::Alignment textVAlign );
|
||||
void setSelectionTextLineSpacing( double textLineSpacing );
|
||||
void setSelectionTextColorNode( ColorNode textColorNode );
|
||||
void setSelectionLineWidth( double lineWidth );
|
||||
void setSelectionLineWidth( const libglabels::Distance& lineWidth );
|
||||
void setSelectionLineColorNode( ColorNode lineColorNode );
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
inline double LabelModel::h() const
|
||||
inline libglabels::Distance LabelModel::h() const
|
||||
{
|
||||
return mRotate ? mFrame->w() : mFrame->h();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
@@ -70,12 +70,15 @@ namespace glabels
|
||||
if ( lineColor.alpha() )
|
||||
{
|
||||
/* 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
|
||||
{
|
||||
/* Has FILL, but no OUTLINE. */
|
||||
painter->drawRect( QRectF( 0, 0, mW, mH ) );
|
||||
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -83,10 +86,10 @@ namespace glabels
|
||||
if ( lineColor.alpha() )
|
||||
{
|
||||
/* Has only OUTLINE. */
|
||||
painter->setPen( QPen( shadowColor, mLineWidth ) );
|
||||
painter->setPen( QPen( shadowColor, mLineWidth.pt() ) );
|
||||
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 fillColor = mFillColorNode.color();
|
||||
|
||||
painter->setPen( QPen( lineColor, mLineWidth ) );
|
||||
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
||||
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() )
|
||||
{
|
||||
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()) )
|
||||
{
|
||||
path.addRect( 0, 0, mW, mH );
|
||||
path.addRect( 0, 0, mW.pt(), mH.pt() );
|
||||
}
|
||||
else if ( mLineColorNode.color().alpha() )
|
||||
{
|
||||
path.addRect( (-mLineWidth/2)-s*slopPixels, (-mLineWidth/2)-s*slopPixels,
|
||||
mW+mLineWidth+s*2*slopPixels, mH+mLineWidth+s*2*slopPixels );
|
||||
path.addRect( (-mLineWidth.pt()/2) - s*slopPixels,
|
||||
(-mLineWidth.pt()/2) - s*slopPixels,
|
||||
(mW + mLineWidth).pt() + s*2*slopPixels,
|
||||
(mH + mLineWidth).pt() + s*2*slopPixels );
|
||||
path.closeSubpath();
|
||||
path.addRect( mLineWidth/2+s*slopPixels, mLineWidth/2+s*slopPixels,
|
||||
mW-mLineWidth-s*2*slopPixels, mH-mLineWidth-s*2*slopPixels );
|
||||
path.addRect( mLineWidth.pt()/2 + s*slopPixels,
|
||||
mLineWidth.pt()/2 + s*slopPixels,
|
||||
(mW - mLineWidth).pt() - s*2*slopPixels,
|
||||
(mH - mLineWidth).pt() - s*2*slopPixels );
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace glabels
|
||||
///
|
||||
/// X0 Property Getter
|
||||
///
|
||||
double LabelModelObject::x0() const
|
||||
libglabels::Distance LabelModelObject::x0() const
|
||||
{
|
||||
return mX0;
|
||||
}
|
||||
@@ -122,7 +122,7 @@ namespace glabels
|
||||
///
|
||||
/// X0 Property Setter
|
||||
///
|
||||
void LabelModelObject::setX0( double value )
|
||||
void LabelModelObject::setX0( const libglabels::Distance& value )
|
||||
{
|
||||
if ( mX0 != value )
|
||||
{
|
||||
@@ -135,7 +135,7 @@ namespace glabels
|
||||
///
|
||||
/// Y0 Property Getter
|
||||
///
|
||||
double LabelModelObject::y0() const
|
||||
libglabels::Distance LabelModelObject::y0() const
|
||||
{
|
||||
return mY0;
|
||||
}
|
||||
@@ -144,7 +144,7 @@ namespace glabels
|
||||
///
|
||||
/// Y0 Property Setter
|
||||
///
|
||||
void LabelModelObject::setY0( double value )
|
||||
void LabelModelObject::setY0( const libglabels::Distance& value )
|
||||
{
|
||||
if ( mY0 != value )
|
||||
{
|
||||
@@ -157,7 +157,7 @@ namespace glabels
|
||||
///
|
||||
/// W (Width) Property Getter
|
||||
///
|
||||
double LabelModelObject::w() const
|
||||
libglabels::Distance LabelModelObject::w() const
|
||||
{
|
||||
return mW;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ namespace glabels
|
||||
///
|
||||
/// W (Width) Property Setter
|
||||
///
|
||||
void LabelModelObject::setW( double value )
|
||||
void LabelModelObject::setW( const libglabels::Distance& value )
|
||||
{
|
||||
if ( mW != value )
|
||||
{
|
||||
@@ -179,7 +179,7 @@ namespace glabels
|
||||
///
|
||||
/// H (Height) Property Getter
|
||||
///
|
||||
double LabelModelObject::h() const
|
||||
libglabels::Distance LabelModelObject::h() const
|
||||
{
|
||||
return mH;
|
||||
}
|
||||
@@ -188,7 +188,7 @@ namespace glabels
|
||||
///
|
||||
/// H (Height) Property Setter
|
||||
///
|
||||
void LabelModelObject::setH( double value )
|
||||
void LabelModelObject::setH( const libglabels::Distance& value )
|
||||
{
|
||||
if ( mH != value )
|
||||
{
|
||||
@@ -245,7 +245,7 @@ namespace glabels
|
||||
///
|
||||
/// Shadow X Property Getter
|
||||
///
|
||||
double LabelModelObject::shadowX() const
|
||||
libglabels::Distance LabelModelObject::shadowX() const
|
||||
{
|
||||
return mShadowX;
|
||||
}
|
||||
@@ -254,7 +254,7 @@ namespace glabels
|
||||
///
|
||||
/// Shadow X Property Setter
|
||||
///
|
||||
void LabelModelObject::setShadowX( double value )
|
||||
void LabelModelObject::setShadowX( const libglabels::Distance& value )
|
||||
{
|
||||
if ( mShadowX != value )
|
||||
{
|
||||
@@ -267,7 +267,7 @@ namespace glabels
|
||||
///
|
||||
/// Shadow Y Property Getter
|
||||
///
|
||||
double LabelModelObject::shadowY() const
|
||||
libglabels::Distance LabelModelObject::shadowY() const
|
||||
{
|
||||
return mShadowY;
|
||||
}
|
||||
@@ -276,7 +276,7 @@ namespace glabels
|
||||
///
|
||||
/// Shadow Y Property Setter
|
||||
///
|
||||
void LabelModelObject::setShadowY( double value )
|
||||
void LabelModelObject::setShadowY( const libglabels::Distance& value )
|
||||
{
|
||||
if ( mShadowY != value )
|
||||
{
|
||||
@@ -524,7 +524,7 @@ namespace glabels
|
||||
/// Virtual Line Width Property Default Getter
|
||||
/// (Overridden by concrete class)
|
||||
///
|
||||
double LabelModelObject::lineWidth() const
|
||||
libglabels::Distance LabelModelObject::lineWidth() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -534,7 +534,7 @@ namespace glabels
|
||||
/// Virtual Line Width Property Default Setter
|
||||
/// (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
|
||||
///
|
||||
void LabelModelObject::setPosition( double x0, double y0 )
|
||||
void LabelModelObject::setPosition( const libglabels::Distance& x0,
|
||||
const libglabels::Distance& y0 )
|
||||
{
|
||||
if ( ( mX0 != x0 ) || ( mY0 != y0 ) )
|
||||
{
|
||||
@@ -749,7 +750,8 @@ namespace glabels
|
||||
///
|
||||
/// 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 ) )
|
||||
{
|
||||
@@ -764,7 +766,8 @@ namespace glabels
|
||||
///
|
||||
/// Set Size
|
||||
///
|
||||
void LabelModelObject::setSize( double w, double h )
|
||||
void LabelModelObject::setSize( const libglabels::Distance& w,
|
||||
const libglabels::Distance& h )
|
||||
{
|
||||
mW = w;
|
||||
mH = h;
|
||||
@@ -776,30 +779,33 @@ namespace glabels
|
||||
///
|
||||
/// 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;
|
||||
libglabels::Distance wNew = w;
|
||||
libglabels::Distance hNew = h;
|
||||
|
||||
if ( h > (w*aspectRatio) )
|
||||
{
|
||||
h = w*aspectRatio;
|
||||
hNew = w*aspectRatio;
|
||||
}
|
||||
else
|
||||
{
|
||||
w = h/aspectRatio;
|
||||
wNew = h/aspectRatio;
|
||||
}
|
||||
|
||||
setSize( w, h );
|
||||
setSize( wNew, hNew );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Set Width (But Maintain Current Aspect Ratio)
|
||||
///
|
||||
void LabelModelObject::setWHonorAspect( double w )
|
||||
void LabelModelObject::setWHonorAspect( const libglabels::Distance& w )
|
||||
{
|
||||
double aspectRatio = mH / mW;
|
||||
double h = w * aspectRatio;
|
||||
libglabels::Distance h = w * aspectRatio;
|
||||
|
||||
if ( ( mW != w ) || ( mH != h ) )
|
||||
{
|
||||
@@ -814,10 +820,10 @@ namespace glabels
|
||||
///
|
||||
/// Set Height (But Maintain Current Aspect Ratio)
|
||||
///
|
||||
void LabelModelObject::setHHonorAspect( double h )
|
||||
void LabelModelObject::setHHonorAspect( const libglabels::Distance& h )
|
||||
{
|
||||
double aspectRatio = mH / mW;
|
||||
double w = h / aspectRatio;
|
||||
libglabels::Distance w = h / aspectRatio;
|
||||
|
||||
if ( ( mW != w ) || ( mH != h ) )
|
||||
{
|
||||
@@ -837,10 +843,10 @@ namespace glabels
|
||||
using std::min;
|
||||
using std::max;
|
||||
|
||||
QPointF a1( - lineWidth()/2, - lineWidth()/2 );
|
||||
QPointF a2( mW + lineWidth()/2, - lineWidth()/2 );
|
||||
QPointF a3( mW + lineWidth()/2, mH + lineWidth()/2 );
|
||||
QPointF a4( - lineWidth()/2, mH + lineWidth()/2 );
|
||||
QPointF a1( ( - lineWidth()/2).pt(), ( - lineWidth()/2).pt() );
|
||||
QPointF a2( (mW + lineWidth()/2).pt(), ( - lineWidth()/2).pt() );
|
||||
QPointF a3( (mW + lineWidth()/2).pt(), (mH + lineWidth()/2).pt() );
|
||||
QPointF a4( ( - lineWidth()/2).pt(), (mH + lineWidth()/2).pt() );
|
||||
|
||||
a1 = mMatrix.map( a1 );
|
||||
a2 = mMatrix.map( a2 );
|
||||
@@ -848,10 +854,10 @@ namespace glabels
|
||||
a4 = mMatrix.map( a4 );
|
||||
|
||||
LabelRegion region;
|
||||
region.setX1( 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.setX2( 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.setX1( libglabels::Distance(min( a1.x(), min( a2.x(), min( a3.x(), a4.x() ) ) )) + mX0 );
|
||||
region.setY1( libglabels::Distance(min( a1.y(), min( a2.y(), min( a3.y(), a4.y() ) ) )) + mY0 );
|
||||
region.setX2( libglabels::Distance(max( a1.x(), max( a2.x(), max( a3.x(), a4.x() ) ) )) + mX0 );
|
||||
region.setY2( libglabels::Distance(max( a1.y(), max( a2.y(), max( a3.y(), a4.y() ) ) )) + mY0 );
|
||||
|
||||
return region;
|
||||
}
|
||||
@@ -902,14 +908,16 @@ namespace glabels
|
||||
///
|
||||
/// 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
|
||||
*/
|
||||
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 );
|
||||
|
||||
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.
|
||||
///
|
||||
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 )
|
||||
{
|
||||
QPointF p( x, y );
|
||||
p -= QPointF( mX0, mY0 ); // Translate point to x0,y0
|
||||
QPointF p( x.pt(), y.pt() );
|
||||
p -= QPointF( mX0.pt(), mY0.pt() ); // Translate point to x0,y0
|
||||
|
||||
foreach ( Handle* handle, mHandles )
|
||||
{
|
||||
@@ -958,12 +968,12 @@ namespace glabels
|
||||
void LabelModelObject::draw( QPainter* painter, bool inEditor, MergeRecord* record ) const
|
||||
{
|
||||
painter->save();
|
||||
painter->translate( mX0, mY0 );
|
||||
painter->translate( mX0.pt(), mY0.pt() );
|
||||
|
||||
if ( mShadowState )
|
||||
{
|
||||
painter->save();
|
||||
painter->translate( mShadowX, mShadowY );
|
||||
painter->translate( mShadowX.pt(), mShadowY.pt() );
|
||||
painter->setMatrix( mMatrix, true );
|
||||
drawShadow( painter, inEditor, record );
|
||||
painter->restore();
|
||||
@@ -983,7 +993,7 @@ namespace glabels
|
||||
{
|
||||
painter->save();
|
||||
|
||||
painter->translate( mX0, mY0 );
|
||||
painter->translate( mX0.pt(), mY0.pt() );
|
||||
painter->setMatrix( mMatrix, true );
|
||||
|
||||
if ( mOutline )
|
||||
@@ -1000,7 +1010,5 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
+36
-97
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <QMatrix>
|
||||
#include <QPainter>
|
||||
|
||||
#include "libglabels/Distance.h"
|
||||
#include "ColorNode.h"
|
||||
#include "TextNode.h"
|
||||
#include "BarcodeStyle.h"
|
||||
@@ -70,15 +71,11 @@ namespace glabels
|
||||
//
|
||||
// ID Property.
|
||||
//
|
||||
Q_PROPERTY( int id READ id )
|
||||
|
||||
int id() const;
|
||||
|
||||
//
|
||||
// Selected Property.
|
||||
//
|
||||
Q_PROPERTY( bool selected READ isSelected WRITE select RESET unselect )
|
||||
|
||||
bool isSelected() const;
|
||||
void select( bool value = true );
|
||||
void unselect();
|
||||
@@ -87,44 +84,34 @@ namespace glabels
|
||||
//
|
||||
// x0 Property ( x coordinate of origin )
|
||||
//
|
||||
Q_PROPERTY( double x0 READ x0 WRITE setX0 );
|
||||
|
||||
double x0() const;
|
||||
void setX0( double value );
|
||||
libglabels::Distance x0() const;
|
||||
void setX0( const libglabels::Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// y0 Property ( y coordinate of origin )
|
||||
//
|
||||
Q_PROPERTY( double y0 READ y0 WRITE setY0 );
|
||||
|
||||
double y0() const;
|
||||
void setY0( double value );
|
||||
libglabels::Distance y0() const;
|
||||
void setY0( const libglabels::Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// w Property ( width of bounding box )
|
||||
//
|
||||
Q_PROPERTY( double w READ w WRITE setW );
|
||||
|
||||
double w() const;
|
||||
void setW( double value );
|
||||
libglabels::Distance w() const;
|
||||
void setW( const libglabels::Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// h Property ( height of bounding box )
|
||||
//
|
||||
Q_PROPERTY( double h READ h WRITE setH );
|
||||
|
||||
double h() const;
|
||||
void setH( double value );
|
||||
libglabels::Distance h() const;
|
||||
void setH( const libglabels::Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// Transformation Matrix Property
|
||||
//
|
||||
Q_PROPERTY( QMatrix matrix READ matrix WRITE setMatrix );
|
||||
|
||||
QMatrix matrix() const;
|
||||
void setMatrix( const QMatrix& value );
|
||||
|
||||
@@ -132,8 +119,6 @@ namespace glabels
|
||||
//
|
||||
// Shadow State Property
|
||||
//
|
||||
Q_PROPERTY( bool shadow READ shadow WRITE setShadow );
|
||||
|
||||
bool shadow() const;
|
||||
void setShadow( bool value );
|
||||
|
||||
@@ -141,26 +126,20 @@ namespace glabels
|
||||
//
|
||||
// Shadow x Offset Property
|
||||
//
|
||||
Q_PROPERTY( double shadowX READ shadowX WRITE setShadowX );
|
||||
|
||||
double shadowX() const;
|
||||
void setShadowX( double value );
|
||||
libglabels::Distance shadowX() const;
|
||||
void setShadowX( const libglabels::Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// Shadow y Offset Property
|
||||
//
|
||||
Q_PROPERTY( double shadowY READ shadowY WRITE setShadowY );
|
||||
|
||||
double shadowY() const;
|
||||
void setShadowY( double value );
|
||||
libglabels::Distance shadowY() const;
|
||||
void setShadowY( const libglabels::Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// Shadow opacity Property
|
||||
//
|
||||
Q_PROPERTY( double shadowOpacity READ shadowOpacity WRITE setShadowOpacity );
|
||||
|
||||
double shadowOpacity() const;
|
||||
void setShadowOpacity( double value );
|
||||
|
||||
@@ -168,8 +147,6 @@ namespace glabels
|
||||
//
|
||||
// Shadow Color Property
|
||||
//
|
||||
Q_PROPERTY( ColorNode shadowColorNode READ shadowColorNode WRITE setShadowColorNode );
|
||||
|
||||
ColorNode shadowColorNode() const;
|
||||
void setShadowColorNode( const ColorNode& value );
|
||||
|
||||
@@ -181,8 +158,6 @@ namespace glabels
|
||||
//
|
||||
// Virtual Text Property: fontFamily
|
||||
//
|
||||
Q_PROPERTY( QString fontFamily READ fontFamily WRITE setFontFamily );
|
||||
|
||||
virtual QString fontFamily() const;
|
||||
virtual void setFontFamily( const QString &value );
|
||||
|
||||
@@ -190,8 +165,6 @@ namespace glabels
|
||||
//
|
||||
// Virtual Text Property: fontSize
|
||||
//
|
||||
Q_PROPERTY( double fontSize READ fontSize WRITE setFontSize );
|
||||
|
||||
virtual double fontSize() const;
|
||||
virtual void setFontSize( double value );
|
||||
|
||||
@@ -199,8 +172,6 @@ namespace glabels
|
||||
//
|
||||
// Virtual Text Property: fontWeight
|
||||
//
|
||||
Q_PROPERTY( QFont::Weight fontWeight READ fontWeight WRITE setFontWeight );
|
||||
|
||||
virtual QFont::Weight fontWeight() const;
|
||||
virtual void setFontWeight( QFont::Weight value );
|
||||
|
||||
@@ -208,8 +179,6 @@ namespace glabels
|
||||
//
|
||||
// Virtual Text Property: fontItalicFlag
|
||||
//
|
||||
Q_PROPERTY( bool fontItalicFlag READ fontItalicFlag WRITE setFontItalicFlag );
|
||||
|
||||
virtual bool fontItalicFlag() const;
|
||||
virtual void setFontItalicFlag( bool value );
|
||||
|
||||
@@ -217,8 +186,6 @@ namespace glabels
|
||||
//
|
||||
// Virtual Text Property: fontUnderlineFlag
|
||||
//
|
||||
Q_PROPERTY( bool fontUnderlineFlag READ fontUnderlineFlag WRITE setFontUnderlineFlag );
|
||||
|
||||
virtual bool fontUnderlineFlag() const;
|
||||
virtual void setFontUnderlineFlag( bool value );
|
||||
|
||||
@@ -226,8 +193,6 @@ namespace glabels
|
||||
//
|
||||
// Virtual Text Property: textColorNode
|
||||
//
|
||||
Q_PROPERTY( ColorNode textColorNode READ textColorNode WRITE setTextColorNode );
|
||||
|
||||
virtual ColorNode textColorNode() const;
|
||||
virtual void setTextColorNode( const ColorNode &value );
|
||||
|
||||
@@ -235,8 +200,6 @@ namespace glabels
|
||||
//
|
||||
// Virtual Text Property: textHAlign
|
||||
//
|
||||
Q_PROPERTY( Qt::Alignment textHAlign READ textHAlign WRITE setTextHAlign );
|
||||
|
||||
virtual Qt::Alignment textHAlign() const;
|
||||
virtual void setTextHAlign( Qt::Alignment value );
|
||||
|
||||
@@ -244,8 +207,6 @@ namespace glabels
|
||||
//
|
||||
// Virtual Text Property: textVAlign
|
||||
//
|
||||
Q_PROPERTY( Qt::Alignment textVAlign READ textVAlign WRITE setTextVAlign );
|
||||
|
||||
virtual Qt::Alignment textVAlign() const;
|
||||
virtual void setTextVAlign( Qt::Alignment value );
|
||||
|
||||
@@ -253,8 +214,6 @@ namespace glabels
|
||||
//
|
||||
// Virtual Text Property: textLineSpacing
|
||||
//
|
||||
Q_PROPERTY( double textLineSpacing READ textLineSpacing WRITE setTextLineSpacing );
|
||||
|
||||
virtual double textLineSpacing() const;
|
||||
virtual void setTextLineSpacing( double value );
|
||||
|
||||
@@ -266,8 +225,6 @@ namespace glabels
|
||||
//
|
||||
// Virtual Image Property: filenameNode
|
||||
//
|
||||
Q_PROPERTY( TextNode filenameNode READ filenameNode WRITE setFilenameNode );
|
||||
|
||||
virtual TextNode filenameNode() const;
|
||||
virtual void setFilenameNode( const TextNode &value );
|
||||
|
||||
@@ -279,17 +236,13 @@ namespace glabels
|
||||
//
|
||||
// Virtual Shape Property: lineWidth
|
||||
//
|
||||
Q_PROPERTY( double lineWidth READ lineWidth WRITE setLineWidth );
|
||||
|
||||
virtual double lineWidth() const;
|
||||
virtual void setLineWidth( double value );
|
||||
virtual libglabels::Distance lineWidth() const;
|
||||
virtual void setLineWidth( const libglabels::Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// Virtual Shape Property: lineColorNode
|
||||
//
|
||||
Q_PROPERTY( ColorNode lineColorNode READ lineColorNode WRITE setLineColorNode );
|
||||
|
||||
virtual ColorNode lineColorNode() const;
|
||||
virtual void setLineColorNode( const ColorNode &value );
|
||||
|
||||
@@ -297,8 +250,6 @@ namespace glabels
|
||||
//
|
||||
// Virtual Shape Property: fillColorNode
|
||||
//
|
||||
Q_PROPERTY( ColorNode fillColorNode READ fillColorNode WRITE setFillColorNode );
|
||||
|
||||
virtual ColorNode fillColorNode() const;
|
||||
virtual void setFillColorNode( const ColorNode &value );
|
||||
|
||||
@@ -310,8 +261,6 @@ namespace glabels
|
||||
//
|
||||
// Virtual Barcode Property: bcDataNode
|
||||
//
|
||||
Q_PROPERTY( TextNode bcDataNode READ bcDataNode WRITE setBcDataNode );
|
||||
|
||||
virtual TextNode bcDataNode() const;
|
||||
virtual void setBcDataNode( const TextNode &value );
|
||||
|
||||
@@ -319,8 +268,6 @@ namespace glabels
|
||||
//
|
||||
// Virtual Barcode Property: bcTextFlag
|
||||
//
|
||||
Q_PROPERTY( bool bcTextFlag READ bcTextFlag WRITE setBcTextFlag );
|
||||
|
||||
virtual bool bcTextFlag() const;
|
||||
virtual void setBcTextFlag( bool value );
|
||||
|
||||
@@ -328,8 +275,6 @@ namespace glabels
|
||||
//
|
||||
// Virtual Barcode Property: bcChecksumFlag
|
||||
//
|
||||
Q_PROPERTY( bool bcChecksumFlag READ bcChecksumFlag WRITE setBcChecksumFlag );
|
||||
|
||||
virtual bool bcChecksumFlag() const;
|
||||
virtual void setBcChecksumFlag( bool value );
|
||||
|
||||
@@ -337,8 +282,6 @@ namespace glabels
|
||||
//
|
||||
// Virtual Barcode Property: bcColorNode
|
||||
//
|
||||
Q_PROPERTY( ColorNode bcColorNode READ bcColorNode WRITE setBcColorNode );
|
||||
|
||||
virtual ColorNode bcColorNode() const;
|
||||
virtual void setBcColorNode( const ColorNode &value );
|
||||
|
||||
@@ -346,8 +289,6 @@ namespace glabels
|
||||
//
|
||||
// Virtual Barcode Property: bcStyle
|
||||
//
|
||||
Q_PROPERTY( BarcodeStyle bcStyle READ bcStyle WRITE setBcStyle );
|
||||
|
||||
virtual BarcodeStyle bcStyle() const;
|
||||
virtual void setBcStyle( const BarcodeStyle &value );
|
||||
|
||||
@@ -355,8 +296,6 @@ namespace glabels
|
||||
//
|
||||
// Virtual Barcode Property: bcFormatDigits
|
||||
//
|
||||
Q_PROPERTY( int bcFormatDigits READ bcFormatDigits WRITE setBcFormatDigits );
|
||||
|
||||
virtual int bcFormatDigits() const;
|
||||
virtual void setBcFormatDigits( int value );
|
||||
|
||||
@@ -375,18 +314,18 @@ namespace glabels
|
||||
// Position and Size methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
void setPosition( double x0, double y0 );
|
||||
void setPositionRelative( double dx, double dy );
|
||||
void setSize( double w, double h );
|
||||
void setSizeHonorAspect( double w, double h );
|
||||
void setWHonorAspect( double w );
|
||||
void setHHonorAspect( double h );
|
||||
void setPosition( const libglabels::Distance& x0, const libglabels::Distance& y0 );
|
||||
void setPositionRelative( const libglabels::Distance& dx, const libglabels::Distance& dy );
|
||||
void setSize( const libglabels::Distance& w, const libglabels::Distance& h );
|
||||
void setSizeHonorAspect( const libglabels::Distance& w, const libglabels::Distance& h );
|
||||
void setWHonorAspect( const libglabels::Distance& w );
|
||||
void setHHonorAspect( const libglabels::Distance& h );
|
||||
LabelRegion getExtent();
|
||||
void rotate( double thetaDegs );
|
||||
void flipHoriz();
|
||||
void flipVert();
|
||||
bool isLocatedAt( double scale, double x, double y ) const;
|
||||
Handle* handleAt( double scale, double x, double y ) const;
|
||||
bool isLocatedAt( double scale, const libglabels::Distance& x, const libglabels::Distance& y ) const;
|
||||
Handle* handleAt( double scale, const libglabels::Distance& x, const libglabels::Distance& y ) const;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
@@ -406,21 +345,21 @@ namespace glabels
|
||||
// Protected Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
bool mSelectedFlag;
|
||||
bool mSelectedFlag;
|
||||
|
||||
double mX0;
|
||||
double mY0;
|
||||
double mW;
|
||||
double mH;
|
||||
libglabels::Distance mX0;
|
||||
libglabels::Distance mY0;
|
||||
libglabels::Distance mW;
|
||||
libglabels::Distance mH;
|
||||
|
||||
bool mShadowState;
|
||||
double mShadowX;
|
||||
double mShadowY;
|
||||
double mShadowOpacity;
|
||||
ColorNode mShadowColorNode;
|
||||
bool mShadowState;
|
||||
libglabels::Distance mShadowX;
|
||||
libglabels::Distance mShadowY;
|
||||
double mShadowOpacity;
|
||||
ColorNode mShadowColorNode;
|
||||
|
||||
QList<Handle*> mHandles;
|
||||
Outline* mOutline;
|
||||
QList<Handle*> mHandles;
|
||||
Outline* mOutline;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
@@ -67,7 +67,7 @@ namespace glabels
|
||||
///
|
||||
/// Line Width Property Getter
|
||||
///
|
||||
double LabelModelShapeObject::lineWidth( void ) const
|
||||
libglabels::Distance LabelModelShapeObject::lineWidth( void ) const
|
||||
{
|
||||
return mLineWidth;
|
||||
}
|
||||
@@ -76,7 +76,7 @@ namespace glabels
|
||||
///
|
||||
/// Line Width Property Setter
|
||||
///
|
||||
void LabelModelShapeObject::setLineWidth( double value )
|
||||
void LabelModelShapeObject::setLineWidth( const libglabels::Distance& value )
|
||||
{
|
||||
if ( mLineWidth != value )
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
@@ -50,8 +50,8 @@ namespace glabels
|
||||
//
|
||||
// Shape Property: lineWidth
|
||||
//
|
||||
virtual double lineWidth( void ) const;
|
||||
virtual void setLineWidth( double value );
|
||||
virtual libglabels::Distance lineWidth( void ) const;
|
||||
virtual void setLineWidth( const libglabels::Distance& value );
|
||||
|
||||
|
||||
//
|
||||
@@ -81,9 +81,9 @@ namespace glabels
|
||||
// Private Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
double mLineWidth;
|
||||
ColorNode mLineColorNode;
|
||||
ColorNode mFillColorNode;
|
||||
libglabels::Distance mLineWidth;
|
||||
ColorNode mLineColorNode;
|
||||
ColorNode mFillColorNode;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
@@ -34,10 +34,10 @@ namespace glabels
|
||||
|
||||
QRectF r;
|
||||
|
||||
r.setX( min( mX1, mX2 ) );
|
||||
r.setY( min( mY1, mY2 ) );
|
||||
r.setWidth( fabs( mX2 - mX1 ) );
|
||||
r.setHeight( fabs( mY2 - mY1 ) );
|
||||
r.setX( min( mX1, mX2 ).pt() );
|
||||
r.setY( min( mY1, mY2 ).pt() );
|
||||
r.setWidth( fabs( mX2 - mX1 ).pt() );
|
||||
r.setHeight( fabs( mY2 - mY1 ).pt() );
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
+21
-20
@@ -22,6 +22,7 @@
|
||||
#define glabels_LabelRegion_h
|
||||
|
||||
#include <QRectF>
|
||||
#include "libglabels/Distance.h"
|
||||
|
||||
|
||||
namespace glabels
|
||||
@@ -40,30 +41,30 @@ namespace glabels
|
||||
//
|
||||
// X1 Property
|
||||
//
|
||||
inline double x1( void ) const;
|
||||
inline void setX1( double value );
|
||||
libglabels::Distance x1( void ) const;
|
||||
void setX1( const libglabels::Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// Y1 Property
|
||||
//
|
||||
inline double y1( void ) const;
|
||||
inline void setY1( double value );
|
||||
libglabels::Distance y1( void ) const;
|
||||
void setY1( const libglabels::Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// X2 Property
|
||||
//
|
||||
inline double x2( void ) const;
|
||||
inline void setX2( double value );
|
||||
libglabels::Distance x2( void ) const;
|
||||
void setX2( const libglabels::Distance& value );
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Y2 Property
|
||||
//
|
||||
inline double y2( void ) const;
|
||||
inline void setY2( double value );
|
||||
libglabels::Distance y2( void ) const;
|
||||
void setY2( const libglabels::Distance& value );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
@@ -77,59 +78,59 @@ namespace glabels
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
double mX1;
|
||||
double mY1;
|
||||
double mX2;
|
||||
double mY2;
|
||||
libglabels::Distance mX1;
|
||||
libglabels::Distance mY1;
|
||||
libglabels::Distance mX2;
|
||||
libglabels::Distance mY2;
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// INLINE METHODS
|
||||
/////////////////////////////////
|
||||
double LabelRegion::x1( void ) const
|
||||
inline libglabels::Distance LabelRegion::x1( void ) const
|
||||
{
|
||||
return mX1;
|
||||
}
|
||||
|
||||
|
||||
void LabelRegion::setX1( double value )
|
||||
inline void LabelRegion::setX1( const libglabels::Distance& value )
|
||||
{
|
||||
mX1 = value;
|
||||
}
|
||||
|
||||
|
||||
double LabelRegion::y1( void ) const
|
||||
inline libglabels::Distance LabelRegion::y1( void ) const
|
||||
{
|
||||
return mY1;
|
||||
}
|
||||
|
||||
|
||||
void LabelRegion::setY1( double value )
|
||||
inline void LabelRegion::setY1( const libglabels::Distance& value )
|
||||
{
|
||||
mY1 = value;
|
||||
}
|
||||
|
||||
|
||||
double LabelRegion::x2( void ) const
|
||||
inline libglabels::Distance LabelRegion::x2( void ) const
|
||||
{
|
||||
return mX2;
|
||||
}
|
||||
|
||||
|
||||
void LabelRegion::setX2( double value )
|
||||
inline void LabelRegion::setX2( const libglabels::Distance& value )
|
||||
{
|
||||
mX2 = value;
|
||||
}
|
||||
|
||||
|
||||
double LabelRegion::y2( void ) const
|
||||
inline libglabels::Distance LabelRegion::y2( void ) const
|
||||
{
|
||||
return mY2;
|
||||
}
|
||||
|
||||
|
||||
void LabelRegion::setY2( double value )
|
||||
inline void LabelRegion::setY2( const libglabels::Distance& value )
|
||||
{
|
||||
mY2 = value;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
@@ -165,7 +165,7 @@ namespace glabels
|
||||
QString pgSizeString = libglabels::Db::lookupPaperNameFromId( tmplate->paperId() );
|
||||
pageSizeLabel->setText( pgSizeString );
|
||||
|
||||
QString labelSizeString = frame->sizeDescription( libglabels::Units::inch() );
|
||||
QString labelSizeString = frame->sizeDescription( libglabels::Distance::Units::IN );
|
||||
labelSizeLabel->setText( labelSizeString );
|
||||
|
||||
QString layoutString = frame->layoutDescription();
|
||||
|
||||
+23
-23
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
@@ -78,7 +78,7 @@ namespace glabels
|
||||
{
|
||||
mBlocked = true;
|
||||
|
||||
lineWidthSpin->setValue( mObject->lineWidth() );
|
||||
lineWidthSpin->setValue( mObject->lineWidth().pt() );
|
||||
lineColorButton->setColorNode( mObject->lineColorNode() );
|
||||
fillColorButton->setColorNode( mObject->fillColorNode() );
|
||||
|
||||
@@ -93,8 +93,8 @@ namespace glabels
|
||||
{
|
||||
mBlocked = true;
|
||||
|
||||
posXSpin->setValue( mObject->x0() );
|
||||
posYSpin->setValue( mObject->y0() );
|
||||
posXSpin->setValue( mObject->x0().in() );
|
||||
posYSpin->setValue( mObject->y0().in() );
|
||||
|
||||
mBlocked = false;
|
||||
}
|
||||
@@ -107,8 +107,8 @@ namespace glabels
|
||||
{
|
||||
mBlocked = true;
|
||||
|
||||
sizeWSpin->setValue( mObject->w() );
|
||||
sizeHSpin->setValue( mObject->h() );
|
||||
sizeWSpin->setValue( mObject->w().in() );
|
||||
sizeHSpin->setValue( mObject->h().in() );
|
||||
|
||||
mBlocked = false;
|
||||
}
|
||||
@@ -122,8 +122,8 @@ namespace glabels
|
||||
mBlocked = true;
|
||||
|
||||
shadowEnableCheck->setChecked( mObject->shadow() );
|
||||
shadowXSpin->setValue( mObject->shadowX() );
|
||||
shadowYSpin->setValue( mObject->shadowY() );
|
||||
shadowXSpin->setValue( mObject->shadowX().in() );
|
||||
shadowYSpin->setValue( mObject->shadowY().in() );
|
||||
shadowColorButton->setColorNode( mObject->shadowColorNode() );
|
||||
shadowOpacitySpin->setValue( 100*mObject->shadowOpacity() );
|
||||
|
||||
@@ -138,12 +138,12 @@ namespace glabels
|
||||
{
|
||||
mBlocked = true;
|
||||
|
||||
double whMax = std::max( mModel->w(), mModel->h() );
|
||||
libglabels::Distance whMax = std::max( mModel->w(), mModel->h() );
|
||||
|
||||
posXSpin->setRange( -whMax, 2*whMax );
|
||||
posYSpin->setRange( -whMax, 2*whMax );
|
||||
sizeWSpin->setRange( 0, 2*whMax );
|
||||
sizeHSpin->setRange( 0, 2*whMax );
|
||||
posXSpin->setRange( -whMax.in(), 2*whMax.in() );
|
||||
posYSpin->setRange( -whMax.in(), 2*whMax.in() );
|
||||
sizeWSpin->setRange( 0, 2*whMax.in() );
|
||||
sizeHSpin->setRange( 0, 2*whMax.in() );
|
||||
|
||||
mBlocked = false;
|
||||
}
|
||||
@@ -236,7 +236,7 @@ namespace glabels
|
||||
{
|
||||
mBlocked = true;
|
||||
|
||||
mObject->setLineWidth( lineWidthSpin->value() );
|
||||
mObject->setLineWidth( libglabels::Distance::pt(lineWidthSpin->value()) );
|
||||
mObject->setLineColorNode( lineColorButton->colorNode() );
|
||||
|
||||
mBlocked = false;
|
||||
@@ -275,26 +275,26 @@ namespace glabels
|
||||
if ( !mBlocked )
|
||||
{
|
||||
mBlocked = true;
|
||||
|
||||
|
||||
libglabels::Distance spinW = libglabels::Distance::in(sizeWSpin->value());
|
||||
libglabels::Distance spinH = libglabels::Distance::in(sizeHSpin->value());
|
||||
|
||||
if ( sizeAspectCheck->isChecked() )
|
||||
{
|
||||
double spinW = sizeWSpin->value();
|
||||
double spinH = sizeHSpin->value();
|
||||
|
||||
if ( fabs(spinW - mObject->w()) > fabs(spinH - mObject->h()) )
|
||||
{
|
||||
mObject->setWHonorAspect( spinW );
|
||||
sizeHSpin->setValue( mObject->h() );
|
||||
sizeHSpin->setValue( mObject->h().in() );
|
||||
}
|
||||
else
|
||||
{
|
||||
mObject->setHHonorAspect( spinH );
|
||||
sizeWSpin->setValue( mObject->w() );
|
||||
sizeWSpin->setValue( mObject->w().in() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mObject->setSize( sizeWSpin->value(), sizeHSpin->value() );
|
||||
mObject->setSize( spinW, spinH );
|
||||
}
|
||||
|
||||
mBlocked = false;
|
||||
@@ -309,8 +309,8 @@ namespace glabels
|
||||
mBlocked = true;
|
||||
|
||||
mObject->setShadow( shadowEnableCheck->isChecked() );
|
||||
mObject->setShadowX( shadowXSpin->value() );
|
||||
mObject->setShadowY( shadowYSpin->value() );
|
||||
mObject->setShadowX( libglabels::Distance::in(shadowXSpin->value()) );
|
||||
mObject->setShadowY( libglabels::Distance::in(shadowYSpin->value()) );
|
||||
mObject->setShadowColorNode( shadowColorButton->colorNode() );
|
||||
mObject->setShadowOpacity( shadowOpacitySpin->value()/100.0 );
|
||||
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
@@ -78,10 +78,10 @@ void glabels::Outline::draw( QPainter* painter ) const
|
||||
painter->setBrush( Qt::NoBrush );
|
||||
|
||||
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->drawRect( QRectF( 0, 0, mOwner->w(), mOwner->h() ) );
|
||||
painter->drawRect( QRectF( 0, 0, mOwner->w().pt(), mOwner->h().pt() ) );
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
@@ -97,10 +97,10 @@ QPainterPath glabels::Outline::hoverPath( double scale ) const
|
||||
QPainterPath path;
|
||||
|
||||
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.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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
@@ -104,7 +104,7 @@ namespace glabels
|
||||
{
|
||||
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
|
||||
{
|
||||
@@ -178,7 +178,7 @@ namespace glabels
|
||||
for ( int i = iStart; i < iEnd; i++ )
|
||||
{
|
||||
painter->save();
|
||||
painter->translate( mOrigins[i].x(), mOrigins[i].y() );
|
||||
painter->translate( mOrigins[i].x().pt(), mOrigins[i].y().pt() );
|
||||
|
||||
painter->save();
|
||||
clipLabel( painter );
|
||||
@@ -238,12 +238,12 @@ namespace glabels
|
||||
if ( mModel->rotate() )
|
||||
{
|
||||
painter->rotate( 90.0 );
|
||||
painter->translate( 0, mModel->h() );
|
||||
painter->translate( 0, mModel->h().pt() );
|
||||
}
|
||||
|
||||
if ( mPrintReverse )
|
||||
{
|
||||
painter->translate( mModel->w(), 0 );
|
||||
painter->translate( mModel->w().pt(), 0 );
|
||||
painter->scale( -1, 1 );
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
|
||||
+12
-10
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
@@ -79,12 +79,12 @@ namespace glabels
|
||||
if ( mModel != NULL )
|
||||
{
|
||||
// Set scene up with a 5% margin around paper
|
||||
double x = -0.05 * mModel->tmplate()->pageWidth();
|
||||
double y = -0.05 * mModel->tmplate()->pageHeight();
|
||||
double w = 1.10 * mModel->tmplate()->pageWidth();
|
||||
double h = 1.10 * mModel->tmplate()->pageHeight();
|
||||
libglabels::Distance x = -0.05 * mModel->tmplate()->pageWidth();
|
||||
libglabels::Distance y = -0.05 * mModel->tmplate()->pageHeight();
|
||||
libglabels::Distance w = 1.10 * mModel->tmplate()->pageWidth();
|
||||
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 );
|
||||
|
||||
drawPaper( mModel->tmplate()->pageWidth(), mModel->tmplate()->pageHeight() );
|
||||
@@ -128,7 +128,7 @@ namespace glabels
|
||||
///
|
||||
/// Draw Paper
|
||||
///
|
||||
void Preview::drawPaper( double pw, double ph )
|
||||
void Preview::drawPaper( const libglabels::Distance& pw, const libglabels::Distance& ph )
|
||||
{
|
||||
QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect();
|
||||
shadowEffect->setColor( shadowColor );
|
||||
@@ -140,7 +140,7 @@ namespace glabels
|
||||
pen.setCosmetic( true );
|
||||
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->setPen( pen );
|
||||
pageItem->setGraphicsEffect( shadowEffect );
|
||||
@@ -166,7 +166,9 @@ namespace glabels
|
||||
///
|
||||
/// 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 );
|
||||
QPen pen( labelOutlineColor );
|
||||
@@ -177,7 +179,7 @@ namespace glabels
|
||||
QGraphicsPathItem *labelOutlineItem = new QGraphicsPathItem( path );
|
||||
labelOutlineItem->setBrush( brush );
|
||||
labelOutlineItem->setPen( pen );
|
||||
labelOutlineItem->setPos( x, y );
|
||||
labelOutlineItem->setPos( x.pt(), y.pt() );
|
||||
|
||||
mScene->addItem( labelOutlineItem );
|
||||
}
|
||||
|
||||
+6
-3
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
@@ -67,9 +67,12 @@ namespace glabels
|
||||
/////////////////////////////////
|
||||
private:
|
||||
void clearScene();
|
||||
void drawPaper( double pw, double ph );
|
||||
void drawPaper( const libglabels::Distance& pw, const libglabels::Distance& ph );
|
||||
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();
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
@@ -138,7 +138,7 @@ namespace glabels
|
||||
///
|
||||
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->setFullPage( true );
|
||||
mPrinter->setPageMargins( 0, 0, 0, 0, QPrinter::Point );
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
|
||||
+28
-26
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
@@ -110,12 +110,12 @@ namespace glabels
|
||||
if ( mTmplate != NULL )
|
||||
{
|
||||
// Set scene up with a 5% margin around paper
|
||||
double x = -0.05 * mTmplate->pageWidth();
|
||||
double y = -0.05 * mTmplate->pageHeight();
|
||||
double w = 1.10 * mTmplate->pageWidth();
|
||||
double h = 1.10 * mTmplate->pageHeight();
|
||||
libglabels::Distance x = -0.05 * mTmplate->pageWidth();
|
||||
libglabels::Distance y = -0.05 * mTmplate->pageHeight();
|
||||
libglabels::Distance w = 1.10 * mTmplate->pageWidth();
|
||||
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 );
|
||||
|
||||
drawPaper( mTmplate->pageWidth(), mTmplate->pageHeight() );
|
||||
@@ -141,7 +141,7 @@ namespace glabels
|
||||
///
|
||||
/// Draw Paper
|
||||
///
|
||||
void SimplePreview::drawPaper( double pw, double ph )
|
||||
void SimplePreview::drawPaper( const libglabels::Distance& pw, const libglabels::Distance& ph )
|
||||
{
|
||||
QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect();
|
||||
shadowEffect->setColor( shadowColor );
|
||||
@@ -153,7 +153,7 @@ namespace glabels
|
||||
pen.setCosmetic( true );
|
||||
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->setPen( pen );
|
||||
pageItem->setGraphicsEffect( shadowEffect );
|
||||
@@ -179,7 +179,9 @@ namespace glabels
|
||||
///
|
||||
/// 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 );
|
||||
QPen pen( labelOutlineColor );
|
||||
@@ -189,7 +191,7 @@ namespace glabels
|
||||
QGraphicsPathItem *labelItem = new QGraphicsPathItem( path );
|
||||
labelItem->setBrush( brush );
|
||||
labelItem->setPen( pen );
|
||||
labelItem->setPos( x, y );
|
||||
labelItem->setPos( x.pt(), y.pt() );
|
||||
|
||||
mScene->addItem( labelItem );
|
||||
}
|
||||
@@ -202,32 +204,32 @@ namespace glabels
|
||||
{
|
||||
libglabels::Frame *frame = mTmplate->frames().first();
|
||||
|
||||
double w = frame->w();
|
||||
double h = frame->h();
|
||||
libglabels::Distance w = frame->w();
|
||||
libglabels::Distance h = frame->h();
|
||||
|
||||
double min = ( w < h ) ? w : h;
|
||||
libglabels::Distance min = libglabels::min( w, h );
|
||||
|
||||
QPen pen( arrowColor );
|
||||
pen.setWidthF( 0.25*min*arrowScale );
|
||||
pen.setWidthF( 0.25*min.pt()*arrowScale );
|
||||
pen.setCapStyle( Qt::FlatCap );
|
||||
pen.setJoinStyle( Qt::MiterJoin );
|
||||
|
||||
QBrush brush( upColor );
|
||||
|
||||
libglabels::Point origin = frame->getOrigins().first();
|
||||
double x0 = origin.x();
|
||||
double y0 = origin.y();
|
||||
libglabels::Distance x0 = origin.x();
|
||||
libglabels::Distance y0 = origin.y();
|
||||
|
||||
QPainterPath path;
|
||||
path.moveTo( 0, min*arrowScale/3 );
|
||||
path.lineTo( 0, -min*arrowScale );
|
||||
path.moveTo( -min*arrowScale/2, -min*arrowScale/2 );
|
||||
path.lineTo( 0, -min*arrowScale );
|
||||
path.lineTo( min*arrowScale/2, -min*arrowScale/2 );
|
||||
path.moveTo( 0, min.pt()*arrowScale/3 );
|
||||
path.lineTo( 0, -min.pt()*arrowScale );
|
||||
path.moveTo( -min.pt()*arrowScale/2, -min.pt()*arrowScale/2 );
|
||||
path.lineTo( 0, -min.pt()*arrowScale );
|
||||
path.lineTo( min.pt()*arrowScale/2, -min.pt()*arrowScale/2 );
|
||||
|
||||
QGraphicsPathItem *arrowItem = new QGraphicsPathItem( path );
|
||||
arrowItem->setPen( pen );
|
||||
arrowItem->setPos( x0+w/2, y0+h/2 );
|
||||
arrowItem->setPos( (x0+w/2).pt(), (y0+h/2).pt() );
|
||||
if ( mRotateFlag )
|
||||
{
|
||||
arrowItem->setRotation( 90 );
|
||||
@@ -235,17 +237,17 @@ namespace glabels
|
||||
|
||||
QGraphicsSimpleTextItem *upItem = new QGraphicsSimpleTextItem( tr("Up") );
|
||||
upItem->setBrush( brush );
|
||||
upItem->setFont( QFont( upFontFamily, min*upScale, QFont::Bold ) );
|
||||
upItem->setPos( x0+w/2, y0+h/2 );
|
||||
upItem->setFont( QFont( upFontFamily, min.pt()*upScale, QFont::Bold ) );
|
||||
upItem->setPos( (x0+w/2).pt(), (y0+h/2).pt() );
|
||||
QRectF rect = upItem->boundingRect();
|
||||
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 );
|
||||
}
|
||||
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 );
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
@@ -68,9 +68,11 @@ namespace glabels
|
||||
private:
|
||||
void update();
|
||||
void clearScene();
|
||||
void drawPaper( double pw, double ph );
|
||||
void drawPaper( const libglabels::Distance& pw, const libglabels::Distance& ph );
|
||||
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();
|
||||
|
||||
|
||||
|
||||
+49
-43
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
@@ -59,7 +59,7 @@ namespace
|
||||
|
||||
const QColor gridLineColor( 192, 192, 192 );
|
||||
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 double markupLineWidthPixels = 1;
|
||||
@@ -235,8 +235,8 @@ glabels::View::zoomToFit()
|
||||
double wPixels = mScrollArea->maximumViewportSize().width();
|
||||
double hPixels = mScrollArea->maximumViewportSize().height();
|
||||
|
||||
double x_scale = ( wPixels - ZOOM_TO_FIT_PAD ) / mModel->w();
|
||||
double y_scale = ( hPixels - ZOOM_TO_FIT_PAD ) / mModel->h();
|
||||
double x_scale = ( wPixels - ZOOM_TO_FIT_PAD ) / mModel->w().pt();
|
||||
double y_scale = ( hPixels - ZOOM_TO_FIT_PAD ) / mModel->h().pt();
|
||||
double newZoom = min( x_scale, y_scale ) * PTS_PER_INCH / physicalDpiX();
|
||||
|
||||
// Limits
|
||||
@@ -279,7 +279,8 @@ glabels::View::setZoomReal( double zoom, bool zoomToFitFlag )
|
||||
/* Actual scale depends on DPI of display (assume DpiX == DpiY). */
|
||||
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. */
|
||||
mX0 = (width()/mScale - mModel->w()) / 2;
|
||||
@@ -354,11 +355,11 @@ glabels::View::mousePressEvent( QMouseEvent* event )
|
||||
QTransform transform;
|
||||
|
||||
transform.scale( mScale, mScale );
|
||||
transform.translate( mX0, mY0 );
|
||||
transform.translate( mX0.pt(), mY0.pt() );
|
||||
|
||||
QPointF pWorld = transform.inverted().map( event->posF() );
|
||||
double xWorld = pWorld.x();
|
||||
double yWorld = pWorld.y();
|
||||
libglabels::Distance xWorld = libglabels::Distance::pt( pWorld.x() );
|
||||
libglabels::Distance yWorld = libglabels::Distance::pt( pWorld.y() );
|
||||
|
||||
|
||||
if ( event->button() & Qt::LeftButton )
|
||||
@@ -523,11 +524,11 @@ glabels::View::mouseMoveEvent( QMouseEvent* event )
|
||||
QTransform transform;
|
||||
|
||||
transform.scale( mScale, mScale );
|
||||
transform.translate( mX0, mY0 );
|
||||
transform.translate( mX0.pt(), mY0.pt() );
|
||||
|
||||
QPointF pWorld = transform.inverted().map( event->posF() );
|
||||
double xWorld = pWorld.x();
|
||||
double yWorld = pWorld.y();
|
||||
libglabels::Distance xWorld = libglabels::Distance::pt( pWorld.x() );
|
||||
libglabels::Distance yWorld = libglabels::Distance::pt( pWorld.y() );
|
||||
|
||||
|
||||
/*
|
||||
@@ -624,11 +625,11 @@ glabels::View::mouseReleaseEvent( QMouseEvent* event )
|
||||
QTransform transform;
|
||||
|
||||
transform.scale( mScale, mScale );
|
||||
transform.translate( mX0, mY0 );
|
||||
transform.translate( mX0.pt(), mY0.pt() );
|
||||
|
||||
QPointF pWorld = transform.inverted().map( event->posF() );
|
||||
double xWorld = pWorld.x();
|
||||
double yWorld = pWorld.y();
|
||||
libglabels::Distance xWorld = libglabels::Distance::pt( pWorld.x() );
|
||||
libglabels::Distance yWorld = libglabels::Distance::pt( pWorld.y() );
|
||||
|
||||
|
||||
if ( event->button() & Qt::LeftButton )
|
||||
@@ -703,15 +704,16 @@ glabels::View::leaveEvent( QEvent* event )
|
||||
/// Handle resize motion
|
||||
///
|
||||
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();
|
||||
|
||||
/*
|
||||
* 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 );
|
||||
|
||||
/*
|
||||
@@ -723,8 +725,8 @@ glabels::View::handleResizeMotion( double xWorld, double yWorld )
|
||||
double x1 = 0.0;
|
||||
double y1 = 0.0;
|
||||
|
||||
double x2 = mResizeObject->w();
|
||||
double y2 = mResizeObject->h();
|
||||
double x2 = mResizeObject->w().pt();
|
||||
double y2 = mResizeObject->h().pt();
|
||||
|
||||
/*
|
||||
* Calculate new size
|
||||
@@ -793,20 +795,22 @@ glabels::View::handleResizeMotion( double xWorld, double yWorld )
|
||||
{
|
||||
case Handle::E:
|
||||
case Handle::W:
|
||||
mResizeObject->setWHonorAspect( w );
|
||||
mResizeObject->setWHonorAspect( libglabels::Distance::pt(w) );
|
||||
break;
|
||||
case Handle::N:
|
||||
case Handle::S:
|
||||
mResizeObject->setHHonorAspect( h );
|
||||
mResizeObject->setHHonorAspect( libglabels::Distance::pt(h) );
|
||||
break;
|
||||
default:
|
||||
mResizeObject->setSizeHonorAspect( w, h );
|
||||
mResizeObject->setSizeHonorAspect( libglabels::Distance::pt(w),
|
||||
libglabels::Distance::pt(h) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
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 )
|
||||
{
|
||||
case Handle::NW:
|
||||
x0 += x2 - mResizeObject->w();
|
||||
y0 += y2 - mResizeObject->h();
|
||||
x0 += x2 - mResizeObject->w().pt();
|
||||
y0 += y2 - mResizeObject->h().pt();
|
||||
break;
|
||||
case Handle::N:
|
||||
case Handle::NE:
|
||||
y0 += y2 - mResizeObject->h();
|
||||
y0 += y2 - mResizeObject->h().pt();
|
||||
break;
|
||||
case Handle::W:
|
||||
case Handle::SW:
|
||||
x0 += x2 - mResizeObject->w();
|
||||
x0 += x2 - mResizeObject->w().pt();
|
||||
break;
|
||||
defaule:
|
||||
break;
|
||||
@@ -832,7 +836,8 @@ glabels::View::handleResizeMotion( double xWorld, double yWorld )
|
||||
}
|
||||
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 );
|
||||
p0 = mResizeObject->matrix().map( p0 );
|
||||
p0 += QPointF( mResizeObject->x0(), mResizeObject->y0() );
|
||||
mResizeObject->setPosition( p0.x(), p0.y() );
|
||||
p0 += QPointF( mResizeObject->x0().pt(), mResizeObject->y0().pt() );
|
||||
mResizeObject->setPosition( libglabels::Distance::pt(p0.x()),
|
||||
libglabels::Distance::pt(p0.y()) );
|
||||
}
|
||||
|
||||
|
||||
@@ -866,7 +872,7 @@ glabels::View::paintEvent( QPaintEvent* event )
|
||||
|
||||
/* Transform. */
|
||||
painter.scale( mScale, mScale );
|
||||
painter.translate( mX0, mY0 );
|
||||
painter.translate( mX0.pt(), mY0.pt() );
|
||||
|
||||
/* Now draw from the bottom layer up. */
|
||||
drawBgLayer( &painter );
|
||||
@@ -899,7 +905,7 @@ glabels::View::drawBgLayer( QPainter* painter )
|
||||
if ( mModel->rotate() )
|
||||
{
|
||||
painter->rotate( -90 );
|
||||
painter->translate( -mModel->frame()->w(), 0 );
|
||||
painter->translate( -mModel->frame()->w().pt(), 0 );
|
||||
}
|
||||
painter->drawPath( mModel->frame()->path() );
|
||||
|
||||
@@ -917,7 +923,7 @@ glabels::View::drawBgLayer( QPainter* painter )
|
||||
if ( mModel->rotate() )
|
||||
{
|
||||
painter->rotate( -90 );
|
||||
painter->translate( -mModel->frame()->w(), 0 );
|
||||
painter->translate( -mModel->frame()->w().pt(), 0 );
|
||||
}
|
||||
painter->drawPath( mModel->frame()->path() );
|
||||
|
||||
@@ -933,10 +939,10 @@ glabels::View::drawGridLayer( QPainter* painter )
|
||||
{
|
||||
if ( mGridVisible )
|
||||
{
|
||||
double w = mModel->frame()->w();
|
||||
double h = mModel->frame()->h();
|
||||
libglabels::Distance w = mModel->frame()->w();
|
||||
libglabels::Distance h = mModel->frame()->h();
|
||||
|
||||
double x0, y0;
|
||||
libglabels::Distance x0, y0;
|
||||
if ( dynamic_cast<const libglabels::FrameRect*>( mModel->frame() ) )
|
||||
{
|
||||
x0 = gridSpacing;
|
||||
@@ -953,7 +959,7 @@ glabels::View::drawGridLayer( QPainter* painter )
|
||||
if ( mModel->rotate() )
|
||||
{
|
||||
painter->rotate( -90 );
|
||||
painter->translate( -mModel->frame()->w(), 0 );
|
||||
painter->translate( -mModel->frame()->w().pt(), 0 );
|
||||
}
|
||||
|
||||
painter->setClipPath( mModel->frame()->path() );
|
||||
@@ -962,14 +968,14 @@ glabels::View::drawGridLayer( QPainter* painter )
|
||||
pen.setCosmetic( true );
|
||||
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();
|
||||
@@ -993,7 +999,7 @@ glabels::View::drawMarkupLayer( QPainter* painter )
|
||||
if ( mModel->rotate() )
|
||||
{
|
||||
painter->rotate( -90 );
|
||||
painter->translate( -mModel->frame()->w(), 0 );
|
||||
painter->translate( -mModel->frame()->w().pt(), 0 );
|
||||
}
|
||||
|
||||
foreach( libglabels::Markup* markup, mModel->frame()->markups() )
|
||||
@@ -1035,7 +1041,7 @@ glabels::View::drawFgLayer( QPainter* painter )
|
||||
if ( mModel->rotate() )
|
||||
{
|
||||
painter->rotate( -90 );
|
||||
painter->translate( -mModel->frame()->w(), 0 );
|
||||
painter->translate( -mModel->frame()->w().pt(), 0 );
|
||||
}
|
||||
painter->drawPath( mModel->frame()->path() );
|
||||
|
||||
|
||||
+26
-25
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
@@ -56,7 +56,7 @@ namespace glabels
|
||||
signals:
|
||||
void contextMenuActivate();
|
||||
void zoomChanged();
|
||||
void pointerMoved( double x, double y );
|
||||
void pointerMoved( const libglabels::Distance& x, const libglabels::Distance& y );
|
||||
void pointerExited();
|
||||
void modeChanged();
|
||||
|
||||
@@ -128,7 +128,8 @@ namespace glabels
|
||||
// Private methods
|
||||
/////////////////////////////////////
|
||||
private:
|
||||
void handleResizeMotion( double xWorld, double yWorld );
|
||||
void handleResizeMotion( const libglabels::Distance& xWorld,
|
||||
const libglabels::Distance& yWorld );
|
||||
|
||||
void drawBgLayer( QPainter* painter );
|
||||
void drawGridLayer( QPainter* painter );
|
||||
@@ -169,41 +170,41 @@ namespace glabels
|
||||
Barcode
|
||||
};
|
||||
|
||||
QScrollArea* mScrollArea;
|
||||
QScrollArea* mScrollArea;
|
||||
|
||||
double mZoom;
|
||||
bool mZoomToFitFlag;
|
||||
double mScale;
|
||||
double mX0;
|
||||
double mY0;
|
||||
double mZoom;
|
||||
bool mZoomToFitFlag;
|
||||
double mScale;
|
||||
libglabels::Distance mX0;
|
||||
libglabels::Distance mY0;
|
||||
|
||||
bool mMarkupVisible;
|
||||
bool mGridVisible;
|
||||
bool mMarkupVisible;
|
||||
bool mGridVisible;
|
||||
|
||||
double mGridSpacing;
|
||||
double mGridSpacing;
|
||||
|
||||
LabelModel* mModel;
|
||||
LabelModel* mModel;
|
||||
|
||||
State mState;
|
||||
State mState;
|
||||
|
||||
/* ArrowSelectRegion state */
|
||||
bool mSelectRegionVisible;
|
||||
LabelRegion mSelectRegion;
|
||||
bool mSelectRegionVisible;
|
||||
LabelRegion mSelectRegion;
|
||||
|
||||
/* ArrowMove state */
|
||||
double mMoveLastX;
|
||||
double mMoveLastY;
|
||||
libglabels::Distance mMoveLastX;
|
||||
libglabels::Distance mMoveLastY;
|
||||
|
||||
/* ArrowResize state */
|
||||
LabelModelObject* mResizeObject;
|
||||
Handle* mResizeHandle;
|
||||
bool mResizeHonorAspect;
|
||||
LabelModelObject* mResizeObject;
|
||||
Handle* mResizeHandle;
|
||||
bool mResizeHonorAspect;
|
||||
|
||||
/* CreateDrag state */
|
||||
CreateType mCreateObjectType;
|
||||
LabelModelObject* mCreateObject;
|
||||
double mCreateX0;
|
||||
double mCreateY0;
|
||||
CreateType mCreateObjectType;
|
||||
LabelModelObject* mCreateObject;
|
||||
libglabels::Distance mCreateX0;
|
||||
libglabels::Distance mCreateY0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
*
|
||||
@@ -374,7 +374,7 @@ glabels::XmlLabelParser::parseShadowAttrs( const QDomElement &node, LabelModelOb
|
||||
|
||||
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
|
||||
*
|
||||
* Copyright (C) 2014 Jim Evins <evins@snaught.com>
|
||||
* Copyright (C) 2014-2016 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user