00001 //------------------------------------------------------------------------------ 00002 // This file is part of the OpenStructure project <www.openstructure.org> 00003 // 00004 // Copyright (C) 2008-2011 by the OpenStructure authors 00005 // Copyright (C) 2003-2010 by the IPLT authors 00006 // 00007 // This library is free software; you can redistribute it and/or modify it under 00008 // the terms of the GNU Lesser General Public License as published by the Free 00009 // Software Foundation; either version 3.0 of the License, or (at your option) 00010 // any later version. 00011 // This library is distributed in the hope that it will be useful, but WITHOUT 00012 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00013 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00014 // details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public License 00017 // along with this library; if not, write to the Free Software Foundation, Inc., 00018 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 //------------------------------------------------------------------------------ 00020 00021 /* 00022 Authors: Ansgar Philippsen, Andreas Schenk 00023 */ 00024 00025 #ifndef IMG_GUI_MASK_OVERLAY_HH_ 00026 #define IMG_GUI_MASK_OVERLAY_HH_ 00027 00028 #include <ost/geom/geom.hh> 00029 #include <ost/img/image_handle.hh> 00030 #include <ost/img/mask.hh> 00031 00032 #include <ost/gui/module_config.hh> 00033 00034 #include "overlay_base.hh" 00035 00036 namespace ost { namespace img { namespace gui { 00037 00038 // fw decl 00039 class DataViewerPanel; 00040 00041 // overlay base class 00042 class DLLEXPORT_OST_GUI MaskOverlay: public Overlay 00043 { 00044 public: 00045 MaskOverlay(); 00046 MaskOverlay(const MaskPtr& m); 00047 00048 virtual bool OnMouseEvent(QMouseEvent* e, DataViewerPanel* dvp, 00049 const QPoint& lastmouse); 00050 virtual bool OnKeyEvent(QKeyEvent* e, DataViewerPanel* dvp); 00051 virtual void OnDraw(QPainter& pnt, DataViewerPanel* dvp, bool is_active); 00052 virtual QMenu* GetMenu(); 00053 00054 MaskPtr GetMask() const; 00055 void SetMask(const MaskPtr& m); 00056 void ClearMask(); 00057 void ClearShift(){shift_=geom::Vec2();} 00058 geom::Vec2 GetShift(){return shift_;} 00059 void SetShift(geom::Vec2 shift); 00060 void ApplyShiftToMask(); 00061 00062 protected: 00063 std::vector<geom::Polygon2> polygons_; 00064 QMenu* menu_; 00065 int active_; 00066 bool add_mode_; 00067 geom::Polygon2 new_poly_; 00068 geom::Vec2 old_mouse_pos_; 00069 geom::Vec2 shift_; 00070 }; 00071 00072 }}} //ns 00073 00074 #endif