Beispiel #1
0
/*******************************************************************************
  Function Name  : OnInitialUpdate
  Input(s)       : -
  Output         : FALSE - If focus is set to Any UI control explicitly
  Functionality  : Initialises dialog's UI components
  Member of      : CGraphBottomView
  Author(s)      : Raja N
  Date Created   : 10/12/2004
  Modifications  : Raja N on 15.12.2004, Added code to check graph control
                   proper load by checking the window handle
*******************************************************************************/
void CGraphBottomView::OnInitialUpdate()
{
    // Call Parent windows Update
    CFormView::OnInitialUpdate();
    // Load Icons from direction buttons
    m_omBtnUp.SetIcon(AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_ICON_UP)));
    m_omBtnDown.SetIcon(AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_ICON_DOWN)));
    m_omBtnLeft.SetIcon(AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_ICON_LEFT)));
    m_omBtnRight.SetIcon(AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_ICON_RIGHT)));
    //CGraphList * podList = NULL;
    CGraphChildFrame* pParentWnd = NULL;
    pParentWnd = (CGraphChildFrame*)pomGetParentWindow();
    pParentWnd->m_pomBottomView = this;
    // Get Graph Control Pointer
    m_pDMGraphCtrl = pParentWnd->m_pDMGraphCtrl;
    // If window handle is invalid then init pointer with NULL
    /*if( m_opDMGraphCtrl != NULL &&
        IsWindow(m_opDMGraphCtrl->m_hWnd) == FALSE )
    {
        m_opDMGraphCtrl = NULL;
    }*/
    //Update initial values
    m_dblarrTime[0] = dRound(m_dblarrTime[0], 3);
    m_dblarrTime[1] = dRound(m_dblarrTime[1], 3);
    m_dblDeltaTime  = dRound(m_dblDeltaTime , 3);
    // Create List Control
    m_lstSignalDetails.DeleteAllItems();
    //Set List Control styles
    m_lstSignalDetails.SetExtendedStyle
    (LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT  );
    //Create Columns
    vCreateColumns();
}
Beispiel #2
0
/*******************************************************************************
  Function Name  : vUpdateCursordetails
  Input(s)       : X, Y, shCursorID
  Output         : -
  Functionality  : Cusor details updater
  Member of      : CGraphBottomView
  Author(s)      : ArunKumar K
  Date Created   : 22/12/2010
  Modifications  :
*******************************************************************************/
void CGraphBottomView::vUpdateCursordetails(double X, double /*Y*/, short shCursorID)
{
    m_dblarrTime[shCursorID - 1] = X;

    if( m_dblarrTime[1] != 0)
    {
        m_dblDeltaTime = m_dblarrTime[1] - m_dblarrTime[0];
        vUpdateSignalData();
    }

    if( m_dblarrTime[0] == 0 && m_dblarrTime[1] == 0 )
    {
        vUpdateSignalData();
    }

    if( m_dblarrTime[0] == 0)
    {
        m_dblDeltaTime = 0;
    }

    m_dblarrTime[0] = dRound(m_dblarrTime[0], 3);
    m_dblarrTime[1] = dRound(m_dblarrTime[1], 3);
    m_dblDeltaTime  = dRound(m_dblDeltaTime , 3);
    UpdateData(FALSE);
}
/*******************************************************************************
  Function Name  : vUpdateSignalData
  Input(s)       : -
  Output         : -
  Functionality  : This function will update signal data based on cursor details.
  Member of      : CGraphBottomView
  Author(s)      : ArunKumar K
  Date Created   : 22/12/2010
  Modifications  : ArunKumar K, 24/12/2010
                   Made the dblDiff to contain only modulus of difference.
*******************************************************************************/
void CGraphBottomView::vUpdateSignalData()
{
    if ( m_pDMGraphCtrl == NULL )
    {
        return;
    }

    CGraphChildFrame* pParentWnd = NULL;
    pParentWnd = (CGraphChildFrame*)pomGetParentWindow();
    double dblValue1 = 0, dblValue2 = 0, dblDiff;
    CString strValue1, strValue2, strDiffVal;

    if( m_dblarrTime[0] == 0 && m_dblarrTime[1] == 0 )
    {
        for( int nIndex = 0; nIndex < m_lstSignalDetails.GetItemCount(); nIndex++)
        {
            m_lstSignalDetails.SetItemText( nIndex, 3, STR_EMPTY);  //Cursor 1 value
            m_lstSignalDetails.SetItemText( nIndex, 4, STR_EMPTY);  //Cursor 2 value
            m_lstSignalDetails.SetItemText( nIndex, 5, STR_EMPTY); //Difference value
        }
        return;
    }

    for( int nIndex = 0; nIndex < m_lstSignalDetails.GetItemCount(); nIndex++)
    {
        dblValue1 = 0;
        dblValue2 = 0;
        m_pDMGraphCtrl->GetElementValueAtCursor( (short)nIndex, m_dblarrTime[0], &dblValue1);
        m_pDMGraphCtrl->GetElementValueAtCursor( (short)nIndex, m_dblarrTime[1], &dblValue2);

        dblDiff = dblValue2 - dblValue1;

        if( dblDiff < 0)
        {
            dblDiff = -dblDiff;
        }

        dRound(dblValue1, 3);
        dRound(dblValue2, 3);
        dRound(dblDiff, 3);

        strValue1.Format( _T("%.3lf") ,dblValue1);
        strValue2.Format( _T("%.3lf") ,dblValue2);
        strDiffVal.Format(_T("%.3lf") ,dblDiff);

        m_lstSignalDetails.SetItemText( nIndex, 3, strValue1);  //Cursor 1 value
        m_lstSignalDetails.SetItemText( nIndex, 4, strValue2);  //Cursor 2 value
        m_lstSignalDetails.SetItemText( nIndex, 5, strDiffVal); //Difference value
    }
}
Beispiel #4
0
void test_round::test()
{
    {
        double d = 15.0;
        int id = dRound ( d );
        assert ( id == 15 );
        d = 15.2;
        id = dRound ( 15.2 );
        assert ( id == 15 );
        d = 15.8;
        id = dRound ( d );
        assert ( id == 16 );
        d = 15.5;
        id = dRound ( d );
        assert ( id = 16 );
    }
    {
        double d = 15.0;
        int id = dRound ( d, 5 );
        assert ( id == 15 );
        d = 15.2;
        id = dRound ( 15.2, 5 );
        assert ( id == 15 );
        d = 15.8;
        id = dRound ( d, 5 );
        assert ( id == 15 );
        d = 15.5;
        id = dRound ( d, 5 );
        assert ( id == 15 );

        d = 17;
        id = dRound ( d , 5 );
        assert ( id == 15 );

        d = 18;
        id = dRound ( d, 5 );
        assert ( id == 20 );

        d = 19;
        id = dRound ( d, 5 );
        assert ( id == 20 );
    }
}