Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpPlotCurve.cpp
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
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 http://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  * Authors:
34  * Nicolas Melchior
35  *
36  *****************************************************************************/
37 #include <visp3/core/vpConfig.h>
38 
39 #ifndef DOXYGEN_SHOULD_SKIP_THIS
40 
41 #include <visp3/gui/vpPlotCurve.h>
42 #include <visp3/gui/vpDisplayOpenCV.h>
43 #include <visp3/gui/vpDisplayX.h>
44 #include <visp3/gui/vpDisplayGDI.h>
45 #include <visp3/gui/vpDisplayGTK.h>
46 #include <visp3/gui/vpDisplayD3D.h>
47 
48 #if defined(VISP_HAVE_DISPLAY)
49 vpPlotCurve::vpPlotCurve() :
50  color(vpColor::red), curveStyle(point), thickness(1), nbPoint(0), lastPoint(),
51  pointListx(), pointListy(), pointListz(), legend(), xmin(0), xmax(0), ymin(0), ymax(0)
52 {
53 }
54 
55 vpPlotCurve::~vpPlotCurve()
56 {
57  pointListx.clear();
58  pointListy.clear();
59  pointListz.clear();
60 }
61 
62 void
63 vpPlotCurve::plotPoint(const vpImage<unsigned char> &I, const vpImagePoint &iP, const double x, const double y)
64 {
65  nbPoint++;
66 
67  if (nbPoint > 1)
68  {
69  vpDisplay::displayLine(I,lastPoint, iP, color, thickness);
70  }
71 #if defined (VISP_HAVE_DISPLAY)
72  double top;
73  double left;
74  double width;
75  double height;
76 
77  if (iP.get_i() <= lastPoint.get_i()) {top = iP.get_i()-5; height = lastPoint.get_i() - top+10;}
78  else {top = lastPoint.get_i()-5; height = iP.get_i() - top+10;}
79  if (iP.get_j() <= lastPoint.get_j()) {left = iP.get_j()-5; width = lastPoint.get_j() - left+10;}
80  else {left = lastPoint.get_j()-5; width = iP.get_j() - left+10;}
81  vpDisplay::flushROI(I,vpRect(left,top,width,height));
82 #endif
83  lastPoint = iP;
84  pointListx.push_back(x);
85  pointListy.push_back(y);
86  pointListz.push_back(0.0);
87 }
88 
89 void
90 vpPlotCurve::plotList(const vpImage<unsigned char> &I, const double xorg, const double yorg, const double zoomx, const double zoomy)
91 {
92  std::list<double>::const_iterator it_ptListx = pointListx.begin();
93  std::list<double>::const_iterator it_ptListy = pointListy.begin();
94 
95  unsigned int k = 0;
96  vpImagePoint iP;
97  while (k < nbPoint)
98  {
99  iP.set_ij(yorg-(zoomy*(*it_ptListy)),xorg+(zoomx*(*it_ptListx)));
100 
101  if (k > 0)
102  vpDisplay::displayLine(I,lastPoint, iP, color, thickness);
103 
104  lastPoint = iP;
105 
106  ++it_ptListx;
107  ++it_ptListy;
108  k++;
109  }
110 }
111 
112 #elif !defined(VISP_BUILD_SHARED_LIBS)
113 // Work arround to avoid warning: libvisp_core.a(vpPlotCurve.cpp.o) has no symbols
114 void dummy_vpPlotCurve() {};
115 #endif
116 #endif
double get_i() const
Definition: vpImagePoint.h:199
Class to define colors available for display functionnalities.
Definition: vpColor.h:121
double get_j() const
Definition: vpImagePoint.h:210
Defines a rectangle in the plane.
Definition: vpRect.h:82
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 ...
Definition: vpImagePoint.h:88
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
void set_ij(const double ii, const double jj)
Definition: vpImagePoint.h:185