tangxu
2024-12-29 f7ec23b2fe6e8e48bbb32b8c9321b64529622406
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
using System;
using System.Collections.Generic;
using System.Windows.Forms; 
using HydrEngineCSharp;
 
namespace DPumpHydr.WinFrmUI.Volute
{
    public partial class OccDesignBaseCtrl : UserControl
    {
        protected HydrEngineCSharp.CDisplayView pDisplayView;
        protected string strTurbopumpTopoShapeName = "ÎÏ¿ÇÉè¼Æx";
 
 
      
        public OccDesignBaseCtrl()
        {
            InitializeComponent();
 
            //this.DefaultDockArea = RLT.Enum.Crown.DockArea.Document;
            //this._isDispCloseIcon = false ;//²»ÄܹرÕ
 
 
 
            this.MouseDown += OnMouseDown;
            this.MouseMove += OnMouseMove;
            this.MouseUp += OnMouseUp;
            this.MouseWheel += OnMouseWheel;
 
 
            //string strTurbopumpTopoShapeName = "ÎÏ¿ÇÉè¼Æ" + (m_nNum++).ToString();
            //bool bSucc = pDisplayView.addTurbopumpTopoShape(strTurbopumpTopoShapeName);
            //if (bSucc)
            //{
            //    m_nCreateCurve = 1;
            //    //MessageBox.Show("¿ªÊ¼ÎÏ¿ÇÉè¼Æ"); 
            //}
 
 
 
        }
 
 
        protected override void OnPaint(PaintEventArgs e)
        {
            // »æÖÆ´úÂë
            pDisplayView.OCCDraw();
        }
 
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            // ³ß´ç¸Ä±äʱµÄ´úÂë
            if (pDisplayView != null)
            {
                pDisplayView.OCCResize();
            }
        }
 
 
 
 
 
        protected void OnMouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                // Êó±ê×ó¼ü°´ÏµIJÙ×÷
                HydrEngineCSharp.LT_PtInt2D pLT_PtInt2D = new HydrEngineCSharp.LT_PtInt2D(e.X, e.Y);
                uint nF = 0;
                pDisplayView.LButtonDown(nF, pLT_PtInt2D);
            }
            else if (e.Button == MouseButtons.Middle)
            {
                HydrEngineCSharp.LT_PtInt2D pLT_PtInt2D = new HydrEngineCSharp.LT_PtInt2D(e.X, e.Y);
                uint nF = 0;
                pDisplayView.MButtonDown(nF, pLT_PtInt2D);
            }
            else if (e.Button == MouseButtons.Right)
            {
                HydrEngineCSharp.LT_PtInt2D pLT_PtInt2D = new HydrEngineCSharp.LT_PtInt2D(e.X, e.Y);
                uint nF = 0;
                pDisplayView.RButtonDown(nF, pLT_PtInt2D);
            }
        }
 
        protected void OnMouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                // Êó±ê×ó¼ü°´ÏµIJÙ×÷
                HydrEngineCSharp.LT_PtInt2D pLT_PtInt2D = new HydrEngineCSharp.LT_PtInt2D(e.X, e.Y);
                uint nF = 0;
                pDisplayView.LButtonUp(nF, pLT_PtInt2D);
            }
            else if (e.Button == MouseButtons.Middle)
            {
                HydrEngineCSharp.LT_PtInt2D pLT_PtInt2D = new HydrEngineCSharp.LT_PtInt2D(e.X, e.Y);
                uint nF = 0;
                pDisplayView.MButtonUp(nF, pLT_PtInt2D);
            }
            else if (e.Button == MouseButtons.Right)
            {
                HydrEngineCSharp.LT_PtInt2D pLT_PtInt2D = new HydrEngineCSharp.LT_PtInt2D(e.X, e.Y);
                uint nF = 0;
                pDisplayView.RButtonUp(nF, pLT_PtInt2D);
            }
        }
        // Êó±ê¹öÂֵIJÙ×÷
        protected void OnMouseWheel(object sender, MouseEventArgs e)
        {
            // e.Delta ·µ»Ø¹öÂֵĹö¶¯Öµ
            // Èç¹û e.Delta > 0 Ôò±íʾ¹öÂÖÏòÉÏ
            // Èç¹û e.Delta < 0 Ôò±íʾ¹öÂÖÏòÏÂ
 
 
            HydrEngineCSharp.LT_PtInt2D pLT_PtInt2D = new HydrEngineCSharp.LT_PtInt2D(e.X, e.Y);
            uint nF = 0;
            pDisplayView.MouseWheel(nF, (short)e.Delta, pLT_PtInt2D);
        }
        // Êó±êµÄ²Ù×÷
        protected void OnMouseMove(object sender, MouseEventArgs e)
        {
            HydrEngineCSharp.LT_PtInt2D pLT_PtInt2D = new HydrEngineCSharp.LT_PtInt2D(e.X, e.Y);
            uint nF = 0;
            pDisplayView.MouseMove(nF, pLT_PtInt2D);
        }
 
 
        public void SetViewDirect(DPumpHydr.Model.eViewDirect vd)
        {
            if (vd == Model.eViewDirect.TOP)
                pDisplayView.SetViewDirect(HydrEngineCSharp.VIEWDIRECT.TOPVIEW);
 
            if (vd == Model.eViewDirect.FRONT)
                pDisplayView.SetViewDirect(HydrEngineCSharp.VIEWDIRECT.FRONTVIEW);
 
            if (vd == Model.eViewDirect.BACK)
                pDisplayView.SetViewDirect(HydrEngineCSharp.VIEWDIRECT.BACKVIEW);
 
            if (vd == Model.eViewDirect.INI)
                pDisplayView.SetViewDirect(HydrEngineCSharp.VIEWDIRECT.INITVIEW);
 
            if (vd == Model.eViewDirect.LEFT)
                pDisplayView.SetViewDirect(HydrEngineCSharp.VIEWDIRECT.LEFTVIEW);
 
            if (vd == Model.eViewDirect.RIGHT)
                pDisplayView.SetViewDirect(HydrEngineCSharp.VIEWDIRECT.RIGHTVIEW);
        }
        protected bool _is3D = true;
 
  
        public void ClearAll()
        {
            //pDisplayView.DeleteObject(strTurbopumpTopoShapeName);
            //pDisplayView.addTurbopumpTopoShape(strTurbopumpTopoShapeName);
        }
        public virtual void Initial( )
        { 
        }
 
        #region 1-8 ½ØÃæÉè¼Æ
        bool _isFirstSectShape18 = true;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void RefreshAllSectShape18(ViewModel.SectionBundleInfo bundle)
        {
            if (_isFirstSectShape18)
            {
                CreateSectShape18(bundle);
            }
            else
            {
                EditSectShape18(bundle);
            }
            _isFirstSectShape18 = false;
        }
        protected void CreateSectShape18(ViewModel.SectionBundleInfo bundle)
        {
            //pDisplayView.Update3DViews(_is3D);
 
            double dStartAngle = -HydrDisplayEngineBridge.PI_4;
 
            double dDetAngle = 2 * HydrDisplayEngineBridge.PI / 8;
            for (int i = 8; i >=1; i--)
            {
                var theSectionParam = bundle.ToSectionShapePara(i);
 
                double dGama_Left, dGama_Right, dH, dR_out, dR_Left, dR_Right, dBaseWidth, dBaseCircleRadius;
                dGama_Left = theSectionParam.Gama_Left;
                dGama_Right = theSectionParam.Gama_Right;
                dH = theSectionParam.H;
                dR_out = theSectionParam.R_out;
                dR_Left = theSectionParam.R_Left;
                dR_Right = theSectionParam.R_Right;
                dBaseWidth = theSectionParam.BaseWidth;
                dBaseCircleRadius = theSectionParam.BaseCircleRadius;
 
                string wstrShapeNameI = string.Format("SectShape_{0}", theSectionParam.Index);
 
 
                HydrProperties theHydrProperties = new HydrProperties();
                HydrGeomCurve theHydrGeomCurve = HydrDisplayEngineBridge.CreateGeomCurve(HydrCurveType.EHydrGeomSection);
                HydrGeomSection pHydrGeomCurve = theHydrGeomCurve as HydrGeomSection;
                if (pHydrGeomCurve == null)
                {
                    continue;
                }
 
 
                double dAngle = (8 - theSectionParam.Index) * dDetAngle + dStartAngle;
                theHydrProperties.SetShapeName(wstrShapeNameI);
                pHydrGeomCurve.SetHydrProperties(theHydrProperties);
                pHydrGeomCurve.SetGeomSection(dGama_Left, dGama_Right, dH, dR_out, dR_Left, dR_Right, dBaseWidth);
                pHydrGeomCurve.SetMatrix(dAngle, dBaseCircleRadius);
                //if (_is3D)
                //{
                    
                //    BcGeMatrix theMatrix = BcGeMatrix.translate(0, dBaseCircleRadius, 0);
                //    BcGeMatrix theMatrix1 = BcGeMatrix.rotate(-dAngle, 1.0, 0.0, 0.0);
                //    theMatrix.postMult(theMatrix1);
                //    pHydrGeomCurve.SetMatrix(theMatrix);
                //}
 
                pDisplayView.addVoluteCurve( theSectionParam.Index, pHydrGeomCurve);  
            }
 
 
   
                Invalidate(true);
                pDisplayView.FitAll3DViews(true);
             
        }
 
 
 
        protected void EditSectShape18(ViewModel.SectionBundleInfo bundle)
        {
            pDisplayView.Update3DViews(_is3D);
 
            double dStartAngle = -HydrDisplayEngineBridge.PI_4;
 
            double dDetAngle = 2 * HydrDisplayEngineBridge.PI / 8;
            for (int i = 1; i <= 8; i++)
            {
                var theSectionParam = bundle.ToSectionShapePara(i);
 
                double dGama_Left, dGama_Right, dH, dR_out, dR_Left, dR_Right, dBaseWidth, dBaseCircleRadius;
                dGama_Left = theSectionParam.Gama_Left;
                dGama_Right = theSectionParam.Gama_Right;
                dH = theSectionParam.H;
                dR_out = theSectionParam.R_out;
                dR_Left = theSectionParam.R_Left;
                dR_Right = theSectionParam.R_Right;
                dBaseWidth = theSectionParam.BaseWidth;
                dBaseCircleRadius = theSectionParam.BaseCircleRadius;
 
                string wstrShapeNameI = string.Format("SectShape_{0}", theSectionParam.Index);
 
 
                HydrProperties theHydrProperties = new HydrProperties();
                HydrGeomCurve theHydrGeomCurve = HydrDisplayEngineBridge.CreateGeomCurve(HydrCurveType.EHydrGeomSection);
                HydrGeomSection pHydrGeomCurve = theHydrGeomCurve as HydrGeomSection;
                if (pHydrGeomCurve == null)
                {
                    continue;
                }
                double dAngle = (8 - theSectionParam.Index) * dDetAngle + dStartAngle;
 
           
                theHydrProperties.SetShapeName(wstrShapeNameI);
                pHydrGeomCurve.SetHydrProperties(theHydrProperties);
                pHydrGeomCurve.SetGeomSection(dGama_Left, dGama_Right, dH, dR_out, dR_Left, dR_Right, dBaseWidth );
                pHydrGeomCurve.SetMatrix(dAngle, dBaseCircleRadius);
                //if (_is3D)
                //{
                   
                //    BcGeMatrix theMatrix = BcGeMatrix.translate(0, dBaseCircleRadius, 0);
                //    BcGeMatrix theMatrix1 = BcGeMatrix.rotate(-dAngle, 1.0, 0.0, 0.0);
                //    theMatrix.postMult(theMatrix1);
                //    pHydrGeomCurve.SetMatrix(theMatrix);
                //}
 
                pDisplayView.editVoluteCurve(wstrShapeNameI, pHydrGeomCurve);
            }
 
 
 
            Invalidate(true);
 
 
        }
 
        public void RefreshSingleSectShape18(ViewModel.SectionShapePara theSectionParam)
        {
            pDisplayView.Update3DViews(true );
 
            double dStartAngle = -HydrDisplayEngineBridge.PI_4;
 
            double dDetAngle = 2 * HydrDisplayEngineBridge.PI / 8;
 
 
            double dGama_Left, dGama_Right, dH, dR_out, dR_Left, dR_Right, dBaseWidth, dBaseCircleRadius;
            dGama_Left = theSectionParam.Gama_Left;
            dGama_Right = theSectionParam.Gama_Right;
            dH = theSectionParam.H;
            dR_out = theSectionParam.R_out;
            dR_Left = theSectionParam.R_Left;
            dR_Right = theSectionParam.R_Right;
            dBaseWidth = theSectionParam.BaseWidth;
            dBaseCircleRadius = theSectionParam.BaseCircleRadius;
 
            string wstrShapeNameI = string.Format("SectShape_{0}", theSectionParam.Index);
 
 
            HydrProperties theHydrProperties = new HydrProperties();
            HydrGeomCurve theHydrGeomCurve = HydrDisplayEngineBridge.CreateGeomCurve(HydrCurveType.EHydrGeomSection);
            HydrGeomSection pHydrGeomCurve = theHydrGeomCurve as HydrGeomSection;
            if (pHydrGeomCurve == null)
            {
                return;
            }
 
            double dAngle = (8 - theSectionParam.Index) * dDetAngle + dStartAngle;
 
            theHydrProperties.SetShapeName(wstrShapeNameI);
            pHydrGeomCurve.SetHydrProperties(theHydrProperties);
            pHydrGeomCurve.SetGeomSection(dGama_Left, dGama_Right, dH, dR_out, dR_Left, dR_Right, dBaseWidth );
            pHydrGeomCurve.SetMatrix(dAngle, dBaseCircleRadius);
            //{
        
            //    BcGeMatrix theMatrix = BcGeMatrix.translate(0, dBaseCircleRadius, 0);
            //    BcGeMatrix theMatrix1 = BcGeMatrix.rotate(-dAngle, 1.0, 0.0, 0.0);
            //    theMatrix.postMult(theMatrix1);
            //    pHydrGeomCurve.SetMatrix(theMatrix);
            //}
 
            pDisplayView.editVoluteCurve(wstrShapeNameI, pHydrGeomCurve);
             
 
            Invalidate(true);  
        }
 
 
 
 
        #endregion
 
 
 
 
 
        public HydrGeomSplineParam Create2DWaterBody(WaterBodyOuterParam theWaterBodyOuterParam)
        {
            if (this._is3D)
                return null;
                
            bool bSucc = pDisplayView.build2DMidCurve(theWaterBodyOuterParam);
            Invalidate(true);
            pDisplayView.FitAll3DViews(true);
            if (bSucc)
            {
                return pDisplayView.getHydrGeomSplineParam();
            }
            else
            {
                return null;
            }
        }
        public void Create3DWaterBody(WaterBodyOuterParam theWaterBodyOuterParam, HydrGeomSplineParam theHydrGeomSplineParam)
        {
            if (!this._is3D)
                return;
            if (theHydrGeomSplineParam != null)
            {
                string wstrName = "Ë®Ìå";
                string wstrShapeNameI = wstrName;
                HydrGeomCurve theHydrGeomCurve = HydrDisplayEngineBridge.CreateGeomCurve(HydrCurveType.EHydrGeomCircle);
                HydrProperties theHydrProperties = new HydrProperties();
                theHydrProperties.SetShapeName(wstrShapeNameI);
                theHydrGeomCurve.SetHydrProperties(theHydrProperties);
                if (pDisplayView.hasBuildThicknessBody())
                pDisplayView.removeThicknessBody();//
                pDisplayView.buildWaterBody(wstrShapeNameI, theHydrGeomSplineParam, theWaterBodyOuterParam);
                Invalidate(true);
                pDisplayView.FitAll3DViews(true);
            }
 
        }
        public void Edit3DWaterBody(WaterBodyOuterParam theWaterBodyOuterParam, HydrGeomSplineParam theHydrGeomSplineParam)
        {
            if (!this._is3D)
                return;
            if(theHydrGeomSplineParam != null)
            {
                pDisplayView.rebuildWaterBody(theHydrGeomSplineParam, theWaterBodyOuterParam);
                Invalidate(true);
                pDisplayView.FitAll3DViews(true);
            }
        }
    }
}