Krita Source Code Documentation
Loading...
Searching...
No Matches
psd_vector_stroke_data Struct Reference

#include <psd_additional_layer_info_block.h>

Public Member Functions

void appendToDashPattern (double val)
 
QDomDocument getASLXML ()
 
void loadFromShapeStroke (KoShapeStrokeSP stroke)
 
void setFillEnabled (bool enabled)
 
void setLineCapType (const QString val)
 
void setLineJoinType (const QString val)
 
void setOpacityFromPercentage (double o)
 
void setResolution (double res)
 
void setScaleLock (bool enabled)
 
void setStrokeAdjust (bool enabled)
 
void setStrokeDashOffset (double dashOffset)
 
void setStrokeEnabled (bool enabled)
 
void setStrokeMiterLimit (double limit)
 
void setStrokePixel (double width)
 
void setStrokeWidth (double width)
 
void setupShapeStroke (KoShapeStrokeSP stroke)
 
void setVersion (int version)
 

Static Public Member Functions

static void setupCatcher (const QString path, KisAslCallbackObjectCatcher &catcher, psd_vector_stroke_data *data)
 

Public Attributes

QVector< double > dashPattern
 
bool fillEnabled {true}
 
bool gradient {false}
 
double opacity {1.0}
 
QPen pen
 
bool pixelWidth {false}
 
double resolution {72.0}
 
bool scaleLock {false}
 
bool strokeAdjust {false}
 
bool strokeEnabled {false}
 
int strokeVersion {2}
 

Detailed Description

Definition at line 983 of file psd_additional_layer_info_block.h.

Member Function Documentation

◆ appendToDashPattern()

void psd_vector_stroke_data::appendToDashPattern ( double val)
inline

Definition at line 1055 of file psd_additional_layer_info_block.h.

1055 {
1056 // QPen doesn't like 0 in the dash pattern,
1057 // even though it's necessary for some styles
1058 dashPattern.append(qMax(val, 1e-6));
1059 }

◆ getASLXML()

QDomDocument psd_vector_stroke_data::getASLXML ( )
inline

Definition at line 1096 of file psd_additional_layer_info_block.h.

1096 {
1098 w.enterDescriptor("", "", "strokeStyle");
1099
1100 w.writeInteger("strokeStyleVersion", 2);
1101 w.writeBoolean("strokeEnabled", strokeEnabled);
1102 w.writeBoolean("fillEnabled", fillEnabled);
1103
1104 w.writeUnitFloat("strokeStyleLineWidth", "#Pxl", pen.widthF() * (resolution / 72.0));
1105 w.writeUnitFloat("strokeStyleLineDashOffset ", "#Pnt", pen.dashOffset());
1106 w.writeDouble("strokeStyleMiterLimit", pen.miterLimit());
1107
1108 QString linecap = "strokeStyleButtCap";
1109 if (pen.capStyle() == Qt::SquareCap) {
1110 linecap = "strokeStyleSquareCap";
1111 } else if (pen.capStyle() == Qt::RoundCap) {
1112 linecap = "strokeStyleRoundCap";
1113 }
1114 QString linejoin = "strokeStyleMiterJoin";
1115 if (pen.joinStyle() == Qt::BevelJoin) {
1116 linejoin = "strokeStyleBevelJoin";
1117 } else if (pen.joinStyle() == Qt::RoundJoin) {
1118 linejoin = "strokeStyleRoundJoin";
1119 }
1120 w.writeEnum("strokeStyleLineCapType", "strokeStyleLineCapType", linecap);
1121 w.writeEnum("strokeStyleLineJoinType", "strokeStyleLineJoinType", linejoin);
1122
1123 // Other values are "strokeStyleAlignInside" and "strokeStyleAlignOutside" but we don't support these.
1124 w.writeEnum("strokeStyleLineAlignment", "strokeStyleLineAlignment", "strokeStyleAlignCenter");
1125
1126 w.writeBoolean("strokeStyleScaleLock", false);
1127 w.writeBoolean("strokeStyleStrokeAdjust", false);
1128
1129 w.enterList("strokeStyleLineDashSet");
1130 Q_FOREACH(const double val, dashPattern) {
1131 if (val <= 1e-6) {
1132 w.writeUnitFloat("", "#Nne", 0);
1133 } else {
1134 w.writeUnitFloat("", "#Nne", val);
1135 }
1136 }
1137 w.leaveList();
1138
1139 w.writeEnum("strokeStyleBlendMode", "BlnM", "Nrml");
1140 w.writeUnitFloat("strokeStyleOpacity ", "#Prc", opacity * 100.0);
1141
1142 // Color Descriptor
1143 // Missing is "patternLayer"
1144 if (gradient) {
1145 w.enterDescriptor("strokeStyleContent", "", "gradientLayer");
1147 fill.setFromQGradient(pen.brush().gradient());
1148 fill.writeASL(w);
1149 w.leaveDescriptor();
1150 } else {
1151 w.enterDescriptor("strokeStyleContent", "", "solidColorLayer");
1153 c.fromQColor(pen.color());
1154 c.setOpacity(1.0);
1156 fill.fill_color = c;
1157 fill.writeASL(w);
1158 w.leaveDescriptor();
1159 }
1160
1161 w.writeDouble("strokeStyleResolution", resolution);
1162
1163 w.leaveDescriptor();
1164
1165 return w.document();
1166 }
static KoColorSpaceRegistry * instance()
void setFromQGradient(const QGradient *gradient)

References psd_layer_solid_color::fill_color, KoColor::fromQColor(), KoColorSpaceRegistry::instance(), psd_layer_gradient_fill::setFromQGradient(), KoColor::setOpacity(), psd_layer_solid_color::writeASL(), and psd_layer_gradient_fill::writeASL().

◆ loadFromShapeStroke()

void psd_vector_stroke_data::loadFromShapeStroke ( KoShapeStrokeSP stroke)
inline

Definition at line 1067 of file psd_additional_layer_info_block.h.

1067 {
1068 pen = stroke->resultLinePen();
1069 gradient = stroke->lineBrush().gradient()? true: false;
1070 opacity = stroke->color().alphaF();
1071 dashPattern = stroke->lineDashes();
1072 }

◆ setFillEnabled()

void psd_vector_stroke_data::setFillEnabled ( bool enabled)
inline

Definition at line 1010 of file psd_additional_layer_info_block.h.

1010 {
1011 fillEnabled = enabled;
1012 }

◆ setLineCapType()

void psd_vector_stroke_data::setLineCapType ( const QString val)
inline

Definition at line 1028 of file psd_additional_layer_info_block.h.

1028 {
1029 if (val == "strokeStyleButtCap") {
1030 pen.setCapStyle(Qt::FlatCap);
1031 } else if (val == "strokeStyleSquareCap") {
1032 pen.setCapStyle(Qt::SquareCap);
1033 } else if (val == "strokeStyleRoundCap") {
1034 pen.setCapStyle(Qt::RoundCap);
1035 }
1036 }

◆ setLineJoinType()

void psd_vector_stroke_data::setLineJoinType ( const QString val)
inline

Definition at line 1037 of file psd_additional_layer_info_block.h.

1037 {
1038 if (val == "strokeStyleMiterJoin") {
1039 pen.setJoinStyle(Qt::MiterJoin);
1040 } else if (val == "strokeStyleBevelJoin") {
1041 pen.setJoinStyle(Qt::BevelJoin);
1042 } else if (val == "strokeStyleRoundJoin") {
1043 pen.setJoinStyle(Qt::RoundJoin);
1044 }
1045 }

◆ setOpacityFromPercentage()

void psd_vector_stroke_data::setOpacityFromPercentage ( double o)
inline

Definition at line 1060 of file psd_additional_layer_info_block.h.

1060 {
1061 opacity = o * 0.01;
1062 }

◆ setResolution()

void psd_vector_stroke_data::setResolution ( double res)
inline

Definition at line 1063 of file psd_additional_layer_info_block.h.

1063 {
1064 resolution = res;
1065 }

◆ setScaleLock()

void psd_vector_stroke_data::setScaleLock ( bool enabled)
inline

Definition at line 1047 of file psd_additional_layer_info_block.h.

1047 {
1048 scaleLock = enabled;
1049 }

◆ setStrokeAdjust()

void psd_vector_stroke_data::setStrokeAdjust ( bool enabled)
inline

Definition at line 1051 of file psd_additional_layer_info_block.h.

1051 {
1052 strokeAdjust = enabled;
1053 }

◆ setStrokeDashOffset()

void psd_vector_stroke_data::setStrokeDashOffset ( double dashOffset)
inline

Definition at line 1022 of file psd_additional_layer_info_block.h.

1022 {
1023 pen.setDashOffset(dashOffset);
1024 }

◆ setStrokeEnabled()

void psd_vector_stroke_data::setStrokeEnabled ( bool enabled)
inline

Definition at line 1007 of file psd_additional_layer_info_block.h.

1007 {
1008 strokeEnabled = enabled;
1009 }

◆ setStrokeMiterLimit()

void psd_vector_stroke_data::setStrokeMiterLimit ( double limit)
inline

Definition at line 1025 of file psd_additional_layer_info_block.h.

1025 {
1026 pen.setMiterLimit(limit);
1027 }

◆ setStrokePixel()

void psd_vector_stroke_data::setStrokePixel ( double width)
inline

Definition at line 1017 of file psd_additional_layer_info_block.h.

1017 {
1018 pen.setWidthF(width);
1019 pixelWidth = true;
1020 }

◆ setStrokeWidth()

void psd_vector_stroke_data::setStrokeWidth ( double width)
inline

Definition at line 1013 of file psd_additional_layer_info_block.h.

1013 {
1014 pen.setWidthF(width);
1015 pixelWidth = false;
1016 }

◆ setupCatcher()

static void psd_vector_stroke_data::setupCatcher ( const QString path,
KisAslCallbackObjectCatcher & catcher,
psd_vector_stroke_data * data )
inlinestatic

Definition at line 1074 of file psd_additional_layer_info_block.h.

1074 {
1075 catcher.subscribeInteger(path + "/strokeStyle/strokeStyleVersion", std::bind(&psd_vector_stroke_data::setVersion, data, std::placeholders::_1));
1076 catcher.subscribeBoolean(path + "/strokeStyle/strokeEnabled", std::bind(&psd_vector_stroke_data::setStrokeEnabled, data, std::placeholders::_1));
1077 catcher.subscribeBoolean(path + "/strokeStyle/fillEnabled", std::bind(&psd_vector_stroke_data::setFillEnabled, data, std::placeholders::_1));
1078
1079 catcher.subscribeUnitFloat(path + "/strokeStyle/strokeStyleLineWidth", "#Pxl", std::bind(&psd_vector_stroke_data::setStrokeWidth, data, std::placeholders::_1));
1080 //catcher.subscribeUnitFloat(path + "/strokeStyle/strokeStyleLineWidth", "#Pnt", std::bind(&psd_vector_stroke_data::setStrokePixel, data, std::placeholders::_1));
1081 catcher.subscribeUnitFloat(path + "/strokeStyle/strokeStyleLineDashOffset", "#Pnt", std::bind(&psd_vector_stroke_data::setStrokeDashOffset, data, std::placeholders::_1));
1082 catcher.subscribeDouble(path + "/strokeStyle/strokeStyleMiterLimit", std::bind(&psd_vector_stroke_data::setStrokeMiterLimit, data, std::placeholders::_1));
1083
1084 catcher.subscribeEnum(path + "/strokeStyle/strokeStyleLineCapType", "strokeStyleLineCapType", std::bind(&psd_vector_stroke_data::setLineCapType, data, std::placeholders::_1));
1085 catcher.subscribeEnum(path + "/strokeStyle/strokeStyleLineJoinType", "strokeStyleLineJoinType", std::bind(&psd_vector_stroke_data::setLineJoinType, data, std::placeholders::_1));
1086
1087 catcher.subscribeBoolean(path + "/strokeStyle/strokeStyleScaleLock", std::bind(&psd_vector_stroke_data::setScaleLock, data, std::placeholders::_1));
1088 catcher.subscribeBoolean(path + "/strokeStyle/strokeStyleStrokeAdjust", std::bind(&psd_vector_stroke_data::setStrokeAdjust, data, std::placeholders::_1));
1089
1090 catcher.subscribeUnitFloat(path + "/strokeStyle/strokeStyleLineDashSet/", "#Nne", std::bind(&psd_vector_stroke_data::appendToDashPattern, data, std::placeholders::_1));
1091
1092 catcher.subscribeUnitFloat(path + "/strokeStyle/strokeStyleOpacity", "#Prc", std::bind(&psd_vector_stroke_data::setOpacityFromPercentage, data, std::placeholders::_1));
1093 catcher.subscribeDouble(path + "/strokeStyle/strokeStyleResolution", std::bind(&psd_vector_stroke_data::setResolution, data, std::placeholders::_1));
1094 }
void subscribeDouble(const QString &path, ASLCallbackDouble callback)
void subscribeEnum(const QString &path, const QString &typeId, ASLCallbackString callback)
void subscribeInteger(const QString &path, ASLCallbackInteger callback)
void subscribeUnitFloat(const QString &path, const QString &unit, ASLCallbackDouble callback)
void subscribeBoolean(const QString &path, ASLCallbackBoolean callback)
void setStrokeDashOffset(double dashOffset)

References appendToDashPattern(), setFillEnabled(), setLineCapType(), setLineJoinType(), setOpacityFromPercentage(), setResolution(), setScaleLock(), setStrokeAdjust(), setStrokeDashOffset(), setStrokeEnabled(), setStrokeMiterLimit(), setStrokeWidth(), setVersion(), KisAslCallbackObjectCatcher::subscribeBoolean(), KisAslCallbackObjectCatcher::subscribeDouble(), KisAslCallbackObjectCatcher::subscribeEnum(), KisAslCallbackObjectCatcher::subscribeInteger(), and KisAslCallbackObjectCatcher::subscribeUnitFloat().

◆ setupShapeStroke()

void psd_vector_stroke_data::setupShapeStroke ( KoShapeStrokeSP stroke)
inline

Definition at line 1168 of file psd_additional_layer_info_block.h.

1168 {
1169 double width = pen.widthF();
1170 width = (width / resolution) * 72.0;
1171 stroke->setLineWidth(width);
1172 stroke->setCapStyle(pen.capStyle());
1173 stroke->setJoinStyle(pen.joinStyle());
1174 stroke->setDashOffset(pen.dashOffset());
1175 stroke->setMiterLimit(pen.miterLimit());
1176 if (dashPattern.isEmpty()) {
1177 stroke->setLineStyle(Qt::SolidLine, QVector<double>());
1178 } else {
1179 if (dashPattern.size() % 2 > 0) {
1180 QVector<double> pattern = dashPattern;
1181 pattern.append(dashPattern);
1182 stroke->setLineStyle(Qt::CustomDashLine, pattern);
1183 } else {
1184 stroke->setLineStyle(Qt::CustomDashLine, dashPattern);
1185 }
1186 }
1187 }

◆ setVersion()

void psd_vector_stroke_data::setVersion ( int version)
inline

Definition at line 1003 of file psd_additional_layer_info_block.h.

1003 {
1004 strokeVersion = version;
1005 }

Member Data Documentation

◆ dashPattern

QVector<double> psd_vector_stroke_data::dashPattern

Definition at line 996 of file psd_additional_layer_info_block.h.

◆ fillEnabled

bool psd_vector_stroke_data::fillEnabled {true}

Definition at line 988 of file psd_additional_layer_info_block.h.

988{true};

◆ gradient

bool psd_vector_stroke_data::gradient {false}

Definition at line 991 of file psd_additional_layer_info_block.h.

991{false};

◆ opacity

double psd_vector_stroke_data::opacity {1.0}

Definition at line 998 of file psd_additional_layer_info_block.h.

998{1.0};

◆ pen

QPen psd_vector_stroke_data::pen

Definition at line 990 of file psd_additional_layer_info_block.h.

◆ pixelWidth

bool psd_vector_stroke_data::pixelWidth {false}

Definition at line 1001 of file psd_additional_layer_info_block.h.

1001{false};

◆ resolution

double psd_vector_stroke_data::resolution {72.0}

Definition at line 1000 of file psd_additional_layer_info_block.h.

1000{72.0};

◆ scaleLock

bool psd_vector_stroke_data::scaleLock {false}

Definition at line 993 of file psd_additional_layer_info_block.h.

993{false};

◆ strokeAdjust

bool psd_vector_stroke_data::strokeAdjust {false}

Definition at line 994 of file psd_additional_layer_info_block.h.

994{false};

◆ strokeEnabled

bool psd_vector_stroke_data::strokeEnabled {false}

Definition at line 987 of file psd_additional_layer_info_block.h.

987{false};

◆ strokeVersion

int psd_vector_stroke_data::strokeVersion {2}

Definition at line 985 of file psd_additional_layer_info_block.h.

985{2};

The documentation for this struct was generated from the following file: