Пример #1
0
void tGauge::UnitsChanged( tUnitsType type, int unitsValue )
{
    if( ( m_Indicators.size() > 0 ) && ( m_UnitsType == type ) )
    {
        tDigitalData pData( m_Indicators.at( 0 ).dataId );
        tConvert* pConverter = tConvert::Instance();

        //special case for UNITS_ECONOMY. They can be inverted by the user, and we need
        //to retrieve the new limits from tDigitalData, which handles this.
        if( type == UNITS_ECONOMY )
        {
            RealLimits.max = pData.MaxConverted();
            RealLimits.min = pData.MinConverted();

            RealWarnings.max = pData.WarningHighConverted();
            RealWarnings.min = pData.WarningLowConverted();

            AbsoluteLimits.max = pData.AbsoluteMaxConverted();
            AbsoluteLimits.min = pData.AbsoluteMinConverted();
        }
        else
        {
            tFloatLimits limits;
            limits.max = pConverter->ToUser( m_UnitsType, m_UnitsValue, RealLimits.max );
            limits.min = pConverter->ToUser( m_UnitsType, m_UnitsValue, RealLimits.min );

            tFloatLimits warnings;
            warnings.max = pConverter->ToUser( m_UnitsType, m_UnitsValue, RealWarnings.max );
            warnings.min = pConverter->ToUser( m_UnitsType, m_UnitsValue, RealWarnings.min );

            tFloatLimits absLimits;
            absLimits.max = pConverter->ToUser( m_UnitsType, m_UnitsValue, AbsoluteLimits.max );
            absLimits.min = pConverter->ToUser( m_UnitsType, m_UnitsValue, AbsoluteLimits.min );
            AbsoluteLimits = absLimits;
            SetLimits( limits, warnings );
        }

        m_UnitsType = type;
        m_UnitsValue = unitsValue;

        int limitIndex = GetCustomHobartLimits();
        SetCustomHobartLimits( limitIndex );

        OnLimitsChanged();

        m_UnitsStr = pData.UnitStr();
        ReconfigureGauge();
        InvalidateBackground();
    }
}
Пример #2
0
void tGauge::InitialiseLimits()
{
    tDigitalData pData( GetDataId() );

    m_UnitsType = pData.Units( GetDataId().DataType() );
    m_UnitsValue = tUnitsSettings::Instance()->Units( m_UnitsType );

    AbsoluteLimits = pData.AbsoluteLimitsConverted();

    //Check for user specified limits, else get from tDigitalData.
    tFloatLimits limits;
    if( m_GaugeParams.m_Limits.IsValid() && m_UnitsType != UNITS_ECONOMY )
    {
        limits = pData.ConvertLimits( m_GaugeParams.m_Limits );
    }
    else
    {
        limits = tFloatLimits( pData.MinConverted(), pData.MaxConverted() );
    }

    //Check for user specified warnings, else get from tDigitalData.
    tFloatLimits warnings;
    if( m_GaugeParams.m_Warnings.IsValid() && m_UnitsType != UNITS_ECONOMY )
    {
        warnings = pData.ConvertLimits( m_GaugeParams.m_Warnings );
    }
    else
    {
        warnings = tFloatLimits( pData.WarningLowConverted(), pData.WarningHighConverted() );
    }

    SetCaptions();

    //mildly bad form when called from the constructor as SetLimits is virtual.. but base implementation is desired in this case, so all good.
    tGauge::SetLimits( limits, warnings );

    // We may have dynamically changing custom limits.
    OnLimitsChanged();
}
Пример #3
0
void ScrollBarBase::SetDocumentSize(float limit)
{
	_documentSize = limit;
	OnLimitsChanged();
	SetPos(GetPos()); // update scroll box position
}
Пример #4
0
void ScrollBarBase::SetPageSize(float ps)
{
	_pageSize = ps;
	OnLimitsChanged();
	SetPos(GetPos()); // update scroll box size and position
}
Пример #5
0
tGauge::tGauge( const tDataId& dataId, QWidget* parent, const tGaugeParams& params )
    :   tOverlayWidget( parent ),
        m_pUpdateTimer( 0 ),
        m_BezelEnabled( params.m_GaugeFlags.IsClear( tGaugeParams::HideBezel ) ),
        m_InvertedText( params.m_GaugeFlags.IsSet( tGaugeParams::InvertText ) ),
        m_OutlineText( params.m_GaugeFlags.IsSet( tGaugeParams::OutlineText ) ),
        m_CaptionEnabled( params.m_GaugeFlags.IsClear( tGaugeParams::HideCaption ) ),
        m_UnitsEnabled( params.m_GaugeFlags.IsClear( tGaugeParams::HideCaption ) ),
        m_IsSelected( false ),
        m_ForeIsCached( false ),
        m_BackIsCached( false ),
        m_AutoConfigureEnabled( params.m_GaugeFlags.IsSet( tGaugeParams::AutoConfig ) ),
        m_ForcedHide( params.m_GaugeFlags.IsSet( tGaugeParams::HideGauge ) ),
        m_UseStrictClickableRegion( params.m_GaugeFlags.IsSet( tGaugeParams::UseStrictRegions ) ),
        m_BackCache( NULL ),
        m_ForeCache( NULL ),
        m_IsOverlay( false ),
        m_TopBorderGrad( true ),
        m_BottomBorderGrad( true ),
        m_LeftBorder( true ),
        m_TopBorder( true ),
        m_RightBorder( true ),
        m_BottomBorder( true ),
        m_BackgroundFill( true ),
        m_GaugeParams( params ),
        m_Modified( false ),
        m_OriginalGeometry( QRect() ),
        m_StartTimerID( 0 ),
        m_Registered( false ),
        m_HideBezelOverride( params.m_GaugeFlags.IsSet( tGaugeParams::HideBezelOverride ) ),
        m_NormalizedPos( params.m_NormalizedPos ),
        m_NormalizedSize( params.m_NormalizedSize ),
        m_SaveLimits( false ),
        m_Enabled( true ),
        m_UpdateRate(cDefaultRate)
{
    setObjectName( params.m_UsesGauge );
    setAttribute( Qt::WA_TransparentForMouseEvents );
    //for auto source adding
    tDigitalDataSourceSelection* pSourceSelection = tDigitalDataManager::Instance()->GetSourceSelection();
    Connect( pSourceSelection, SIGNAL( NumInstancesChanged( int ) ), this, SLOT( OnGlobalDataSourceNumInstancesChanged( int ) ) );

    // dispay settings changed
    Connect( tInstrumentUiSettings::Instance(), SIGNAL( DisplayInstancesChanged () ), this, SLOT( OnDisplaySettingsUpdated () ) );
    Connect( tInstrumentUiSettings::Instance(), SIGNAL( GaugeLimitsChanged () ), this, SLOT( OnLimitsChanged() ) );

    //for updating
    m_pUpdateTimer = new QTimer( this );
    m_pUpdateTimer->setInterval(m_UpdateRate);

    Connect( m_pUpdateTimer, SIGNAL( timeout() ), this, SLOT( UpdateValues() ) );
    Connect( m_pUpdateTimer, SIGNAL( timeout() ), this, SLOT( UpdateCaption() ) );

    //for unit changes
    Connect( tUnitsSettings::Instance(), SIGNAL( UnitsChanged( tUnitsType,int ) ), this, SLOT( UnitsChanged( tUnitsType, int ) ) );

     if( !m_BezelEnabled && params.m_GaugeFlags.IsClear( tGaugeParams::HideBezelOverride ) )
    {
        m_OutlineText = true;
    }

    //must happen before showEvent
    SetStartDelay( m_StartDelayCounter * 100 );
    m_StartDelayCounter++;
    if( ( m_StartDelayCounter % 10 ) == 0 )
    {
        m_StartDelayCounter = 0;
    }

    if( dataId.DataType() == DATA_TYPE_INVALID )
    {
        setAttribute( Qt::WA_TransparentForMouseEvents );
        return;
    }

    for( int i = 0; i < params.m_DataList.size(); i++ )
    {
        m_Indicators << tIndicator( params.m_DataList.at( i ) );
    }
    if( m_Indicators.size() == 0 )
    {
        m_Indicators << tIndicator( dataId );
    }

    InitialiseLimits();

    // Vessel fuel capacity - scales will change for some data types.
    Connect( tDigitalDataManager::Instance()->GetFuelSettings(), SIGNAL( VesselFuelCapacityChanged(float) ), this, SLOT( OnVesselFuelCapacityChanged() ) );
}