Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpDisplay.cpp
1
/*
2
* ViSP, open source Visual Servoing Platform software.
3
* Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4
*
5
* This software is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
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 https://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
38
39
#include <visp3/core/vpDisplay.h>
40
#include <visp3/core/vpDisplayException.h>
41
#include <visp3/core/vpImageConvert.h>
42
43
#include <visp3/core/vpMath.h>
44
#include <visp3/core/vpMeterPixelConversion.h>
45
#include <visp3/core/vpPoint.h>
46
47
BEGIN_VISP_NAMESPACE
51
vpDisplay::vpDisplay
()
52
:
m_displayHasBeenInitialized
(false),
m_windowXPosition
(0),
m_windowYPosition
(0),
m_width
(0),
m_height
(0),
m_title
(),
53
m_scale
(1),
m_scaleType
(
SCALE_DEFAULT
)
54
{ }
55
59
vpDisplay::vpDisplay
(
const
vpDisplay
&d)
60
:
m_displayHasBeenInitialized
(d.
m_displayHasBeenInitialized
),
m_windowXPosition
(d.
m_windowXPosition
),
61
m_windowYPosition
(d.
m_windowYPosition
),
m_width
(d.
m_width
),
m_height
(d.
m_height
),
m_title
(d.
m_title
),
62
m_scale
(d.
m_scale
),
m_scaleType
(d.
m_scaleType
)
63
{ }
64
68
vpDisplay::~vpDisplay
() {
m_displayHasBeenInitialized
=
false
; }
69
139
void
vpDisplay::getImage
(
const
vpImage<unsigned char>
&Isrc,
vpImage<vpRGBa>
&Idest)
140
{
141
if
(Isrc.
display
!=
nullptr
) {
142
(Isrc.
display
)->
getImage
(Idest);
143
}
144
else
{
145
vpImageConvert::convert
(Isrc, Idest);
146
}
147
}
148
217
void
vpDisplay::getImage
(
const
vpImage<vpRGBa>
&Isrc,
vpImage<vpRGBa>
&Idest)
218
{
219
if
(Isrc.
display
!=
nullptr
) {
220
(Isrc.
display
)->
getImage
(Idest);
221
}
222
else
{
223
Idest = Isrc;
224
}
225
}
226
232
void
vpDisplay::setDownScalingFactor
(
unsigned
int
scale)
233
{
234
if
(!
m_displayHasBeenInitialized
) {
235
m_scale
= scale;
236
}
237
else
{
238
std::cout <<
"Warning: Cannot apply the down scaling factor "
<< scale
239
<<
" to the display window since the display is initialized yet..."
<< std::endl;
240
}
241
}
242
250
unsigned
int
vpDisplay::computeAutoScale
(
unsigned
int
width,
unsigned
int
height)
251
{
252
unsigned
int
screen_width, screen_height;
253
getScreenSize(screen_width, screen_height);
254
double
wscale = std::max<double>(1., ceil((2. *
static_cast<
double
>
(width)) /
static_cast<
double
>
(screen_width)));
255
double
hscale = std::max<double>(1., ceil((2. *
static_cast<
double
>
(height)) /
static_cast<
double
>
(screen_height)));
256
unsigned
int
scale = std::max<unsigned int>(1u, std::max<unsigned int>(
static_cast<
unsigned
int
>
(wscale),
static_cast<
unsigned
int
>
(hscale)));
257
return
scale;
258
}
259
263
void
vpDisplay::setScale
(
vpScaleType
scaleType,
unsigned
int
width,
unsigned
int
height)
264
{
265
switch
(scaleType) {
266
case
vpDisplay::SCALE_AUTO
:
267
setDownScalingFactor
(
computeAutoScale
(width, height));
268
break
;
269
case
vpDisplay::SCALE_DEFAULT
:
270
case
vpDisplay::SCALE_1
:
271
break
;
272
case
vpDisplay::SCALE_2
:
273
setDownScalingFactor
(2);
274
break
;
275
case
vpDisplay::SCALE_3
:
276
setDownScalingFactor
(3);
277
break
;
278
case
vpDisplay::SCALE_4
:
279
setDownScalingFactor
(4);
280
break
;
281
case
vpDisplay::SCALE_5
:
282
setDownScalingFactor
(5);
283
break
;
284
case
vpDisplay::SCALE_6
:
285
setDownScalingFactor
(6);
286
break
;
287
case
vpDisplay::SCALE_7
:
288
setDownScalingFactor
(7);
289
break
;
290
case
vpDisplay::SCALE_8
:
291
setDownScalingFactor
(8);
292
break
;
293
case
vpDisplay::SCALE_9
:
294
setDownScalingFactor
(9);
295
break
;
296
case
vpDisplay::SCALE_10
:
297
setDownScalingFactor
(10);
298
break
;
299
default
: {
300
throw
(
vpException
(
vpException::fatalError
,
"Unsupported scale type in vpDisplay::setScale()"
));
301
}
302
}
303
}
304
335
void
vpDisplay::setDownScalingFactor
(
vpScaleType
scaleType)
336
{
337
if
(!
m_displayHasBeenInitialized
) {
338
m_scaleType
= scaleType;
339
}
340
}
341
END_VISP_NAMESPACE
vpDisplay::m_height
unsigned int m_height
Definition
vpDisplay.h:928
vpDisplay::m_scaleType
vpScaleType m_scaleType
Definition
vpDisplay.h:931
vpDisplay::m_width
unsigned int m_width
Definition
vpDisplay.h:927
vpDisplay::setDownScalingFactor
virtual void setDownScalingFactor(unsigned int scale)
Definition
vpDisplay.cpp:232
vpDisplay::~vpDisplay
virtual ~vpDisplay()
Definition
vpDisplay.cpp:68
vpDisplay::m_windowXPosition
int m_windowXPosition
display position
Definition
vpDisplay.h:924
vpDisplay::m_title
std::string m_title
Definition
vpDisplay.h:929
vpDisplay::getImage
static void getImage(const vpImage< unsigned char > &Is, vpImage< vpRGBa > &Id)
Definition
vpDisplay.cpp:139
vpDisplay::m_windowYPosition
int m_windowYPosition
display position
Definition
vpDisplay.h:926
vpDisplay::m_scale
unsigned int m_scale
Definition
vpDisplay.h:930
vpDisplay::vpScaleType
vpScaleType
Definition
vpDisplay.h:176
vpDisplay::SCALE_7
@ SCALE_7
Definition
vpDisplay.h:190
vpDisplay::SCALE_AUTO
@ SCALE_AUTO
Definition
vpDisplay.h:177
vpDisplay::SCALE_6
@ SCALE_6
Definition
vpDisplay.h:188
vpDisplay::SCALE_10
@ SCALE_10
Definition
vpDisplay.h:196
vpDisplay::SCALE_4
@ SCALE_4
Definition
vpDisplay.h:184
vpDisplay::SCALE_1
@ SCALE_1
Definition
vpDisplay.h:179
vpDisplay::SCALE_8
@ SCALE_8
Definition
vpDisplay.h:192
vpDisplay::SCALE_3
@ SCALE_3
Definition
vpDisplay.h:182
vpDisplay::SCALE_5
@ SCALE_5
Definition
vpDisplay.h:186
vpDisplay::SCALE_2
@ SCALE_2
Definition
vpDisplay.h:180
vpDisplay::SCALE_9
@ SCALE_9
Definition
vpDisplay.h:194
vpDisplay::SCALE_DEFAULT
@ SCALE_DEFAULT
Definition
vpDisplay.h:198
vpDisplay::m_displayHasBeenInitialized
bool m_displayHasBeenInitialized
display has been initialized
Definition
vpDisplay.h:922
vpDisplay::vpDisplay
vpDisplay()
Definition
vpDisplay.cpp:51
vpDisplay::computeAutoScale
unsigned int computeAutoScale(unsigned int width, unsigned int height)
Definition
vpDisplay.cpp:250
vpDisplay::setScale
void setScale(vpScaleType scaleType, unsigned int width, unsigned int height)
Definition
vpDisplay.cpp:263
vpException
error that can be emitted by ViSP classes.
Definition
vpException.h:60
vpException::fatalError
@ fatalError
Fatal error.
Definition
vpException.h:72
vpImageConvert::convert
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
Definition
vpImageConvert.cpp:73
vpImage
Definition of the vpImage class member functions.
Definition
vpImage.h:131
vpImage::display
vpDisplay * display
Definition
vpImage.h:136
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
core
src
display
vpDisplay.cpp
Generated by
1.17.0