xref: /AOO41X/main/drawinglayer/inc/drawinglayer/texture/texture.hxx (revision 035a2f44eca4e31ced924464e6584eacbf3e9114)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_DRAWINGLAYER_TEXTURE_TEXTURE_HXX
25 #define INCLUDED_DRAWINGLAYER_TEXTURE_TEXTURE_HXX
26 
27 #include <drawinglayer/drawinglayerdllapi.h>
28 #include <basegfx/matrix/b2dhommatrix.hxx>
29 #include <basegfx/range/b2drange.hxx>
30 #include <basegfx/color/bcolor.hxx>
31 #include <basegfx/tools/gradienttools.hxx>
32 #include <vector>
33 
34 //////////////////////////////////////////////////////////////////////////////
35 namespace drawinglayer
36 {
37     namespace texture
38     {
39         class DRAWINGLAYER_DLLPUBLIC GeoTexSvx
40         {
41         public:
42             GeoTexSvx();
43             virtual ~GeoTexSvx();
44 
45             // compare operator
46             virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const;
operator !=(const GeoTexSvx & rGeoTexSvx) const47             bool operator!=(const GeoTexSvx& rGeoTexSvx) const { return !operator==(rGeoTexSvx); }
48 
49             // virtual base methods
50             virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const;
51             virtual void modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const;
52         };
53     } // end of namespace texture
54 } // end of namespace drawinglayer
55 
56 //////////////////////////////////////////////////////////////////////////////
57 
58 namespace drawinglayer
59 {
60     namespace texture
61     {
62         /// helper class for processing equal number of matrices and colors
63         /// for texture processing
64         struct B2DHomMatrixAndBColor
65         {
66             basegfx::B2DHomMatrix   maB2DHomMatrix;
67             basegfx::BColor         maBColor;
68         };
69     } // end of namespace texture
70 } // end of namespace drawinglayer
71 
72 //////////////////////////////////////////////////////////////////////////////
73 
74 namespace drawinglayer
75 {
76     namespace texture
77     {
78         class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradient : public GeoTexSvx
79         {
80         protected:
81             basegfx::ODFGradientInfo            maGradientInfo;
82             basegfx::B2DRange                   maTargetRange;
83             basegfx::BColor                     maStart;
84             basegfx::BColor                     maEnd;
85             double                              mfBorder;
86 
87         public:
88             GeoTexSvxGradient(
89                 const basegfx::B2DRange& rTargetRange,
90                 const basegfx::BColor& rStart,
91                 const basegfx::BColor& rEnd,
92                 sal_uInt32 nSteps,
93                 double fBorder);
94             virtual ~GeoTexSvxGradient();
95 
96             // compare operator
97             virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const;
98 
99             // virtual base methods
100             virtual void appendTransformationsAndColors(
101                 std::vector< B2DHomMatrixAndBColor >& rEntries,
102                 basegfx::BColor& rOutmostColor) = 0;
103 
104             // data access
getStart() const105             const basegfx::BColor& getStart() const { return maStart; }
getEnd() const106             const basegfx::BColor& getEnd() const { return maEnd; }
107         };
108     } // end of namespace texture
109 } // end of namespace drawinglayer
110 
111 //////////////////////////////////////////////////////////////////////////////
112 
113 namespace drawinglayer
114 {
115     namespace texture
116     {
117         class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientLinear : public GeoTexSvxGradient
118         {
119         public:
120             GeoTexSvxGradientLinear(
121                 const basegfx::B2DRange& rTargetRange,
122                 const basegfx::BColor& rStart,
123                 const basegfx::BColor& rEnd,
124                 sal_uInt32 nSteps,
125                 double fBorder,
126                 double fAngle);
127             virtual ~GeoTexSvxGradientLinear();
128 
129             virtual void appendTransformationsAndColors(
130                 std::vector< B2DHomMatrixAndBColor >& rEntries,
131                 basegfx::BColor& rOutmostColor);
132             virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const;
133         };
134     } // end of namespace texture
135 } // end of namespace drawinglayer
136 
137 //////////////////////////////////////////////////////////////////////////////
138 
139 namespace drawinglayer
140 {
141     namespace texture
142     {
143         class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientAxial : public GeoTexSvxGradient
144         {
145         public:
146             GeoTexSvxGradientAxial(
147                 const basegfx::B2DRange& rTargetRange,
148                 const basegfx::BColor& rStart,
149                 const basegfx::BColor& rEnd,
150                 sal_uInt32 nSteps,
151                 double fBorder,
152                 double fAngle);
153             virtual ~GeoTexSvxGradientAxial();
154 
155             virtual void appendTransformationsAndColors(
156                 std::vector< B2DHomMatrixAndBColor >& rEntries,
157                 basegfx::BColor& rOutmostColor);
158             virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const;
159         };
160     } // end of namespace texture
161 } // end of namespace drawinglayer
162 
163 //////////////////////////////////////////////////////////////////////////////
164 
165 namespace drawinglayer
166 {
167     namespace texture
168     {
169         class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientRadial : public GeoTexSvxGradient
170         {
171         public:
172             GeoTexSvxGradientRadial(
173                 const basegfx::B2DRange& rTargetRange,
174                 const basegfx::BColor& rStart,
175                 const basegfx::BColor& rEnd,
176                 sal_uInt32 nSteps,
177                 double fBorder,
178                 double fOffsetX,
179                 double fOffsetY);
180             virtual ~GeoTexSvxGradientRadial();
181 
182             virtual void appendTransformationsAndColors(
183                 std::vector< B2DHomMatrixAndBColor >& rEntries,
184                 basegfx::BColor& rOutmostColor);
185             virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const;
186         };
187     } // end of namespace texture
188 } // end of namespace drawinglayer
189 
190 //////////////////////////////////////////////////////////////////////////////
191 
192 namespace drawinglayer
193 {
194     namespace texture
195     {
196         class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientElliptical : public GeoTexSvxGradient
197         {
198         public:
199             GeoTexSvxGradientElliptical(
200                 const basegfx::B2DRange& rTargetRange,
201                 const basegfx::BColor& rStart,
202                 const basegfx::BColor& rEnd,
203                 sal_uInt32 nSteps,
204                 double fBorder,
205                 double fOffsetX,
206                 double fOffsetY,
207                 double fAngle);
208             virtual ~GeoTexSvxGradientElliptical();
209 
210             virtual void appendTransformationsAndColors(
211                 std::vector< B2DHomMatrixAndBColor >& rEntries,
212                 basegfx::BColor& rOutmostColor);
213             virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const;
214         };
215     } // end of namespace texture
216 } // end of namespace drawinglayer
217 
218 //////////////////////////////////////////////////////////////////////////////
219 
220 namespace drawinglayer
221 {
222     namespace texture
223     {
224         class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientSquare : public GeoTexSvxGradient
225         {
226         public:
227             GeoTexSvxGradientSquare(
228                 const basegfx::B2DRange& rTargetRange,
229                 const basegfx::BColor& rStart,
230                 const basegfx::BColor& rEnd,
231                 sal_uInt32 nSteps,
232                 double fBorder,
233                 double fOffsetX,
234                 double fOffsetY,
235                 double fAngle);
236             virtual ~GeoTexSvxGradientSquare();
237 
238             virtual void appendTransformationsAndColors(
239                 std::vector< B2DHomMatrixAndBColor >& rEntries,
240                 basegfx::BColor& rOutmostColor);
241             virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const;
242         };
243     } // end of namespace texture
244 } // end of namespace drawinglayer
245 
246 //////////////////////////////////////////////////////////////////////////////
247 
248 namespace drawinglayer
249 {
250     namespace texture
251     {
252         class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientRect : public GeoTexSvxGradient
253         {
254         public:
255             GeoTexSvxGradientRect(
256                 const basegfx::B2DRange& rTargetRange,
257                 const basegfx::BColor& rStart,
258                 const basegfx::BColor& rEnd,
259                 sal_uInt32 nSteps,
260                 double fBorder,
261                 double fOffsetX,
262                 double fOffsetY,
263                 double fAngle);
264             virtual ~GeoTexSvxGradientRect();
265 
266             virtual void appendTransformationsAndColors(
267                 std::vector< B2DHomMatrixAndBColor >& rEntries,
268                 basegfx::BColor& rOutmostColor);
269             virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const;
270         };
271     } // end of namespace texture
272 } // end of namespace drawinglayer
273 
274 //////////////////////////////////////////////////////////////////////////////
275 
276 namespace drawinglayer
277 {
278     namespace texture
279     {
280         class DRAWINGLAYER_DLLPUBLIC GeoTexSvxHatch : public GeoTexSvx
281         {
282         protected:
283             basegfx::B2DHomMatrix               maTextureTransform;
284             basegfx::B2DHomMatrix               maBackTextureTransform;
285             double                              mfDistance;
286             double                              mfAngle;
287             sal_uInt32                          mnSteps;
288 
289         public:
290             GeoTexSvxHatch(
291                 const basegfx::B2DRange& rTargetRange,
292                 double fDistance,
293                 double fAngle);
294             virtual ~GeoTexSvxHatch();
295 
296             // compare operator
297             virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const;
298 
299             virtual void appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices);
300             double getDistanceToHatch(const basegfx::B2DPoint& rUV) const;
301             const basegfx::B2DHomMatrix& getBackTextureTransform() const;
302         };
303     } // end of namespace texture
304 } // end of namespace drawinglayer
305 
306 //////////////////////////////////////////////////////////////////////////////
307 
308 namespace drawinglayer
309 {
310     namespace texture
311     {
312         // This class applies a tiling to the unit range. The given range
313         // will be repeated inside the unit range in X and Y and for each
314         // tile a matrix will be created (by appendTransformations) that
315         // represents the needed transformation to map a filling in unit
316         // coordinates to that tile.
317         // When offsetX is given, every 2nd line will be ofsetted by the
318         // given percentage value (offsetX has to be 0.0 <= offsetX <= 1.0).
319         // Accordingly to offsetY. If both are given, offsetX is preferred
320         // and offsetY is ignored.
321         class DRAWINGLAYER_DLLPUBLIC GeoTexSvxTiled : public GeoTexSvx
322         {
323         protected:
324             basegfx::B2DRange               maRange;
325             double                          mfOffsetX;
326             double                          mfOffsetY;
327 
328         public:
329             GeoTexSvxTiled(
330                 const basegfx::B2DRange& rRange,
331                 double fOffsetX = 0.0,
332                 double fOffsetY = 0.0);
333             virtual ~GeoTexSvxTiled();
334 
335             // compare operator
336             virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const;
337 
338             virtual void appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices);
339         };
340     } // end of namespace texture
341 } // end of namespace drawinglayer
342 
343 //////////////////////////////////////////////////////////////////////////////
344 
345 #endif //_DRAWINGLAYER_TEXTURE_TEXTURE_HXX
346 
347 // eof
348