OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimAnnotationMultiLineObject.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 // Copyright (C) 2000 ImageLinks Inc.
3 //
4 // License: LGPL
5 //
6 // See LICENSE.txt file in the top level directory for more details.
7 //
8 // Author: Garrett Potts
9 //
10 //*************************************************************************
11 // $Id: ossimAnnotationMultiLineObject.cpp 9094 2006-06-13 19:12:40Z dburken $
13 
15  "ossimAnnotationMultiLineObject",
17 
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 }
72 
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 }
85 
86 
88  double y)
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 }
104 
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 }
141 
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 }
155 
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 }
180 
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 }
void makeNan()
Definition: ossimDrect.h:388
ossim_uint32 x
virtual std::ostream & print(std::ostream &out) const
Generic print method.
ossim_uint32 y
bool valid() const
Definition: ossimRefPtr.h:75
const ossimDpt & ul() const
Definition: ossimDrect.h:339
double y
Definition: ossimDpt.h:165
virtual ossimAnnotationObject * getNewClippedObject(const ossimDrect &rect) const
ossimDrect combine(const ossimDrect &rect) const
Definition: ossimDrect.h:826
virtual void draw(ossimRgbImage &anImage) const
void setThickness(ossim_int32 thickness)
All the drawing algorithms have thickness.
virtual std::ostream & print(std::ostream &out) const
Generic print method.
ossimRefPtr< ossimImageData > getImageData()
Will return the image data.
unsigned int ossim_uint32
virtual bool intersects(const ossimDrect &rect) const
virtual ossimIrect getImageRectangle() const
bool hasNans() const
Definition: ossimDrect.h:396
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.
virtual bool isPointWithin(const ossimDpt &imagePoint) const
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
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
virtual void applyScale(double x, double y)
RTTI_DEF1(ossimAnnotationMultiLineObject, "ossimAnnotationMultiLineObject", ossimAnnotationObject)