OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
strategies.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2020 by the OpenStructure authors
5 // Copyright (C) 2003-2010 by the IPLT authors
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the Free
9 // Software Foundation; either version 3.0 of the License, or (at your option)
10 // any later version.
11 // This library is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 // details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this library; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 //------------------------------------------------------------------------------
20 
21 /*
22  Authors: Andreas Schenk, Ansgar Philippsen
23 */
24 
25 #ifndef IMG_GUI_STRATEGIES_HH_
26 #define IMG_GUI_STRATEGIES_HH_
27 
28 
29 #include <ost/geom/geom.hh>
30 
31 #include "strategies_fw.hh"
32 
33 #include <QPainter>
34 #include <QPoint>
35 #include <QColor>
36 #include <QPen>
37 #include <QBrush>
38 namespace ost { namespace img { namespace gui {
39 
40 
42 {
43 public:
45  virtual ~SymbolDrawingStrategy() {};
46 
47  virtual void Draw(QPainter& pnt, const QPoint& center);
48 
49  virtual void SetPenColor(const QColor& color){pen_.setColor(color);}
50  virtual QColor GetPenColor() const {return pen_.color();}
51  void SetPen(const QPen& pen) {pen_=pen;}
52  virtual QPen GetPen() const {return pen_;}
53  virtual void SetBrush(const QBrush& brush) {brush_=brush;}
54  virtual QBrush GetBrush() const {return brush_;}
55  virtual unsigned int GetSymbolSize() const {return symbolsize_;}
56  virtual void SetSymbolSize(unsigned int symbolsize) {symbolsize_=symbolsize;}
57  virtual unsigned int GetSymbolStrength() const {return symbolstrength_;}
58  virtual void SetSymbolStrength(unsigned int s) {symbolstrength_=s;}
59  virtual bool HasCrosshair(){return false;}
60  virtual String GetShape()=0;
61 protected:
62  virtual void DrawSymbol(QPainter& pnt, const QPoint& center)=0;
63  unsigned int symbolsize_;
64  unsigned int symbolstrength_;
65  QPen pen_;
66  QBrush brush_;
67 };
68 
69 
71 {
72 public:
74  {}
76  SymbolDrawingStrategy(strategy)
77  {}
78  virtual String GetShape(){return "Square";}
79 protected:
80  virtual void DrawSymbol(QPainter& pnt, const QPoint& center);
81 };
82 
84 {
85 public:
88  void SetPen(const QPen& pen);
89  void SetPenColor(const QColor& color);
90  virtual void Draw(QPainter& pnt, const QPoint& center);
91  virtual bool HasCrosshair(){return true;}
92 protected:
93  virtual void DrawCrosshair(QPainter& pnt, const QPoint& center);
94  void SetCrosshairColor();
95  QPen pen2_;
96 };
97 
99 {
100 public:
103  {}
105  CrosshairBaseDrawingStrategy(strategy){}
106  virtual String GetShape(){return "Circle";}
107 protected:
108  virtual void DrawSymbol(QPainter& pnt, const QPoint& center);
109 };
110 
112 {
113 public:
116  {}
119  {}
120  virtual String GetShape(){return "Square";}
121 protected:
122  virtual void DrawSymbol(QPainter& pnt, const QPoint& center);
123 };
124 
126 {
127 public:
130  {}
132  SymbolDrawingStrategy(strategy)
133  {}
134  virtual String GetShape(){return "Circle";}
135 protected:
136  virtual void DrawSymbol(QPainter& pnt, const QPoint& center);
137 };
138 
139 }}} //ns
140 
141 #endif /*STRATEGIES_HH_*/
virtual void DrawSymbol(QPainter &pnt, const QPoint &center)
std::string String
Definition: base.hh:54
virtual void Draw(QPainter &pnt, const QPoint &center)
virtual void DrawSymbol(QPainter &pnt, const QPoint &center)
virtual void SetSymbolStrength(unsigned int s)
Definition: strategies.hh:58
virtual void SetSymbolSize(unsigned int symbolsize)
Definition: strategies.hh:56
virtual QColor GetPenColor() const
Definition: strategies.hh:50
virtual QPen GetPen() const
Definition: strategies.hh:52
virtual void Draw(QPainter &pnt, const QPoint &center)
void SetPen(const QPen &pen)
Definition: strategies.hh:51
virtual void SetPenColor(const QColor &color)
Definition: strategies.hh:49
virtual void DrawSymbol(QPainter &pnt, const QPoint &center)=0
virtual QBrush GetBrush() const
Definition: strategies.hh:54
SquareDrawingStrategy(const SymbolDrawingStrategy &strategy)
Definition: strategies.hh:75
virtual void DrawCrosshair(QPainter &pnt, const QPoint &center)
virtual unsigned int GetSymbolStrength() const
Definition: strategies.hh:57
virtual void DrawSymbol(QPainter &pnt, const QPoint &center)
virtual unsigned int GetSymbolSize() const
Definition: strategies.hh:55
CrosshairCircleDrawingStrategy(const SymbolDrawingStrategy &strategy)
Definition: strategies.hh:104
CircleDrawingStrategy(const SymbolDrawingStrategy &strategy)
Definition: strategies.hh:131
CrosshairSquareDrawingStrategy(const SymbolDrawingStrategy &strategy)
Definition: strategies.hh:117
virtual void DrawSymbol(QPainter &pnt, const QPoint &center)
virtual void SetBrush(const QBrush &brush)
Definition: strategies.hh:53