00001
00002
00003
00004
00005
00006
00007
00008 #ifndef VIEWERPOINTCLOUDMODULE_H_
00009 #define VIEWERPOINTCLOUDMODULE_H_
00010
00011 #include "OglGui/GroupBox.h"
00012 #include "OglGui/Window.h"
00013
00014 #include "OglGui/ViewerPointCloudNavigator.h"
00015 #include "OglGui/WindowView2D.h"
00016 #include "OglGui/WindowListener.h"
00017
00018 #include "TableViewerPointCloud.h"
00019
00020 #include "../OglImageCacheStore.h"
00021
00022 namespace Impala {
00023 namespace Application {
00024 namespace MediaTable {
00025
00026 class ViewerPointCloudModule :
00027 public VisualizationModule,
00028 public OglGui::WindowListener
00029 {
00030 public:
00031 typedef OglGui::ViewerPointCloudNavigator ViewerPointCloudNavigator;
00032 typedef OglGui::ViewerPointCloud ViewerPointCloud;
00033 typedef OglGui::ViewerPoint ViewerPoint;
00034 typedef OglGui::WindowView2D WindowView2D;
00035
00036 ViewerPointCloudModule() : VisualizationModule("ViewerPointCloud")
00037 {
00038 }
00039
00040 void ButtonSelectionEvent(OglGui::Button *src, void *userData)
00041 {
00042 if(src->GetLabel() == "New " + GetName())
00043 {
00044 StoreConfigWindowValues();
00045 DoHandleNewWindow(GetName(), mConfigWindow);
00046 delete mConfigWindow;
00047 DoReleaseConfigWindow();
00048 }
00049 else
00050 VisualizationModule::ButtonSelectionEvent(src, userData);
00051 }
00052
00053 void ViewSelected()
00054 {
00055 VisualizationModule::DrawConfigWindow();
00056 OglGui::GroupBox* grp =
00057 new OglGui::GroupBox(mConfigWindow, mConfigWindow->W()-2, 362, "");
00058
00059 AddSelectorWithColumnsOfType(grp, "X", mStringValues["View"],
00060 TableDataSource::TYPE_FLAG_NUMBER, true);
00061 AddSelectorWithColumnsOfType(grp, "Y", mStringValues["View"],
00062 TableDataSource::TYPE_FLAG_NUMBER, true);
00063 AddSelectorWithColumnsOfType(grp, "Image", mStringValues["View"],
00064 TableDataSource::TYPE_FLAG_IMAGE, true);
00065 (new OglGui::Button(grp, grp->W()-4, 26, "New "+GetName(), BEV_ETCHED))
00066 ->SetButtonListener(this);
00067
00068 grp->RepositionViewports();
00069 grp->ScaleChildren();
00070 }
00071
00072 std::string GetNewWindowName()
00073 {
00074 if(mStringValues["X"].length() == 0)
00075 return VisualizationModule::GetNewWindowName();
00076 if(mStringValues["Y"].length() == 0)
00077 return VisualizationModule::GetNewWindowName();
00078 return mStringValues["X"].substr(0, 8) + "-" + mStringValues["Y"].substr(0, 8);
00079 }
00080
00081 void NewWindow(OglGui::Window* wnd)
00082 {
00083 int w = wnd->W();
00084 int h = wnd->H();
00085 TableDataStore* tds = TableDataStore::GetInstance();
00086 TableDataView* mSource = tds->GetTableDataView(mStringValues["View"]);
00087
00088 TableViewerPointCloud* vpCloud =
00089 new TableViewerPointCloud(wnd, mSource, 4, 4, 2*w/3-4, 2*h/2-4);
00090
00091 WindowView2D* detailWnd =
00092 new WindowView2D(wnd, 2*w/3+4, 4, w/3-4, h/2-4, NULL);
00093
00094 detailWnd->SetBorderType(BEV_ETCHED);
00095 vpCloud->SetBorderType(BEV_ETCHED);
00096
00097 ViewerPointCloudNavigator* vpcNavigator =
00098 new ViewerPointCloudNavigator(wnd, 2*w/3+4, h/2+4, w/3-4, h/2-4);
00099 vpcNavigator->SetTarget(vpCloud);
00100 vpcNavigator->SetNoMouseInput(true);
00101 vpcNavigator->PointSize(2);
00102 wnd->SetWindowListener(this, (void *) vpcNavigator);
00103
00104 vpCloud->DetailImageInterface(detailWnd);
00105 vpCloud->ScaleThreshold(10);
00106 vpCloud->SetGetOglImageByIdInterface(this);
00107 vpCloud->SetOglImageCache(OglImageCacheStore::GetInstance());
00108 vpCloud->MaxVisibleImages(150);
00109
00110 vpCloud->AddDataFromTableDataView(mStringValues["X"],
00111 mStringValues["Y"],
00112 mStringValues["Image"]);
00113
00114
00115 wnd->ScaleChildren();
00116 wnd->SetBackground(oglGUI_BG);
00117 }
00118
00119 void WindowMouseEvent(OglGui::Window* src, int msg, int but, int state,
00120 int x, int y, void *userData)
00121 {
00122 if ((msg == oglMouseMove || msg == oglMouseDown)
00123 && (state & oglLeftButton))
00124 {
00125 if(state & oglControl)
00126 {
00127 state &= ~oglControl;
00128 state |= oglShift;
00129 }
00130 else if(state & oglShift)
00131 {
00132 state &= ~oglShift;
00133 }
00134 but = oglRightButton;
00135
00136 OglGui::OglWindow::ToTopWindow(src, x, y);
00137 OglGui::OglWindow::TopWindowTo(((OglGui::Window*) userData), x, y);
00138 ((OglGui::Window*) userData)->MouseFunc(msg, but, state, x, y);
00139 }
00140 }
00141 };
00142
00143 } } }
00144
00145 #endif