Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
vpPlotCurve.cpp
1/****************************************************************************
2 *
3 * ViSP, open source Visual Servoing Platform software.
4 * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
5 *
6 * This software is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 * See the file LICENSE.txt at the root directory of this source
11 * distribution for additional information about the GNU GPL.
12 *
13 * For using ViSP with software that can not be combined with the GNU
14 * GPL, please contact Inria about acquiring a ViSP Professional
15 * Edition License.
16 *
17 * See https://visp.inria.fr for more information.
18 *
19 * This software was developed at:
20 * Inria Rennes - Bretagne Atlantique
21 * Campus Universitaire de Beaulieu
22 * 35042 Rennes Cedex
23 * France
24 *
25 * If you have questions regarding the use of this file, please contact
26 * Inria at visp@inria.fr
27 *
28 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30 *
31 * Description:
32 * Define a curve for the vpPlot class.
33 *
34*****************************************************************************/
35#include <visp3/core/vpConfig.h>
36
37#ifndef DOXYGEN_SHOULD_SKIP_THIS
38
39#include <visp3/gui/vpDisplayD3D.h>
40#include <visp3/gui/vpDisplayGDI.h>
41#include <visp3/gui/vpDisplayGTK.h>
42#include <visp3/gui/vpDisplayOpenCV.h>
43#include <visp3/gui/vpDisplayX.h>
44#include <visp3/gui/vpPlotCurve.h>
45
46#if defined(VISP_HAVE_DISPLAY)
47vpPlotCurve::vpPlotCurve()
48 : color(vpColor::red), curveStyle(point), thickness(1), nbPoint(0), lastPoint(), pointListx(), pointListy(),
49 pointListz(), legend(), xmin(0), xmax(0), ymin(0), ymax(0)
50{
51}
52
53vpPlotCurve::~vpPlotCurve()
54{
55 pointListx.clear();
56 pointListy.clear();
57 pointListz.clear();
58}
59
60void vpPlotCurve::plotPoint(const vpImage<unsigned char> &I, const vpImagePoint &iP, double x, double y)
61{
62 nbPoint++;
63
64 if (nbPoint > 1) {
65 vpDisplay::displayLine(I, lastPoint, iP, color, thickness);
66 }
67#if defined(VISP_HAVE_DISPLAY)
68 double top;
69 double left;
70 double width;
71 double height;
72
73 if (iP.get_i() <= lastPoint.get_i()) {
74 top = iP.get_i() - 5;
75 height = lastPoint.get_i() - top + 10;
76 } else {
77 top = lastPoint.get_i() - 5;
78 height = iP.get_i() - top + 10;
79 }
80 if (iP.get_j() <= lastPoint.get_j()) {
81 left = iP.get_j() - 5;
82 width = lastPoint.get_j() - left + 10;
83 } else {
84 left = lastPoint.get_j() - 5;
85 width = iP.get_j() - left + 10;
86 }
87 vpDisplay::flushROI(I, vpRect(left, top, width, height));
88#endif
89 lastPoint = iP;
90 pointListx.push_back(x);
91 pointListy.push_back(y);
92 pointListz.push_back(0.0);
93}
94
95void vpPlotCurve::plotList(const vpImage<unsigned char> &I, double xorg, double yorg, double zoomx, double zoomy)
96{
97 std::list<double>::const_iterator it_ptListx = pointListx.begin();
98 std::list<double>::const_iterator it_ptListy = pointListy.begin();
99
100 unsigned int k = 0;
101 vpImagePoint iP;
102 while (k < nbPoint) {
103 iP.set_ij(yorg - (zoomy * (*it_ptListy)), xorg + (zoomx * (*it_ptListx)));
104
105 if (k > 0)
106 vpDisplay::displayLine(I, lastPoint, iP, color, thickness);
107
108 lastPoint = iP;
109
110 ++it_ptListx;
111 ++it_ptListy;
112 k++;
113 }
114}
115
116#elif !defined(VISP_BUILD_SHARED_LIBS)
117// Work around to avoid warning: libvisp_core.a(vpPlotCurve.cpp.o) has no
118// symbols
119void dummy_vpPlotCurve(){};
120#endif
121#endif
Class to define RGB colors available for display functionalities.
Definition vpColor.h:152
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1, bool segment=true)
static void flushROI(const vpImage< unsigned char > &I, const vpRect &roi)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
double get_j() const
void set_ij(double ii, double jj)
double get_i() const
Definition of the vpImage class member functions.
Definition vpImage.h:135
Defines a rectangle in the plane.
Definition vpRect.h:76