Label C++ Sample
Source code for Label sample is available in Samples\VC\Labels\Label
folder of the installation directory. Label is an application, implemented in Visual Basic 6.0 which
displays Light.mdg model. It demonstrates programming 3D Labels
Running the application
On start the application adds new child 3D Labels
to each object in the Light.mdg model to display the object name.
"New Label" group adds a new top level label at a specified
location. All top level labels are listed in the provided list box.
Modify button displays properties of the selected label from the list
box.
Font group on Label Properties form allows changing size, face and color of
the font. The "Color" text on the form has the current color of the
label.
Implementation
Most of the implementation is contained in CLabelDlg class Child labels for each object are added in
CLabelDlg::AddObjectLabel function called from the CLabelDlg::OnInitDialog()..
IArray2
containing all labels attached to an object is acquired from the relevant ISection
as "Items" property via IPropertyArray2.
To add a new label InsertNew method of IArray2
is called with the type parameter set to the value of eItemTypeLabel member of the EItemType
enumeration.
An individual label is controlled via IText
obtained from the object in the IArray2. Name of
the label is modified in CLabelDlg::SetLabelName() using IItem
queried from IText.
In the same way IArray2
of the top level objects is acquired from IModel
in the CLabelDlg::GetItemsArray function.
3D position of the added label is set using ILocation
queried from IText.
Attributes of the font of the selected label are modified in
LabelPropertiesDlg
form with the help of IDIFont
interface.
See also IText, ILocation, IItem,
IDIFont
, Visual Basic Samples, All samples.
|