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 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_CROPPRIMITIVE2D_HXX
23 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_CROPPRIMITIVE2D_HXX
24 
25 #include <drawinglayer/drawinglayerdllapi.h>
26 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
27 #include <basegfx/matrix/b2dhommatrix.hxx>
28 
29 //////////////////////////////////////////////////////////////////////////////
30 
31 namespace drawinglayer
32 {
33     namespace primitive2d
34     {
35         /** CropPrimitive2D class
36 
37             Caution: Due to old constraints (old core definitions) the
38             crop distances describe how the uncropped content is defined
39             relative to the current object size. This means that maTransformation
40             describes the rurrent object size (the part of the object visible
41             with the crop applied). To get the original size and orientation
42             of the uncropped content it is necessary to calc back from the
43             current situation (maTransformation) using the crop values
44             to get to the uncropped original content.
45 
46             Thus a transformation has to be calculated which will be applied
47             to the already exsisting content to get it to the uncropped state
48             ans then this is masked with the current state (mask polygon
49             created from unit polygon and maTransformation).
50 
51             At least in this primitive the units of the crop values are
52             already in the local coordinate system; inthe core these distances
53             are defined relative to the object content size (PrefMapMode
54             and PrefSize of the content)...
55 
56             Of course this is a primitive, so feel free to just ignore all that
57             stuff and use the automatically generated decomposition. Sigh.
58         */
59         class DRAWINGLAYER_DLLPUBLIC CropPrimitive2D : public GroupPrimitive2D
60         {
61         private:
62             // the transformation already applied to the child geometry
63             basegfx::B2DHomMatrix           maTransformation;
64 
65             // the crop offsets relative to the range of the unrotated content
66             double                          mfCropLeft;
67             double                          mfCropTop;
68             double                          mfCropRight;
69             double                          mfCropBottom;
70 
71         public:
72             /// constructor
73             CropPrimitive2D(
74                 const Primitive2DSequence& rChildren,
75                 const basegfx::B2DHomMatrix& rTransformation,
76                 double fCropLeft,
77                 double fCropTop,
78                 double fCropRight,
79                 double fCropBottom);
80 
81             /// data read access
getTransformation() const82             const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; }
getCropLeft() const83             double getCropLeft() const { return mfCropLeft; }
getCropTop() const84             double getCropTop() const { return mfCropTop; }
getCropRight() const85             double getCropRight() const { return mfCropRight; }
getCropBottom() const86             double getCropBottom() const { return mfCropBottom; }
87 
88             /// compare operator
89             virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
90 
91             /// local decomposition
92             virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
93 
94             /// provide unique ID
95             DeclPrimitrive2DIDBlock()
96         };
97     } // end of namespace primitive2d
98 } // end of namespace drawinglayer
99 
100 //////////////////////////////////////////////////////////////////////////////
101 
102 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_CROPPRIMITIVE2D_HXX
103 
104 //////////////////////////////////////////////////////////////////////////////
105 // eof
106