Example #1
0
        /// <summary>
        ///     Prompts a user to select new leader points for an existing annotation.
        ///     DisplayLeader will automatically be set to true.
        /// </summary>
        ///TODO
        public void EditLeader()
        {
            if (!Application.IsConnected)
            {
                throw SprExceptions.SprNotConnected;
            }

            if (!IsPlaced)
            {
                throw new SprException("Annotation {0} is not placed.", Id);
            }

            var annoOrigin = new SprPoint3D();

            // Get an object on screen and set the origin point to its location
            var objId = Application.GetObjectId("SELECT NEW ANNOTATION START POINT", ref annoOrigin);

            if (objId == 0)
            {
                Application.Windows.TextWindow.Text = "Annotation placement canceled.";
                return;
            }

            // Get the annotation leader point on screen
            var annoLeader = Application.GetPoint("SELECT NEW LEADER LOCATION", annoOrigin);

            if (annoLeader == null)
            {
                Application.Windows.TextWindow.Text = "Tag placement canceled.";
                return;
            }

            var curObject = Application.GetObjectData(objId);

            DisplayLeader = true;
            Flags        |= SprConstants.SprTagLabel;
            Flags        |= SprConstants.SprTagEdit;

            // Update the tag with the new leader points
            Application.SprStatus = Application.DrApi.TagSetDbl(Id, 0, Flags, annoLeader.DrPointDbl,
                                                                annoOrigin.DrPointDbl, curObject.Linkage.DrKey, Text);
            if (Application.SprStatus != 0)
            {
                throw Application.SprException;
            }

            //Refresh();

            //// Flip the tag 180 degrees.  Intergraph is AWESOME!
            //var swap = LeaderPoint;
            //LeaderPoint = OriginPoint;
            //OriginPoint = swap;

            Update();

            SendToTextWindow();
            //Application.SprStatus = Application.DrApi.ViewUpdate(1);
            //Application.Run(SprNativeMethods.ViewUpdate, 1);
        }
Example #2
0
        private void SetOriginPoint(SprPoint3D newpoint)
        {
            if (!IsPlaced)
            {
                throw SprExceptions.SprTagNotPlaced;
            }

            _originPoint        = newpoint;
            Row["tag_origin_x"] = newpoint.East;
            Row["tag_origin_y"] = newpoint.North;
            Row["tag_origin_z"] = newpoint.Elevation;
        }
Example #3
0
        /// <summary>
        ///     Prompts a user to place the current tag.
        /// </summary>
        public void Place()
        {
            if (!Application.IsConnected)
            {
                throw SprExceptions.SprNotConnected;
            }

            if (IsPlaced)
            {
                throw new SprException("Tag {0} is already placed", Id);
            }

            var tagOrigin = new SprPoint3D();

            // Get an object on screen and set the origin point to its location
            Application.HighlightClear();
            var objId = Application.GetObjectId("SELECT TAG START POINT", ref tagOrigin);

            if (objId == 0)
            {
                Application.Windows.TextWindow.Text = "Tag placement canceled.";
                return;
            }

            // Highlight the selected object
            Application.HighlightObject(objId, Color.Fuchsia);

            // Get the tag leader point using the origin for depth
            var tagLeader = Application.GetPoint("SELECT TAG LEADER LOCATION", tagOrigin);

            if (tagLeader == null)
            {
                Application.HighlightClear();
                Application.Windows.TextWindow.Text = "Tag placement canceled.";
                return;
            }

            _linkedObject = Application.GetObjectData(objId);

            Flags |= SprConstants.SprTagLabel;
            Id     = Application.NextTag;

            // Set the tag registry values
            SprUtilities.SetTagRegistry(this);

            // Place the tag
            Application.SprStatus = Application.DrApi.TagSetDbl(Id, 0, Flags, ref tagLeader.DrPointDbl,
                                                                ref tagOrigin.DrPointDbl, LinkedObject.Linkage.DrKey, Text);
            if (Application.SprStatus != 0)
            {
                throw Application.SprException;
            }

            //IsPlaced = true;
            _leaderPoint = tagLeader;
            _originPoint = tagOrigin;

            Application.Tags.Add(this);
            Refresh();

            // Clear the tag registry
            SprUtilities.ClearTagRegistry();

            SendToTextWindow();

            Application.HighlightClear();
            Application.SprStatus = Application.DrApi.ViewUpdate(1);
            if (Application.SprStatus != 0)
            {
                throw Application.SprException;
            }
        }
Example #4
0
        /// <summary>
        ///     Prompts a user to select new leader points for an existing tag.
        ///     DisplayLeader will automatically be set to true.
        /// </summary>
        public void EditLeader()
        {
            if (!Application.IsConnected)
            {
                throw SprExceptions.SprNotConnected;
            }

            if (!IsPlaced)
            {
                throw new SprException("Tag {0} is not placed.", Id);
            }

            var tagOrigin = new SprPoint3D();

            // Get an object on screen and set the origin point to its location
            Application.HighlightClear();
            var objId = Application.GetObjectId("SELECT NEW TAG START POINT", ref tagOrigin);

            if (objId == 0)
            {
                Application.Windows.TextWindow.Text = "Tag placement canceled.";
                return;
            }

            // Highlight the selected object
            Application.HighlightObject(objId, Color.Fuchsia);

            // Get the tag leader point on screen
            var tagLeader = Application.GetPoint("SELECT NEW LEADER LOCATION", tagOrigin);

            if (tagLeader == null)
            {
                Application.HighlightClear();
                Application.Windows.TextWindow.Text = "Tag placement canceled.";
                return;
            }

            _linkedObject = Application.GetObjectData(objId);

            DisplayLeader = true;
            Flags        |= SprConstants.SprTagLabel;
            Flags        |= SprConstants.SprTagEdit;

            // Update the tag with the new leader points
            Application.SprStatus = Application.DrApi.TagSetDbl(Id, 0, Flags, tagLeader.DrPointDbl,
                                                                tagOrigin.DrPointDbl, LinkedObject.Linkage.DrKey, Text);
            if (Application.SprStatus != 0)
            {
                throw Application.SprException;
            }

            Refresh();

            // Flip the tag 180 degrees.  Intergraph is AWESOME!
            var swap = LeaderPoint;

            LeaderPoint = OriginPoint;
            OriginPoint = swap;

            Update();

            SendToTextWindow();
            Application.HighlightClear();

            Application.SprStatus = Application.DrApi.ViewUpdate(1);
            if (Application.SprStatus != 0)
            {
                throw Application.SprException;
            }
        }
Example #5
0
        /// <summary>
        ///     Prompts a user to place the current annotation.
        /// </summary>
        /// TODO
        public void Place()
        {
            if (!Application.IsConnected)
            {
                throw SprExceptions.SprNotConnected;
            }

            if (IsPlaced)
            {
                throw new SprException("Annotation {0} is already placed", Id);
            }

            var leaderPoint = new SprPoint3D();

            // Get the annotation leader point
            int objId = Application.GetObjectId("SELECT A POINT ON AN OBJECT TO LOCATE THE ANNOTATION", ref leaderPoint);

            if (objId == 0)
            {
                Application.Windows.TextWindow.Text = "Annotation placement canceled.";
                return;
            }

            // Get the annotation center point using the leaderpoint for depth calculation
            var centerPoint = Application.GetPoint("SELECT THE CENTER POINT FOR THE ANNOTATION LABEL", leaderPoint);

            if (centerPoint == null)
            {
                Application.Windows.TextWindow.Text = "Annotation placement canceled.";
                return;
            }

            // Set the annotation points
            LeaderPoint = leaderPoint;
            CenterPoint = centerPoint;

            // Place the annotation on screen
            var annoId = 0;

            //Application.SprStatus = Application.DrApi.AnnotationCreateDbl(Type, ref DrAnnotationDbl, out annoId);

            // Link the located object to the annotation
            //SprStatus = DrApi.AnnotationDataSet(annoId, anno.Type, ref drAnno, ref objId);

            Refresh();
            // Retrieve the placed annotation data
            //anno = Annotations_Get(anno.Id);

            // Add an ObjectId field
            //Annotations_AddDataField("object_id");

            // Save the ObjectId to the annotation data
            //anno.Data["object_id"] = objId;

            // Update the annotation
            //Annotations_Update(anno);

            // Update the text window
            Application.Windows.TextWindow.Title = string.Format("Annotation {0}", Id);
            Application.Windows.TextWindow.Text  = Text;

            // Update the main view
            Application.SprStatus = Application.DrApi.ViewUpdate(1);
            if (Application.SprStatus != 0)
            {
                throw Application.SprException;
            }
        }