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

#include <ossimAnnotationMultiLineObject.h>

Inheritance diagram for ossimAnnotationMultiLineObject:
ossimAnnotationObject ossimObject ossimReferenced

Public Member Functions

 ossimAnnotationMultiLineObject ()
 
 ossimAnnotationMultiLineObject (const std::vector< ossimPolyLine > &lineList, unsigned char r=255, unsigned char g=255, unsigned char b=255, long thickness=1)
 
 ossimAnnotationMultiLineObject (const ossimPolyLine &lineList, unsigned char r=255, unsigned char g=255, unsigned char b=255, long thickness=1)
 
 ossimAnnotationMultiLineObject (const ossimAnnotationMultiLineObject &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 ()
 
virtual const vector< ossimPolyLine > & getPolyLineList () const
 
virtual vector< ossimPolyLine > & getPolyLineList ()
 
virtual void setPolyLine (const ossimPolyLine &line)
 
- 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

vector< ossimPolyLinethePolyLineList
 
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 ossimAnnotationMultiLineObject.h.

Constructor & Destructor Documentation

◆ ossimAnnotationMultiLineObject() [1/4]

ossimAnnotationMultiLineObject::ossimAnnotationMultiLineObject ( )

Referenced by getNewClippedObject().

◆ ossimAnnotationMultiLineObject() [2/4]

ossimAnnotationMultiLineObject::ossimAnnotationMultiLineObject ( const std::vector< ossimPolyLine > &  lineList,
unsigned char  r = 255,
unsigned char  g = 255,
unsigned char  b = 255,
long  thickness = 1 
)
inline

Definition at line 19 of file ossimAnnotationMultiLineObject.h.

References ossimAnnotationObject::computeBoundingRect().

24  :ossimAnnotationObject(r, g, b, thickness),
25  thePolyLineList(lineList)
26  {
28  }
ossimAnnotationObject(ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255, ossim_uint8 thickness=1)

◆ ossimAnnotationMultiLineObject() [3/4]

ossimAnnotationMultiLineObject::ossimAnnotationMultiLineObject ( const ossimPolyLine lineList,
unsigned char  r = 255,
unsigned char  g = 255,
unsigned char  b = 255,
long  thickness = 1 
)
inline

Definition at line 30 of file ossimAnnotationMultiLineObject.h.

References ossimAnnotationObject::computeBoundingRect().

35  :ossimAnnotationObject(r, g, b, thickness)
36  {
37  thePolyLineList.push_back(lineList);
39  }
ossimAnnotationObject(ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255, ossim_uint8 thickness=1)

◆ ossimAnnotationMultiLineObject() [4/4]

ossimAnnotationMultiLineObject::ossimAnnotationMultiLineObject ( const ossimAnnotationMultiLineObject rhs)
inline

Definition at line 42 of file ossimAnnotationMultiLineObject.h.

46  {
47  }
ossimAnnotationObject(ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255, ossim_uint8 thickness=1)

Member Function Documentation

◆ applyScale()

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

Implements ossimAnnotationObject.

Definition at line 87 of file ossimAnnotationMultiLineObject.cpp.

References theBoundingRect, thePolyLineList, x, and y.

Referenced by ossimGeoAnnotationPolyLineObject::applyScale().

89 {
90  for(ossim_uint32 i=0; i < thePolyLineList.size(); ++i)
91  {
92  vector<ossimDpt>& vList = thePolyLineList[i].getVertexList();
93 
94  for(ossim_uint32 i2 = 0; i2 < vList.size(); ++i2)
95  {
96  vList[i].x *= x;
97  vList[i].y *= y;
98  vList[i].x *= x;
99  vList[i].y *= y;
100  }
101  }
103 }
ossim_uint32 x
ossim_uint32 y
unsigned int ossim_uint32

◆ computeBoundingRect()

void ossimAnnotationMultiLineObject::computeBoundingRect ( )
virtual

Implements ossimAnnotationObject.

Definition at line 156 of file ossimAnnotationMultiLineObject.cpp.

References ossimDrect::combine(), ossimDrect::hasNans(), ossimDrect::makeNan(), theBoundingRect, and thePolyLineList.

Referenced by ossimGeoAnnotationPolyLineObject::computeBoundingRect(), and ossimGeoAnnotationPolyLineObject::transform().

157 {
159 
160  if(thePolyLineList.size() == 1)
161  {
162  theBoundingRect = thePolyLineList[0].getBoundingRect();
163  }
164  else if(thePolyLineList.size() > 1)
165  {
166  for(ossim_uint32 i = 0; i < thePolyLineList.size(); ++i)
167  {
168  ossimDrect rect = thePolyLineList[i].getBoundingRect();
170  {
171  theBoundingRect = rect;
172  }
173  else if(!rect.hasNans())
174  {
176  }
177  }
178  }
179 }
void makeNan()
Definition: ossimDrect.h:388
ossimDrect combine(const ossimDrect &rect) const
Definition: ossimDrect.h:826
unsigned int ossim_uint32
bool hasNans() const
Definition: ossimDrect.h:396

◆ draw()

void ossimAnnotationMultiLineObject::draw ( ossimRgbImage anImage) const
virtual

Implements ossimAnnotationObject.

Definition at line 18 of file ossimAnnotationMultiLineObject.cpp.

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

Referenced by ossimGeoAnnotationPolyLineObject::draw().

19 {
20  if(anImage.getImageData().valid())
21  {
23  anImage.setThickness(theThickness);
24  ossimDrect imageRect = anImage.getImageData()->getImageRectangle();
25 
26 
27 
28  if(theBoundingRect.intersects(imageRect))
29  {
30  // we need to extend it by a couple of pixels since
31  // if a pixel lies on the edge and then another pixel is just off
32  // the edge we will get a stair step and so for several pixels
33  // the line might be inside the image rectangle but the clip
34  // algorithm will only draw 1 pixel since it thinks the first
35  // point is inside and the second point is outside and will
36  // execute the clip algorithm keeping only the first
37  // point.
38  ossimDrect clipRect(imageRect.ul().x - 10,
39  imageRect.ul().y - 10,
40  imageRect.lr().x + 10,
41  imageRect.lr().y + 10);
42 
43  for(ossim_uint32 i = 0; i < thePolyLineList.size(); ++i)
44  {
45  const vector<ossimDpt>& vList = thePolyLineList[i].getVertexList();
46 
47  if(vList.size() == 1)
48  {
49  anImage.drawLine(ossimIpt(vList[0]),
50  ossimIpt(vList[0]));
51  }
52  else
53  {
54  for(ossim_uint32 i2 = 0; i2 < (vList.size()-1); ++i2)
55  {
56  ossimDpt start = vList[i2];
57  ossimDpt end = vList[i2+1];
58  // now we can draw.
59  if(clipRect.clip(start, end))
60  {
61  anImage.drawLine(ossimIpt((int)start.x,
62  (int)start.y),
63  ossimIpt((int)end.x,
64  (int)end.y));
65  }
66  }
67  }
68  }
69  }
70  }
71 }
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.
unsigned int ossim_uint32
virtual ossimIrect getImageRectangle() const
bool intersects(const ossimDrect &rect) const
Definition: ossimDrect.cpp:289
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()

virtual ossimObject* ossimAnnotationMultiLineObject::dup ( ) const
inlinevirtual

Reimplemented from ossimObject.

Definition at line 49 of file ossimAnnotationMultiLineObject.h.

50  {
51  return new ossimAnnotationMultiLineObject(*this);
52  }

◆ getBoundingRect()

virtual void ossimAnnotationMultiLineObject::getBoundingRect ( ossimDrect rect) const
inlinevirtual

◆ getNewClippedObject()

ossimAnnotationObject * ossimAnnotationMultiLineObject::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 105 of file ossimAnnotationMultiLineObject.cpp.

References intersects(), ossimDrect::lr(), ossimAnnotationMultiLineObject(), ossimAnnotationObject::theBlue, ossimAnnotationObject::theGreen, thePolyLineList, ossimAnnotationObject::theRed, ossimAnnotationObject::theThickness, ossimDrect::ul(), ossimDpt::x, and ossimDpt::y.

Referenced by ossimGeoAnnotationPolyLineObject::getNewClippedObject().

106 {
108 
109  if(intersects(rect))
110  {
111  vector<ossimPolyLine> lineList;
112  vector<ossimPolyLine> tempResult;
113 
114  ossimDrect clipRect(rect.ul().x - 10,
115  rect.ul().y - 10,
116  rect.lr().x + 10,
117  rect.lr().y + 10);
118 
119  for(ossim_uint32 i =0; i< thePolyLineList.size();++i)
120  {
121  if(thePolyLineList[i].clipToRect(tempResult, clipRect))
122  {
123  lineList.insert(lineList.end(),
124  tempResult.begin(),
125  tempResult.end());
126  }
127  }
128 
129  if(lineList.size() > 0)
130  {
131  result = new ossimAnnotationMultiLineObject(lineList,
132  theRed,
133  theGreen,
134  theBlue,
135  theThickness);
136  }
137  }
138 
139  return result;
140 }
const ossimDpt & ul() const
Definition: ossimDrect.h:339
double y
Definition: ossimDpt.h:165
unsigned int ossim_uint32
virtual bool intersects(const ossimDrect &rect) const
double x
Definition: ossimDpt.h:164
const ossimDpt & lr() const
Definition: ossimDrect.h:341

◆ getPolyLineList() [1/2]

virtual const vector<ossimPolyLine>& ossimAnnotationMultiLineObject::getPolyLineList ( ) const
inlinevirtual

Definition at line 67 of file ossimAnnotationMultiLineObject.h.

Referenced by ossimGeoAnnotationPolyLineObject::transform().

68  {
69  return thePolyLineList;
70  }

◆ getPolyLineList() [2/2]

virtual vector<ossimPolyLine>& ossimAnnotationMultiLineObject::getPolyLineList ( )
inlinevirtual

Definition at line 72 of file ossimAnnotationMultiLineObject.h.

73  {
74  return thePolyLineList;
75  }

◆ intersects()

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

Implements ossimAnnotationObject.

Definition at line 73 of file ossimAnnotationMultiLineObject.cpp.

References thePolyLineList.

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

74 {
75 
76  for(ossim_uint32 i = 0; i < thePolyLineList.size(); ++i)
77  {
78  if(thePolyLineList[i].isWithin(rect))
79  {
80  return true;
81  }
82  }
83  return false;
84 }
unsigned int ossim_uint32

◆ isPointWithin()

bool ossimAnnotationMultiLineObject::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 142 of file ossimAnnotationMultiLineObject.cpp.

References thePolyLineList.

143 {
144  for(ossim_uint32 i=0; i < thePolyLineList.size(); ++i)
145  {
146  if(thePolyLineList[i].isPointWithin(imagePoint))
147  {
148  return true;
149  }
150 
151  }
152 
153  return false;
154 }
unsigned int ossim_uint32
virtual bool isPointWithin(const ossimDpt &imagePoint) const

◆ print()

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

References ossimAnnotationObject::print(), and thePolyLineList.

Referenced by ossimGeoAnnotationPolyLineObject::print().

182 {
184 
185  for(ossim_uint32 i = 0; i < thePolyLineList.size();++i)
186  {
187  out << thePolyLineList[i] << endl
188  <<"______________________________________"<<endl;
189  }
190  return out;
191 }
virtual std::ostream & print(std::ostream &out) const
Generic print method.
unsigned int ossim_uint32

◆ setPolyLine()

virtual void ossimAnnotationMultiLineObject::setPolyLine ( const ossimPolyLine line)
inlinevirtual

Definition at line 76 of file ossimAnnotationMultiLineObject.h.

77  {
78  thePolyLineList.clear();
79  thePolyLineList.push_back(line);
80  }

Member Data Documentation

◆ theBoundingRect

ossimDrect ossimAnnotationMultiLineObject::theBoundingRect
protected

Definition at line 83 of file ossimAnnotationMultiLineObject.h.

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

◆ thePolyLineList

vector<ossimPolyLine> ossimAnnotationMultiLineObject::thePolyLineList
protected

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