Home Page > Programming Samples and Tutorials > .NET Samples > Delphi Samples > Metrics
Metrics Native Delhpi Sample
Metrics Delphi Sample
Source code for Metrics sample is available in Samples\Delphi
folder of the installation directory. The sample is a Delphi 7 project, which
can be loaded by later versions of Borland environments.
Description
Implementation
All functionality is implemented in TForm1 module. InitModelInfo() procedure,
called initially from TForm1.OnFormShow(),
accesses IMetrics
interfaces of the two objects in the model. OnCalculateDist() button handler
calls IMetrics.Dist method to acquire set of
nearest points. The result can be accessed via the returned m_iRel
IRelation interface.
Pairs of nearest points are obtained from m_iRel in
TForm1.OnClientDraw ClientDraw
event handler. Lists of nearest points of each object are obtained with calls to
IRelation.GetItemList
methods. Which point is nearest to which is determined by set of pairs returned
from IRelation.GetRelation.
Each pair is pair of positions in the lists obtained previously. Lists are
designed to store generic information of various types. As described in IMetrics
topic the actual type of the stored items is IVertex.
This means that type conversion is required. An element of list is cast first to
generic IUnknown interface type and than IVertex is
queried from it with (iUnkn as IVertex) query.
See also KernelCAD and Delphi, Delphi Samples,
Visual C++ Samples,
All samples.
|