Choreonoid  1.8
ImageWidget.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_BASE_IMAGE_WIDGET_H
6 #define CNOID_BASE_IMAGE_WIDGET_H
7 
8 #include <QWidget>
9 #include <cnoid/Image>
10 #include <thread>
11 #include <mutex>
12 #include "exportdecl.h"
13 
14 namespace cnoid {
15 
16 class Image;
17 
18 class CNOID_EXPORT ImageWidget : public QWidget
19 {
20  Q_OBJECT
21 
22 public:
23  explicit ImageWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
24 
25 //public Q_SLOTS:
26  void setPixmap(const QPixmap& pixmap);
27  void setImage(const Image& image);
28  void setImage(const QImage& image);
29 
30  void setScalingEnabled(bool on);
31  bool isScalingEnabled() const;
32 
33  void zoom(double scale);
34  void translate(QPoint pos);
35 
36  bool getTransform(QTransform& transform);
37  double getAngle();
38  void setTransform(const QTransform& transform);
39  void setAngle(double angle);
40  void rotate(double angle);
41  void reset();
42  Image& getImage();
43  void clear();
44  std::mutex mtx;
45 
46  protected:
47  virtual void paintEvent(QPaintEvent* event);
48  virtual QSize sizeHint() const;
49  virtual void resizeEvent(QResizeEvent *event);
50 
51 private:
52  QPixmap pixmap_;
53  bool isScalingEnabled_;
54  QTransform transform_;
55  QTransform notScaledTransform_;
56  QTransform initialTransform_;
57  Image transformedImage;
58 
59  void fitCenter();
60  void resize(const QSize& size);
61  bool fitted;
62  QSize oldSize;
63  double oldScale;
64  bool settedT;
65 
66 };
67 
68 }
69 
70 #endif
cnoid::ImageWidget
Definition: ImageWidget.h:18
cnoid::ImageWidget::mtx
std::mutex mtx
Definition: ImageWidget.h:44
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::Image
Definition: Image.h:16