STK and VC++ joint programming practice (the first round: preparation work)

STK version: 9.2.2

VC version: vc15

Development environment: Visual Studio 2017

Install STK 9.2.2, check the help documentation, and confirm that CodeSamples (sample code) is also installed with the installation package, including C# (CSharp), Java, HTML, Matlab, VB.NET, PowerPoint and other languages. The directory structure is as follows:

Among them, C# and Java language have the most example codes, each with more than 20 examples. This article focuses on VC++ exploration. The VC++ code examples are in the '.\CodeSamples\CustomApplications\C++' directory, including two examples: Events and Tutorial, as shown in the figure below.

It can be seen that the default solution provided by STK version 9.2.2 is based on vs2005 and vs2008.

Run VS2017 (other versions of VS should be similar) and open the sample solution (such as the Samples_VS2008.sln in the picture above, prompt: STK sample code and all project projects of STK are developed based on MFC and conform to Microsoft's COM component specification , so VS2017 needs to install "Visual C++ MFC for x86 and x64"), it prompts to upgrade the solution version, just follow the default operation.

Build the project. . .

Of course it is an error!

Error message (the error may be different on your host): error MSB8036: Windows SDK version 8.1 cannot be found . Please install the desired version of the Windows SDK or change the SDK version in the project property pages or by right-clicking on the solution and selecting "Retarget Solution" .

Click the right mouse button on the solution as prompted and select 'Reset Solution Target'.

Then the following window pops up, keep the default value, and click the 'OK' button directly to complete the reset operation.

Build the solution again, where building the "Tutorial" project succeeds and building the "Events" project fails.

There are two warnings when generating the "Tutorial" project, which can be ignored. Run the "Tutorial" project, and the program interface is as follows:

Judging from the interface, you can create a new scene and zoom in on a two-dimensional scene. Click the 'New Scenario' button to create a new scenario, and a "New Scenario Created" prompt box will pop up after the end, click the 'OK' button in the prompt box, the program interface is as follows:

Among them, the 3D window can be rotated and zoomed normally through the operation of the left and right buttons of the mouse, and the 2D window can be clicked on the "Zoom In" button first, and then press the left button of the mouse and drag to draw the enlarged area in the window to execute the 2D bottom. To zoom in on the graph, click the 'Zoom Out' button to restore the previous zoom effect.

In addition, when the mouse is moved in the 3D window, the interface will prompt the latitude and longitude information of the current mouse position. Double-clicking the left mouse button in the 3D window can also directly prompt the latitude and longitude information in the 3D window.

OK ! Look back at the "Events " item.

错误信息为:fatal error C1189: #error:  MFC does not support WINVER less than 0x0501.  Please change the definition of WINVER in your project properties or precompiled header.

Search the keyword 'WINVER' in the project, locate the file stdafx.h, and find that the WINVER defined in the sample code is a bit old (0x0400), indicating that the STK9 product was compiled and produced really early (but this does not hinder the professionalism of its products and stability), as shown in the figure below.

  1. stdafx.h (code snippet)

Directly comment out the above line of code, the compiler will automatically determine the above environment variables (configuration) according to the current system configuration, and regenerate the project, OK! success! (Note: If you copy the code from the default installation location and then compile it, you need to re-specify the relative path of the project's external include directory (CppIncludes, the files in this directory are very important, and will be explained one by one in the follow-up practice),' The Tutorial' project does not have this problem, indicating that the configuration and functions of the two sample projects are still different).

Run the 'Events' project, the program interface is as follows:

The interface is similar to the 'Tutorial' project and is based on dialog boxes. There are only 3D windows and more functions. You can create a new scene, add satellites to the scene, add ground facilities, and perform simulation (animation demonstration). The edit box below can also output in real time scene information.

After some operations, the interface is as follows:

Guess you like

Origin blog.csdn.net/wangyulj/article/details/123817570