1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
|
/*=========================================================================
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.kitware.com/VolViewCopyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "@APPLICATION_CLASS_NAME@.h"
#if @CREATE_WINDOW@
#include "@WINDOW_CLASS_NAME@.h"
#endif
#include "vtkKWLanguage.h"
#if @AUTHENTICATED_READ@
#include "vtkVVFileAuthenticator.h"
#endif
#include <vtksys/SystemTools.hxx>
#include <vtksys/CommandLineArguments.hxx>
#ifdef _WIN32
#include <windows.h>
#endif
#include "vtkKWWidgetsProConfigure.h" // Needed for KWWidgetsPro_USE_LICENSE
#ifdef KWWidgetsPro_USE_LICENSE
#include "vtkKWRegistrationWizard.h"
#endif
#if @HAS_EXTRA_SOURCES@
extern "C" int @EXTRA_SOURCES_LIB_INIT@(Tcl_Interp *interp);
#endif
int my_main(int argc, char *argv[])
{
// Process some command-line arguments
int registry_level = 10;
vtksys::CommandLineArguments args;
args.Initialize(argc, argv);
args.AddArgument(
"-L", vtksys::CommandLineArguments::SPACE_ARGUMENT, ®istry_level,
"Registry level");
args.Parse();
int remaining_argc;
char **remaining_argv;
args.GetRemainingArguments(&remaining_argc, &remaining_argv);
// Initialize Tcl
ostrstream err;
Tcl_Interp *interp =
@APPLICATION_CLASS_NAME@::InitializeTcl(remaining_argc, remaining_argv, &err);
if (!interp)
{
err << ends;
#ifdef _WIN32
::MessageBox(0, err.str(),
"Error: InitializeTcl failed", MB_ICONERROR|MB_OK);
#else
cerr << "Error: InitializeTcl failed: " << err.str() << endl;
#endif
return 1;
}
#if @HAS_EXTRA_SOURCES@
@EXTRA_SOURCES_LIB_INIT@(interp);
#endif
@APPLICATION_CLASS_NAME@ *app = @APPLICATION_CLASS_NAME@::New();
app->SetRegistryLevel(registry_level);
if (strlen("@APPLICATION_NAME@"))
{
app->SetName("@APPLICATION_NAME@");
}
app->SetMajorVersion(@MAJOR_VERSION@);
app->SetMinorVersion(@MINOR_VERSION@);
if (strlen("@RELEASE_NAME@"))
{
app->SetReleaseName("@RELEASE_NAME@");
}
app->SetReleaseMode(@APP_BUILD_AS_RELEASE@);
if (strlen("@COMPANY_NAME@"))
{
app->SetCompanyName("@COMPANY_NAME@");
}
if (strlen("@EMAIL_FEEDBACK_ADDRESS@"))
{
app->SetEmailFeedbackAddress("@EMAIL_FEEDBACK_ADDRESS@");
}
if (strlen("@PURCHASE_URL@"))
{
app->SetPurchaseURL(
"@PURCHASE_URL@");
}
if (strlen("@COMPANY_SALES_CONTACT@"))
{
app->SetCompanySalesContact(
"@COMPANY_SALES_CONTACT@");
}
if (strlen("@COMPANY_SUPPORT_CONTACT@"))
{
app->SetCompanySupportContact(
"@COMPANY_SUPPORT_CONTACT@");
}
if (strlen("@PRIMARY_COPYRIGHT@"))
{
app->SetPrimaryCopyright(
"@PRIMARY_COPYRIGHT@");
}
if (strlen("@DOCUMENTATION_FILENAME@"))
{
app->SetHelpDialogStartingPage("@DOCUMENTATION_FILENAME@");
}
if (strlen("@TUTORIAL_FILENAME@"))
{
app->SetTutorialStartingPage("@TUTORIAL_FILENAME@");
}
if (strlen("@FILE_EXTENSIONS_SPACE@"))
{
app->SetSessionFileExtensions("@FILE_EXTENSIONS_SPACE@");
}
if (strlen("@APP_EXPIRE_TIME@"))
{
app->SetExpireTime("@APP_EXPIRE_TIME@");
}
vtkKWLanguage::SetCurrentLanguage(
vtkKWLanguage::GetLanguageFromXPG("@DEFAULT_LANGUAGE@"));
// Authenticate files prior to loading them ?
app->SetAuthenticateRead(@AUTHENTICATED_READ@);
#if @AUTHENTICATED_READ@
if (strlen("@AUTHENTICATED_READ_PUBLIC_KEY_FILE@") &&
app->GetAuthenticator())
{
app->GetAuthenticator()->SetPublicKeyFile(
"@AUTHENTICATED_READ_PUBLIC_KEY_FILE@");
}
#endif
#if defined(KWWidgetsPro_USE_LICENSE)
if (app->GetRegistrationWizard())
{
app->GetRegistrationWizard()->SetSupportLimitedEditionMode(@SUPPORT_LIMITED_EDITION_MODE@);
app->GetRegistrationWizard()->SetSupportTrialMode(@SUPPORT_TRIAL_MODE@);
}
#endif
// Get the application settings from the registry.
// It has to be called now, since parsing the command line may have
// changed the registry level; it can not be called in the application
// constructor or even the KWApplication constructor since we need the
// application name to be set, and that name is set at the end.
app->RestoreApplicationSettingsFromRegistry();
// Add a window
#if @CREATE_WINDOW@
@WINDOW_CLASS_NAME@ *win = @WINDOW_CLASS_NAME@::New();
if (strlen("@DOCUMENTATION_FILENAME@") || strlen("@TUTORIAL_FILENAME@"))
{
win->SupportHelpOn();
}
#if @SUPPORT_PLUGINS@
win->SupportPluginsOn();
#endif
app->AddWindow(win);
win->Delete();
#endif
// Start the app
app->Start(remaining_argc, remaining_argv);
int ret = app->GetExitStatus();
app->Delete();
#if VTK_MAJOR_VERSION > 5 || (VTK_MAJOR_VERSION == 5 && VTK_MINOR_VERSION > 0)
args.DeleteRemainingArguments(remaining_argc, &remaining_argv);
#else
int cc;
for (cc = 0; cc < remaining_argc; ++cc)
{
delete [] remaining_argv[cc];
}
delete [] remaining_argv;
#endif
return ret;
}
#ifdef _WIN32
int __stdcall WinMain(HINSTANCE, HINSTANCE, LPSTR lpCmdLine, int)
{
int argc;
char **argv;
vtksys::SystemTools::ConvertWindowsCommandLineToUnixArguments(
lpCmdLine, &argc, &argv);
int ret = my_main(argc, argv);
for (int i = 0; i < argc; i++) { delete [] argv[i]; }
delete [] argv;
return ret;
}
#else
int main(int argc, char *argv[])
{
return my_main(argc, argv);
}
#endif
|