00001 #ifndef Impala_Visualization_GUI_PreviewBar_h
00002 #define Impala_Visualization_GUI_PreviewBar_h
00003
00004 #include "OglGui/Window.h"
00005 #include "OglGui/CheckBox.h"
00006 #include "OglGui/ProgressBar.h"
00007 #include "Visualization/ImageSet.h"
00008 #include "Visualization/ImagesListener.h"
00009
00010 #include "PreviewBarSelectionListener.h"
00011
00012 namespace Impala {
00013 namespace Visualization {
00014 namespace GUI {
00015
00016
00017
00018 class PreviewBar : public OglGui::Window,
00019 public OglGui::CheckBoxListener,
00020 public Visualization::ImagesListener
00021 {
00022 public:
00023 typedef OglGui::CheckBox CheckBox;
00024 typedef OglGui::ProgressBar ProgressBar;
00025
00026 PreviewBar(OglGui::Window *parent, int width, int height, String name,
00027 double quality, bool selected=false) :
00028 OglGui::Window(parent, width, height)
00029 {
00030 Init(name, quality, selected);
00031 mListener = NULL;
00032 mType = 0;
00033 }
00034
00035 void SetHighlight(bool highlight)
00036 {
00037 mHighlighted = highlight;
00038 UpdateBackgroundColor();
00039 }
00040
00041 void SetSmall(bool small)
00042 {
00043 SetVisible(!small);
00044 }
00045
00046 void SetType(int type)
00047 {
00048 mType = type;
00049 UpdateBackgroundColor();
00050 }
00051
00052 int GetType()
00053 {
00054 return mType;
00055 }
00056
00057
00058 void SetPreviewBarSelectionListener(PreviewBarSelectionListener *l,
00059 void* userData)
00060 {
00061 mListener = l;
00062 mListenerData = userData;
00063 }
00064
00065 virtual void ImageSelectionEvent(Visualization::ImagesWindow *src,
00066 int imIndex, void* listenerData)
00067 {
00068 ILOG_DEBUG("ImSelEvent: selected rank=" << imIndex << " keyframe=" <<
00069 GetImageKeyframeID(imIndex));
00070 if (mListener)
00071 mListener->PreviewBarImageClickEvent(this, mName,
00072 GetImageKeyframeID(imIndex),
00073 mListenerData);
00074 }
00075
00076 protected:
00077 void Init(String name, double quality, bool selected)
00078 {
00079 mName = name;
00080
00081 SetBorderType(4);
00082 SetBorderFillShaded(2);
00083 mHighlighted = false;
00084 mChecked = selected;
00085 UpdateBackgroundColor();
00086
00087
00088 mCheck = new CheckBox(this, 8, WndHeight()-26, 162, 24, name, selected);
00089 mCheck->SetCheckBoxListener(this);
00090
00091
00092 ProgressBar *progBar = new ProgressBar(this, 8, 4, 162, 16);
00093 progBar->SetAlwaysDraw(false);
00094 progBar->SetBorderType(BEV_LINE);
00095 progBar->SetRoundness(6,6,6,6);
00096 progBar->SetColors(0x40ffffff, oglTrRED);
00097 progBar->ShowPercentage();
00098 progBar->SetProgress(quality * 100);
00099
00100
00101 mPreviewImages = NULL;
00102 }
00103
00104
00105 virtual void CheckBoxEvent(CheckBox *src, bool checked, void* userData)
00106 {
00107 mChecked = checked;
00108 if (mListener)
00109 mListener->PreviewBarSelectionEvent(this, mName, checked,
00110 mListenerData);
00111 UpdateBackgroundColor();
00112 }
00113
00114
00115 virtual void UpdateBackgroundColor()
00116 {
00117 int clr, check, highlight;
00118
00119 check = 0x009F0000;
00120 highlight = 0x00000080;
00121
00122 switch (mType) {
00123 case 0:
00124 clr = 0xff101010; break;
00125 case 1:
00126 clr = 0xFF408060; break;
00127 case 2:
00128 clr = 0xFF406080; break;
00129 case 3:
00130 clr = 0xFF406060; break;
00131 case 4:
00132 clr = 0xFF404040; break;
00133 case 10:
00134 clr = 0xff603060; break;
00135 case 11:
00136 clr = 0xff602060; break;
00137 default:
00138 clr = 0xff7f7f7f; break;
00139 }
00140
00141 if (mHighlighted)
00142 clr += highlight;
00143
00144 if (mChecked)
00145 clr += check;
00146
00147 SetBorderBackground(clr);
00148 }
00149
00150 virtual int GetImageKeyframeID(int rank)
00151 {
00152 return -1;
00153 }
00154
00155 PreviewBarSelectionListener* mListener;
00156 void* mListenerData;
00157
00158 CheckBox* mCheck;
00159 Visualization::ImageSet* mPreviewImages;
00160
00161 String mName;
00162 bool mChecked;
00163 bool mHighlighted;
00164 int mType;
00165
00166 int debug;
00167
00168 ILOG_VAR_DEC;
00169 };
00170
00171 ILOG_VAR_INIT(PreviewBar, Visualization.GUI);
00172
00173 }
00174 }
00175 }
00176
00177 #endif