Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

TableViewerPointCloud.h

Go to the documentation of this file.
00001 #ifndef TABLEVIEWERPOINTCLOUD_H
00002 
00003 #include "OglGui/ViewerPointCloud.h"
00004 
00005 #include "../TableDataView.h"
00006 #include "../TableDataViewController.h"
00007 
00008 namespace Impala { namespace Application { namespace MediaTable {
00009         
00010 class TableViewerPointCloud : 
00011         public OglGui::ViewerPointCloud,
00012         public TableDataViewController
00013 {
00014 public:
00015         typedef OglGui::ViewerPoint             ViewerPoint;
00016         
00017         TableViewerPointCloud(TableDataView* view, int x, int y, int w, int h):
00018                 OglGui::ViewerPointCloud(x,y,w,h),
00019                 TableDataViewController(view)
00020         {
00021                 InitContextMenu(this);
00022         }
00023         
00024         TableViewerPointCloud(Window* parent, TableDataView* view,
00025                                                   int x, int y, int w, int h) :
00026                 OglGui::ViewerPointCloud(parent,x,y,w,h),
00027                 TableDataViewController(view)
00028         {
00029                 InitContextMenu(this);
00030         }
00031         
00032         void AddDataFromTableDataView(std::string columnX,
00033                                                                   std::string columnY,
00034                                                                   std::string columnImage)
00035         {
00036                 mColumns[0] = columnX;
00037                 mColumns[1] = columnY;
00038                 mColumns[2] = columnImage;
00039                 
00040                 ILOG_USER("Added TableViewerPointCloud for " << columnX << " vs " << columnY << " with images from " << columnImage);           
00041                 
00042         OGLWND *oglWnd = GetOGLWND();
00043                 double xmin = 0, xmax = 0, ymin = 0, ymax = 0;
00044                 GetColumnMinMax(columnX, xmin, xmax);
00045                 GetColumnMinMax(columnY, ymin, ymax);
00046                 double xrange = xmax - xmin;
00047                 double yrange = ymax - ymin;
00048                 for (int i=0; i<GetTableDataView()->GetFilteredRows(); i++)
00049         {
00050                 OGLVIEW* view = viewSys.View2D(oglWnd,0,0,0,6,6);
00051             viewSys.SetTags(view, FlexViewTags);
00052             viewSys.ClearTags(view, visibleTag|showBgTag);
00053                         
00054             view->borderCol = MarkToColor(GetTableDataView()->GetMark(i));
00055                         double x, y;
00056                         if(GetTableDataView()->GetColumn(columnX)->GetType() == TableDataSource::TYPE_INT)
00057                     x = GetTableDataView()->GetSortedIntData(columnX, i);
00058                         else
00059                                 x = GetTableDataView()->GetSortedDoubleData(columnX, i);
00060                         if(GetTableDataView()->GetColumn(columnY)->GetType() == TableDataSource::TYPE_INT)
00061                     y = GetTableDataView()->GetSortedIntData(columnY, i);
00062                         else
00063                                 y = GetTableDataView()->GetSortedDoubleData(columnY, i);
00064                         
00065                         x -= xmin + xrange/2;
00066                         y -= ymin + yrange/2;
00067                         x *= W()/xrange;
00068                         y *= H()/yrange;
00069             ViewerPoint* vp = new ViewerPoint(view, x, y);
00070             vp->SetId(GetTableDataView()->GetSortedQuid(columnImage, i));
00071         }
00072         }
00073         
00074         virtual void DisplayFunc()
00075         {
00076                 mOglWnd->selectCol = oglWHITE;
00077                 mOglWnd->dragging = false;
00078                 OglGui::ViewerPointCloud::DisplayFunc();
00079         }
00080         
00081     virtual void MouseFunc(int msg, int btn, int state, int x, int y)
00082         {
00083         if (btn == oglRightButton)
00084                 {
00085             int rx=0, ry=0;
00086             ToTopWindow(this, rx, ry);
00087             OpenContextMenu(rx+x,ry+y);
00088                         return;
00089                 }
00090                 else if ((msg == oglMouseMove || msg == oglMouseDown)
00091                         && (state & oglLeftButton))
00092                 {
00093                         if(state & oglControl)
00094                         {
00095                                 state &= ~oglControl;
00096                                 state |= oglShift;
00097                                 btn = oglRightButton;
00098                         }
00099                         
00100                         else if(state & oglShift)
00101                         {
00102                                 state &= ~oglShift;
00103                                 btn = oglRightButton;
00104                         }
00105                 } 
00106                 OglGui::ViewerPointCloud::MouseFunc(msg, btn, state, x, y);             
00107         }
00108         
00109     void TransformMarkedTo(int sourcemask, int targetmask)
00110         {
00111                 if(sourcemask == 1 || targetmask == 1)
00112                 {
00113                         LIST *obj, *objList = mOglWnd->objectList;
00114                         ForAllElements(obj, objList)
00115                         {
00116                                 OGLVIEW*    view = (OGLVIEW*) obj->info;
00117                                 
00118                                 if (view && (view->tags & selectedTag) && 
00119                                 (view->SysData2 == (void*)OglGui::ViewerPoint::cMagicNr))
00120                                 {
00121                                         OglGui::ViewerPoint* vp;
00122                                         vp = (OglGui::ViewerPoint*) view->SysData1;
00123                                         if (vp)
00124                                         {
00125                                                 long long id = vp->GetId();
00126                                                 long row = (long) id;
00127                                                 int mark = GetTableDataView()->GetMarkById(row);
00128                                                 if(sourcemask == 1)
00129                                                         mark |= targetmask;
00130                                                 else {
00131                                                         mark &= !(-sourcemask);
00132                                                 }
00133                                                 //mark &= !1;
00134                                                 SetMarkById(row, mark);
00135                                                 view->borderCol = MarkToColor(mark);
00136                                         }
00137                                 }
00138                                 
00139                         }
00140                         mSkipUpdateSelectionEvent = true;
00141                         GetTableDataView()->DoUpdateSelectionEvent();
00142                 } else
00143                         TableDataViewController::
00144 				TransformMarkedTo(sourcemask,targetmask);
00145 
00146         }
00147         
00148         void MarkAllRows(int mark, bool state)
00149         {
00150                 if(mark == 1) // (un)mark selection
00151                 {
00152                         LIST   *obj, *objList = mOglWnd->objectList;
00153                         ForAllElements(obj, objList)
00154                         {
00155                                 OGLVIEW*    view = (OGLVIEW*) obj->info;
00156                                 viewSys.SetTagsTo(view, selectedTag, state);
00157                         }                       
00158                         //mSource->MarkAllRows(1, false);
00159                         //mSource->DoUpdateSelectionEvent();
00160                 } else
00161                         TableDataViewController::MarkAllRows(mark, state);
00162         }
00163         
00164         void MarkAllFilteredRows(int mark, bool state)
00165         {
00166                 if(mark == 1) // (un)mark selection
00167                 {
00168                         LIST   *obj, *objList = mOglWnd->objectList;
00169                         ForAllElements(obj, objList)
00170                         {
00171                                 OGLVIEW*    view = (OGLVIEW*) obj->info;
00172                                 viewSys.SetTagsTo(view, selectedTag, state);
00173                         }
00174                         //mSource->MarkAllRows(1, false);
00175                         //mSource->DoUpdateSelectionEvent();
00176                 } else
00177                         TableDataViewController::MarkAllFilteredRows(mark, state);
00178         }
00179         
00180         virtual void KeyboardFunc(int c, int state)
00181         {
00182                 TableDataViewController::KeyboardFunc(c, state);
00183         }
00184         
00185         void UpdateRowsEvent()
00186         {
00187                 UpdateAllViewers();
00188         }
00189         
00190         void UpdateSelectionEvent()
00191         {
00192                 if(mSkipUpdateSelectionEvent)
00193                 {
00194                         mSkipUpdateSelectionEvent = false;
00195                         return;
00196                 }
00197                 
00198                 UpdateAllMarks();
00199         }
00200         
00201         void UpdateAllMarks()
00202         {
00203                 LIST *obj, *objList = mOglWnd->objectList;
00204                 ForAllElements(obj, objList)
00205                 {
00206                         OGLVIEW*    view = 0;
00207                         if(obj && obj->info)
00208                                 (OGLVIEW*) obj->info;
00209                         
00210                         if (view && 
00211                                 (view->SysData2 == (void*)OglGui::ViewerPoint::cMagicNr))
00212                         {
00213                                 OglGui::ViewerPoint* vp;
00214                                 vp = (OglGui::ViewerPoint*) view->SysData1;
00215                                 if (vp)
00216                                 {
00217                                         long long id = vp->GetId();
00218                                         long row = (long) id;
00219                                         int mark = GetTableDataView()->GetMarkById(row);
00220                                         view->borderCol = MarkToColor(mark);                                            
00221                                 }
00222                         }
00223                 }
00224                 UpdateScene();          
00225         }
00226         
00227         void UpdateAllViewers()
00228         {
00229                 /*LIST *obj, *objList = mOglWnd->objectList;
00230                 ForAllElements(obj, objList)
00231                 {
00232                         OGLVIEW*    view = 0;
00233                         if(obj && obj->info)
00234                                 (OGLVIEW*) obj->info;
00235                                                 
00236                         if (view && 
00237                                 (view->SysData2 == (void*)OglGui::ViewerPoint::cMagicNr))
00238                         {
00239                                 OglGui::ViewerPoint* vp;
00240                                 vp = (OglGui::ViewerPoint*) view->SysData1;
00241                                 if (vp)
00242                                 {
00243                                         long long id = vp->GetId();
00244                                         long row = (long) id;
00245                                         bool visible =  mView->GetRowForID(row) != -1;
00246                                         delete vp;
00247                                         delete view;
00248                                 }
00249                         }
00250                 }
00251                 AddDataFromTableDataView(mColumns[0], mColumns[1], mColumns[2]);
00252                 UpdateScene();*/
00253         }
00254                 
00255         bool                            mSkipUpdateSelectionEvent;
00256         std::string                     mColumns[3];
00257         
00258         ILOG_VAR_DECL;
00259 };
00260         
00261 ILOG_VAR_INIT(TableViewerPointCloud, Application.MediaTable);
00262         
00263 } } } // Namespace Impala::Application::MediaTable
00264 #endif

Generated on Fri Mar 19 09:30:33 2010 for ImpalaSrc by  doxygen 1.5.1