Home Page > Programming Samples and Tutorials > C++ Samples > Gear Sample
Gear C++ Sample
Gear Sample
Source code for Gear sample is available in Samples\VC
folder of the installation directory. If you are going to compile
the project we suggest to
copy whole VC directory to location outside of the installation folder.
Gear is an MFC dialog-based application which
displays simplified model of a gear using KernelCAD ActiveX control and allows to modify geometrical parameters of the
model.
Gear is rather advanced sample. It demonstrates usage of tree-tier design
which includes Geometry layer. This sample differs form Turbine sample by
more realistic and hence more complicated geometry of the model.
Implementation
While analyzing the implementation it is recommended to keep the Gear.glm
model open in 3D Debugger to compare. It is even better to use the debugger
to watch actual sequence and logic of the application and the parameters
returned by the KernelCAD interfaces.
Roles of classes:
CGearDlg - implements the GUI layer. CGearDlg does not know
anything about the geometry of the model. It just displays parameters, takes
their new values and passes it to the Geometry layer. This work is done in CGearDlg::UpdateObject() method. It also takes display parameters
from the
geometrical layer and updates the dialog. This is done by CGearDlg::UpdatePage().
Gear class. Gear class implements geometrical layer of the application. It keeps most important parameters of the geometry, which are familiar
and useful to the End User . It also knows how to converts these parameters into
calls to KernelCAD software interfaces. Another role of the geometry layer is to
validate and handle invalid user input.
Note that for simplicity there is no extensive validation of user input. In a
real application assertions in implementation should be replaced with more
comprehensive input validation and error handling.
See also: All C++ Samples,
All samples
|