16#include <QPainterPath>
20#include <klocalizedstring.h>
34#define INNER_RADIUS 50
38 m_resolution(image->xRes()),
43 QGridLayout* optionLayout =
new QGridLayout(
this);
44 Q_CHECK_PTR(optionLayout);
45 optionLayout->setContentsMargins(0, 0, 0, 0);
47 optionLayout->addWidget(
new QLabel(i18n(
"Distance:"),
this), 0, 0);
48 optionLayout->addWidget(
new QLabel(i18n(
"Angle:"),
this), 1, 0);
55 m_angleLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
58 KComboBox* unitBox =
new KComboBox(
this);
63 optionLayout->addWidget(unitBox, 0, 2);
64 optionLayout->addItem(
new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::Expanding), 2, 0, 1, 2);
110 qreal lineAngle =
normalizeAngle(std::atan2(lineVector.y(), lineVector.x()));
112 const qreal ANGLE_BETWEEN_CONSTRAINED_LINES = (2 *
M_PI) / 24;
114 const quint32 constrainedLineIndex =
static_cast<quint32
>((lineAngle / ANGLE_BETWEEN_CONSTRAINED_LINES) + 0.5);
115 const qreal constrainedLineAngle = constrainedLineIndex * ANGLE_BETWEEN_CONSTRAINED_LINES;
119 const QPointF constrainedLineVector(lineLength * std::cos(constrainedLineAngle), lineLength * std::sin(constrainedLineAngle));
121 const QPointF result =
m_startPos + constrainedLineVector;
129 QPen pen(Qt::SolidLine);
132 QPainterPath elbowPath;
139 bool switch_elbow = QPointF::dotProduct(diff, offset) > 0.0;
151 int spanAngle = switch_elbow ? -
angle() :
angle();
159 spanAngle = -spanAngle;
162 elbowPath.arcTo(rectangle, startAngle, spanAngle);
167 converter.
zoom(&sx, &sy);
177 QString message = i18nc(
"%1=distance %2=unit of distance %3=angle in degrees",
"%1 %2\n%3°",
180 QString::number(
angle(),
'f',1));
207 if (event->
modifiers() & Qt::AltModifier) {
211 }
else if(event->
modifiers() & Qt::ShiftModifier){
217 if(!(event->
modifiers() & Qt::ControlModifier)) {
246 specialSpacer->setObjectName(
"SpecialSpacer");
247 specialSpacer->setFixedSize(0, 0);
260 return acos(qAbs(dot)) / (2*
M_PI)*360;
274 return bound.normalized();
qreal distance(const QPointF &p1, const QPointF &p2)
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void updateCanvas(const QRectF &rc) override
KisViewManager * viewManager() const
void showFloatingMessage(const QString &message, const QIcon &icon, int timeout=4500, KisFloatingMessage::Priority priority=KisFloatingMessage::Medium, int alignment=Qt::AlignCenter|Qt::TextWordWrap)
shows a floating message in the top right corner of the canvas
Qt::KeyboardModifiers modifiers() const
static KoUnit fromListForUi(int index, ListOptions listOptions=ListAll, qreal factor=1.0)
QString symbol() const
Get the symbol string of the unit.
static QStringList listOfUnitNameForUi(ListOptions listOptions=ListAll)
Returns the list of unit types for the UI, controlled with the given listOptions.
qreal toUserValue(qreal ptValue, bool rounding=true) const
int indexInListForUi(ListOptions listOptions=ListAll) const
virtual void zoom(qreal *zoomX, qreal *zoomY) const
std::enable_if< std::is_floating_point< T >::value, T >::type normalizeAngle(T a)
QString KRITAIMAGE_EXPORT prettyFormatReal(qreal value)