⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form5.frm

📁 集装箱的装箱问题 给定一个集装箱
💻 FRM
📖 第 1 页 / 共 2 页
字号:
                ss(I) = textline
        ElseIf Mid(textline, 1, 7) = "PRO_EFF" Then
                temps = Split(textline, "|")
                itmx.SubItems(1) = CStr(Format(temps(1), "0.00%"))
                itmx.Tag = itmx.Tag + "|" + CStr(I)
                ss(I) = textline
        Else
                      
                ss(I) = textline

        End If
        DoEvents
    Loop
    'paintpic
    'For i = 1 To UBound(ss, 2)
        'Paintboxs (i - 1)
    'Next i
Close
End Sub
Private Sub Form_Resize()
ListView1.Height = 2400
ListView1.Top = 0
ListView1.Left = 0
ListView1.Width = Me.ScaleWidth
Picture1.Left = 3060 + 50
Picture1.Top = ListView1.Height + 50
Picture1.Height = Me.ScaleHeight - 2400 - 50
Picture2.Left = 0
Picture2.Top = ListView1.Height + 50
Picture2.Height = Me.ScaleHeight - 2400 - 50
TreeView1.Height = Picture2.ScaleHeight
TreeView1.Top = 0
TreeView1.Left = 0
Picture2.Width = 3060
Picture1.Width = Me.ScaleWidth - 3060 - 50
Picture1.ScaleMode = 1
Label1.Width = Picture1.ScaleWidth - 400
Label1.Left = 200
Label1.Top = Picture1.ScaleHeight - 620

End Sub
Private Sub ListView1_Click()
init_treeview ListView1.SelectedItem.Tag
End Sub

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
PopupMenu popmun
End If
End Sub
Private Sub popclear_Click()
Picture1.Cls
Label1.Caption = ""
End Sub

Private Sub TreeView1_Click()
'MsgBox TreeView1.SelectedItem.Tag
If TreeView1.SelectedItem.Children > 0 Then

Label1.Caption = TreeView1.SelectedItem.Tag
Else
Label1.Caption = TreeView1.SelectedItem.Parent.Tag + "  " + TreeView1.SelectedItem.Text



End If
End Sub
Private Sub TreeView1_DblClick()
If TreeView1.SelectedItem.Children > 0 Then
temps = Split(TreeView1.SelectedItem.Child.Tag, "|")
Picture1.Cls
paintpic temps(1)


For Each nots In TreeView1.Nodes
If nots.Children = 0 Then
If nots.Parent.Index = TreeView1.SelectedItem.Index Then
    Paintboxs nots.Tag
End If
End If
Next
Label1.Caption = TreeView1.SelectedItem.Tag
Else
Label1.Caption = TreeView1.SelectedItem.Parent.Tag + "  " + TreeView1.SelectedItem.Text
temps = Split(TreeView1.SelectedItem.Tag, "|")

paintpic temps(1)
Paintboxs TreeView1.SelectedItem.Tag
End If

End Sub

'画箱子装载图
Private Sub Paintboxs(ByVal paintstr As String)
    Index = Index + 1
    Picture1.ForeColor = RGB(255, 0, 0)
    '查找箱子尺寸
    Debug.Print paintstr
    
    temps = Split(paintstr, "|")
    Debug.Print temps(4)
            '0第N个容器|1容器在LISTVIEW中索引|2工作面编号|3子工作面编号|4货物再LISTVIEW中索引
            '|5货物名称|6装载的货物数量|7X方向可装载的数量|7Y方向可装载的数量|9Z方向可装载的数量
            '|10起点X坐标|11起点Y坐标|12起点Z坐标|13是否水平旋转
            Bales_X = CDbl(Form4.ListView3.ListItems(CInt(temps(4))).SubItems(2))
            Bales_Y = CDbl(Form4.ListView3.ListItems(CInt(temps(4))).SubItems(3))
            Bales_Z = CDbl(Form4.ListView3.ListItems(CInt(temps(4))).SubItems(4))
            dt_color = Int(155 / Form4.ListView3.ListItems.Count) * CInt(temps(4))
            dt_color1 = Int(255 / Form4.ListView3.ListItems.Count) * CInt(temps(4))
            dt_color2 = Int(200 / Form4.ListView3.ListItems.Count) * CInt(temps(4))
    Debug.Print Bales_X
    Debug.Print Bales_Y
    Debug.Print Bales_Z
    If CInt(temps(13)) = 1 Then
        temp = Bales_X
        Bales_X = Bales_Y
        Bales_Y = temp
    End If
    '画箱子
    box_count = 0
    For I = 1 To CInt(temps(7))
        For j = 1 To CInt(temps(9))
            For k = 1 To CInt(temps(8))
                box_count = box_count + 1
                Dim tips(1 To 8, 1 To 2)
                s_x = CInt(temps(10)) - Int(CInt(temps(11)) / 1.414)
                s_y = Int(CInt(temps(11)) / 1.414) - CInt(temps(12))
                tips(2, 1) = s_x + Bales_X * I - Int(Bales_Y / 1.414) * (k - 1)
                tips(2, 2) = s_y + Int(Bales_Y / 1.414) * (k - 1) - Bales_Z * (j - 1)
                tips(3, 1) = s_x + Bales_X * I - Int(Bales_Y / 1.414) * k
                tips(3, 2) = s_y + Int(Bales_Y / 1.414) * k - Bales_Z * (j - 1)
                tips(4, 1) = s_x + Bales_X * (I - 1) - Int(Bales_Y / 1.414) * k
                tips(4, 2) = s_y + Int(Bales_Y / 1.414) * k - Bales_Z * (j - 1)
                tips(5, 1) = s_x + Bales_X * (I - 1) - Int(Bales_Y / 1.414) * (k - 1)
                tips(5, 2) = s_y + Int(Bales_Y / 1.414) * (k - 1) - Bales_Z * j
                tips(6, 1) = s_x + Bales_X * I - Int(Bales_Y / 1.414) * (k - 1)
                tips(6, 2) = s_y + Int(Bales_Y / 1.414) * (k - 1) - Bales_Z * j
                tips(7, 1) = s_x + Bales_X * I - Int(Bales_Y / 1.414) * k
                tips(7, 2) = s_y + Int(Bales_Y / 1.414) * k - Bales_Z * j
                tips(8, 1) = s_x + Bales_X * (I - 1) - Int(Bales_Y / 1.414) * k
                tips(8, 2) = s_y + Int(Bales_Y / 1.414) * k - Bales_Z * j



                For dt_i = 1 To Int(Bales_Y / 1.414)
                Picture1.Line (tips(5, 1) - dt_i, tips(5, 2) + dt_i)-(tips(6, 1) - dt_i, tips(6, 2) + dt_i), RGB(0, dt_color1, dt_color2)
                Next dt_i

                For dt_i = 1 To Int(Bales_Y / 1.414)
                Picture1.Line (tips(6, 1) - dt_i, tips(6, 2) + dt_i)-(tips(2, 1) - dt_i, tips(2, 2) + dt_i), RGB(0, dt_color1, dt_color2)
                Next dt_i                'Picture1.Line (tips(7, 1), tips(7, 2))-(tips(3, 1), tips(3, 2))
                'Picture1.Line (tips(8, 1), tips(8, 2))-(tips(4, 1), tips(4, 2))
                Picture1.Line (tips(8, 1), tips(8, 2))-(tips(3, 1), tips(3, 2)), RGB(0, dt_color1, dt_color2), BF
                Picture1.Line (tips(2, 1), tips(2, 2))-(tips(3, 1), tips(3, 2))
                'Picture1.Line (tips(3, 1), tips(3, 2))-(tips(4, 1), tips(4, 2))
                
                Picture1.Line (tips(5, 1), tips(5, 2))-(tips(6, 1), tips(6, 2))
                 Picture1.Line (tips(6, 1), tips(6, 2))-(tips(7, 1), tips(7, 2))
                'Picture1.Line (tips(7, 1), tips(7, 2))-(tips(8, 1), tips(8, 2))
                Picture1.Line (tips(8, 1), tips(8, 2))-(tips(5, 1), tips(5, 2))
                Picture1.Line (tips(6, 1), tips(6, 2))-(tips(2, 1), tips(2, 2))
                Picture1.Line (tips(8, 1), tips(8, 2))-(tips(3, 1), tips(3, 2)), , B
                If box_count = CInt(temps(6)) Then
                    Exit Sub
                End If
                DoEvents
            Next k
        Next j
    Next I
End Sub
'画图
Private Sub paintpic(ByVal con_index As Integer)
    Picture1.ForeColor = RGB(0, 0, 0)

            con_x = CDbl(Form4.ListView2.ListItems(con_index).SubItems(2))
            con_y = CDbl(Form4.ListView2.ListItems(con_index).SubItems(3))
            con_z = CDbl(Form4.ListView2.ListItems(con_index).SubItems(4))
    Picture1.ScaleMode = 1
    picture1_sc = Picture1.ScaleWidth / Picture1.ScaleHeight
    Picture1.ScaleMode = 0
    
    Picture1.ScaleWidth = 17000   ' 设置宽度的单位值。
    Picture1.ScaleHeight = Picture1.ScaleWidth / picture1_sc ' 设置高度的单位值。
    Picture1.ScaleTop = -6000   ' 顶部设置刻度。
    Picture1.ScaleLeft = -4000   ' 左部设置刻度。
    Picture1.Cls
    '画集装箱
    Dim tips(1 To 8, 1 To 2)
    tips(1, 1) = 0
    tips(1, 2) = 0
    tips(2, 1) = con_x
    tips(2, 2) = 0
    tips(3, 1) = con_x - Int(con_y / 1.414)
    tips(3, 2) = Int(con_y / 1.414)
    tips(4, 1) = -Int(con_y / 1.414)
    tips(4, 2) = Int(con_y / 1.414)
    tips(5, 1) = 0
    tips(5, 2) = -con_z
    tips(6, 1) = con_x
    tips(6, 2) = -con_z
    tips(7, 1) = con_x - Int(con_y / 1.414)
    tips(7, 2) = Int(con_y / 1.414) - con_z
    tips(8, 1) = -Int(con_y / 1.414)
    tips(8, 2) = Int(con_y / 1.414) - con_z
    Picture1.DrawStyle = 1
    Picture1.Line (tips(1, 1), tips(1, 2))-(tips(2, 1), tips(2, 2))
    Picture1.DrawStyle = 0
    Picture1.Line (tips(2, 1), tips(2, 2))-(tips(3, 1), tips(3, 2))
    Picture1.Line (tips(3, 1), tips(3, 2))-(tips(4, 1), tips(4, 2))
    Picture1.DrawStyle = 1
    Picture1.Line (tips(4, 1), tips(4, 2))-(tips(1, 1), tips(1, 2))
    Picture1.DrawStyle = 0
    Picture1.Line (tips(5, 1), tips(5, 2))-(tips(6, 1), tips(6, 2))
    Picture1.Line (tips(6, 1), tips(6, 2))-(tips(7, 1), tips(7, 2))
    Picture1.Line (tips(7, 1), tips(7, 2))-(tips(8, 1), tips(8, 2))
    Picture1.Line (tips(8, 1), tips(8, 2))-(tips(5, 1), tips(5, 2))
    Picture1.DrawStyle = 1
    Picture1.Line (tips(5, 1), tips(5, 2))-(tips(1, 1), tips(1, 2))
    Picture1.DrawStyle = 0
    Picture1.Line (tips(6, 1), tips(6, 2))-(tips(2, 1), tips(2, 2))
    Picture1.Line (tips(7, 1), tips(7, 2))-(tips(3, 1), tips(3, 2))
    Picture1.Line (tips(8, 1), tips(8, 2))-(tips(4, 1), tips(4, 2))
    '打印坐标方向
    Picture1.DrawMode = 13
    Picture1.DrawStyle = 0
    Picture1.PSet (tips(2, 1) + 300, tips(2, 2)), vbWhite
    Picture1.Print "X"
    Picture1.PSet (tips(5, 1), tips(5, 2) - 300), vbWhite
    Picture1.Print "Z"
    Picture1.PSet (tips(4, 1) - 150, tips(4, 2) + 150), vbWhite
    Picture1.Print "Y"
End Sub



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -