rock_widget_collection  0.1
ImageViewOld.h
Go to the documentation of this file.
1 /*
2  * File: ImageViewOld.h
3  * Author: blueck
4  *
5  * Created on 17. Juni 2010, 14:14
6  */
7 
8 #ifndef IMAGEVIEWOLD_H
9 #define IMAGEVIEWOLD_H
10 
11 #include <MultiWidget.h>
12 #include <QtGui/QWidget>
13 #include <QtGui/QPaintEvent>
14 #include <QtGui/QPainter>
15 #include <QtGui/QImage>
16 #include <QtGui/QPen>
17 #include <QtCore/QByteArray>
18 #include <QtCore/QList>
19 #include <QtGui/qfiledialog.h>
20 #include <QtGui/QMenu>
21 #include <QtCore/QString>
22 #include <QtDesigner/QDesignerExportWidget>
23 
24 #include <iostream>
25 #include <frame_helper/FrameQImageConverter.h>
26 
27 #include "ImageViewOldGL.h"
28 
74 class QDESIGNER_WIDGET_EXPORT ImageViewOld : public MultiWidget
75 {
76  Q_OBJECT
77  Q_CLASSINFO("Author", "Alexander Duda")
78  Q_PROPERTY(bool Use_OpenGL READ onOpenGL WRITE openGL USER false)
79  Q_PROPERTY(bool Aspect_Ratio READ getAspectRatio WRITE setAspectRatio USER false)
80 
81 public:
82  friend class ImageViewOldGL;
89  ImageViewOld(QWidget *parent = NULL,bool use_openGL = false);
90 
94  virtual ~ImageViewOld();
95  void contextMenuEvent ( QContextMenuEvent * event );
96  int heightForWidth( int w ) {return w*image.height()/image.width(); };
97  void mouseDoubleClickEvent ( QMouseEvent * event );
98 signals:
99  void clickImage(int x,int y);
100  void userExport();
101 
102 public slots:
103  void emitUserExport();
104  void update();
105  void update2();
106  void setDefaultImage();
107 
108  void setZoomEnabled(bool enabled);
109 
110  virtual void openGL(bool flag);
111  bool onOpenGL(){return image_view_gl;};
112  void setAspectRatio(bool value)
113  {
114  aspect_ratio=value;
115  if(image_view_gl)
116  image_view_gl->setAspectRatio(value);
117  };
118  bool getAspectRatio(){return aspect_ratio;};
119 
120  //for saving displayed frames
121  void saveImage(bool overlay=true);
122  bool saveImage2(QString path,bool overlay=true);
123  bool saveImage3(const QString &mode, int pixel_size, int width, int height,const char* pbuffer, QString path,QString format);
124 
126  void resetCrop();
127 
129  void crop(int x, int y, int w, int h);
130 
131 
148  void addRawImage(const QString &mode, int pixel_size, int width, int height,const char* pbuffer, const int size);
149  void addFrame(const base::samples::frame::Frame &frame);
150 
155  void addImage(const QImage &image);
156 
157  void setGroupStatus(int groupNr, bool enable);
158 
163  void clearGroups();
164 
165  int getHeight()const {return image.height();};
166  int getWidth()const {return image.width();};
167  int getFormat()const {return image.format();};
168 
169 protected:
174  void drawDrawItemsToImage(QImage &image,bool all=false);
175  void drawDrawItemsToPainter(QPainter &painter,bool all=false);
176  virtual void resizeEvent(QResizeEvent *event);
177  virtual void paintEvent(QPaintEvent *event);
178  void mousePressEvent(QMouseEvent *event);
179  void mouseReleaseEvent(QMouseEvent *event);
180  void calculateRects();
181  std::pair<QPoint, bool> toImage(QPoint const& p);
182 
183  QMenu contextMenu;
184  QAction *save_image_act;
185  QAction *user_export_act;
186  QString save_path;
187 
188  QImage originalImage; // holds the original image
189  QImage image;
190  QRect currentCrop;
191  bool no_input;
193 
194  frame_helper::FrameQImageConverter frame_converter;
196 
197  QRectF target;
198  QRectF source;
199 
201  QPoint pressPoint;
203 };
204 
205 #endif /* IMAGEVIEWOLD_H */
206 
QPoint pressPoint
Definition: ImageViewOld.h:201
QAction * save_image_act
Definition: ImageViewOld.h:184
QRect currentCrop
Definition: ImageViewOld.h:190
frame_helper::FrameQImageConverter frame_converter
Definition: ImageViewOld.h:194
int getHeight() const
Definition: ImageViewOld.h:165
void paintEvent(QPaintEvent *event)
Definition: PaintWidget.cc:128
void drawDrawItemsToImage(QImage &image, bool all=false)
int getFormat() const
Definition: ImageViewOld.h:167
ImageViewOldGL * image_view_gl
Definition: ImageViewOld.h:195
QMenu contextMenu
Definition: ImageViewOld.h:183
int getWidth() const
Definition: ImageViewOld.h:166
bool onOpenGL()
Definition: ImageViewOld.h:111
QString save_path
Definition: ImageViewOld.h:186
void drawDrawItemsToPainter(QPainter &painter, bool all=false)
Definition: PaintWidget.cc:134
QImage originalImage
Definition: ImageViewOld.h:188
QAction * user_export_act
Definition: ImageViewOld.h:185
void setAspectRatio(bool value)
Definition: ImageViewOld.h:112
bool getAspectRatio()
Definition: ImageViewOld.h:118