OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimAdjustmentInfo.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 // Copyright (C) 2000 ImageLinks Inc.
3 //
4 // LICENSE: See top level LICENSE.txt file.
5 //
6 // Author: Garrett Potts
7 //
8 //*************************************************************************
9 // $Id: ossimAdjustmentInfo.cpp 15833 2009-10-29 01:41:53Z eshirschorn $
12 
13 static const char* PARAM_PREFIX = "adj_param_";
14 static const char* NUMBER_OF_PARAMS_KW = "number_of_params";
15 static const char* DIRTY_FLAG_KW = "dirty_flag";
16 
17 
19 {
20  ossim_int32 idx = 0;
21 
22  out << "Description: " << data.getDescription()
23  << "\nNumber of Params: " << data.theParameterList.size()
24  << "\nDirty flag: " << data.theDirtyFlag << std::endl;
25 
26  for(idx = 0; idx < (int)data.getNumberOfAdjustableParameters(); ++idx)
27  {
28  out << "Param " << idx << std::endl;
29  out << data.theParameterList[idx] << std::endl;
30  }
31 
32  return out;
33 }
34 
35 
36 ossimAdjustmentInfo::ossimAdjustmentInfo(int numberOfAdjustableParameters)
37  :theParameterList(numberOfAdjustableParameters),
38  theDescription(""),
39  theDirtyFlag(false)
40 {
41 }
42 
44  :theParameterList(rhs.theParameterList),
46  theDirtyFlag(rhs.theDirtyFlag)
47 {
48 }
49 
51 {
52  std::vector<ossimAdjustableParameterInfo> temp = theParameterList;
53 
54  theParameterList.resize(numberOfAdjustableParameters);
55  if(temp.size() < numberOfAdjustableParameters)
56  {
57  std::copy(temp.begin(),
58  temp.end(),
59  theParameterList.begin());
60  }
61  else if(temp.size() > numberOfAdjustableParameters)
62  {
63  if(numberOfAdjustableParameters > 0)
64  {
65  std::copy(temp.begin(),
66  temp.begin()+numberOfAdjustableParameters,
67  theParameterList.begin());
68  }
69  }
70 }
71 
73 {
74  return (ossim_uint32)theParameterList.size();
75 }
76 
78 {
79  return theDescription;
80 }
81 
83 {
84  theDescription = description;
85 }
86 
88 {
89  return theDirtyFlag;
90 }
91 
93 {
94  theDirtyFlag = flag;
95 }
96 
98  ossim_uint32 idx)
99 {
100  if(idx < theParameterList.size())
101  {
102  theParameterList[idx].setLockFlag(flag);
103  }
104 }
105 
107 {
108  ossim_uint32 idx = 0;
109 
110  for(idx = 0; idx < theParameterList.size();++idx)
111  {
112  double center = theParameterList[idx].computeOffset();
113  theParameterList[idx].setParameter(0.0);
114  theParameterList[idx].setCenter(center);
115  }
116 }
117 
118 
119 std::vector<ossimAdjustableParameterInfo>& ossimAdjustmentInfo::getParameterList()
120 {
121  return theParameterList;
122 }
123 
124 const std::vector<ossimAdjustableParameterInfo>& ossimAdjustmentInfo::getParameterList()const
125 {
126  return theParameterList;
127 }
128 
130  const ossimString& prefix)const
131 {
132  kwl.add(prefix,
134  getDescription(),
135  true);
136  kwl.add(prefix.c_str(),
137  NUMBER_OF_PARAMS_KW,
138  static_cast<ossim_uint32>(theParameterList.size()),
139  true);
140 
141  kwl.add(prefix,
142  DIRTY_FLAG_KW,
143  (short)theDirtyFlag,
144  true);
145 
146  ossimString value;
147  for(ossim_uint32 idx = 0; idx < theParameterList.size();++idx)
148  {
149  ossimString newPrefix = ossimString(prefix) + (ossimString(PARAM_PREFIX) + ossimString::toString(idx)+".");
150  theParameterList[idx].saveState(kwl, newPrefix.c_str());
151  }
152 
153  return true;
154 }
155 
157  const ossimString& prefix)
158 {
160  setNumberOfAdjustableParameters(ossimString(kwl.find(prefix, NUMBER_OF_PARAMS_KW)).toUInt32());
161  const char *dirtyFlag = kwl.find(prefix, DIRTY_FLAG_KW);
162  ossimString value;
163 
164  if(dirtyFlag)
165  {
166  theDirtyFlag = ossimString(dirtyFlag).toBool();
167  }
168  else
169  {
170  theDirtyFlag = false;
171  }
172 
173  for(ossim_uint32 idx = 0; idx < theParameterList.size();++idx)
174  {
175  ossimString newPrefix = ossimString(prefix) + (ossimString(PARAM_PREFIX) + ossimString::toString(idx)+".");
176  if(!theParameterList[idx].loadState(kwl, newPrefix.c_str()))
177  {
178  return false;
179  }
180  }
181 
182  return true;
183 }
void setLockFlag(bool flag, ossim_uint32 idx)
std::ostream & operator<<(std::ostream &out, const ossimAdjustmentInfo &data)
Represents serializable keyword/value map.
const char * find(const char *key) const
ossim_uint32 getNumberOfAdjustableParameters() const
bool loadState(const ossimKeywordlist &kwl, const ossimString &prefix=ossimString(""))
static ossimString toString(bool aValue)
Numeric to string methods.
ossimString getDescription() const
void setDirtyFlag(bool flag=true)
std::vector< ossimAdjustableParameterInfo > & getParameterList()
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
bool saveState(ossimKeywordlist &kwl, const ossimString &prefix=ossimString("")) const
bool toBool() const
String to numeric methods.
unsigned int ossim_uint32
static const char * DESCRIPTION_KW
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
ossimString theDescription
ossimAdjustmentInfo(int numberOfAdjustableParameters=0)
void setNumberOfAdjustableParameters(ossim_uint32 numberOfAdjustableParameters)
std::vector< ossimAdjustableParameterInfo > theParameterList
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
int ossim_int32
void setDescription(const ossimString &description)