Formatting Value Labels in Engeneering Format

Posted by: cpn on 14 September 2021, 7:05 pm EST

  • Posted 14 September 2021, 7:05 pm EST

    For OlectraChart v8 used as a C++/DLL (still beating my .NET/C# collogues in speed and performance :-)
    I'm trying to formatting value labels in engineering format (the exponent in a factor of 3, like 31.23E+03, 0.7E-6 etc.) I can't find a way to do this using the standard formatting #0? using SetXAxisLabelFormat.
    But I found that the component is sending and event for the value labels when using SetXAnnotationMethod(XRT_ANNO_VALUES_EVENT).
    But the format of the parameters is not documented. I think that this could probably be used to alter a value like 1.5E+04 to 15E+03 on the fly.
    Please provide me with the argument of the event.
    Thanks cpede
  • Replied 14 September 2021, 10:03 pm EST

    OK, found it myself: XrtFormatAxisAnnoCallbackStruct.


    LRESULT CMyChart::OnAxisAnno(WPARAM, LPARAM lData)
    {
    XrtFormatAxisAnnoCallbackStruct* pData =
    (XrtFormatAxisAnnoCallbackStruct*)lData;
    if (pData == NULL) return 0L;

    // for some strange reason adding X after each number string
    size_t nLen = _tcslen(pData->label->string) + 1; // one X
    TCHAR *pszText = new TCHAR[nLen + 1];
    ::ZeroMemory(pszText, (nLen + 1)* sizeof(TCHAR));
    _tcscpy_s(pszText, nLen + 1, pData->label->string);
    _tcscat_s(pszText, nLen + 1, _T("X"));
    pData->label->string = pszText;
    return 0L;
    }


    The problem is now:
    I get assertions in SetRepaint
    olch2d8.dll!00007fff273f4047() Unknown
    * Who is responsible for deleting the old pData->label->string, and how should this be deleted?
    * Or should I delete the entire XrtValueLabel pData->label?

    Thanks cpede
  • Replied 26 September 2021, 4:52 pm EST

    Again:
    What is the right way of overwriting the pData->label->string?
    Who is responsible for deleting the old pData->label->string, and how should this be deleted?
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels