00001
00002
00003
00004 #ifndef OglGui_ConceptSupport_Control_h
00005 #define OglGui_ConceptSupport_Control_h
00006
00007 #ifndef OglGui_ViewerPointCloud_h
00008 #include "OglGui/ViewerPointCloud.h"
00009 #endif
00010
00011 #ifndef OglGui_Button_h
00012 #include "OglGui/Button.h"
00013 #endif
00014
00015 #ifndef OglGui_CheckBox_h
00016 #include "OglGui/CheckBox.h"
00017 #endif
00018
00019 namespace OglGui
00020 {
00021
00022 class ConceptSupportControl : public Window, ButtonListener
00023 {
00024 public:
00025 static const int cNrOfColors = 8;
00026 static const int cSetBtnId = cNrOfColors;
00027 static const int cShowBtnId = cNrOfColors+1;
00028 static const int cHideBtnId = cNrOfColors+2;
00029 static const int cUnSelectBtnId = cNrOfColors+3;
00030 static const int cSelectBtnId = cNrOfColors+4;
00031
00032 ConceptSupportControl(Window* parent, int x, int y, int w, int h) :
00033 Window(parent, x, y, w, h)
00034 {
00035 Init(w, h);
00036 }
00037
00038 void SetViewerPointCloud(ViewerPointCloud* vpc)
00039 {
00040 mViewerPointCloud = vpc;
00041 }
00042
00043 ULONG* Colors()
00044 {
00045 return mColors;
00046 }
00047
00048 void ColorButtonSelection(Button* src, int userData)
00049 {
00050 for (int i=0; i<cNrOfColors; i++)
00051 mColorButtons[i]->SetBorderType(i==userData ? BEV_RIDGE : BEV_LINE);
00052 mColorIndex = userData;
00053 }
00054
00055 void CommandButtonSelection(Button* src, int cmd)
00056 {
00057 ViewerPointCloud* vpc = mViewerPointCloud;
00058 if (cmd==cSetBtnId)
00059 vpc->BorderColorTagged(selectedTag, true, mColors[mColorIndex]);
00060 if (cmd==cShowBtnId)
00061 vpc->TagBorderColorOnOff(mColors[mColorIndex],visibleTag|selectableTag,ignoreTag);
00062 if (cmd==cHideBtnId)
00063 vpc->TagBorderColorOnOff(mColors[mColorIndex],ignoreTag,visibleTag|selectableTag|selectedTag);
00064 if (cmd==cUnSelectBtnId)
00065 vpc->TagBorderColor(mColors[mColorIndex], selectedTag, false);
00066 if (cmd==cSelectBtnId)
00067 vpc->TagBorderColor(mColors[mColorIndex], selectedTag, true);
00068 }
00069
00070 virtual void ButtonSelectionEvent(Button *src, void* userData)
00071 {
00072 if (userData>=(void*)0 && userData<(void*)cNrOfColors)
00073 ColorButtonSelection(src, (int) (long long) userData);
00074 else
00075 CommandButtonSelection(src, (int) (long long) userData);
00076 }
00077
00078 private:
00079 void Init(int w, int h)
00080 {
00081 mViewerPointCloud = 0;
00082
00083 mColorIndex = 0;
00084 mColors[0] = 0xffff0000;
00085 mColors[1] = 0xffff8000;
00086 mColors[2] = 0xff800000;
00087 mColors[3] = 0xffffff00;
00088 mColors[4] = 0xff0000ff;
00089 mColors[5] = 0xff8080ff;
00090 mColors[6] = 0xff800080;
00091 mColors[7] = 0xffff00ff;
00092
00093
00094 for (int i=0; i<cNrOfColors; i++)
00095 {
00096 char buf[100];
00097 mColorButtons[i] = ColorButton(this, 4, 4+i*20, 16, 16, mColors[i]);
00098 mColorButtons[i]->SetButtonListener(this, i);
00099 sprintf(buf, "Set %d info string", 8-i);
00100 mColorStrings[i] = new StaticText(this,20, 4+i*20, W()-24, 16, buf);
00101 mColorStrings[i]->SetAlign(oglLeftAlign, oglCenterAlign);
00102 }
00103
00104
00105 int btnY = 4 + cNrOfColors*20;
00106 int cmdNr = cNrOfColors;
00107 mSetButton = CmdButton(4, btnY, 40, 20, "Set", cmdNr);
00108 mShowButton = CmdButton(48, btnY, 40, 20, "Show", cmdNr+1);
00109 mHideButton = CmdButton(92, btnY, 40, 20, "Hide", cmdNr+2);
00110 mSelectButton = CmdButton(142, btnY, 24, 20, "Un", cmdNr+3);
00111 mUnSelectButton = CmdButton(166, btnY, 60, 20, "Select", cmdNr+4);
00112 }
00113
00114 Button* CmdButton(int x, int y, int w, int h, strconst str, int userData)
00115 {
00116 Button* btn = new Button(this, x, y, w, h, str, 4, 1);
00117 btn->SetButtonListener(this, userData);
00118 return btn;
00119 }
00120
00121 Button* ColorButton(Window* parent, int x, int y, int w, int h, ULONG col)
00122 {
00123 Button* btn = new Button(parent, x, y, w, h, "", BEV_LINE, 1);
00124 btn->SetBorderFillShaded(0);
00125 btn->SetBorderBackground(col);
00126 btn->SetDoStateFeedback(false);
00127 return btn;
00128 }
00129
00130 ViewerPointCloud* mViewerPointCloud;
00131 Button* mSetButton;
00132 Button* mShowButton;
00133 Button* mHideButton;
00134 Button* mSelectButton;
00135 Button* mUnSelectButton;
00136 Button* mColorButtons[cNrOfColors];
00137 ULONG mColors[cNrOfColors];
00138 int mColorIndex;
00139 StaticText* mColorStrings[cNrOfColors];
00140 };
00141
00142 }
00143 #endif
00144
00145