DrawingView.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2007 Jürgen Riegel <juergen.riegel@web.de>              *
00003  *                                                                         *
00004  *   This file is Drawing of the FreeCAD CAx development system.           *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A DrawingICULAR PURPOSE.  See the      *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #ifndef DRAWINGGUI_DRAWINGVIEW_H
00025 #define DRAWINGGUI_DRAWINGVIEW_H
00026 
00027 #include <Gui/MDIView.h>
00028 #include <QGraphicsView>
00029 
00030 QT_BEGIN_NAMESPACE
00031 class QSlider;
00032 class QAction;
00033 class QActionGroup;
00034 class QFile;
00035 class QPopupMenu;
00036 class QToolBar;
00037 class QSvgWidget;
00038 class QScrollArea;
00039 class QPrinter;
00040 QT_END_NAMESPACE
00041 
00042 namespace DrawingGui
00043 {
00044 
00045 class DrawingGuiExport SvgView : public QGraphicsView
00046 {
00047     Q_OBJECT
00048 
00049 public:
00050     enum RendererType { Native, OpenGL, Image };
00051 
00052     SvgView(QWidget *parent = 0);
00053 
00054     void openFile(const QFile &file);
00055     void setRenderer(RendererType type = Native);
00056     void drawBackground(QPainter *p, const QRectF &rect);
00057 
00058 public Q_SLOTS:
00059     void setHighQualityAntialiasing(bool highQualityAntialiasing);
00060     void setViewBackground(bool enable);
00061     void setViewOutline(bool enable);
00062 
00063 protected:
00064     void wheelEvent(QWheelEvent *event);
00065     void paintEvent(QPaintEvent *event);
00066 
00067 private:
00068     RendererType m_renderer;
00069 
00070     QGraphicsItem *m_svgItem;
00071     QGraphicsRectItem *m_backgroundItem;
00072     QGraphicsRectItem *m_outlineItem;
00073 
00074     QImage m_image;
00075 };
00076 
00077 class DrawingGuiExport DrawingView : public Gui::MDIView
00078 {
00079     Q_OBJECT
00080 
00081 public:
00082     DrawingView(QWidget* parent = 0);
00083 
00084 public Q_SLOTS:
00085     void load(const QString &path = QString());
00086     void setRenderer(QAction *action);
00087     void viewAll();
00088 
00089 public:
00090     bool onMsg(const char* pMsg,const char** ppReturn);
00091     bool onHasMsg(const char* pMsg) const;
00092     void print();
00093     void printPdf();
00094     void printPreview();
00095 
00096 protected Q_SLOTS:
00097     void print(QPrinter* printer);
00098 
00099 protected:
00100     void contextMenuEvent(QContextMenuEvent *event);
00101 
00102 private:
00103     QAction *m_nativeAction;
00104     QAction *m_glAction;
00105     QAction *m_imageAction;
00106     QAction *m_highQualityAntialiasingAction;
00107     QAction *m_backgroundAction;
00108     QAction *m_outlineAction;
00109 
00110     SvgView *m_view;
00111 
00112     QString m_currentPath;
00113 };
00114 
00115 } // namespace DrawingViewGui
00116 
00117 #endif // DRAWINGGUI_DRAWINGVIEW_H

Generated on Wed Nov 23 19:00:09 2011 for FreeCAD by  doxygen 1.6.1