DrawBorder.cxx
Go to the documentation of this file.
1 
12 // for truncation warning
13 #ifdef _MSC_VER
14 #include "msdevstudio/MSconfig.h"
15 #endif
16 
17 #include "DrawBorder.h"
18 
19 #include "graphics/Color.h"
20 #include "graphics/ViewBase.h"
21 
22 #include <vector>
23 
24 using std::vector;
25 
26 using namespace hippodraw;
27 
29 
31 {
32 }
33 
35 {
36  // Left empty to avoid copying.
37 }
38 
40 {
41  if ( s_instance == 0 ) {
42  s_instance = new DrawBorder ();
43  }
44  return s_instance;
45 }
46 
48 {
49  m_view = view;
50 }
51 
53 {
54  return m_view;
55 }
56 
58 {
59 
60  Rect rect = m_view->getDrawRect();
61  double width = rect.getWidth();
62  double height = rect.getHeight();
63 
64  width = width - 2;
65  height = height - 2;
66 
67  vector <double> vx (8);
68  vector <double> vy (8);
69 
70  vx [0] = 2;
71  vy [0] = 2;
72  vx [1] = width;
73  vy [1] = 2;
74 
75  vx [2] = width;
76  vy [2] = 2;
77  vx [3] = width;
78  vy [3] = height;
79 
80  vx [4] = width;
81  vy [4] = height;
82  vx [5] = 2;
83  vy [5] = height;
84 
85  vx [6] = 2;
86  vy [6] = height;
87  vx [7] = 2;
88  vy [7] = 2;
89 
90  m_view->drawViewLines ( vx, vy, Line::Solid, Color(180, 180, 180), 0 );
91 
92  // Now draw the knobs.
93 
94  drawKnob ( 2, 2); //Upper Right.
95  drawKnob ( width / 2, 2); //Upper Middle.
96  drawKnob ( width, 2); //Upper Left.
97 
98  drawKnob ( 2, height / 2); //Middle Left.
99  drawKnob ( width, height / 2); //Middle Right.
100 
101  drawKnob ( 2, height); //Lower left.
102  drawKnob ( width / 2, height); //Lower middle.
103  drawKnob ( width, height); //Lower right.
104 
105 }
106 
107 void DrawBorder::drawKnob( double x, double y)
108 {
109 
110  int size = 2;
111 
112  vector <double> vx (8);
113  vector <double> vy (8);
114 
115  vx [0] = x-size;
116  vy [0] = y-size;
117  vx [1] = x+size;
118  vy [1] = y-size;
119 
120  vx [2] = x+size;
121  vy [2] = y-size;
122  vx [3] = x+size;
123  vy [3] = y+size;
124 
125  vx [4] = x+size;
126  vy [4] = y+size;
127  vx [5] = x-size;
128  vy [5] = y+size;
129 
130  vx [6] = x-size;
131  vy [6] = y+size;
132  vx [7] = x-size;
133  vy [7] = y-size;
134 
135  m_view->drawViewLines ( vx, vy, Line::Solid, Color(180, 180, 180), 0 );
136 }
double getHeight() const
A shortcut to get size.height.
Definition: Rectangle.cxx:113
static DrawBorder * instance()
Returns the pointer to the singleton instance.
Definition: DrawBorder.cxx:39
void draw()
Does the actual drawing in the view.
Definition: DrawBorder.cxx:57
ViewBase * m_view
The View object.
Definition: DrawBorder.h:34
static DrawBorder * s_instance
The instance of the application.
Definition: DrawBorder.h:28
void drawKnob(double x, double y)
Draws a knob centered at x, y.
Definition: DrawBorder.cxx:107
virtual Rect getDrawRect() const =0
Returns the drawing Rectangle in the devices coordinate system.
void setView(ViewBase *view)
Sets the View object.
Definition: DrawBorder.cxx:47
DrawBorder class interface.
double getWidth() const
A shortcut to get size.width.
Definition: Rectangle.cxx:108
virtual void drawViewLines(const std::vector< double > &x, const std::vector< double > &y, Line::Style style, bool color, float size)=0
Draws multiple line segments.
A Color class for creating the color object following the standard RGB color space.
Definition: Color.h:37
intp size(numeric::array arr)
Definition: num_util.cpp:296
Color class interface.
Class representing a rectangle.
Definition: Rectangle.h:34
The abstract base class for views.
Definition: ViewBase.h:62
A singleton class to draw the border with knobies around the selected display.
Definition: DrawBorder.h:23
ViewBase * getView()
Gets the view object.
Definition: DrawBorder.cxx:52
DrawBorder()
A default constructor for avoiding creation except by itself.
Definition: DrawBorder.cxx:30
hippodraw::ViewBase class interface

Generated for HippoDraw Class Library by doxygen