예제 #1
0
        public Vector2 WorldToGrid(Vector3 pos, SnapMode snapMode = SnapMode.None)
        {
            pos = transform.InverseTransformPoint(pos);
            pos = pos / scale;

            switch (snapMode)
            {
            case SnapMode.None:
                break;

            case SnapMode.Round:
                pos.x = Mathf.Round(pos.x);
                pos.y = Mathf.Round(pos.y);
                break;

            case SnapMode.Ceil:
                pos.x = Mathf.Ceil(pos.x);
                pos.y = Mathf.Ceil(pos.y);
                break;

            case SnapMode.Tile:
            case SnapMode.Floor:
                pos.x = Mathf.Floor(pos.x);
                pos.y = Mathf.Floor(pos.y);
                break;

            default:
                throw new NotImplementedException();
            }
            return(pos);
        }
예제 #2
0
        selectPointEntity(string cmd, int osMode)
        {
            object mode = SnapMode.getOSnap();

            SnapMode.setOSnap(osMode);

            ObjectId idPnt = ObjectId.Null;

            Database db = BaseObjs._db;
            Editor   ed = BaseObjs._editor;

            PromptEntityOptions peo = new PromptEntityOptions(string.Format("\nSelect {0} Point:", cmd));

            peo.AllowNone = false;
            peo.SetRejectMessage("\nSelected Entity is not a Cogo Point.");
            peo.AddAllowedClass(typeof(CogoPoint), true);
            try
            {
                idPnt = ed.GetEntity(peo).ObjectId;
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(string.Format("{0} Pnt.cs: line: 118", ex.Message));
            }
            finally
            {
                SnapMode.setOSnap((int)mode);
            }

            return(idPnt);
        }
예제 #3
0
        //--------------------------------------------------------------------------------------------------

        void _WorkspaceController_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == nameof(WorkspaceController.CurrentToolAction))
            {
                SupportedSnapModes = _WorkspaceController.CurrentToolAction?.SupportedSnapModes ?? SnapMode.None;
            }
        }
예제 #4
0
        public override bool StartManipulation(int x, int y)
        {
            if (!editor.Selection.Any())
            {
                return(false);
            }

            snapMode  = editor.Config.RotateToolSnapMode;
            snapValue = editor.Config.RotateToolSnapValue;
            angle     = 0;
            vector0   = Vector3.Zero;
            vector1   = Vector3.Zero;

            targets  = editor.GetSelection();
            initRots = targets.Select(t => t.Rotation).ToArray();

            var origin = targets.Last().Position;
            var mp     = new Point(x, y);


            var intersectX = IntersectRing(origin, Vector3.UnitX, mp);
            var intersectY = IntersectRing(origin, Vector3.UnitY, mp);
            var intersectZ = IntersectRing(origin, Vector3.UnitZ, mp);

            var index = PollIntersections(intersectX, intersectY, intersectZ);

            if (index < 0)
            {
                return(false);
            }

            if (index == 0)
            {
                manipulating = true;
                direction    = Vector3.UnitX;
                initialPoint = intersectX.HitPoint;
                currentPoint = intersectX.HitPoint;
                return(true);
            }

            if (index == 1)
            {
                manipulating = true;
                direction    = Vector3.UnitY;
                initialPoint = intersectY.HitPoint;
                currentPoint = intersectY.HitPoint;
                return(true);
            }

            if (index == 2)
            {
                manipulating = true;
                direction    = Vector3.UnitZ;
                initialPoint = intersectZ.HitPoint;
                currentPoint = intersectZ.HitPoint;
                return(true);
            }

            return(false);
        }
예제 #5
0
        private void UpdateSnapBox(SnapMode Mode)
        {
            string name = "none";

            switch (Mode)
            {
            case SnapMode.Mil100:
                name = "100 mil";
                break;

            case SnapMode.Mil50:
                name = "50 mil";
                break;

            case SnapMode.MM1:
                name = "1mm";
                break;

            case SnapMode.MM05:
                name = "0.5mm";
                break;

            case SnapMode.Off:
                name = "off";
                break;
            }

            CurrentSnapMode = Mode;
            Redraw(false);

            toolStripDropDownButton1.Text = "Snap: " + name;
        }
예제 #6
0
 public void RemoveMode(SnapMode snapMode)
 {
     if (EnabledSnapModes.Contains(snapMode))
     {
         EnabledSnapModes.Remove(snapMode);
         SnapStateChanged?.Invoke(this, null);
     }
 }
예제 #7
0
 /// <summary>
 /// Perform any actions in the OnMouseMove event that are necessary for snap drawing.
 /// </summary>
 /// <param name="snapMode">snapMode</param>
 /// <param name="pos">Current position.</param>
 protected virtual void DoMouseMoveForSnapDrawing(SnapMode snapMode, Point pos)
 {
     if (snapMode != SnapMode.None)
     {
         Rectangle invalid = new Rectangle((int)(pos.X - SnapTol - SnapPen.Width), (int)(pos.Y - SnapTol - SnapPen.Width), (int)(SnapTol + SnapPen.Width) * 2, (int)((SnapTol + SnapPen.Width) * 2));
         Map.Invalidate(invalid);
     }
 }
예제 #8
0
 public void AddMode(SnapMode snapMode)
 {
     if (!EnabledSnapModes.Contains(snapMode))
     {
         EnabledSnapModes.Add(snapMode);
         SnapStateChanged?.Invoke(this, null);
     }
 }
예제 #9
0
 public void SetCursor(Sprite cursorSprite, float scale, SnapMode snap)
 {
     cursor.sprite = cursorSprite;
     cursor.color  = new Color(1, 1, 1, .3f);
     cursor.transform.localScale = Vector3.one * scale;
     snapMode           = snap;
     transform.rotation = Quaternion.identity;
     isVert             = true;
 }
예제 #10
0
파일: cmdGD_old.cs 프로젝트: 15831944/EM
        getDockLimits()
        {
            List <Point3d> pnts3d = new List <Point3d>();

            Point3d pnt3dPick;

            Entity ent = Select.selectEntity(typeof(Polyline3d), "\nSelect Finish Floor 3d Polyline: ",
                                             "3d Polyline selection failed.  Exiting...", out pnt3dPick);

            Polyline3d poly3d = (Polyline3d)ent;

            ResultBuffer rb = poly3d.ObjectId.getXData("AVG");

            if (rb == null)
            {
                return(pnts3d);
            }
            TypedValue[] tvs = rb.AsArray();
            bldgNum = tvs[2].Value.ToString();

            using (BaseObjs._acadDoc.LockDocument())
            {
                Object selectCycling = Application.GetSystemVariable("SELECTIONCYCLING");
                Application.SetSystemVariable("SELECTIONCYCLING", 0);
                Object osMode = SnapMode.getOSnap();
                SnapMode.setOSnap((int)osModes.END);
                PromptStatus ps;

                try
                {
                    bool    escape   = false;
                    Point3d pnt3dRet = UserInput.getPoint("\nSelect Dock Begin point (CCW orientation)", Pub.pnt3dO, out escape, out ps, osMode: 1);
                    if (escape)
                    {
                        return(pnts3d);
                    }
                    pnts3d.Add(pnt3dRet);

                    pnt3dRet = UserInput.getPoint("\nSelect Dock End point (CCW orientation)", pnt3dRet, out escape, out ps, osMode: 1);
                    if (escape)
                    {
                        return(pnts3d);
                    }
                    pnts3d.Add(pnt3dRet);
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " cmdGD_old.cs: line: 284");
                }
                finally
                {
                    Application.SetSystemVariable("SELECTIONCYCLING", selectCycling);
                    SnapMode.setOSnap((int)osMode);
                }
            }
            return(pnts3d);
        }
        public static float SnapToFrame(float time, SnapMode snap)
        {
            if (snap == SnapMode.Disabled)
            {
                return(time);
            }

            return(SnapToFrame(time, FrameRate));
        }
예제 #12
0
 private static Vector3 ApplySnap(Vector3 point, SnapMode snapMode)
 {
     if (snapMode == SnapMode.Unit)
     {
         point.x = Mathf.RoundToInt(point.x * SNAPSPERUNITYUNIT) * 1f / SNAPSPERUNITYUNIT;
         point.y = 0;
         point.z = Mathf.RoundToInt(point.z * SNAPSPERUNITYUNIT) * 1f / SNAPSPERUNITYUNIT;
     }
     return(point);
 }
예제 #13
0
 public void ToggleSnappingMode(bool art)
 {
     if (art)
     {
         snapMode = SnapMode.SnapToArtPixel;
     }
     else
     {
         snapMode = SnapMode.SnapToScreenPixel;
     }
 }
예제 #14
0
 public BaseForm(SnapMode snapMode, int snapMargin)
 {
     this.SnapMode   = snapMode;
     this.SnapMargin = snapMargin;
     if (snapMargin > 0)
     {
         this.LocationChanged += baseForm_LocationChanged;
     }
     this.MouseDown += Form_MouseDown;
     this.MouseMove += Form_MouseMove;
     this.MouseUp   += Form_MouseUp;
 }
예제 #15
0
		public Grid(Vector3 origin, float gridUnit = 1,
		            SnapMode snapX = SnapMode.SNAP, SnapMode snapY = SnapMode.SNAP, SnapMode snapZ = SnapMode.SNAP,
		            float xFixedPos = 0, float yFixedPos = 0, float zFixedPos = 0)
		{
			this.origin = origin;
			this.gridUnit = gridUnit;
			this.snapX = snapX;
			this.snapY = snapY;
			this.snapZ = snapZ;
			this.xFixedPos = xFixedPos;
			this.yFixedPos = yFixedPos;
			this.zFixedPos = zFixedPos;
		}
예제 #16
0
        public void SnapSetter(SnapMode mode)
        {
            Rhino.ApplicationSettings.ModelAidSettingsState   setting    = Rhino.ApplicationSettings.ModelAidSettings.GetDefaultState();
            Rhino.ApplicationSettings.SmartTrackSettingsState smtsetting = Rhino.ApplicationSettings.SmartTrackSettings.GetDefaultState();

            if (mode != SnapMode.Current)
            {
                current    = Rhino.ApplicationSettings.ModelAidSettings.GetCurrentState();
                smtcurrent = Rhino.ApplicationSettings.SmartTrackSettings.GetCurrentState();
            }
            else
            {
                setting    = current;
                smtsetting = smtcurrent;
            }
            switch (mode)
            {
            case SnapMode.Default:

                Rhino.RhinoApp.WriteLine("Default");
                break;

            case SnapMode.EndOnly:

                smtsetting.UseSmartTrack = false;
                setting.OsnapModes       = Rhino.ApplicationSettings.OsnapModes.None;
                setting.OsnapModes       = Rhino.ApplicationSettings.OsnapModes.End;

                Rhino.RhinoApp.WriteLine("EndOnly");
                break;

            case SnapMode.OffAll:

                smtsetting.UseSmartTrack = false;
                setting.OsnapModes       = Rhino.ApplicationSettings.OsnapModes.None;

                Rhino.RhinoApp.WriteLine("OffAll");
                break;

            case SnapMode.Current:

                Rhino.RhinoApp.WriteLine("Current");
                break;

            default:
                break;
            }

            Rhino.ApplicationSettings.ModelAidSettings.UpdateFromState(setting);
            Rhino.ApplicationSettings.SmartTrackSettings.UpdateFromState(smtsetting);
        }
예제 #17
0
    void OnGUI()
    {
        GUILayout.BeginHorizontal ();
        GUILayout.FlexibleSpace();
         		GUILayout.Label ( "  Snap To Grid v1.0" );
        GUILayout.FlexibleSpace ();
        GUILayout.EndHorizontal ();

        snapMode = (SnapMode)EditorGUILayout.EnumPopup ( snapMode );

        GUI.enabled = snapMode != SnapMode.Vertical;
        float newWidth = EditorGUILayout.FloatField ( "Grid width", width );
        if ( ( newWidth != 0 ) && ( newWidth != width ) )
        {
            width = newWidth;
            autoApply = false;
        }
        GUI.enabled = true;

        GUI.enabled = snapMode != SnapMode.Horizontal;
        float newHeight = EditorGUILayout.FloatField ( "Grid height", height );
        if ( ( newHeight != 0 ) && ( newHeight != height ) )
        {
            height = newHeight;
            autoApply = false;
        }
        GUI.enabled = true;

        EditorGUILayout.Space();
        bool displayGridBefore = displayGrid;
        displayGrid = EditorGUILayout.Toggle ( "Display grid", displayGrid );
        if ( displayGridBefore != displayGrid )
            SceneView.currentDrawingSceneView.Repaint ();

        EditorGUILayout.Space();
        autoApply = EditorGUILayout.Toggle ( "Auto apply", autoApply );
        if ( autoApply )
        {
            GUIStyle style = new GUIStyle ();
            style.normal.textColor = Color.gray;
            style.alignment = TextAnchor.MiddleCenter;
            GUILayout.Label ( "Auto applied to selection", style );
        }
        else
        {
            if ( GUILayout.Button ( "Apply to selection" ) )
                ApplyToSelection ();
        }
    }
예제 #18
0
        public static double SnapY(double y, SnapMode mode = SnapMode.Normal)
        {
            switch (mode)
            {
            case SnapMode.Normal:
                return((int)(Math.Round((double)y / Settings.Snap.Y, MidpointRounding.AwayFromZero) * Settings.Snap.Y));

            case SnapMode.Decrease:
                return((int)(Math.Floor((double)y / Settings.Snap.Y) * Settings.Snap.Y));

            case SnapMode.Increase:
                return((int)(Math.Ceiling((double)y / Settings.Snap.Y) * Settings.Snap.Y));
            }

            throw new ArgumentException("SnapMode is not supported.");
        }
예제 #19
0
파일: cmdS.cs 프로젝트: 15831944/EM
        S(Point3d pnt3d, string desc)
        {
            ObjectId idPnt3d = ObjectId.Null;
            Object   osMode  = SnapMode.getOSnap();

            SnapMode.setOSnap(0);
            PromptStatus ps = PromptStatus.Cancel;

            try
            {
                if (pnt3d == Pub.pnt3dO)
                {
                    pnt3d = UserInput.getPoint("New Point: ", out ps, osMode: 641);
                    if (pnt3d == Pub.pnt3dO)
                    {
                        return(ObjectId.Null);
                    }
                    else
                    {
                        if (pnt3d.Z == 0.0)
                        {
                            double elev;
                            bool   escape = UserInput.getUserInput("Enter Elevation: ", out elev, 0.0);
                            if (escape)
                            {
                                return(ObjectId.Null);
                            }
                            pnt3d = new Point3d(pnt3d.X, pnt3d.Y, elev);
                        }
                    }
                }

                uint pntNum;

                ObjectId idCgPnt = pnt3d.setPoint(out pntNum, desc);
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdS.cs: line: 48");
            }
            finally
            {
                SnapMode.setOSnap((int)osMode);
            }

            return(idPnt3d);
        }
예제 #20
0
        private void cmdSetPoint_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            boolSetPointAtCenter = false;
            bool escape = true;

            Point3d pnt3dTAR = Pub.pnt3dO;

            BaseObjs.acadActivate();
            Object osMode = SnapMode.getOSnap();

            SnapMode.setOSnap((int)osModes.PER);

            double slope = Convert.ToDouble(cmbSlope.SelectedValue);

            if (slope != 0.0)
            {
                pnt3dTAR = Grading_Floor.getPoint("Select Building Edge in Direction of Increasing Slope", Centroid, out escape);
            }

            Grading_Floor.AVG(idBldgLim, Centroid, slope, Convert.ToDouble(txtPadElev.Text), boolSetPointAtCenter, pnt3dTAR);
            idBldgLim.delete();
            SnapMode.setOSnap((int)osMode);
        }
예제 #21
0
        bool LoadCfg()
        {
            ConfigNode file;

            if (System.IO.File.Exists(CFC_CFG_FILE))
            {
                file = ConfigNode.Load(CFC_CFG_FILE);
            }
            else
            {
                return(false);
            }

            ConfigNode node = file.GetNode(CFC_NODE);

            if (node != null)
            {
                actionKey = (KeyCode)System.Enum.Parse(typeof(KeyCode), SafeLoad(node.GetValue("actionKey"), "O"));
                snapMode  = (SnapMode)System.Enum.Parse(typeof(SnapMode), SafeLoad(node.GetValue("snapMode"), SnapMode.smooth.ToString()));
                DebugPrint("LoadCfg, actionKey: " + actionKey.ToString() + ", snapMode: " + snapMode.ToString());
            }
            return(true);
        }
예제 #22
0
        MCG()
        {
            object dynMode   = null;
            object dynPrompt = null;
            object osMode    = null;

            try
            {
                dynMode   = Application.GetSystemVariable("DYNMODE");
                dynPrompt = Application.GetSystemVariable("DYNPROMPT");

                Application.SetSystemVariable("DYNMODE", 3);
                Application.SetSystemVariable("DYNPROMPT", 1);

                osMode = SnapMode.getOSnap();
                SnapMode.setOSnap((int)osModes.NOD);

                string       descVal = "", descKey = "";
                Point3d      pnt3dPick;
                PromptStatus ps;
                CogoPoint    cgPnt;
                Entity       ent    = Select.selectEntity(typeof(CogoPoint), "\nSelect a point on the desired group or <CR> for Menu: ", "", out pnt3dPick, out ps);
                short        color  = 256;
                string       prompt = "";
                TypedValue[] tvs;

                switch (ps)
                {
                case PromptStatus.OK:
                    cgPnt   = (CogoPoint)ent;
                    descVal = cgPnt.RawDescription;
                    break;

                case PromptStatus.Cancel:
                    return;

                case PromptStatus.None:
                    bool     exists;
                    ObjectId idDict = Dict.getNamedDictionary("cmdMCG", out exists);
                    if (exists)
                    {
                        ResultBuffer rb = Dict.getXRec(idDict, "defaultCmd");
                        if (rb == null)
                        {
                            descVal = "CPNT-ON";
                        }
                        else
                        {
                            tvs     = rb.AsArray();
                            descVal = tvs[0].Value.ToString();
                        }
                    }
                    else
                    {
                        descVal = "CPNT-ON";
                    }
                    descKey = "O";
                    foreach (CgPnt_Group.pntGroupParams pntGrp in CgPnt_Group.pntGroups)
                    {
                        if (pntGrp.name == descVal)
                        {
                            descKey = pntGrp.key;
                            break;
                        }
                    }

                    bool escape;
                    prompt = string.Format("\nSelect [cpntJoin/cpntOn/cpntSt/cpntTrans/cpntMisc/utlSEw/utlSD/utlWat/utlMIsc/Cp/SPnt/Exist/eXit] <{0}> [J/O/S/T/M/SE/SD/W/MI/C/SP/E/X]", descVal);
                    escape = UserInput.getUserInputKeyword(descKey, out descKey, prompt, "J O S T M SE SD W MI C SP E X");
                    if (escape)
                    {
                        return;
                    }

                    if (descKey.ToUpper() == "X")
                    {
                        return;
                    }

                    exists = false;
                    foreach (CgPnt_Group.pntGroupParams pntGrp in CgPnt_Group.pntGroups)
                    {
                        if (pntGrp.key == descKey)
                        {
                            descVal = pntGrp.name;
                            color   = pntGrp.color;
                            exists  = true;
                            break;
                        }
                    }

                    if (!exists)
                    {
                        Application.ShowAlertDialog("Value entered is out of range. Exiting...");
                        return;
                    }

                    break;
                }
                Layer.manageLayers(descVal);
                ObjectId idPntLblStyle = Pnt_Style.getPntLabelStyle(descVal);
                ObjectId idPntStyle    = Pnt_Style.getPntStyle(descVal);

                Layer.manageLayer(descVal, color);

                prompt = string.Format("\nSelect Point(s) to be moved to group {0}\r", descVal);

                Editor ed = BaseObjs._editor;

                tvs = new TypedValue[1];
                Type type = typeof(CogoPoint);
                tvs.SetValue(new TypedValue((int)DxfCode.Start, RXClass.GetClass(type).DxfName), 0);

                SelectionFilter        filter = new SelectionFilter(tvs);
                PromptSelectionOptions pso    = new PromptSelectionOptions();
                pso.MessageForAdding            = prompt;
                pso.MessageForRemoval           = "\nRemove Items";
                pso.RejectObjectsOnLockedLayers = true;

                PromptSelectionResult psr = null;
                BaseObjs.acadActivate();

                psr = BaseObjs._editor.GetSelection(pso, filter);
                SelectionSet ss = psr.Value;

                if (ss != null && ss.Count > 0)
                {
                    ObjectId[] ids = ss.GetObjectIds();
                    try
                    {
                        using (Transaction tr = BaseObjs.startTransactionDb())
                        {
                            foreach (ObjectId id in ids)
                            {
                                CogoPoint cogoPnt = (CogoPoint)tr.GetObject(id, OpenMode.ForWrite);
                                cogoPnt.RawDescription = descVal;
                                cogoPnt.Layer          = descVal;
                                cogoPnt.LabelStyleId   = idPntLblStyle;
                                cogoPnt.StyleId        = idPntStyle;
                            }
                            tr.Commit();
                        }
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(ex.Message + " cmdMCG.cs: line: 155");
                    }
                    CgPnt_Group.updatePntGroups();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdMCG.cs: line: 162");
            }
            finally
            {
                SnapMode.setOSnap((int)osMode);
                Application.SetSystemVariable("DYNMODE", (Int16)dynMode);
                Application.SetSystemVariable("DYNPROMPT", (Int16)dynPrompt);
            }
        }
        public static void Reload()
        {
            LockAxisX = EditorPrefs.GetBool("LockAxisX", false);
            LockAxisY = EditorPrefs.GetBool("LockAxisY", false);
            LockAxisZ = EditorPrefs.GetBool("LockAxisZ", false);

            UniformGrid = EditorPrefs.GetBool("UniformGrid", true);
            EditMode    = GetEnum("EditMode", ToolEditMode.Generate);

            SnapVector          = GetVector3("MoveSnap", Vector3.one);
            DefaultMoveOffset   = GetVector3("DefaultMoveOffset", Vector3.zero);
            DefaultRotateOffset = GetVector3("DefaultRotateOffset", Vector3.zero);

            ShapeBuildMode     = GetEnum("ShapeBuildMode", ShapeMode.Box);
            DefaultTexGenFlags = GetEnum("DefaultTexGenFlags", defaultTextGenFlagsState);

            GridVisible = EditorPrefs.GetBool("ShowGrid", true);
            SnapMode    = (SnapMode)EditorPrefs.GetInt("SnapMode", (int)(EditorPrefs.GetBool("ForceSnapToGrid", true) ? SnapMode.GridSnapping : SnapMode.None));

            VisibleHelperSurfaces = GetEnum("HelperSurfaces", DefaultHelperSurfaceFlags);

            ClipMode          = GetEnum("ClipMode", ClipMode.RemovePositive);
            EnableRealtimeCSG = EditorPrefs.GetBool("EnableRealtimeCSG", true);

            DefaultMaterial = GetMaterial("DefaultMaterial", MaterialUtility.WallMaterial);


            SnapScale          = EditorPrefs.GetFloat("ScaleSnap", 0.1f);
            SnapRotation       = EditorPrefs.GetFloat("RotationSnap", 15.0f);
            DefaultShapeHeight = EditorPrefs.GetFloat("DefaultShapeHeight", 1.0f);
            CurveSides         = (uint)EditorPrefs.GetInt("CurveSides", 10);

            SelectionVertex  = EditorPrefs.GetBool("SelectionVertex", true);
            SelectionEdge    = EditorPrefs.GetBool("SelectionEdge", true);
            SelectionSurface = EditorPrefs.GetBool("SelectionSurface", true);

            HiddenSurfacesNotSelectable = EditorPrefs.GetBool("HiddenSurfacesNotSelectable", true);
//			HiddenSurfacesOrthoSelectable	= EditorPrefs.GetBool("HiddenSurfacesOrthoSelectable", true);
            ShowTooltips       = EditorPrefs.GetBool("ShowTooltips", true);
            AutoRigidbody      = EditorPrefs.GetBool("AutoRigidbody", (CSGModel.DefaultSettings & ModelSettingsFlags.AutoUpdateRigidBody) == ModelSettingsFlags.AutoUpdateRigidBody);
            DefaultPreserveUVs = EditorPrefs.GetBool("DefaultPreserveUVs", (CSGModel.DefaultSettings & ModelSettingsFlags.PreserveUVs) == ModelSettingsFlags.PreserveUVs);
            SnapNonCSGObjects  = EditorPrefs.GetBool("SnapNonCSGObjects", true);

            AutoCommitExtrusion = EditorPrefs.GetBool("AutoCommitExtrusion", false);

            MaxSphereSplits = Mathf.Max(3, EditorPrefs.GetInt("MaxSphereSplits", 9));

            CircleSides             = Mathf.Max(3, EditorPrefs.GetInt("CircleSides", 18));
            MaxCircleSides          = Mathf.Max(3, EditorPrefs.GetInt("MaxCircleSides", 144));
            CircleOffset            = EditorPrefs.GetFloat("CircleOffset", 0);
            CircleSmoothShading     = EditorPrefs.GetBool("CircleSmoothShading", true);
            CircleSingleSurfaceEnds = EditorPrefs.GetBool("CircleSingleSurfaceEnds", true);
            CircleDistanceToSide    = EditorPrefs.GetBool("CircleDistanceToSide", true);
            CircleRecenter          = EditorPrefs.GetBool("CircleRecenter", true);


            SphereSplits         = Mathf.Max(1, EditorPrefs.GetInt("SphereSplits", 1));
            SphereOffset         = EditorPrefs.GetFloat("SphereOffset", 0);
            SphereSmoothShading  = EditorPrefs.GetBool("SphereSmoothShading", true);
            SphereDistanceToSide = EditorPrefs.GetBool("SphereDistanceToSide", true);
            HemiSphereMode       = EditorPrefs.GetBool("HemiSphereMode", false);

            LinearStairsStepLength = EditorPrefs.GetFloat("LinearStairsStepLength", 0.30f);
            LinearStairsStepHeight = EditorPrefs.GetFloat("LinearStairsStepHeight", 0.20f);
            LinearStairsStepWidth  = EditorPrefs.GetFloat("LinearStairsStepWidth", 1.0f);
            LinearStairsTotalSteps = EditorPrefs.GetInt("LinearStairsTotalSteps", 4);

            LinearStairsLength       = EditorPrefs.GetFloat("LinearStairsLength", 16.0f);
            LinearStairsHeight       = EditorPrefs.GetFloat("LinearStairsHeight", 16.0f);
            LinearStairsLengthOffset = EditorPrefs.GetFloat("LinearStairsLengthOffset", 0.0f);
            LinearStairsHeightOffset = EditorPrefs.GetFloat("LinearStairsHeightOffset", 0.0f);

            DistanceUnit = GetEnum("DistanceUnit", DistanceUnit.Meters);

            ShowSceneInfo = EditorPrefs.GetBool("ShowSceneInfo", false);


            var sceneViews = SortedSceneViews();

            EnsureValidSceneviewNames(sceneViews);
            var arrayString = EditorPrefs.GetString("Wireframe", string.Empty);

            if (arrayString.Contains(','))
            {
                LegacyLoadWireframeSettings(sceneViews, arrayString);
            }
            else
            {
                LoadWireframeSettings(sceneViews, arrayString);
            }

            UpdateSnapSettings();
        }
예제 #24
0
파일: Convert_App.cs 프로젝트: 15831944/EM
        convertBubble()
        {
            ObjectId idWO  = ObjectId.Null; //wipeout
            ObjectId idSM  = ObjectId.Null; //symbol
            ObjectId idTX  = ObjectId.Null; //text
            ObjectId idLDR = ObjectId.Null; //leader

            Point3d pnt3d  = Pub.pnt3dO;
            Object  osMode = SnapMode.getOSnap();

            int scale = Misc.getCurrAnnoScale();

            TypedValue[] tvs = new TypedValue[2];
            tvs.SetValue(new TypedValue((int)DxfCode.Start, "INSERT"), 0);
            tvs.SetValue(new TypedValue((int)DxfCode.LayerName, "BUBBLE"), 1);

            SelectionSet ss = Select.buildSSet(tvs);

            ObjectId[] idsBR = ss.GetObjectIds();

            ObjectId idLayer   = Layer.manageLayers("BUBBLE");
            double   angleView = -(double)Application.GetSystemVariable("VIEWTWIST");

            Database db = HostApplicationServices.WorkingDatabase;

            using (Transaction tr = BaseObjs.startTransactionDb())
            {
                DBDictionary     groups = (DBDictionary)db.GroupDictionaryId.GetObject(OpenMode.ForRead);
                BlockTableRecord ms     = Blocks.getBlockTableRecordMS();

                foreach (ObjectId idBR in idsBR)
                {
                    BlockReference br = (BlockReference)tr.GetObject(idBR, OpenMode.ForWrite);

                    if (br.Name == "CWP")
                    {
                        br.ObjectId.delete();
                        continue;
                    }

                    Scale3d  scaleFactor = br.ScaleFactors;
                    Matrix3d m3d         = scaleFactor.GetMatrix();
                    double   scaleBR     = m3d.GetScale();

                    double              rotation = br.Rotation;
                    Point3d             pnt3dPos = br.Position;
                    string              name     = br.Name;
                    string              value    = string.Empty;
                    Entity              ent      = null;
                    AttributeCollection atts     = br.AttributeCollection;
                    foreach (ObjectId id in atts)
                    {
                        ent = id.getEnt();
                        AttributeReference attDef = (AttributeReference)ent;
                        value = attDef.TextString;
                    }

                    Vector3d v3d = new Vector3d(scaleBR * 1.35, scaleBR * 1.35, 0);
                    v3d = v3d * 1.1;
                    Point3d pnt3dLL = pnt3dPos - v3d;
                    Point3d pnt3dUR = pnt3dPos + v3d;
                    Point3d pnt3dLR = new Point3d(pnt3dUR.X, pnt3dLL.Y, 0.0);
                    Point3d pnt3dUL = new Point3d(pnt3dLL.X, pnt3dUR.Y, 0.0);

                    Point3dCollection pnts3d = new Point3dCollection {
                        pnt3dLL,
                        pnt3dLR,
                        pnt3dUR,
                        pnt3dUL,
                        pnt3dLL
                    };

                    tvs = new TypedValue[2];
                    tvs.SetValue(new TypedValue((int)DxfCode.Start, "LWPOLYLINE"), 0);
                    tvs.SetValue(new TypedValue((int)DxfCode.LayerName, "BUBBLE"), 1);

                    Point3d pnt3dBeg = Pub.pnt3dO;
                    Point3d pnt3dEnd = Pub.pnt3dO;
                    Point3d pnt3dMid = Pub.pnt3dO;

                    double             bulge = 0.0, delta0 = 0.0;
                    double             dirChord, dirTarget, disChord, disTarget;
                    Polyline           poly;
                    ObjectIdCollection idsLdr = new ObjectIdCollection();
                    ss = Select.buildSSet(tvs, pnts3d);
                    if (ss != null && ss.Count > 0)
                    {
                        ObjectId[] ids = ss.GetObjectIds();
                        foreach (ObjectId id in ids)
                        {
                            poly = (Polyline)id.getEnt();
                            if (poly != null)
                            {
                                pnt3dBeg = poly.StartPoint;
                                pnt3dMid = poly.GetPoint3dAt(1);
                                pnt3dEnd = poly.EndPoint;

                                bulge     = poly.GetBulgeAt(1);
                                delta0    = Geom.getDelta(bulge);
                                disChord  = pnt3dMid.getDistance(pnt3dEnd);
                                disTarget = (0.5 * disChord) / System.Math.Cos(delta0 / 4);
                                dirChord  = pnt3dMid.getDirection(pnt3dEnd);
                                dirTarget = dirChord - delta0 / 4;
                                pnt3dMid  = pnt3dMid.traverse(dirTarget, disTarget);

                                //dirTarget = pnt3dEnd.getDirection(pnt3dPos);    //direction towards center of circle
                                //disTarget = pnt3dEnd.getDistance(pnt3dPos);     //distance from original end point to center
                                //disTarget = disTarget - Pub.radius * scale * 0.85;    //0.85 per addSymbolAndWipeout  - factors to adjust symbols for best fit.
                                //pnt3dEnd = pnt3dEnd.traverse(dirTarget, disTarget);

                                pnt3dEnd = pnt3dPos;

                                pnts3d = new Point3dCollection {
                                    pnt3dBeg,
                                    pnt3dMid,
                                    pnt3dEnd
                                };
                                ObjectId idLdr = Ldr.addLdr(pnts3d, idLayer, 0.09 * scale, 0, clr.byl, ObjectId.Null, spline: true);
                                idsLdr.Add(idLdr);
                                poly.ObjectId.delete();
                            }
                        }
                    }

                    idSM = Base_Tools45.Draw.addSymbolAndWipeout(pnt3dPos, angleView, out idWO, Pub.radius, 1024, true);
                    idSM.moveToTop();
                    idSM.moveBelow(new ObjectIdCollection {
                        idWO
                    });
                    if (idsLdr.Count > 0)
                    {
                        idWO.moveBelow(idsLdr);
                    }
                    Color color = new Color();
                    color = Color.FromColorIndex(ColorMethod.ByLayer, 256);
                    idTX  = Txt.addMText(value, pnt3dPos, angleView, 0.8, 0.09, AttachmentPoint.MiddleCenter, "Annotative", "BUBBLE", color, Pub.JUSTIFYCENTER);
                    br.ObjectId.delete();

                    Draw.addXData(idSM, scale, idTX, idsLdr, idWO, 1024, "0".stringToHandle(), "");
                    //DBObjectCollection dbObjs = new DBObjectCollection();
                    //ent = (Entity)br;
                    //ent.Explode(dbObjs);
                    //foreach(Autodesk.AutoCAD.DatabaseServices.DBObject dbObj in dbObjs){
                    //    Autodesk.AutoCAD.DatabaseServices.Entity e = (Autodesk.AutoCAD.DatabaseServices.Entity)dbObj;
                    //    ms.AppendEntity(e);
                    //    tr.AddNewlyCreatedDBObject(e, true);
                    //    if(e.GetType() == typeof(Circle)){
                    //        foreach (DBDictionaryEntry entry in groups)
                    //        {
                    //            ObjectId idGrp = entry.Value;
                    //            Group group = (Group)tr.GetObject(idGrp, (OpenMode.ForRead));
                    //            ObjectId[] ids = group.GetAllEntityIds();
                    //            List<ObjectId> lstIDs = new List<ObjectId>();
                    //            foreach (ObjectId id in ids)
                    //                lstIDs.Add(id);
                    //            if (lstIDs.Contains(idBR))
                    //            {
                    //                group.UpgradeOpen();
                    //                foreach (ObjectId idEnt in lstIDs)
                    //                {
                    //                    group.Remove(idEnt);
                    //                    idEnt.delete();
                    //                }
                    //                group.Erase();
                    //                break;
                    //            }
                    //        }
                    //    }
                    //    e.ObjectId.delete();
                    //}
                }
                tr.Commit();
            }

            SnapMode.setOSnap((int)osMode);
        }
예제 #25
0
        internal static Vector3 Do(int id, Vector3 position, Vector3 direction, float size, CSGHandles.CapFunction capFunction, SnapMode snapMode, Vector3[] snapVertices, CSGHandles.InitFunction initFunction = null, CSGHandles.InitFunction shutdownFunction = null)
        {
            var evt = Event.current;

            switch (evt.GetTypeForControl(id))
            {
            case EventType.Layout:
            {
                if (capFunction != null)
                {
                    capFunction(id, position, Quaternion.LookRotation(direction), size, EventType.Layout);
                }
                else
                {
                    HandleUtility.AddControl(id, HandleUtility.DistanceToCircle(position, size * .2f));
                }
                break;
            }

            case EventType.MouseDown:
            {
                if (CSGHandles.disabled)
                {
                    break;
                }
                if (((HandleUtility.nearestControl == id && evt.button == 0) ||
                     (GUIUtility.keyboardControl == id && evt.button == 2)) && GUIUtility.hotControl == 0)
                {
                    s_SnapVertices = null;
                    if (initFunction != null)
                    {
                        initFunction();
                    }
                    GUIUtility.hotControl  = GUIUtility.keyboardControl = id;
                    s_CurrentMousePosition = s_StartMousePosition = evt.mousePosition;
                    s_StartPosition        = position;
                    evt.Use();
                    EditorGUIUtility.SetWantsMouseJumping(1);
                }

                break;
            }

            case EventType.MouseDrag:
            {
                if (GUIUtility.hotControl == id)
                {
                    if (s_SnapVertices == null)
                    {
                        if (snapVertices != null)
                        {
                            s_SnapVertices = snapVertices.ToArray();
                        }
                        else
                        {
                            s_SnapVertices = new Vector3[] { s_StartPosition }
                        };
                    }
                    s_CurrentMousePosition += evt.delta;
                    var dist           = HandleUtility.CalcLineTranslation(s_StartMousePosition, s_CurrentMousePosition, s_StartPosition, direction);
                    var worldDirection = Handles.matrix.MultiplyVector(direction);
                    var worldPosition  = Handles.matrix.MultiplyPoint(s_StartPosition) + (worldDirection * dist);
                    position = Handles.inverseMatrix.MultiplyPoint(worldPosition);

                    switch (snapMode)
                    {
                    case SnapMode.GridSnapping:
                    {
                        var delta = RealtimeCSG.CSGGrid.SnapDeltaToGrid(position - s_StartPosition, s_SnapVertices, snapToGridPlane: false, snapToSelf: true);
                        position = delta + s_StartPosition;
                        break;
                    }

                    case SnapMode.RelativeSnapping:
                    {
                        var delta = RealtimeCSG.CSGGrid.SnapDeltaRelative(position - s_StartPosition, snapToGridPlane: false);
                        position = delta + s_StartPosition;
                        break;
                    }

                    default:
                    case SnapMode.None:
                    {
                        position = RealtimeCSG.CSGGrid.HandleLockedAxi(position - s_StartPosition) + s_StartPosition;
                        break;
                    }
                    }

                    GUI.changed = true;
                    evt.Use();
                }
                break;
            }

            case EventType.MouseUp:
            {
                if (GUIUtility.hotControl == id && (evt.button == 0 || evt.button == 2))
                {
                    GUIUtility.hotControl = 0;
                    if (shutdownFunction != null)
                    {
                        shutdownFunction();
                    }
                    evt.Use();
                    EditorGUIUtility.SetWantsMouseJumping(0);
                }
                break;
            }

            case EventType.Repaint:
            {
                var originalColor = Handles.color;
                Handles.color = CSGHandles.StateColor(originalColor, CSGHandles.disabled, CSGHandles.FocusControl == id);
                if (capFunction != null)
                {
                    capFunction(id, position, Quaternion.LookRotation(direction), size, EventType.Repaint);
                }

                Handles.color = originalColor;
                break;
            }
            }
            return(position);
        }
예제 #26
0
		public Grid(float gridUnit = 1,
		            SnapMode snapX = SnapMode.SNAP, SnapMode snapY = SnapMode.SNAP, SnapMode snapZ = SnapMode.SNAP,
		            float xFixedPos = 0, float yFixedPos = 0, float zFixedPos = 0)
			:this(new Vector3(0, 0, 0), gridUnit, snapX, snapY, snapZ, xFixedPos, yFixedPos, zFixedPos) { }
예제 #27
0
		public Grid(Vector3 origin, float gridUnit = 1, SnapMode snap = SnapMode.SNAP, float fixedPos = 0)
			:this(origin, gridUnit, snap, snap, snap, fixedPos, fixedPos, fixedPos) { }
예제 #28
0
		public Grid(float gridUnit, SnapMode snap, float fixedPos)
			:this(new Vector3(0, 0, 0), gridUnit, snap, snap, snap, fixedPos, fixedPos, fixedPos) { }
 float TimeToPixel(float time, SnapMode snap)
 {
     return(SnapToFrame(time, snap) * PixelPerSecond + ZeroTimePixel);
 }
예제 #30
0
파일: DimPL_App.cs 프로젝트: 15831944/EM
        dimpl(double txtSize, int maxRows, double sizeRow)
        {
            PromptStatus   ps;
            Point3d        pnt3d1a, pnt3d2a, pntPick;
            List <Point3d> pnts3dEntX, pnts3dEnt1, pnts3dEnt2, pnts3d1a, pnts3d2a;
            Object         xRefPath1, xRefPath2, xRefPathX = null;
            Line           lineX, line1, line2;

            Entity        ent1, ent2;
            List <Handle> handles   = new List <Handle>();
            int           annoScale = Misc.getCurrAnnoScale();
            double        txtHeight = System.Math.Round(txtSize * annoScale, 3);

            Object osModeOrg = SnapMode.getOSnap();

            SnapMode.setOSnap(1);

            bool escape = false;
            bool isClosed;
            FullSubentityPath        path;
            List <FullSubentityPath> paths = new List <FullSubentityPath>();

            Entity entX = xRef.getNestedEntity("\nSelect Property Line: ", out escape, out xRefPathX, out ps, out pnts3dEntX, out path, out pntPick, out isClosed);

            if (escape || ps == PromptStatus.None)
            {
                return;
            }
            paths.Add(path);

            lineX = null;
            if (entX is Line)
            {
                lineX = (Line)entX;
            }
            else if (entX is Polyline)
            {
            }
            entHandles.hX = lineX.Handle;

            ent1 = xRef.getNestedEntity("\nSelect SubDivision Line: ", out escape, out xRefPath1, out ps, out pnts3dEnt1, out path, out pntPick, out isClosed);  //check if entX and line1 are in same drawing.
            if (escape || ps == PromptStatus.None)
            {
                return;
            }
            paths.Add(path);

            line1 = null;
            if (ent1 is Line)
            {
                line1 = (Line)ent1;
            }
            else if (ent1 is Polyline)
            {
            }

            pnts3d1a = pnts3dEnt1.intersectWith(pnts3dEntX, true, extend.both);
            if (pnts3d1a.Count > 1)
            {
                return;
            }
            pnt3d1a = pnts3d1a[0];
            if (pnt3d1a.X == -1)
            {
                pnts3d1a = pnts3dEntX.intersectWith(pnts3dEnt1, true, extend.both);
                pnt3d1a  = pnts3d1a[0];
            }

            entHandles.h1 = line1.Handle;

            escape = false;

            ent2 = xRef.getNestedEntity("\nSelect SubDivision Line: ", out escape, out xRefPath2, out ps, out pnts3dEnt2, out path, out pntPick, out isClosed);  //To do: check if entX and line1 are in same drawing.
            if (escape || ps == PromptStatus.None)
            {
                return;
            }

            paths.Add(path);

            line2 = null;
            if (ent2 is Line)
            {
                line2 = (Line)ent2;
            }
            else if (ent2 is Polyline)
            {
            }

            pnts3d2a = pnts3dEnt2.intersectWith(pnts3dEntX, false, extend.both);
            if (pnts3d2a.Count > 1)
            {
                return;
            }
            pnt3d2a = pnts3d2a[0];
            if (pnt3d2a.X == -1)
            {
                pnts3d2a = pnts3dEntX.intersectWith(pnts3dEnt2, true, extend.both);
                pnt3d2a  = pnts3d2a[0];
            }

            entHandles.h2 = line2.Handle;

            handles.Add(entHandles.hX);
            handles.Add(entHandles.h1);
            handles.Add(entHandles.h2);

            SnapMode.setOSnap(0);
            getTextLocation(pnt3d1a, pnt3d2a, txtSize, annoScale, sizeRow, txtHeight, maxRows, handles, xRefPathX);
            int osM;

            int.TryParse(osModeOrg.ToString(), out osM);
            SnapMode.setOSnap(osM);

            xRef.unHighlightNestedEntity(paths);
        }
예제 #31
0
파일: cmdRTx.cs 프로젝트: 15831944/EM
        SetPointBySlopeFromRef3dPoly()
        {
            ObjectId idPoly    = ObjectId.Null;
            Point3d  pnt3dPick = Pub.pnt3dO;
            Dictionary <double, ObjectId> basePnts = new Dictionary <double, ObjectId>();

            double station = 0.0;

            try
            {
                gp.poly3dRF = (Polyline3d)Select.selectEntity(typeof(Polyline3d), "\nSelect Breakline (3dPolyline): ", "Breakline selection failed.  Exiting...", out pnt3dPick);
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdRTx.cs: line: 28");
            }

            gp.vertex = pnt3dPick.getVertexNo(gp.poly3dRF.ObjectId);

            string ResultRTr = Grading_Palette.gPalette.pGrading.cmdRTr_Default;

            if (ResultRTr == string.Empty)
            {
                ResultRTr = "R";
            }

            double deltaZ = double.Parse(Dict.getCmdDefault("cmdRTr", "DeltaZ").ToString());
            double grade  = Pub.Slope;

            object mode = SnapMode.getOSnap();

            SnapMode.setOSnap(513); //endpoint + nearest

            try
            {
                do
                {
                    List <ObjectId> idPnts = new List <ObjectId>();

                    bool escape = false;

                    gp.pnt3dT = Grading_GetPointTracking.getPoint("Select Target Location: ", "cmdRTR");


                    if (!gp.inBounds)
                    {
                        continue;
                    }

                    if (gp.pnt3dT != Pub.pnt3dO)
                    {
                        string prompt = string.Format("\nZ value difference / Rate of grade /Both <{0}>:[Z/R/B]", ResultRTr);
                        escape = UserInput.getUserInputKeyword(ResultRTr.ToUpper(), out ResultRTr, prompt, "Z R B");
                        if (escape)
                        {
                            break;
                        }

                        double elevTAR = 0;
                        switch (ResultRTr.ToUpper())
                        {
                        case "R":
                            escape = UserInput.getUserInput("\nRate of Grade: ", out grade, grade);
                            if (escape)
                            {
                                break;
                            }
                            Pub.Slope = grade;
                            gp.pnt3dX = gc.calcBasePntAndTargetPntElev(gp.pnt3dT, grade, gp.poly3dRF, gp.vertex, out elevTAR, out station);
                            if (gp.pnt3dX == Pub.pnt3dO && !gp.shift)
                            {
                                Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowAlertDialog("Point Selected is out of bounds of selected segment. Exiting...");
                                continue;
                            }

                            gp.pnt3dT = new Point3d(gp.pnt3dT.X, gp.pnt3dT.Y, elevTAR);
                            break;

                        case "Z":
                            deltaZ = Pub.dZ;
                            escape = UserInput.getUserInput("Z Value Difference", out deltaZ, deltaZ);
                            if (escape)
                            {
                                break;
                            }
                            Pub.dZ    = deltaZ;
                            gp.pnt3dX = gc.calcBasePntAndTargetPntElev(gp.pnt3dT, 0.0, gp.poly3dRF, gp.vertex, out elevTAR, out station);
                            if (gp.pnt3dX == Pub.pnt3dO && !gp.shift)
                            {
                                Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowAlertDialog("Point Selected is out of bounds of selected segment.");
                                break;
                            }

                            gp.pnt3dT = new Point3d(gp.pnt3dT.X, gp.pnt3dT.Y, elevTAR + deltaZ);
                            break;

                        case "B":
                            escape = UserInput.getUserInput("\nRate of Grade: ", out grade, grade);
                            if (escape)
                            {
                                break;
                            }
                            Pub.Slope = grade;
                            escape    = UserInput.getUserInput("Z Value Difference", out deltaZ, deltaZ);
                            if (escape)
                            {
                                break;
                            }

                            gp.pnt3dX = gc.calcBasePntAndTargetPntElev(gp.pnt3dT, grade, gp.poly3dRF, gp.vertex, out elevTAR, out station);
                            if (gp.pnt3dX == Pub.pnt3dO && !gp.shift)
                            {
                                Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowAlertDialog("Point Selected is out of bounds of selected segment.");
                                break;
                            }

                            gp.pnt3dT = new Point3d(gp.pnt3dT.X, gp.pnt3dT.Y, elevTAR + deltaZ);
                            break;
                        }

                        if (!escape)
                        {
                            uint     pntNum;
                            ObjectId idPntBase = ObjectId.Null;
                            if (basePnts.TryGetValue(station, out idPntBase))
                            {
                                idPnts.Add(idPntBase);
                            }
                            else
                            {
                                idPntBase = gp.pnt3dX.setPoint(out pntNum, "CPNT-ON");
                                basePnts.Add(station, idPntBase);
                                idPnts.Add(idPntBase);
                            }

                            idPnts.Add(gp.pnt3dT.setPoint(out pntNum, "CPNT-ON"));

                            if (ResultRTr != "B")
                            {
                                List <Handle> hPnts = new List <Handle>();
                                hPnts.Add(idPnts[0].getHandle());
                                hPnts.Add(idPnts[1].getHandle());
                                BrkLine.makeBreakline(apps.lnkBrks, "cmdRTR", out idPoly, idPnts);
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }while (1 < 2);

                Grading_Palette.gPalette.pGrading.cmdRTr_Default = ResultRTr;

                Dict.setCmdDefault("cmdRTr", "cmdDefault", ResultRTr);
                Dict.setCmdDefault("cmdRTr", "Slope", grade.ToString());
                Dict.setCmdDefault("cmdRTr", "DeltaZ", deltaZ.ToString());
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdRTx.cs: line: 157");
            }
            finally
            {
                SnapMode.setOSnap((int)mode);
            }
        }
예제 #32
0
 public Mesh(string meshType, double width, double height, double originX, double originY, double angle, SnapMode snapMode, Color color, int zIndex)
 {
     realWidth     = width;
     realHeight    = height;
     this.snapMode = snapMode;
     this.meshType = meshType;
     this.color    = new SolidColorBrush(color);
     rect.Fill     = this.color;
     this.zIndex   = zIndex;
     SetValue(Canvas.ZIndexProperty, this.zIndex);
     Angle        = angle;
     this.originX = originX;
     this.originY = originY;
 }
예제 #33
0
        selectPoint(string cmd, int osMode)
        {
            object mode = SnapMode.getOSnap();

            SnapMode.setOSnap(osMode);
            CogoPoint cogoPnt = null;

            Database db = BaseObjs._db;
            Editor   ed = BaseObjs._editor;

            Autodesk.AutoCAD.DatabaseServices.Entity ent = null;

            TypedValue[] tvs = new TypedValue[1];
            tvs.SetValue(new TypedValue((int)DxfCode.Start, "AECC_COGO_POINT"), 0);

            SelectionFilter       filter = new SelectionFilter(tvs);
            PromptSelectionResult psr    = null;

            PromptSelectionOptions pso = new PromptSelectionOptions();

            pso.MessageForAdding = string.Format("\nSelect {0} Point:", cmd);

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    try
                    {
                        psr = ed.GetSelection(filter);
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} Pnt.cs: line: 72", ex.Message));
                    }
                    if (psr.Status == PromptStatus.OK)
                    {
                        SelectionSet SS = psr.Value;

                        foreach (SelectedObject OBJ in SS)
                        {
                            if (OBJ != null)
                            {
                                ent = (Autodesk.AutoCAD.DatabaseServices.Entity)tr.GetObject(OBJ.ObjectId, OpenMode.ForRead);
                            }
                            if (ent != null)
                            {
                                if (ent.GetType().ToString() == "Autodesk.Civil.DatabaseServices.CogoPoint")
                                {
                                    cogoPnt = (CogoPoint)ent;
                                }
                            }
                        }
                    }
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(string.Format("{0} Pnt.cs: line: 92", ex.Message));
            }
            finally
            {
                SnapMode.setOSnap((int)mode);
            }
            return(cogoPnt);
        }
예제 #34
0
 public Point GetSnappedMouse(SnapMode snapMode = SnapMode.Normal)
 {
     var snapped = ToAbsolutePoint(GetSnappedPoint(mousePosition, snapMode));
     return new Point(snapped.X / GridCellWidth, snapped.Y / GridCellHeight);
 }
예제 #35
0
        BLO()
        {
            bool   escape;
            string ResultBLO = "I";
            string prompt    = string.Format("\nSelect Method (Interval distance/Number of points per segment) [I/N] <{0}>:", ResultBLO);

            escape = UserInput.getUserInputKeyword(ResultBLO.ToUpper(), out ResultBLO, prompt, "I N");
            if (escape)
            {
                return;
            }
            int          numPnts = 1;
            double       spacing = 10;
            PromptStatus ps;

            switch (ResultBLO)
            {
            case "I":
                escape = UserInput.getUserInput(string.Format("\nInterval Distance <{0}>", spacing), out spacing, spacing);
                if (escape)
                {
                    return;
                }
                break;

            case "N":
                ps = UserInput.getUserInputInt(string.Format("\nNumber of Points: <{0}>", numPnts), true, false, false, false, true, numPnts, out numPnts);
                if (ps != PromptStatus.OK)
                {
                    return;
                }
                break;
            }

            double deltaZ = 0.50;

            escape = UserInput.getUserInput(string.Format("\nElevation Offset <{0}>", deltaZ), out deltaZ, deltaZ);
            if (escape)
            {
                return;
            }

            double deltaXY = 2.00;

            escape = UserInput.getUserInput(string.Format("\nHorizontal Offset <{0}>", deltaXY), out deltaXY, deltaXY);
            if (escape)
            {
                return;
            }

            bool answer;

            ps = UserInput.getUserInputYesNo("\nAdjust Corner Points", true, out answer);
            if (ps != PromptStatus.OK)
            {
                return;
            }

            SnapMode.setOSnap(8);

            List <ObjectId> ids = new List <ObjectId>();
            ObjectId        id  = ObjectId.Null;

            prompt = "";

            Point3d pnt3dBase = Pub.pnt3dO;
            Point3d pnt3dLast = Pub.pnt3dO;

            bool proceed = true;

            do
            {
                if (ids.Count == 0)
                {
                    prompt = "\nSelect First Point: ";
                }
                else if (ResultBLO == "N")
                {
                    prompt    = "\nSelect Second Point: ";
                    pnt3dBase = pnt3dLast;
                }
                else
                {
                    prompt = "\nSelect Next Point: ";
                }

                string resElev1 = UserInput.getCogoPoint(prompt, out id, Pub.pnt3dO, osMode: 8);
                if (resElev1 == string.Empty)
                {
                    proceed = false;
                }
                else
                {
                    pnt3dLast = id.getCogoPntCoordinates();
                    ids.Add(id);
                }

                if (ResultBLO == "N")
                {
                    if (ids.Count == 2)
                    {
                        proceed = false;
                    }
                }
            }while (proceed);

            if (ids.Count < 2)
            {
                return;
            }

            Point3d pnt3d1 = Pub.pnt3dO;
            Point3d pnt3d2 = Pub.pnt3dO;
            int     k      = 0;

            k = ids.Count;

            List <POI> vPOIs = new List <POI>();

            for (int i = 1; i < k; i++)
            {
                pnt3d1 = ids[i - 1].getCogoPntCoordinates();
                pnt3d2 = ids[i - 0].getCogoPntCoordinates();

                double dist  = pnt3d1.getDistance(pnt3d2);
                double slope = (gp.pnt3d2.Z - gp.pnt3d1.Z) / dist;

                double remain = dist - (spacing * System.Math.Truncate(dist / spacing));

                if (remain > 0.0001)
                {
                    numPnts = (int)System.Math.Truncate(dist / spacing);
                }
                else
                {
                    numPnts = (int)System.Math.Truncate(dist / spacing) - 1;
                }
            }
        }
예제 #36
0
파일: cmdSPG.cs 프로젝트: 15831944/EM
        SPG(string nameCmd)
        {
            gp.pnt3d1 = Pub.pnt3dO;
            gp.pnt3d2 = Pub.pnt3dO;
            PromptStatus ps    = PromptStatus.Cancel;
            string       desc1 = "";
            string       desc2 = "";
            bool         escape;
            object       mode = SnapMode.getOSnap();

            try
            {
                Point3d  pnt3d1   = Pub.pnt3dO;
                ObjectId idCgPnt1 = CgPnt.selectCogoPointByNode("\nSelect FIRST point-node: ", ref pnt3d1, out escape, out ps, osMode: 8);
                if (ps == PromptStatus.Cancel)
                {
                    return;
                }
                desc1     = idCgPnt1.getCogoPntDesc();
                gp.pnt3d1 = pnt3d1;

                Point3d  pnt3d2   = Pub.pnt3dO;
                ObjectId idCgPnt2 = CgPnt.selectCogoPointByNode("\nSelect SECOND point-node: ", ref pnt3d2, out escape, out ps, osMode: 8);
                if (ps == PromptStatus.Cancel)
                {
                    return;
                }
                desc2     = idCgPnt2.getCogoPntDesc();
                gp.pnt3d2 = pnt3d2;

                SnapMode.setOSnap(1);

                do
                {
                    gp.pnt3dX = Pub.pnt3dO;
                    gp.pnt3dT = Pub.pnt3dO;

                    gp.pnt3dT = gPnt.getPoint("\nSelect Target location or press Enter to exit: ", nameCmd);
                    if (gp.pnt3dT == Pub.pnt3dO)
                    {
                        return;
                    }

                    gp.pnt3dX = gc.calcBasePnt3d(gp.pnt3dT, gp.pnt3d1, gp.pnt3d2);
                    if (gp.pnt3dX == Pub.pnt3dO)
                    {
                        return;
                    }

                    uint pntNum;
                    CgPnt.setPoint(gp.pnt3dX, out pntNum, desc1);
                }while (1 < 2);
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdSPG.cs: line: 63");
            }
            finally
            {
                SnapMode.setOSnap((int)mode);
            }
        }
예제 #37
0
        protected bool TrySnapToSurface(SnapMode snapMode)
        {
            if (m_closestHitDistSq < float.MaxValue)
            {
                Vector3 newDragPointPosition = m_hitPos;

                //bool isAnyStatic = AnyCopiedGridIsStatic;
                //if (isAnyStatic)
                //{
                //    m_pasteDirForward = Vector3.Forward;
                //    m_pasteDirUp = Vector3.Up;
                //}
                //else if (m_hitNormal.Length() > 0.5)
                //{
                if (m_hitNormal.Length() > 0.5) 
                { 
                    //if (snapMode == MyGridPlacementSettings.SnapMode.OneFreeAxis)
                    //{
                    //    m_pasteDirUp = m_hitNormal;

                    //    float dotUp = m_pasteDirUp.Dot(m_hitEntity.WorldMatrix.Up);
                    //    float dotFwd = m_pasteDirUp.Dot(m_hitEntity.WorldMatrix.Forward);
                    //    float dotRt = m_pasteDirUp.Dot(m_hitEntity.WorldMatrix.Right);
                    //    if (Math.Abs(dotUp) > Math.Abs(dotFwd))
                    //    {
                    //        if (Math.Abs(dotUp) > Math.Abs(dotRt))
                    //        {
                    //            m_pasteDirForward = Vector3.Normalize(m_hitEntity.WorldMatrix.Right - (dotRt * m_pasteDirUp));
                    //        }
                    //        else
                    //        {
                    //            m_pasteDirForward = Vector3.Normalize(m_hitEntity.WorldMatrix.Forward - (dotFwd * m_pasteDirUp));
                    //        }
                    //    }
                    //    else
                    //    {
                    //        if (Math.Abs(dotFwd) > Math.Abs(dotRt))
                    //        {
                    //            m_pasteDirForward = Vector3.Normalize(m_hitEntity.WorldMatrix.Up - (dotUp * m_pasteDirUp));
                    //        }
                    //        else
                    //        {
                    //            m_pasteDirForward = Vector3.Normalize(m_hitEntity.WorldMatrix.Forward - (dotFwd * m_pasteDirUp));
                    //        }
                    //    }
                    //}
                    //else if (snapMode == MyGridPlacementSettings.SnapMode.Base6Directions)
                    {
                        var hitGrid = m_hitEntity as MyCubeGrid;
                        if (hitGrid != null)
                        {
                            Matrix hitGridRotation = hitGrid.WorldMatrix.GetOrientation();
                            Matrix firstRotation = GetFirstGridOrientationMatrix();
                            Matrix newFirstRotation = Matrix.AlignRotationToAxes(ref firstRotation, ref hitGridRotation);
                            Matrix rotationDelta = Matrix.Invert(firstRotation) * newFirstRotation;

                            m_pasteDirForward = newFirstRotation.Forward;
                            m_pasteDirUp = newFirstRotation.Up;
                            m_pasteOrientationAngle = 0.0f;
                        }
                    }
                }

                Matrix newOrientation = GetFirstGridOrientationMatrix();
                Vector3 globalCenterDelta = Vector3.TransformNormal(m_dragPointToPositionLocal, newOrientation);

                m_pastePosition = newDragPointPosition + globalCenterDelta;

                if (MyDebugDrawSettings.DEBUG_DRAW_COPY_PASTE)
                {
                    MyRenderProxy.DebugDrawSphere(newDragPointPosition, 0.08f, Color.Red.ToVector3(), 1.0f, false);
                    MyRenderProxy.DebugDrawSphere(m_pastePosition, 0.08f, Color.Red.ToVector3(), 1.0f, false);
                }

                IsSnapped = true;
                return true;
            }
            IsSnapped = false;
            return false;
        }
예제 #38
0
        public Point GetSnappedPoint(Point point, SnapMode snapMode = SnapMode.Normal)
        {
            var absolutePoint = ToAbsolutePoint(point);
            var absoluteX = absolutePoint.X;
            var absoluteY = absolutePoint.Y;

            var closestGridX = 0;
            var closestGridY = 0;
            switch (snapMode)
            {
                case SnapMode.Normal:
                    closestGridX = absoluteX - (absoluteX % GridCellWidth) - (absoluteX < 0 ? GridCellWidth : 0);
                    closestGridY = absoluteY - (absoluteY % GridCellHeight) - (absoluteY < 0 ? GridCellHeight : 0);
                    break;
                case SnapMode.Half:
                    var halfCellWidth = GridCellWidth / 2;
                    var halfCellHeight = GridCellHeight / 2;
                    closestGridX = absoluteX - (absoluteX % halfCellWidth) - (absoluteX < 0 ? halfCellWidth : 0);
                    closestGridY = absoluteY - (absoluteY % halfCellHeight) - (absoluteY < 0 ? halfCellHeight : 0);
                    break;
            }
            return ToRelativePoint(new Point(closestGridX, closestGridY));
        }