FOX/ObjCryst++  1.10.X (development)
Tracker.cpp
1 /* ObjCryst++ Object-Oriented Crystallographic Library
2  (c) 2005- Vincent Favre-Nicolin vincefn@users.sourceforge.net
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 /*
19 * source file ObjCryst++ Tracker class
20 *
21 */
22 #include "ObjCryst/RefinableObj/Tracker.h"
23 
24 using namespace std;
25 
26 namespace ObjCryst
27 {
29 //
30 // Tracker
31 //
33 Tracker::Tracker(const string &name)
34 :mName(name)
35 {}
36 
37 Tracker::~Tracker()
38 {}
39 
40 const string& Tracker::GetName()const{return mName;}
41 void Tracker::AppendValue(const long n)
42 {mvValues[n]=this->ReadValue();}
43 
45 {
46  mvValues.clear();
47 }
48 
49 const std::map<long,REAL>& Tracker::GetValues()const{return mvValues;}
50 std::map<long,REAL>& Tracker::GetValues(){return mvValues;}
51 
52 
53 
55 //
56 // MainTracker
57 //
59 
60 MainTracker::MainTracker()
61 {
62  #ifdef __WX__CRYST__
63  mpWXTrackerGraph=0;
64  #endif
65 }
66 
67 MainTracker::~MainTracker()
68 {
69  #ifdef __WX__CRYST__
70  this->WXDelete();
71  #endif
72  this->ClearTrackers();
73 }
74 void MainTracker::AddTracker(Tracker *t)
75 {
76  mvpTracker.insert(t);
78  this->UpdateDisplay();
79 }
80 
81 void MainTracker::AppendValues(const long nb)
82 {
83  for(std::set<Tracker*>::iterator pos=mvpTracker.begin(); pos!=mvpTracker.end();++pos)
84  (*pos)->AppendValue(nb);
86 }
87 
89 {
90  std::set<Tracker*>::iterator pos;
91  for(pos=mvpTracker.begin();pos!=mvpTracker.end();++pos) delete *pos;
92  mvpTracker.clear();
94  this->UpdateDisplay();
95 }
96 
98 {
99  std::set<Tracker*>::iterator pos;
100  for(pos=mvpTracker.begin();pos!=mvpTracker.end();++pos) (*pos)->Clear();
102  this->UpdateDisplay();
103 }
104 
105 void MainTracker::SaveAll(std::ostream &os)const
106 {
107  std::set<Tracker*>::const_iterator posT,posT0;
108  os<<"#Trial ";
109  for(posT=mvpTracker.begin();posT!=mvpTracker.end();++posT) os<<(*posT)->GetName()<<" ";
110  os<<endl;
111 
112  posT0=mvpTracker.begin();
113  std::map<long,REAL>::const_iterator pos0,pos;
114  for(pos0=(*posT0)->GetValues().begin();pos0!=(*posT0)->GetValues().end();++pos0)
115  {
116  const long k=pos0->first;
117  os<<k<<" ";
118  for(posT=mvpTracker.begin();posT!=mvpTracker.end();posT++)
119  {
120  pos=(*posT)->GetValues().find(k);
121  if(pos==(*posT)->GetValues().end()) os << -1.0 <<" ";
122  else os << pos->second <<" ";
123  }
124  os<<endl;
125  }
126 }
127 
128 const std::set<Tracker*> &MainTracker::GetTrackerList()const
129 {
130  return mvpTracker;
131 }
132 
134 {
135  #ifdef __WX__CRYST__
136  if(0!=mpWXTrackerGraph)mpWXTrackerGraph->UpdateDisplay();
137  #endif
138 }
141 #ifdef __WX__CRYST__
142 WXTrackerGraph* MainTracker::WXCreate(wxFrame *frame)
143 {
144  if(0==mpWXTrackerGraph) mpWXTrackerGraph=new WXTrackerGraph(frame,this);
145  return mpWXTrackerGraph;
146 }
147 WXTrackerGraph* MainTracker::WXGet(){return mpWXTrackerGraph;}
148 void MainTracker::WXDelete()
149 {
150  if(0!=mpWXTrackerGraph)
151  {
152  delete mpWXTrackerGraph;
153  mpWXTrackerGraph=0;
154  }
155 }
156 void MainTracker::WXNotifyDelete()
157 {
158  mpWXTrackerGraph=0;
159 }
160 #endif
161 
162 
163 }//namespace
We need to record exactly when refinable objects have been modified for the last time (to avoid re-co...
Definition: RefinableObj.h:138
void Clear()
Removes all stored values.
Definition: Tracker.cpp:44
void UpdateDisplay() const
Update display, if any.
Definition: Tracker.cpp:133
RefinableObjClock mClockTrackerList
Last time a tracker was added.
Definition: Tracker.h:92
void Click()
Record an event for this clock (generally, the 'time' an object has been modified, or some computation has been made)
void ClearValues()
Removes all stored values.
Definition: Tracker.cpp:97
const RefinableObjClock & GetClockValues() const
Get last time values were whanged.
Definition: Tracker.cpp:140
const RefinableObjClock & GetClockTrackerList() const
Get last time a tracker was added.
Definition: Tracker.cpp:139
void ClearTrackers()
Removes all Trackers.
Definition: Tracker.cpp:88
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
Definition: Atom.cpp:47
void SaveAll(std::ostream &out) const
Will save to a single file if all recorded trial numbers are the same Otherwise ? ...
Definition: Tracker.cpp:105
RefinableObjClock mClockValues
Last time values were whanged.
Definition: Tracker.h:94