CAVAPA-GUI  30.5.2014
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
calibrationpoints.h
1 /****************************************************************************
2  * Copyright (c) 2014, Joel Kivelä, Erkki Koskenkorva, Oskari Leppäaho,
3  * Mika Lehtinen and Petri Partanen.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * * Neither the name of the copyright holders nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
22  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 ****************************************************************************/
30 #ifndef CALIBRATIONPOINTS_H
31 #define CALIBRATIONPOINTS_H
32 
33 #include <QVector2D>
34 #include <QPainter>
35 #include <QFontMetrics>
36 
37 namespace cavapa_gui {
38 
39 
53 {
54 public:
56 
62  void push_back(QPointF newPoint);
63 
70  void draw(QPainter& painter) const;
71 
76  unsigned int size() const { return points.size(); }
77 
85  void setHighlightedPoint(const int i) { highlightedIndex = i; }
86 
92  QPointF at (const int pos) { return points.at(pos); }
93 
99  QPointF& operator[] (const int pos) { return points[pos]; }
100 
104  void clear() { points.clear(); }
105 
113  void removeHighlighted();
114 
120  static QColor getComplementaryColor(const QColor color);
121 
122 private:
123 
132  void drawSinglePoint(QPainter& painter, unsigned int i,
133  int lOfst) const;
134 
135  std::vector<QPointF> points;
136  unsigned int highlightedIndex;
137 };
138 
139 }
140 #endif // CALIBRATIONPOINTS_H
void draw(QPainter &painter) const
Draws all the points on a QPainter.
Definition: calibrationpoints.cpp:43
QPointF at(const int pos)
Returns the calibration point at specified location.
Definition: calibrationpoints.h:92
QPointF & operator[](const int pos)
Returns the calibration point at specified location.
Definition: calibrationpoints.h:99
static QColor getComplementaryColor(const QColor color)
Returns the complementary color of the specified color.
Definition: calibrationpoints.cpp:79
CalibrationPoints stores a collection of calibration points that can be drawn on a QPainter...
Definition: calibrationpoints.h:52
void removeHighlighted()
Removes the highlighted calibration point.
Definition: calibrationpoints.cpp:116
void push_back(QPointF newPoint)
Adds a new calibration point.
Definition: calibrationpoints.cpp:38
unsigned int size() const
Returns the number of control points in CalibrationPoints.
Definition: calibrationpoints.h:76
void clear()
Removes all the calibration points.
Definition: calibrationpoints.h:104
void setHighlightedPoint(const int i)
Sets the highlighted calibration point.
Definition: calibrationpoints.h:85