Hi Nikolay,
This happens because the Sandbox interface is being launched with a default Sandbox instance. This is the SandboxProcess::ProcessCommandLine() routine excerpted from SandboxProcess.cpp:
int SandboxProcess::ProcessCommandLine( const StringList& argv ) const
{
ArgumentList arguments =
ExtractArguments( argv, ArgumentItemMode::AsViews, ArgumentOption::AllowWildcards );
SandboxInstance instance( this );
bool launchInterface = false;
int count = 0;
for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
{
const Argument& arg = *i;
if ( arg.IsNumeric() )
{
throw Error( "Unknown numeric argument: " + arg.Token() );
}
else if ( arg.IsString() )
{
throw Error( "Unknown string argument: " + arg.Token() );
}
else if ( arg.IsSwitch() )
{
throw Error( "Unknown switch argument: " + arg.Token() );
}
else if ( arg.IsLiteral() )
{
// These are standard parameters that all processes should provide.
if ( arg.Id() == "-interface" )
launchInterface = true;
else if ( arg.Id() == "-help" )
{
ShowHelp();
return 0;
}
else
throw Error( "Unknown argument: " + arg.Token() );
}
else if ( arg.IsItemList() )
{
++count;
if ( arg.Items().IsEmpty() )
throw Error( "No view(s) found: " + arg.Token() );
for ( StringList::const_iterator j = arg.Items().Begin(); j != arg.Items().End(); ++j )
{
View v = View::ViewById( *j );
if ( v.IsNull() )
throw Error( "No such view: " + *j );
instance.LaunchOn( v );
}
}
}
if ( launchInterface )
instance.LaunchInterface();
else if ( count == 0 )
{
if ( ImageWindow::ActiveWindow().IsNull() )
throw Error( "There is no active image window." );
instance.LaunchOnCurrentView();
}
return 0;
}
The instance is initialized in line 174:
SandboxInstance instance( this );
This creates a default instance, that is, an instance whose parameters have all their default values. Since the above routine is just a skeleton, it does not interpret any command line parameters and hence does not modify the instance. Then on lines 226 and 231, the instance is used to either launch the process interface or to execute it on the current view, respectively:
instance.LaunchInterface();
instance.LaunchOnCurrentView();
For a good (and easy to follow) example of a real command-line processing routine, you can see FastRotationProcess.cpp. As you can see, this routine modifies the instance being launched or executed through several command-line parameters:
int FastRotationProcess::ProcessCommandLine( const StringList& argv ) const
{
ArgumentList arguments =
ExtractArguments( argv,
ArgumentItemMode::AsViews,
ArgumentOption::AllowWildcards|ArgumentOption::NoPreviews );
FastRotationInstance instance( this );
bool launchInterface = false;
int count = 0;
for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
{
const Argument& arg = *i;
if ( arg.IsNumeric() )
{
if ( arg.Id() == "a" || arg.Id() == "angle" )
{
if ( arg.NumericValue() == +180 || arg.NumericValue() == -180 )
instance.mode = FastRotationMode::Rotate180;
else if ( arg.NumericValue() == 90 )
instance.mode = FastRotationMode::Rotate90CCW;
else if ( arg.NumericValue() == -90 )
instance.mode = FastRotationMode::Rotate90CW;
else
throw Error( "Invalid fast rotation angle - must be 180 or +/-90 degrees: " + arg.Token() );
}
else
throw Error( "Unknown numeric argument: " + arg.Token() );
}
else if ( arg.IsString() )
throw Error( "Unknown string argument: " + arg.Token() );
else if ( arg.IsSwitch() )
throw Error( "Unknown switch argument: " + arg.Token() );
else if ( arg.IsLiteral() )
{
if ( arg.Id() == "r180" )
instance.mode = FastRotationMode::Rotate180;
else if ( arg.Id() == "r90" || arg.Id() == "r90ccw" )
instance.mode = FastRotationMode::Rotate90CCW;
else if ( arg.Id() == "r90cw" )
instance.mode = FastRotationMode::Rotate90CW;
else if ( arg.Id() == "mh" )
instance.mode = FastRotationMode::HorizontalMirror;
else if ( arg.Id() == "mv" )
instance.mode = FastRotationMode::VerticalMirror;
else if ( arg.Id() == "-interface" )
launchInterface = false;
else if ( arg.Id() == "-help" )
{
ShowHelp();
return 0;
}
else
throw Error( "Unknown argument: " + arg.Token() );
}
else if ( arg.IsItemList() )
{
++count;
if ( arg.Items().IsEmpty() )
{
Console().WriteLn( "No view(s) found: " + arg.Token() );
continue;
}
for ( StringList::const_iterator j = arg.Items().Begin(); j != arg.Items().End(); ++j )
{
View v = View::ViewById( *j );
if ( v.IsNull() )
throw Error( "No such view: " + *j );
instance.LaunchOn( v );
}
}
}
if ( launchInterface )
instance.LaunchInterface();
else if ( count == 0 )
{
if ( ImageWindow::ActiveWindow().IsNull() )
throw Error( "There is no active image window." );
instance.LaunchOnCurrentWindow();
}
return 0;
}