MRPT  1.9.9
mrpt::img::CEnhancedMetaFile Class Reference

Detailed Description

This class represents a Windows Enhanced Meta File (EMF) for generating and saving graphics.

If used under Linux, a ".png", non-vectorial, file will be generated instead.

Definition at line 22 of file CEnhancedMetaFile.h.

#include <mrpt/img/CEnhancedMetaFile.h>

Inheritance diagram for mrpt::img::CEnhancedMetaFile:
Inheritance graph

Public Types

enum  TPenStyle {
  psSolid = 0, psDash, psDot, psDashDot,
  psDashDotDot
}
 Definition of pen styles. More...
 

Public Member Functions

 CEnhancedMetaFile (const std::string &targetFileName, int scaleFactor=1)
 Constructor. More...
 
virtual ~CEnhancedMetaFile ()
 Destructor. More...
 
void setPixel (int x, int y, size_t color) override
 Changes the value of the pixel (x,y). More...
 
size_t getWidth () const override
 Returns the width of the image in pixels (this currently has no applicability for a EMF file...) More...
 
size_t getHeight () const override
 Returns the height of the image in pixels (this currently has no applicability for a EMF file...) More...
 
void drawImage (int x, int y, const mrpt::img::CImage &img) override
 Draws an image as a bitmap at a given position. More...
 
void line (int x0, int y0, int x1, int y1, const mrpt::img::TColor color, unsigned int width=1, TPenStyle penStyle=psSolid) override
 Draws a line. More...
 
void textOut (int x0, int y0, const std::string &str, const mrpt::img::TColor color) override
 Places a text label. More...
 
virtual void selectVectorTextFont (const std::string &fontName, int fontSize, bool bold=false, bool italic=false)
 Select the current font used when drawing text. More...
 
void drawImage (int x, int y, const mrpt::img::CImage &img, float rotation, float scale) override
 Draws an image as a bitmap at a given position, with some custom scale and rotation changes. More...
 
virtual void rectangle (int x0, int y0, int x1, int y1, const mrpt::img::TColor color, unsigned int width=1)
 Draws a rectangle (an empty rectangle, without filling) More...
 
template<class T >
void ellipseGaussian (math::CMatrixTemplateNumeric< T > *cov2D, T mean_x, T mean_y, float confIntervalStds=2, const mrpt::img::TColor &color=mrpt::img::TColor(255, 255, 255), unsigned int width=1, int nEllipsePoints=20)
 Draws an ellipse representing a given confidence interval of a 2D Gaussian distribution. More...
 
void triangle (int x0, int y0, int size, const mrpt::img::TColor color, bool inferior=true, unsigned int width=1)
 Draws a triangle. More...
 
virtual void filledRectangle (int x0, int y0, int x1, int y1, const mrpt::img::TColor color)
 Draws a filled rectangle. More...
 
virtual void selectTextFont (const std::string &fontName)
 Select the current font used when drawing text. More...
 
void cross (int x0, int y0, const mrpt::img::TColor color, char type, unsigned int size=5, unsigned int width=1)
 Draw a cross. More...
 
virtual void drawCircle (int x, int y, int radius, const mrpt::img::TColor &color=mrpt::img::TColor(255, 255, 255), unsigned int width=1)
 Draws a circle of a given radius. More...
 
template<class MATRIX2X2 >
void ellipseGaussian (const MATRIX2X2 *cov2D, const double mean_x, const double mean_y, double confIntervalStds=2, const mrpt::img::TColor &color=mrpt::img::TColor(255, 255, 255), unsigned int width=1, int nEllipsePoints=20)
 Draws an ellipse representing a given confidence interval of a 2D Gaussian distribution. More...
 
template<class FEATURELIST >
void drawFeaturesSimple (const FEATURELIST &list, const TColor &color=TColor::red(), const int cross_size=5)
 Draws a set of marks onto the image, given a generic container of entities having just "x" and "y" fields. More...
 
template<class FEATURELIST >
void drawFeatures (const FEATURELIST &list, const TColor &color=TColor::red(), const bool showIDs=false, const bool showResponse=false)
 Draws a set of marks (or scaled circles for features with scale) onto the image, given a generic container of features. More...
 

Static Public Member Functions

static void LINUX_IMG_WIDTH (int value)
 In Linux, the size of the bitmap image that emulates the EMF (Default:800) More...
 
static int LINUX_IMG_WIDTH ()
 
static void LINUX_IMG_HEIGHT (int value)
 In Linux, the size of the bitmap image that emulates the EMF (Default:600) More...
 
static int LINUX_IMG_HEIGHT ()
 

Protected Attributes

std::string m_selectedFont
 The selected font name. More...
 
const uint32_tm_selectedFontBitmaps
 Direct access to character bitmaps. More...
 

Private Attributes

void_ptr_noncopy m_hdc
 
int m_scale
 
void_ptr_noncopy m_hFont {nullptr}
 
std::string m_targetFile
 

Member Enumeration Documentation

◆ TPenStyle

enum mrpt::img::CCanvas::TPenStyle
inherited

Definition of pen styles.

Enumerator
psSolid 
psDash 
psDot 
psDashDot 
psDashDotDot 

Definition at line 54 of file CCanvas.h.

Constructor & Destructor Documentation

◆ CEnhancedMetaFile()

CEnhancedMetaFile::CEnhancedMetaFile ( const std::string targetFileName,
int  scaleFactor = 1 
)

Constructor.

Parameters
targetFileNameThis file will be created and the EMF saved there.
scaleFactorAll coordinates in draw commands will be internally multiplied by this scale, to provide a way of obtaining "subpixel" drawing.

Definition at line 43 of file CEnhancedMetaFile.cpp.

References mrpt::img::CCanvas::filledRectangle(), mrpt::non_copiable_ptr_basic< T >::get(), LINUX_IMG_HEIGHT_value, LINUX_IMG_WIDTH_value, m_hdc, and THROW_EXCEPTION.

◆ ~CEnhancedMetaFile()

CEnhancedMetaFile::~CEnhancedMetaFile ( )
virtual

Destructor.

Definition at line 63 of file CEnhancedMetaFile.cpp.

References mrpt::non_copiable_ptr_basic< T >::get(), m_hdc, m_hFont, and m_targetFile.

Member Function Documentation

◆ cross()

void CCanvas::cross ( int  x0,
int  y0,
const mrpt::img::TColor  color,
char  type,
unsigned int  size = 5,
unsigned int  width = 1 
)
inherited

Draw a cross.

Parameters
x0The point x coordinate
y0The point y coordinate
colorThe color of the cross
sizeThe size of the cross
typeThe cross type. It could be: 'x', '+' or ':'(like '+' but clear at the center dot)
widthThe desired width of the cross (this is IGNORED yet)

Definition at line 305 of file CCanvas.cpp.

References mrpt::img::CCanvas::line(), and THROW_EXCEPTION.

Referenced by mrpt::img::CCanvas::drawFeatures(), mrpt::img::CCanvas::drawFeaturesSimple(), find_chessboard_corners_multiple(), and mrpt::gui::CDisplayWindow::plot().

◆ drawCircle()

void CCanvas::drawCircle ( int  x,
int  y,
int  radius,
const mrpt::img::TColor color = mrpt::img::TColor(255, 255, 255),
unsigned int  width = 1 
)
virtualinherited

Draws a circle of a given radius.

Parameters
xThe center - x coordinate in pixels.
yThe center - y coordinate in pixels.
radiusThe radius - in pixels.
colorThe color of the circle.
widthThe desired width of the line (this is IGNORED in this virtual class)

Reimplemented in mrpt::img::CImage.

Definition at line 333 of file CCanvas.cpp.

References mrpt::img::CCanvas::line(), M_2PI, and mrpt::round().

Referenced by mrpt::img::CCanvas::drawFeatures().

◆ drawFeatures()

template<class FEATURELIST >
void mrpt::img::CCanvas::drawFeatures ( const FEATURELIST &  list,
const TColor color = TColor::red(),
const bool  showIDs = false,
const bool  showResponse = false 
)
inlineinherited

Draws a set of marks (or scaled circles for features with scale) onto the image, given a generic container of features.

The class of FEATURELIST can be:

See also
drawFeaturesSimple

Definition at line 321 of file CCanvas.h.

References mrpt::img::CCanvas::cross(), mrpt::img::CCanvas::drawCircle(), mrpt::format(), mrpt::img::TColor::red(), mrpt::round(), and mrpt::img::CCanvas::textOut().

◆ drawFeaturesSimple()

template<class FEATURELIST >
void mrpt::img::CCanvas::drawFeaturesSimple ( const FEATURELIST &  list,
const TColor color = TColor::red(),
const int  cross_size = 5 
)
inlineinherited

Draws a set of marks onto the image, given a generic container of entities having just "x" and "y" fields.

The class of FEATURELIST can be, for example, std::vector<mrpt::math::TPoint2D>, std::vector<TPixelCoordsf> or mrpt::vision::CFeatureList

See also
drawFeatures

Definition at line 300 of file CCanvas.h.

References mrpt::img::CCanvas::cross(), and mrpt::round().

◆ drawImage() [1/2]

void CEnhancedMetaFile::drawImage ( int  x,
int  y,
const mrpt::img::CImage img 
)
overridevirtual

Draws an image as a bitmap at a given position.

Parameters
x0The top-left corner x coordinates on this canvas where the image is to be drawn
y0The top-left corner y coordinates on this canvas where the image is to be drawn
imgThe image to be drawn in this canvas This method may be redefined in some classes implementing this interface in a more appropiate manner.

Reimplemented from mrpt::img::CCanvas.

Definition at line 86 of file CEnhancedMetaFile.cpp.

References ASSERT_, mrpt::non_copiable_ptr_basic< T >::get(), m_hdc, m_scale, and THROW_EXCEPTION.

Referenced by mrpt::slam::CMetricMapBuilderICP::saveCurrentEstimationToImage().

◆ drawImage() [2/2]

void mrpt::img::CEnhancedMetaFile::drawImage ( int  x,
int  y,
const mrpt::img::CImage img,
float  rotation,
float  scale 
)
inlineoverridevirtual

Draws an image as a bitmap at a given position, with some custom scale and rotation changes.

Parameters
x0The top-left corner x coordinates on this canvas where the image is to be drawn
y0The top-left corner y coordinates on this canvas where the image is to be drawn
rotationThe rotation in radians, positive values being anti-clockwise direction, 0 is the normal position.
scaleThe scale factor, e.g. 2 means twice the original size.
imgThe image to be drawn in this canvas This method may be redefined in some classes implementing this interface in a more appropiate manner.

Reimplemented from mrpt::img::CCanvas.

Definition at line 135 of file CEnhancedMetaFile.h.

References mrpt::img::CCanvas::drawImage().

◆ ellipseGaussian() [1/2]

template<class T >
void mrpt::img::CEnhancedMetaFile::ellipseGaussian ( math::CMatrixTemplateNumeric< T > *  cov2D,
mean_x,
mean_y,
float  confIntervalStds = 2,
const mrpt::img::TColor color = mrpt::img::TColor(255, 255, 255),
unsigned int  width = 1,
int  nEllipsePoints = 20 
)
inline

Draws an ellipse representing a given confidence interval of a 2D Gaussian distribution.

Parameters
mean_xThe x coordinate of the center point of the ellipse.
mean_yThe y coordinate of the center point of the ellipse.
cov2DA 2x2 covariance matrix.
confIntervalStdsHow many "sigmas" for the confidence level (i.e. 2->95%, 3=99.97%,...)
colorThe color of the ellipse
widthThe desired width of the line (this is IGNORED in this virtual class)
nEllipsePointsThe number of points to generate to approximate the ellipse shape.
Exceptions
std::exceptionOn an invalid matrix.

Definition at line 170 of file CEnhancedMetaFile.h.

References line(), M_2PI, MRPT_END_WITH_CLEAN_UP, MRPT_START, and mrpt::round().

◆ ellipseGaussian() [2/2]

template<class MATRIX2X2 >
void mrpt::img::CCanvas::ellipseGaussian ( const MATRIX2X2 *  cov2D,
const double  mean_x,
const double  mean_y,
double  confIntervalStds = 2,
const mrpt::img::TColor color = mrpt::img::TColor(255, 255, 255),
unsigned int  width = 1,
int  nEllipsePoints = 20 
)
inlineinherited

Draws an ellipse representing a given confidence interval of a 2D Gaussian distribution.

Parameters
mean_xThe x coordinate of the center point of the ellipse.
mean_yThe y coordinate of the center point of the ellipse.
cov2DA 2x2 covariance matrix.
confIntervalStdsHow many "sigmas" for the confidence level (i.e. 2->95%, 3=99.97%,...)
colorThe color of the ellipse
widthThe desired width of the line (this is IGNORED in this virtual class)
nEllipsePointsThe number of points to generate to approximate the ellipse shape.
Exceptions
std::exceptionOn an invalid matrix.

Definition at line 250 of file CCanvas.h.

References mrpt::img::CCanvas::line(), M_2PI, MRPT_END_WITH_CLEAN_UP, MRPT_START, and mrpt::round().

◆ filledRectangle()

void CCanvas::filledRectangle ( int  x0,
int  y0,
int  x1,
int  y1,
const mrpt::img::TColor  color 
)
virtualinherited

Draws a filled rectangle.

Parameters
x0The top-left x coordinate
y0The top-left y coordinate
x1The right-bottom x coordinate
y1The right-bottom y coordinate
colorThe color of the rectangle fill This method may be redefined in some classes implementing this interface in a more appropiate manner.
See also
rectangle

Definition at line 214 of file CCanvas.cpp.

References mrpt::img::CCanvas::getHeight(), mrpt::img::CCanvas::getWidth(), min, and mrpt::img::CCanvas::setPixel().

Referenced by mrpt::slam::CGridMapAligner::AlignPDF_robustMatch(), CEnhancedMetaFile(), and mrpt::gui::CDisplayWindow::plot().

◆ getHeight()

size_t mrpt::img::CEnhancedMetaFile::getHeight ( ) const
inlineoverridevirtual

Returns the height of the image in pixels (this currently has no applicability for a EMF file...)

Implements mrpt::img::CCanvas.

Definition at line 70 of file CEnhancedMetaFile.h.

◆ getWidth()

size_t mrpt::img::CEnhancedMetaFile::getWidth ( ) const
inlineoverridevirtual

Returns the width of the image in pixels (this currently has no applicability for a EMF file...)

Implements mrpt::img::CCanvas.

Definition at line 67 of file CEnhancedMetaFile.h.

◆ line()

void CEnhancedMetaFile::line ( int  x0,
int  y0,
int  x1,
int  y1,
const mrpt::img::TColor  color,
unsigned int  width = 1,
TPenStyle  penStyle = psSolid 
)
overridevirtual

Draws a line.

Parameters
x0The starting point x coordinate
y0The starting point y coordinate
x1The end point x coordinate
y1The end point y coordinate
colorThe color of the line
widthThe desired width of the line (this is IGNORED in this virtual class) This method may be redefined in some classes implementing this interface in a more appropiate manner.

Reimplemented from mrpt::img::CCanvas.

Definition at line 169 of file CEnhancedMetaFile.cpp.

References mrpt::non_copiable_ptr_basic< T >::get(), m_hdc, and m_scale.

Referenced by ellipseGaussian(), rectangle(), and mrpt::slam::CMetricMapBuilderICP::saveCurrentEstimationToImage().

◆ LINUX_IMG_HEIGHT() [1/2]

void CEnhancedMetaFile::LINUX_IMG_HEIGHT ( int  value)
static

In Linux, the size of the bitmap image that emulates the EMF (Default:600)

Definition at line 33 of file CEnhancedMetaFile.cpp.

References LINUX_IMG_HEIGHT_value.

◆ LINUX_IMG_HEIGHT() [2/2]

int CEnhancedMetaFile::LINUX_IMG_HEIGHT ( )
static

Definition at line 37 of file CEnhancedMetaFile.cpp.

References LINUX_IMG_HEIGHT_value.

◆ LINUX_IMG_WIDTH() [1/2]

void CEnhancedMetaFile::LINUX_IMG_WIDTH ( int  value)
static

In Linux, the size of the bitmap image that emulates the EMF (Default:800)

Definition at line 28 of file CEnhancedMetaFile.cpp.

References LINUX_IMG_WIDTH_value.

◆ LINUX_IMG_WIDTH() [2/2]

int CEnhancedMetaFile::LINUX_IMG_WIDTH ( )
static

Definition at line 32 of file CEnhancedMetaFile.cpp.

References LINUX_IMG_WIDTH_value.

◆ rectangle()

void CEnhancedMetaFile::rectangle ( int  x0,
int  y0,
int  x1,
int  y1,
const mrpt::img::TColor  color,
unsigned int  width = 1 
)
virtual

Draws a rectangle (an empty rectangle, without filling)

Parameters
x0The top-left x coordinate
y0The top-left y coordinate
x1The right-bottom x coordinate
y1The right-bottom y coordinate
colorThe color of the line
widthThe desired width of the line.
See also
filledRectangle

Definition at line 269 of file CEnhancedMetaFile.cpp.

References line().

◆ selectTextFont()

void CCanvas::selectTextFont ( const std::string fontName)
virtualinherited

Select the current font used when drawing text.

Parameters
fontNameThe name of the font

Valid font names:

  • 5x7
  • 6x13
  • 6x13B
  • 6x13O
  • 9x15 (Default at start-up)
  • 9x15B
  • 10x20
  • 18x18ja (Asian characters for UTF-8 strings - Only available if MRPT is built with MRPT_HAS_ASIAN_FONTS = true)

See also
textOut, The example in this page.

Definition at line 229 of file CCanvas.cpp.

References init_fonts_list(), list_registered_fonts, mrpt::img::CCanvas::m_selectedFont, and mrpt::img::CCanvas::m_selectedFontBitmaps.

Referenced by mrpt::img::CImage::drawChessboardCorners(), selectVectorTextFont(), and mrpt::img::CCanvas::textOut().

◆ selectVectorTextFont()

void CEnhancedMetaFile::selectVectorTextFont ( const std::string fontName,
int  fontSize,
bool  bold = false,
bool  italic = false 
)
virtual

Select the current font used when drawing text.

Parameters
fontNameThe face name of a font (e.g. "Arial","System",...)
fontSizeThe size of the font in pts.
boldWhether the font is bold
italicWhether the font is italic
See also
textOut, CCanvas::selectTextFont

Definition at line 215 of file CEnhancedMetaFile.cpp.

References mrpt::non_copiable_ptr_basic< T >::get(), m_hdc, MRPT_TRY_END, MRPT_TRY_START, MRPT_UNUSED_PARAM, mrpt::img::CCanvas::selectTextFont(), and mrpt::system::os::strcpy().

◆ setPixel()

void CEnhancedMetaFile::setPixel ( int  x,
int  y,
size_t  color 
)
overridevirtual

Changes the value of the pixel (x,y).

Pixel coordinates starts at the left-top corner of the image, and start in (0,0). The meaning of the parameter "color" depends on the implementation: it will usually be a 24bit RGB value (0x00RRGGBB), but it can also be just a 8bit gray level. This method must support (x,y) values OUT of the actual image size without neither raising exceptions, nor leading to memory access errors.

Implements mrpt::img::CCanvas.

Definition at line 257 of file CEnhancedMetaFile.cpp.

References mrpt::non_copiable_ptr_basic< T >::get(), m_hdc, and m_scale.

◆ textOut()

void CEnhancedMetaFile::textOut ( int  x0,
int  y0,
const std::string str,
const mrpt::img::TColor  color 
)
overridevirtual

Places a text label.

Parameters
x0The x coordinates
y0The y coordinates
strThe string to put
colorThe text color
fontSizeThe font size, in "points" This method may be redefined in some classes implementing this interface in a more appropiate manner.
See also
rectangle

Reimplemented from mrpt::img::CCanvas.

Definition at line 196 of file CEnhancedMetaFile.cpp.

References mrpt::non_copiable_ptr_basic< T >::get(), m_hdc, and m_scale.

◆ triangle()

void CCanvas::triangle ( int  x0,
int  y0,
int  size,
const mrpt::img::TColor  color,
bool  inferior = true,
unsigned int  width = 1 
)
inherited

Draws a triangle.

Parameters
x0The triangle center x coordinate
y0The triangle center y coordinate
sizeThe size of the triangle
colorThe color of the line
inferiorThe position of the triangle
widthThe desired width of the line.
See also
triangle

Definition at line 190 of file CCanvas.cpp.

References mrpt::img::CCanvas::line(), and mrpt::round().

Member Data Documentation

◆ m_hdc

void_ptr_noncopy mrpt::img::CEnhancedMetaFile::m_hdc
private

◆ m_hFont

void_ptr_noncopy mrpt::img::CEnhancedMetaFile::m_hFont {nullptr}
private

Definition at line 27 of file CEnhancedMetaFile.h.

Referenced by ~CEnhancedMetaFile().

◆ m_scale

int mrpt::img::CEnhancedMetaFile::m_scale
private

Definition at line 26 of file CEnhancedMetaFile.h.

Referenced by drawImage(), line(), setPixel(), and textOut().

◆ m_selectedFont

std::string mrpt::img::CCanvas::m_selectedFont
protectedinherited

The selected font name.

Definition at line 44 of file CCanvas.h.

Referenced by mrpt::img::CCanvas::selectTextFont().

◆ m_selectedFontBitmaps

const uint32_t* mrpt::img::CCanvas::m_selectedFontBitmaps
protectedinherited

Direct access to character bitmaps.

Definition at line 47 of file CCanvas.h.

Referenced by mrpt::img::CCanvas::selectTextFont(), and mrpt::img::CCanvas::textOut().

◆ m_targetFile

std::string mrpt::img::CEnhancedMetaFile::m_targetFile
private

Definition at line 28 of file CEnhancedMetaFile.h.

Referenced by ~CEnhancedMetaFile().




Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020