예제 #1
0
void
QvisOpacitySlider::paintValueText(QPainter *p, const QPalette &cg, int x,
    int h)
{
    // Create the text that we have to display.
    int v = (state == Dragging) ? (valueFromPosition(sliderPos)) : value();
    float t = float(v - minimum()) / float(maximum() - minimum());
    QString txt; txt.sprintf("%d%%", int(t * 100.f));

    // Figure out the y offset.
    int dy = h - fontMetrics().height();
    int y = (h - dy / 2);

    // Set the brush and draw the text.
    p->setPen(cg.color(QPalette::Text));
    p->drawText(x + textPadding(), y, txt);
}
예제 #2
0
파일: CTRNNViz.cpp 프로젝트: buhrmann/dynmx
//----------------------------------------------------------------------------------------------------------------------
void CTRNNViz::renderAsMatrix()
{
    ci::Vec2f textPadding (m_padding, m_padding);

    // Weights matrix label
    ci::Vec2f wLabelPos = ci::Vec2f(0, m_label2y);
    ci::gl::drawSolidRect(ci::Rectf(wLabelPos.x, wLabelPos.y, wLabelPos.x + m_width, wLabelPos.y + m_labelHeight));
    ci::gl::drawString("CTRNN " + s_weightModeNames[m_weightMode], wLabelPos + textPadding, m_textColor, m_font);

    // Mode button
    ci::gl::color(0.7f, 0.7f, 0.7f);
    ci::gl::drawSolidRect(m_weightModeButton);

    // Render children (vector and matrix viz)
    for(int i = 0; i < 2; i++)
    {
        m_children[i]->update();
    }
}
예제 #3
0
int
QvisOpacitySlider::imageWidth() const
{
    return width() - fontMetrics().width("100%") - textPadding();
}
예제 #4
0
파일: CTRNNViz.cpp 프로젝트: buhrmann/dynmx
//----------------------------------------------------------------------------------------------------------------------
void CTRNNViz::update()
{
    ci::Vec2f textPadding (m_padding, m_padding);

    // Move to correct position
    glPushMatrix();
    dmx::translate(m_pTM->getTranslate());

    // outputs label
    ci::gl::color(m_labelColor);
    ci::gl::drawSolidRect(ci::Rectf(0, 0, m_width, m_labelHeight));
    ci::gl::drawString("CTRNN outputs", textPadding, m_textColor, m_font);

    // Mode button
    ci::gl::color(0.7f, 0.7f, 0.7f);
    ci::gl::drawSolidRect(m_modeButton);

    // Draw according to selected mode
    ci::gl::color(m_labelColor);
    renderAs(m_mode);

    // data label
    ci::gl::color(m_labelColor);
    ci::Vec2f dLabelPos = ci::Vec2f(0, m_label3y);
    ci::gl::drawSolidRect(ci::Rectf(dLabelPos.x, dLabelPos.y, dLabelPos.x + m_width, dLabelPos.y + m_labelHeight));
    ci::gl::drawString("CTRNN data ", dLabelPos + textPadding, m_textColor, m_font);

    // text box
    ci::Vec2f textBoxPos = dLabelPos + ci::Vec2f(0, m_labelHeight + m_padding);
    float textBoxH = 3 * m_lineHeight + 2 * m_padding;
    if (m_topology->isAdaptive())
        textBoxH += 2 * m_lineHeight;
    ci::gl::drawSolidRect(ci::Rectf(textBoxPos.x, textBoxPos.y, textBoxPos.x + m_width, textBoxPos.y + textBoxH));

    // text
    ci::Vec2f textPos = textBoxPos + textPadding;

    // get selected node from current viz
    int i;
    switch (m_mode)
    {
    case kRM_Matrix:
    default:
        i = m_outputs->m_iSel;
        break;
    case kRM_Wheel:
        i = m_wheelViz->getSelectedNeuron();
        break;
    case kRM_Ring:
        i = m_neuronViz->getSelectedNeuron();
        break;
    case kRM_Layers:
        i = m_layerViz->getSelectedNeuron();
        break;
    }

    char str [128];
    if(i != -1)
    {
        sprintf(str, "Node: %i", i);
        ci::gl::drawString(str, textPos, m_textColor, m_font);

        sprintf(str, "b: %2.2f | t: %2.2f | g: %2.2f", m_ctrnn->getBias(i), m_ctrnn->getTimeConstant(i), m_ctrnn->getGain(i));
        ci::gl::drawString(str, textPos + ci::Vec2f(0, m_lineHeight), m_textColor, m_font);

        sprintf(str, "e: %2.2f | i: %2.2f | y: %2.2f | out: %1.3f", m_ctrnn->getExternalInput(i), m_ctrnn->getInput(i), m_ctrnn->getState(i), m_ctrnn->getOutput(i));
        ci::gl::drawString(str, textPos + ci::Vec2f(0, 2 * m_lineHeight), m_textColor, m_font);

        if (m_topology->isAdaptive())
        {
            sprintf(str, "mean-out: %2.2f | mean-diff: %2.2f", ((AdapNN*)m_ctrnn)->getMeanOutput(i), m_ctrnn->getOutput(i) - ((AdapNN*)m_ctrnn)->getMeanOutput(i));
            ci::gl::drawString(str, textPos + ci::Vec2f(0, 4 * m_lineHeight), m_textColor, m_font);
        }
    }

    if(m_mode == kRM_Matrix)
    {
        const int& iW = m_weights->m_iSel;
        const int& jW = m_weights->m_jSel;
        if(iW != -1 && jW != -1)
        {
            sprintf(str, "value %i > %i: %2.6f", iW, jW, m_weights->getValue(iW, jW));
            ci::gl::drawString(str, textPos, m_textColor, m_font);
        }
    }

    glPopMatrix();
}