示例#1
0
        public void DeleteBulkhead(int index)
        {
            Bulkheads.RemoveAt(index);
            BaseHull.Instance().Bulkheads.RemoveAt(index);

            BaseHull.Instance().Notify("HullData");
        }
示例#2
0
        public void createClick(object sender, RoutedEventArgs e)
        {
            //Point loc = GetMousePosition();

            CreateHullDialog createHullDialog = new CreateHullDialog();

            //createHullDialog.Top = loc.Y;
            //createHullDialog.Left = loc.X;
            if (createHullDialog.ShowDialog() == true)
            {
                CreateHullData data = (CreateHullData)this.FindResource("CreateHullData");
                if (data != null)
                {
                    Hull tempHull = new Hull(data);
                    BaseHull.Instance().Bulkheads = tempHull.Bulkheads;

                    undoLog.Clear();
                    undoLog.Add(BaseHull.Instance());

                    redoLog.Clear();

                    UpdateViews();
                }
            }
        }
        private void OK_Click(object sender, RoutedEventArgs e)
        {
            UI_Params values = (UI_Params)this.FindResource("Curr_UI_Params");

            values.ChangeChinesExpanded = false;
            BaseHull.Instance().ChangeChines(values.NumChines);
        }
示例#4
0
        public void saveClick(object sender, RoutedEventArgs e)
        {
            if (BaseHull.Instance() == null)
            {
                return;
            }

            SaveFileDialog saveDlg = new SaveFileDialog();

            saveDlg.Filter           = "AVS Hull files (*.avsh)|*.avsh|All files (*.*)|*.*";
            saveDlg.FilterIndex      = 0;
            saveDlg.RestoreDirectory = true;

            Nullable <bool> result = saveDlg.ShowDialog();

            if (result == true)
            {
                BaseHull.Instance().Timestamp = DateTime.Now;

                System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(Hull));

                using (FileStream output = new FileStream(saveDlg.FileName, FileMode.Create))
                {
                    writer.Serialize(output, BaseHull.Instance());
                }
                undoLog.Snapshot();
                redoLog.Clear();
            }
        }
示例#5
0
        private void ChangeChinesClick(object sender, RoutedEventArgs e)
        {
            UI_Params values = (UI_Params)this.FindResource("Curr_UI_Params");

            values.NumChines            = BaseHull.Instance().NumChines / 2;
            values.ChangeChinesExpanded = !values.LayoutSetupExpanded;
        }
示例#6
0
        public void ResizeClick(object sender, RoutedEventArgs e)
        {
            if (BaseHull.Instance().Bulkheads.Count == 0)
            {
                MessageBox.Show("Can't resize a non-existant hull.");
                return;
            }

            HullView hull = new HullView();

            Size3D originalSize = hull.GetSize();

            ResizeWindow resize = new ResizeWindow();

            resize.ShowDialog();

            if (resize.OK)
            {
                ResizeWindowData resizeData = (ResizeWindowData)resize.FindResource("ResizeData");
                double           scale_x    = 1.0;
                double           scale_y    = 1.0;
                double           scale_z    = 1.0;

                if (resizeData != null)
                {
                    scale_x = resizeData.Width / originalSize.X;
                    scale_y = resizeData.Height / originalSize.Y;
                    scale_z = resizeData.Length / originalSize.Z;

                    BaseHull.Instance().Scale(scale_x, scale_y, scale_z);
                    UpdateViews();
                }
            }
        }
示例#7
0
 public void Undo_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     if (undoLog.Count > 1)
     {
         redoLog.Add(undoLog.Pop());
         BaseHull.Instance().Bulkheads = undoLog.Peek().Bulkheads;
         UpdateViews();
     }
 }
示例#8
0
        public void Redo_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (redoLog.Count > 0)
            {
                BaseHull.Instance().Bulkheads = redoLog.Pop().Bulkheads;
                undoLog.Add(BaseHull.Instance());
                undoLog.StartSnapshot();

                UpdateViews();
            }
        }
示例#9
0
 public void UpdateBulkheadPoint(int bulkhead, int chine, double x, double y, double z)
 {
     if (chine < 0 && BaseHull.Instance().Bulkheads[bulkhead].Type != Bulkhead.BulkheadType.BOW)
     {
         // assume we are shifting the bulkhead in the Z direction
         BaseHull.Instance().Bulkheads[bulkhead].MoveZ(z);
     }
     else
     {
         BaseHull.Instance().Bulkheads[bulkhead].UpdateBulkheadPoint(chine, x, y, z);
     }
 }
示例#10
0
        public HullView()
        {
            Bulkheads = new List <Bulkhead>();

            foreach (Bulkhead bulkhead in BaseHull.Instance().Bulkheads)
            {
                Bulkheads.Add((Bulkhead)bulkhead.Clone());
            }

            m_SelectedBulkhead = NOT_SELECTED;
            Chines             = GenerateChines(POINTS_PER_CHINE);
        }
示例#11
0
        public DesignControl()
        {
            InitializeComponent();

            BaseHull.Instance().PropertyChanged += hull_PropertyChanged;

            undoLog = (HullLog)this.FindResource("UndoLog");
            undoLog.Clear();
            undoLog.Add(BaseHull.Instance());

            redoLog = (HullLog)this.FindResource("RedoLog");
            redoLog.Clear();
        }
示例#12
0
 void hull_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     Debug.WriteLine("DesignControl.PropertyChanged: " + e.PropertyName);
     if (e.PropertyName == "HullData" || e.PropertyName == "Bulkhead" || e.PropertyName == "HullScale" || e.PropertyName == "Bulkhead.Handle")
     {
         if (e.PropertyName != "Bulkhead.Handle")
         {
             undoLog.StartSnapshot();
         }
         undoLog.Add(BaseHull.Instance());
         redoLog.Clear();
         UpdateViews();
     }
 }
        private void SetupPanels()
        {
            m_panels = new List <Panel>();
            Hull myHull = BaseHull.Instance();

            // Initialize the panels
            if (myHull != null && myHull.Bulkheads.Count != 0)
            {
                HullView eHull = new HullView();
                List <Point3DCollection> chines = eHull.GenerateChines();

                for (int index = 0; index < chines.Count / 2; index++)
                {
                    Panel p = new Panel(chines[index], chines[index + 1]);
                    p.name = "Panel " + (index + 1);
                    m_panels.Add(p);
                }

                int bulkheadIndex = 1;

                foreach (Bulkhead bulk in eHull.Bulkheads)
                {
                    if (bulk.Type != Bulkhead.BulkheadType.BOW)
                    {
                        Panel p = new Panel(bulk);
                        p.name = "Bulkhead " + bulkheadIndex;
                        bulkheadIndex++;
                        m_panels.Add(p);
                    }
                }
            }

            foreach (Panel panel in m_panels)
            {
                MenuItem item = new MenuItem();
                item.Header = panel.name;
                item.Click += AddPanelClick;
                PanelContextMenu.Items.Add(item);
            }
        }
示例#14
0
        public void openClick(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openDlg = new OpenFileDialog();

            openDlg.Filter           = "AVS Hull files (*.avsh)|*.avsh|All files (*.*)|*.*";
            openDlg.FilterIndex      = 0;
            openDlg.RestoreDirectory = true;

            Nullable <bool> result = openDlg.ShowDialog();

            if (result == true)
            {
                Hull tempHull;

                System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(Hull));

                using (Stream reader = new FileStream(openDlg.FileName, FileMode.Open))
                {
                    // Call the Deserialize method to restore the object's state.
                    tempHull = (Hull)serializer.Deserialize(reader);

                    // Make sure we have a timestamp
                    if (tempHull.Timestamp == DateTime.MinValue)
                    {
                        tempHull.Timestamp = DateTime.Now;
                    }

                    BaseHull.Instance().Bulkheads = tempHull.Bulkheads;

                    undoLog.Clear();
                    undoLog.Add(BaseHull.Instance());

                    redoLog.Clear();

                    PerspectiveView.Perspective = HullControl.PerspectiveType.PERSPECTIVE;
                    UpdateViews();
                }
            }
        }
示例#15
0
        public void InsertBulkhead(double Z)
        {
            int num_chines = Bulkheads[0].NumChines;

            if (num_chines % 2 == 1)
            {
                num_chines = num_chines / 2 + 1;
            }
            else
            {
                num_chines /= 2;
            }

            // get points for new bulkhead
            // First, create chines for base hull
            List <Point3DCollection> chines = GenerateChines(BaseHull.Instance(), POINTS_PER_CHINE);
            Point3DCollection        points = new Point3DCollection();

            for (int ii = num_chines - 1; ii >= 0; ii--)
            {
                Point3D point = GeometryOperations.InterpolateFromZ(chines[ii], Z);
                points.Add(point);
            }

            // figure out where it goes
            int index = 0;

            for (int ii = 0; ii < BaseHull.Instance().Bulkheads.Count; ii++)
            {
                if (BaseHull.Instance().Bulkheads[ii].Points[0].Z > Z)
                {
                    index = ii;
                    break;
                }
            }

            BaseHull.Instance().Bulkheads.Insert(index, new Bulkhead(points, Bulkhead.BulkheadType.VERTICAL, BaseHull.Instance().Bulkheads[index].IsFlatBottomed, BaseHull.Instance().Bulkheads[index].HasClosedTop));
            BaseHull.Instance().Notify("HullData");
        }
示例#16
0
        public void importClick(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openDlg = new OpenFileDialog();

            openDlg.Filter           = "Hull files (*.hul)|*.hul|All files (*.*)|*.*";
            openDlg.FilterIndex      = 0;
            openDlg.RestoreDirectory = true;

            if (openDlg.ShowDialog() == true)
            {
                Hull tempHull = new Hull(openDlg.FileName);

                BaseHull.Instance().Bulkheads = tempHull.Bulkheads;

                PerspectiveView.Perspective = HullControl.PerspectiveType.PERSPECTIVE;

                undoLog.Clear();
                undoLog.Add(BaseHull.Instance());

                redoLog.Clear();
                UpdateViews();
            }
        }
示例#17
0
 public override void ChangeChines(int numChines)
 {
     base.ChangeChines(numChines);
     BaseHull.Instance().ChangeChines(numChines);
 }