|
Krita Source Code Documentation
|
#include <kis_curve_widget.h>
Inheritance diagram for KisCurveWidget:Public Types | |
| enum | PointConstrain { PointConstrain_None , PointConstrain_AlwaysCorner , PointConstrain_AlwaysSmooth } |
Public Slots | |
| void | setCurve (KisCubicCurve inlist) |
Signals | |
| void | compressorShouldEmitModified () |
| void | curveChanged (const KisCubicCurve &) |
| void | modified (void) |
| void | pointSelectedChanged () |
| void | shouldFocusIOControls () |
| void | shouldSyncIOControls () |
Public Member Functions | |
| void | addPointInTheMiddle () |
| void | applyGlobalPointConstrain () |
| std::optional< KisCubicCurvePoint > | currentPoint () const |
| std::optional< QPointF > | currentPointPosition () const |
| KisCubicCurve | curve () |
| void | drawGrid (QPainter &p, int wWidth, int wHeight) |
| void | dropInOutControls () |
| QPixmap | getPixmap () |
| PointConstrain | globalPointConstrain () const |
| std::optional< bool > | isCurrentPointSetAsCorner () const |
| bool | jumpOverExistingPoints (QPointF &pt, int skipIndex) |
| KisCurveWidget (QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags()) | |
| int | nearestPointInRange (QPointF pt, int wWidth, int wHeight) const |
| bool | pointSelected () const |
| Private (KisCurveWidget *parent) | |
| void | reset (void) |
| bool | setCurrentPoint (const QPointF &position, bool setAsCorner) |
| bool | setCurrentPointAsCorner (bool setAsCorner) |
| bool | setCurrentPointPosition (const QPointF &position) |
| void | setCurveModified (bool rewriteSpinBoxesValues=true) |
| void | setCurveRepaint () |
| void | setGlobalPointConstrain (PointConstrain constrain) |
| void | setPixmap (const QPixmap &pix) |
| void | setState (enumState st) |
| void | setupInOutControls (QSpinBox *in, QSpinBox *out, int inMin, int inMax, int outMin, int outMax) |
| enumState | state () const |
| void | syncIOControls () |
| ~KisCurveWidget () override | |
Public Attributes | |
| KisCubicCurve | m_curve |
| KisCubicCurvePoint | m_draggedAwayPoint |
| int | m_draggedAwayPointIndex {0} |
| KisCurveWidget::PointConstrain | m_globalPointConstrain {KisCurveWidget::PointConstrain_None} |
| int | m_grab_point_index {-1} |
| double | m_grabOffsetX {0.0} |
| double | m_grabOffsetY {0.0} |
| double | m_grabOriginalX {0.0} |
| double | m_grabOriginalY {0.0} |
| int | m_handleSize {12} |
| KisThreadSafeSignalCompressor | m_modifiedSignalsCompressor |
| QPixmap | m_pix |
| QPixmap * | m_pixmapCache {nullptr} |
| bool | m_pixmapDirty {true} |
| bool | m_readOnlyMode {false} |
| bool | m_splineDirty {false} |
| enumState | m_state {enumState::ST_NORMAL} |
Protected Slots | |
| void | notifyModified () |
| void | slotCompressorShouldEmitModified () |
Protected Member Functions | |
| void | keyPressEvent (QKeyEvent *) override |
| void | leaveEvent (QEvent *) override |
| void | mouseMoveEvent (QMouseEvent *e) override |
| void | mousePressEvent (QMouseEvent *e) override |
| void | mouseReleaseEvent (QMouseEvent *e) override |
| void | paintEvent (QPaintEvent *) override |
| void | resizeEvent (QResizeEvent *e) override |
Properties | |
| bool | pointSelected |
Private Attributes | |
| Private *const | d {nullptr} |
| KisCurveWidget * | m_curveWidget {nullptr} |
Private Attributes inherited from Private | |
| KisCanvas2 * | canvas |
| int | displayedFrame |
| int | intendedFrame |
Friends | |
| class | CurveEditorItem |
Additional Inherited Members | |
Private Member Functions inherited from Private | |
| Private (KisCanvas2 *c) | |
KisCurveWidget is a widget that shows a single curve that can be edited by the user. The user can grab the curve and move it; this creates a new control point. Control points can be deleted by selecting a point and pressing the delete key.
(From: https://techbase.kde.org/Projects/Widgets_and_Classes#KisCurveWidget) KisCurveWidget allows editing of spline based y=f(x) curves. Handy for cases where you want the user to control such things as tablet pressure response, color transformations, acceleration by time, aeroplane lift by angle of attack.
Private members for KisCurveWidget class
Definition at line 40 of file kis_curve_widget.h.
| Enumerator | |
|---|---|
| PointConstrain_None | |
| PointConstrain_AlwaysCorner | |
| PointConstrain_AlwaysSmooth | |
Definition at line 80 of file kis_curve_widget.h.
| KisCurveWidget::KisCurveWidget | ( | QWidget * | parent = nullptr, |
| Qt::WindowFlags | f = Qt::WindowFlags() ) |
Create a new curve widget with a default curve, that is a straight line from bottom-left to top-right.
Definition at line 53 of file kis_curve_widget.cpp.
References compressorShouldEmitModified(), connect(), d, notifyModified(), and slotCompressorShouldEmitModified().
|
override |
Definition at line 71 of file kis_curve_widget.cpp.
References d.
| void KisCurveWidget::addPointInTheMiddle | ( | ) |
Handy function that creates new point in the middle of the curve and sets focus on the m_intIn field, so the user can move this point anywhere in a moment
Definition at line 245 of file kis_curve_widget.cpp.
References d, PointConstrain_AlwaysCorner, pointSelectedChanged(), and shouldFocusIOControls().
| void KisCurveWidget::applyGlobalPointConstrain | ( | ) |
Ensure that all points conform to the global constrain set
|
signal |
Emitted to notify that the start() function in compressor can be activated. Thanks to that, blocking signals in curve widget blocks "sending signals" (calling start() function) to the signal compressor. It effectively makes signals work nearly the same way they worked before adding the signal compressor in between.
| std::optional< KisCubicCurvePoint > KisCurveWidget::currentPoint | ( | ) | const |
Definition at line 142 of file kis_curve_widget.cpp.
References d.
| std::optional< QPointF > KisCurveWidget::currentPointPosition | ( | ) | const |
| KisCubicCurve KisCurveWidget::curve | ( | ) |
Definition at line 519 of file kis_curve_widget.cpp.
References d.
|
signal |
|
inline |
Nothing to be said! =)
| void KisCurveWidget::dropInOutControls | ( | ) |
| QPixmap KisCurveWidget::getPixmap | ( | ) |
| KisCurveWidget::PointConstrain KisCurveWidget::globalPointConstrain | ( | ) | const |
Definition at line 163 of file kis_curve_widget.cpp.
References d.
| std::optional< bool > KisCurveWidget::isCurrentPointSetAsCorner | ( | ) | const |
| bool KisCurveWidget::jumpOverExistingPoints | ( | QPointF & | pt, |
| int | skipIndex ) |
Check whether newly created/moved point pt doesn't overlap with any of existing ones from m_points and adjusts its coordinates. skipIndex is the index of the point, that shouldn't be taken into account during the search (e.g. because it's pt itself)
Returns false in case the point can't be placed anywhere without overlapping
|
overrideprotected |
Definition at line 198 of file kis_curve_widget.cpp.
References addPointInTheMiddle(), d, isCurrentPointSetAsCorner(), PointConstrain_None, pointSelected, pointSelectedChanged(), setCurrentPointAsCorner(), and ST_NORMAL.
|
overrideprotected |
Definition at line 533 of file kis_curve_widget.cpp.
Emitted whenever a control point has changed position.
|
overrideprotected |
Definition at line 444 of file kis_curve_widget.cpp.
References bounds, d, MOUSE_AWAY_THRES, POINT_AREA, pointSelectedChanged(), and ST_NORMAL.
|
overrideprotected |
Definition at line 385 of file kis_curve_widget.cpp.
References currentPoint(), d, PointConstrain_AlwaysCorner, PointConstrain_None, pointSelectedChanged(), and ST_DRAG.
|
overrideprotected |
| int KisCurveWidget::nearestPointInRange | ( | QPointF | pt, |
| int | wWidth, | ||
| int | wHeight ) const |
Find the nearest point to pt from m_points
|
protectedslot |
Definition at line 537 of file kis_curve_widget.cpp.
References curveChanged(), d, and modified().
|
overrideprotected |
Keep in mind that QLineF rounds doubles to ints mathematically, not just rounds down like in C
Definition at line 267 of file kis_curve_widget.cpp.
References KisConfig::antialiasCurves(), d, KisCubicCurvePoint::isSetAsCorner(), p, KisCubicCurvePoint::x(), and KisCubicCurvePoint::y().
| bool KisCurveWidget::pointSelected | ( | ) | const |
|
signal |
Emitted whenever the status of whether a control point is selected or not changes
| KisCurveWidget::Private | ( | KisCurveWidget * | parent | ) |
Reset the curve to the default shape
Definition at line 168 of file kis_curve_widget.cpp.
References d, and pointSelectedChanged().
|
overrideprotected |
Definition at line 261 of file kis_curve_widget.cpp.
References d.
| bool KisCurveWidget::setCurrentPoint | ( | const QPointF & | position, |
| bool | setAsCorner ) |
Definition at line 77 of file kis_curve_widget.cpp.
References d, PointConstrain_AlwaysCorner, PointConstrain_None, and pointSelectedChanged().
| bool KisCurveWidget::setCurrentPointAsCorner | ( | bool | setAsCorner | ) |
Definition at line 113 of file kis_curve_widget.cpp.
References d, and PointConstrain_None.
| bool KisCurveWidget::setCurrentPointPosition | ( | const QPointF & | position | ) |
Definition at line 106 of file kis_curve_widget.cpp.
References d, and setCurrentPoint().
|
slot |
Replace the current curve with a curve specified by the curve defined by the control points in inlist.
Definition at line 524 of file kis_curve_widget.cpp.
References d, and pointSelectedChanged().
| void KisCurveWidget::setCurveModified | ( | bool | rewriteSpinBoxesValues = true | ) |
Common update routines
| void KisCurveWidget::setCurveRepaint | ( | ) |
| void KisCurveWidget::setGlobalPointConstrain | ( | PointConstrain | constrain | ) |
| void KisCurveWidget::setPixmap | ( | const QPixmap & | pix | ) |
Set a background pixmap. The background pixmap will be drawn under the grid and the curve.
XXX: or is the pixmap what is drawn to the left and bottom of the curve itself?
Definition at line 181 of file kis_curve_widget.cpp.
References d.
| void KisCurveWidget::setupInOutControls | ( | QSpinBox * | in, |
| QSpinBox * | out, | ||
| int | inMin, | ||
| int | inMax, | ||
| int | outMin, | ||
| int | outMax ) |
Connect/disconnect external spinboxes to the curve inMin / inMax - is the range for input values outMin / outMax - is the range for output values
|
signal |
|
signal |
|
protectedslot |
This function is called when compressorShouldEmitModified() is emitted. For why it's needed,
Definition at line 543 of file kis_curve_widget.cpp.
References d.
|
inline |
| void KisCurveWidget::syncIOControls | ( | ) |
Synchronize In/Out spinboxes with the curve
|
friend |
Definition at line 46 of file kis_curve_widget.h.
|
private |
Definition at line 175 of file kis_curve_widget.h.
| KisCubicCurve KisCurveWidget::m_curve |
Definition at line 42 of file kis_curve_widget_p.h.
|
private |
Definition at line 24 of file kis_curve_widget_p.h.
| KisCubicCurvePoint KisCurveWidget::m_draggedAwayPoint |
Definition at line 35 of file kis_curve_widget_p.h.
| int KisCurveWidget::m_draggedAwayPointIndex {0} |
Definition at line 36 of file kis_curve_widget_p.h.
| KisCurveWidget::PointConstrain KisCurveWidget::m_globalPointConstrain {KisCurveWidget::PointConstrain_None} |
Definition at line 43 of file kis_curve_widget_p.h.
| int KisCurveWidget::m_grab_point_index {-1} |
Definition at line 30 of file kis_curve_widget_p.h.
| double KisCurveWidget::m_grabOffsetX {0.0} |
Definition at line 31 of file kis_curve_widget_p.h.
| double KisCurveWidget::m_grabOffsetY {0.0} |
Definition at line 32 of file kis_curve_widget_p.h.
| double KisCurveWidget::m_grabOriginalX {0.0} |
Definition at line 33 of file kis_curve_widget_p.h.
| double KisCurveWidget::m_grabOriginalY {0.0} |
Definition at line 34 of file kis_curve_widget_p.h.
| int KisCurveWidget::m_handleSize {12} |
Definition at line 50 of file kis_curve_widget_p.h.
| KisThreadSafeSignalCompressor KisCurveWidget::m_modifiedSignalsCompressor |
Compresses the modified() signals
Definition at line 64 of file kis_curve_widget_p.h.
| QPixmap KisCurveWidget::m_pix |
Definition at line 45 of file kis_curve_widget_p.h.
| QPixmap* KisCurveWidget::m_pixmapCache {nullptr} |
Definition at line 47 of file kis_curve_widget_p.h.
| bool KisCurveWidget::m_pixmapDirty {true} |
Definition at line 46 of file kis_curve_widget_p.h.
| bool KisCurveWidget::m_readOnlyMode {false} |
Definition at line 38 of file kis_curve_widget_p.h.
| bool KisCurveWidget::m_splineDirty {false} |
Definition at line 41 of file kis_curve_widget_p.h.
| enumState KisCurveWidget::m_state {enumState::ST_NORMAL} |
State functions. At the moment used only for dragging.
Definition at line 56 of file kis_curve_widget_p.h.
|
read |
Definition at line 43 of file kis_curve_widget.h.