File indexing completed on 2024-06-23 04:27:03
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2007 Jan Hambrecht <jaham@gmx.net> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "enhancedpath/EnhancedPathShapeFactory.h" 0008 #include "enhancedpath/EnhancedPathShape.h" 0009 0010 #include <KoShapeStroke.h> 0011 #include <KoProperties.h> 0012 #include <KoXmlNS.h> 0013 #include <KoColorBackground.h> 0014 #include <KoShapeLoadingContext.h> 0015 0016 #include <KoIcon.h> 0017 0018 #include <klocalizedstring.h> 0019 #include "kis_pointer_utils.h" 0020 0021 #include <QString> 0022 0023 #include <math.h> 0024 0025 EnhancedPathShapeFactory::EnhancedPathShapeFactory() 0026 : KoShapeFactoryBase(EnhancedPathShapeId, i18n("An enhanced path shape")) 0027 { 0028 setToolTip(i18n("An enhanced path")); 0029 setIconName(koIconNameCStr("krita_draw_path")); 0030 setXmlElementNames(KoXmlNS::draw, QStringList("custom-shape")); 0031 setLoadingPriority(1); 0032 0033 // addCross(); 0034 // addArrow(); 0035 // addCallout(); 0036 // addSmiley(); 0037 // addCircularArrow(); 0038 // addGearhead(); 0039 } 0040 0041 KoShape *EnhancedPathShapeFactory::createDefaultShape(KoDocumentResourceManager *) const 0042 { 0043 EnhancedPathShape *shape = new EnhancedPathShape(QRect(0, 0, 100, 100)); 0044 shape->setStroke(toQShared(new KoShapeStroke(1.0))); 0045 shape->setShapeId(KoPathShapeId); 0046 0047 shape->addModifiers("35"); 0048 0049 shape->addFormula("Right", "width - $0"); 0050 shape->addFormula("Bottom", "height - $0"); 0051 shape->addFormula("Half", "min(0.5 * height, 0.5 * width)"); 0052 0053 shape->addCommand("M $0 0"); 0054 shape->addCommand("L ?Right 0 ?Right $0 width $0 width ?Bottom ?Right ?Bottom"); 0055 shape->addCommand("L ?Right height $0 height $0 ?Bottom 0 ?Bottom 0 $0 $0 $0"); 0056 shape->addCommand("Z"); 0057 0058 ComplexType handle; 0059 handle["draw:handle-position"] = "$0 0"; 0060 handle["draw:handle-range-x-minimum"] = '0'; 0061 handle["draw:handle-range-x-maximum"] = "?Half"; 0062 shape->addHandle(handle); 0063 shape->setSize(QSize(100, 100)); 0064 0065 return shape; 0066 } 0067 0068 KoShape *EnhancedPathShapeFactory::createShape(const KoProperties *params, KoDocumentResourceManager *) const 0069 { 0070 QVariant viewboxData; 0071 const QRect viewBox = (params->property(QLatin1String("viewBox"), viewboxData)) ? 0072 viewboxData.toRect() : 0073 QRect(0, 0, 100, 100); 0074 0075 EnhancedPathShape *shape = new EnhancedPathShape(viewBox); 0076 0077 shape->setShapeId(KoPathShapeId); 0078 shape->setStroke(toQShared(new KoShapeStroke(1.0))); 0079 shape->addModifiers(params->stringProperty("modifiers")); 0080 0081 ListType handles = params->property("handles").toList(); 0082 foreach (const QVariant &v, handles) { 0083 shape->addHandle(v.toMap()); 0084 } 0085 0086 ComplexType formulae = params->property("formulae").toMap(); 0087 ComplexType::const_iterator formula = formulae.constBegin(); 0088 ComplexType::const_iterator lastFormula = formulae.constEnd(); 0089 for (; formula != lastFormula; ++formula) { 0090 shape->addFormula(formula.key(), formula.value().toString()); 0091 } 0092 0093 QStringList commands = params->property("commands").toStringList(); 0094 foreach (const QString &cmd, commands) { 0095 shape->addCommand(cmd); 0096 } 0097 0098 QVariant color; 0099 if (params->property("background", color)) { 0100 shape->setBackground(QSharedPointer<KoColorBackground>(new KoColorBackground(color.value<QColor>()))); 0101 } 0102 QSizeF size = shape->size(); 0103 if (size.width() > size.height()) { 0104 shape->setSize(QSizeF(100, 100 * size.height() / size.width())); 0105 } else { 0106 shape->setSize(QSizeF(100 * size.width() / size.height(), 100)); 0107 } 0108 0109 return shape; 0110 } 0111 0112 KoProperties *EnhancedPathShapeFactory::dataToProperties( 0113 const QString &modifiers, const QStringList &commands, 0114 const ListType &handles, const ComplexType &formulae) const 0115 { 0116 KoProperties *props = new KoProperties(); 0117 props->setProperty("modifiers", modifiers); 0118 props->setProperty("commands", commands); 0119 props->setProperty("handles", handles); 0120 props->setProperty("formulae", formulae); 0121 props->setProperty("background", QVariant::fromValue<QColor>(QColor(Qt::red))); 0122 0123 return props; 0124 } 0125 0126 void EnhancedPathShapeFactory::addCross() 0127 { 0128 QString modifiers("35"); 0129 0130 QStringList commands; 0131 commands.append("M $0 0"); 0132 commands.append("L ?Right 0 ?Right $0 width $0 width ?Bottom ?Right ?Bottom"); 0133 commands.append("L ?Right height $0 height $0 ?Bottom 0 ?Bottom 0 $0 $0 $0"); 0134 commands.append("Z"); 0135 0136 ListType handles; 0137 ComplexType handle; 0138 handle["draw:handle-position"] = "$0 0"; 0139 handle["draw:handle-range-x-minimum"] = '0'; 0140 handle["draw:handle-range-x-maximum"] = "?Half"; 0141 handles.append(QVariant(handle)); 0142 0143 ComplexType formulae; 0144 formulae["Right"] = "width - $0"; 0145 formulae["Bottom"] = "height - $0"; 0146 formulae["Half"] = "min(0.5 * height, 0.5 * width)"; 0147 0148 KoShapeTemplate t; 0149 t.id = KoPathShapeId; 0150 t.templateId = "cross"; 0151 t.name = i18n("Cross"); 0152 t.family = "funny"; 0153 t.toolTip = i18n("A cross"); 0154 t.iconName = koIconName("cross-shape"); 0155 t.properties = dataToProperties(modifiers, commands, handles, formulae); 0156 0157 addTemplate(t); 0158 } 0159 0160 void EnhancedPathShapeFactory::addArrow() 0161 { 0162 { 0163 // arrow right 0164 QString modifiers("60 35"); 0165 0166 QStringList commands; 0167 commands.append("M $0 $1"); 0168 commands.append("L $0 0 width ?HalfHeight $0 height $0 ?LowerCorner 0 ?LowerCorner 0 $1"); 0169 commands.append("Z"); 0170 0171 ListType handles; 0172 ComplexType handle; 0173 handle["draw:handle-position"] = "$0 $1"; 0174 handle["draw:handle-range-x-minimum"] = '0'; 0175 handle["draw:handle-range-x-maximum"] = "width"; 0176 handle["draw:handle-range-y-minimum"] = '0'; 0177 handle["draw:handle-range-y-maximum"] = "?HalfHeight"; 0178 handles.append(QVariant(handle)); 0179 0180 ComplexType formulae; 0181 formulae["HalfHeight"] = "0.5 * height"; 0182 formulae["LowerCorner"] = "height - $1"; 0183 0184 KoShapeTemplate t; 0185 t.id = KoPathShapeId; 0186 t.templateId = "arrow_right"; 0187 t.name = i18n("Arrow"); 0188 t.family = "arrow"; 0189 t.toolTip = i18n("An arrow"); 0190 t.iconName = koIconName("draw-arrow-forward"); 0191 t.properties = dataToProperties(modifiers, commands, handles, formulae); 0192 0193 addTemplate(t); 0194 } 0195 0196 { 0197 // arrow left 0198 QString modifiers("40 35"); 0199 0200 QStringList commands; 0201 commands.append("M $0 $1"); 0202 commands.append("L $0 0 0 ?HalfHeight $0 height $0 ?LowerCorner width ?LowerCorner width $1"); 0203 commands.append("Z"); 0204 0205 ListType handles; 0206 ComplexType handle; 0207 handle["draw:handle-position"] = "$0 $1"; 0208 handle["draw:handle-range-x-minimum"] = '0'; 0209 handle["draw:handle-range-x-maximum"] = "width"; 0210 handle["draw:handle-range-y-minimum"] = '0'; 0211 handle["draw:handle-range-y-maximum"] = "?HalfHeight"; 0212 handles.append(QVariant(handle)); 0213 0214 ComplexType formulae; 0215 formulae["HalfHeight"] = "0.5 * height"; 0216 formulae["LowerCorner"] = "height - $1"; 0217 0218 KoShapeTemplate t; 0219 t.id = KoPathShapeId; 0220 t.templateId = "arrow_left"; 0221 t.name = i18n("Arrow"); 0222 t.family = "arrow"; 0223 t.toolTip = i18n("An arrow"); 0224 t.iconName = koIconName("draw-arrow-back"); 0225 t.properties = dataToProperties(modifiers, commands, handles, formulae); 0226 0227 addTemplate(t); 0228 } 0229 0230 { 0231 // arrow top 0232 QString modifiers("35 40"); 0233 0234 QStringList commands; 0235 commands.append("M $0 $1"); 0236 commands.append("L 0 $1 ?HalfWidth 0 width $1 ?RightCorner $1 ?RightCorner height $0 height"); 0237 commands.append("Z"); 0238 0239 ListType handles; 0240 ComplexType handle; 0241 handle["draw:handle-position"] = "$0 $1"; 0242 handle["draw:handle-range-x-minimum"] = '0'; 0243 handle["draw:handle-range-x-maximum"] = "?HalfWidth"; 0244 handle["draw:handle-range-y-minimum"] = '0'; 0245 handle["draw:handle-range-y-maximum"] = "height"; 0246 handles.append(QVariant(handle)); 0247 0248 ComplexType formulae; 0249 formulae["HalfWidth"] = "0.5 * width"; 0250 formulae["RightCorner"] = "width - $0"; 0251 0252 KoShapeTemplate t; 0253 t.id = KoPathShapeId; 0254 t.templateId = "arrow_top"; 0255 t.name = i18n("Arrow"); 0256 t.family = "arrow"; 0257 t.toolTip = i18n("An arrow"); 0258 t.iconName = koIconName("draw-arrow-up"); 0259 t.properties = dataToProperties(modifiers, commands, handles, formulae); 0260 0261 addTemplate(t); 0262 } 0263 0264 { 0265 // arrow bottom 0266 QString modifiers("35 60"); 0267 0268 QStringList commands; 0269 commands.append("M $0 $1"); 0270 commands.append("L 0 $1 ?HalfWidth height width $1 ?RightCorner $1 ?RightCorner 0 $0 0"); 0271 commands.append("Z"); 0272 0273 ListType handles; 0274 ComplexType handle; 0275 handle["draw:handle-position"] = "$0 $1"; 0276 handle["draw:handle-range-x-minimum"] = '0'; 0277 handle["draw:handle-range-x-maximum"] = "?HalfWidth"; 0278 handle["draw:handle-range-y-minimum"] = '0'; 0279 handle["draw:handle-range-y-maximum"] = "height"; 0280 handles.append(QVariant(handle)); 0281 0282 ComplexType formulae; 0283 formulae["HalfWidth"] = "0.5 * width"; 0284 formulae["RightCorner"] = "width - $0"; 0285 0286 KoShapeTemplate t; 0287 t.id = KoPathShapeId; 0288 t.templateId = "arrow_bottom"; 0289 t.name = i18n("Arrow"); 0290 t.family = "arrow"; 0291 t.toolTip = i18n("An arrow"); 0292 t.iconName = koIconName("draw-arrow-down"); 0293 t.properties = dataToProperties(modifiers, commands, handles, formulae); 0294 0295 addTemplate(t); 0296 } 0297 } 0298 0299 void EnhancedPathShapeFactory::addCallout() 0300 { 0301 QString modifiers("4250 45000"); 0302 0303 QStringList commands; 0304 commands.append("M 3590 0"); 0305 commands.append("X 0 3590"); 0306 commands.append("L ?f2 ?f3 0 8970 0 12630 ?f4 ?f5 0 18010"); 0307 commands.append("Y 3590 21600"); 0308 commands.append("L ?f6 ?f7 8970 21600 12630 21600 ?f8 ?f9 18010 21600"); 0309 commands.append("X 21600 18010"); 0310 commands.append("L ?f10 ?f11 21600 12630 21600 8970 ?f12 ?f13 21600 3590"); 0311 commands.append("Y 18010 0"); 0312 commands.append("L ?f14 ?f15 12630 0 8970 0 ?f16 ?f17"); 0313 commands.append("Z"); 0314 commands.append("N"); 0315 0316 ComplexType formulae; 0317 formulae["f0"] = "$0 -10800"; 0318 formulae["f1"] = "$1 -10800"; 0319 formulae["f2"] = "if(?f18 ,$0 ,0)"; 0320 formulae["f3"] = "if(?f18 ,$1 ,6280)"; 0321 formulae["f4"] = "if(?f23 ,$0 ,0)"; 0322 formulae["f5"] = "if(?f23 ,$1 ,15320)"; 0323 formulae["f6"] = "if(?f26 ,$0 ,6280)"; 0324 formulae["f7"] = "if(?f26 ,$1 ,21600)"; 0325 formulae["f8"] = "if(?f29 ,$0 ,15320)"; 0326 formulae["f9"] = "if(?f29 ,$1 ,21600)"; 0327 formulae["f10"] = "if(?f32 ,$0 ,21600)"; 0328 formulae["f11"] = "if(?f32 ,$1 ,15320)"; 0329 formulae["f12"] = "if(?f34 ,$0 ,21600)"; 0330 formulae["f13"] = "if(?f34 ,$1 ,6280)"; 0331 formulae["f14"] = "if(?f36 ,$0 ,15320)"; 0332 formulae["f15"] = "if(?f36 ,$1 ,0)"; 0333 formulae["f16"] = "if(?f38 ,$0 ,6280)"; 0334 formulae["f17"] = "if(?f38 ,$1 ,0)"; 0335 formulae["f18"] = "if($0 ,-1,?f19)"; 0336 formulae["f19"] = "if(?f1 ,-1,?f22)"; 0337 formulae["f20"] = "abs(?f0)"; 0338 formulae["f21"] = "abs(?f1)"; 0339 formulae["f22"] = "?f20 -?f21"; 0340 formulae["f23"] = "if($0 ,-1,?f24)"; 0341 formulae["f24"] = "if(?f1 ,?f22 ,-1)"; 0342 formulae["f25"] = "$1 -21600"; 0343 formulae["f26"] = "if(?f25 ,?f27 ,-1)"; 0344 formulae["f27"] = "if(?f0 ,-1,?f28)"; 0345 formulae["f28"] = "?f21 -?f20"; 0346 formulae["f29"] = "if(?f25 ,?f30 ,-1)"; 0347 formulae["f30"] = "if(?f0 ,?f28 ,-1)"; 0348 formulae["f31"] = "$0 -21600"; 0349 formulae["f32"] = "if(?f31 ,?f33 ,-1)"; 0350 formulae["f33"] = "if(?f1 ,?f22 ,-1)"; 0351 formulae["f34"] = "if(?f31 ,?f35 ,-1)"; 0352 formulae["f35"] = "if(?f1 ,-1,?f22)"; 0353 formulae["f36"] = "if($1 ,-1,?f37)"; 0354 formulae["f37"] = "if(?f0 ,?f28 ,-1)"; 0355 formulae["f38"] = "if($1 ,-1,?f39)"; 0356 formulae["f39"] = "if(?f0 ,-1,?f28)"; 0357 formulae["f40"] = "$0"; 0358 formulae["f41"] = "$1"; 0359 0360 ListType handles; 0361 ComplexType handle; 0362 handle["draw:handle-position"] = "$0 $1"; 0363 handles.append(QVariant(handle)); 0364 0365 KoShapeTemplate t; 0366 t.id = KoPathShapeId; 0367 t.templateId = "callout"; 0368 t.name = i18n("Callout"); 0369 t.family = "funny"; 0370 t.toolTip = i18n("A callout"); 0371 t.iconName = koIconName("callout-shape"); 0372 KoProperties *properties = dataToProperties(modifiers, commands, handles, formulae); 0373 properties->setProperty(QLatin1String("viewBox"), QRect(0, 0, 21600, 21600)); 0374 t.properties = properties; 0375 0376 addTemplate(t); 0377 } 0378 0379 void EnhancedPathShapeFactory::addSmiley() 0380 { 0381 QString modifiers("17520"); 0382 0383 QStringList commands; 0384 commands.append("U 10800 10800 10800 10800 0 23592960"); 0385 commands.append("Z"); 0386 commands.append("N"); 0387 commands.append("U 7305 7515 1165 1165 0 23592960"); 0388 commands.append("Z"); 0389 commands.append("N"); 0390 commands.append("U 14295 7515 1165 1165 0 23592960"); 0391 commands.append("Z"); 0392 commands.append("N"); 0393 commands.append("M 4870 ?f1"); 0394 commands.append("C 8680 ?f2 12920 ?f2 16730 ?f1"); 0395 commands.append("Z"); 0396 commands.append("F"); 0397 commands.append("N"); 0398 0399 ComplexType formulae; 0400 formulae["f0"] = "$0 -15510"; 0401 formulae["f1"] = "17520-?f0"; 0402 formulae["f2"] = "15510+?f0"; 0403 0404 ListType handles; 0405 ComplexType handle; 0406 handle["draw:handle-position"] = "10800 $0"; 0407 handle["draw:handle-range-y-minimum"] = "15510"; 0408 handle["draw:handle-range-y-maximum"] = "17520"; 0409 handles.append(QVariant(handle)); 0410 0411 KoShapeTemplate t; 0412 t.id = KoPathShapeId; 0413 t.templateId = "smiley"; 0414 t.name = i18n("Smiley"); 0415 t.family = "funny"; 0416 t.toolTip = i18n("Smiley"); 0417 t.iconName = koIconName("smiley-shape"); 0418 KoProperties *properties = dataToProperties(modifiers, commands, handles, formulae); 0419 properties->setProperty(QLatin1String("viewBox"), QRect(0, 0, 21600, 21600)); 0420 t.properties = properties; 0421 0422 addTemplate(t); 0423 } 0424 0425 void EnhancedPathShapeFactory::addCircularArrow() 0426 { 0427 QString modifiers("180 0 5500"); 0428 0429 QStringList commands; 0430 commands.append("B ?f3 ?f3 ?f20 ?f20 ?f19 ?f18 ?f17 ?f16"); 0431 commands.append("W 0 0 21600 21600 ?f9 ?f8 ?f11 ?f10"); 0432 commands.append("L ?f24 ?f23 ?f36 ?f35 ?f29 ?f28"); 0433 commands.append("Z"); 0434 commands.append("N"); 0435 0436 ComplexType formulae; 0437 0438 formulae["f0"] = "$0"; 0439 formulae["f1"] = "$1"; 0440 formulae["f2"] = "$2"; 0441 formulae["f3"] = "10800+$2"; 0442 formulae["f4"] = "10800*sin($0 *(pi/180))"; 0443 formulae["f5"] = "10800*cos($0 *(pi/180))"; 0444 formulae["f6"] = "10800*sin($1 *(pi/180))"; 0445 formulae["f7"] = "10800*cos($1 *(pi/180))"; 0446 formulae["f8"] = "?f4 +10800"; 0447 formulae["f9"] = "?f5 +10800"; 0448 formulae["f10"] = "?f6 +10800"; 0449 formulae["f11"] = "?f7 +10800"; 0450 formulae["f12"] = "?f3 *sin($0 *(pi/180))"; 0451 formulae["f13"] = "?f3 *cos($0 *(pi/180))"; 0452 formulae["f14"] = "?f3 *sin($1 *(pi/180))"; 0453 formulae["f15"] = "?f3 *cos($1 *(pi/180))"; 0454 formulae["f16"] = "?f12 +10800"; 0455 formulae["f17"] = "?f13 +10800"; 0456 formulae["f18"] = "?f14 +10800"; 0457 formulae["f19"] = "?f15 +10800"; 0458 formulae["f20"] = "21600-?f3"; 0459 formulae["f21"] = "13500*sin($1 *(pi/180))"; 0460 formulae["f22"] = "13500*cos($1 *(pi/180))"; 0461 formulae["f23"] = "?f21 +10800"; 0462 formulae["f24"] = "?f22 +10800"; 0463 formulae["f25"] = "$2 -2700"; 0464 formulae["f26"] = "?f25 *sin($1 *(pi/180))"; 0465 formulae["f27"] = "?f25 *cos($1 *(pi/180))"; 0466 formulae["f28"] = "?f26 +10800"; 0467 formulae["f29"] = "?f27 +10800"; 0468 formulae["f30"] = "($1+45)*pi/180"; 0469 formulae["f31"] = "sqrt(((?f29-?f24)*(?f29-?f24))+((?f28-?f23)*(?f28-?f23)))"; 0470 formulae["f32"] = "sqrt(2)/2*?f31"; 0471 formulae["f33"] = "?f32*sin(?f30)"; 0472 formulae["f34"] = "?f32*cos(?f30)"; 0473 formulae["f35"] = "?f28+?f33"; 0474 formulae["f36"] = "?f29+?f34"; 0475 0476 ListType handles; 0477 ComplexType handle; 0478 handle["draw:handle-position"] = "$0 10800"; 0479 handle["draw:handle-polar"] = "10800 10800"; 0480 handle["draw:handle-radius-range-minimum"] = "10800"; 0481 handle["draw:handle-radius-range-maximum"] = "10800"; 0482 handles.append(QVariant(handle)); 0483 0484 handle.clear(); 0485 handle["draw:handle-position"] = "$1 $2"; 0486 handle["draw:handle-polar"] = "10800 10800"; 0487 handle["draw:handle-radius-range-minimum"] = '0'; 0488 handle["draw:handle-radius-range-maximum"] = "10800"; 0489 handles.append(QVariant(handle)); 0490 0491 KoShapeTemplate t; 0492 t.id = KoPathShapeId; 0493 t.templateId = "circulararrow"; 0494 t.name = i18n("Circular Arrow"); 0495 t.family = "arrow"; 0496 t.toolTip = i18n("A circular-arrow"); 0497 t.iconName = koIconName("circular-arrow-shape"); 0498 KoProperties *properties = dataToProperties(modifiers, commands, handles, formulae); 0499 properties->setProperty(QLatin1String("viewBox"), QRect(0, 0, 21600, 21600)); 0500 t.properties = properties; 0501 addTemplate(t); 0502 } 0503 0504 void EnhancedPathShapeFactory::addGearhead() 0505 { 0506 QStringList commands; 0507 commands.append("M 20 70"); 0508 commands.append("L 20 100 30 100 30 50 30 70 40 70 40 40 0 40 0 70 10 70 10 50 10 100 20 100"); 0509 commands.append("Z"); 0510 commands.append("N"); 0511 0512 uint toothCount = 10; 0513 qreal toothAngle = 360.0 / qreal(toothCount); 0514 //kDebug() <<"toothAngle =" << toothAngle; 0515 qreal outerRadius = 0.5 * 25.0; 0516 qreal innerRadius = 0.5 * 17.0; 0517 QPointF center(20, 25); 0518 qreal radian = (270.0 - 0.35 * toothAngle) * M_PI / 180.0; 0519 commands.append(QString("M %1 %2").arg(center.x() + innerRadius * cos(radian)).arg(center.y() + innerRadius * sin(radian))); 0520 QString cmd("L"); 0521 for (uint i = 0; i < toothCount; ++i) { 0522 radian += 0.15 * toothAngle * M_PI / 180.0; 0523 cmd += QString(" %1 %2").arg(center.x() + outerRadius * cos(radian)).arg(center.y() + outerRadius * sin(radian)); 0524 radian += 0.35 * toothAngle * M_PI / 180.0; 0525 cmd += QString(" %1 %2").arg(center.x() + outerRadius * cos(radian)).arg(center.y() + outerRadius * sin(radian)); 0526 radian += 0.15 * toothAngle * M_PI / 180.0; 0527 cmd += QString(" %1 %2").arg(center.x() + innerRadius * cos(radian)).arg(center.y() + innerRadius * sin(radian)); 0528 radian += 0.35 * toothAngle * M_PI / 180.0; 0529 cmd += QString(" %1 %2").arg(center.x() + innerRadius * cos(radian)).arg(center.y() + innerRadius * sin(radian)); 0530 } 0531 //kDebug() <<"gear command =" << cmd; 0532 commands.append(cmd); 0533 commands.append("Z"); 0534 commands.append("N"); 0535 0536 KoShapeTemplate t; 0537 t.id = KoPathShapeId; 0538 t.templateId = "gearhead"; 0539 t.name = i18n("Gearhead"); 0540 t.family = "funny"; 0541 t.toolTip = i18n("A gearhead"); 0542 t.iconName = koIconName("gearhead-shape"); 0543 KoProperties *properties = dataToProperties(QString(), commands, ListType(), ComplexType()); 0544 properties->setProperty("background", QVariant::fromValue<QColor>(QColor(Qt::blue))); 0545 properties->setProperty(QLatin1String("viewBox"), QRect(0, 0, 40, 90)); 0546 t.properties = properties; 0547 addTemplate(t); 0548 } 0549 0550 bool EnhancedPathShapeFactory::supports(const QDomElement &e, KoShapeLoadingContext &context) const 0551 { 0552 Q_UNUSED(context); 0553 return (e.localName() == "custom-shape" && e.namespaceURI() == KoXmlNS::draw); 0554 }