QtiPlot  0.9.8.2
ImageWidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : ImageWidget.h
3  Project : QtiPlot
4  --------------------------------------------------------------------
5  Copyright : (C) 2008 - 2010 by Ion Vasilief
6  Email (use @ for *) : ion_vasilief*yahoo.fr
7  Description : A widget displaying images in 2D plots
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
29 #ifndef IMAGEWIDGET_H
30 #define IMAGEWIDGET_H
31 
32 #include <QWidget>
33 #include "FrameWidget.h"
34 
35 class ApplicationWindow;
36 
37 class ImageWidget: public FrameWidget
38 {
39  Q_OBJECT
40 
41 public:
43  ImageWidget(Graph *, const QString& fn = QString::null);
45  ImageWidget(Graph *, const QImage& image);
46 
48  QPixmap pixmap() const {return d_pix;};
49  void setPixmap(const QPixmap&);
50 
52  bool load(const QString& fn, bool update = true);
54  QString fileName(){return d_file_name;};
55 
56  bool saveInternally(){return d_save_xpm;};
57  void setSaveInternally(bool save = true){d_save_xpm = save;};
58 
59  void print(QPainter *p, const QwtScaleMap map[QwtPlot::axisCnt]);
60  virtual QString saveToString();
61 
62  void clone(ImageWidget* t);
63  static void restore(Graph *g, const QStringList& lst);
64 
66  QString windowName(){return d_window_name;};
67  void setWindowName(const QString& name){d_window_name = name;};
68 
69  static QPixmap windowPixmap(ApplicationWindow *mw, const QString& name, const QSize& size);
70  void paintEvent(QPaintEvent *e);
71 
72 private:
73  void draw(QPainter *painter, const QRect& r);
74  QPixmap d_pix;
76  QString d_file_name;
78  bool d_save_xpm;
80  QString d_window_name;
81 };
82 
83 #endif
void setWindowName(const QString &name)
Definition: ImageWidget.h:67
static void restore(Graph *g, const QStringList &lst)
Definition: ImageWidget.cpp:240
virtual QString saveToString()
Definition: ImageWidget.cpp:223
void draw(QPainter *painter, const QRect &r)
Definition: ImageWidget.cpp:168
void clone(ImageWidget *t)
Definition: ImageWidget.cpp:213
A 2D-plotting widget.
Definition: Graph.h:123
void setSaveInternally(bool save=true)
Definition: ImageWidget.h:57
QString d_file_name
The file from which the image was loaded.
Definition: ImageWidget.h:76
void setPixmap(const QPixmap &)
Definition: ImageWidget.cpp:200
QString fileName()
Return d_file_name.
Definition: ImageWidget.h:54
QPixmap d_pix
Definition: ImageWidget.h:74
bool load(const QString &fn, bool update=true)
Import image from d_file_name. Returns true if successful.
Definition: ImageWidget.cpp:86
Definition: ImageWidget.h:37
ImageWidget(Graph *, const QString &fn=QString::null)
Construct an image widget from a file name.
Definition: ImageWidget.cpp:46
bool d_save_xpm
Flag telling if the pixmap must be saved in the .qti project as XPM.
Definition: ImageWidget.h:78
QPixmap pixmap() const
Return the pixmap to be drawn.
Definition: ImageWidget.h:48
QString windowName()
Return d_window_name.
Definition: ImageWidget.h:66
Definition: FrameWidget.h:38
QtiPlot&#39;s main window.
Definition: ApplicationWindow.h:133
void print(QPainter *p, const QwtScaleMap map[QwtPlot::axisCnt])
Definition: ImageWidget.cpp:157
static QPixmap windowPixmap(ApplicationWindow *mw, const QString &name, const QSize &size)
Definition: ImageWidget.cpp:118
void paintEvent(QPaintEvent *e)
Definition: ImageWidget.cpp:139
bool saveInternally()
Definition: ImageWidget.h:56
QString d_window_name
The window whos image is drawn.
Definition: ImageWidget.h:80