//------------------------------------------------------------------------------ // gso_Map2D class -- // (C) Piero Giubilato 2008-2010, Berkeley Lab -- //------------------------------------------------------------------------------ //______________________________________________________________________________ // {Trace} // [File name] "gso_Map2D.h" // [Author] "Piero Giubilato" // [Version] "1.5" // [Modified by] "Piero Giubilato" // [Last revision] "04 Jul 2009" // [Language] "C++" // [Compiler] "Visual C++ 9.x" // [Member of] "Cool SEAL" // [Project] "SEAL" // [Description] "Header for the gso_Map2D class" // [Key documentation] // "Visual C++ Reference Help" // "Root reference guide" // {Trace} //______________________________________________________________________________ // Overloading check #if !defined gso_Map2D_H #define gso_Map2D_H // Standard components #include // Root components #include #include #include #include // Application components #include "data_Layer.h" #include "gso_Frame.h" #include "gso_Palette.h" // Label structure struct lbl_Item { TGString text; Int_t left; Int_t top; UInt_t side; }; // Map2D Object class gso_Map2D: public gso_Frame { private: // Enums static enum k_data_Type {kdt_Null, kdt_UShort, kdt_Short, kdt_UInt, kdt_Int, kdt_Float, kdt_Double}; static enum k_mouse_Mode {kmm_Out, kmm_None, kmm_Start, kmm_Square, kmm_Drag, kmm_Zoom, kmm_Data}; static enum k_mouse_data {kmd_None, kmd_Point}; // Constants static const UInt_t ruler_Size = 18; static const UInt_t grid_step_Min = 16; static const UInt_t grid_Color = 0x777777; static const UInt_t ruler_backColor = 0xFFFFFF; static const UInt_t ruler_textColor = 0x000000; static const UInt_t ruler_maj_tick_Size = 12; static const UInt_t ruler_min_tick_Size = 4; static const UInt_t ruler_maj_step_Min = 48; static const UInt_t ruler_min_step_Min = 8; // Default font (must be a static constant) static const TGFont* text_font_Default;// The deafult font // Graphic Context for ruler drawing GContext_t ruler_gc_Hnd; // The graphic context used to write text into the frame GCValues_t ruler_gc_Set; // The graphic context parameters TGFont* ruler_Font; // The font used to write // Graphic Contex for XOR drawing GContext_t xor_gc_Hnd; // The graphic context used to write text into the frame GCValues_t xor_gc_Set; // The graphic context parameters TGFont* xor_Font; // The font used for the xor drawing // Graphic Contex for flyer drawing GContext_t flyer_gc_Hnd; // The graphic context used to write text into the frame GCValues_t flyer_gc_Set; // The graphic context parameters TGFont* flyer_Font; // The font used for the flyer drawing // Data representation elements Pixmap_t img_PxMap; // The virtual image of the whole data image at 1:1 zoom Pixmap_t map_PxMap; // The current view image UInt_t* map_Array; // The pivot array (ARGB array) UInt_t data_Mode; UInt_t data_draw_Style; // The data representation style UInt_t data_Width; UInt_t data_Height; // Data reference (2D array) const UShort_t* data_US; const Short_t* data_S; const UInt_t* data_UI; const Int_t* data_I; const Float_t* data_F; const Double_t* data_D; Double_t* data_Local; // Not used at the moment //inline Double_t data_Point(UInt_t i) const {return (Double_t();}; // Rulers elements Pixmap_t rulH_PxMap; // The horizontal ruler UInt_t* rulH_Array; // The pivot array (ARGB array) Pixmap_t rulV_PxMap; // The vertical ruler UInt_t* rulV_Array; // The pivot array (ARGB array) // The linked palette gso_Palette* palette; // The palette range use Double_t pal_range_Max; Double_t pal_range_Min; Double_t pal_rs_Max; Double_t pal_rs_Min; Float_t pal_rel_Start; Float_t pal_rel_Stop; bool pal_range_Auto; bool pal_range_Update; // True if range has changed // The data range auto for plot and histo //Double_t data_range_Max; //Double_t data_range_Min; //bool data_range_Auto; //bool data_range_Update; // Labels elements std::vector lbl_List; // The labels void txt_Layout(TGString* txt_String, TGTextLayout** layout, UInt_t* width, UInt_t* height); // ROI elements Double_t roi_Left, roi_start_Left, roi_old_Left; Double_t roi_Top, roi_start_Top, roi_old_Top; Double_t roi_Width, roi_start_Width, roi_old_Width; Double_t roi_Height, roi_start_Height, roi_old_Height; bool roi_Update; // True if Roi has changed // Mouse elements Int_t mouse_curr_X, mouse_start_X, mouse_old_X; Int_t mouse_curr_Y, mouse_start_Y, mouse_old_Y; Int_t mouse_start_B, mouse_old_B; TString mouse_data_String; Pixmap_t mouse_flyer_Map; UInt_t* mouse_flyer_Array; Int_t mouse_flyer_oX, mouse_flyer_oY; Int_t mouse_flyer_oLeft, mouse_flyer_oTop; Int_t mouse_flyer_oWidth, mouse_flyer_oHeight; bool mouse_flyer_Drawn; Int_t mouse_curr_Mode, mouse_old_Mode; Int_t mouse_data_Mode; bool mouse_to_data_XY(Int_t mX, Int_t mY, Double_t& dX, Double_t& dY); // Data void data_Init(UInt_t d_Width, UInt_t d_Height); void data_Copy(); // Drawing void Draw(); // Draw all void Draw(Double_t rLeft, Double_t rTop, Double_t rWidth, Double_t rHeight); // Draw ROI void data_Draw(Double_t rLeft, Double_t rTop, Double_t rWidth, Double_t rHeight); // Creates the map PxMap void data_Image(); // Creates the whole dataset image PxMap template void rtw_Map(const U* data, UInt_t dW, UInt_t dH, bool dAR, Double_t rL, Double_t rT, Double_t rW, Double_t rH); template void wdi_Map(const U* data, UInt_t dW, UInt_t dH); template void rtw_Plot(const U* data, UInt_t dW, UInt_t dH, bool dAR, Double_t rL, Double_t rT, Double_t rW, Double_t rH); template void wdi_Plot(const U* data, UInt_t dW, UInt_t dH); void ruler_Draw(Double_t rL, Double_t rT, Double_t rW, Double_t rH); void label_Draw(); void mouse_flyer_Draw(Int_t left, Int_t top, TString* str); // Timer-related UInt_t data_refresh_ID; TTimer* refresh_Timer; // Special private memebers gso_Map2D(const gso_Map2D&) {} const gso_Map2D& operator=(const gso_Map2D&) {return *this;} protected: void DoRedraw(); // Paints the whole frame (including data and rulers) void DoRedraw_Data(); // Paints the data PxMap only void DoRedraw_Rulers(); // Paints the rulers PxMaps only public: // Data representation style static enum k_Style {ks_Map, ks_Plot, ks_Histo}; // Default methods gso_Map2D(const TGWindow* window, gso_Palette* pal, UInt_t width = 1, UInt_t height = 1, UInt_t bvl_Size = 0, Float_t bvl_Thick = 1, UInt_t textColor = 0, UInt_t foreColor = 0x777777, UInt_t backColor = 0); ~gso_Map2D(); // Events void Event(Event_t* evn); // Assign data link void data_Set(const UShort_t* data, UInt_t data_Width, UInt_t data_Height); void data_Set(const Short_t* data, UInt_t data_Width, UInt_t data_Height); void data_Set(const UInt_t* data, UInt_t data_Width, UInt_t data_Height); void data_Set(const Int_t* data, UInt_t data_Width, UInt_t data_Height); void data_Set(const Float_t* data, UInt_t data_Width, UInt_t data_Height); void data_Set(const Double_t* data, UInt_t data_Width, UInt_t data_Height); // Keep ROOTCInt out of this! #ifndef __CINT__ // Assign layer link void data_Set(const data_Layer* layer); void data_Set(const data_Layer* layer); void data_Set(const data_Layer* layer); void data_Set(const data_Layer* layer); void data_Set(const data_Layer* layer); void data_Set(const data_Layer* layer); // Overloading check #endif // Data methods const Pixmap_t data_PxMap(bool whole = false); void data_Style(UInt_t dStyle); UInt_t data_Style() const {return data_draw_Style;}; void data_Refresh(); void data_Refresh(Double_t r_Left, Double_t r_Top, Double_t r_Width, Double_t r_Height); void data_Refresh(bool x_Fit, bool y_Fit, bool oto_Fit = false, bool px_Fit = false); void data_refresh_Auto(UInt_t interval); Double_t data_Value(UInt_t x, UInt_t y) const; UInt_t data_size_X() const {return data_Width;}; UInt_t data_size_Y() const {return data_Height;}; // Data ROI Double_t data_roi_Left() {return roi_Left;}; Double_t data_roi_Top() {return roi_Top;}; Double_t data_roi_Width() {return roi_Width;}; Double_t data_roi_Height() {return roi_Height;}; // gso_Frame overloaded methods void SetFont(const char *fontName, Int_t size, Int_t weight = 0, Int_t slant = 0); void SetFont(const char *fontName, Bool_t global); void SetFont(FontStruct_t font, Bool_t global); void SetTextColor(Pixel_t color); void MoveResize(Int_t left, Int_t top, UInt_t width, UInt_t height); void Resize(UInt_t left, UInt_t top); void Resize(TGDimension size) {Resize(size.fWidth, size.fHeight);}; // Range void range_Set(Double_t max, Double_t min); void range_Get(const Double_t* max, const Double_t* min) const; bool range_Auto() const; void range_Auto(bool automatic); Double_t range_Max() const; void range_Max(Double_t max); Double_t range_Min() const; void range_Min(Double_t min); // Palette slots void pal_updated_Do(); void pal_start_Do(Float_t); void pal_shift_Do(Float_t); void pal_scale_Do(Float_t); void pal_stop_Do(Float_t); // Signals (Be aware that here the comment is MANDATORY!) virtual void opt_Clicked() {Emit("opt_Clicked()");} // *SIGNAL* virtual void roi_Updated() {Emit("roi_Updated()");} // *SIGNAL* virtual void range_Updated() {Emit("range_Updated()");} // *SIGNAL* virtual void style_Updated() {Emit("style_Updated()");} // *SIGNAL* virtual void data_Updated() {Emit("data_Updated()");} // *SIGNAL* virtual void data_Changed() {Emit("data_Changed()");} // *SIGNAL* //virtual void Released() {Emit("Released()");} // *SIGNAL* //virtual void Clicked() {Emit("Clicked()");} // *SIGNAL* // Cint preprocessor token ClassDef(gso_Map2D, 2) }; // End of Overloading check #endif