显示设置
1 设置坐标轴样式
AnyCAD内置ViewCube和坐标轴两种显示样式,用以表示当前相机的方向。
csharp
//设置为红绿蓝轴
renderView.SetViewCube(EnumViewCoordinateType.Axis);
//显示为Cube
renderView.SetViewCube(EnumViewCoordinateType.Cube);
// 不显示
renderView.SetViewCube(EnumViewCoordinateType.Empty);
设置坐标轴的位置:
csharp
// 设置不到屏幕四个角中的一个 [0, 1, 2, 3]
renderView.Viewer.SetCoordinateWidgetPosition(1);
2 设置背景
设置背景色
这是背景色为黑色:
csharp
mRenderView.SetBackgroundColor(0, 0, 0, 0);
设置背景图片
使用一张图片作为背景
csharp
OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "Image files (*.png;*.jpg)|*.png;*.jpg";
if (dlg.ShowDialog() != DialogResult.OK)
return;
var texture = ImageTexture2D.Create(dlg.FileName);
var background = new ImageBackground(texture);
mRenderView.Viewer.SetBackground(background);
3 设置标准视图
系统内置了几种标准的视角,前后左右上下等
csharp
// 设置到默认的3D视角
mRenderView.SetStandardView(EnumStandardView.DefaultView);
4 屏幕截图
把屏幕截图保存为位图文件:
csharp
SaveFileDialog dialog = new SaveFileDialog();
dialog.Filter = "Bitmap (*.bmp)|*.bmp";
if (dialog.ShowDialog() != DialogResult.OK)
return;
var screenShot = mRenderView.CreateScreenShot();
screenShot.ToBGR();
screenShot.SaveFile(dialog.FileName);
5 鼠标按键设置
通过控件得到ViewContext对象,可以设置鼠标按键的行为。
csharp
var viewContext = renderView.ViewContext;
``
### 鼠标功能
```csharp
viewContext.SetPanButton(EnumMouseButton.Left);
viewContext.OrbitButton(EnumMouseButton.Right);
viewContext.PickButton(EnumMouseButton.Middle);
自由旋转
默认锁定上下翻转,可以通过 SetFreeOribt来解锁
csharp
viewContext.SetFreeOribt(true);
框选
csharp
viewContext.SetRectPick(true);