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