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 _SV_REGBAND_HXX 25 #define _SV_REGBAND_HXX 26 27 #include <vcl/sv.h> 28 #include <tools/poly.hxx> 29 30 /* ======================================================================= 31 32 class ImplRegionBand 33 34 This class handles one y-band of the region. In this band may contain one 35 or more seprarations in x-direction. The y-Band do not contain any 36 separation after creation. 37 38 The separations are modified with basic clipping functions like Union and 39 Intersection - the Class will process the clipping for the actual band. 40 41 The actual separations may be checked by functions like IsInside or 42 IsOver. 43 44 ======================================================================= */ 45 46 // ------------------------ 47 // - ImplRegionBand-Types - 48 // ------------------------ 49 50 // element for the list with x-separations 51 struct ImplRegionBandSep 52 { 53 ImplRegionBandSep* mpNextSep; 54 long mnXLeft; 55 long mnXRight; 56 bool mbRemoved; 57 }; 58 59 enum LineType { LINE_ASCENDING, LINE_DESCENDING, LINE_HORIZONTAL }; 60 61 // element for the list with x-separations 62 struct ImplRegionBandPoint 63 { 64 ImplRegionBandPoint* mpNextBandPoint; 65 long mnX; 66 long mnLineId; 67 bool mbEndPoint; 68 LineType meLineType; 69 }; 70 71 // ------------------ 72 // - ImplRegionBand - 73 // ------------------ 74 75 class ImplRegionBand 76 { 77 public: 78 ImplRegionBand* mpNextBand; // pointer to the next element of the list 79 ImplRegionBand* mpPrevBand; // pointer to the previous element of the list (only used temporaery) 80 ImplRegionBandSep* mpFirstSep; // root of the list with x-separations 81 ImplRegionBandPoint* mpFirstBandPoint; // root of the list with lines 82 long mnYTop; // actual boundary of the band 83 long mnYBottom; 84 85 // bitfield 86 bool mbTouched : 1; 87 88 // create y-band with boundaries 89 ImplRegionBand( long nYTop, long nYBottom ); 90 /** copy y-band with with all data 91 @param theSourceBand 92 The new ImplRegionBand object will 93 be a copy of this band. 94 @param bIgnorePoints 95 When <TRUE/> (the default) the 96 band points pointed to by 97 mpFirstBandPoint are not copied. 98 When <FALSE/> they are copied. 99 You need the points when you are 100 planning to call ProcessPoints() 101 later on. 102 */ 103 ImplRegionBand( const ImplRegionBand & theSourceBand, 104 const bool bIgnorePoints = true); 105 ~ImplRegionBand(); 106 107 long GetXLeftBoundary() const; 108 long GetXRightBoundary() const; 109 110 // combine overlapping bands 111 bool OptimizeBand(); 112 113 // generate separations from lines and process 114 // union with existing separations 115 void ProcessPoints(); 116 // insert point in the list for later processing 117 bool InsertPoint( long nX, long nLineID, 118 bool bEndPoint, LineType eLineType ); 119 120 void Union( long nXLeft, long nXRight ); 121 void Intersect( long nXLeft, long nXRight ); 122 void Exclude( long nXLeft, long nXRight ); 123 void XOr( long nXLeft, long nXRight ); 124 125 void MoveX( long nHorzMove ); 126 void ScaleX( double fHorzScale ); 127 128 bool IsInside( long nX ); 129 bool IsInside( long nLeft, long nRight ); 130 bool IsOver( long nLeft, long nRight ); 131 IsEmpty() const132 bool IsEmpty() const { return ((!mpFirstSep) && (!mpFirstBandPoint)); } 133 134 bool operator==( const ImplRegionBand& rRegionBand ) const; 135 136 /** Split the called band at the given vertical coordinate. After the 137 split the called band will cover the upper part not including nY. 138 The new band will cover the lower part including nY. 139 @param nY 140 The band is split at this y coordinate. The new, lower band 141 will include this very value. 142 @return 143 Returns the new, lower band. 144 */ 145 ImplRegionBand* SplitBand (const sal_Int32 nY); 146 }; 147 148 #endif // _SV_REGBAND_HXX 149