public static bool CheckInCirlce(double x, double y, Circle c)
 {
     double kc = Math.Sqrt((x - c.GetX()) * (x - c.GetX()) + (y - c.GetY()) * (y - c.GetY()));
     if (kc < c.GetRadius())
     { return true; }
     return false;
 }
        private List<Circle> circleChildrens; //các đường tròn con trong 1 đường tròn cha

        public Circle(int _handle)
        {
            this.handle = _handle;
            this.x = Lcad.PropGetFloat(handle, Lcad.LC_PROP_CIRCLE_X);
            this.y = Lcad.PropGetFloat(handle, Lcad.LC_PROP_CIRCLE_Y);
            this.radius = Lcad.PropGetFloat(handle, Lcad.LC_PROP_CIRCLE_RAD);
            this.circleChildrens = new List<Circle>();
            this.circleParent = null;
        }
 //delete Circle Children
 public void RemoveCircleChildren(Circle _circleChildren)
 {
     circleChildrens.Remove(_circleChildren);
 }
 //add Circle Children
 public void AddCirleChildren(Circle _circleChidren)
 {
     circleChildrens.Add(_circleChidren);
 }
 //set Circle Parent
 public void SetCircleParent(Circle _circlePrent)
 {
     this.circleParent = _circlePrent;
 }
 private void VeKhoangCach(Circle c1, Circle c2)
 {
     int hBlockModel = Lcad.PropGetHandle(hDrw, Lcad.LC_PROP_DRW_BLOCK_MODEL);
     Lcad.DrwAddTextStyle(hDrw, "Arial", "Arial");
     Lcad.PropPutStr(hDrw, Lcad.LC_PROP_DRW_TEXTSTYLE, "Arial");
     int newText = 0, newLine = 0;
     newText = Lcad.BlockAddTextWin2(hBlockModel, this.banVeChinh.DeltaX.ToString(), ((c1.GetX() + c2.GetX()) / 2), ((c1.GetY() + c2.GetY()) / 2), Lcad.LC_TA_CENTER, 0.75, 1, 0, 0);
     newLine = Lcad.BlockAddLine(hBlockModel, c1.GetX(), c1.GetY(), c2.GetX(), c2.GetY());            
     Lcad.PropPutStr(newText, Lcad.LC_PROP_ENT_LAYER, "LuoiKichThuoc");
     Lcad.PropPutStr(newLine, Lcad.LC_PROP_ENT_LAYER, "LuoiKichThuoc");
 }
 private void MouseDblClkProc_XayDungLuoiLoMin(int hWnd, int Button, int Flags, int Xwin, int Ywin, double Xdrw, double Ydrw)
 {
     int hBlockModel = Lcad.PropGetHandle(hDrw, Lcad.LC_PROP_DRW_BLOCK_MODEL);
     if (mgCircles == null)
     {
         mgCircles = new ManageCircle();
     }
     else
     {
         Lcad.LayerClear(layerLoMin, hBlockModel);
         Lcad.LayerClear(layerLuoiKichThuoc, hBlockModel);
         mgCircles = new ManageCircle();
     }                                
     int hEntCircle = Lcad.BlockAddCircle(hBlockModel, Xdrw, Ydrw, banKinh, false);
     Lcad.PropPutInt(hEntCircle, Lcad.LC_PROP_ENT_KEY, keyCircle);
     Lcad.PropPutStr(hEntCircle, Lcad.LC_PROP_ENT_LAYER, "LoMin");
     Lcad.BlockUnselect(hBlockModel);           
     //tạo danh sách cột đầu tiên
     List<Circle> listCotDau = new List<Circle>();
     Circle root = new Circle(hEntCircle);
     listCotDau.Add(root);
     //tạo cột đầu tiên từ điểm gốc (số điểm trong cột ứng với số hàng trừ đi điểm gốc)
     for (int i = 0; i < soHang - 1; i++)
     {
         int newHEnt = Lcad.BlockAddClone(hBlockModel, listCotDau[i].GetHandle());
         Lcad.PropPutInt(newHEnt, Lcad.LC_PROP_ENT_KEY, keyCircle);
         Lcad.BlockSelectEnt(hBlockModel, newHEnt, true);
         Lcad.BlockSelMove(hBlockModel, 0, khoangCachHang, false, true);
         Lcad.BlockUnselect(hBlockModel);
         listCotDau.Add(new Circle(newHEnt));
     }
     mgCircles.AddListCircle(listCotDau);
     //thêm các cột còn lại (ứng với số cột trừ đi cột đầu)         
     for (int i = 0; i < soCot - 1; i++)
     {
         List<Circle> listCotGanNhat = new List<Circle>();
         List<Circle> listCotMoi = new List<Circle>();
         if (khoangCachCot > 0)
         {
             listCotGanNhat = mgCircles.GetListCirleOfLastColumn();
         }
         else
         {
             listCotGanNhat = mgCircles.GetListCirleOfFirstColumn();
         }
         foreach (var circle in listCotGanNhat)
         {
             int newHEnt = Lcad.BlockAddClone(hBlockModel, circle.GetHandle());
             Lcad.PropPutInt(newHEnt, Lcad.LC_PROP_ENT_KEY, keyCircle);
             Lcad.BlockSelectEnt(hBlockModel, newHEnt, true);
             Lcad.BlockSelMove(hBlockModel, khoangCachCot, 0, false, true);
             Lcad.BlockUnselect(hBlockModel);
             listCotMoi.Add(new Circle(newHEnt));
         }
         mgCircles.AddListCircle(listCotMoi);
     }
     //hiển thị lưới kích thước
     if (this.banVeChinh.HienKhoangCach)
     {
         DungLuoiKichThuoc();
     }
     //load lại
     //MessageBox.Show("hang" + soHang + "\ncot" + soCot + "\nkc hang" + khoangCachHang + "\nkc cot" + khoangCachCot + "\nX" + Xdrw + "\nY" + Ydrw);
     Lcad.DrwRegenViews(hDrw, 0);
     Lcad.WndExeCommand(hWnd, Lcad.LC_CMD_ZOOM_EXT, 0);
     Lcad.OnEventMouseDblClk(_EventMouseDbclick_LoMin);
     LuuHoChieu(this.hoChieuChinh.MaHoChieu);    //ăn gian...
     BS_LiteCAD.ShowNotifyAutoHide(elementHost1, "Xây dựng lưới lỗ khoan - hoàn thành");
 }
 //vẽ kíp nối giữa 2 lỗ khoan cùng 1 cột
 private void DrawLine_Y(Circle c1, Circle c2)
 {
     //ve
     int hBlockModel = Lcad.PropGetHandle(hDrw, Lcad.LC_PROP_DRW_BLOCK_MODEL);
     int newLine = 0;
     newLine = Lcad.BlockAddLine(hBlockModel, c1.GetX(), c1.GetY(), c2.GetX(), c2.GetY());
     Lcad.PropPutStr(newLine, Lcad.LC_PROP_ENT_LAYER, "KipNo");
 }
 //vẽ kíp nối giữa 2 lỗ khoan cùng 1 hàng
 private void DrawLine_X(Circle c1, Circle c2)
 {
     int gocNghieng = 15;
     double canhHuyen = banVeChinh.DeltaX * 30 / 100;
     double x1, y1, x2, y2, c;  //toa do 2 diem gap khuc
     double a, b;
     //tinh toan
     b = Math.Sin(gocNghieng * (Math.PI / 180)) * canhHuyen;
     a = Math.Sqrt((canhHuyen * canhHuyen) - (b * b));
     //c = banVeChinh.DeltaX - (b * 2);    //sua moi cai dong nay thoi @@
     c = Math.Abs(c1.GetX() - c2.GetX()) - (b * 2);
     if (c1.GetX() > c2.GetX())
     {
         x1 = c1.GetX() - b;
     }
     else
     {
         x1 = c1.GetX() + b;
     }
     y1 = c1.GetY() + a;
     if (c1.GetX() > c2.GetX())
     {
         x2 = x1 - c;
     }
     else
     {
         x2 = x1 + c;
     }
     y2 = y1;
     //ve
     int hBlockModel = Lcad.PropGetHandle(hDrw, Lcad.LC_PROP_DRW_BLOCK_MODEL);
     int newLine1 = 0, newLine2 = 0, newLine3 = 0;
     newLine1 = Lcad.BlockAddLine(hBlockModel, c1.GetX(), c1.GetY(), x1, y1);
     newLine2 = Lcad.BlockAddLine(hBlockModel, x1, y1, x2, y2);
     newLine3 = Lcad.BlockAddLine(hBlockModel, x2, y2, c2.GetX(), c2.GetY());
     Lcad.PropPutStr(newLine1, Lcad.LC_PROP_ENT_LAYER, "KipNo");
     Lcad.PropPutStr(newLine2, Lcad.LC_PROP_ENT_LAYER, "KipNo");
     Lcad.PropPutStr(newLine3, Lcad.LC_PROP_ENT_LAYER, "KipNo");
 }
 //cập nhật ds lỗ khoan theo bản vẽ
 private void UpdateCircleFromAutocad()
 {
     int hBlockModel = Lcad.PropGetHandle(hDrw, Lcad.LC_PROP_DRW_BLOCK_MODEL);
     List<Circle> listCircles = mgCircles.GetListCircles();
     foreach(Circle c in listCircles)
     {
         int hEnt = Lcad.BlockGetFirstEnt(hBlockModel);
         while (hEnt != 0)
         {
             int entID = Lcad.PropGetInt(hEnt, Lcad.LC_PROP_ENT_ID);
             int entType = Lcad.PropGetInt(hEnt, Lcad.LC_PROP_ENT_TYPE);
             if (!Lcad.PropGetBool(hEnt, Lcad.LC_PROP_ENT_DELETED))   //kiểm tra xem ent bị xóa hay không
             {
                 if ((entType == Lcad.LC_ENT_CIRCLE) && (entID == c.GetID()))
                 {
                     Circle newCircle = new Circle(hEnt);
                     c.SetX(newCircle.GetX());
                     c.SetY(newCircle.GetY());
                     break;
                 }
             }
             hEnt = Lcad.BlockGetNextEnt(hBlockModel, hEnt);
         }
     }            
 }
예제 #11
0
 private void MouseDblClkProc_XayDungLuoiLoMin(int hWnd, int Button, int Flags, int Xwin, int Ywin, double Xdrw, double Ydrw)
 {
     if (mgCircles == null)
     {
         mgCircles = new ManageCircle();
     }
     int hModelBlock = Lcad.PropGetHandle(hDrw, Lcad.LC_PROP_DRW_BLOCK_MODEL);
     double r = 0.5;
     int hEntCircle = Lcad.BlockAddCircle(hModelBlock, Xdrw, Ydrw, r, false);
     Lcad.BlockUnselect(hModelBlock);
     // Add a column of new Circles
     List<Circle> listCotDau = new List<Circle>();
     Circle root = new Circle(hEntCircle);
     listCotDau.Add(root);
     //Them hang
     //khoangCachHang = khoangCachHang * -1;
     for (int i = 0; i < soHang - 1; i++)
     {
         int newHEnt = Lcad.BlockAddClone(hModelBlock, listCotDau[i].GetHandle());
         Lcad.BlockSelectEnt(hModelBlock, newHEnt, true);
         Lcad.BlockSelMove(hModelBlock, 0, khoangCachHang, false, true);
         Lcad.BlockUnselect(hModelBlock);
         listCotDau.Add(new Circle(newHEnt));
     }
     mgCircles.AddListCircle(listCotDau);
     //Them cot
     for (int i = 0; i < soCot - 1; i++)
     {
         List<Circle> listCotGanNhat = new List<Circle>();
         List<Circle> listCotMoi = new List<Circle>();
         if (khoangCachCot > 0)
         {
             listCotGanNhat = mgCircles.GetListCirleOfLastColumn();
         }
         else
         {
             listCotGanNhat = mgCircles.GetListCirleOfFirstColumn();
         }
         foreach (var circle in listCotGanNhat)
         {
             int newHEnt = Lcad.BlockAddClone(hModelBlock, circle.GetHandle());
             Lcad.BlockSelectEnt(hModelBlock, newHEnt, true);
             Lcad.BlockSelMove(hModelBlock, khoangCachCot, 0, false, true);
             Lcad.BlockUnselect(hModelBlock);
             listCotMoi.Add(new Circle(newHEnt));
         }
         mgCircles.AddListCircle(listCotMoi);
     }
     MessageBox.Show("hang" + soHang + "\ncot" + soCot + "\nkc hang" + khoangCachHang + "\nkc cot" + khoangCachCot + "\nX" + Xdrw + "\nY" + Ydrw);
     Lcad.DrwRegenViews(hDrw, 0);
     Lcad.WndExeCommand(hWnd, Lcad.LC_CMD_ZOOM_EXT, 0);
     Lcad.OnEventMouseDblClk(_EventMouseDbclick_LoMin);
 }
 public LoKhoan(String maHoChieu, Circle c)
 {
     this.iD = null;
     this.maHoChieu = maHoChieu;
     this.maBanVe = BS_HoChieu.HoChieu(maHoChieu).MaBanVe;
     this.maMayKhoan = null;
     this.maLoKhoan = c.GetID().ToString();
     this.banKinh = c.GetRadius();
     this.chieuSau = 0;
     this.huongKhoan = null;
     this.toaDoX = c.GetX();
     this.toaDoY = c.GetY();
     this.lt = 0;
     this.lkk = 0;
     this.l0 = 0;
     this.lbua = 0;
 }