OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimGeoAnnotationFontObject.cpp
Go to the documentation of this file.
1 //*************************************************************************
2 // License: See top level LICENSE.txt file.
3 //
4 // Author: Garrett Potts
5 //
6 //*************************************************************************
7 //$Id: ossimGeoAnnotationFontObject.cpp 17108 2010-04-15 21:08:06Z dburken $
8 
9 #include <sstream>
10 
15 #include <ossim/font/ossimFont.h>
19 
21  "ossimGeoAnnotationFontObject",
23 
24 
26  :
28  theCenterGround(),
29  theFont(0),
30  theFontInfo(),
31  theAnnotationFontObject(0)
32 {
34  getDefaultFont()->dup();
35  if (!theFont)
36  {
38  << "ossimGeoAnnotationFontObject::ossimGeoAnnotationFontObject"
39  << " WARNING: No font support..."
40  << endl;
41  }
44  ossimString(""));
45 
47 
48 }
49 
51  const ossimGpt& location,
52  const ossimString& s,
53  const ossimIpt& pixelSize,
54  double rotation,
55  const ossimDpt& scale,
56  const ossimDpt& shear,
57  ossim_uint8 r,
58  ossim_uint8 g,
59  ossim_uint8 b)
60  :
61  ossimGeoAnnotationObject(r, g, b),
62  theCenterGround(location),
63  theFont(0),
64  theFontInfo(),
65  theAnnotationFontObject(0)
66 {
67  ossimDpt pt;
68  pt.makeNan();
69 
71  s,
72  pixelSize,
73  rotation,
74  scale,
75  shear,
76  r,
77  g,
78  b);
79 }
80 
83  :
85  theCenterGround(rhs.theCenterGround),
86  theFont(rhs.theFont.valid()?(ossimFont*)rhs.theFont->dup():(ossimFont*)0),
87  theFontInfo(),
88  theAnnotationFontObject(
90  ossimDpt(ossim::nan(), ossim::nan()),
91  rhs.theAnnotationFontObject->theString,
92  rhs.theAnnotationFontObject->thePixelSize,
93  rhs.theAnnotationFontObject->theRotation,
94  ossimDpt(rhs.theAnnotationFontObject->theHorizontalScale,
95  rhs.theAnnotationFontObject->theVerticalScale),
96  ossimDpt(rhs.theAnnotationFontObject->theHorizontalShear,
97  rhs.theAnnotationFontObject->theVerticalShear),
98  rhs.theRed,
99  rhs.theGreen,
100  rhs.theBlue))
101 {
103 }
104 
106 {
108  theFont = 0;
109 }
110 
112 {
113  return new ossimGeoAnnotationFontObject(*this);
114 }
115 
116 
118 {
119  theFont = font;
120 
122 }
123 
125 {
126  return theFont.get();
127 }
128 
130 {
132  {
134  }
135 }
136 
138 {
140  {
142  }
143 }
144 
146 {
148  {
150  }
151 }
152 
154 {
156  {
158  }
159 }
160 
162  ossim_uint8 g,
163  ossim_uint8 b)
164 {
166  {
168  }
169 }
170 
172 {
173  if(projection)
174  {
175  ossimDpt ipt;
176 
177  projection->worldToLocal(theCenterGround, ipt);
180  }
181 }
182 
184 {
185  theCenterGround = gpt;
186 }
187 
189 {
190  return theAnnotationFontObject.get();
191 }
192 
194 {
195  theAnnotationFontObject->draw(anImage);
196 }
197 
199 {
201 }
202 
204 {
206 }
207 
209  const ossimDrect& /* rect */)const
210 {
211  return (ossimAnnotationObject*)0;
212 }
213 
215 {
216  return theAnnotationFontObject->intersects(rect);
217 }
218 
220 {
222 }
223 
225  const char* prefix) const
226 {
227  kwl.add(prefix, "center", theCenterGround.toString().c_str());
228  kwl.add(prefix, "text", theAnnotationFontObject->getString().c_str());
229  theFontInfo.saveState(kwl, prefix);
230 
231  return ossimGeoAnnotationObject::saveState(kwl, prefix);
232 }
233 
235  const char* prefix)
236 {
237  //---
238  // Base class state must be called first to pick up colors...
239  //---
240  bool status = ossimGeoAnnotationObject::loadState(kwl, prefix);
241 
244 
245  const char* lookup;
246 
247  lookup = kwl.find(prefix, "text");
248  if (lookup)
249  {
251  }
252 
253  lookup = kwl.find(prefix, "center");
254  if (lookup)
255  {
256  std::istringstream is(lookup);
257  is >> theCenterGround;
258  }
259 
260  // Get the font information.
261  theFontInfo.loadState(kwl, prefix);
262 
263  // See if we can make a font.
265  createFont(theFontInfo);
266  if (f.valid())
267  {
268  theFont = f;
270  }
271 
273 
274  return status;
275 }
ossim_uint32 x
virtual void setShear(const ossimDpt &shear)
virtual bool intersects(const ossimDrect &rect) const
virtual void setThickness(ossim_uint8 thickness)
Represents serializable keyword/value map.
virtual ossimAnnotationObject * getNewClippedObject(const ossimDrect &rect) const
ossim_uint32 y
bool valid() const
Definition: ossimRefPtr.h:75
virtual void setFont(ossimFont *font)
const char * find(const char *key) const
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
This code was derived from https://gist.github.com/mshockwave.
Definition: Barrier.h:8
virtual void setColor(ossim_uint8 r, ossim_uint8 g, ossim_uint8 b)
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.
virtual ossimString getString() const
virtual void setPointSize(const ossimIpt &size)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Saves the current state of this object.
virtual void applyScale(double x, double y)
virtual void setRotation(double rotation)
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
virtual void draw(ossimRgbImage &anImage) const
virtual ossimDrect getBoundingRect() const
yy_size_t size
virtual void setScale(const ossimDpt &scale)
bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
ossimAnnotationFontObject * getFontObject()
virtual void setString(const ossimString &s)
virtual void setCenterGround(const ossimGpt &gpt)
virtual void setPointSize(const ossimIpt &size)
virtual void setRotation(double rotation)
virtual void setColor(ossim_uint8 r, ossim_uint8 g, ossim_uint8 b)
Class to draw fonts onto an image.
RTTI_DEF1(ossimGeoAnnotationFontObject, "ossimGeoAnnotationFontObject", ossimGeoAnnotationObject)
virtual void setGeometryInformation(const ossimFontInformation &info)
virtual void applyScale(double x, double y)
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
return status
bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Saves the current state of this object.
static ossimFontFactoryRegistry * instance()
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
bool worldToLocal(const ossimGpt &world_pt, ossimDpt &local_pt) const
Exposes the 3D world-to-local image coordinate reverse projection.
ossimString toString(ossim_uint32 precision=15) const
Definition: ossimGpt.cpp:78
std::basic_istringstream< char > istringstream
Class for char input memory streams.
Definition: ossimIosFwd.h:32
virtual void draw(ossimRgbImage &anImage) const
virtual void setScale(const ossimDpt &scale)
virtual void getBoundingRect(ossimDrect &rect) const
unsigned char ossim_uint8
virtual void transform(ossimImageGeometry *projection)
virtual void setShear(const ossimDpt &shear)
virtual bool intersects(const ossimDrect &rect) const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
void makeNan()
Definition: ossimDpt.h:65
virtual void setCenterPosition(const ossimIpt &position)
ossimRefPtr< ossimAnnotationFontObject > theAnnotationFontObject