Commit 0e72c156 by cat

zd

parent 2a736a55
......@@ -71,6 +71,7 @@
<div
style="display:flex; align-items:center; justify-content: space-between; margin-bottom: 12px;">
<div style="font-weight: 600;">纪要</div>
<el-button type="primary" size="small" icon="el-icon-download" @click="handleExportHyjy">导出</el-button>
</div>
<div class="summary" v-html="detail.hyjy"></div>
</el-card>
......@@ -327,7 +328,17 @@ export default {
this.$message.warning('缺少会议ID')
return
}
download('hyjyxx/hyjyxx/exportWord_YY', { id: this.id }, `会议转录文本_${this.detail.ypwjName || this.id}_${new Date().getTime()}.docx`)
download('hyjyxx/hyjyxx/exportWord_YY', { id: this.id }, `${this.detail.hymc+'转录文本'}.docx`)
},
/**
* 导出Word(转录文本)
*/
handleExportHyjy() {
if (!this.id) {
this.$message.warning('缺少会议ID')
return
}
download('/hyjyxx/hyjyxx/exportWord_JY', { id: this.id }, `${this.detail.hymc +'会议纪要'}.docx`)
}
}
}
......
......@@ -68,7 +68,6 @@
</div>
<!-- 缩略图 end-->
<!-- 缩略图弹窗 start -->
<!-- 缩略图弹窗 start -->
<el-dialog v-if="shouldShowThumb" title="缩略图预览" :visible.sync="showThumbDialog" width="80%" append-to-body
:z-index="9999999" :modal="true" :close-on-click-modal="true" :close-on-press-escape="true"
custom-class="thumbnail-dialog">
......@@ -78,7 +77,6 @@
</div>
</el-dialog>
<!-- 缩略图弹窗 end -->
<!-- 缩略图弹窗 end -->
</div>
<!-- 添加加载状态和错误提示 -->
......@@ -2207,32 +2205,196 @@ export default {
await this.renderAnnotationsFromJbbznr(originSegy);
await this.renderAnnotationsFromXbbznr(originSegy);
// 统一在标注恢复后,强制刷新上下两个widget,避免非悬浮状态下显示旧帧
// 减少刷新频率,避免底部图闪烁
try { this._seismicWidget && this._seismicWidget.invalidate && this._seismicWidget.invalidate(); } catch (e) { }
try { this._seismicWidgetBottom && this._seismicWidgetBottom.invalidate && this._seismicWidgetBottom.invalidate(); } catch (e) { }
requestAnimationFrame(() => {
try { this._seismicWidget && this._seismicWidget.invalidate && this._seismicWidget.invalidate(); } catch (e) { }
try { this._seismicWidgetBottom && this._seismicWidgetBottom.invalidate && this._seismicWidgetBottom.invalidate(); } catch (e) { }
});
// 关键修复:切换下一道后,强制将底部 widget 绑定为当前 pipeline,并重新插入绘制工具,防止短暂显示上一道
try {
// 确保 pipeline/路径键为当前
// 确保 pipeline/路径键为当前(只在必要时调用,避免频繁刷新)
await this.assertBottomPipelineCurrent();
this.refreshBottomDisplay();
// 移除重复的 refreshBottomDisplay 调用,避免闪烁
// this.refreshBottomDisplay(); // 注释掉,因为 assertBottomPipelineCurrent 已经会刷新
// 确保 plots 对象存在(如果为 null,重新创建)
if (!this.plots && this._seismicWidget && this.$refs.plot) {
try {
this.plots = new Plot({
'canvasElement': this.$refs.plot,
'root': this._seismicWidget
});
} catch (e) {
console.warn('[loadCurrentSegy] 重新创建 plots 失败:', e);
}
}
// 重新插入顶部工具(有些环境下 setPipeline 后工具管理器会丢失已插入的工具)
if (this._seismicWidget && this.checkWidgetStatus()) {
// 如果工具还没有初始化,先初始化它们
if (!this.annotationTool || !this.annotations) {
try {
this.initAnnotationTools(this._seismicWidget);
} catch (e) {
console.warn('[loadCurrentSegy] 初始化顶部注释工具失败:', e);
}
}
const tm = this._seismicWidget.getTool && this._seismicWidget.getTool();
if (tm) {
// 重新插入顶部 annotationTool
if (this.annotationTool) {
try { tm.remove(this.annotationTool); } catch (e) { }
try { tm.insert(0, this.annotationTool); } catch (e) { }
// 工具启用状态根据当前面板同步
try { this.annotationTool.setEnabled(!!this.isDrawingText); } catch (e) { }
}
// 重新插入顶部 pencilTool(如果已创建)
if (this.pencilTool) {
try { tm.remove(this.pencilTool); } catch (e) { }
try { tm.insert(0, this.pencilTool); } catch (e) { }
// 工具启用状态根据当前面板同步
try { this.pencilTool.setEnabled(!!this.showLineStylePanel); } catch (e) { }
}
}
}
// 重新插入底部工具(有些环境下 setPipeline 后工具管理器会丢失已插入的工具)
if (this._seismicWidgetBottom) {
// 如果底部工具还没有初始化,先初始化它们
if (!this.annotationToolBottom) {
try {
this.initAnnotationToolsBottom(this._seismicWidgetBottom);
} catch (e) {
console.warn('[loadCurrentSegy] 初始化底部注释工具失败:', e);
}
}
const tm = this._seismicWidgetBottom.getTool && this._seismicWidgetBottom.getTool();
if (tm) {
// 先移除所有工具
try { this.pencilToolBottom && tm.remove(this.pencilToolBottom); } catch (e) { }
try { this.annotationToolBottom && tm.remove(this.annotationToolBottom); } catch (e) { }
try { this.pencilToolBottom && tm.insert(0, this.pencilToolBottom); } catch (e) { }
try { this.annotationToolBottom && tm.insert(0, this.annotationToolBottom); } catch (e) { }
// 根据当前激活的工具,只插入需要的工具,并确保顺序正确
if (this.showLineStylePanel && this.pencilToolBottom) {
// 线条工具激活时,只插入线条工具,确保文本工具被禁用
try {
// 暂时冻结 widget 更新,避免刷新导致闪烁
try {
if (this._seismicWidgetBottom.setOptions) {
this._seismicWidgetBottom.setOptions({ 'freezeupdate': true });
}
} catch (e) { }
tm.insert(0, this.pencilToolBottom);
this.pencilToolBottom.setMode(PaintMode.Pencil);
this.pencilToolBottom.setEditMode(EditMode.Create);
this.pencilToolBottom.setEnabled(true);
// 恢复 widget 更新
try {
if (this._seismicWidgetBottom.setOptions) {
this._seismicWidgetBottom.setOptions({ 'freezeupdate': false });
}
} catch (e) { }
} catch (e) {
// 确保即使出错也恢复更新
try {
if (this._seismicWidgetBottom && this._seismicWidgetBottom.setOptions) {
this._seismicWidgetBottom.setOptions({ 'freezeupdate': false });
}
} catch (e2) { }
}
// 确保文本工具被禁用
if (this.annotationToolBottom) {
try {
this.annotationToolBottom.setEnabled(false);
this.annotationToolBottom.editNode(null);
} catch (e) { }
}
} else if (this.isDrawingText && this.annotationToolBottom) {
// 文本工具激活时,只插入文本工具
try {
// 暂时冻结 widget 更新,避免刷新导致闪烁
try {
if (this._seismicWidgetBottom.setOptions) {
this._seismicWidgetBottom.setOptions({ 'freezeupdate': true });
}
} catch (e) { }
tm.insert(0, this.annotationToolBottom);
// 关键修复:设置文本工具属性,确保底部图可以输入文本
const fontString = `${this.textStyle.bold ? 'bold ' : ''}${this.textStyle.italic ? 'italic ' : ''}${this.textStyle.size || 22}px ${this.textStyle.font || 'Sans-serif'}`;
const textProperties = {
'editmode': EditMode.Create,
'mode': PaintMode.Text,
'node': {
'textstyle': new TextStyle({
color: this.textStyle.color || '#000000',
size: this.textStyle.size || 22,
font: fontString,
alignment: this.textStyle.align || 'left',
bold: this.textStyle.bold || false,
italic: this.textStyle.italic || false
}),
'textbox': {
'border': (this.textStyle.borderRadius || 0) > 0,
'borderradius': this.textStyle.borderRadius || 0,
'padding': (this.textStyle.borderRadius || 0) > 0 ? (this.textStyle.borderRadius || 0) : 5,
'fixedsize': this.textStyle.fixedFont || false
},
'selectable': true,
'movable': true,
'editable': true,
'preserveontextfinish': true,
'preserveonblur': true,
'autofocus': true,
'sizemode': this.textStyle.fixedFont ?
(SizeMode.FixedWidth | SizeMode.FixedHeight) :
SizeMode.WrappedWidth
}
};
this.annotationToolBottom.setProperties(textProperties);
this.annotationToolBottom.setEnabled(true);
// 恢复 widget 更新
try {
if (this._seismicWidgetBottom.setOptions) {
this._seismicWidgetBottom.setOptions({ 'freezeupdate': false });
}
} catch (e) { }
} catch (e) {
console.warn('[loadCurrentSegy] 设置底部文本工具属性失败:', e);
// 确保即使出错也恢复更新
try {
if (this._seismicWidgetBottom && this._seismicWidgetBottom.setOptions) {
this._seismicWidgetBottom.setOptions({ 'freezeupdate': false });
}
} catch (e2) { }
}
// 确保线条工具被禁用
if (this.pencilToolBottom) {
try {
this.pencilToolBottom.setEnabled(false);
} catch (e) { }
}
} else {
// 都没有激活,都插入但都禁用
try { this.pencilToolBottom && tm.insert(0, this.pencilToolBottom); } catch (e) { }
try { this.annotationToolBottom && tm.insert(0, this.annotationToolBottom); } catch (e) { }
try { this.pencilToolBottom && this.pencilToolBottom.setEnabled(false); } catch (e) { }
try { this.annotationToolBottom && this.annotationToolBottom.setEnabled(false); } catch (e) { }
}
}
// 工具启用状态根据当前面板同步
try { this.pencilToolBottom && this.pencilToolBottom.setEnabled(!!this.showLineStylePanel); } catch (e) { }
try { this.annotationToolBottom && this.annotationToolBottom.setEnabled(!!this.isDrawingText); } catch (e) { }
try { this._seismicWidgetBottom.invalidate && this._seismicWidgetBottom.invalidate(); } catch (e) { }
// 移除这里的 invalidate,避免频繁刷新导致闪烁
// try { this._seismicWidgetBottom.invalidate && this._seismicWidgetBottom.invalidate(); } catch (e) { }
}
} catch (e) { /* ignore */ }
// 关键:确保 isWidgetReady 在加载完成后为 true
if (this._seismicWidget && this.checkWidgetStatus()) {
this.isWidgetReady = true;
}
} catch (e) {
console.warn('[loadCurrentSegy] 重新插入工具时出错:', e);
}
} catch (e) {
console.error('[index2] 标注恢复失败:', e);
} finally {
......@@ -2925,6 +3087,18 @@ export default {
this._seismicWidget.setPipeline(pipeline);
this._seismicWidget.setOptions({ 'axes': { 'samples': { 'title': { 'visible': true, 'text': displayName || this.extractFileName(segyPath) || pipeline.getName() } } } });
// 关键修复:恢复 plots 对象,确保工具栏功能可用
if (!this.plots && this._seismicWidget && this.$refs.plot) {
try {
this.plots = new Plot({
'canvasElement': this.$refs.plot,
'root': this._seismicWidget
});
} catch (e) {
console.warn('[loadSegyIntoWidget] 恢复 plots 失败:', e);
}
}
// 如果不跳过刷新,则立即刷新;否则等待统一刷新
if (!skipRefresh) {
// 强制刷新以确保显示新的数据
......@@ -2977,15 +3151,49 @@ export default {
if (!this._seismicWidgetBottom && this.$refs.plot2) this.initSecondWidget(this.$refs.plot2);
if (!this._seismicWidgetBottom) throw new Error('底部Widget未初始化');
// 设置新的 pipeline,并记录为“当前版本”
// 设置新的 pipeline,并记录为"当前版本"
this.pipelineBottom = pipeline;
this._bottomSegyKey = displayName || this.extractFileName(segyPath) || pipeline.getName();
this._bottomSegyPath = segyPath;
const newKey = displayName || this.extractFileName(segyPath) || pipeline.getName();
const newPath = segyPath;
// 关键修复:如果 pipeline、路径和名称都没有变化,不需要重新设置,避免不必要的刷新
if (this._seismicWidgetBottom.getPipeline && this._seismicWidgetBottom.getPipeline() === pipeline &&
String(this._bottomSegyPath) === String(newPath) && String(this._bottomSegyKey) === String(newKey)) {
// 完全一致,不需要做任何操作
return;
}
this._bottomSegyKey = newKey;
this._bottomSegyPath = newPath;
// 关键修复:在设置 pipeline 前冻结更新,避免中间状态刷新
let wasFrozen = false;
try {
if (this._seismicWidgetBottom.setOptions) {
wasFrozen = this._seismicWidgetBottom.setOptions({ 'freezeupdate': true });
}
} catch (e) { }
this._seismicWidgetBottom.setPipeline(pipeline);
this._seismicWidgetBottom.setOptions({ 'axes': { 'samples': { 'title': { 'visible': true, 'text': displayName || this.extractFileName(segyPath) || pipeline.getName() } } } });
this._seismicWidgetBottom.setOptions({ 'axes': { 'samples': { 'title': { 'visible': true, 'text': newKey } } } });
// 恢复更新(如果 skipRefresh 为 false,会在后面刷新)
try {
if (this._seismicWidgetBottom.setOptions && wasFrozen !== undefined && skipRefresh) {
// 如果 skipRefresh 为 true,先恢复更新,但不立即刷新
this._seismicWidgetBottom.setOptions({ 'freezeupdate': false });
}
} catch (e) { }
// 如果不跳过刷新,则立即刷新;否则等待统一刷新
if (!skipRefresh) {
// 恢复更新(如果之前被冻结)
try {
if (this._seismicWidgetBottom.setOptions && wasFrozen !== undefined) {
this._seismicWidgetBottom.setOptions({ 'freezeupdate': false });
}
} catch (e) { }
// 强制刷新以确保显示新的数据
this.$nextTick(() => {
try {
......@@ -4300,10 +4508,30 @@ export default {
// 如果已经有当前有效的 bottom pipeline,优先使用它,避免回退到旧数据
if (this.pipelineBottom) {
try {
this._seismicWidgetBottom.setPipeline(this.pipelineBottom);
this._seismicWidgetBottom.setOptions({
'axes': { 'headers': { 'fields': this._headers }, 'samples': { 'title': { 'visible': true, 'text': this.pipelineBottom.getName && this.pipelineBottom.getName() } } }
});
// 关键修复:检查 pipeline 是否已经设置,避免重复设置导致刷新
const currentPipeline = this._seismicWidgetBottom.getPipeline && this._seismicWidgetBottom.getPipeline();
if (currentPipeline !== this.pipelineBottom) {
// 只有 pipeline 不同时才设置,并使用 freezeupdate 避免闪烁
let wasFrozen = false;
try {
if (this._seismicWidgetBottom.setOptions) {
wasFrozen = this._seismicWidgetBottom.setOptions({ 'freezeupdate': true });
}
} catch (e) { }
this._seismicWidgetBottom.setPipeline(this.pipelineBottom);
this._seismicWidgetBottom.setOptions({
'axes': { 'headers': { 'fields': this._headers }, 'samples': { 'title': { 'visible': true, 'text': this.pipelineBottom.getName && this.pipelineBottom.getName() } } }
});
// 恢复更新
try {
if (this._seismicWidgetBottom.setOptions && wasFrozen !== undefined) {
this._seismicWidgetBottom.setOptions({ 'freezeupdate': false });
}
} catch (e) { }
}
setTimeout(() => { try { this._seismicWidgetBottom.fitToBounds(); } catch (e) { } }, 200);
this.setScrollbarCSS(this._seismicWidgetBottom);
try { this.initAnnotationToolsBottom(this._seismicWidgetBottom); } catch (e) { }
......@@ -4326,6 +4554,15 @@ export default {
try { pipelineBottom.addTraceProcessor(new Reverse({ 'apply': false, 'name': 'Reverse' })); } catch (e) { }
this.pipelineBottom = pipelineBottom;
// 关键修复:使用 freezeupdate 避免设置 pipeline 时的闪烁
let wasFrozen = false;
try {
if (this._seismicWidgetBottom.setOptions) {
wasFrozen = this._seismicWidgetBottom.setOptions({ 'freezeupdate': true });
}
} catch (e) { }
this._seismicWidgetBottom.setPipeline(pipelineBottom);
this._seismicWidgetBottom.setOptions({
'axes': {
......@@ -4335,6 +4572,13 @@ export default {
}
}
});
// 恢复更新
try {
if (this._seismicWidgetBottom.setOptions && wasFrozen !== undefined) {
this._seismicWidgetBottom.setOptions({ 'freezeupdate': false });
}
} catch (e) { }
// 延迟调用fitToBounds,确保初始状态稳定
setTimeout(() => {
this._seismicWidgetBottom.fitToBounds();
......@@ -4345,7 +4589,7 @@ export default {
try { this.initAnnotationToolsBottom(this._seismicWidgetBottom); } catch (e) { console.warn('初始化底部注释工具失败:', e); }
} catch (e) {
console.warn('初始化下半屏流水线失败:', e);
}
}
}
} catch (error) {
console.error('创建下半屏视图失败:', error);
......@@ -4379,7 +4623,81 @@ export default {
// 选择工具(限制在底部标注层)
const selectionToolBottom = new Selection()
.setNodeFilter((nodes) => nodes.filter((node) => this.annotationsBottom.indexOfChild(node) >= 0));
.setNodeFilter((nodes) => nodes.filter((node) => this.annotationsBottom.indexOfChild(node) >= 0))
.addListener(SelectionEvents.onPick, (tool, eventArgs) => {
// 关键修复:在工具操作时冻结 widget 更新,避免触发任何刷新或 pipeline 检查
let wasFrozen = false;
try {
if (widget && widget.setOptions) {
wasFrozen = widget.setOptions({ 'freezeupdate': true });
}
} catch (e) { }
try {
const selection = eventArgs.getSelection();
const length = selection.length;
if (length === 0) {
// 点击空白区域,取消选中
if (this.annotationToolBottom && this.annotationToolBottom.getMode() === PaintMode.Edit) {
this.annotationToolBottom.editNode(null);
}
if (this.pencilToolBottom && this.pencilToolBottom.getMode() === PaintMode.Edit) {
this.pencilToolBottom.editNode(null);
// 如果线条工具面板是激活的,切换回创建模式,允许继续绘制新线条
if (this.showLineStylePanel && this.pencilToolBottom.isEnabled()) {
this.pencilToolBottom.setEditMode(EditMode.Create);
}
}
} else if (length > 0) {
// 选中了节点,根据节点类型决定使用哪个工具
const selectedNode = selection[length - 1];
// 检查节点是否是文本节点
const isTextNode = (selectedNode.text !== undefined && selectedNode.text !== null) ||
(typeof selectedNode.getText === 'function');
// 检查节点是否是路径节点(线条)
const isPathNode = selectedNode.getType && selectedNode.getType() === 'Path' ||
(selectedNode.getProperties && selectedNode.getProperties().linestyle);
if (isTextNode && this.annotationToolBottom) {
// 文本节点:使用 annotationToolBottom 编辑
if (this.annotationToolBottom.getMode() !== PaintMode.Edit || this.annotationToolBottom.getShape() !== selectedNode) {
this.annotationToolBottom.setEditMode(EditMode.EditNode);
this.annotationToolBottom.editNode(selectedNode);
}
// 如果线条工具在编辑模式,取消它
if (this.pencilToolBottom && this.pencilToolBottom.getMode() === PaintMode.Edit) {
this.pencilToolBottom.editNode(null);
}
} else if (isPathNode && this.pencilToolBottom) {
// 路径节点(线条):使用 pencilToolBottom 编辑
// 关键修复:即使 pencilToolBottom 当前未启用,也要启用它并设置为编辑模式
if (!this.pencilToolBottom.isEnabled()) {
this.pencilToolBottom.setEnabled(true);
}
if (this.pencilToolBottom.getMode() !== PaintMode.Edit || this.pencilToolBottom.getShape() !== selectedNode) {
this.pencilToolBottom.setEditMode(EditMode.EditNode);
this.pencilToolBottom.editNode(selectedNode);
}
// 如果文本工具在编辑模式,取消它
if (this.annotationToolBottom && this.annotationToolBottom.getMode() === PaintMode.Edit) {
this.annotationToolBottom.editNode(null);
}
}
eventArgs.stopPropagation(true, true);
}
} finally {
// 恢复 widget 更新
try {
if (widget && widget.setOptions && wasFrozen !== undefined) {
widget.setOptions({ 'freezeupdate': false });
}
} catch (e) { }
}
});
const toolManager = widget.getTool();
try { toolManager.remove(this.annotationToolBottom); toolManager.remove(selectionToolBottom); } catch (e) { }
......@@ -4422,7 +4740,9 @@ export default {
} catch (e) { }
}
if (this.annotationsBottom.indexOfChild(node) === -1) this.annotationsBottom.addChild(node);
try { widget.invalidate && widget.invalidate(); } catch (e) { }
// 移除频繁的 invalidate 调用,避免闪烁
// 工具绘制完成后,widget 会自动更新,不需要手动刷新
// try { widget.invalidate && widget.invalidate(); } catch (e) { }
});
// 线条工具(底部)
......@@ -4442,8 +4762,39 @@ export default {
this.collectedAnnotations.push({ type: 'path', properties: props, panel: 'bottom', _nodeRef: node });
} catch (e) { }
if (this.annotationsBottom.indexOfChild(node) === -1) this.annotationsBottom.addChild(node);
try { tool.setEditMode(EditMode.EditNode); tool.editNode(node); } catch (e) { }
try { widget.invalidate && widget.invalidate(); } catch (e) { }
// 关键修复:绘制完成后,确保节点保持可编辑属性
try {
const props = typeof node.getProperties === 'function' ? node.getProperties() : {};
if (!props.selectable || !props.movable || !props.editable) {
// 如果属性丢失,重新设置
const currentLineStyle = props.linestyle || new LineStyle({
color: this.lineStyle?.color || '#0351ad',
width: this.lineStyle?.width || 2,
pattern: this.getProcessedLinePattern ? this.getProcessedLinePattern(this.lineStyle?.pattern) : []
});
node.setProperties({
...props,
linestyle: currentLineStyle,
selectable: true,
movable: true,
editable: true
});
}
} catch (e) {
console.warn('设置底部线条节点编辑属性失败:', e);
}
// 修复:绘制完成后,保持编辑模式,让用户可以立即编辑刚绘制的线条
try {
if (this.pencilToolBottom && this.pencilToolBottom.isEnabled() && this.showLineStylePanel) {
// 设置编辑模式,让用户可以选择和编辑刚绘制的线条
this.pencilToolBottom.setEditMode(EditMode.EditNode);
this.pencilToolBottom.editNode(node);
}
} catch (e) {
console.warn('设置底部线条编辑模式失败:', e);
}
});
// 默认禁用,按按钮再启用
......@@ -4458,11 +4809,38 @@ export default {
refreshBottomDisplay() {
try {
if (this._seismicWidgetBottom && this.pipelineBottom) {
try { this._seismicWidgetBottom.setPipeline(this.pipelineBottom); } catch (e) { }
try { this._seismicWidgetBottom.invalidate && this._seismicWidgetBottom.invalidate(); } catch (e) { }
requestAnimationFrame(() => {
try { this._seismicWidgetBottom.invalidate && this._seismicWidgetBottom.invalidate(); } catch (e) { }
});
// 只有在 pipeline 确实需要更新时才调用 setPipeline,避免不必要的刷新
// 检查当前 pipeline 是否已经是正确的
const currentPipeline = this._seismicWidgetBottom.getPipeline && this._seismicWidgetBottom.getPipeline();
if (currentPipeline !== this.pipelineBottom) {
// 关键修复:使用 freezeupdate 避免刷新时的闪烁
let wasFrozen = false;
try {
if (this._seismicWidgetBottom.setOptions) {
wasFrozen = this._seismicWidgetBottom.setOptions({ 'freezeupdate': true });
}
} catch (e) { }
try {
this._seismicWidgetBottom.setPipeline(this.pipelineBottom);
} catch (e) { }
// 恢复更新
try {
if (this._seismicWidgetBottom.setOptions && wasFrozen !== undefined) {
this._seismicWidgetBottom.setOptions({ 'freezeupdate': false });
}
} catch (e) { }
// 只有在 pipeline 改变时才刷新
try {
this.$nextTick(() => {
if (this._seismicWidgetBottom && this._seismicWidgetBottom.invalidate) {
this._seismicWidgetBottom.invalidate();
}
});
} catch (e) { }
}
}
} catch (e) { /* ignore */ }
},
......@@ -4482,19 +4860,74 @@ export default {
try {
const info = this.getExpectedBottomInfo();
if (!info || !info.path) return;
// 关键修复:如果路径和名称都匹配,不需要做任何操作,直接返回,避免任何刷新
// 使用严格相等比较,确保不会因为类型不同而误判
if (String(this._bottomSegyPath) === String(info.path) && String(this._bottomSegyKey) === String(info.name)) {
return;
}
// 关键修复:在切换 pipeline 前冻结 widget 更新,避免闪烁
let wasFrozen = false;
try {
if (this._seismicWidgetBottom && this._seismicWidgetBottom.setOptions) {
wasFrozen = this._seismicWidgetBottom.setOptions({ 'freezeupdate': true });
}
} catch (e) { }
// 优先用路径判断是否一致
if (!this._bottomSegyPath || this._bottomSegyPath !== info.path) {
await this.loadSegyIntoWidget('bottom', info.path, info.name, false);
try { this._seismicWidgetBottom && this._seismicWidgetBottom.invalidate && this._seismicWidgetBottom.invalidate(); } catch (e) { }
if (!this._bottomSegyPath || String(this._bottomSegyPath) !== String(info.path)) {
// 使用 skipRefresh=true 并手动控制刷新,避免不必要的刷新
await this.loadSegyIntoWidget('bottom', info.path, info.name, true);
// 恢复 widget 更新
try {
if (this._seismicWidgetBottom && this._seismicWidgetBottom.setOptions && wasFrozen !== undefined) {
this._seismicWidgetBottom.setOptions({ 'freezeupdate': false });
}
// 只在真正需要时才刷新一次
if (this._seismicWidgetBottom && this._seismicWidgetBottom.invalidate) {
this.$nextTick(() => {
try {
this._seismicWidgetBottom.invalidate();
} catch (e) { }
});
}
} catch (e) { }
return;
}
// 其次用名称兜底
// 其次用名称兜底(通常不会走到这里,因为路径已匹配)
const expectedKey = info.name;
if (!this._bottomSegyKey || this._bottomSegyKey !== expectedKey) {
await this.loadSegyIntoWidget('bottom', info.path, info.name, false);
try { this._seismicWidgetBottom && this._seismicWidgetBottom.invalidate && this._seismicWidgetBottom.invalidate(); } catch (e) { }
if (!this._bottomSegyKey || String(this._bottomSegyKey) !== String(expectedKey)) {
await this.loadSegyIntoWidget('bottom', info.path, info.name, true);
// 恢复 widget 更新
try {
if (this._seismicWidgetBottom && this._seismicWidgetBottom.setOptions && wasFrozen !== undefined) {
this._seismicWidgetBottom.setOptions({ 'freezeupdate': false });
}
if (this._seismicWidgetBottom && this._seismicWidgetBottom.invalidate) {
this.$nextTick(() => {
try {
this._seismicWidgetBottom.invalidate();
} catch (e) { }
});
}
} catch (e) { }
} else {
// 如果只是名称不匹配但路径匹配,直接恢复更新,不需要重新加载
try {
if (this._seismicWidgetBottom && this._seismicWidgetBottom.setOptions && wasFrozen !== undefined) {
this._seismicWidgetBottom.setOptions({ 'freezeupdate': false });
}
} catch (e) { }
}
} catch (e) { /* ignore */ }
} catch (e) {
// 确保即使出错也恢复更新
try {
if (this._seismicWidgetBottom && this._seismicWidgetBottom.setOptions) {
this._seismicWidgetBottom.setOptions({ 'freezeupdate': false });
}
} catch (e2) { }
}
},
// 同步滚动条(左右与上下)- 防死循环版本
......@@ -4551,11 +4984,15 @@ export default {
top.setModelLimits = function (rect) {
const result = originalTop(rect);
// 修复:避免在工具操作时触发底部图的刷新,防止闪烁
// 移除跨 widget 的自动刷新,避免点击一个图时另一个图闪烁
if (!self._isSyncingZoom) {
self._isSyncingZoom = true;
try {
originalBottom(rect);
if (bottom.invalidate) bottom.invalidate();
// 关键修复:移除自动刷新底部图,避免点击顶部图时底部图闪烁
// 工具操作(绘制、点击等)不应该触发跨 widget 的刷新
// if (bottom.invalidate) bottom.invalidate();
if (self.updateWidgetScrollbar) self.updateWidgetScrollbar(bottom);
// 使用CSS方法彻底禁用内部滚动条
if (self.setScrollbarCSS) self.setScrollbarCSS(bottom);
......@@ -4572,11 +5009,15 @@ export default {
bottom.setModelLimits = function (rect) {
const result = originalBottom(rect);
// 关键修复:避免在工具操作时触发顶部图的刷新,防止闪烁
// 移除跨 widget 的自动刷新,这是导致点击底部图时顶部图闪烁的根本原因
if (!self._isSyncingZoom) {
self._isSyncingZoom = true;
try {
originalTop(rect);
if (top.invalidate) top.invalidate();
// 关键修复:移除自动刷新顶部图,避免点击底部图时顶部图闪烁
// 工具操作(绘制、点击等)不应该触发跨 widget 的刷新
// if (top.invalidate) top.invalidate();
if (self.updateWidgetScrollbar) self.updateWidgetScrollbar(top);
// 使用CSS方法彻底禁用内部滚动条
if (self.setScrollbarCSS) self.setScrollbarCSS(top);
......@@ -6109,29 +6550,62 @@ export default {
.setNodeFilter((nodes) => nodes.filter((node) =>
this.annotations.indexOfChild(node) >= 0))
.addListener(SelectionEvents.onPick, (tool, eventArgs) => {
if (!this.annotationTool.isEnabled() && !this.pencilTool?.isEnabled()) return;
const selection = eventArgs.getSelection();
const length = selection.length;
if (length === 0) {
if (this.annotationTool.getMode() === PaintMode.Edit) {
// 点击空白区域,取消选中
if (this.annotationTool && this.annotationTool.getMode() === PaintMode.Edit) {
this.annotationTool.editNode(null);
}
if (this.pencilTool && this.pencilTool.getMode() === PaintMode.Edit) {
this.pencilTool.editNode(null);
// 如果线条工具面板是激活的,切换回创建模式,允许继续绘制新线条
if (this.showLineStylePanel && this.pencilTool.isEnabled()) {
this.pencilTool.setEditMode(EditMode.Create);
}
}
} else if (length > 0) {
// 选中了节点,根据节点类型决定使用哪个工具
const selectedNode = selection[length - 1];
const currentTool = this.annotationTool.isEnabled() ? this.annotationTool :
(this.pencilTool && this.pencilTool.isEnabled() ? this.pencilTool : null);
if (currentTool && selectedNode !== currentTool.getShape()) {
currentTool.setEditMode(EditMode.EditNode);
currentTool.editNode(selectedNode);
this.selectedShape = selectedNode;
eventArgs.stopPropagation(true, true);
// 检查节点是否是文本节点(通过检查是否有 text 属性或 getText 方法)
const isTextNode = (selectedNode.text !== undefined && selectedNode.text !== null) ||
(typeof selectedNode.getText === 'function');
// 检查节点是否是路径节点(线条)
const isPathNode = selectedNode.getType && selectedNode.getType() === 'Path' ||
(selectedNode.getProperties && selectedNode.getProperties().linestyle);
if (isTextNode && this.annotationTool) {
// 文本节点:使用 annotationTool 编辑
if (this.annotationTool.getMode() !== PaintMode.Edit || this.annotationTool.getShape() !== selectedNode) {
this.annotationTool.setEditMode(EditMode.EditNode);
this.annotationTool.editNode(selectedNode);
this.selectedShape = selectedNode;
}
// 如果线条工具在编辑模式,取消它
if (this.pencilTool && this.pencilTool.getMode() === PaintMode.Edit) {
this.pencilTool.editNode(null);
}
} else if (isPathNode && this.pencilTool) {
// 路径节点(线条):使用 pencilTool 编辑
// 关键修复:即使 pencilTool 当前未启用,也要启用它并设置为编辑模式,以便可以编辑线条
if (!this.pencilTool.isEnabled()) {
this.pencilTool.setEnabled(true);
}
if (this.pencilTool.getMode() !== PaintMode.Edit || this.pencilTool.getShape() !== selectedNode) {
this.pencilTool.setEditMode(EditMode.EditNode);
this.pencilTool.editNode(selectedNode);
this.selectedShape = selectedNode;
}
// 如果文本工具在编辑模式,取消它
if (this.annotationTool && this.annotationTool.getMode() === PaintMode.Edit) {
this.annotationTool.editNode(null);
}
}
eventArgs.stopPropagation(true, true);
}
});
......@@ -6312,63 +6786,79 @@ export default {
console.warn('Widget or annotation tools not ready');
return;
}
// 在启用工具前确保底部绑定的是当前索引(等待更正完成)
await this.assertBottomPipelineCurrent();
// 如果是关闭文本工具,直接禁用并返回
if (this.isDrawingText) {
this.isDrawingText = false;
this.showTextStylePanel = false;
if (this.annotationTool) {
this.annotationTool.setEnabled(false);
this.annotationTool.editNode(null);
}
if (this.annotationToolBottom) {
try { this.annotationToolBottom.setEnabled(false); this.annotationToolBottom.editNode(null); } catch (e) { }
}
return;
}
if (!this.annotationTool) {
console.warn('注释工具未初始化');
return;
}
this.isDrawingText = !this.isDrawingText;
this.showTextStylePanel = this.isDrawingText;
// 先清除线条工具,避免功能冲突
if (this.showLineStylePanel && this.pencilTool) {
this.deactivatePencilTool();
}
if (this.isDrawingText) {
// 确保文本大小为22px
this.textStyle.size = 22;
this.isDrawingText = true;
this.showTextStylePanel = true;
// 创建完整的字体字符串,确保包含字体大小
const fontString = `${this.textStyle.bold ? 'bold ' : ''}${this.textStyle.italic ? 'italic ' : ''}${this.textStyle.size}px ${this.textStyle.font}`;
// 确保文本大小为22px
this.textStyle.size = 22;
// 先设置属性
const textProperties = {
'editmode': EditMode.Create,
'mode': PaintMode.Text,
'node': {
'textstyle': new TextStyle({
color: this.textStyle.color,
size: this.textStyle.size,
font: fontString, // 使用完整的字体字符串
alignment: this.textStyle.align,
bold: this.textStyle.bold,
italic: this.textStyle.italic
}),
'textbox': {
'border': this.textStyle.borderRadius > 0,
'borderradius': this.textStyle.borderRadius,
'padding': this.textStyle.borderRadius > 0 ? this.textStyle.borderRadius : 5,
'fixedsize': this.textStyle.fixedFont
},
'selectable': true,
'movable': true,
'editable': true,
'preserveontextfinish': true,
'preserveonblur': true,
'autofocus': true,
'sizemode': this.textStyle.fixedFont ?
(SizeMode.FixedWidth | SizeMode.FixedHeight) :
SizeMode.WrappedWidth
}
};
// 创建完整的字体字符串,确保包含字体大小
const fontString = `${this.textStyle.bold ? 'bold ' : ''}${this.textStyle.italic ? 'italic ' : ''}${this.textStyle.size}px ${this.textStyle.font}`;
//console.log('文本绘制工具配置:', textProperties);
this.annotationTool.setProperties(textProperties);
if (this.annotationToolBottom) {
try { this.annotationToolBottom.setProperties(textProperties); } catch (e) { }
// 先设置属性
const textProperties = {
'editmode': EditMode.Create,
'mode': PaintMode.Text,
'node': {
'textstyle': new TextStyle({
color: this.textStyle.color,
size: this.textStyle.size,
font: fontString, // 使用完整的字体字符串
alignment: this.textStyle.align,
bold: this.textStyle.bold,
italic: this.textStyle.italic
}),
'textbox': {
'border': this.textStyle.borderRadius > 0,
'borderradius': this.textStyle.borderRadius,
'padding': this.textStyle.borderRadius > 0 ? this.textStyle.borderRadius : 5,
'fixedsize': this.textStyle.fixedFont
},
'selectable': true,
'movable': true,
'editable': true,
'preserveontextfinish': true,
'preserveonblur': true,
'autofocus': true,
'sizemode': this.textStyle.fixedFont ?
(SizeMode.FixedWidth | SizeMode.FixedHeight) :
SizeMode.WrappedWidth
}
};
// 添加事件监听器来打印文本绘制数据
this.annotationTool.addListener(EditEvents.Start, (tool, command) => {
//console.log('文本绘制工具配置:', textProperties);
this.annotationTool.setProperties(textProperties);
if (this.annotationToolBottom) {
try { this.annotationToolBottom.setProperties(textProperties); } catch (e) { }
}
// 添加事件监听器来打印文本绘制数据
this.annotationTool.addListener(EditEvents.Start, (tool, command) => {
const node = command.getNode();
const textStyle = node.getTextStyle ? node.getTextStyle() : null;
// console.log('开始绘制文本:', {
......@@ -6392,7 +6882,7 @@ export default {
// });
});
this.annotationTool.addListener(EditEvents.Change, (tool, event) => {
this.annotationTool.addListener(EditEvents.Change, (tool, event) => {
const node = tool.getShape();
if (node) {
const textStyle = node.getTextStyle ? node.getTextStyle() : null;
......@@ -6427,7 +6917,7 @@ export default {
}
});
this.annotationTool.addListener(EditEvents.End, (tool, node) => {
this.annotationTool.addListener(EditEvents.End, (tool, node) => {
if (node) {
// 修复:按优先级提取文本,即使前面的方法返回空也要继续尝试
let text = '';
......@@ -6549,14 +7039,79 @@ export default {
this.requestRepaint();
});
this.annotationTool.setEnabled(true);
if (this.annotationToolBottom) { try { this.annotationToolBottom.setEnabled(true); } catch (e) { } }
// 确保底部仍绑定当前数据
this.refreshBottomDisplay();
} else {
this.annotationTool.setEnabled(false);
this.annotationTool.editNode(null);
if (this.annotationToolBottom) { try { this.annotationToolBottom.setEnabled(false); this.annotationToolBottom.editNode(null); } catch (e) { } }
this.annotationTool.setEnabled(true);
// 关键修复:确保底部文本工具被正确插入到工具管理器
// 先冻结 widget 更新,避免工具操作时的任何刷新
if (this.annotationToolBottom && this._seismicWidgetBottom) {
try {
// 先检查底部 pipeline 是否需要更新(在冻结前检查,避免不必要的冻结)
const info = this.getExpectedBottomInfo();
const needUpdatePipeline = info && info.path &&
(String(this._bottomSegyPath) !== String(info.path) || String(this._bottomSegyKey) !== String(info.name));
// 如果需要更新 pipeline,先冻结,然后更新
let wasFrozen = false;
if (needUpdatePipeline) {
try {
if (this._seismicWidgetBottom.setOptions) {
wasFrozen = this._seismicWidgetBottom.setOptions({ 'freezeupdate': true });
}
} catch (e) { }
// 只在真正需要时才更新 pipeline
await this.assertBottomPipelineCurrent();
} else {
// 即使不需要更新 pipeline,也冻结一下,避免工具操作时的刷新
try {
if (this._seismicWidgetBottom.setOptions) {
wasFrozen = this._seismicWidgetBottom.setOptions({ 'freezeupdate': true });
}
} catch (e) { }
}
const tm = this._seismicWidgetBottom.getTool && this._seismicWidgetBottom.getTool();
if (tm) {
// 先移除线条工具,避免冲突
if (this.pencilToolBottom) {
try {
this.pencilToolBottom.setEnabled(false);
tm.remove(this.pencilToolBottom);
} catch (e) { }
}
// 移除文本工具(如果已存在)
try {
tm.remove(this.annotationToolBottom);
} catch (e) { }
// 插入文本工具到最前面
tm.insert(0, this.annotationToolBottom);
// 设置属性并启用
this.annotationToolBottom.setProperties(textProperties);
this.annotationToolBottom.setEnabled(true);
// 恢复 widget 更新
try {
if (this._seismicWidgetBottom.setOptions && wasFrozen !== undefined) {
this._seismicWidgetBottom.setOptions({ 'freezeupdate': false });
}
} catch (e) { }
} else {
// 如果没有工具管理器,也要恢复更新
try {
if (this._seismicWidgetBottom.setOptions && wasFrozen !== undefined) {
this._seismicWidgetBottom.setOptions({ 'freezeupdate': false });
}
} catch (e) { }
}
} catch (e) {
console.warn('[toggleDrawText] 设置底部文本工具失败:', e);
// 确保即使出错也恢复更新
try {
if (this._seismicWidgetBottom && this._seismicWidgetBottom.setOptions) {
this._seismicWidgetBottom.setOptions({ 'freezeupdate': false });
}
} catch (e2) { }
}
}
},
......@@ -6984,7 +7539,8 @@ export default {
if (this.pencilTool) {
this.pencilTool.setEnabled(false);
const widget = this.plots.getRoot();
// 修复:如果 plots 为 null,直接使用 _seismicWidget
const widget = (this.plots && this.plots.getRoot) ? this.plots.getRoot() : this._seismicWidget;
if (widget && widget.getTool()) {
widget.getTool().remove(this.pencilTool);
}
......@@ -7002,8 +7558,9 @@ export default {
if (this.annotations) {
this.annotations.invalidate();
}
if (this.plots && this.plots.getRoot()) {
this.plots.getRoot().invalidate();
const widget = (this.plots && this.plots.getRoot) ? this.plots.getRoot() : this._seismicWidget;
if (widget) {
widget.invalidate();
}
},
......@@ -7361,7 +7918,8 @@ export default {
if (!this.checkWidgetStatus() || !this.isWidgetReady) return;
const widget = this.plots.getRoot();
// 修复:如果 plots 为 null,直接使用 _seismicWidget
const widget = (this.plots && this.plots.getRoot) ? this.plots.getRoot() : this._seismicWidget;
if (!widget) return;
// 确保注释层存在
......@@ -7428,9 +7986,42 @@ export default {
if (node && this.annotations.indexOfChild(node) === -1) {
this.annotations.addChild(node);
}
tool.setEditMode(EditMode.EditNode);
tool.editNode(node);
this.selectedShape = node;
// 关键修复:绘制完成后,确保节点保持可编辑属性
try {
const props = typeof node.getProperties === 'function' ? node.getProperties() : {};
if (!props.selectable || !props.movable || !props.editable) {
// 如果属性丢失,重新设置
const currentLineStyle = props.linestyle || new LineStyle({
color: this.lineStyle?.color || '#0351ad',
width: this.lineStyle?.width || 2,
pattern: this.getProcessedLinePattern ? this.getProcessedLinePattern(this.lineStyle?.pattern) : []
});
node.setProperties({
...props,
linestyle: currentLineStyle,
selectable: true,
movable: true,
editable: true
});
}
} catch (e) {
console.warn('设置线条节点编辑属性失败:', e);
}
// 修复:绘制完成后,保持编辑模式,让用户可以立即编辑刚绘制的线条
// 用户可以通过点击空白区域或按 ESC 来取消编辑,然后继续绘制新线条
try {
if (this.pencilTool && this.pencilTool.isEnabled() && this.showLineStylePanel) {
// 设置编辑模式,让用户可以选择和编辑刚绘制的线条
this.pencilTool.setEditMode(EditMode.EditNode);
this.pencilTool.editNode(node);
this.selectedShape = node;
}
} catch (e) {
console.warn('设置线条编辑模式失败:', e);
}
this.requestRepaint();
});
}
......@@ -7449,40 +8040,60 @@ export default {
}
toolManager.insert(0, this.pencilTool);
// 在启用工具前确保底部绑定的是当前索引
await this.assertBottomPipelineCurrent();
// 关键修复:激活线条工具时,确保底部 widget 立即绑定当前 pipeline 并重绘,避免短暂显示上一道
try {
if (this._seismicWidgetBottom && this.pipelineBottom) {
try { this._seismicWidgetBottom.setPipeline(this.pipelineBottom); } catch (e) { }
try { this._seismicWidgetBottom.invalidate && this._seismicWidgetBottom.invalidate(); } catch (e) { }
requestAnimationFrame(() => { try { this._seismicWidgetBottom.invalidate && this._seismicWidgetBottom.invalidate(); } catch (e) { } });
}
} catch (e) { /* ignore */ }
this.pencilTool.setEnabled(true);
// 同步启用底部线条工具
if (this.pencilToolBottom && this._seismicWidgetBottom) {
try {
const tm = this._seismicWidgetBottom.getTool && this._seismicWidgetBottom.getTool();
if (tm) {
// 暂时冻结 widget 更新,避免刷新导致闪烁
try {
if (this._seismicWidgetBottom.setOptions) {
this._seismicWidgetBottom.setOptions({ 'freezeupdate': true });
}
} catch (e) { }
// 关键修复:先禁用并移除文本工具,避免工具冲突
if (this.annotationToolBottom) {
try {
this.annotationToolBottom.setEnabled(false);
this.annotationToolBottom.editNode(null);
tm.remove(this.annotationToolBottom);
} catch (e) { }
}
// 移除并重新插入线条工具,确保它在最前面
try { tm.remove(this.pencilToolBottom); } catch (e) { }
tm.insert(0, this.pencilToolBottom);
// 确保线条工具设置为创建模式
this.pencilToolBottom.setMode(PaintMode.Pencil);
this.pencilToolBottom.setEditMode(EditMode.Create);
this.pencilToolBottom.setEnabled(true);
// 恢复 widget 更新
try {
if (this._seismicWidgetBottom.setOptions) {
this._seismicWidgetBottom.setOptions({ 'freezeupdate': false });
}
} catch (e) { }
}
this.pencilToolBottom.setEnabled(true);
} catch (e) { }
} catch (e) {
// 确保即使出错也恢复更新
try {
if (this._seismicWidgetBottom && this._seismicWidgetBottom.setOptions) {
this._seismicWidgetBottom.setOptions({ 'freezeupdate': false });
}
} catch (e2) { }
}
}
// 确保底部仍绑定当前数据
this.refreshBottomDisplay();
await this.assertBottomPipelineCurrent();
// 再次校验,若仍被外部影响,强制更正
await this.assertBottomPipelineCurrent();
},
deactivatePencilTool() {
this.showLineStylePanel = false;
if (this.pencilTool) {
this.pencilTool.setEnabled(false);
const widget = this.plots.getRoot();
// 修复:如果 plots 为 null,直接使用 _seismicWidget
const widget = (this.plots && this.plots.getRoot) ? this.plots.getRoot() : this._seismicWidget;
if (widget && widget.getTool()) {
try {
widget.getTool().remove(this.pencilTool);
......@@ -7540,19 +8151,12 @@ export default {
}
if (this.$refs.plot2) {
this.$refs.plot2.addEventListener('contextmenu', this.showContextMenu);
// 保守修复:在进入/离开底部画布时强制重绘,避免显示旧帧
const bottomEnter = () => { try { this._seismicWidgetBottom && this._seismicWidgetBottom.invalidate && this._seismicWidgetBottom.invalidate(); } catch (e) { } };
const bottomLeave = () => { try { this._seismicWidgetBottom && this._seismicWidgetBottom.invalidate && this._seismicWidgetBottom.invalidate(); } catch (e) { } };
try {
this.$refs.plot2.removeEventListener('mouseenter', bottomEnter);
this.$refs.plot2.removeEventListener('mouseleave', bottomLeave);
} catch (e) { }
try {
this.$refs.plot2.addEventListener('mouseenter', bottomEnter);
this.$refs.plot2.addEventListener('mouseleave', bottomLeave);
// 在点击底部画布时强校验绑定的数据是否为当前索引
this.$refs.plot2.addEventListener('mousedown', () => this.assertBottomPipelineCurrent());
} catch (e) { }
// 移除 mouseenter/mouseleave 事件监听器,避免频繁刷新导致闪烁
// 这些监听器会在鼠标移入/移出时触发刷新,导致图闪烁
// 在点击底部画布时强校验绑定的数据是否为当前索引
// 移除 mousedown 事件监听器,避免每次点击都触发刷新导致闪烁
// 在切换下一道时已经在 loadCurrentSegy 中调用了 assertBottomPipelineCurrent
// 不需要在每次点击时都检查
}
// document 的 click 事件只需要绑定一次
if (!this._contextMenuClickBound) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment