Home Page > KernelCAD Components > Programming
Programming of KernelCAD Control
Programming of the KernelCAD Control
Manipulation of the current model and its rendering properties is performed
via interfaces implemented by KernelCAD control. Interface is a simple notion,
which does not require any special knowledge. Interface is a small group of
methods (functions) related to a certain functionality.
Programming Samples provide ample examples of their
usage.
KernelCAD interfaces are organized
in a hierarchical fashion. This means that one have to traverse the interface hierarchy tree using
casts and
other methods to obtain needed interface of a particular object.
IModel is the root interface for geometry-related interfaces, from which all
its dependent interfaces can be obtained. To get IModel interface call GetModel method
of the control which in C++ case will look like:
IModel * pIModel= (IModel*)m_ctrlCAD.GetModel();
Using casts (or QueryInterface() calls in C++) and other
interface methods like IModel::GetSection() interface hierarchy can be traversed to obtain
the interface needed and call its methods.
IView interface is the root for functionality related to viewing properties
of the control's display rather than geometry of the model. IView reference is
returned by GetView() method of the control.
In unmanaged environments like native C++ or VB, every interface reference, obtained with the QueryInterface() or
a call to an interface method, should be released with a call to Release()
method, like pIModel->Release(), when
it is no longer needed. In Visual
Basic this operation looks like:
Set iMyInterface = Nothing.
C++ interface declarations are available in DIInterface.h located in
Samples\Vc\Include directory of the installation folder. The same folder contains DIError.h with declarations
of error codes specific to DInsight software. All other return
codes for interface methods are contained in Winerror.h - the standard header file
of your development environment. If you cannot find one on your
machine use copy from Samples\Vc\Include directory of this product installation
folder.
Microsoft Visual Basic and Microsoft Visual Studio .NET detect control's interfaces and types automatically after the
control has been added to the project. To access this information open Object
Browser and activate KernelCADTypeLib set.
Advanced: KernelCAD software slightly deviates from
the COM standard. Traversing
the Interface Hierarchy can obtain interface implemented by an object different
from the original one. This means that result of a query depends on the query
path. For example for a Generic 3D Object path ISection->
IArray
returns IArray of its child sections, but path ISection->IAxiBase->IArray
returns IArray of its base knots. See also Interface
queries
See also: User Input Validation
|