Krita Source Code Documentation
Loading...
Searching...
No Matches
KoZoomStrategy Class Reference

#include <KoZoomStrategy.h>

+ Inheritance diagram for KoZoomStrategy:

Public Member Functions

void cancelInteraction () override
 
void finishInteraction (Qt::KeyboardModifiers modifiers) override
 Execute the zoom.
 
void forceZoomIn ()
 
void forceZoomOut ()
 
 KoZoomStrategy (KoZoomTool *tool, KoCanvasController *controller, const QPointF &clicked)
 
- Public Member Functions inherited from KoShapeRubberSelectStrategy
KUndo2CommandcreateCommand () override
 
void handleMouseMove (const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override
 
 KoShapeRubberSelectStrategy (KoToolBase *tool, const QPointF &clicked, bool useSnapToGrid=false)
 
void paint (QPainter &painter, const KoViewConverter &converter) override
 
- Public Member Functions inherited from KoInteractionStrategy
 KoInteractionStrategy (KoToolBase *parent)
 constructor
 
KoToolBasetool () const
 
virtual ~KoInteractionStrategy ()
 Destructor.
 

Protected Member Functions

SelectionMode currentMode () const override
 
- Protected Member Functions inherited from KoShapeRubberSelectStrategy
 KoShapeRubberSelectStrategy (KoShapeRubberSelectStrategyPrivate &)
 constructor
 
QRectF selectedRectangle () const
 
- Protected Member Functions inherited from KoInteractionStrategy
uint decorationThickness () const
 
uint grabSensitivity () const
 Convenience function to get the global grab sensitivity.
 
uint handleRadius () const
 Convenience function to get the global handle radius.
 
 KoInteractionStrategy (KoInteractionStrategyPrivate &)
 constructor
 

Private Attributes

KoCanvasControllerm_controller
 
bool m_forceZoomOut
 

Additional Inherited Members

- Protected Types inherited from KoShapeRubberSelectStrategy
enum  SelectionMode { CrossingSelection , CoveringSelection }
 
- Protected Attributes inherited from KoInteractionStrategy
KoInteractionStrategyPrivated_ptr
 

Detailed Description

//internal This is a strategy for the KoZoomTool which will be used to do the actual zooming

Definition at line 19 of file KoZoomStrategy.h.

Constructor & Destructor Documentation

◆ KoZoomStrategy()

KoZoomStrategy::KoZoomStrategy ( KoZoomTool * tool,
KoCanvasController * controller,
const QPointF & clicked )

constructor

Parameters
toolthe parent tool this strategy is for
controllerthe canvas controller that wraps the canvas the tool is acting on.
clickedthe location (in document points) where the interaction starts.

Definition at line 20 of file KoZoomStrategy.cpp.

21 : KoShapeRubberSelectStrategy(tool, clicked, false),
22 m_controller(controller),
23 m_forceZoomOut(false)
24{
25}
KoShapeRubberSelectStrategy(KoToolBase *tool, const QPointF &clicked, bool useSnapToGrid=false)
KoCanvasController * m_controller

Member Function Documentation

◆ cancelInteraction()

void KoZoomStrategy::cancelInteraction ( )
overridevirtual

This method will undo frames based interactions by calling createCommand() and unexecuting that.

Reimplemented from KoInteractionStrategy.

Definition at line 56 of file KoZoomStrategy.cpp.

57{
59 d->tool->canvas()->updateCanvas(d->selectedRect().normalized() | d->tool->decorationsRect());
60}

◆ currentMode()

KoShapeRubberSelectStrategy::SelectionMode KoZoomStrategy::currentMode ( ) const
overrideprotectedvirtual

◆ finishInteraction()

void KoZoomStrategy::finishInteraction ( Qt::KeyboardModifiers modifiers)
overridevirtual

Execute the zoom.

Implements KoInteractionStrategy.

Definition at line 27 of file KoZoomStrategy.cpp.

28{
30
31 const QTransform documentToWidget =
34
35 const QRect pixelRect = documentToWidget.mapRect(d->selectedRect()).toRect();
36
37 bool m_zoomOut = m_forceZoomOut;
38 if (modifiers & Qt::ControlModifier) {
39 m_zoomOut = !m_zoomOut;
40 }
41
42 auto makeStillPoint = [&] () -> KoViewTransformStillPoint {
43 const QPointF center = pixelRect.center();
45 };
46
47 if (m_zoomOut) {
48 m_controller->zoomOut(makeStillPoint());
49 } else if (pixelRect.width() > 5 && pixelRect.height() > 5) {
50 m_controller->zoomTo(pixelRect);
51 } else {
52 m_controller->zoomIn(makeStillPoint());
53 }
54}
virtual const KoViewConverter * viewConverter() const =0
virtual void zoomTo(const QRect &rect)=0
zoom so that rect is exactly visible (as close as possible)
virtual void zoomIn(const KoViewTransformStillPoint &stillPoint)=0
zooms in keeping stillPoint not moved.
virtual void zoomOut(const KoViewTransformStillPoint &stillPoint)=0
zooms out keeping stillPoint not moved.
virtual KoCanvasBase * canvas() const
virtual QTransform viewToWidget() const
virtual KoViewTransformStillPoint makeWidgetStillPoint(const QPointF &viewPoint) const
Creates a still point that links the viewPoint of the widget to the corresponding point of the image.
virtual QPointF documentToView(const QPointF &documentPoint) const

References KoCanvasController::canvas(), KoViewConverter::documentToView(), m_controller, m_forceZoomOut, KoViewConverter::makeWidgetStillPoint(), KoCanvasBase::viewConverter(), KoViewConverter::viewToWidget(), KoCanvasController::zoomIn(), KoCanvasController::zoomOut(), and KoCanvasController::zoomTo().

◆ forceZoomIn()

void KoZoomStrategy::forceZoomIn ( )

Definition at line 72 of file KoZoomStrategy.cpp.

73{
74 m_forceZoomOut = false;
75}

References m_forceZoomOut.

◆ forceZoomOut()

void KoZoomStrategy::forceZoomOut ( )

Definition at line 67 of file KoZoomStrategy.cpp.

68{
69 m_forceZoomOut = true;
70}

References m_forceZoomOut.

Member Data Documentation

◆ m_controller

KoCanvasController* KoZoomStrategy::m_controller
private

Definition at line 40 of file KoZoomStrategy.h.

◆ m_forceZoomOut

bool KoZoomStrategy::m_forceZoomOut
private

Definition at line 42 of file KoZoomStrategy.h.


The documentation for this class was generated from the following files: