00001 #ifndef Impala_Visualization_ViewWithRect_h
00002 #define Impala_Visualization_ViewWithRect_h
00003
00004 #include "Visualization/View.h"
00005 #include "Core/Geometry/Rectangle.h"
00006
00007 namespace Impala
00008 {
00009 namespace Visualization
00010 {
00011
00012
00013 class ViewWithRect : public View
00014 {
00015 public:
00016 typedef Core::Geometry::Rectangle Rectangle;
00017
00018
00019 ViewWithRect(OGLWND* oglWnd, int x, int y, int imW, int imH,
00020 double scale, bool texturing, bool noTexScaling,
00021 bool keepDispImage, OglGui::ViewListener* listener = 0) :
00022 View(oglWnd, x, y, imW, imH, scale, texturing, noTexScaling,
00023 keepDispImage, listener)
00024 {
00025 }
00026
00027 void
00028 SetRect(Rectangle r)
00029 {
00030 mRect = r;
00031 mRect.CheckSize();
00032 }
00033
00034 Rectangle
00035 GetRect()
00036 {
00037 return mRect;
00038 }
00039
00040 virtual void
00041 OnDrawView()
00042 {
00043 if (!mRect.Valid())
00044 return;
00045
00046 OGLIMAGE* oglIm = GetOGLIMAGE();
00047 if (!oglIm)
00048 return;
00049
00050 OGC ogc;
00051 OGCSave(&ogc);
00052 glPushMatrix();
00053
00054 viewSys.View2DImageTransform(GetOGLVIEW2D());
00055 SetSolidLineColor(oglRED);
00056 SetLineWidth(1);
00057 DrawRectangle(mRect.mLeft, oglIm->h - mRect.mTop - mRect.Height(),
00058 mRect.Width(), mRect.Height());
00059
00060 glPopMatrix();
00061 OGCRestore(&ogc);
00062
00063 OglGui::View::OnDrawView();
00064 }
00065
00066 virtual void
00067 OnMouse(int msg, int btn, int state, int x, int y)
00068 {
00069 std::cout << "MOUSE" << std::endl;
00070
00071 Visualization::View::OnMouse(msg, btn, state, x, y);
00072 mRect = GetPointerDragRect();
00073
00074 OglGui::View::OnMouse(msg, btn, state, x, y);
00075 }
00076
00077 private:
00078
00079
00080 Rectangle mRect;
00081
00082 };
00083
00084 }
00085 }
00086
00087 #endif