OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimAnnotationEllipseObject.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See LICENSE.txt file in the top level directory.
4 //
5 // Author: Garrett Potts
6 //
7 //*************************************************************************
8 // $Id: ossimAnnotationEllipseObject.cpp 13964 2009-01-14 16:30:07Z gpotts $
11 #include <ossim/base/ossimCommon.h>
12 
14  "ossimAnnotationEllipseObject",
16 
18  const ossimDpt& center,
19  const ossimDpt& widthHeight,
20  ossim_float64 azimuthInDegrees,
21  bool enableFill,
22  ossim_uint8 r,
23  ossim_uint8 g,
24  ossim_uint8 b,
25  ossim_uint8 thickness)
26  : ossimAnnotationObject(r, g, b, thickness),
27  theCenter(center),
28  theWidthHeight(widthHeight),
29  theAzimuthInDegrees(azimuthInDegrees),
30  theFillEnabled(enableFill),
31  theDrawAxesFlag(false),
32  theBoundingRect(0,0,0,0)
33 {
34  computeBoundingRect();
35 }
36 
40  theCenter(rhs.theCenter),
41  theWidthHeight(rhs.theWidthHeight),
42  theAzimuthInDegrees(rhs.theAzimuthInDegrees),
43  theFillEnabled(rhs.theFillEnabled),
44  theDrawAxesFlag(rhs.theDrawAxesFlag),
45  theBoundingRect(rhs.theBoundingRect)
46 {
47 }
48 
50 {
51  return new ossimAnnotationEllipseObject(*this);
52 }
53 
55 {
56 }
57 
59 {
60  theCenter.x *= x;
61  theCenter.y *= y;
62  theWidthHeight.x *= x;
63  theWidthHeight.y *= y;
65 }
66 
67 
68 
70 {
72  anImage.setThickness(theThickness);
73 
75  {
76  if(theFillEnabled)
77  {
78  anImage.drawFilledEllipse((int)(theCenter.x),
79  (int)(theCenter.y),
80  (int)(theWidthHeight.x),
81  (int)(theWidthHeight.y),
83  }
84  else
85  {
86  anImage.drawEllipse((int)(theCenter.x),
87  (int)(theCenter.y),
88  (int)(theWidthHeight.x),
89  (int)(theWidthHeight.y),
92  }
93  }
94 }
95 
97 {
98  return rect.intersects(theBoundingRect);
99 }
100 
102  const ossimDrect& rect)const
103 {
104  if(intersects(rect))
105  {
106  return (ossimAnnotationObject*)dup();
107  }
108 
109  return (ossimAnnotationEllipseObject*)NULL;
110 }
111 
113 {
115  out << endl;
116  out << "ellipse_center: " << theCenter
117  << "\nellipse_height: " << theWidthHeight.y
118  << "\nellipse_width: " << theWidthHeight.x
119  << "\nfill_enabled: " << theFillEnabled
120  << "\ndraw_axes: " << theDrawAxesFlag
121  << "\nellipse_bounding_rect: " << theBoundingRect;
122  return out;
123 }
124 
126 {
127  rect = theBoundingRect;
128 }
129 
131 {
132  ossim_float64 maxDimension =
134  theBoundingRect = ossimDrect(theCenter.x - maxDimension,
135  theCenter.y - maxDimension,
136  theCenter.x + maxDimension,
137  theCenter.y + maxDimension);
138 }
139 
141 {
142  return theBoundingRect.pointWithin(point);
143 }
144 
146  const ossimDpt& widthHeight)
147 {
148  theCenter = center;
149  theWidthHeight = widthHeight;
150 
152 }
153 
155 {
156  theAzimuthInDegrees = azimuth;
157 }
158 
160 {
161  return theAzimuthInDegrees;
162 }
163 
165 {
166  theFillEnabled = enabled;
167 }
168 
170 {
171  return theFillEnabled;
172 }
173 
175 {
176  theDrawAxesFlag = flag;
177 }
178 
180 {
181  return theDrawAxesFlag;
182 }
183 
185  const char* prefix)const
186 {
187  return ossimAnnotationObject::saveState(kwl, prefix);
188 }
189 
191  const char* prefix)
192 {
193  return ossimAnnotationObject::loadState(kwl, prefix);
194 }
virtual void setDrawAxesFlag(bool flag)
Turns on and off drawing of axes on the ellipse.
ossim_uint32 x
bool pointWithin(const ossimDpt &pt, double epsilon=0.0) const
Definition: ossimDrect.h:781
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Saves the current state of this object.
T max(T a, T b)
Definition: ossimCommon.h:236
Represents serializable keyword/value map.
ossim_uint32 y
virtual std::ostream & print(std::ostream &out) const
Generic print method.
double y
Definition: ossimDpt.h:165
void setThickness(ossim_int32 thickness)
All the drawing algorithms have thickness.
virtual std::ostream & print(std::ostream &out) const
Generic print method.
void drawEllipse(int cx, int cy, int sminor, int smajor, double rot, bool drawAxes=false)
Draws an ellipse.
virtual void applyScale(double x, double y)
double ossim_float64
virtual ossimDrect getBoundingRect() const
ossimRefPtr< ossimImageData > getImageData()
Will return the image data.
virtual bool isPointWithin(const ossimDpt &imagePoint) const
virtual ossimIrect getImageRectangle() const
virtual void draw(ossimRgbImage &anImage) const
virtual void setCenterWidthHeight(const ossimDpt &center, const ossimDpt &widthHeight)
bool intersects(const ossimDrect &rect) const
Definition: ossimDrect.cpp:289
virtual ossimAnnotationObject * getNewClippedObject(const ossimDrect &rect) const
void setDrawColor(ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255)
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
ossimAnnotationEllipseObject(const ossimDpt &center=ossimDpt(0, 0), const ossimDpt &widthHeight=ossimDpt(1, 1), ossim_float64 azimuthInDegrees=0.0, bool enableFill=false, ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255, ossim_uint8 thickness=1)
virtual void setAzimuth(ossim_float64 azimuth)
Sets the azimuth.
double x
Definition: ossimDpt.h:164
void drawFilledEllipse(int cx, int cy, int sminor, int smajor, double rot)
Draws a filled ellipse.
virtual bool intersects(const ossimDrect &rect) const
RTTI_DEF1(ossimAnnotationEllipseObject, "ossimAnnotationEllipseObject", ossimAnnotationObject) ossimAnnotationEllipseObject
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Saves the current state of this object.
#define RAD_PER_DEG
unsigned char ossim_uint8
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
virtual ossim_float64 getAzimuth() const
Gets the azimuth.