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 > KernelCAD Components > Methods and Properties
Methods and Properties of KernelCAD

ActiveX Interface of the KernelCAD Control

Properties:

ModelPath
ShowGlobalAxes
ShowLocalAxes
DIBackColor
RenderSolid
EmbeddedModel
TransparBackgrEnabled

Methods:

GetModel
Save
SaveAs
UpdateSurface
GetView
RequestClientDraw
RequestEvent
UpdateView

Events:

MouseDown
MouseMove
MouseUp
ClientDraw
CurrentObjectChanged
Extended Mouse Events
KernelCADEvent Event
 

Properties


ModelPath Property

Type: String
 
Remarks:
 
ModelPath string is the main property of the control. It contains the path of an existing model file or empty string. When the property is assigned a new value the control automatically loads the model and updates the 3D window. A message is displayed if the load fails. Use the SaveAs method to save the current model in a new location and change the ModelPath property at the same time.
ModelPath can be either relative or full path (with drive letter or starting with hash). There are two kinds of relative paths:
 
1) Standard (like Models\Cube.glm), which is relative to the installation folder. The control reads the location of the installation folder from the registry. For example KerCADne.ocx reads the installation directory from the "InstallDir" string of the "HKEY_LOCAL_MACHINE\SOFTWARE\DInsight\KerCADne\2.1" key. This value can be set in installation packages for distribution of the application developed with KernelCAD, when control is not installed but only registered on the target computer. It is not recommended to modify the key with KernelCAD installed.
 
2) Relative path with modifier prefix, which specified the root. Currently supported modifiers are:     (a) <EXEPATH>. Path <EXEPATH>Models\Samples\Lines.glm means that the lines,glm is located in the Models\Samples subdirectory of the folder where the application's executable (.exe) file is located. Note that at design time control does not display any model when the Model Path has <EXEPATH> modifier. The <EXEPATH> modified paths are useful for distributing applications where location of the target directory is normally not known beforehand.
    (b) <OCXPATH>. Path <OCXPATH>Models\Std.glm means that the Std,glm is located in the Models\ subdirectory of the folder where the control's executable (.ocx) file is located. 
 
The model path can be an empty string, in which case the KernelCAD component will not attempt to load any file on start of the application, the model will have no objects and 3D window will be empty. This option can be useful when the model is constructed dynamically using Dynamic Object Creation to avoid references to external files or other reasons. Note that a model file is valid even if the saved model is empty (has no objects).

ModelPath strings for Pro level components must have .glm extension. KernelCAD Enterprise component can load and save files with other extensions. Supported formats are enumerated by the ECADFormat enumeration

When the control is being inserted for the first time into a form or dialog or created dynamically the default value of the property is taken from the Registry (see below). If the correspondent registry values are not present the ModelPathis set to empty string.

The default value of ModelPath is constructed by appending DefaultModel registry value from HKEY_LOCAL_MACHINE\SOFTWARE\DInsight\KernCAD\<version> key to InstallDir path string in the same key. For controls different from standard KernelCAD the "KernCAD" key name above should be replaced with specific ocx name. InstallDir and DefaultModel values can be changed (for controls only) to any suitable locations.


 
ShowGlobalAxes Property
 
Type: Boolean
 
Remarks:
 
If this property is set to true the global axes will appear in the control's window.

 
ShowLocalAxes Property
 
Type: Boolean
 
Remarks:
 
The component handles only runtime changes of this property. unless there is only one object in the model, this property is ignored on initialization of the control during application startup and in design mode (form editors). In these situations visibility of a local frame is controlled by the ShowLocalFrame value stored in the section.

When the property is being set to false at runtime all local frames will be hidden. When the property is being set  to true at runtime ShowLocalFrame of the current section will be set to true. If no section is selected as current, but the model has a single top level section ShowLocalFrame of the section will be set to true  If there is more than one top level section no action is taken.


 
DIBackColor Property
 
Type: Long integer
 
Remarks:
 
This property determines background color of the control window. To modify the color in Development Environment open Properties dialog box (right-click > Properties or similar option in the IDE menu) and go to the Render page. In Visual Studio 2003, 2005, 2008 click icon on top of the Properties Window to open the Property Pages Dialog. Programmatically the property needs to be cast to COLORREF standard C++/VB data type to use.

COLORREF is a DWORD (four bytes) size integral data. The first three bytes keep red, green and blue components of the color. The fours byte is not currently used in KernelCAD. To obtain KernelCAD style floating point number representing for example green component divide value of the third byte by the 255 and cast to float or double type. Samples\VC\Include\Misc.h file contains two C++ macros, which perform the above conversion both ways.

Use utility from tools menu of 3D Debugger to convert between COLOREF and rgb(a) colors

Background can be transparent to show the window behind. See the TransparBackgrEnabled property.

The background cal also have gradient colors. See details at Background.


 
RenderSolid Property
 
Type: Boolean
 
Remarks:
 
If this property is false the model will be displayed in wire frame mode. Otherwise it will be displayed as a solid object (Default).

 
EmbeddedModel Property
 
Type: Boolean
 
Default:  False
 
Remarks:
 
This property is not available in 64 bit edition. Contact us for more information
 
The EmbeddedModel property is a design-time only property. Is is supposed to be changed only in form designers or resource editors of a Development Environment. The property should not be modified at runtime. Use Property Pages Dialog or Properties Window to modify the property.
 
If this property is true the model will be embedded into the executable file of the application, which uses the KernelCAD component. This helps avoiding issues of locating or transmitting the model and makes sure the correct model is loaded by the component. Embedding model is particularly useful when model has significant value by itself or has restricted copyrights and is not intended to be accessible by the user.
If this property is false (default) the model is loaded on the application start up from location specified by ModelPath and the location is considered valid for persistence of the model, for example by the Save method

When this property is changed from false to true the model will be loaded from the location specified by ModelPath, after that ModelPath is not used by the component.

When this property is changed from true to false the user will be prompted to select the location where the previously embedded model will be saved to. After that ModelPath is considered as persistent location of the model.

To update or change an embedded model set the property in Property Pages Dialog or Properties Window to false. Make sure ModelPath points to the new model and change the property back to true.

Object Array sample uses embedded model.


 
TransparBackgrEnabled Property
 
Type: Boolean
 
Remarks:
 
When this property is true and the DIBackColor is 0 (zero in all components) the control will have transparent background so that the window behind will be visible instead of any background. .NET applications must also set the Visible property of the KernelCAD control to false using form editor at design time.
TransparBackgrEnabled property is a design-time property: Changes to its value only have effect at runtime and only if they are made in a form or resource editor.

This property is ignored on Windows prior to Windows Vista, where value of DIBackColor 0 will make the background black.


Methods

LPUNKNOWN GetModel()  

Return Values

A reference  to IUnknown interface (IUnknown* in C++) implemented by the model object of the control. Type of return can be interpreted differently by different environments to suite its object structure.
 
Remarks
 
GetModel method returns a reference to IUnknown interface implemented by the model. IModel interface and hence all other interfaces, defining geometry of the model, can be accessed via this interface. Actual reference returned by the method already has inherited type of IModel. This means that often (definitely in a C++ and C# code) the pointer can be simply cast directly to IModel type. In addition to that, GetModel method is declared in the type library of the control as returning IModel pointer, which means that high level Development Environments like Visual Basic will treat the method as returning IModel interface. See also Interface List

BOOL Save()

Returns 

TRUE in case of success.

Remarks

 Call to save the model in its current location.

 
BOOL SaveAs(BSTR strFilePath)

Parameters

strFilePath - Full path of the file to save to. Type of return will be interpreted differently by different environments to suite its type system.

Returns

 TRUE in case of success.

Remarks

Call to save the model to a new file. The ModelPath property will be changed to strFilePath.
Normally the Development Environment used to insert the KernelCAD Control into an application project will create a wrapper class or use a different way to represent the property like the Object Browser in Visual Basic, where BSTR object will be replaced with a type more suitable for the Environment you are using.

KernelCAD Enterprise only: If strFilePath has .stl or .wrl extensions the model will be saved in STL or VRMl formats. If strFilePath has no extension it is interpreted as an STL directory path. The new STL directory tree will be created and objects of the model will be saves as separate .stl files in the directory. See "STL Tree" topic of KernelCAD Enterprise documentation for more details.

When the KernelCAD component is in Two Dimensional mode strFilePath can have .emf or .wmf extension and the scene will be saved in the Extended Windows Metafile or older Windows Metafile format, which can be used for embedding in different documents for printing etc.


BOOL UpdateSurface()

Returns 

TRUE in case of success.

Remarks

This method is equivalent to Update method of IModel interface with the addition that UpdateSurface redraws the control's window automatically. See MiniCAD sample

The method recalculates the surface of the model after any changes to parameters of the model. This method or Update method has to be called after a any modification of the models parameters that affects the shape of the object. Most commonly this is done after call(s)  to one of SetParam methods of IElement or IElem interface. In contrast, for example, object movements with I3DObject do not change internal geometry of the object, so the UpdateSurface method does not have to be called.

A valid sequence of modifications  should involve only one modification per parameter. Before making another modification to the same geometrical parameter UpdateSurface or Update has to be called. For example 

    iElemPoint.SetParam(0, 0.5);
    iElemPoint.SetParam(1, 0.9);
    iModel.Update();

is a valid sequence, but 

    iElemPoint.SetParam(0, 0.5);
    iElemPoint.SetParam(0, 0.9);
    iModel.Update();

is not.

Note that this method is costly in terms of computational load, so it is recommended to call it once per logically complete sequence of user input.


LPUNKNOWN GetView()

Returns 

Pointer to IUnknown interface implemented by the View object of the control.   

Remarks

Although the return type is declared as LPUNKNOWN, GetView method actually returns the pointer to the IView interface implemented by the View object of the control. IView interface gives access to rendering properties of the control. In addition, it gives access to ILook interface, which can be retrieved either using QueryInterface in C++ or by coercion of the reference to ILook type in Visual Basic. The actual pointer returned by the method already has an inherited type of IView. This means that in a C++ code this pointer can be simply cast directly to IView type. Additionally, GetModel method is declared in the type library of the control as returning IView pointer, which means that high level Development Environments like Visual Basic will treat the method as returning IView interface. See also Interface List

void RequestClientDraw(boolean request)

Parameters

request - [in] true if ClientDraw event needs to be raised and false otherwise.

Remarks

 As invoking ClientDraw event involves some performance cost, this event is not raised by default. This method has to be called to enable or disable the event.

void RequestEvent(int event, boolean request)

Parameters

event - [in] id of the event to be requested. Valid values are listed in EDIEvent enumeration.

request - [in] true if the event needs to be raised and false otherwise.

Remarks

 Some events in the KernelCAD software (such as MouseHover event) involve additional computational load and are not enabled by default. This method allows programmatic enabling of them.  

LPUNKNOWN UpdateView()

Remarks

This method forces redrawing the window of the control. For performance reasons it should be used instead of UpdateSurface when there are no modifications to geometry of surface, for example when some objects have been moved without changing their internal parameters.

Events


void OnMouseDownKernelCAD(short Button, short Shift, long x, long y)     

Parameters  

Button - [in] 1 if left button pressed, 2 - if right mouse button pressed. Shift - [in] equals to 1 if Shift key is down and 0 otherwise. x, y - [in] - window coordinates of the mouse pointer. 

Remarks

The name of the handler for the event can be selected during implementation. OnMouseDownKernelCAD method is called when the user clicks  in the control display area using mouse buttons.

Notice: This event is not raised in the Dual Mode. Use MouseEx in this mode instead


void OnMouseMoveKernelCAD(short Button, short Shift, long x, long y)     

Parameters  

Button - [in] 1 if left button pressed, 2 - if right mouse button pressed. Shift - [in] equals to 1 if Shift key is down and 0 otherwise. x,y - [in] - window coordinates of the mouse pointer. 

Remarks

The name of the handler for the event can be selected during implementation. OnMouseMoveKernelCAD method is called when the user moves the mouse in the control display area.

Notice: This event is not raised in the Dual Mode. Use MouseEx in this mode instead


void OnMouseUpKernelCAD(short Button, short Shift, long x, long y)     

Parameters  

Button - [in] 1 if left button pressed, 2 - if right mouse button pressed. Shift - [in] equals to 1 if Shift key is down and 0 otherwise. x,y - [in] - window coordinates of the mouse pointer. 

Remarks

The name of the handler for the event can be selected during implementation. OnMouseDownKernelCAD method is called when user releases a mouse button while the pointer is positioned over the control display.


void OnClientDraw()    

Remarks

ClientDraw event is raised when the controls view needs to be repainted and after the rest of the model has been drawn. Query IDraw interface via path: control->GetModel -> IModel ->IDraw and use its methods to perform custom drawing operations. Important: As client drawing involves some performance cost this event is not raised by default. To enable or disable it RequestClientDraw method has to be called.


void CurrentObjectChanged(VARIANT iSect)   

Remarks

CurrentObjectChanged event is raised in Modify mode when the user selects a different object as current. punkVal member of iSect  is a reference to ISection interface (can be safely cast to ISection type) of the newly selected object.

When the passed reference is NULL it means that user clicked outside any objects in the components view.

There are two context properties which modify behaviour related to this event. See more at Selection via the current object


void MouseEx(long eventType, long xMouse, long yMouse, long data)   

Parameters  

eventType [in] - Type of the event 

xMouse, yMouse [in] - window coordinates of the mouse pointer. The coordinates are relative to the top left corner of the window of the control. 

data[in] -Currently unused. Reserved for different types of events to be added in future releases

Remarks

The MouseEx event is used for detection of mouse behaviour slightly more complex than standard Mouse Up/Down/Move events. The actual type of event is described by the eventType parameter. Valid values of  eventType are enumerated by EDIEvent. In this release only eEventMouseHover, eEventMouseRButtonDown, eEventMouseRButtonMove and eEventMouseRButtonUp are passed trough via this event. Consider disabling conext menu for the right hand mouse button actions

The MouseHover event type occurs when the mouse pointer has stopped in a small area for about half a second after some movement . This is similar to behaviour detected for displaying tool tips in Windows User Interface.

Note: To receive notification about one of MouseEx events it has to be enabled with a call to RequestEvent with the same eventType value.


void KernelCADEvent( long eventType, const VARIANT& param0, VARIANT* param1 ) 

Parameters  

eventType [in] - Type of the event. Valid values are enumerated in EDIEvent

param0 [in] - Parameter of the event. Meaning depends on eventType and is documented in each particular case

param1 [in,out] - Parameter of the event. Meaning depends on eventType and is documented in each particular case

Remarks

Meaning of param0 and param1 depends on the eventType. Most often the KernelCADEvent event is used to notify the application that the user selected a context menu item. eventType in this case coincides with EDIEvent.eEventUICommand. See more details in Context Menu topic