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 DG Kernel ActiveX control and allows to modify geometrical parameters of the 
model.  
See DG Kernel and Delphi for information about
importing  DG Kernel 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 
entity is kept into m_iEntity. It is obtained by UpdateSectInfo() procedure using call 
       
m_iModel.GetEntity(m_nCurSect, &m_iEntity); 
Note the line m_iStrip := Nil done on the current m_pIEntity. This is important 
because this UpdateSectInfo()  call is probably switching to another entity which is 
another object and maintains its own reference counting. 
The same procedure TMiniCADForm::UpdateSectInfo() acquires IAxiBase 
interface using line: 
  m_iAxiBase := (m_iEntity as IAxiBase);  
Prior to that we query the entity type with 
  m_iEntity.GetEntityType(szSectType);  
to check if the entity 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_iEntity. This is the last job done in TMiniCADForm.UpdateSectInfo(). Note that IStrip
m_iStrip is 
implemented by object which represents cross-entity segment strip in case of 
Generic 3D Entity 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().  
                 |