Commit ea809f6d by zhaopanyu

zpy

parent 5ab506fd
......@@ -13,7 +13,7 @@
<!-- 右侧按钮组 -->
<div class="toolbar-right">
<div class="color-maps">
<el-select v-model="currentColorMap" @change="switchColorMap" size="small" style="width: 160px;">
<el-select v-model="currentColorMap" @change="switchColorMap" size="small">
<el-option v-for="map in colorMaps" :key="map" :label="map" :value="map">
</el-option>
</el-select>
......@@ -21,6 +21,7 @@
<toolbar-controls :plots="plots" :data-loaded="isWidgetReady" :show-line-style-panel="showLineStylePanel"
@toggleLineStylePanel="toggleLineStylePanel" @exporting="exporting = $event"
@closePrintDialog="showPrintDialog = false" />
<el-tooltip content="绘制文本" placement="bottom" effect="light">
<el-button @click="toggleDrawText" :class="{ 'active': isDrawingText }">
<i class="el-icon-edit-outline"></i>
......@@ -232,6 +233,7 @@ import { Path } from '@int/geotoolkit/scene/shapes/Path';
import { LINE_PATTERNS, FILL_PATTERNS, TEXT_PATTERNS, LINESTYLE_PATTERNS, IMAGE_PATTERNS, LS_KEYS, FS_KEYS, TS_KEYS } from '@/api/Patterns.js';
import { SizeMode } from '@int/geotoolkit/scene/shapes/Text';
import { RgbaColor } from '@int/geotoolkit/util/RgbaColor';
import { NormalizationType } from '@int/geotoolkit/seismic/pipeline/NormalizationType';
// 导入新的组件
import ToolbarControls from '@/components/ToolbarControls.vue';
import LineStylePanel from '@/components/LineStylePanel.vue';
......@@ -338,7 +340,7 @@ export default {
colorMaps: ['CustomGrayScale', 'CustomRedScale'], // 可用的颜色映射
textStyle: {
color: '#000000',
size: 12,
size: 22,
font: 'Sans-serif',
bold: false,
italic: false,
......@@ -426,6 +428,7 @@ export default {
clipboard: null, // 用于存储复制的路径
undoStack: [], // 撤销栈
redoStack: [], // 重做栈
_headers: [], // 添加这一行
}
},
mounted() {
......@@ -503,6 +506,9 @@ export default {
}
try {
// 确保 _headers 被重置
this._headers = [];
new SegyReader(file, new StandardSegyFormat(), -6)
.loadMetaData((reader) => {
if (reader instanceof Error) {
......@@ -510,6 +516,32 @@ export default {
console.error(this.loadingError);
return;
}
// 获取头信息字段
const knownHeaders = reader.getTraceHeaderFields();
let cdpHeader = null;
// 确保 knownHeaders 存在且是数组
if (knownHeaders && Array.isArray(knownHeaders)) {
knownHeaders.forEach((field) => {
if (field && field.getName) {
if (field.getName() === 'CDP') {
cdpHeader = field;
}
this._headers.push({
'visible': field.getName() === 'CDP',
'name': field.getName(),
'color': 'black'
});
}
});
}
// 如果没有CDP字段,使用第一个可用字段
if (cdpHeader == null && this._headers.length > 0) {
this._headers[0].visible = true;
}
reader.readDataSetStatistics((reader, statistics) => {
try {
if (!statistics) {
......@@ -552,7 +584,25 @@ export default {
pipeline.setColorMap(colorMap);
}
pipeline.setPlotType({ 'Wiggle': false, 'InterpolatedDensity': true });
// 优化pipeline设置
pipeline.setOptions({
'normalization': {
'type': NormalizationType.RMS,
'scale': 0.4 // 增加scale以提高对比度
},
'plot': {
'type': {
'Wiggle': false,
'InterpolatedDensity': true,
'SimpleDensity': false
},
'decimationSpacing': 1, // 减小decimationSpacing以提高精度
'interpolation': {
'type': 'Linear', // 使用线性插值
'factor': 1 // 插值因子
}
}
});
if (this.widget) {
try {
......@@ -563,6 +613,23 @@ export default {
this.widget.setPipeline(pipeline);
this.widget.fitToBounds();
this.initAnnotationTools(this.widget);
// 在widget中配置坐标轴
this.widget.setOptions({
'axes': {
'samples': { // Y轴
'title': {
'visible': false
}
},
'headers': { // X轴
'fields': this._headers,
'options': {
'minimumSpan': 100
}
}
}
});
} catch (error) {
this.loadingError = `设置widget属性失败: ${error.message}`;
console.error('Error configuring widget:', error);
......@@ -583,8 +650,8 @@ export default {
}
})
.catch(error => {
// this.loadingError = `获取地震数据失败: ${error.message}`;
// console.error('Error fetching seismic data:', error);
this.loadingError = `获取地震数据失败: ${error.message}`;
console.error('Error fetching seismic data:', error);
});
},
......@@ -739,26 +806,95 @@ export default {
this.showTextStylePanel = this.isDrawingText;
if (this.isDrawingText) {
// 确保文本大小为22px
this.textStyle.size = 22;
// 创建完整的字体字符串,确保包含字体大小
const fontString = `${this.textStyle.bold ? 'bold ' : ''}${this.textStyle.italic ? 'italic ' : ''}${this.textStyle.size}px ${this.textStyle.font}`;
// 先设置属性
this.annotationTool.setProperties({
const textProperties = {
'editmode': EditMode.Create,
'mode': PaintMode.Text,
'node': {
'textstyle': new TextStyle({
color: this.textStyle.color,
size: this.textStyle.size,
font: this.textStyle.font,
alignment: this.textStyle.align
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
'autofocus': true,
'sizemode': this.textStyle.fixedFont ?
(SizeMode.FixedWidth | SizeMode.FixedHeight) :
SizeMode.WrappedWidth
}
};
console.log('文本绘制工具配置:', textProperties);
this.annotationTool.setProperties(textProperties);
// 添加事件监听器来打印文本绘制数据
this.annotationTool.addListener(EditEvents.Start, (tool, command) => {
const node = command.getNode();
const textStyle = node.getTextStyle ? node.getTextStyle() : null;
console.log('开始绘制文本:', {
tool: tool.getMode(),
node: node,
properties: node.getProperties(),
textStyle: textStyle,
fontSize: textStyle ? textStyle.size || textStyle.font : this.textStyle.size
});
});
this.annotationTool.addListener(EditEvents.Change, (tool, event) => {
const node = tool.getShape();
if (node) {
const textStyle = node.getTextStyle ? node.getTextStyle() : null;
console.log('文本绘制更新:', {
properties: node.getProperties(),
bounds: node.getBounds ? node.getBounds() : null,
textStyle: textStyle,
fontSize: textStyle ? textStyle.size || textStyle.font : this.textStyle.size
});
}
});
this.annotationTool.addListener(EditEvents.End, (tool, node) => {
if (node) {
let text = '';
if (typeof node.getText === 'function') {
text = node.getText();
} else if (node.text) {
text = node.text;
} else if (node.getProperties && node.getProperties().text) {
text = node.getProperties().text;
}
const textStyle = node.getTextStyle ? node.getTextStyle() : null;
console.log('文本绘制完成:', {
properties: node.getProperties(),
text: text,
bounds: node.getBounds ? node.getBounds() : null,
textStyle: textStyle,
fontSize: textStyle ? textStyle.size || textStyle.font : this.textStyle.size,
currentTextStyle: this.textStyle
});
}
});
// 最后启用工具
this.annotationTool.setEnabled(true);
} else {
this.annotationTool.setEnabled(false);
......@@ -1144,42 +1280,68 @@ export default {
return;
}
const colors = new Array(255); // 创建255个颜色点以实现平滑渐变
const colors = new Array(255);
try {
// 白色到黑色的平滑渐变
// 前55%保持较亮的白色区域
interpolate(colors, 0, 140, {
// 优化后的灰度映射 - 增强对比度
// 白色区域 (0-15%)
interpolate(colors, 0, 38, {
A: 255,
R: 255,
G: 255,
B: 255
}, {
A: 255,
R: 230,
G: 230,
B: 230
});
// 浅灰过渡区域 (15-40%)
interpolate(colors, 39, 101, {
A: 255,
R: 230,
G: 230,
B: 230
}, {
A: 255,
R: 254,
G: 254,
B: 254
R: 180,
G: 180,
B: 180
});
// 中灰过渡区域 (40-60%)
interpolate(colors, 102, 152, {
A: 255,
R: 180,
G: 180,
B: 180
}, {
A: 255,
R: 240,
G: 240,
B: 240
R: 120,
G: 120,
B: 120
});
// 中间过渡区域(约25%)
interpolate(colors, 141, 203, {
// 深灰过渡区域 (60-85%)
interpolate(colors, 153, 216, {
A: 255,
R: 240,
G: 240,
B: 240
R: 120,
G: 120,
B: 120
}, {
A: 255,
R: 150,
G: 150,
B: 150
R: 60,
G: 60,
B: 60
});
// 最后的深色渐变区域(约20%)
interpolate(colors, 204, 254, {
// 黑色区域 (85-100%)
interpolate(colors, 217, 254, {
A: 255,
R: 150,
G: 150,
B: 150
R: 60,
G: 60,
B: 60
}, {
A: 255,
R: 0,
......@@ -1203,25 +1365,25 @@ export default {
const colors = new Array(255);
try {
// 第1段:251,20,10 到 219,138,100 (约20%)
interpolate(colors, 0, 51, {
// 第1段:起始红色到红棕色 (0-20%)
interpolate(colors, 0, 42, {
A: 255,
R: 251,
G: 20,
B: 10
R: 246,
G: 40,
B: 26
}, {
A: 255,
R: 219,
G: 138,
B: 100
R: 221,
G: 139,
B: 102
});
// 第2段:219,138,100 到 215,198,146 (约15%)
interpolate(colors, 52, 90, {
// 第2段:红棕色到浅褐色 (20-40%)
interpolate(colors, 43, 84, {
A: 255,
R: 219,
G: 138,
B: 100
R: 221,
G: 139,
B: 102
}, {
A: 255,
R: 215,
......@@ -1229,8 +1391,8 @@ export default {
B: 146
});
// 第3段:215,198,146 到 251,250,255 (约20%)
interpolate(colors, 91, 130, {
// 第3段:浅褐色到白色 (40-60%)
interpolate(colors, 85, 126, {
A: 255,
R: 215,
G: 198,
......@@ -1242,43 +1404,43 @@ export default {
B: 255
});
// 第4段:251,250,255 到 176,177,225 (约20%)
interpolate(colors, 131, 181, {
// 第4段:白色到灰紫色 (60-75%)
interpolate(colors, 127, 168, {
A: 255,
R: 251,
G: 250,
B: 255
}, {
A: 255,
R: 176,
G: 177,
B: 225
R: 110,
G: 110,
B: 138
});
// 第5段:176,177,225 到 136,136,164 (约10%)
interpolate(colors, 182, 206, {
// 第5段:灰紫色到深灰 (75-90%)
interpolate(colors, 169, 210, {
A: 255,
R: 176,
G: 177,
B: 225
R: 110,
G: 110,
B: 138
}, {
A: 255,
R: 136,
G: 136,
B: 164
R: 50,
G: 49,
B: 54
});
// 第6段:136,136,164 到 22,22,22 (约25%)
interpolate(colors, 207, 254, {
// 第6段:保持深灰到结束 (90-100%)
interpolate(colors, 211, 254, {
A: 255,
R: 136,
G: 136,
B: 164
R: 50,
G: 49,
B: 54
}, {
A: 255,
R: 22,
G: 22,
B: 22
R: 50,
G: 49,
B: 54
});
map.set(colors);
......@@ -1323,7 +1485,7 @@ export default {
pattern: this.getProcessedLinePattern(this.lineStyle.pattern)
});
this.pencilTool = new Paint({
const pencilProperties = {
'layer': widget.getManipulatorLayer(),
'mode': PaintMode.Pencil,
'editmode': EditMode.Create,
......@@ -1333,30 +1495,45 @@ export default {
'movable': true,
'editable': true
}
});
};
console.log('线条绘制工具配置:', pencilProperties);
this.pencilTool = new Paint(pencilProperties);
// 添加事件监听
this.pencilTool
.addListener(EditEvents.Start, (tool, command) => {
console.log('开始绘制', command.getNode());
this.annotations.addChild(command.getNode());
const node = command.getNode();
console.log('开始绘制线条:', {
tool: tool.getMode(),
properties: node.getProperties()
});
this.annotations.addChild(node);
})
.addListener(EditEvents.Change, (tool, event) => {
console.log('绘制中');
const node = tool.getShape();
if (node) {
console.log('线条绘制更新:', {
properties: node.getProperties(),
bounds: node.getBounds ? node.getBounds() : null
});
}
})
.addListener(EditEvents.End, (tool, node) => {
console.log('绘制结束', node);
if (node) {
console.log('线条绘制完成:', {
properties: node.getProperties(),
bounds: node.getBounds ? node.getBounds() : null
});
}
if (node && this.annotations.indexOfChild(node) === -1) {
this.annotations.addChild(node);
}
// 绘制结束后切换到编辑模式而不是停用工具
tool.setEditMode(EditMode.EditNode);
tool.editNode(node);
// 记录当前选中的形状
this.selectedShape = node;
this.requestRepaint();
});
}
......
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