Example #1
0
        public void setBlockPropCurrent(CScriptFEMM femm, double dCurrent, double dMeshSize)
        {
            CPoint blockPoint = null;

            blockPoint = this.Face.getBlockPoint();

            if (blockPoint == null)
            {
                CNotice.printTraceID("NBPF");
                return;
            }

            string strMaterialName = this.m_strMaterial;

            string strCircuit = NodeName + "_current";

            if (CurrentDirection == EMCurrentDirection.OUT)
            {
                dCurrent = -dCurrent;
            }

            femm.addCircuitProp(strCircuit, dCurrent);

            femm.setBlockProp(blockPoint, strMaterialName, dMeshSize, strCircuit, 0, MovingPart, Turns);
        }
Example #2
0
        public bool loadSettingFromFile()
        {
            string strAppDataPath     = Environment.GetEnvironmentVariable("APPDATA");
            string strSettingFilePath = Path.Combine(strAppDataPath, "DoSA-Open_2D");

            string strSettingFileFullName = Path.Combine(strSettingFilePath, "setting.ini");


            // CSettingData.ProgramDirectory 가 초기화 되어 있어야 한다.
            if (m_manageFile.isExistFile(strSettingFileFullName) == false)
            {
                CNotice.noticeWarningID("TCFD");
                return(false);
            }

            try
            {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(CSettingDataClone));
                StreamReader  reader        = new StreamReader(strSettingFileFullName);

                CSettingDataClone settingDataClone = new CSettingDataClone();
                settingDataClone = (CSettingDataClone)xmlSerializer.Deserialize(reader);

                settingDataClone.copyCloneToSettingData();

                reader.Close();
            }
            catch (Exception ex)
            {
                CNotice.printTrace(ex.Message);
                CNotice.printTraceID("AEOW");
            }

            return(true);
        }
Example #3
0
        public void drawDesign(CScriptFEMM femm)
        {
            CFace face = null;

            foreach (CNode node in NodeList)
            {
                if (node.GetType().BaseType.Name == "CParts")
                {
                    CParts nodeParts = (CParts)node;

                    face = nodeParts.Face;

                    if (null != face)
                    {
                        nodeParts.Face.drawFace(femm, nodeParts.MovingPart);
                    }
                    else
                    {
                        CNotice.printTraceID("YATT1");
                    }
                }
            }

            femm.zoomFit();
        }
Example #4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (this.m_faceType != EMFaceType.POLYGON)
            {
                CNotice.printTraceID("TBOA");
                return;
            }

            this.addPointControl(new CPointControl(), true, this.panelPointControl);
        }
Example #5
0
        /// <summary>
        /// FEMM 에 Face 를 그린다.
        ///
        /// FEMM 에 형상을 그릴 때는 절대좌표를 사용해야 한다.
        /// </summary>
        /// <param name="femm">FEMM</param>
        /// <param name="emMoving">Line 의 Group 를 결정하기 위한 동작부 여부</param>
        public bool drawFace(CScriptFEMM femm, EMMoving emMoving = EMMoving.FIXED)
        {
            double x1, y1, x2, y2;
            bool   bDirectionArc = false;

            if (m_listRelativePoint.Count < MIN_POINT_COUNT)
            {
                CNotice.printTraceID("YATT2");
                return(false);
            }

            /// 매번 생성하는 Property 이기 때문에
            /// LineList 는 새로운 List에  담는 동작 한번만 호출하고, 사용은 새로운 List 를 사용한다.
            List <CPoint> listAbsolutePoint = new List <CPoint>();

            listAbsolutePoint = AbsolutePointList;

            // Face 에 저장될 때는 Rectangle 도 4개의 직선으로 저장되기 때문에
            // Face 를 그릴 때는 모두 다각형으로 취급한다.
            for (int i = 0; i < listAbsolutePoint.Count; i++)
            {
                // 마지막 Point 만 제외한다.
                if (i < listAbsolutePoint.Count - 1)
                {
                    x1 = listAbsolutePoint[i].m_dX;
                    y1 = listAbsolutePoint[i].m_dY;
                    x2 = listAbsolutePoint[i + 1].m_dX;
                    y2 = listAbsolutePoint[i + 1].m_dY;
                }
                // 마지막 선은 끝점과 첫점을 있는다
                else
                {
                    x1 = listAbsolutePoint[i].m_dX;
                    y1 = listAbsolutePoint[i].m_dY;
                    x2 = listAbsolutePoint[0].m_dX;
                    y2 = listAbsolutePoint[0].m_dY;
                }

                if (listAbsolutePoint[i].m_emLineKind == EMLineKind.ARC)
                {
                    bDirectionArc = (listAbsolutePoint[i].m_emDirectionArc == EMDirectionArc.BACKWARD ? true : false);
                    femm.drawArc(x1, y1, x2, y2, bDirectionArc, emMoving);
                }
                else
                {
                    femm.drawLine(x1, y1, x2, y2, emMoving);
                }
            }

            return(true);
        }
Example #6
0
        public void setBlockProp(CScriptFEMM femm, double dMeshSize)
        {
            CPoint blockPoint = null;

            blockPoint = this.Face.getBlockPoint();

            if (blockPoint == null)
            {
                CNotice.printTraceID("NBPF");
                return;
            }

            string strMaterialName = this.m_strMaterial;

            femm.setBlockProp(blockPoint, strMaterialName, dMeshSize, "none", 0, MovingPart, 0);
        }
Example #7
0
        private void buttonFitAll_Click(object sender, EventArgs e)
        {
            FormMain formMain = ((FormMain)this.Owner);

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

            // FEMM 을 최상위로 올린다.
            CProgramFEMM.showFEMM();

            // 혹시 FEMM 의 화면이 닫힌 경우 FEMM 의 화면을 복원합니다.
            formMain.reopenFEMM();

            formMain.m_femm.zoomFit();
        }
Example #8
0
        /// <summary>
        /// 다각형의 포인트를 저장한다.
        /// </summary>
        /// <param name="listPoint"></param>
        /// <returns></returns>
        public bool setPolygonPoints(List <CPoint> listPoint)
        {
            if (listPoint.Count < MIN_POINT_COUNT)
            {
                CNotice.printTraceID("YATT");
                return(false);
            }

            m_listRelativePoint.Clear();

            m_emFaceType = EMFaceType.POLYGON;

            foreach (CPoint point in listPoint)
            {
                m_listRelativePoint.Add(point);
            }

            return(true);
        }
Example #9
0
        /// <summary>
        /// Face 의 형상 정보가 없는 경우 호출되는 생성자
        /// </summary>
        public PopupShape(EMFaceType drawType, EMKind emKind)
        {
            InitializeComponent();

            m_strPartName = string.Empty;

            m_bCreatePopupWindow = true;

            textBoxBaseX.Text = "0.0";
            textBoxBaseY.Text = "0.0";

            switch (emKind)
            {
            case EMKind.COIL:
                labelPartName.Text = "Coil Name :";
                this.Text          = "Add Coil";
                break;

            case EMKind.MAGNET:
                labelPartName.Text = "Magnet Name :";
                this.Text          = "Add Magnet";
                break;

            case EMKind.STEEL:
                labelPartName.Text = "Steel Name :";
                this.Text          = "Add Steel";
                break;

            default:
                CNotice.printTraceID("TPTI");
                return;
            }

            comboBoxFaceType.SelectedItem = drawType.ToString();

            /// 코일의 경우는 코일계산 때문에 Rectangle 로 고정을 해야 한다.
            if (emKind == EMKind.COIL)
            {
                comboBoxFaceType.Enabled = false;
            }
        }
Example #10
0
        public void setBlockProp(CScriptFEMM femm, double dMeshSize)
        {
            CPoint blockPoint = null;

            blockPoint = this.Face.getBlockPoint();

            if (blockPoint == null)
            {
                CNotice.printTraceID("NBPF");
                return;
            }

            string strMaterialName = this.m_strMaterial;

            double dMagnetAngle = 0;

            switch (emMagnetDirection)
            {
            case EMMagnetDirection.RIGHT:
                dMagnetAngle = 0;
                break;

            case EMMagnetDirection.UP:
                dMagnetAngle = 90;
                break;

            case EMMagnetDirection.LEFT:
                dMagnetAngle = 180;
                break;

            case EMMagnetDirection.DOWN:
                dMagnetAngle = 270;
                break;

            default:
                break;
            }

            femm.setBlockProp(blockPoint, strMaterialName, dMeshSize, "none", dMagnetAngle, MovingPart, 0);
        }
Example #11
0
        public bool initialShapeDesignValue()
        {
            if (Face == null)
            {
                CNotice.printTraceID("YATT3");
                return(false);
            }

            double minX = 0;
            double maxX = 0;
            double minY = 0;
            double maxY = 0;

            Face.getMinMaxX(ref minX, ref maxX);
            Face.getMinMaxY(ref minY, ref maxY);

            Height        = maxY - minY;
            InnerDiameter = minX * 2.0f;
            OuterDiameter = maxX * 2.0f;

            return(true);
        }
Example #12
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            /// 완벽한 입력인 상태에서만 Draw 및 저장이 가능한다.
            if (isInputDataOK() == false)
            {
                return;
            }

            /// 형상 유효성 확인
            ///
            CFace face = makeFace();

            if (face == null)
            {
                CNotice.noticeWarningID("TWAP1");
                return;
            }

            if (false == face.isShapeOK())
            {
                CNotice.printTraceID("TWAP3");
                return;
            }

            m_strPartName     = textBoxPartName.Text;
            this.DialogResult = DialogResult.OK;

            FormMain formMain = ((FormMain)this.Owner);

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

            // 혹시 FEMM 의 화면이 닫힌 경우 FEMM 의 화면을 복원합니다.
            formMain.reopenFEMM();
        }
Example #13
0
        // 코일에 대한 문자열 라인을 넘겨 받아서 코일 객체를 초기화 한다.
        public bool readObject(List <string> listStringLines)
        {
            CReadFile readFile = new CReadFile();
            string    strTemp;

            string[] arrayString;

            List <string> listInformationLines = new List <string>();
            List <string> listShapeLines       = new List <string>();

            bool bShapeLine = false;

            if (m_kindKey != EMKind.STEEL)
            {
                CNotice.printTraceID("YATT6");
                return(false);
            }

            try
            {
                // Shape 라인과 정보 라인을 분리한다.
                foreach (string strLine in listStringLines)
                {
                    if (readFile.isEndLine(strLine) == "Shape")
                    {
                        bShapeLine = false;
                    }

                    if (bShapeLine == true)
                    {
                        listShapeLines.Add(strLine);
                    }
                    else
                    {
                        if (readFile.isBeginLine(strLine) == "Shape")
                        {
                            bShapeLine = true;
                        }
                        else
                        {
                            listInformationLines.Add(strLine);
                        }
                    }
                }

                // 정보 라인을 처리한다.
                foreach (string strLine in listInformationLines)
                {
                    strTemp = strLine.Trim('\t');

                    arrayString = strTemp.Split('=');

                    if (arrayString.Length != 2)
                    {
                        CNotice.noticeWarningID("TIAP5");
                        return(false);
                    }

                    switch (arrayString[0])
                    {
                    // CNode
                    case "NodeName":
                        NodeName = arrayString[1];
                        break;

                    case "KindKey":
                        m_kindKey = (EMKind)Enum.Parse(typeof(EMKind), arrayString[1]);
                        break;

                    // CParts
                    case "MovingParts":
                        MovingPart = (EMMoving)Enum.Parse(typeof(EMMoving), arrayString[1]);
                        break;

                    // CSteel
                    case "Material":
                        Material = arrayString[1];
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                CNotice.printTrace(ex.Message);
                return(false);
            }

            return(true);
        }
Example #14
0
        public void designCoil()
        {
            if (InnerDiameter <= 0.0f)
            {
                CNotice.noticeWarningID("TIDV");
                return;
            }

            if (OuterDiameter <= 0.0f)
            {
                CNotice.noticeWarningID("TODV");
                return;
            }

            if (OuterDiameter <= InnerDiameter)
            {
                CNotice.noticeWarningID("ODSB");
                return;
            }

            if (Height <= 0.0f)
            {
                CNotice.noticeWarningID("CHVI");
                return;
            }

            if (CopperDiameter <= 0.0f)
            {
                CNotice.noticeWarningID("ETCD");
                return;
            }

            if (HorizontalCoefficient <= 0.0f)
            {
                CNotice.noticeWarningID("ETVF");
                return;
            }

            if (VerticalCoefficient <= 0.0f)
            {
                CNotice.noticeWarningID("ETVF2");
                return;
            }

            if (ResistanceCoefficient <= 0.0f)
            {
                CNotice.noticeWarningID("ETVF1");
                return;
            }

            try
            {
                //*****************************************************************************
                // 수식계산에서 발생하는 예외처리를 하라.
                //*****************************************************************************
                double dCoilAvgDiameter = (InnerDiameter + OuterDiameter) / 2.0f;
                double dWidth           = Math.Abs(OuterDiameter - InnerDiameter) / 2.0f;

                // 동선경을 선택해서 WireDiameter 가 설정이 되지 않는 경우 여기서 자동 계산한다.
                if (WireDiameter == 0.0f)
                {
                    WireDiameter = calculateWireDiameter();
                }

                int iHorizontal_N = (int)((1 / HorizontalCoefficient) * (dWidth / WireDiameter));
                int iVirtical_N   = (int)((1 / VerticalCoefficient) * (Height / WireDiameter));

                // 수평 적층 수가 짝수가 아니면 한층을 뺀다. (짝수 정렬만 가능하다)
                if (iHorizontal_N % 2 != 0)
                {
                    iHorizontal_N -= 1;
                }

                this.Turns           = iHorizontal_N * iVirtical_N;
                this.TurnsOfOneLayer = iVirtical_N;
                this.Layers          = iHorizontal_N;

                double dWireLength = Math.PI * this.Turns * dCoilAvgDiameter;

                // IEC 317, 단위 저항 보간
                double res_a = 0.0, res_b = 0.0, res_c = 0.0;

                // 온도 계수
                double dTemperatureCoefficient = 0.0f;

                if (m_strMaterial == "Copper")
                {
                    // IEC 317, 단위 저항 보간
                    res_a = 0.021771473f;
                    res_b = 0.99730833f;
                    res_c = -1.9999322f;

                    // 온도 계수
                    dTemperatureCoefficient = 0.004041f;
                }
                // 두가지 밖에 없어서 알루미늄의 경우이다.
                else if (m_strMaterial == "Aluminum")
                {
                    // IEC 317, 단위 저항 보간
                    res_a = 0.036438f;
                    res_b = 0.981116f;
                    res_c = -1.995774f;

                    // 온도 계수
                    dTemperatureCoefficient = 0.004308f;
                }
                else
                {
                    CNotice.printTraceID("TIAP1");
                    return;
                }


                double dResistancePerMeter = res_a * (Math.Pow(res_b, CopperDiameter) * Math.Pow(CopperDiameter, res_c));

                dResistancePerMeter = (1 + dTemperatureCoefficient * (this.Temperature - 20.0f)) * dResistancePerMeter;
                this.Resistance     = dResistancePerMeter * dWireLength * ResistanceCoefficient;

                this.Resistance = this.Resistance / 1000.0f;
            }
            catch (Exception ex)
            {
                CNotice.printTrace(ex.Message);
            }
        }
Example #15
0
        // 코일에 대한 문자열 라인을 넘겨 받아서 코일 객체를 초기화 한다.
        public bool readObject(List <string> listStringLines)
        {
            CReadFile readFile = new CReadFile();
            string    strTemp;

            string[] arrayString;

            List <string> listInformationLines = new List <string>();
            List <string> listShapeLines       = new List <string>();

            bool bShapeLine = false;

            if (m_kindKey != EMKind.COIL)
            {
                CNotice.printTraceID("YATT7");
                return(false);
            }

            try
            {
                // Shape 라인과 정보 라인을 분리한다.
                foreach (string strLine in listStringLines)
                {
                    if (readFile.isEndLine(strLine) == "Shape")
                    {
                        bShapeLine = false;
                    }

                    if (bShapeLine == true)
                    {
                        listShapeLines.Add(strLine);
                    }
                    else
                    {
                        if (readFile.isBeginLine(strLine) == "Shape")
                        {
                            bShapeLine = true;
                        }
                        else
                        {
                            listInformationLines.Add(strLine);
                        }
                    }
                }

                // 정보 라인을 처리한다.
                foreach (string strLine in listInformationLines)
                {
                    strTemp = strLine.Trim('\t');

                    arrayString = strTemp.Split('=');


                    switch (arrayString[0])
                    {
                    // CNode
                    case "NodeName":
                        NodeName = arrayString[1];
                        break;

                    case "KindKey":
                        m_kindKey = (EMKind)Enum.Parse(typeof(EMKind), arrayString[1]);
                        break;

                    // CParts
                    case "MovingParts":
                        MovingPart = (EMMoving)Enum.Parse(typeof(EMMoving), arrayString[1]);
                        break;

                    // CCoil
                    case "Material":
                        Material = arrayString[1];
                        break;

                    case "CurrentDirection":
                        CurrentDirection = (EMCurrentDirection)Enum.Parse(typeof(EMCurrentDirection), arrayString[1]);
                        break;

                    case "Turns":
                        Turns = Convert.ToInt16(arrayString[1]);
                        break;

                    case "Resistance":
                        Resistance = Convert.ToDouble(arrayString[1]);
                        break;

                    case "Layers":
                        Layers = Convert.ToInt16(arrayString[1]);
                        break;

                    case "TurnsOfOneLayer":
                        TurnsOfOneLayer = Convert.ToInt16(arrayString[1]);
                        break;

                    case "CoilWireGrade":
                        CoilWireGrade = (EMCoilWireGrade)Enum.Parse(typeof(EMCoilWireGrade), arrayString[1]);
                        break;

                    case "InnerDiameter":
                        InnerDiameter = Convert.ToDouble(arrayString[1]);
                        break;

                    case "OuterDiameter":
                        OuterDiameter = Convert.ToDouble(arrayString[1]);
                        break;

                    case "Height":
                        Height = Convert.ToDouble(arrayString[1]);
                        break;

                    case "CopperDiameter":
                        CopperDiameter = Convert.ToDouble(arrayString[1]);
                        break;

                    case "WireDiameter":
                        WireDiameter = Convert.ToDouble(arrayString[1]);
                        break;

                    case "Temperature":
                        Temperature = Convert.ToDouble(arrayString[1]);
                        break;

                    case "HorizontalCoefficient":
                        HorizontalCoefficient = Convert.ToDouble(arrayString[1]);
                        break;

                    case "VerticalCoefficient":
                        VerticalCoefficient = Convert.ToDouble(arrayString[1]);
                        break;

                    case "ResistanceCoefficient":
                        ResistanceCoefficient = Convert.ToDouble(arrayString[1]);
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                CNotice.printTrace(ex.Message);
                return(false);
            }

            return(true);
        }
Example #16
0
        protected bool readShapeInformation(List <string> listShapeLines)
        {
            string strTemp;

            string[] arrayString;

            try
            {
                // Shape 정보가 있는 경우만 m_face 를 생성하고 읽기 작업을 진행한다.
                if (listShapeLines.Count > 0)
                {
                    m_face = new CFace();
                }
                else
                {
                    return(false);
                }

                CPoint point = null;

                // 형상 라인을 처리한다.
                foreach (string strLine in listShapeLines)
                {
                    strTemp = strLine.Trim('\t');

                    arrayString = strTemp.Split('=');

                    /// 각 줄의 String 배열은 항상 2개이여야 한다.
                    if (arrayString.Length != 2)
                    {
                        CNotice.noticeWarningID("TIAP5");
                        return(false);
                    }

                    if (m_face == null)
                    {
                        CNotice.printTraceID("IIAT");
                        return(false);
                    }

                    switch (arrayString[0])
                    {
                    case "BasePointX":
                        m_face.BasePoint.m_dX = Double.Parse(arrayString[1]);
                        break;

                    case "BasePointY":
                        m_face.BasePoint.m_dY = Double.Parse(arrayString[1]);
                        break;

                    case "FaceType":
                        m_face.FaceType = (EMFaceType)Enum.Parse(typeof(EMFaceType), arrayString[1]);
                        break;

                    case "PointX":
                        // PointX 키워드를 만날때 새로운 CPoint 생성하고,
                        // ArcDriction 키워드를 만날때 생성된 CPoint 를 Face 에 추가한다.
                        // 따라서 저장될때 X, Y, LineKind, ArcDriction 의 순서로 꼭 저장 되어야 한다.
                        point      = new CPoint();
                        point.m_dX = Double.Parse(arrayString[1]);
                        break;

                    case "PointY":
                        if (point != null)
                        {
                            point.m_dY = Double.Parse(arrayString[1]);
                        }
                        else
                        {
                            CNotice.noticeWarningID("YCWX");
                            return(false);
                        }
                        break;

                    case "LineKind":
                        if (point != null)
                        {
                            point.m_emLineKind = (EMLineKind)Enum.Parse(typeof(EMLineKind), arrayString[1]);
                        }
                        else
                        {
                            CNotice.noticeWarningID("TIAP9");
                            return(false);
                        }
                        break;

                    case "ArcDriction":
                        if (point != null)
                        {
                            point.m_emDirectionArc = (EMDirectionArc)Enum.Parse(typeof(EMDirectionArc), arrayString[1]);
                        }
                        else
                        {
                            CNotice.noticeWarningID("TIAP10");
                            return(false);
                        }

                        // ArcDriction 에서 point 을 저장한다.
                        m_face.addPoint(point);
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                CNotice.printTrace(ex.Message);
                return(false);
            }

            return(true);
        }
Example #17
0
        public static bool isDataOK(bool bOpenNoticeDialog = true)
        {
            bool bCheck = false;

            bCheck = m_manageFile.isExistFile(m_strFemmExeFileFullName);
            if (bCheck == false)
            {
                if (bOpenNoticeDialog == true)
                {
                    CNotice.noticeWarningID("TEFD");
                }
                else
                {
                    CNotice.printTraceID("TEFD");
                }

                return(false);
            }

            bCheck = m_manageFile.isExistDirectory(m_strWorkingDirName);

            if (bCheck == false)
            {
                if (bOpenNoticeDialog == true)
                {
                    CNotice.noticeWarningID("TDWD");
                }
                else
                {
                    CNotice.printTraceID("TDWD");
                }

                return(false);
            }

            bCheck = m_manageFile.isExistDirectory(m_strProgramDirName);

            if (bCheck == false)
            {
                if (bOpenNoticeDialog == true)
                {
                    CNotice.noticeWarningID("TIAP2");
                }
                else
                {
                    CNotice.printTraceID("TIAP2");
                }

                return(false);
            }

            if (m_dMeshLevelPercent <= 0.05f)
            {
                if (bOpenNoticeDialog == true)
                {
                    CNotice.noticeWarningID("TMSL");
                }
                else
                {
                    CNotice.printTraceID("TMSL");
                }

                return(false);
            }

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

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

                CScriptFEMM femm = formMain.m_femm;

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

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

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

                            if (((CParts)nodeParts).Face.RelativePointList[i].m_dY != Double.Parse(ListPointControl[i].StrCoordY.Trim()))
                            {
                                retCheck = true;
                            }
                        }
                    }
                }

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

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

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

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

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

                    if (ListPointControl[i].StrCoordY.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());

                CFace face = null;

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

                    if (null != face)
                    {
                        face.drawFace(femm);
                    }
                    else
                    {
                        CNotice.printTraceID("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 < ListPointControl.Count; i++)
                    {
                        retCheck = true;

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

                        if (ListPointControl[i].StrCoordY.Trim().Length == 0)
                        {
                            retCheck = false;
                        }
                        else
                        {
                            dP1_Y = Double.Parse(ListPointControl[i].StrCoordY.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.printTraceID("ATTW");
                                }
                                /// 다각형만 적용된다.
                                /// 만약 사각형의 경우 i = 1 까지 모두 채워지면 모두 입력된 상태로 if 문의 위에처 처리되기 때문이다.
                                bArc          = ListPointControl[i].IsArc;
                                bArcDirection = ListPointControl[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.StrCoordY != "")
                    {
                        CPoint selectedPoint = new CPoint();

                        selectedPoint.m_dX = Double.Parse(pointControl.StrCoordX) + dBase_X;
                        selectedPoint.m_dY = Double.Parse(pointControl.StrCoordY) + dBase_Y;

                        femm.clearSelected();

                        femm.selectPoint(selectedPoint);
                    }
                }
            }
            catch (Exception ex)
            {
                CNotice.printTrace(ex.Message);
            }
        }
Example #19
0
        public void buttonDraw_Click(object sender, EventArgs e)
        {
            try
            {
                /// 완벽한 입력인 상태에서만 Draw 가 가능한다.
                bool retOK = isInputDataOK();

                if (retOK == false)
                {
                    return;
                }

                /// [문제]
                ///  - Form 에서는 Parent를 사용할 수 없어 Owner 속성을 사용하지만
                ///    종종 Owner 가 null 로 넘어오는 문제가 발생한다.
                /// [해결]
                ///  - PopupShape 창을 생성하기 전에 Owner 속성을 FormMain 으로 초기화 해 두어야
                ///    확실하게 FormMain 을 얻을 수 있다.
                FormMain formMain = ((FormMain)this.Owner);

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

                /// 형상 유효성 확인
                ///
                CFace face = makeFace();

                if (face == null)
                {
                    CNotice.noticeWarningID("TWAP1");
                    return;
                }

                if (false == face.isShapeOK())
                {
                    CNotice.printTraceID("TWAP3");
                    return;
                }

                CScriptFEMM femm = formMain.m_femm;

                femm.deleteAll();

                /// 1. 작업 중인 Face 를 제외하고 형상 그리기
                foreach (CNode node in formMain.m_design.NodeList)
                {
                    if (node.GetType().BaseType.Name == "CParts")
                    {
                        if (node.NodeName != m_strPartName)
                        {
                            ((CParts)node).Face.drawFace(femm);
                        }
                    }
                }

                // FEMM 을 최상위로 올린다.
                CProgramFEMM.showFEMM();

                // 혹시 FEMM 의 화면이 닫힌 경우 FEMM 의 화면을 복원합니다.
                formMain.reopenFEMM();

                /// 2. 작업중인 Face 형상 그리기
                face.drawFace(femm);
            }
            catch (Exception ex)
            {
                CNotice.printTrace(ex.Message);
            }
        }
Example #20
0
        // Base Point 와 상대좌표로 좌표값이 저장되는 Face 가 생성된다.
        public CFace makeFace()
        {
            try
            {
                CFace face = new CFace();

                face.BasePoint.m_dX = Double.Parse(textBoxBaseX.Text);
                face.BasePoint.m_dY = Double.Parse(textBoxBaseY.Text);

                if (FaceType == EMFaceType.RECTANGLE)
                {
                    if (ListPointControl.Count != 2)
                    {
                        CNotice.printTraceID("TATP1");
                        return(null);
                    }

                    double x1, y1, x2, y2;

                    x1 = Double.Parse(ListPointControl[0].StrCoordX);
                    y1 = Double.Parse(ListPointControl[0].StrCoordY);
                    x2 = Double.Parse(ListPointControl[1].StrCoordX);
                    y2 = Double.Parse(ListPointControl[1].StrCoordY);

                    face.setRectanglePoints(x1, y1, x2, y2);
                }
                else
                {
                    if (ListPointControl.Count < 4)
                    {
                        CNotice.printTraceID("TANM");
                        return(null);
                    }

                    List <CPoint> listPoint = new List <CPoint>();

                    foreach (CPointControl pointControl in ListPointControl)
                    {
                        // 매번 신규로 생성을 해야 한다.
                        CPoint point = new CPoint();

                        point.m_dX = Double.Parse(pointControl.StrCoordX);
                        point.m_dY = Double.Parse(pointControl.StrCoordY);

                        if (pointControl.IsArc == true)
                        {
                            point.m_emLineKind = EMLineKind.ARC;
                        }
                        else
                        {
                            point.m_emLineKind = EMLineKind.STRAIGHT;
                        }

                        if (pointControl.IsArcDirection == true)
                        {
                            point.m_emDirectionArc = EMDirectionArc.BACKWARD;
                        }
                        else
                        {
                            point.m_emDirectionArc = EMDirectionArc.FORWARD;
                        }

                        listPoint.Add(point);
                    }

                    face.setPolygonPoints(listPoint);
                }

                return(face);
            }
            catch (Exception ex)
            {
                CNotice.printTrace(ex.Message);
                return(null);
            }
        }
Example #21
0
        private bool isInputDataOK()
        {
            try
            {
                // 빈칸 확인으로 null 비교를 사용하지 말라. (.Length == 0 나 "" 를 사용하라)
                if (textBoxName.Text.Length == 0)
                {
                    CNotice.noticeWarningID("PEAN");
                    return(false);
                }

                /// Design 생성이다.
                if (m_strNewKind == "Design")
                {
                    // 디자인을 무조건 프로그램 작업디렉토리에 생성하는 것으로 한다.
                    // 따라서 디자인을 생성할 때의 적용버튼 임으로 작업 디렉토리는 프로그램 작업 디렉토리를 사용하고 있다.
                    List <string> listDirectories = m_manageFile.getDirectoryList(CSettingData.m_strWorkingDirName);

                    // 소문자로 비교하기 위해서 임시로 사용한다.
                    string strOldTempName, strNewTempName;

                    foreach (string directoryName in listDirectories)
                    {
                        // 디렉토리 경로에 GetFileName 을 사용하면 가장 마지막 디렉토리가 넘어온다.
                        strOldTempName = Path.GetFileName(directoryName).ToLower();
                        strNewTempName = m_strName.ToLower();

                        if (strOldTempName == strNewTempName)
                        {
                            // 기존 디자인이 이미 존재할 때 삭제하고 새롭게 시작할지를 물어 온다
                            DialogResult ret = CNotice.noticeWarningOKCancelID("TSDA", "W");

                            if (ret == DialogResult.OK)
                            {
                                m_manageFile.deleteDirectory(directoryName);
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                    }
                }
                /// Experiment 들의 생성이다.
                else
                {
                    /// 호출할 때 Owner 를 FormMain 으로 초기화 해야 확실하게 얻을 수 있다.
                    FormMain formMain = ((FormMain)this.Owner);

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

                    if (true == formMain.m_design.isExistNode(textBoxName.Text))
                    {
                        CNotice.noticeWarningID("IIAE");
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                CNotice.printTrace(ex.Message);
                return(false);
            }

            return(true);
        }
Example #22
0
        /// <summary>
        /// Face 의 형상 정보가 있는 경우 호출되는 생성자
        /// </summary>
        public PopupShape(string partName, CFace face, EMKind emKind)
        {
            InitializeComponent();

            m_strPartName = partName;

            m_bCreatePopupWindow = false;

            try
            {
                switch (emKind)
                {
                case EMKind.COIL:
                    labelPartName.Text = "Coil Name :";
                    this.Text          = "Change Coil";
                    break;

                case EMKind.MAGNET:
                    labelPartName.Text = "Magnet Name :";
                    this.Text          = "Change Magnet";
                    break;

                case EMKind.STEEL:
                    labelPartName.Text = "Steel Name :";
                    this.Text          = "Change Steel";
                    break;

                default:
                    CNotice.printTraceID("TPTI");
                    return;
                }

                if (face == null)
                {
                    CNotice.printTraceID("CTPS1");
                    return;
                }

                textBoxBaseX.Text = face.BasePoint.m_dX.ToString();
                textBoxBaseY.Text = face.BasePoint.m_dY.ToString();

                if (face.getPointCount() < MIN_POLYGON_CONTROL_COUNT)
                {
                    CNotice.printTraceID("CTPS");
                    return;
                }

                /// 파트이름을 표시만하고 수정을 하지 못하게 한다.
                textBoxPartName.Text    = partName;
                textBoxPartName.Enabled = false;

                if (face.FaceType == EMFaceType.RECTANGLE)
                {
                    // 설정과 동시에 이벤트가 호출되고
                    // 이벤트함수에서 FaceType 가 지정되면서 Popup 창의 형태와 UserControl 이 초기화 된다.
                    comboBoxFaceType.SelectedItem = EMFaceType.RECTANGLE.ToString();

                    this.ListPointControl[0].StrCoordX = face.RelativePointList[0].m_dX.ToString();
                    this.ListPointControl[0].StrCoordY = face.RelativePointList[0].m_dY.ToString();

                    this.ListPointControl[1].StrCoordX = face.RelativePointList[2].m_dX.ToString();
                    this.ListPointControl[1].StrCoordY = face.RelativePointList[2].m_dY.ToString();
                }
                else if (face.FaceType == EMFaceType.POLYGON)
                {
                    // 설정과 동시에 이벤트가 호출되고
                    // 이벤트함수에서 FaceType 가 지정되면서 Popup 창의 형태와 UserControl 이 초기화 된다.
                    comboBoxFaceType.SelectedItem = EMFaceType.POLYGON.ToString();

                    for (int i = 0; i < face.getPointCount(); i++)
                    {
                        // 기본 생성 Control 수 보다 작을 때는 있는 Control 에 데이터를 담고
                        // 클 때는 Control 를 생성하면서 데이터를 담은다.
                        if (i >= MIN_POLYGON_CONTROL_COUNT)
                        {
                            this.addPointControl(new CPointControl(), true, this.panelPointControl);
                        }

                        this.ListPointControl[i].StrCoordX = face.RelativePointList[i].m_dX.ToString();
                        this.ListPointControl[i].StrCoordY = face.RelativePointList[i].m_dY.ToString();

                        if (face.RelativePointList[i].m_emLineKind == EMLineKind.ARC)
                        {
                            this.ListPointControl[i].IsArc = true;
                        }
                        else
                        {
                            this.ListPointControl[i].IsArc = false;
                        }

                        if (face.RelativePointList[i].m_emDirectionArc == EMDirectionArc.BACKWARD)
                        {
                            this.ListPointControl[i].IsArcDirection = true;
                        }
                        else
                        {
                            this.ListPointControl[i].IsArcDirection = false;
                        }
                    }
                }
                else
                {
                    CNotice.printTraceID("UAWF");
                    return;
                }

                /// 코일의 경우는 코일계산 때문에 Rectangle 로 고정을 해야 한다.
                if (emKind == EMKind.COIL)
                {
                    comboBoxFaceType.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                CNotice.printTrace(ex.Message);
            }
        }
Example #23
0
        public bool attachDefault(string strExperimentFullName, CPoint pointBoundaryBlock)
        {
            CReadFile   readFile   = new CReadFile();
            CManageFile manageFile = new CManageFile();

            List <string> listString = new List <string>();
            string        strLine    = string.Empty;

            char[]   separators = { ' ', '\t' };
            string[] strArray;

            string strFileName         = Path.GetFileNameWithoutExtension(strExperimentFullName);
            string strTempFileFullName = Path.Combine(Path.GetDirectoryName(strExperimentFullName), strFileName + "_temp.fem");

            if (manageFile.isExistFile(strExperimentFullName) == false)
            {
                CNotice.printTraceID("NFFF");
                return(false);
            }
            else
            {
                File.Move(strExperimentFullName, strTempFileFullName);
            }

            StreamWriter writeFile    = new StreamWriter(strExperimentFullName);
            int          iNumBlock    = 0;
            int          nCountBlock  = 0;
            bool         bBlockLabels = false;

            try
            {
                readFile.getAllLines(strTempFileFullName, ref listString);

                for (int i = 0; i < listString.Count; i++)
                {
                    strLine = listString[i];

                    strArray = strLine.Split(separators, StringSplitOptions.None);

                    if (strArray[0] == "[NumBlockLabels]")
                    {
                        iNumBlock    = Int32.Parse(strArray[2]);
                        nCountBlock  = 0;
                        bBlockLabels = true;

                        writeFile.WriteLine(strLine);

                        /// 구분 Label 행은 건너 뛴다.
                        continue;
                    }

                    if (bBlockLabels == true)
                    {
                        if (pointBoundaryBlock.m_dX == Double.Parse(strArray[0]) && pointBoundaryBlock.m_dY == Double.Parse(strArray[1]))
                        {
                            if (strArray.Length != 9)
                            {
                                CNotice.printTraceID("TWAP2");
                                return(false);
                            }

                            /// dettach block setting
                            strArray[8] = "2";
                            strLine     = string.Empty;

                            foreach (string str in strArray)
                            {
                                strLine += str + '\t';
                            }
                        }

                        nCountBlock++;

                        if (nCountBlock >= iNumBlock)
                        {
                            bBlockLabels = false;
                        }
                    }

                    writeFile.WriteLine(strLine);
                }

                File.Delete(strTempFileFullName);
            }
            catch (Exception ex)
            {
                CNotice.printTrace(ex.Message);
                writeFile.Close();
                return(false);
            }

            writeFile.Close();
            return(true);
        }
Example #24
0
        private bool isInputDataOK()
        {
            /// 1. 입력값 확인
            ///
            if (textBoxPartName.Text.Length == 0)
            {
                CNotice.noticeWarningID("PEAP");
                return(false);
            }

            for (int i = 0; i < ListPointControl.Count; i++)
            {
                if (ListPointControl[i].StrCoordX.Trim().Length == 0)
                {
                    CNotice.noticeWarningID("PETC");
                    return(false);
                }

                if (ListPointControl[i].StrCoordY.Trim().Length == 0)
                {
                    CNotice.noticeWarningID("PETC");
                    return(false);
                }
            }

            string strX1, strY1, strX2, strY2;

            /// 동일한 좌표값이 점이 중복으로 있는 경우
            for (int i = 0; i < ListPointControl.Count - 1; i++)
            {
                for (int j = i + 1; j < ListPointControl.Count; j++)
                {
                    strX1 = ListPointControl[i].StrCoordX.Trim();
                    strY1 = ListPointControl[i].StrCoordY.Trim();
                    strX2 = ListPointControl[j].StrCoordX.Trim();
                    strY2 = ListPointControl[j].StrCoordY.Trim();

                    if (strX1 == strX2 && strY1 == strY2)
                    {
                        CNotice.noticeWarningID("TATP");
                        return(false);
                    }
                }
            }

            /// 파트 초기 생성때는 m_strPartName = string.Empty 로 PopupShape 객체를 생성하고,
            /// 파트 수정 때는 m_strPartName 에 이름을 넣어서  PopupShape 객체를 생성하기 때문에 파트의 수정인지를 m_strPartName 로 파악한다.
            if (m_strPartName.Length == 0)
            {
                /// [문제]
                ///  - Form 에서는 Parent를 사용할 수 없어 Owner 속성을 사용하지만
                ///    종종 Owner 가 null 로 넘어오는 문제가 발생한다.
                /// [해결]
                ///  - PopupShape 창을 생성하기 전에 Owner 속성을 FormMain 으로 초기화 해 두어야
                ///    확실하게 FormMain 을 얻을 수 있다.
                FormMain formMain = ((FormMain)this.Owner);

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

                if (true == formMain.m_design.isExistNode(textBoxPartName.Text))
                {
                    CNotice.noticeWarningID("TPAE");
                    return(false);
                }
            }

            return(true);
        }