Fixed protractor tool

- Corrected and cleaned up rotation calculation
- Fixed button position/size issues (clickable area didn't correspond to the button image)
- Fixed tool flashing during resizing
- (new feature) Buttons now scale proportionally to the protractor when it is resized
- Everything is now drawn by default at a scale of 1 instead of 1.5
- Pen width set to 0 (i.e always 1 pixel thick regardless of zoom), to keep the old look & feel
- Scaled the marker tool image (.svg) to look like it did before without scaling it in code
- Removed debug messages

Tested on OS X, works fine.
preferencesAboutTextFull
Craig Watson 9 years ago
parent b5b8c72249
commit 7e96ab18eb
  1. 74
      resources/images/angleMarker.svg
  2. 260
      src/tools/UBGraphicsProtractor.cpp
  3. 9
      src/tools/UBGraphicsProtractor.h

@ -1,15 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="40.815px" height="19.919px" viewBox="-10.719 10.182 40.815 19.919" enable-background="new -10.719 10.182 40.815 19.919"
xml:space="preserve">
<path fill="#707070" stroke="#000000" stroke-miterlimit="3.8637" d="M21.02,11.062c4.547-0.003,8.234,3.68,8.236,8.227l0.002,1.854
c0.002,4.547-3.682,8.234-8.228,8.236l-22.729,0.014c-4.545,0.002-8.232-3.682-8.236-8.227v-1.854
c-0.004-4.546,3.681-8.234,8.227-8.236L21.02,11.062z"/>
<path fill="#FFFFFF" d="M17.315,23.464c0.201-0.002,0.363,0.156,0.363,0.35c0,0.191-0.162,0.35-0.36,0.35l-16.677,0.01
c-0.199,0-0.361-0.156-0.362-0.35c0-0.195,0.161-0.35,0.36-0.35L17.315,23.464z M17.315,19.871c0.199,0.001,0.361,0.157,0.361,0.351
s-0.162,0.351-0.361,0.351L0.639,20.583c-0.201,0-0.362-0.157-0.362-0.351s0.161-0.351,0.36-0.351L17.315,19.871z M17.311,16.28
c0.201,0,0.363,0.156,0.363,0.349c0,0.194-0.162,0.351-0.361,0.351l-16.678,0.01c-0.199,0.001-0.359-0.156-0.361-0.35
c0-0.192,0.162-0.351,0.361-0.351L17.311,16.28z"/>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Layer_1"
x="0px"
y="0px"
width="18.512798"
height="8.9038639"
viewBox="-10.719 10.182 18.512799 8.9038636"
enable-background="new -10.719 10.182 40.815 19.919"
xml:space="preserve"
inkscape:version="0.91 r13725"
sodipodi:docname="angleMarker.svg"><metadata
id="metadata11"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs9" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="640"
inkscape:window-height="480"
id="namedview7"
showgrid="false"
units="px"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:zoom="6.7132184"
inkscape:cx="20.123506"
inkscape:cy="9.7515518"
inkscape:window-x="747"
inkscape:window-y="144"
inkscape:window-maximized="0"
inkscape:current-layer="Layer_1" /><path
stroke-miterlimit="3.8637"
d="m 3.7691007,10.4123 c 2.094337,-0.0014 3.7925601,1.694999 3.7934813,3.789336 l 9.179e-4,0.853947 c 9.179e-4,2.094337 -1.6959202,3.79256 -3.7897967,3.793482 l -10.4689215,0.0065 c -2.0934159,9.09e-4 -3.7916387,-1.695919 -3.7934817,-3.789336 l 0,-0.853947 c -0.0018,-2.093876 1.6954599,-3.79256 3.7893363,-3.793482 l 10.468461,-0.0065 z"
id="path3"
inkscape:connector-curvature="0"
style="fill:#707070;stroke:#000000;stroke-width:0.46059754;stroke-miterlimit:3.86369991" /><path
d="m 2.0625868,16.12463 c 0.09258,-9.09e-4 0.1671969,0.07186 0.1671969,0.16121 0,0.08797 -0.074617,0.161209 -0.1658151,0.161209 l -7.6813853,0.0046 c -0.091659,0 -0.1662757,-0.07186 -0.1667364,-0.161208 0,-0.08982 0.074156,-0.161209 0.1658152,-0.161209 l 7.6809247,-0.0046 z m 0,-1.654927 c 0.091659,4.61e-4 0.1662756,0.07231 0.1662756,0.16167 0,0.08935 -0.074617,0.16167 -0.1662756,0.16167 l -7.6809247,0.0046 c -0.09258,0 -0.1667363,-0.07231 -0.1667363,-0.16167 0,-0.08935 0.074156,-0.16167 0.1658151,-0.16167 l 7.6818459,-0.0046 z m -0.00184,-1.654006 c 0.09258,0 0.1671968,0.07186 0.1671968,0.160749 0,0.08935 -0.074617,0.16167 -0.1662757,0.16167 l -7.6818459,0.0046 c -0.091659,4.61e-4 -0.1653545,-0.07186 -0.1662756,-0.161209 0,-0.08843 0.074617,-0.16167 0.1662756,-0.16167 l 7.6809248,-0.0042 z"
id="path5"
inkscape:connector-curvature="0"
style="fill:#ffffff" /></svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

@ -37,10 +37,8 @@
#include <QtWidgets/QGraphicsView>
//#include <math.h>
const QRectF UBGraphicsProtractor::sDefaultRect = QRectF(-175, -175, 350, 350);
const QRectF UBGraphicsProtractor::sDefaultRect = QRectF(-250, -250, 500, 500);
UBGraphicsProtractor::UBGraphicsProtractor()
: QGraphicsEllipseItem(sDefaultRect)
@ -82,9 +80,11 @@ UBGraphicsProtractor::UBGraphicsProtractor()
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly
setFlag(QGraphicsItem::ItemIsSelectable, false);
setScale(1.5);
mCloseSvgItem->setPos(closeButtonRect().topLeft());
mResetSvgItem->setPos(resetButtonRect().topLeft());
mResizeSvgItem->setPos(resizeButtonRect().topLeft());
mMarkerSvgItem->setPos(markerButtonRect().topLeft());
mRotateSvgItem->setPos(rotateButtonRect().topLeft());
}
@ -95,8 +95,11 @@ void UBGraphicsProtractor::paint(QPainter *painter, const QStyleOptionGraphicsIt
Q_UNUSED(styleOption);
Q_UNUSED(widget);
QPen pen_(drawColor());
pen_.setWidth(0); // Line width = 1 pixel regardless of scale / zoom
painter->setPen(pen_);
painter->setFont(QFont("Arial"));
painter->setPen(drawColor());
painter->setBrush(fillBrush());
painter->drawPie(QRectF(rect().center().x() - radius(), rect().center().y() - radius(), 2 * radius(), 2 * radius()), mStartAngle * 16, mSpan * 16);
paintGraduations(painter);
@ -195,12 +198,6 @@ void UBGraphicsProtractor::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
qreal angle = startLine.angleTo(currentLine);
qreal scaleFactor = currentLine.length()/startLine.length();
qreal mod_angle = 0;
if (angle>350)
{
mod_angle= angle - 360; // only for debugging
angle= angle - 360;
}
switch (mCurrentTool)
{
@ -210,17 +207,15 @@ void UBGraphicsProtractor::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
setStartAngle(mStartAngle * 16);
mPreviousMousePos = currentPoint;
//qDebug() << "UBGraphicsProtractor Rotate"<<"mStartAngle= "<<mStartAngle<<"angle = "<<angle<<"modulo_angle"<<mod_angle;
break;
case Resize :
prepareGeometryChange();
setPos(rect().center().x(), rect().center().y());
setScale(scaleFactor);
setPos(-rect().center().x(), -rect().center().y());
mScaleFactor *= scaleFactor;
setTransform(QTransform::fromTranslate(rect().center().x(), rect().center().y()), true);
setTransform(QTransform::fromScale(scaleFactor, scaleFactor), true);
setTransform(QTransform::fromTranslate(-rect().center().x(), -rect().center().y()), true);
mScaleFactor *= scaleFactor;
break;
case MoveMarker :
@ -346,70 +341,70 @@ qreal UBGraphicsProtractor::antiScale() const
QRectF UBGraphicsProtractor::resetButtonRect () const
{
//qreal antiSc = antiScale();
qreal antiSc = 1;
qreal refWidth = buttonSizeReference().width();
qreal width = mResetSvgItem->boundingRect().width();
qreal height = mResetSvgItem->boundingRect().height();
return QRectF(-refWidth * 7, -height/2.0, width, height);
if (buttonSizeReference().width() * antiSc <= buttonSizeReference().width() * 15)
return QRectF(-buttonSizeReference().width() * 7, -buttonSizeReference().height() * antiSc / 2,
buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc);
else
return QRectF(-buttonSizeReference().width() * antiSc / 2, -buttonSizeReference().height() * antiSc / 2,
buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc);
// Note: these hardcoded position values make it impossible
// to use setScale() on the buttons without affecting their
// relative position on the tool.
}
QRectF UBGraphicsProtractor::closeButtonRect () const
{
//qreal antiSc = antiScale();
qreal antiSc = 1;
qreal refWidth = buttonSizeReference().width();
qreal width = mCloseSvgItem->boundingRect().width();
qreal height = mCloseSvgItem->boundingRect().height();
//qDebug() << "UBGraphicsProtractor closeButtonRect"<<"antiSc = "<<antiSc;
return QRectF(-refWidth * 9, -height/2.0, width, height);
}
if (buttonSizeReference().width() * antiSc <= buttonSizeReference().width() * 2)
return QRectF(-buttonSizeReference().width() * 9, -buttonSizeReference().height() * antiSc / 2,
buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc);
else if (buttonSizeReference().width() * antiSc <= buttonSizeReference().width() * 15)
return QRectF(-buttonSizeReference().width() * 7 -buttonSizeReference().width() * antiSc, -buttonSizeReference().height() * antiSc / 2,
buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc);
else
return QRectF(-buttonSizeReference().width() * antiSc / 2, -buttonSizeReference().height() * antiSc / 2,
buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc);
QRectF UBGraphicsProtractor::resizeButtonRect () const
{
qreal refWidth = buttonSizeReference().width();
qreal width = mResizeSvgItem->boundingRect().width();
qreal height = mResizeSvgItem->boundingRect().height();
return QRectF(refWidth * 8, -height/2.0, width, height);
}
QRectF UBGraphicsProtractor::resizeButtonRect () const
QRectF UBGraphicsProtractor::rotateButtonRect () const
{
//qreal antiSc = antiScale();
qreal antiSc = 1;
qreal refWidth = buttonSizeReference().width();
qreal width = mRotateSvgItem->boundingRect().width();
qreal height = mRotateSvgItem->boundingRect().height();
return QRectF(refWidth * 5.5, -refWidth * 5, width, height);
if (buttonSizeReference().width() * antiSc <= buttonSizeReference().width() * 15)
return QRectF(buttonSizeReference().width() * 8, -buttonSizeReference().height() * antiSc / 2,
buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc);
else
{
mResizeSvgItem->setZValue(zValue()+10);
return QRectF(-buttonSizeReference().width() * antiSc / 2, -buttonSizeReference().height() * antiSc / 2,
buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc);
}
}
QRectF UBGraphicsProtractor::markerButtonRect () const
{
qreal width = mMarkerSvgItem->boundingRect().width();
qreal height = mMarkerSvgItem->boundingRect().height();
return QRectF(radius() + 3, -height/2, width, height);
}
void UBGraphicsProtractor::paintGraduations(QPainter *painter)
{
painter->save();
const int tenDegreeGraduationLength = 15;
const int fiveDegreeGraduationLength = 10;
const int oneDegreeGraduationLength = 5;
const int tenDegreeGraduationLength = 22;
const int fiveDegreeGraduationLength = 15;
const int oneDegreeGraduationLength = 7;
QFont font1 = painter->font();
#ifdef Q_OS_OSX
font1.setPointSizeF(font1.pointSizeF() - 3);
// TODO: remove this (?)
font1.setPointSizeF(font1.pointSizeF());
font1.setWeight(QFont::Thin);
#endif
QFontMetricsF fm1(font1);
@ -429,7 +424,8 @@ void UBGraphicsProtractor::paintGraduations(QPainter *painter)
qreal co = cos(((qreal)angle + mStartAngle) * PI/180);
qreal si = sin(((qreal)angle + mStartAngle) * PI/180);
if (0 == angle % 90)
painter->drawLine(QLineF(QPointF(center.x(), center.y()), QPointF(center.x() + co*tenDegreeGraduationLength, center.y() - si*tenDegreeGraduationLength)));
painter->drawLine(QLineF(QPointF(center.x(), center.y()),
QPointF(center.x() + co*tenDegreeGraduationLength, center.y() - si*tenDegreeGraduationLength)));
//external arc
painter->drawLine(QLineF(QPointF(center.x()+ rad*co, center.y() - rad*si),
@ -468,145 +464,34 @@ void UBGraphicsProtractor::paintButtons(QPainter *painter)
{
Q_UNUSED(painter);
qreal co = cos(mStartAngle * PI/180); // cos(rad)
qreal si = sin(mStartAngle * PI/180); //sin(rad)
if (mShowButtons)
{
qreal scale = buttonSizeReference().width() / mCloseSvgItem->boundingRect().width();
/*qDebug() << "UBGraphicsProtractor paint()"
<<"closeButtonRect_Topleft="<<closeButtonRect().topLeft()
<<"mStartAngle="<<mStartAngle
<<"mCurrentAngle="<<mCurrentAngle
<<"rect_center = "<<rect().center();
*/
// The buttons (close, reset, resize & rotate) are rotated around the center
// of the protractor, to follow it as it is rotated.
// As coordinates are local to each QGraphicsItem, the position of the rotation
// center relative to each button is the inverse of that button's position.
// Determine and apply the coordinates of the close button object.
//---------------------------------------------------------------
qreal pos_close_x = closeButtonRect().topLeft().x()* co;
qreal pos_close_y = qAbs(closeButtonRect().topLeft().x()) * si + closeButtonRect().topLeft().y();
qDebug() << "pos_close_x ="<<pos_close_x<<"pos_close_y ="<<pos_close_y<<"cos"<<co<<"sin"<<si;
mCloseSvgItem->setPos(pos_close_x,pos_close_y);
mCloseSvgItem->resetTransform();
//mCloseSvgItem->translate(-closeButtonRect().left(),-closeButtonRect().top()); --
mCloseSvgItem->setPos(-pos_close_x,-pos_close_y);
//mCloseSvgItem->setPos(-closeButtonRect().left(),-closeButtonRect().top());
//mCloseSvgItem->rotate(-mStartAngle); --
mCloseSvgItem->setTransformOriginPoint(closeButtonRect().topLeft() * -1);
mCloseSvgItem->setRotation(rotation() - mStartAngle);
//mCloseSvgItem->translate(closeButtonRect().left(), closeButtonRect().top()); --
mCloseSvgItem->setPos(pos_close_x, pos_close_y);
//mCloseSvgItem->setPos(closeButtonRect().left(), closeButtonRect().top());
//mCloseSvgItem->scale(scale * antiSc, scale * antiSc);//this do not impact the bounding box of thr svg item...
mCloseSvgItem->setScale(scale );//this do not impact the bounding box of thr svg item...
// Determine and apply the position on the reset button object.
//------------------------------------------------------------
qreal pos_reset_x = resetButtonRect().topLeft().x()* co;
qreal pos_reset_y = qAbs(resetButtonRect().topLeft().x()) * si + resetButtonRect().topLeft().y();
mResetSvgItem->setPos(pos_reset_x,pos_reset_y);
//mResetSvgItem->setPos(resetButtonRect().topLeft() + rect().center());
mResetSvgItem->resetTransform();
//mResetSvgItem->translate(-resetButtonRect().left(), -resetButtonRect().top());--
mResetSvgItem->setPos(-pos_reset_x, -pos_reset_y);
//mResetSvgItem->rotate(-mStartAngle);--
mResetSvgItem->setRotation(-mStartAngle);
mResetSvgItem->setTransformOriginPoint(resetButtonRect().topLeft() * -1);
mResetSvgItem->setRotation(rotation() - mStartAngle);
//mResetSvgItem->translate(resetButtonRect().left(), resetButtonRect().top());--
mResetSvgItem->setPos(pos_reset_x, pos_reset_y);
mResizeSvgItem->setTransformOriginPoint(resizeButtonRect().topLeft() * -1);
mResizeSvgItem->setRotation(rotation() - mStartAngle);
//mResetSvgItem->scale(scale * antiSc, scale * antiSc);//this do not impact the bounding box of thr svg item...
mResetSvgItem->setScale(scale );//this do not impact the bounding box of thr svg item...
// Determine and apply the position on the resize button object.
//------------------------------------------------------------
qreal pos_resize_x = resizeButtonRect().topLeft().x()* co;
qreal pos_resize_y = -(resizeButtonRect().topLeft().x()) * si + resizeButtonRect().topLeft().y();
qDebug() << "pos_resize_x ="<<pos_resize_x<<"pos_resize_y ="<<pos_resize_y;
// mResizeSvgItem->setPos(resizeButtonRect().topLeft() + rect().center());
mResizeSvgItem->setPos(pos_resize_x,pos_resize_y);
mResizeSvgItem->resetTransform();
mResizeSvgItem->setPos(-pos_resize_x, -pos_resize_y);
//mResizeSvgItem->rotate(-mStartAngle);--
mResizeSvgItem->setRotation(-mStartAngle);
//mResizeSvgItem->translate(-resizeButtonRect().left(), -resizeButtonRect().top());--
mResizeSvgItem->setPos(pos_resize_x, pos_resize_y);
// mResizeSvgItem->scale(scale * antiSc, scale * antiSc);//this do not impact the bounding box of thr svg item...
mResizeSvgItem->setScale(scale);//this do not impact the bounding box of thr svg item...
// Determine and apply the position on the rotate button object.
//--------------------------------------------------------------
qreal qPow_x = qPow(rotateButtonRect().topLeft().x(),2);
qreal qPow_y = qPow(rotateButtonRect().topLeft().y(),2);
qreal module_rotate_pos = qSqrt(qPow_x + qPow_y);
qreal arg_rotate_pos = (qAtan2(rotateButtonRect().topLeft().y(), rotateButtonRect().topLeft().x())); //argument in radian
qreal co_r = cos(-mStartAngle * PI/180 + arg_rotate_pos); // cos(rad)
qreal si_r = sin(-mStartAngle * PI/180 + arg_rotate_pos); //sin(rad)
qreal pos_rotate_x = (module_rotate_pos * co_r) ;
qreal pos_rotate_y = (module_rotate_pos * si_r) ;
mRotateSvgItem->setPos(pos_rotate_x,pos_rotate_y);
//mRotateSvgItem->setPos(rotateButtonRect().topLeft() + rect().center()); --
mRotateSvgItem->resetTransform();
mRotateSvgItem->setPos(-pos_rotate_x, -pos_rotate_y);
//mRotateSvgItem->rotate(-mStartAngle);--
mRotateSvgItem->setRotation(-mStartAngle);
mRotateSvgItem->setPos(pos_rotate_x, pos_rotate_y);
//mRotateSvgItem->scale(scale, scale);//this do not impact the bounding box of thr svg item...
mRotateSvgItem->setScale(scale);//this do not impact the bounding box of thr svg item...
//qDebug()<<"UBGraphicsProtractor scale()"<<"scale ="<<scale<<"antiSc = "<<antiSc <<"mScaleFactor ="<<mScaleFactor;
mRotateSvgItem->setTransformOriginPoint(rotateButtonRect().topLeft() * -1);
mRotateSvgItem->setRotation(rotation() - mStartAngle);
}
qreal scale = markerSizeReference().width()/mMarkerSvgItem->boundingRect().width();
qreal pos_marker_x = markerButtonRect().topLeft().x()* co;
qreal pos_marker_y = -(markerButtonRect().topLeft().x()) * si + markerButtonRect().topLeft().y();
// mMarkerSvgItem->setPos(markerButtonRect().topLeft() + rect().center()); --
mMarkerSvgItem->setPos(pos_marker_x, pos_marker_y);
mMarkerSvgItem->resetTransform();
//mMarkerSvgItem->setPos(-markerButtonRect().left(), -markerButtonRect().top());--
mMarkerSvgItem->setPos(-pos_marker_x, -pos_marker_y);
//mMarkerSvgItem->rotate(- mStartAngle - mCurrentAngle);
mMarkerSvgItem->setRotation(- mStartAngle - mCurrentAngle);
mMarkerSvgItem->setPos(pos_marker_x, pos_marker_y);
//mMarkerSvgItem->setPos(markerButtonRect().left(), markerButtonRect().top());--
//mMarkerSvgItem->scale(scale, scale);//this do not impact the bounding box of thr svg item...
mMarkerSvgItem->setScale( scale);//this do not impact the bounding box of thr svg item...
mMarkerSvgItem->setTransformOriginPoint(markerButtonRect().topLeft() * -1);
mMarkerSvgItem->setRotation(rotation() - mStartAngle - mCurrentAngle);
mCloseSvgItem->setVisible(mShowButtons);
mResetSvgItem->setVisible(mShowButtons);
mResizeSvgItem->setVisible(mShowButtons);
mRotateSvgItem->setVisible(mShowButtons);
mMarkerSvgItem->setVisible(true);
}
@ -670,26 +555,25 @@ UBGraphicsProtractor::Tool UBGraphicsProtractor::toolFromPos(QPointF pos)
t.rotate(mCurrentAngle);
QPointF p2 = t.map(pos);
qDebug() << "UBGraphicsProtractor toolFromPos()"<<"p1="<<p1<<"p2 ="<<p2<<"closeButtonRect_topLeft=";
qDebug() <<"closeButtonRect_topleft"<<closeButtonRect().topLeft()<<"closeButtonRect_width"<<closeButtonRect().width();
if (resizeButtonRect().contains(p1.x(),p1.y()))
//if (resizeButtonRect().contains(p1))
return Resize;
else if (closeButtonRect().contains(p1))
{
qDebug() << "UBGraphicsProtractor toolFromPos()"<<"closeButtonRect_Topleft="<<closeButtonRect().topLeft();
return Close;
}
else if (resetButtonRect().contains(p1))
return Reset;
else if (rotateButtonRect().contains(p1))
return Rotate;
else if (markerButtonRect().contains(p2))
return MoveMarker;
else if (line.length() <= radius())
return Move;
else
return None;
}

@ -28,11 +28,9 @@
#ifndef UBGRAPHICSPROTRACTOR_H_
#define UBGRAPHICSPROTRACTOR_H_
//#include <QtGui>
#include <QtWidgets>
#include <QtWidgets/QGraphicsItem>
#include <QtWidgets/QGraphicsView>
#include <QtSvg>
#include "core/UB.h"
@ -99,9 +97,10 @@ class UBGraphicsProtractor : public UBAbstractDrawRuler, public QGraphicsEllipse
QRectF closeButtonRect () const;
QRectF resizeButtonRect () const;
QRectF rotateButtonRect () const{return QRectF(buttonSizeReference().width() * 5.5, -buttonSizeReference().width() * 5, buttonSizeReference().width(), buttonSizeReference().width());}
QRectF markerButtonRect () const{return QRectF(radius() + 3, -markerSizeReference().height() / 2 , markerSizeReference().width(), markerSizeReference().height());}
inline qreal radius () const{return rect().height() / 2 - 20;}
QRectF rotateButtonRect () const;
QRectF markerButtonRect () const;
inline qreal radius () const{return rect().height() / 2 - 20;}
// Members
QPointF mPreviousMousePos;

Loading…
Cancel
Save