OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimImageSourceHistogramFilter.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // Author: Garrett Potts (gpotts@imagelinks)
6 // Description:
7 //
8 //*************************************************************************
9 // $Id: ossimImageSourceHistogramFilter.cpp 13312 2008-07-27 01:26:52Z gpotts $
15 #include <ossim/base/ossimCommon.h>
19 
20 static const ossimKeyword PROPRIETARY_FILENAME_KW("proprietary_filename",
21  "imports a proprietary file");
22 
23 static const ossimKeyword HISTOGRAM_FILENAME_KW("histogram_filename",
24  "read an OSSIM histogram file");
25 
26 
27 RTTI_DEF1(ossimImageSourceHistogramFilter, "ossimImageSourceHistogramFilter", ossimImageSourceFilter)
28 
31  theCurrentResLevel(0),
32  theHistogram(NULL),
33  theFilename("")
34 {
35  setNumberOfInputs(2);
36  theInputListIsFixedFlag = true;
37 }
38 
41  : ossimImageSourceFilter(inputSource),
42  theCurrentResLevel(0),
43  theHistogram(histogram),
44  theFilename("")
45 {
48 }
49 
51 {
52 }
53 
54 
56 {
57  theHistogram = histogram;
58 
59  if(theHistogram.valid())
60  {
62  }
63 }
64 
66 {
68 
69  bool result = histogram->importHistogram(filename);
70 
71  if(result)
72  {
73  theFilename = filename;
74  setHistogram(histogram);
75  }
76 
77  return result;
78 }
79 
81 {
82  if(!getInput(1))
83  {
84  return theHistogram;
85  }
86  else
87  {
89  if(histoSource)
90  {
91  return histoSource->getHistogram();
92  }
93  }
94 
95  return (ossimMultiResLevelHistogram*)0;
96 }
97 
99 {
100  if(!getInput(1))
101  {
102  return theHistogram;
103  }
104  else
105  {
107  if(histoSource)
108  {
109  return histoSource->getHistogram();
110  }
111  }
112 
113  return (ossimMultiResLevelHistogram*)0;
114 }
115 
117  const ossimConnectableObject* object)const
118 {
119  if(object)
120  {
121  if(PTR_CAST(ossimImageSource, object) && ( inputIndex == 0 ))
122  {
123  return true;
124  }
125  else if(PTR_CAST(ossimHistogramSource, object) && ( inputIndex == 1 ))
126  {
127  return true;
128  }
129  }
130 
131  return false;
132 }
133 
135 {
138  {
139  // only initialize if it's a new object
140  initialize();
141  }
142 }
143 
145  const char* prefix)const
146 {
147  bool result = ossimImageSourceFilter::saveState(kwl, prefix);
148 
149  kwl.add(prefix,
150  HISTOGRAM_FILENAME_KW,
151  theFilename,
152  true);
153 
154  return result;
155 }
156 
158  const char* prefix)
159 {
160  const char* proprietaryName = kwl.find(prefix, PROPRIETARY_FILENAME_KW);
161  const char* ossimName = kwl.find(prefix, HISTOGRAM_FILENAME_KW);
162  bool result = true;
163  ossimFilename file;
164 
165  if(proprietaryName)
166  {
167  theFilename = ossimFilename(proprietaryName);
168  }
169  else if(ossimName)
170  {
171  if(!theHistogram)
172  {
174  }
175  theFilename = ossimFilename(ossimName);
176 
177  }
178 
179  if(theFilename.exists()&&(theFilename!=""))
180  {
181  if(!theHistogram)
182  {
184  }
186  }
187  if(theHistogram.valid())
188  {
189  theHistogram->setBinCount(0, 0);
190  }
191 
192  result = ossimImageSourceFilter::loadState(kwl, prefix);
193 
196 
197  return result;
198 }
199 
201 {
202 
203  out << "ossimImageSourceHistogramFilter::print:\n"
204  << "theFilename: " << endl;
205 
206  return ossimImageSourceFilter::print(out);
207 }
virtual void setNumberOfInputs(ossim_int32 numberOfInputs)
Will set the number of inputs.
virtual bool importHistogram(const ossimFilename &inputFile)
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=NULL)
Method to the load (recreate) the state of an object from a keyword list.
void setBinCount(double binNumber, double count)
virtual void connectInputEvent(ossimConnectionEvent &event)
Represents serializable keyword/value map.
bool canConnectMyInputTo(ossim_int32 inputIndex, const ossimConnectableObject *object) const
required to be overriden by derived classes
bool valid() const
Definition: ossimRefPtr.h:75
const char * find(const char *key) const
virtual std::ostream & print(std::ostream &out) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
virtual ossimRefPtr< ossimMultiResLevelHistogram > getHistogram()
ossimRefPtr< ossimMultiResLevelHistogram > theHistogram
virtual ossimConnectableObject * getNewObject(ossim_uint32 i=0)
ossimConnectableObject * getInput(ossim_uint32 index=0)
returns the object at the specified index.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
virtual std::ostream & print(std::ostream &out) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
virtual void setHistogram(ossimRefPtr< ossimMultiResLevelHistogram > histogram)
bool exists() const
ossimImageSource * theInputConnection
#define PTR_CAST(T, p)
Definition: ossimRtti.h:321
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=NULL) const
Method to save the state of an object to a keyword list.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
bool theInputListIsFixedFlag
Indicates whether the theInputObjectList is fixed.
#define RTTI_DEF1(cls, name, b1)
Definition: ossimRtti.h:485
virtual ossimRefPtr< ossimMultiResLevelHistogram > getHistogram()
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
int ossim_int32