fixed issue with ruler and compass. They show now the correct radius information

preferencesAboutTextFull
Claudio Valerio 12 years ago
parent c57d086ed7
commit b84294dfc0
  1. 1
      src/frameworks/UBFileSystemUtils.cpp
  2. 9
      src/tools/UBGraphicsCompass.cpp
  3. 2
      src/tools/UBGraphicsCompass.h
  4. 3
      src/tools/UBGraphicsRuler.cpp

@ -397,7 +397,6 @@ QString UBFileSystemUtils::lastPathComponent(const QString& path)
QString UBFileSystemUtils::mimeTypeFromFileName(const QString& fileName) QString UBFileSystemUtils::mimeTypeFromFileName(const QString& fileName)
{ {
Q_ASSERT(fileName.length());
QString ext = extension(fileName); QString ext = extension(fileName);
if (ext == "xls" || ext == "xlsx") return "application/msexcel"; if (ext == "xls" || ext == "xlsx") return "application/msexcel";

@ -51,6 +51,13 @@ UBGraphicsCompass::UBGraphicsCompass()
, mDrewCenterCross(false) , mDrewCenterCross(false)
{ {
setRect(sDefaultRect); setRect(sDefaultRect);
setBrush(QBrush(Qt::red));
//TODO claudio: remove code duplication
QDesktopWidget* desktop = UBApplication::desktop();
int dpiCommon = (desktop->physicalDpiX() + desktop->physicalDpiY()) / 2;
mPixelsPerMillimeter = qRound(dpiCommon / 25.4f);
setFlag(QGraphicsItem::ItemIsMovable, true); setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag(QGraphicsItem::ItemIsSelectable, true); setFlag(QGraphicsItem::ItemIsSelectable, true);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
@ -399,7 +406,7 @@ void UBGraphicsCompass::paintAngleDisplay(QPainter *painter)
void UBGraphicsCompass::paintRadiusDisplay(QPainter *painter) void UBGraphicsCompass::paintRadiusDisplay(QPainter *painter)
{ {
qreal radiusInCentimeters = rect().width() / (sPixelsPerMillimeter * 10); qreal radiusInCentimeters = rect().width() / (mPixelsPerMillimeter * 10);
QString format = rect().width() >= sDisplayRadiusUnitMinLength ? "%1 cm" : "%1"; QString format = rect().width() >= sDisplayRadiusUnitMinLength ? "%1 cm" : "%1";
QString radiusText = QString(format).arg(radiusInCentimeters, 0, 'f', 1); QString radiusText = QString(format).arg(radiusInCentimeters, 0, 'f', 1);

@ -113,6 +113,7 @@ class UBGraphicsCompass: public QObject, public QGraphicsRectItem, public UBItem
QGraphicsSvgItem* mResizeSvgItem; QGraphicsSvgItem* mResizeSvgItem;
qreal mAntiScaleRatio; qreal mAntiScaleRatio;
bool mDrewCenterCross; bool mDrewCenterCross;
int mPixelsPerMillimeter;
// Constants // Constants
static const QRect sDefaultRect; static const QRect sDefaultRect;
@ -130,7 +131,6 @@ class UBGraphicsCompass: public QObject, public QGraphicsRectItem, public UBItem
static const QColor sDarkBackgroundEdgeFillColor; static const QColor sDarkBackgroundEdgeFillColor;
static const QColor sDarkBackgroundMiddleFillColor; static const QColor sDarkBackgroundMiddleFillColor;
static const QColor sDarkBackgroundDrawColor; static const QColor sDarkBackgroundDrawColor;
static const int sPixelsPerMillimeter = 5;
static const int sDisplayRadiusOnPencilArmMinLength = 300; static const int sDisplayRadiusOnPencilArmMinLength = 300;
static const int sDisplayRadiusUnitMinLength = 250; static const int sDisplayRadiusUnitMinLength = 250;
}; };

@ -164,6 +164,9 @@ void UBGraphicsRuler::paintGraduations(QPainter *painter)
const int millimetersPerCentimeter = 10; const int millimetersPerCentimeter = 10;
const int millimetersPerHalfCentimeter = 5; const int millimetersPerHalfCentimeter = 5;
qDebug() << sPixelsPerMillimeter;
painter->save(); painter->save();
painter->setFont(font()); painter->setFont(font());
QFontMetricsF fontMetrics(painter->font()); QFontMetricsF fontMetrics(painter->font());

Loading…
Cancel
Save