"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "plugins/tools/basictools/kis_tool_measure.cc" between
krita-5.1.3.tar.xz and krita-5.1.4.tar.xz

About: Krita is a painting program offering art tools for everyone (concept art, texture and matte painters, illustrations and comics).

kis_tool_measure.cc  (krita-5.1.3.tar.xz):kis_tool_measure.cc  (krita-5.1.4.tar.xz)
skipping to change at line 16 skipping to change at line 16
*/ */
#include "kis_tool_measure.h" #include "kis_tool_measure.h"
#include <math.h> #include <math.h>
#include <QPainter> #include <QPainter>
#include <QLayout> #include <QLayout>
#include <QWidget> #include <QWidget>
#include <QLabel> #include <QLabel>
#include <QPainterPath>
#include <kcombobox.h> #include <kcombobox.h>
#include <kis_debug.h> #include <kis_debug.h>
#include <klocalizedstring.h> #include <klocalizedstring.h>
#include "kis_image.h" #include "kis_image.h"
#include "kis_cursor.h" #include "kis_cursor.h"
#include "KoPointerEvent.h" #include "KoPointerEvent.h"
#include "KoCanvasBase.h" #include "KoCanvasBase.h"
#include <KoViewConverter.h> #include <KoViewConverter.h>
#include "krita_utils.h" #include "krita_utils.h"
#include "kis_floating_message.h" #include "kis_floating_message.h"
#include "kis_canvas2.h" #include "kis_canvas2.h"
#include "KisViewManager.h" #include "KisViewManager.h"
#include <KisOptimizedBrushOutline.h>
#define INNER_RADIUS 50 #define INNER_RADIUS 50
KisToolMeasureOptionsWidget::KisToolMeasureOptionsWidget(QWidget* parent, double resolution) KisToolMeasureOptionsWidget::KisToolMeasureOptionsWidget(QWidget* parent, double resolution)
: QWidget(parent), : QWidget(parent),
m_resolution(resolution), m_resolution(resolution),
m_unit(KoUnit::Pixel) m_unit(KoUnit::Pixel)
{ {
m_distance = 0.0; m_distance = 0.0;
QGridLayout* optionLayout = new QGridLayout(this); QGridLayout* optionLayout = new QGridLayout(this);
skipping to change at line 96 skipping to change at line 99
: KisTool(canvas, KisCursor::crossCursor()) : KisTool(canvas, KisCursor::crossCursor())
{ {
} }
KisToolMeasure::~KisToolMeasure() KisToolMeasure::~KisToolMeasure()
{ {
} }
void KisToolMeasure::paint(QPainter& gc, const KoViewConverter &converter) void KisToolMeasure::paint(QPainter& gc, const KoViewConverter &converter)
{ {
qreal sx, sy;
converter.zoom(&sx, &sy);
gc.scale(sx / currentImage()->xRes(), sy / currentImage()->yRes());
QPen old = gc.pen(); QPen old = gc.pen();
QPen pen(Qt::SolidLine); QPen pen(Qt::SolidLine);
gc.setPen(pen); gc.setPen(pen);
gc.drawLine(m_startPos, m_endPos); QPainterPath elbowPath;
elbowPath.moveTo(m_endPos);
if (deltaX() >= 0) elbowPath.lineTo(m_startPos);
gc.drawLine(QPointF(m_startPos.x(), m_startPos.y()), QPointF(m_startPos.
x() + INNER_RADIUS, m_startPos.y())); if (deltaX() >= 0) {
else elbowPath.lineTo(QPointF(m_startPos.x() + INNER_RADIUS, m_startPos.y()))
gc.drawLine(QPointF(m_startPos.x(), m_startPos.y()), QPointF(m_startPos. ;
x() - INNER_RADIUS, m_startPos.y())); } else {
elbowPath.lineTo(QPointF(m_startPos.x() - INNER_RADIUS, m_startPos.y()))
;
}
if (distance() >= INNER_RADIUS) { if (distance() >= INNER_RADIUS) {
QRectF rectangle(m_startPos.x() - INNER_RADIUS, m_startPos.y() - INNER_R ADIUS, 2*INNER_RADIUS, 2*INNER_RADIUS); QRectF rectangle(m_startPos.x() - INNER_RADIUS, m_startPos.y() - INNER_R ADIUS, 2*INNER_RADIUS, 2*INNER_RADIUS);
int startAngle = (deltaX() >= 0) ? 0 : 180 * 16; int startAngle = (deltaX() >= 0) ? 0 : 180;
int spanAngle; int spanAngle;
if ((deltaY() >= 0 && deltaX() >= 0) || (deltaY() < 0 && deltaX() < 0)) if ((deltaY() >= 0 && deltaX() >= 0) || (deltaY() < 0 && deltaX() < 0))
spanAngle = static_cast<int>(angle() * 16); {
else spanAngle = static_cast<int>(angle());
spanAngle = static_cast<int>(-angle() * 16); } else {
gc.drawArc(rectangle, startAngle, spanAngle); spanAngle = static_cast<int>(-angle());
}
elbowPath.arcTo(rectangle, startAngle, spanAngle);
} }
// The opengl renderer doesn't take the QPainter's transform, so the path is
scaled here
qreal sx, sy;
converter.zoom(&sx, &sy);
QTransform transf;
transf.scale(sx / currentImage()->xRes(), sy / currentImage()->yRes());
paintToolOutline(&gc, transf.map(elbowPath));
gc.setPen(old); gc.setPen(old);
} }
void KisToolMeasure::showDistanceAngleOnCanvas() void KisToolMeasure::showDistanceAngleOnCanvas()
{ {
KisCanvas2 *kisCanvas = qobject_cast<KisCanvas2*>(canvas()); KisCanvas2 *kisCanvas = qobject_cast<KisCanvas2*>(canvas());
QString message = i18nc("%1=distance %2=unit of distance %3=angle in degrees ", "%1 %2\n%3°", QString message = i18nc("%1=distance %2=unit of distance %3=angle in degrees ", "%1 %2\n%3°",
m_optionsWidget->m_distanceLabel->text(), m_optionsWidget->m_distanceLabel->text(),
m_optionsWidget->m_unit.symbol(), m_optionsWidget->m_unit.symbol(),
QString::number(angle(),'f',1)); QString::number(angle(),'f',1));
kisCanvas->viewManager()->showFloatingMessage(message, QIcon(), 2000, KisFlo atingMessage::High); kisCanvas->viewManager()->showFloatingMessage(message, QIcon(), 2000, KisFlo atingMessage::High);
 End of changes. 7 change blocks. 
19 lines changed or deleted 31 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)