Class DispEngine
HiAPI display engine.
public class DispEngine : IDisposable, IGetDispEngine
- Inheritance
-
DispEngine
- Implements
- Inherited Members
- Extension Methods
Constructors
DispEngine(IDisplayee)
Ctor. The SetViewToHomeView() is called in this function.
public DispEngine(IDisplayee displayee)
Parameters
displayee
IDisplayee
DispEngine(params IDisplayee[])
Ctor.
public DispEngine(params IDisplayee[] displayees)
Parameters
displayees
IDisplayee[]displayees to render.
Fields
CoreDll
Core dll path.
public const string CoreDll = "core.dll"
Field Value
defaultFontFile
public const string defaultFontFile = "Font/WCL06.ttf"
Field Value
Properties
BackgroundColor
Background color
public Vec3d BackgroundColor { get; set; }
Property Value
ContextProjDepth
public static double ContextProjDepth { get; }
Property Value
CursorOffsetX
Internal Use.
public int CursorOffsetX { get; }
Property Value
CursorOffsetY
Internal Use.
public int CursorOffsetY { get; }
Property Value
CursorX
Internal Use.
public int CursorX { get; set; }
Property Value
CursorY
Internal Use.
public int CursorY { get; set; }
Property Value
Displayee
Displayee to be rendered in the rendering loop. The SetViewToHomeView() is called in this function.
public IDisplayee Displayee { get; set; }
Property Value
FontFile
Font file.
public static string FontFile { get; set; }
Property Value
IsOnDispThread
public static bool IsOnDispThread { get; }
Property Value
IsVisible
The anime stop running if the value is false; otherwise, the anime starts or keeps running.
public bool IsVisible { get; set; }
Property Value
Model
public Mat4d Model { get; set; }
Property Value
- Mat4d
Model matrix in MVP convention. This Model matrix is the first matrix in HiDisp.Disp.Bind.modelMatStack.
PixelProj
public Mat4d PixelProj { get; set; }
Property Value
PreCursorX
Internal Use.
public int PreCursorX { get; set; }
Property Value
PreCursorY
Internal Use.
public int PreCursorY { get; set; }
Property Value
PrincipleView
public Mat4d PrincipleView { get; set; }
Property Value
- Mat4d
view = PrincipleView * SketchView. Where view matrix is in MVP convention.
Remarks
The default value is new Mat4d(new Vec3d(1, 0, 0), -Math.PI / 2). This make the 2D plane from xy plane to xz plane. The xz plane is much suit for 3D engineering display.
RefreshingPeriod
Image refreshing period.
public TimeSpan RefreshingPeriod { get; set; }
Property Value
ScaleProj
public Mat4d ScaleProj { get; set; }
Property Value
SketchView
view = PrincipleView * SketchView. Where view matrix is in MVP convention.
public Mat4d SketchView { get; set; }
Property Value
Methods
DeleteDispContext()
public static void DeleteDispContext()
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
protected virtual void Dispose(bool disposing)
Parameters
disposing
bool
EnqueueDispose(IDisposable)
Enqueues a disposable object to be disposed on the display thread.
public static Task EnqueueDispose(IDisposable disposable)
Parameters
disposable
IDisposableThe disposable object to be disposed
Returns
- Task
A task representing the disposal operation
EnqueueTask(Task)
Enqueues a task to be executed on the display thread.
public static Task EnqueueTask(Task task)
Parameters
task
TaskThe task to be executed
Returns
- Task
The enqueued task
EnqueueTask<T>(Task<T>)
Enqueues a task to be executed on the display thread.
public static Task<T> EnqueueTask<T>(Task<T> task)
Parameters
task
Task<T>The task to be executed
Returns
- Task<T>
The enqueued task
Type Parameters
T
The type of the task result
~DispEngine()
protected ~DispEngine()
FinishDisp()
Elegantly end the rendering core. Probably not essential.
public static void FinishDisp()
GetDispEngine()
Get DispEngine.
public DispEngine GetDispEngine()
Returns
Init(string)
public static void Init(string fontFile = null)
Parameters
fontFile
string
IsMouseButtonPressed(long)
public bool IsMouseButtonPressed(long mouseButton)
Parameters
mouseButton
long
Returns
KeyDown(long)
Key down. This function is typically called in the GUI implementation for keyboard interaction.
public void KeyDown(long key)
Parameters
key
longkey
KeyDownTransform(long, key_table__transform_view_by_key_pressing_t)
Transform SketchView by key. Home, F1, F2, F3, F4 call SetViewToHomeView(), SetViewToFrontView(), SetViewToSideView(), SetViewToTopView(), SetViewToIsometricView() respectively. PageDown and PageUp scale the SketchView. Left, Right, Down, Up translate the SketchView; Press Shift make these keys to rotate the SketchView.
public void KeyDownTransform(long key, key_table__transform_view_by_key_pressing_t table)
Parameters
key
longkey
table
key_table__transform_view_by_key_pressing_ttable
KeyUp(long)
Key up. This function is typically called in the GUI implementation for keyboard interaction.
public void KeyUp(long key)
Parameters
key
longkey
LockGlContext()
Lock a opengl context. The function is only used for native OpenGL rendering. After lock the gl context, It should be unlock by UnlockGlContext(nint).
public static nint LockGlContext()
Returns
Remarks
If any other lock requires LockGlContext, the lock should better set inside LockGlContext. or it is easy to occur race condition. see design pattern of "Solid" class for reference.
MouseButtonDown(long)
Mouse button down. This function is typically called in the GUI implementation for mouse interaction.
public void MouseButtonDown(long button)
Parameters
button
longbutton
MouseButtonUp(long)
Mouse button up. This function is typically called in the GUI implementation for mouse interaction.
public void MouseButtonUp(long button)
Parameters
button
longbutton
MouseDragTransform(int, int, mouse_button_table__transform_view_by_mouse_drag_t)
Transform the view by mouse drag. If drag by left mouse button, Translate(double, double) is performed; If drag by right mouse button, Rotate(double, double) is performed.
public void MouseDragTransform(int x, int y, mouse_button_table__transform_view_by_mouse_drag_t mouse_button_table)
Parameters
x
inty
intmouse_button_table
mouse_button_table__transform_view_by_mouse_drag_t
MouseMove(int, int)
Mouse move. This function is typically called in the GUI implementation for mouse interaction.
public void MouseMove(int x, int y)
Parameters
MouseWheel(int, int)
Mouse wheel move. This function is typically called in the GUI implementation for mouse interaction.
public void MouseWheel(int deltaX, int deltaY)
Parameters
MouseWheelTransform(int, int, double)
Scale SketchView by mouse wheel.
public void MouseWheelTransform(int deltaX, int deltaY, double zooming_ratio = 0.2)
Parameters
deltaX
intmouse wheel delta X
deltaY
intmouse wheel delta Y. The traditional mouse wheel.
zooming_ratio
double
NewDispContext()
public static void NewDispContext()
Resize(int, int)
Resize the opengl context.
public void Resize(int w, int h)
Parameters
Rotate(double, double)
Rotate the SketchView. Usually used by mouse drag on window. The rotation axis is along (delta_y, 0, delta_x). The rotation rad is 5 * Math.Sqrt(delta_y * delta_y + delta_x * delta_x) / window_height.
public void Rotate(double delta_x, double delta_y)
Parameters
RotateAndScaleByTouchPad(Vec2d, Vec2d, Vec2d, Vec2d)
public void RotateAndScaleByTouchPad(Vec2d prePosA, Vec2d curPosA, Vec2d prePosB, Vec2d curPosB)
Parameters
RotateWithoutHeightAdjustment(double, double)
Rotate the SketchView. Usually used by keyboard command. The rotation axis is along (delta_y, 0, delta_x). The rotation rad is Math.ToRad(Math.Sqrt(delta_y * delta_y + delta_x * delta_x)).
public void RotateWithoutHeightAdjustment(double delta_x, double delta_y)
Parameters
SetViewToFrontView()
Set the SketchView to front view.
public void SetViewToFrontView()
SetViewToHomeView()
Set the SketchView to home view(front view). This is the same as SetViewToFrontView().
public void SetViewToHomeView()
SetViewToIsometricView()
Set the SketchView to isometric view.
public void SetViewToIsometricView()
SetViewToSideView()
Set the SketchView to side view.
public void SetViewToSideView()
SetViewToTopView()
Set the SketchView to top view.
public void SetViewToTopView()
Start(int, int)
Start a thread of keeping Swapping buffers of OpenGL context. If the thread has running, this function does nothing.
public void Start(int panelWidth, int panelHeight)
Parameters
Terminate()
Terminate the opengl context swapping buffers thread from Start(int, int). If the thread has not running, this function does nothing.
public void Terminate()
Translate(double, double)
Translate the SketchView. Usually used by mouse drag on window. The translation is (delta_x * 2.0 / h, 0, -delta_y* 2.0 / h). Where h is window height.
public void Translate(double delta_x, double delta_y)
Parameters
UnlockGlContext(nint)
Unlock opengl context. The function is only used for native OpenGL rendering. The function unlock the opengl context for LockGlContext().
public static void UnlockGlContext(nint disp_torch_p)
Parameters
disp_torch_p
nint
Events
FinishingDisp
Event at the begining of FinishDisp()
public static event Action FinishingDisp
Event Type
ImageRequestAfterBufferSwapped
Triggered after swap buffer of gl context.
public event DispEngine.ImageRequestedDelegate ImageRequestAfterBufferSwapped