00001 #ifndef Impala_Visualisation_Plot_Plottable_h
00002 #define Impala_Visualisation_Plot_Plottable_h
00003
00004 #include "Core/Array/Arrays.h"
00005 #include "Visualization/Plot/PlottableMouseListener.h"
00006
00007 namespace Impala
00008 {
00009 namespace Visualization
00010 {
00011 namespace Plot
00012 {
00013
00014 class Plot;
00015
00016 class Plottable
00017 {
00018 public:
00019 Plottable()
00020 {
00021 mMouseListener = 0;
00022 mRed = 1.0;
00023 mBlue = 0.0;
00024 mGreen = 0.0;
00025 mMinX = mMinY = -1;
00026 mMaxX = mMaxY = 1;
00027 mMinZ = mMaxZ = 0;
00028 }
00029
00030 void SetPlottableMouseListener(PlottableMouseListener* l, int userData)
00031 {
00032 SetPlottableMouseListener(l,(void*) (long long) userData);
00033 }
00034 void SetPlottableMouseListener(PlottableMouseListener* l, void *userData=0)
00035 {
00036 mMouseListener = l;
00037 mMouseListenerData = userData;
00038 }
00039
00047 virtual void
00048 Draw(Plot* plot) = 0;
00049
00050 void
00051 SetColor(double red, double green, double blue)
00052 {
00053 mRed = red;
00054 mGreen = green;
00055 mBlue = blue;
00056 }
00057
00058 void
00059 SelectColor()
00060 {
00061 glColor3d(mRed, mGreen, mBlue);
00062 }
00063
00064 virtual bool
00065 GetDimensionsX(double& min, double& max)
00066 {
00067 min = mMinX;
00068 max = mMaxX;
00069 return mMinX != mMaxX;
00070 }
00071
00072 virtual bool
00073 GetDimensionsY(double& min, double& max)
00074 {
00075 min = mMinY;
00076 max = mMaxY;
00077 return mMinY != mMaxY;
00078 }
00079
00080 virtual bool
00081 GetDimensionsZ(double& min, double& max)
00082 {
00083 min = mMinZ;
00084 max = mMaxZ;
00085 return mMinZ != mMaxZ;
00086 }
00087
00088 void
00089 SetDimensionsX(double min, double max)
00090 {
00091 mMinX = min;
00092 mMaxX = max;
00093 }
00094
00095 void
00096 SetDimensionsY(double min, double max)
00097 {
00098 mMinY = min;
00099 mMaxY = max;
00100 }
00101
00102 void
00103 SetDimensionsZ(double min, double max)
00104 {
00105 mMinZ = min;
00106 mMaxZ = max;
00107 }
00108
00109 virtual void
00110 OnMouse(double x, double y, int msg, int but, int state)
00111 {
00112 if (mMouseListener)
00113 mMouseListener->OnMouse(this,x,y,msg,but,state,mMouseListenerData);
00114 }
00115
00116 virtual void
00117 SetData(Core::Array::Array2dScalarReal64* data)
00118 {
00119 }
00120
00121 protected:
00122 PlottableMouseListener* mMouseListener;
00123 void* mMouseListenerData;
00124
00125 double mRed, mBlue, mGreen;
00126 double mMinX, mMinY, mMinZ;
00127 double mMaxX, mMaxY, mMaxZ;
00128 };
00129
00130 }
00131 }
00132 }
00133
00134 #endif Impala_Visualisation_Plot_Plottable_h