Beispiel #1
0
void InterfacePlotterDialog::configChanged()
{
    QFont pfont = mPlotter->font();
    pfont.setPointSize( mSettings.fontSize );
    QFontMetrics fm( pfont );
    int axisTextWidth = fm.width(i18nc("Largest axis title", "99999 XXXX"));
    mPlotter->setMaxAxisTextWidth( axisTextWidth );
    mPlotter->setFont( pfont );
    if ( !mSettings.automaticDetection )
    {
        mPlotter->setMinimumValue( mSettings.minimumValue * mMultiplier );
        mPlotter->setMaximumValue( mSettings.maximumValue * mMultiplier );
    }
    else
    {
        // Don't want the disabled settings to be used as hints
        mPlotter->setMinimumValue( 0 );
        mPlotter->setMaximumValue( 1 );
    }
    mPlotter->setHorizontalScale( mSettings.pixel );
    mPlotter->setVerticalLinesDistance( mSettings.distance );
    mPlotter->setShowAxis( mSettings.labels );
    mPlotter->setShowVerticalLines( mSettings.verticalLines );
    mPlotter->setShowHorizontalLines( mSettings.horizontalLines );
    mPlotter->setUseAutoRange( mSettings.automaticDetection );
    mPlotter->setVerticalLinesScroll( mSettings.verticalLinesScroll );

    mSentLabel->setLabel( i18nc( "network traffic", "Sending" ), mSettings.colorOutgoing);
    mReceivedLabel->setLabel( i18nc( "network traffic", "Receiving" ), mSettings.colorIncoming);

    addBeams();
}
Beispiel #2
0
void InterfacePlotterDialog::useBitrate( bool useBits )
{
    // Have to wipe the plotters if we change units
    if ( mUseBitrate != useBits )
    {
        int nb = mPlotter->numBeams();
        for ( int i = 0; i < nb; i++ )
        {
            mPlotter->removeBeam(0);
        }
        mOutgoingVisible = false;
        mIncomingVisible = false;
    }

    mUseBitrate = useBits;
    if ( mUseBitrate )
        mMultiplier = 1000;
    else
        mMultiplier = 1024;
    addBeams();
    for ( int beamId = 0; beamId < mPlotter->numBeams(); beamId++ )
    {
        QString lastValue = formattedRate( mPlotter->lastValue(beamId), mUseBitrate );
        static_cast<FancyPlotterLabel *>((static_cast<QWidgetItem *>(mLabelLayout->itemAt(beamId)))->widget())->setText(lastValue);
    }
    setPlotterUnits();
}
Beispiel #3
0
void LaserSystem::update(float dt)
{
    // Store the laser sensors to turn off
    laserSensorsToDisable.clear();
    for (int tileId: tileMapData[Tiles::LaserSensor])
        laserSensorsToDisable.insert(tileId);

    // Update laser beams
    for (auto ent: world.query<Laser, TilePosition, State>())
    {
        auto laser = ent.get<Laser>();
        auto tilePos = ent.get<TilePosition>();
        auto state = ent.get<State>();
        if (state->value)
            addBeams(*laser, *tilePos);
        else
            laser->beams.clear();
    }

    // Turn off the laser sensors in the list
    for (int tileId: laserSensorsToDisable)
        es::Events::send(SwitchEvent{tileId, SwitchEvent::Off});
}