diff --git a/krita/plugins/tools/selectiontools/kis_tool_select_brush.cc b/krita/plugins/tools/selectiontools/kis_tool_select_brush.cc index 36ac8083a7..65460daa82 100644 --- a/krita/plugins/tools/selectiontools/kis_tool_select_brush.cc +++ b/krita/plugins/tools/selectiontools/kis_tool_select_brush.cc @@ -1,271 +1,245 @@ /* * kis_tool_select_brush.cc -- part of Krita * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include #include #include #include #include #include #include #include #include USING_PART_OF_NAMESPACE_EIGEN #include "kis_cursor.h" #include "kis_canvas2.h" #include "kis_painter.h" #include "kis_pixel_selection.h" #include "kis_image.h" #include "kis_selection_options.h" #include "kis_tool_select_brush.h" #include "kis_selection_tool_helper.h" #include "kis_paintop_preset.h" KisToolSelectBrush::KisToolSelectBrush(KoCanvasBase * canvas) : KisToolSelectBase(canvas, KisCursor::load("tool_brush_selection_cursor.png", 6, 6)), m_brushRadius(15), m_dragging(false) { resetSelection(); } KisToolSelectBrush::~KisToolSelectBrush() { } QWidget* KisToolSelectBrush::createOptionWidget() { KisToolSelectBase::createOptionWidget(); m_optWidget->setWindowTitle(i18n("Brush Selection")); QHBoxLayout* fl = new QHBoxLayout(); QLabel * lbl = new QLabel(i18n("Brush size:"), m_optWidget); fl->addWidget(lbl); KIntNumInput * input = new KIntNumInput(m_optWidget); input->setRange(0, 500, 5); input->setValue(m_brushRadius*2); fl->addWidget(input); connect(input, SIGNAL(valueChanged(int)), this, SLOT(slotSetBrushSize(int))); QVBoxLayout* l = dynamic_cast(m_optWidget->layout()); Q_ASSERT(l); l->insertLayout(1, fl); m_optWidget->disableSelectionModeOption(); return m_optWidget; } void KisToolSelectBrush::paint(QPainter& gc, const KoViewConverter &converter) { Q_UNUSED(converter); - - //convert to view coordinates - QPainterPath toolOutline; - for(int i=0; ibutton() == Qt::LeftButton) { m_dragging = true; m_lastPoint=convertToPixelCoord(e->point); addPoint(convertToPixelCoord(e->point)); e->accept(); } else if (e->button()==Qt::RightButton || e->button()==Qt::MidButton) { m_dragging = false; resetSelection(); e->accept(); } } void KisToolSelectBrush::mouseMoveEvent(KoPointerEvent *e) { if (m_dragging) { // this gives better performance if(Vector2f((m_lastPoint-e->point).x(), (m_lastPoint-e->point).y()).norm()point)+smallRandomPoint); } } void KisToolSelectBrush::mouseReleaseEvent(KoPointerEvent *e) { if (m_dragging && e->button() == Qt::LeftButton) { m_dragging = false; applyToSelection(m_selection); e->accept(); } } void KisToolSelectBrush::activate(bool temprorary) { KisToolSelectBase::activate(temprorary); } void KisToolSelectBrush::deactivate() { resetSelection(); KisToolSelectBase::deactivate(); } void KisToolSelectBrush::slotSetBrushSize(int size) { m_brushRadius = ((qreal) size)/2.0; } void KisToolSelectBrush::applyToSelection(const QPainterPath &selection) { KisCanvas2 * kisCanvas = dynamic_cast(canvas()); Q_ASSERT(kisCanvas); if (!kisCanvas) return; KisSelectionToolHelper helper(kisCanvas, currentNode(), i18n("Brush Selection")); if (m_selectionMode == PIXEL_SELECTION) { KisPixelSelectionSP tmpSel = new KisPixelSelection(); KisPainter painter(tmpSel); painter.setBounds(currentImage()->bounds()); painter.setPaintColor(KoColor(Qt::black, tmpSel->colorSpace())); painter.setFillStyle(KisPainter::FillStyleForegroundColor); painter.setStrokeStyle(KisPainter::StrokeStyleNone); painter.setAntiAliasPolygonFill(m_optWidget->antiAliasSelection()); painter.setOpacity(OPACITY_OPAQUE); painter.setPaintOpPreset(currentPaintOpPreset(), currentImage()); painter.setCompositeOp(tmpSel->colorSpace()->compositeOp(COMPOSITE_OVER)); painter.fillPainterPath(selection); QUndoCommand* cmd = helper.selectPixelSelection(tmpSel, m_selectAction); canvas()->addCommand(cmd); resetSelection(); } } void KisToolSelectBrush::resetSelection() { updateCanvasPixelRect(m_selection.boundingRect()); m_dragging=false; m_selection = QPainterPath(); } void KisToolSelectBrush::addPoint(const QPointF& point) { QPainterPath ellipse; ellipse.addEllipse(point, m_brushRadius, m_brushRadius); m_selection |= (ellipse); addGap(m_lastPoint, point); updateCanvasPixelRect(QRectF(m_lastPoint, point).normalized().adjusted(-m_brushRadius, -m_brushRadius, m_brushRadius, m_brushRadius)); m_lastPoint = point; } void KisToolSelectBrush::addGap(const QPointF& start, const QPointF& end) { Vector2f way((end-start).x(), (end-start).y()); if(way.norm() < m_brushRadius/3.) return; Vector2f direction(way.normalized()); //rotate 90 degrees clockwise Vector2f rotatedPlus(direction.y(), -direction.x()); //rotate 90 degrees counter clockwise Vector2f rotatedMinus(-direction.y(), direction.x()); Vector2f p1(rotatedPlus * m_brushRadius); Vector2f p2(way+p1); Vector2f p4(rotatedMinus * m_brushRadius); Vector2f p3(way+p4); //we need to convert floating point vectors to int ones because of a bug in QPainterPath::operator|=() //FIXME: http://bugreports.qt.nokia.com/browse/QTBUG-8035 //converting int to float should be done with rounding, so don't use eigen casting. //parameter start contains important decimal places, these shouldn't be lost. QPointF pp1 = QPointF(p1.x(), p1.y()).toPoint(); QPointF pp2 = QPointF(p2.x(), p2.y()).toPoint(); QPointF pp3 = QPointF(p3.x(), p3.y()).toPoint(); QPointF pp4 = QPointF(p4.x(), p4.y()).toPoint(); pp1+=start; pp2+=start; pp3+=start; pp4+=start; QPainterPath gap; gap.moveTo(pp1); gap.lineTo(pp2); gap.lineTo(pp3); gap.lineTo(pp4); gap.closeSubpath(); m_selection |= (gap); } #include "kis_tool_select_brush.moc" diff --git a/krita/ui/tool/kis_tool.cc b/krita/ui/tool/kis_tool.cc index 56cdb10624..7715fea2d6 100644 --- a/krita/ui/tool/kis_tool.cc +++ b/krita/ui/tool/kis_tool.cc @@ -1,521 +1,531 @@ /* * Copyright (c) 2006 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kis_tool.h" #include #include #include #include +#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_OPENGL #include #endif #include "kis_node_shape.h" #include "kis_layer_container_shape.h" #include "kis_shape_layer.h" #include #include #include #include #include #include #include #include #include #include #include #include "kis_canvas_resource_provider.h" #include "canvas/kis_canvas2.h" #include "filter/kis_filter_configuration.h" #include "kis_config.h" #include "kis_config_notifier.h" #include "kis_cursor.h" #include struct KisTool::Private { Private() : currentPattern(0), currentGradient(0), currentPaintOpPreset(0), currentGenerator(0), optionWidget(0) { } QCursor cursor; // the cursor that should be shown on tool activation. // From the canvas resources KisPattern * currentPattern; KoAbstractGradient * currentGradient; KoColor currentFgColor; KoColor currentBgColor; QString currentPaintOp; KisPaintOpPresetSP currentPaintOpPreset; KisNodeSP currentNode; float currentExposure; KisFilterConfiguration * currentGenerator; QWidget* optionWidget; KAction* toggleFgBg; KAction* resetFgBg; }; KisTool::KisTool(KoCanvasBase * canvas, const QCursor & cursor) : KoToolBase(canvas) , d(new Private) { d->cursor = cursor; m_outlinePaintMode = XOR_MODE; connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), SLOT(resetCursorStyle())); d->toggleFgBg = new KAction(i18n("Swap Foreground and Background Color"), this); d->toggleFgBg->setShortcut(QKeySequence(Qt::Key_X)); connect(d->toggleFgBg, SIGNAL(triggered()), this, SLOT(slotToggleFgBg())); addAction("toggle_fg_bg", d->toggleFgBg); d->resetFgBg = new KAction(i18n("Reset Foreground and Background Color"), this); d->resetFgBg->setShortcut(QKeySequence(Qt::Key_D)); connect(d->resetFgBg, SIGNAL(triggered()), this, SLOT(slotResetFgBg())); addAction("reset_fg_bg", d->resetFgBg); } KisTool::~KisTool() { delete d; } void KisTool::activate(bool) { resetCursorStyle(); d->currentFgColor = canvas()->resourceManager()->resource(KoCanvasResource::ForegroundColor).value(); d->currentBgColor = canvas()->resourceManager()->resource(KoCanvasResource::BackgroundColor).value(); d->currentPattern = static_cast(canvas()->resourceManager()-> resource(KisCanvasResourceProvider::CurrentPattern).value()); d->currentGradient = static_cast(canvas()->resourceManager()-> resource(KisCanvasResourceProvider::CurrentGradient).value()); d->currentPaintOpPreset = canvas()->resourceManager()->resource(KisCanvasResourceProvider::CurrentPaintOpPreset).value(); if (d->currentPaintOpPreset && d->currentPaintOpPreset->settings()) { d->currentPaintOpPreset->settings()->activate(); } d->currentNode = canvas()->resourceManager()-> resource(KisCanvasResourceProvider::CurrentKritaNode).value(); d->currentExposure = static_cast(canvas()->resourceManager()-> resource(KisCanvasResourceProvider::HdrExposure).toDouble()); d->currentGenerator = static_cast(canvas()->resourceManager()-> resource(KisCanvasResourceProvider::CurrentGeneratorConfiguration).value()); } void KisTool::deactivate() { } void KisTool::resourceChanged(int key, const QVariant & v) { switch (key) { case(KoCanvasResource::ForegroundColor): d->currentFgColor = v.value(); break; case(KoCanvasResource::BackgroundColor): d->currentBgColor = v.value(); break; case(KisCanvasResourceProvider::CurrentPattern): d->currentPattern = static_cast(v.value()); break; case(KisCanvasResourceProvider::CurrentGradient): d->currentGradient = static_cast(v.value()); break; case(KisCanvasResourceProvider::CurrentPaintOpPreset): d->currentPaintOpPreset = canvas()->resourceManager()->resource(KisCanvasResourceProvider::CurrentPaintOpPreset).value(); break; case(KisCanvasResourceProvider::HdrExposure): d->currentExposure = static_cast(v.toDouble()); case(KisCanvasResourceProvider::CurrentGeneratorConfiguration): d->currentGenerator = static_cast(v.value()); case(KisCanvasResourceProvider::CurrentKritaNode): d->currentNode = (v.value()); default: ; // Do nothing }; } QPointF KisTool::convertToPixelCoord(KoPointerEvent *e) { if (!image()) return e->point; return image()->documentToPixel(e->point); } QPointF KisTool::convertToPixelCoord(const QPointF& pt) { if (!image()) return pt; return image()->documentToPixel(pt); } QPoint KisTool::convertToIntPixelCoord(KoPointerEvent *e) { if (!image()) return e->point.toPoint(); return image()->documentToIntPixel(e->point); } -QPointF KisTool::viewToPixel(const QPointF &viewCoord) +QPointF KisTool::viewToPixel(const QPointF &viewCoord) const { if (!image()) return viewCoord; return image()->documentToPixel(canvas()->viewConverter()->viewToDocument(viewCoord)); } QRectF KisTool::convertToPt(const QRectF &rect) { if (!image()) return rect; QRectF r; //We add 1 in the following to the extreme coords because a pixel always has size r.setCoords(int(rect.left()) / image()->xRes(), int(rect.top()) / image()->yRes(), int(1 + rect.right()) / image()->xRes(), int(1 + rect.bottom()) / image()->yRes()); return r; } -QPointF KisTool::pixelToView(const QPoint &pixelCoord) +QPointF KisTool::pixelToView(const QPoint &pixelCoord) const { if (!image()) return pixelCoord; QPointF documentCoord = image()->pixelToDocument(pixelCoord); return canvas()->viewConverter()->documentToView(documentCoord); } -QPointF KisTool::pixelToView(const QPointF &pixelCoord) +QPointF KisTool::pixelToView(const QPointF &pixelCoord) const { if (!image()) return pixelCoord; QPointF documentCoord = image()->pixelToDocument(pixelCoord); return canvas()->viewConverter()->documentToView(documentCoord); } -QRectF KisTool::pixelToView(const QRectF &pixelRect) +QRectF KisTool::pixelToView(const QRectF &pixelRect) const { if (!image()) return pixelRect; QPointF topLeft = pixelToView(pixelRect.topLeft()); QPointF bottomRight = pixelToView(pixelRect.bottomRight()); return QRectF(topLeft, bottomRight); } +QPainterPath KisTool::pixelToView(const QPainterPath &pixelPath) const +{ + QMatrix matrix; + qreal zoomX, zoomY; + canvas()->viewConverter()->zoom(&zoomX, &zoomY); + matrix.scale(zoomX/image()->xRes(), zoomY/ image()->yRes()); + return matrix.map(pixelPath); +} + void KisTool::updateCanvasPixelRect(const QRectF &pixelRect) { canvas()->updateCanvas(convertToPt(pixelRect)); } void KisTool::updateCanvasViewRect(const QRectF &viewRect) { canvas()->updateCanvas(canvas()->viewConverter()->viewToDocument(viewRect)); } KisImageWSP KisTool::image() const { // For now, krita tools only work in krita, not for a krita shape. Krita shapes are for 2.1 KisCanvas2 * kisCanvas = dynamic_cast(canvas()); if (kisCanvas) { return kisCanvas->currentImage(); } return 0; } QCursor KisTool::cursor() const { return d->cursor; } KisSelectionSP KisTool::currentSelection() const { KisCanvas2 * kisCanvas = dynamic_cast(canvas()); if (kisCanvas) { KisView2 * view = kisCanvas->view(); if (view) return view->selection(); } return 0; } void KisTool::notifyModified() const { if (image()) { image()->setModified(); } } KisPattern * KisTool::currentPattern() { return d->currentPattern; } KoAbstractGradient * KisTool::currentGradient() { return d->currentGradient; } KisPaintOpPresetSP KisTool::currentPaintOpPreset() { return d->currentPaintOpPreset; } KisNodeSP KisTool::currentNode() { return d->currentNode; } KoColor KisTool::currentFgColor() { return d->currentFgColor; } KoColor KisTool::currentBgColor() { return d->currentBgColor; } KisImageWSP KisTool::currentImage() { return image(); } KisFilterConfiguration * KisTool::currentGenerator() { return d->currentGenerator; } void KisTool::mousePressEvent(KoPointerEvent *event) { event->ignore(); } void KisTool::mouseMoveEvent(KoPointerEvent *event) { event->ignore(); } void KisTool::mouseReleaseEvent(KoPointerEvent *event) { event->ignore(); } void KisTool::setupPainter(KisPainter* painter) { Q_ASSERT(currentImage()); if (!currentImage()) return; painter->setBounds(currentImage()->bounds()); painter->setPaintColor(currentFgColor()); painter->setBackgroundColor(currentBgColor()); painter->setGenerator(currentGenerator()); painter->setPattern(currentPattern()); painter->setGradient(currentGradient()); painter->setPaintOpPreset(currentPaintOpPreset(), currentImage()); if (KisPaintLayer* l = dynamic_cast(currentNode().data())) { painter->setChannelFlags(l->channelFlags()); if (l->alphaLocked()) { painter->setLockAlpha(l->alphaLocked()); } } } void KisTool::setupPaintAction(KisRecordedPaintAction* action) { action->setPaintColor(currentFgColor()); action->setBackgroundColor(currentBgColor()); } QWidget* KisTool::createOptionWidget() { d->optionWidget = new QLabel(i18n("No options")); d->optionWidget->setObjectName(toolId() + " Option Widget"); return d->optionWidget; } QWidget* KisTool::optionWidget() { return d->optionWidget; } -void KisTool::paintToolOutline(QPainter* painter, QPainterPath &path) +void KisTool::paintToolOutline(QPainter* painter, const QPainterPath &path) { #if defined(HAVE_OPENGL) if (m_outlinePaintMode==XOR_MODE && isCanvasOpenGL()) { beginOpenGL(); glEnable(GL_LINE_SMOOTH); glEnable(GL_COLOR_LOGIC_OP); glLogicOp(GL_XOR); glColor3f(0.501961, 1.0, 0.501961); QList subPathPolygons = path.toSubpathPolygons(); for(int i=0; isetCompositionMode(QPainter::RasterOp_SourceXorDestination); painter->setPen(QColor(128, 255, 128)); painter->drawPath(path); } else/* if (m_outlinePaintMode==BW_MODE)*/ #endif { QPen pen = painter->pen(); pen.setWidth(3); pen.setColor(QColor(0, 0, 0, 100)); painter->setPen(pen); painter->drawPath(path); pen.setWidth(1); pen.setColor(Qt::white); painter->setPen(pen); painter->drawPath(path); } } void KisTool::resetCursorStyle() { KisConfig cfg; switch (cfg.cursorStyle()) { case CURSOR_STYLE_TOOLICON: useCursor(d->cursor); break; case CURSOR_STYLE_CROSSHAIR: useCursor(KisCursor::crossCursor()); break; case CURSOR_STYLE_POINTER: useCursor(KisCursor::upArrowCursor()); break; case CURSOR_STYLE_NO_CURSOR: useCursor(KisCursor::blankCursor()); break; #if defined(HAVE_OPENGL) case CURSOR_STYLE_3D_MODEL: useCursor(d->cursor); break; #endif case CURSOR_STYLE_OUTLINE: default: // use tool cursor as default, if the tool supports outline, it will set the cursor to blank and show outline useCursor(d->cursor); } } void KisTool::slotToggleFgBg() { KoResourceManager* resourceManager = canvas()->resourceManager(); KoColor c = resourceManager->foregroundColor(); resourceManager->setForegroundColor(resourceManager->backgroundColor()); resourceManager->setBackgroundColor(c); } void KisTool::slotResetFgBg() { KoResourceManager* resourceManager = canvas()->resourceManager(); resourceManager->setForegroundColor(KoColor(Qt::black, KoColorSpaceRegistry::instance()->rgb8())); resourceManager->setBackgroundColor(KoColor(Qt::white, KoColorSpaceRegistry::instance()->rgb8())); } bool KisTool::isCanvasOpenGL() const { return canvas()->canvasController()->isCanvasOpenGL(); } void KisTool::beginOpenGL() { #if defined(HAVE_OPENGL) KisOpenGLCanvas2 *canvasWidget = dynamic_cast(canvas()->canvasWidget()); Q_ASSERT(canvasWidget); if (canvasWidget) { canvasWidget->beginOpenGL(); } #endif } void KisTool::endOpenGL() { #if defined(HAVE_OPENGL) KisOpenGLCanvas2 *canvasWidget = dynamic_cast(canvas()->canvasWidget()); Q_ASSERT(canvasWidget); if (canvasWidget) { canvasWidget->endOpenGL(); } #endif } #include "kis_tool.moc" diff --git a/krita/ui/tool/kis_tool.h b/krita/ui/tool/kis_tool.h index 8eb454686a..d4d792bf9c 100644 --- a/krita/ui/tool/kis_tool.h +++ b/krita/ui/tool/kis_tool.h @@ -1,181 +1,185 @@ /* * Copyright (c) 2006 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KIS_TOOL_H_ #define KIS_TOOL_H_ #include #include #include #include #include #include #include class KoCanvasBase; class KisPattern; class KoAbstractGradient; class KisFilterConfiguration; class KisPainter; class QPainter; class QPainterPath; class KisRecordedPaintAction; enum PaintMode { XOR_MODE, BW_MODE }; /// Definitions of the toolgroups of Krita static const QString TOOL_TYPE_SHAPE = "0 Krita/Shape"; // Geometric shapes like ellipses and lines static const QString TOOL_TYPE_FREEHAND = "1 Krita/Freehand"; // Freehand drawing tools static const QString TOOL_TYPE_TRANSFORM = "2 Krita/Transform"; // Tools that transform the layer; static const QString TOOL_TYPE_FILL = "3 Krita/Fill"; // Tools that fill parts of the canvas static const QString TOOL_TYPE_VIEW = "4 Krita/View"; // Tools that affect the canvas: pan, zoom, etc. static const QString TOOL_TYPE_SELECTED = "5 Krita/Select"; // Tools that select pixels class KRITAUI_EXPORT KisTool : public KoToolBase { Q_OBJECT public: KisTool(KoCanvasBase * canvas, const QCursor & cursor); virtual ~KisTool(); // KoToolBase Implementation. public slots: virtual void activate(bool temporary = false); virtual void deactivate(); virtual void resourceChanged(int key, const QVariant & res); public: /// reimplemented from superclass virtual void mousePressEvent(KoPointerEvent *event); /// reimplemented from superclass virtual void mouseMoveEvent(KoPointerEvent *event); /// reimplemented from superclass virtual void mouseReleaseEvent(KoPointerEvent *event); /// reimplemented from superclass virtual void mouseDoubleClickEvent(KoPointerEvent *) {} // when a krita tool is enabled, don't push double click on /// Convert from native (postscript points) to image pixel /// coordinates. QPointF convertToPixelCoord(KoPointerEvent *e); QPointF convertToPixelCoord(const QPointF& pt); /// Convert from native (postscript points) to integer image pixel /// coordinates. This truncates the floating point components and /// should be used in preference to QPointF::toPoint(), which rounds, /// to ensure the cursor acts on the pixel it is visually over. QPoint convertToIntPixelCoord(KoPointerEvent *e); QRectF convertToPt(const QRectF &rect); - QPointF viewToPixel(const QPointF &viewCoord); + QPointF viewToPixel(const QPointF &viewCoord) const; /// Convert an integer pixel coordinate into a view coordinate. /// The view coordinate is at the centre of the pixel. - QPointF pixelToView(const QPoint &pixelCoord); + QPointF pixelToView(const QPoint &pixelCoord) const; /// Convert a floating point pixel coordinate into a view coordinate. - QPointF pixelToView(const QPointF &pixelCoord); + QPointF pixelToView(const QPointF &pixelCoord) const; /// Convert a pixel rectangle into a view rectangle. - QRectF pixelToView(const QRectF &pixelRect); + QRectF pixelToView(const QRectF &pixelRect) const; + + /// Convert a pixel path into a view path + QPainterPath pixelToView(const QPainterPath &pixelPath) const; /// Update the canvas for the given rectangle in image pixel coordinates. void updateCanvasPixelRect(const QRectF &pixelRect); /// Update the canvas for the given rectangle in view coordinates. void updateCanvasViewRect(const QRectF &viewRect); virtual QWidget* createOptionWidget(); virtual QWidget* optionWidget(); inline void setOutlineStyle(PaintMode mode) { m_outlinePaintMode = mode; } protected: KisImageWSP image() const; QCursor cursor() const; /// @return the currently active selection KisSelectionSP currentSelection() const; /// Call this to set the document modified void notifyModified() const; KisImageWSP currentImage(); KisPattern* currentPattern(); KoAbstractGradient * currentGradient(); KisNodeSP currentNode(); KoColor currentFgColor(); KoColor currentBgColor(); KisPaintOpPresetSP currentPaintOpPreset(); KisFilterConfiguration * currentGenerator(); /// convenience method to fill the painter's settings with all the current resources virtual void setupPainter(KisPainter * painter); virtual void setupPaintAction(KisRecordedPaintAction* action); /// paint the path which is in view coordinates, default paint mode is XOR_MODE, BW_MODE is also possible - void paintToolOutline(QPainter * painter, QPainterPath &path); + /// never apply transformations to the painter, they would be useless, if drawing in OpenGL mode. The coordinates in the path should be in view coordinates. + void paintToolOutline(QPainter * painter, const QPainterPath &path); /// Returns true if the canvas this tool is associated with supports OpenGL rendering. bool isCanvasOpenGL() const; /// Call before starting to use native OpenGL commands when painting this tool's decorations. /// This is a convenience method that calls beginOpenGL() on the OpenGL canvas object. void beginOpenGL(); /// Call after finishing use of native OpenGL commands when painting this tool's decorations. /// This is a convenience method that calls endOpenGL() on the OpenGL canvas object. void endOpenGL(); protected slots: /** * Called whenever the configuration settings change. */ virtual void resetCursorStyle(); private slots: void slotToggleFgBg(); void slotResetFgBg(); private: PaintMode m_outlinePaintMode; struct Private; Private* const d; }; #endif // KIS_TOOL_H_