Esempio n. 1
0
        /// <summary>
        /// Расчет обработки
        /// </summary>
        private void Calculate()
        {
            ObjectForm.SetProgressVisible(true);
            DeleteProcessing();
            SettingForm.RefreshSettings();
            ObjectForm.RefreshObjects();

            ProcessingActions = ActionGenerator.Generate(ProcessObjects, SectionCurves);

            ProcessingForm.ShowData(ProcessingActions);
            var machineProgram = ProgramGenerator.Generate(ProcessingActions);

            ProgramForm.SetProgram(machineProgram);
            ObjectForm.SetProgressVisible(false);
        }
Esempio n. 2
0
 /// <summary>
 /// Удалить обработку
 /// </summary>
 private void DeleteProcessing()
 {
     if (ActionGenerator.IsCalculation)
     {
         ActionGenerator.Abort();
         AutocadUtils.ShowError("Расчет обработки прерван");
         return;
     }
     if (ProcessingActions == null)
     {
         return;
     }
     AutocadUtils.DeleteCurves(ProcessingActions.ConvertAll(p => p.ObjectId));
     AutocadUtils.DeleteCurves(ProcessingActions.ConvertAll(p => p.DirectObjectId));
     AutocadUtils.DeleteCurves(ProcessingActions.ConvertAll(p => p.ToolObjectId));
     ProcessingActions.Clear();
     ProcessingForm.ShowData(ProcessingActions);
 }
Esempio n. 3
0
        public void Initialize()
        {
            AutocadUtils.WriteMessage("Инициализация плагина ProcessingProgram. Версия с режимом обработки."); // + DateTime.Today.ToShortDateString()); TODO Assemlly.DateTime()

            ObjectForm.DeleteAll        += (sender, args) => DeleteAll();
            ObjectForm.DeleteProcessing += (sender, args) => DeleteProcessing();
            ObjectForm.Calculate        += (sender, args) => Calculate();
            ObjectForm.Quit             += (sender, args) => AutocadUtils.Close();
            ObjectForm.AddObjects       += (sender, args) => AddObjects();
            ObjectForm.ShowTools        += (sender, args) => AutocadUtils.ShowModalDialog(ToolStoreForm);
            ObjectForm.CurrentChanged   += (sender, args) => AutocadUtils.SelectObject(args.Data.Curve.ObjectId);
            ObjectForm.ChangeOutside    += (sender, args) =>
            {
                CalcUtils.ChangeOutside(args.Data.Curve.ObjectId);
                Calculate();
            };
            ObjectForm.ReverseProcess += (sender, args) =>
            {
                args.Data.Direction *= -1;
                Calculate();
            };
            ObjectForm.DeleteObject += (sender, args) =>
            {
                ProcessObjects.Remove(args.Data);
                if (ProcessObjects.All(p => p.Curve != args.Data.Curve))
                {
                    ProcessCurves.Remove(args.Data.Curve);
                }
                Calculate();
            };
            SettingForm.AddSectionObjects += (sender, args) =>
            {
                AddSectionObjects();
                SettingForm.SetSectionDesc(SectionCurves.Any() ? String.Format("Сечение установлено. {0} элемента", SectionCurves.Count) : "");
            };

            AutocadUtils.AddPaletteSet("Объекты", ObjectForm);

            ProcessingForm.CurrentChanged   += (sender, args) => AutocadUtils.SelectObjects(args.Data.ObjectId, args.Data.ToolObjectId);
            ProcessingForm.DeleteProcessing += (sender, args) => DeleteProcessing();
            ProcessingForm.Calculate        += (sender, args) => Calculate();
            AutocadUtils.AddPaletteSet("Обработка", ProcessingForm);

            AutocadUtils.AddPaletteSet("Программа", ProgramForm);
            AutocadUtils.AddPaletteSet("Настройки", SettingForm);

            AutocadUtils.Selected += (sender, args) => ProcessingForm.SelectObjects(args.Data);
            AutocadUtils.Focused  += (sender, args) => ProcessingForm.SetFocus(args.Data);
            AutocadUtils.Focused  += (sender, args) => ObjectForm.SetFocus(args.Data);

            CalcUtils.Init(ProcessObjects, ProcessCurves);
            ProcessObjectFactory.Init(ProcessObjects, ProcessCurves);

            var machine = new Machine();

            machine.ChangeActionsCount += (sender, args) => ObjectForm.ShowProgress(String.Format("Генерация обработки... {0} строк", args.Data));
            ActionGenerator.SetMachine(machine);

            //AutocadUtils.CreateTest();
            //RunTest();
        }