From 1d501c80ecab74e725fe3d9369317e57b7545c45 Mon Sep 17 00:00:00 2001 From: freefire <97975089@qq.com> Date: Mon, 13 Jan 2025 23:34:41 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E4=BC=98=E5=8C=96log=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.aardio | 34 ++++++++++++++++++++++++++-------- script/heatmap_script.R | 2 +- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/main.aardio b/main.aardio index fe14271..3361e94 100644 --- a/main.aardio +++ b/main.aardio @@ -1,13 +1,13 @@ import fonts.fontAwesome; import win.ui; /*DSG{{*/ -mainForm = win.form(text="CircosHeatmap-aardio";right=800;bottom=600;bgcolor=16777215) +mainForm = win.form(text="CircosHeatmap-aardio"; right=1000; bottom=700; bgcolor=16777215) mainForm.add( -btnRun={cls="plus";text="生成pdf";left=684;top=413;right=791;bottom=448;align="left";border={color=-16777216;width=1};db=1;dr=1;font=LOGFONT(h=-16;name='微软雅黑');iconStyle={align="left";font=LOGFONT(h=-13;name='FontAwesome');padding={left=15}};iconText='\uF08B';textPadding={left=32};z=3}; -btnSelectFile={cls="plus";text="数据源";left=569;top=413;right=676;bottom=448;align="left";border={color=-16777216;width=1};db=1;dr=1;font=LOGFONT(h=-16;name='微软雅黑');iconStyle={align="left";font=LOGFONT(h=-13;name='FontAwesome');padding={left=18}};iconText='\uF15C';textPadding={left=35};z=2}; -editConsole={cls="edit";left=10;top=459;right=791;bottom=591;bgcolor=4274224;border=1;color=15326936;db=1;dl=1;dr=1;hscroll=1;multiline=1;readonly=1;vscroll=1;z=5}; -editRScript={cls="edit";left=10;top=10;right=791;bottom=401;border=1;color=4473924;db=1;dl=1;dr=1;dt=1;hscroll=1;multiline=1;vscroll=1;z=4}; -inputFile={cls="plus";left=10;top=413;right=562;bottom=448;align="left";border={color=-16736064;width=1};db=1;dl=1;dr=1;editable="edit";font=LOGFONT(h=-13);textPadding={left=5;top=8;right=5;bottom=2};z=1} + btnRun={cls="plus"; text="生成pdf"; left=820; top=660; right=920; bottom=690; align="left"; border={color=-16777216; width=1}; db=1; dr=1; font=LOGFONT(h=-16; name='微软雅黑'); iconStyle={align="left"; font=LOGFONT(h=-13; name='FontAwesome'); padding={left=15}}; iconText='\uF08B'; textPadding={left=32}; z=3}; + btnSelectFile={cls="plus"; text="数据源"; left=710; top=660; right=810; bottom=690; align="left"; border={color=-16777216; width=1}; db=1; dr=1; font=LOGFONT(h=-16; name='微软雅黑'); iconStyle={align="left"; font=LOGFONT(h=-13; name='FontAwesome'); padding={left=18}}; iconText='\uF15C'; textPadding={left=35}; z=2}; + editConsole={cls="richedit"; left=10; top=510; right=990; bottom=650; bgcolor=4274224; color=15326936; db=1; dl=1; dr=1; hscroll=1; multiline=1; readonly=1; vscroll=1; z=5}; + editRScript={cls="edit"; left=10; top=10; right=990; bottom=500; border=1; color=4473924; db=1; dl=1; dr=1; dt=1; hscroll=1; multiline=1; vscroll=1; z=4}; + inputFile={cls="plus"; left=10; top=660; right=700; bottom=690; align="left"; border={color=-16736064; width=1}; db=1; dl=1; dr=1; editable="edit"; font=LOGFONT(h=-13); textPadding={left=5; top=8; right=5; bottom=2}; z=1} ) /*}}*/ @@ -42,6 +42,12 @@ import fsys.dlg; mainForm.editRScript.print($"\script\heatmap_script.R"); +var initEditConsole = function(){ + mainForm.editConsole.text = null; + mainForm.editConsole.appendText( textColor = 0xF5D971, point = 10, "当前仅支持 csv 格式的数据源。如果您的数据是其他格式(如 xls、xlsx),可以将其转换为 csv 格式后再使用。" ); +} +initEditConsole(); + // 选择文件按钮点击事件 mainForm.btnSelectFile.oncommand = function(id, event) { var filePath = fsys.dlg.open("CSV 文件|*.csv||",, "选择输入文件"); @@ -64,10 +70,22 @@ mainForm.btnRun.oncommand = function(id, event) { console.log("请选择PDF文件的保存路径!"); return; } - + + initEditConsole(); + // 执行 R 脚本 var out = process.r.exec(mainForm.editRScript.text, inputFilePath, outputFilePath); - mainForm.editConsole.print(out); + mainForm.editConsole.appendLink('\r\n'); + mainForm.editConsole.appendText(out); + + out_lines = string.split(out, '\r\n'); + if (out_lines[#out_lines] == outputFilePath) { + mainForm.editConsole.appendLink('\r\n'); + mainForm.editConsole.appendText( textColor = 0x37D437, point = 10, "热图已成功保存至:" + outputFilePath); + } + // 滚动到最后一行 + mainForm.editConsole.vScroll(); + } //显示版本号 diff --git a/script/heatmap_script.R b/script/heatmap_script.R index 32c8af6..f0311c5 100644 --- a/script/heatmap_script.R +++ b/script/heatmap_script.R @@ -81,4 +81,4 @@ circos.clear() # 关闭PDF设备 dev.off() -message("热图已成功保存至: ", output_pdf) \ No newline at end of file +message(output_pdf) \ No newline at end of file