ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvImage.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // Local
11 #include "ecvHObject.h"
12 
13 // Qt
14 #include <QImage>
15 
16 class ccCameraSensor;
17 
20 public:
23 
25  ccImage(const QImage& image, const QString& name = QString("unknown"));
26 
27  // inherited methods (ccHObject)
28  virtual bool isSerializable() const override { return true; }
29 
31  virtual CV_CLASS_ENUM getClassID() const override {
32  return CV_TYPES::IMAGE;
33  }
34 
36 
40  bool load(const QString& filename, QString& error);
41 
43  inline QImage& data() { return m_image; }
45  inline const QImage& data() const { return m_image; }
46 
48  void setData(const QImage& image);
49 
51  inline unsigned getW() const { return m_width; }
52 
54  inline unsigned getH() const { return m_height; }
55 
57  void setAlpha(float value);
58 
60  inline float getAlpha() const { return m_texAlpha; }
61 
63  void setAspectRatio(float ar) { m_aspectRatio = ar; }
64 
66  inline float getAspectRatio() const { return m_aspectRatio; }
67 
70 
72  ccCameraSensor* getAssociatedSensor() { return m_associatedSensor; }
73 
76  return m_associatedSensor;
77  }
78 
79 protected:
80  // inherited from ccHObject
81  virtual void drawMeOnly(CC_DRAW_CONTEXT& context) override;
82  virtual void onDeletionOf(const ccHObject* obj) override;
83  bool toFile_MeOnly(QFile& out, short dataVersion) const override;
84  short minimumFileVersion_MeOnly() const override;
85  bool fromFile_MeOnly(QFile& in,
86  short dataVersion,
87  int flags,
88  LoadedIDMap& oldToNewIDMap) override;
89 
92 
94  unsigned m_width;
96  unsigned m_height;
97 
99 
103 
105  float m_texAlpha;
106 
108  QImage m_image;
109 
112 };
int64_t CV_CLASS_ENUM
Type of object type flags (64 bits)
Definition: CVTypes.h:97
std::string filename
#define CV_DB_LIB_API
Definition: CV_db.h:15
std::shared_ptr< core::Tensor > image
std::string name
Camera (projective) sensor.
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
Generic image.
Definition: ecvImage.h:19
unsigned getW() const
Returns image width.
Definition: ecvImage.h:51
virtual void drawMeOnly(CC_DRAW_CONTEXT &context) override
Draws the entity only (not its children)
virtual void onDeletionOf(const ccHObject *obj) override
This method is called when another object is deleted.
float m_texAlpha
Texture transparency.
Definition: ecvImage.h:105
bool load(const QString &filename, QString &error)
Loads image from file.
unsigned m_height
Image height (in pixels)
Definition: ecvImage.h:96
virtual bool isSerializable() const override
Returns whether object is serializable of not.
Definition: ecvImage.h:28
ccImage()
Default constructor.
void setData(const QImage &image)
Sets image data.
unsigned getH() const
Returns image height.
Definition: ecvImage.h:54
void setAspectRatio(float ar)
Manually sets aspect ratio.
Definition: ecvImage.h:63
ccImage(const QImage &image, const QString &name=QString("unknown"))
Constructor from QImage.
ccCameraSensor * getAssociatedSensor()
Returns associated sensor.
Definition: ecvImage.h:72
bool toFile_MeOnly(QFile &out, short dataVersion) const override
Save own object data.
short minimumFileVersion_MeOnly() const override
const QImage & data() const
Returns image data (const version)
Definition: ecvImage.h:45
bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads own object data.
float getAspectRatio() const
Returns aspect ratio.
Definition: ecvImage.h:66
QImage & data()
Returns image data.
Definition: ecvImage.h:43
float getAlpha() const
Returns image texture transparency.
Definition: ecvImage.h:60
ccCameraSensor * m_associatedSensor
Associated sensor.
Definition: ecvImage.h:111
void setAlpha(float value)
Sets image texture transparency.
float m_aspectRatio
Aspect ratio w/h.
Definition: ecvImage.h:102
void setAssociatedSensor(ccCameraSensor *sensor)
Sets associated sensor.
unsigned m_width
Image width (in pixels)
Definition: ecvImage.h:94
void updateAspectRatio()
Updates aspect ratio.
QImage m_image
Image data.
Definition: ecvImage.h:108
virtual CV_CLASS_ENUM getClassID() const override
Returns unique class ID.
Definition: ecvImage.h:31
const ccCameraSensor * getAssociatedSensor() const
Returns associated sensor (const version)
Definition: ecvImage.h:75
QMultiMap< unsigned, unsigned > LoadedIDMap
Map of loaded unique IDs (old ID --> new ID)
ImGuiContext * context
Definition: Window.cpp:76
static void error(char *msg)
Definition: lsd.c:159
@ IMAGE
Definition: CVTypes.h:114
Display context.