ViSP  2.9.0
vpPlotCurve.cpp
1 /****************************************************************************
2  *
3  * $Id: vpPlotCurve.cpp 4632 2014-02-03 17:06:40Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2014 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  color(vpColor::red), curveStyle(point), thickness(1), nbPoint(0), lastPoint(),
55  pointListx(), pointListy(), pointListz(), xmin(0), xmax(0), ymin(0), ymax(0)
56 {
57 }
58 
59 vpPlotCurve::~vpPlotCurve()
60 {
61  pointListx.clear();
62  pointListy.clear();
63  pointListz.clear();
64 }
65 
66 void
67 vpPlotCurve::plotPoint(const vpImage<unsigned char> &I, const vpImagePoint &iP, const double x, const double y)
68 {
69  nbPoint++;
70 
71  if (nbPoint > 1)
72  {
73  vpDisplay::displayLine(I,lastPoint, iP, color, thickness);
74  }
75 #if defined (VISP_HAVE_DISPLAY)
76  double top;
77  double left;
78  double width;
79  double height;
80 
81  if (iP.get_i() <= lastPoint.get_i()) {top = iP.get_i()-5; height = lastPoint.get_i() - top+10;}
82  else {top = lastPoint.get_i()-5; height = iP.get_i() - top+10;}
83  if (iP.get_j() <= lastPoint.get_j()) {left = iP.get_j()-5; width = lastPoint.get_j() - left+10;}
84  else {left = lastPoint.get_j()-5; width = iP.get_j() - left+10;}
85  vpDisplay::flushROI(I,vpRect(left,top,width,height));
86 #endif
87  lastPoint = iP;
88  pointListx.push_back(x);
89  pointListy.push_back(y);
90  pointListz.push_back(0.0);
91 }
92 
93 void
94 vpPlotCurve::plotList(const vpImage<unsigned char> &I, const double xorg, const double yorg, const double zoomx, const double zoomy)
95 {
96  std::list<double>::const_iterator it_ptListx = pointListx.begin();
97  std::list<double>::const_iterator it_ptListy = pointListy.begin();
98 
99  unsigned int k = 0;
100  vpImagePoint iP;
101  while (k < nbPoint)
102  {
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 #endif
117 #endif
double get_i() const
Definition: vpImagePoint.h:194
Class to define colors available for display functionnalities.
Definition: vpColor.h:125
double get_j() const
Definition: vpImagePoint.h:205
Defines a rectangle in the plane.
Definition: vpRect.h:85
static void flushROI(const vpImage< unsigned char > &I, const vpRect &roi)
Definition: vpDisplay.cpp:2011
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
void set_ij(const double ii, const double jj)
Definition: vpImagePoint.h:180