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: Andreas Schenk, Ansgar Philippsen 00023 */ 00024 00025 #ifndef IMG_GUI_STRATEGIES_HH_ 00026 #define IMG_GUI_STRATEGIES_HH_ 00027 00028 00029 #include <ost/geom/geom.hh> 00030 00031 #include "strategies_fw.hh" 00032 00033 #include <QPainter> 00034 #include <QPoint> 00035 #include <QColor> 00036 #include <QPen> 00037 #include <QBrush> 00038 namespace ost { namespace img { namespace gui { 00039 00040 00041 class SymbolDrawingStrategy 00042 { 00043 public: 00044 SymbolDrawingStrategy(); 00045 virtual ~SymbolDrawingStrategy() {}; 00046 00047 virtual void Draw(QPainter& pnt, const QPoint& center); 00048 00049 virtual void SetPenColor(const QColor& color){pen_.setColor(color);} 00050 virtual QColor GetPenColor() const {return pen_.color();} 00051 void SetPen(const QPen& pen) {pen_=pen;} 00052 virtual QPen GetPen() const {return pen_;} 00053 virtual void SetBrush(const QBrush& brush) {brush_=brush;} 00054 virtual QBrush GetBrush() const {return brush_;} 00055 virtual unsigned int GetSymbolSize() const {return symbolsize_;} 00056 virtual void SetSymbolSize(unsigned int symbolsize) {symbolsize_=symbolsize;} 00057 virtual unsigned int GetSymbolStrength() const {return symbolstrength_;} 00058 virtual void SetSymbolStrength(unsigned int s) {symbolstrength_=s;} 00059 virtual bool HasCrosshair(){return false;} 00060 virtual String GetShape()=0; 00061 protected: 00062 virtual void DrawSymbol(QPainter& pnt, const QPoint& center)=0; 00063 unsigned int symbolsize_; 00064 unsigned int symbolstrength_; 00065 QPen pen_; 00066 QBrush brush_; 00067 }; 00068 00069 00070 class SquareDrawingStrategy: public SymbolDrawingStrategy 00071 { 00072 public: 00073 SquareDrawingStrategy():SymbolDrawingStrategy() 00074 {} 00075 SquareDrawingStrategy(const SymbolDrawingStrategy& strategy): 00076 SymbolDrawingStrategy(strategy) 00077 {} 00078 virtual String GetShape(){return "Square";} 00079 protected: 00080 virtual void DrawSymbol(QPainter& pnt, const QPoint& center); 00081 }; 00082 00083 class CrosshairBaseDrawingStrategy: public SymbolDrawingStrategy 00084 { 00085 public: 00086 CrosshairBaseDrawingStrategy(); 00087 CrosshairBaseDrawingStrategy(const SymbolDrawingStrategy& strategy); 00088 void SetPen(const QPen& pen); 00089 void SetPenColor(const QColor& color); 00090 virtual void Draw(QPainter& pnt, const QPoint& center); 00091 virtual bool HasCrosshair(){return true;} 00092 protected: 00093 virtual void DrawCrosshair(QPainter& pnt, const QPoint& center); 00094 void SetCrosshairColor(); 00095 QPen pen2_; 00096 }; 00097 00098 class CrosshairCircleDrawingStrategy: public CrosshairBaseDrawingStrategy 00099 { 00100 public: 00101 CrosshairCircleDrawingStrategy(): 00102 CrosshairBaseDrawingStrategy() 00103 {} 00104 CrosshairCircleDrawingStrategy(const SymbolDrawingStrategy& strategy): 00105 CrosshairBaseDrawingStrategy(strategy){} 00106 virtual String GetShape(){return "Circle";} 00107 protected: 00108 virtual void DrawSymbol(QPainter& pnt, const QPoint& center); 00109 }; 00110 00111 class CrosshairSquareDrawingStrategy: public CrosshairBaseDrawingStrategy 00112 { 00113 public: 00114 CrosshairSquareDrawingStrategy(): 00115 CrosshairBaseDrawingStrategy() 00116 {} 00117 CrosshairSquareDrawingStrategy(const SymbolDrawingStrategy& strategy): 00118 CrosshairBaseDrawingStrategy(strategy) 00119 {} 00120 virtual String GetShape(){return "Square";} 00121 protected: 00122 virtual void DrawSymbol(QPainter& pnt, const QPoint& center); 00123 }; 00124 00125 class CircleDrawingStrategy: public SymbolDrawingStrategy 00126 { 00127 public: 00128 CircleDrawingStrategy(): 00129 SymbolDrawingStrategy() 00130 {} 00131 CircleDrawingStrategy(const SymbolDrawingStrategy& strategy): 00132 SymbolDrawingStrategy(strategy) 00133 {} 00134 virtual String GetShape(){return "Circle";} 00135 protected: 00136 virtual void DrawSymbol(QPainter& pnt, const QPoint& center); 00137 }; 00138 00139 }}} //ns 00140 00141 #endif /*STRATEGIES_HH_*/