Visual Servoing Platform
version 3.6.0
Loading...
Searching...
No Matches
vpDisplay.cpp
1
/****************************************************************************
2
*
3
* ViSP, open source Visual Servoing Platform software.
4
* Copyright (C) 2005 - 2023 by Inria. All rights reserved.
5
*
6
* This software is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
10
* See the file LICENSE.txt at the root directory of this source
11
* distribution for additional information about the GNU GPL.
12
*
13
* For using ViSP with software that can not be combined with the GNU
14
* GPL, please contact Inria about acquiring a ViSP Professional
15
* Edition License.
16
*
17
* See https://visp.inria.fr for more information.
18
*
19
* This software was developed at:
20
* Inria Rennes - Bretagne Atlantique
21
* Campus Universitaire de Beaulieu
22
* 35042 Rennes Cedex
23
* France
24
*
25
* If you have questions regarding the use of this file, please contact
26
* Inria at visp@inria.fr
27
*
28
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30
*
31
* Description:
32
* Image display.
33
*
34
*****************************************************************************/
35
36
#include <limits>
37
38
#include <visp3/core/vpDisplay.h>
39
#include <visp3/core/vpDisplayException.h>
40
#include <visp3/core/vpImageConvert.h>
41
42
#include <visp3/core/vpMath.h>
43
#include <visp3/core/vpMeterPixelConversion.h>
44
#include <visp3/core/vpPoint.h>
45
54
vpDisplay::vpDisplay
()
55
: m_displayHasBeenInitialized(false), m_windowXPosition(0), m_windowYPosition(0), m_width(0), m_height(0), m_title(),
56
m_scale(1), m_scaleType(SCALE_DEFAULT)
57
{ }
58
62
vpDisplay::vpDisplay
(
const
vpDisplay
&d)
63
: m_displayHasBeenInitialized(d.m_displayHasBeenInitialized), m_windowXPosition(d.m_windowXPosition),
64
m_windowYPosition(d.m_windowYPosition), m_width(d.m_width), m_height(d.m_height), m_title(d.m_title),
65
m_scale(d.m_scale), m_scaleType(d.m_scaleType)
66
{ }
67
71
vpDisplay::~vpDisplay
() {
m_displayHasBeenInitialized
=
false
; }
72
138
void
vpDisplay::getImage
(
const
vpImage<unsigned char>
&Isrc,
vpImage<vpRGBa>
&Idest)
139
{
140
if
(Isrc.
display
!= NULL) {
141
(Isrc.
display
)->
getImage
(Idest);
142
}
143
else
{
144
vpImageConvert::convert
(Isrc, Idest);
145
}
146
}
147
212
void
vpDisplay::getImage
(
const
vpImage<vpRGBa>
&Isrc,
vpImage<vpRGBa>
&Idest)
213
{
214
if
(Isrc.
display
!= NULL) {
215
(Isrc.
display
)->
getImage
(Idest);
216
}
217
else
{
218
Idest = Isrc;
219
}
220
}
221
227
void
vpDisplay::setDownScalingFactor
(
unsigned
int
scale)
228
{
229
if
(!
m_displayHasBeenInitialized
)
230
m_scale
= scale;
231
else
{
232
std::cout <<
"Warning: Cannot apply the down scaling factor "
<< scale
233
<<
" to the display window since the display is initialized yet..."
<< std::endl;
234
}
235
}
236
242
unsigned
int
vpDisplay::computeAutoScale
(
unsigned
int
width,
unsigned
int
height)
243
{
244
unsigned
int
screen_width, screen_height;
245
getScreenSize(screen_width, screen_height);
246
double
wscale = (std::max)(1., ceil(2. * (
double
)width / (
double
)screen_width));
247
double
hscale = (std::max)(1., ceil(2. * (
double
)height / (
double
)screen_height));
248
unsigned
int
scale = (
unsigned
int)(std::max)(1u, (std::max)((
unsigned
int)wscale, (
unsigned
int)hscale));
249
return
scale;
250
}
251
255
void
vpDisplay::setScale
(
vpScaleType
scaleType,
unsigned
int
width,
unsigned
int
height)
256
{
257
switch
(scaleType) {
258
case
vpDisplay::SCALE_AUTO
:
259
setDownScalingFactor
(
computeAutoScale
(width, height));
260
break
;
261
case
vpDisplay::SCALE_DEFAULT
:
262
case
vpDisplay::SCALE_1
:
263
break
;
264
case
vpDisplay::SCALE_2
:
265
setDownScalingFactor
(2);
266
break
;
267
case
vpDisplay::SCALE_3
:
268
setDownScalingFactor
(3);
269
break
;
270
case
vpDisplay::SCALE_4
:
271
setDownScalingFactor
(4);
272
break
;
273
case
vpDisplay::SCALE_5
:
274
setDownScalingFactor
(5);
275
break
;
276
case
vpDisplay::SCALE_6
:
277
setDownScalingFactor
(6);
278
break
;
279
case
vpDisplay::SCALE_7
:
280
setDownScalingFactor
(7);
281
break
;
282
case
vpDisplay::SCALE_8
:
283
setDownScalingFactor
(8);
284
break
;
285
case
vpDisplay::SCALE_9
:
286
setDownScalingFactor
(9);
287
break
;
288
case
vpDisplay::SCALE_10
:
289
setDownScalingFactor
(10);
290
break
;
291
}
292
}
293
320
void
vpDisplay::setDownScalingFactor
(
vpScaleType
scaleType)
321
{
322
if
(!
m_displayHasBeenInitialized
)
323
m_scaleType
= scaleType;
324
}
vpDisplay
Class that defines generic functionalities for display.
Definition
vpDisplay.h:173
vpDisplay::m_scaleType
vpScaleType m_scaleType
Definition
vpDisplay.h:215
vpDisplay::setDownScalingFactor
virtual void setDownScalingFactor(unsigned int scale)
Definition
vpDisplay.cpp:227
vpDisplay::vpDisplay
vpDisplay()
Definition
vpDisplay.cpp:54
vpDisplay::~vpDisplay
virtual ~vpDisplay()
Definition
vpDisplay.cpp:71
vpDisplay::getImage
static void getImage(const vpImage< unsigned char > &Is, vpImage< vpRGBa > &Id)
Definition
vpDisplay.cpp:138
vpDisplay::m_scale
unsigned int m_scale
Definition
vpDisplay.h:214
vpDisplay::vpScaleType
vpScaleType
Definition
vpDisplay.h:178
vpDisplay::SCALE_7
@ SCALE_7
Definition
vpDisplay.h:192
vpDisplay::SCALE_AUTO
@ SCALE_AUTO
Definition
vpDisplay.h:179
vpDisplay::SCALE_6
@ SCALE_6
Definition
vpDisplay.h:190
vpDisplay::SCALE_10
@ SCALE_10
Definition
vpDisplay.h:198
vpDisplay::SCALE_4
@ SCALE_4
Definition
vpDisplay.h:186
vpDisplay::SCALE_1
@ SCALE_1
Definition
vpDisplay.h:181
vpDisplay::SCALE_8
@ SCALE_8
Definition
vpDisplay.h:194
vpDisplay::SCALE_3
@ SCALE_3
Definition
vpDisplay.h:184
vpDisplay::SCALE_5
@ SCALE_5
Definition
vpDisplay.h:188
vpDisplay::SCALE_2
@ SCALE_2
Definition
vpDisplay.h:182
vpDisplay::SCALE_9
@ SCALE_9
Definition
vpDisplay.h:196
vpDisplay::SCALE_DEFAULT
@ SCALE_DEFAULT
Definition
vpDisplay.h:200
vpDisplay::m_displayHasBeenInitialized
bool m_displayHasBeenInitialized
display has been initialized
Definition
vpDisplay.h:206
vpDisplay::computeAutoScale
unsigned int computeAutoScale(unsigned int width, unsigned int height)
Definition
vpDisplay.cpp:242
vpDisplay::setScale
void setScale(vpScaleType scaleType, unsigned int width, unsigned int height)
Definition
vpDisplay.cpp:255
vpImageConvert::convert
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
Definition
vpImageConvert.cpp:68
vpImage
Definition of the vpImage class member functions.
Definition
vpImage.h:135
vpImage::display
vpDisplay * display
Definition
vpImage.h:140
modules
core
src
display
vpDisplay.cpp
Generated by
1.12.0