Visual Servoing Platform version 3.7.0
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
55
64
69
140{
141 if (Isrc.display != nullptr) {
142 (Isrc.display)->getImage(Idest);
143 }
144 else {
145 vpImageConvert::convert(Isrc, Idest);
146 }
147}
148
218{
219 if (Isrc.display != nullptr) {
220 (Isrc.display)->getImage(Idest);
221 }
222 else {
223 Idest = Isrc;
224 }
225}
226
232void vpDisplay::setDownScalingFactor(unsigned int scale)
233{
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
250unsigned 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
263void vpDisplay::setScale(vpScaleType scaleType, unsigned int width, unsigned int height)
264{
265 switch (scaleType) {
268 break;
271 break;
274 break;
277 break;
280 break;
283 break;
286 break;
289 break;
292 break;
295 break;
298 break;
299 default: {
300 throw(vpException(vpException::fatalError, "Unsupported scale type in vpDisplay::setScale()"));
301 }
302 }
303}
304
336{
338 m_scaleType = scaleType;
339 }
340}
341END_VISP_NAMESPACE
unsigned int m_height
Definition vpDisplay.h:928
vpScaleType m_scaleType
Definition vpDisplay.h:931
unsigned int m_width
Definition vpDisplay.h:927
virtual void setDownScalingFactor(unsigned int scale)
virtual ~vpDisplay()
Definition vpDisplay.cpp:68
int m_windowXPosition
display position
Definition vpDisplay.h:924
std::string m_title
Definition vpDisplay.h:929
static void getImage(const vpImage< unsigned char > &Is, vpImage< vpRGBa > &Id)
int m_windowYPosition
display position
Definition vpDisplay.h:926
unsigned int m_scale
Definition vpDisplay.h:930
@ SCALE_DEFAULT
Definition vpDisplay.h:198
bool m_displayHasBeenInitialized
display has been initialized
Definition vpDisplay.h:922
unsigned int computeAutoScale(unsigned int width, unsigned int height)
void setScale(vpScaleType scaleType, unsigned int width, unsigned int height)
error that can be emitted by ViSP classes.
Definition vpException.h:60
@ fatalError
Fatal error.
Definition vpException.h:72
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
Definition of the vpImage class member functions.
Definition vpImage.h:131
vpDisplay * display
Definition vpImage.h:136