Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -426,6 +426,77 @@ with gr.Blocks(title=COMPANY_NAME) as demo:
|
|
| 426 |
submit_btn = gr.Button("✅ 提交 RZF 訂單", variant="primary")
|
| 427 |
order_status = gr.Textbox(label="通知", interactive=False)
|
| 428 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 429 |
with gr.Tab("📐 同軸度計算"):
|
| 430 |
gr.Markdown("## 📐 雷射同軸度與 mRad 雙向換算")
|
| 431 |
|
|
@@ -567,77 +638,6 @@ with gr.Blocks(title=COMPANY_NAME) as demo:
|
|
| 567 |
4. **全角發散** (業界標準):$\\theta_{full} = 2 \\times \\theta_{half}$
|
| 568 |
""")
|
| 569 |
|
| 570 |
-
with gr.Tab("🎯 光束焦距收斂計算"):
|
| 571 |
-
gr.Markdown("## 🎯 計算焦距光斑收斂角度 (Focus Beam Convergence)")
|
| 572 |
-
|
| 573 |
-
# 加入焦距光斑雷射模組示意圖 (內建 SVG)
|
| 574 |
-
gr.HTML("""
|
| 575 |
-
<div style="display: flex; justify-content: center; align-items: center; margin-bottom: 20px; background-color: #fcfcfc; padding: 15px; border-radius: 8px; border: 1px solid #eee;">
|
| 576 |
-
<svg width="500" height="200" viewBox="0 0 500 200" xmlns="http://www.w3.org/2000/svg">
|
| 577 |
-
<!-- Laser Module & Lens -->
|
| 578 |
-
<rect x="10" y="80" width="70" height="40" rx="5" fill="#607D8B" stroke="#455A64" stroke-width="2"/>
|
| 579 |
-
<rect x="80" y="85" width="15" height="30" rx="2" fill="#37474F"/>
|
| 580 |
-
<ellipse cx="105" cy="100" rx="5" ry="30" fill="rgba(135, 206, 235, 0.6)" stroke="#0288D1" stroke-width="1.5"/> <!-- Lens -->
|
| 581 |
-
<text x="45" y="105" fill="white" font-size="12" font-weight="bold" text-anchor="middle" font-family="sans-serif">LASER</text>
|
| 582 |
-
|
| 583 |
-
<!-- Converging Beam (Blue) -->
|
| 584 |
-
<polygon points="105,70 105,130 380,110 380,90" fill="rgba(33, 150, 243, 0.2)" stroke="#1976D2" stroke-width="1.5"/>
|
| 585 |
-
|
| 586 |
-
<!-- Center Line -->
|
| 587 |
-
<line x1="105" y1="100" x2="480" y2="100" stroke="#9E9E9E" stroke-width="1.5" stroke-dasharray="5,5"/>
|
| 588 |
-
|
| 589 |
-
<!-- D1 (Laser Output) Plane & Dimension -->
|
| 590 |
-
<line x1="105" y1="30" x2="105" y2="170" stroke="#388E3C" stroke-width="1" stroke-dasharray="3,3"/>
|
| 591 |
-
<line x1="115" y1="70" x2="115" y2="130" stroke="#388E3C" stroke-width="2"/>
|
| 592 |
-
<text x="105" y="25" fill="#388E3C" font-size="12" text-anchor="middle" font-family="sans-serif">出光面</text>
|
| 593 |
-
<text x="125" y="105" fill="#388E3C" font-size="12" font-weight="bold" font-family="sans-serif">d1</text>
|
| 594 |
-
|
| 595 |
-
<!-- D2 (Focal Spot) Plane & Dimension -->
|
| 596 |
-
<line x1="380" y1="30" x2="380" y2="170" stroke="#388E3C" stroke-width="1" stroke-dasharray="3,3"/>
|
| 597 |
-
<line x1="390" y1="90" x2="390" y2="110" stroke="#388E3C" stroke-width="2"/>
|
| 598 |
-
<text x="380" y="25" fill="#388E3C" font-size="12" text-anchor="middle" font-family="sans-serif">焦平面</text>
|
| 599 |
-
<text x="400" y="105" fill="#388E3C" font-size="12" font-weight="bold" font-family="sans-serif">d2</text>
|
| 600 |
-
|
| 601 |
-
<!-- Focal Length L -->
|
| 602 |
-
<line x1="105" y1="185" x2="380" y2="185" stroke="#555" stroke-width="1"/>
|
| 603 |
-
<line x1="105" y1="180" x2="105" y2="190" stroke="#555" stroke-width="1"/>
|
| 604 |
-
<line x1="380" y1="180" x2="380" y2="190" stroke="#555" stroke-width="1"/>
|
| 605 |
-
<text x="242" y="180" fill="#555" font-size="13" text-anchor="middle" font-family="sans-serif">焦距 (L)</text>
|
| 606 |
-
|
| 607 |
-
<!-- Angle notation -->
|
| 608 |
-
<path d="M 280 100 A 100 100 0 0 0 278 111" fill="none" stroke="#D32F2F" stroke-width="1"/>
|
| 609 |
-
<path d="M 280 100 A 100 100 0 0 1 278 89" fill="none" stroke="#D32F2F" stroke-width="1"/>
|
| 610 |
-
<text x="265" y="104" fill="#D32F2F" font-size="12" font-weight="bold" font-family="sans-serif">θ</text>
|
| 611 |
-
</svg>
|
| 612 |
-
</div>
|
| 613 |
-
""")
|
| 614 |
-
|
| 615 |
-
with gr.Row():
|
| 616 |
-
with gr.Column():
|
| 617 |
-
gr.Markdown("### 輸入焦距與光斑參數")
|
| 618 |
-
size_type_focus = gr.Radio(["直徑 (Diameter)", "半徑 (Radius)"], label="光斑尺寸類型", value="直徑 (Diameter)")
|
| 619 |
-
|
| 620 |
-
with gr.Row():
|
| 621 |
-
focal_input = gr.Number(label="焦距長度 (mm)", value=50.0)
|
| 622 |
-
focal_unit = gr.Radio(["毫米 (mm)", "公分 (cm)", "公尺 (m)"], label="距離單位", value="毫米 (mm)")
|
| 623 |
-
|
| 624 |
-
with gr.Row():
|
| 625 |
-
d1_focus_in = gr.Number(label="雷射出光尺寸 (d1) mm", value=3.0)
|
| 626 |
-
d2_focus_in = gr.Number(label="焦距光斑尺寸 (d2) mm", value=0.5)
|
| 627 |
-
|
| 628 |
-
focus_calc_btn = gr.Button("開始計算收斂角度", variant="primary")
|
| 629 |
-
focus_out_text = gr.Markdown("等待輸入...")
|
| 630 |
-
|
| 631 |
-
with gr.Column():
|
| 632 |
-
focus_out_plot = gr.Plot(label="Focus Beam Convergence Plot")
|
| 633 |
-
gr.Markdown("""
|
| 634 |
-
**計算原理說明**:
|
| 635 |
-
1. 設定雷射出光為起始點,焦平面光斑為終點,測試距離為焦距 $L$。
|
| 636 |
-
2. 計算光束半徑收斂差:${\Delta r = r_1 - r_2}$
|
| 637 |
-
3. **半收斂角**:$\\theta_{half} = \\arctan(\\frac{\\Delta r}{L})$
|
| 638 |
-
4. **全收斂角**:$\\theta_{full} = 2 \\times \\theta_{half}$
|
| 639 |
-
""")
|
| 640 |
-
|
| 641 |
# 新增:線斑角度計算分頁
|
| 642 |
with gr.Tab("📏 線斑角度計算"):
|
| 643 |
gr.Markdown("## 📏 測量線光斑長度計算發散角度 (Line Laser Angle)")
|
|
|
|
| 426 |
submit_btn = gr.Button("✅ 提交 RZF 訂單", variant="primary")
|
| 427 |
order_status = gr.Textbox(label="通知", interactive=False)
|
| 428 |
|
| 429 |
+
with gr.Tab("🎯 光束焦距收斂計算"):
|
| 430 |
+
gr.Markdown("## 🎯 計算焦距光斑收斂角度 (Focus Beam Convergence)")
|
| 431 |
+
|
| 432 |
+
# 加入焦距光斑雷射模組示意圖 (內建 SVG)
|
| 433 |
+
gr.HTML("""
|
| 434 |
+
<div style="display: flex; justify-content: center; align-items: center; margin-bottom: 20px; background-color: #fcfcfc; padding: 15px; border-radius: 8px; border: 1px solid #eee;">
|
| 435 |
+
<svg width="500" height="200" viewBox="0 0 500 200" xmlns="http://www.w3.org/2000/svg">
|
| 436 |
+
<!-- Laser Module & Lens -->
|
| 437 |
+
<rect x="10" y="80" width="70" height="40" rx="5" fill="#607D8B" stroke="#455A64" stroke-width="2"/>
|
| 438 |
+
<rect x="80" y="85" width="15" height="30" rx="2" fill="#37474F"/>
|
| 439 |
+
<ellipse cx="105" cy="100" rx="5" ry="30" fill="rgba(135, 206, 235, 0.6)" stroke="#0288D1" stroke-width="1.5"/> <!-- Lens -->
|
| 440 |
+
<text x="45" y="105" fill="white" font-size="12" font-weight="bold" text-anchor="middle" font-family="sans-serif">LASER</text>
|
| 441 |
+
|
| 442 |
+
<!-- Converging Beam (Blue) -->
|
| 443 |
+
<polygon points="105,70 105,130 380,110 380,90" fill="rgba(33, 150, 243, 0.2)" stroke="#1976D2" stroke-width="1.5"/>
|
| 444 |
+
|
| 445 |
+
<!-- Center Line -->
|
| 446 |
+
<line x1="105" y1="100" x2="480" y2="100" stroke="#9E9E9E" stroke-width="1.5" stroke-dasharray="5,5"/>
|
| 447 |
+
|
| 448 |
+
<!-- D1 (Laser Output) Plane & Dimension -->
|
| 449 |
+
<line x1="105" y1="30" x2="105" y2="170" stroke="#388E3C" stroke-width="1" stroke-dasharray="3,3"/>
|
| 450 |
+
<line x1="115" y1="70" x2="115" y2="130" stroke="#388E3C" stroke-width="2"/>
|
| 451 |
+
<text x="105" y="25" fill="#388E3C" font-size="12" text-anchor="middle" font-family="sans-serif">出光面</text>
|
| 452 |
+
<text x="125" y="105" fill="#388E3C" font-size="12" font-weight="bold" font-family="sans-serif">d1</text>
|
| 453 |
+
|
| 454 |
+
<!-- D2 (Focal Spot) Plane & Dimension -->
|
| 455 |
+
<line x1="380" y1="30" x2="380" y2="170" stroke="#388E3C" stroke-width="1" stroke-dasharray="3,3"/>
|
| 456 |
+
<line x1="390" y1="90" x2="390" y2="110" stroke="#388E3C" stroke-width="2"/>
|
| 457 |
+
<text x="380" y="25" fill="#388E3C" font-size="12" text-anchor="middle" font-family="sans-serif">焦平面</text>
|
| 458 |
+
<text x="400" y="105" fill="#388E3C" font-size="12" font-weight="bold" font-family="sans-serif">d2</text>
|
| 459 |
+
|
| 460 |
+
<!-- Focal Length L -->
|
| 461 |
+
<line x1="105" y1="185" x2="380" y2="185" stroke="#555" stroke-width="1"/>
|
| 462 |
+
<line x1="105" y1="180" x2="105" y2="190" stroke="#555" stroke-width="1"/>
|
| 463 |
+
<line x1="380" y1="180" x2="380" y2="190" stroke="#555" stroke-width="1"/>
|
| 464 |
+
<text x="242" y="180" fill="#555" font-size="13" text-anchor="middle" font-family="sans-serif">焦距 (L)</text>
|
| 465 |
+
|
| 466 |
+
<!-- Angle notation -->
|
| 467 |
+
<path d="M 280 100 A 100 100 0 0 0 278 111" fill="none" stroke="#D32F2F" stroke-width="1"/>
|
| 468 |
+
<path d="M 280 100 A 100 100 0 0 1 278 89" fill="none" stroke="#D32F2F" stroke-width="1"/>
|
| 469 |
+
<text x="265" y="104" fill="#D32F2F" font-size="12" font-weight="bold" font-family="sans-serif">θ</text>
|
| 470 |
+
</svg>
|
| 471 |
+
</div>
|
| 472 |
+
""")
|
| 473 |
+
|
| 474 |
+
with gr.Row():
|
| 475 |
+
with gr.Column():
|
| 476 |
+
gr.Markdown("### 輸入焦距與光斑參數")
|
| 477 |
+
size_type_focus = gr.Radio(["直徑 (Diameter)", "半徑 (Radius)"], label="光斑尺寸類型", value="直徑 (Diameter)")
|
| 478 |
+
|
| 479 |
+
with gr.Row():
|
| 480 |
+
focal_input = gr.Number(label="焦距長度 (mm)", value=50.0)
|
| 481 |
+
focal_unit = gr.Radio(["毫米 (mm)", "公分 (cm)", "公尺 (m)"], label="距離單位", value="毫米 (mm)")
|
| 482 |
+
|
| 483 |
+
with gr.Row():
|
| 484 |
+
d1_focus_in = gr.Number(label="雷射出光尺寸 (d1) mm", value=3.0)
|
| 485 |
+
d2_focus_in = gr.Number(label="焦距光斑尺寸 (d2) mm", value=0.5)
|
| 486 |
+
|
| 487 |
+
focus_calc_btn = gr.Button("開始計算收斂角度", variant="primary")
|
| 488 |
+
focus_out_text = gr.Markdown("等待輸入...")
|
| 489 |
+
|
| 490 |
+
with gr.Column():
|
| 491 |
+
focus_out_plot = gr.Plot(label="Focus Beam Convergence Plot")
|
| 492 |
+
gr.Markdown("""
|
| 493 |
+
**計算原理說明**:
|
| 494 |
+
1. 設定雷射出光為起始點,焦平面光斑為終點,測試距離為焦距 $L$。
|
| 495 |
+
2. 計算光束半徑收斂差:${\Delta r = r_1 - r_2}$
|
| 496 |
+
3. **半收斂角**:$\\theta_{half} = \\arctan(\\frac{\\Delta r}{L})$
|
| 497 |
+
4. **全收斂角**:$\\theta_{full} = 2 \\times \\theta_{half}$
|
| 498 |
+
""")
|
| 499 |
+
|
| 500 |
with gr.Tab("📐 同軸度計算"):
|
| 501 |
gr.Markdown("## 📐 雷射同軸度與 mRad 雙向換算")
|
| 502 |
|
|
|
|
| 638 |
4. **全角發散** (業界標準):$\\theta_{full} = 2 \\times \\theta_{half}$
|
| 639 |
""")
|
| 640 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 641 |
# 新增:線斑角度計算分頁
|
| 642 |
with gr.Tab("📏 線斑角度計算"):
|
| 643 |
gr.Markdown("## 📏 測量線光斑長度計算發散角度 (Line Laser Angle)")
|