KernelCAD Documentation

DInsight Home
Skip Navigation Links.
Start page
Quick Start
Installation
Overview of the software
What is new
Collapse KernelCAD ModelsKernelCAD Models
Collapse KernelCAD ComponentsKernelCAD Components
KernelCAD Control
KernelCAD .NET Control
Methods and Properties
Menu
Model Explorer
Birds Eye View
Programming
Direct User Access
Direct Operations
Interface Queries
Printing Support
Data Types
Modes of KernelCAD Control
DIObjectGenerator class
Properties
FlatObjectArray Poperty
Context
64 bit development
Dual Mode
Initialisation Context
Overlay Editor
Memory Management
Input validation
Collapse Advanced functionalityAdvanced functionality
Collapse InterfacesInterfaces
Alphabetical list
I3DGrid
I3DBugger
I3Dpt
IAxiBase
IAxis
IBoolSection
IBoolSectionEx
IBoundary
IColor
IConstraint
IData
IDiffSurface_KC
IDIFont
IDraw
IDrawUtil
IDraw2
IElem
IElement
IKCLine
ILightSource
ILocation
ILocationEx
IMaterial
IMetrics
IMetrics2
IModel
IModel2
IModelEx
IPatch
IKCPathCollisionDetector
IProfiles
IPropertyArray
IPropertyArray2
IStdShape
IStrip
ISurface
IText
ITexture
ITransform
IUnknown
Collapse Open Cascade TechnologyOpen Cascade Technology
Collapse DataData
Collapse MovementMovement
Collapse FramesFrames
Collapse Oriented ObjectsOriented Objects
Collapse SectionsSections
Collapse GeneralGeneral
Collapse Topological InterfacesTopological Interfaces
Collapse Viewing InterfacesViewing Interfaces
Collapse Lines And CurvesLines And Curves
Collapse Symmetry InterfacesSymmetry Interfaces
Collapse Clipping plane interfacesClipping plane interfaces
Collapse AlgorithmsAlgorithms
Collapse 2D Geometry2D Geometry
Collapse Programming Samples and TutorialsProgramming Samples and Tutorials
Collapse OverviewOverview
Collapse DeploymentDeployment
Collapse .NET Samples.NET Samples
Collapse C++ SamplesC++ Samples
Collapse Visual Basic SamplesVisual Basic Samples
Collapse Delphi SamplesDelphi Samples
Collapse 3D Debugger3D Debugger
Collapse DeploymentDeployment
Licensing
Model Viewer
Open C++ Source
Technical Support
Skip Navigation LinksHome Page > Programming Samples and Tutorials > C++ Samples > Pick
PPick C++ Sample

Pick Visual C++ Sample

Pick is an application, which displays Light.glm 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,, All samples.