Android: Zoom
The SDK offers two ways to achieve zooming the active view.
Existing commands JAVA
Simply using the runCommand() method of the singleton CFxARESInstance.instance().
The final call looks like: CFxARESInstance.instance().runCommand("_ZOOM\n_FIT\n");
This execution can be linked with a onClickListener() of a simple Button. All existing commands take care about refreshing the GA ( graphics area ) properly.
Button.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
CFxARESInstance.instance().runCommand("_ZOOM\n_FIT\n");
}
});
Hint: The same can be e.g. done with PAN.
Available commands are: -PAN 0,0,0 1,1,1\n , PANUP, PANDOWN, PANLEFT, PANRIGHT
Custom code - Java Native Interface JAVA C++
The other way is to write custom C++ code that requires some more actions but has more potential regarding when and how it is executed. The first step is to specify a native Java method that can be called from the app side but must be implemented on C++ side. This native method can be linked with a onClickListener() of simple Button. When the View is updated programmatically without a core command, it must be executed from the working thread and refreshing of the GA ( graphics area ) must be addressed manually. The JNI method accesses the C++ part of the application and must be executed within the working thread. A suitable method runOnWorkingThread() is provided by CFxARESInstance.instance() .
Refreshing the GA can be achieved with a modeless operation. The modeless helper class CModellessOperationHelper is implemented as a guard. When the object is getting destroyed it takes care about refreshing the graphics area.
public static native void ZoomFit();
Button.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
CFxARESInstance.instance().runOnWorkingThread(new Runnable()
{
@Override
public void run()
{
JNI.ZoomFit();
}
});
}
});