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