Home Page > Programming Samples and Tutorials > Delphi Samples > MiniCAD
Delphi MiniCAD Sample
MiniCAD Delphi Sample
Source code for MiniCAD sample is available in Samples\Delphi
folder of the installation directory. MiniCAD is a form application which
displays DI model using KernelCAD ActiveX control and allows to modify geometrical parameters of the
model.
See KernelCAD and Delphi for information about
importing KernelCAD into Borland Developer Studio.
See also: C# MiniCAD Sample,
Visual Basic MiniCAD Sample,
Visual Basic .NET MiniCAD Sample,
All samples
Description
Implementation
Almost all functionality is implemented by TMiniCADForm class. Navigation through the interface
hierarchy is the most important task. InitModelInfo() procedure retrieves m_iModel IModel interface.
m_iModel := KernelCAD1.GetModel();
Interface to the current
section is kept into m_iSection. It is obtained by UpdateSectInfo() procedure using call
m_iModel.GetSection(m_nCurSect, &m_iSection);
Note the line m_iStrip := Nil done on the current m_pISection. This is important
because this UpdateSectInfo() call is probably switching to another section which is
another object and maintains its own reference counting.
The same procedure TMiniCADForm::UpdateSectInfo() acquires IAxiBase
interface using line:
m_iAxiBase := (m_iSection as IAxiBase);
Prior to that we query the section type with
m_iSection.GetSectionType(szSectType);
to check if the section is a "3DSection". Otherwise it is a Surface
of Revolution, which does not have base. We could have deduce it if the
cast to m_iAxiBase have failed.
Interface List says that we can query two more interfaces, namely
I3DObject and IStrip from m_iSection. This is the last job done in TMiniCADForm.UpdateSectInfo(). Note that IStrip
m_iStrip is
implemented by object which represents cross-section segment strip in case of
Generic 3D Section and profile segment strip in case
of Surface Of Revolution.
Actual geometry changes are done in OnApply() procedure through
IElement interfaces
which are kept in m_iElemJoint and m_iElemSegment members. These are
obtained by UpdateJointInfo() and UpdateSegmentInfo().
|