private void glControl1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.ControlKey)
            {
                ctrldown = false;
            }

            if (e.KeyCode == Keys.ShiftKey)
            {
                m_movingobjectmode = false;
                // update object info
                Object3d obj = UVDLPApp.Instance().SelectedObject;
                if (obj != null)
                {
                    m_savex = obj.m_center.x - m_savex;
                    m_savey = obj.m_center.y - m_savey;
                    //m_savez = obj.m_center.z - m_savez;
                    UVDLPApp.Instance().m_undoer.SaveTranslation(obj, m_savex, m_savey, 0);
                    if (obj.tag == Object3d.OBJ_SUPPORT)
                    {
                        //obj.CalcMinMaxes();
                        obj.FindMinMax();
                        m_saveh = (obj.m_max.z - obj.m_min.z) / m_saveh;
                        UVDLPApp.Instance().m_undoer.SaveScale(obj, 1, 1, m_saveh);
                        UVDLPApp.Instance().m_undoer.LinkToPrev();
                    }
                }
            }
        }
        public void FillObjectInfo(Object3d obj)
        {
            if (obj == null)
            {
                foreach (Control ctl in layoutPanel.Controls)
                {
                    if (ctl.GetType() == typeof(ctlInfoItem))
                    {
                        ((ctlInfoItem)ctl).DataText = "";
                    }
                }
                tName.Text = "";
                return;
            }
            obj.FindMinMax();
            tName.Text       = obj.Name;
            tPoints.DataText = obj.NumPoints.ToString();
            tPolys.DataText  = obj.NumPolys.ToString();
            tMin.DataText    = String.Format("{0:0.00}, {1:0.00}, {2:0.00}", obj.m_min.x, obj.m_min.y, obj.m_min.z);
            tMax.DataText    = String.Format("{0:0.00}, {1:0.00}, {2:0.00}", obj.m_max.x, obj.m_max.y, obj.m_max.z);
            double xs, ys, zs;

            xs             = obj.m_max.x - obj.m_min.x;
            ys             = obj.m_max.y - obj.m_min.y;
            zs             = obj.m_max.z - obj.m_min.z;
            tSize.DataText = String.Format("{0:0.00}, {1:0.00}, {2:0.00}", xs, ys, zs);
            double vol = obj.Volume;

            vol /= 1000.0; // convert to cm^3
            tVolume.DataText = string.Format("{0:0.000} cm^3", vol);
            double cost = vol * (UVDLPApp.Instance().m_buildparms.m_resinprice / 1000.0);

            tCost.DataText = string.Format("{0:0.000}", cost);
        }
示例#3
0
 public int GetNumberOfSlices(SliceBuildConfig sp, Object3d obj)
 {
     try
     {
         obj.FindMinMax();
         int numslices = (int)((obj.m_max.z - obj.m_min.z) / sp.ZThick);
         return(numslices);
     }
     catch (Exception)
     {
         return(0);
     }
 }
示例#4
0
 private void slicefunc()
 {
     try
     {
         //determine the number of slices
         m_obj.FindMinMax();
         // I think I should calculate the number of slices from the world 0 position, not just the bottom of the object
         int numslices = (int)((m_obj.m_max.z - m_obj.m_min.z) / m_sf.m_config.ZThick);
         // I should start slicing at Wz 0, not Oz 0
         double curz = (double)m_obj.m_min.z;
         RaiseSliceEvent(eSliceEvent.eSliceStarted, 0, numslices);
         DebugLogger.Instance().LogRecord("Slicing started");
         int c = 0;
         m_obj.CalcMinMaxes();
         m_obj.ClearCached();
         for (c = 0; c < numslices; c++)
         {
             // check for cancelation
             if (m_cancel)
             {
                 isslicing = false;
                 m_cancel  = false;
                 RaiseSliceEvent(eSliceEvent.eSliceCancelled, c, numslices);
                 return;
             }
             //get a list of polygons at this slice z height that potentially intersect
             ArrayList lstply = GetZPolys(m_obj, curz);
             //iterate through all the polygons and generate x/y line segments at this 3d z level
             ArrayList lstintersections = GetZIntersections(lstply, curz);
             // move the slice for the next layer
             curz += m_sf.m_config.ZThick;
             //create a new slice
             Slice sl = new Slice();
             // Set the list of intersections
             sl.m_segments = lstintersections;
             // add the slice to slicefile
             m_sf.m_slices.Add(sl);
             //raise an event to say we've finished a slice
             RaiseSliceEvent(eSliceEvent.eLayerSliced, c, numslices);
         }
         RaiseSliceEvent(eSliceEvent.eSliceCompleted, c, numslices);
         DebugLogger.Instance().LogRecord("Slicing Completed");
         isslicing = false;
     }
     catch (Exception ex)
     {
         DebugLogger.Instance().LogRecord(ex.Message);
         //RaiseSliceEvent(eSliceEvent.eSliceCancelled,0,0);
         m_cancel = true;
     }
 }
示例#5
0
        private void slicefunc()
        {
            try
            {
                // m_slices = new ArrayList();
                //iterate
                //determine the number of slices
                m_obj.FindMinMax();
                int numslices = (int)((m_obj.m_max.z - m_obj.m_min.z) / m_sf.m_config.ZThick);

                double curz = (double)m_obj.m_min.z;
                RaiseSliceEvent(eSliceEvent.eSliceStarted, 0, numslices);
                DebugLogger.Instance().LogRecord("Slicing started");
                int c = 0;
                for (c = 0; c < numslices; c++)
                {
                    if (m_cancel)
                    {
                        isslicing = false;
                        m_cancel  = false;
                        RaiseSliceEvent(eSliceEvent.eSliceCancelled, c, numslices);
                        return;
                    }
                    //get a list of polygons at this slice z height that intersect
                    ArrayList lstply = GetZPolys(m_obj, curz);
                    //iterate through all the polygons and generat 2d line segments at this z level
                    ArrayList lstintersections = GetZIntersections(lstply, curz);
                    curz += m_sf.m_config.ZThick;
                    Slice sl = new Slice();
                    sl.m_segments = lstintersections;
                    m_sf.m_slices.Add(sl);
                    RaiseSliceEvent(eSliceEvent.eLayerSliced, c, numslices);
                }
                RaiseSliceEvent(eSliceEvent.eSliceCompleted, c, numslices);
                DebugLogger.Instance().LogRecord("Slicing Completed");
                isslicing = false;
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogRecord(ex.Message);
            }
        }
 private void glControl1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Modifiers == Keys.Control)
     {
         ctrldown = true;
     }
     // if the delete key is pressed, deleted the currently selected object
     if (e.KeyCode == Keys.Delete)
     {
         UVDLPApp.Instance().RemoveCurrentModel();
     }
     if ((e.KeyCode == Keys.Z) && (e.Modifiers == Keys.Control))
     {
         UVDLPApp.Instance().m_undoer.Undo();
     }
     if (e.KeyCode == Keys.ShiftKey)
     {
         if (m_movingobjectmode == false)
         {
             m_movingobjectmode = true;
             Object3d obj = UVDLPApp.Instance().SelectedObject;
             if (obj != null)
             {
                 m_savex = obj.m_center.x;
                 m_savey = obj.m_center.y;
                 //m_savez = obj.m_center.z;
                 if (obj.tag == Object3d.OBJ_SUPPORT)
                 {
                     //obj.CalcMinMaxes();
                     obj.FindMinMax();
                     m_saveh = obj.m_max.z - obj.m_min.z;
                 }
             }
         }
     }
 }