OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ossimAnnotationGdBitmapFont Class Reference

#include <ossimAnnotationGdBitmapFont.h>

Inheritance diagram for ossimAnnotationGdBitmapFont:
ossimAnnotationObject ossimObject ossimReferenced

Public Member Functions

 ossimAnnotationGdBitmapFont (const ossimDpt &position=ossimDpt(0, 0), const ossimString &text=ossimString(""), ossimGdFontPtr font=ossimGdFontLarge, unsigned char r=255, unsigned char g=255, unsigned char b=255, long thickness=1)
 
 ossimAnnotationGdBitmapFont (const ossimAnnotationGdBitmapFont &rhs)
 
virtual ossimObjectdup () const
 
virtual void applyScale (double x, double y)
 
virtual void draw (ossimRgbImage &anImage) const
 
virtual bool intersects (const ossimDrect &rect) const
 
virtual ossimAnnotationObjectgetNewClippedObject (const ossimDrect &rect) const
 
virtual std::ostream & print (std::ostream &out) const
 Generic print method. More...
 
virtual void getBoundingRect (ossimDrect &rect) const
 
virtual void computeBoundingRect ()
 
virtual void setFont (ossimGdFontPtr font)
 
virtual void setText (const ossimString &text)
 
virtual void setCenterText (const ossimDpt &center, const ossimString &text)
 
virtual void setUpperLeftText (const ossimDpt &upperLeft, const ossimString &text)
 
virtual void setCenterTextPosition (const ossimDpt &position)
 
virtual void setUpperLeftTextPosition (const ossimDpt &position)
 
virtual bool isPointWithin (const ossimDpt &imagePoint) const
 
- Public Member Functions inherited from ossimAnnotationObject
virtual ~ossimAnnotationObject ()
 
 ossimAnnotationObject (ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255, ossim_uint8 thickness=1)
 
virtual void applyScale (const ossimDpt &scale)
 
virtual ossimDrect getBoundingRect () const
 
virtual void setColor (ossim_uint8 r, ossim_uint8 g, ossim_uint8 b)
 
void getColor (ossim_uint8 &r, ossim_uint8 &g, ossim_uint8 &b) const
 
ossim_uint8 getThickness () const
 
virtual void setThickness (ossim_uint8 thickness)
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 Saves the current state of this object. More...
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 Method to the load (recreate) the state of an object from a keyword list. More...
 
virtual ossimString getName () const
 
virtual void setName (const ossimString &name)
 
ossim_uint32 getId () const
 
virtual ossim_uint32 setId ()
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getDescription () const
 
virtual ossimString getClassName () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
virtual void accept (ossimVisitor &visitor)
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 

Protected Member Functions

virtual ~ossimAnnotationGdBitmapFont ()
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Protected Attributes

ossimGdFontPtr theFontPtr
 
ossimString theText
 
ossimDrect theBoundingRect
 
ossimDpt thePosition
 
- Protected Attributes inherited from ossimAnnotationObject
ossim_uint8 theRed
 
ossim_uint8 theGreen
 
ossim_uint8 theBlue
 
ossim_uint8 theThickness
 
ossimString theName
 
ossim_uint32 theId
 

Additional Inherited Members

- Static Public Member Functions inherited from ossimAnnotationObject
static ossim_uint32 getNextId ()
 
static void restIdCounter ()
 
- Static Protected Attributes inherited from ossimAnnotationObject
static ossim_uint32 theIdCounter = 0
 

Detailed Description

This is a class that will have hardcoded bitmap fonts. These fonts will be from the gd library.

Definition at line 22 of file ossimAnnotationGdBitmapFont.h.

Constructor & Destructor Documentation

◆ ossimAnnotationGdBitmapFont() [1/2]

ossimAnnotationGdBitmapFont::ossimAnnotationGdBitmapFont ( const ossimDpt position = ossimDpt(0,0),
const ossimString text = ossimString(""),
ossimGdFontPtr  font = ossimGdFontLarge,
unsigned char  r = 255,
unsigned char  g = 255,
unsigned char  b = 255,
long  thickness = 1 
)

Definition at line 20 of file ossimAnnotationGdBitmapFont.cpp.

References computeBoundingRect().

27  :ossimAnnotationObject(r, g, b, thickness),
28  theFontPtr(font),
29  theText(text),
30  thePosition(position)
31 {
33 }
ossimAnnotationObject(ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255, ossim_uint8 thickness=1)

◆ ossimAnnotationGdBitmapFont() [2/2]

ossimAnnotationGdBitmapFont::ossimAnnotationGdBitmapFont ( const ossimAnnotationGdBitmapFont rhs)

Definition at line 35 of file ossimAnnotationGdBitmapFont.cpp.

36  : ossimAnnotationObject(rhs),
38  theText(rhs.theText),
41 {
42 }
ossimAnnotationObject(ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255, ossim_uint8 thickness=1)

◆ ~ossimAnnotationGdBitmapFont()

ossimAnnotationGdBitmapFont::~ossimAnnotationGdBitmapFont ( )
protectedvirtual

Definition at line 44 of file ossimAnnotationGdBitmapFont.cpp.

45 {
46 }

Member Function Documentation

◆ applyScale()

void ossimAnnotationGdBitmapFont::applyScale ( double  x,
double  y 
)
virtual

Implements ossimAnnotationObject.

Definition at line 53 of file ossimAnnotationGdBitmapFont.cpp.

References theBoundingRect, thePosition, ossimDpt::x, x, ossimDpt::y, and y.

Referenced by ossimGeoAnnotationGdBitmapFont::applyScale().

54 {
55  thePosition.x *= x;
56  thePosition.y *= y;
57 
59 }
ossim_uint32 x
ossim_uint32 y
double y
Definition: ossimDpt.h:165
double x
Definition: ossimDpt.h:164

◆ computeBoundingRect()

void ossimAnnotationGdBitmapFont::computeBoundingRect ( )
virtual

◆ draw()

void ossimAnnotationGdBitmapFont::draw ( ossimRgbImage anImage) const
virtual

Will draw the bitmap to the screen.

Implements ossimAnnotationObject.

Definition at line 61 of file ossimAnnotationGdBitmapFont.cpp.

References ossimGdFont::data, ossimRgbImage::getImageData(), ossimImageData::getImageRectangle(), ossimImageData::getOrigin(), ossimGdFont::h, ossimDrect::intersects(), ossimRgbImage::setDrawColor(), ossimString::size(), ossimRgbImage::slowPlotPixel(), ossimAnnotationObject::theBlue, theBoundingRect, theFontPtr, ossimAnnotationObject::theGreen, thePosition, ossimAnnotationObject::theRed, theText, ossimGdFont::w, ossimDpt::x, and ossimDpt::y.

Referenced by ossimGeographicAnnotationGrid::draw(), and ossimGeoAnnotationGdBitmapFont::draw().

62 {
63  if(!theFontPtr||
64  !anImage.getImageData())
65  {
66  return;
67  }
68  ossimDpt origin = anImage.getImageData()->getOrigin();
69 
70  ossimDrect rect = anImage.getImageData()->getImageRectangle();
71 
72  if(theBoundingRect.intersects(rect))
73  {
75  ossimDpt position(thePosition.x - origin.x,
76  thePosition.y - origin.y);
77  for(std::string::size_type character = 0;
78  character < theText.size();
79  ++character)
80  {
81  long charOffset = theText[character];
82 
83  // we need to shift the offset to a positive value.
84  // if it goes negative we just add 256 to the value.
85  if(charOffset < 0)
86  {
87  charOffset += 256;
88  }
89  // get the starting offset to the bitmap
90  long offset = charOffset*theFontPtr->w*theFontPtr->h;
91  for(long row = 0; row < theFontPtr->h; ++row)
92  {
93  for(long col = 0; col < theFontPtr->w; ++col)
94  {
95  if(theFontPtr->data[(int)offset])
96  {
97  anImage.slowPlotPixel(ossim::round<int>(position.x + col),
98  ossim::round<int>(position.y + row),
99  theRed,
100  theGreen,
101  theBlue);
102  }
103  ++offset;
104  }
105  }
106  position.x += theFontPtr->w;
107  }
108  }
109 }
double y
Definition: ossimDpt.h:165
ossimRefPtr< ossimImageData > getImageData()
Will return the image data.
void slowPlotPixel(ossim_int32 x, ossim_int32 y, ossim_uint8 r, ossim_uint8 g, ossim_uint8 b)
This will plot a pixel and will do inside outside compares.
std::string::size_type size() const
Definition: ossimString.h:405
virtual ossimIrect getImageRectangle() const
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
virtual const ossimIpt & getOrigin() const

◆ dup()

virtual ossimObject* ossimAnnotationGdBitmapFont::dup ( ) const
inlinevirtual

Reimplemented from ossimObject.

Definition at line 34 of file ossimAnnotationGdBitmapFont.h.

Referenced by getNewClippedObject().

35  {
36  return new ossimAnnotationGdBitmapFont(*this);
37  }
ossimAnnotationGdBitmapFont(const ossimDpt &position=ossimDpt(0, 0), const ossimString &text=ossimString(""), ossimGdFontPtr font=ossimGdFontLarge, unsigned char r=255, unsigned char g=255, unsigned char b=255, long thickness=1)

◆ getBoundingRect()

void ossimAnnotationGdBitmapFont::getBoundingRect ( ossimDrect rect) const
virtual

◆ getNewClippedObject()

ossimAnnotationObject * ossimAnnotationGdBitmapFont::getNewClippedObject ( const ossimDrect rect) const
virtual

Will allocate a new object that is clipped to the passed. in rect. Look at derived classes to see if the object is actually clipped or not. A new object is returned if it clips to the rect else NULL should be returned it doesn't clip.

Implements ossimAnnotationObject.

Definition at line 111 of file ossimAnnotationGdBitmapFont.cpp.

References dup(), and intersects().

Referenced by ossimGeoAnnotationGdBitmapFont::getNewClippedObject().

112 {
114 
115  if(intersects(rect))
116  {
117  result = (ossimAnnotationGdBitmapFont*)dup();
118  }
119 
120  return result;
121 }
virtual bool intersects(const ossimDrect &rect) const
virtual ossimObject * dup() const

◆ intersects()

virtual bool ossimAnnotationGdBitmapFont::intersects ( const ossimDrect rect) const
inlinevirtual

Implements ossimAnnotationObject.

Definition at line 45 of file ossimAnnotationGdBitmapFont.h.

References ossimDrect::intersects().

Referenced by getNewClippedObject(), and ossimGeoAnnotationGdBitmapFont::intersects().

46  {
47  return rect.intersects(theBoundingRect);
48  }
bool intersects(const ossimDrect &rect) const
Definition: ossimDrect.cpp:289

◆ isPointWithin()

bool ossimAnnotationGdBitmapFont::isPointWithin ( const ossimDpt imagePoint) const
virtual

Will determine if the point is within the font

Reimplemented from ossimAnnotationObject.

Definition at line 180 of file ossimAnnotationGdBitmapFont.cpp.

References ossimDrect::pointWithin(), and theBoundingRect.

181 {
182  return theBoundingRect.pointWithin(imagePoint);
183 }
bool pointWithin(const ossimDpt &pt, double epsilon=0.0) const
Definition: ossimDrect.h:781

◆ print()

std::ostream & ossimAnnotationGdBitmapFont::print ( std::ostream &  out) const
virtual

Generic print method.

Derived classes should re-implement as they see fit.

Returns
std::ostream&

Reimplemented from ossimAnnotationObject.

Definition at line 123 of file ossimAnnotationGdBitmapFont.cpp.

References theBoundingRect, thePosition, and theText.

Referenced by ossimGeoAnnotationGdBitmapFont::print().

124 {
125  out << "text_value: " << theText << endl
126  << "text_bouding_rect: " << theBoundingRect << endl
127  << "text_position: " << thePosition << endl;
128  return out;
129 }

◆ setCenterText()

void ossimAnnotationGdBitmapFont::setCenterText ( const ossimDpt center,
const ossimString text 
)
virtual

Set's the text string to render. This will assume that the x,y passed in is suppose to be the center. We will compute the upper left corner from this

Definition at line 166 of file ossimAnnotationGdBitmapFont.cpp.

References setCenterTextPosition(), and setText().

Referenced by ossimGeographicAnnotationGrid::computeBoundingRect(), and ossimGeographicAnnotationGrid::draw().

168 {
169  setText(text);
170  setCenterTextPosition(upperLeft);
171 }
virtual void setCenterTextPosition(const ossimDpt &position)
virtual void setText(const ossimString &text)

◆ setCenterTextPosition()

void ossimAnnotationGdBitmapFont::setCenterTextPosition ( const ossimDpt position)
virtual

Sets the center position of the string. will use this value to compute the actual origin of upper left corner of the first character. Make sure you have the text set before you call this method

Definition at line 173 of file ossimAnnotationGdBitmapFont.cpp.

References computeBoundingRect(), ossimDrect::height(), theBoundingRect, thePosition, ossimDrect::width(), ossimDpt::x, and ossimDpt::y.

Referenced by ossimGeographicAnnotationGrid::draw(), and setCenterText().

174 {
175  thePosition.x = position.x - theBoundingRect.width()/2.0;
176  thePosition.y = position.y - theBoundingRect.height()/2.0;
178 }
ossim_float64 width() const
Definition: ossimDrect.h:522
double y
Definition: ossimDpt.h:165
ossim_float64 height() const
Definition: ossimDrect.h:517
double x
Definition: ossimDpt.h:164

◆ setFont()

void ossimAnnotationGdBitmapFont::setFont ( ossimGdFontPtr  font)
virtual

Sets the current bitmap font to use.

Definition at line 142 of file ossimAnnotationGdBitmapFont.cpp.

References theFontPtr.

Referenced by ossimGeoAnnotationGdBitmapFont::setFont().

143 {
144  theFontPtr = font;
145 }

◆ setText()

void ossimAnnotationGdBitmapFont::setText ( const ossimString text)
virtual

◆ setUpperLeftText()

void ossimAnnotationGdBitmapFont::setUpperLeftText ( const ossimDpt upperLeft,
const ossimString text 
)
virtual

Set's the text string to render. This will assume that the x,y passed in is suppose to be the upper left.

Definition at line 153 of file ossimAnnotationGdBitmapFont.cpp.

References setText(), and setUpperLeftTextPosition().

155 {
156  setText(text);
157  setUpperLeftTextPosition(upperLeft);
158 }
virtual void setUpperLeftTextPosition(const ossimDpt &position)
virtual void setText(const ossimString &text)

◆ setUpperLeftTextPosition()

void ossimAnnotationGdBitmapFont::setUpperLeftTextPosition ( const ossimDpt position)
virtual

The actual upper left corner of the character.

Definition at line 160 of file ossimAnnotationGdBitmapFont.cpp.

References computeBoundingRect(), and thePosition.

Referenced by setUpperLeftText(), and ossimGeoAnnotationGdBitmapFont::transform().

Member Data Documentation

◆ theBoundingRect

ossimDrect ossimAnnotationGdBitmapFont::theBoundingRect
protected

◆ theFontPtr

ossimGdFontPtr ossimAnnotationGdBitmapFont::theFontPtr
protected

Definition at line 112 of file ossimAnnotationGdBitmapFont.h.

Referenced by computeBoundingRect(), draw(), and setFont().

◆ thePosition

ossimDpt ossimAnnotationGdBitmapFont::thePosition
protected

This position is suppose to be the upperleft corner of the first character in the string

Definition at line 120 of file ossimAnnotationGdBitmapFont.h.

Referenced by applyScale(), computeBoundingRect(), draw(), print(), setCenterTextPosition(), and setUpperLeftTextPosition().

◆ theText

ossimString ossimAnnotationGdBitmapFont::theText
protected

Definition at line 113 of file ossimAnnotationGdBitmapFont.h.

Referenced by computeBoundingRect(), draw(), print(), and setText().


The documentation for this class was generated from the following files: