1 #pragma once
2 
3 #ifndef TDERIVEDREGIONSTYLES_H
4 #define TDERIVEDREGIONSTYLES_H
5 
6 // TnzCore includes
7 #include "tvectorimage.h"
8 #include "tregionoutline.h"
9 #include "tsimplecolorstyles.h"
10 
11 #undef DVAPI
12 #undef DVVAR
13 
14 #ifdef COLORFX_EXPORTS
15 #define DVAPI DV_EXPORT_API
16 #define DVVAR DV_EXPORT_VAR
17 #else
18 #define DVAPI DV_IMPORT_API
19 #define DVVAR DV_IMPORT_VAR
20 #endif
21 
22 //======================================================
23 
24 //    Forward declarations
25 
26 class TRandom;
27 
28 //======================================================
29 
30 //============================================================
31 
32 class MovingModifier final : public TOutlineStyle::RegionOutlineModifier {
33   TPointD m_move;
34 
35 public:
MovingModifier(const TPointD & point)36   MovingModifier(const TPointD &point) : m_move(point) {}
37 
38   TOutlineStyle::RegionOutlineModifier *clone() const override;
39 
getMovePoint()40   TPointD getMovePoint() const { return m_move; }
41 
42   void modify(TRegionOutline &outline) const override;
43 
44 public:
loadData(TInputStreamInterface & is)45   void loadData(TInputStreamInterface &is) { is >> m_move.x >> m_move.y; }
46 
saveData(TOutputStreamInterface & os)47   void saveData(TOutputStreamInterface &os) const {
48     os << m_move.x << m_move.y;
49   }
50 };
51 
52 //============================================================
53 
54 class MovingSolidColor final : public TSolidColorStyle {
55 public:
56   MovingSolidColor(const TPixel32 &color, const TPointD &move);
57 
58   TColorStyle *clone() const override;
59 
isRegionStyle()60   bool isRegionStyle() const override { return true; }
isStrokeStyle()61   bool isStrokeStyle() const override { return false; }
62 
63   int getParamCount() const override;
64   TColorStyle::ParamType getParamType(int index) const override;
65 
66   QString getParamNames(int index) const override;
67   void getParamRange(int index, double &min, double &max) const override;
68   double getParamValue(TColorStyle::double_tag, int index) const override;
69   void setParamValue(int index, double value) override;
70 
getTagId()71   int getTagId() const override { return 1125; };
getDescription()72   QString getDescription() const override {
73     return QCoreApplication::translate("MovingSolidColor", "Offset");
74   }
75 
76   void drawRegion(const TColorFunction *cf, const bool antiAliasing,
77                   TRegionOutline &boundary) const override;
78 
79 protected:
80   void loadData(TInputStreamInterface &is) override;
81   void saveData(TOutputStreamInterface &os) const override;
82 };
83 
84 //============================================================
85 
86 class DVAPI ShadowStyle final : public TSolidColorStyle {
87   TPointD m_shadowDirection;
88   TPixel32 m_shadowColor;
89   double m_density;
90   double m_len;
91 
92 public:
93   ShadowStyle(const TPixel32 &bgColor, const TPixel32 &shadowColor,
94               const TPointD &shadowDirection = TPointD(-1, -1),
95               double len = 30.0, double density = 0.4);
96 
97   TColorStyle *clone() const override;
98 
99   void makeIcon(const TDimension &d) override;
isRegionStyle()100   bool isRegionStyle() const override { return true; }
isStrokeStyle()101   bool isStrokeStyle() const override { return false; }
102 
103   // TPixel32 getMainColor() const {return m_shadowColor; }
104   // void setMainColor(const TPixel32 &color){ m_shadowColor=color; }
105 
getColorParamCount()106   int getColorParamCount() const override { return 2; }
107   TPixel32 getColorParamValue(int index) const override;
108   void setColorParamValue(int index, const TPixel32 &color) override;
109 
110   int getParamCount() const override;
111   TColorStyle::ParamType getParamType(int index) const override;
112 
113   QString getParamNames(int index) const override;
114   void getParamRange(int index, double &min, double &max) const override;
115   double getParamValue(TColorStyle::double_tag, int index) const override;
116   void setParamValue(int index, double value) override;
117 
getTagId()118   int getTagId() const override { return 1127; };
getDescription()119   QString getDescription() const override {
120     return QCoreApplication::translate("ShadowStyle", "Hatched Shading");
121   }
122 
123   void drawRegion(const TColorFunction *cf, const bool antiAliasing,
124                   TRegionOutline &boundary) const override;
125 
126 protected:
127   void loadData(TInputStreamInterface &is) override;
128   void saveData(TOutputStreamInterface &os) const override;
129 
130 private:
131   void drawPolyline(const TColorFunction *cf, std::vector<T3DPointD> &polyline,
132                     TPointD shadowDirection) const;
133 };
134 
135 //============================================================
136 
137 class DVAPI ShadowStyle2 final : public TSolidColorStyle {
138   TPointD m_shadowDirection;
139   TPixel32 m_shadowColor;
140   double m_shadowLength;
141 
142 public:
143   ShadowStyle2(const TPixel32 &bgColor, const TPixel32 &shadowColor,
144                const TPointD &shadowDirection = TPointD(-1, -1),
145                double shadowLength            = 70.0);
146 
147   TColorStyle *clone() const override;
148 
isRegionStyle()149   bool isRegionStyle() const override { return true; }
isStrokeStyle()150   bool isStrokeStyle() const override { return false; }
151 
152   // TPixel32 getMainColor() const {return m_shadowColor; }
153   // void setMainColor(const TPixel32 &color){ m_shadowColor=color; }
154 
getColorParamCount()155   int getColorParamCount() const override { return 2; }
156   TPixel32 getColorParamValue(int index) const override;
157   void setColorParamValue(int index, const TPixel32 &color) override;
158 
159   int getParamCount() const override;
160   TColorStyle::ParamType getParamType(int index) const override;
161 
162   QString getParamNames(int index) const override;
163   void getParamRange(int index, double &min, double &max) const override;
164   double getParamValue(TColorStyle::double_tag, int index) const override;
165   void setParamValue(int index, double value) override;
166 
getTagId()167   int getTagId() const override { return 1135; };
getDescription()168   QString getDescription() const override {
169     return QCoreApplication::translate("ShadowStyle2", "Plain Shadow");
170   }
171 
172   void drawRegion(const TColorFunction *cf, const bool antiAliasing,
173                   TRegionOutline &boundary) const override;
174 
175 protected:
176   void loadData(TInputStreamInterface &is) override;
177   void saveData(TOutputStreamInterface &os) const override;
178 
179 private:
180   void drawPolyline(const TColorFunction *cf,
181                     const std::vector<T3DPointD> &polyline,
182                     TPointD shadowDirection) const;
183 };
184 
185 //============================================================
186 
187 class RubberModifier final : public TOutlineStyle::RegionOutlineModifier {
188   double m_deform;
189 
190 public:
RubberModifier(double deform)191   RubberModifier(double deform) : m_deform(deform) {}
192 
loadData(TInputStreamInterface & is)193   void loadData(TInputStreamInterface &is) { is >> m_deform; }
saveData(TOutputStreamInterface & os)194   void saveData(TOutputStreamInterface &os) const { os << m_deform; }
195 
getDeform()196   double getDeform() { return m_deform; }
setDeform(const double deform)197   void setDeform(const double deform) { m_deform = deform; }
198 
199   void modify(TRegionOutline &outline) const override;
200 
201   TOutlineStyle::RegionOutlineModifier *clone() const override;
202 };
203 
204 //============================================================
205 
206 class DVAPI TRubberFillStyle final : public TSolidColorStyle {
207   typedef std::vector<TQuadratic> QuadraticVector;
208   typedef std::vector<TQuadratic *> QuadraticPVector;
209 
210 public:
211   TRubberFillStyle(const TPixel32 &color, double deform);
212 
213   TColorStyle *clone() const override;
214 
isRegionStyle()215   bool isRegionStyle() const override { return true; }
isStrokeStyle()216   bool isStrokeStyle() const override { return false; }
217 
218   int getParamCount() const override;
219   TColorStyle::ParamType getParamType(int index) const override;
220 
221   QString getParamNames(int index) const override;
222   void getParamRange(int index, double &min, double &max) const override;
223   double getParamValue(TColorStyle::double_tag, int index) const override;
224   void setParamValue(int index, double value) override;
225 
226   void makeIcon(const TDimension &d) override;
227 
getTagId()228   int getTagId() const override { return 1128; };
getDescription()229   QString getDescription() const override {
230     return QCoreApplication::translate("TRubberFillStyle", "Blob");
231   }
232 
233   void drawRegion(const TColorFunction *cf, const bool antiAliasing,
234                   TRegionOutline &boundary) const override;
235 
236 protected:
237   void loadData(TInputStreamInterface &is) override;
238   void saveData(TOutputStreamInterface &os) const override;
239 
240 private:
241   void transformPolylines();
242 };
243 
244 //============================================================
245 
246 class DVAPI TPointShadowFillStyle final : public TSolidColorStyle {
247   TPointD m_shadowDirection;
248   TPixel32 m_shadowColor;
249   double m_shadowSize;
250   double m_density;
251   double m_pointSize;
252 
253 public:
254   TPointShadowFillStyle(const TPixel32 &bgColor, const TPixel32 &shadowColor,
255                         const TPointD &shadowDirection = TPointD(-1, -1),
256                         double density = 0.1, double shadowSize = 30.0,
257                         double pointSize = 5.0);
258 
259   TColorStyle *clone() const override;
260 
isRegionStyle()261   bool isRegionStyle() const override { return true; }
isStrokeStyle()262   bool isStrokeStyle() const override { return false; }
263 
264   /*
265 TPixel32 getMainColor() const {return m_shadowColor; }
266 void setMainColor(const TPixel32 &color){ m_shadowColor=color; }
267 */
268 
getColorParamCount()269   int getColorParamCount() const override { return 2; }
270   TPixel32 getColorParamValue(int index) const override;
271   void setColorParamValue(int index, const TPixel32 &color) override;
272 
273   int getParamCount() const override;
274   TColorStyle::ParamType getParamType(int index) const override;
275 
276   QString getParamNames(int index) const override;
277   void getParamRange(int index, double &min, double &max) const override;
278   double getParamValue(TColorStyle::double_tag, int index) const override;
279   void setParamValue(int index, double value) override;
280 
getTagId()281   int getTagId() const override { return 1129; };
getDescription()282   QString getDescription() const override {
283     return QCoreApplication::translate("TPointShadowFillStyle",
284                                        "Sponge Shading");
285   }
286 
287   void drawRegion(const TColorFunction *cf, const bool antiAliasing,
288                   TRegionOutline &boundary) const override;
289 
290 protected:
291   void loadData(TInputStreamInterface &is) override;
292   void saveData(TOutputStreamInterface &os) const override;
293 
294 private:
295   double triangleArea(const TPointD &a, const TPointD &b,
296                       const TPointD &c) const;
297   void shadowOnEdge_parallel(const TPointD &p0, const TPointD &p1,
298                              const TPointD &p2, TRandom &rnd) const;
299 
300   void deleteSameVerts(TRegionOutline::Boundary::iterator &rit,
301                        std::vector<T3DPointD> &pv) const;
302 };
303 
304 //============================================================
305 
306 class DVAPI TDottedFillStyle final : public TSolidColorStyle {
307   TPixel32 m_pointColor;
308   double m_dotSize;
309   double m_dotDist;
310   bool m_isShifted;
311 
312 public:
313   TDottedFillStyle(const TPixel32 &bgColor, const TPixel32 &pointColor,
314                    const double dotSize, const double dotDist,
315                    const bool isShifted);
316 
317   TDottedFillStyle(const TPixel32 &color);
318 
319   TColorStyle *clone() const override;
320 
321   /*
322 TPixel32 getMainColor() const {return m_pointColor; }
323 void setMainColor(const TPixel32 &color){ m_pointColor=color; }
324 */
325 
getColorParamCount()326   int getColorParamCount() const override { return 2; }
327   TPixel32 getColorParamValue(int index) const override;
328   void setColorParamValue(int index, const TPixel32 &color) override;
329 
isRegionStyle()330   bool isRegionStyle() const override { return true; }
isStrokeStyle()331   bool isStrokeStyle() const override { return false; }
332 
333   int getParamCount() const override;
334   TColorStyle::ParamType getParamType(int index) const override;
335 
336   QString getParamNames(int index) const override;
337   void getParamRange(int index, double &min, double &max) const override;
338   double getParamValue(TColorStyle::double_tag, int index) const override;
339   void setParamValue(int index, double value) override;
340 
341   void drawRegion(const TColorFunction *cf, const bool antiAliasing,
342                   TRegionOutline &boundary) const override;
343 
getTagId()344   int getTagId() const override { return 1130; };
getDescription()345   QString getDescription() const override {
346     return QCoreApplication::translate("TDottedFillStyle", "Polka Dots");
347   }
348 
349 protected:
350   void loadData(TInputStreamInterface &is) override;
351   void saveData(TOutputStreamInterface &os) const override;
352 
353 private:
354   int nbClip(const double LDotDist, const bool LIsShifted,
355              const TRectD &bbox) const;
356 };
357 
358 //============================================================
359 
360 class DVAPI TCheckedFillStyle final : public TSolidColorStyle {
361   TPixel32 m_pointColor;
362   double m_HDist, m_HAngle;
363   double m_VDist, m_VAngle, m_Thickness;
364 
365 public:
366   TCheckedFillStyle(const TPixel32 &bgColor, const TPixel32 &pointColor,
367                     const double HDist, const double HAngle, const double VDist,
368                     const double VAngle, const double Thickness);
369 
370   TCheckedFillStyle(const TPixel32 &color);
371 
372   TColorStyle *clone() const override;
373 
374   /*
375 TPixel32 getMainColor() const {return m_pointColor; }
376 void setMainColor(const TPixel32 &color){ m_pointColor=color; }
377 */
378 
getColorParamCount()379   int getColorParamCount() const override { return 2; }
380   TPixel32 getColorParamValue(int index) const override;
381   void setColorParamValue(int index, const TPixel32 &color) override;
382 
isRegionStyle()383   bool isRegionStyle() const override { return true; }
isStrokeStyle()384   bool isStrokeStyle() const override { return false; }
385 
386   int getParamCount() const override;
387   TColorStyle::ParamType getParamType(int index) const override;
388 
389   QString getParamNames(int index) const override;
390   void getParamRange(int index, double &min, double &max) const override;
391   double getParamValue(TColorStyle::double_tag, int index) const override;
392   void setParamValue(int index, double value) override;
393 
394   void drawRegion(const TColorFunction *cf, const bool antiAliasing,
395                   TRegionOutline &boundary) const override;
396 
getTagId()397   int getTagId() const override { return 1131; };
getDescription()398   QString getDescription() const override {
399     return QCoreApplication::translate("TCheckedFillStyle", "Square");
400   }
401 
402 private:
403   void getHThickline(const TPointD &lc, const double lx, TPointD &p0,
404                      TPointD &p1, TPointD &p2, TPointD &p3) const;
405   void getVThickline(const TPointD &lc, const double ly, TPointD &p0,
406                      TPointD &p1, TPointD &p2, TPointD &p3) const;
407   int nbClip(const TRectD &bbox) const;
408 
409 protected:
410   void loadData(TInputStreamInterface &is) override;
411   void saveData(TOutputStreamInterface &os) const override;
412 };
413 
414 //============================================================
415 
416 class ArtisticModifier final : public TOutlineStyle::RegionOutlineModifier {
417   TPointD m_move;
418   double m_period;
419 
420 public:
ArtisticModifier(const TPointD & point,double period)421   ArtisticModifier(const TPointD &point, double period)
422       : m_move(point), m_period(period) {}
423 
424   TOutlineStyle::RegionOutlineModifier *clone() const override;
425 
loadData(TInputStreamInterface & is)426   void loadData(TInputStreamInterface &is) {
427     is >> m_move.x >> m_move.y >> m_period;
428   }
saveData(TOutputStreamInterface & os)429   void saveData(TOutputStreamInterface &os) const {
430     os << m_move.x << m_move.y << m_period;
431   }
432 
getMovePoint()433   TPointD getMovePoint() const { return m_move; }
getPeriod()434   double getPeriod() const { return m_period; }
435 
436   void modify(TRegionOutline &outline) const override;
437 };
438 
439 //============================================================
440 
441 class ArtisticSolidColor final : public TSolidColorStyle {
442 public:
443   ArtisticSolidColor(const TPixel32 &color, const TPointD &move, double period);
444 
445   TColorStyle *clone() const override;
446 
isRegionStyle()447   bool isRegionStyle() const override { return true; }
isStrokeStyle()448   bool isStrokeStyle() const override { return false; }
449 
450   int getParamCount() const override;
451   TColorStyle::ParamType getParamType(int index) const override;
452 
453   QString getParamNames(int index) const override;
454   void getParamRange(int index, double &min, double &max) const override;
455   double getParamValue(TColorStyle::double_tag, int index) const override;
456   void setParamValue(int index, double value) override;
457 
getTagId()458   int getTagId() const override { return 1132; };
getDescription()459   QString getDescription() const override {
460     return QCoreApplication::translate("ArtisticSolidColor", "Irregular");
461   }
462 
463   void drawRegion(const TColorFunction *cf, const bool antiAliasing,
464                   TRegionOutline &boundary) const override;
465 
466 protected:
467   void loadData(TInputStreamInterface &is) override;
468   void saveData(TOutputStreamInterface &os) const override;
469 };
470 
471 //============================================================
472 
473 class DVAPI TChalkFillStyle final : public TSolidColorStyle {
474   TPixel32 m_color0;
475   double m_density, m_size;
476 
477 public:
478   TChalkFillStyle(const TPixel32 &color0, const TPixel32 &color1,
479                   const double density, const double size);
480   TChalkFillStyle(const TPixel32 &color0, const TPixel32 &color1);
481 
482   TColorStyle *clone() const override;
483 
484   /*
485 TPixel32 getMainColor() const {return m_color0; }
486 void setMainColor(const TPixel32 &color){ m_color0=color; }
487 */
488 
getColorParamCount()489   int getColorParamCount() const override { return 2; }
490   TPixel32 getColorParamValue(int index) const override;
491   void setColorParamValue(int index, const TPixel32 &color) override;
492 
isRegionStyle()493   bool isRegionStyle() const override { return true; }
isStrokeStyle()494   bool isStrokeStyle() const override { return false; }
495 
496   int getParamCount() const override;
497   TColorStyle::ParamType getParamType(int index) const override;
498 
499   QString getParamNames(int index) const override;
500   void getParamRange(int index, double &min, double &max) const override;
501   double getParamValue(TColorStyle::double_tag, int index) const override;
502   void setParamValue(int index, double value) override;
503 
504   void drawRegion(const TColorFunction *cf, const bool antiAliasing,
505                   TRegionOutline &boundary) const override;
506 
getDescription()507   QString getDescription() const override {
508     return QCoreApplication::translate("TChalkFillStyle", "Chalk");
509   }
510   void loadData(int oldId, TInputStreamInterface &) override;
getObsoleteTagIds(std::vector<int> & ids)511   void getObsoleteTagIds(std::vector<int> &ids) const override {
512     ids.push_back(1133);
513   }
getTagId()514   int getTagId() const override { return 1143; };
515 
516 protected:
517   void loadData(TInputStreamInterface &is) override;
518   void saveData(TOutputStreamInterface &os) const override;
519 };
520 
521 //============================================================
522 
523 class DVAPI TChessFillStyle final : public TSolidColorStyle {
524   TPixel32 m_pointColor;
525   double m_HDist, m_VDist, m_Angle;
526 
527 public:
528   TChessFillStyle(const TPixel32 &bgColor, const TPixel32 &pointColor,
529                   const double HDist, const double VDist, const double Angle);
530   TChessFillStyle(const TPixel32 &color);
531 
532   TColorStyle *clone() const override;
533 
534   /*
535 TPixel32 getMainColor() const {return m_pointColor; }
536 void setMainColor(const TPixel32 &color){ m_pointColor=color; }
537 */
538 
getColorParamCount()539   int getColorParamCount() const override { return 2; }
540   TPixel32 getColorParamValue(int index) const override;
541   void setColorParamValue(int index, const TPixel32 &color) override;
542 
isRegionStyle()543   bool isRegionStyle() const override { return true; }
isStrokeStyle()544   bool isStrokeStyle() const override { return false; }
545 
546   int getParamCount() const override;
547   TColorStyle::ParamType getParamType(int index) const override;
548 
549   QString getParamNames(int index) const override;
550   void getParamRange(int index, double &min, double &max) const override;
551   double getParamValue(TColorStyle::double_tag, int index) const override;
552   void setParamValue(int index, double value) override;
553 
554   void drawRegion(const TColorFunction *cf, const bool antiAliasing,
555                   TRegionOutline &boundary) const override;
556 
getTagId()557   int getTagId() const override { return 1136; };
getDescription()558   QString getDescription() const override {
559     return QCoreApplication::translate("TChessFillStyle", "Chessboard");
560   }
561 
562 protected:
563   void loadData(TInputStreamInterface &is) override;
564   void saveData(TOutputStreamInterface &os) const override;
565 
566 private:
567   void makeGrid(TRectD &bbox, TRotation &rotM, std::vector<TPointD> &grid,
568                 int &nbClip) const;
569 };
570 
571 //============================================================
572 
573 class DVAPI TStripeFillStyle final : public TSolidColorStyle {
574   TPixel32 m_pointColor;
575   double m_Dist, m_Angle, m_Thickness;
576 
577 public:
578   TStripeFillStyle(const TPixel32 &bgColor, const TPixel32 &pointColor,
579                    const double Dist, const double Angle,
580                    const double Thickness);
581   TStripeFillStyle(const TPixel32 &color);
582 
583   TColorStyle *clone() const override;
584 
585   /*
586 TPixel32 getMainColor() const {return m_pointColor; }
587 void setMainColor(const TPixel32 &color){ m_pointColor=color; }
588 */
589 
getColorParamCount()590   int getColorParamCount() const override { return 2; }
591   TPixel32 getColorParamValue(int index) const override;
592   void setColorParamValue(int index, const TPixel32 &color) override;
593 
isRegionStyle()594   bool isRegionStyle() const override { return true; }
isStrokeStyle()595   bool isStrokeStyle() const override { return false; }
596 
597   int getParamCount() const override;
598   TColorStyle::ParamType getParamType(int index) const override;
599 
600   QString getParamNames(int index) const override;
601   void getParamRange(int index, double &min, double &max) const override;
602   double getParamValue(TColorStyle::double_tag, int index) const override;
603   void setParamValue(int index, double value) override;
604 
605   void drawRegion(const TColorFunction *cf, const bool antiAliasing,
606                   TRegionOutline &boundary) const override;
607 
getTagId()608   int getTagId() const override { return 1137; };
getDescription()609   QString getDescription() const override {
610     return QCoreApplication::translate("TStripeFillStyle", "Banded");
611   }
612 
613 protected:
614   void loadData(TInputStreamInterface &is) override;
615   void saveData(TOutputStreamInterface &os) const override;
616 
617   void makeIcon(const TDimension &d) override;
618 
619 private:
620   void getThickline(const TPointD &lc, const double ly, TPointD &p0,
621                     TPointD &p1, TPointD &p2, TPointD &p3) const;
622   int nbClip(const TRectD &bbox) const;
623 };
624 
625 //============================================================
626 
627 class DVAPI TLinGradFillStyle final : public TSolidColorStyle {
628   TPixel32 m_pointColor;
629   double m_Angle;
630   double m_XPos, m_YPos, m_Size;
631 
632 public:
633   TLinGradFillStyle(const TPixel32 &bgColor, const TPixel32 &pointColor,
634                     const double Angle, const double XPos, const double YPos,
635                     const double Size);
636   TLinGradFillStyle(const TPixel32 &color);
637 
638   TColorStyle *clone() const override;
639 
640   /*
641 TPixel32 getMainColor() const {return m_pointColor; }
642 void setMainColor(const TPixel32 &color){ m_pointColor=color; }
643 */
644 
getColorParamCount()645   int getColorParamCount() const override { return 2; }
646   TPixel32 getColorParamValue(int index) const override;
647   void setColorParamValue(int index, const TPixel32 &color) override;
648 
isRegionStyle()649   bool isRegionStyle() const override { return true; }
isStrokeStyle()650   bool isStrokeStyle() const override { return false; }
651 
652   int getParamCount() const override;
653   TColorStyle::ParamType getParamType(int index) const override;
654 
655   QString getParamNames(int index) const override;
656   void getParamRange(int index, double &min, double &max) const override;
657   double getParamValue(TColorStyle::double_tag, int index) const override;
658   void setParamValue(int index, double value) override;
659 
660   void drawRegion(const TColorFunction *cf, const bool antiAliasing,
661                   TRegionOutline &boundary) const override;
662 
getTagId()663   int getTagId() const override { return 1138; };
getDescription()664   QString getDescription() const override {
665     return QCoreApplication::translate("TLinGradFillStyle", "Linear Gradient");
666   }
667 
668 protected:
669   void loadData(TInputStreamInterface &is) override;
670   void saveData(TOutputStreamInterface &os) const override;
671 
672 private:
673   void getRects(const TRectD &bbox, std::vector<TPointD> &r0,
674                 std::vector<TPointD> &r1, std::vector<TPointD> &r2) const;
675 
676   void getRect(const TRectD &bbox, std::vector<TPointD> &r) const;
677 };
678 
679 //============================================================
680 
681 class DVAPI TRadGradFillStyle final : public TSolidColorStyle {
682   TPixel32 m_pointColor;
683   double m_Radius;
684   double m_XPos, m_YPos;
685   double m_Smooth;
686 
687 public:
688   TRadGradFillStyle(const TPixel32 &bgColor, const TPixel32 &pointColor,
689                     const double XPos, const double YPos, const double Radius,
690                     const double Smooth);
691   TRadGradFillStyle(const TPixel32 &color);
692 
693   TColorStyle *clone() const override;
694 
695   //  TPixel32 getMainColor() const {return m_pointColor; }
696   //  void setMainColor(const TPixel32 &color){ m_pointColor=color; }
697 
getColorParamCount()698   int getColorParamCount() const override { return 2; }
699   TPixel32 getColorParamValue(int index) const override;
700   void setColorParamValue(int index, const TPixel32 &color) override;
701 
isRegionStyle()702   bool isRegionStyle() const override { return true; }
isStrokeStyle()703   bool isStrokeStyle() const override { return false; }
704 
705   int getParamCount() const override;
706   TColorStyle::ParamType getParamType(int index) const override;
707 
708   QString getParamNames(int index) const override;
709   void getParamRange(int index, double &min, double &max) const override;
710   double getParamValue(TColorStyle::double_tag, int index) const override;
711   void setParamValue(int index, double value) override;
712 
713   void drawRegion(const TColorFunction *cf, const bool antiAliasing,
714                   TRegionOutline &boundary) const override;
715 
getTagId()716   int getTagId() const override { return 1139; };
getDescription()717   QString getDescription() const override {
718     return QCoreApplication::translate("TRadGradFillStyle", "Radial Gradient");
719   }
720 
721 protected:
722   void loadData(TInputStreamInterface &is) override;
723   void saveData(TOutputStreamInterface &os) const override;
724 };
725 
726 //============================================================
727 
728 class DVAPI TCircleStripeFillStyle final : public TSolidColorStyle {
729   TPixel32 m_pointColor;
730   double m_XPos, m_YPos;
731   double m_Dist, m_Thickness;
732 
733 public:
734   TCircleStripeFillStyle(const TPixel32 &bgColor, const TPixel32 &pointColor,
735                          const double XPos, const double YPos,
736                          const double Dist, const double Thickness);
737   TCircleStripeFillStyle(const TPixel32 &color);
738 
739   TColorStyle *clone() const override;
740 
741   /*
742 TPixel32 getMainColor() const {return m_pointColor; }
743 void setMainColor(const TPixel32 &color){ m_pointColor=color; }
744 */
745 
getColorParamCount()746   int getColorParamCount() const override { return 2; }
747   TPixel32 getColorParamValue(int index) const override;
748   void setColorParamValue(int index, const TPixel32 &color) override;
749 
isRegionStyle()750   bool isRegionStyle() const override { return true; }
isStrokeStyle()751   bool isStrokeStyle() const override { return false; }
752 
753   int getParamCount() const override;
754   TColorStyle::ParamType getParamType(int index) const override;
755 
756   QString getParamNames(int index) const override;
757   void getParamRange(int index, double &min, double &max) const override;
758   double getParamValue(TColorStyle::double_tag, int index) const override;
759   void setParamValue(int index, double value) override;
760 
761   void drawRegion(const TColorFunction *cf, const bool antiAliasing,
762                   TRegionOutline &boundary) const override;
763 
getTagId()764   int getTagId() const override { return 1140; };
getDescription()765   QString getDescription() const override {
766     return QCoreApplication::translate("TCircleStripeFillStyle", "Concentric");
767   }
768 
769 protected:
770   void loadData(TInputStreamInterface &is) override;
771   void saveData(TOutputStreamInterface &os) const override;
772 
773 private:
774   void getCircleStripeQuads(const TPointD &center, const double r1,
775                             const double r2, std::vector<TPointD> &pv) const;
776   void drawCircleStripe(const TPointD &center, const double r1, const double r2,
777                         const TPixel32 &col) const;
778 };
779 
780 //============================================================
781 
782 class DVAPI TMosaicFillStyle final : public TSolidColorStyle {
783   TPixel32 m_pointColor[4];
784   double m_size;
785   double m_deform;
786   double m_minThickness;
787   double m_maxThickness;
788 
789 public:
790   TMosaicFillStyle(const TPixel32 &bgColor, const TPixel32 pointColor[4],
791                    const double size, const double deform,
792                    const double minThickness, const double maxThickness);
793   TMosaicFillStyle(const TPixel32 bgColor);
794 
795   TColorStyle *clone() const override;
796 
797   /*
798 TPixel32 getMainColor() const {return m_pointColor[0]; }
799 void setMainColor(const TPixel32 &color){ m_pointColor[0]=color; }
800 */
801 
getColorParamCount()802   int getColorParamCount() const override { return 5; }
803   TPixel32 getColorParamValue(int index) const override;
804   void setColorParamValue(int index, const TPixel32 &color) override;
805 
isRegionStyle()806   bool isRegionStyle() const override { return true; }
isStrokeStyle()807   bool isStrokeStyle() const override { return false; }
808 
809   int getParamCount() const override;
810   TColorStyle::ParamType getParamType(int index) const override;
811 
812   QString getParamNames(int index) const override;
813   void getParamRange(int index, double &min, double &max) const override;
814   double getParamValue(TColorStyle::double_tag, int index) const override;
815   void setParamValue(int index, double value) override;
816 
817   void drawRegion(const TColorFunction *cf, const bool antiAliasing,
818                   TRegionOutline &boundary) const override;
819 
getTagId()820   int getTagId() const override { return 1141; };
getDescription()821   QString getDescription() const override {
822     return QCoreApplication::translate("TMosaicFillStyle", "Stained Glass");
823   }
824 
825 protected:
826   void loadData(TInputStreamInterface &is) override;
827   void saveData(TOutputStreamInterface &os) const override;
828 
829 private:
830   void preaprePos(const TRectD &box, std::vector<TPointD> &v, int &lX, int &lY,
831                   TRandom &rand) const;
832   bool getQuad(const int ix, const int iy, const int lX, const int lY,
833                std::vector<TPointD> &v, TPointD *pquad, TRandom &rand) const;
834 };
835 
836 //============================================================
837 
838 class DVAPI TPatchFillStyle final : public TSolidColorStyle {
839   TPixel32 m_pointColor[6];
840   double m_size;
841   double m_deform;
842   double m_thickness;
843 
844 public:
845   TPatchFillStyle(const TPixel32 &bgColor, const TPixel32 pointColor[6],
846                   const double size, const double deform,
847                   const double thickness);
848   TPatchFillStyle(const TPixel32 &bgColor);
849 
850   TColorStyle *clone() const override;
851 
getColorParamCount()852   int getColorParamCount() const override { return 7; }
853   TPixel32 getColorParamValue(int index) const override;
854   void setColorParamValue(int index, const TPixel32 &color) override;
855 
isRegionStyle()856   bool isRegionStyle() const override { return true; }
isStrokeStyle()857   bool isStrokeStyle() const override { return false; }
858 
859   int getParamCount() const override;
860   TColorStyle::ParamType getParamType(int index) const override;
861 
862   QString getParamNames(int index) const override;
863   void getParamRange(int index, double &min, double &max) const override;
864   double getParamValue(TColorStyle::double_tag, int index) const override;
865   void setParamValue(int index, double value) override;
866 
867   void drawRegion(const TColorFunction *cf, const bool antiAliasing,
868                   TRegionOutline &boundary) const override;
869 
getTagId()870   int getTagId() const override { return 1142; };
getDescription()871   QString getDescription() const override {
872     return QCoreApplication::translate("TPatchFillStyle", "Beehive");
873   }
874 
875 private:
876   void preaprePos(const TRectD &box, std::vector<TPointD> &v, int &lX, int &lY,
877                   TRandom &rand) const;
878   bool getQuadLine(const TPointD &a, const TPointD &b, const double thickn,
879                    TPointD *quad) const;
880   void drawGLQuad(const TPointD *quad) const;
881   int nbClip(const int lX, const int lY, const std::vector<TPointD> &v) const;
882 
883 protected:
884   void loadData(TInputStreamInterface &is) override;
885   void saveData(TOutputStreamInterface &os) const override;
886 };
887 
888 #endif  // TDERIVEDREGIONSTYLES_H
889