Changeset View
Changeset View
Standalone View
Standalone View
libs/image/kis_distance_information.h
Context not available. | |||||
22 | 22 | | |||
---|---|---|---|---|---|
23 | #include <QPointF> | 23 | #include <QPointF> | ||
24 | #include <QVector2D> | 24 | #include <QVector2D> | ||
25 | #include <QDomDocument> | ||||
26 | #include <QDomElement> | ||||
25 | #include "kritaimage_export.h" | 27 | #include "kritaimage_export.h" | ||
26 | 28 | | |||
27 | class KisPaintInformation; | 29 | class KisPaintInformation; | ||
30 | class KisDistanceInformation; | ||||
28 | 31 | | |||
32 | /** | ||||
33 | * A time in milliseconds that is assumed to be longer than any stroke (or other paint operation) | ||||
34 | * will ever last. This is used instead of infinity to avoid potential errors. The value is | ||||
35 | * approximately ten years. | ||||
36 | */ | ||||
37 | const qreal LONG_TIME = 320000000000.0; | ||||
29 | 38 | | |||
30 | /** | 39 | /** | ||
31 | * This structure contains information about the desired spacing | 40 | * This structure contains information about the desired spacing | ||
Context not available. | |||||
134 | } | 143 | } | ||
135 | 144 | | |||
136 | /** | 145 | /** | ||
137 | * @return The desired maximum amount of time between dabs, in milliseconds. Returns a time of | 146 | * @return The desired maximum amount of time between dabs, in milliseconds. Returns LONG_TIME | ||
138 | * approximately 1 year if time-based spacing is disabled. | 147 | * if time-based spacing is disabled. | ||
139 | */ | 148 | */ | ||
140 | inline qreal timedSpacingInterval() const { | 149 | inline qreal timedSpacingInterval() const { | ||
141 | return isTimedSpacingEnabled() ? | 150 | return isTimedSpacingEnabled() ? | ||
142 | m_timedSpacingInterval : | 151 | m_timedSpacingInterval : | ||
143 | 32000000000.0; | 152 | LONG_TIME; | ||
144 | } | 153 | } | ||
145 | 154 | | |||
146 | inline bool isIsotropic() const { | 155 | inline bool isIsotropic() const { | ||
Context not available. | |||||
174 | }; | 183 | }; | ||
175 | 184 | | |||
176 | /** | 185 | /** | ||
186 | * Represents some information that can be used to initialize a KisDistanceInformation object. The | ||||
187 | * main purpose of this class is to allow serialization of KisDistanceInformation initial settings | ||||
188 | * to XML. | ||||
189 | */ | ||||
190 | class KRITAIMAGE_EXPORT KisDistanceInitInfo { | ||||
191 | | ||||
192 | public: | ||||
193 | | ||||
194 | /** | ||||
195 | * Creates a KisDistanceInitInfo with no initial last dab information, and spacing update | ||||
196 | * interval set to LONG_TIME. | ||||
197 | */ | ||||
198 | explicit KisDistanceInitInfo(); | ||||
199 | | ||||
200 | /** | ||||
201 | * Creates a KisDistanceInitInfo with no initial last dab information, and the specified spacing | ||||
202 | * update interval. | ||||
203 | */ | ||||
204 | explicit KisDistanceInitInfo(qreal spacingUpdateInterval); | ||||
205 | | ||||
206 | /** | ||||
207 | * Creates a KisDistanceInitInfo with the specified last dab information, and spacing update | ||||
208 | * interval set to LONG_TIME. | ||||
209 | */ | ||||
210 | explicit KisDistanceInitInfo(const QPointF &lastPosition, qreal lastTime, qreal lastAngle); | ||||
211 | | ||||
212 | /** | ||||
213 | * Creates a KisDistanceInitInfo with the specified last dab information and spacing update | ||||
214 | * interval. | ||||
215 | */ | ||||
216 | explicit KisDistanceInitInfo(const QPointF &lastPosition, qreal lastTime, qreal lastAngle, | ||||
217 | qreal spacingUpdateInterval); | ||||
218 | | ||||
219 | bool operator==(const KisDistanceInitInfo &other) const; | ||||
220 | | ||||
221 | bool operator!=(const KisDistanceInitInfo &other) const; | ||||
222 | | ||||
223 | /** | ||||
224 | * Constructs a KisDistanceInformation with initial settings based on this object. | ||||
225 | */ | ||||
226 | KisDistanceInformation makeDistInfo(); | ||||
227 | | ||||
228 | void toXML(QDomDocument &doc, QDomElement &elt) const; | ||||
229 | | ||||
230 | static KisDistanceInitInfo fromXML(const QDomElement &elt); | ||||
231 | | ||||
232 | private: | ||||
233 | // Indicates whether lastPosition, lastTime, and lastAngle are valid or not. | ||||
234 | bool m_hasLastInfo; | ||||
235 | | ||||
236 | QPointF m_lastPosition; | ||||
237 | qreal m_lastTime; | ||||
238 | qreal m_lastAngle; | ||||
239 | | ||||
240 | qreal m_spacingUpdateInterval; | ||||
241 | }; | ||||
242 | | ||||
243 | /** | ||||
177 | * This structure is used as return value of paintLine to contain | 244 | * This structure is used as return value of paintLine to contain | ||
178 | * information that is needed to be passed for the next call. | 245 | * information that is needed to be passed for the next call. | ||
179 | */ | 246 | */ | ||
180 | class KRITAIMAGE_EXPORT KisDistanceInformation { | 247 | class KRITAIMAGE_EXPORT KisDistanceInformation { | ||
181 | public: | 248 | public: | ||
182 | KisDistanceInformation(); | 249 | KisDistanceInformation(); | ||
250 | KisDistanceInformation(qreal spacingUpdateInterval); | ||||
183 | KisDistanceInformation(const QPointF &lastPosition, qreal lastTime, qreal lastAngle); | 251 | KisDistanceInformation(const QPointF &lastPosition, qreal lastTime, qreal lastAngle); | ||
252 | /** | ||||
253 | * @param spacingUpdateInterval The amount of time allowed between spacing updates, in | ||||
254 | * milliseconds. Only used when timed spacing is enabled. | ||||
255 | */ | ||||
256 | KisDistanceInformation(const QPointF &lastPosition, qreal lastTime, qreal lastAngle, | ||||
257 | qreal spacingUpdateInterval); | ||||
184 | KisDistanceInformation(const KisDistanceInformation &rhs); | 258 | KisDistanceInformation(const KisDistanceInformation &rhs); | ||
185 | KisDistanceInformation(const KisDistanceInformation &rhs, int levelOfDetail); | 259 | KisDistanceInformation(const KisDistanceInformation &rhs, int levelOfDetail); | ||
186 | KisDistanceInformation& operator=(const KisDistanceInformation &rhs); | 260 | KisDistanceInformation& operator=(const KisDistanceInformation &rhs); | ||
Context not available. | |||||
188 | ~KisDistanceInformation(); | 262 | ~KisDistanceInformation(); | ||
189 | 263 | | |||
190 | const KisSpacingInformation& currentSpacing() const; | 264 | const KisSpacingInformation& currentSpacing() const; | ||
265 | void setSpacing(const KisSpacingInformation &spacing); | ||||
266 | /** | ||||
267 | * Returns true if this KisDistanceInformation should have its spacing information updated | ||||
268 | * immediately (regardless of whether a dab is ready to be painted). | ||||
269 | */ | ||||
270 | bool needsSpacingUpdate() const; | ||||
271 | | ||||
191 | bool hasLastDabInformation() const; | 272 | bool hasLastDabInformation() const; | ||
192 | QPointF lastPosition() const; | 273 | QPointF lastPosition() const; | ||
193 | qreal lastTime() const; | 274 | qreal lastTime() const; | ||
Context not available. |