/// <summary> /// AddTextAnnot adds a text annotation to the annotation manager. /// </summary> /// <param name="leftPixels">The left coordinate of the annotation (pixels).</param> /// <param name="topPixels">The top coordinate of the annotation (pixels).</param> /// <param name="widthPixels">The width of the annotation (pixels).</param> /// <param name="heightPixels">The height of the annotation (pixels).</param> /// <param name="text">The text.</param> /// <param name="italic">The italic flag.</param> /// <param name="underline">The underline flag.</param> /// <param name="fontName">The font name.</param> /// <param name="rotation">The rotation of the annotation in the range [0;360] (degrees, clockwise). </param> public void AddTextAnnot(int leftPixels, int topPixels, int widthPixels, int heightPixels, string text, bool italic, bool underline, string fontName, int rotation) { if (_textWriter != null) { _textWriter.WriteLine("AddTextAnnot"); _textWriter.WriteLine("leftPixels: " + leftPixels + " topPixels: " + topPixels + " widthPixels: " + widthPixels + " heightPixels: " + heightPixels); _textWriter.WriteLine("text: " + text); _textWriter.WriteLine("italic: " + italic + " underline: " + underline + " fontName: " + fontName + " rotation: " + rotation); } AnnotationText annotationText = _annotationManager.AddTextAnnot(ToInchesHorizontal(leftPixels), ToInchesVertical(topPixels), ToInchesHorizontal(widthPixels), ToInchesVertical(heightPixels), text); GdPictureStatus status = _annotationManager.GetStat(); if (status != GdPictureStatus.OK) { LastError = status; } annotationText.Rotation = rotation; annotationText.FontName = fontName; annotationText.FontStyle = FontStyle.Regular; if (italic) { annotationText.FontStyle |= FontStyle.Italic; } if (underline) { annotationText.FontStyle |= FontStyle.Underline; } }
protected override MutableObject Mutate(MutableObject mutable) { foreach (var entry in AnnotationText.GetEntries(mutable)) { var annotationString = AnnotationText.GetValue(entry); var stringParts = annotationString.Split(' '); if (stringParts[0].ToLower().CompareTo("allocate") != 0) { Debug.Log("The string " + annotationString + " isn't an allocate!"); AddressTarget.SetValue((uint)0, entry); SizeTarget.SetValue(1, entry); continue; } SizeTarget.SetValue(int.Parse(stringParts[1]), entry); try { AddressTarget.SetValue(uint.Parse(stringParts[4].Split('x')[1], System.Globalization.NumberStyles.HexNumber), entry); } catch { Debug.Log("What?"); } } return(mutable); }
/// <summary> /// Returns true if ResponseInstruction instances are equal /// </summary> /// <param name="input">Instance of ResponseInstruction to be compared</param> /// <returns>Boolean</returns> public bool Equals(ResponseInstruction input) { if (input == null) { return(false); } return (( Text == input.Text || (Text != null && Text.Equals(input.Text)) ) && ( StreetName == input.StreetName || (StreetName != null && StreetName.Equals(input.StreetName)) ) && ( Distance == input.Distance || (Distance != null && Distance.Equals(input.Distance)) ) && ( Time == input.Time || (Time != null && Time.Equals(input.Time)) ) && ( Interval == input.Interval || Interval != null && Interval.SequenceEqual(input.Interval) ) && ( Sign == input.Sign || (Sign != null && Sign.Equals(input.Sign)) ) && ( AnnotationText == input.AnnotationText || (AnnotationText != null && AnnotationText.Equals(input.AnnotationText)) ) && ( AnnotationImportance == input.AnnotationImportance || (AnnotationImportance != null && AnnotationImportance.Equals(input.AnnotationImportance)) ) && ( ExitNumber == input.ExitNumber || (ExitNumber != null && ExitNumber.Equals(input.ExitNumber)) ) && ( TurnAngle == input.TurnAngle || (TurnAngle != null && TurnAngle.Equals(input.TurnAngle)) )); }
public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = 41; if (AnnotationPosition != null) { hashCode = hashCode * 59 + AnnotationPosition.GetHashCode(); } if (AnnotationTail != null) { hashCode = hashCode * 59 + AnnotationTail.GetHashCode(); } if (AnnotationText != null) { hashCode = hashCode * 59 + AnnotationText.GetHashCode(); } if (AxisTitleText != null) { hashCode = hashCode * 59 + AxisTitleText.GetHashCode(); } if (ColorbarPosition != null) { hashCode = hashCode * 59 + ColorbarPosition.GetHashCode(); } if (ColorbarTitleText != null) { hashCode = hashCode * 59 + ColorbarTitleText.GetHashCode(); } if (LegendPosition != null) { hashCode = hashCode * 59 + LegendPosition.GetHashCode(); } if (LegendText != null) { hashCode = hashCode * 59 + LegendText.GetHashCode(); } if (ShapePosition != null) { hashCode = hashCode * 59 + ShapePosition.GetHashCode(); } if (TitleText != null) { hashCode = hashCode * 59 + TitleText.GetHashCode(); } return(hashCode); } }
protected override void OnProcessOutputSchema(MutableObject newSchema) { foreach (var entry in AnnotationText.GetEntries(newSchema)) { AddressTarget.SetValue((uint)0, entry); } Router.TransmitAllSchema(newSchema); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; if (Text != null) { hashCode = hashCode * 59 + Text.GetHashCode(); } if (StreetName != null) { hashCode = hashCode * 59 + StreetName.GetHashCode(); } if (Distance != null) { hashCode = hashCode * 59 + Distance.GetHashCode(); } if (Time != null) { hashCode = hashCode * 59 + Time.GetHashCode(); } if (Interval != null) { hashCode = hashCode * 59 + Interval.GetHashCode(); } if (Sign != null) { hashCode = hashCode * 59 + Sign.GetHashCode(); } if (AnnotationText != null) { hashCode = hashCode * 59 + AnnotationText.GetHashCode(); } if (AnnotationImportance != null) { hashCode = hashCode * 59 + AnnotationImportance.GetHashCode(); } if (ExitNumber != null) { hashCode = hashCode * 59 + ExitNumber.GetHashCode(); } if (TurnAngle != null) { hashCode = hashCode * 59 + TurnAngle.GetHashCode(); } return(hashCode); } }
AnnotationText CreateAnnotationText(XmlNode xmlAnnotation) { AnnotationText annotationText = new AnnotationText(); XmlNode xmlElements = null; XmlNodeList annotationChildNodeList = xmlAnnotation.ChildNodes; for (int w = 0; w < annotationChildNodeList.Count; w++) { xmlElements = annotationChildNodeList.Item(w); switch (xmlElements.Name) { case "value": //Debug.Log ("value: " + xmlElements.InnerText); if (xmlElements.InnerText.Length == 0) { return(null); } annotationText.TextValue = xmlElements.InnerText; break; case "formatting": //Debug.Log ("formatting: " + xmlElements.InnerText); XmlNodeList formattingChildNodes = xmlElements.ChildNodes; XmlNode xmlColor = formattingChildNodes.Item(0); FormattingText formattingText = new FormattingText(); int red = Int32.Parse(formattingChildNodes.Item(0).ChildNodes.Item(0).InnerText); int green = Int32.Parse(formattingChildNodes.Item(0).ChildNodes.Item(1).InnerText); int blue = Int32.Parse(formattingChildNodes.Item(0).ChildNodes.Item(2).InnerText); formattingText.Color = new Color32((byte)red, (byte)green, (byte)blue, 0); annotationText.FormattingText = formattingText; break; default: break; } } annotationText = (AnnotationText)AddAnnotationCommonFields(xmlAnnotation, annotationText); return(annotationText); }
/// <summary> /// Draw the annotation timestamp with custom parameters and custom content /// </summary> /// <param name="customActionEventArgs">The arguments received from the custom action handler</param> /// <param name="annotationManager">The annotation manager object</param> private static void AddTimestampAnnotation(CustomActionEventArgs customActionEventArgs, AnnotationManager annotationMngr) { // Remove timestamp if added on page ClearAnnotation(annotationMngr, "timestamp"); AnnotationText timestamp = annotationMngr.AddTextAnnot(0.2f, 0.2f, 3.0f, 0.2f, DateTime.Now.ToString("G")); timestamp.AutoSize = true; timestamp.Fill = false; timestamp.Stroke = false; timestamp.FontName = "Courier New"; timestamp.ForeColor = Color.OrangeRed; timestamp.FontSize = 10; timestamp.CanEditText = false; timestamp.Tag = "timestamp"; annotationMngr.SaveAnnotationsToPage(); customActionEventArgs.docuVieware.ReloadAnnotations(); }
protected override IEnumerator ProcessPayload(VisualPayload payload) { var annotationType = AnnotationType.GetLastKeyValue(payload.Data); var icon = VisualizerFactory.InstantiateAnnotationIcon(annotationType); if (annotationType == "transmit") { icon.Color = ChallengeSetColorField.GetFirstValue(payload.Data); } else if (annotationType == "receive") { icon.Color = RequestColorField.GetFirstValue(payload.Data); } icon.AnnotationText = AnnotationText.GetLastKeyValue(payload.Data); icon.Initialize(this, payload); yield return(null); }
public static Bitmap GenerateBitmap(DicomDataset dataset, bool burnInOverlays = true, bool anonymize = false) { var dcmImage = new DicomImage(dataset) { OverlayColor = -1 }; var bitmap = dcmImage.RenderImage(); if (burnInOverlays) { var modality = dataset.Get <String>(DicomTag.Modality); var markers = anonymize ? AnnotationText.GenerateAnnotationItems(modality, dataset, true) : AnnotationText.GenerateAnnotationItems(modality, dataset); var perentRectangle = new Rectangle(0, 0, bitmap.Width, bitmap.Height); var bmp = new Bitmap(bitmap); var gph = Graphics.FromImage(bmp); foreach (var annotationItem in markers) { var clientRectangle = AnnotationText.CalculateSubRectangle(perentRectangle, annotationItem.AnnotationRect); // Deflate the client rectangle by 4 pixels to allow some space // between neighbouring rectangles whose borders coincide. Rectangle.Inflate(clientRectangle, -4, -4); var fontSize = clientRectangle.Height - 1; //allow p's and q's, etc to extend slightly beyond the bounding rectangle. Only completely visible lines are shown. var format = new StringFormat(); format.FormatFlags = StringFormatFlags.NoClip; format.FormatFlags |= StringFormatFlags.NoWrap; AnnotationJustification(annotationItem, format); AnnotationVerticalAlignment(annotationItem, format); var style = FontStyle.Regular; if (annotationItem.Bold) { style |= FontStyle.Bold; } if (annotationItem.Italics) { style |= FontStyle.Italic; } // Font var font = CreateFont("Century Gothic", fontSize, style, GraphicsUnit.Pixel); // Drop Shadow clientRectangle.Offset(1, 1); gph.DrawString(annotationItem.AnnotationText, font, Brushes.Black, clientRectangle, format); // Foreground Colour clientRectangle.Offset(-1, -1); gph.DrawString(annotationItem.AnnotationText, font, Brushes.White, clientRectangle, format); font.Dispose(); } // Clean Up gph.Dispose(); return(bmp); } return((Bitmap)bitmap); }
AnnotationText CreateAnnotationText(XmlNode xmlAnnotation) { AnnotationText annotationText = new AnnotationText (); XmlNode xmlElements = null; XmlNodeList annotationChildNodeList = xmlAnnotation.ChildNodes; for (int w = 0; w < annotationChildNodeList.Count; w++) { xmlElements = annotationChildNodeList.Item (w); switch (xmlElements.Name) { case "value": //Debug.Log ("value: " + xmlElements.InnerText); if(xmlElements.InnerText.Length == 0) return null; annotationText.TextValue = xmlElements.InnerText; break; case "formatting": //Debug.Log ("formatting: " + xmlElements.InnerText); XmlNodeList formattingChildNodes = xmlElements.ChildNodes; XmlNode xmlColor = formattingChildNodes.Item (0); FormattingText formattingText = new FormattingText (); int red = Int32.Parse (formattingChildNodes.Item (0).ChildNodes.Item (0).InnerText); int green = Int32.Parse (formattingChildNodes.Item (0).ChildNodes.Item (1).InnerText); int blue = Int32.Parse (formattingChildNodes.Item (0).ChildNodes.Item (2).InnerText); formattingText.Color = new Color32 ((byte)red, (byte)green, (byte)blue, 0); annotationText.FormattingText = formattingText; break; default: break; } } annotationText = (AnnotationText) AddAnnotationCommonFields (xmlAnnotation, annotationText); return annotationText; }
public void LoadFromFile() { List <AnnotationText> textAnnotationList = new List <AnnotationText> (); List <AnnotationMark> markAnnotationList = new List <AnnotationMark> (); List <AnnotationInk> inkAnnotationList = new List <AnnotationInk> (); List <AnnotationLink> linkAnnotationList = new List <AnnotationLink>(); if (annotationXmlPath == null) { Debug.Log("ERROR - XML path null"); return; } TextAsset textAsset = new TextAsset(); textAsset = (TextAsset)Resources.Load(annotationXmlPath, typeof(TextAsset)); if (textAsset == null) { if (annotationXmlPath.Contains(".xml")) { Debug.Log("ERROR - the filename can't have extension. Delete .xml from the filename"); } else { Debug.Log("ERROR - There was a problem loading xml file"); } return; } XmlDocument xml = new XmlDocument(); xml.LoadXml(textAsset.text); // Load Take XmlNodeList xmlTakeList = xml.SelectNodes("/annotation_document/session/take"); for (int j = 0; j < xmlTakeList.Count; j++) { XmlNodeList xmlAnnotationSetList = xmlTakeList.Item(j).SelectNodes("annotations/annotation_set"); if (xmlAnnotationSetList.Count == 0) { continue; } take = CreateTake(xmlTakeList.Item(j)); if (take == null) { Debug.Log("ERROR creating class Take"); return; } // Load Annotations //XmlNodeList xmlAnnotationSetList = xml.SelectNodes ("/annotation_document/session/take/annotations/annotation_set"); int nNodes = xmlAnnotationSetList.Count; //Debug.Log ("annotation set count: " + nNodes); for (int i = 0; i < nNodes; i++) { //Debug.Log("annotation set name: " + xmlAnnotationSetList.Item(i).Name); XmlNodeList tmpList = xmlAnnotationSetList.Item(i).SelectNodes("annotation"); //Debug.Log("annotation count: " + tmpList.Count); for (int w = 0; w < tmpList.Count; w++) { XmlNode xmlAnnotation = tmpList.Item(w); // Debug.Log("type = " + xmlAnnotation.Attributes[0].InnerText); switch (xmlAnnotation.Attributes [0].InnerText) { case "text": AnnotationText annotation = CreateAnnotationText(xmlAnnotation); if (annotation == null) { continue; } annotation.Type = "text"; textAnnotationList.Add(annotation); Debug.Log("TEXT annotation"); continue; case "mark": AnnotationMark annotationMark = new AnnotationMark(); annotationMark.Type = "mark"; annotationMark = (AnnotationMark)AddAnnotationCommonFields(xmlAnnotation, annotationMark); markAnnotationList.Add(annotationMark); Debug.Log("MARK annotation"); continue; case "ink": AnnotationInk annotationInk = new AnnotationInk(); annotationInk.Type = "ink"; annotationInk = CreateAnnotationInk(xmlAnnotation); inkAnnotationList.Add(annotationInk); Debug.Log("INK annotation"); continue; case "link": AnnotationLink annotationLink = new AnnotationLink(); annotationLink.Type = "link"; annotationLink = CreateAnnotationLink(xmlAnnotation); linkAnnotationList.Add(annotationLink); Debug.Log("LINK annotation"); continue; case "audio": Debug.Log("Audio annotation"); continue; default: continue; } } } take.TextAnnotationList = textAnnotationList; take.InkAnnotationList = inkAnnotationList; take.MarkAnnotationList = markAnnotationList; take.LinkAnnotationList = linkAnnotationList; Debug.Log("Number of Text Annotation: " + take.TextAnnotationList.Count); Debug.Log("Number of Mark Annotation: " + take.MarkAnnotationList.Count); Debug.Log("Number of Ink Annotation: " + take.InkAnnotationList.Count); Debug.Log("Number of Link Annotation: " + take.LinkAnnotationList.Count); } }
/// <inheritdoc /> public bool Equals([AllowNull] Edits other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( AnnotationPosition == other.AnnotationPosition || AnnotationPosition != null && AnnotationPosition.Equals(other.AnnotationPosition) ) && ( AnnotationTail == other.AnnotationTail || AnnotationTail != null && AnnotationTail.Equals(other.AnnotationTail) ) && ( AnnotationText == other.AnnotationText || AnnotationText != null && AnnotationText.Equals(other.AnnotationText) ) && ( AxisTitleText == other.AxisTitleText || AxisTitleText != null && AxisTitleText.Equals(other.AxisTitleText) ) && ( ColorbarPosition == other.ColorbarPosition || ColorbarPosition != null && ColorbarPosition.Equals(other.ColorbarPosition) ) && ( ColorbarTitleText == other.ColorbarTitleText || ColorbarTitleText != null && ColorbarTitleText.Equals(other.ColorbarTitleText) ) && ( LegendPosition == other.LegendPosition || LegendPosition != null && LegendPosition.Equals(other.LegendPosition) ) && ( LegendText == other.LegendText || LegendText != null && LegendText.Equals(other.LegendText) ) && ( ShapePosition == other.ShapePosition || ShapePosition != null && ShapePosition.Equals(other.ShapePosition) ) && ( TitleText == other.TitleText || TitleText != null && TitleText.Equals(other.TitleText) )); }
void WriteTextAnnotation(AnnotationText annotationText) { GameObject textObject = new GameObject (); TextMesh textMesh = textObject.AddComponent<TextMesh>(); // GameObject textMeshGameObject = Resources.Load("TextMeshPrefab") as GameObject; // TextMesh textMesh = textMeshGameObject.GetComponent<TextMesh>(); textMesh.characterSize = 0.1f; textMesh.text = annotationText.TextValue; textMesh.color = new Color(annotationText.FormattingText.Color.r, annotationText.FormattingText.Color.g, annotationText.FormattingText.Color.b); GameObject cluster = FindClosestCluster(annotationText.PositionKin); if (cluster == null) { Debug.Log("Error: Could find cluster to add annotation!"); return; } textObject.AddComponent<GameObjectFollowBoxCollider>(); textMesh.transform.parent = cluster.transform; // TextMesh annotationMesh = cluster.AddComponent<TextMesh>(); // annotationMesh = textMesh; /*TextMeshPro textMeshPro = textObject.AddComponent<TextMeshPro> (); textMeshPro.gameObject.AddComponent <CameraFacingBillboard>(); textMeshPro.fontSize = 1; textMeshPro.text = annotationText.TextValue; textMeshPro.color = new Color(annotationText.FormattingText.Color.r, annotationText.FormattingText.Color.g, annotationText.FormattingText.Color.b); textMeshPro.transform.position = annotationText.PositionKin; // CALIBRATION Calibration calibration = calibrations[currentCalibration]; textMeshPro.transform.Rotate (calibration.RotationX, calibration.RotationY, calibration.RotationZ); textMeshPro.transform.Translate (calibration.Position.x, calibration.Position.y, calibration.Position.z);*/ gameObjectsInTheScene.Add (textMesh.gameObject); }