1 #pragma once 2 3 #ifndef STROKESTYLES_H 4 #define STROKESTYLES_H 5 6 // TnzCore includes 7 #include "tsimplecolorstyles.h" 8 #include "tvectorimage.h" 9 #include "tstrokeprop.h" 10 #include "tgl.h" 11 12 class TVectorRendeData; 13 class TRandom; 14 15 #undef DVAPI 16 #undef DVVAR 17 18 #ifdef COLORFX_EXPORTS 19 #define DVAPI DV_EXPORT_API 20 #define DVVAR DV_EXPORT_VAR 21 #else 22 #define DVAPI DV_IMPORT_API 23 #define DVVAR DV_IMPORT_VAR 24 #endif 25 26 //============================================================================= 27 28 typedef struct { 29 TPointD point; 30 double dbl1; 31 double dbl2; 32 } PointAnd2Double; 33 34 typedef std::vector<TPointD> Points; 35 36 typedef struct { 37 float blend; 38 Points points; 39 } BlendAndPoint; 40 41 typedef std::vector<std::pair<TPointD, TPixel32>> PointsAndColors; 42 typedef std::vector<Points> PointMatrix; 43 typedef std::vector<std::pair<TPointD, double>> PointsAndDoubles; 44 typedef std::vector<std::pair<GLenum, Points>> DrawmodePointsMatrix; 45 typedef std::vector<TRectD> RectVector; 46 typedef std::vector<PointAnd2Double> PointsAnd2Doubles; 47 typedef std::vector<double> Doubles; 48 typedef std::vector<BlendAndPoint> BlendAndPoints; 49 //============================================================================= 50 51 template <class T> 52 class TOptimizedStrokeStyleT : public TColorStyle { 53 public: TOptimizedStrokeStyleT()54 TOptimizedStrokeStyleT() {} 55 isRegionStyle()56 bool isRegionStyle() const override { return false; } isStrokeStyle()57 bool isStrokeStyle() const override { return true; } 58 59 TStrokeProp *makeStrokeProp(const TStroke *stroke) override; 60 makeRegionProp(const TRegion * region)61 TRegionProp *makeRegionProp(const TRegion *region) override { 62 assert(false); 63 return 0; 64 }; 65 66 virtual void computeData(T &data, const TStroke *stroke, 67 const TColorFunction *cf) const = 0; 68 virtual void drawStroke(const TColorFunction *cf, T &data, 69 const TStroke *stroke) const = 0; 70 }; 71 72 //------------------------------------------------------------------- 73 74 class TFurStrokeStyle final : public TOptimizedStrokeStyleT<Points> { 75 double m_cs, m_sn, m_angle, m_length; 76 TPixel32 m_color; 77 78 public: 79 TFurStrokeStyle(); 80 81 TColorStyle *clone() const override; 82 invalidate()83 void invalidate() {} 84 85 void computeData(Points &positions, const TStroke *stroke, 86 const TColorFunction *cf) const override; 87 void drawStroke(const TColorFunction *cf, Points &positions, 88 const TStroke *stroke) const override; 89 getDescription()90 QString getDescription() const override { 91 return QCoreApplication::translate("TFurStrokeStyle", "Herringbone"); 92 } 93 hasMainColor()94 bool hasMainColor() const override { return true; } getMainColor()95 TPixel32 getMainColor() const override { return m_color; } setMainColor(const TPixel32 & color)96 void setMainColor(const TPixel32 &color) override { m_color = color; } 97 98 int getParamCount() const override; 99 TColorStyle::ParamType getParamType(int index) const override; 100 101 QString getParamNames(int index) const override; 102 void getParamRange(int index, double &min, double &max) const override; 103 double getParamValue(TColorStyle::double_tag, int index) const override; 104 void setParamValue(int index, double value) override; 105 saveData(TOutputStreamInterface & os)106 void saveData(TOutputStreamInterface &os) const override { 107 os << m_color << m_angle << m_length; 108 } 109 loadData(TInputStreamInterface & is)110 void loadData(TInputStreamInterface &is) override { 111 is >> m_color >> m_angle >> m_length; 112 m_cs = cos(m_angle); 113 m_sn = sin(m_angle); 114 } 115 getTagId()116 int getTagId() const override { return 103; }; 117 }; 118 119 //------------------------------------------------------------------- 120 121 class TChainStrokeStyle final : public TOptimizedStrokeStyleT<Points> { 122 TPixel32 m_color; 123 124 public: 125 TChainStrokeStyle(const TPixel32 &color); 126 TChainStrokeStyle(); 127 invalidate()128 void invalidate() {} 129 130 TColorStyle *clone() const override; 131 getDescription()132 QString getDescription() const override { 133 return QCoreApplication::translate("TChainStrokeStyle", "Chain"); 134 } 135 hasMainColor()136 bool hasMainColor() const override { return true; } getMainColor()137 TPixel32 getMainColor() const override { return m_color; } setMainColor(const TPixel32 & color)138 void setMainColor(const TPixel32 &color) override { m_color = color; } 139 140 void computeData(Points &positions, const TStroke *stroke, 141 const TColorFunction *cf) const override; 142 void drawStroke(const TColorFunction *cf, Points &positions, 143 const TStroke *stroke) const override; 144 loadData(TInputStreamInterface & is)145 void loadData(TInputStreamInterface &is) override { is >> m_color; } saveData(TOutputStreamInterface & os)146 void saveData(TOutputStreamInterface &os) const override { os << m_color; } getTagId()147 int getTagId() const override { return 104; }; 148 }; 149 150 //------------------------------------------------------------------- 151 152 class TSprayStrokeStyle final : public TSimpleStrokeStyle { 153 TPixel32 m_color; 154 double m_blend, m_intensity, m_radius; 155 156 public: 157 TSprayStrokeStyle(); 158 invalidate()159 void invalidate() {} 160 161 TColorStyle *clone() const override; 162 getDescription()163 QString getDescription() const override { 164 return QCoreApplication::translate("TSprayStrokeStyle", "Circlets"); 165 } 166 hasMainColor()167 bool hasMainColor() const override { return true; } getMainColor()168 TPixel32 getMainColor() const override { return m_color; } setMainColor(const TPixel32 & color)169 void setMainColor(const TPixel32 &color) override { m_color = color; } 170 171 int getParamCount() const override; 172 TColorStyle::ParamType getParamType(int index) const override; 173 174 QString getParamNames(int index) const override; 175 void getParamRange(int index, double &min, double &max) const override; 176 double getParamValue(TColorStyle::double_tag, int index) const override; 177 void setParamValue(int index, double value) override; 178 179 void drawStroke(const TColorFunction *cf, 180 const TStroke *stroke) const override; 181 loadData(TInputStreamInterface & is)182 void loadData(TInputStreamInterface &is) override { 183 is >> m_color >> m_blend >> m_intensity >> m_radius; 184 } saveData(TOutputStreamInterface & os)185 void saveData(TOutputStreamInterface &os) const override { 186 os << m_color << m_blend << m_intensity << m_radius; 187 } getTagId()188 int getTagId() const override { return 106; }; 189 }; 190 191 //------------------------------------------------------------------- 192 193 class TGraphicPenStrokeStyle final 194 : public TOptimizedStrokeStyleT<DrawmodePointsMatrix> { 195 TPixel32 m_color; 196 double m_intensity; 197 198 public: 199 TGraphicPenStrokeStyle(); 200 invalidate()201 void invalidate() {} 202 203 TColorStyle *clone() const override; 204 getDescription()205 QString getDescription() const override { 206 return QCoreApplication::translate("TGraphicPenStrokeStyle", "Dashes"); 207 } 208 hasMainColor()209 bool hasMainColor() const override { return true; } getMainColor()210 TPixel32 getMainColor() const override { return m_color; } setMainColor(const TPixel32 & color)211 void setMainColor(const TPixel32 &color) override { m_color = color; } 212 213 int getParamCount() const override; 214 TColorStyle::ParamType getParamType(int index) const override; 215 216 QString getParamNames(int index) const override; 217 void getParamRange(int index, double &min, double &max) const override; 218 double getParamValue(TColorStyle::double_tag, int index) const override; 219 void setParamValue(int index, double value) override; 220 221 void computeData(DrawmodePointsMatrix &data, const TStroke *stroke, 222 const TColorFunction *cf) const override; 223 void drawStroke(const TColorFunction *cf, DrawmodePointsMatrix &data, 224 const TStroke *stroke) const override; 225 loadData(TInputStreamInterface & is)226 void loadData(TInputStreamInterface &is) override { 227 is >> m_color >> m_intensity; 228 } saveData(TOutputStreamInterface & os)229 void saveData(TOutputStreamInterface &os) const override { 230 os << m_color << m_intensity; 231 } getTagId()232 int getTagId() const override { return 107; }; 233 }; 234 235 //------------------------------------------------------------------- 236 237 class TDottedLineStrokeStyle final : public TOptimizedStrokeStyleT<Points> { 238 TPixel32 m_color; 239 double m_in, m_line, m_out, m_blank; 240 241 public: 242 TDottedLineStrokeStyle(); 243 244 void computeData(Points &positions, const TStroke *stroke, 245 const TColorFunction *cf) const override; 246 void drawStroke(const TColorFunction *cf, Points &positions, 247 const TStroke *stroke) const override; 248 invalidate()249 void invalidate() {} 250 251 TColorStyle *clone() const override; 252 getDescription()253 QString getDescription() const override { 254 return QCoreApplication::translate("TDottedLineStrokeStyle", "Vanishing"); 255 } 256 hasMainColor()257 bool hasMainColor() const override { return true; } getMainColor()258 TPixel32 getMainColor() const override { return m_color; } setMainColor(const TPixel32 & color)259 void setMainColor(const TPixel32 &color) override { m_color = color; } 260 261 int getParamCount() const override; 262 TColorStyle::ParamType getParamType(int index) const override; 263 264 QString getParamNames(int index) const override; 265 void getParamRange(int index, double &min, double &max) const override; 266 double getParamValue(TColorStyle::double_tag, int index) const override; 267 void setParamValue(int index, double value) override; 268 loadData(TInputStreamInterface & is)269 void loadData(TInputStreamInterface &is) override { 270 is >> m_color >> m_in >> m_line >> m_out >> m_blank; 271 } saveData(TOutputStreamInterface & os)272 void saveData(TOutputStreamInterface &os) const override { 273 os << m_color << m_in << m_line << m_out << m_blank; 274 } isSaveSupported()275 bool isSaveSupported() { return true; } 276 getTagId()277 int getTagId() const override { return 111; } 278 }; 279 280 //------------------------------------------------------------------- 281 282 class TRopeStrokeStyle final : public TOptimizedStrokeStyleT<Points> { 283 TPixel32 m_color; 284 double m_bend; 285 286 public: 287 TRopeStrokeStyle(); 288 289 void computeData(Points &positions, const TStroke *stroke, 290 const TColorFunction *cf) const override; 291 void drawStroke(const TColorFunction *cf, Points &positions, 292 const TStroke *stroke) const override; 293 invalidate()294 void invalidate() {} 295 296 TColorStyle *clone() const override; 297 getDescription()298 QString getDescription() const override { 299 return QCoreApplication::translate("TRopeStrokeStyle", "Rope"); 300 } 301 hasMainColor()302 bool hasMainColor() const override { return true; } getMainColor()303 TPixel32 getMainColor() const override { return m_color; } setMainColor(const TPixel32 & color)304 void setMainColor(const TPixel32 &color) override { m_color = color; } 305 306 int getParamCount() const override; 307 TColorStyle::ParamType getParamType(int index) const override; 308 309 QString getParamNames(int index) const override; 310 void getParamRange(int index, double &min, double &max) const override; 311 double getParamValue(TColorStyle::double_tag, int index) const override; 312 void setParamValue(int index, double value) override; 313 loadData(TInputStreamInterface & is)314 void loadData(TInputStreamInterface &is) override { is >> m_color >> m_bend; } saveData(TOutputStreamInterface & os)315 void saveData(TOutputStreamInterface &os) const override { 316 os << m_color << m_bend; 317 } isSaveSupported()318 bool isSaveSupported() { return true; } 319 getTagId()320 int getTagId() const override { return 108; } 321 }; 322 323 //------------------------------------------------------------------- 324 325 class TCrystallizeStrokeStyle final : public TOptimizedStrokeStyleT<Points> { 326 TPixel32 m_color; 327 double m_period, m_opacity; 328 329 public: 330 TCrystallizeStrokeStyle(); 331 332 void computeData(Points &positions, const TStroke *stroke, 333 const TColorFunction *cf) const override; 334 void drawStroke(const TColorFunction *cf, Points &positions, 335 const TStroke *stroke) const override; 336 invalidate()337 void invalidate() {} 338 339 TColorStyle *clone() const override; 340 getDescription()341 QString getDescription() const override { 342 return QCoreApplication::translate("TCrystallizeStrokeStyle", "Tulle"); 343 } 344 hasMainColor()345 bool hasMainColor() const override { return true; } getMainColor()346 TPixel32 getMainColor() const override { return m_color; } setMainColor(const TPixel32 & color)347 void setMainColor(const TPixel32 &color) override { m_color = color; } 348 349 int getParamCount() const override; 350 TColorStyle::ParamType getParamType(int index) const override; 351 352 QString getParamNames(int index) const override; 353 void getParamRange(int index, double &min, double &max) const override; 354 double getParamValue(TColorStyle::double_tag, int index) const override; 355 void setParamValue(int index, double value) override; 356 loadData(TInputStreamInterface & is)357 void loadData(TInputStreamInterface &is) override { 358 is >> m_color >> m_period >> m_opacity; 359 } saveData(TOutputStreamInterface & os)360 void saveData(TOutputStreamInterface &os) const override { 361 os << m_color << m_period << m_opacity; 362 } isSaveSupported()363 bool isSaveSupported() { return true; } 364 getTagId()365 int getTagId() const override { return 109; } 366 }; 367 368 //------------------------------------------------------------------- 369 370 class TBraidStrokeStyle final : public TSimpleStrokeStyle { 371 TPixel32 m_colors[3]; 372 double m_period; 373 374 public: 375 TBraidStrokeStyle(); 376 377 TColorStyle *clone() const override; 378 379 void drawStroke(const TColorFunction *cf, 380 const TStroke *stroke) const override; 381 invalidate()382 void invalidate() {} 383 getDescription()384 QString getDescription() const override { 385 return QCoreApplication::translate("TBraidStrokeStyle", "Plait"); 386 } 387 hasMainColor()388 bool hasMainColor() const override { return true; } getMainColor()389 TPixel32 getMainColor() const override { return m_colors[0]; } setMainColor(const TPixel32 & color)390 void setMainColor(const TPixel32 &color) override { m_colors[0] = color; } 391 getColorParamCount()392 int getColorParamCount() const override { return 3; } 393 TPixel32 getColorParamValue(int index) const override; 394 void setColorParamValue(int index, const TPixel32 &color) override; 395 396 int getParamCount() const override; 397 TColorStyle::ParamType getParamType(int index) const override; 398 399 QString getParamNames(int index) const override; 400 void getParamRange(int index, double &min, double &max) const override; 401 double getParamValue(TColorStyle::double_tag, int index) const override; 402 void setParamValue(int index, double value) override; 403 loadData(TInputStreamInterface & is)404 void loadData(TInputStreamInterface &is) override { 405 is >> m_colors[0] >> m_colors[1] >> m_colors[2] >> m_period; 406 } 407 void loadData(int oldId, TInputStreamInterface &) override; saveData(TOutputStreamInterface & os)408 void saveData(TOutputStreamInterface &os) const override { 409 os << m_colors[0] << m_colors[1] << m_colors[2] << m_period; 410 } isSaveSupported()411 bool isSaveSupported() { return true; } 412 getTagId()413 int getTagId() const override { return 136; }; getObsoleteTagIds(std::vector<int> & ids)414 void getObsoleteTagIds(std::vector<int> &ids) const override { 415 ids.push_back(112); 416 } 417 }; 418 419 //------------------------------------------------------------------- 420 421 class TSketchStrokeStyle final : public TSimpleStrokeStyle { 422 TPixel32 m_color; 423 double m_density; 424 425 public: 426 TSketchStrokeStyle(); 427 428 TColorStyle *clone() const override; 429 invalidate()430 void invalidate() {} 431 getDescription()432 QString getDescription() const override { 433 return QCoreApplication::translate("TSketchStrokeStyle", "Fuzz"); 434 } 435 hasMainColor()436 bool hasMainColor() const override { return true; } getMainColor()437 TPixel32 getMainColor() const override { return m_color; } setMainColor(const TPixel32 & color)438 void setMainColor(const TPixel32 &color) override { m_color = color; } 439 440 int getParamCount() const override; 441 TColorStyle::ParamType getParamType(int index) const override; 442 443 QString getParamNames(int index) const override; 444 void getParamRange(int index, double &min, double &max) const override; 445 double getParamValue(TColorStyle::double_tag, int index) const override; 446 void setParamValue(int index, double value) override; 447 448 void drawStroke(const TColorFunction *cf, 449 const TStroke *stroke) const override; 450 loadData(TInputStreamInterface & is)451 void loadData(TInputStreamInterface &is) override { 452 is >> m_color >> m_density; 453 } saveData(TOutputStreamInterface & os)454 void saveData(TOutputStreamInterface &os) const override { 455 os << m_color << m_density; 456 } isSaveSupported()457 bool isSaveSupported() { return true; } 458 getTagId()459 int getTagId() const override { return 113; } 460 }; 461 462 //------------------------------------------------------------------- 463 464 class TBubbleStrokeStyle final : public TSimpleStrokeStyle { 465 TPixel32 m_color0, m_color1; 466 467 public: 468 TBubbleStrokeStyle(); 469 470 TColorStyle *clone() const override; 471 invalidate()472 void invalidate() {} 473 getDescription()474 QString getDescription() const override { 475 return QCoreApplication::translate("TBubbleStrokeStyle", "Bubbles"); 476 } 477 hasMainColor()478 bool hasMainColor() const override { return true; } getMainColor()479 TPixel32 getMainColor() const override { return m_color0; } setMainColor(const TPixel32 & color)480 void setMainColor(const TPixel32 &color) override { m_color0 = color; } 481 getColorParamCount()482 int getColorParamCount() const override { return 2; } getColorParamValue(int index)483 TPixel32 getColorParamValue(int index) const override { 484 return index == 0 ? m_color0 : m_color1; 485 } setColorParamValue(int index,const TPixel32 & color)486 void setColorParamValue(int index, const TPixel32 &color) override { 487 if (index == 0) 488 m_color0 = color; 489 else 490 m_color1 = color; 491 } 492 493 void drawStroke(const TColorFunction *cf, 494 const TStroke *stroke) const override; 495 loadData(TInputStreamInterface & is)496 void loadData(TInputStreamInterface &is) override { 497 is >> m_color0 >> m_color1; 498 } 499 void loadData(int oldId, TInputStreamInterface &) override; saveData(TOutputStreamInterface & os)500 void saveData(TOutputStreamInterface &os) const override { 501 os << m_color0 << m_color1; 502 } isSaveSupported()503 bool isSaveSupported() { return true; } 504 getTagId()505 int getTagId() const override { return 114; }; getObsoleteTagIds(std::vector<int> & ids)506 void getObsoleteTagIds(std::vector<int> &ids) const override { 507 ids.push_back(137); 508 } 509 }; 510 511 //------------------------------------------------------------------- 512 513 class TTissueStrokeStyle final : public TOptimizedStrokeStyleT<PointMatrix> { 514 TPixel32 m_color; 515 double m_density, m_border; 516 517 public: 518 TTissueStrokeStyle(); 519 520 TColorStyle *clone() const override; 521 522 void computeData(PointMatrix &data, const TStroke *stroke, 523 const TColorFunction *cf) const override; 524 void drawStroke(const TColorFunction *cf, PointMatrix &data, 525 const TStroke *stroke) const override; 526 invalidate()527 void invalidate() {} 528 getDescription()529 QString getDescription() const override { 530 return QCoreApplication::translate("TTissueStrokeStyle", "Gauze"); 531 } 532 hasMainColor()533 bool hasMainColor() const override { return true; } getMainColor()534 TPixel32 getMainColor() const override { return m_color; } setMainColor(const TPixel32 & color)535 void setMainColor(const TPixel32 &color) override { m_color = color; } 536 537 int getParamCount() const override; 538 TColorStyle::ParamType getParamType(int index) const override; 539 540 QString getParamNames(int index) const override; 541 void getParamRange(int index, double &min, double &max) const override; 542 double getParamValue(TColorStyle::double_tag, int index) const override; 543 void setParamValue(int index, double value) override; 544 loadData(TInputStreamInterface & is)545 void loadData(TInputStreamInterface &is) override { 546 is >> m_color >> m_density >> m_border; 547 } saveData(TOutputStreamInterface & os)548 void saveData(TOutputStreamInterface &os) const override { 549 os << m_color << m_density << m_border; 550 } 551 getTagId()552 int getTagId() const override { return 117; } 553 }; 554 555 //------------------------------------------------------------------- 556 557 class TBiColorStrokeStyle final : public TOutlineStyle { 558 TPixel32 m_color0, m_color1; 559 double m_parameter; 560 561 public: 562 TBiColorStrokeStyle(); 563 564 TColorStyle *clone() const override; 565 566 void drawStroke(const TColorFunction *cf, TStrokeOutline *outline, 567 const TStroke *stroke) const override; 568 void drawRegion(const TColorFunction *cf, const bool antiAliasing, 569 TRegionOutline &boundary) const override; 570 isRegionStyle()571 bool isRegionStyle() const override { return false; } isStrokeStyle()572 bool isStrokeStyle() const override { return true; } 573 invalidate()574 void invalidate() {} 575 getDescription()576 QString getDescription() const override { 577 return QCoreApplication::translate("TBiColorStrokeStyle", "Shade"); 578 } 579 hasMainColor()580 bool hasMainColor() const override { return true; } getMainColor()581 TPixel32 getMainColor() const override { return m_color0; } setMainColor(const TPixel32 & color)582 void setMainColor(const TPixel32 &color) override { m_color0 = color; } 583 584 void loadData(TInputStreamInterface &is) override; 585 void loadData(int oldId, TInputStreamInterface &) override; 586 587 void saveData(TOutputStreamInterface &os) const override; 588 getColorParamCount()589 int getColorParamCount() const override { return 2; } getColorParamValue(int index)590 TPixel32 getColorParamValue(int index) const override { 591 return index == 0 ? m_color0 : m_color1; 592 } setColorParamValue(int index,const TPixel32 & color)593 void setColorParamValue(int index, const TPixel32 &color) override { 594 if (index == 0) 595 m_color0 = color; 596 else 597 m_color1 = color; 598 } 599 getTagId()600 int getTagId() const override { return 135; }; getObsoleteTagIds(std::vector<int> & ids)601 void getObsoleteTagIds(std::vector<int> &ids) const override { 602 ids.push_back(115); 603 ids.push_back(119); 604 } 605 }; 606 607 //------------------------------------------------------------------- 608 609 class TNormal2StrokeStyle final : public TOutlineStyle { 610 TPixel32 m_color; 611 double m_lightx, m_lighty, m_shininess, m_metal, m_bend; 612 613 public: 614 TNormal2StrokeStyle(); 615 616 TColorStyle *clone() const override; 617 618 void drawRegion(const TColorFunction *cf, const bool antiAliasing, 619 TRegionOutline &boundary) const override; 620 void drawStroke(const TColorFunction *cf, TStrokeOutline *outline, 621 const TStroke *stroke) const override; 622 isRegionStyle()623 bool isRegionStyle() const override { return false; } isStrokeStyle()624 bool isStrokeStyle() const override { return true; } 625 invalidate()626 void invalidate() {} 627 getDescription()628 QString getDescription() const override { 629 return QCoreApplication::translate("TNormal2StrokeStyle", "Bump"); 630 } 631 hasMainColor()632 bool hasMainColor() const override { return true; } getMainColor()633 TPixel32 getMainColor() const override { return m_color; } setMainColor(const TPixel32 & color)634 void setMainColor(const TPixel32 &color) override { m_color = color; } 635 636 int getParamCount() const override; 637 TColorStyle::ParamType getParamType(int index) const override; 638 639 QString getParamNames(int index) const override; 640 void getParamRange(int index, double &min, double &max) const override; 641 double getParamValue(TColorStyle::double_tag, int index) const override; 642 void setParamValue(int index, double value) override; 643 loadData(TInputStreamInterface & is)644 void loadData(TInputStreamInterface &is) override { 645 is >> m_color >> m_lightx >> m_lighty >> m_shininess >> m_metal >> m_bend; 646 } 647 void loadData(int oldId, TInputStreamInterface &) override; saveData(TOutputStreamInterface & os)648 void saveData(TOutputStreamInterface &os) const override { 649 os << m_color << m_lightx << m_lighty << m_shininess << m_metal << m_bend; 650 } 651 getTagId()652 int getTagId() const override { return 120; }; getObsoleteTagIds(std::vector<int> & ids)653 void getObsoleteTagIds(std::vector<int> &ids) const override { 654 ids.push_back(121); 655 } 656 }; 657 658 //------------------------------------------------------------------- 659 660 class TChalkStrokeStyle2 final : public TOptimizedStrokeStyleT<Doubles> { 661 TPixel32 m_color; 662 double m_blend, m_intensity, m_in, m_out, m_noise; 663 664 public: 665 TChalkStrokeStyle2(); 666 667 TColorStyle *clone() const override; 668 invalidate()669 void invalidate() {} 670 getDescription()671 QString getDescription() const override { 672 return QCoreApplication::translate("TChalkStrokeStyle2", "Chalk"); 673 } 674 hasMainColor()675 bool hasMainColor() const override { return true; } getMainColor()676 TPixel32 getMainColor() const override { return m_color; } setMainColor(const TPixel32 & color)677 void setMainColor(const TPixel32 &color) override { m_color = color; } 678 679 int getParamCount() const override; 680 TColorStyle::ParamType getParamType(int index) const override; 681 682 QString getParamNames(int index) const override; 683 void getParamRange(int index, double &min, double &max) const override; 684 double getParamValue(TColorStyle::double_tag, int index) const override; 685 void setParamValue(int index, double value) override; 686 687 void computeData(Doubles &positions, const TStroke *stroke, 688 const TColorFunction *cf) const override; 689 void drawStroke(const TColorFunction *cf, Doubles &positions, 690 const TStroke *stroke) const override; 691 loadData(TInputStreamInterface & is)692 void loadData(TInputStreamInterface &is) override { 693 is >> m_color >> m_blend >> m_intensity >> m_in >> m_out >> m_noise; 694 } 695 void loadData(int oldId, TInputStreamInterface &) override; saveData(TOutputStreamInterface & os)696 void saveData(TOutputStreamInterface &os) const override { 697 os << m_color << m_blend << m_intensity << m_in << m_out << m_noise; 698 } getTagId()699 int getTagId() const override { return 123; }; getObsoleteTagIds(std::vector<int> & ids)700 void getObsoleteTagIds(std::vector<int> &ids) const override { 701 ids.push_back(105); 702 } 703 }; 704 705 //------------------------------------------------------------------- 706 707 class TBlendStrokeStyle2 final 708 : public TOptimizedStrokeStyleT<PointsAndDoubles> { 709 TPixel32 m_color; 710 double m_blend, m_in, m_out; 711 712 public: 713 TBlendStrokeStyle2(); 714 715 TColorStyle *clone() const override; 716 717 void computeData(PointsAndDoubles &data, const TStroke *stroke, 718 const TColorFunction *cf) const override; 719 void drawStroke(const TColorFunction *cf, PointsAndDoubles &data, 720 const TStroke *stroke) const override; 721 invalidate()722 void invalidate() {} 723 getDescription()724 QString getDescription() const override { 725 return QCoreApplication::translate("TBlendStrokeStyle2", "Fade"); 726 } 727 hasMainColor()728 bool hasMainColor() const override { return true; } getMainColor()729 TPixel32 getMainColor() const override { return m_color; } setMainColor(const TPixel32 & color)730 void setMainColor(const TPixel32 &color) override { m_color = color; } 731 732 int getParamCount() const override; 733 TColorStyle::ParamType getParamType(int index) const override; 734 735 QString getParamNames(int index) const override; 736 void getParamRange(int index, double &min, double &max) const override; 737 double getParamValue(TColorStyle::double_tag, int index) const override; 738 void setParamValue(int index, double value) override; 739 loadData(TInputStreamInterface & is)740 void loadData(TInputStreamInterface &is) override { 741 is >> m_color >> m_blend >> m_in >> m_out; 742 } 743 void loadData(int oldId, TInputStreamInterface &) override; saveData(TOutputStreamInterface & os)744 void saveData(TOutputStreamInterface &os) const override { 745 os << m_color << m_blend << m_in << m_out; 746 } isSaveSupported()747 bool isSaveSupported() { return true; } 748 getTagId()749 int getTagId() const override { return 125; }; getObsoleteTagIds(std::vector<int> & ids)750 void getObsoleteTagIds(std::vector<int> &ids) const override { 751 ids.push_back(110); 752 } 753 }; 754 755 //------------------------------------------------------------------- 756 757 class TTwirlStrokeStyle final : public TOptimizedStrokeStyleT<Doubles> { 758 TPixel32 m_color; 759 double m_period, m_blend; 760 761 public: 762 TTwirlStrokeStyle(); 763 764 TColorStyle *clone() const override; 765 766 void computeData(Doubles &data, const TStroke *stroke, 767 const TColorFunction *cf) const override; 768 void drawStroke(const TColorFunction *cf, Doubles &data, 769 const TStroke *stroke) const override; 770 // void drawStroke(const TColorFunction *cf, const TStroke *stroke) const; 771 invalidate()772 void invalidate() {} 773 getDescription()774 QString getDescription() const override { 775 return QCoreApplication::translate("TTwirlStrokeStyle", "Ribbon"); 776 } 777 hasMainColor()778 bool hasMainColor() const override { return true; } getMainColor()779 TPixel32 getMainColor() const override { return m_color; } setMainColor(const TPixel32 & color)780 void setMainColor(const TPixel32 &color) override { m_color = color; } 781 782 int getParamCount() const override; 783 TColorStyle::ParamType getParamType(int index) const override; 784 785 QString getParamNames(int index) const override; 786 void getParamRange(int index, double &min, double &max) const override; 787 double getParamValue(TColorStyle::double_tag, int index) const override; 788 void setParamValue(int index, double value) override; 789 loadData(TInputStreamInterface & is)790 void loadData(TInputStreamInterface &is) override { 791 is >> m_color >> m_period >> m_blend; 792 } saveData(TOutputStreamInterface & os)793 void saveData(TOutputStreamInterface &os) const override { 794 os << m_color << m_period << m_blend; 795 } isSaveSupported()796 bool isSaveSupported() { return true; } 797 getTagId()798 int getTagId() const override { return 126; } 799 }; 800 801 //------------------------------------------------------------------- 802 803 class TSawToothStrokeStyle final : public TOutlineStyle { 804 TPixel32 m_color; 805 double m_parameter; 806 807 public: 808 TSawToothStrokeStyle(TPixel32 color = TPixel32::Blue, 809 double parameter = 20.0); 810 811 TColorStyle *clone() const override; 812 drawRegion(const TColorFunction * cf,const bool antiAliasing,TRegionOutline & boundary)813 void drawRegion(const TColorFunction *cf, const bool antiAliasing, 814 TRegionOutline &boundary) const override {} 815 void drawStroke(const TColorFunction *cf, TStrokeOutline *outline, 816 const TStroke *stroke) const override; 817 isRegionStyle()818 bool isRegionStyle() const override { return false; } isStrokeStyle()819 bool isStrokeStyle() const override { return true; } 820 invalidate()821 void invalidate() {} 822 823 void computeOutline(const TStroke *stroke, TStrokeOutline &outline, 824 TOutlineUtil::OutlineParameter param) const override; 825 getDescription()826 QString getDescription() const override { 827 return QCoreApplication::translate("TSawToothStrokeStyle", "Jagged"); 828 } 829 hasMainColor()830 bool hasMainColor() const override { return true; } getMainColor()831 TPixel32 getMainColor() const override { return m_color; } setMainColor(const TPixel32 & color)832 void setMainColor(const TPixel32 &color) override { m_color = color; } 833 834 int getParamCount() const override; 835 TColorStyle::ParamType getParamType(int index) const override; 836 837 QString getParamNames(int index) const override; 838 void getParamRange(int index, double &min, double &max) const override; 839 double getParamValue(TColorStyle::double_tag, int index) const override; 840 void setParamValue(int index, double value) override; 841 getTagId()842 int getTagId() const override { return 127; }; loadData(TInputStreamInterface & is)843 void loadData(TInputStreamInterface &is) override { 844 is >> m_color >> m_parameter; 845 } saveData(TOutputStreamInterface & os)846 void saveData(TOutputStreamInterface &os) const override { 847 os << m_color << m_parameter; 848 } 849 }; 850 851 //------------------------------------------------------------------- 852 853 class TMultiLineStrokeStyle2 final 854 : public TOptimizedStrokeStyleT<BlendAndPoints> { 855 TPixel32 m_color0, m_color1; 856 double m_intensity, m_length, m_thick, m_noise; 857 858 public: 859 TMultiLineStrokeStyle2(); 860 861 TColorStyle *clone() const override; 862 863 void computeData(BlendAndPoints &data, const TStroke *stroke, 864 const TColorFunction *cf) const override; 865 void drawStroke(const TColorFunction *cf, BlendAndPoints &data, 866 const TStroke *stroke) const override; 867 // void drawStroke(const TColorFunction *cf, const TStroke *stroke) const; 868 invalidate()869 void invalidate() {} 870 getDescription()871 QString getDescription() const override { 872 return QCoreApplication::translate("TMultiLineStrokeStyle2", "Gouache"); 873 } 874 hasMainColor()875 bool hasMainColor() const override { return true; } getMainColor()876 TPixel32 getMainColor() const override { return m_color0; } setMainColor(const TPixel32 & color)877 void setMainColor(const TPixel32 &color) override { m_color0 = color; } 878 getColorParamCount()879 int getColorParamCount() const override { return 2; } getColorParamValue(int index)880 TPixel32 getColorParamValue(int index) const override { 881 return index == 0 ? m_color0 : m_color1; 882 } setColorParamValue(int index,const TPixel32 & color)883 void setColorParamValue(int index, const TPixel32 &color) override { 884 if (index == 0) 885 m_color0 = color; 886 else 887 m_color1 = color; 888 } 889 890 int getParamCount() const override; 891 TColorStyle::ParamType getParamType(int index) const override; 892 893 QString getParamNames(int index) const override; 894 void getParamRange(int index, double &min, double &max) const override; 895 double getParamValue(TColorStyle::double_tag, int index) const override; 896 void setParamValue(int index, double value) override; 897 loadData(TInputStreamInterface & is)898 void loadData(TInputStreamInterface &is) override { 899 is >> m_color0 >> m_color1 >> m_intensity >> m_length >> m_thick >> m_noise; 900 } 901 void loadData(int oldId, TInputStreamInterface &) override; saveData(TOutputStreamInterface & os)902 void saveData(TOutputStreamInterface &os) const override { 903 os << m_color0 << m_color1 << m_intensity << m_length << m_thick << m_noise; 904 } isSaveSupported()905 bool isSaveSupported() { return true; } 906 getTagId()907 int getTagId() const override { return 138; }; getObsoleteTagIds(std::vector<int> & ids)908 void getObsoleteTagIds(std::vector<int> &ids) const override { 909 ids.push_back(118); 910 ids.push_back(128); 911 } 912 }; 913 914 //------------------------------------------------------------------- 915 916 class TZigzagStrokeStyle final : public TOptimizedStrokeStyleT<Points> { 917 TPixel32 m_color; 918 double m_minDist, m_maxDist; 919 double m_minAngle, m_maxAngle; 920 double m_thickness; 921 922 // void drawBLines(RectVector& rects) const; 923 void setRealMinMax() const; 924 bool getZigZagPosition(const TStroke *stroke, TRandom &rnd, const double s, 925 const int first, const double minTranslLength, 926 TThickPoint &pos, TThickPoint &pos1) const; 927 928 public: 929 TZigzagStrokeStyle(); 930 931 TColorStyle *clone() const override; 932 933 void computeData(Points &positions, const TStroke *stroke, 934 const TColorFunction *cf) const override; 935 void drawStroke(const TColorFunction *cf, Points &positions, 936 const TStroke *stroke) const override; 937 // void drawStroke(const TColorFunction *cf, const TStroke *stroke) const; 938 invalidate()939 void invalidate() {} 940 getDescription()941 QString getDescription() const override { 942 return QCoreApplication::translate("TZigzagStrokeStyle", "Zigzag"); 943 } 944 hasMainColor()945 bool hasMainColor() const override { return true; } getMainColor()946 TPixel32 getMainColor() const override { return m_color; } setMainColor(const TPixel32 & color)947 void setMainColor(const TPixel32 &color) override { m_color = color; } 948 949 int getParamCount() const override; 950 TColorStyle::ParamType getParamType(int index) const override; 951 952 QString getParamNames(int index) const override; 953 void getParamRange(int index, double &min, double &max) const override; 954 double getParamValue(TColorStyle::double_tag, int index) const override; 955 void setParamValue(int index, double value) override; 956 loadData(TInputStreamInterface & is)957 void loadData(TInputStreamInterface &is) override { 958 is >> m_color >> m_minDist >> m_maxDist >> m_minAngle >> m_maxAngle >> 959 m_thickness; 960 } saveData(TOutputStreamInterface & os)961 void saveData(TOutputStreamInterface &os) const override { 962 os << m_color << m_minDist << m_maxDist << m_minAngle << m_maxAngle 963 << m_thickness; 964 } isSaveSupported()965 bool isSaveSupported() { return true; } 966 getTagId()967 int getTagId() const override { return 129; } 968 }; 969 970 //------------------------------------------------------------------- 971 972 class TSinStrokeStyle final : public TOptimizedStrokeStyleT<Points> { 973 TPixel32 m_color; 974 double m_frequency, m_thick; 975 976 public: 977 TSinStrokeStyle(); 978 979 TColorStyle *clone() const override; 980 981 void computeData(Points &positions, const TStroke *stroke, 982 const TColorFunction *cf) const override; 983 void drawStroke(const TColorFunction *cf, Points &positions, 984 const TStroke *stroke) const override; 985 // void drawStroke(const TColorFunction *cf, const TStroke *stroke) const; 986 invalidate()987 void invalidate() {} 988 getDescription()989 QString getDescription() const override { 990 return QCoreApplication::translate("TSinStrokeStyle", "Wave"); 991 } 992 hasMainColor()993 bool hasMainColor() const override { return true; } getMainColor()994 TPixel32 getMainColor() const override { return m_color; } setMainColor(const TPixel32 & color)995 void setMainColor(const TPixel32 &color) override { m_color = color; } 996 997 int getParamCount() const override; 998 TColorStyle::ParamType getParamType(int index) const override; 999 1000 QString getParamNames(int index) const override; 1001 void getParamRange(int index, double &min, double &max) const override; 1002 double getParamValue(TColorStyle::double_tag, int index) const override; 1003 void setParamValue(int index, double value) override; 1004 loadData(TInputStreamInterface & is)1005 void loadData(TInputStreamInterface &is) override { 1006 is >> m_color >> m_frequency >> m_thick; 1007 } saveData(TOutputStreamInterface & os)1008 void saveData(TOutputStreamInterface &os) const override { 1009 os << m_color << m_frequency << m_thick; 1010 } 1011 getTagId()1012 int getTagId() const override { return 130; } 1013 }; 1014 1015 //------------------------------------------------------------------- 1016 1017 class TFriezeStrokeStyle2 final : public TOptimizedStrokeStyleT<Points> { 1018 TPixel32 m_color; 1019 double m_parameter, m_thick; 1020 1021 public: 1022 TFriezeStrokeStyle2(); 1023 1024 TColorStyle *clone() const override; 1025 invalidate()1026 void invalidate() {} 1027 getDescription()1028 QString getDescription() const override { 1029 return QCoreApplication::translate("TFriezeStrokeStyle2", "Curl"); 1030 } 1031 hasMainColor()1032 bool hasMainColor() const override { return true; } getMainColor()1033 TPixel32 getMainColor() const override { return m_color; } setMainColor(const TPixel32 & color)1034 void setMainColor(const TPixel32 &color) override { m_color = color; } 1035 1036 int getParamCount() const override; 1037 TColorStyle::ParamType getParamType(int index) const override; 1038 1039 QString getParamNames(int index) const override; 1040 void getParamRange(int index, double &min, double &max) const override; 1041 double getParamValue(TColorStyle::double_tag, int index) const override; 1042 void setParamValue(int index, double value) override; 1043 1044 void computeData(std::vector<TPointD> &positions, const TStroke *stroke, 1045 const TColorFunction *cf) const override; 1046 void drawStroke(const TColorFunction *cf, std::vector<TPointD> &positions, 1047 const TStroke *stroke) const override; 1048 // void drawStroke(const TColorFunction *cf, const TStroke *stroke) const; 1049 loadData(TInputStreamInterface & is)1050 void loadData(TInputStreamInterface &is) override { 1051 is >> m_color >> m_parameter >> m_thick; 1052 } 1053 void loadData(int oldId, TInputStreamInterface &) override; saveData(TOutputStreamInterface & os)1054 void saveData(TOutputStreamInterface &os) const override { 1055 os << m_color << m_parameter << m_thick; 1056 } getTagId()1057 int getTagId() const override { return 133; }; getObsoleteTagIds(std::vector<int> & ids)1058 void getObsoleteTagIds(std::vector<int> &ids) const override { 1059 ids.push_back(102); 1060 } 1061 }; 1062 1063 //------------------------------------------------------------------- 1064 1065 class TDualColorStrokeStyle2 final : public TOutlineStyle { 1066 TPixel32 m_color0, m_color1; 1067 double m_parameter; 1068 1069 public: 1070 TDualColorStrokeStyle2(TPixel32 color0 = TPixel32::Blue, 1071 TPixel32 color1 = TPixel32::Yellow, 1072 double parameter = 20.0); 1073 1074 TColorStyle *clone() const override; 1075 drawRegion(const TColorFunction * cf,const bool antiAliasing,TRegionOutline & boundary)1076 void drawRegion(const TColorFunction *cf, const bool antiAliasing, 1077 TRegionOutline &boundary) const override {} 1078 void drawStroke(const TColorFunction *cf, TStrokeOutline *outline, 1079 const TStroke *stroke) const override; 1080 isRegionStyle()1081 bool isRegionStyle() const override { return false; } isStrokeStyle()1082 bool isStrokeStyle() const override { return true; } 1083 invalidate()1084 void invalidate() {} 1085 1086 void computeOutline(const TStroke *stroke, TStrokeOutline &outline, 1087 TOutlineUtil::OutlineParameter param) const override; 1088 getDescription()1089 QString getDescription() const override { 1090 return QCoreApplication::translate("TDualColorStrokeStyle2", "Striped"); 1091 } 1092 hasMainColor()1093 bool hasMainColor() const override { return true; } getMainColor()1094 TPixel32 getMainColor() const override { return m_color0; } setMainColor(const TPixel32 & color)1095 void setMainColor(const TPixel32 &color) override { m_color0 = color; } 1096 getColorParamCount()1097 int getColorParamCount() const override { return 2; } getColorParamValue(int index)1098 TPixel32 getColorParamValue(int index) const override { 1099 return (index == 0) ? m_color0 : m_color1; 1100 } setColorParamValue(int index,const TPixel32 & color)1101 void setColorParamValue(int index, const TPixel32 &color) override { 1102 if (index == 0) 1103 m_color0 = color; 1104 else 1105 m_color1 = color; 1106 } 1107 1108 int getParamCount() const override; 1109 TColorStyle::ParamType getParamType(int index) const override; 1110 1111 QString getParamNames(int index) const override; 1112 void getParamRange(int index, double &min, double &max) const override; 1113 double getParamValue(TColorStyle::double_tag, int index) const override; 1114 void setParamValue(int index, double value) override; 1115 getTagId()1116 int getTagId() const override { return 132; }; loadData(TInputStreamInterface & is)1117 void loadData(TInputStreamInterface &is) override { 1118 is >> m_color0 >> m_color1 >> m_parameter; 1119 } saveData(TOutputStreamInterface & os)1120 void saveData(TOutputStreamInterface &os) const override { 1121 os << m_color0 << m_color1 << m_parameter; 1122 } 1123 }; 1124 1125 //------------------------------------------------------------------- 1126 1127 class TLongBlendStrokeStyle2 final : public TOutlineStyle { 1128 TPixel32 m_color0, m_color1; 1129 double m_parameter; 1130 1131 public: 1132 TLongBlendStrokeStyle2(TPixel32 color0 = TPixel32::Blue, 1133 TPixel32 color1 = TPixel32::Transparent, 1134 double parameter = 20.0); 1135 1136 TColorStyle *clone() const override; 1137 drawRegion(const TColorFunction * cf,const bool antiAliasing,TRegionOutline & boundary)1138 void drawRegion(const TColorFunction *cf, const bool antiAliasing, 1139 TRegionOutline &boundary) const override {} 1140 void drawStroke(const TColorFunction *cf, TStrokeOutline *outline, 1141 const TStroke *stroke) const override; 1142 isRegionStyle()1143 bool isRegionStyle() const override { return false; } isStrokeStyle()1144 bool isStrokeStyle() const override { return true; } 1145 invalidate()1146 void invalidate() {} 1147 1148 void computeOutline(const TStroke *stroke, TStrokeOutline &outline, 1149 TOutlineUtil::OutlineParameter param) const override; 1150 getDescription()1151 QString getDescription() const override { 1152 return QCoreApplication::translate("TLongBlendStrokeStyle2", "Watercolor"); 1153 } 1154 hasMainColor()1155 bool hasMainColor() const override { return true; } getMainColor()1156 TPixel32 getMainColor() const override { return m_color0; } setMainColor(const TPixel32 & color0)1157 void setMainColor(const TPixel32 &color0) override { m_color0 = color0; } 1158 getColorParamCount()1159 int getColorParamCount() const override { return 2; } getColorParamValue(int index)1160 TPixel32 getColorParamValue(int index) const override { 1161 return index == 0 ? m_color0 : m_color1; 1162 } setColorParamValue(int index,const TPixel32 & color)1163 void setColorParamValue(int index, const TPixel32 &color) override { 1164 if (index == 0) 1165 m_color0 = color; 1166 else 1167 m_color1 = color; 1168 } 1169 1170 int getParamCount() const override; 1171 TColorStyle::ParamType getParamType(int index) const override; 1172 1173 QString getParamNames(int index) const override; 1174 void getParamRange(int index, double &min, double &max) const override; 1175 double getParamValue(TColorStyle::double_tag, int index) const override; 1176 void setParamValue(int index, double value) override; 1177 getTagId()1178 int getTagId() const override { return 134; }; loadData(TInputStreamInterface & is)1179 void loadData(TInputStreamInterface &is) override { 1180 is >> m_color0 >> m_color1 >> m_parameter; 1181 } saveData(TOutputStreamInterface & os)1182 void saveData(TOutputStreamInterface &os) const override { 1183 os << m_color0 << m_color1 << m_parameter; 1184 } 1185 }; 1186 1187 //------------------------------------------------------------------- 1188 1189 #ifdef _DEBUG 1190 1191 class OutlineViewerStyle final : public TSolidColorStyle { 1192 double m_parameter[4]; 1193 1194 bool m_boolPar; 1195 int m_intPar; 1196 int m_enumPar; 1197 TFilePath m_pathPar; 1198 1199 protected: 1200 void loadData(TInputStreamInterface &is) override; 1201 void saveData(TOutputStreamInterface &os) const override; 1202 1203 public: 1204 OutlineViewerStyle(TPixel32 color = TPixel32::Black, double parameter0 = 0.0, 1205 double parameter1 = 0.0, double parameter2 = 2.0, 1206 double parameter3 = 3.0); 1207 1208 TColorStyle *clone() const override; 1209 1210 int getParamCount() const override; 1211 TColorStyle::ParamType getParamType(int index) const override; 1212 1213 QString getParamNames(int index) const override; 1214 1215 bool getParamValue(TColorStyle::bool_tag, int index) const override; 1216 void setParamValue(int index, bool value) override; 1217 1218 void getParamRange(int index, int &min, int &max) const override; 1219 int getParamValue(TColorStyle::int_tag, int index) const override; 1220 void setParamValue(int index, int value) override; 1221 1222 void getParamRange(int index, QStringList &enumItems) const override; 1223 1224 void getParamRange(int index, double &min, double &max) const override; 1225 double getParamValue(TColorStyle::double_tag, int index) const override; 1226 void setParamValue(int index, double value) override; 1227 1228 TFilePath getParamValue(TColorStyle::TFilePath_tag, int index) const override; 1229 void setParamValue(int index, const TFilePath &path) override; 1230 1231 void computeOutline(const TStroke *stroke, TStrokeOutline &outline, 1232 TOutlineUtil::OutlineParameter param) const override; 1233 isRegionStyle()1234 bool isRegionStyle() const override { return false; } isStrokeStyle()1235 bool isStrokeStyle() const override { return true; } 1236 1237 void drawStroke(const TColorFunction *cf, TStrokeOutline *outline, 1238 const TStroke *stroke) const override; getDescription()1239 QString getDescription() const override { 1240 return QCoreApplication::translate("OutlineViewerStyle", 1241 "OutlineViewer(OnlyDebug)"); 1242 } getTagId()1243 int getTagId() const override { return 99; }; 1244 }; 1245 1246 #endif 1247 1248 //------------------------------------------------------------------- 1249 1250 class TMatrioskaStrokeStyle; 1251 1252 class TMatrioskaStrokeProp final : public TStrokeProp { 1253 protected: 1254 double m_outlinePixelSize; 1255 TMatrioskaStrokeStyle *m_colorStyle; 1256 1257 std::vector<TStrokeOutline> m_outline; 1258 1259 std::vector<TStroke *> m_appStrokes; 1260 1261 public: 1262 TMatrioskaStrokeProp(const TStroke *stroke, TMatrioskaStrokeStyle *style); 1263 ~TMatrioskaStrokeProp(); 1264 1265 const TColorStyle *getColorStyle() const override; 1266 1267 TStrokeProp *clone(const TStroke *stroke) const override; 1268 void draw(const TVectorRenderData &rd) override; 1269 }; 1270 1271 class TMatrioskaStrokeStyle final : public TSolidColorStyle { 1272 double m_parameter; 1273 TPixel32 m_color2; 1274 1275 protected: 1276 void loadData(TInputStreamInterface &is) override; 1277 void saveData(TOutputStreamInterface &os) const override; 1278 1279 public: 1280 TMatrioskaStrokeStyle(TPixel32 color1 = TPixel32::Magenta, 1281 TPixel32 color2 = TPixel32::Blue, 1282 double parameter = 6.0, bool alternate = true); 1283 1284 TColorStyle *clone() const override; 1285 getColorParamCount()1286 int getColorParamCount() const override { return 2; } 1287 TPixel32 getColorParamValue(int index) const override; 1288 void setColorParamValue(int index, const TPixel32 &color) override; 1289 1290 int getParamCount() const override; 1291 TColorStyle::ParamType getParamType(int index) const override; 1292 1293 QString getParamNames(int index) const override; 1294 void getParamRange(int index, double &min, double &max) const override; 1295 double getParamValue(TColorStyle::double_tag, int index) const override; 1296 void setParamValue(int index, double value) override; 1297 1298 TStrokeProp *makeStrokeProp(const TStroke *stroke) override; 1299 isRegionStyle()1300 bool isRegionStyle() const override { return false; } isStrokeStyle()1301 bool isStrokeStyle() const override { return true; } 1302 getDescription()1303 QString getDescription() const override { 1304 return QCoreApplication::translate("TMatrioskaStrokeStyle", "Toothpaste"); 1305 } getTagId()1306 int getTagId() const override { return 141; }; 1307 }; 1308 1309 #endif // STROKESTYLES_H 1310