krita

KisPainter Class Reference

#include <kis_painter.h>

Inheritance diagram for KisPainter:

KisProgressSubject KisConvolutionPainter KisFillPainter KisGradientPainter List of all members.

Detailed Description

KisPainter contains the graphics primitives necessary to draw on a KisPaintDevice.

This is the same kind of abstraction as used in Qt itself, where you have QPainter and QPaintDevice.

However, KisPainter works on a tiled image and supports different colour models, and that's a lot more complicated.

KisPainter supports transactions that can group various paint operations in one undoable step.

For more complex operations, you might want to have a look at the subclasses of KisPainter: KisConvolutionPainter, KisFillPainter and KisGradientPainter

Definition at line 56 of file kis_painter.h.


Public Types

enum  FillStyle {
  FillStyleNone, FillStyleForegroundColor, FillStyleBackgroundColor, FillStylePattern,
  FillStyleGradient, FillStyleStrokes
}
enum  StrokeStyle { StrokeStyleNone, StrokeStyleBrush }

Public Member Functions

 KisPainter ()
 KisPainter (KisPaintDeviceSP device)
virtual ~KisPainter ()
void begin (KisPaintDeviceSP device)
KCommand * end ()
void beginTransaction (const QString &customName=QString::null)
KCommand * endTransaction ()
void beginTransaction (KisTransaction *command)
KisTransactiontransaction ()
KisPaintDeviceSP device () const
void bitBlt (Q_INT32 dx, Q_INT32 dy, const KisCompositeOp &op, KisPaintDeviceSP src, Q_INT32 sx, Q_INT32 sy, Q_INT32 sw, Q_INT32 sh)
void bitBlt (Q_INT32 dx, Q_INT32 dy, const KisCompositeOp &op, KisPaintDeviceSP src, Q_UINT8 opacity, Q_INT32 sx, Q_INT32 sy, Q_INT32 sw, Q_INT32 sh)
void bltMask (Q_INT32 dx, Q_INT32 dy, const KisCompositeOp &op, KisPaintDeviceSP src, KisPaintDeviceSP selMask, Q_UINT8 opacity, Q_INT32 sx, Q_INT32 sy, Q_INT32 sw, Q_INT32 sh)
void bltSelection (Q_INT32 dx, Q_INT32 dy, const KisCompositeOp &op, KisPaintDeviceSP src, KisSelectionSP selMask, Q_UINT8 opacity, Q_INT32 sx, Q_INT32 sy, Q_INT32 sw, Q_INT32 sh)
void bltSelection (Q_INT32 dx, Q_INT32 dy, const KisCompositeOp &op, KisPaintDeviceSP src, Q_UINT8 opacity, Q_INT32 sx, Q_INT32 sy, Q_INT32 sw, Q_INT32 sh)
QRect dirtyRect ()
QRect addDirtyRect (QRect r)
void paintPolyline (const QValueVector< KisPoint > &points, int index=0, int numPoints=-1)
double paintLine (const KisPoint &pos1, const double pressure1, const double xTilt1, const double yTilt1, const KisPoint &pos2, const double pressure2, const double xTilt2, const double yTilt2, const double savedDist=-1)
double paintBezierCurve (const KisPoint &pos1, const double pressure1, const double xTilt1, const double yTilt1, const KisPoint &control1, const KisPoint &control2, const KisPoint &pos2, const double pressure2, const double xTilt2, const double yTilt2, const double savedDist=-1)
void getBezierCurvePoints (const KisPoint &pos1, const KisPoint &control1, const KisPoint &control2, const KisPoint &pos2, vKisPoint &points)
void paintRect (const KisPoint &startPoint, const KisPoint &endPoint, const double pressure, const double xTilt, const double yTilt)
void paintEllipse (const KisPoint &startPoint, const KisPoint &endPoint, const double pressure, const double, const double)
void paintPolygon (const vKisPoint &points)
void paintAt (const KisPoint &pos, const double pressure, const double, const double)
void setBrush (KisBrush *brush)
KisBrushbrush () const
void setPattern (KisPattern *pattern)
KisPatternpattern () const
void setPaintColor (const KisColor &color)
KisColor paintColor () const
void setBackgroundColor (const KisColor &color)
KisColor backgroundColor () const
void setFillColor (const KisColor &color)
KisColor fillColor () const
void setFillStyle (FillStyle fillStyle)
FillStyle fillStyle () const
void setStrokeStyle (StrokeStyle strokeStyle)
StrokeStyle strokeStyle () const
void setOpacity (Q_UINT8 opacity)
Q_UINT8 opacity () const
void setCompositeOp (const KisCompositeOp &op)
KisCompositeOp compositeOp () const
void setFilter (KisFilterSP filter)
KisFilterSP filter ()
void setDuplicateOffset (const KisPoint &offset)
KisPoint duplicateOffset ()
void setDuplicateHealing (bool v)
bool duplicateHealing ()
void setDuplicateHealingRadius (int r)
int duplicateHealingRadius ()
void setDuplicatePerspectiveCorrection (bool v)
bool duplicatePerspectiveCorrection ()
void setDuplicateStart (const KisPoint start)
KisPoint duplicateStart ()
void setPressure (double pressure)
double pressure ()
void setPaintOp (KisPaintOp *paintOp)
KisPaintOppaintOp () const
void setDab (KisPaintDeviceSP dab)
KisPaintDeviceSP dab () const
bool cancelRequested () const

Protected Member Functions

void init ()
 KisPainter (const KisPainter &)
KisPainteroperator= (const KisPainter &)
void fillPolygon (const vKisPoint &points, FillStyle fillStyle)

Static Protected Member Functions

static double pointToLineDistance (const KisPoint &p, const KisPoint &l0, const KisPoint &l1)

Protected Attributes

KisPaintDeviceSP m_device
KisTransactionm_transaction
QRect m_dirtyRect
KisColor m_paintColor
KisColor m_backgroundColor
KisColor m_fillColor
FillStyle m_fillStyle
StrokeStyle m_strokeStyle
KisBrushm_brush
KisPatternm_pattern
KisPoint m_duplicateOffset
KisPoint m_duplicateStart
bool m_duplicateHealing
int m_duplicateHealingRadius
bool m_duplicatePerspectiveCorrection
Q_UINT8 m_opacity
KisCompositeOp m_compositeOp
KisFilterSP m_filter
KisPaintOpm_paintOp
double m_pressure
bool m_cancelRequested
Q_INT32 m_pixelSize
KisColorSpacem_colorSpace
KisProfilem_profile
KisPaintDeviceSP m_dab

Member Enumeration Documentation

This enum contains the styles with which we can fill things like polygons and ellipses.

Definition at line 294 of file kis_painter.h.

The style of the brush stroke around polygons and so.

Definition at line 309 of file kis_painter.h.


Constructor & Destructor Documentation

KisPainter::KisPainter (  ) 

Construct painter without a device.

Definition at line 69 of file kis_painter.cc.

KisPainter::KisPainter ( KisPaintDeviceSP  device  ) 

Construct a painter, and begin painting on the device.

Definition at line 74 of file kis_painter.cc.


Member Function Documentation

void KisPainter::begin ( KisPaintDeviceSP  device  ) 

Start painting on the specified device.

Not undoable.

Definition at line 106 of file kis_painter.cc.

KCommand * KisPainter::end (  ) 

Finish painting on the current device.

Definition at line 118 of file kis_painter.cc.

void KisPainter::beginTransaction ( const QString &  customName = QString::null  ) 

Begin an undoable paint operation.

Definition at line 123 of file kis_painter.cc.

KCommand * KisPainter::endTransaction (  ) 

Finish the undoable paint operation.

Definition at line 139 of file kis_painter.cc.

void KisPainter::beginTransaction ( KisTransaction command  ) 

begin a transaction with the given command

Definition at line 131 of file kis_painter.cc.

KisTransaction* KisPainter::transaction (  )  [inline]

Return the current transcation.

Definition at line 91 of file kis_painter.h.

KisPaintDeviceSP KisPainter::device (  )  const [inline]

Returns the current paint device.

Definition at line 95 of file kis_painter.h.

void KisPainter::bitBlt ( Q_INT32  dx,
Q_INT32  dy,
const KisCompositeOp op,
KisPaintDeviceSP  src,
Q_INT32  sx,
Q_INT32  sy,
Q_INT32  sw,
Q_INT32  sh 
) [inline]

Blast the specified region from src onto the current paint device.

Definition at line 105 of file kis_painter.h.

void KisPainter::bitBlt ( Q_INT32  dx,
Q_INT32  dy,
const KisCompositeOp op,
KisPaintDeviceSP  src,
Q_UINT8  opacity,
Q_INT32  sx,
Q_INT32  sy,
Q_INT32  sw,
Q_INT32  sh 
)

Overloaded version of the previous, differs in that it is possible to specify a value for opacity.

Definition at line 153 of file kis_painter.cc.

void KisPainter::bltMask ( Q_INT32  dx,
Q_INT32  dy,
const KisCompositeOp op,
KisPaintDeviceSP  src,
KisPaintDeviceSP  selMask,
Q_UINT8  opacity,
Q_INT32  sx,
Q_INT32  sy,
Q_INT32  sw,
Q_INT32  sh 
)

A version of bitBlt that renders using an external mask, ignoring the src device's own selection, if it has one.

Definition at line 266 of file kis_painter.cc.

void KisPainter::bltSelection ( Q_INT32  dx,
Q_INT32  dy,
const KisCompositeOp op,
KisPaintDeviceSP  src,
KisSelectionSP  selMask,
Q_UINT8  opacity,
Q_INT32  sx,
Q_INT32  sy,
Q_INT32  sw,
Q_INT32  sh 
)

A version of bitBlt that renders using an external selection mask, ignoring the src device's own selection, if it has one.

Definition at line 243 of file kis_painter.cc.

void KisPainter::bltSelection ( Q_INT32  dx,
Q_INT32  dy,
const KisCompositeOp op,
KisPaintDeviceSP  src,
Q_UINT8  opacity,
Q_INT32  sx,
Q_INT32  sy,
Q_INT32  sw,
Q_INT32  sh 
)

A version of bitBlt that renders using the src device's selection mask, if it has one.

Definition at line 370 of file kis_painter.cc.

QRect KisPainter::dirtyRect (  ) 

The methods below are 'higher' level than the above methods.

They need brushes, colors etc. set before they can be called. The methods do not directly tell the image to update, but you can call dirtyRect() to get the rect that needs to be notified by your painting code.

Call will RESET the dirtyRect!

Definition at line 147 of file kis_painter.cc.

QRect KisPainter::addDirtyRect ( QRect  r  )  [inline]

Add the r to the current dirty rect, and return the dirtyRect after adding r to it.

Definition at line 174 of file kis_painter.h.

void KisPainter::paintPolyline ( const QValueVector< KisPoint > &  points,
int  index = 0,
int  numPoints = -1 
)

Paint a line that connects the dots in points.

double KisPainter::paintLine ( const KisPoint pos1,
const double  pressure1,
const double  xTilt1,
const double  yTilt1,
const KisPoint pos2,
const double  pressure2,
const double  xTilt2,
const double  yTilt2,
const double  savedDist = -1 
)

Draw a line between pos1 and pos2 using the currently set brush and color.

If savedDist is less than zero, the brush is painted at pos1 before being painted along the line using the spacing setting.

Returns:
the drag distance, that is the remains of the distance between p1 and p2 not covered because the currenlty set brush has a spacing greater than that distance.

Definition at line 385 of file kis_painter.cc.

double KisPainter::paintBezierCurve ( const KisPoint pos1,
const double  pressure1,
const double  xTilt1,
const double  yTilt1,
const KisPoint control1,
const KisPoint control2,
const KisPoint pos2,
const double  pressure2,
const double  xTilt2,
const double  yTilt2,
const double  savedDist = -1 
)

Draw a Bezier curve between pos1 and pos2 using control points 1 and 2.

If savedDist is less than zero, the brush is painted at pos1 before being painted along the curve using the spacing setting.

Returns:
the drag distance, that is the remains of the distance between p1 and p2 not covered because the currenlty set brush has a spacing greater than that distance.

Definition at line 538 of file kis_painter.cc.

void KisPainter::getBezierCurvePoints ( const KisPoint pos1,
const KisPoint control1,
const KisPoint control2,
const KisPoint pos2,
vKisPoint &  points 
)

Fill the given vector points with the points needed to draw the Bezier curve between pos1 and pos2 using control points 1 and 2, excluding the final pos2.

Definition at line 505 of file kis_painter.cc.

void KisPainter::paintRect ( const KisPoint startPoint,
const KisPoint endPoint,
const double  pressure,
const double  xTilt,
const double  yTilt 
)

Paint the rectangle with given begin and end points.

Definition at line 590 of file kis_painter.cc.

void KisPainter::paintEllipse ( const KisPoint startPoint,
const KisPoint endPoint,
const double  pressure,
const   double,
const   double 
)

Paint the ellipse with given begin and end points.

Definition at line 608 of file kis_painter.cc.

void KisPainter::paintPolygon ( const vKisPoint &  points  ) 

Paint the polygon with the points given in points.

It automatically closes the polygon by drawing the line from the last point to the first.

Definition at line 900 of file kis_painter.cc.

void KisPainter::paintAt ( const KisPoint pos,
const double  pressure,
const   double,
const   double 
)

Draw a spot at pos using the currently set paint op, brush and color.

Definition at line 653 of file kis_painter.cc.

void KisPainter::setBrush ( KisBrush brush  )  [inline]

Set the current brush.

Definition at line 267 of file kis_painter.h.

KisBrush* KisPainter::brush (  )  const [inline]

Returns the currently set brush.

Definition at line 269 of file kis_painter.h.

void KisPainter::setPattern ( KisPattern pattern  )  [inline]

Set the current pattern.

Definition at line 272 of file kis_painter.h.

KisPattern* KisPainter::pattern (  )  const [inline]

Returns the currently set pattern.

Definition at line 274 of file kis_painter.h.

void KisPainter::setPaintColor ( const KisColor color  )  [inline]

Set the color that will be used to paint with.

Definition at line 277 of file kis_painter.h.

KisColor KisPainter::paintColor (  )  const [inline]

Returns the color that will be used to paint with.

Definition at line 280 of file kis_painter.h.

void KisPainter::setBackgroundColor ( const KisColor color  )  [inline]

Set the current background color.

Definition at line 283 of file kis_painter.h.

KisColor KisPainter::backgroundColor (  )  const [inline]

Returns the current background color.

Definition at line 285 of file kis_painter.h.

void KisPainter::setFillColor ( const KisColor color  )  [inline]

Set the current fill color.

Definition at line 288 of file kis_painter.h.

KisColor KisPainter::fillColor (  )  const [inline]

Returns the current fill color.

Definition at line 290 of file kis_painter.h.

void KisPainter::setFillStyle ( FillStyle  fillStyle  )  [inline]

Set the current style with which to fill.

Definition at line 304 of file kis_painter.h.

FillStyle KisPainter::fillStyle (  )  const [inline]

Returns the current fill style.

Definition at line 306 of file kis_painter.h.

void KisPainter::setStrokeStyle ( StrokeStyle  strokeStyle  )  [inline]

Set the current brush stroke style.

Definition at line 315 of file kis_painter.h.

StrokeStyle KisPainter::strokeStyle (  )  const [inline]

Returns the current brush stroke style.

Definition at line 317 of file kis_painter.h.

void KisPainter::setOpacity ( Q_UINT8  opacity  )  [inline]

Set the opacity which is used in painting (like filling polygons).

Definition at line 320 of file kis_painter.h.

Q_UINT8 KisPainter::opacity (  )  const [inline]

Returns the opacity that is used in painting.

Definition at line 322 of file kis_painter.h.

void KisPainter::setCompositeOp ( const KisCompositeOp op  )  [inline]

Sets the current composite operation.

Everything painted will be composited on the destination layer with this composite op.

Definition at line 328 of file kis_painter.h.

KisCompositeOp KisPainter::compositeOp (  )  const [inline]

Returns the current composite operation.

Definition at line 330 of file kis_painter.h.

void KisPainter::setFilter ( KisFilterSP  filter  )  [inline]

Sets the current KisFilter, used by the paintops that support it (like KisFilterOp).

Definition at line 333 of file kis_painter.h.

KisFilterSP KisPainter::filter (  )  [inline]

Returns the current KisFilter.

Definition at line 335 of file kis_painter.h.

void KisPainter::setDuplicateOffset ( const KisPoint offset  )  [inline]

The offset for paint operations that use it (like KisDuplicateOp).

It will use as source the part of the layer that is at its paintedPosition - duplicateOffset

Definition at line 342 of file kis_painter.h.

KisPoint KisPainter::duplicateOffset (  )  [inline]

Returns the offset for duplication.

Definition at line 344 of file kis_painter.h.

void KisPainter::setPressure ( double  pressure  )  [inline]

Sets the current pressure for things that like to use this.

Definition at line 359 of file kis_painter.h.

double KisPainter::pressure (  )  [inline]

Returns the current pressure.

Definition at line 361 of file kis_painter.h.

void KisPainter::setPaintOp ( KisPaintOp paintOp  )  [inline]

Set the current paint operation.

This is used for all drawing functions. The painter will DELETE the paint op itself!! That means no that you should not delete it yourself (or put it on the stack)

Definition at line 368 of file kis_painter.h.

KisPaintOp* KisPainter::paintOp (  )  const [inline]

Returns the current paint operation.

Definition at line 370 of file kis_painter.h.

void KisPainter::setDab ( KisPaintDeviceSP  dab  )  [inline]

Set a current 'dab'. This usually is a paint device containing a rendered brush.

Definition at line 373 of file kis_painter.h.

KisPaintDeviceSP KisPainter::dab (  )  const [inline]

Get the currently set dab.

Definition at line 375 of file kis_painter.h.

bool KisPainter::cancelRequested (  )  const [inline]

Is cancel Requested by the KisProgressSubject for this painter.

Definition at line 378 of file kis_painter.h.

void KisPainter::init (  )  [protected]

Initialize, set everything to '0' or defaults.

Definition at line 81 of file kis_painter.cc.

double KisPainter::pointToLineDistance ( const KisPoint p,
const KisPoint l0,
const KisPoint l1 
) [static, protected]

Calculate the distance that point p is from the line made by connecting l0 and l1.

Definition at line 662 of file kis_painter.cc.

void KisPainter::fillPolygon ( const vKisPoint &  points,
FillStyle  fillStyle 
) [protected]

Fill the polygon defined by points with the fillStyle.

Definition at line 760 of file kis_painter.cc.


The documentation for this class was generated from the following files:
KDE Home | KDE Accessibility Home | Description of Access Keys