//------------------------------------------------------------------------------ // gui_Movie class -- // (C) Piero Giubilato 2008-2010, Berkeley Lab -- //------------------------------------------------------------------------------ //______________________________________________________________________________ // {Trace} // [File name] "gui_Movie.cpp" // [Author] "Piero Giubilato" // [Version] "0.5" // [Modified by] "Piero Giubilato" // [Last revision] "20 Jul 2009" // [Language] "C++" // [Compiler] "Visual C++ 9.x" // [Member of] "Cool SEAL" // [Project] "SEAL" // [Description] "Source for the gui_Movie class" // [Key documentation] // "Visual C++ Reference Help" // "Root reference guide" // {Trace} //______________________________________________________________________________ // Standard component #include // Root Component #include #include #include // Application component #include "cool.h" #include "global.h" #include "gui_Movie.h" // CINT Preprocessor class import definition ClassImp(gui_Movie) // ********************** // Object special methods // ********************** //______________________________________________________________________________ gui_Movie::gui_Movie(gui_2D* map, UInt_t left, UInt_t top, UInt_t width, UInt_t height, UInt_t textColor): gui_Object(0) { // Default, no data constructor dbg_Print("gui_Movie::gui_Movie:(default)", DBG_LVL_ZERO); // Sets up the map Init(map, left, top, width, height, textColor); } //______________________________________________________________________________ gui_Movie::gui_Movie(gui_Object* parent, gui_2D* map, UInt_t left, UInt_t top, UInt_t width, UInt_t height, UInt_t textColor): gui_Object(parent) { // Parent constructor dbg_Print("gui_Movie::gui_Movie:(gui_Object*)", DBG_LVL_ZERO); // Sets up the object Init(map, left, top, width, height, textColor); } //______________________________________________________________________________ void gui_Movie::Init(gui_2D* map, UInt_t left, UInt_t top, UInt_t width, UInt_t height, UInt_t textColor) { // Common init procedure dbg_Print("gui_Movie::Init:(default)", DBG_LVL_ZERO); // Ks k_ctrl_Border = 8; // Space between controls k_btn_Size = 24; // Accessory buttons k_btn_Radius = 6; // Accessory buttons radius k_btn_Depth = 1; // Accessory buttons depth k_btn_Color = cool::Gui->kc_gray_Dark; // Accessory buttons color // No data data_Type = kdt_Null; // Linked map map_View = map; // Create the control buttons // Left btn_Ctrl.push_back(new gso_Button(Parent()->Window(), "<", k_btn_Size , k_btn_Size, gso_Button::km_Button, cool::Gui->kc_White, k_btn_Color, Parent()->backColor(), (Float_t)k_btn_Radius, (Float_t)k_btn_Depth)); Parent()->Window()->AddFrame(btn_Ctrl.back(), new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); btn_Ctrl.back()->Connect(btn_Ctrl.back(), "Clicked()", "gui_Movie", this, "btn_ctrl_Do(Long_t)"); // Right btn_Ctrl.push_back(new gso_Button(Parent()->Window(), ">", k_btn_Size , k_btn_Size, gso_Button::km_Button, cool::Gui->kc_White, k_btn_Color, Parent()->backColor(), (Float_t)k_btn_Radius, (Float_t)k_btn_Depth)); Parent()->Window()->AddFrame(btn_Ctrl.back(), new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); btn_Ctrl.back()->Connect(btn_Ctrl.back(), "Clicked()", "gui_Movie", this, "btn_ctrl_Do(Long_t)"); // Creates the ctrl menu mnu_Ctrl = new TGPopupMenu(); mnu_Ctrl->AddEntry("a...", 0); mnu_Ctrl->AddEntry("b...", 1); mnu_Ctrl->AddSeparator(); mnu_Ctrl->AddEntry("c...", 2); mnu_Ctrl->Connect(mnu_Ctrl, "Activated(Int_t)", "gui_Movie", this, "mnu_ctrl_Do(Int_t)"); // Creates the numeric num_Ctrl.push_back(new TGNumberEntry(Parent()->Window(), 0)); Parent()->Window()->AddFrame(num_Ctrl.back(), new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); num_Ctrl.back()->Connect(num_Ctrl.back(), "ValueSet(Long_t)", "gui_Movie", this, "num_ctrl_Do(Long_t)"); num_Ctrl.back()->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, 1); // Creates the slider sld_Frame = new TGHSlider(Parent()->Window()); Parent()->Window()->AddFrame(sld_Frame, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); sld_Frame->Connect(sld_Frame, "PositionChanged(Int_t)", "gui_Movie", this, "sld_frame_Do(Int_t)"); // Defines the object as transparent gui_Object::obj_Transparent = true; // Show the object Resize(width, height); Move(left, top); } //______________________________________________________________________________ gui_Movie::~gui_Movie() { // Default destructor. dbg_Print("gui_Movie::~gui_Movie()", DBG_LVL_ZERO); // Removes the btn_Ctrl for (UInt_t i = 0; i < btn_Ctrl.size(); i++) { Parent()->Window()->RemoveFrame(btn_Ctrl[i]); btn_Ctrl[i]->DestroyWindow(); delete btn_Ctrl[i]; } } //______________________________________________________________________________ void gui_Movie::btn_ctrl_Do(Long_t) { // Handles the file button dbg_Print("gui_Movie::btn_ctrl_Do:(Long)", DBG_LVL_FLOW); } //______________________________________________________________________________ void gui_Movie::mnu_ctrl_Do(Int_t Idx) { // Handles the file menu dbg_Print("gui_Movie::mnu_ctrl_Do:(Int)", DBG_LVL_FLOW); // Selects what to do //switch (Idx) { //case 0: data_Save(""); break; // Save current viwe //case 1: data_Save("", true); break; // Save whole data set //case 2: data_Save("", true, true); break; // Save whole data as raw numbers //} } //______________________________________________________________________________ void gui_Movie::num_ctrl_Do(Int_t arg) { // Handles the ROI changes from the map dbg_Print("gui_Movie::num_ctrl_Do:(Int_t)", DBG_LVL_FLOW); } //______________________________________________________________________________ void gui_Movie::sld_frame_Do(Int_t pos) { // Handles the ROI changes from the map dbg_Print("gui_Movie::sld_frame_Do:(Int_t)", DBG_LVL_FLOW); std::cout << pos << "\n"; } // ************************** // gui_Movie specific methods // ************************** //______________________________________________________________________________ void gui_Movie::data_Set() { // Rereads the map data dbg_Print("gui_Movie::data_Set:()", DBG_LVL_FLOW); // Set the controls properties according to // the burst dimensions // Get burst size UInt_t size; switch (data_Type) { case kdt_Null: return; break; case kdt_UShort: size = data_US->frame_Count(); break; case kdt_Short: size = data_S->frame_Count(); break; case kdt_UInt: size = data_UI->frame_Count(); break; case kdt_Int: size = data_I->frame_Count(); break; case kdt_Float: size = data_F->frame_Count(); break; case kdt_Double: size = data_D->frame_Count(); break; } // Numeric and slider num_Ctrl[0]->SetLimitValues(0, size - 1); sld_Frame->SetRange(0, size - 1); } //______________________________________________________________________________ void gui_Movie::data_Refresh() { // Rereads the map data dbg_Print("gui_Movie::data_Refresh:()", DBG_LVL_FLOW); // Refresh current frame data_Refresh((UInt_t)sld_Frame->GetPosition()); } //______________________________________________________________________________ void gui_Movie::data_Refresh(UInt_t frm_Idx) { // Rereads the frame data, showing them in the linked map dbg_Print("gui_Movie::data_Refresh:(UInt)", DBG_LVL_FLOW); // Check that we have data if (!data_Type) return; // Assigns data to the linked map switch (data_Type) { case kdt_Null: return; break; case kdt_UShort: map_View->data_Set(data_US->frame(frm_Idx)->layer(0)); break; case kdt_Short: map_View->data_Set(data_S->frame(frm_Idx)->layer(0)); break; case kdt_UInt: map_View->data_Set(data_UI->frame(frm_Idx)->layer(0)); break; case kdt_Int: map_View->data_Set(data_I->frame(frm_Idx)->layer(0)); break; case kdt_Float: map_View->data_Set(data_F->frame(frm_Idx)->layer(0)); break; case kdt_Double: map_View->data_Set(data_D->frame(frm_Idx)->layer(0)); break; } // Refresh map_View->data_Refresh(); } //______________________________________________________________________________ void gui_Movie::data_Save(char* file, bool whole, bool raw) const { } // ********************** // Object general methods // ********************** //______________________________________________________________________________ void gui_Movie::ReDraw() { // Redraw the object to keep it in pair with the general GUI parameters dbg_Print("gui_CoolButton::ReDraw:()", DBG_LVL_FLOW); // What we need here is to change the desk background color, this will in // turn trigger the re-rendering of the whole map color_Set(obj_foreColor, Parent()->backColor()); } //______________________________________________________________________________ void gui_Movie::color_Set(UInt_t foreColor, UInt_t backColor) { // Overloads the gui object color function dbg_Print("gui_Movie::color_Set:(default)", DBG_LVL_FLOW); // Buttons for (UInt_t i = 0; i < btn_Ctrl.size(); i++) btn_Ctrl[i]->SetColor(k_btn_Color, backColor); // Provides connections for the standard gui_Object color calls obj_foreColor = foreColor; obj_backColor = backColor; } //______________________________________________________________________________ void gui_Movie::Move(UInt_t left, UInt_t top) { // Moves the map frame dbg_Print("gui_Movie::Move:(default)", DBG_LVL_FLOW); // Moves the btn_Ctrl btn_Ctrl[0]->Move(left, top); btn_Ctrl[1]->Move(left + btn_Ctrl[1]->GetWidth() + sld_Frame->GetWidth() + num_Ctrl[0]->GetWidth() + k_ctrl_Border * 3, top); // Moves the slider sld_Frame->Move(left + btn_Ctrl[1]->GetWidth() + k_ctrl_Border, top); // Moves the num_Ctrl num_Ctrl[0]->Move(sld_Frame->GetX() + sld_Frame->GetWidth() + k_ctrl_Border, top); // Stores the new datas obj_Left = left; obj_Top = top; // Sets no data: data_Type = kdt_Null; // Refresh the container Update(); } //______________________________________________________________________________ void gui_Movie::Resize(UInt_t width, UInt_t height) { // Resizes the map frame dbg_Print("gui_Movie::Resize:(default)", DBG_LVL_FLOW); // Check if (width < 160 + btn_Ctrl[0]->GetWidth() * 2 + num_Ctrl[0]->GetWidth() + k_ctrl_Border * 3) { width = 160 + btn_Ctrl[0]->GetWidth() * 2 + num_Ctrl[0]->GetWidth() + k_ctrl_Border * 3; } // Resizes the controls sld_Frame->Resize(width - btn_Ctrl[0]->GetWidth() * 2 - num_Ctrl[0]->GetWidth() - k_ctrl_Border * 3, height); // Stores the new datas obj_Width = width; obj_Height = height; // Updates the position of all the other objects // This call also update the object! Move(obj_Left, obj_Top); } //______________________________________________________________________________ void gui_Movie::MoveResize(UInt_t left, UInt_t top, UInt_t width, UInt_t height) { // Pre-update the object position obj_Left= left; obj_Top = top; // Resizes the map frame (this call will also move // the object to the new obj_Left, obj_Top) Resize(width, height); } //______________________________________________________________________________ void gui_Movie::LowerWindow() const { // Puts all the windows which compose the object to // the back of the Z-order stack dbg_Print("gui_Movie::LowerWindow:()", DBG_LVL_FLOW); // Objects for (UInt_t i = 0; i < num_Ctrl.size(); i++) num_Ctrl[i]->LowerWindow(); for (UInt_t i = 0; i < btn_Ctrl.size(); i++) btn_Ctrl[i]->LowerWindow(); sld_Frame->LowerWindow(); } //______________________________________________________________________________ void gui_Movie::RaiseWindow() const { // Puts all the windows which compose the object on // the top of the Z-order stack dbg_Print("gui_Movie::RaiseWindow:()", DBG_LVL_FLOW); // Objects for (UInt_t i = 0; i < num_Ctrl.size(); i++) num_Ctrl[i]->RaiseWindow(); for (UInt_t i = 0; i < btn_Ctrl.size(); i++) btn_Ctrl[i]->RaiseWindow(); sld_Frame->RaiseWindow(); }