00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef AMROC_EVALUATORBASE_H
00010 #define AMROC_EVALUATORBASE_H
00011
00019 #include "IO/control-device.h"
00020
00021 #include <cstdio>
00022 #include <cfloat>
00023
00024 #define LEN_TKEYS 80
00025
00026 class VisualGridBase;
00027
00034 class EvaluatorBase : public controlable {
00035 public:
00036 EvaluatorBase() {
00037 tkeys = (char *) 0;
00038 fkeys = (int *) 0;
00039 ikeys = (int *) 0;
00040 mvals = (float *) 0;
00041 std::sprintf(title,"HDF-Visualizer for scalar functions");
00042 }
00043
00044 ~EvaluatorBase() {
00045 if (tkeys) delete [] tkeys;
00046 if (fkeys) delete [] fkeys;
00047 if (ikeys) delete [] ikeys;
00048 if (mvals) delete [] mvals;
00049 }
00050
00051 virtual void register_at(ControlDevice& Ctrl) {}
00052 virtual void register_at(ControlDevice& Ctrl,const std::string& prefix) {}
00053 virtual void init() {}
00054 virtual void update() {}
00055 virtual void finish() {}
00056
00057 virtual void SetUp(VisualGridBase *gr) {
00058 Grid = gr;
00059 if (tkeys) delete [] tkeys;
00060 if (fkeys) delete [] fkeys;
00061 if (ikeys) delete [] ikeys;
00062 if (mvals) delete [] mvals;
00063
00064 tkeys = new char[NKeys() * LEN_TKEYS];
00065 std::sprintf(&(tkeys[0]),"Function ");
00066 fkeys = new int[NKeys()];
00067 fkeys[0] = 1;
00068 ikeys = new int[NKeys()];
00069 ikeys[0] = 102;
00070
00071 mvals = new float[2*NKeys()];
00072 for (int i=0; i<NKeys(); i++) {
00073 mvals[2*i] = FLT_MAX; mvals[2*i+1] = FLT_MIN;
00074 }
00075 }
00076
00077 virtual int NKeys() const { return 1; }
00078
00079 char* TitleKeys() const { return tkeys; }
00080 char* TitleKeys(int n) const { return &(tkeys[n*LEN_TKEYS]); }
00081 int* FunctionsKeys() const { return fkeys; }
00082 int* KeyboardKeys() const { return ikeys; }
00083 float* Mvals() const { return mvals; }
00084 float* Mvals(int n) const { return &(mvals[2*n]); }
00085 char* Title() { return title; }
00086 VisualGridBase& TheGrid() { return *Grid; }
00087 VisualGridBase& TheGrid() const { return *Grid; }
00088
00089 public:
00090 float* mvals;
00091 protected:
00092 char* tkeys;
00093 int* fkeys;
00094 int* ikeys;
00095 char title[LEN_TKEYS];
00096 VisualGridBase* Grid;
00097 };
00098
00099
00100 #endif