00001 #ifndef Impala_Visualization_ViewListenerWithRectangles_h
00002 #define Impala_Visualization_ViewListenerWithRectangles_h
00003
00004 #include "Visualization/View.h"
00005 #include "Core/Geometry/RectangleList.h"
00006
00007 namespace Impala
00008 {
00009 namespace Visualization
00010 {
00011
00012
00013 class ViewListenerWithRectangles : public OglGui::ViewListener
00014 {
00015 public:
00016
00017 ViewListenerWithRectangles()
00018 {
00019 mList = new Core::Geometry::RectangleList;
00020 mColor = oglRED;
00021 }
00022
00023
00024
00025 ViewListenerWithRectangles(Core::Geometry::RectangleList* rList,
00026 ULONG color = oglRED)
00027 {
00028 mList = rList;
00029 mColor = color;
00030 }
00031
00032
00033 void SetRectangle(int left, int top, int right, int bottom)
00034 {
00035 Clear();
00036 AddRectangle(left, top, right, bottom);
00037 }
00038
00039 void AddRectangle(int left, int top, int right, int bottom)
00040 {
00041 mList->push_back(Core::Geometry::Rectangle(left,top,right,bottom));
00042 }
00043
00044 void Clear()
00045 {
00046 mList->EraseAll();
00047 }
00048
00049 virtual void OnDrawView(OglGui::View* view)
00050 {
00051 if (mList->size() == 0)
00052 return;
00053
00054 OGLIMAGE* oglIm = view->GetOGLIMAGE();
00055 if (!oglIm)
00056 return;
00057
00058 OGC ogc;
00059 OGCSave(&ogc);
00060 glPushMatrix();
00061
00062 viewSys.View2DImageTransform(view->GetOGLVIEW2D());
00063 SetSolidLineColor(mColor);
00064 SetLineWidth(1);
00065 for (Core::Geometry::RectangleListCI r=mList->begin() ; r!=mList->end() ; r++)
00066
00067 DrawRectangle(r->mLeft, oglIm->h - r->mTop - r->Height(),
00068 r->Width(), r->Height());
00069 glPopMatrix();
00070 OGCRestore(&ogc);
00071 }
00072
00073 private:
00074
00075 Core::Geometry::RectangleList* mList;
00076 ULONG mColor;
00077
00078 };
00079
00080 }
00081 }
00082
00083 #endif