ManualGroupDraw.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 "ManualGroupDraw.h" // 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 // add the named tool to the toolbar control void addTool (IToolbarControlPtr &ipToolbar, const char *name) { CComBSTR toolID ("esriControlCommands."); toolID.Append (name); long itemIndex; ipToolbar->AddItem (CComVariant(toolID), 0, -1, VARIANT_FALSE, 0, esriCommandStyleIconOnly, &itemIndex); } // generate a random floating-point number in the specified range [low, high) double dRandom (double low, double high) { static const double MAX_RAND = double ((1 << 31) - 1); #if defined(ESRI_UNIX) return low + double(random()) / MAX_RAND * (high - low); #elif defined(ESRI_WINDOWS) return low + double(rand()) / MAX_RAND * (high - low); #endif } // 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 ("creating 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); } } // use a compound statement to ensure that destructors will be invoked before the AoExit call 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 ManualGroupDraw mainWindow; mainWindow.show(); printf ("passing control to Qt\n"); qapp.exec(); } shutdown(); return 0; }