Example #1
0
        /// <summary>
        ///     Prompts a user to select a point inside SmartPlant Review.
        ///     Retrieves the physical point selected on screen.
        /// </summary>
        /// <param name="prompt">The prompt string to be displayed in the application text window.</param>
        /// <returns>SprPoint3D representing the selected point.</returns>
        public SprPoint3D GetPoint(string prompt)
        {
            if (!IsConnected)
                throw SprExceptions.SprNotConnected;

            var returnPoint = new SprPoint3D();
            int abortFlag;

            Activate();

            // Prompt the user for a 3D point inside SPR
            SprStatus = DrApi.PointLocateDbl(prompt, out abortFlag, ref returnPoint.DrPointDbl);
            if (SprStatus != 0)
                throw SprException;

            // Return null if the locate operation was aborted
            return abortFlag != 0 ? returnPoint : null;
        }
Example #2
0
        /// <summary>
        ///     Prompts a user to select a point inside SmartPlant Review.
        ///     Retrieves the physical point selected on screen.
        /// </summary>
        /// <param name="prompt">The prompt string to be displayed in the application text window.</param>
        /// <param name="targetPoint">The point used to calculate depth.</param>
        /// <returns></returns>
        public SprPoint3D GetPoint(string prompt, SprPoint3D targetPoint)
        {
            if (!IsConnected)
                throw SprExceptions.SprNotConnected;

            var returnPoint = new SprPoint3D();
            int abort;
            int objId;
            const int flag = 0;

            Activate();

            // Prompt the user for a 3D point inside SPR
            SprStatus = DrApi.PointLocateExtendedDbl(prompt, out abort, ref returnPoint.DrPointDbl,
                                                         ref targetPoint.DrPointDbl, out objId, flag);
            if (SprStatus != 0)
                throw SprException;

            // Return null if the locate operation was aborted
            if (abort == 0)
                return returnPoint;
            return null;
            //return abort != 0 ? returnPoint : null;
        }
Example #3
0
 /// <summary>
 ///     Prompts a user to select an object inside SmartPlant Review.
 ///     Retrieves the Object Id of the selected object.
 /// </summary>
 /// <param name="prompt">The prompt string to be displayed in the application text window.</param>
 /// <returns>Integer value representing the selected Object Id.</returns>
 public int GetObjectId(string prompt)
 {
     var pt = new SprPoint3D();
     return GetObjectId(prompt, ref pt);
 }
Example #4
0
        /// <summary>
        ///     Prompts a user to select an object inside SmartPlant Review.
        ///     Retrieves the Object Id of the selected object.
        /// </summary>
        /// <param name="prompt">The prompt string to be displayed in the application text window.</param>
        /// <param name="refPoint">The returned reference point representing the selected point.</param>
        /// <returns>Integer value representing the selected Object Id.</returns>
        public int GetObjectId(string prompt, ref SprPoint3D refPoint)
        {
            if (!IsConnected)
                throw SprExceptions.SprNotConnected;

            const int filterFlag = 0;
            var returnId = -1;

            Activate();

            // Prompt the user for a 3D point inside SPR
            SprStatus = DrApi.ObjectLocateDbl(prompt, filterFlag, out returnId, ref refPoint.DrPointDbl);
            if (SprStatus != 0)
                throw SprException;

            return returnId;
        }
Example #5
0
        public void SetEyePoint(SprPoint3D eyePoint)
        {
            if (!IsConnected)
                throw SprExceptions.SprNotConnected;

            // Create the DrViewDbl
            dynamic objViewdataDbl = Activator.CreateInstance(SprImportedTypes.DrViewDbl);

            // Set the view object as the SPR Application main view
            SprStatus = DrApi.ViewGetDbl(0, ref objViewdataDbl);
            if (SprStatus != 0)
                throw SprException;

            // Apply the updated eyepoint
            objViewdataDbl.EyeUorPoint = eyePoint.DrPointDbl;

            // Update the main view in SPR
            SprStatus = DrApi.ViewSetDbl(0, ref objViewdataDbl);
            if (SprStatus != 0)
                throw SprException;
        }
Example #6
0
        /// <summary>
        ///     Toggles annotation display in the SmartPlant Review application main window.
        /// </summary>
        /// <param name="visible">Determines the annotation visibility state.</param>
        //public void Annotations_Display(bool visible)
        //{
        //    // Throw an expection if not connected
        //    if (!IsConnected) throw SprExceptions.SprNotConnected;
        //    // Create the params
        //    var visValue = Convert.ToInt32(visible);
        //    // Create the view object
        //    dynamic objViewdataDbl = Activator.CreateInstance(SprImportedTypes.DrViewDbl);
        //    // Throw an exception if the DrViewDbl is null
        //    if (objViewdataDbl == null) throw SprExceptions.SprObjectCreateFail;
        //    // Set the view object as the SPR Application main view
        //    SprStatus = DrApi.ViewGetDbl(0, ref objViewdataDbl);
        //    // Apply the updated annotation display
        //    objViewdataDbl.AllAnnotationsDisplay = visValue;
        //    // Update the global annotation visibility properties
        //    SprStatus = DrApi.GlobalOptionsSet(SprConstants.SprGlobalAnnoDisplay, visValue);
        //    SprStatus = DrApi.GlobalOptionsSet(SprConstants.SprGlobalAnnoTextDisplay, visValue);
        //    SprStatus = DrApi.GlobalOptionsSet(SprConstants.SprGlobalAnnoDataDisplay, visValue);
        //    // Update the main view in SPR
        //    SprStatus = DrApi.ViewSetDbl(0, ref objViewdataDbl);
        //}
        /// <summary>
        ///     Creates a new data field in the Mdb text_annotations table.
        ///     Returns true if the field already exists.
        /// </summary>
        /// <param name="fieldName">The string name of the field to be added.  Spaces in the field name are replaced.</param>
        /// <returns>Indicates the success or failure of the table modification.</returns>
        //public bool Annotations_AddDataField(string fieldName)
        //{
        //    // Throw an exception if not connected
        //    if (!IsConnected) throw SprExceptions.SprNotConnected;
        //    // Add the tag field to the MDB database
        //    return DbMethods.AddDbField(MdbPath, "text_annotations", fieldName);
        //}
        /// <summary>
        ///     Prompts a user to place a new annotation in the SmartPlant Review main view.
        /// </summary>
        /// <param name="anno">Reference SprAnnotation containing the annotation information.</param>
        public void Annotations_Place(ref SprAnnotation anno)
        {
            // Throw exception if not connected
            if (!IsConnected) throw SprExceptions.SprNotConnected;

            // Create the leader point
            var leaderPoint = new SprPoint3D();

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

            // Exit if the object selection failed/canceled
            if (objId == 0)
            {
                Windows.TextWindow.Text = "Annotation placement canceled.";
                return;
            }

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

            // Exit if the centerpoint selection failed/canceled
            if (centerPoint == null)
            {
                Windows.TextWindow.Text = "Annotation placement canceled.";
                return;
            }

            // Create a reference to the DrAnnotation
            var drAnno = anno.DrAnnotationDbl;

            // Set the annotation points
            drAnno.LeaderPoint = leaderPoint.DrPointDbl;
            drAnno.CenterPoint = centerPoint.DrPointDbl;

            // Place the annotation on screen
            int annoId;
            SprStatus = DrApi.AnnotationCreateDbl(anno.Type, ref drAnno, out annoId);
            if (SprStatus != 0)
                throw SprException;

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

            // 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
            Windows.TextWindow.Title = string.Format("Annotation {0}", anno.Id);
            Windows.TextWindow.Text = anno.Text;

            // Update the main view
            SprStatus = DrApi.ViewUpdate(1);
            if (SprStatus != 0)
                throw SprException;
        }
Example #7
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 #8
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 #9
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 #10
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;
        }
Example #11
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);
        }