53 lines
1.5 KiB
C#
53 lines
1.5 KiB
C#
using Hi.Geom;
|
|
using Hi.Disp;
|
|
using Hi.Native;
|
|
|
|
namespace Sample.Disp
|
|
{
|
|
/// <summary>
|
|
/// Demonstrates basic object picking with mouse interaction in the HiAPI system.
|
|
/// Shows how to create a pickable 3D object that responds to mouse events by changing its appearance.
|
|
/// Implements the Pickable base class to enable mouse event handling.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// ### Source Code
|
|
/// [!code-csharp[SampleCode](~/../Hi.Sample.Wpf/Disp/DemoPick1.cs)]
|
|
/// </remarks>
|
|
public class DemoPick1 : Pickable, IDisplayee
|
|
{
|
|
bool isMouseOver = false;
|
|
/// <inheritdoc/>
|
|
public void Display(Bind bind)
|
|
{
|
|
bind.PickID = PickingID;
|
|
bind.RGB = new Vec3d(isMouseOver ? 0 : 1, 1, 1);
|
|
new Box3d(0, 0, 0, 1, 1, 1).DisplayFace(bind);
|
|
bind.PickID = 0;
|
|
}
|
|
/// <inheritdoc/>
|
|
public void ExpandToBox3d(Box3d dst)
|
|
{
|
|
dst.Expand(new Vec3d(0, 0, 0));
|
|
dst.Expand(new Vec3d(1, 1, 1));
|
|
}
|
|
/// <inheritdoc/>
|
|
public override void OnMouseEnter(ui_event_type e, panel_state_t state)
|
|
{
|
|
isMouseOver = true;
|
|
}
|
|
/// <inheritdoc/>
|
|
public override void OnMouseLeave(ui_event_type e, panel_state_t state)
|
|
{
|
|
isMouseOver = false;
|
|
}
|
|
/// <summary>
|
|
/// Entry point for the DemoPick1 example.
|
|
/// Creates and displays a simple pickable object that changes color on mouse hover.
|
|
/// </summary>
|
|
static void Main()
|
|
{
|
|
DemoUtil.RunApplication("DemoPick1", new DemoPick1());
|
|
}
|
|
}
|
|
}
|