|
Krita Source Code Documentation
|
The KisSpinBoxUnitManager class is an abstract interface for the unitspinboxes classes to manage different type of units. More...
#include <kis_spin_box_unit_manager.h>
Inheritance diagram for KisSpinBoxUnitManager:Public Types | |
| enum | Constrain { NOCONSTR = 0 , REFISINT = 1 , VALISINT = 2 } |
| enum | UnitDimension { LENGTH = 0 , IMLENGTH = 1 , ANGLE = 2 , TIME = 3 } |
Public Slots | |
| void | clearSyncWithOtherUnitManager (KisSpinBoxUnitManager *other) |
| void | selectApparentUnitFromIndex (int index) |
| void | setApparentUnitFromSymbol (QString pSymbol) |
| void | setUnitDimension (UnitDimension dimension) |
| void | syncWithOtherUnitManager (KisSpinBoxUnitManager *other) |
Signals | |
| void | conversionConstantChanged (qreal newConversionFactor, qreal oldConversionFactor) const |
| void | conversionFactorChanged (qreal newConversionFactor, qreal oldConversionFactor) const |
| void | unitAboutToChange () |
| void | unitChanged (int index) |
| void | unitChanged (QString symbol) |
| void | unitDimensionChanged (int dimCode) |
| void | unitListChanged () |
Public Member Functions | |
| QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
| int | getApparentUnitId () const |
| get the position of the apparent unit in the list of units. It is useful if we want to build a model for combo-box based unit management. | |
| int | getApparentUnitRecommendedDecimals () const |
| get a hint of how many decimals the spinbox needs to display. | |
| QString | getApparentUnitSymbol () const |
| qreal | getApparentValue (double refValue) const |
| virtual qreal | getConversionConstant (int dim, QString symbol) const |
| some units conversions are done via an affine transform, not just a linear transform. This function gives the constant of this affine transform (usually 0). | |
| virtual qreal | getConversionFactor (int dim, QString symbol) const |
| gets the conversion factor of a managed unit, or -1 in case of error. This method is the one that needs to be overridden to extend the ability of the KisSpinBoxUnitManager. | |
| QString | getReferenceUnitSymbol () const |
| qreal | getReferenceValue (double apparentValue) const |
| virtual QStringList | getsUnitSymbolList (bool withName=false) const |
| int | getUnitDimensionType () const |
| KisSpinBoxUnitManager (QObject *parent=0) | |
| Private (KisSpinBoxUnitManager::UnitDimension pDim=KisSpinBoxUnitManager::LENGTH, QString pUnitSymbol="pt", double pConv=1.0) | |
| int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
| ~KisSpinBoxUnitManager () override | |
Static Public Member Functions | |
| static bool | isUnitId (int code) |
Static Public Attributes | |
| static const QStringList | referenceUnitSymbols = {"pt", "px", "°", "frame"} |
| this list holds the symbols of the reference unit per dimension. The index is equal to the value in UnitDimension so that the dimension name can be used to index the list. | |
Protected Member Functions | |
| void | grantDocumentRelativeUnits () |
| calling this method gives access to document relative units. Only subclasses that manage those units should call it. | |
| virtual bool | hasPercent (int unitDim) const |
| indicate if the unit manager has some kind of way of using a percent unit, used by the main class to add percent when necessary. | |
| void | newUnitSymbolToUnitIndex (QString symbol) |
| convert a unitChanged signal with a QString to one with an index. | |
| void | recomputeConversionConstant () const |
| void | recomputeConversionFactor () const |
Protected Attributes | |
| Private * | d |
Static Protected Attributes | |
| static const QStringList | documentRelativeLengthUnitSymbols = {"px", "vw", "vh"} |
| static const QStringList | documentRelativeTimeUnitSymbols = {"s", "%"} |
Additional Inherited Members | |
Private Member Functions inherited from Private | |
| Private (KisCanvas2 *c) | |
Private Attributes inherited from Private | |
| KisCanvas2 * | canvas |
| int | displayedFrame |
| int | intendedFrame |
The KisSpinBoxUnitManager class is an abstract interface for the unitspinboxes classes to manage different type of units.
The class differentiates between unit dimension (distance, angle, time).
The class allows to convert values between reference unit and apparent unit, but also to get other information like possible units symbols.
This class doesn't allow to use relative units (units whose conversion factor is dependent of the context), even if it's private data is prepared to manage it. The reason for this is that from the library of this class it is very hard to easily access the information needed. So all will be managed by subclasses in other libs.
The class is a subclass of QAbstractListModel, so that available list of units is easily accessed by other Qt standard components, like QComboBoxes.
Definition at line 54 of file kis_spin_box_unit_manager.cpp.
| Enumerator | |
|---|---|
| NOCONSTR | |
| REFISINT | |
| VALISINT | |
Definition at line 84 of file kis_spin_box_unit_manager.h.
| Enumerator | |
|---|---|
| LENGTH | |
| IMLENGTH | |
| ANGLE | |
| TIME | |
Definition at line 72 of file kis_spin_box_unit_manager.h.
|
explicit |
Definition at line 92 of file kis_spin_box_unit_manager.cpp.
References connect(), d, newUnitSymbolToUnitIndex(), and unitChanged().
|
override |
|
slot |
Definition at line 541 of file kis_spin_box_unit_manager.cpp.
References d, dim, selectApparentUnitFromIndex(), and unitChanged().
|
signal |
|
signal |
|
override |
Definition at line 304 of file kis_spin_box_unit_manager.cpp.
References dim, and getsUnitSymbolList().
| int KisSpinBoxUnitManager::getApparentUnitId | ( | ) | const |
get the position of the apparent unit in the list of units. It is useful if we want to build a model for combo-box based unit management.
Definition at line 118 of file kis_spin_box_unit_manager.cpp.
References d, and getsUnitSymbolList().
| int KisSpinBoxUnitManager::getApparentUnitRecommendedDecimals | ( | ) | const |
get a hint of how many decimals the spinbox needs to display.
Definition at line 124 of file kis_spin_box_unit_manager.cpp.
| QString KisSpinBoxUnitManager::getApparentUnitSymbol | ( | ) | const |
Definition at line 113 of file kis_spin_box_unit_manager.cpp.
References d.
Definition at line 319 of file kis_spin_box_unit_manager.cpp.
References d, dim, recomputeConversionConstant(), recomputeConversionFactor(), v, and VALISINT.
some units conversions are done via an affine transform, not just a linear transform. This function gives the constant of this affine transform (usually 0).
Reimplemented in KisDocumentAwareSpinBoxUnitManager.
Definition at line 269 of file kis_spin_box_unit_manager.cpp.
References dim.
gets the conversion factor of a managed unit, or -1 in case of error. This method is the one that needs to be overridden to extend the ability of the KisSpinBoxUnitManager.
Reimplemented in KisDocumentAwareSpinBoxUnitManager.
Definition at line 338 of file kis_spin_box_unit_manager.cpp.
References ANGLE, dim, KoUnit::fromSymbol(), IMLENGTH, LENGTH, TIME, and KoUnit::toUserValuePrecise().
| QString KisSpinBoxUnitManager::getReferenceUnitSymbol | ( | ) | const |
Definition at line 108 of file kis_spin_box_unit_manager.cpp.
References d, and referenceUnitSymbols.
Definition at line 277 of file kis_spin_box_unit_manager.cpp.
References d, dim, recomputeConversionConstant(), recomputeConversionFactor(), REFISINT, and v.
|
virtual |
Definition at line 148 of file kis_spin_box_unit_manager.cpp.
References ANGLE, d, dim, documentRelativeLengthUnitSymbols, documentRelativeTimeUnitSymbols, hasPercent(), IMLENGTH, LENGTH, percentStr(), KoUnit::Pixel, KoUnit::symbol(), TIME, KoUnit::TypeCount, and KoUnit::unitDescription().
| int KisSpinBoxUnitManager::getUnitDimensionType | ( | ) | const |
Definition at line 103 of file kis_spin_box_unit_manager.cpp.
References d.
|
protected |
calling this method gives access to document relative units. Only subclasses that manage those units should call it.
Definition at line 611 of file kis_spin_box_unit_manager.cpp.
References d.
indicate if the unit manager has some kind of way of using a percent unit, used by the main class to add percent when necessary.
Reimplemented in KisDocumentAwareSpinBoxUnitManager.
Definition at line 564 of file kis_spin_box_unit_manager.cpp.
|
protected |
convert a unitChanged signal with a QString to one with an index.
Definition at line 556 of file kis_spin_box_unit_manager.cpp.
References dim, getsUnitSymbolList(), and unitChanged().
|
inline |
Definition at line 57 of file kis_spin_box_unit_manager.cpp.
|
protected |
Definition at line 596 of file kis_spin_box_unit_manager.cpp.
References conversionConstantChanged(), d, dim, and getConversionConstant().
|
protected |
Definition at line 581 of file kis_spin_box_unit_manager.cpp.
References conversionFactorChanged(), d, dim, and getConversionFactor().
Definition at line 297 of file kis_spin_box_unit_manager.cpp.
References getsUnitSymbolList().
Definition at line 513 of file kis_spin_box_unit_manager.cpp.
References getsUnitSymbolList(), rowCount(), and setApparentUnitFromSymbol().
|
slot |
Definition at line 415 of file kis_spin_box_unit_manager.cpp.
References ANGLE, conversionFactorChanged(), d, dim, documentRelativeLengthUnitSymbols, documentRelativeTimeUnitSymbols, getConversionFactor(), getsUnitSymbolList(), IMLENGTH, LENGTH, TIME, unitAboutToChange(), and unitChanged().
|
slot |
Definition at line 401 of file kis_spin_box_unit_manager.cpp.
References d, dim, referenceUnitSymbols, and unitDimensionChanged().
|
slot |
Definition at line 522 of file kis_spin_box_unit_manager.cpp.
References connect(), d, dim, getsUnitSymbolList(), getUnitDimensionType(), selectApparentUnitFromIndex(), and unitChanged().
|
signal |
|
signal |
|
signal |
Definition at line 87 of file kis_spin_box_unit_manager.cpp.
| QVector<KisSpinBoxUnitManager*> KisSpinBoxUnitManager::connectedUnitManagers |
Definition at line 89 of file kis_spin_box_unit_manager.cpp.
| KisSpinBoxUnitManager::Constrains KisSpinBoxUnitManager::constrains { KisSpinBoxUnitManager::NOCONSTR } |
Definition at line 75 of file kis_spin_box_unit_manager.cpp.
|
mutable |
Definition at line 72 of file kis_spin_box_unit_manager.cpp.
Definition at line 73 of file kis_spin_box_unit_manager.cpp.
|
mutable |
Definition at line 70 of file kis_spin_box_unit_manager.cpp.
Definition at line 71 of file kis_spin_box_unit_manager.cpp.
|
protected |
Definition at line 141 of file kis_spin_box_unit_manager.h.
| KisSpinBoxUnitManager::UnitDimension KisSpinBoxUnitManager::dim |
Definition at line 67 of file kis_spin_box_unit_manager.cpp.
|
staticprotected |
Definition at line 51 of file kis_spin_box_unit_manager.h.
|
staticprotected |
Definition at line 52 of file kis_spin_box_unit_manager.h.
Definition at line 84 of file kis_spin_box_unit_manager.cpp.
| qreal KisSpinBoxUnitManager::hundredPercent {0} |
Definition at line 85 of file kis_spin_box_unit_manager.cpp.
|
static |
this list holds the symbols of the reference unit per dimension. The index is equal to the value in UnitDimension so that the dimension name can be used to index the list.
Definition at line 49 of file kis_spin_box_unit_manager.h.
|
mutable |
Definition at line 77 of file kis_spin_box_unit_manager.cpp.
Definition at line 78 of file kis_spin_box_unit_manager.cpp.
|
mutable |
Definition at line 80 of file kis_spin_box_unit_manager.cpp.
Definition at line 81 of file kis_spin_box_unit_manager.cpp.
| QString KisSpinBoxUnitManager::unitSymbol |
Definition at line 69 of file kis_spin_box_unit_manager.cpp.