public ReturnCode AddModel(ShellBaseModel model) { lock (lockObject) { try { objectsToDraw.Add(model); return(ReturnCode.Success); } catch { return(ReturnCode.Fail); } } }
//создание оболочек для отображения bool CreateShells() { try { moduleGraphicLibrary.DeleteAllModels(); float radius_x = 0; float radius_y = 0; float size_x = 0; float size_y = 0; float height = 0; float conus_angle = 0; float start_x = 0; float d = 0; _ProgFun = textBoxProgFun.Text; float nhx = 0; //количество ребер по оси X float hwx = 0; //толщина ребра по оси X float sizeRebroX = 0; //размер ребра по оси X в процентах float nhy = 0; //количество ребер по оси Y float hwy = 0; //толщина ребра по оси Y float sizeRebroY = 0; //размер ребра по оси Y в процентах if (!GetValue(textBox14.Text, ref scaleCoef)) { MessageBox.Show("Ошибка в поле <коэф-т визуализации>"); return(false); } if (!GetValue(textBoxEdgesXCount.Text, ref nhx)) { MessageBox.Show("Ошибка в поле <количество рёбер по оси X>"); return(false); } if (!GetValue(textBoxEdgesYCount.Text, ref nhy)) { MessageBox.Show("Ошибка в поле <количество рёбер по оси Y>"); return(false); } if (!GetValue(textBoxEdgesXSize.Text, ref sizeRebroX)) { MessageBox.Show("Ошибка в поле <размер ребра по оси X>"); return(false); } sizeRebroX /= 100; if (!GetValue(textBoxEdgesYSize.Text, ref sizeRebroY)) { MessageBox.Show("Ошибка в поле <размер ребра по оси Y>"); return(false); } sizeRebroY /= 100; if (!GetValue(textBoxEdgesXh.Text, ref hwx)) { MessageBox.Show("Ошибка в поле <толщина ребра по оси X>"); return(false); } if (!GetValue(textBoxEdgesYh.Text, ref hwy)) { MessageBox.Show("Ошибка в поле <толщина ребра по оси Y>"); return(false); } if (tabControl1.SelectedIndex == 0) { shell = new ShellRectangularModelWithEdgesNew(); if (!GetValue(textBoxRxPlane.Text, ref radius_x)) { MessageBox.Show("Ошибка в поле <радиус по оси X>"); return(false); } if (!GetValue(textBoxRyPlane.Text, ref radius_y)) { MessageBox.Show("Ошибка в поле <радиус по оси Y>"); return(false); } if (!GetValue(textBoxSizeXPlane.Text, ref size_x)) { MessageBox.Show("Ошибка в поле <размер по оси X>"); return(false); } if (!GetValue(textBoxSizeYPlane.Text, ref size_y)) { MessageBox.Show("Ошибка в поле <размер по оси Y>"); return(false); } if (!GetValue(textBoxSizeHPlane.Text, ref height)) { MessageBox.Show("Ошибка в поле <толщина оболочки>"); return(false); } if (!((ShellRectangularModelWithEdgesNew)(shell)).CreateModel(moduleGraphicLibrary.device, radius_x, radius_y, size_x, size_y, height, (int)nhy, (int)nhx, hwy, hwx, sizeRebroY * size_x, sizeRebroX * size_y, Function, 0, (float)Convert.ToDouble(textBox14.Text), _ProgFun)) { MessageBox.Show("Ошибка при создании прямоугольной оболочки"); return(false); } } if (tabControl1.SelectedIndex == 1) { shell = new ShellCylindarModelWithEdgesNew(); if (!GetValue(textBoxRyCylindric.Text, ref radius_y)) { MessageBox.Show("Ошибка в поле <радиус по оси Y>"); return(false); } if (!GetValue(textBoxRxCylindric.Text, ref size_x)) { MessageBox.Show("Ошибка в поле <размер по оси X>"); return(false); } if (!GetValue(textBoxSizeYCylindric.Text, ref size_y)) { MessageBox.Show("Ошибка в поле <угловой размер по оси Y>"); return(false); } if (!GetValue(textBoxSizeHCylindric.Text, ref height)) { MessageBox.Show("Ошибка в поле <толщина оболочки>"); return(false); } if (!((ShellCylindarModelWithEdgesNew)(shell)).CreateModel(moduleGraphicLibrary.device, radius_y, size_x, size_y, height, (int)nhy, (int)nhx, hwy, hwx, sizeRebroY * size_x, sizeRebroX * size_y, Function, 0, (float)Convert.ToDouble(textBox14.Text), _ProgFun)) { MessageBox.Show("Ошибка при создании цилиндрической оболочки"); return(false); } } if (tabControl1.SelectedIndex == 2) { shell = new ShellConusModelWithEdgesNew(); if (!GetValue(textBoxAngleCone.Text, ref conus_angle)) { MessageBox.Show("Ошибка в поле <угол конусности>"); return(false); } if (!GetValue(textBoxStartXCone.Text, ref start_x)) { MessageBox.Show("Ошибка в поле <начальная координата по оси X>"); return(false); } if (!GetValue(textBoxSizeXCone.Text, ref size_x)) { MessageBox.Show("Ошибка в поле <размер по оси X>"); return(false); } if (!GetValue(textBoxSizeYCone.Text, ref size_y)) { MessageBox.Show("Ошибка в поле <угловой размер по оси Y>"); return(false); } if (!GetValue(textBoxSizeHCone.Text, ref height)) { MessageBox.Show("Ошибка в поле <толщина оболочки>"); return(false); } if (!((ShellConusModelWithEdgesNew)(shell)).CreateModel(moduleGraphicLibrary.device, conus_angle, start_x, size_x, size_y, height, (int)nhy, (int)nhx, hwy, hwx, sizeRebroY * size_x, sizeRebroX * size_y, Function, 0, (float)Convert.ToDouble(textBox14.Text), _ProgFun)) { MessageBox.Show("Ошибка при создании конической оболочки"); return(false); } } if (tabControl1.SelectedIndex == 3) { shell = new ShellSphereModellWithEdgesNew(); if (!GetValue(textBoxRadiusSpheric.Text, ref radius_x)) { MessageBox.Show("Ошибка в поле <радиус>"); return(false); } if (!GetValue(textBoxStartAngleSpheric.Text, ref start_x)) { MessageBox.Show("Ошибка в поле <угловая начальная координата по оси X>"); return(false); } if (!GetValue(textBoxSizeXSpheric.Text, ref size_x)) { MessageBox.Show("Ошибка в поле <угловой размер по оси X>"); return(false); } if (!GetValue(textBoxSizeYSpheric.Text, ref size_y)) { MessageBox.Show("Ошибка в поле <угловой размер по оси Y>"); return(false); } if (!GetValue(textBoxSizeHSpheric.Text, ref height)) { MessageBox.Show("Ошибка в поле <толщина оболочки>"); return(false); } if (!((ShellSphereModellWithEdgesNew)(shell)).CreateModel(moduleGraphicLibrary.device, radius_x, start_x, size_x, size_y, height, (int)nhy, (int)nhx, hwy, hwx, sizeRebroY * size_x, sizeRebroX * size_y, Function, 0, (float)Convert.ToDouble(textBox14.Text), _ProgFun)) { MessageBox.Show("Ошибка при создании сферической оболочки"); return(false); } } if (tabControl1.SelectedIndex == 4) { shell = new ShellTorusModellWithEdgesNew(); if (!GetValue(textBoxRadiusTorus.Text, ref radius_x)) { MessageBox.Show("Ошибка в поле <радиус>"); return(false); } if (!GetValue(textBoxStartAngleTorus.Text, ref start_x)) { MessageBox.Show("Ошибка в поле <угловая начальная координата по оси X>"); return(false); } if (!GetValue(textBoxSizeXTorus.Text, ref size_x)) { MessageBox.Show("Ошибка в поле <угловой размер по оси X>"); return(false); } if (!GetValue(textBoxSizeYTorus.Text, ref size_y)) { MessageBox.Show("Ошибка в поле <угловой размер по оси Y>"); return(false); } if (!GetValue(textBoxSizeHTorus.Text, ref height)) { MessageBox.Show("Ошибка в поле <толщина оболочки>"); return(false); } if (!GetValue(textBoxOffsetTorus.Text, ref d)) { MessageBox.Show("Ошибка в поле <смещение от оси вращения>"); return(false); } if (!((ShellTorusModellWithEdgesNew)(shell)).CreateModel(moduleGraphicLibrary.device, d, radius_x, start_x, size_x, size_y, height, (int)nhy, (int)nhx, hwy, hwx, sizeRebroY * size_x, sizeRebroX * size_y, Function, 0, (float)Convert.ToDouble(textBox14.Text), _ProgFun)) { MessageBox.Show("Ошибка при создании торообразной оболочки"); return(false); } } moduleGraphicLibrary.AddModel(shell); if (checkBox2.Checked) { shell.SetAutoAnimation(true); } shell.SetAnimationWeight((float)trackBar2.Value / trackBar2.Maximum); } catch { return(false); } return(true); }