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

Points.h

Go to the documentation of this file.
00001 #ifndef Impala_Visualization_Plot_Points_h
00002 #define Impala_Visualization_Plot_Points_h
00003 
00004 #include "Visualization/Plot/Plottable.h"
00005 #include <vector>
00006 
00007 namespace Impala
00008 {
00009 namespace Visualization
00010 {
00011 namespace Plot
00012 {
00013 
00014 
00015 class Points : public Plottable
00016 {
00017 public:
00018     Points()
00019     {
00020         mHighLightPoint = -1;
00021         mHighLightCol = 0xffff00ff;
00022     }
00023 
00024     void    HighLightPoint(int idx)     { mHighLightPoint = idx; }
00025     int     HighLightPoint()            { return mHighLightPoint; }
00026     void    HighLightColor(ULONG col)   { mHighLightCol = col; }
00027 
00028     double  PointX(int idx)             { return mData[idx*7]; }
00029     double  PointY(int idx)             { return mData[idx*7+1]; }
00030     int     Size()                      { return mData.size()/7; }
00031 
00032     void
00033     Draw(Plot* plot)
00034     {
00035         if (mData.size() == 0)
00036             return;
00037         for (int i=0 ; i<mData.size() ; i+=7)
00038         {
00039             if ((i/7)==mHighLightPoint)
00040             {
00041                 int r,g, b;
00042                 COLOR2RGB(mHighLightCol,r,g,b);
00043                 glColor3ub(r,g,b);
00044                 glPointSize(mData[i+6]+4);
00045                 glBegin(GL_POINTS);
00046                 glVertex3d(mData[i], mData[i+1], mData[i+2]);
00047                 glEnd();
00048             }
00049             glColor3d(mData[i+3], mData[i+4], mData[i+5]);
00050             glPointSize(mData[i+6]);
00051             glBegin(GL_POINTS);
00052             glVertex3d(mData[i], mData[i+1], mData[i+2]);
00053             glEnd();
00054         }
00055     }
00056 
00057     /*
00058     void
00059     Draw(Plot* plot)
00060     {
00061         if (mData.size() == 0)
00062             return;
00063         //glPointSize(2.);
00064         //glBegin(GL_POINTS);
00065         for (int i=0 ; i<mData.size() ; i+=7)
00066         {
00067             //glPushMatrix();
00068 
00069             //double x = -1.0 + mMinX + (mData[i] / (mMaxX-mMinX)) * 2.0;
00070             //double y = -1.0 + mMinY + (mData[i+1] / (mMaxY-mMinY)) * 2.0;
00071             //glTranslated(x, y, mData[i+2]);
00072             //glTranslated(mData[i], mData[i+1], mData[i+2]);
00073             glColor3d(mData[i+3], mData[i+4], mData[i+5]);
00074             //double size = mData[i+6] / 2;
00075             //double sizeX = mData[i+6] * (mMaxX-mMinX) / 2;
00076             //double sizeY = mData[i+6] * (mMaxY-mMinY);
00077             //
00078             //glBegin(GL_QUADS);
00079             //glVertex2d(-sizeX,-sizeY);
00080             //glVertex2d(-sizeX, sizeY);
00081             //glVertex2d( sizeX, sizeY);
00082             //glVertex2d( sizeX,-sizeY);
00083 
00084             //glPointSize(2.);
00085             glPointSize(mData[i+6]);
00086             glBegin(GL_POINTS);
00087             glVertex3d(mData[i], mData[i+1], mData[i+2]);
00088             glEnd();
00089 
00090             //glPopMatrix();
00091         }
00092         //glEnd();
00093     }
00094 */
00095     void
00096     AddPoint(double x, double y, double z, double r, double g, double b,
00097              double size, bool updateDims=true)
00098     {
00099         int i = mData.size();
00100         mData.resize(i + 7);
00101         mData[i++] = x;
00102         mData[i++] = y;
00103         mData[i++] = z;
00104         mData[i++] = r;
00105         mData[i++] = g;
00106         mData[i++] = b;
00107         mData[i++] = size;
00108         if (updateDims)
00109             UpdateDimensions();
00110     }
00111 
00112     void
00113     Clear()
00114     {
00115         mData.clear();
00116     }
00117 
00118     void
00119     UpdateDimensions()
00120     {
00121         for (int i=0 ; i<mData.size() ; i+=7)
00122         {
00123             double x = mData[i];
00124             if (x < mMinX)
00125                 mMinX = x;
00126             else if (x > mMaxX)
00127                 mMaxX = x;
00128             double y = mData[i+1];
00129             if (y < mMinY)
00130                 mMinY = y;
00131             else if (y > mMaxY)
00132                 mMaxY = y;
00133         }
00134     }
00135 
00136     void SetPointSize(int idx, double size)
00137     {
00138         int sz = mData.size();
00139         if (idx < 0 || idx*7 > sz-1)
00140             return;
00141         mData[idx*7+6] = size;
00142     }
00143 
00144 protected:
00145 
00146     std::vector<double> mData;
00147     int                 mHighLightPoint;
00148     ULONG               mHighLightCol;
00149 };
00150 
00151 }//namespace Plot
00152 }//namespace Visulization
00153 }//namespace Impala
00154 
00155 #endif

Generated on Fri Mar 19 09:31:51 2010 for ImpalaSrc by  doxygen 1.5.1