Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _SV_REGBAND_HXX
21 : #define _SV_REGBAND_HXX
22 :
23 : #include <tools/solar.h>
24 : #include <tools/poly.hxx>
25 :
26 : /* =======================================================================
27 :
28 : class ImplRegionBand
29 :
30 : This class handles one y-band of the region. In this band may contain one
31 : or more seprarations in x-direction. The y-Band do not contain any
32 : separation after creation.
33 :
34 : The separations are modified with basic clipping functions like Union and
35 : Intersection - the Class will process the clipping for the actual band.
36 :
37 : The actual separations may be checked by functions like IsInside or
38 : IsOver.
39 :
40 : ======================================================================= */
41 :
42 : // ------------------------
43 : // - ImplRegionBand-Types -
44 : // ------------------------
45 :
46 : // element for the list with x-separations
47 : struct ImplRegionBandSep
48 : {
49 : ImplRegionBandSep* mpNextSep;
50 : long mnXLeft;
51 : long mnXRight;
52 : bool mbRemoved;
53 : };
54 :
55 : enum LineType { LINE_ASCENDING, LINE_DESCENDING, LINE_HORIZONTAL };
56 :
57 : // element for the list with x-separations
58 : struct ImplRegionBandPoint
59 : {
60 : ImplRegionBandPoint* mpNextBandPoint;
61 : long mnX;
62 : long mnLineId;
63 : bool mbEndPoint;
64 : LineType meLineType;
65 : };
66 :
67 : // ------------------
68 : // - ImplRegionBand -
69 : // ------------------
70 :
71 : class ImplRegionBand
72 : {
73 : public:
74 : ImplRegionBand* mpNextBand; // pointer to the next element of the list
75 : ImplRegionBand* mpPrevBand; // pointer to the previous element of the list (only used temporaery)
76 : ImplRegionBandSep* mpFirstSep; // root of the list with x-separations
77 : ImplRegionBandPoint* mpFirstBandPoint; // root of the list with lines
78 : long mnYTop; // actual boundary of the band
79 : long mnYBottom;
80 :
81 : // bitfield
82 : bool mbTouched : 1;
83 :
84 : // create y-band with boundaries
85 : ImplRegionBand( long nYTop, long nYBottom );
86 : /** copy y-band with with all data
87 : @param theSourceBand
88 : The new ImplRegionBand object will
89 : be a copy of this band.
90 : @param bIgnorePoints
91 : When <TRUE/> (the default) the
92 : band points pointed to by
93 : mpFirstBandPoint are not copied.
94 : When <FALSE/> they are copied.
95 : You need the points when you are
96 : planning to call ProcessPoints()
97 : later on.
98 : */
99 : ImplRegionBand( const ImplRegionBand & theSourceBand,
100 : const bool bIgnorePoints = true);
101 : ~ImplRegionBand();
102 :
103 : long GetXLeftBoundary() const;
104 : long GetXRightBoundary() const;
105 :
106 : // combine overlapping bands
107 : bool OptimizeBand();
108 :
109 : // generate separations from lines and process
110 : // union with existing separations
111 : void ProcessPoints();
112 : // insert point in the list for later processing
113 : bool InsertPoint( long nX, long nLineID,
114 : bool bEndPoint, LineType eLineType );
115 :
116 : void Union( long nXLeft, long nXRight );
117 : void Intersect( long nXLeft, long nXRight );
118 : void Exclude( long nXLeft, long nXRight );
119 : void XOr( long nXLeft, long nXRight );
120 :
121 : void MoveX( long nHorzMove );
122 : void ScaleX( double fHorzScale );
123 :
124 : bool IsInside( long nX );
125 : bool IsInside( long nLeft, long nRight );
126 : bool IsOver( long nLeft, long nRight );
127 :
128 :
129 2087854 : bool IsEmpty() const { return ((!mpFirstSep) && (!mpFirstBandPoint)); }
130 :
131 : bool operator==( const ImplRegionBand& rRegionBand ) const;
132 :
133 : /** Split the called band at the given vertical coordinate. After the
134 : split the called band will cover the upper part not including nY.
135 : The new band will cover the lower part including nY.
136 : @param nY
137 : The band is split at this y coordinate. The new, lower band
138 : will include this very value.
139 : @return
140 : Returns the new, lower band.
141 : */
142 : ImplRegionBand* SplitBand (const sal_Int32 nY);
143 : };
144 :
145 : #endif // _SV_REGBAND_HXX
146 :
147 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|