Ignore:
Timestamp:
05/12/04 20:22:24 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mastro
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mastro/MAstroCamera.cc

    r3957 r4058  
    9090
    9191#include "../mhist/MHCamera.h" // FIXME: This dependancy is very bad!
    92                                // HOW TO GET RID OF IT? Move MHCamera to mgeom?
     92                      // HOW TO GET RID OF IT? Move MHCamera to mgeom?
    9393
    9494//#include "MStarLocalPos.h"
     
    292292//  'c' Use the underlaying MHCamera as histogram
    293293//  '0' Draw the reflection on a virtual perfect mirror
     294//  '=' Draw '0' or '*' propotional to the star magnitude
    294295//
    295296// If the Pad contains an object MHCamera of type MHCamera it is used.
     
    312313    const Bool_t hasdot  = o.Contains(".", TString::kIgnoreCase);
    313314    const Bool_t usecam  = o.Contains("c", TString::kIgnoreCase);
     315    const Bool_t resize  = o.Contains("=", TString::kIgnoreCase);
    314316
    315317    // Get camera
     
    389391                m->SetMarkerColor(kMagenta);
    390392                m->SetMarkerStyle(kDot);
    391                 AddMap(m);
     393                fMapG.Add(m);
    392394            }
    393395            if (h)
     
    402404        // transform meters into millimeters (camera display works with mm)
    403405        mean *= 1./num;
    404         DrawStar(mean(0), mean(1), *radec, !hasmean, Form("x=%.1fmm y=%.1fmm", mean(0), mean(1)));
     406        DrawStar(mean(0), mean(1), *radec, hasmean?kBlack:-1, Form("x=%.1fmm y=%.1fmm", mean(0), mean(1)), resize);
    405407
    406408        if (hasnull)
     
    409411            star *= rot;
    410412            const TVector3 spot = fMirror0->GetReflection(star, fGeom->GetCameraDist())*1000;
    411             DrawStar(spot(0), spot(1), *radec, !hasmean, Form("x=%.1fmm y=%.1fmm", mean(0), mean(1)));
     413            DrawStar(spot(0), spot(1), *radec, hasmean?kBlack:-1, Form("x=%.1fmm y=%.1fmm", mean(0), mean(1)), resize);
     414            // This can be used to get the abberation...
    412415            //cout << TMath::Hypot(spot(0), spot(1)) << " " << TMath::Hypot(mean(0)-spot(0), mean(1)-spot(1)) << endl;
    413416        }
     
    481484// x [mm]: x coordinate in the camera plane (assuming a perfect mirror)
    482485// y [mm]: y coordinate in the camera plane (assuming a perfect mirror)
     486//
     487// We assume (0, 0) to be the center of the FOV
    483488//
    484489// dzd [deg]: Delta Zd
  • trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc

    r3710 r4058  
    128128
    129129#include "MTime.h"
     130//#include "MString.h"
    130131#include "MAstro.h"
    131132#include "MAstroSky2Local.h"
     
    144145using namespace std;
    145146
     147void MVector3::WriteBinary(ostream &out) const
     148{
     149    const Double_t t = Theta();
     150    const Double_t p = Phi();
     151    const Float_t  m = Mag();
     152    out.write((char*)&t, 8);
     153    out.write((char*)&p, 8);
     154    out.write((char*)&m, 4);
     155    out << fName << endl;
     156}
     157
     158void MVector3::ReadBinary(istream &in)
     159{
     160    Double_t t, p;
     161    Float_t  m;
     162
     163    in.read((char*)&t, 8);
     164    in.read((char*)&p, 8);
     165    in.read((char*)&m, 4);
     166    fName.ReadLine(in);
     167
     168    SetMagThetaPhi(m, t, p);
     169}
     170
    146171// --------------------------------------------------------------------------
    147172//
     
    153178{
    154179    fList.SetOwner();
     180    fMapG.SetOwner();
    155181    fToolTip = new TGToolTip(0, "", 0);
    156182}
     
    179205    fToolTip->Hide();
    180206    delete fToolTip;
    181 
    182     DeleteMap();
    183207}
    184208
     
    253277    if (!fin)
    254278    {
    255         gLog << err << "Cannot open file " << catalog << ": ";
     279        gLog << err << "Cannot open catalog file " << catalog << ": ";
    256280        gLog << strerror(errno) << endl;
    257281        return 0;
     
    345369    if (!fin)
    346370    {
    347         gLog << err << "Cannot open file " << catalog << ": ";
     371        gLog << err << "Cannot open catalog file " << catalog << ": ";
    348372        gLog << strerror(errno) << endl;
    349373        return 0;
     
    420444    if (!fin)
    421445    {
    422         gLog << err << "Cannot open file " << catalog << ": ";
     446        gLog << err << "Cannot open catalog file " << catalog << ": ";
    423447        gLog << strerror(errno) << endl;
    424448        return 0;
     
    484508// --------------------------------------------------------------------------
    485509//
     510// Read from a ascii heasarc ppm catalog. set bit kHasChanged
     511// Already read data is not deleted. To delete the stored data call
     512// Delete().
     513// If the second argument is given all survived stars are written
     514// to a file outname. This files will contain an apropriate compressed
     515// file format. You can read such files again using ReadCompressed.
     516//
     517Int_t MAstroCatalog::ReadHeasarcPPM(TString catalog, TString outname)
     518{
     519    SetBit(kHasChanged);
     520
     521    gLog << inf << "Reading Heasarc PPM catalog: " << catalog << endl;
     522
     523    ifstream fin(catalog);
     524    if (!fin)
     525    {
     526        gLog << err << "Cannot open catalog file " << catalog << ": ";
     527        gLog << strerror(errno) << endl;
     528        return 0;
     529    }
     530
     531    ofstream *fout = outname.IsNull() ? 0 : new ofstream(outname);
     532    if (fout && !*fout)
     533    {
     534        gLog << warn << "Cannot open output file " << outname << ": ";
     535        gLog << strerror(errno) << endl;
     536        delete fout;
     537        fout = 0;
     538    }
     539
     540    Int_t add=0;
     541    Int_t cnt=0;
     542    Int_t n  =0;
     543
     544    Double_t maxmag=0;
     545
     546    while (1)
     547    {
     548        TString row;
     549        row.ReadLine(fin);
     550        if (!fin)
     551            break;
     552
     553        cnt++;
     554
     555        if (!row.BeginsWith("PPM "))
     556            continue;
     557
     558        const TString name = row(0, row.First('|'));
     559        row = row(row.First('|')+1, row.Length());
     560        row = row(row.First('|')+1, row.Length());
     561
     562        const TString vmag = row(0, row.First('|'));
     563
     564        n++;
     565        const Double_t mag = atof(vmag.Data());
     566        maxmag = TMath::Max(maxmag, mag);
     567        if (mag>fLimMag)
     568            continue;
     569
     570        row = row(row.First('|')+1, row.Length());
     571        row = row(row.First('|')+1, row.Length());
     572
     573        row = row(row.First('|')+1, row.Length());
     574        row = row(row.First('|')+1, row.Length());
     575
     576        row = row(row.First('|')+1, row.Length());
     577        row = row(row.First('|')+1, row.Length());
     578
     579        const TString ra = row(0, row.First('|'));
     580        row = row(row.First('|')+1, row.Length());
     581        const TString de = row(0, row.First('|'));
     582        row = row(row.First('|')+1, row.Length());
     583
     584        Char_t sgn;
     585        Int_t d, m;
     586        Float_t s;
     587        if (sscanf(ra.Data(), "%d %d %f", &d, &m, &s)!=3)
     588        {
     589            // gLog << "Error loading entry in line " << i << endl;
     590            continue;
     591        }
     592        const Double_t ra0 = MAstro::Hms2Rad(d, m, s);
     593
     594        if (sscanf(de.Data(), "%c%d %d %f", &sgn, &d, &m, &s)!=4)
     595        {
     596            // gLog << "Error loading entry in line " << i << endl;
     597            continue;
     598        }
     599        const Double_t de0 = MAstro::Dms2Rad(d, m, s, sgn);
     600
     601        MVector3 *star=new MVector3;
     602        star->SetRaDec(ra0, de0, mag);
     603        star->SetName(name);
     604        if (star->Angle(fRaDec)*TMath::RadToDeg()>fRadiusFOV)
     605        {
     606            delete star;
     607            continue;
     608        }
     609
     610        fList.Add(star);
     611        add++;
     612
     613        if (fout)
     614            star->WriteBinary(*fout);
     615    }
     616
     617    gLog << inf << "Read " << add << " out of " << n << " (Total max mag=" << maxmag << ")" << endl;
     618
     619    return add;
     620}
     621
     622// --------------------------------------------------------------------------
     623//
     624// Read from a MAstroCatalog compressed catalog. set bit kHasChanged
     625// Already read data is not deleted. To delete the stored data call
     626// Delete().
     627//
     628Int_t MAstroCatalog::ReadCompressed(TString catalog)
     629{
     630    SetBit(kHasChanged);
     631
     632    gLog << inf << "Reading MAstroCatalog compressed catalog: " << catalog << endl;
     633
     634    ifstream fin(catalog);
     635    if (!fin)
     636    {
     637        gLog << err << "Cannot open catalog file " << catalog << ": ";
     638        gLog << strerror(errno) << endl;
     639        return 0;
     640    }
     641
     642    Int_t add=0;
     643    Int_t cnt=0;
     644    Int_t n  =0;
     645
     646    Double_t maxmag=0;
     647
     648    MVector3 entry;
     649
     650    while (1)
     651    {
     652        cnt++;
     653
     654        entry.ReadBinary(fin);
     655        if (!fin)
     656            break;
     657
     658        n++;
     659
     660        const Double_t mag = entry.Magnitude();
     661        maxmag = TMath::Max(maxmag, mag);
     662        if (mag>fLimMag)
     663            continue;
     664
     665        if (entry.Angle(fRaDec)*TMath::RadToDeg()>fRadiusFOV)
     666            continue;
     667
     668        fList.Add(entry.Clone());
     669        add++;
     670    }
     671
     672    gLog << inf << "Read " << add << " out of " << n << " (Total max mag=" << maxmag << ")" << endl;
     673
     674    return add;
     675}
     676
     677// --------------------------------------------------------------------------
     678//
    486679// Set Range of pad. If something has changed create and draw new primitives.
    487680// Paint all gui primitives.
     
    494687        DrawPrimitives(o);
    495688
    496     PaintMap();
     689    fMapG.Paint();
     690}
     691
     692// --------------------------------------------------------------------------
     693//
     694// Set Range of pad if pad available. If something has changed create
     695// and draw new primitives. Paint all gui primitives to the Drawable with
     696// Id id. This can be used to be able to
     697//
     698/*
     699void MAstroCatalog::PaintImg(Int_t id, Option_t *o)
     700{
     701    if (gPad)
     702        SetRangePad(o);
     703
     704    if (TestBit(kHasChanged))
     705    {
     706        if (id>0)
     707            gPad=0;
     708        DrawPrimitives(o);
     709    }
     710
     711    fMapG.Paint(id, fRadiusFOV);
     712}
     713*/
     714
     715// --------------------------------------------------------------------------
     716//
     717// Set Range of pad. If something has changed create and draw new primitives.
     718// Paint all gui primitives.
     719//
     720// Because in some kind of multi-threaded environments gPad doesn't stay
     721// the same in a single thread (because it might be changed in the same
     722// thread inside a gui updating timer for example) we have to secure the
     723// usage of gPad with a bit. This is also not multi-thread safe against
     724// calling this function, but the function should work well in multi-
     725// threaded environments. Never call this function from different threads
     726// simultaneously.
     727//
     728void MAstroCatalog::PaintImg(unsigned char *buf, int w, int h)
     729{
     730    const char * o = "local mirrorx yellow *";
     731
     732    if (TestBit(kHasChanged))
     733    {
     734        SetBit(kDrawingImage);
     735        DrawPrimitives(o);
     736        ResetBit(kDrawingImage);
     737    }
     738
     739    fMapG.Paint(buf, w, h, fRadiusFOV);
    497740}
    498741
     
    503746// x, y: Pad Coordinates to draw star
    504747// v: Sky position (Ra/Dec) of the star
    505 // transparent: Draw marker or tooltip only
     748// col: Color of marker (<0 mean transparent)
    506749// txt: additional tooltip text
    507 //
    508 void MAstroCatalog::DrawStar(Double_t x, Double_t y, const TVector3 &v, Bool_t transparent, const char *txt)
     750// resize: means resize the marker according to the magnitude
     751//
     752void MAstroCatalog::DrawStar(Double_t x, Double_t y, const TVector3 &v, Int_t col, const char *txt, Bool_t resize)
    509753{
    510754    const Double_t ra  = v.Phi()*TMath::RadToDeg()/15;
    511755    const Double_t dec = (TMath::Pi()/2-v.Theta())*TMath::RadToDeg();
    512756
    513     TString str = v.GetName();
    514     str += Form(":  Ra=%.2fh", ra);
    515     str += Form("  Dec=%.1fd", dec);
    516     str += Form("  Mag=%.1f", -2.5*log10(v.Mag()));
     757    const Double_t mag = -2.5*log10(v.Mag());
     758
     759    //MString str;
     760    //str.Print("%s:  Ra=%.2fh  Dec=%.1fd  Mag=%.1f", v.GetName(), ra, dec, mag);
     761    TString str(Form("%s:  Ra=%.2fh  Dec=%.1fd  Mag=%.1f", v.GetName(), ra, dec, mag));
    517762    if (txt)
    518         str += Form("  (%s)", txt);
     763    {
     764        str += "  (";
     765        str += txt;
     766        str += ")";
     767    }
    519768
    520769    // draw star on the camera display
    521     TMarker *tip=new TMarker(x, y, transparent ? kDot : kFullDotMedium);;
    522     tip->SetMarkerColor(kBlack);
    523     AddMap(tip, new TString(str));
     770    TMarker *tip=new TMarker(x, y, col<0 ? kDot : kFullDotMedium);;
     771    tip->SetMarkerColor(col);
     772    fMapG.Add(tip, new TString(str));
     773
     774    if (!resize)
     775        return;
     776
     777    tip->SetMarkerSize((10 - (mag>1 ? mag : 1))/15);
     778    tip->SetMarkerStyle(kCircle);
    524779}
    525780
     
    530785void MAstroCatalog::Update(Bool_t upd)
    531786{
     787    SetBit(kHasChanged);
    532788    if (gPad && TestBit(kMustCleanup))
    533789    {
    534         SetBit(kHasChanged);
    535790        gPad->Modified();
    536791        if (upd)
     
    560815    if (fObservatory)
    561816        delete fObservatory;
    562     fObservatory=(MObservatory*)obs.Clone();
     817    fObservatory=new MObservatory;
     818    obs.Copy(*fObservatory);
    563819}
    564820
     
    588844        return kERROR;
    589845
     846    if (TestBit(kDrawingImage) || !gPad)
     847        return v.Mod2()<fRadiusFOV*fRadiusFOV;
     848
    590849    return v.X()>gPad->GetX1() && v.Y()>gPad->GetY1() &&
    591850           v.X()<gPad->GetX2() && v.Y()<gPad->GetY2();
     
    612871// corresponding pad coordinates.
    613872//
    614 Bool_t MAstroCatalog::DrawLine(const TVector2 &v, Double_t dx, Double_t dy, const TRotation &rot, Int_t type)
     873Bool_t MAstroCatalog::DrawLine(const TVector2 &v, Int_t dx, Int_t dy, const TRotation &rot, Int_t type)
    615874{
    616875    const TVector2 add(dx*TMath::DegToRad(), dy*TMath::DegToRad());
    617876
    618     TVector2 v0 = v;
    619     TVector2 v1 = v+add;
     877    // Define all lines in the same direction
     878    const TVector2 va(dy==1?v:v+add);
     879    const TVector2 vb(dy==1?v+add:v);
     880
     881    TVector2 v0(va);
     882    TVector2 v1(vb);
    620883
    621884    const Int_t rc0 = Convert(rot, v0);
     
    629892    line->SetLineStyle(kDashDotted); //kDashed, kDotted, kDashDotted
    630893    line->SetLineColor(kWhite+type*2);
    631     AddMap(line);
    632 
    633     const TVector2 deg = v*TMath::RadToDeg();
    634     TString txt = type==1 ?
    635         Form("Ra=%.2fh  Dec=%.1fd", fmod(deg.X()/15+48, 24),  fmod(90-deg.Y()+270,180)-90) :
    636         Form("Zd=%.1fd  Az=%.1fd",  fmod(deg.Y()+270,180)-90, fmod(deg.X()+720, 360));
     894    fMapG.Add(line);
     895
     896    if (dx!=0)
     897        return kTRUE;
     898
     899    const TVector2 deg = va*TMath::RadToDeg();
     900    /*
     901    MString txt;
     902    if (type==1)
     903        txt.Print("Ra=%.2fh  Dec=%.1fd", fmod(deg.X()/15+48, 24),  fmod(90-deg.Y()+270,180)-90);
     904    else
     905        txt.Print("Zd=%.1fd  Az=%.1fd",  fmod(deg.Y()+270,180)-90, fmod(deg.X()+720, 360));
     906        */
     907    TString txt;
     908    if (type==1)
     909        txt = Form("Ra=%.2fh  Dec=%.1fd", fmod(deg.X()/15+48, 24),  fmod(90-deg.Y()+270,180)-90);
     910    else
     911        txt = Form("Zd=%.1fd  Az=%.1fd",  fmod(deg.Y()+270,180)-90, fmod(deg.X()+720, 360));
    637912
    638913    TMarker *tip=new TMarker(v0.X(), v0.Y(), kDot);
    639914    tip->SetMarkerColor(kWhite+type*2);
    640     AddMap(tip, new TString(txt));
     915    fMapG.Add(tip, new TString(txt));
    641916
    642917    return kTRUE;
     
    8851160// be more far away from the center than the display shows.
    8861161//
     1162// If you want the stars to be displayed as circles with a size
     1163// showing their magnitude use "*" as an option.
     1164//
     1165// Use 'white'  to display white instead of black stars
     1166// Use 'yellow' to display white instead of black stars
     1167//
    8871168//
    8881169void MAstroCatalog::AddPrimitives(TString o)
     
    8931174    const Bool_t miry   = o.Contains("mirrory", TString::kIgnoreCase);
    8941175    const Bool_t mirror = o.Contains("mirror",  TString::kIgnoreCase) && !mirx && !miry;
     1176    const Bool_t size   = o.Contains("*",       TString::kIgnoreCase);
     1177    const Bool_t white  = o.Contains("white",   TString::kIgnoreCase);
     1178    const Bool_t yellow = o.Contains("yellow",  TString::kIgnoreCase) && !white;
    8951179
    8961180    // X is vice versa, because ra is defined anti-clockwise
     
    9011185
    9021186    TIter Next(&fList);
    903     TVector3 *v=0;
    904     while ((v=(TVector3*)Next()))
    905     {
    906         // FIXME: Check Magnitude!
     1187    MVector3 *v=0;
     1188    while ((v=(MVector3*)Next()))
     1189    {
     1190        if (v->Magnitude()>fLimMag)
     1191            continue;
     1192
    9071193        TVector2 s(v->Phi(), v->Theta());
    9081194        if (Convert(rot, s)==kTRUE)
    909             DrawStar(s.X(), s.Y(), *v, kFALSE);
    910     }
    911 
    912     if (!same)
     1195            DrawStar(s.X(), s.Y(), *v, yellow?kYellow:(white?kWhite:kBlack), 0, size);
     1196    }
     1197
     1198    if (!same && !TestBit(kDrawingImage) && gPad)
    9131199    {
    9141200        TPaveText *pv = new TPaveText(0.01, 0.90, 0.63, 0.99, "brNDC");
    9151201        pv->AddText(GetPadTitle());
    916         AddMap(pv);
     1202        fMapG.Add(pv);
    9171203    }
    9181204
    9191205    TMarker *mk=new TMarker(0, 0, kMultiply);
    920     mk->SetMarkerColor(kBlack);
     1206    mk->SetMarkerColor(white||yellow?kWhite:kBlack);
    9211207    mk->SetMarkerSize(1.5);
    922     AddMap(mk);
     1208    fMapG.Add(mk);
    9231209}
    9241210
     
    9351221
    9361222    const Double_t edge = fRadiusFOV/TMath::Sqrt(2.);
    937     gPad->Range(-edge, -edge, edge, edge);
     1223    //gPad->Range(-edge, -edge, edge, edge);
    9381224
    9391225    const Float_t w = gPad->GetWw();
     
    9561242void MAstroCatalog::DrawPrimitives(Option_t *o)
    9571243{
    958     DeleteMap();
    959 
    960     SetRangePad(o);
     1244    fMapG.Delete();
     1245
     1246    if (!TestBit(kDrawingImage) && gPad)
     1247        SetRangePad(o);
    9611248
    9621249#ifdef DEBUG
     
    9711258
    9721259    // Append to a possible second pad
    973     if (!gPad->GetListOfPrimitives()->FindObject(this))
     1260    if (!TestBit(kDrawingImage) && gPad && !gPad->GetListOfPrimitives()->FindObject(this))
    9741261        AppendPad(o);
    9751262
    9761263    ResetBit(kHasChanged);
    977 }
    978 
    979 // --------------------------------------------------------------------------
    980 //
    981 // Call Paint() of all gui elements
    982 //
    983 void MAstroCatalog::PaintMap()
    984 {
    985     Long_t key, val;
    986     TExMapIter map(&fMapG);
    987     while (map.Next(key, val))
    988         ((TObject*)key)->Paint();
    9891264}
    9901265
     
    10141289// --------------------------------------------------------------------------
    10151290//
    1016 // Search for an object at px, py in fMapG. Return the pointer to it
    1017 // if found. Set str accordingly if a tooltip string is found.
    1018 //
    1019 TObject *MAstroCatalog::PickObject(Int_t px, Int_t py, TString &str) const
    1020 {
    1021     Long_t key, val;
    1022     TExMapIter map(&fMapG);
    1023     while (map.Next(key, val))
    1024     {
    1025         if (!val)
    1026             continue;
    1027 
    1028         TObject *o=(TObject*)key;
    1029         if (o->DistancetoPrimitive(px, py)>TPad::GetMaxPickDistance())
    1030             continue;
    1031 
    1032         str = *(TString*)val;
    1033         return o;
    1034     }
    1035     return NULL;
    1036 }
    1037 
    1038 // --------------------------------------------------------------------------
    1039 //
    10401291// This function was connected to all created canvases. It is used
    10411292// to redirect GetObjectInfo into our own status bar.
     
    10511302    if (!gPad)
    10521303        return;
     1304
    10531305
    10541306    // Try to find a corresponding object with kCannotPick set and
     
    10561308    TString str;
    10571309    if (!selected || selected==this)
    1058         selected = PickObject(px, py, str);
     1310        selected =  fMapG.PickObject(px, py, str);
    10591311
    10601312    if (!selected)
     
    11371389// --------------------------------------------------------------------------
    11381390//
    1139 // Calculate distance to primitive by checking all gui elements
    1140 //
    1141 Int_t MAstroCatalog::DistancetoPrimitive(Int_t px, Int_t py)
    1142 {
    1143     Int_t min = INT_MAX;
    1144 
    1145     Long_t key, val;
    1146     TExMapIter map(&fMapG);
    1147     while (map.Next(key, val))
    1148     {
    1149         TObject *o=(TObject*)key;
    1150 
    1151         const Int_t d = o->DistancetoPrimitive(px, py);
    1152 
    1153         if (d<TPad::GetMaxPickDistance())
    1154             return 0;
    1155 
    1156         if (d<min)
    1157             min=d;
    1158     }
    1159 
    1160     return min;
    1161 }
    1162 
    1163 // --------------------------------------------------------------------------
    1164 //
    11651391// Displays a tooltip
    11661392//
     
    11841410}
    11851411
     1412// --------------------------------------------------------------------------
     1413//
     1414// Calculate distance to primitive by checking all gui elements
     1415//
     1416Int_t MAstroCatalog::DistancetoPrimitive(Int_t px, Int_t py)
     1417{
     1418    return fMapG.DistancetoPrimitive(px, py);
     1419}
     1420
    11861421// ------------------------------------------------------------------------
    11871422//
     
    11911426char *MAstroCatalog::GetObjectInfo(Int_t px, Int_t py) const
    11921427{
    1193 
    1194     TString str;
    1195     PickObject(px, py, str);
    1196 
    1197     static char txt[129];
    1198     txt[128]=0;
    1199 
    1200     return strncpy(txt, str.Data(), 128);
    1201 }
    1202 
    1203 
    1204 /*
    1205 void MAstroCatalog::RecursiveRemove(TObject *obj)
    1206 {
    1207     ULong_t hash;
    1208     Long_t key, val;
    1209 
    1210     TExMapIter map(&fMapG);
    1211     while (map.Next(hash, key, val))
    1212     {
    1213         if (key != (Long_t)obj)
    1214             continue;
    1215 
    1216         fMapG.Remove(hash, key);
    1217         delete (TObject*)(key);
    1218         if (val)
    1219             delete (TString*)(val);
    1220         break;
    1221     }
    1222 }
    1223 */
     1428    return fMapG.GetObjectInfo(px, py);
     1429}
  • trunk/MagicSoft/Mars/mastro/MAstroCatalog.h

    r3959 r4058  
    55#include <TVector3.h>
    66#endif
    7 #ifndef ROOT_TExMap
    8 #include <TExMap.h>
    9 #endif
    107#ifndef ROOT_TList
    118#include <TList.h>
     9#endif
     10#ifndef MARS_MGMap
     11#include <MGMap.h>
    1212#endif
    1313
     
    5757    const char *GetName() const { return fName; }
    5858
     59    void WriteBinary(ostream &out) const;
     60    void ReadBinary(istream &in);
     61
    5962    ClassDef(MVector3, 1) // A specialized TVector3 storeing a star-name
    6063};
     
    6669    Double_t   fRadiusFOV; // [deg] Radius of Field of View
    6770
    68     TExMap     fMapG;      //! A map with all gui primitives and tooltips
    6971    TGToolTip *fToolTip;   //! The tooltip currently displayed
    7072
     
    8082//#if ROOT_VERSION_CODE < ROOT_VERSION(4,00,03)
    8183    Bool_t fPlainScreen;  //! Just a dummy!!!! ([Set,Is]Freezed)
     84    Bool_t fNoToolTips;   //! Just a dummy!!!! ([Set,Is]Freezed)
    8285//#endif
    8386
     
    8689    virtual void  SetRangePad(Option_t *o);
    8790
    88     Int_t     Convert(const TRotation &rot, TVector2 &v) const;
    89     void      Draw(const TVector2 &v0, const TRotation &rot, TArrayI &dx, TArrayI &dy, Int_t stepx, Int_t stepy, Int_t type);
    90     void      DrawPrimitives(Option_t *o);
    91     Bool_t    DrawLine(const TVector2 &v0, Double_t dx, Double_t dy, const TRotation &rot, Int_t type);
    92     void      DrawGrid(const TVector3 &v0, const TRotation &rot, Int_t type);
    93     void      Paint(Option_t *o="");
    94     Int_t     DistancetoPrimitive(Int_t px, Int_t py);
    95     //void      RecursiveRemove(TObject *obj);
    96     void      PaintMap();
    97     void      DeleteMap()
    98     {
    99         Long_t key, val;
    100         TExMapIter map(&fMapG);
    101         while (map.Next(key, val))
    102         {
    103             delete (TObject*)(key);
    104             if (!val)
    105                 continue;
    106 
    107             delete (TString*)(val);
    108             /*
    109               Long_t key2, val2;
    110               TExMapIter map2(&fMapG);
    111               while (map2.Next(key2, val2))
    112                   if (val==val2)
    113                   {
    114                       delete (TObject*)key;
    115                       fMapG.Remove(key);
    116                   }
    117              */
    118         }
    119         fMapG.Delete();
    120     }
     91    Int_t  Convert(const TRotation &rot, TVector2 &v) const;
     92    void   Draw(const TVector2 &v0, const TRotation &rot, TArrayI &dx, TArrayI &dy, Int_t stepx, Int_t stepy, Int_t type);
     93    void   DrawPrimitives(Option_t *o);
     94    Bool_t DrawLine(const TVector2 &v0, Int_t dx, Int_t dy, const TRotation &rot, Int_t type);
     95    void   DrawGrid(const TVector3 &v0, const TRotation &rot, Int_t type);
     96    void   Paint(Option_t *o="");
     97    Int_t  DistancetoPrimitive(Int_t px, Int_t py);
    12198
    12299protected:
    123100    enum {
    124         kHasChanged  = BIT(15), // Display has changed
    125         kGuiActive   = BIT(16), // GUI is interactive
    126         kPlainScreen = BIT(17), // View is a plain screen view
    127         kMirrorX     = BIT(18), // Mirror display in X
    128         kMirrorY     = BIT(19), // Mirror display in Y
    129         kNoToolTips  = BIT(20)  // suppress tooltips
     101        kHasChanged   = BIT(15), // Display has changed
     102        kGuiActive    = BIT(16), // GUI is interactive
     103        kPlainScreen  = BIT(17), // View is a plain screen view
     104        kMirrorX      = BIT(18), // Mirror display in X
     105        kMirrorY      = BIT(19), // Mirror display in Y
     106        kNoToolTips   = BIT(20), // suppress tooltips
     107        kDrawingImage = BIT(21)  // just drawing into a bitmap
    130108    };
    131109
    132     TList    fList;             // List of stars loaded
    133     MVector3 fRaDec;            // pointing position
     110    MGMap    fMapG;              //! A map with all gui primitives and tooltips
    134111
    135     MObservatory *fObservatory; // Possible obervatory location
    136     MTime        *fTime;        // Possible observation time
     112    TList    fList;              // List of stars loaded
     113    MVector3 fRaDec;             // pointing position
     114
     115    MObservatory *fObservatory;  // Possible obervatory location
     116    MTime        *fTime;         // Possible observation time
    137117
    138118    TRotation AlignCoordinates(const TVector3 &v) const;
    139119    virtual TString GetPadTitle() const;
    140120    TRotation GetGrid(Bool_t local);
    141     void      DrawStar(Double_t x, Double_t y, const TVector3 &v, Bool_t t, const char *txt=0);
     121    void      DrawStar(Double_t x, Double_t y, const TVector3 &v, Int_t col, const char *txt=0, Bool_t resize=kFALSE);
    142122    void      Update(Bool_t upd=kFALSE);
    143123
    144124    void      ExecuteEventKbd(Int_t keycode, Int_t keysym);
    145125    void      ExecuteEvent(Int_t event, Int_t mp1, Int_t mp2);
    146     TObject  *PickObject(Int_t px, Int_t py, TString &str) const;
    147126    char     *GetObjectInfo(Int_t px, Int_t py) const;
    148 
    149     void AddMap(TObject *k, void *v=0)
    150     {
    151         fMapG.Add(fMapG.GetSize(), (Long_t)k, (Long_t)v);
    152     }
    153127
    154128public:
     
    172146        Update();
    173147    } // *MENU* *ARGS={deg=>fRadiusFOV}
     148    void SetRadiusFOV(Double_t pixsize, Double_t w, Double_t h)
     149    {
     150        // pixsize [arcsec/pixel]
     151        // w       [pixel]
     152        // h       [pixel]
     153        const Double_t scale = TMath::Hypot(w, h)/2;
     154        SetRadiusFOV(scale*pixsize/3600);
     155    } // Set Radius of FOV using the pixsize [arcsec/pix], width and height [pixel] of image
     156
    174157    void SetRaDec(Double_t ra, Double_t dec) { fRaDec.SetRaDec(ra, dec, 1); Update(); }
    175158    void SetRaDec(const TVector3 &v)         { fRaDec=v; Update(); }
     
    185168    Double_t GetRadiusFOV() const { return fRadiusFOV; } // Get maximum radius of Field Of View
    186169
    187     void Delete(Option_t *o="") { fList.Delete(); DeleteMap(); } // Delete list of stars
     170    void Delete(Option_t *o="") { fList.Delete(); fMapG.Delete(); } // Delete list of stars
    188171
    189172    Int_t ReadXephem(TString catalog = "/usr/X11R6/lib/xephem/catalogs/YBS.edb");
    190173    Int_t ReadNGC2000(TString catalog = "ngc2000.dat");
    191174    Int_t ReadBSC(TString catalog = "bsc5.dat");
     175    Int_t ReadHeasarcPPM(TString catalog = "heasarc_ppm.tdat", TString fout="");
     176    Int_t ReadCompressed(TString catalog);
    192177
    193178    void Print(Option_t *o="") const { fList.Print(); } // Print all stars
     
    195180    TList *GetList() { return &fList; } // Return list of stars
    196181
     182    //void PaintImg(Int_t id=0, Option_t *o="");
     183    void PaintImg(unsigned char *buf, int w=768, int h=576);
    197184    void Draw(Option_t *o="");
    198185    void SetDrawOption(Option_t *option="")
Note: See TracChangeset for help on using the changeset viewer.