/// <summary> /// Updates annotation data directly in the Mdb text_annotations table. /// </summary> /// <param name="anno">SprAnnotation containing the annotation information.</param> /// <returns>Indicates the success or failure of the text_annotations modification.</returns> public bool Annotations_Update(SprAnnotation anno) { // Throw an exception if not connected //if (!IsConnected)throw SprExceptions.SprNotConnected; // Retrieve the site table var annoTable = DbMethods.GetDbTable(MdbPath, "text_annotations"); // Return false if the table is null if (annoTable == null) return false; // Return false if no tags exist if (annoTable.Rows.Count == 0) return false; // Create the row filter for the specified tag var rowFilter = string.Format("id = {0}", anno.Id); var tblFilter = annoTable.Select(rowFilter); // Iterate through each dictionary key/value pair foreach (var kvp in anno.Data) // Set the values for the selected tag tblFilter[0][kvp.Key] = kvp.Value; // Return the result of the table update //return DbMethods.UpdateDbTable(MdbPath, annoTable, rowFilter); return false; }
/// <summary> /// Prompts a user to select an annotation in the SmartPlant Review main view. /// </summary> /// <param name="type">The string type of the annotation to be selected.</param> /// <returns>SprAnnotation containing the selected annotation information.</returns> public SprAnnotation Annotations_Select(string type) { // Throw an exception if not connected if (!IsConnected) throw SprExceptions.SprNotConnected; // Create the params int annoId; // Create the return annotation object var anno = new SprAnnotation(); // Set the SPR application visible Activate(); // Prompt the user to select the annotation var msg = string.Format("SELECT THE DESIRED {0} ANNOTATION", type.ToUpper()); SprStatus = DrApi.AnnotationLocate(type, msg, 0, out annoId); if (SprStatus != 0) throw SprException; // Return null if the annotation locate failed if (annoId == 0) return null; // Set the annotation ID //anno.Id = annoId; // Get the associated object ID int assocId; var drAnno = anno.DrAnnotationDbl; SprStatus = DrApi.AnnotationDataGet(annoId, type, ref drAnno, out assocId); if (SprStatus != 0) throw SprException; // Return null if the associated object id is zero if (assocId == 0) return null; // Set the assiciated object //anno.AssociatedObject = GetObjectData(assocId); // Return the completed annotation return anno; }
/// <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; }
/// <summary> /// Retrieves the desired annotation from the Mdb text_annotations table. /// </summary> /// <param name="annoId">Unique Id of the annotation to retrieve.</param> /// <returns>SprAnnotation containing the retirned annotation information.</returns> public SprAnnotation Annotations_Get(int annoId) { // Throw an exception if not connected //if (!IsConnected) throw SprExceptions.SprNotConnected; // Create the new tag var anno = new SprAnnotation(); // Retrieve the site table var annoTable = DbMethods.GetDbTable(MdbPath, "text_annotations"); // Return null if the table retrieval failed if (annoTable == null) return null; // Return null if no annotations exist if (annoTable.Rows.Count == 0) return null; // Create the row filter for the desired tag var rowFilter = annoTable.Select(string.Format("id = '{0}'", annoId)); // Throw an exception if the annotation was not found if (rowFilter.Length == 0) throw SprExceptions.SprAnnotationNotFound; // Iterate through each column foreach (DataColumn col in annoTable.Columns) { // Add the key/value from the first filtered row to the dictionary anno.Data[col.ColumnName] = rowFilter[0][col]; } // Set the tag as placed anno.IsPlaced = true; // Return the tag return anno; }
public void Annotations_EditLeader(ref SprAnnotation annotation) { }
/// <summary> /// Adds an annotation directly into the Mdb annotation table. /// </summary> /// <param name="anno">SprAnnotation containing the annotation information.</param> public void Annotations_Add(SprAnnotation anno) { throw new NotImplementedException(); }