Exemple #1
0
 public SvgScriptElement(string s)
 {
     CDataNode tn = new CDataNode(s);
     AddChild(tn);
 }
        /// <summary>
        /// 형상 입력때나 수정때 형상을 다시 그린다
        ///  - 수정 부품만 빼고 타 부품들은 다시 그리고, 수정 부품은 창에 기록된 값을 그린다.
        /// </summary>
        /// <param name="pointControl">좌표점 PointControl</param>
        /// <param name="bRedraw">형상 수정이 없어도 강제로 ARC 변경때 강제로 수정함</param>
        internal void drawTemporaryFace(CPointUI pointControl, bool bRedraw = false)
        {
            try
            {
                /// [문제]
                ///  - Form 에서는 Parent를 사용할 수 없어 Owner 속성을 사용하지만
                ///    종종 Owner 가 null 로 넘어오는 문제가 발생한다.
                /// [해결]
                ///  - PopupShape 창을 생성하기 전에 Owner 속성을 FormMain 으로 초기화 해 두어야
                ///    확실하게 FormMain 을 얻을 수 있다.
                FormMain formMain = ((FormMain)this.Owner);

                if (formMain == null)
                {
                    CNotice.printLogID("CNGM");
                    return;
                }

                CScriptFEMM femm = formMain.m_femm;

                CDataNode nodeParts = formMain.m_design.getNode(m_strPartName);

                /// 0. 해당 좌표점의 수정이 있었는지를 판단한다.
                ///  - 수정이 있는 경우만 다시 그리기 위해서이다.
                bool retCheck = false;

                /// 초기 생성때는 이전 nodeParts 가 없음으로 사용하지 않고, 기존 노드의 수정때만 사용한다.
                if (nodeParts != null)
                {
                    /// 좌표 Control 에 빈칸이 존재하는 지를 확인함
                    for (int i = 0; i < ListPointUI.Count; i++)
                    {
                        /// 해당 좌표점만 비교한다.
                        /// 만약, Parts 의 모든 좌표점을 비교하면 다른 좌표점이 수정되었을때 나머지 좌표점의 수정이 없어도 다시 그리기가 된다.
                        if (ListPointUI[i] == pointControl)
                        {
                            if (((CShapeParts)nodeParts).Face.RelativePointList[i].X != Double.Parse(ListPointUI[i].StrCoordX.Trim()))
                            {
                                retCheck = true;
                            }

                            if (((CShapeParts)nodeParts).Face.RelativePointList[i].Y != Double.Parse(ListPointUI[i].StrCoordZ.Trim()))
                            {
                                retCheck = true;
                            }
                        }
                    }
                }

                // Arc 관련 이벤트 호출이면 강제로 다시그리기를 한다.
                if (bRedraw == true)
                {
                    retCheck = true;
                }

                if (retCheck == true)
                {
                    femm.deleteAll();

                    /// 1. 혹시 수정중이라면, 현재 작업 중인 Face 를 제외하고 형상 그리기
                    foreach (CDataNode node in formMain.m_design.GetNodeList)
                    {
                        if (node.GetType().BaseType.Name == "CShapeParts")
                        {
                            if (node.NodeName != m_strPartName)
                            {
                                ((CShapeParts)node).Face.drawFace(femm);
                            }
                        }
                    }
                }

                /// 2. 현재 수정중이거나 생성중인 Face 의 형상 그리기
                retCheck = true;

                /// 좌표 Control 에 빈칸이 존재하는 지를 확인함
                for (int i = 0; i < ListPointUI.Count; i++)
                {
                    if (ListPointUI[i].StrCoordX.Trim().Length == 0)
                    {
                        retCheck = false;
                    }

                    if (ListPointUI[i].StrCoordZ.Trim().Length == 0)
                    {
                        retCheck = false;
                    }
                }

                double dBase_X, dBase_Y;
                dBase_X = dBase_Y = 0;

                dBase_X = Double.Parse(textBoxBaseX.Text.Trim());
                dBase_Y = Double.Parse(textBoxBaseY.Text.Trim());

                // 모든 데이터가 입력된 경우는 폐곡선의 정상적인 Face 를 그린다.
                if (retCheck == true)
                {
                    CFace faceTemp = makeFaceInPopup();

                    if (null != faceTemp)
                    {
                        faceTemp.drawFace(femm);
                    }
                    else
                    {
                        CNotice.printLogID("TSWN");
                    }
                }
                // 모든 데이터가 아직 입력되지 않은 상태는 입력중인 데이터만으로 그림을 그린다.
                else
                {
                    double dP1_X, dP1_Y, dP2_X, dP2_Y;

                    bool bArc, bArcDirection;

                    dP1_X = dP1_Y = dP2_X = dP2_Y = 0;
                    bArc  = bArcDirection = false;

                    for (int i = 0; i < ListPointUI.Count; i++)
                    {
                        retCheck = true;

                        if (ListPointUI[i].StrCoordX.Trim().Length == 0)
                        {
                            retCheck = false;
                        }
                        else
                        {
                            dP1_X = Double.Parse(ListPointUI[i].StrCoordX.Trim()) + dBase_X;
                        }

                        if (ListPointUI[i].StrCoordZ.Trim().Length == 0)
                        {
                            retCheck = false;
                        }
                        else
                        {
                            dP1_Y = Double.Parse(ListPointUI[i].StrCoordZ.Trim()) + dBase_Y;
                        }

                        /// X, Y 값이 모두 입력된 Point Control 인 경우
                        if (retCheck == true)
                        {
                            if (i == 0)
                            {
                                /// 사각형, 다각형 모두 적용된다.
                                femm.drawPoint(dP1_X, dP1_Y);
                            }
                            else
                            {
                                if (this.FaceType == EMFaceType.RECTANGLE)
                                {
                                    CNotice.printLogID("ATTW");
                                }
                                /// 다각형만 적용된다.
                                /// 만약 사각형의 경우 i = 1 까지 모두 채워지면 모두 입력된 상태로 if 문의 위에처 처리되기 때문이다.
                                bArc          = ListPointUI[i].IsArc;
                                bArcDirection = ListPointUI[i].IsArcDirection;

                                if (bArc == true)
                                {
                                    femm.drawArc(dP2_X, dP2_Y, dP1_X, dP1_Y, bArcDirection);
                                }
                                else
                                {
                                    femm.drawLine(dP2_X, dP2_Y, dP1_X, dP1_Y);
                                }
                            }

                            // 이번 점을 이전 점으로 저장한다.
                            dP2_X = dP1_X;
                            dP2_Y = dP1_Y;
                        }
                        /// 채워지지 않은 좌표값을 발견하면 바로 빠져 나간다
                        else
                        {
                            break;
                        }
                    }
                }

                /// 선택된 좌표점을 붉은 색으로 표시한다.
                ///
                /// Base X, Y 변경 할때나 Leave 이벤트는 제외해야 함으로 null 을 넘겨오도록 되어 있다.
                if (pointControl != null)
                {
                    /// XY 값 모두 들어 있는 경우에만 표시를 한다.
                    if (pointControl.StrCoordX != "" && pointControl.StrCoordZ != "")
                    {
                        CPoint selectedPoint = new CPoint();

                        selectedPoint.X = Double.Parse(pointControl.StrCoordX) + dBase_X;
                        selectedPoint.Y = Double.Parse(pointControl.StrCoordZ) + dBase_Y;

                        femm.clearSelected();

                        femm.selectPoint(selectedPoint);
                    }
                }
            }
            catch (Exception ex)
            {
                CNotice.printLog(ex.Message);
            }
        }
Exemple #3
0
 public SvgScriptElement()
 {
     CDataNode tn = new CDataNode("");
     AddChild(tn);
 }