Ignore:
Timestamp:
08/05/05 18:13:49 (19 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mastro
Files:
2 edited

Legend:

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

    r7181 r7264  
    1717!
    1818!   Author(s): Thomas Bretz, 03/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
    19 !   Author(s): Robert Wagner, 08/2004 <mailto:rwagner@mppmu.mpg.de>
    2019!
    21 !   Copyright: MAGIC Software Development, 2002-2004
     20!   Copyright: MAGIC Software Development, 2002-2005
    2221!
    2322!
     
    121120//     http://heasarc.gsfc.nasa.gov/W3Browse/star-catalog/
    122121//
     122//  Class Version 2:
     123//    + MAttLine fAttLineSky;    // Line Style and color for sky coordinates
     124//    + MAttLine fAttLineLocal;  // Line Style and color for local coordinates
     125//    + added new base class TAttMarker
     126//
    123127//////////////////////////////////////////////////////////////////////////////
    124128#include "MAstroCatalog.h"
     
    154158#endif
    155159
     160ClassImp(MAttLine);
    156161ClassImp(MAstroCatalog);
    157162
     
    170175
    171176    fToolTip = gROOT->IsBatch() || !gClient ? 0 : new TGToolTip(0, "", 0);
     177
     178    fAttLineSky.SetLineStyle(kDashDotted);
     179    fAttLineLocal.SetLineStyle(kDashDotted);
     180
     181    fAttLineSky.SetLineColor(kRed);
     182    fAttLineLocal.SetLineColor(kBlue);
     183
     184    SetMarkerColor(kBlack);
     185    SetMarkerStyle(kCircle);
    172186}
    173187
     
    221235// --------------------------------------------------------------------------
    222236//
    223 // return int correspoding to TSubString
    224 //
    225 Int_t MAstroCatalog::atoi(const TSubString &sub)
    226 {
    227     return atoi(TString(sub));
    228 }
    229 
    230 // --------------------------------------------------------------------------
    231 //
    232 // return float correspoding to TSubString
    233 //
    234 Float_t MAstroCatalog::atof(const TSubString &sub)
    235 {
    236     return atof(TString(sub));
    237 }
    238 
    239 // --------------------------------------------------------------------------
    240 //
    241237// return int correspoding to TString
    242238//
    243239Int_t MAstroCatalog::atoi(const TString &s)
    244240{
    245     return std::atoi(s);
     241    return const_cast<TString&>(s).Atoi();
    246242}
    247243
     
    252248Float_t MAstroCatalog::atof(const TString &s)
    253249{
    254     return std::atof(s);
     250    return const_cast<TString&>(s).Atof();
    255251}
    256252
     
    678674{
    679675    if (gPad)
    680         SetRangePad(o);
     676        SetRangePad(o);
    681677
    682678    if (TestBit(kHasChanged))
     
    748744
    749745    // draw star on the camera display
    750     TMarker *tip=new TMarker(x, y, col<0 ? kDot : kFullDotMedium);;
    751     tip->SetMarkerColor(col);
     746    TMarker *tip=new TMarker(x, y, kDot);
     747    TAttMarker::Copy(*tip);
     748
    752749    fMapG.Add(tip, new TString(str));
    753750
    754     if (!resize)
    755         return;
    756 
    757     tip->SetMarkerSize((10 - (mag>1 ? mag : 1))/15);
    758     tip->SetMarkerStyle(kCircle);
     751    if (resize)
     752        tip->SetMarkerSize((10 - (mag>1 ? mag : 1))/15);
    759753}
    760754
     
    870864
    871865    TLine *line = new TLine(v0.X(), v0.Y(), v1.X(), v1.Y());
    872     line->SetLineStyle(kDashDotted); //kDashed, kDotted, kDashDotted
    873     line->SetLineColor(kWhite+type*2);
     866    if (type==1)
     867        dynamic_cast<TAttLine&>(fAttLineSky).Copy(dynamic_cast<TAttLine&>(*line));
     868    else
     869        dynamic_cast<TAttLine&>(fAttLineLocal).Copy(dynamic_cast<TAttLine&>(*line));
    874870    fMapG.Add(line);
    875871
     
    11521148    const Bool_t yellow = o.Contains("yellow",  TString::kIgnoreCase) && !white;
    11531149
     1150    if (white)
     1151        SetMarkerColor(kWhite);
     1152
    11541153    // X is vice versa, because ra is defined anti-clockwise
    11551154    mirx || mirror ? ResetBit(kMirrorX) : SetBit(kMirrorX);
     
    12081207// --------------------------------------------------------------------------
    12091208//
    1210 // First delete all gui elements.
    1211 // Set the correct range of the pad.
    1212 // Create all gui primitives
    1213 // If "this" is not in the current pad add it to the current pad.
    1214 // Reset vit kHasChanged
    1215 //
     1209// Bends some pointers into the right direction...
     1210// Calls TAttLine::SetLineAttributes and connects some signals
     1211// to the gui to recreate the gui elements if something has changed.
     1212//
     1213void MAstroCatalog::SetLineAttributes(MAttLine &att)
     1214{
     1215    if (!gPad)
     1216        return;
     1217
     1218    gPad->SetSelected(&att);
     1219    gROOT->SetSelectedPrimitive(&att);
     1220
     1221    att.SetLineAttributes();
     1222
     1223    TQObject::Connect("TGColorSelect", "ColorSelected(Pixel_t)", "MAstroCatalog", this, "ForceUpdate()");
     1224    TQObject::Connect("TGListBox",     "Selected(Int_t)",        "MAstroCatalog", this, "ForceUpdate()");
     1225}
     1226
     1227// --------------------------------------------------------------------------
     1228//
     1229// Calls TAttMarker::SetMarkerAttributes and connects some signals
     1230// to the gui to recreate the gui elements if something has changed.
     1231//
     1232void MAstroCatalog::SetMarkerAttributes()
     1233{
     1234    if (!gPad)
     1235        return;
     1236
     1237    TAttMarker::SetMarkerAttributes();
     1238
     1239    // Make sure that if something is changed the gui elements
     1240    // are recreated
     1241    TQObject::Connect("TGedMarkerSelect", "MarkerSelected(Style_t)", "MAstroCatalog", this, "ForceUpdate()");
     1242    TQObject::Connect("TGColorSelect",    "ColorSelected(Pixel_t)",  "MAstroCatalog", this, "ForceUpdate()");
     1243    TQObject::Connect("TGListBox",        "Selected(Int_t)",         "MAstroCatalog", this, "ForceUpdate()");
     1244}
     1245
    12161246void MAstroCatalog::DrawPrimitives(Option_t *o)
    12171247{
  • trunk/MagicSoft/Mars/mastro/MAstroCatalog.h

    r4977 r7264  
    77#ifndef ROOT_TList
    88#include <TList.h>
     9#endif
     10#ifndef ROOT_TAttLine
     11#include <TAttLine.h>
     12#endif
     13#ifndef ROOT_TAttMarker
     14#include <TAttMarker.h>
    915#endif
    1016#ifndef MARS_MGMap
     
    1723class TGToolTip;
    1824
    19 class MAstroCatalog : public TObject
     25class MAttLine : public TObject, public TAttLine
     26{
     27public:
     28    MAttLine() { }
     29    ClassDef(MAttLine, 1) // Helper class to have a TAttLine derving from TObject (for standalone GED editor)
     30};
     31
     32class MAstroCatalog : public TObject, public TAttMarker
    2033{
    2134private:
    22     Double_t   fLimMag;    // [1]   Limiting Magnitude
    23     Double_t   fRadiusFOV; // [deg] Radius of Field of View
     35    Double_t   fLimMag;     // [1]   Limiting Magnitude
     36    Double_t   fRadiusFOV;  // [deg] Radius of Field of View
    2437
    25     TGToolTip *fToolTip;   //! The tooltip currently displayed
     38    TGToolTip *fToolTip;    //! The tooltip currently displayed
     39
     40    MAttLine fAttLineSky;   // Line Style and color for sky coordinates
     41    MAttLine fAttLineLocal; // Line Style and color for local coordinates
    2642
    2743    void ShowToolTip(Int_t px, Int_t py, const char *txt);
     44    void SetLineAttributes(MAttLine &att);
    2845
    2946    TString FindToken(TString &line, Char_t tok=',');
    3047
    31     Int_t   atoi(const TSubString &sub);
    32     Float_t atof(const TSubString &sub);
    3348    Int_t   atoi(const TString &s);
    3449    Float_t atof(const TString &s);
    3550
    3651//#if ROOT_VERSION_CODE < ROOT_VERSION(4,00,03)
    37     Bool_t fPlainScreen;  //! Just a dummy!!!! ([Set,Is]Freezed)
    38     Bool_t fNoToolTips;   //! Just a dummy!!!! ([Set,Is]Freezed)
     52//    Bool_t fPlainScreen;  //! Just a dummy!!!! ([Set,Is]Freezed)
     53//    Bool_t fNoToolTips;   //! Just a dummy!!!! ([Set,Is]Freezed)
    3954//#endif
    4055
     
    8499    ~MAstroCatalog();
    85100
     101    void ForceUpdate() { Update(kTRUE); } // Slot for marker handling
     102
     103    // Setter to control the sky position and behaviour
    86104    void SetTime(const MTime &time);
    87105    void SetObservatory(const MObservatory &obs);
     
    109127    } // Set Radius of FOV using the pixsize [arcsec/pix], width and height [pixel] of image
    110128
    111     void SetRaDec(Double_t ra, Double_t dec) { fRaDec.SetRaDec(ra, dec, 1); Update(); }
    112     void SetRaDec(const TVector3 &v)         { fRaDec=v; Update(); }
    113     void SetGuiActive(Bool_t b=kTRUE)        { b ? SetBit(kGuiActive) : ResetBit(kGuiActive); }
     129    void     SetRaDec(Double_t ra, Double_t dec) { fRaDec.SetRaDec(ra, dec, 1); Update(); }
     130    void     SetRaDec(const TVector3 &v)         { fRaDec=v; Update(); }
     131    void     SetGuiActive(Bool_t b=kTRUE)        { b ? SetBit(kGuiActive) : ResetBit(kGuiActive); }
    114132
    115     void   SetPlainScreen(Bool_t b=kTRUE)    { b ? SetBit(kPlainScreen) : ResetBit(kPlainScreen); Update(); } // *TOGGLE* *GETTER=IsPlainScreen
    116     Bool_t IsPlainScreen() const             { return TestBit(kPlainScreen); }
     133    void     SetPlainScreen(Bool_t b=kTRUE)    { b ? SetBit(kPlainScreen) : ResetBit(kPlainScreen); Update(); } // *TOGGLE* *GETTER=IsPlainScreen
     134    Bool_t   IsPlainScreen() const             { return TestBit(kPlainScreen); }
    117135
    118     void   SetNoToolTips(Bool_t b=kTRUE)     { b ? SetBit(kNoToolTips) : ResetBit(kNoToolTips); } // *TOGGLE* *GETTER=HasNoToolTips
    119     Bool_t HasNoToolTips() const             { return TestBit(kNoToolTips); }
     136    void     SetNoToolTips(Bool_t b=kTRUE)     { b ? SetBit(kNoToolTips) : ResetBit(kNoToolTips); } // *TOGGLE* *GETTER=HasNoToolTips
     137    Bool_t   HasNoToolTips() const             { return TestBit(kNoToolTips); }
    120138
    121139    Double_t GetLimMag() const { return fLimMag; } // Get Limiting Magnitude
    122140    Double_t GetRadiusFOV() const { return fRadiusFOV; } // Get maximum radius of Field Of View
    123141
    124     void Delete(Option_t *o="") { fList.Delete(); fMapG.Delete(); } // Delete list of stars
    125 
    126     Int_t ReadXephem(TString catalog = "/usr/X11R6/lib/xephem/catalogs/YBS.edb");
    127     Int_t ReadNGC2000(TString catalog = "ngc2000.dat");
    128     Int_t ReadBSC(TString catalog = "bsc5.dat");
    129     Int_t ReadHeasarcPPM(TString catalog = "heasarc_ppm.tdat", TString fout="");
    130     Int_t ReadCompressed(TString catalog);
     142    // Interface to set stars
     143    Int_t  ReadXephem(TString catalog = "/usr/X11R6/lib/xephem/catalogs/YBS.edb");
     144    Int_t  ReadNGC2000(TString catalog = "ngc2000.dat");
     145    Int_t  ReadBSC(TString catalog = "bsc5.dat");
     146    Int_t  ReadHeasarcPPM(TString catalog = "heasarc_ppm.tdat", TString fout="");
     147    Int_t  ReadCompressed(TString catalog);
    131148    Bool_t AddObject(Float_t ra, Float_t dec, Float_t mag, TString name="");
    132149
    133     void Print(Option_t *o="") const { fList.Print(); } // Print all stars
    134 
     150    // Interface to get stars
    135151    TList *GetList() { return &fList; } // Return list of stars
    136152
    137     //void PaintImg(Int_t id=0, Option_t *o="");
    138     void PaintImg(unsigned char *buf, int w=768, int h=576, Option_t *o=0);
     153    // TObject
     154    void Delete(Option_t *o="") { fList.Delete(); fMapG.Delete(); } // Delete list of stars
     155    void Print(Option_t *o="") const { fList.Print(); } // Print all stars
    139156    void Draw(Option_t *o="");
    140157    void SetDrawOption(Option_t *option="")
     
    144161    } //*MENU*
    145162
     163    // Interface to Cosy
     164    void PaintImg(unsigned char *buf, int w=768, int h=576, Option_t *o=0);
     165
     166    // Interface to line styles
     167    void SetLineAttributesLocal() { SetLineAttributes(fAttLineLocal); } //*MENU*
     168    void SetLineAttributesSky()   { SetLineAttributes(fAttLineSky);   } //*MENU*
     169    void SetMarkerAttributes();   //*MENU*
     170
    146171    virtual void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected=0);
    147172
    148     ClassDef(MAstroCatalog, 1) // Display class for star catalogs
     173    ClassDef(MAstroCatalog, 2) // Display class for star catalogs
    149174};
    150175
Note: See TracChangeset for help on using the changeset viewer.