ViSP  2.8.0
vpPlotCurve.cpp
1 /****************************************************************************
2  *
3  * $Id: vpPlotCurve.cpp 4056 2013-01-05 13:04:42Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Define a curve for the vpPlot class.
36  *
37  * Authors:
38  * Nicolas Melchior
39  *
40  *****************************************************************************/
41 #include <visp/vpConfig.h>
42 
43 #ifndef DOXYGEN_SHOULD_SKIP_THIS
44 
45 #include <visp/vpPlotCurve.h>
46 #include <visp/vpDisplayOpenCV.h>
47 #include <visp/vpDisplayX.h>
48 #include <visp/vpDisplayGDI.h>
49 #include <visp/vpDisplayGTK.h>
50 #include <visp/vpDisplayD3D.h>
51 
52 #if defined(VISP_HAVE_DISPLAY)
53 vpPlotCurve::vpPlotCurve()
54 {
55  color = vpColor::red;
56  pointListx.clear();
57  pointListy.clear();
58  pointListz.clear();
59  nbPoint = 0;
60  thickness = 1 ;
61 }
62 
63 vpPlotCurve::~vpPlotCurve()
64 {
65  pointListx.clear();
66  pointListy.clear();
67  pointListz.clear();
68 }
69 
70 void
71 vpPlotCurve::plotPoint(const vpImage<unsigned char> &I, const vpImagePoint &iP, const double x, const double y)
72 {
73  nbPoint++;
74 
75  if (nbPoint > 1)
76  {
77  vpDisplay::displayLine(I,lastPoint, iP, color, thickness);
78  }
79 #if defined (VISP_HAVE_DISPLAY)
80  double top;
81  double left;
82  double width;
83  double height;
84 
85  if (iP.get_i() <= lastPoint.get_i()) {top = iP.get_i()-5; height = lastPoint.get_i() - top+10;}
86  else {top = lastPoint.get_i()-5; height = iP.get_i() - top+10;}
87  if (iP.get_j() <= lastPoint.get_j()) {left = iP.get_j()-5; width = lastPoint.get_j() - left+10;}
88  else {left = lastPoint.get_j()-5; width = iP.get_j() - left+10;}
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 
97 void
98 vpPlotCurve::plotList(const vpImage<unsigned char> &I, const double xorg, const double yorg, const double zoomx, const double zoomy)
99 {
100  std::list<double>::const_iterator it_ptListx = pointListx.begin();
101  std::list<double>::const_iterator it_ptListy = pointListy.begin();
102 
103  unsigned int k = 0;
104  vpImagePoint iP;
105  while (k < nbPoint)
106  {
107  iP.set_ij(yorg-(zoomy*(*it_ptListy)),xorg+(zoomx*(*it_ptListx)));
108 
109  if (k > 0)
110  vpDisplay::displayLine(I,lastPoint, iP, color, thickness);
111 
112  lastPoint = iP;
113 
114  ++it_ptListx;
115  ++it_ptListy;
116  k++;
117  }
118 }
119 
120 #endif
121 #endif
double get_i() const
Definition: vpImagePoint.h:181
double get_j() const
Definition: vpImagePoint.h:192
static const vpColor red
Definition: vpColor.h:167
void set_ij(const double i, const double j)
Definition: vpImagePoint.h:167
Defines a rectangle in the plane.
Definition: vpRect.h:82
static void flushROI(const vpImage< unsigned char > &I, const vpRect &roi)
Definition: vpDisplay.cpp:2008
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:92
virtual void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)=0