Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpDisplay.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  * Image display.
32  *
33  * Authors:
34  * Eric Marchand
35  * Fabien Spindler
36  *
37  *****************************************************************************/
38 
39 #include <limits>
40 
41 #include <visp3/core/vpDisplay.h>
42 #include <visp3/core/vpDisplayException.h>
43 #include <visp3/core/vpImageConvert.h>
44 
45 #include <visp3/core/vpPoint.h>
46 #include <visp3/core/vpMeterPixelConversion.h>
47 #include <visp3/core/vpMath.h>
48 
58  : m_displayHasBeenInitialized(false), m_windowXPosition(0), m_windowYPosition(0),
59  m_width(0), m_height(0), m_title(), m_scale(1), m_scaleType(SCALE_DEFAULT)
60 {
61 }
62 
67  : m_displayHasBeenInitialized(false), m_windowXPosition(0), m_windowYPosition(0),
68  m_width(0), m_height(0), m_title(), m_scale(1)
69 {
73 
74  m_width = d.m_width;
75  m_height = d.m_height;
76  m_title = d.m_title;
77  m_scale = d.m_scale;
79 }
80 
85 {
87 }
88 
154 void
156 {
157  if ( Isrc.display != NULL )
158  {
159  ( Isrc.display )->getImage ( Idest ) ;
160  }
161  else
162  {
163  vpImageConvert::convert(Isrc, Idest);
164  }
165 }
166 
232 void
234 {
235  if ( Isrc.display != NULL )
236  {
237  ( Isrc.display )->getImage ( Idest ) ;
238  }
239  else {
240  Idest = Isrc;
241  }
242 }
243 
248 void vpDisplay::setDownScalingFactor(unsigned int scale)
249 {
251  m_scale = scale;
252  else {
253  std::cout << "Warning: Cannot apply the down scaling factor " << scale << " to the display window since the display is initialized yet..." << std::endl;
254  }
255 }
256 
263 unsigned int vpDisplay::computeAutoScale(unsigned int width, unsigned int height)
264 {
265  unsigned int screen_width, screen_height;
266  getScreenSize(screen_width, screen_height);
267  double wscale = std::max(1., ceil(2.*(double)width / (double)screen_width));
268  double hscale = std::max(1., ceil(2.*(double)height / (double)screen_height));
269  unsigned int scale = (unsigned int)std::max(1u, std::max((unsigned int)wscale, (unsigned int)hscale));
270  return scale;
271 }
272 
276 void vpDisplay::setScale(vpScaleType scaleType, unsigned int width, unsigned int height)
277 {
278  switch (scaleType) {
280  setDownScalingFactor( computeAutoScale(width, height) );
281  break;
283  case vpDisplay::SCALE_1:
284  break;
285  case vpDisplay::SCALE_2:
287  break;
288  case vpDisplay::SCALE_3:
290  break;
291  case vpDisplay::SCALE_4:
293  break;
294  case vpDisplay::SCALE_5:
296  break;
297  case vpDisplay::SCALE_6:
299  break;
300  case vpDisplay::SCALE_7:
302  break;
303  case vpDisplay::SCALE_8:
305  break;
306  case vpDisplay::SCALE_9:
308  break;
309  case vpDisplay::SCALE_10:
311  break;
312  }
313 }
314 
341 {
343  m_scaleType = scaleType;
344 }
unsigned int m_height
Definition: vpDisplay.h:196
vpDisplay * display
Definition: vpImage.h:135
int m_windowYPosition
display position
Definition: vpDisplay.h:194
Class that defines generic functionnalities for display.
Definition: vpDisplay.h:169
unsigned int computeAutoScale(unsigned int width, unsigned int height)
Definition: vpDisplay.cpp:263
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
virtual void setDownScalingFactor(unsigned int scale)
Definition: vpDisplay.cpp:248
bool m_displayHasBeenInitialized
display has been initialized
Definition: vpDisplay.h:190
int m_windowXPosition
display position
Definition: vpDisplay.h:192
unsigned int m_scale
Definition: vpDisplay.h:198
void setScale(vpScaleType scaleType, unsigned int width, unsigned int height)
Definition: vpDisplay.cpp:276
vpScaleType m_scaleType
Definition: vpDisplay.h:199
std::string m_title
Definition: vpDisplay.h:197
virtual ~vpDisplay()
Definition: vpDisplay.cpp:84
static void getImage(const vpImage< unsigned char > &Is, vpImage< vpRGBa > &Id)
Definition: vpDisplay.cpp:155
unsigned int m_width
Definition: vpDisplay.h:195
vpScaleType
Values that could be applied to a display to down scale the size of the display.
Definition: vpDisplay.h:173
Definition of the vpImage class member functions.
Definition: vpImage.h:117