void
GUIParameterTracker::GUIParameterTrackerPanel::drawValues() {
    // compute which font to use
    /*
    SUMOReal fontIdx = ((SUMOReal) myWidthInPixels-300.) / 10.;
    if(fontIdx<=0) fontIdx = 1;
    if(fontIdx>4) fontIdx = 4;
    */
    pfSetScale((SUMOReal) 0.1);
    pfSetScaleXY((SUMOReal)(.1*300./myWidthInPixels), (SUMOReal)(.1*300./(SUMOReal) myHeightInPixels));

//    GUITexturesHelper::getFontRenderer().SetActiveFont(4-fontIdx);
    //
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glDisable(GL_TEXTURE_2D);
    size_t run = 0;
    for (TrackedVarsVector::iterator i=myParent->myTracked.begin(); i!=myParent->myTracked.end(); i++) {
        TrackerValueDesc *desc = *i;
        drawValue(*desc,
                  (SUMOReal) myWidthInPixels / (SUMOReal) myParent->myTracked.size() *(SUMOReal) run);
        run++;
    }
//    GUITexturesHelper::getFontRenderer().Draw(myWidthInPixels, myHeightInPixels);//this, width, height);
}
void SliderView::draw() {
  View::draw();
  drawOkButton(okFocused_);
  drawCancelButton(cancelFocused_);
  drawSlider();
  drawValue();
}
void Slider::setNewMask ()
{
  QBitmap bm(size());
  bm.fill(Qt::color0);

  QBitmap bm_sld(slider->size());
  QPixmap pm = QPixmap::grabWidget(slider);
  bm_sld = pm.createHeuristicMask();

  QPainter painter;
  QBitmap bm_val,bm_min,bm_max;
  bm_val = drawValue();
  bm_min = drawMinValue();
  bm_max = drawMaxValue();

  painter.begin(&bm);
  painter.drawPixmap(slider->x(),slider->y(),bm_sld);
  if (orientation == 0) painter.drawPixmap(0,0,bm_val);
    else if (orientation == 1) painter.drawPixmap(width()/2+10,0,bm_val);
  if (orientation == 0) painter.drawPixmap(0,height()/2+10,bm_min);
    else if (orientation == 1) painter.drawPixmap(0,0,bm_min);
  if (orientation == 0) painter.drawPixmap(width()/2,height()/2+10,bm_max);
    else if (orientation == 1) painter.drawPixmap(0,height()/2,bm_max);
  painter.end();

  setMask(bm);
}
Beispiel #4
0
void caCircularGauge::paintEvent(QPaintEvent *)
{
    QPainter	painter(this);
    int size = qMin(height(), width());

    /* see http://doc.trolltech.com/4.4/coordsys.html#window-viewport-conversion for a analogous example */
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setViewport((int)((width()-size)*.5),(int)((height()-size)*.5),size,size);
    painter.setWindow(-50,-50,100,100);

    drawColorBar(&painter);

    if (isEnabled())
        drawNeedle(&painter);

    if (m_valueDisplayed)
        drawValue(&painter);

    if (!isEnabled())
    {
        QColor c = palette().color(QPalette::Background);
        c.setAlpha(200);
        painter.fillRect(painter.window(), c);
    }
    if (m_scaleEnabled)
    {
        drawScale(&painter);
        drawLabels(&painter);
    }
}
Beispiel #5
0
void VUMeter::paintEvent(QPaintEvent *)
{
    //绘制准备工作,启用反锯齿,平移坐标轴中心,等比例缩放
    QPainter painter(this);
    painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
    painter.setWindow(0, 0, 100, 540);

    //绘制边框
    drawBorder(&painter);
    //绘制柱状音量
    drawBar(&painter);
    //绘制值
    drawValue(&painter);
}
Beispiel #6
0
//--------------------------------------------------------------
void ofApp::draw(){
    ofBackground(255);
    ofSetColor(0);

    //draw pots as sliders
    string pString = "pots ";
    for(int i = 0; i < 8; i++){
      int yPos = 50;
      if(i >= 4)
        yPos = 300;
      drawValue(50 + (i % 4) * 100, yPos, 50, 200, vq.getParameters().pots[i]);
      pString += ofToString(vq.getParameters().pots[i]) + " ";
    }

    //draw buttons as boxes
    string bString = "buttons ";
    for(int i = 0; i < 5; i++){
      drawValue(50 + i * 100, 600, 50, 50, vq.getParameters().buttons[i]);
      bString += ofToString(vq.getParameters().buttons[i]) + " ";
    }

    //print values as string
    ofDrawBitmapString(pString + "\n" + bString, 10, ofGetHeight()-30);
}
Beispiel #7
0
/******************************************************************************
 * UI_update
 ******************************************************************************/
Void UI_update(UI_Handle hUI)
{
    Int i;

    for (i = 0; i < UI_Num_Values; i++) {
        if (stringAttrs[i].y >= 0 && stringAttrs[i].valid) {
            if (hUI->osd) {
                drawValue(hUI, i);
            }
            else {
                printf("%s %s ", stringAttrs[i].col1String,
                       stringAttrs[i].col2String);
            }
        }
    }

    if (!hUI->osd) {
        printf("\n\n");
    }
}
Beispiel #8
0
void QRoundProgressBar::paintEvent(QPaintEvent* /*event*/)
{
    double outerRadius = qMin(width(), height());
    QRectF baseRect(1, 1, outerRadius-2, outerRadius-2);

    QImage buffer(outerRadius, outerRadius, QImage::Format_ARGB32_Premultiplied);

    QPainter p(&buffer);
    p.setRenderHint(QPainter::Antialiasing);

    // data brush
    rebuildDataBrushIfNeeded();

    // background
    drawBackground(p, buffer.rect());

    // base circle
    drawBase(p, baseRect);

    // data circle
    double arcStep = 360.0 / (m_max - m_min) * m_value;
    drawValue(p, baseRect, m_value, arcStep);

    // center circle
    double innerRadius(0);
    QRectF innerRect;
    calculateInnerRect(baseRect, outerRadius, innerRect, innerRadius);
    drawInnerBackground(p, innerRect);

    // text
    drawText(p, innerRect, innerRadius, m_value);

    // finally draw the bar
    p.end();

    QPainter painter(this);
    painter.fillRect(baseRect, palette().background());
    painter.drawImage(0,0, buffer);
}
Beispiel #9
0
void RingChart::drawRing(QPainter &p, const QPoint &center, int ring, int radius1, int radius2, bool checkHighlight, double mouseAngle)
{
	int row_count = m_model->rowCount();

	// calculate segments
    double totalValue = 0;

    for (int r = 0; r < row_count; r++)
    {
        const QModelIndex index(m_model->index(r, ring));
        double value = m_model->data(index).toDouble();

        if (value > 0.0)
            totalValue += value;
    }

	// draw segments
	double startAngle = 0.0;
    bool isHighlighted = false;
    double angleHl1, angleHl2, valueHl;
    QModelIndex indexHl;

	// outer rect
	QRect pieRect(center.x() - radius2, center.y() - radius2, radius2 * 2, radius2 * 2);

    for (int r = 0; r < row_count; r++)
    {
        const QModelIndex index(m_model->index(r, ring));
        double value = m_model->data(index).toDouble();

        if (value > 0.0) {
            double angle = 360 * value / totalValue;



            if (checkHighlight && startAngle <= mouseAngle && mouseAngle <= (startAngle + angle))
            {
                isHighlighted = true;
                angleHl1 = startAngle;
                angleHl2 = angle;
                valueHl = value;
                indexHl = index;
            }
            else
            {            
				drawSegment(p, pieRect, index, value, startAngle, angle, false);
                drawValue(p, pieRect, index, value, startAngle, angle, false);
            }

            startAngle += angle;
        }
    }

    // highlight to be drawn over the other segments
    if (isHighlighted)
    {
        setIndexUnderMouse(indexHl);

        drawSegment(p, pieRect, indexHl, valueHl, angleHl1, angleHl2, true);
        drawValue(p, pieRect, indexHl, valueHl, angleHl1, angleHl2, true);
    }
    else
        setIndexUnderMouse(QModelIndex());
}
Beispiel #10
0
void PieChart::drawContent(QPainter &p)
{
    int w = width() - m_margin*2;
    int h = height() - m_margin*2;

    int wh = qMin(w,h);
    int wh2 = wh / 2;

    int dx2 = (w - wh) / 2;
    int dy2 = (h - wh) / 2;

    QRect pieRect = QRect(dx2+m_margin, dy2+m_margin, wh, wh);

    p.drawEllipse(pieRect);

    if (!m_model)
        return;

    int row_count = m_model->rowCount();
    if (!row_count)
        return;

    int count = m_model->columnCount();
    if (!count)
        return;

    if (m_index < 0 || m_index >= count)
        return;

    // check if need to draw highlight
    bool checkHighlight = false;
    double mouseAngle = 0;

    // check if we're inside piechart at all
    if (!m_mousePos.isNull() && pieRect.contains(m_mousePos))
    {
        // Determine the distance from the center point of the pie chart.
        double cx = m_mousePos.x() - dx2 - wh2;
        double cy = dy2 + wh2 - m_mousePos.y();
        double dr = pow(pow(cx, 2) + pow(cy, 2), 0.5);
        if (!(dr == 0 || dr > wh2)){
            // Determine the angle of the point.
            mouseAngle = (180 / M_PI) * acos(cx/dr);
            if (cy < 0)
                mouseAngle = 360 - mouseAngle;

            checkHighlight = true;
        }
    }

    // draw pie chart
    p.setFont(m_font);

    int c = m_index;

    double totalValue = 0;

    for (int r = 0; r < row_count; r++)
    {
        const QModelIndex index(m_model->index(r, c));
        double value = m_model->data(index).toDouble();

        if (value > 0.0)
            totalValue += value;
    }

    double startAngle = 0.0;
    bool isHighlighted = false;
    double angleHl1, angleHl2, valueHl;
    QModelIndex indexHl;

    for (int r = 0; r < row_count; r++)
    {
        const QModelIndex index(m_model->index(r, c));
        double value = m_model->data(index).toDouble();

        if (value > 0.0) {
            double angle = 360 * value / totalValue;

            if (checkHighlight && startAngle <= mouseAngle && mouseAngle <= (startAngle + angle))
            {
                isHighlighted = true;
                angleHl1 = startAngle;
                angleHl2 = angle;
                valueHl = value;
                indexHl = index;
            }
            else
            {
                drawSegment(p, pieRect, index, value, startAngle, angle, false);
                drawValue(p, pieRect, index, value, startAngle, angle, false);
            }

            startAngle += angle;
        }
    }

    // highlight to be drawn over the other segments
    if (isHighlighted)
    {
        setIndexUnderMouse(indexHl);

        drawSegment(p, pieRect, indexHl, valueHl, angleHl1, angleHl2, true);
        drawValue(p, pieRect, indexHl, valueHl, angleHl1, angleHl2, true);
    }
    else
        setIndexUnderMouse(QModelIndex());
}