00001
00002
00003
00004
00005
00006
00007 #include <QGraphicsRectItem>
00008 #include "ViewProfile.h"
00009 #include "ViewProfileParameters.h"
00010
00011 const int FRAME_WIDTH = 2;
00012
00013
00014
00015 const double SLOP_ON_SIDES = 0.5;
00016
00017 ViewProfile::ViewProfile(QGraphicsScene *scene,
00018 int minimumWidth,
00019 QWidget *parent) :
00020 QGraphicsView (scene, parent)
00021 {
00022 setRenderHint (QPainter::Antialiasing);
00023 setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
00024 setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
00025
00026 setMinimumHeight (160);
00027 setMaximumHeight (160);
00028 setMinimumWidth (minimumWidth);
00029
00030 createFrame ();
00031 refit ();
00032 }
00033
00034 void ViewProfile::createFrame ()
00035 {
00036 m_frame = new QGraphicsRectItem (0, 0, 100, 100);
00037 m_frame->setPen (QPen (QBrush (qRgb (0.0, 0.0, 0.0)), FRAME_WIDTH));
00038
00039 scene()->addItem (m_frame);
00040 }
00041
00042 void ViewProfile::refit ()
00043 {
00044
00045 QRectF bounds = QRectF (VIEW_PROFILE_X_MIN - SLOP_ON_SIDES,
00046 VIEW_PROFILE_Y_MIN,
00047 VIEW_PROFILE_X_MAX + 2 * SLOP_ON_SIDES,
00048 VIEW_PROFILE_Y_MAX);
00049 fitInView (bounds);
00050 setSceneRect (bounds);
00051 }
00052
00053 void ViewProfile::resizeEvent(QResizeEvent *event)
00054 {
00055 refit ();
00056
00057 QGraphicsView::resizeEvent (event);
00058 }