The STK Engine Reference Application

Note: Although the example that accompanies this shipment is in C#, the following discussion is focused on aspects of the reference application that are applicable and important regardless of programming language.

This shipment of the STK Engine is accompanied by an application that illustrates some of the ways in which you can leverage STK Engine embedded technology in your custom, stand-alone applications. The example used here is an application called Single Integrated Space Picture (SISP), designed to provide information on satellites and other assets of interest to the user at a glance.

This application, together with source files in C# (see note above, however), are located at:

<STK install folder>/CodeSamples/CustomApplications/CSharp/Sisp

To load the SISP application, please open the solution file in the directory referenced above in Visual Studio 2015, Visual Studio 2013, or Visual Studio 2012. That directory also contains a text version of the full C# source code (SISPSource.txt).

Object Model

When the application is launched, the constructor SispForm() is invoked, which contains the following line:

stkRoot = new AGI.STKObjects.AgStkObjectRoot();

This line instantiates an instance of STK Automation Object Model. The Object Model is designed to make it easy for users to build custom solutions using STK Engine. It provides developers with capabilities to control and automate STK objects, manage the lifetime of STK objects, access Data Provider Tools, perform access and coverage computations, and respond to events generated by STK. It is the preferred way of accessing and manipulating STK.

When the application's main form is loaded, SispForm_Load() event is called, which contains the following line.

stkRoot.NewScenario("SISP");

The above line uses the object model to create a new scenario. If you browse through the application code, you will see that the objects model is used extensively to access STK's analytical and visualization capabilities - creating and defining objects, calculating access, etc. For example, in the SispForm_Load() event, mentioned above, object model methods and properties are used to create and define a new scenario and to add a facility and set properties.

Another illustration of effective use of the Object model is in the event addVehicleShown_Click(object sender, EventArgs e), which implements the button used for moving great arc vehicles from a vehicles 'Available' list to a vehicles 'Shown' list.

Looping through the selected vehicles list, this event repeatedly calls an AddVehicle(...) function that creates a new vehicle and sets waypoints and various graphics properties for it on each iteration. Ordinarily, the graphics display in the Globe window would be updated every time that a vehicle is added. To prevent this and thereby improve performance, the addVehicleShown_Click event calls an object model method 'stkRoot.BeginUpdate()' to suspend graphics updating before beginning the loop through the selected vehicles list and calls 'stkRoot.EndUpdate()' afterwards to resume updating.

Before you move on to the next section, you may want to take a few minutes to explore the STK X Help System. STK X Help contains a wealth of information on the ActiveX components shipped with STK X, including code samples in other .NET languages languages (Visual Basic, C#, etc.) and C++.

Sending Connect Commands

Another way of accessing and manipulating STK is via sending Connect commands. A member of the axAgUiAxVOCntrl1.Application property, the ExecuteCommand method, is used for sending Connect commands to be processed by STK. In the accompanying C# code, the method is invoked in the function SendCommand(string command) through the following line:

rVal = this.axAgUiAxVOCntrl1.Application.ExecuteCommand(command);

The help page for the ExecuteCommand method contains important Connect command formatting information and links to:

If you browse through the accompanying code listing, you will see that the ExecuteCommand method (via the SendCommand function) is used a few times in communicating with STK.

Communicating with the Globe Control

The event globe_DblClick () retrieves various kinds of information about an object that is double-clicked on the Globe control and uses it to update various data displays in the application. The globe_DblClick() event calls UpdateFacility() method to accomplish this. This method includes three calls to functions that invoke the AgPickInfoData object:

private void UpdateFacility()
{
...

x = Int32.Parse(suvellanceXTextBox.Text);
y = Int32.Parse(suvellanceYTextBox.Text);

path = PickObjectInfo(x, y);

...
if (survAccessOn)
{
suvellanceLatitudeTextBox.Text = Convert.ToString(PickInfoLat(x, y));
suvellanceLongitudeTextBox.Text = Convert.ToString(PickInfoLon(x, y));

...
}

The values in suvellanceXTextBox.Text and suvellanceYTextBox.Text were set globally in axAgUiAxVOCntrl1_MouseMoveEvent event on the Globe control:

private AgPickInfoData SetPickInfoData(int x, int y)
{
...
else if (globeViewTabControl.SelectedIndex == GLOBETAP_INDEX_3D)
{
return axAgUiAxVOCntrl1.PickInfo(x, y);
}
return null;
}

The PickInfo method processes the point clicked and returns an AgPickInfoData object that contains (if available) the corresponding 3D scene latitude, longitude and altitude and the STK object (if any) at that location. When that object is returned to the calling function -- PickObjectInfo, for example -- specific information is extracted from it -- here, the ObjPath string:

private string PickObjectInfo(int x, int y)
{
AgPickInfoData pickInfoData;

pickInfoData = SetPickInfoData(x, y);
return pickInfoData.ObjPath;
{

For example, it might return the string "/Application/STK/Scenario/Test/Satellite/tle-08747". Finally, when returned to UpdateFacility() function, the string is used in updating the application's data displays. The PickInfoLat and PickInfoLon functions work similarly, returning position information from the AgPickInfoData.Lat and AgPickInfoData.Lon properties, respectively.

Another method of the axAgUiAxVOCntrl1 object is the ZoomIn method, which is invoked by code implementing a button on the application's GUI:

private void zoomInVO_Click(object sender, EventArgs e)
{
if (globeViewTabControl.SelectedIndex == GLOBETAP_INDEX_3D)axAgUiAxVOCntrl1.ZoomIn();

...
}

Further Examples

Many of the remaining methods and functions of the reference application include calls to various object model objects, methods and properties. A number of sample custom applications in different programming languages are provided.

STK 11.2.1 Programming Interface