SinglePhotoView::SinglePhotoView(QWidget *parent) :
    QGraphicsView(parent)
{
    this->setMouseTracking(true);
    setScene(&gScene);
    //gScene.addRect(0, 0, 90, 90);
    scaleFactor = 1;
    pixItem = NULL;
    dragging = false;
    allowAddPoints = true;
    //pointPaint.ql = &selectedPoints;

    // this->scale(scaleFactor, scaleFactor);
    this->setRenderHint(QPainter::Antialiasing);
    this->setRenderHint(QPainter::SmoothPixmapTransform);

    srcPointPaint.setColorScheme(0);
    dstPointPaint.setColorScheme(1);
    gScene.addItem(&srcPointPaint);
    gScene.addItem(&dstPointPaint);
    srcPointPaint.setRatio(this->mapToScene(1, 0).x()-this->mapToScene(0, 0).x());
    dstPointPaint.setRatio(this->mapToScene(1, 0).x()-this->mapToScene(0, 0).x());
}
Example #2
0
GraphView::GraphView(QWidget *parent)
  :
    QGraphicsView(parent),
    selectedItem(NULL),
    edgeSource(NULL),
    currentEdge(NULL),
    currentNode(NULL),
    currentAction(NONE),
    status(NULL),
    undoStack(NULL),
    nodeRadius(15),
    weightedGraph(false),
    undirectedGraph(false),
    numberOfNodes(0),
    numberOfEdges(0),
    nextNodeID(1),
    filePath("")
{
    setScene(new QGraphicsScene());
    scene()->setSceneRect(rect());
    setMouseTracking(true);
    viewport()->installEventFilter(this);
}
Example #3
0
GraphicsView::GraphicsView(QWidget *parent) :
    QGraphicsView(parent),
    dt(1/100.0)
{
    // use opengl for rendering
    QGLWidget *widget = new QGLWidget(QGLFormat(QGL::SampleBuffers));
    widget->makeCurrent();
    setViewport(widget);
    setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
    setCacheMode(QGraphicsView::CacheNone);

    // create graphics scene
    GraphicsScene *graphicsScene = new GraphicsScene(this);
    setScene(graphicsScene);

    // create world rendering thing
    WorldView* worldView = new WorldView(this, &worldModel);

    // make world rendering thing render when grahpics scene needs to draw stuff
    connect(graphicsScene, SIGNAL(render()), worldView, SLOT(render()));

    tick();
}
Example #4
0
SvgView::SvgView(QWidget *parent)
    : QGraphicsView(parent)
    , m_renderer(Native)
    , m_svgItem(0)
    , m_backgroundItem(0)
    , m_outlineItem(0)
{
    setScene(new QGraphicsScene(this));
    setTransformationAnchor(AnchorUnderMouse);
    setDragMode(ScrollHandDrag);
    setViewportUpdateMode(FullViewportUpdate);

    // Prepare background check-board pattern
    QPixmap tilePixmap(64, 64);
    tilePixmap.fill(Qt::white);
    QPainter tilePainter(&tilePixmap);
    QColor color(255, 255, 255);
    tilePainter.fillRect(0, 0, 32, 32, color);
    tilePainter.fillRect(32, 32, 32, 32, color);
    tilePainter.end();

    setBackgroundBrush(tilePixmap);
}
Example #5
0
ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent), toolTip(0) , dive(0), diveDC(0)
{
	gc.printer = false;
	fill_profile_color();
	setScene(new QGraphicsScene());

	setBackgroundBrush(profile_color[BACKGROUND].at(0));
	scene()->installEventFilter(this);

	setRenderHint(QPainter::Antialiasing);
	setRenderHint(QPainter::HighQualityAntialiasing);
	setRenderHint(QPainter::SmoothPixmapTransform);

	defaultPen.setJoinStyle(Qt::RoundJoin);
	defaultPen.setCapStyle(Qt::RoundCap);
	defaultPen.setWidth(2);
	defaultPen.setCosmetic(true);

	setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
	setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);


}
Example #6
0
Viewport::Viewport(QGraphicsScene* scene, QWidget* parent)
    : QGraphicsView(parent), scene(scene),
      scale(100), pitch(0), yaw(0), angle_locked(false),
      view_selector(new ViewSelector(this)),
      mouse_info(new QGraphicsTextItem("\n")),
      scene_info(new QGraphicsTextItem()), hover(false),
      gl_initialized(false), ui_hidden(false)
{
    setScene(scene);
    setStyleSheet("QGraphicsView { border-style: none; }");

    setSceneRect(-width()/2, -height()/2, width(), height());
    setRenderHints(QPainter::Antialiasing);

    auto gl = new QOpenGLWidget(this);
    setViewport(gl);

    for (auto i : {mouse_info, scene_info})
    {
        i->setDefaultTextColor(Colors::base04);
        scene->addItem(i);
    }
}
Example #7
0
ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent), toolTip(0) , dive(0), diveDC(0), rulerItem(0), toolBarProxy(0)
{
    printMode = false;
    isGrayscale = false;
    rulerEnabled = false;
    gc.printer = false;
    fill_profile_color();
    setScene(new QGraphicsScene());

    scene()->installEventFilter(this);

    setRenderHint(QPainter::Antialiasing);
    setRenderHint(QPainter::HighQualityAntialiasing);
    setRenderHint(QPainter::SmoothPixmapTransform);

    defaultPen.setJoinStyle(Qt::RoundJoin);
    defaultPen.setCapStyle(Qt::RoundCap);
    defaultPen.setWidth(2);
    defaultPen.setCosmetic(true);

    setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
}
Example #8
0
ShortcutEditorIcon::ShortcutEditorIcon(QWidget * parent) : QGraphicsView(parent),
    validItem_       (new DynamicSVGItem(SHORTCUT_EDITOR_ICON_VALID)),
    invalidItem_     (new DynamicSVGItem(SHORTCUT_EDITOR_ICON_INVALID)),
    inProgressItem_  (new DynamicSVGItem(SHORTCUT_EDITOR_ICON_PROGRESS)),
    nonActivableItem_(new DynamicSVGItem(SHORTCUT_EDITOR_ICON_NON_ACTIVABLE)),
    valid_(false)
{
    setScene(&scene_);

    inProgressItem_->setTransformOriginPoint(
        inProgressItem_->boundingRect().center());

    QObject::connect(&animateTimer_, &QTimer::timeout, [this]
    {
        inProgressItem_->setRotation(rotationIndex_ += 3);
    });

    setStyleSheet("border: 0px"); // removing ugly border
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

    setFixedSize(32, 32);
}
Example #9
0
TsimpleScore::TsimpleScore(int notesNumber, QWidget* parent) :
  QGraphicsView(parent),
  m_notesNr(notesNumber),
  m_bgGlyph(0),
  m_prevBGglyph(-1)
{
  if (TscoreNote::touchEnabled())
    viewport()->setAttribute(Qt::WA_AcceptTouchEvents, true);
  else {
    viewport()->setAttribute(Qt::WA_AcceptTouchEvents, false);
    setMouseTracking(true);
  }
  m_wheelFree = true;
  m_wheelLockTimer = new QTimer(this);
  m_wheelLockTimer->setTimerType(Qt::PreciseTimer);
  m_wheelLockTimer->setInterval(150);
  m_wheelLockTimer->setSingleShot(true);
  connect(m_wheelLockTimer, &QTimer::timeout, this, &TsimpleScore::wheelLockSlot);
  setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

  m_scene = new TscoreScene(this);
  connect(m_scene, SIGNAL(statusTip(QString)), this, SLOT(statusTipChanged(QString)));
  setScene(m_scene);

  m_staff = new TscoreStaff(m_scene, m_notesNr);
  m_staff->enableToAddNotes(false);
  m_clefType = m_staff->scoreClef()->clef().type();
  connect(m_staff, SIGNAL(noteChanged(int)), this, SLOT(noteWasClicked(int)));
  connect(m_staff, SIGNAL(clefChanged(Tclef)), this, SLOT(onClefChanged(Tclef)));

  setBGcolor(palette().base().color());
  setEnabledDblAccid(false);
  setAlignment(Qt::AlignLeft);
  resizeEvent(0);
}
Example #10
0
MapperGLCanvas::MapperGLCanvas(MainWindow* mainWindow, QWidget* parent, const QGLWidget * shareWidget, QGraphicsScene* scene)
  : QGraphicsView(parent),
    _mainWindow(mainWindow),
    _mousePressedOnVertex(false),
    _activeVertex(NO_VERTEX),
    _shapeGrabbed(false), // comment out?
    _shapeFirstGrab(false), // comment out?
    _zoomLevel(0)
{
  // For now clicking on the window doesn't do anything.
  setDragMode(QGraphicsView::NoDrag);

  setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing |
                 QPainter::HighQualityAntialiasing | QPainter::SmoothPixmapTransform);

  setResizeAnchor(AnchorViewCenter);
  setInteractive(true);

  //setFrameStyle(Sunken | StyledPanel);
  // TODO: check this
  // setOptimizationFlags(QGraphicsView::DontSavePainterState);
  //setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  setTransformationAnchor(QGraphicsView::AnchorUnderMouse);

  resetTransform();
  // setAcceptDrops(true);

  // Render with OpenGL.
  setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers), this, shareWidget));
  setViewportUpdateMode(QGraphicsView::FullViewportUpdate);

  // TODO: do we need to delete scene (or call new QGraphicsScene(this)?)
  setScene(scene ? scene : new QGraphicsScene);

  // Black background.
  this->scene()->setBackgroundBrush(Qt::black);
}
SoccerView::SoccerView(QMutex* _drawMutex)
{
  drawMutex = _drawMutex;
  shutdownSoccerView = false;
  glWidget = new QGLWidget ( QGLFormat ( QGL::DoubleBuffer ) );
  setViewport ( glWidget );
  LoadFieldGeometry();
  scene = new QGraphicsScene ( this );
  setScene ( scene );
  this->setViewportUpdateMode ( QGraphicsView::NoViewportUpdate );
  scene->setBackgroundBrush ( QBrush ( QColor ( 0,0x91,0x19,255 ),Qt::SolidPattern ) );
  scene->setSceneRect ( -3700,-2700,7400,5400 );
  ConstructField();
  fieldBrush = new QBrush ( Qt::NoBrush );
  fieldLinePen = new QPen();
  fieldLinePen->setColor ( Qt::white );
  fieldLinePen->setWidth ( 10 );
  fieldLinePen->setJoinStyle ( Qt::MiterJoin );
  fieldItem = scene->addPath ( *field,*fieldLinePen,*fieldBrush );
  fieldItem->setZValue(0);
  drawScale = 0.15;
  //this->setRenderHint ( QPainter::Antialiasing, true );
  this->setRenderHint ( QPainter::HighQualityAntialiasing, true );
  this->setDragMode ( QGraphicsView::ScrollHandDrag );
  this->setGeometry ( 400,100,1336,756 );
  scalingRequested = true;

  //LogPlayer data
//  playLogfile = new QPushButton(this);
//  playLogfile->setObjectName(QString::fromUtf8("play_logfile_button"));
//  playLogfile->setCheckable(false);
//  playLogfile->setText("Play Logfile");
//  playLogfile->setGeometry(10, 10, 150, 30);

  //Timer for casual redraw
  startTimer ( 1000 );
}
Example #12
0
PathView::PathView(QWidget *parent)
	: QGraphicsView(parent)
{
	_scene = new QGraphicsScene(this);
	setScene(_scene);
	setCacheMode(QGraphicsView::CacheBackground);
	setDragMode(QGraphicsView::ScrollHandDrag);
	setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setRenderHint(QPainter::Antialiasing, true);
	setAcceptDrops(false);

	_mapScale = new ScaleItem();
	_mapScale->setZValue(2.0);

	_zoom = ZOOM_MAX;
	_map = 0;
	_poi = 0;

	_units = Metric;

	_showTracks = true;
	_showRoutes = true;
	_showWaypoints = true;
	_showWaypointLabels = true;
	_showPOI = true;
	_showPOILabels = true;
	_overlapPOIs = true;
	_showRouteWaypoints = true;
	_trackWidth = 3;
	_routeWidth = 3;
	_trackStyle = Qt::SolidLine;
	_routeStyle = Qt::DashLine;

	_plot = false;
}
Example #13
0
void SnapshotCanvas::setPixmap(const QPixmap &pixmap)
{
    delete m_scene;
    m_scene = new QGraphicsScene(this);
    m_scene->setBackgroundBrush(QColor(180, 180, 180));

    connect(m_scene, SIGNAL(selectionChanged()),
            this, SLOT(slotSelectionChanged()));

    m_pixmapItem = new QGraphicsPixmapItem(pixmap);

    QGraphicsDropShadowEffect *dropShadowFX = new QGraphicsDropShadowEffect();
    dropShadowFX->setColor(QColor(63, 63, 63, 220));
    dropShadowFX->setOffset(0, 0);
    dropShadowFX->setBlurRadius(20);
    m_pixmapItem->setGraphicsEffect(dropShadowFX);

    m_scene->addItem(m_pixmapItem);
    m_scene->setSceneRect(pixmap.rect());

    setScene(m_scene);

    adjustMaximumSize();
}
/*
 * Initialize the widget
 */
MixerCurveWidget::MixerCurveWidget(QWidget *parent) : QGraphicsView(parent)
{

    // Create a layout, add a QGraphicsView and put the SVG inside.
    // The Mixer Curve widget looks like this:
    // |--------------------|
    // |                    |
    // |                    |
    // |     Graph  |
    // |                    |
    // |                    |
    // |                    |
    // |--------------------|


    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setRenderHint(QPainter::Antialiasing);

    curveMin=0.0;
    curveMax=1.0;



    QGraphicsScene *scene = new QGraphicsScene(this);
    QSvgRenderer *renderer = new QSvgRenderer();
    plot = new QGraphicsSvgItem();
    renderer->load(QString(":/configgadget/images/curve-bg.svg"));
    plot->setSharedRenderer(renderer);
    //plot->setElementId("map");
    scene->addItem(plot);
    plot->setZValue(-1);
    scene->setSceneRect(plot->boundingRect());
    setScene(scene);

}
Example #15
0
MainWindow::MainWindow(const QRect &sceneRect) : QGraphicsView()
{
    // Check if we have artwork for the sreen size. Otherwise we construct a
    // scene of size 1024x768, and scale the view to fit the screen instead:
    QString folder = QString::number(sceneRect.width()) + "x" + QString::number(sceneRect.height());
    QFile artworkForScreenSize(QStringLiteral(":/") + folder + QDir::separator() + "background");
    
    if (artworkForScreenSize.exists()) {
        scene = new GraphicsScene(sceneRect);
    } else {
        QRect unscaledRect = QRect(0, 0, 1024, 768);
        scene = new GraphicsScene(unscaledRect);
        scale(qreal(sceneRect.width()) / unscaledRect.width(), qreal(sceneRect.height()) / unscaledRect.height());
    }

    setScene(scene);
    setAlignment(Qt::AlignLeft | Qt::AlignTop);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    scene->setupScene();
#ifndef QT_NO_OPENGL
    setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
#endif
}
Example #16
0
Canvas::Canvas(QGraphicsView * parent) :
                    QGraphicsView(parent),
                    _startX(0),
                    _startY(0),
                    _endX(0),
                    _endY(0),
                    buttonPressed(false),
                    shapeSet(false),
                    shapeDrawn(true),
                    enableResize(false),
                    edgeLocker(false),
                    coordinatesIterationMove(0, 0),
                    isMoved(false),
                    currentScene(new Scene),
                    currentPen(QPen()),
                    enableToRotate(false),
                    enableFill(false)
{
    setScene(currentScene);
    setMouseTracking(true);
    _direction = None;
    _normalize = NormalizeNone;

}
Example #17
0
VLCStatsView::VLCStatsView( QWidget *parent ) : QGraphicsView( parent )
{
    QColor history(0, 0, 0, 255),
        total(237, 109, 0, 160),
        content(109, 237, 0, 160);

    scale( 1.0, -1.0 ); /* invert our Y axis */
    setOptimizationFlags( QGraphicsView::DontAdjustForAntialiasing );
    setAlignment( Qt::AlignLeft );
    setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    viewScene = new QGraphicsScene( this );
    historyShape = viewScene->addPolygon( QPolygonF(), QPen(Qt::NoPen),
                                             QBrush(history) );
    totalbitrateShape = viewScene->addPolygon( QPolygonF(), QPen(Qt::NoPen),
                                           QBrush(total) );
    setScene( viewScene );
    reset();

    QPen linepen( Qt::DotLine );
    linepen.setBrush( QBrush( QColor( 33, 33, 33 ) ) );
    for ( int i=0; i<3; i++ )
        rulers[i] = viewScene->addLine( QLineF(), linepen );
}
Example #18
0
Game::Game()
{
  //  start = new Start();
    scene = new QGraphicsScene();

    player = new Player();
    scene->addItem(player);

  /*  QGraphicsPixmapItem *drum = new QGraphicsPixmapItem();
    drum->setPixmap(QPixmap(":/images/testdrum2.png"));
    drum->setPos(0,143);
    scene->addItem(drum);*/

    player->setFlag(QGraphicsItem::ItemIsFocusable);
    player->setFocus();

    setScene(scene);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setFixedSize(768,557);

    scene->setSceneRect(0,0,768,557);
    scene->setBackgroundBrush(QBrush(QPixmap(":/image/bgg6.png")));

    //create the score
    score = new Score();
    scene->addItem(score);

    QTimer * timer = new QTimer();
    QObject::connect(timer,SIGNAL(timeout()),player,SLOT(spawn()));
    timer->start(1200);

    mytimer = new Mytimer();
    scene->addItem(mytimer);

}
Example #19
0
Game::Game()
{
    scene = new QGraphicsScene(this);
    scene->setSceneRect(-400, -300, 800, 600);
    setScene(scene);

    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setFixedSize(800,600);

    rightPressed = false;
    leftPressed = false;
    isPaused = false;
    isWin = false;

    bar = new Bar();
    ball = new Ball();
    scene->addItem(bar);
    scene->addItem(ball);

    initializeBricks();

    connect(ball, &Ball::gameOver, this, &Game::gameOver);
}
Example #20
0
PlotGraph::PlotGraph(std::vector<double> & firstRow_in,
                     std::vector<double> & secondRow_in,
                     std::vector<double> & thirdRow_in,
                     std::vector<double> & fourthRow_in,
                     QWidget *parent)
    :QGraphicsView(parent)
{
    firstRow = firstRow_in;
    secondRow = secondRow_in;
    thirdRow = thirdRow_in;
    fourthRow = fourthRow_in;
    nPlottingPoints = firstRow.size();
    QGraphicsScene *scene = new QGraphicsScene(this);
    scene->setItemIndexMethod(QGraphicsScene::NoIndex);
    sceneX = -250;
    sceneY = -250;
    sceneHeigth = 490;
    sceneWidth = 490;

    xOrigin = sceneX + 30;
    yOrigin = sceneY + sceneHeigth - 80;
    xMax = sceneX + sceneWidth - 30;
    yMax = sceneY + 30;

    scene->setSceneRect(sceneX, sceneY, sceneHeigth, sceneWidth);
    setScene(scene);
    setCacheMode(CacheBackground);
    setViewportUpdateMode(BoundingRectViewportUpdate);
    setRenderHint(QPainter::Antialiasing);
    setTransformationAnchor(AnchorUnderMouse);
    setWindowTitle(tr("Bacterial Growth - Graph"));

    timerId = startTimer(1000 / 50);

    addingLine = 0;
}
Example #21
0
//______________________________________________________________________________
YSPTView::YSPTView(QMenuBar *mb)
{
    //creates the view with a shared menubar

    // Sets up the subclassed QGraphicsView

    setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);


    //Set-up the scene

    fPt = new YSPeriodicTable(this);
    setScene(fPt);

    //Set-up the view
    setSceneRect(fPt->sceneRect());

    //Use ScrollHand Drag Mode to enable Panning
    setDragMode(ScrollHandDrag);

    fMenuBar = mb;
    CreateActions();
    CreateMenus();
}
Example #22
0
//! [0]
View::View(const QString &offices, const QString &images, QWidget *parent)
    : QGraphicsView(parent)
{
    officeTable = new QSqlRelationalTableModel(this);
    officeTable->setTable(offices);
    officeTable->setRelation(1, QSqlRelation(images, "locationid", "file"));
    officeTable->select();
//! [0]

//! [1]
    scene = new QGraphicsScene(this);
    scene->setSceneRect(0, 0, 465, 615);
    setScene(scene);

    addItems();

    QGraphicsPixmapItem *logo = scene->addPixmap(QPixmap(":/logo.png"));
    logo->setPos(30, 515);

    setMinimumSize(470, 620);
    setMaximumSize(470, 620);

   setWindowTitle(tr("Offices World Wide"));
}
Example #23
0
IPProcessGrid::IPProcessGrid(QWidget *parent) : QGraphicsView(parent)
{
    _scene = new IPProcessGridScene(this);

    setScene(_scene);
    setAlignment(Qt::AlignLeft | Qt::AlignTop);
    setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
    setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
    //setCacheMode(QGraphicsView::CacheBackground);
    centerOn(0,0);

    setDragMode(QGraphicsView::RubberBandDrag);
    setMouseTracking(true);

    _scale = 1.0;

    _isRunning = false;
    _isSequenceRunning = true;

    _currentStep = NULL;

    _stopExecution = false;

    _sequenceCount = 0;
    _sequenceIndex = 0;
    _lastSequenceIndex = 0;

    _lastProcessSuccess = false;

    _updateNeeded = true;

    // add a dummy object to allow correct placement of new objects with drag&drop
    scene()->addItem(new QGraphicsRectItem(0,0,0,0));

    connect(_scene, &QGraphicsScene::sceneRectChanged, this, &IPProcessGrid::sceneRectChanged);
}
Example #24
0
CanvasWidget::CanvasWidget(QWidget *parent) 
    : QGraphicsView(parent),
      rightPressed(false),
      leftPressed(false),
      usingKeys(0)
{
#if defined ANDROID
    setRenderHints(QPainter::HighQualityAntialiasing | QPainter::SmoothPixmapTransform);
#endif

    setScene(new QGraphicsScene());
    setFocus();
    setStyleSheet( "QGraphicsView { border-style: none; }" );
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    scene()->setItemIndexMethod(QGraphicsScene::NoIndex); //Disable index for better performance
    setFrameStyle(QFrame::NoFrame);
    setFocusPolicy(Qt::StrongFocus);
    setAlignment(Qt::AlignLeft | Qt::AlignTop);
    setViewportUpdateMode(SmartViewportUpdate);
    
    scene()->addItem(&background);
    background.show();
    scene()->addItem(&pauseOverlay);
    pauseOverlay.setZValue(1);
    
    moveBarTimer.setInterval(DEFAULT_UPDATE_INTERVAL);
    connect(&moveBarTimer, SIGNAL(timeout()), SLOT(moveBar()));
    
    updateBarTimer.setInterval(DEFAULT_UPDATE_INTERVAL);
    connect(&updateBarTimer, SIGNAL(timeout()), SLOT(updateBar()));
    lastMousePosition = QPoint(0, 0);
    
    updateBarTimer.start();
    setCursor(QCursor(Qt::BlankCursor));
}
Example #25
0
void ImageView::loadImageData(const QString& source)
{
	imageSource = source;
	image = new QImage(imageSource);
	imageitem = new ImageItem(*image);
	imageitem->setPos(0, 0);

	edgepath = new QGraphicsPathItem(imageitem);
	edgepath->setPen(QPen(PolygonItem::defaultAreaColor, 4, Qt::SolidLine, Qt::FlatCap,
	        Qt::BevelJoin));

	area = new PolygonItem(imageitem->rect(), edgepath);

	scene = new QGraphicsScene(this);
	setBackgroundBrush(QBrush(Qt::gray, Qt::DiagCrossPattern));
	scene->setSceneRect(imageitem->rect());
	setScene(scene);

	scene->addItem(imageitem);

	scene->addItem(edgepath);
	edgepath->setPos(0, 0);

	scene->addItem(area);

	//	QGraphicsLineItem* lnitem = new QGraphicsLineItem(area);
	//	lnitem->setPos(image->width() / 2, image->height() / 2 );
	//	lnitem->setLine(0, 0, image->width(), 0);
	//	//lnitem->setPos()
	//	lnitem->setPen(QPen(Qt::blue));
	//	lnitem->rotate(45);
	//
	//	scene->addItem(lnitem);

	zoomNormal();
}
Example #26
0
void ChatLog::onWorkerTimeout()
{
    // Fairly arbitrary but
    // large values will make the UI unresponsive
    const int stepSize = 50;

    layout(workerLastIndex, workerLastIndex+stepSize, useableWidth());
    workerLastIndex += stepSize;

    // done?
    if (workerLastIndex >= lines.size())
    {
        workerTimer->stop();

        // switch back to the scene containing the chat messages
        setScene(scene);

        // make sure everything gets updated
        updateSceneRect();
        checkVisibility();
        updateTypingNotification();
        updateMultiSelectionRect();

        // scroll
        if (workerStb)
            scrollToBottom();
        else
            scrollToLine(workerAnchorLine);

        // don't keep a Ptr to the anchor line
        workerAnchorLine = ChatLine::Ptr();

        // hidden during busy screen
        verticalScrollBar()->show();
    }
}
Example #27
0
GameView::GameView()
{
    scene = new QGraphicsScene;
    snake = new Snake;
    addItems();
    setScene(scene);
    score = 0;

    connect(this,SIGNAL(keyPress(QKeyEvent*)),
            snake,SLOT(keyPressEvent(QKeyEvent*)));
    connect(snake,SIGNAL(addandDelBox(OneBox*,OneBox*)),
            this,SLOT(changedItem(OneBox*,OneBox*)));
    connect(snake,SIGNAL(needNewBox()),this,SLOT(needNewBox()));
    connect(snake,SIGNAL(gameEnd()),this,SLOT(endGame()));

    //添加边界线,进行碰撞检测
    QGraphicsLineItem *topLineItem =new QGraphicsLineItem(-20,-20,820,-20);
    QGraphicsLineItem *leftLineItem = new QGraphicsLineItem(-20,-20,-20,620);
    QGraphicsLineItem *buttonLineItem = new QGraphicsLineItem(-20,620,820,620);
    QGraphicsLineItem *rightLineItem = new QGraphicsLineItem(820,-20,820,620);
    scene->addItem(topLineItem);
    scene->addItem(leftLineItem);
    scene->addItem(buttonLineItem);
    scene->addItem(rightLineItem);

//设置窗口大小,不可改变
    setMinimumSize(802, 602);
    setMaximumSize(802, 602);

    scene->setSceneRect(0,0,800,600);
//    setSceneRect(0,0,800,600);
//    setSceneRect(0,0,800,600);

    setBackgroundBrush(Qt::black);
    needNewBox();
}
Example #28
0
/*******************************************************************************
    switch_view
*******************************************************************************/
void BrowserView::switch_view(BrowserParam& param)
{
    Debug::debug() << "  [BrowserView] switch_view param.mode " << param.mode;
    //Debug::debug() << "  [BrowserView] switch_view param.filter" << param.filter;
    //Debug::debug() << "  [BrowserView] switch_view param.data" << param.data;

    /* save current state */
    SETTINGS()->_viewMode = param.mode;

    CentralToolBar::instance()->showHideGoUp(param.mode);
    
    /* handle scene switch view */
    SceneBase * scene = m_scenes[ param.mode ];

    if( !scene->isInit() )
      scene->initScene();
          
    scene->setMode( param.mode );
    scene->setFilter( param.filter );
    scene->setData( param.data );
    scene->populateScene();
    this->setFocus();
    
    show_bottom_panel( m_scenes[param.mode]->bottomWidget() );

    CentralToolBar::instance()->setExplorerFilterText(param.filter);
    

    switch( VIEW::typeForView(VIEW::Id(param.mode)) ) {
      case VIEW::LOCAL      : setScene(static_cast<LocalScene*>(m_scenes[param.mode]));    break;
      case VIEW::RADIO      : setScene(static_cast<StreamScene*>(m_scenes[param.mode]));   break;
      case VIEW::CONTEXT    : setScene(static_cast<ContextScene*>(m_scenes[param.mode]));  break;
      case VIEW::SETTING    : setScene(static_cast<SettingsScene*>(m_scenes[param.mode])); break;
      case VIEW::FILESYSTEM : setScene(static_cast<FileScene*>(m_scenes[param.mode]));     break;
      case VIEW::ABOUT      : setScene(static_cast<AboutScene*>(m_scenes[param.mode]));    break;
    }

    /* restore scroll position */
    m_scrollbar->setSliderPosition(param.scroll);

    /* status widget update */
    do_statuswidget_update();    
}
Example #29
0
HPiano::HPiano(QWidget* parent)
    : QGraphicsView(parent)
{
    setLineWidth(0);
    setMidLineWidth(0);

    setScene(new QGraphicsScene);
    setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
    setResizeAnchor(QGraphicsView::AnchorUnderMouse);
    setMouseTracking(true);
    setRubberBandSelectionMode(Qt::IntersectsItemBoundingRect);
    setDragMode(QGraphicsView::RubberBandDrag);
    setMaximumSize(QSize(KEY_WIDTH * 52+8, KEY_HEIGHT+8+80));
    setMinimumSize(QSize(100, KEY_HEIGHT+8));

    scene()->setSceneRect(0.0, 0.0, KEY_WIDTH * 52, KEY_HEIGHT);

    _firstKey   = 21;
    _lastKey    = 108;   // 88 key piano
    _currentKey = -1;
    qreal x = 0.0;
    for (int i = _firstKey; i <= _lastKey; ++i) {
        PianoKeyItem* k = new PianoKeyItem(this, i);
        switch(i % 12) {
        case  0:
        case  5:
            k->setType(i == _lastKey ? 6 : 0);
            k->setPos(x, 0);
            x += KEY_WIDTH;
            break;

        case  2:
            k->setType(1);
            k->setPos(x, 0);
            x += KEY_WIDTH;
            break;
        case  4:
        case 11:
            k->setType(2);
            k->setPos(x, 0);
            x += KEY_WIDTH;
            break;

        case  7:
            k->setType(3);
            k->setPos(x, 0);
            x += KEY_WIDTH;
            break;

        case  9:
            k->setType(i == _firstKey ? 5 : 4);
            k->setPos(x, 0);
            x += KEY_WIDTH;
            break;

        case  1:
        case  6:
            k->setType(7);
            k->setPos(x - BKEY_WIDTH * 5/9, 0);
            break;
        case  3:
        case 10:
            k->setType(7);
            k->setPos(x - BKEY_WIDTH * 4/9, 0);
            break;
        case 8:
            k->setType(7);
            k->setPos(x - BKEY_WIDTH / 2.0, 0);
            break;
        }
        keys.append(k);
        scene()->addItem(k);
    }
}
Example #30
0
void KeyboardView::loadKeyboard(const QString & fileName) {
  /**
   * need to have a rectangle that covers the entire keyboard
   * so we can set it background color and generally make it look pretty
   *
   * set key top color from the ini file
   * set key pressed color from the ini file
   * set the key pen from the ini file
   *
   */
  delete m_kbd;
  m_kbd = new KeyboardDef();
  m_scene->clear();
  m_kbd->load(fileName);

  QSettings settings(fileName,QSettings::IniFormat);
  settings.setIniCodec("UTF-8");
  settings.beginGroup("Header");
  m_buttonWidth = settings.value("button width",80).toInt();
  m_buttonHeight = settings.value("button height",80).toInt();
  m_vspace = settings.value("vertical spacing",5).toInt();
  m_hspace = settings.value("horizontal spacing",5).toInt();
  QString textColor = settings.value("text color","white").toString();
  QString keyUpColor = settings.value("key up color","black").toString();
  QString keyDownColor =  settings.value("key down color","gray").toString();
  QString keyboardColor = settings.value("keyboard color","darkgray").toString();
  QString css = settings.value("css",QString()).toString();

  m_nullKeyAllowed = settings.value("null key",false).toBool();
  m_debug = settings.value("debug",false).toBool();

  settings.endGroup();
  for(int i=0;i < m_kbd->keyCount();i++) {
    KeyDef * key = m_kbd->getKey(i);
    int width = m_buttonWidth*key->getSpan() + m_hspace*(key->getSpan() - 1);
    int height = m_buttonHeight;
    QRect r(0,0,width,height);

    GraphicsButton * btn = new GraphicsButton(r,key);
    btn->setCss(css);
    btn->setColor(GraphicsButton::TextColor,textColor);
    btn->setColor(GraphicsButton::ButtonUpColor,keyUpColor);
    btn->setColor(GraphicsButton::ButtonDownColor,keyDownColor);
    btn->setColor(GraphicsButton::KeyboardColor,keyboardColor);

    btn->setup();
    addButton(key->getRow(),key->getCol(),btn);
  }
  //  QSize sz = m_kbd->getButtonSize();
  /**
   * we need to resize the sceneRect after each load. It seems that if the
   * scene rect is updated as it increases, but not as it decreases
   * this is now done in KeyboardWidget
   *  m_view->setSceneRect(m_view->sceneRect());
   */
  if (m_debug) {
    int width  =  (m_kbd->cols() * m_buttonWidth) + (m_kbd->cols() - 1)*m_hspace;
    int height =  (m_kbd->rows() * m_buttonHeight) + (m_kbd->rows() - 1)*m_vspace;
    QLOG_DEBUG() << QString("Rows: %1, Cols: %2, button size %3 x %4")
      .arg(m_kbd->rows())
      .arg(m_kbd->cols())
      .arg(m_buttonWidth)
      .arg(m_buttonHeight);
    QLOG_DEBUG() << QString("Calculated size: %1 x %2").arg(width).arg(height);
    QRectF r = m_scene->sceneRect();
    //  m_scene->setSceneRect(r);
    QLOG_DEBUG() << QString("Scenerect %1 x %2").arg(r.width()).arg(r.height());
    QLOG_DEBUG() << "Scenerect" << r;
    QLOG_DEBUG() << "--------------------------------------------------";
  }
  setScene(m_scene);
  /// TODO get from ini and poss to KeyboardDef before creating buttons
  m_scene->setBackgroundBrush(QColor(keyboardColor));

}