mdlTransient_free( pTransient, FALSE );

Hello,

 

I saw that for non persistent display, we need to use transient with Microstation v8i.

I can drawing a transient but when I try to free it and keep element displayed -> mdlTransient( pTransient, FALSE); element is erased too.

Or in MDL, API References we have this : "BoolInt eraseDisplay IN TRUE to erase display". BTW : FALSE should keep element displayed untill a refresh view is done (It's what I need).

Can you explain me why element is erased too ?

 

Regards,

 

  • Native Code

    Saris said:
    I still use native code because application .

    Bentley Systems use the term native code to describe C/C++ source code that is compiled using a C or C++ compiler rather than the MDL compiler (bcomp.exe). With the V8 generation, it is easier than ever to write a native code application. In fact, if you look at the MDL examples delivered with the V8i SS1 SDK, they are all written in C++ (.cpp files).

    DirectX

    Saris said:
    Before we used simple mdlElement_display (..) to display them. These elements still display until we have a refresh on the view. With transient, if I understood, they need to be present in temporary database for transient to still displayed.

    From MicroStation XM, the display system uses Microsoft DirectX rather than the OpenGL used in earlier versions. It is the change in the graphics sub-system that changes the way temporary elements are drawn. Bentley describe the current graphics as 'self-healing'. A side affect of that is that elements drawing in TEMP mode with mdlElement_display persist on screen only until the next video refresh. That's why we have to move to the mdlTransient_api to create temporary elements with XM and later.

    Saris said:
    #include ...
    
    Private TransDescrP myTransient = NULL;
    
    void NewDisplay_mdlElementDisplay ( MSElement* pElement, int drawMode )
    {
        #if MSVERSION < 0x890  /* MicroStation V8 */
            mdlElement_display( pElement, drawMode );
        #else /* MicroStation V8i */
            myTransient = mdlTransient_addElement( myTransient, pElement, FALSE, 0x00ff, drawMode, FALSE, FALSE, TRUE );
            mdlTransient_free (&myTransient, FALSE);
        #endif
    }
    

    Either (i) use a global (MDL Private, C++ static) variable for the transient, or (ii) create your transient in MicroStation's global variable msTransientElmP.

    The problem here is that you've created a transient but freed it immediately. The graphics last only as long as myTransient, which is not very long. Defer mdlTransient_free (&myTransient, FALSE); until your command has finished (i.e. implement a CLEANUP event handler to free the transient). If you use MicroStation's global variable then MicroStation will free it for you when your application unloads.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

  • Hello Jon Summers,

    I still use native code because application start long years ago on previous Microstation version. Now we need to migrate this application on Microstation v8i. Most of mdl functionalities still working fine but not for displaying temporary elements (like it's explain in other post or on LA Solution web site).

    For these temporary element, before we used simple mdlElement_display (..) to display them. These elements still display until we have a refresh on the view. With transient, if I understood, they need to be present in temporary database for transient to still displayed.

    We need to reproduce similar functionalities like on Microstation v85. So, I think to catch event on zoom IN/OUT with mdlView_setFunction( UPDATE_PRE, __myFunction__ );

     

    BTW : there is my C file to use display or transient whether application is running on MicroStation v85 or v8i. Like this way, myTransient is no more in temporary transient database and will no more displayed. I will remove mdlTransient_free and use it in __myFunction__

    #include ...

    Private TransDescrP myTransient = NULL;

    void NewDisplay_mdlElementDisplay ( MSElement* pElement, int drawMode )
    {
        #if MSVERSION < 0x890  /* MicroStation V8 */
            mdlElement_display( pElement, drawMode );
        #else /* MicroStation V8i */
            myTransient = mdlTransient_addElement( myTransient, pElement, FALSE, 0x00ff, drawMode, FALSE, FALSE, TRUE );
            mdlTransient_free (&myTransient, FALSE);
        #endif
    }

  • While your comment is valid if the transient is added to MicroStation's global descriptor, it's not required to add a transient to MicroStation's global descriptor.

    We won't know unless we see a code snippet.

    MicroStationAPI

    As some people continue to remind us (you know who you are), the mdlTransient_api is superseded in V8i by the C++ MicroStationAPI.

    Here's a transient example that uses the MicroStationAPI.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

  • Jon,

    I believe Transients, along with Element Descriptors which they are based upon, are stored in global memory. It is correct that you may loose a locally defined pointer to it, but the memory itself, as long as it concerns MicroStation engine, is persistent until it is explicitly freed by you it or until your MDL application exits (in V8 a Transient is freed automatically because it is associated with application's MDL descriptor, whether on pre-V8 editions it was orphaned).

    Cheers,

    /Chris Z.

  • You've haven't told us much about variable pTransient. Its name suggests that it's a local variable. MicroStation only draws what it knows about. If a local variable containing transient data goes out-of-scope, the data vanishes and MicroStation can't draw it.

    A code snippet is worth 1,000 words.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

  • In V8i the geometry display system (DirectDraw engine) always displays the current state of its database.

    When you insert a Transient it is visible, when you remove it it's not. Geometry database is no longer decoupled from view display like it was in older MicroStation editions and all requests to draw or to inhibit drawing to view window are now meaningless. As soon as MicroStation regains control, it refreshes display of what it believes is curent state of its geometry engine's database. 

    It is correct that some parts of MDL API no longer reflect the valid status quo -- these remain purely for the purpose of not breaking the old code.

    The only difference between Transients and other geometry is that Transients are not stored in the DGN file (but they can be inserted to, or removed from geometry engine's database, just like any other geometry).

    HTH

    Cheers,

    /Chris Z.