Creating Extended Objects (How to Create a Plug-In) |
www.CAD6.com |
Plug-ins can create so-called "extended objects", which extend the group of predefined object types of the CAD6interface.
Basically, an extended object has two parts: The first part is the object body, which contains an arbitrary sequence of data blocks. These data blocks store data that can only be interpreted by the plug.in that created this extended object. Usually, this data will consist of some definition points plus a set of non-geometrical parameters. It is created using the MKI_ExtOpen, MKI_ExtAddDataBlock and MKI_ExtFastInsert functions. The second part is a list of entities used as display data. The display data must have been created by the plug-in that created the extended object, and must contain standard objects of the CAD6interface. The display data is used to display the extended object, and must be created using standard command for object, instance, and/or clipping entity creation while the extended object is open (after calling either MKI_ExtOpen or MKI_ExtListOpen).
Once the user performs any modification on such an extended object, the plug-in has two major tasks to fulfill: First, the plug-in must update the data blocks sequence to reflect the modification performed by the user. This could a simple translation (resulting in a translation of all definition points using MKI_EditEntityPointsMatrix), or a more complex task like distorting (where the plug-in might have to react more sophisticated by adapting some of the data structure, e.g. replacing circles by ellipses or a bezier curve sequence) or even parameter editing.
After updating the object's data block sequence, the plug-in must then update the display used to display the extended data block. In simple cases, an update of the display data's display matrix might do, but normally, the whole display data must be recreated based on the new values (using MKI_ExtListOpen and MKI_ExtListClose).
A plug-in creating extended objects must contain a MKI_PlugInNotify procedure that is called each time an extended object has to be updated. This procedure must also be able to provide some information about that object, like its textual description.
For parameter, text, and attribute editing of extended objects, please see Editing Extended Objects.
The creation and maintenance of extended objects is quite complex, so it's not possible to give a short example that is still complete. For further experience, you can find a complete example of a plug-in creating and maintaining extended objects in the sources of SAMPLE_.DLL. This implementation includes additional code for language-dependent data libraries and the implementation of a dialog window for parameter editing.
|
CAD6interface 2024.2 - Copyright 2024 Malz++Kassner® GmbH