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

#include <ossimAnnotationLineObject.h>

Inheritance diagram for ossimAnnotationLineObject:
ossimAnnotationObject ossimObject ossimReferenced

Public Member Functions

 ossimAnnotationLineObject ()
 
 ossimAnnotationLineObject (const ossimIpt &start, const ossimIpt &end, unsigned char r=255, unsigned char g=255, unsigned char b=255, long thickness=1)
 
 ossimAnnotationLineObject (long x1, long y1, long x2, long y2, unsigned char r=255, unsigned char g=255, unsigned char b=255, long thickness=1)
 
 ossimAnnotationLineObject (const ossimAnnotationLineObject &rhs)
 
virtual ossimObjectdup () const
 
virtual void applyScale (double x, double y)
 
virtual ossimAnnotationObjectgetNewClippedObject (const ossimDrect &rect) const
 
virtual bool intersects (const ossimDrect &rect) const
 
virtual void draw (ossimRgbImage &anImage) const
 
virtual std::ostream & print (std::ostream &out) const
 Generic print method. More...
 
virtual void getBoundingRect (ossimDrect &rect) const
 
virtual bool isPointWithin (const ossimDpt &imagePoint) const
 
virtual void computeBoundingRect ()
 
void setLine (const ossimDpt &start, const ossimDpt &end)
 
void getLine (ossimDpt &start, ossimDpt &end)
 
- 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 Attributes

ossimIpt theStart
 
ossimIpt theEnd
 
ossimDrect theBoundingRect
 
- 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 ()
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 
- Static Protected Attributes inherited from ossimAnnotationObject
static ossim_uint32 theIdCounter = 0
 

Detailed Description

Definition at line 15 of file ossimAnnotationLineObject.h.

Constructor & Destructor Documentation

◆ ossimAnnotationLineObject() [1/4]

ossimAnnotationLineObject::ossimAnnotationLineObject ( )

Referenced by dup().

◆ ossimAnnotationLineObject() [2/4]

ossimAnnotationLineObject::ossimAnnotationLineObject ( const ossimIpt start,
const ossimIpt end,
unsigned char  r = 255,
unsigned char  g = 255,
unsigned char  b = 255,
long  thickness = 1 
)

Definition at line 28 of file ossimAnnotationLineObject.cpp.

References computeBoundingRect().

34  :ossimAnnotationObject(r, g, b, thickness),
35  theStart(start),
36  theEnd(end)
37 {
39 }
ossimAnnotationObject(ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255, ossim_uint8 thickness=1)

◆ ossimAnnotationLineObject() [3/4]

ossimAnnotationLineObject::ossimAnnotationLineObject ( long  x1,
long  y1,
long  x2,
long  y2,
unsigned char  r = 255,
unsigned char  g = 255,
unsigned char  b = 255,
long  thickness = 1 
)

Definition at line 41 of file ossimAnnotationLineObject.cpp.

References computeBoundingRect().

49  :ossimAnnotationObject(r, g, b, thickness),
50  theStart(x1, y1),
51  theEnd(x2, y2)
52 {
54 }
ossimAnnotationObject(ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255, ossim_uint8 thickness=1)

◆ ossimAnnotationLineObject() [4/4]

ossimAnnotationLineObject::ossimAnnotationLineObject ( const ossimAnnotationLineObject rhs)

Definition at line 56 of file ossimAnnotationLineObject.cpp.

58  theStart(rhs.theStart),
59  theEnd(rhs.theEnd),
61 {
62 }
ossimAnnotationObject(ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255, ossim_uint8 thickness=1)

Member Function Documentation

◆ applyScale()

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

Implements ossimAnnotationObject.

Definition at line 69 of file ossimAnnotationLineObject.cpp.

References computeBoundingRect(), theEnd, theStart, ossimIpt::x, x, ossimIpt::y, and y.

Referenced by ossimGeoAnnotationLineObject::applyScale().

70 {
71  theStart.x = ossim::round<int>(theStart.x*x);
72  theStart.y = ossim::round<int>(theStart.y*y);
73  theEnd.x = ossim::round<int>(theEnd.x*x);
74  theEnd.y = ossim::round<int>(theEnd.y*y);
76 }
ossim_uint32 x
ossim_uint32 y
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141

◆ computeBoundingRect()

void ossimAnnotationLineObject::computeBoundingRect ( )
virtual

Implements ossimAnnotationObject.

Definition at line 150 of file ossimAnnotationLineObject.cpp.

References theBoundingRect, theEnd, and theStart.

Referenced by applyScale(), ossimGeoAnnotationLineObject::computeBoundingRect(), ossimAnnotationLineObject(), and setLine().

151 {
152  vector<ossimDpt> pts(2);
153 
154  pts[0] = theStart;
155  pts[1] = theEnd;
156 
158 }

◆ draw()

void ossimAnnotationLineObject::draw ( ossimRgbImage anImage) const
virtual

Implements ossimAnnotationObject.

Definition at line 101 of file ossimAnnotationLineObject.cpp.

References ossimRgbImage::drawLine(), ossimRgbImage::getImageData(), ossimImageData::getImageRectangle(), ossimDrect::lr(), ossimRgbImage::setDrawColor(), ossimRgbImage::setThickness(), ossimAnnotationObject::theBlue, theEnd, ossimAnnotationObject::theGreen, ossimAnnotationObject::theRed, theStart, ossimAnnotationObject::theThickness, ossimDrect::ul(), ossimRefPtr< T >::valid(), ossimDpt::x, and ossimDpt::y.

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

102 {
103  if(anImage.getImageData().valid())
104  {
105  anImage.setDrawColor(theRed, theGreen, theBlue);
106  anImage.setThickness(theThickness);
107  ossimDrect imageRect = anImage.getImageData()->getImageRectangle();
108  ossimDpt start = theStart;
109  ossimDpt end = theEnd;
110 
111  if(anImage.getImageData().valid())
112  {
113  // we need to extend it by a couple of pixels since
114  // if a pixel lies on the edge and then another pixel is just off
115  // the edge we will get a stair step and so for several pixels
116  // the line might be inside the image rectangle but the clip
117  // algorithm will only draw 1 pixel since it thinks the first
118  // point is inside and the second point is outside and will
119  // execute the clip algorithm keeping only the first
120  // point.
121  ossimDrect clipRect(imageRect.ul().x - 10,
122  imageRect.ul().y - 10,
123  imageRect.lr().x + 10,
124  imageRect.lr().y + 10);
125  // now we can draw.
126  if(clipRect.clip(start, end))
127  {
128  anImage.drawLine(ossimIpt((int)start.x,
129  (int)start.y),
130  ossimIpt((int)end.x,
131  (int)end.y));
132  }
133  }
134  }
135 }
bool valid() const
Definition: ossimRefPtr.h:75
const ossimDpt & ul() const
Definition: ossimDrect.h:339
double y
Definition: ossimDpt.h:165
void setThickness(ossim_int32 thickness)
All the drawing algorithms have thickness.
ossimRefPtr< ossimImageData > getImageData()
Will return the image data.
virtual ossimIrect getImageRectangle() const
void drawLine(double x1, double y1, double x2, double y2)
About all the draw routines will call draw line.
void setDrawColor(ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255)
double x
Definition: ossimDpt.h:164
const ossimDpt & lr() const
Definition: ossimDrect.h:341

◆ dup()

ossimObject * ossimAnnotationLineObject::dup ( ) const
virtual

Reimplemented from ossimObject.

Definition at line 64 of file ossimAnnotationLineObject.cpp.

References ossimAnnotationLineObject().

Referenced by getNewClippedObject().

65 {
66  return new ossimAnnotationLineObject(*this);
67 }

◆ getBoundingRect()

void ossimAnnotationLineObject::getBoundingRect ( ossimDrect rect) const
virtual

Implements ossimAnnotationObject.

Definition at line 145 of file ossimAnnotationLineObject.cpp.

References theBoundingRect.

Referenced by ossimGeoAnnotationLineObject::getBoundingRect().

146 {
147  rect = theBoundingRect;
148 }

◆ getLine()

void ossimAnnotationLineObject::getLine ( ossimDpt start,
ossimDpt end 
)

Definition at line 167 of file ossimAnnotationLineObject.cpp.

References theEnd, and theStart.

168 {
169  start = theStart;
170  end = theEnd;
171 }

◆ getNewClippedObject()

ossimAnnotationObject * ossimAnnotationLineObject::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 78 of file ossimAnnotationLineObject.cpp.

References ossimDrect::clip(), dup(), setLine(), theEnd, and theStart.

Referenced by ossimGeoAnnotationLineObject::getNewClippedObject().

79 {
81  ossimDpt start = theStart;
82  ossimDpt end = theEnd;
83 
84  if(rect.clip(start, end))
85  {
86  result = (ossimAnnotationLineObject*)dup();
87  result->setLine(start, end);
88  }
89 
90  return result;
91 }
void setLine(const ossimDpt &start, const ossimDpt &end)
bool clip(ossimDpt &p1, ossimDpt &p2) const
Definition: ossimDrect.cpp:653
virtual ossimObject * dup() const

◆ intersects()

bool ossimAnnotationLineObject::intersects ( const ossimDrect rect) const
virtual

Implements ossimAnnotationObject.

Definition at line 93 of file ossimAnnotationLineObject.cpp.

References ossimDrect::clip(), theEnd, and theStart.

Referenced by ossimGeoAnnotationLineObject::intersects().

94 {
95  ossimDpt start = theStart;
96  ossimDpt end = theEnd;
97 
98  return rect.clip(start, end);
99 }
bool clip(ossimDpt &p1, ossimDpt &p2) const
Definition: ossimDrect.cpp:653

◆ isPointWithin()

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

This method allows you to pick an object. It will return true or false if the point falls somewhere on an object. Look at derived classes for further information.

Reimplemented from ossimAnnotationObject.

Definition at line 173 of file ossimAnnotationLineObject.cpp.

References ossimDrect::pointWithin(), and theBoundingRect.

174 {
175  if(theBoundingRect.pointWithin(point))
176  {
177  // we will use the implicit form of a line to determine if the point is
178  // on the line. For now we will just return true if it is within the
179  // bounding rect.
180  return true;
181  }
182 
183  return false;
184 }
bool pointWithin(const ossimDpt &pt, double epsilon=0.0) const
Definition: ossimDrect.h:781

◆ print()

std::ostream & ossimAnnotationLineObject::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 137 of file ossimAnnotationLineObject.cpp.

References theBoundingRect, theEnd, and theStart.

138 {
139  out << "line_start: " << theStart << endl
140  << "line_end: " << theEnd << endl
141  << "bounding_rect: " << theBoundingRect << endl;
142  return out;
143 }

◆ setLine()

void ossimAnnotationLineObject::setLine ( const ossimDpt start,
const ossimDpt end 
)

Member Data Documentation

◆ theBoundingRect

ossimDrect ossimAnnotationLineObject::theBoundingRect
protected

◆ theEnd

ossimIpt ossimAnnotationLineObject::theEnd
protected

◆ theStart

ossimIpt ossimAnnotationLineObject::theStart
protected

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