ก้าวไปอีกหนึ่งก้าวกับ XSection Plot

สวมวิญญานใหม่ด้วย PySide2

หลังจากผมคอมไพล์ XSection Plot ใหม่ด้วยสภาวะแวดล้อมพัฒนาของ Qt5 platform ด้วย PySide2 ผมเปลี่ยนลิขสิทธิ์ของโปรแกรมเดิมที่กำกวมออกมาฟรีสมบูรณ์แบบเหมือนกันกับ Surveyor Pocket Tools สามารถนำไปทำซ้ำแจกจ่ายได้ตามอัธยาศัย แต่ห้ามดัดแปลง ห้ามนำไปจำหน่ายหรือให้เช่า

XSection Plot
Copyright (C) Prajuab Riabroy. All Rights Reserved.

XSection Plot is free for use in any environment, including but not necessarily limited to: personal, academic, commercial, government, business, non-profit, and for-profit. "Free" in the preceding sentence means that there is no cost or charge associated with the installation and use of XSection Plot. 
Permission is hereby granted, free of charge, to any person obtaining a copy of this software (the "Software"), to use the Software without restriction, including the rights to use, copy, publish, and distribute the Software, and to permit persons to whom the Software is furnished to do so.

You may not modify, adapt, rent, lease, loan, sell, or create derivative works based upon the Software or any part thereof. 

The above copyright notice and this permission notice shall be included in all copies of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

แก้ไข bugs

นอกจากย้ายโค้ดมาใช้ PySide2 แล้ว ผมเลยถือโอกาสแก้บั๊กเล็กน้อยไปหลายอย่าง เช่น

  • เวลาคลิกขวาเพื่อเรียกเมนูในช่องป้อนข้อมูล โปรแกรมจะ terminate ทันที
  • ใน Section Layout ตรง Horizontal Grid เมื่อปรับ Distance from CL to left ไปแล้ว โปรแกรมไม่จำค่าใหม่
  • อื่นๆอีกเล็กน้อยประมาณสิบกว่าอย่าง

คอมไพล์และสร้างไฟล์ execute binary ด้วย PyInstaller

ตอนนี้โปรแกรมสนับสนุนทั้ง 32 บิตและ 64 บิต ผมใช้ PyCharm เป็นทูลส์ในการพัฒนา และเลือกได้ว่าจะใช้ 32 บิตหรือ 64 บิต เมื่อโปรแกรม stable แล้ว ก็จะสร้าง execute binary file ด้วย PyInstaller ตามสภาวะแวดล้อม ต้องทำสองครั้ง ครั้งแรก 32 บิตและครั้งที่สอง 64 บิต โดยแต่ละครั้งจะได้ไฟล์ exe, pyd, dll รวมถึงไลบรารีของไพทอนที่เราเรียกใช้ และที่สำคัญคือไลบรารีของ PySide2

ทำไฟล์ Setup ด้วย Inno Setup

ไฟล์ที่ได้จาก PyInstaller ทั้งหมด ผมจะนำมาสร้างไฟล์ Setup ด้วย Inno Setup เพื่อนเก่าที่ใช้กันมานมนาน มีดีเพียงพอที่จะสร้างไฟล์ Setup ได้ง่ายๆ มี options ให้เลือกพอสมควร สุดท้ายจะได้ไฟล์ Setup ที่เป็น Execute file ไฟล์เดียวพร้อมจะนำไปอัพโหลดให้ผู้ใช้นำไปใช้งานได้

ทดสอบโปรแกรมด้วยแบบรูปตัดตามยาว

ผมจะลองทดสอบโปรแกรมจากข้อมูล ความจริง XSection Plot คือโปรแกรมสร้างหรือช่วยเขียนรูปตัดตามขวาง แต่ยังพอเอามาประยุกต์ใช้กับ Long Profile ได้ แต่ไฟล์ข้อมูลส่วนใหญ่จะมีข้อมูลเพียงหนึ่ง Section เท่านั้นจะเริ่มจากไฟล์ข้อมูลของ Existing Ground Section ก่อนครับ ข้อมูลดังในกรอบข้างล่าง สามารถ copy ไป paste ในโปรแกรม text file editor เช่น Notepad ได้จากนั้น save ตั้ง extension เป็น gxml (ตัวอย่างผมตั้งชื่อว่า lake-road.gxml)

<root version="1.0">
  <!--Generated by XSection Plot-->
  <!--This data file is Existing ground section-->
  <Header>
    <AppName>XSection Plot</AppName>
    <Developer>Prajuab Riabroy</Developer>
    <Version>4.1.512</Version>
    <SectionType>Ground</SectionType>
    <DateCreated>2017-11-18 18:57:18.700532</DateCreated>
  </Header>
  <ProjectInfo>
    <ProjectName>Cantonment Lake</ProjectName>
    <ClientName></ClientName>
    <ContractorName></ContractorName>
    <DrawingTitle></DrawingTitle>
    <DrawnName></DrawnName>
    <ApprovedName></ApprovedName>
    <ClientApprovedName></ClientApprovedName>
    <CheckedName></CheckedName>
    <SurveyorName></SurveyorName>
    <SurveyedDate></SurveyedDate>
    <DrawingNo></DrawingNo>
    <SheetNo></SheetNo>
    <DrawingDate></DrawingDate>
    <Revision></Revision>
    <UseLocaleLanguage>False</UseLocaleLanguage>
    <MapTexts>
      <MapText Label="Client" Locale="เจ้าของโครงการ"/>
      <MapText Label="Contractor" Locale="ผู้รับจ้าง"/>
      <MapText Label="Drawn" Locale="เขียน"/>
      <MapText Label="Design" Locale="ออกแบบ"/>
      <MapText Label="Surveyor" Locale="ผู้สำรวจ"/>
      <MapText Label="Surveyed Date" Locale="วันที่สำรวจ"/>
      <MapText Label="Checked" Locale="ตรวจสอบ"/>
      <MapText Label="Approved" Locale="อนุมัติ"/>
      <MapText Label="Client Approved" Locale="ผู้คุมงานอนุมัติ"/>
      <MapText Label="Drawing No." Locale="แบบเลขที่"/>
      <MapText Label="Plotted Date" Locale="แบบวันที่"/>
      <MapText Label="Project" Locale="โครงการ"/>
      <MapText Label="Drawing Title" Locale="แผนที่แสดง"/>
      <MapText Label="Sheet No." Locale="แบบเลขที่"/>
      <MapText Label="Scale" Locale="มาตราส่วน"/>
      <MapText Label="Vertical" Locale="ทางดิ่ง"/>
      <MapText Label="Horizontal" Locale="ทางราบ"/>
      <MapText Label="Vertical Scale" Locale="มาตราส่วนทางดิ่ง"/>
      <MapText Label="Horizontal Scale" Locale="มาตราส่วนทางราบ"/>
      <MapText Label="Legend" Locale="สัญลักษณ์"/>
      <MapText Label="Note" Locale="หมายเหตุ"/>
      <MapText Label="Geodetic Information" Locale="ข้อมูลระบบพิกัด"/>
      <MapText Label="No." Locale="ครั้งที่"/>
      <MapText Label="Amendments" Locale="ความเห็น"/>
      <MapText Label="By" Locale="โดย"/>
      <MapText Label="Date" Locale="วันที่"/>
      <MapText Label="Revision" Locale="ครั้งที่แก้ไข"/>
    </MapTexts>
  </ProjectInfo>
  <SectionOptions>
    <VerticalScale>500.0</VerticalScale>
    <HorizontalScale>1000.0</HorizontalScale>
    <HozGridSpace>10.0</HozGridSpace>
    <VertGridSpace>2.0</VertGridSpace>
    <GridLineType>0</GridLineType>
    <CalcIntersection>True</CalcIntersection>
    <CalcArea>True</CalcArea>
    <TrimTypical>False</TrimTypical>
    <NumDecimalElev>3</NumDecimalElev>
    <NumDecimalDist>3</NumDecimalDist>
    <UseIntervalText>True</UseIntervalText>
    <IntervalDist>10.0</IntervalDist>
    <PrefixText>MSL</PrefixText>
    <PostfixText>MSL</PostfixText>
    <UsePostPrefix>1</UsePostPrefix>
    <UseOffsetElevFormat>2</UseOffsetElevFormat>
    <CalcPlotAreaCut>True</CalcPlotAreaCut>
    <CalcPlotAreaFill>True</CalcPlotAreaFill>
    <NumVertCLLeft>1</NumVertCLLeft>
    <NumVertCLRight>90</NumVertCLRight>
    <NumHozTopBottom>10</NumHozTopBottom>
    <LeftSideText>LT.</LeftSideText>
    <RightSideText>RT.</RightSideText>
    <StationText>Km.</StationText>
    <SelectedTBlock>2</SelectedTBlock>
    <NumSectionRows>1</NumSectionRows>
    <NumSectionColumns>1</NumSectionColumns>
    <SurveyType>0</SurveyType>
    <PlotTBlock>True</PlotTBlock>
    <SwapLeftAndRight>False</SwapLeftAndRight>
  </SectionOptions>
  <PageSetup>
    <Size>Custom</Size>
    <Width>930.0</Width>
    <Height>200.0</Height>
  </PageSetup>
  <Sections>
    <NumSections>1</NumSections>
    <Section Name="0+000">
      <XPositionOnPaper>47.2</XPositionOnPaper>
      <YPositionOnPaper>11.7</YPositionOnPaper>
      <TopGridElev>14.0</TopGridElev>
      <NumPoints>29</NumPoints>
      <Points>
        <Point Elevation="5.741" Offset="0.0"/>
        <Point Elevation="5.802" Offset="29.5"/>
        <Point Elevation="4.186" Offset="44.5"/>
        <Point Elevation="1.955" Offset="66.778"/>
        <Point Elevation="1.04" Offset="84.5"/>
        <Point Elevation="1.017" Offset="114.5"/>
        <Point Elevation="0.895" Offset="144.5"/>
        <Point Elevation="1.162" Offset="174.5"/>
        <Point Elevation="1.012" Offset="234.5"/>
        <Point Elevation="1.145" Offset="264.5"/>
        <Point Elevation="1.16" Offset="316.642"/>
        <Point Elevation="1.317" Offset="339.5"/>
        <Point Elevation="1.619" Offset="386.947"/>
        <Point Elevation="1.518" Offset="409.5"/>
        <Point Elevation="1.311" Offset="454.5"/>
        <Point Elevation="1.261" Offset="484.5"/>
        <Point Elevation="1.065" Offset="544.5"/>
        <Point Elevation="1.113" Offset="574.5"/>
        <Point Elevation="2.799" Offset="634.5"/>
        <Point Elevation="1.664" Offset="664.5"/>
        <Point Elevation="1.442" Offset="694.5"/>
        <Point Elevation="1.108" Offset="724.5"/>
        <Point Elevation="1.099" Offset="754.5"/>
        <Point Elevation="1.854" Offset="784.5"/>
        <Point Elevation="1.549" Offset="814.5"/>
        <Point Elevation="8.402" Offset="844.5"/>
        <Point Elevation="8.555" Offset="866.792"/>
        <Point Elevation="8.68" Offset="889.5"/>
        <Point Elevation="8.58" Offset="916.9"/>
      </Points>
    </Section>
  </Sections>
</root>

ต่อไปเป็น Typical Section ขนาดเล็กกว่า ผมตั้งชื่อว่า lake-typical.txml

<root version="1.0">
  <!--Generated by XSection Plot-->
  <!--This data file is Typical section-->
  <Header>
    <AppName>XSection Plot</AppName>
    <Developer>Prajuab Riabroy</Developer>
    <Version>4.1.512</Version>
    <SectionType>Typical</SectionType>
    <DateCreated>2017-11-18 18:57:26.689154</DateCreated>
  </Header>
  <Sections>
    <NumSections>1</NumSections>
    <Section Name="">
      <XPositionOnPaper>47.2</XPositionOnPaper>
      <YPositionOnPaper>11.7</YPositionOnPaper>
      <TopGridElev>0.0</TopGridElev>
      <NumPoints>4</NumPoints>
      <Points>
        <Point Elevation="5.0" Offset="36.944"/>
        <Point Elevation="5.0" Offset="695.0"/>
        <Point Elevation="8.4" Offset="845.0"/>
        <Point Elevation="8.44" Offset="900.0"/>
      </Points>
    </Section>
  </Sections>
</root>

เปิดไฟล์ข้อมูลทดสอบบน XSection Plot

จากนั้นนำสองไฟล์มาเปิดด้วย XSection Plot เวลาเปิดไฟล์ให้เลือกรูปแบบของไฟล์ด้วยจะได้เปิดง่าย  มีชื่อ extension ตามลำดับดังนี้ gxml, txml

จะได้ข้อมูลปรากฎขึ้นบนโปรแกรมดังนี้

ตั้งหน้ากระดาษ (Page Setup)

ผมลองเลือกใช้หน้ากระดาษที่ไม่มาตรฐานเพื่อให้ฟิตกับขนาดรูปตัดตามยาว ยาว 940 มม. และกว้าง 200 มม.

ตั้งค่า (Settings)

ผมตั้งสเกลทางราบเป็น 1:1000 และสเกลทางดิ่ง 1:250 อย่างอื่นดูรูปด้านล่าง

จัดวางรูปตัดบนกระดาษ (Section Layout)

จะเห็นกระดาษขนาด 200 มม. x 940 มม. แล้วเลือกพารามิเตอร์ดังรูปด้านล่าง

ดูรูปตัด (Section Viewer)

จะเห็นรูปตัดตามยาวที่ประกอบไปด้วย Existing Ground และ Typical

ลองซูมดู ก็ได้แบบ drawing มาพอถูๆไถๆ ที่สามารถนำไปเขียนเพิ่มเติมได้ในโปรแกรมด้านเขียนแบบทั้งหลายเช่น Autocad, Microstation, Draftsight

Save to DXF

จัดเก็บไฟล์ในรูป Autocad DXF เพื่อสามารถนำไปเปิดในโปรแกรมอื่นได้

เปิดไฟล์แบบรูปตัดตามยาว

ผมใช้ Microstation เปิดแบบรูปตัดตามยาวได้ผลลัพธ์ดังนี้และพร้อมจะนำแบบไปเขียนเพิ่มเติมตามความต้องการ

ครับคงอีกไม่นานก็จะคงจะปล่อยเวอร์ชั่นเสถียรให้สามารถดาวน์โหลดได้ พบกันใหม่ครับ

Leave a Reply

Your email address will not be published. Required fields are marked *