[2615] | 1 | #include "sopnamsp.h"
|
---|
[670] | 2 | #include "machdefs.h"
|
---|
| 3 | #include <stdlib.h>
|
---|
| 4 | #include <typeinfo>
|
---|
[2322] | 5 | #include <iostream>
|
---|
[670] | 6 | #include <string>
|
---|
| 7 |
|
---|
| 8 | #include "nomspecrespadapter.h"
|
---|
| 9 | #include "specrespvector.h"
|
---|
| 10 | #include "gaussfilt.h"
|
---|
| 11 | #include "pidrawer.h"
|
---|
| 12 |
|
---|
| 13 | // ------ Classe de Drawer pour tracer Y = Transmission(nu = X)
|
---|
| 14 | class PISpectralResponseDrawer : public PIDrawer {
|
---|
| 15 | public :
|
---|
| 16 | PISpectralResponseDrawer(SpectralResponse* sr, bool ad=false);
|
---|
| 17 | ~PISpectralResponseDrawer();
|
---|
| 18 | virtual void Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
|
---|
| 19 | virtual void UpdateLimits();
|
---|
| 20 |
|
---|
| 21 | protected:
|
---|
| 22 | SpectralResponse * mSR;
|
---|
| 23 | bool mAd;
|
---|
| 24 | };
|
---|
| 25 |
|
---|
| 26 | PISpectralResponseDrawer::PISpectralResponseDrawer(SpectralResponse* sr, bool ad)
|
---|
| 27 | {
|
---|
| 28 | mSR = sr;
|
---|
| 29 | mAd = ad;
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | PISpectralResponseDrawer::~PISpectralResponseDrawer()
|
---|
| 33 | {
|
---|
| 34 | if (mAd && mSR) delete mSR;
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | void
|
---|
| 38 | PISpectralResponseDrawer::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
|
---|
| 39 | {
|
---|
| 40 | if (!mSR) return;
|
---|
| 41 | PIGrCoord x1, x2, y1, y2;
|
---|
| 42 | g->GetGrSpace(x1, x2, y1, y2);
|
---|
| 43 | double xMax = x2;
|
---|
| 44 | double xMin = x1;
|
---|
| 45 | double yMax = y2;
|
---|
| 46 | double yMin = y1;
|
---|
| 47 | double xStep = (xMax - xMin)/100;
|
---|
| 48 | double xOld = xMin;
|
---|
| 49 | double yOld = mSR->transmission(xMin);
|
---|
| 50 | double x,y;
|
---|
| 51 | for (x = xMin+xStep; x<xMax; x+=xStep) {
|
---|
| 52 | y = mSR->transmission(x);
|
---|
| 53 | if (y>yMin && yOld>yMin &&
|
---|
| 54 | y<yMax && yOld<yMax)
|
---|
| 55 | g->DrawLine(xOld, yOld, x, y);
|
---|
| 56 | xOld = x;
|
---|
| 57 | yOld = y;
|
---|
| 58 | }
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | void
|
---|
| 62 | PISpectralResponseDrawer::UpdateLimits()
|
---|
| 63 | {
|
---|
| 64 | if (!mSR) return;
|
---|
| 65 | double xmin, xmax;
|
---|
| 66 | double ymin, ymax;
|
---|
| 67 | xmin = mSR->minFreq();
|
---|
| 68 | xmax = mSR->maxFreq();
|
---|
| 69 | double dx = (xmax-xmin)*0.025;
|
---|
| 70 | xmin -= dx; xmax += dx;
|
---|
| 71 | ymin = 0.;
|
---|
| 72 | ymax = mSR->peakTransmission()*1.05;
|
---|
| 73 | SetLimits(xmin, xmax, ymin, ymax);
|
---|
| 74 | // cout << " DBG - " << xmin << "," << xmax << " " << ymin << "," << ymax << endl;
|
---|
| 75 | }
|
---|
| 76 | //-------------------------------------------------------------------------
|
---|
| 77 | // Class Adaptateur d'objet (Pour NamedObjMgr) d'objet SpectralResponse
|
---|
| 78 | //-------------------------------------------------------------------------
|
---|
| 79 |
|
---|
| 80 | /* --Methode-- */
|
---|
| 81 | NOMAdapter_SpectralResponse::NOMAdapter_SpectralResponse(SpectralResponse* o)
|
---|
| 82 | : NObjMgrAdapter(o)
|
---|
| 83 | {
|
---|
| 84 | mSR = o;
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | /* --Methode-- */
|
---|
| 88 | NOMAdapter_SpectralResponse::~NOMAdapter_SpectralResponse()
|
---|
| 89 | {
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | /* --Methode-- */
|
---|
| 93 | NObjMgrAdapter* NOMAdapter_SpectralResponse::Clone(AnyDataObj* o)
|
---|
| 94 | {
|
---|
| 95 | SpectralResponse* sr = dynamic_cast<SpectralResponse *>(o);
|
---|
| 96 | if (sr) return ( new NOMAdapter_SpectralResponse(sr) );
|
---|
| 97 | return ( new NObjMgrAdapter(o) );
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 |
|
---|
| 101 | /* --Methode-- */
|
---|
| 102 | void NOMAdapter_SpectralResponse::SavePPF(POutPersist& pos, string const & nom)
|
---|
| 103 | {
|
---|
| 104 | GaussianFilter* gf = dynamic_cast<GaussianFilter *> (mSR);
|
---|
| 105 | SpecRespVec* vecFilt = dynamic_cast<SpecRespVec *> (mSR);
|
---|
| 106 | if (gf) { // C'est un GaussianFilter ....
|
---|
| 107 | ObjFileIO<GaussianFilter> oio(gf);
|
---|
| 108 | oio.Write(pos, nom);
|
---|
| 109 | }
|
---|
| 110 | else if (vecFilt) {
|
---|
| 111 | ObjFileIO<SpecRespVec> oio(vecFilt);
|
---|
| 112 | oio.Write(pos, nom);
|
---|
| 113 | }
|
---|
| 114 | else {
|
---|
| 115 | string s = typeid(*mSR).name();
|
---|
| 116 | cout << "NOMAdapter_SpectralResponse::SavePPF() - Error : Not supported for " << s << endl;
|
---|
| 117 | }
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | /* --Methode-- */
|
---|
[2975] | 121 | void NOMAdapter_SpectralResponse::Print(ostream& os, int)
|
---|
[670] | 122 | {
|
---|
| 123 | os << (*mSR);
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | /* --Methode-- */
|
---|
| 127 | PIDrawer* NOMAdapter_SpectralResponse::GetDrawer(string & dopt)
|
---|
| 128 | {
|
---|
| 129 | return(new PISpectralResponseDrawer(mSR, false));
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 |
|
---|
| 133 | /* --Methode--
|
---|
| 134 | NTupleInterface* NOMAdapter_SpectralResponse::GetNTupleInterface(bool& adel)
|
---|
| 135 | {
|
---|
| 136 | adel = true;
|
---|
| 137 | return( new NTupInt_SpectralResponse(mSR) );
|
---|
| 138 | }
|
---|
| 139 | */
|
---|
| 140 |
|
---|
| 141 |
|
---|