Draw force elements
DrawForceElements.cpp
// Copyright 2010 ESRI
// 
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
// 
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
// 
// See the use restrictions.
// 


#include "DrawForceElements.h"
#include "DrawForceElementsWindow.h"

#if defined(ESRI_UNIX)
    #include <Qt/QtCore>
#elif defined(ESRI_WINDOWS)
    #include <QtCore/QtCore>
#endif

// the first macro expands the symbol defined on the command line; the second puts quotes around it
#define EXPANDSTRING(x) STRINGIFY(x)
#define STRINGIFY(x) #x


// get the full path of a dataset in the Defense Solutions sample data
CComBSTR dsDataPath (const char *relativeDatasetPath)
{
#if defined(ESRI_UNIX)
    CComBSTR path (EXPANDSTRING(DATADIRECTORY) "/Samples/data/defensesolutions/");
#elif defined(ESRI_WINDOWS)
    // Change the following path if the SDK is installed to a different directory.
    CComBSTR path (L"C:\\Program Files\\ArcGIS\\DeveloperKit10.0\\Samples\\data\\defensesolutions\\");
#endif

    path.Append (relativeDatasetPath);
    return path.Copy();
}


// shut down arc objects and terminate the application
void shutdown()
{
    IAoInitializePtr ipInit (CLSID_AoInitialize);
    ipInit->Shutdown();
    ::AoUninitialize();
    AoExit (0);
}


int main(int argc, char **argv)
{
    printf ("initializing application\n");
    {
        printf ("calling AoInitialize\n");

        ::AoInitialize (NULL);

#if defined(ESRI_UNIX)
        ::DsInitialize();
#endif
        {
            printf ("initializing license\n");

            IAoInitializePtr ipInit (CLSID_AoInitialize);
            esriLicenseStatus status;
            ipInit->Initialize (esriLicenseProductCodeEngine, &status);
            if ( status != esriLicenseCheckedOut )
            {
                printf ("Invalid Licensing.\n");
                ::AoUninitialize();
                AoExit (0);
            }
        }

    QAxApplication qapp (argc, argv);

        // get the current time and use it to seed the RNG
        QTime time = QTime::currentTime();

#if defined(ESRI_UNIX)
        srandom (1000 * time.second() + time.msec());
#elif defined(ESRI_WINDOWS)
        srand (1000 * time.second() + time.msec());
#endif


        printf ("initializing renderer\n");

        // instantiate and display the main widget
        DrawForceElementsWindow window;
        window.show();

        printf ("passing control to Qt\n");

        qapp.exec();
    }
    shutdown();
    return 0;
}