duheng
2024-09-20 7d17fabc46e87ea0f0896f760034f4d16a4dfed0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
namespace HStation.WinFrmUI
{
    public partial class XhsProjectSimulationBimfaceCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public XhsProjectSimulationBimfaceCtrl()
        {
            InitializeComponent();
            this.bimfaceInterop3dContainer1.LoadCompletedEvent += BimfaceInterop3dContainer1_LoadCompletedEvent;
            this.bimfaceInterop3dContainer1.ClickInEvent += BimfaceInterop3dContainer1_ClickInEvent;
        }
 
        /// <summary>
        /// 点击组件事件
        /// </summary>
        public event Action<string> ClickParterEvent;
 
        private HStation.Vmo.XhsProjectVmo _project = null;
        private HStation.Vmo.XhsProjectSiteVmo _projectSite = null;
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public async Task SetBindingData(HStation.Vmo.XhsProjectVmo project, HStation.Vmo.XhsProjectSiteVmo projectSite)
        {
            if (project == null)
            {
                return;
            }
            _project = project;
            _projectSite = projectSite;
            if (_projectSite == null)
            {
                _projectSite = await BLLFactory<HStation.BLL.XhsProjectSite>.Instance.GetDefaultByProjectID(_project.ID);
            }
            await this.bimfaceInterop3dContainer1.InitialContainer();
        }
 
        //页面加载完成后触发
        private async void BimfaceInterop3dContainer1_LoadCompletedEvent()
        {
            if (_projectSite == null)
            {
                return;
            }
 
            var relation = await BLLFactory<Yw.BLL.BimfaceFileRelation>.Instance
                .GetDefaultByObjectTypeAndObjectIDOfPurpose
                    (HStation.Xhs.DataType.XhsProjectSite, _projectSite.ID, HStation.Xhs.Purpose.Simulation);
            if (relation == null)
            {
                return;
            }
 
            var bimfaceFile = await BLLFactory<Yw.BLL.BimfaceFile>.Instance.GetByID(relation.BimfaceFileID);
            if (bimfaceFile == null)
            {
                return;
            }
 
            var viewToken = await BimfaceHelper.GetViewToken(bimfaceFile.BimfaceId);
            if (string.IsNullOrEmpty(viewToken))
            {
                return;
            }
            await this.bimfaceInterop3dContainer1.LoadView(viewToken);
        }
 
        //构件点击
        private void BimfaceInterop3dContainer1_ClickInEvent(Yw.WinFrmUI.Bimface.ClickIn3dInfo obj)
        {
            if (obj == null)
            {
                return;
            }
            this.ClickParterEvent?.Invoke(obj.ObjectId);
        }
 
        #region 构件的显示与隐藏
 
        /// <summary>
        /// 显示构件
        /// </summary>
        /// <param name="elementIds">构件id列表</param>
        /// <returns></returns>
        public async Task ShowComponents(List<string> elementIds)
        {
            await this.bimfaceInterop3dContainer1.ShowComponents(elementIds);
        }
 
        /// <summary>
        /// 隐藏构件
        /// </summary>
        /// <param name="elementIds">构件id列表</param>
        /// <returns></returns>
        public async Task HideComponents(List<string> elementIds)
        {
            await this.bimfaceInterop3dContainer1.HideComponents(elementIds);
        }
 
        /// <summary>
        /// 显示所有构件
        /// </summary>
        /// <returns></returns>
        public async Task ShowAllComponents()
        {
            await this.bimfaceInterop3dContainer1.ShowAllComponents();
        }
 
        #endregion
 
        #region 构件的半透明与取消
 
        /// <summary>
        /// 半透明构件
        /// </summary>
        /// <param name="elementIds">构件id列表</param>
        /// <returns></returns>
        public async Task TranslucentComponents(List<string> elementIds)
        {
            await this.bimfaceInterop3dContainer1.TranslucentComponents(elementIds);
        }
 
        /// <summary>
        /// 取消构件半透明
        /// </summary>
        /// <param name="elementIds">构件id列表</param>
        /// <returns></returns>
        public async Task OpaqueComponents(List<string> elementIds)
        {
            await this.bimfaceInterop3dContainer1.OpaqueComponents(elementIds);
        }
 
        #endregion
 
        #region 构件的选中与取消
 
        /// <summary>
        /// 设置选择的构件
        /// </summary>
        /// <returns></returns>
        public async Task SetSelectedComponents(List<string> elements)
        {
            await this.bimfaceInterop3dContainer1.SetSelectedComponents(elements);
        }
 
        /// <summary>
        /// 增加选择的构件
        /// </summary>
        /// <param name="elements"></param>
        /// <returns></returns>
        public async Task AddSelectedComponents(List<string> elements)
        {
            await this.bimfaceInterop3dContainer1.AddSelectedComponents(elements);
        }
 
        /// <summary>
        /// 移除选择的构件
        /// </summary>
        /// <param name="elements"></param>
        /// <returns></returns>
        public async Task RemoveSelectedComponents(List<string> elements)
        {
            await this.bimfaceInterop3dContainer1.RemoveSelectedComponents(elements);
        }
 
        /// <summary>
        /// 清除选择的构件
        /// </summary>
        /// <param name="elements"></param>
        /// <returns></returns>
        public async Task ClearSelectedComponents()
        {
            await this.bimfaceInterop3dContainer1.ClearSelectedComponents();
        }
 
        #endregion
 
    }
}