OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimMapViewController.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 //
7 //*************************************************************************
8 // $Id: ossimMapViewController.cpp 15766 2009-10-20 12:37:09Z gpotts $
14 #include <iostream>
15 #include <fstream>
16 using namespace std;
17 
18 RTTI_DEF1(ossimMapViewController, "ossimMapViewController", ossimViewController);
19 
22 {
23 }
24 
26  ossim_uint32 inputListSize,
27  ossim_uint32 outputListSize,
28  bool inputListFixedFlag,
29  bool outputListFixedFlag)
30  :ossimViewController(owner,
31  inputListSize,
32  outputListSize,
33  inputListFixedFlag,
34  outputListFixedFlag)
35 {
36  if(theOwner)
37  {
40 
41  if(proj)
42  {
43  // we are initialized to the first view.
44  theView = proj->dup();
45  }
46  else
47  {
48  // initialize the controller to true geographic
50  }
51  }
52  else
53  {
54  // initialize the controller to true geographic
56  }
57 }
58 
60 {
61 }
62 
64 {
65  if(PTR_CAST(ossimMapProjection, object))
66  {
67  return ossimViewController::setView(object);
68  }
69 
70  return false;
71 }
72 
74 {
76 
77  if(!theView)
78  {
79  // initialize the controller to geographic
82 
83  if(proj)
84  {
85  // we are initialized to the first view.
86  setView(proj->dup());
87  propagateView();
88  }
89  else
90  {
91  // initialize the controller to true geographic
93  propagateView();
94  }
95  }
96  else
97  {
98  propagateView();
99  }
100 }
101 
103 {
104  if(file.exists())
105  {
106  ossimKeywordlist kwl;
107  kwl.addFile(file.c_str());
108 
110  if(dynamic_cast<ossimMapProjection*>(proj.get()))
111  {
112  setView(proj.get());
113  }
114  }
115 
116  theGeometryFile = file;
117 }
118 
119 
121  const char* prefix)const
122 {
123  ossimSource::saveState(kwl, prefix);
125 
126  ossimString newPrefix = prefix;
127  newPrefix += "projection.";
128 
129  if(proj)
130  {
131  if(theGeometryFile == "")
132  {
133  proj->saveState(kwl, newPrefix.c_str());
134  }
135  else
136  {
137  ofstream output(theGeometryFile.c_str());
138  if(output)
139  {
140  kwl.add(prefix,
143  ossimKeywordlist kwl2;
144  proj->saveState(kwl2);
145  kwl2.writeToStream(output);
146  }
147  else
148  {
149  ossimNotify(ossimNotifyLevel_WARN) << "WARNING ossimMapViewController::saveState can't open filename " << theGeometryFile
150  << "\nsaving inline to passed in keywordlist" << std::endl;
151  proj->saveState(kwl, newPrefix);
152  }
153  }
154  }
155 
156  return true;
157 }
158 
160  const char* prefix)
161 {
162  ossimSource::loadState(kwl, prefix);
163 
166 
167  if(theGeometryFile == "")
168  {
169  ossimString newPrefix = prefix;
170  newPrefix += "projection.";
172  }
173  else
174  {
175  ossimKeywordlist kwl2;
176  kwl2.addFile(theGeometryFile);
177 
179  }
180 
181  if(dynamic_cast<ossimMapProjection*>(proj.get()))
182  {
183  setView(proj.get());
184  }
185 
186  return true;
187 }
virtual void setFilename(const ossimFilename &file)
virtual ossimObject * dup() const =0
ossimRefPtr< ossimObject > theView
virtual bool setView(ossimObject *object)
virtual void changeOwner(ossimObject *owner)
Permits changing the object&#39;s owner.
virtual ossimObject * getView()
Represents serializable keyword/value map.
bool addFile(const char *file)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Definition: ossimSource.cpp:55
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Definition: ossimSource.cpp:66
const char * find(const char *key) const
virtual bool propagateView()
virtual const ossimObject * findFirstViewOfType(RTTItypeid typeId) const
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
virtual bool setView(ossimObject *object)
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
virtual void changeOwner(ossimObject *owner)
Permits changing the object&#39;s owner.
ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
bool exists() const
unsigned int ossim_uint32
#define STATIC_TYPE_INFO(T)
Definition: ossimRtti.h:319
#define PTR_CAST(T, p)
Definition: ossimRtti.h:321
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
RTTI_DEF1(ossimMapViewController, "ossimMapViewController", ossimViewController)
virtual void writeToStream(std::ostream &out) const
static ossimProjectionFactoryRegistry * instance()
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
std::basic_ofstream< char > ofstream
Class for char output file streams.
Definition: ossimIosFwd.h:47
static const char * FILENAME_KW
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)