├── .gitignore ├── .vs └── CADCtrl │ └── v14 │ └── .suo ├── CADCtrl.sln ├── CADCtrl.suo ├── CADCtrl ├── App.config ├── CADCtrl.cs ├── CADCtrl.csproj ├── CADCtrl.csproj.user ├── CADView.xaml ├── CADView.xaml.cs ├── CADView.xaml.cs~RF1771951.TMP ├── Properties │ └── AssemblyInfo.cs ├── SharpGL.SceneGraph.dll ├── SharpGL.WPF.dll ├── SharpGL.dll ├── bin │ ├── Debug │ │ ├── CADCtrl.dll │ │ ├── CADCtrl.dll.config │ │ ├── CADCtrl.pdb │ │ ├── SharpGL.SceneGraph.dll │ │ ├── SharpGL.WPF.dll │ │ ├── SharpGL.dll │ │ └── log4net.dll │ └── Release │ │ ├── CADCtrl.dll │ │ ├── CADCtrl.pdb │ │ ├── SharpGL.SceneGraph.dll │ │ ├── SharpGL.WPF.dll │ │ └── SharpGL.dll ├── log4net.dll └── obj │ ├── Debug │ ├── CADCtrl.csproj.FileListAbsolute.txt │ ├── CADCtrl.csprojResolveAssemblyReference.cache │ ├── CADCtrl.dll │ ├── CADCtrl.g.resources │ ├── CADCtrl.pdb │ ├── CADCtrl_MarkupCompile.cache │ ├── CADCtrl_MarkupCompile.i.cache │ ├── CADView.baml │ ├── CADView.g.cs │ ├── CADView.g.i.cs │ ├── DesignTimeResolveAssemblyReferences.cache │ └── DesignTimeResolveAssemblyReferencesInput.cache │ └── Release │ ├── CADCtrl.csproj.FileListAbsolute.txt │ ├── CADCtrl.dll │ ├── CADCtrl.g.resources │ ├── CADCtrl.pdb │ ├── CADCtrl_MarkupCompile.cache │ ├── CADCtrl_MarkupCompile.i.cache │ ├── CADView.baml │ ├── CADView.g.cs │ ├── CADView.g.i.cs │ ├── DesignTimeResolveAssemblyReferences.cache │ └── DesignTimeResolveAssemblyReferencesInput.cache └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # git ignore file -------------------------------------------------------------------------------- /.vs/CADCtrl/v14/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/.vs/CADCtrl/v14/.suo -------------------------------------------------------------------------------- /CADCtrl.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CADCtrl", "CADCtrl\CADCtrl.csproj", "{4FE34744-B0A5-47D3-932B-670A3374C48C}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {4FE34744-B0A5-47D3-932B-670A3374C48C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {4FE34744-B0A5-47D3-932B-670A3374C48C}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {4FE34744-B0A5-47D3-932B-670A3374C48C}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {4FE34744-B0A5-47D3-932B-670A3374C48C}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /CADCtrl.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl.suo -------------------------------------------------------------------------------- /CADCtrl/App.config: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /CADCtrl/CADCtrl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace CADCtrl 7 | { 8 | public class CADCtrl 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /CADCtrl/CADCtrl.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {4FE34744-B0A5-47D3-932B-670A3374C48C} 9 | Library 10 | Properties 11 | CADCtrl 12 | CADCtrl 13 | v4.0 14 | 512 15 | 16 | 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | .\log4net.dll 38 | 39 | 40 | 41 | 42 | .\SharpGL.dll 43 | 44 | 45 | .\SharpGL.SceneGraph.dll 46 | 47 | 48 | .\SharpGL.WPF.dll 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | CADView.xaml 66 | 67 | 68 | 69 | 70 | 71 | Designer 72 | MSBuild:Compile 73 | 74 | 75 | 76 | 77 | 78 | 79 | 86 | -------------------------------------------------------------------------------- /CADCtrl/CADCtrl.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Program 5 | D:\C++公用文件夹\My Projects_VS2010\Ansys_builder\Ansys_builder\bin\Debug\Ansys_builder.exe 6 | 7 | 8 | ShowAllFiles 9 | 10 | -------------------------------------------------------------------------------- /CADCtrl/CADView.xaml: -------------------------------------------------------------------------------- 1 |  10 | 21 | -------------------------------------------------------------------------------- /CADCtrl/CADView.xaml.cs~RF1771951.TMP: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Data; 8 | using System.Windows.Documents; 9 | using System.Windows.Input; 10 | using System.Windows.Media; 11 | using System.Windows.Media.Imaging; 12 | using System.Windows.Navigation; 13 | using System.Windows.Shapes; 14 | using SharpGL; 15 | using SharpGL.SceneGraph; 16 | using System.Collections.ObjectModel; 17 | using log4net; 18 | using SharpGL.SceneGraph.Primitives; 19 | 20 | namespace CADCtrl 21 | { 22 | /// 23 | /// CADView.xaml 的交互逻辑 24 | /// 25 | public partial class CADView : UserControl 26 | { 27 | public static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 28 | 29 | private Point m_center_offset; 30 | private double m_distance; 31 | public double m_scale; 32 | public double m_rotate_x_degree; 33 | public double m_rotate_y_degree; 34 | public double m_rotate_z_degree; 35 | 36 | private OpenGL m_openGLCtrl; 37 | private double m_pixaxis;//像素对应平移的倍数 38 | private double m_gridstep;//栅格间距,像素为单位 39 | private int LineNumber; 40 | private int RectNumber; 41 | private int PointNumber; 42 | private int CubeNumber; 43 | private CADRect m_border; 44 | private double m_wheel_multi;//滚轮滚动一次放大的倍数 45 | Dictionary AllLines = new Dictionary(); 46 | Dictionary> AllPointsInLines = new Dictionary>(); 47 | Dictionary AllRects = new Dictionary(); 48 | Dictionary> AllPointsInRects = new Dictionary>(); 49 | Dictionary AllPoints = new Dictionary(); 50 | Dictionary AllCubes = new Dictionary(); 51 | Dictionary SelCubes = new Dictionary(); 52 | Dictionary SelPoints = new Dictionary(); 53 | Dictionary SelLines = new Dictionary(); 54 | Dictionary SelRects = new Dictionary(); 55 | Dictionary AllColors = new Dictionary(); 56 | Dictionary AllLinesColor = new Dictionary(); 57 | Dictionary AllRectsColor = new Dictionary(); 58 | Dictionary AllCubesColor = new Dictionary(); 59 | Point MidMouseDownStart = new Point(0, 0); 60 | Point MidMouseDownEnd = new Point(0, 0); 61 | Point m_currentpos = new Point(0, 0); 62 | CADPoint m_cur_sel_point = new CADPoint(0, 0); 63 | public ObservableCollection m_sel_rect_list = new ObservableCollection(); 64 | public ObservableCollection m_sel_point_list = new ObservableCollection(); 65 | //public ObservableCollection m_sel_rebar_list = new ObservableCollection(); 66 | public bool key_down_esc; 67 | public bool key_down_copy; 68 | public bool key_down_move; 69 | public bool key_down_del; 70 | public bool key_down_shift; 71 | 72 | CADPoint zero = null; 73 | CADPoint ax_p = null; 74 | CADPoint ay_p = null; 75 | CADPoint az_p = null; 76 | CADPoint ax_n = null; 77 | CADPoint ay_n = null; 78 | CADPoint az_n = null; 79 | 80 | 81 | 82 | private bool cross_mouse_view = true; 83 | private CADLine tempLine = new CADLine(); 84 | private CADPoint tempPoint = new CADPoint(); 85 | private CADPoint m_curaxispos = new CADPoint(); 86 | public bool b_draw_line = false; 87 | private int clicked_count = 0; 88 | 89 | public int isRebar = 0; 90 | public CADView() 91 | { 92 | InitializeComponent(); 93 | m_openGLCtrl = openGLCtrl.OpenGL; 94 | log4net.Config.XmlConfigurator.Configure(); 95 | log.Info("dll start up"); 96 | } 97 | private void UserControl_Loaded(object sender, RoutedEventArgs e) 98 | { 99 | m_openGLCtrl = openGLCtrl.OpenGL; 100 | m_center_offset = new Point(0, 0); 101 | m_distance = -10; 102 | m_pixaxis = 0.1208;//与移动速度成反比 103 | m_scale = 0.00002; 104 | if (isRebar == 1) 105 | m_scale = 0.005; 106 | m_border = new CADRect(0, 0, 0, 0); 107 | m_wheel_multi = 0.2; 108 | m_gridstep = 50; 109 | LineNumber = 0; 110 | RectNumber = 0; 111 | PointNumber = 1; 112 | CubeNumber = 0; 113 | AllPoints[PointNumber] = new CADPoint(); 114 | AllPoints[PointNumber].m_id = PointNumber; 115 | m_pixaxis = m_pixaxis * this.Height;//(this.Width < this.Height ? this.Width : this.Height); 116 | AllColors.Add(1, new CADRGB(1, 1, 1)); 117 | AllColors.Add(2, new CADRGB(1, 0, 0)); 118 | AllColors.Add(3, new CADRGB(0, 1, 0)); 119 | AllColors.Add(4, new CADRGB(0, 0, 1)); 120 | 121 | key_down_esc = false; 122 | key_down_copy = false; 123 | key_down_move = false; 124 | key_down_del = false; 125 | key_down_shift = false; 126 | 127 | zero = new CADPoint(0, 0, 0); 128 | ax_p = new CADPoint(1, 0, 0); 129 | ay_p = new CADPoint(0, 1, 0); 130 | az_p = new CADPoint(0, 0, 1); 131 | ax_n = new CADPoint(-1, 0, 0); 132 | ay_n = new CADPoint(0, -1, 0); 133 | az_n = new CADPoint(0, 0, -1); 134 | 135 | m_rotate_x_degree = 0; 136 | m_rotate_y_degree = 0; 137 | m_rotate_z_degree = 0; 138 | } 139 | 140 | 141 | 142 | private void OpenGLControl_OpenGLDraw(object sender, OpenGLEventArgs args) 143 | { 144 | m_openGLCtrl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); 145 | m_openGLCtrl.MatrixMode(OpenGL.GL_MODELVIEW); 146 | m_openGLCtrl.LoadIdentity(); 147 | m_openGLCtrl.LookAt(0, 0, 0, 0, 0, -1, 0, 1, 0); 148 | this.RedrawAll(); 149 | 150 | } 151 | 152 | private void OpenGLControl_OpenGLInitialized(object sender, OpenGLEventArgs args) 153 | { 154 | 155 | } 156 | 157 | private void OpenGLControl_MouseDown(object sender, MouseButtonEventArgs e) 158 | { 159 | if (e.MiddleButton == MouseButtonState.Pressed && key_down_shift == false) 160 | { 161 | if (e.ClickCount == 2) 162 | { 163 | this.Cursor = Cursors.SizeAll; 164 | if ((m_border.m_ye - m_border.m_ys) > (m_border.m_xe - m_border.m_xs)) 165 | m_scale = this.Height / 50 / (m_border.m_ye - m_border.m_ys); 166 | else 167 | m_scale = this.Width / 50 / (m_border.m_xe - m_border.m_xs); 168 | if (m_scale > 1000000) 169 | m_scale = 8 / (m_border.m_xe - m_border.m_xs); 170 | if (m_scale > 1000000) 171 | m_scale = 8 / (m_border.m_ye - m_border.m_ys); 172 | if (m_scale > 1000000) 173 | { 174 | if (isRebar == 0) 175 | m_scale = 0.00001; 176 | else 177 | m_scale = 0.005; 178 | } 179 | m_center_offset.X = -(m_border.m_xe + m_border.m_xs) / 2 * m_pixaxis * m_scale; 180 | m_center_offset.Y = -(m_border.m_ye + m_border.m_ys) / 2 * m_pixaxis * m_scale; 181 | } 182 | else 183 | { 184 | if (e.ClickCount == 1) 185 | { 186 | MidMouseDownStart = e.GetPosition(e.Source as FrameworkElement); 187 | this.Cursor = Cursors.SizeAll; 188 | this.cross_mouse_view = false; 189 | } 190 | else 191 | this.cross_mouse_view = true; 192 | } 193 | } 194 | 195 | if (e.MiddleButton == MouseButtonState.Pressed && key_down_shift == true) 196 | { 197 | MidMouseDownStart = e.GetPosition(e.Source as FrameworkElement); 198 | this.Cursor = Cursors.ScrollNS; 199 | } 200 | if (e.LeftButton == MouseButtonState.Pressed) 201 | { 202 | if (b_draw_line && clicked_count == 1) 203 | { 204 | this.UserEndLine(); 205 | clicked_count = 0; 206 | } 207 | if (b_draw_line && clicked_count == 0) 208 | { 209 | this.UserStartLine(); 210 | clicked_count++; 211 | } 212 | Point mousepos = new Point(m_currentpos.X / m_scale / m_pixaxis, m_currentpos.Y / m_scale / m_pixaxis); 213 | int id_sel_point = -1; 214 | double sel_dis_point = 1 / m_scale; 215 | double real_dis = 0.1 / m_scale; 216 | if (isRebar == 1) 217 | real_dis = 4 * real_dis; 218 | if (AllPoints.Count > 0) 219 | { 220 | foreach (int id in this.AllPoints.Keys) 221 | { 222 | double dis = this.GetDistance(mousepos, AllPoints[id]); 223 | if (dis < real_dis && dis < sel_dis_point) 224 | { 225 | id_sel_point = id; 226 | sel_dis_point = dis; 227 | } 228 | } 229 | } 230 | 231 | if (id_sel_point > 0) 232 | { 233 | CADPoint temp_cur_point = null; 234 | 235 | if (AllPoints.ContainsKey(id_sel_point)) 236 | { 237 | 238 | if (key_down_move || key_down_copy) 239 | { 240 | Vector move = new Vector(AllPoints[id_sel_point].m_x - m_cur_sel_point.m_x, AllPoints[id_sel_point].m_y - m_cur_sel_point.m_y); 241 | if (SelRects.Count > 0) 242 | { 243 | if (key_down_move) 244 | { 245 | foreach (int value in SelRects.Keys) 246 | { 247 | if (AllPointsInRects[value].Contains(id_sel_point)) 248 | { 249 | temp_cur_point = AllPoints[id_sel_point].Copy(); 250 | } 251 | SelRects[value].m_xs = AllRects[value].m_xs + (float)move.X; 252 | SelRects[value].m_ys = AllRects[value].m_ys + (float)move.Y; 253 | SelRects[value].m_xe = AllRects[value].m_xe + (float)move.X; 254 | SelRects[value].m_ye = AllRects[value].m_ye + (float)move.Y; 255 | this.AddRect(SelRects[value]); 256 | } 257 | key_down_move = false; 258 | } 259 | if (key_down_copy) 260 | { 261 | CADRect new_rect = new CADRect(); 262 | int[] keys = SelRects.Keys.ToArray(); 263 | SelRects.Clear(); 264 | foreach (int value in keys) 265 | { 266 | new_rect = AllRects[value].Copy(); 267 | new_rect.m_xs = AllRects[value].m_xs + (float)move.X; 268 | new_rect.m_ys = AllRects[value].m_ys + (float)move.Y; 269 | new_rect.m_xe = AllRects[value].m_xe + (float)move.X; 270 | new_rect.m_ye = AllRects[value].m_ye + (float)move.Y; 271 | new_rect.UpdataWH(); 272 | RectNumber++; 273 | new_rect.m_id = RectNumber; 274 | SelRects.Add(RectNumber, new_rect); 275 | this.AddRect(new_rect); 276 | } 277 | key_down_copy = false; 278 | } 279 | } 280 | } 281 | 282 | if (temp_cur_point != null) 283 | { 284 | m_cur_sel_point = temp_cur_point; 285 | this.AddPoint(temp_cur_point); 286 | } 287 | else 288 | m_cur_sel_point = AllPoints[id_sel_point].Copy(); 289 | key_down_move = false; 290 | } 291 | 292 | if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) 293 | { 294 | if (isRebar == 1) 295 | this.SelPoints.Clear(); 296 | this.SelPoint(id_sel_point); 297 | if (temp_cur_point != null) 298 | { 299 | this.AllPoints.Remove(id_sel_point); 300 | } 301 | return; 302 | } 303 | else 304 | { 305 | if (!SelPoints.ContainsKey(id_sel_point)) 306 | { 307 | SelPoints.Clear(); 308 | m_sel_point_list.Clear(); 309 | } 310 | this.SelPoint(id_sel_point); 311 | if (temp_cur_point != null) 312 | { 313 | this.AllPoints.Remove(id_sel_point); 314 | } 315 | return; 316 | } 317 | } 318 | else 319 | { 320 | 321 | if ((Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.Control) 322 | { 323 | m_cur_sel_point = new CADPoint(); 324 | this.SelPoints.Clear(); 325 | m_sel_point_list.Clear(); 326 | } 327 | } 328 | 329 | 330 | int id_sel_line = -1; 331 | double sel_dis_line = 1 / m_scale; 332 | if (AllLines.Count > 0) 333 | { 334 | foreach (int id in this.AllLines.Keys) 335 | { 336 | double dis = this.GetDistance(mousepos, AllLines[id]); 337 | if (dis < 0) 338 | continue; 339 | if (dis < 0.06 / m_scale && dis < sel_dis_line) 340 | { 341 | id_sel_line = id; 342 | sel_dis_line = dis; 343 | } 344 | } 345 | } 346 | 347 | 348 | 349 | if (id_sel_line > 0) 350 | { 351 | if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) 352 | this.SelLine(id_sel_line); 353 | else 354 | { 355 | if (!SelLines.ContainsKey(id_sel_line)) 356 | SelLines.Clear(); 357 | this.SelLine(id_sel_line); 358 | } 359 | } 360 | else 361 | { 362 | if ((Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.Control) 363 | this.SelLines.Clear(); 364 | } 365 | 366 | int id_sel_rect = -1; 367 | double sel_dis_rect = 1 / m_scale; 368 | if (AllRects.Count > 0) 369 | { 370 | foreach (int id in this.AllRects.Keys) 371 | { 372 | double dis = this.GetDistance(mousepos, AllRects[id]); 373 | if (dis < 0) 374 | continue; 375 | if (dis < 0.06 / m_scale && dis < sel_dis_rect) 376 | { 377 | id_sel_rect = id; 378 | sel_dis_rect = dis; 379 | } 380 | } 381 | } 382 | 383 | 384 | 385 | if (id_sel_rect > 0) 386 | { 387 | if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) 388 | this.SelRect(id_sel_rect); 389 | else 390 | { 391 | if (!SelRects.ContainsKey(id_sel_rect)) 392 | { 393 | SelRects.Clear(); 394 | m_sel_rect_list.Clear(); 395 | } 396 | this.SelRect(id_sel_rect); 397 | } 398 | } 399 | else 400 | { 401 | if ((Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.Control) 402 | { 403 | this.SelRects.Clear(); 404 | m_sel_rect_list.Clear(); 405 | } 406 | } 407 | } 408 | } 409 | 410 | private void OpenGLControl_MouseUp(object sender, MouseButtonEventArgs e) 411 | { 412 | if (e.MiddleButton == MouseButtonState.Released) 413 | { 414 | this.cross_mouse_view = true; 415 | //this.Cursor = Cursors.Arrow; 416 | } 417 | } 418 | 419 | private void OpenGLControl_MouseMove(object sender, MouseEventArgs e) 420 | { 421 | if (e.MiddleButton == MouseButtonState.Released) 422 | this.Cursor = Cursors.None; 423 | if (e.MiddleButton == MouseButtonState.Pressed && key_down_shift == false) 424 | { 425 | MidMouseDownEnd = e.GetPosition(e.Source as FrameworkElement); 426 | Vector vDistance = MidMouseDownEnd - MidMouseDownStart; 427 | m_center_offset.X = m_center_offset.X + vDistance.X; 428 | m_center_offset.Y = m_center_offset.Y - vDistance.Y; 429 | MidMouseDownStart = MidMouseDownEnd; 430 | } 431 | 432 | if (e.MiddleButton == MouseButtonState.Pressed && key_down_shift == true) 433 | { 434 | MidMouseDownEnd = e.GetPosition(e.Source as FrameworkElement); 435 | 436 | Vector vDistance = MidMouseDownEnd - MidMouseDownStart; 437 | m_rotate_x_degree = m_rotate_x_degree + vDistance.X; 438 | m_rotate_y_degree = m_rotate_y_degree + vDistance.Y; 439 | if (m_rotate_x_degree >= 360) 440 | m_rotate_x_degree = m_rotate_x_degree - 360; 441 | if (m_rotate_y_degree >= 360) 442 | m_rotate_y_degree = m_rotate_x_degree - 360; 443 | if (m_rotate_x_degree <= -360) 444 | m_rotate_x_degree = m_rotate_x_degree + 360; 445 | if (m_rotate_y_degree <= -360) 446 | m_rotate_y_degree = m_rotate_x_degree + 360; 447 | //log.Info(string.Format("vDistance = [{0},{1}]", vDistance.X, vDistance.Y)); 448 | //this.DrawText(string.Format("shift down:%d,%d", vDistance.X, vDistance.Y), new Point(0, 15)); 449 | //m_center_offset.X = m_center_offset.X + vDistance.X; 450 | //m_center_offset.Y = m_center_offset.Y - vDistance.Y; 451 | MidMouseDownStart = MidMouseDownEnd; 452 | 453 | } 454 | 455 | if (key_down_move || key_down_copy) 456 | { 457 | if (this.SelRects.Count > 0) 458 | { 459 | Vector move = new Vector(m_currentpos.X / m_scale / m_pixaxis - m_cur_sel_point.m_x, m_currentpos.Y / m_scale / m_pixaxis - m_cur_sel_point.m_y); 460 | if (SelRects.Count > 0) 461 | { 462 | foreach (int value in SelRects.Keys) 463 | { 464 | SelRects[value].m_xs = AllRects[value].m_xs + (float)move.X; 465 | SelRects[value].m_ys = AllRects[value].m_ys + (float)move.Y; 466 | SelRects[value].m_xe = AllRects[value].m_xe + (float)move.X; 467 | SelRects[value].m_ye = AllRects[value].m_ye + (float)move.Y; 468 | } 469 | } 470 | } 471 | } 472 | m_currentpos.Y = this.Height / 2 - e.GetPosition(e.Source as FrameworkElement).Y - m_center_offset.Y; 473 | m_currentpos.X = -this.Width / 2 + e.GetPosition(e.Source as FrameworkElement).X - m_center_offset.X; 474 | 475 | m_curaxispos.m_x = (float)(m_currentpos.X / m_scale / m_pixaxis); 476 | m_curaxispos.m_y = (float)(m_currentpos.Y / m_scale / m_pixaxis); 477 | 478 | if (b_draw_line && clicked_count == 1) 479 | { 480 | tempLine.m_xe = m_curaxispos.m_x; 481 | tempLine.m_ye = m_curaxispos.m_y; 482 | } 483 | 484 | } 485 | 486 | private void OpenGLControl_MouseWheel(object sender, MouseWheelEventArgs e) 487 | { 488 | Vector vDistance = new Vector(); 489 | if (e.Delta > 0) 490 | { 491 | vDistance.X = (m_center_offset.X - e.GetPosition(e.Source as FrameworkElement).X + this.Width / 2) * -m_wheel_multi; 492 | vDistance.Y = (m_center_offset.Y + e.GetPosition(e.Source as FrameworkElement).Y - this.Height / 2) * -m_wheel_multi; 493 | m_scale -= m_scale * m_wheel_multi; 494 | m_gridstep -= 1; 495 | } 496 | else 497 | { 498 | vDistance.X = (m_center_offset.X - e.GetPosition(e.Source as FrameworkElement).X + this.Width / 2) * m_wheel_multi; 499 | vDistance.Y = (m_center_offset.Y + e.GetPosition(e.Source as FrameworkElement).Y - this.Height / 2) * m_wheel_multi; 500 | m_scale += m_scale * m_wheel_multi; 501 | m_gridstep += 1; 502 | } 503 | 504 | if (m_gridstep > 70) 505 | m_gridstep = 50; 506 | if (m_gridstep < 30) 507 | m_gridstep = 50; 508 | if (m_scale <= 0.0000001) 509 | m_scale = 0.0000001; 510 | else 511 | { 512 | m_center_offset.X = m_center_offset.X + vDistance.X; 513 | m_center_offset.Y = m_center_offset.Y + vDistance.Y; 514 | } 515 | 516 | m_currentpos.Y = this.Height / 2 - e.GetPosition(e.Source as FrameworkElement).Y - m_center_offset.Y; 517 | m_currentpos.X = -this.Width / 2 + e.GetPosition(e.Source as FrameworkElement).X - m_center_offset.X; 518 | 519 | 520 | m_curaxispos.m_x = (float)(m_currentpos.X / m_scale / m_pixaxis); 521 | m_curaxispos.m_y = (float)(m_currentpos.Y / m_scale / m_pixaxis); 522 | } 523 | 524 | 525 | 526 | 527 | private void RedrawAll() 528 | { 529 | //m_openGLCtrl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); 530 | 531 | m_openGLCtrl.Enable(OpenGL.GL_DEPTH_TEST); 532 | float[] global_ambient = new float[] { 0.8f, 0.5f, 0.5f, 1.0f }; 533 | float[] light0pos = new float[] { 0.0f, 50.0f, 100.0f, 1.0f }; 534 | float[] light0ambient = new float[] { 0.2f, 0.2f, 0.2f, 1.0f }; 535 | float[] light0diffuse = new float[] { 0.3f, 0.3f, 0.3f, 1.0f }; 536 | float[] light0specular = new float[] { 0.8f, 0.8f, 0.8f, 1.0f }; 537 | 538 | float[] lmodel_ambient = new float[] { 0.8f, 0.2f, 0.2f, 1.0f }; 539 | m_openGLCtrl.LightModel(OpenGL.GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); 540 | m_openGLCtrl.LightModel(OpenGL.GL_LIGHT_MODEL_AMBIENT, global_ambient); 541 | m_openGLCtrl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_POSITION, light0pos); 542 | m_openGLCtrl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_AMBIENT, light0ambient); 543 | m_openGLCtrl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_DIFFUSE, light0diffuse); 544 | m_openGLCtrl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_SPECULAR, light0specular); 545 | m_openGLCtrl.Enable(OpenGL.GL_LIGHTING); 546 | m_openGLCtrl.Enable(OpenGL.GL_LIGHT0); 547 | 548 | m_openGLCtrl.ShadeModel(OpenGL.GL_SMOOTH); 549 | 550 | m_openGLCtrl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); 551 | m_openGLCtrl.LoadIdentity(); 552 | //m_openGLCtrl.Translate(0.0f, 0.0f, -6.0f); 553 | //m_openGLCtrl.Rotate(10, 0.0f, 1.0f, 0.0f); 554 | 555 | 556 | 557 | m_openGLCtrl.Rotate(m_rotate_x_degree, 0.0f, 1.0f, 0.0f); 558 | m_openGLCtrl.Rotate(m_rotate_y_degree, 1.0f, 0.0f, 0.0f); 559 | 560 | m_openGLCtrl.Translate(m_center_offset.X / m_pixaxis, m_center_offset.Y / m_pixaxis, m_distance); 561 | 562 | //m_openGLCtrl.Scale(m_scale, m_scale, m_scale); 563 | 564 | 565 | 566 | 567 | 568 | //float[] light_position = new float[] { 1200, 0, 0, 0 }; 569 | //float[] fLightDiffuse = new float[4] { 1.0f, 0.0f, 0.0f, 1.0f };// 漫射光参数 570 | //float[] ambient = new float[] { 0.0f, 0.4f, 0.4f, 1.0f }; 571 | //float[] fLightSpecular = new float[4] { 1f, 1f, 1f, 1f }; //镜面反射 572 | 573 | 574 | 575 | //m_openGLCtrl.Enable(OpenGL.GL_LIGHTING);//开启光照 576 | ////m_openGLCtrl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_DIFFUSE, fLightDiffuse); 577 | ////m_openGLCtrl.Enable(OpenGL.GL_LIGHT1); 578 | 579 | //m_openGLCtrl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_AMBIENT, ambient); 580 | //m_openGLCtrl.Enable(OpenGL.GL_LIGHT0); 581 | 582 | //m_openGLCtrl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_POSITION, light_position); 583 | 584 | //m_openGLCtrl.Light(OpenGL.GL_LIGHT2, OpenGL.GL_SPECULAR, fLightSpecular);//漫射光源 585 | //m_openGLCtrl.Enable(OpenGL.GL_LIGHT2); 586 | 587 | 588 | 589 | 590 | 591 | //float[] fLightPosition = new float[4] { 0.0f, 3.0f, 2.0f, 0.0f }; //5f, 8f, -8f, 1f };// 光源位置 592 | //float[] fLightAmbient = new float[4] { 1f, 1f, 1f, 1f };// 环境光参数 593 | //float[] fLightDiffuse = new float[4] { 1f, 1f, 1f, 1f };// 漫射光参数 594 | //float[] fLightSpecular = new float[4] { 1f, 1f, 1f, 1f }; //镜面反射 595 | 596 | //m_openGLCtrl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_AMBIENT, fLightAmbient);//环境光源 597 | //m_openGLCtrl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_DIFFUSE, fLightDiffuse);//漫射光源 598 | //m_openGLCtrl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_POSITION, fLightPosition);//光源位置 599 | ////m_openGLCtrl.ClearColor(0.0f, 0.2f, 0.2f, 0.0f); 600 | ////m_openGLCtrl.ClearDepth(1f); 601 | //m_openGLCtrl.DepthFunc(OpenGL.GL_LEQUAL); 602 | //m_openGLCtrl.Enable(OpenGL.GL_DEPTH_TEST); 603 | //m_openGLCtrl.ShadeModel(OpenGL.GL_SMOOTH); 604 | //m_openGLCtrl.Enable(OpenGL.GL_LIGHTING);//开启光照 605 | //m_openGLCtrl.Enable(OpenGL.GL_LIGHT0); 606 | //m_openGLCtrl.Enable(OpenGL.GL_NORMALIZE); 607 | 608 | 609 | 610 | this.DrawGrids(); 611 | 612 | if (cross_mouse_view) 613 | this.DrawMouseLine(m_scale); 614 | 615 | if (b_draw_line) 616 | this.DrawLine(tempLine); 617 | 618 | if (SelLines.Count > 0) 619 | { 620 | foreach (int value in this.SelLines.Keys) 621 | { 622 | this.DrawSelLine(value); 623 | } 624 | } 625 | 626 | if (SelRects.Count > 0) 627 | { 628 | foreach (int value in this.SelRects.Keys) 629 | { 630 | this.DrawSelRect(value); 631 | } 632 | } 633 | 634 | 635 | if (AllLines.Count > 0) 636 | { 637 | foreach (int key in this.AllLines.Keys) 638 | { 639 | this.DrawLine(AllLines[key], AllColors[AllLinesColor[key]]); 640 | } 641 | } 642 | 643 | if (AllRects.Count > 0) 644 | { 645 | foreach (int key in this.AllRects.Keys) 646 | { 647 | this.DrawRect(AllRects[key], AllColors[AllRectsColor[key]]); 648 | } 649 | } 650 | 651 | if (AllCubes.Count > 0) 652 | { 653 | foreach (int key in this.AllCubes.Keys) 654 | { 655 | this.DrawCube(AllCubes[key], AllColors[AllCubesColor[key]]); 656 | } 657 | } 658 | 659 | if (AllPoints.Count > 0) 660 | { 661 | foreach (int key in this.AllPoints.Keys) 662 | { 663 | this.DrawPoint(AllPoints[key]); 664 | } 665 | } 666 | 667 | if (SelPoints.Count > 0) 668 | { 669 | foreach (int value in this.SelPoints.Keys) 670 | { 671 | this.DrawSelPoint(value); 672 | } 673 | } 674 | 675 | double real_scale = m_scale; 676 | if (isRebar == 1) 677 | real_scale = m_scale / 3; 678 | 679 | this.DrawCoord(m_scale); 680 | 681 | //this.DrawLine(new CADLine(0, 0, 0.5 / real_scale, 0)); 682 | //this.DrawLine(new CADLine(0.5 / real_scale, 0, 0.4 / real_scale, 0.05 / real_scale)); 683 | //this.DrawLine(new CADLine(0.5 / real_scale, 0, 0.4 / real_scale, -0.05 / real_scale)); 684 | //this.DrawLine(new CADLine(0.4 / real_scale, 0.05 / real_scale, 0.4 / real_scale, -0.05 / real_scale)); 685 | 686 | //this.DrawLine(new CADLine(0.15 / real_scale, -0.1 / real_scale, 0.35 / real_scale, -0.3 / real_scale)); 687 | //this.DrawLine(new CADLine(0.15 / real_scale, -0.3 / real_scale, 0.35 / real_scale, -0.1 / real_scale)); 688 | 689 | //this.DrawLine(new CADLine(0, 0, 0, 0.5 / real_scale)); 690 | //this.DrawLine(new CADLine(0, 0.5 / real_scale, 0.05 / real_scale, 0.4 / real_scale)); 691 | //this.DrawLine(new CADLine(0, 0.5 / real_scale, -0.05 / real_scale, 0.4 / real_scale)); 692 | //this.DrawLine(new CADLine(0.05 / real_scale, 0.4 / real_scale, -0.05 / real_scale, 0.4 / real_scale)); 693 | 694 | //this.DrawLine(new CADLine(-0.2 / real_scale, 0.25 / real_scale, -0.1 / real_scale, 0.35 / real_scale)); 695 | //this.DrawLine(new CADLine(-0.2 / real_scale, 0.25 / real_scale, -0.3 / real_scale, 0.35 / real_scale)); 696 | //this.DrawLine(new CADLine(-0.2 / real_scale, 0.25 / real_scale, -0.2 / real_scale, 0.1 / real_scale)); 697 | 698 | string pos_str = string.Format("Point:[{2:0.00},{3:0.00}] Position:[{0:0.00},{1:0.00}]", m_currentpos.X / m_scale / m_pixaxis, m_currentpos.Y / m_scale / m_pixaxis, m_cur_sel_point.m_x, m_cur_sel_point.m_y); 699 | if (isRebar == 1) 700 | pos_str = string.Format("[XY]:[{0:0.00},{1:0.00}]", m_cur_sel_point.m_x, m_cur_sel_point.m_y); 701 | this.DrawText(pos_str, new Point(0, 5)); 702 | 703 | } 704 | 705 | private void AddLine(CADLine line, int color_id = 0) 706 | { 707 | if (line == null) 708 | return; 709 | CADLine this_line = line.Copy(); 710 | if (this_line.m_id == 0) 711 | { 712 | LineNumber++; 713 | this_line.m_id = LineNumber; 714 | } 715 | int this_line_id = this_line.m_id; 716 | if (!AllColors.ContainsKey(color_id)) 717 | color_id = 1; 718 | if (this.AllLines.ContainsKey(this_line_id)) 719 | { 720 | AllLines[this_line_id] = this_line.Copy(); 721 | AllLinesColor[this_line_id] = color_id; 722 | CADPoint point = new CADPoint(this_line.m_xs, this_line.m_ys); 723 | List pointsItems = AllPointsInLines[this_line_id]; 724 | for (int i = 0; i < pointsItems.Count; i++) 725 | { 726 | if (AllPoints.ContainsKey(pointsItems[i])) 727 | AllPoints.Remove(pointsItems[i]); 728 | } 729 | pointsItems.Clear(); 730 | this.AddPoint(point); 731 | pointsItems.Add(PointNumber); 732 | point.m_x = this_line.m_xe; 733 | point.m_y = this_line.m_ye; 734 | this.AddPoint(point); 735 | pointsItems.Add(PointNumber); 736 | AllPointsInLines[this_line_id] = pointsItems; 737 | } 738 | else 739 | { 740 | AllLines.Add(this_line_id, this_line.Copy()); 741 | AllLinesColor.Add(this_line_id, color_id); 742 | CADPoint point = new CADPoint(this_line.m_xs, this_line.m_ys); 743 | List pointsItems = new List(); 744 | this.AddPoint(point); 745 | pointsItems.Add(PointNumber); 746 | point.m_x = this_line.m_xe; 747 | point.m_y = this_line.m_ye; 748 | this.AddPoint(point); 749 | pointsItems.Add(PointNumber); 750 | AllPointsInLines.Add(this_line_id, pointsItems); 751 | if (this_line.m_xs > this_line.m_xe) 752 | { 753 | m_border.m_xs = m_border.m_xs < this_line.m_xe ? m_border.m_xs : this_line.m_xe; 754 | m_border.m_xe = m_border.m_xe > this_line.m_xs ? m_border.m_xe : this_line.m_xs; 755 | } 756 | else 757 | { 758 | m_border.m_xs = m_border.m_xs < this_line.m_xs ? m_border.m_xs : this_line.m_xs; 759 | m_border.m_xe = m_border.m_xe > this_line.m_xe ? m_border.m_xe : this_line.m_xe; 760 | } 761 | if (this_line.m_ys > this_line.m_ye) 762 | { 763 | m_border.m_ys = m_border.m_ys < this_line.m_ye ? m_border.m_ys : this_line.m_ye; 764 | m_border.m_ye = m_border.m_ye > this_line.m_ys ? m_border.m_ye : this_line.m_ys; 765 | } 766 | else 767 | { 768 | m_border.m_ys = m_border.m_ys < this_line.m_ys ? m_border.m_ys : this_line.m_ys; 769 | m_border.m_ye = m_border.m_ye > this_line.m_ye ? m_border.m_ye : this_line.m_ye; 770 | } 771 | } 772 | if (AllLines.Count > 0) 773 | { 774 | foreach (int value in AllLines.Keys) 775 | { 776 | CADPoint point = this.GetCrossPoint(this_line, AllLines[value]); 777 | if (point != null) 778 | { 779 | point.m_style = 1; 780 | this.AddPoint(point); 781 | AllPointsInLines[this_line_id].Add(PointNumber); 782 | AllPointsInLines[value].Add(PointNumber); 783 | } 784 | } 785 | } 786 | if (AllRects.Count > 0) 787 | { 788 | foreach (int value in AllRects.Keys) 789 | { 790 | CADLine temp_this_line = new CADLine(); 791 | temp_this_line.m_xs = AllRects[value].m_xs; 792 | temp_this_line.m_ys = AllRects[value].m_ys; 793 | 794 | temp_this_line.m_xe = AllRects[value].m_xs; 795 | temp_this_line.m_ye = AllRects[value].m_ye; 796 | CADPoint point = this.GetCrossPoint(this_line, temp_this_line); 797 | if (point != null) 798 | { 799 | point.m_style = 1; 800 | this.AddPoint(point); 801 | AllPointsInLines[this_line_id].Add(PointNumber); 802 | AllPointsInRects[value].Add(PointNumber); 803 | } 804 | temp_this_line.m_xs = AllRects[value].m_xe; 805 | temp_this_line.m_ys = AllRects[value].m_ye; 806 | point = this.GetCrossPoint(this_line, temp_this_line); 807 | if (point != null) 808 | { 809 | point.m_style = 1; 810 | this.AddPoint(point); 811 | AllPointsInLines[this_line_id].Add(PointNumber); 812 | AllPointsInRects[value].Add(PointNumber); 813 | } 814 | temp_this_line.m_xe = AllRects[value].m_xe; 815 | temp_this_line.m_ye = AllRects[value].m_ys; 816 | point = this.GetCrossPoint(this_line, temp_this_line); 817 | if (point != null) 818 | { 819 | point.m_style = 1; 820 | this.AddPoint(point); 821 | AllPointsInLines[this_line_id].Add(PointNumber); 822 | AllPointsInRects[value].Add(PointNumber); 823 | } 824 | temp_this_line.m_xs = AllRects[value].m_xs; 825 | temp_this_line.m_ys = AllRects[value].m_ys; 826 | point = this.GetCrossPoint(this_line, temp_this_line); 827 | if (point != null) 828 | { 829 | point.m_style = 1; 830 | this.AddPoint(point); 831 | AllPointsInLines[this_line_id].Add(PointNumber); 832 | AllPointsInRects[value].Add(PointNumber); 833 | } 834 | } 835 | } 836 | } 837 | 838 | 839 | 840 | private void AddPoint(CADPoint point) 841 | { 842 | if (point == null) 843 | return; 844 | CADPoint this_point = point.Copy(); 845 | if (this_point.m_id == 0) 846 | { 847 | PointNumber++; 848 | this_point.m_id = PointNumber; 849 | } 850 | int this_point_id = this_point.m_id; 851 | //if (!AllColors.ContainsKey(color_id)) 852 | // color_id = 1; 853 | this_point.m_count++; 854 | if (this.AllPoints.ContainsKey(this_point_id)) 855 | { 856 | AllPoints[this_point_id] = this_point.Copy(); 857 | //AllLinesColor[LineNumber] = color_id; 858 | } 859 | else 860 | { 861 | AllPoints.Add(this_point_id, this_point.Copy()); 862 | } 863 | } 864 | 865 | private bool AddCube(CADCube cube, int color_id = 0) 866 | { 867 | if (cube == null) 868 | return false; 869 | CADCube this_cube = cube.Copy(); 870 | if (this_cube.m_id == 0) 871 | { 872 | CubeNumber++; 873 | this_cube.m_id = CubeNumber; 874 | } 875 | int this_cube_id = this_cube.m_id; 876 | if (!AllColors.ContainsKey(color_id)) 877 | color_id = 1; 878 | if (!AllCubesColor.ContainsKey(this_cube_id)) 879 | AllCubesColor.Add(this_cube_id, color_id); 880 | if (this.AllCubes.ContainsKey(this_cube_id)) 881 | { 882 | AllCubes[this_cube_id] = this_cube.Copy(); 883 | } 884 | else 885 | { 886 | AllCubes.Add(this_cube_id, this_cube.Copy()); 887 | } 888 | return true; 889 | } 890 | 891 | private bool AddRect(CADRect rect, int color_id = 0) 892 | { 893 | if (rect == null) 894 | return false; 895 | foreach (CADRect value in this.AllRects.Values) 896 | { 897 | if (((int)(value.m_xs + value.m_xe) - (int)(rect.m_xs + rect.m_xe)) == 0 && 898 | ((int)(value.m_ys + value.m_ye) - (int)(rect.m_ys + rect.m_ye)) == 0 && 899 | (int)(value.m_height - rect.m_height) == 0 && 900 | (int)(value.m_width - rect.m_width) == 0 && 901 | value.m_id != rect.m_id) 902 | { 903 | return false; 904 | } 905 | } 906 | CADRect this_rect = rect.Copy(); 907 | if (this_rect.m_id == 0) 908 | { 909 | RectNumber++; 910 | this_rect.m_id = RectNumber; 911 | } 912 | if (!AllColors.ContainsKey(color_id)) 913 | color_id = 1; 914 | int this_rect_id = this_rect.m_id; 915 | if (this.AllRects.ContainsKey(this_rect_id)) 916 | { 917 | AllRects[this_rect_id] = this_rect.Copy(); 918 | AllRectsColor[this_rect_id] = color_id; 919 | CADPoint point = new CADPoint(this_rect.m_xs, this_rect.m_ys); 920 | List pointsItems = AllPointsInRects[this_rect_id]; 921 | for (int i = 0; i < pointsItems.Count; i++) 922 | { 923 | if (AllPoints.ContainsKey(pointsItems[i])) 924 | AllPoints.Remove(pointsItems[i]); 925 | } 926 | pointsItems.Clear(); 927 | this.AddPoint(point);//角点 928 | pointsItems.Add(PointNumber); 929 | point.m_x = this_rect.m_xs; 930 | point.m_y = this_rect.m_ye; 931 | this.AddPoint(point);//角点 932 | pointsItems.Add(PointNumber); 933 | point.m_x = this_rect.m_xe; 934 | point.m_y = this_rect.m_ys; 935 | this.AddPoint(point);//角点 936 | pointsItems.Add(PointNumber); 937 | point.m_x = this_rect.m_xe; 938 | point.m_y = this_rect.m_ye; 939 | this.AddPoint(point);//角点 940 | pointsItems.Add(PointNumber); 941 | if (isRebar != 1) 942 | { 943 | point.m_x = (this_rect.m_xs + this_rect.m_xe) / 2; 944 | point.m_y = (this_rect.m_ys + this_rect.m_ye) / 2; 945 | this.AddPoint(point);//中心 946 | pointsItems.Add(PointNumber); 947 | } 948 | point.m_x = this_rect.m_xs; 949 | point.m_y = (this_rect.m_ys + this_rect.m_ye) / 2; 950 | this.AddPoint(point);//边中点 951 | pointsItems.Add(PointNumber); 952 | point.m_x = this_rect.m_xe; 953 | point.m_y = (this_rect.m_ys + this_rect.m_ye) / 2; 954 | this.AddPoint(point);//边中点 955 | pointsItems.Add(PointNumber); 956 | point.m_x = (this_rect.m_xs + this_rect.m_xe) / 2; 957 | point.m_y = this_rect.m_ys; 958 | this.AddPoint(point);//边中点 959 | pointsItems.Add(PointNumber); 960 | point.m_x = (this_rect.m_xs + this_rect.m_xe) / 2; 961 | point.m_y = this_rect.m_ye; 962 | this.AddPoint(point);//边中点 963 | pointsItems.Add(PointNumber); 964 | //int[] pointsItems = { PointNumber - 3, PointNumber - 2,PointNumber - 1, PointNumber }; 965 | AllPointsInRects[this_rect_id] = pointsItems; 966 | for (int i = 0; i < m_sel_rect_list.Count; i++) 967 | { 968 | if (m_sel_rect_list[i].m_id == this_rect_id) 969 | { 970 | m_sel_rect_list[i] = AllRects[this_rect_id]; 971 | } 972 | } 973 | } 974 | else 975 | { 976 | AllRects.Add(this_rect_id, this_rect.Copy()); 977 | AllRectsColor.Add(this_rect_id, color_id); 978 | CADPoint point = new CADPoint(this_rect.m_xs, this_rect.m_ys); 979 | List pointsItems = new List(); 980 | this.AddPoint(point);//角点 981 | pointsItems.Add(PointNumber); 982 | point = new CADPoint(); 983 | point.m_x = this_rect.m_xs; 984 | point.m_y = this_rect.m_ye; 985 | this.AddPoint(point);//角点 986 | pointsItems.Add(PointNumber); 987 | point = new CADPoint(); 988 | point.m_x = this_rect.m_xe; 989 | point.m_y = this_rect.m_ys; 990 | this.AddPoint(point);//角点 991 | pointsItems.Add(PointNumber); 992 | point = new CADPoint(); 993 | point.m_x = this_rect.m_xe; 994 | point.m_y = this_rect.m_ye; 995 | this.AddPoint(point);//角点 996 | pointsItems.Add(PointNumber); 997 | if (isRebar != 1) 998 | { 999 | point = new CADPoint(); 1000 | point.m_x = (this_rect.m_xs + this_rect.m_xe) / 2; 1001 | point.m_y = (this_rect.m_ys + this_rect.m_ye) / 2; 1002 | this.AddPoint(point);//中心 1003 | pointsItems.Add(PointNumber); 1004 | } 1005 | point = new CADPoint(); 1006 | point.m_x = this_rect.m_xs; 1007 | point.m_y = (this_rect.m_ys + this_rect.m_ye) / 2; 1008 | this.AddPoint(point);//边中点 1009 | pointsItems.Add(PointNumber); 1010 | point = new CADPoint(); 1011 | point.m_x = this_rect.m_xe; 1012 | point.m_y = (this_rect.m_ys + this_rect.m_ye) / 2; 1013 | this.AddPoint(point);//边中点 1014 | pointsItems.Add(PointNumber); 1015 | point = new CADPoint(); 1016 | point.m_x = (this_rect.m_xs + this_rect.m_xe) / 2; 1017 | point.m_y = this_rect.m_ys; 1018 | this.AddPoint(point);//边中点 1019 | pointsItems.Add(PointNumber); 1020 | point = new CADPoint(); 1021 | point.m_x = (this_rect.m_xs + this_rect.m_xe) / 2; 1022 | point.m_y = this_rect.m_ye; 1023 | this.AddPoint(point);//边中点 1024 | pointsItems.Add(PointNumber); 1025 | //int[] pointsItems = { PointNumber - 3, PointNumber - 2, PointNumber - 1, PointNumber }; 1026 | AllPointsInRects.Add(this_rect_id, pointsItems); 1027 | if (this_rect.m_xs > this_rect.m_xe) 1028 | { 1029 | m_border.m_xs = m_border.m_xs < this_rect.m_xe ? m_border.m_xs : this_rect.m_xe; 1030 | m_border.m_xe = m_border.m_xe > this_rect.m_xs ? m_border.m_xe : this_rect.m_xs; 1031 | } 1032 | else 1033 | { 1034 | m_border.m_xs = m_border.m_xs < this_rect.m_xs ? m_border.m_xs : this_rect.m_xs; 1035 | m_border.m_xe = m_border.m_xe > this_rect.m_xe ? m_border.m_xe : this_rect.m_xe; 1036 | } 1037 | if (this_rect.m_ys > this_rect.m_ye) 1038 | { 1039 | m_border.m_ys = m_border.m_ys < this_rect.m_ye ? m_border.m_ys : this_rect.m_ye; 1040 | m_border.m_ye = m_border.m_ye > this_rect.m_ys ? m_border.m_ye : this_rect.m_ys; 1041 | } 1042 | else 1043 | { 1044 | m_border.m_ys = m_border.m_ys < this_rect.m_ys ? m_border.m_ys : this_rect.m_ys; 1045 | m_border.m_ye = m_border.m_ye > this_rect.m_ye ? m_border.m_ye : this_rect.m_ye; 1046 | } 1047 | } 1048 | if (AllLines.Count > 0) 1049 | { 1050 | foreach (int value in AllLines.Keys) 1051 | { 1052 | 1053 | CADLine cur_line = AllLines[value]; 1054 | CADLine this_rect_line = new CADLine(); 1055 | this_rect_line.m_xs = this_rect.m_xs; 1056 | this_rect_line.m_ys = this_rect.m_ys; 1057 | 1058 | this_rect_line.m_xe = this_rect.m_xs; 1059 | this_rect_line.m_ye = this_rect.m_ye; 1060 | CADPoint point = this.GetCrossPoint(this_rect_line, cur_line); 1061 | if (point != null) 1062 | { 1063 | this.AddPoint(point); 1064 | AllPointsInRects[this_rect_id].Add(PointNumber); 1065 | AllPointsInLines[value].Add(PointNumber); 1066 | } 1067 | 1068 | this_rect_line.m_xs = this_rect.m_xe; 1069 | this_rect_line.m_ys = this_rect.m_ye; 1070 | point = this.GetCrossPoint(this_rect_line, cur_line); 1071 | if (point != null) 1072 | { 1073 | this.AddPoint(point); 1074 | AllPointsInRects[this_rect_id].Add(PointNumber); 1075 | AllPointsInLines[value].Add(PointNumber); 1076 | } 1077 | this_rect_line.m_xe = this_rect.m_xe; 1078 | this_rect_line.m_ye = this_rect.m_ys; 1079 | point = this.GetCrossPoint(this_rect_line, cur_line); 1080 | if (point != null) 1081 | { 1082 | this.AddPoint(point); 1083 | AllPointsInRects[this_rect_id].Add(PointNumber); 1084 | AllPointsInLines[value].Add(PointNumber); 1085 | } 1086 | this_rect_line.m_xs = this_rect.m_xs; 1087 | this_rect_line.m_ys = this_rect.m_ys; 1088 | point = this.GetCrossPoint(this_rect_line, cur_line); 1089 | if (point != null) 1090 | { 1091 | this.AddPoint(point); 1092 | AllPointsInRects[this_rect_id].Add(PointNumber); 1093 | AllPointsInLines[value].Add(PointNumber); 1094 | } 1095 | } 1096 | } 1097 | if (AllRects.Count > 0) 1098 | { 1099 | foreach (int value in AllRects.Keys) 1100 | { 1101 | if (value == this_rect.m_id) 1102 | continue; 1103 | CADRect cur_this_rect = AllRects[value]; 1104 | CADLine this_rect_line = new CADLine(); 1105 | this_rect_line.m_xs = this_rect.m_xs; 1106 | this_rect_line.m_ys = this_rect.m_ys; 1107 | 1108 | this_rect_line.m_xe = this_rect.m_xs; 1109 | this_rect_line.m_ye = this_rect.m_ye; 1110 | 1111 | CADLine temp_line = new CADLine(); 1112 | temp_line.m_xs = cur_this_rect.m_xs; 1113 | temp_line.m_ys = cur_this_rect.m_ys; 1114 | 1115 | temp_line.m_xe = cur_this_rect.m_xs; 1116 | temp_line.m_ye = cur_this_rect.m_ye; 1117 | CADPoint point = this.GetCrossPoint(this_rect_line, temp_line); 1118 | if (point != null) 1119 | { 1120 | this.AddPoint(point); 1121 | AllPointsInRects[this_rect_id].Add(PointNumber); 1122 | AllPointsInRects[value].Add(PointNumber); 1123 | } 1124 | 1125 | temp_line.m_xs = cur_this_rect.m_xe; 1126 | temp_line.m_ys = cur_this_rect.m_ye; 1127 | point = this.GetCrossPoint(this_rect_line, temp_line); 1128 | if (point != null) 1129 | { 1130 | this.AddPoint(point); 1131 | AllPointsInRects[this_rect_id].Add(PointNumber); 1132 | AllPointsInRects[value].Add(PointNumber); 1133 | } 1134 | temp_line.m_xe = cur_this_rect.m_xe; 1135 | temp_line.m_ye = cur_this_rect.m_ys; 1136 | point = this.GetCrossPoint(this_rect_line, temp_line); 1137 | if (point != null) 1138 | { 1139 | this.AddPoint(point); 1140 | AllPointsInRects[this_rect_id].Add(PointNumber); 1141 | AllPointsInRects[value].Add(PointNumber); 1142 | } 1143 | temp_line.m_xs = cur_this_rect.m_xs; 1144 | temp_line.m_ys = cur_this_rect.m_ys; 1145 | point = this.GetCrossPoint(this_rect_line, temp_line); 1146 | if (point != null) 1147 | { 1148 | this.AddPoint(point); 1149 | AllPointsInRects[this_rect_id].Add(PointNumber); 1150 | AllPointsInRects[value].Add(PointNumber); 1151 | } 1152 | 1153 | 1154 | this_rect_line.m_xs = cur_this_rect.m_xe; 1155 | this_rect_line.m_ys = cur_this_rect.m_ye; 1156 | 1157 | temp_line.m_xs = cur_this_rect.m_xs; 1158 | temp_line.m_ys = cur_this_rect.m_ys; 1159 | 1160 | temp_line.m_xe = cur_this_rect.m_xs; 1161 | temp_line.m_ye = cur_this_rect.m_ye; 1162 | point = this.GetCrossPoint(this_rect_line, temp_line); 1163 | if (point != null) 1164 | { 1165 | this.AddPoint(point); 1166 | AllPointsInRects[this_rect_id].Add(PointNumber); 1167 | AllPointsInRects[value].Add(PointNumber); 1168 | } 1169 | 1170 | temp_line.m_xs = cur_this_rect.m_xe; 1171 | temp_line.m_ys = cur_this_rect.m_ye; 1172 | point = this.GetCrossPoint(this_rect_line, temp_line); 1173 | if (point != null) 1174 | { 1175 | this.AddPoint(point); 1176 | AllPointsInRects[this_rect_id].Add(PointNumber); 1177 | AllPointsInRects[value].Add(PointNumber); 1178 | } 1179 | temp_line.m_xe = cur_this_rect.m_xe; 1180 | temp_line.m_ye = cur_this_rect.m_ys; 1181 | point = this.GetCrossPoint(this_rect_line, temp_line); 1182 | if (point != null) 1183 | { 1184 | this.AddPoint(point); 1185 | AllPointsInRects[this_rect_id].Add(PointNumber); 1186 | AllPointsInRects[value].Add(PointNumber); 1187 | } 1188 | temp_line.m_xs = cur_this_rect.m_xs; 1189 | temp_line.m_ys = cur_this_rect.m_ys; 1190 | point = this.GetCrossPoint(this_rect_line, temp_line); 1191 | if (point != null) 1192 | { 1193 | this.AddPoint(point); 1194 | AllPointsInRects[this_rect_id].Add(PointNumber); 1195 | AllPointsInRects[value].Add(PointNumber); 1196 | } 1197 | 1198 | 1199 | this_rect_line.m_xe = cur_this_rect.m_xe; 1200 | this_rect_line.m_ye = cur_this_rect.m_ys; 1201 | 1202 | temp_line.m_xs = cur_this_rect.m_xs; 1203 | temp_line.m_ys = cur_this_rect.m_ys; 1204 | 1205 | temp_line.m_xe = cur_this_rect.m_xs; 1206 | temp_line.m_ye = cur_this_rect.m_ye; 1207 | point = this.GetCrossPoint(this_rect_line, temp_line); 1208 | if (point != null) 1209 | { 1210 | this.AddPoint(point); 1211 | AllPointsInRects[this_rect_id].Add(PointNumber); 1212 | AllPointsInRects[value].Add(PointNumber); 1213 | } 1214 | 1215 | temp_line.m_xs = cur_this_rect.m_xe; 1216 | temp_line.m_ys = cur_this_rect.m_ye; 1217 | point = this.GetCrossPoint(this_rect_line, temp_line); 1218 | if (point != null) 1219 | { 1220 | this.AddPoint(point); 1221 | AllPointsInRects[this_rect_id].Add(PointNumber); 1222 | AllPointsInRects[value].Add(PointNumber); 1223 | } 1224 | temp_line.m_xe = cur_this_rect.m_xe; 1225 | temp_line.m_ye = cur_this_rect.m_ys; 1226 | point = this.GetCrossPoint(this_rect_line, temp_line); 1227 | if (point != null) 1228 | { 1229 | this.AddPoint(point); 1230 | AllPointsInRects[this_rect_id].Add(PointNumber); 1231 | AllPointsInRects[value].Add(PointNumber); 1232 | } 1233 | temp_line.m_xs = cur_this_rect.m_xs; 1234 | temp_line.m_ys = cur_this_rect.m_ys; 1235 | point = this.GetCrossPoint(this_rect_line, temp_line); 1236 | if (point != null) 1237 | { 1238 | this.AddPoint(point); 1239 | AllPointsInRects[this_rect_id].Add(PointNumber); 1240 | AllPointsInRects[value].Add(PointNumber); 1241 | } 1242 | 1243 | this_rect_line.m_xs = cur_this_rect.m_xs; 1244 | this_rect_line.m_ys = cur_this_rect.m_ys; 1245 | 1246 | temp_line.m_xs = cur_this_rect.m_xs; 1247 | temp_line.m_ys = cur_this_rect.m_ys; 1248 | 1249 | temp_line.m_xe = cur_this_rect.m_xs; 1250 | temp_line.m_ye = cur_this_rect.m_ye; 1251 | point = this.GetCrossPoint(this_rect_line, temp_line); 1252 | if (point != null) 1253 | { 1254 | this.AddPoint(point); 1255 | AllPointsInRects[this_rect_id].Add(PointNumber); 1256 | AllPointsInRects[value].Add(PointNumber); 1257 | } 1258 | 1259 | temp_line.m_xs = cur_this_rect.m_xe; 1260 | temp_line.m_ys = cur_this_rect.m_ye; 1261 | point = this.GetCrossPoint(this_rect_line, temp_line); 1262 | if (point != null) 1263 | { 1264 | this.AddPoint(point); 1265 | AllPointsInRects[this_rect_id].Add(PointNumber); 1266 | AllPointsInRects[value].Add(PointNumber); 1267 | } 1268 | temp_line.m_xe = cur_this_rect.m_xe; 1269 | temp_line.m_ye = cur_this_rect.m_ys; 1270 | point = this.GetCrossPoint(this_rect_line, temp_line); 1271 | if (point != null) 1272 | { 1273 | this.AddPoint(point); 1274 | AllPointsInRects[this_rect_id].Add(PointNumber); 1275 | AllPointsInRects[value].Add(PointNumber); 1276 | } 1277 | temp_line.m_xs = cur_this_rect.m_xs; 1278 | temp_line.m_ys = cur_this_rect.m_ys; 1279 | point = this.GetCrossPoint(this_rect_line, temp_line); 1280 | if (point != null) 1281 | { 1282 | this.AddPoint(point); 1283 | AllPointsInRects[this_rect_id].Add(PointNumber); 1284 | AllPointsInRects[value].Add(PointNumber); 1285 | } 1286 | 1287 | } 1288 | } 1289 | return true; 1290 | } 1291 | 1292 | 1293 | private void SelLine(int line_id) 1294 | { 1295 | if (!this.SelLines.ContainsKey(line_id)) 1296 | { 1297 | this.SelLines.Add(line_id, this.AllLines[line_id]); 1298 | } 1299 | else 1300 | this.SelLines.Remove(line_id); 1301 | } 1302 | 1303 | 1304 | private void SelPoint(int point_id) 1305 | { 1306 | if (!this.SelPoints.ContainsKey(point_id)) 1307 | { 1308 | this.SelPoints.Add(point_id, this.AllPoints[point_id]); 1309 | //m_sel_point_list.Add(this.AllPoints[point_id]); 1310 | bool flag = false; 1311 | for (int i = 0; i < m_sel_point_list.Count; i++) 1312 | { 1313 | if (m_sel_point_list[i].m_id == point_id) 1314 | { 1315 | m_sel_point_list[i] = this.AllPoints[point_id]; 1316 | flag = true; 1317 | break; 1318 | } 1319 | 1320 | } 1321 | if (!flag) 1322 | m_sel_point_list.Add(this.AllPoints[point_id]); 1323 | } 1324 | else 1325 | { 1326 | this.SelPoints.Remove(point_id); 1327 | for (int i = 0; i < m_sel_point_list.Count; i++) 1328 | { 1329 | if (m_sel_point_list[i].m_id == point_id) 1330 | { 1331 | m_sel_point_list.RemoveAt(i); 1332 | break; 1333 | } 1334 | } 1335 | m_cur_sel_point = new CADPoint(); 1336 | } 1337 | } 1338 | 1339 | 1340 | private void SelRect(int rect_id) 1341 | { 1342 | if (!this.SelRects.ContainsKey(rect_id)) 1343 | { 1344 | this.SelRects.Add(rect_id, this.AllRects[rect_id].Copy()); 1345 | bool flag = false; 1346 | for (int i = 0; i < m_sel_rect_list.Count; i++) 1347 | { 1348 | if (m_sel_rect_list[i].m_id == rect_id) 1349 | { 1350 | m_sel_rect_list[i] = this.AllRects[rect_id]; 1351 | flag = true; 1352 | break; 1353 | } 1354 | } 1355 | if (!flag) 1356 | m_sel_rect_list.Add(this.AllRects[rect_id]); 1357 | } 1358 | else 1359 | { 1360 | this.SelRects.Remove(rect_id); 1361 | for (int i = 0; i < m_sel_rect_list.Count; i++) 1362 | { 1363 | if (m_sel_rect_list[i].m_id == rect_id) 1364 | { 1365 | m_sel_rect_list.RemoveAt(i); 1366 | break; 1367 | } 1368 | } 1369 | 1370 | } 1371 | } 1372 | 1373 | 1374 | private void DrawLine(CADLine line, CADRGB color = null) 1375 | { 1376 | if (line.m_id == -1) 1377 | return; 1378 | m_openGLCtrl.LineWidth(1); 1379 | m_openGLCtrl.Begin(SharpGL.Enumerations.BeginMode.Lines); 1380 | if (color == null) 1381 | m_openGLCtrl.Color(1.0f, 1.0f, 1.0f); 1382 | else 1383 | m_openGLCtrl.Color(color.m_r, color.m_g, color.m_b); 1384 | m_openGLCtrl.Vertex(line.m_xs, line.m_ys, line.m_zs); 1385 | m_openGLCtrl.Vertex(line.m_xe, line.m_ye, line.m_ze); 1386 | m_openGLCtrl.End(); 1387 | m_openGLCtrl.Flush(); 1388 | } 1389 | 1390 | private void DrawCoord(double scale) 1391 | { 1392 | m_openGLCtrl.LineWidth(2); 1393 | m_openGLCtrl.Begin(SharpGL.Enumerations.BeginMode.Lines); 1394 | 1395 | m_openGLCtrl.Color(1.0f, 0.0f, 0.0f); 1396 | m_openGLCtrl.Vertex(ax_p.m_x / scale, ax_p.m_y / scale, ax_p.m_z / scale); 1397 | m_openGLCtrl.Vertex( zero.m_x / scale, zero.m_y / scale, zero.m_z / scale); 1398 | 1399 | m_openGLCtrl.Color(0.0f, 1.0f, 0.0f); 1400 | m_openGLCtrl.Vertex(ay_p.m_x / scale, ay_p.m_y / scale, ay_p.m_z / scale); 1401 | m_openGLCtrl.Vertex(zero.m_x / scale, zero.m_y / scale, zero.m_z / scale); 1402 | 1403 | m_openGLCtrl.Color(0.0f, 0.0f, 1.0f); 1404 | m_openGLCtrl.Vertex(az_p.m_x / scale, az_p.m_y / scale, az_p.m_z / scale); 1405 | m_openGLCtrl.Vertex(zero.m_x / scale, zero.m_y / scale, zero.m_z / scale); 1406 | 1407 | m_openGLCtrl.End(); 1408 | m_openGLCtrl.Flush(); 1409 | 1410 | m_openGLCtrl.LineWidth(1); 1411 | m_openGLCtrl.Begin(SharpGL.Enumerations.BeginMode.Lines); 1412 | 1413 | m_openGLCtrl.Color(0.0f, 1.0f, 1.0f); 1414 | m_openGLCtrl.Vertex(ax_p.m_x / 3 / scale, ax_p.m_y / 3 / scale, ax_p.m_z / 3 / scale); 1415 | m_openGLCtrl.Vertex(ay_p.m_x / 3 / scale, ay_p.m_y / 3 / scale, ay_p.m_z / 3 / scale); 1416 | 1417 | m_openGLCtrl.Color(1.0f, 0.0f, 1.0f); 1418 | m_openGLCtrl.Vertex(ay_p.m_x / 3 / scale, ay_p.m_y / 3 / scale, ay_p.m_z / 3 / scale); 1419 | m_openGLCtrl.Vertex(az_p.m_x / 3 / scale, az_p.m_y / 3 / scale, az_p.m_z / 3 / scale); 1420 | 1421 | m_openGLCtrl.Color(1.0f, 1.0f, 0.0f); 1422 | m_openGLCtrl.Vertex(az_p.m_x / 3 / scale, az_p.m_y / 3 / scale, az_p.m_z / 3 / scale); 1423 | m_openGLCtrl.Vertex(ax_p.m_x / 3 / scale, ax_p.m_y / 3 / scale, ax_p.m_z / 3 / scale); 1424 | 1425 | m_openGLCtrl.End(); 1426 | m_openGLCtrl.Flush(); 1427 | } 1428 | 1429 | 1430 | private void DrawPoint(CADPoint point, CADRGB color = null) 1431 | { 1432 | if (point.m_style == 0) 1433 | m_openGLCtrl.PointSize(3.0f); 1434 | if (point.m_style == 1) 1435 | m_openGLCtrl.PointSize(2.5f); 1436 | if (isRebar == 1) 1437 | m_openGLCtrl.PointSize(5.0f); 1438 | if (point.m_is_rebar == 1) 1439 | { 1440 | m_openGLCtrl.Begin(SharpGL.Enumerations.BeginMode.Polygon); 1441 | if (color == null) 1442 | m_openGLCtrl.Color(1.0f, 1.0f, 0.0f); 1443 | 1444 | double r = 12; 1445 | if (point.m_diameter > 0) 1446 | r = 10 * point.m_diameter; 1447 | double pi = 3.1415926; 1448 | int n = 20; 1449 | for (int i = 0; i < n; i++) 1450 | m_openGLCtrl.Vertex(point.m_x + r * Math.Cos(2 * pi / n * i), point.m_y + r * Math.Sin(2 * pi / n * i)); 1451 | m_openGLCtrl.End(); 1452 | m_openGLCtrl.Flush(); 1453 | return; 1454 | 1455 | } 1456 | else 1457 | { 1458 | m_openGLCtrl.Begin(SharpGL.Enumerations.BeginMode.Points); 1459 | 1460 | if (color == null) 1461 | { 1462 | m_openGLCtrl.Color(1.0f, 1.0f, 1.0f); 1463 | if (point.m_style == 1) 1464 | m_openGLCtrl.Color(0.0f, 1.0f, 1.0f); 1465 | } 1466 | else 1467 | m_openGLCtrl.Color(color.m_r, color.m_g, color.m_b); 1468 | m_openGLCtrl.Vertex(point.m_x, point.m_y, point.m_z); 1469 | m_openGLCtrl.End(); 1470 | m_openGLCtrl.Flush(); 1471 | } 1472 | } 1473 | 1474 | 1475 | private void DrawGridLine(CADLine line) 1476 | { 1477 | m_openGLCtrl.LineWidth(1); 1478 | m_openGLCtrl.Begin(SharpGL.Enumerations.BeginMode.Lines); 1479 | m_openGLCtrl.Color(0.2f, 0.2f, 0.2f); 1480 | m_openGLCtrl.Vertex(line.m_xs, line.m_ys, line.m_zs); 1481 | m_openGLCtrl.Vertex(line.m_xe, line.m_ye, line.m_ze); 1482 | m_openGLCtrl.End(); 1483 | m_openGLCtrl.Flush(); 1484 | } 1485 | 1486 | private void DrawRect(CADRect rect, CADRGB color = null) 1487 | { 1488 | m_openGLCtrl.LineWidth(1); 1489 | m_openGLCtrl.Begin(SharpGL.Enumerations.BeginMode.Lines); 1490 | if (color == null) 1491 | m_openGLCtrl.Color(1.0f, 1.0f, 1.0f); 1492 | else 1493 | m_openGLCtrl.Color(color.m_r, color.m_g, color.m_b); 1494 | m_openGLCtrl.Vertex(rect.m_xs, rect.m_ys); 1495 | m_openGLCtrl.Vertex(rect.m_xe, rect.m_ys); 1496 | 1497 | m_openGLCtrl.Vertex(rect.m_xe, rect.m_ys); 1498 | m_openGLCtrl.Vertex(rect.m_xe, rect.m_ye); 1499 | 1500 | m_openGLCtrl.Vertex(rect.m_xe, rect.m_ye); 1501 | m_openGLCtrl.Vertex(rect.m_xs, rect.m_ye); 1502 | 1503 | m_openGLCtrl.Vertex(rect.m_xs, rect.m_ye); 1504 | m_openGLCtrl.Vertex(rect.m_xs, rect.m_ys); 1505 | 1506 | m_openGLCtrl.End(); 1507 | m_openGLCtrl.Flush(); 1508 | } 1509 | 1510 | 1511 | 1512 | private void DrawRect3D(Rect3D rect3d, CADRGB color = null) 1513 | { 1514 | 1515 | } 1516 | 1517 | 1518 | private void DrawCube(CADCube cube, CADRGB color = null) 1519 | { 1520 | //m_openGLCtrl.LineWidth(1); 1521 | m_openGLCtrl.Begin(SharpGL.Enumerations.BeginMode.Quads); 1522 | //if (color == null) 1523 | // m_openGLCtrl.Color(1.0f, 1.0f, 1.0f); 1524 | //else 1525 | // m_openGLCtrl.Color(color.m_r, color.m_g, color.m_b); 1526 | //m_openGLCtrl.Color(1.0f, 1.0f, 0.0f); 1527 | if(AllColors.ContainsKey(cube.color)) 1528 | m_openGLCtrl.Color(AllColors[cube.color].m_r, AllColors[cube.color].m_g, AllColors[cube.color].m_b); 1529 | else 1530 | m_openGLCtrl.Color(1.0f, 1.0f, 0.0f); 1531 | m_openGLCtrl.Vertex(cube.m_surfs[0].m_points[0].m_x, cube.m_surfs[0].m_points[0].m_y, cube.m_surfs[0].m_points[0].m_z); 1532 | m_openGLCtrl.Vertex(cube.m_surfs[0].m_points[1].m_x, cube.m_surfs[0].m_points[1].m_y, cube.m_surfs[0].m_points[1].m_z); 1533 | m_openGLCtrl.Vertex(cube.m_surfs[0].m_points[2].m_x, cube.m_surfs[0].m_points[2].m_y, cube.m_surfs[0].m_points[2].m_z); 1534 | m_openGLCtrl.Vertex(cube.m_surfs[0].m_points[3].m_x, cube.m_surfs[0].m_points[3].m_y, cube.m_surfs[0].m_points[3].m_z); 1535 | 1536 | //m_openGLCtrl.Color(1.0f, 0.0f, 1.0f); 1537 | m_openGLCtrl.Vertex(cube.m_surfs[1].m_points[0].m_x, cube.m_surfs[1].m_points[0].m_y, cube.m_surfs[1].m_points[0].m_z); 1538 | m_openGLCtrl.Vertex(cube.m_surfs[1].m_points[1].m_x, cube.m_surfs[1].m_points[1].m_y, cube.m_surfs[1].m_points[1].m_z); 1539 | m_openGLCtrl.Vertex(cube.m_surfs[1].m_points[2].m_x, cube.m_surfs[1].m_points[2].m_y, cube.m_surfs[1].m_points[2].m_z); 1540 | m_openGLCtrl.Vertex(cube.m_surfs[1].m_points[3].m_x, cube.m_surfs[1].m_points[3].m_y, cube.m_surfs[1].m_points[3].m_z); 1541 | 1542 | //m_openGLCtrl.Color(0.0f, 1.0f, 1.0f); 1543 | m_openGLCtrl.Vertex(cube.m_surfs[2].m_points[0].m_x, cube.m_surfs[2].m_points[0].m_y, cube.m_surfs[2].m_points[0].m_z); 1544 | m_openGLCtrl.Vertex(cube.m_surfs[2].m_points[1].m_x, cube.m_surfs[2].m_points[1].m_y, cube.m_surfs[2].m_points[1].m_z); 1545 | m_openGLCtrl.Vertex(cube.m_surfs[2].m_points[2].m_x, cube.m_surfs[2].m_points[2].m_y, cube.m_surfs[2].m_points[2].m_z); 1546 | m_openGLCtrl.Vertex(cube.m_surfs[2].m_points[3].m_x, cube.m_surfs[2].m_points[3].m_y, cube.m_surfs[2].m_points[3].m_z); 1547 | 1548 | //m_openGLCtrl.Color(0.0f, 0.0f, 1.0f); 1549 | m_openGLCtrl.Vertex(cube.m_surfs[3].m_points[0].m_x, cube.m_surfs[3].m_points[0].m_y, cube.m_surfs[3].m_points[0].m_z); 1550 | m_openGLCtrl.Vertex(cube.m_surfs[3].m_points[1].m_x, cube.m_surfs[3].m_points[1].m_y, cube.m_surfs[3].m_points[1].m_z); 1551 | m_openGLCtrl.Vertex(cube.m_surfs[3].m_points[2].m_x, cube.m_surfs[3].m_points[2].m_y, cube.m_surfs[3].m_points[2].m_z); 1552 | m_openGLCtrl.Vertex(cube.m_surfs[3].m_points[3].m_x, cube.m_surfs[3].m_points[3].m_y, cube.m_surfs[3].m_points[3].m_z); 1553 | 1554 | //m_openGLCtrl.Color(0.0f, 1.0f, 0.0f); 1555 | m_openGLCtrl.Vertex(cube.m_surfs[4].m_points[0].m_x, cube.m_surfs[4].m_points[0].m_y, cube.m_surfs[4].m_points[0].m_z); 1556 | m_openGLCtrl.Vertex(cube.m_surfs[4].m_points[1].m_x, cube.m_surfs[4].m_points[1].m_y, cube.m_surfs[4].m_points[1].m_z); 1557 | m_openGLCtrl.Vertex(cube.m_surfs[4].m_points[2].m_x, cube.m_surfs[4].m_points[2].m_y, cube.m_surfs[4].m_points[2].m_z); 1558 | m_openGLCtrl.Vertex(cube.m_surfs[4].m_points[3].m_x, cube.m_surfs[4].m_points[3].m_y, cube.m_surfs[4].m_points[3].m_z); 1559 | 1560 | //m_openGLCtrl.Color(0.0f, 1.0f, 0.5f); 1561 | m_openGLCtrl.Vertex(cube.m_surfs[5].m_points[0].m_x, cube.m_surfs[5].m_points[0].m_y, cube.m_surfs[5].m_points[0].m_z); 1562 | m_openGLCtrl.Vertex(cube.m_surfs[5].m_points[1].m_x, cube.m_surfs[5].m_points[1].m_y, cube.m_surfs[5].m_points[1].m_z); 1563 | m_openGLCtrl.Vertex(cube.m_surfs[5].m_points[2].m_x, cube.m_surfs[5].m_points[2].m_y, cube.m_surfs[5].m_points[2].m_z); 1564 | m_openGLCtrl.Vertex(cube.m_surfs[5].m_points[3].m_x, cube.m_surfs[5].m_points[3].m_y, cube.m_surfs[5].m_points[3].m_z); 1565 | 1566 | log.Info(cube.m_surfs[5].m_points[3].m_x); 1567 | 1568 | m_openGLCtrl.End(); 1569 | m_openGLCtrl.Flush(); 1570 | 1571 | Teapot tp = new Teapot(); 1572 | tp.Draw(m_openGLCtrl, 14, 1, OpenGL.GL_FILL); 1573 | 1574 | } 1575 | 1576 | private void DrawSelLine(int line_id) 1577 | { 1578 | if (!AllLines.ContainsKey(line_id)) 1579 | return; 1580 | CADLine line = AllLines[line_id]; 1581 | m_openGLCtrl.LineWidth(5); 1582 | m_openGLCtrl.Begin(SharpGL.Enumerations.BeginMode.Lines); 1583 | m_openGLCtrl.Color(0.7f, 0.2f, 0.2f); 1584 | m_openGLCtrl.Vertex(line.m_xs, line.m_ys); 1585 | m_openGLCtrl.Vertex(line.m_xe, line.m_ye); 1586 | 1587 | m_openGLCtrl.End(); 1588 | m_openGLCtrl.Flush(); 1589 | } 1590 | 1591 | private void DrawSelPoint(int point_id) 1592 | { 1593 | if (!AllPoints.ContainsKey(point_id)) 1594 | return; 1595 | CADPoint point = AllPoints[point_id]; 1596 | if (point.m_is_rebar == 1) 1597 | { 1598 | m_openGLCtrl.Begin(SharpGL.Enumerations.BeginMode.Polygon); 1599 | m_openGLCtrl.Color(0.7f, 0.2f, 0.7f); 1600 | double r = 12; 1601 | if (point.m_diameter > 0) 1602 | r = 10 * point.m_diameter; 1603 | double pi = 3.1415926; 1604 | int n = 20; 1605 | for (int i = 0; i < n; i++) 1606 | m_openGLCtrl.Vertex(point.m_x + r * Math.Cos(2 * pi / n * i), point.m_y + r * Math.Sin(2 * pi / n * i)); 1607 | m_openGLCtrl.End(); 1608 | m_openGLCtrl.Flush(); 1609 | return; 1610 | 1611 | } 1612 | else 1613 | { 1614 | m_openGLCtrl.PointSize(8.0f); 1615 | m_openGLCtrl.Begin(SharpGL.Enumerations.BeginMode.Points); 1616 | m_openGLCtrl.Color(0.7f, 0.2f, 0.7f); 1617 | m_openGLCtrl.Vertex(point.m_x, point.m_y); 1618 | 1619 | m_openGLCtrl.End(); 1620 | m_openGLCtrl.Flush(); 1621 | } 1622 | } 1623 | 1624 | 1625 | private void DrawSelRect(int rect_id) 1626 | { 1627 | if (!AllRects.ContainsKey(rect_id)) 1628 | return; 1629 | CADRect rect = SelRects[rect_id];//AllRects[rect_id]; 1630 | 1631 | m_openGLCtrl.LineWidth(5); 1632 | m_openGLCtrl.Begin(SharpGL.Enumerations.BeginMode.Lines); 1633 | m_openGLCtrl.Color(0.2f, 0.7f, 0.2f); 1634 | m_openGLCtrl.Vertex(rect.m_xs, rect.m_ys); 1635 | m_openGLCtrl.Vertex(rect.m_xe, rect.m_ys); 1636 | 1637 | m_openGLCtrl.Vertex(rect.m_xe, rect.m_ys); 1638 | m_openGLCtrl.Vertex(rect.m_xe, rect.m_ye); 1639 | 1640 | m_openGLCtrl.Vertex(rect.m_xe, rect.m_ye); 1641 | m_openGLCtrl.Vertex(rect.m_xs, rect.m_ye); 1642 | 1643 | m_openGLCtrl.Vertex(rect.m_xs, rect.m_ye); 1644 | m_openGLCtrl.Vertex(rect.m_xs, rect.m_ys); 1645 | 1646 | m_openGLCtrl.End(); 1647 | m_openGLCtrl.Flush(); 1648 | } 1649 | 1650 | 1651 | private void DrawText(string text, Point pos) 1652 | { 1653 | float font_size = 12.0f; 1654 | if (isRebar == 1) 1655 | font_size = 8.0f; 1656 | m_openGLCtrl.DrawText((int)(pos.X), (int)(pos.Y), 0.5f, 1.0f, 0.5f, "Lucida Console", font_size, text); 1657 | } 1658 | 1659 | 1660 | private void DrawMouseLine(double scale) 1661 | { 1662 | //UserDrawLine(new Point(0,0),new Point(1000,1000)); 1663 | m_openGLCtrl.LineWidth(1); 1664 | m_openGLCtrl.Begin(SharpGL.Enumerations.BeginMode.Lines); 1665 | m_openGLCtrl.Color(1.0f, 1.0f, 1.0f); 1666 | //m_openGLCtrl.Vertex(0, 0); 1667 | //m_openGLCtrl.Vertex(1000, -1000); 1668 | int line_len = 50; 1669 | int rect_len = 5; 1670 | m_openGLCtrl.Vertex(m_currentpos.X / scale / m_pixaxis, (m_currentpos.Y - line_len) / scale / m_pixaxis,0); 1671 | m_openGLCtrl.Vertex(m_currentpos.X / scale / m_pixaxis, (m_currentpos.Y + line_len) / scale / m_pixaxis,0); 1672 | 1673 | m_openGLCtrl.Vertex((m_currentpos.X - line_len) / scale / m_pixaxis, m_currentpos.Y / scale / m_pixaxis,0); 1674 | m_openGLCtrl.Vertex((m_currentpos.X + line_len) / scale / m_pixaxis, m_currentpos.Y / scale / m_pixaxis,0); 1675 | 1676 | m_openGLCtrl.Vertex((m_currentpos.X - rect_len) / scale / m_pixaxis, (m_currentpos.Y - rect_len) / scale / m_pixaxis,0); 1677 | m_openGLCtrl.Vertex((m_currentpos.X - rect_len) / scale / m_pixaxis, (m_currentpos.Y + rect_len) / scale / m_pixaxis,0); 1678 | 1679 | m_openGLCtrl.Vertex((m_currentpos.X - rect_len) / scale / m_pixaxis, (m_currentpos.Y + rect_len) / scale / m_pixaxis,0); 1680 | m_openGLCtrl.Vertex((m_currentpos.X + rect_len) / scale / m_pixaxis, (m_currentpos.Y + rect_len) / scale / m_pixaxis,0); 1681 | 1682 | m_openGLCtrl.Vertex((m_currentpos.X + rect_len) / scale / m_pixaxis, (m_currentpos.Y + rect_len) / scale / m_pixaxis,0); 1683 | m_openGLCtrl.Vertex((m_currentpos.X + rect_len) / scale / m_pixaxis, (m_currentpos.Y - rect_len) / scale / m_pixaxis,0); 1684 | 1685 | m_openGLCtrl.Vertex((m_currentpos.X + rect_len) / scale / m_pixaxis, (m_currentpos.Y - rect_len) / scale / m_pixaxis,0); 1686 | m_openGLCtrl.Vertex((m_currentpos.X - rect_len) / scale / m_pixaxis, (m_currentpos.Y - rect_len) / scale / m_pixaxis,0); 1687 | 1688 | m_openGLCtrl.End(); 1689 | m_openGLCtrl.Flush(); 1690 | } 1691 | 1692 | 1693 | private void DrawGrids() 1694 | { 1695 | 1696 | CADLine line = new CADLine(0, 0, 0, 0); 1697 | double real_gridstep = m_gridstep; 1698 | if (isRebar == 1) 1699 | real_gridstep = m_gridstep / 2; 1700 | for (int i = 0; i <= (int)(this.Width / real_gridstep / 2) + 1; i++) 1701 | { 1702 | line.m_xs = (float)((i - (int)(m_center_offset.X / real_gridstep)) * (real_gridstep / m_scale / m_pixaxis)); 1703 | line.m_xe = (float)((i - (int)(m_center_offset.X / real_gridstep)) * (real_gridstep / m_scale / m_pixaxis)); 1704 | line.m_ys = (float)((-this.Height / 2 - m_center_offset.Y) / m_scale / m_pixaxis); 1705 | line.m_ye = (float)((this.Height / 2 - m_center_offset.Y) / m_scale / m_pixaxis); 1706 | this.DrawGridLine(line); 1707 | line.m_xs = (float)((-i - (int)(m_center_offset.X / real_gridstep)) * (real_gridstep / m_scale / m_pixaxis)); 1708 | line.m_xe = (float)((-i - (int)(m_center_offset.X / real_gridstep)) * (real_gridstep / m_scale / m_pixaxis)); 1709 | line.m_ys = (float)((-this.Height / 2 - m_center_offset.Y) / m_scale / m_pixaxis); 1710 | line.m_ye = (float)((this.Height / 2 - m_center_offset.Y) / m_scale / m_pixaxis); 1711 | this.DrawGridLine(line); 1712 | } 1713 | 1714 | for (int i = 0; i <= (int)(this.Height / real_gridstep / 2) + 1; i++) 1715 | { 1716 | line.m_ys = (float)((i - (int)(m_center_offset.Y / real_gridstep)) * (real_gridstep / m_scale / m_pixaxis)); 1717 | line.m_ye = (float)((i - (int)(m_center_offset.Y / real_gridstep)) * (real_gridstep / m_scale / m_pixaxis)); 1718 | line.m_xs = (float)((-this.Width / 2 - m_center_offset.X) / m_scale / m_pixaxis); 1719 | line.m_xe = (float)((this.Width / 2 - m_center_offset.X) / m_scale / m_pixaxis); 1720 | this.DrawGridLine(line); 1721 | line.m_ys = (float)((-i - (int)(m_center_offset.Y / real_gridstep)) * (real_gridstep / m_scale / m_pixaxis)); 1722 | line.m_ye = (float)((-i - (int)(m_center_offset.Y / real_gridstep)) * (real_gridstep / m_scale / m_pixaxis)); 1723 | line.m_xs = (float)((-this.Width / 2 - m_center_offset.X) / m_scale / m_pixaxis); 1724 | line.m_xe = (float)((this.Width / 2 - m_center_offset.X) / m_scale / m_pixaxis); 1725 | this.DrawGridLine(line); 1726 | } 1727 | 1728 | } 1729 | 1730 | 1731 | 1732 | private void DelLine(int line_id) 1733 | { 1734 | if (this.AllLines.ContainsKey(line_id)) 1735 | { 1736 | if (AllPointsInLines[line_id].Count > 0) 1737 | { 1738 | foreach (int value in AllPointsInLines[line_id]) 1739 | { 1740 | if (AllPoints.ContainsKey(value)) 1741 | AllPoints.Remove(value); 1742 | if (SelPoints.ContainsKey(value)) 1743 | { 1744 | SelPoints.Remove(value); 1745 | for (int i = 0; i < m_sel_point_list.Count; i++) 1746 | { 1747 | if (m_sel_point_list[i].m_id == value) 1748 | { 1749 | m_sel_point_list.RemoveAt(i); 1750 | break; 1751 | } 1752 | } 1753 | } 1754 | } 1755 | } 1756 | 1757 | AllPointsInLines.Remove(line_id); 1758 | AllLines.Remove(line_id); 1759 | AllLinesColor.Remove(line_id); 1760 | 1761 | 1762 | } 1763 | if (AllPointsInLines.Count > 0) 1764 | { 1765 | foreach (int value in AllPointsInLines.Keys) 1766 | { 1767 | 1768 | for (int i = 0; i < AllPointsInLines[value].Count; i++) 1769 | { 1770 | if (!AllPoints.ContainsKey(AllPointsInLines[value][i])) 1771 | AllPointsInLines[value].Remove(i); 1772 | } 1773 | 1774 | } 1775 | } 1776 | if (AllPointsInRects.Count > 0) 1777 | { 1778 | foreach (int value in AllPointsInRects.Keys) 1779 | { 1780 | 1781 | for (int i = 0; i < AllPointsInRects[value].Count; i++) 1782 | { 1783 | if (!AllPoints.ContainsKey(AllPointsInRects[value][i])) 1784 | AllPointsInRects[value].RemoveAt(i); 1785 | } 1786 | 1787 | } 1788 | } 1789 | this.UpdateBorder(); 1790 | } 1791 | 1792 | private void DelAllLines() 1793 | { 1794 | if (AllLines.Count > 0) 1795 | { 1796 | foreach (int line_id in AllLines.Keys) 1797 | { 1798 | if (AllPointsInLines[line_id].Count > 0) 1799 | { 1800 | foreach (int value in AllPointsInLines[line_id]) 1801 | { 1802 | if (AllPoints.ContainsKey(value)) 1803 | AllPoints.Remove(value); 1804 | if (SelPoints.ContainsKey(value)) 1805 | { 1806 | SelPoints.Remove(value); 1807 | for (int i = 0; i < m_sel_point_list.Count; i++) 1808 | { 1809 | if (m_sel_point_list[i].m_id == value) 1810 | { 1811 | m_sel_point_list.RemoveAt(i); 1812 | break; 1813 | } 1814 | } 1815 | } 1816 | } 1817 | } 1818 | } 1819 | } 1820 | AllPointsInLines.Clear(); 1821 | AllLines.Clear(); 1822 | AllLinesColor.Clear(); 1823 | SelLines.Clear(); 1824 | LineNumber = 0; 1825 | if (AllPointsInRects.Count > 0) 1826 | { 1827 | foreach (int value in AllPointsInRects.Keys) 1828 | { 1829 | for (int i = 0; i < AllPointsInRects[value].Count; i++) 1830 | { 1831 | if (!AllPoints.ContainsKey(AllPointsInRects[value][i])) 1832 | AllPointsInRects[value].RemoveAt(i); 1833 | } 1834 | } 1835 | } 1836 | 1837 | this.UpdateBorder(); 1838 | } 1839 | 1840 | 1841 | private void DelCube(int cube_id) 1842 | { 1843 | if (this.AllCubes.ContainsKey(cube_id)) 1844 | { 1845 | // if (AllPointsInLines[cube_id].Count > 0) 1846 | // { 1847 | // foreach (int value in AllPointsInLines[line_id]) 1848 | // { 1849 | // if (AllPoints.ContainsKey(value)) 1850 | // AllPoints.Remove(value); 1851 | // if (SelPoints.ContainsKey(value)) 1852 | // { 1853 | // SelPoints.Remove(value); 1854 | // for (int i = 0; i < m_sel_point_list.Count; i++) 1855 | // { 1856 | // if (m_sel_point_list[i].m_id == value) 1857 | // { 1858 | // m_sel_point_list.RemoveAt(i); 1859 | // break; 1860 | // } 1861 | // } 1862 | // } 1863 | // } 1864 | // } 1865 | 1866 | //AllPointsInLines.Remove(cube_id); 1867 | AllCubes.Remove(cube_id); 1868 | AllCubesColor.Remove(cube_id); 1869 | 1870 | 1871 | } 1872 | //if (AllPointsInLines.Count > 0) 1873 | //{ 1874 | // foreach (int value in AllPointsInLines.Keys) 1875 | // { 1876 | 1877 | // for (int i = 0; i < AllPointsInLines[value].Count; i++) 1878 | // { 1879 | // if (!AllPoints.ContainsKey(AllPointsInLines[value][i])) 1880 | // AllPointsInLines[value].Remove(i); 1881 | // } 1882 | 1883 | // } 1884 | //} 1885 | //if (AllPointsInRects.Count > 0) 1886 | //{ 1887 | // foreach (int value in AllPointsInRects.Keys) 1888 | // { 1889 | 1890 | // for (int i = 0; i < AllPointsInRects[value].Count; i++) 1891 | // { 1892 | // if (!AllPoints.ContainsKey(AllPointsInRects[value][i])) 1893 | // AllPointsInRects[value].RemoveAt(i); 1894 | // } 1895 | 1896 | // } 1897 | //} 1898 | this.UpdateBorder(); 1899 | } 1900 | 1901 | 1902 | public void Test(object obj = null) 1903 | { 1904 | //CADCube m_cube = (CADCube)obj; 1905 | if (obj == null) 1906 | { 1907 | CADCube m_cube = new CADCube(); 1908 | m_cube.m_id = CubeNumber; 1909 | CubeNumber++; 1910 | m_cube.color = 2; 1911 | CADPoint point1 = new CADPoint(1, 1, 1); 1912 | CADPoint point2 = new CADPoint(-1, 1, 1); 1913 | CADPoint point3 = new CADPoint(-1, -1, 1); 1914 | CADPoint point4 = new CADPoint(1, -1, 1); 1915 | 1916 | CADPoint point5 = new CADPoint(1, 1, -1); 1917 | CADPoint point6 = new CADPoint(-1, 1, -1); 1918 | CADPoint point7 = new CADPoint(-1, -1, -1); 1919 | CADPoint point8 = new CADPoint(1, -1, -1); 1920 | 1921 | //if (m_cube.m_surfs[0] == null) 1922 | //{ 1923 | // MessageBox.Show("surfs"); 1924 | // return; 1925 | //} 1926 | m_cube.m_surfs[0].m_points[0] = point1.Copy(); 1927 | m_cube.m_surfs[0].m_points[1] = point2.Copy(); 1928 | m_cube.m_surfs[0].m_points[2] = point3.Copy(); 1929 | m_cube.m_surfs[0].m_points[3] = point4.Copy(); 1930 | 1931 | m_cube.m_surfs[1].m_points[0] = point5.Copy(); 1932 | m_cube.m_surfs[1].m_points[1] = point6.Copy(); 1933 | m_cube.m_surfs[1].m_points[2] = point7.Copy(); 1934 | m_cube.m_surfs[1].m_points[3] = point8.Copy(); 1935 | 1936 | m_cube.m_surfs[2].m_points[0] = point1.Copy(); 1937 | m_cube.m_surfs[2].m_points[1] = point4.Copy(); 1938 | m_cube.m_surfs[2].m_points[2] = point8.Copy(); 1939 | m_cube.m_surfs[2].m_points[3] = point5.Copy(); 1940 | 1941 | m_cube.m_surfs[3].m_points[0] = point2.Copy(); 1942 | m_cube.m_surfs[3].m_points[1] = point3.Copy(); 1943 | m_cube.m_surfs[3].m_points[2] = point7.Copy(); 1944 | m_cube.m_surfs[3].m_points[3] = point6.Copy(); 1945 | 1946 | m_cube.m_surfs[4].m_points[0] = point1.Copy(); 1947 | m_cube.m_surfs[4].m_points[1] = point2.Copy(); 1948 | m_cube.m_surfs[4].m_points[2] = point6.Copy(); 1949 | m_cube.m_surfs[4].m_points[3] = point5.Copy(); 1950 | 1951 | m_cube.m_surfs[5].m_points[0] = point4.Copy(); 1952 | m_cube.m_surfs[5].m_points[1] = point3.Copy(); 1953 | m_cube.m_surfs[5].m_points[2] = point7.Copy(); 1954 | m_cube.m_surfs[5].m_points[3] = point8.Copy(); 1955 | 1956 | this.UserDrawCube(m_cube); 1957 | 1958 | } 1959 | } 1960 | 1961 | private void DelRect(int rect_id) 1962 | { 1963 | if (this.AllRects.ContainsKey(rect_id)) 1964 | { 1965 | if (AllPointsInRects[rect_id].Count > 0) 1966 | { 1967 | foreach (int value in AllPointsInRects[rect_id]) 1968 | { 1969 | if (AllPoints.ContainsKey(value)) 1970 | AllPoints.Remove(value); 1971 | if (SelPoints.ContainsKey(value)) 1972 | { 1973 | SelPoints.Remove(value); 1974 | for (int i = 0; i < m_sel_point_list.Count; i++) 1975 | { 1976 | if (m_sel_point_list[i].m_id == value) 1977 | { 1978 | m_sel_point_list.RemoveAt(i); 1979 | break; 1980 | } 1981 | } 1982 | } 1983 | } 1984 | } 1985 | AllPointsInRects.Remove(rect_id); 1986 | AllRects.Remove(rect_id); 1987 | AllRectsColor.Remove(rect_id); 1988 | for (int i = 0; i < m_sel_rect_list.Count; i++) 1989 | { 1990 | if (m_sel_rect_list[i].m_id == rect_id) 1991 | { 1992 | m_sel_rect_list.RemoveAt(i); 1993 | break; 1994 | } 1995 | } 1996 | 1997 | } 1998 | if (AllPointsInLines.Count > 0) 1999 | { 2000 | foreach (int value in AllPointsInLines.Keys) 2001 | { 2002 | for (int i = 0; i < AllPointsInLines[value].Count; i++) 2003 | { 2004 | if (!AllPoints.ContainsKey(AllPointsInLines[value][i])) 2005 | AllPointsInLines[value].RemoveAt(i); 2006 | } 2007 | } 2008 | } 2009 | if (AllPointsInRects.Count > 0) 2010 | { 2011 | foreach (int value in AllPointsInRects.Keys) 2012 | { 2013 | for (int i = 0; i < AllPointsInRects[value].Count; i++) 2014 | { 2015 | if (!AllPoints.ContainsKey(AllPointsInRects[value][i])) 2016 | AllPointsInRects[value].RemoveAt(i); 2017 | } 2018 | } 2019 | } 2020 | this.UpdateBorder(); 2021 | } 2022 | 2023 | private void DelAllRects() 2024 | { 2025 | if (AllRects.Count > 0) 2026 | { 2027 | foreach (int rect_id in AllRects.Keys) 2028 | { 2029 | if (AllPointsInRects[rect_id].Count > 0) 2030 | { 2031 | foreach (int value in AllPointsInRects[rect_id]) 2032 | { 2033 | if (AllPoints.ContainsKey(value)) 2034 | AllPoints.Remove(value); 2035 | if (SelPoints.ContainsKey(value)) 2036 | { 2037 | SelPoints.Remove(value); 2038 | for (int i = 0; i < m_sel_point_list.Count; i++) 2039 | { 2040 | if (m_sel_point_list[i].m_id == value) 2041 | { 2042 | m_sel_point_list.RemoveAt(i); 2043 | break; 2044 | } 2045 | } 2046 | } 2047 | } 2048 | } 2049 | } 2050 | } 2051 | AllPointsInRects.Clear(); 2052 | AllRects.Clear(); 2053 | AllRectsColor.Clear(); 2054 | SelRects.Clear(); 2055 | m_sel_rect_list.Clear(); 2056 | RectNumber = 0; 2057 | if (AllPointsInLines.Count > 0) 2058 | { 2059 | foreach (int value in AllPointsInLines.Keys) 2060 | { 2061 | if (AllPointsInLines[value].Count > 0) 2062 | { 2063 | for (int i = 0; i < AllPointsInLines[value].Count; i++) 2064 | { 2065 | if (!AllPoints.ContainsKey(AllPointsInLines[value][i])) 2066 | AllPointsInLines[value].RemoveAt(i); 2067 | } 2068 | } 2069 | } 2070 | } 2071 | this.UpdateBorder(); 2072 | } 2073 | 2074 | private void UpdateBorder() 2075 | { 2076 | m_border = new CADRect(0, 0, 0, 0); 2077 | if (AllRects.Count > 0) 2078 | { 2079 | foreach (CADRect rect in this.AllRects.Values) 2080 | { 2081 | if (rect.m_xs > rect.m_xe) 2082 | { 2083 | m_border.m_xs = m_border.m_xs < rect.m_xe ? m_border.m_xs : rect.m_xe; 2084 | m_border.m_xe = m_border.m_xe > rect.m_xs ? m_border.m_xe : rect.m_xs; 2085 | } 2086 | else 2087 | { 2088 | m_border.m_xs = m_border.m_xs < rect.m_xs ? m_border.m_xs : rect.m_xs; 2089 | m_border.m_xe = m_border.m_xe > rect.m_xe ? m_border.m_xe : rect.m_xe; 2090 | } 2091 | if (rect.m_ys > rect.m_ye) 2092 | { 2093 | m_border.m_ys = m_border.m_ys < rect.m_ye ? m_border.m_ys : rect.m_ye; 2094 | m_border.m_ye = m_border.m_ye > rect.m_ys ? m_border.m_ye : rect.m_ys; 2095 | } 2096 | else 2097 | { 2098 | m_border.m_ys = m_border.m_ys < rect.m_ys ? m_border.m_ys : rect.m_ys; 2099 | m_border.m_ye = m_border.m_ye > rect.m_ye ? m_border.m_ye : rect.m_ye; 2100 | } 2101 | } 2102 | } 2103 | if (AllLines.Count > 0) 2104 | { 2105 | foreach (CADLine line in this.AllLines.Values) 2106 | { 2107 | if (line.m_xs > line.m_xe) 2108 | { 2109 | m_border.m_xs = m_border.m_xs < line.m_xe ? m_border.m_xs : line.m_xe; 2110 | m_border.m_xe = m_border.m_xe > line.m_xs ? m_border.m_xe : line.m_xs; 2111 | } 2112 | else 2113 | { 2114 | m_border.m_xs = m_border.m_xs < line.m_xs ? m_border.m_xs : line.m_xs; 2115 | m_border.m_xe = m_border.m_xe > line.m_xe ? m_border.m_xe : line.m_xe; 2116 | } 2117 | if (line.m_ys > line.m_ye) 2118 | { 2119 | m_border.m_ys = m_border.m_ys < line.m_ye ? m_border.m_ys : line.m_ye; 2120 | m_border.m_ye = m_border.m_ye > line.m_ys ? m_border.m_ye : line.m_ys; 2121 | } 2122 | else 2123 | { 2124 | m_border.m_ys = m_border.m_ys < line.m_ys ? m_border.m_ys : line.m_ys; 2125 | m_border.m_ye = m_border.m_ye > line.m_ye ? m_border.m_ye : line.m_ye; 2126 | } 2127 | } 2128 | } 2129 | } 2130 | 2131 | private double GetDistance(Point point, CADLine line) 2132 | { 2133 | //if ((point.X - line.m_xs) * (point.X - line.m_xe) > 0 || (point.Y - line.m_ys) * (point.Y - line.m_ye) > 0) 2134 | // return -1; 2135 | double result = -1; 2136 | double a = line.m_ys - line.m_ye; 2137 | double b = line.m_xe - line.m_xs; 2138 | double c = line.m_xs * line.m_ye - line.m_ys * line.m_xe; 2139 | 2140 | CADLine normal = new CADLine(point.X, point.Y, point.X - a, point.Y + b); 2141 | // 如果分母为0 则平行或共线, 不相交 2142 | double denominator = (line.m_ye - line.m_ys) * (normal.m_xe - normal.m_xs) - (line.m_xs - line.m_xe) * (normal.m_ys - normal.m_ye); 2143 | if (Math.Abs(denominator) < 0.00005) 2144 | { 2145 | return result; 2146 | } 2147 | 2148 | // 线段所在直线的交点坐标 (x , y) 2149 | double x = ((line.m_xe - line.m_xs) * (normal.m_xe - normal.m_xs) * (normal.m_ys - line.m_ys) + (line.m_ye - line.m_ys) * (normal.m_xe - normal.m_xs) * line.m_xs - (normal.m_ye - normal.m_ys) * (line.m_xe - line.m_xs) * normal.m_xs) / denominator; 2150 | double y = -((line.m_ye - line.m_ys) * (normal.m_ye - normal.m_ys) * (normal.m_xs - line.m_xs) + (line.m_xe - line.m_xs) * (normal.m_ye - normal.m_ys) * line.m_ys - (normal.m_xe - normal.m_xs) * (line.m_ye - line.m_ys) * normal.m_ys) / denominator; 2151 | 2152 | if ((x - line.m_xs) * (x - line.m_xe) <= 0 && (y - line.m_ys) * (y - line.m_ye) <= 0) 2153 | result = Math.Abs((a * point.X + b * point.Y + c) / Math.Sqrt(a * a + b * b)); 2154 | //GetCrossPoint(line, normal); 2155 | return result; 2156 | 2157 | } 2158 | 2159 | private double GetDistance(Point point, CADPoint cad_point) 2160 | { 2161 | double result = 0.0; 2162 | result = (cad_point.m_x - point.X) * (cad_point.m_x - point.X) + (cad_point.m_y - point.Y) * (cad_point.m_y - point.Y); 2163 | return Math.Sqrt(result); 2164 | } 2165 | private double GetDistance(Point point, CADRect rect) 2166 | { 2167 | //if ((point.X - rect.m_xs) * (point.X - rect.m_xe) > 0 || (point.Y - rect.m_ys) * (point.Y - rect.m_ye) > 0) 2168 | // return -1; 2169 | double result = -1; 2170 | double dis = 0.0; 2171 | CADLine line = new CADLine(rect.m_xs, rect.m_ys, rect.m_xs, rect.m_ye); 2172 | result = this.GetDistance(point, line); 2173 | line.m_xs = rect.m_xe; 2174 | line.m_ys = rect.m_ye; 2175 | dis = this.GetDistance(point, line); 2176 | if (dis >= 0) 2177 | { 2178 | if (result > 0) 2179 | result = result < dis ? result : dis; 2180 | else 2181 | result = dis; 2182 | } 2183 | line.m_xe = rect.m_xe; 2184 | line.m_ye = rect.m_ys; 2185 | dis = this.GetDistance(point, line); 2186 | if (dis >= 0) 2187 | { 2188 | if (result > 0) 2189 | result = result < dis ? result : dis; 2190 | else 2191 | result = dis; 2192 | } 2193 | line.m_xs = rect.m_xs; 2194 | line.m_ys = rect.m_ys; 2195 | dis = this.GetDistance(point, line); 2196 | if (dis >= 0) 2197 | { 2198 | if (result > 0) 2199 | result = result < dis ? result : dis; 2200 | else 2201 | result = dis; 2202 | } 2203 | return result; 2204 | } 2205 | 2206 | private CADPoint GetCrossPoint(CADLine line1, CADLine line2) 2207 | { 2208 | CADPoint point = null; 2209 | // 如果分母为0 则平行或共线, 不相交 2210 | double denominator = (line1.m_ye - line1.m_ys) * (line2.m_xe - line2.m_xs) - (line1.m_xs - line1.m_xe) * (line2.m_ys - line2.m_ye); 2211 | if (Math.Abs(denominator) < 0.00005) 2212 | { 2213 | return point; 2214 | } 2215 | 2216 | // 线段所在直线的交点坐标 (x , y) 2217 | double x = ((line1.m_xe - line1.m_xs) * (line2.m_xe - line2.m_xs) * (line2.m_ys - line1.m_ys) + (line1.m_ye - line1.m_ys) * (line2.m_xe - line2.m_xs) * line1.m_xs - (line2.m_ye - line2.m_ys) * (line1.m_xe - line1.m_xs) * line2.m_xs) / denominator; 2218 | double y = -((line1.m_ye - line1.m_ys) * (line2.m_ye - line2.m_ys) * (line2.m_xs - line1.m_xs) + (line1.m_xe - line1.m_xs) * (line2.m_ye - line2.m_ys) * line1.m_ys - (line2.m_xe - line2.m_xs) * (line1.m_ye - line1.m_ys) * line2.m_ys) / denominator; 2219 | 2220 | /** 2 判断交点是否在两条线段上 **/ 2221 | if ( 2222 | // 交点在线段1上 2223 | (x - line1.m_xs) * (x - line1.m_xe) <= 0 && (y - line1.m_ys) * (y - line1.m_ye) <= 0 2224 | // 且交点也在线段2上 2225 | && (x - line2.m_xs) * (x - line2.m_xe) <= 0 && (y - line2.m_ys) * (y - line2.m_ye) <= 0) 2226 | 2227 | // 返回交点p 2228 | point = new CADPoint(x, y); 2229 | return point; 2230 | } 2231 | 2232 | public void UserDrawLine(Point p1, Point p2, int color_id = 0) 2233 | { 2234 | CADLine line = new CADLine(p1, p2); 2235 | this.AddLine(line, color_id); 2236 | } 2237 | 2238 | public void UserDrawLine(CADLine line, int color_id = 0) 2239 | { 2240 | this.AddLine(line, color_id); 2241 | } 2242 | 2243 | public void UserDelAllLines() 2244 | { 2245 | this.DelAllLines(); 2246 | } 2247 | 2248 | public void UserDelLine(int line_id) 2249 | { 2250 | this.DelLine(line_id); 2251 | } 2252 | 2253 | public void UserDelAllRects() 2254 | { 2255 | this.DelAllRects(); 2256 | } 2257 | 2258 | public void UserDelRect(int rect_id) 2259 | { 2260 | this.DelRect(rect_id); 2261 | } 2262 | 2263 | public void UserDelPoint(int point_id) 2264 | { 2265 | if (this.SelPoints.ContainsKey(point_id) && SelPoints[point_id].m_id > 0) 2266 | this.SelPoints.Remove(point_id); 2267 | if (this.AllPoints.ContainsKey(point_id) && AllPoints[point_id].m_id > 0) 2268 | this.AllPoints.Remove(point_id); 2269 | } 2270 | 2271 | public void UserDelAllPoints() 2272 | { 2273 | this.SelPoints.Clear(); 2274 | this.AllPoints.Clear(); 2275 | PointNumber = 1; 2276 | this.AllPoints.Add(PointNumber, new CADPoint()); 2277 | 2278 | } 2279 | 2280 | public bool UserDrawRect(Point p1, Point p2, int color_id = 0) 2281 | { 2282 | 2283 | CADRect rect = new CADRect(p1, p2); 2284 | return this.AddRect(rect, color_id); 2285 | 2286 | } 2287 | 2288 | public bool UserDrawRect(CADRect rect, int color_id = 0) 2289 | { 2290 | return this.AddRect(rect, color_id); 2291 | } 2292 | 2293 | public bool UserDrawCube(CADCube cube, int color_id = 0) 2294 | { 2295 | return this.AddCube(cube); 2296 | } 2297 | 2298 | public void UserDrawPoint(CADPoint point, int color_id = 0) 2299 | { 2300 | this.AddPoint(point); 2301 | } 2302 | 2303 | public void UserSelLine(int id) 2304 | { 2305 | this.SelLine(id); 2306 | } 2307 | 2308 | public void UserSelRect(int id) 2309 | { 2310 | this.SelRect(id); 2311 | } 2312 | 2313 | public void UserSelPoint(int id) 2314 | { 2315 | this.SelPoint(id); 2316 | } 2317 | 2318 | public int[] UserGetSelLines() 2319 | { 2320 | int[] result = this.SelLines.Keys.ToArray(); 2321 | return result; 2322 | } 2323 | 2324 | public int[] UserGetSelRects() 2325 | { 2326 | int[] result = this.SelRects.Keys.ToArray(); 2327 | return result; 2328 | } 2329 | 2330 | public int[] UserGetSelPoints() 2331 | { 2332 | int[] result = this.SelPoints.Keys.ToArray(); 2333 | return result; 2334 | } 2335 | 2336 | public Dictionary UserGetLines() 2337 | { 2338 | return AllLines; 2339 | } 2340 | 2341 | public Dictionary UserGetRects() 2342 | { 2343 | return AllRects; 2344 | } 2345 | 2346 | public Dictionary UserGetPoints() 2347 | { 2348 | return AllPoints; 2349 | } 2350 | 2351 | public void UserStartLine() 2352 | { 2353 | tempLine.m_id = 0; 2354 | tempLine.m_xs = m_curaxispos.m_x; 2355 | tempLine.m_ys = m_curaxispos.m_y; 2356 | tempLine.m_xe = m_curaxispos.m_x; 2357 | tempLine.m_ye = m_curaxispos.m_y; 2358 | } 2359 | 2360 | public void UserEndLine() 2361 | { 2362 | if (tempLine.m_id == -1) 2363 | return; 2364 | tempLine.m_xe = m_curaxispos.m_x; 2365 | tempLine.m_ye = m_curaxispos.m_y; 2366 | if ((tempLine.m_xs - tempLine.m_xe) * (tempLine.m_xs - tempLine.m_xe) + (tempLine.m_ys - tempLine.m_ye) * (tempLine.m_ys - tempLine.m_ye) <= 1) 2367 | { 2368 | tempLine.m_id = -1; 2369 | return; 2370 | } 2371 | else 2372 | { 2373 | this.UserDrawLine(tempLine.Copy()); 2374 | tempLine.m_id = -1; 2375 | tempLine.m_xs = m_curaxispos.m_x; 2376 | tempLine.m_ys = m_curaxispos.m_y; 2377 | } 2378 | } 2379 | 2380 | public void ZoomView() 2381 | { 2382 | //m_scale = 8 / ((m_border.m_ye - m_border.m_ys) > (m_border.m_xe - m_border.m_xs) ? (m_border.m_ye - m_border.m_ys) : (m_border.m_xe - m_border.m_xs)); 2383 | if ((m_border.m_ye - m_border.m_ys) > (m_border.m_xe - m_border.m_xs)) 2384 | m_scale = this.Height / 50 / (m_border.m_ye - m_border.m_ys); 2385 | else 2386 | m_scale = this.Width / 50 / (m_border.m_xe - m_border.m_xs); 2387 | if (m_scale > 1000000) 2388 | m_scale = 8 / (m_border.m_xe - m_border.m_xs); 2389 | if (m_scale > 1000000) 2390 | m_scale = 8 / (m_border.m_ye - m_border.m_ys); 2391 | if (m_scale > 1000000) 2392 | m_scale = 0.00001; 2393 | m_center_offset.X = -(m_border.m_xe - m_border.m_xs) / 2 * m_pixaxis * m_scale; 2394 | m_center_offset.Y = -(m_border.m_ye - m_border.m_ys) / 2 * m_pixaxis * m_scale; 2395 | } 2396 | 2397 | public void ReactToL() 2398 | { 2399 | this.key_down_copy = false; 2400 | this.key_down_move = false; 2401 | this.key_down_del = false; 2402 | this.b_draw_line = true; 2403 | return; 2404 | } 2405 | public void ReactToDel() 2406 | { 2407 | this.key_down_copy = false; 2408 | this.key_down_move = false; 2409 | this.key_down_del = true; 2410 | this.b_draw_line = false; 2411 | int[] sel_keys = this.UserGetSelRects(); 2412 | foreach (int key in sel_keys) 2413 | { 2414 | this.UserDelRect(key); 2415 | } 2416 | sel_keys = this.UserGetSelPoints(); 2417 | foreach (int key in sel_keys) 2418 | { 2419 | this.UserDelPoint(key); 2420 | } 2421 | sel_keys = this.UserGetSelLines(); 2422 | foreach (int key in sel_keys) 2423 | { 2424 | this.UserDelLine(key); 2425 | } 2426 | this.key_down_del = false; 2427 | return; 2428 | } 2429 | 2430 | public void ShiftDwon() 2431 | { 2432 | this.key_down_shift = true; 2433 | } 2434 | 2435 | public void ShiftUp() 2436 | { 2437 | this.key_down_shift = false; 2438 | } 2439 | 2440 | public void ReactToESC() 2441 | { 2442 | if (!key_down_move && !key_down_copy) 2443 | { 2444 | SelRects.Clear(); 2445 | SelPoints.Clear(); 2446 | m_sel_point_list.Clear(); 2447 | SelLines.Clear(); 2448 | } 2449 | 2450 | if (key_down_copy) 2451 | { 2452 | if (SelRects.Count > 0) 2453 | { 2454 | int[] keys = SelRects.Keys.ToArray(); 2455 | foreach (int value in keys) 2456 | { 2457 | SelRects[value] = AllRects[value].Copy(); 2458 | } 2459 | } 2460 | key_down_copy = false; 2461 | } 2462 | 2463 | if (b_draw_line) 2464 | { 2465 | b_draw_line = false; 2466 | tempLine.m_id = -1; 2467 | } 2468 | 2469 | if (key_down_move) 2470 | { 2471 | if (SelRects.Count > 0) 2472 | { 2473 | int[] keys = SelRects.Keys.ToArray(); 2474 | foreach (int value in keys) 2475 | { 2476 | SelRects[value] = AllRects[value].Copy(); 2477 | } 2478 | } 2479 | key_down_move = false; 2480 | } 2481 | 2482 | 2483 | 2484 | key_down_del = false; 2485 | } 2486 | 2487 | private void UserControl_PreviewKeyDown(object sender, KeyEventArgs e) 2488 | { 2489 | if (e.Key == Key.Escape) 2490 | { 2491 | key_down_esc = true; 2492 | return; 2493 | } 2494 | if (e.Key == Key.C) 2495 | { 2496 | key_down_copy = true; 2497 | return; 2498 | } 2499 | if (e.Key == Key.M) 2500 | { 2501 | key_down_move = true; 2502 | MessageBox.Show("M down"); 2503 | return; 2504 | } 2505 | if (e.Key == Key.Delete) 2506 | { 2507 | key_down_del = true; 2508 | return; 2509 | } 2510 | if (e.Key == Key.LeftShift) 2511 | { 2512 | key_down_shift = true; 2513 | MessageBox.Show("shift down"); 2514 | return; 2515 | } 2516 | } 2517 | 2518 | private void UserControl_PreviewKeyUp(object sender, KeyEventArgs e) 2519 | { 2520 | if (e.Key == Key.LeftShift) 2521 | { 2522 | key_down_shift = false; 2523 | MessageBox.Show("shift up"); 2524 | } 2525 | } 2526 | 2527 | 2528 | public class CADLine 2529 | { 2530 | public int m_id { get; set; } 2531 | public float m_xs { get; set; } 2532 | public float m_ys { get; set; } 2533 | public float m_xe { get; set; } 2534 | public float m_ye { get; set; } 2535 | public float m_zs { get; set; } 2536 | public float m_ze { get; set; } 2537 | 2538 | public CADLine() 2539 | { 2540 | m_id = 0; 2541 | m_xs = 0.0f; 2542 | m_ys = 0.0f; 2543 | m_zs = 0.0f; 2544 | m_ze = 0.0f; 2545 | m_xe = 0.0f; 2546 | m_ye = 0.0f; 2547 | } 2548 | 2549 | public CADLine(Point p1, Point p2) 2550 | { 2551 | m_id = 0; 2552 | m_xs = (float)p1.X; 2553 | m_ys = (float)p1.Y; 2554 | m_xe = (float)p2.X; 2555 | m_ye = (float)p2.Y; 2556 | m_zs = 0; 2557 | m_ze = 0; 2558 | } 2559 | 2560 | public CADLine(double xs, double ys, double xe, double ye) 2561 | { 2562 | m_id = 0; 2563 | m_xs = (float)xs; 2564 | m_ys = (float)ys; 2565 | m_zs =0; 2566 | m_xe = (float)xe; 2567 | m_ye = (float)ye; 2568 | m_ze = 0; 2569 | } 2570 | 2571 | public CADLine(double xs, double ys, double zs, double xe, double ye, double ze) 2572 | { 2573 | m_id = 0; 2574 | m_xs = (float)xs; 2575 | m_ys = (float)ys; 2576 | m_zs = (float)zs; 2577 | m_xe = (float)xe; 2578 | m_ye = (float)ye; 2579 | m_ze = (float)ze; 2580 | } 2581 | 2582 | public CADLine(CADPoint p1,CADPoint p2) 2583 | { 2584 | m_id = 0; 2585 | m_xs = p1.m_x; 2586 | m_ys = p1.m_y; 2587 | m_zs = p1.m_z; 2588 | m_xe = p2.m_x; 2589 | m_ye = p2.m_y; 2590 | m_ze = p2.m_z; 2591 | } 2592 | public CADLine Copy() 2593 | { 2594 | CADLine result = new CADLine(m_xs, m_ys, m_zs, m_xe, m_ye, m_ze); 2595 | result.m_id = m_id; 2596 | return result; 2597 | } 2598 | 2599 | public static implicit operator CADRect(CADLine value)//implicit隐式转换,explicit显式转换 2600 | { 2601 | checked 2602 | { 2603 | if (value == null) 2604 | return null; 2605 | CADRect result = new CADRect(value.m_xs, value.m_ys, value.m_xe, value.m_ye); 2606 | result.m_id = value.m_id; 2607 | return result; 2608 | } 2609 | } 2610 | } 2611 | 2612 | public class CADRect 2613 | { 2614 | public int m_id { get; set; } 2615 | public float m_xs { get; set; } 2616 | public float m_ys { get; set; } 2617 | public float m_xe { get; set; } 2618 | public float m_ye { get; set; } 2619 | public float m_len { get; set; } 2620 | public int m_flag { get; set; }//梁柱标志,0表示梁,1表示柱 2621 | public float m_width { get; set; } 2622 | public float m_height { get; set; } 2623 | public string m_rebar { get; set; }//钢筋布置索引,编号意味着对应1好钢筋图 2624 | public int m_concrete { get; set; }//混凝土等级索引,需要预定义好 2625 | public CADRect() 2626 | { 2627 | 2628 | m_id = 0; 2629 | m_xs = 0.0f; 2630 | m_ys = 0.0f; 2631 | m_xe = 0.0f; 2632 | m_ye = 0.0f; 2633 | m_len = 0.0f; 2634 | m_flag = 1; 2635 | m_rebar = ""; 2636 | m_concrete = 0; 2637 | m_width = Math.Abs(m_xs - m_xe); 2638 | m_height = Math.Abs(m_ys - m_ye); 2639 | } 2640 | 2641 | public CADRect(Point p1, Point p2, int flag = 1) 2642 | { 2643 | 2644 | m_id = 0; 2645 | m_xs = (float)p1.X; 2646 | m_ys = (float)p1.Y; 2647 | m_xe = (float)p2.X; 2648 | m_ye = (float)p2.Y; 2649 | m_len = 0.0f; 2650 | m_flag = flag; 2651 | m_rebar = ""; 2652 | m_concrete = 0; 2653 | m_width = Math.Abs(m_xs - m_xe); 2654 | m_height = Math.Abs(m_ys - m_ye); 2655 | } 2656 | 2657 | public CADRect(double xs, double ys, double xe, double ye, int flag = 1) 2658 | { 2659 | 2660 | m_id = 0; 2661 | m_xs = (float)xs; 2662 | m_ys = (float)ys; 2663 | m_xe = (float)xe; 2664 | m_ye = (float)ye; 2665 | m_len = 0.0f; 2666 | m_flag = flag; 2667 | m_rebar = ""; 2668 | m_concrete = 0; 2669 | m_width = Math.Abs(m_xs - m_xe); 2670 | m_height = Math.Abs(m_ys - m_ye); 2671 | } 2672 | 2673 | public void UpdataWH() 2674 | { 2675 | m_width = Math.Abs(m_xs - m_xe); 2676 | m_height = Math.Abs(m_ys - m_ye); 2677 | } 2678 | 2679 | public CADRect Copy() 2680 | { 2681 | CADRect result = new CADRect(m_xs, m_ys, m_xe, m_ye); 2682 | result.m_len = m_len; 2683 | result.m_id = m_id; 2684 | result.m_flag = m_flag; 2685 | result.m_rebar = m_rebar; 2686 | result.m_concrete = m_concrete; 2687 | return result; 2688 | } 2689 | 2690 | public static implicit operator CADLine(CADRect value)//implicit隐式转换,explicit显式转换 2691 | { 2692 | checked 2693 | { 2694 | if (value == null) 2695 | return null; 2696 | CADLine result = new CADLine(value.m_xs, value.m_ys, value.m_xe, value.m_ye); 2697 | result.m_id = value.m_id; 2698 | 2699 | return result; 2700 | } 2701 | } 2702 | 2703 | } 2704 | 2705 | 2706 | 2707 | 2708 | public class CADPoint 2709 | { 2710 | public int m_id { get; set; } 2711 | public float m_x { get; set; } 2712 | public float m_y { get; set; } 2713 | public float m_z { get; set; } 2714 | public int m_is_rebar { get; set; } 2715 | public int m_diameter { get; set; } 2716 | public int m_strength { get; set; } 2717 | public int m_count { get; set; } 2718 | public int m_style { get; set; }//0正常点,1辅助点 2719 | public CADPoint() 2720 | { 2721 | m_id = 0; 2722 | m_x = 0.0f; 2723 | m_y = 0.0f; 2724 | m_z = 0.0f; 2725 | m_is_rebar = 0; 2726 | m_diameter = -1; 2727 | m_strength = -1; 2728 | m_count = 0; 2729 | m_style = 0; 2730 | 2731 | } 2732 | 2733 | 2734 | public CADPoint(double x, double y, double z = 0) 2735 | { 2736 | m_id = 0; 2737 | m_x = (float)x; 2738 | m_y = (float)y; 2739 | m_z = (float)z; 2740 | m_is_rebar = 0; 2741 | m_diameter = -1; 2742 | m_strength = -1; 2743 | m_count = 0; 2744 | m_style = 0; 2745 | 2746 | } 2747 | 2748 | public CADPoint Copy() 2749 | { 2750 | CADPoint result = new CADPoint(m_x, m_y, m_z); 2751 | result.m_id = m_id; 2752 | result.m_is_rebar = m_is_rebar; 2753 | result.m_diameter = m_diameter; 2754 | result.m_strength = m_strength; 2755 | result.m_count = m_count; 2756 | result.m_style = m_style; 2757 | return result; 2758 | } 2759 | 2760 | public static CADPoint operator/(CADPoint src, double divide) 2761 | { 2762 | return new CADPoint(src.m_x/divide, src.m_y / divide, src.m_z / divide); 2763 | } 2764 | 2765 | //public static CADLine operator -(CADPoint a, CADPoint b) 2766 | //{ 2767 | // return new CADLine(a,b); 2768 | //} 2769 | } 2770 | 2771 | 2772 | public class Rect3D 2773 | { 2774 | public int m_id = 0; 2775 | public CADPoint[] m_points = new CADPoint[4]; 2776 | public Rect3D() 2777 | { 2778 | 2779 | } 2780 | public Rect3D(CADPoint[] points) 2781 | { 2782 | int len = points.Length; 2783 | if (len != 4) 2784 | return; 2785 | for (int i = 0; i < len; i++) 2786 | { 2787 | m_points[i] = points[i].Copy(); 2788 | } 2789 | } 2790 | 2791 | public Rect3D(CADPoint point1, CADPoint point2, CADPoint point3, CADPoint point4) 2792 | { 2793 | m_points[0] = point1.Copy(); 2794 | m_points[1] = point2.Copy(); 2795 | m_points[2] = point3.Copy(); 2796 | m_points[3] = point4.Copy(); 2797 | } 2798 | 2799 | public Rect3D Copy() 2800 | { 2801 | Rect3D result = new Rect3D(m_points); 2802 | result.m_id = m_id; 2803 | return result; 2804 | } 2805 | } 2806 | 2807 | public class CADCube 2808 | { 2809 | public Rect3D[] m_surfs = null; 2810 | public int m_id = 0; 2811 | public int color = 0; 2812 | 2813 | public CADCube() 2814 | { 2815 | m_surfs = new Rect3D[6]; 2816 | for (int i = 0; i < 6; i++) 2817 | m_surfs[i] = new Rect3D(); 2818 | } 2819 | public CADCube(Rect3D[] surfs) 2820 | { 2821 | int len = surfs.Length; 2822 | if (len != 6) 2823 | return; 2824 | for (int i = 0; i < len; i++) 2825 | m_surfs[i] = surfs[i].Copy(); 2826 | } 2827 | public CADCube(Rect3D surf1, Rect3D surf2, Rect3D surf3, Rect3D surf4, Rect3D surf5, Rect3D surf6) 2828 | { 2829 | m_surfs[0] = surf1.Copy(); 2830 | m_surfs[1] = surf2.Copy(); 2831 | m_surfs[2] = surf3.Copy(); 2832 | m_surfs[3] = surf4.Copy(); 2833 | m_surfs[4] = surf5.Copy(); 2834 | m_surfs[5] = surf6.Copy(); 2835 | 2836 | } 2837 | public CADCube Copy() 2838 | { 2839 | CADCube result = new CADCube(); 2840 | result.m_id = this.m_id; 2841 | result.color = color; 2842 | result.m_surfs = this.m_surfs; 2843 | return result; 2844 | } 2845 | } 2846 | 2847 | 2848 | 2849 | public class CADRGB 2850 | { 2851 | public float m_r = 0.0f; 2852 | public float m_g = 0.0f; 2853 | public float m_b = 0.0f; 2854 | public CADRGB() 2855 | { } 2856 | public CADRGB(double r, double g, double b) 2857 | { 2858 | m_r = (float)r; 2859 | m_g = (float)g; 2860 | m_b = (float)b; 2861 | } 2862 | 2863 | public CADRGB Copy() 2864 | { 2865 | 2866 | return new CADRGB(m_r, m_g, m_b); 2867 | } 2868 | } 2869 | } 2870 | } 2871 | 2872 | -------------------------------------------------------------------------------- /CADCtrl/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过以下 6 | // 特性集控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("CADCtrl")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("CADCtrl")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("54945e3f-9cbd-4912-88ac-d5fab1a4bc8d")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 内部版本号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /CADCtrl/SharpGL.SceneGraph.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/SharpGL.SceneGraph.dll -------------------------------------------------------------------------------- /CADCtrl/SharpGL.WPF.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/SharpGL.WPF.dll -------------------------------------------------------------------------------- /CADCtrl/SharpGL.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/SharpGL.dll -------------------------------------------------------------------------------- /CADCtrl/bin/Debug/CADCtrl.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/bin/Debug/CADCtrl.dll -------------------------------------------------------------------------------- /CADCtrl/bin/Debug/CADCtrl.dll.config: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /CADCtrl/bin/Debug/CADCtrl.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/bin/Debug/CADCtrl.pdb -------------------------------------------------------------------------------- /CADCtrl/bin/Debug/SharpGL.SceneGraph.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/bin/Debug/SharpGL.SceneGraph.dll -------------------------------------------------------------------------------- /CADCtrl/bin/Debug/SharpGL.WPF.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/bin/Debug/SharpGL.WPF.dll -------------------------------------------------------------------------------- /CADCtrl/bin/Debug/SharpGL.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/bin/Debug/SharpGL.dll -------------------------------------------------------------------------------- /CADCtrl/bin/Debug/log4net.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/bin/Debug/log4net.dll -------------------------------------------------------------------------------- /CADCtrl/bin/Release/CADCtrl.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/bin/Release/CADCtrl.dll -------------------------------------------------------------------------------- /CADCtrl/bin/Release/CADCtrl.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/bin/Release/CADCtrl.pdb -------------------------------------------------------------------------------- /CADCtrl/bin/Release/SharpGL.SceneGraph.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/bin/Release/SharpGL.SceneGraph.dll -------------------------------------------------------------------------------- /CADCtrl/bin/Release/SharpGL.WPF.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/bin/Release/SharpGL.WPF.dll -------------------------------------------------------------------------------- /CADCtrl/bin/Release/SharpGL.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/bin/Release/SharpGL.dll -------------------------------------------------------------------------------- /CADCtrl/log4net.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/log4net.dll -------------------------------------------------------------------------------- /CADCtrl/obj/Debug/CADCtrl.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\obj\Debug\CADCtrl_MarkupCompile.cache 2 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\obj\Debug\CADView.baml 3 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\obj\Debug\CADView.g.cs 4 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\obj\Debug\CADCtrl.g.resources 5 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\obj\Debug\CADCtrl.csprojResolveAssemblyReference.cache 6 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\bin\Debug\CADCtrl.dll 7 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\bin\Debug\CADCtrl.pdb 8 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\bin\Debug\SharpGL.dll 9 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\bin\Debug\SharpGL.SceneGraph.dll 10 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\bin\Debug\SharpGL.WPF.dll 11 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\obj\Debug\CADCtrl.dll 12 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\obj\Debug\CADCtrl.pdb 13 | D:\C++公用文件夹\My Projects_VS2010\temp\CADCtrl\CADCtrl\bin\Debug\CADCtrl.dll 14 | D:\C++公用文件夹\My Projects_VS2010\temp\CADCtrl\CADCtrl\bin\Debug\CADCtrl.pdb 15 | D:\C++公用文件夹\My Projects_VS2010\temp\CADCtrl\CADCtrl\bin\Debug\SharpGL.dll 16 | D:\C++公用文件夹\My Projects_VS2010\temp\CADCtrl\CADCtrl\bin\Debug\SharpGL.SceneGraph.dll 17 | D:\C++公用文件夹\My Projects_VS2010\temp\CADCtrl\CADCtrl\bin\Debug\SharpGL.WPF.dll 18 | D:\C++公用文件夹\My Projects_VS2010\temp\CADCtrl\CADCtrl\obj\Debug\CADCtrl.csprojResolveAssemblyReference.cache 19 | D:\C++公用文件夹\My Projects_VS2010\temp\CADCtrl\CADCtrl\obj\Debug\CADView.baml 20 | D:\C++公用文件夹\My Projects_VS2010\temp\CADCtrl\CADCtrl\obj\Debug\CADView.g.cs 21 | D:\C++公用文件夹\My Projects_VS2010\temp\CADCtrl\CADCtrl\obj\Debug\CADCtrl_MarkupCompile.cache 22 | D:\C++公用文件夹\My Projects_VS2010\temp\CADCtrl\CADCtrl\obj\Debug\CADCtrl.g.resources 23 | D:\C++公用文件夹\My Projects_VS2010\temp\CADCtrl\CADCtrl\obj\Debug\CADCtrl.dll 24 | D:\C++公用文件夹\My Projects_VS2010\temp\CADCtrl\CADCtrl\obj\Debug\CADCtrl.pdb 25 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\bin\Debug\log4net.dll 26 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\bin\Debug\CADCtrl.dll.config 27 | -------------------------------------------------------------------------------- /CADCtrl/obj/Debug/CADCtrl.csprojResolveAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/obj/Debug/CADCtrl.csprojResolveAssemblyReference.cache -------------------------------------------------------------------------------- /CADCtrl/obj/Debug/CADCtrl.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/obj/Debug/CADCtrl.dll -------------------------------------------------------------------------------- /CADCtrl/obj/Debug/CADCtrl.g.resources: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/obj/Debug/CADCtrl.g.resources -------------------------------------------------------------------------------- /CADCtrl/obj/Debug/CADCtrl.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/obj/Debug/CADCtrl.pdb -------------------------------------------------------------------------------- /CADCtrl/obj/Debug/CADCtrl_MarkupCompile.cache: -------------------------------------------------------------------------------- 1 | CADCtrl 2 | 3 | 4 | library 5 | C# 6 | .cs 7 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\obj\Debug\ 8 | CADCtrl 9 | none 10 | false 11 | DEBUG;TRACE 12 | 13 | 12090036334 14 | 15 | 31181065217 16 | 18-1541181203 17 | CADView.xaml; 18 | 19 | False 20 | 21 | -------------------------------------------------------------------------------- /CADCtrl/obj/Debug/CADCtrl_MarkupCompile.i.cache: -------------------------------------------------------------------------------- 1 | CADCtrl 2 | 3 | 4 | library 5 | C# 6 | .cs 7 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\obj\Debug\ 8 | CADCtrl 9 | none 10 | false 11 | DEBUG;TRACE 12 | 13 | 12090036334 14 | 15 | 4-546616520 16 | 18-1541181203 17 | CADView.xaml; 18 | 19 | False 20 | 21 | -------------------------------------------------------------------------------- /CADCtrl/obj/Debug/CADView.baml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/obj/Debug/CADView.baml -------------------------------------------------------------------------------- /CADCtrl/obj/Debug/CADView.g.cs: -------------------------------------------------------------------------------- 1 | #pragma checksum "..\..\CADView.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "2221756F63D8816CB4741FB29FFCC094" 2 | //------------------------------------------------------------------------------ 3 | // 4 | // 此代码由工具生成。 5 | // 运行时版本:4.0.30319.42000 6 | // 7 | // 对此文件的更改可能会导致不正确的行为,并且如果 8 | // 重新生成代码,这些更改将会丢失。 9 | // 10 | //------------------------------------------------------------------------------ 11 | 12 | using SharpGL.WPF; 13 | using System; 14 | using System.Diagnostics; 15 | using System.Windows; 16 | using System.Windows.Automation; 17 | using System.Windows.Controls; 18 | using System.Windows.Controls.Primitives; 19 | using System.Windows.Data; 20 | using System.Windows.Documents; 21 | using System.Windows.Ink; 22 | using System.Windows.Input; 23 | using System.Windows.Markup; 24 | using System.Windows.Media; 25 | using System.Windows.Media.Animation; 26 | using System.Windows.Media.Effects; 27 | using System.Windows.Media.Imaging; 28 | using System.Windows.Media.Media3D; 29 | using System.Windows.Media.TextFormatting; 30 | using System.Windows.Navigation; 31 | using System.Windows.Shapes; 32 | using System.Windows.Shell; 33 | 34 | 35 | namespace CADCtrl { 36 | 37 | 38 | /// 39 | /// CADView 40 | /// 41 | public partial class CADView : System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector { 42 | 43 | 44 | #line 10 "..\..\CADView.xaml" 45 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] 46 | internal SharpGL.WPF.OpenGLControl openGLCtrl; 47 | 48 | #line default 49 | #line hidden 50 | 51 | private bool _contentLoaded; 52 | 53 | /// 54 | /// InitializeComponent 55 | /// 56 | [System.Diagnostics.DebuggerNonUserCodeAttribute()] 57 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")] 58 | public void InitializeComponent() { 59 | if (_contentLoaded) { 60 | return; 61 | } 62 | _contentLoaded = true; 63 | System.Uri resourceLocater = new System.Uri("/CADCtrl;component/cadview.xaml", System.UriKind.Relative); 64 | 65 | #line 1 "..\..\CADView.xaml" 66 | System.Windows.Application.LoadComponent(this, resourceLocater); 67 | 68 | #line default 69 | #line hidden 70 | } 71 | 72 | [System.Diagnostics.DebuggerNonUserCodeAttribute()] 73 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")] 74 | [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] 75 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")] 76 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] 77 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] 78 | void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { 79 | switch (connectionId) 80 | { 81 | case 1: 82 | this.openGLCtrl = ((SharpGL.WPF.OpenGLControl)(target)); 83 | 84 | #line 11 "..\..\CADView.xaml" 85 | this.openGLCtrl.OpenGLDraw += new SharpGL.SceneGraph.OpenGLEventHandler(this.OpenGLControl_OpenGLDraw); 86 | 87 | #line default 88 | #line hidden 89 | 90 | #line 12 "..\..\CADView.xaml" 91 | this.openGLCtrl.OpenGLInitialized += new SharpGL.SceneGraph.OpenGLEventHandler(this.OpenGLControl_OpenGLInitialized); 92 | 93 | #line default 94 | #line hidden 95 | 96 | #line 13 "..\..\CADView.xaml" 97 | this.openGLCtrl.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.OpenGLControl_MouseDown); 98 | 99 | #line default 100 | #line hidden 101 | 102 | #line 14 "..\..\CADView.xaml" 103 | this.openGLCtrl.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.OpenGLControl_MouseUp); 104 | 105 | #line default 106 | #line hidden 107 | 108 | #line 15 "..\..\CADView.xaml" 109 | this.openGLCtrl.MouseMove += new System.Windows.Input.MouseEventHandler(this.OpenGLControl_MouseMove); 110 | 111 | #line default 112 | #line hidden 113 | 114 | #line 16 "..\..\CADView.xaml" 115 | this.openGLCtrl.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.OpenGLControl_MouseWheel); 116 | 117 | #line default 118 | #line hidden 119 | 120 | #line 18 "..\..\CADView.xaml" 121 | this.openGLCtrl.Loaded += new System.Windows.RoutedEventHandler(this.UserControl_Loaded); 122 | 123 | #line default 124 | #line hidden 125 | 126 | #line 19 "..\..\CADView.xaml" 127 | this.openGLCtrl.PreviewKeyDown += new System.Windows.Input.KeyEventHandler(this.UserControl_PreviewKeyDown); 128 | 129 | #line default 130 | #line hidden 131 | 132 | #line 20 "..\..\CADView.xaml" 133 | this.openGLCtrl.PreviewKeyUp += new System.Windows.Input.KeyEventHandler(this.UserControl_PreviewKeyUp); 134 | 135 | #line default 136 | #line hidden 137 | return; 138 | } 139 | this._contentLoaded = true; 140 | } 141 | } 142 | } 143 | 144 | -------------------------------------------------------------------------------- /CADCtrl/obj/Debug/CADView.g.i.cs: -------------------------------------------------------------------------------- 1 | #pragma checksum "..\..\CADView.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "2221756F63D8816CB4741FB29FFCC094" 2 | //------------------------------------------------------------------------------ 3 | // 4 | // 此代码由工具生成。 5 | // 运行时版本:4.0.30319.42000 6 | // 7 | // 对此文件的更改可能会导致不正确的行为,并且如果 8 | // 重新生成代码,这些更改将会丢失。 9 | // 10 | //------------------------------------------------------------------------------ 11 | 12 | using SharpGL.WPF; 13 | using System; 14 | using System.Diagnostics; 15 | using System.Windows; 16 | using System.Windows.Automation; 17 | using System.Windows.Controls; 18 | using System.Windows.Controls.Primitives; 19 | using System.Windows.Data; 20 | using System.Windows.Documents; 21 | using System.Windows.Ink; 22 | using System.Windows.Input; 23 | using System.Windows.Markup; 24 | using System.Windows.Media; 25 | using System.Windows.Media.Animation; 26 | using System.Windows.Media.Effects; 27 | using System.Windows.Media.Imaging; 28 | using System.Windows.Media.Media3D; 29 | using System.Windows.Media.TextFormatting; 30 | using System.Windows.Navigation; 31 | using System.Windows.Shapes; 32 | using System.Windows.Shell; 33 | 34 | 35 | namespace CADCtrl { 36 | 37 | 38 | /// 39 | /// CADView 40 | /// 41 | public partial class CADView : System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector { 42 | 43 | 44 | #line 10 "..\..\CADView.xaml" 45 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] 46 | internal SharpGL.WPF.OpenGLControl openGLCtrl; 47 | 48 | #line default 49 | #line hidden 50 | 51 | private bool _contentLoaded; 52 | 53 | /// 54 | /// InitializeComponent 55 | /// 56 | [System.Diagnostics.DebuggerNonUserCodeAttribute()] 57 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")] 58 | public void InitializeComponent() { 59 | if (_contentLoaded) { 60 | return; 61 | } 62 | _contentLoaded = true; 63 | System.Uri resourceLocater = new System.Uri("/CADCtrl;component/cadview.xaml", System.UriKind.Relative); 64 | 65 | #line 1 "..\..\CADView.xaml" 66 | System.Windows.Application.LoadComponent(this, resourceLocater); 67 | 68 | #line default 69 | #line hidden 70 | } 71 | 72 | [System.Diagnostics.DebuggerNonUserCodeAttribute()] 73 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")] 74 | [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] 75 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")] 76 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] 77 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] 78 | void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { 79 | switch (connectionId) 80 | { 81 | case 1: 82 | this.openGLCtrl = ((SharpGL.WPF.OpenGLControl)(target)); 83 | 84 | #line 11 "..\..\CADView.xaml" 85 | this.openGLCtrl.OpenGLDraw += new SharpGL.SceneGraph.OpenGLEventHandler(this.OpenGLControl_OpenGLDraw); 86 | 87 | #line default 88 | #line hidden 89 | 90 | #line 12 "..\..\CADView.xaml" 91 | this.openGLCtrl.OpenGLInitialized += new SharpGL.SceneGraph.OpenGLEventHandler(this.OpenGLControl_OpenGLInitialized); 92 | 93 | #line default 94 | #line hidden 95 | 96 | #line 13 "..\..\CADView.xaml" 97 | this.openGLCtrl.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.OpenGLControl_MouseDown); 98 | 99 | #line default 100 | #line hidden 101 | 102 | #line 14 "..\..\CADView.xaml" 103 | this.openGLCtrl.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.OpenGLControl_MouseUp); 104 | 105 | #line default 106 | #line hidden 107 | 108 | #line 15 "..\..\CADView.xaml" 109 | this.openGLCtrl.MouseMove += new System.Windows.Input.MouseEventHandler(this.OpenGLControl_MouseMove); 110 | 111 | #line default 112 | #line hidden 113 | 114 | #line 16 "..\..\CADView.xaml" 115 | this.openGLCtrl.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.OpenGLControl_MouseWheel); 116 | 117 | #line default 118 | #line hidden 119 | 120 | #line 18 "..\..\CADView.xaml" 121 | this.openGLCtrl.Loaded += new System.Windows.RoutedEventHandler(this.UserControl_Loaded); 122 | 123 | #line default 124 | #line hidden 125 | 126 | #line 19 "..\..\CADView.xaml" 127 | this.openGLCtrl.PreviewKeyDown += new System.Windows.Input.KeyEventHandler(this.UserControl_PreviewKeyDown); 128 | 129 | #line default 130 | #line hidden 131 | 132 | #line 20 "..\..\CADView.xaml" 133 | this.openGLCtrl.PreviewKeyUp += new System.Windows.Input.KeyEventHandler(this.UserControl_PreviewKeyUp); 134 | 135 | #line default 136 | #line hidden 137 | return; 138 | } 139 | this._contentLoaded = true; 140 | } 141 | } 142 | } 143 | 144 | -------------------------------------------------------------------------------- /CADCtrl/obj/Debug/DesignTimeResolveAssemblyReferences.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/obj/Debug/DesignTimeResolveAssemblyReferences.cache -------------------------------------------------------------------------------- /CADCtrl/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache -------------------------------------------------------------------------------- /CADCtrl/obj/Release/CADCtrl.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\bin\Release\CADCtrl.dll 2 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\bin\Release\CADCtrl.pdb 3 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\bin\Release\SharpGL.dll 4 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\bin\Release\SharpGL.SceneGraph.dll 5 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\bin\Release\SharpGL.WPF.dll 6 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\obj\Release\CADView.baml 7 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\obj\Release\CADView.g.cs 8 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\obj\Release\CADCtrl_MarkupCompile.cache 9 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\obj\Release\CADCtrl.g.resources 10 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\obj\Release\CADCtrl.dll 11 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\obj\Release\CADCtrl.pdb 12 | -------------------------------------------------------------------------------- /CADCtrl/obj/Release/CADCtrl.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/obj/Release/CADCtrl.dll -------------------------------------------------------------------------------- /CADCtrl/obj/Release/CADCtrl.g.resources: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/obj/Release/CADCtrl.g.resources -------------------------------------------------------------------------------- /CADCtrl/obj/Release/CADCtrl.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/obj/Release/CADCtrl.pdb -------------------------------------------------------------------------------- /CADCtrl/obj/Release/CADCtrl_MarkupCompile.cache: -------------------------------------------------------------------------------- 1 | CADCtrl 2 | 3 | 4 | library 5 | C# 6 | .cs 7 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\obj\Release\ 8 | CADCtrl 9 | none 10 | false 11 | TRACE 12 | 13 | 12090036334 14 | 15 | 31181065217 16 | 17-2049788891 17 | CADView.xaml; 18 | 19 | False 20 | 21 | -------------------------------------------------------------------------------- /CADCtrl/obj/Release/CADCtrl_MarkupCompile.i.cache: -------------------------------------------------------------------------------- 1 | CADCtrl 2 | 3 | 4 | library 5 | C# 6 | .cs 7 | D:\C++公用文件夹\My Projects_VS2010\CADCtrl\CADCtrl\obj\Release\ 8 | CADCtrl 9 | none 10 | false 11 | TRACE 12 | 13 | 12090036334 14 | 15 | 4-546616520 16 | 17-2049788891 17 | CADView.xaml; 18 | 19 | False 20 | 21 | -------------------------------------------------------------------------------- /CADCtrl/obj/Release/CADView.baml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/obj/Release/CADView.baml -------------------------------------------------------------------------------- /CADCtrl/obj/Release/CADView.g.cs: -------------------------------------------------------------------------------- 1 | #pragma checksum "..\..\CADView.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "ACEA827B51B4AFE1F07548A29972C062" 2 | //------------------------------------------------------------------------------ 3 | // 4 | // 此代码由工具生成。 5 | // 运行时版本:4.0.30319.42000 6 | // 7 | // 对此文件的更改可能会导致不正确的行为,并且如果 8 | // 重新生成代码,这些更改将会丢失。 9 | // 10 | //------------------------------------------------------------------------------ 11 | 12 | using SharpGL.WPF; 13 | using System; 14 | using System.Diagnostics; 15 | using System.Windows; 16 | using System.Windows.Automation; 17 | using System.Windows.Controls; 18 | using System.Windows.Controls.Primitives; 19 | using System.Windows.Data; 20 | using System.Windows.Documents; 21 | using System.Windows.Ink; 22 | using System.Windows.Input; 23 | using System.Windows.Markup; 24 | using System.Windows.Media; 25 | using System.Windows.Media.Animation; 26 | using System.Windows.Media.Effects; 27 | using System.Windows.Media.Imaging; 28 | using System.Windows.Media.Media3D; 29 | using System.Windows.Media.TextFormatting; 30 | using System.Windows.Navigation; 31 | using System.Windows.Shapes; 32 | using System.Windows.Shell; 33 | 34 | 35 | namespace CADCtrl { 36 | 37 | 38 | /// 39 | /// CADView 40 | /// 41 | public partial class CADView : System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector { 42 | 43 | 44 | #line 10 "..\..\CADView.xaml" 45 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] 46 | internal SharpGL.WPF.OpenGLControl openGLCtrl; 47 | 48 | #line default 49 | #line hidden 50 | 51 | private bool _contentLoaded; 52 | 53 | /// 54 | /// InitializeComponent 55 | /// 56 | [System.Diagnostics.DebuggerNonUserCodeAttribute()] 57 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")] 58 | public void InitializeComponent() { 59 | if (_contentLoaded) { 60 | return; 61 | } 62 | _contentLoaded = true; 63 | System.Uri resourceLocater = new System.Uri("/CADCtrl;component/cadview.xaml", System.UriKind.Relative); 64 | 65 | #line 1 "..\..\CADView.xaml" 66 | System.Windows.Application.LoadComponent(this, resourceLocater); 67 | 68 | #line default 69 | #line hidden 70 | } 71 | 72 | [System.Diagnostics.DebuggerNonUserCodeAttribute()] 73 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")] 74 | [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] 75 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")] 76 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] 77 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] 78 | void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { 79 | switch (connectionId) 80 | { 81 | case 1: 82 | this.openGLCtrl = ((SharpGL.WPF.OpenGLControl)(target)); 83 | 84 | #line 10 "..\..\CADView.xaml" 85 | this.openGLCtrl.OpenGLDraw += new SharpGL.SceneGraph.OpenGLEventHandler(this.OpenGLControl_OpenGLDraw); 86 | 87 | #line default 88 | #line hidden 89 | 90 | #line 10 "..\..\CADView.xaml" 91 | this.openGLCtrl.OpenGLInitialized += new SharpGL.SceneGraph.OpenGLEventHandler(this.OpenGLControl_OpenGLInitialized); 92 | 93 | #line default 94 | #line hidden 95 | 96 | #line 10 "..\..\CADView.xaml" 97 | this.openGLCtrl.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.OpenGLControl_MouseDown); 98 | 99 | #line default 100 | #line hidden 101 | 102 | #line 10 "..\..\CADView.xaml" 103 | this.openGLCtrl.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.OpenGLControl_MouseUp); 104 | 105 | #line default 106 | #line hidden 107 | 108 | #line 10 "..\..\CADView.xaml" 109 | this.openGLCtrl.MouseMove += new System.Windows.Input.MouseEventHandler(this.OpenGLControl_MouseMove); 110 | 111 | #line default 112 | #line hidden 113 | 114 | #line 10 "..\..\CADView.xaml" 115 | this.openGLCtrl.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.OpenGLControl_MouseWheel); 116 | 117 | #line default 118 | #line hidden 119 | 120 | #line 10 "..\..\CADView.xaml" 121 | this.openGLCtrl.Loaded += new System.Windows.RoutedEventHandler(this.UserControl_Loaded); 122 | 123 | #line default 124 | #line hidden 125 | 126 | #line 10 "..\..\CADView.xaml" 127 | this.openGLCtrl.PreviewKeyDown += new System.Windows.Input.KeyEventHandler(this.UserControl_PreviewKeyDown); 128 | 129 | #line default 130 | #line hidden 131 | return; 132 | } 133 | this._contentLoaded = true; 134 | } 135 | } 136 | } 137 | 138 | -------------------------------------------------------------------------------- /CADCtrl/obj/Release/CADView.g.i.cs: -------------------------------------------------------------------------------- 1 | #pragma checksum "..\..\CADView.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "ACEA827B51B4AFE1F07548A29972C062" 2 | //------------------------------------------------------------------------------ 3 | // 4 | // 此代码由工具生成。 5 | // 运行时版本:4.0.30319.42000 6 | // 7 | // 对此文件的更改可能会导致不正确的行为,并且如果 8 | // 重新生成代码,这些更改将会丢失。 9 | // 10 | //------------------------------------------------------------------------------ 11 | 12 | using SharpGL.WPF; 13 | using System; 14 | using System.Diagnostics; 15 | using System.Windows; 16 | using System.Windows.Automation; 17 | using System.Windows.Controls; 18 | using System.Windows.Controls.Primitives; 19 | using System.Windows.Data; 20 | using System.Windows.Documents; 21 | using System.Windows.Ink; 22 | using System.Windows.Input; 23 | using System.Windows.Markup; 24 | using System.Windows.Media; 25 | using System.Windows.Media.Animation; 26 | using System.Windows.Media.Effects; 27 | using System.Windows.Media.Imaging; 28 | using System.Windows.Media.Media3D; 29 | using System.Windows.Media.TextFormatting; 30 | using System.Windows.Navigation; 31 | using System.Windows.Shapes; 32 | using System.Windows.Shell; 33 | 34 | 35 | namespace CADCtrl { 36 | 37 | 38 | /// 39 | /// CADView 40 | /// 41 | public partial class CADView : System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector { 42 | 43 | 44 | #line 10 "..\..\CADView.xaml" 45 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] 46 | internal SharpGL.WPF.OpenGLControl openGLCtrl; 47 | 48 | #line default 49 | #line hidden 50 | 51 | private bool _contentLoaded; 52 | 53 | /// 54 | /// InitializeComponent 55 | /// 56 | [System.Diagnostics.DebuggerNonUserCodeAttribute()] 57 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")] 58 | public void InitializeComponent() { 59 | if (_contentLoaded) { 60 | return; 61 | } 62 | _contentLoaded = true; 63 | System.Uri resourceLocater = new System.Uri("/CADCtrl;component/cadview.xaml", System.UriKind.Relative); 64 | 65 | #line 1 "..\..\CADView.xaml" 66 | System.Windows.Application.LoadComponent(this, resourceLocater); 67 | 68 | #line default 69 | #line hidden 70 | } 71 | 72 | [System.Diagnostics.DebuggerNonUserCodeAttribute()] 73 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")] 74 | [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] 75 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")] 76 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] 77 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] 78 | void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { 79 | switch (connectionId) 80 | { 81 | case 1: 82 | this.openGLCtrl = ((SharpGL.WPF.OpenGLControl)(target)); 83 | 84 | #line 10 "..\..\CADView.xaml" 85 | this.openGLCtrl.OpenGLDraw += new SharpGL.SceneGraph.OpenGLEventHandler(this.OpenGLControl_OpenGLDraw); 86 | 87 | #line default 88 | #line hidden 89 | 90 | #line 10 "..\..\CADView.xaml" 91 | this.openGLCtrl.OpenGLInitialized += new SharpGL.SceneGraph.OpenGLEventHandler(this.OpenGLControl_OpenGLInitialized); 92 | 93 | #line default 94 | #line hidden 95 | 96 | #line 10 "..\..\CADView.xaml" 97 | this.openGLCtrl.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.OpenGLControl_MouseDown); 98 | 99 | #line default 100 | #line hidden 101 | 102 | #line 10 "..\..\CADView.xaml" 103 | this.openGLCtrl.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.OpenGLControl_MouseUp); 104 | 105 | #line default 106 | #line hidden 107 | 108 | #line 10 "..\..\CADView.xaml" 109 | this.openGLCtrl.MouseMove += new System.Windows.Input.MouseEventHandler(this.OpenGLControl_MouseMove); 110 | 111 | #line default 112 | #line hidden 113 | 114 | #line 10 "..\..\CADView.xaml" 115 | this.openGLCtrl.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.OpenGLControl_MouseWheel); 116 | 117 | #line default 118 | #line hidden 119 | 120 | #line 10 "..\..\CADView.xaml" 121 | this.openGLCtrl.Loaded += new System.Windows.RoutedEventHandler(this.UserControl_Loaded); 122 | 123 | #line default 124 | #line hidden 125 | 126 | #line 10 "..\..\CADView.xaml" 127 | this.openGLCtrl.PreviewKeyDown += new System.Windows.Input.KeyEventHandler(this.UserControl_PreviewKeyDown); 128 | 129 | #line default 130 | #line hidden 131 | return; 132 | } 133 | this._contentLoaded = true; 134 | } 135 | } 136 | } 137 | 138 | -------------------------------------------------------------------------------- /CADCtrl/obj/Release/DesignTimeResolveAssemblyReferences.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/obj/Release/DesignTimeResolveAssemblyReferences.cache -------------------------------------------------------------------------------- /CADCtrl/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/11Zero/CADCtrl/706b7250b24ebd62d8191fffb1979eca81e7619e/CADCtrl/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CADCtrl 2 | 基于WPF的动态链接库形式的CAD控件 3 | ## 使用说明 ## 4 | 1. 解决方案添加CADCtrl.dll引用 5 | 2. 在所需添加控件的窗体中using CADCtrl 6 | 3. 在所需添加控件的窗体xaml布局文件头部Window属性中添加xmlns:CAD="clr-namespace:CADCtrl;assembly=CADCtrl" 7 | 4. 在窗体中的Grid或其他容器内添加,上述布局属性可根据控件父类UserControl属性来修改。 8 | ## 接口列表 ## 9 | - public void UserDrawLine(Point p1, Point p2, int color_id = 0) 10 | - public void UserDrawLine(CADLine line, int color_id = 0) 11 | - public void UserDelAllLines() 12 | - public void UserDelLine(int line_id) 13 | - public void UserDelAllRects() 14 | - public void UserDelRect(int rect_id) 15 | - public void UserDelPoint(int point_id) 16 | - public void UserDelAllPoints() 17 | - public bool UserDrawRect(Point p1, Point p2, int color_id = 0) 18 | - public bool UserDrawRect(CADRect rect, int color_id = 0) 19 | - public void UserDrawPoint(CADPoint point, int color_id = 0) 20 | - public void UserSelLine(int id) 21 | - public void UserSelRect(int id) 22 | - public void UserSelPoint(int id) 23 | - public int[] UserGetSelLines() 24 | - public int[] UserGetSelRects() 25 | - public int[] UserGetSelPoints() 26 | - public Dictionary UserGetLines() 27 | - public Dictionary UserGetRects() 28 | - public Dictionary UserGetPoints() --------------------------------------------------------------------------------