DG Kernel Documentation


Skip Navigation Links.
Start page
Quick Start
Search Page
Installation
Overview of the software
What is new
Licensing
Collapse ModelsModels
Collapse DG Kernel ComponentsDG Kernel Components
Collapse API ReferenceAPI Reference
Interface List
Vector Space
Collapse General GeometryGeneral Geometry
Collapse ModelModel
Collapse ViewView
Collapse General ComputingGeneral Computing
Collapse Samples and TutorialsSamples and Tutorials
Collapse GraphicsGraphics
Collapse Math ObjectsMath Objects
Collapse DeprecatedDeprecated
Redistribution
Model Viewer
Open Source
Support
Skip Navigation Links Search Documentation


Pick Visual Basic 6 Sample

Source code for Pick sample is available in Samples\VB folder of the installation directory. Pick is an application, implemented in Visual Basic 6.0 which displays Light.mdg model. It demonstrates programming and handling selection of  objects in 3D view by the end user.

Overview

Implementation

On load of the form the default (View) mode of the component is changed to Modify in Form_Load Sub by using IViewModal interface obtained via IView interface.

KernelCAD1_CurrentObjectChanged handler of the CurrentObjectChanged event obtains ISection interface of the selected object by converting the parameter supplied in the handler, obtains name of the object using ISection.GetName and displays it on the form. Note the 

Both methods two and three use Function GetObjNameAt, which calls ILookEx.GetItemAt method to obtain IItem interface implemented by the object beneath the window point. the Obtained interface is used to query an ISection, which returns name of the object via GetName.

Note the RequestClientDraw call, which enables ClientDraw event. This allows the cross-hair to be drawn in the KernelCAD1_ClientDraw handler.

For the third method MouseHover event is enabled/disabled in CheckHover_Click() with a call to RequestEvent (eEventMouseHover). Handler KernelCAD1_MouseEx of the event uses coordinates of the cursor supplied via parameters of the event to call the GetObjNameAt method. Note that it would be wrong to place this code into Mouse Move event handler as detection adds extra load on rendering and can cause flickering.

Coordinates of the selected 3D point are calculated in GetObjNameAt Sub with the help of IPick.GetItemAt3D or IPick.GetItemAtDepth If the local coordinates are required, global coordinates returned by IPick.GetItemAt3D are converted to local ones relative to the selected object with the help of IFrameEx queried from the obtained IItem. For case of View Frame the 3D point is calculated via  ILookEx.ScreenTo3DEx.

See also IPick, ILookEx, IItem, Visual Basic SamplesAll samples.

Things to try

- Try to implement loading of a different model.

- Try to obtain color and/or location of the selected objects and display it on the form