|
@@ -97,34 +97,41 @@ export class SGraphView extends SCanvasView {
|
|
|
|
|
|
/**
|
|
|
* 适配视图到视图
|
|
|
+ *
|
|
|
+ * @param scale 适配所占绘制区域比例
|
|
|
*/
|
|
|
- fitSceneToView(): void {
|
|
|
+ fitSceneToView(scale: number = 0.8): void {
|
|
|
if (null == this.scene) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 场景中无对象
|
|
|
let rect = this.scene.allItemRect();
|
|
|
- this.fitRectToSize(this.width, this.height, rect);
|
|
|
+ this.fitRectToSize(this.width, this.height, rect, scale);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 适配选中的对象在视图中可见
|
|
|
+ *
|
|
|
+ * @param scale 适配所占绘制区域比例
|
|
|
*/
|
|
|
- fitSelectedToView(): void {
|
|
|
+ fitSelectedToView(scale: number = 0.8): void {
|
|
|
if (null == this.scene) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 场景中无对象
|
|
|
let rect = this.scene.selectedItemRect();
|
|
|
- this.fitRectToSize(this.width, this.height, rect);
|
|
|
+ this.fitRectToSize(this.width, this.height, rect, scale);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 适配任意对象在视图中可见
|
|
|
+ *
|
|
|
+ * @param itemList 参与适配的 item
|
|
|
+ * @param scale 适配所占绘制区域比例
|
|
|
*/
|
|
|
- fitItemToView(itemList: SGraphItem[]): void {
|
|
|
+ fitItemToView(itemList: SGraphItem[], scale: number = 0.8): void {
|
|
|
if (null == this.scene) {
|
|
|
return;
|
|
|
}
|
|
@@ -141,7 +148,7 @@ export class SGraphView extends SCanvasView {
|
|
|
}
|
|
|
}
|
|
|
// 场景中无对象
|
|
|
- this.fitRectToSize(this.width, this.height, rect);
|
|
|
+ this.fitRectToSize(this.width, this.height, rect, scale);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -448,18 +455,20 @@ export class SGraphView extends SCanvasView {
|
|
|
* @param width 宽度
|
|
|
* @param height 高度
|
|
|
* @param rect 对象的矩阵大小
|
|
|
+ * @param scale 适配所占绘制区域比例
|
|
|
*/
|
|
|
private fitRectToSize(
|
|
|
width: number,
|
|
|
height: number,
|
|
|
- rect: SRect | null
|
|
|
+ rect: SRect | null,
|
|
|
+ scale: number = 0.8
|
|
|
): void {
|
|
|
// 未设置场景
|
|
|
if (null == rect || !rect.isValid()) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- this.scale = Math.min(width / rect.width, height / rect.height) * 0.8;
|
|
|
+ this.scale = Math.min(width / rect.width, height / rect.height) * scale;
|
|
|
|
|
|
// 计算场景中心点
|
|
|
let center = rect.center();
|