Пример #1
0
WLinePlot::WLinePlot(QWidget* parent, QWidget *legendParent,
                     WGraphXAxis::Position xAxisPos,
                     WGraphYAxis::Position yAxisPos,
                     int border)
    : WGraphPlot(parent,legendParent,xAxisPos, yAxisPos,border),
      cursorPos(0), wrapAround(true) {

    connect(this,SIGNAL(aboutToDraw()),SLOT(checkRange()));
}
Пример #2
0
WSpacePlot::WSpacePlot(QSize size, bool dg, 
		       QWidget* parent, QWidget *colorBarParent,
		       WGraphXAxis::Position xAxisPos,
		       WGraphYAxis::Position yAxisPos,
		       int border)
  : WGraphWidget(parent,xAxisPos,yAxisPos,border),
    paintColor(red), dataRange(0.0, 1.0),
    recRects(0), cellLabelRect(QRect()),
    colorBar(0), startCell(0,0), currCell(0,0), 
    selecting(true), dragEnabled(false), drawGrid(dg), 
    autoScale(true), multiSelect(true) {
    
    if (colorBarParent) {
      colorBar = new WColorBar(colorBarParent);
      connect(this,SIGNAL(colorChanged(QColor)),
	      colorBar,SLOT(setColor(QColor)));
      connect(colorBar,SIGNAL(rangeSelected(WRange)),
	      this,SLOT(selectRange(WRange)));
      connect(colorBar,SIGNAL(yVisRangeChanged(WRange)),
	      this,SLOT(setDataRange(WRange)));
      colorBar->show();
    } 
    
    setCursor(crossCursor);

    if (drawGrid) setBackgroundColor(white);
    
    setFocusPolicy(TabFocus);
    
    xAxis()->setBaseTick(1.0);
    yAxis()->setBaseTick(1.0);
    
    showGrid(false);
    
    setSize(size);
    
    autoPanTimer = new QTimer(this);
    labelClearTimer = new QTimer(this);
    
    connect(frame(),SIGNAL(aboutToDraw()),this,SLOT(checkDataRange()));
    connect(autoPanTimer,SIGNAL(timeout()),this,SLOT(autoPan()));
    connect(labelClearTimer,SIGNAL(timeout()),this,SLOT(clearCellLabel()));
    connect(this,SIGNAL(frameResized()),SLOT(calcGeometry()));
    connect(this,SIGNAL(visRangeChanged()),SLOT(calcGeometry()));
  }
Пример #3
0
void WGraphFrame::paintEvent(QPaintEvent *e) {

  QPainter p;

  p.begin(this);
  drawFrame(&p);
  p.end();
  
  emit aboutToDraw();

  if (paintPixmap.size()!=contentsRect().size())
    paintPixmap.resize(contentsRect().size());
  
  if (p.begin(&paintPixmap,this)) {
    p.setRasterOp(XorROP);
    if (oldZoomRect.normalize().isValid()) {
      p.setPen(zoomRectPen);
      p.drawRect(oldZoomRect);
    }

    p.setRasterOp(CopyROP);

    parent->drawContent(p, e->erased() || needsRedraw);

    needsRedraw=false;
    drawGrid(p);

    p.setRasterOp(XorROP);
    if (zoomRect.normalize().isValid()) {
      p.setPen(zoomRectPen);
      p.drawRect(zoomRect);
    }
    oldZoomRect=zoomRect;

    p.end();

    bitBlt(this,contentsRect().topLeft(),&paintPixmap);
  }
}
Пример #4
0
QPainter* QQuickContext2DTile::createPainter(bool smooth, bool antialiasing)
{
    if (m_painter.isActive())
        m_painter.end();

    aboutToDraw();
    if (m_device) {
        m_painter.begin(m_device);
        m_painter.resetTransform();
        m_painter.setCompositionMode(QPainter::CompositionMode_Source);

#ifdef QQUICKCONTEXT2D_DEBUG
        int v = 100;
        int gray = (m_rect.x() / m_rect.width() + m_rect.y() / m_rect.height()) % 2;
        if (gray)
            v = 150;
        m_painter.fillRect(QRect(0, 0, m_rect.width(), m_rect.height()), QColor(v, v, v, 255));
#endif

        if (antialiasing)
            m_painter.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing, true);
        else
            m_painter.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing, false);

        if (smooth)
            m_painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
        else
            m_painter.setRenderHint(QPainter::SmoothPixmapTransform, false);

        m_painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
        m_painter.translate(-m_rect.left(), -m_rect.top());
        m_painter.setClipRect(m_rect);
        m_painter.setClipping(false);
        return &m_painter;
    }

    return 0;
}