OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimAdjustableParameterInfo.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: ossimAdjustableParameterInfo.cpp 11347 2007-07-23 13:01:59Z gpotts $
10 #include <sstream>
11 #include <algorithm>
15 #include <ossim/base/ossimCommon.h>
16 // static const char* PARAM_NAME_KW = "name";
17 // static const char* PARAM_UNITS_KW = "units";
18 static const char* PARAM_KW = "parameter";
19 static const char* PARAM_SIGMA_KW = "sigma";
20 static const char* PARAM_CENTER_KW = "center";
21 static const char* PARAM_LOCK_FLAG_KW = "lock_flag";
22 
24 {
25  out << "description: " << data.theDescription << std::endl
26  << "center: " << data.theCenter << std::endl
27  << "parameter: " << data.theParameter << std::endl
28  << "sigma: " << data.theSigma << std::endl
29  << "units: " << (ossimUnitTypeLut::instance()->getEntryString(data.theUnit))
30  << std::endl
31  << "locked: " << (data.theLockFlag?"true":"false") << std::endl;
32 
33  return out;
34 }
35 
36 
38 {
40 }
41 
43 {
44  if(!theLockFlag)
45  {
46  theCenter = center;
47  }
48 }
49 
51 {
52  return theCenter;
53 }
54 
56 {
58 }
59 
61 {
62  if(!theLockFlag)
63  {
64  double minValue = theCenter - theSigma;
65  double maxValue = theCenter + theSigma;
66  double x = 0.0;
67 
69  {
70  x = (value - theCenter)/theSigma;
71 
72  value = theCenter + x*theSigma;
73 
74  if(value < minValue)
75  {
76  x = -1;
77  }
78  else if(value > maxValue)
79  {
80  x = 1.0;
81  }
82  theParameter = x;
83  }
84  }
85 }
86 
88  const ossimString& prefix)
89 {
90  const char* param = kwl.find(prefix, PARAM_KW);
91  const char* sigma = kwl.find(prefix, PARAM_SIGMA_KW);
92  const char* center = kwl.find(prefix, PARAM_CENTER_KW);
93  const char* unit = kwl.find(prefix, ossimKeywordNames::UNITS_KW);
94  const char* locked = kwl.find(prefix, PARAM_LOCK_FLAG_KW);
95 
97 
98  if(param)
99  {
100  theParameter = ossimString(param).toDouble();
101  }
102  else
103  {
104  theParameter = 0.0;
105  }
106  if(unit)
107  {
109  }
110  else
111  {
113  }
114  if(sigma)
115  {
116  theSigma = ossimString(sigma).toDouble();
117  }
118  else
119  {
120  theSigma = 0.0;
121  }
122  if(center)
123  {
124  theCenter = ossimString(center).toDouble();
125  }
126  else
127  {
128  theCenter = 0.0;
129  }
130  if(locked)
131  {
132  theLockFlag = ossimString(locked).toBool();
133  }
134 
135  return true;
136 }
137 
139  const ossimString& prefix)const
140 {
141  kwl.add(prefix,
144  true);
145  kwl.add(prefix, ossimKeywordNames::UNITS_KW,
146  ossimUnitTypeLut::instance()->getEntryString(theUnit), true);
147  kwl.add(prefix, PARAM_KW, theParameter, true);
148  kwl.add(prefix, PARAM_SIGMA_KW, theSigma, true);
149  kwl.add(prefix, PARAM_CENTER_KW, theCenter, true);
150  kwl.add(prefix, PARAM_LOCK_FLAG_KW, theLockFlag, true);
151 
152  return true;
153 }
ossim_uint32 x
bool loadState(const ossimKeywordlist &kwl, const ossimString &prefix=ossimString(""))
ossimUnitType
Represents serializable keyword/value map.
const char * find(const char *key) const
virtual ossimString getEntryString(ossim_int32 entry_number) const
virtual ossim_int32 getEntryNumber(const char *entry_string, bool case_insensitive=true) const
#define abs(a)
Definition: auxiliary.h:74
double ossim_float64
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
std::ostream & operator<<(std::ostream &out, const ossimAdjustableParameterInfo &data)
bool toBool() const
String to numeric methods.
double toDouble() const
#define DBL_EPSILON
static const char * UNITS_KW
static const char * DESCRIPTION_KW
static ossimUnitTypeLut * instance()
Returns the static instance of an ossimUnitTypeLut object.
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
bool saveState(ossimKeywordlist &kwl, const ossimString &prefix=ossimString("")) const