QSapecNG
 All Classes Functions Enumerations Properties
schematicview.h
00001 /*
00002     QSapecNG - Qt based SapecNG GUI front-end
00003     Copyright (C) 2009, Michele Caini
00004 
00005     This program is free software: you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation, either version 3 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 
00020 #ifndef SCHEMATICVIEW_H
00021 #define SCHEMATICVIEW_H
00022 
00023 
00024 #include <QtGui/QGraphicsView>
00025 #include <QtGui/QResizeEvent>
00026 
00027 
00028 namespace qsapecng
00029 {
00030 
00031 
00032 class SchematicScene;
00033 
00034 
00035 class SchematicView: public QGraphicsView
00036 {
00037 
00038   Q_OBJECT
00039 
00040 public:
00041   SchematicView(QWidget* parent = 0): QGraphicsView(parent)
00042   {
00043     setCacheMode(QGraphicsView::CacheBackground);
00044     setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
00045     setDragMode(QGraphicsView::RubberBandDrag);
00046 //     setDragMode(QGraphicsView::ScrollHandDrag);
00047 //     setAlignment(Qt::AlignCenter);
00048     setAlignment(Qt::AlignLeft | Qt::AlignTop);
00049     setAcceptDrops(true);
00050     setMouseTracking(true);
00051     setAttribute(Qt::WA_DeleteOnClose);
00052     adjustSize();
00053   }
00054 
00055 public slots:
00056   void zoomIn()
00057     { scale(1.2, 1.2); }
00058 
00059   void zoomOut()
00060     { scale(1/1.2, 1/1.2); }
00061 
00062   void normalSize()
00063     { resetTransform(); }
00064 
00065   void fitToView()
00066   {
00067     fitInView(sceneRect(), Qt::KeepAspectRatio);
00068     ensureVisible(sceneRect());
00069     centerOn(sceneRect().center());
00070   }
00071 
00072 protected:
00073 //   void resizeEvent(QResizeEvent* event)
00074 //   {
00075 //     setSceneRect(0, 0, event->size().width(), event->size().height());
00076 //     QGraphicsView::resizeEvent(event);
00077 //   }
00078 
00079 };
00080 
00081 
00082 }
00083 
00084 
00085 #endif // SCHEMATICVIEW_H
 All Classes Functions Enumerations Properties