File indexing completed on 2024-12-22 04:16:22

0001 /*
0002  *  SPDX-FileCopyrightText: 2022 Agata Cacko <cacko.azh@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 #include "KisSprayOpOptionModel.h"
0007 
0008 #include <KisLager.h>
0009 
0010 
0011 namespace {
0012 
0013 auto angularDistributionTypeToInt = lager::lenses::getset(
0014 [] (const KisSprayOpOptionData::ParticleDistribution source) -> int
0015 {
0016     if (source == KisSprayOpOptionData::ParticleDistribution_Uniform) {
0017         return 0;
0018     } else { // source == KisSprayOpOptionData::ParticleDistribution_CurveBased
0019         return 1;
0020     }
0021 },
0022 [] (KisSprayOpOptionData::ParticleDistribution dst, int currentValue)
0023 {
0024     if (currentValue == 0) {
0025         dst = KisSprayOpOptionData::ParticleDistribution_Uniform;
0026     } else { // == 1
0027         dst = KisSprayOpOptionData::ParticleDistribution_CurveBased;
0028     }
0029 
0030     return dst;
0031 }
0032 );
0033 
0034 }
0035 
0036 
0037 KisSprayOpOptionModel::KisSprayOpOptionModel(lager::cursor<KisSprayOpOptionData> _optionData)
0038     : optionData(_optionData)
0039     , LAGER_QT(diameter) {_optionData[&KisSprayOpOptionData::diameter].zoom(kislager::lenses::do_static_cast<quint16, int>)}
0040     , LAGER_QT(aspect) {_optionData[&KisSprayOpOptionData::aspect]}
0041     , LAGER_QT(brushRotation) {_optionData[&KisSprayOpOptionData::brushRotation]}
0042     , LAGER_QT(scale) {_optionData[&KisSprayOpOptionData::scale]}
0043     , LAGER_QT(spacing) {_optionData[&KisSprayOpOptionData::spacing]}
0044     , LAGER_QT(jitterMovement) {_optionData[&KisSprayOpOptionData::jitterMovement]}
0045     , LAGER_QT(jitterAmount) {_optionData[&KisSprayOpOptionData::jitterAmount]}
0046     , LAGER_QT(useDensity) {_optionData[&KisSprayOpOptionData::useDensity]}
0047     , LAGER_QT(isNumParticlesVisible) {LAGER_QT(useDensity).map(std::logical_not<>{})}
0048     , LAGER_QT(particleCount) {_optionData[&KisSprayOpOptionData::particleCount].zoom(kislager::lenses::do_static_cast<quint16, int>)}
0049     , LAGER_QT(coverage) {_optionData[&KisSprayOpOptionData::coverage]}
0050     
0051     , LAGER_QT(angularDistributionType) {_optionData[&KisSprayOpOptionData::angularDistributionType]
0052         .zoom(angularDistributionTypeToInt)}
0053     , LAGER_QT(angularDistributionCurve) {_optionData[&KisSprayOpOptionData::angularDistributionCurve]}
0054     , LAGER_QT(angularDistributionCurveRepeat) {_optionData[&KisSprayOpOptionData::angularDistributionCurveRepeat]}
0055     , LAGER_QT(radialDistributionType) {_optionData[&KisSprayOpOptionData::radialDistributionType]
0056         .zoom(kislager::lenses::do_static_cast<KisSprayOpOptionData::ParticleDistribution, int>)}
0057     , LAGER_QT(radialDistributionStdDeviation) {_optionData[&KisSprayOpOptionData::radialDistributionStdDeviation]}
0058     , LAGER_QT(radialDistributionClusteringAmount) {_optionData[&KisSprayOpOptionData::radialDistributionClusteringAmount]}
0059     , LAGER_QT(radialDistributionCurve) {_optionData[&KisSprayOpOptionData::radialDistributionCurve]}
0060     , LAGER_QT(radialDistributionCurveRepeat) {_optionData[&KisSprayOpOptionData::radialDistributionCurveRepeat]}
0061     , LAGER_QT(radialDistributionCenterBiased) {_optionData[&KisSprayOpOptionData::radialDistributionCenterBiased]}
0062     
0063 {
0064 }