OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimAnnotationMultiEllipseObject.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // Author: Garrett Potts
6 //
7 //*************************************************************************
8 // $Id: ossimAnnotationMultiEllipseObject.cpp 17195 2010-04-23 17:32:18Z dburken $
9 
11 
13  (const std::vector<ossimDpt>& pointList,
14  const ossimDpt& widthHeight,
15  bool enableFill,
16  unsigned char r,
17  unsigned char g,
18  unsigned char b,
19  long thickness)
20  :
21  ossimAnnotationObject(r, g, b, thickness),
22  thePointList(pointList),
23  theWidthHeight(widthHeight),
24  theFillFlag(enableFill)
25 {
26  computeBoundingRect();
27 }
28 
30  (const ossimDpt& widthHeight,
31  bool enableFill,
32  unsigned char r,
33  unsigned char g,
34  unsigned char b,
35  long thickness)
36  :
37  ossimAnnotationObject(r, g, b, thickness),
38  theWidthHeight(widthHeight),
39  theFillFlag(enableFill)
40 {
41  theBoundingRect.makeNan();
42 }
43 
45  :thePointList(rhs.thePointList),
46  theWidthHeight(rhs.theWidthHeight),
47  theFillFlag(rhs.theFillFlag),
48  theBoundingRect(rhs.theBoundingRect)
49 {
50 }
51 
53 {
54  return new ossimAnnotationMultiEllipseObject(*this);
55 }
56 
58 {}
59 
61  const ossimDrect& /* rect */)const
62 {
64  << "ossimAnnotationMultiEllipseObject::getNewClippedObject WARNING: Not implemented"
65  << std::endl;
66  return NULL;
67 }
68 
70 {
71  int i;
72  int upper = (int)thePointList.size();
73  for(i = 0; i < upper; ++i)
74  {
75  thePointList[i].x *= x;
76  thePointList[i].y *= y;
77  }
78  theWidthHeight.x *= x;
79  theWidthHeight.y *= y;
80 
82 }
83 
85 {
87  anImage.setThickness(theThickness);
88  ossimDrect imageRect = anImage.getImageData()->getImageRectangle();
89 
90  if(theBoundingRect.intersects(imageRect))
91  {
92  int i;
93  int upper = (int)thePointList.size();
94  if(theFillFlag)
95  {
96  for(i = 0; i < upper; ++i)
97  {
98  ossimDpt tempPoint = thePointList[i];
99 
100  ossimDrect tempRect(ossimDpt(tempPoint.x - theWidthHeight.x,
101  tempPoint.y - theWidthHeight.y),
102  ossimDpt(tempPoint.x + theWidthHeight.x,
103  tempPoint.y + theWidthHeight.y));
104  if(tempRect.intersects(imageRect))
105  {
106  anImage.drawFilledArc(ossim::round<int>(tempPoint.x),
107  ossim::round<int>(tempPoint.y),
108  ossim::round<int>(theWidthHeight.x),
109  ossim::round<int>(theWidthHeight.y),
110  0,
111  360);
112  }
113  }
114  }
115  else
116  {
117  for(i = 0; i < upper; ++i)
118  {
119  ossimDpt tempPoint = thePointList[i];
120 
121  ossimDrect tempRect(ossimDpt(tempPoint.x - theWidthHeight.x,
122  tempPoint.y - theWidthHeight.y),
123  ossimDpt(tempPoint.x + theWidthHeight.x,
124  tempPoint.y + theWidthHeight.y));
125  if(tempRect.intersects(imageRect))
126  {
127  anImage.drawArc(ossim::round<int>(tempPoint.x),
128  ossim::round<int>(tempPoint.y),
129  ossim::round<int>(theWidthHeight.x),
130  ossim::round<int>(theWidthHeight.y),
131  0,
132  360);
133  }
134  }
135  }
136  }
137 }
138 
140 {
141  return rect.intersects(theBoundingRect);
142 }
143 
145 {
147  << "ossimAnnotionMultiEllipseObject::print NOT IMPLEMENTED"
148  << endl;
149  return out;
150 }
151 
153 {
154  rect = theBoundingRect;
155 }
156 
158 {
160 
161  int i;
162  int upper = (int)thePointList.size();
163  for(i = 0; i < upper; ++i)
164  {
165  ossimDpt tempPoint = thePointList[i];
166  if(!tempPoint.hasNans())
167  {
168  ossimDrect tempRect(ossimDpt(tempPoint.x - theWidthHeight.x,
169  tempPoint.y - theWidthHeight.y),
170  ossimDpt(tempPoint.x + theWidthHeight.x,
171  tempPoint.y + theWidthHeight.y));
172  if(!theBoundingRect.hasNans())
173  {
174  theBoundingRect.combine(tempRect);
175  }
176  else
177  {
178  theBoundingRect = tempRect;
179  }
180  }
181  }
182 }
183 
185 {
186  if(!theBoundingRect.hasNans())
187  {
188  return theBoundingRect.pointWithin(imagePoint);
189  }
190  return false;
191 }
192 
194 {
195  theFillFlag = flag;
196 }
197 
199 {
200  if(size)
201  {
202  thePointList.resize(size);
203  }
204  else
205  {
206  thePointList.clear();
207  }
208 }
209 
211 {
212  theWidthHeight = widthHeight;
214 }
215 
217 {
218  return thePointList[i];
219 }
220 
222 {
223  return thePointList[i];
224 }
void makeNan()
Definition: ossimDrect.h:388
ossim_uint32 x
bool pointWithin(const ossimDpt &pt, double epsilon=0.0) const
Definition: ossimDrect.h:781
ossimAnnotationMultiEllipseObject(const std::vector< ossimDpt > &pointList, const ossimDpt &widthHeight=ossimDpt(1, 1), bool enableFill=false, unsigned char r=255, unsigned char g=255, unsigned char b=255, long thickness=1)
ossim_uint32 y
double y
Definition: ossimDpt.h:165
virtual ossimAnnotationObject * getNewClippedObject(const ossimDrect &rect) const
ossimDrect combine(const ossimDrect &rect) const
Definition: ossimDrect.h:826
void setThickness(ossim_int32 thickness)
All the drawing algorithms have thickness.
virtual bool intersects(const ossimDrect &rect) const
virtual ossimDrect getBoundingRect() const
yy_size_t size
ossimRefPtr< ossimImageData > getImageData()
Will return the image data.
virtual bool isPointWithin(const ossimDpt &imagePoint) const
unsigned int ossim_uint32
void drawArc(double cx, double cy, double w, double h, double s, double e)
will draw an arc.
virtual ossimIrect getImageRectangle() const
virtual void setWidthHeight(const ossimDpt &widthHeight)
bool hasNans() const
Definition: ossimDrect.h:396
bool hasNans() const
Definition: ossimDpt.h:67
bool intersects(const ossimDrect &rect) const
Definition: ossimDrect.cpp:289
void setDrawColor(ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255)
double x
Definition: ossimDpt.h:164
void drawFilledArc(double cx, double cy, double w, double h, double s, double e)
This will draw a filled arc.
virtual std::ostream & print(std::ostream &out) const
Generic print method.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
virtual void draw(ossimRgbImage &anImage) const