Krita Source Code Documentation
Loading...
Searching...
No Matches
MyPaintSensorPack.cpp File Reference
#include "MyPaintSensorPack.h"
#include <KisCppQuirks.h>
#include "KisSensorData.h"
#include "kis_assert.h"
#include <KisDynamicSensorFactoryRegistry.h>
#include <KisSimpleDynamicSensorFactory.h>
#include <KisCurveOptionDataCommon.h>
#include <libmypaint/mypaint-brush-settings-gen.h>
#include <libmypaint/mypaint-brush.h>
#include <kis_algebra_2d.h>
#include <MyPaintCurveRangeModel.h>
#include <QJsonDocument>
#include <QJsonObject>
#include <KisStaticInitializer.h>

Go to the source code of this file.

Namespaces

namespace  detail
 

Functions

 detail::addFactory (MyPaintAscensionId, -180, 180, "", "", i18n("%"))
 
 detail::addFactory (MyPaintCustomId, -20, 20, "", "", i18n("%"))
 
 detail::addFactory (MyPaintDeclinationId, 0, 90, "", "", i18n("%"))
 
 detail::addFactory (MyPaintDirectionId, 0, 180, "", "", "")
 
 detail::addFactory (MyPaintFineSpeedId, -20, 20, "", "", "")
 
 detail::addFactory (MyPaintGrossSpeedId, -20, 20, "", "", "")
 
 detail::addFactory (MyPaintPressureId, 0, 20, "", "", "")
 
 detail::addFactory (MyPaintRandomId, 0, 1, "", "", "")
 
 detail::addFactory (MyPaintStrokeId, 0, 1, "", "", "")
 
MyPaintBrushSetting optionIdToMyPaintBrushSettings (const KoID &id)
 
MyPaintBrushInput sensorIdToMyPaintBrushInput (const KoID &id)
 
QString sensorIdToMyPaintBrushInputJsonKey (const KoID &id)
 
template<typename Data , typename SensorData = std::copy_const_t<Data, KisSensorData>>
std::vector< SensorData * > detail::sensors (Data *data)
 

Variables

 detail::KIS_DECLARE_STATIC_INITIALIZER
 

Function Documentation

◆ optionIdToMyPaintBrushSettings()

MyPaintBrushSetting optionIdToMyPaintBrushSettings ( const KoID & id)

Definition at line 236 of file MyPaintSensorPack.cpp.

236 {
237 if (id.id() == "eraser")
238 return MYPAINT_BRUSH_SETTING_ERASER;
239 else if (id.id() == "opaque")
240 return MYPAINT_BRUSH_SETTING_OPAQUE;
241 else if (id.id() == "smudge")
242 return MYPAINT_BRUSH_SETTING_SMUDGE;
243 else if (id.id() == "color_h")
244 return MYPAINT_BRUSH_SETTING_COLOR_H;
245 else if (id.id() == "color_s")
246 return MYPAINT_BRUSH_SETTING_COLOR_S;
247 else if (id.id() == "color_v")
248 return MYPAINT_BRUSH_SETTING_COLOR_V;
249 else if (id.id() == "colorize")
250 return MYPAINT_BRUSH_SETTING_COLORIZE;
251 else if (id.id() == "hardness")
252 return MYPAINT_BRUSH_SETTING_HARDNESS;
253 else if (id.id() == "speed1_gamma")
254 return MYPAINT_BRUSH_SETTING_SPEED1_GAMMA;
255 else if (id.id() == "speed2_gamma")
256 return MYPAINT_BRUSH_SETTING_SPEED2_GAMMA;
257 else if (id.id() == "anti_aliasing")
258 return MYPAINT_BRUSH_SETTING_ANTI_ALIASING;
259 else if (id.id() == "restore_color")
260 return MYPAINT_BRUSH_SETTING_RESTORE_COLOR;
261 else if (id.id() == "slow_tracking")
262 return MYPAINT_BRUSH_SETTING_SLOW_TRACKING;
263 else if (id.id() == "smudge_length")
264 return MYPAINT_BRUSH_SETTING_SMUDGE_LENGTH;
265 else if (id.id() == "snap_to_pixel")
266 return MYPAINT_BRUSH_SETTING_SNAP_TO_PIXEL;
267 else if (id.id() == "change_color_h")
268 return MYPAINT_BRUSH_SETTING_CHANGE_COLOR_H;
269 else if (id.id() == "change_color_l")
270 return MYPAINT_BRUSH_SETTING_CHANGE_COLOR_L;
271 else if (id.id() == "change_color_v")
272 return MYPAINT_BRUSH_SETTING_CHANGE_COLOR_V;
273 else if (id.id() == "tracking_noise")
274 return MYPAINT_BRUSH_SETTING_TRACKING_NOISE;
275 else if (id.id() == "dabs_per_second")
276 return MYPAINT_BRUSH_SETTING_DABS_PER_SECOND;
277 else if (id.id() == "offset_by_speed")
278 return MYPAINT_BRUSH_SETTING_OFFSET_BY_SPEED;
279 else if (id.id() == "opaque_multiply")
280 return MYPAINT_BRUSH_SETTING_OPAQUE_MULTIPLY;
281 else if (id.id() == "speed1_slowness")
282 return MYPAINT_BRUSH_SETTING_SPEED1_SLOWNESS;
283 else if (id.id() == "speed2_slowness")
284 return MYPAINT_BRUSH_SETTING_SPEED2_SLOWNESS;
285 else if (id.id() == "stroke_holdtime")
286 return MYPAINT_BRUSH_SETTING_STROKE_HOLDTIME;
287 else if (id.id() == "direction_filter")
288 return MYPAINT_BRUSH_SETTING_DIRECTION_FILTER;
289 else if (id.id() == "offset_by_random")
290 return MYPAINT_BRUSH_SETTING_OFFSET_BY_RANDOM;
291 else if (id.id() == "opaque_linearize")
292 return MYPAINT_BRUSH_SETTING_OPAQUE_LINEARIZE;
293 else if (id.id() == "radius_by_random")
294 return MYPAINT_BRUSH_SETTING_RADIUS_BY_RANDOM;
295 else if (id.id() == "stroke_threshold")
296 return MYPAINT_BRUSH_SETTING_STROKE_THRESHOLD;
297 else if (id.id() == "pressure_gain_log")
298 return MYPAINT_BRUSH_SETTING_PRESSURE_GAIN_LOG;
299 else if (id.id() == "smudge_radius_log")
300 return MYPAINT_BRUSH_SETTING_SMUDGE_RADIUS_LOG;
301 else if (id.id() == "change_color_hsl_s")
302 return MYPAINT_BRUSH_SETTING_CHANGE_COLOR_HSL_S;
303 else if (id.id() == "change_color_hsv_s")
304 return MYPAINT_BRUSH_SETTING_CHANGE_COLOR_HSV_S;
305 else if (id.id() == "radius_logarithmic")
306 return MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC;
307 else if (id.id() == "elliptical_dab_angle")
308 return MYPAINT_BRUSH_SETTING_ELLIPTICAL_DAB_ANGLE;
309 else if (id.id() == "elliptical_dab_ratio")
310 return MYPAINT_BRUSH_SETTING_ELLIPTICAL_DAB_RATIO;
311 else if (id.id() == "custom_input_slowness")
312 return MYPAINT_BRUSH_SETTING_CUSTOM_INPUT_SLOWNESS;
313 else if (id.id() == "custom_input")
314 return MYPAINT_BRUSH_SETTING_CUSTOM_INPUT;
315 else if (id.id() == "dabs_per_basic_radius")
316 return MYPAINT_BRUSH_SETTING_DABS_PER_BASIC_RADIUS;
317 else if (id.id() == "slow_tracking_per_dab")
318 return MYPAINT_BRUSH_SETTING_SLOW_TRACKING_PER_DAB;
319 else if (id.id() == "dabs_per_actual_radius")
320 return MYPAINT_BRUSH_SETTING_DABS_PER_ACTUAL_RADIUS;
321 else if (id.id() == "offset_by_speed_slowness")
322 return MYPAINT_BRUSH_SETTING_OFFSET_BY_SPEED_SLOWNESS;
323 else if (id.id() == "stroke_duration_logarithmic")
324 return MYPAINT_BRUSH_SETTING_STROKE_DURATION_LOGARITHMIC;
325 else if (id.id() == "smudge_length_log")
326 return MYPAINT_BRUSH_SETTING_SMUDGE_LENGTH_LOG;
327 else if (id.id() == "smudge_bucket")
328 return MYPAINT_BRUSH_SETTING_SMUDGE_BUCKET;
329 else if (id.id() == "smudge_transparency")
330 return MYPAINT_BRUSH_SETTING_SMUDGE_TRANSPARENCY;
331 else if (id.id() == "posterize")
332 return MYPAINT_BRUSH_SETTING_POSTERIZE;
333 else if (id.id() == "posterize_num")
334 return MYPAINT_BRUSH_SETTING_POSTERIZE_NUM;
335
336 return MYPAINT_BRUSH_SETTING_ERASER;
337}

◆ sensorIdToMyPaintBrushInput()

MyPaintBrushInput sensorIdToMyPaintBrushInput ( const KoID & id)

Definition at line 178 of file MyPaintSensorPack.cpp.

179{
180 MyPaintBrushInput result = MYPAINT_BRUSH_INPUT_PRESSURE;
181
182 if (id == MyPaintPressureId) {
183 result = MYPAINT_BRUSH_INPUT_PRESSURE;
184 } else if (id == MyPaintFineSpeedId) {
185 result = MYPAINT_BRUSH_INPUT_SPEED1;
186 } else if (id == MyPaintGrossSpeedId) {
187 result = MYPAINT_BRUSH_INPUT_SPEED2;
188 } else if (id == MyPaintRandomId) {
189 result = MYPAINT_BRUSH_INPUT_RANDOM;
190 } else if (id == MyPaintStrokeId) {
191 result = MYPAINT_BRUSH_INPUT_STROKE;
192 } else if (id == MyPaintDirectionId) {
193 result = MYPAINT_BRUSH_INPUT_DIRECTION;
194 } else if (id == MyPaintDeclinationId) {
195 result = MYPAINT_BRUSH_INPUT_TILT_DECLINATION;
196 } else if (id == MyPaintAscensionId) {
197 result = MYPAINT_BRUSH_INPUT_TILT_ASCENSION;
198 } else if (id == MyPaintCustomId) {
199 result = MYPAINT_BRUSH_INPUT_CUSTOM;
200 } else {
201 qWarning() << "sensorIdToMyPaintBrushInput: unknown sensor id";
202 }
203
204 return result;
205}
const KoID MyPaintDeclinationId("mypaint_tilt_declination", ki18nc("Pen tilt declination", "Declination"))
const KoID MyPaintCustomId("mypaint_custom", ki18n("Custom"))
const KoID MyPaintDirectionId("mypaint_direction", ki18nc("Drawing Angle", "Direction"))
const KoID MyPaintAscensionId("mypaint_tilt_ascension", ki18nc("Pen tilt ascension", "Ascension"))
const KoID MyPaintPressureId("mypaint_pressure", ki18n("Pressure"))
const KoID MyPaintStrokeId("mypaint_stroke", ki18nc("The duration of a brush stroke", "Stroke"))
const KoID MyPaintRandomId("mypaint_random", ki18n("Random"))
const KoID MyPaintGrossSpeedId("mypaint_speed2", ki18n("Gross Speed"))
const KoID MyPaintFineSpeedId("mypaint_speed1", ki18n("Fine Speed"))

References MyPaintAscensionId(), MyPaintCustomId(), MyPaintDeclinationId(), MyPaintDirectionId(), MyPaintFineSpeedId(), MyPaintGrossSpeedId(), MyPaintPressureId(), MyPaintRandomId(), and MyPaintStrokeId().

◆ sensorIdToMyPaintBrushInputJsonKey()

QString sensorIdToMyPaintBrushInputJsonKey ( const KoID & id)

Definition at line 207 of file MyPaintSensorPack.cpp.

208{
209 QString result = "pressure";
210
211 if (id == MyPaintPressureId) {
212 result = "pressure";
213 } else if (id == MyPaintFineSpeedId) {
214 result = "speed1";
215 } else if (id == MyPaintGrossSpeedId) {
216 result = "speed2";
217 } else if (id == MyPaintRandomId) {
218 result = "random";
219 } else if (id == MyPaintStrokeId) {
220 result = "stroke";
221 } else if (id == MyPaintDirectionId) {
222 result = "direction";
223 } else if (id == MyPaintDeclinationId) {
224 result = "tilt_declination";
225 } else if (id == MyPaintAscensionId) {
226 result = "tilt_ascension";
227 } else if (id == MyPaintCustomId) {
228 result = "custom";
229 } else {
230 qWarning() << "sensorIdToMyPaintBrushInputJsonKey: unknown sensor id";
231 }
232
233 return result;
234}

References MyPaintAscensionId(), MyPaintCustomId(), MyPaintDeclinationId(), MyPaintDirectionId(), MyPaintFineSpeedId(), MyPaintGrossSpeedId(), MyPaintPressureId(), MyPaintRandomId(), and MyPaintStrokeId().