Esempio n. 1
0
 /// <summary>
 /// Creates an instance of <cref name="CompactBubbleViewModel"/> class
 /// from given node value
 /// </summary>
 /// <param name="value">Node value</param>
 /// <returns>Instance of <cref name="CompactBubbleViewModel"/> class</returns>
 public static CompactBubbleViewModel Process(MirrorData value)
 {
     items = 0;
     var viewModel = ProcessThing(value, true);
     viewModel.NumberOfItems = items;
     return viewModel;
 }
Esempio n. 2
0
 /// <summary>
 /// This consutructor is for instantiating a Runtime mirror object where we already have the mirrorData
 /// </summary>
 /// <param name="mirrorData"></param>
 /// <param name="core"></param>
 public RuntimeMirror(MirrorData mirrorData, ProtoCore.Core core, ProtoCore.Core staticCore = null) : base(core, staticCore)
 {
     Validity.Assert(this.core != null);
     TargetExecutive = core.CurrentExecutive.CurrentDSASMExec;
     deprecateThisMirror = new DSASM.Mirror.ExecutionMirror(TargetExecutive, core);
     this.mirrorData = mirrorData;
 }
Esempio n. 3
0
        internal WatchViewModel ProcessThing(MirrorData data, string tag, bool showRawData)
        {
            if (data.IsCollection)
            {
                var list = data.GetElements();

                var node = new WatchViewModel(visualizationManager, list.Count == 0 ? "Empty List" : "List", tag, true);
                foreach (var e in list.Select((element, idx) => new { element, idx }))
                {
                    node.Children.Add(ProcessThing(e.element, tag + ":" + e.idx, showRawData));
                }

                return node;
            }
            
            // MAGN-3494: If "data.Data" is null, then return a "null" string 
            // representation instead of casting it as dynamic (that leads to 
            // a crash).
            if (data.IsNull || data.Data == null)
                return new WatchViewModel(visualizationManager, NULL_STRING, tag);

            //If the input data is an instance of a class, create a watch node
            //with the class name and let WatchHandler process the underlying CLR data
            var classMirror = data.Class;
            if (null != classMirror)
            {
                if (data.Data == null && !data.IsNull) //Must be a DS Class instance.
                    return ProcessThing(classMirror.ClassName, tag, showRawData); //just show the class name.
                return Process(data.Data, tag, showRawData);
            }

            //Finally for all else get the string representation of data as watch content.
            return Process(data.Data, tag, showRawData);
        }
Esempio n. 4
0
 /// <summary>
 /// This consutructor is for instantiating a Runtime mirror object where we already have the mirrorData
 /// </summary>
 /// <param name="mirrorData"></param>
 /// <param name="core"></param>
 public RuntimeMirror(MirrorData mirrorData, ProtoCore.RuntimeCore runtimeCoreReflect, ProtoCore.Core staticCore = null)
     : base(runtimeCoreReflect, staticCore)
 {
     Validity.Assert(this.runtimeCore != null);
     TargetExecutive = runtimeCoreReflect.CurrentExecutive.CurrentDSASMExec;
     deprecateThisMirror = new DSASM.Mirror.ExecutionMirror(TargetExecutive, runtimeCoreReflect);
     this.mirrorData = mirrorData;
 }
Esempio n. 5
0
 internal WatchViewModel ProcessThing(MirrorData data, string tag, bool showRawData)
 {
     try
     {
         return baseHandler.Process(data, tag, showRawData);
     }
     catch (Exception)
     {
         return Process(data.Data, tag, showRawData);
     }
 }
Esempio n. 6
0
 private WatchViewModel ProcessThing(MirrorData data, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     try
     {
         return baseHandler.Process(data, tag, showRawData, callback);
     }
     catch (Exception)
     {
         return callback(data.Data, tag, showRawData);
     }
 }
Esempio n. 7
0
 public void AssertValue(MirrorData data, object value)
 {
     if (data.IsCollection)
         AssertCollection(data, value as IEnumerable);
     else if (value == null)
         Assert.IsTrue(data.IsNull);
     else if (value is int)
         Assert.AreEqual((int)value, Convert.ToInt32(data.Data));
     else if (value is double)
         Assert.AreEqual((double)value, Convert.ToDouble(data.Data), 0.00001);
     else
         Assert.AreEqual(value, data.Data);
 }
Esempio n. 8
0
 /// <summary>
 /// Validates the watch content with given mirror data.
 /// </summary>
 /// <param name="watch">WatchViewModel of the watch node</param>
 /// <param name="mirrorData">MirrorData to be shown in watch</param>
 private void AssertWatchContent(WatchViewModel watch, MirrorData mirrorData)
 {
     Assert.IsNotNull(mirrorData);
     if (mirrorData.IsCollection)
         AssertWatchTreeBranchContent(watch.Children, mirrorData.GetElements());
     else if (mirrorData.IsNull)
         Assert.AreEqual("null", watch.NodeLabel);
     else
     {
         string nodeLabel = string.Format("{0}", mirrorData.Data);
         Assert.AreEqual(nodeLabel, watch.NodeLabel);
     }
 }
Esempio n. 9
0
            public RuntimeMirror(string varname, int blockDecl, ProtoCore.RuntimeCore runtimeCore, ProtoCore.Core staticCore = null)
                : base(runtimeCore, staticCore)
            {
                TargetExecutive = runtimeCore.CurrentExecutive.CurrentDSASMExec;
                deprecateThisMirror = new DSASM.Mirror.ExecutionMirror(TargetExecutive, runtimeCore);

                Validity.Assert(this.runtimeCore != null);

                variableName = varname;
                blockDeclaration = blockDecl;
                StackValue svData = deprecateThisMirror.GetValue(variableName, blockDeclaration).DsasmValue;

                mirrorData = new MirrorData(staticCore, this.runtimeCore, svData);
            }
Esempio n. 10
0
            public RuntimeMirror(string varname, int blockDecl, ProtoCore.RuntimeCore runtimeCore, ProtoCore.Core staticCore = null)
                : base(runtimeCore, staticCore)
            {
                TargetExecutive     = runtimeCore.CurrentExecutive.CurrentDSASMExec;
                deprecateThisMirror = new DSASM.Mirror.ExecutionMirror(TargetExecutive, runtimeCore);

                Validity.Assert(this.runtimeCore != null);

                variableName     = varname;
                blockDeclaration = blockDecl;
                StackValue svData = deprecateThisMirror.GetValue(variableName, blockDeclaration).DsasmValue;

                mirrorData = new MirrorData(staticCore, this.runtimeCore, svData);
            }
Esempio n. 11
0
        }                        // Empty constructor required for deserialization

        public void Send(IMyCubeGrid grid, Vector3I blockPosition, PaintMaterial paint, bool useMirroring)
        {
            GridEntId     = grid.EntityId;
            BlockPosition = blockPosition;
            Paint         = new SerializedPaintMaterial(paint);
            MirrorData    = (useMirroring ? new MirrorData(grid) : default(MirrorData));

            Network.SendToServer(this);

            // do the action for local client too
            if (!MyAPIGateway.Session.IsServer)
            {
                DoAction(grid);
            }
        }
Esempio n. 12
0
        internal WatchViewModel ProcessThing(MirrorData data, string tag, bool showRawData = true)
        {
            //If the input data is an instance of a class, create a watch node
            //with the class name and let WatchHandler process the underlying CLR data
            var classMirror = data.Class;
            if (null != classMirror)
            {
                if (data.Data == null && !data.IsNull) //Must be a DS Class instance.
                    return ProcessThing(classMirror.ClassName, tag); //just show the class name.
                return ProcessThing(data.Data as dynamic, tag, showRawData);
            }

            //Finally for all else get the string representation of data as watch content.
            return ProcessThing(data.Data as dynamic, tag);
        }
Esempio n. 13
0
        /// <summary>
        /// Counts the number of all collection items of node output and if specified 
        /// it generates appropriate view model for compact preview bubble
        /// </summary>
        /// <param name="mirrorData">Data which represents the value of node output</param>
        /// <param name="generateViewModel">Flag to not create unused view models</param>
        /// <returns><cref name="CompactBubbleViewModel"/> instance 
        /// if <paramref name="generateViewModel"/> is specified. Otherwise, null</returns>
        private static CompactBubbleViewModel ProcessThing(MirrorData mirrorData, bool generateViewModel)
        {
            if (mirrorData == null)
            {
                return generateViewModel ? new CompactBubbleViewModel(Resources.NullString, 0) : null;
            }

            if (mirrorData.IsCollection)
            {
                var list = mirrorData.GetElements();

                foreach (var item in list)
                {
                    ProcessThing(item, false);
                }

                return generateViewModel
                    ? new CompactBubbleViewModel(true)
                    {
                        NodeLabel = list.Any() ? "List" : "Empty List"
                    }
                    : null;
            }

            items++;

            if (!generateViewModel) return null;

            var viewModel = new CompactBubbleViewModel(false);
            if (mirrorData.Data == null && !mirrorData.IsNull && mirrorData.Class != null)
            {
                viewModel.NodeLabel = mirrorData.Class.ClassName;
            }
            else if (mirrorData.Data is Enum)
            {
                viewModel.NodeLabel = ((Enum)mirrorData.Data).GetDescription();
            }
            else
            {
                // Cut StringData so that only the type name remains
                // for example, "Point (Z = 0.000, Y = 0.000, Z = 0.000)" -> "Point"
                viewModel.NodeLabel = string.IsNullOrEmpty(mirrorData.StringData)
                    ? string.Empty
                    : mirrorData.StringData.Split('(')[0];
            }

            return viewModel;
        }
Esempio n. 14
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="obj"></param>
            /// <returns></returns>
            public override bool Equals(object obj)
            {
                if (object.ReferenceEquals(obj, this))
                {
                    return(true);
                }

                MirrorData data = obj as MirrorData;

                if (null == data)
                {
                    return(false);
                }

                return(StackUtils.CompareStackValues(this.svData, data.svData, this.runtimeCore, data.runtimeCore));
            }
        /// <summary>
        /// Convert mirror data objects for nodes to Revit types.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="geoms"></param>
        private void RevitGeometryFromMirrorData(MirrorData data, ref List <GeometryObject> geoms)
        {
            if (data.IsCollection)
            {
                foreach (var md in data.GetElements())
                {
                    try
                    {
                        RevitGeometryFromMirrorData(md, ref geoms);
                    }
                    catch (Exception ex)
                    {
                        this.dynamoModel.Logger.Log(ex.Message);
                    }
                }
            }
            else
            {
                try
                {
                    var geom = data.Data as PolyCurve;
                    if (geom != null)
                    {
                        geoms.AddRange(geom.ToRevitType());
                        return;
                    }

                    var point = data.Data as Point;
                    if (point != null)
                    {
                        geoms.Add(DocumentManager.Instance.CurrentUIApplication.Application.Create.NewPoint(point.ToXyz()));
                        return;
                    }

                    var curve = data.Data as Curve;
                    if (curve != null)
                    {
                        geoms.Add(curve.ToRevitType());
                        return;
                    }
                }
                catch (Exception ex)
                {
                    this.dynamoModel.Logger.Log(ex.Message);
                }
            }
        }
Esempio n. 16
0
        public void Defect_MAGN_4946()
        {
            var    model     = ViewModel.Model;
            int    value     = 10;
            string codeInCBN = "a = " + value.ToString();

            // Create the initial code block node.
            var codeBlockNodeOne = CreateCodeBlockNode();

            UpdateCodeBlockNodeContent(codeBlockNodeOne, codeInCBN);

            // We should have one code block node by now.
            Assert.AreEqual(1, model.Nodes.Count());


            // Run
            ViewModel.Model.RunExpression();

            // Get preview data given AstIdentifierBase
            var           core          = ViewModel.Model.EngineController.LiveRunnerCore;
            RuntimeMirror runtimeMirror = new RuntimeMirror(codeBlockNodeOne.AstIdentifierBase, 0, core);
            MirrorData    mirrorData    = runtimeMirror.GetData();

            Assert.AreEqual(mirrorData.Data, value);

            // Copy and paste the code block node.
            model.AddToSelection(codeBlockNodeOne);
            model.Copy(null);  // Copy the selected node.
            model.Paste(null); // Paste the copied node.

            // After pasting, we should have two nodes.
            Assert.AreEqual(2, model.Nodes.Count());

            // Make sure we are able to get the second code block node.
            var codeBlockNodeTwo = model.Nodes[1] as CodeBlockNodeModel;

            Assert.IsNotNull(codeBlockNodeTwo);


            // Run
            ViewModel.Model.RunExpression();

            // Get preview data given AstIdentifierBase
            runtimeMirror = new RuntimeMirror(codeBlockNodeTwo.AstIdentifierBase, 0, core);
            mirrorData    = runtimeMirror.GetData();
            Assert.AreEqual(mirrorData.Data, value);
        }
 protected void AssertValue(MirrorData data, object value)
 {
     if (data.IsCollection)
     {
         if (!(value is IEnumerable))
         {
             Assert.Fail("Data is collection but expected vlaue is not.");
         }
         AssertCollection(data, value as IEnumerable);
     }
     else if (value == null)
     {
         Assert.IsTrue(data.IsNull);
     }
     else if (value is int)
     {
         try
         {
             int mirrorData = Convert.ToInt32(data.Data);
             Assert.AreEqual((int)value, mirrorData);
         }
         catch (Exception e)
         {
             Assert.Fail(e.Message);
         }
     }
     else if (value is double)
     {
         try
         {
             double mirrorData = Convert.ToDouble(data.Data);
             Assert.AreEqual((double)value, Convert.ToDouble(data.Data), 0.00001);
         }
         catch (Exception e)
         {
             Assert.Fail(e.Message);
         }
     }
     else if (data.IsPointer && data.Class.ClassName == "_SingleFunctionObject")
     {
         Assert.AreEqual(data.Class.ClassName, value);
     }
     else
     {
         Assert.AreEqual(value, data.Data);
     }
 }
Esempio n. 18
0
        private void BeginNextTransition()
        {
            // A run completed while in transition, we must refresh
            if (queuedRefresh)
            {
                queuedRefresh = false;
                BindToDataSource(queuedMirrorData);
                this.queuedMirrorData = null;
                return;
            }

            if (this.IsInTransition || queuedRequest.Count <= 0)
            {
                return; // Nothing else to do.
            }
            State requestedState = queuedRequest.Dequeue();

            while (requestedState == this.currentState)
            {
                if (queuedRequest.Count <= 0)
                {
                    return; // There's no more request for now.
                }
                requestedState = queuedRequest.Dequeue();
            }

            if (requestedState == State.Hidden)
            {
                BeginFadeOutTransition();
            }
            else if (requestedState == State.Condensed)
            {
                if (this.IsHidden != false)
                {
                    BeginFadeInTransition();
                }
                else if (this.IsExpanded != false)
                {
                    BeginCondenseTransition();
                }
            }
            else if (requestedState == State.Expanded)
            {
                BeginExpandTransition();
            }
        }
Esempio n. 19
0
 /// <summary>
 /// Validates the watch content with given mirror data.
 /// </summary>
 /// <param name="watch">WatchViewModel of the watch node</param>
 /// <param name="mirrorData">MirrorData to be shown in watch</param>
 private void AssertWatchContent(WatchViewModel watch, MirrorData mirrorData)
 {
     Assert.IsNotNull(mirrorData);
     if (mirrorData.IsCollection)
     {
         AssertWatchTreeBranchContent(watch.Children, mirrorData.GetElements());
     }
     else if (mirrorData.IsNull)
     {
         Assert.AreEqual("null", watch.NodeLabel);
     }
     else
     {
         string nodeLabel = string.Format("{0}", mirrorData.Data);
         Assert.AreEqual(nodeLabel, watch.NodeLabel);
     }
 }
Esempio n. 20
0
        private void GetRenderPackagesFromMirrorData(MirrorData mirrorData, ref List <string> labelMap, ref int count)
        {
            if (mirrorData.IsNull)
            {
                return;
            }

            if (mirrorData.IsCollection)
            {
                foreach (var el in mirrorData.GetElements())
                {
                    GetRenderPackagesFromMirrorData(el, ref labelMap, ref count);
                }
            }
            else
            {
                var graphicItem = mirrorData.Data as IGraphicItem;
                if (graphicItem == null)
                {
                    return;
                }

                var package = new RenderPackage(isNodeSelected, displayLabels)
                {
                    Tag = labelMap.Count > count ? labelMap[count] : "?",
                };

                try
                {
                    graphicItem.Tessellate(
                        package,
                        tol: -1.0,
                        maxGridLines: maxTesselationDivisions);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine(
                        "PushGraphicItemIntoPackage: " + e);
                }

                package.ItemsCount++;
                renderPackages.Add(package);
                count++;
            }
        }
Esempio n. 21
0
        internal WatchViewModel ProcessThing(MirrorData data, string tag, bool showRawData = true)
        {
            //If the input data is an instance of a class, create a watch node
            //with the class name and let WatchHandler process the underlying CLR data
            var classMirror = data.Class;

            if (null != classMirror)
            {
                if (data.Data == null && !data.IsNull)                //Must be a DS Class instance.
                {
                    return(ProcessThing(classMirror.ClassName, tag)); //just show the class name.
                }
                return(ProcessThing(data.Data as dynamic, tag, showRawData));
            }

            //Finally for all else get the string representation of data as watch content.
            return(ProcessThing(data.Data as dynamic, tag, showRawData));
        }
Esempio n. 22
0
        private WatchViewModel ProcessThing(MirrorData data, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
        {
            if (data.IsCollection)
            {
                var list = data.GetElements();

                var node = new WatchViewModel(!list.Any() ? WatchViewModel.EMPTY_LIST : WatchViewModel.LIST, tag, RequestSelectGeometry, true);
                foreach (var e in list.Select((element, idx) => new { element, idx }))
                {
                    node.Children.Add(ProcessThing(e.element, runtimeCore, tag + ":" + e.idx, showRawData, callback));
                }

                return(node);
            }

            if (data.Data is Enum)
            {
                return(new WatchViewModel(((Enum)data.Data).GetDescription(), tag, RequestSelectGeometry));
            }

            if (data.Data == null)
            {
                // MAGN-3494: If "data.Data" is null, then return a "null" string
                // representation instead of casting it as dynamic (that leads to
                // a crash).
                if (data.IsNull)
                {
                    return(new WatchViewModel(Resources.NullString, tag, RequestSelectGeometry));
                }

                //If the input data is an instance of a class, create a watch node
                //with the class name and let WatchHandler process the underlying CLR data
                var classMirror = data.Class;
                if (null != classMirror)
                {
                    //just show the class name.
                    return(ProcessThing(classMirror.ClassName, runtimeCore, tag, showRawData, callback));
                }
            }

            //Finally for all else get the string representation of data as watch content.
            return(callback(data.Data, runtimeCore, tag, showRawData));
        }
Esempio n. 23
0
        public static void AssertValue(MirrorData data, object value)
        {
            if (value == null)
            {
                Assert.IsTrue(data.IsNull, "data is null");
            }
            else if (value is int)
            {
                if (data.IsNull)
                {
                    throw new AssertionException("Incorrect verification of null value with int");
                }

                Assert.AreEqual((int)value, Convert.ToInt32(data.Data));
            }
            else if (value is double)
            {
                if (data.IsNull)
                {
                    throw new AssertionException("Incorrect verification of null value with double");
                }

                Assert.AreEqual((double)value, Convert.ToDouble(data.Data), 0.00001);
            }
            else if (data.IsCollection)
            {
                var values = value as IEnumerable;
                if (object.ReferenceEquals(values, null))
                {
                    string errorMessage = string.Format(
                        "The value is {1}, but the expected value is {2}.",
                        data.Data ?? "null",
                        value);
                    throw new AssertionException(errorMessage);
                }
                AssertCollection(data, values);
            }
            else
            {
                Assert.AreEqual(value, data.Data);
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Bind a mirror data to the preview control for display, this call
        /// unbinds the internal data structure from the view that it was
        /// originally bound to and resets the data structure. If this call is
        /// made while the preview control is in condensed or expanded state,
        /// the display will immediately be refreshed. Since this method deals
        /// with UI elements internally, it must be called from the UI thread.
        /// </summary>
        /// <param name="mirrorData">The mirror data to bind the preview control
        /// to. This value can be null to reset the preview control to its
        /// initial state.</param>
        ///
        internal void BindToDataSource(MirrorData mirrorData)
        {
            // First detach the bound data from its view.
            ResetContentViews();

            this.mirrorData         = mirrorData;
            this.cachedLargeContent = null; // Reset expanded content.
            this.cachedSmallContent = null; // Reset condensed content.

            // If at the time of data binding the preview control is within the
            // following states, then its contents need to be updated immediately.
            if (this.IsCondensed)
            {
                RefreshCondensedDisplay(delegate { BeginViewSizeTransition(ComputeSmallContentSize()); });
            }
            else if (this.IsExpanded)
            {
                RefreshExpandedDisplay(delegate { BeginViewSizeTransition(ComputeLargeContentSize()); });
            }
        }
Esempio n. 25
0
        public override bool RequestVisualUpdateAsync(IScheduler scheduler, EngineController engine, IRenderPackageFactory factory, bool forceUpdate = true)
        {
            try
            {
                int           index  = OutPorts[0].Index;
                string        name   = GetAstIdentifierForOutputIndex(index).Name;
                RuntimeMirror mirror = engine.GetMirror(name);
                MirrorData    data   = mirror.GetData();

                List <Autodesk.DesignScript.Geometry.Mesh> meshes = GetMeshes(data);
                _meshes = meshes;
                IRenderPackage render = factory.CreateRenderPackage();
                foreach (Autodesk.DesignScript.Geometry.Mesh m in meshes)
                {
                    if (m != null)
                    {
                        m.Tessellate(render, factory.TessellationParameters);
                        //var method = render.GetType().GetMethod("SetTransform", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance, null, new[] { typeof(double[]) }, null);

                        //if (method != null)
                        //{
                        //    method.Invoke(render, new object[] { new double[]
                        //    {
                        //       transform.XAxis.X, transform.XAxis.Y, transform.XAxis.Z, 0,
                        //       transform.YAxis.X, transform.YAxis.Y, transform.YAxis.Z, 0,
                        //       transform.ZAxis.X, transform.ZAxis.Y, transform.ZAxis.Z, 0,
                        //       transform.Origin.X, transform.Origin.Y, transform.Origin.Z, 1
                        //    }
                        //    });
                        //}
                    }
                }

                // NOTE: I'm not sure calling the Tessellate method from IGraphicItem is necessary here
                // but I've tried calling and am leaving it in here just in case I do wind up needing it.
                //Tessellate(render, factory.TessellationParameters);
                return(true);
            }
            catch { }
            return(false);
        }
 // Add labels for each of a mirror data object's inner data object to a label map.
 private static void AddToLabelMap(MirrorData data, List <string> map, string tag)
 {
     if (data.IsCollection)
     {
         var index    = 0;
         var elements = data.GetElements();
         foreach (var element in elements)
         {
             var newTag = string.Format("{0}:{1}", tag, index++);
             AddToLabelMap(element, map, newTag);
         }
     }
     else if (data.Data is IEnumerable)
     {
         AddToLabelMap(data.Data as IEnumerable, map, tag);
     }
     else
     {
         map.Add(tag);
     }
 }
Esempio n. 27
0
        public void CanGetWorksheets()
        {
            string openPath = Path.Combine(GetTestDirectory(), @"core\excel\WorksheetsFromFile.dyn");

            ViewModel.OpenCommand.Execute(openPath);

            var filename = ViewModel.Model.CurrentWorkspace.FirstNodeFromWorkspace <DSCore.File.Filename>();

            // remap the filename as Excel requires an absolute path
            filename.Value = filename.Value.Replace(@"..\..\..\test", GetTestDirectory());

            var watch = ViewModel.Model.CurrentWorkspace.GetDSFunctionNodeFromWorkspace("Excel.GetWorksheetsFromExcelWorkbook");

            ViewModel.HomeSpace.Run();

            MirrorData mirror = watch.CachedValue;

            Assert.IsTrue(mirror.IsCollection);

            Assert.AreEqual(3, mirror.GetElements().Count);
        }
Esempio n. 28
0
        private static bool IsNodeNull(MirrorData data)
        {
            if (data == null || data.IsNull)
            {
                return(true);
            }

            if (data.IsCollection)
            {
                var elements = data.GetElements();
                foreach (var element in elements)
                {
                    if (IsNodeNull(element))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Esempio n. 29
0
        internal WatchViewModel ProcessThing(MirrorData data, string tag, bool showRawData = true)
        {
            //If the input data is an instance of a class, create a watch node
            //with the class name and let WatchHandler process the underlying CLR data
            var classMirror = data.Class;
            if (null != classMirror)
            {
                if (data.Data == null && !data.IsNull) //Must be a DS Class instance.
                    return ProcessThing(classMirror.ClassName, tag); //just show the class name.
                return ProcessThing(data.Data as dynamic, tag, showRawData);
            }

            // MAGN-3494: If "data.Data" is null, then return a "null" string 
            // representation instead of casting it as dynamic (that leads to 
            // a crash).
            if (data.Data == null)
                return new WatchViewModel("null", tag);

            //Finally for all else get the string representation of data as watch content.
            return ProcessThing(data.Data as dynamic, tag, showRawData);
        }
Esempio n. 30
0
        private WatchViewModel ProcessThing(MirrorData data, string tag, bool showRawData, WatchHandlerCallback callback)
        {
            if (data.IsCollection)
            {
                var list = data.GetElements();

                var node = new WatchViewModel(visualizationManager, list.Count == 0 ? "Empty List" : "List", tag, true);
                foreach (var e in list.Select((element, idx) => new { element, idx }))
                {
                    node.Children.Add(ProcessThing(e.element, tag + ":" + e.idx, showRawData, callback));
                }

                return(node);
            }

            // MAGN-3494: If "data.Data" is null, then return a "null" string
            // representation instead of casting it as dynamic (that leads to
            // a crash).
            if (data.IsNull || data.Data == null)
            {
                return(new WatchViewModel(visualizationManager, NULL_STRING, tag));
            }

            //If the input data is an instance of a class, create a watch node
            //with the class name and let WatchHandler process the underlying CLR data
            var classMirror = data.Class;

            if (null != classMirror)
            {
                if (data.Data == null && !data.IsNull)                                       //Must be a DS Class instance.
                {
                    return(ProcessThing(classMirror.ClassName, tag, showRawData, callback)); //just show the class name.
                }
                return(callback(data.Data, tag, showRawData));
            }

            //Finally for all else get the string representation of data as watch content.
            return(callback(data.Data, tag, showRawData));
        }
Esempio n. 31
0
        /// <summary>
        /// Helper method to get all items from mirror data as flat list recursively.
        /// </summary>
        /// <param name="data">Input data</param>
        /// <returns>List of objects</returns>
        protected static IEnumerable <object> GetElementsFromMirrorData(MirrorData data)
        {
            if (data == null || data.IsNull)
            {
                yield return(null);
            }

            if (data.IsCollection)
            {
                var elems = data.GetElements();
                foreach (var item in elems)
                {
                    var objs = GetElementsFromMirrorData(item);
                    foreach (var obj in objs)
                    {
                        yield return(obj);
                    }
                }
            }

            yield return(data.Data);
        }
Esempio n. 32
0
        private void GetRenderPackagesFromMirrorData(
            Guid outputPortId,
            MirrorData mirrorData,
            string tag,
            bool displayLabels)
        {
            if (mirrorData.IsNull)
            {
                return;
            }

            var package = factory.CreateRenderPackage();

            package.DisplayLabels = displayLabels;
            package.Description   = tag;
            package.IsSelected    = isNodeSelected;

            //Initialize the package here assuming we will only generate a single renderPackage for this node
            //We set the AllowLegacyColorOperations so that we can catch tessellation implementations which
            //use the deprecated calls.  At that point we will roll back the changes to the renderPackage
            //and call tessellate with a new renderPackage object with AllowLegacyColorOperations set to true.
            if (package is IRenderPackageSupplement packageSupplement)
            {
                packageSupplement.AllowLegacyColorOperations = false;
            }

            GetRenderPackagesFromMirrorDataImp(outputPortId, mirrorData, package, tag);

            if (package.MeshVertexColors.Any())
            {
                package.RequiresPerVertexColoration = true;
            }

            if (package.HasRenderingData)
            {
                renderPackageCache.Add(package, outputPortId);
            }
        }
Esempio n. 33
0
 public void AssertValue(MirrorData data, object value)
 {
     if (data.IsCollection)
     {
         AssertCollection(data, value as IEnumerable);
     }
     else if (value == null)
     {
         Assert.IsTrue(data.IsNull);
     }
     else if (value is int)
     {
         Assert.AreEqual((int)value, Convert.ToInt32(data.Data));
     }
     else if (value is double)
     {
         Assert.AreEqual((double)value, Convert.ToDouble(data.Data), 0.00001);
     }
     else
     {
         Assert.AreEqual(value, data.Data);
     }
 }
Esempio n. 34
0
 private void AssertMirrorData(MirrorData data1, MirrorData data2)
 {
     if (data1.IsNull)
     {
         Assert.True(data2.IsNull);
     }
     else if (data1.IsCollection)
     {
         Assert.True(data2.IsCollection);
         List <MirrorData> elems1 = data1.GetElements().ToList();
         List <MirrorData> elems2 = data2.GetElements().ToList();
         Assert.AreEqual(elems1.Count, elems2.Count);
         int i = 0;
         foreach (var item in elems1)
         {
             AssertMirrorData(item, elems2[i++]);
         }
     }
     else
     {
         Assert.AreEqual(data1.Data, data2.Data);
     }
 }
 protected override void HandleTaskExecutionCore()
 {
     var runtimeMirror = engineController.GetMirror(variableName);
     if (runtimeMirror != null)
         cachedMirrorData = runtimeMirror.GetData();
 }
Esempio n. 36
0
        private void GetRenderPackagesFromMirrorData(MirrorData mirrorData, string tag, bool displayLabels, bool isNodeSelectednt)
        {
            if (mirrorData.IsNull)
            {
                return;
            }

            if (mirrorData.IsCollection)
            {
                int count = 0;
                foreach (var el in mirrorData.GetElements())
                {
                    if (el.IsCollection || el.Data is IGraphicItem)
                    {
                        string newTag = tag + ":" + count;
                        GetRenderPackagesFromMirrorData(el, newTag, displayLabels, isNodeSelected);
                    }
                    count = count + 1;
                }
            }
            else
            {
                var graphicItem = mirrorData.Data as IGraphicItem;
                if (graphicItem == null)
                {
                    return;
                }

                var package = factory.CreateRenderPackage();
                var packageWithTransform = package as ITransformable;
                package.Description = tag;

                try
                {
                    graphicItem.Tessellate(package, factory.TessellationParameters);
                    if (package.MeshVertexColors.Count() > 0)
                    {
                        package.RequiresPerVertexColoration = true;
                    }

                    //If the package has a transform that is not the identity matrix
                    //then set requiresCustomTransform to true.
                    if (packageWithTransform != null && packageWithTransform.Transform.SequenceEqual(
                            new double[] { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }) == false)
                    {
                        (packageWithTransform).RequiresCustomTransform = true;
                    }

                    if (factory.TessellationParameters.ShowEdges)
                    {
                        var topology = graphicItem as Topology;
                        if (topology != null)
                        {
                            var surf = graphicItem as Surface;
                            if (surf != null)
                            {
                                foreach (var curve in surf.PerimeterCurves())
                                {
                                    curve.Tessellate(package, factory.TessellationParameters);
                                    curve.Dispose();
                                }
                            }
                            else
                            {
                                var edges = topology.Edges;
                                foreach (var geom in edges.Select(edge => edge.CurveGeometry))
                                {
                                    geom.Tessellate(package, factory.TessellationParameters);
                                    geom.Dispose();
                                }
                                edges.ForEach(x => x.Dispose());
                            }
                        }
                    }

                    var plane = graphicItem as Plane;
                    if (plane != null)
                    {
                        package.RequiresPerVertexColoration = true;

                        var s = 2.5;

                        var cs = CoordinateSystem.ByPlane(plane);
                        var a  = Point.ByCartesianCoordinates(cs, s, s, 0);
                        var b  = Point.ByCartesianCoordinates(cs, -s, s, 0);
                        var c  = Point.ByCartesianCoordinates(cs, -s, -s, 0);
                        var d  = Point.ByCartesianCoordinates(cs, s, -s, 0);

                        // Get rid of the original plane geometry.
                        package.Clear();

                        package.AddTriangleVertex(a.X, a.Y, a.Z);
                        package.AddTriangleVertex(b.X, b.Y, b.Z);
                        package.AddTriangleVertex(c.X, c.Y, c.Z);

                        package.AddTriangleVertex(c.X, c.Y, c.Z);
                        package.AddTriangleVertex(d.X, d.Y, d.Z);
                        package.AddTriangleVertex(a.X, a.Y, a.Z);

                        package.AddTriangleVertexUV(0, 0);
                        package.AddTriangleVertexUV(0, 0);
                        package.AddTriangleVertexUV(0, 0);
                        package.AddTriangleVertexUV(0, 0);
                        package.AddTriangleVertexUV(0, 0);
                        package.AddTriangleVertexUV(0, 0);

                        // Draw plane edges
                        package.AddLineStripVertex(a.X, a.Y, a.Z);
                        package.AddLineStripVertex(b.X, b.Y, b.Z);
                        package.AddLineStripVertex(b.X, b.Y, b.Z);
                        package.AddLineStripVertex(c.X, c.Y, c.Z);
                        package.AddLineStripVertex(c.X, c.Y, c.Z);
                        package.AddLineStripVertex(d.X, d.Y, d.Z);
                        package.AddLineStripVertex(d.X, d.Y, d.Z);
                        package.AddLineStripVertex(a.X, a.Y, a.Z);

                        // Draw normal
                        package.AddLineStripVertex(plane.Origin.X, plane.Origin.Y, plane.Origin.Z);
                        var nEnd = plane.Origin.Add(plane.Normal.Scale(2.5));
                        package.AddLineStripVertex(nEnd.X, nEnd.Y, nEnd.Z);

                        for (var i = 0; i < package.LineVertexCount / 2; i++)
                        {
                            package.AddLineStripVertexCount(2);
                        }

                        for (var i = 0; i < package.LineVertexCount; i++)
                        {
                            package.AddLineStripVertexColor(MidTone, MidTone, MidTone, 255);
                        }

                        for (var i = 0; i < package.MeshVertexCount; i++)
                        {
                            package.AddTriangleVertexNormal(plane.Normal.X, plane.Normal.Y, plane.Normal.Z);
                        }

                        for (var i = 0; i < package.MeshVertexCount; i++)
                        {
                            package.AddTriangleVertexColor(0, 0, 0, 10);
                        }
                    }

                    // The default color coming from the geometry library for
                    // curves is 255,255,255,255 (White). Because we want a default
                    // color of 0,0,0,255 (Black), we adjust the color components here.
                    if (graphicItem is Curve || graphicItem is Surface || graphicItem is Solid || graphicItem is Point)
                    {
                        if (package.LineVertexCount > 0 && package.LineStripVertexColors.Count() <= 0)
                        {
                            package.ApplyLineVertexColors(CreateColorByteArrayOfSize(package.LineVertexCount, DefR, DefG, DefB, DefA));
                        }

                        if (package.PointVertexCount > 0 && package.PointVertexColors.Count() <= 0)
                        {
                            package.ApplyPointVertexColors(CreateColorByteArrayOfSize(package.PointVertexCount, DefR, DefG, DefB, DefA));
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine(
                        "PushGraphicItemIntoPackage: " + e);
                }

                package.DisplayLabels = displayLabels;
                package.IsSelected    = isNodeSelected;

                renderPackages.Add(package);
            }
        }
Esempio n. 37
0
        private static void GetGraphicItemsFromMirrorData(MirrorData mirrorData, List<IGraphicItem> graphicItems)
        {
            if (mirrorData == null) return;

            if (mirrorData.IsCollection)
            {
                foreach (var el in mirrorData.GetElements())
                {
                    GetGraphicItemsFromMirrorData(el, graphicItems);
                }
            }
            else
            {
                var graphicItem = mirrorData.Data as IGraphicItem;
                if (graphicItem == null) return;

                graphicItems.Add(graphicItem);
            }
        }
Esempio n. 38
0
        private WatchViewModel ProcessThing(MirrorData data, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback, List <string> preferredDictionaryOrdering = null)
        {
            if (data.IsCollection)
            {
                var list = data.GetElements();

                var node = new WatchViewModel(!list.Any() ? WatchViewModel.EMPTY_LIST : WatchViewModel.LIST, tag, RequestSelectGeometry, true);
                foreach (var e in list.Select((element, idx) => new { element, idx }))
                {
                    node.Children.Add(ProcessThing(e.element, runtimeCore, tag + ":" + e.idx, showRawData, callback));
                }

                return(node);
            }

            if (data.IsPointer && data.IsDictionary)
            {
                var dict = data.Data as DesignScript.Builtin.Dictionary;

                var keys   = dict.Keys;
                var values = dict.Values;
                if (preferredDictionaryOrdering != null && preferredDictionaryOrdering.Count > 1)
                {
                    keys   = preferredDictionaryOrdering;
                    values = keys.Select(k => dict.ValueAtKey(k));
                }

                var node = new WatchViewModel(keys.Any() ? WatchViewModel.DICTIONARY : WatchViewModel.EMPTY_DICTIONARY, tag, RequestSelectGeometry, true);

                foreach (var e in keys.Zip(values, (key, value) => new { key, value }))
                {
                    node.Children.Add(ProcessThing(e.value, runtimeCore, tag + ":" + e.key, showRawData, callback));
                }

                return(node);
            }

            if (data.Data is Enum)
            {
                return(new WatchViewModel(((Enum)data.Data).GetDescription(), tag, RequestSelectGeometry));
            }

            if (data.Data == null)
            {
                // MAGN-3494: If "data.Data" is null, then return a "null" string
                // representation instead of casting it as dynamic (that leads to
                // a crash).
                if (data.IsNull)
                {
                    return(new WatchViewModel(Resources.NullString, tag, RequestSelectGeometry));
                }

                //If the input data is an instance of a class, create a watch node
                //with the class name and let WatchHandler process the underlying CLR data
                var classMirror = data.Class;
                if (null != classMirror)
                {
                    //just show the class name.
                    return(ProcessThing(classMirror.ClassName, runtimeCore, tag, showRawData, callback));
                }
            }

            //Finally for all else get the string representation of data as watch content.
            return(callback(data.Data, null, runtimeCore, tag, showRawData));
        }
Esempio n. 39
0
        protected void AssertValue(MirrorData data, object value)
        {
            if (data.IsCollection)
            {
                if (!(value is IEnumerable))
                {
                    Assert.Fail("Data is collection but expected value is not.");
                }
                AssertCollection(data, value as IEnumerable);
            }
            else if (value == null)
            {
                Assert.IsTrue(data.IsNull);
            }
            else if (value is int)
            {
                try
                {
                    int mirrorData = Convert.ToInt32(data.Data);
                    Assert.AreEqual((int)value, mirrorData);
                }
                catch (Exception e)
                {
                    Assert.Fail(e.Message);
                }
            }
            else if (value is double)
            {
                try
                {
                    double mirrorData = Convert.ToDouble(data.Data);
                    Assert.AreEqual((double)value, mirrorData, 0.00001);
                }
                catch (Exception e)
                {
                    Assert.Fail(e.Message);
                }
            }
            else if (data.IsPointer && data.Class.ClassName == "Function")
            {
                Assert.AreEqual(data.Class.ClassName, value);
            }
            else if (data.IsDictionary)
            {
                var thisData = data.Data as DesignScript.Builtin.Dictionary;

                if (value is DesignScript.Builtin.Dictionary)
                {
                    var otherVal = (DesignScript.Builtin.Dictionary)value;

                    if (otherVal.Count != thisData.Count)
                    {
                        Assert.Fail("Data and expected value are 2 different dictionaries.");
                    }

                    foreach (var key in otherVal.Keys)
                    {
                        var val = thisData.ValueAtKey(key);
                        if (val == null)
                        {
                            Assert.Fail("Data and expected value are 2 different dictionaries.");
                        }

                        if (val.GetType().IsValueType)
                        {
                            Assert.AreEqual(val, thisData.ValueAtKey(key));
                        }
                    }
                }
                else if (value is IDictionary)
                {
                    var otherVal = (IDictionary)value;

                    if (otherVal.Count != thisData.Count)
                    {
                        Assert.Fail("Data and expected value are 2 different dictionaries.");
                    }

                    foreach (var key in otherVal.Keys)
                    {
                        if (!(key is string))
                        {
                            Assert.Fail("Expected value is a dictionary with non-string key(s).");
                        }
                        var strKey = (string)key;
                        var val    = thisData.ValueAtKey(strKey);
                        if (val == null)
                        {
                            Assert.Fail("Data and expected value are 2 different dictionaries.");
                        }

                        if (val.GetType().IsValueType)
                        {
                            Assert.AreEqual(val, thisData.ValueAtKey(strKey));
                        }
                    }
                }
            }
            else
            {
                Assert.AreEqual(value, data.Data);
            }
        }
Esempio n. 40
0
        /// <summary>
        /// Helper method to get all items from mirror data as flat list recursively.
        /// </summary>
        /// <param name="data">Input data</param>
        /// <returns>List of objects</returns>
        protected static IEnumerable<object> GetElementsFromMirrorData(MirrorData data)
        {
            if (data == null || data.IsNull)
                yield return null;

            if (data.IsCollection)
            {
                var elems = data.GetElements();
                foreach (var item in elems)
                {
                    var objs = GetElementsFromMirrorData(item);
                    foreach (var obj in objs)
                    {
                        yield return obj;
                    }
                }
            }

            yield return data.Data;
        }
Esempio n. 41
0
 /// <summary>
 /// It is possible for a run to complete while the preview display is
 /// in transition.  In these situations, we can store the MirrorData and
 /// set a flag to refresh the display.
 /// </summary>
 internal void EnqueueBindToDataSource(MirrorData mirrorData)
 {
     this.queuedMirrorData = mirrorData;
     this.queuedRefresh    = true;
 }
Esempio n. 42
0
        /// <summary>
        /// Convert mirror data objects for nodes to Revit types.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="geoms"></param>
        private void RevitGeometryFromMirrorData(MirrorData data, ref List<GeometryObject> geoms)
        {
            if (data.IsCollection)
            {
                foreach (var md in data.GetElements())
                {
                    try
                    {
                        RevitGeometryFromMirrorData(md, ref geoms);
                    }
                    catch (Exception ex)
                    {
                        this.dynamoModel.Logger.Log(ex.Message);
                    }
                }
            }
            else
            {
                try
                {
                    var geom = data.Data as PolyCurve;
                    if (geom != null)
                    {
                        // We extract the curves explicitly rather than using PolyCurve's ToRevitType
                        // extension method.  There is a potential issue with CurveLoop which causes
                        // this method to introduce corrupt GNodes.  
                        foreach (var c in geom.Curves())
                        {
                            // Tesselate the curve.  This greatly improves performance when
                            // we're dealing with NurbsCurve's with high knot count, commonly
                            // results of surf-surf intersections.
                            Tesselate(c, ref geoms);
                        }
                        
                        return;
                    }

                    var point = data.Data as Point;
                    if (point != null)
                    {
                        geoms.Add(DocumentManager.Instance.CurrentUIApplication.Application.Create.NewPoint(point.ToXyz()));
                        return;
                    }

                    var curve = data.Data as Curve;
                    if (curve != null)
                    {
                        // Tesselate the curve.  This greatly improves performance when
                        // we're dealing with NurbsCurve's with high knot count, commonly
                        // results of surf-surf intersections.
                        Tesselate(curve, ref geoms);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    this.dynamoModel.Logger.Log(ex.Message);
                }
            }
        }
Esempio n. 43
0
 /// <summary>
 /// Add labels for each of a mirror data object's inner
 /// data object to a label map.
 /// </summary>
 /// <param name="data"></param>
 /// <param name="map"></param>
 /// <param name="tag"></param>
 private void AddToLabelMap(MirrorData data, List<string> map, string tag)
 {
     if (data.IsCollection)
     {
         var list = data.GetElements();
         for (int i = 0; i < list.Count; i++)
         {
             AddToLabelMap(list[i], map, string.Format("{0}:{1}", tag, i));
         }
     }
     else if (data.Data is IEnumerable)
     {
         var list = data.Data as IEnumerable;
         AddToLabelMap(list, map, tag);
     }
     else
     {
         map.Add(tag);
     }
 }
Esempio n. 44
0
        private void OnNodeValueQueried(AsyncTask asyncTask)
        {
            lock (cachedMirrorDataMutex)
            {
                var task = asyncTask as QueryMirrorDataAsyncTask;
                cachedMirrorData = task.MirrorData;
            }

            RaisePropertyChanged("IsUpdated");
        }
Esempio n. 45
0
        /// <summary>
        /// Call this method to asynchronously update the cached MirrorData for 
        /// this NodeModel through DynamoScheduler. AstIdentifierForPreview is 
        /// being accessed within this method, therefore the method is typically
        /// called from the main/UI thread.
        /// </summary>
        /// 
        internal void RequestValueUpdateAsync(IScheduler scheduler, EngineController engine)
        {
            // A NodeModel should have its cachedMirrorData reset when it is 
            // requested to update its value. When the QueryMirrorDataAsyncTask 
            // returns, it will update cachedMirrorData with the latest value.
            // 
            lock (cachedMirrorDataMutex)
            {
                cachedMirrorData = null;
            }

            // Do not have an identifier for preview right now. For an example,
            // this can be happening at the beginning of a code block node creation.
            var variableName = AstIdentifierForPreview.Value;
            if (string.IsNullOrEmpty(variableName))
                return;

            var task = new QueryMirrorDataAsyncTask(new QueryMirrorDataParams
            {
                Scheduler = scheduler,
                EngineController = engine,
                VariableName = variableName
            });

            task.Completed += OnNodeValueQueried;
            scheduler.ScheduleForExecution(task);
        }
        private void GetRenderPackagesFromMirrorData(MirrorData mirrorData, bool displayLabels, bool isNodeSelected, ref List <string> labelMap, ref int count)
        {
            if (mirrorData.IsNull)
            {
                return;
            }

            if (mirrorData.IsCollection)
            {
                foreach (var el in mirrorData.GetElements())
                {
                    GetRenderPackagesFromMirrorData(el, displayLabels, isNodeSelected, ref labelMap, ref count);
                }
            }
            else
            {
                var graphicItem = mirrorData.Data as IGraphicItem;
                if (graphicItem == null)
                {
                    return;
                }

                var package = factory.CreateRenderPackage();
                package.Description = labelMap.Count > count ? labelMap[count] : "?";

                try
                {
                    graphicItem.Tessellate(package, factory.TessellationParameters);
                    if (package.MeshVertexColors.Count() > 0)
                    {
                        package.RequiresPerVertexColoration = true;
                    }

                    if (factory.TessellationParameters.ShowEdges)
                    {
                        var surf = graphicItem as Surface;
                        if (surf != null)
                        {
                            foreach (var curve in surf.PerimeterCurves())
                            {
                                curve.Tessellate(package, factory.TessellationParameters);
                                curve.Dispose();
                            }
                        }

                        var solid = graphicItem as Solid;
                        if (solid != null)
                        {
                            var edges = solid.Edges;
                            foreach (var geom in edges.Select(edge => edge.CurveGeometry))
                            {
                                geom.Tessellate(package, factory.TessellationParameters);
                                geom.Dispose();
                            }
                            edges.ForEach(x => x.Dispose());
                        }
                    }

                    var plane = graphicItem as Plane;
                    if (plane != null)
                    {
                        package.RequiresPerVertexColoration = true;

                        var s = 2.5;

                        var cs = CoordinateSystem.ByPlane(plane);
                        var a  = Point.ByCartesianCoordinates(cs, s, s, 0);
                        var b  = Point.ByCartesianCoordinates(cs, -s, s, 0);
                        var c  = Point.ByCartesianCoordinates(cs, -s, -s, 0);
                        var d  = Point.ByCartesianCoordinates(cs, s, -s, 0);

                        // Get rid of the original plane geometry.
                        package.Clear();

                        package.AddTriangleVertex(a.X, a.Y, a.Z);
                        package.AddTriangleVertex(b.X, b.Y, b.Z);
                        package.AddTriangleVertex(c.X, c.Y, c.Z);

                        package.AddTriangleVertex(c.X, c.Y, c.Z);
                        package.AddTriangleVertex(d.X, d.Y, d.Z);
                        package.AddTriangleVertex(a.X, a.Y, a.Z);

                        package.AddTriangleVertexUV(0, 0);
                        package.AddTriangleVertexUV(0, 0);
                        package.AddTriangleVertexUV(0, 0);
                        package.AddTriangleVertexUV(0, 0);
                        package.AddTriangleVertexUV(0, 0);
                        package.AddTriangleVertexUV(0, 0);

                        // Draw plane edges
                        package.AddLineStripVertex(a.X, a.Y, a.Z);
                        package.AddLineStripVertex(b.X, b.Y, b.Z);
                        package.AddLineStripVertex(b.X, b.Y, b.Z);
                        package.AddLineStripVertex(c.X, c.Y, c.Z);
                        package.AddLineStripVertex(c.X, c.Y, c.Z);
                        package.AddLineStripVertex(d.X, d.Y, d.Z);
                        package.AddLineStripVertex(d.X, d.Y, d.Z);
                        package.AddLineStripVertex(a.X, a.Y, a.Z);

                        // Draw normal
                        package.AddLineStripVertex(plane.Origin.X, plane.Origin.Y, plane.Origin.Z);
                        var nEnd = plane.Origin.Add(plane.Normal.Scale(2.5));
                        package.AddLineStripVertex(nEnd.X, nEnd.Y, nEnd.Z);

                        for (var i = 0; i < package.LineVertexCount / 2; i++)
                        {
                            package.AddLineStripVertexCount(2);
                        }

                        for (var i = 0; i < package.LineVertexCount; i++)
                        {
                            package.AddLineStripVertexColor(MidTone, MidTone, MidTone, 255);
                        }

                        for (var i = 0; i < package.MeshVertexCount; i++)
                        {
                            package.AddTriangleVertexNormal(plane.Normal.X, plane.Normal.Y, plane.Normal.Z);
                        }

                        for (var i = 0; i < package.MeshVertexCount; i++)
                        {
                            package.AddTriangleVertexColor(0, 0, 0, 10);
                        }
                    }

                    // The default color coming from the geometry library for
                    // curves is 255,255,255,255 (White). Because we want a default
                    // color of 0,0,0,255 (Black), we adjust the color components here.
                    if (graphicItem is Curve || graphicItem is Surface || graphicItem is Solid || graphicItem is Point)
                    {
                        if (package.LineVertexCount > 0 && package.LineStripVertexColors.Count() <= 0)
                        {
                            package.ApplyLineVertexColors(CreateColorByteArrayOfSize(package.LineVertexCount, DefR, DefG, DefB, DefA));
                        }

                        if (package.PointVertexCount > 0 && package.PointVertexColors.Count() <= 0)
                        {
                            package.ApplyPointVertexColors(CreateColorByteArrayOfSize(package.PointVertexCount, DefR, DefG, DefB, DefA));
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine(
                        "PushGraphicItemIntoPackage: " + e);
                }

                package.DisplayLabels = displayLabels;
                package.IsSelected    = isNodeSelected;

                renderPackages.Add(package);
                count++;
            }
        }
Esempio n. 47
0
        /// <summary>
        /// Bind a mirror data to the preview control for display, this call 
        /// unbinds the internal data structure from the view that it was 
        /// originally bound to and resets the data structure. If this call is 
        /// made while the preview control is in condensed or expanded state,
        /// the display will immediately be refreshed. Since this method deals 
        /// with UI elements internally, it must be called from the UI thread.
        /// </summary>
        /// <param name="mirrorData">The mirror data to bind the preview control
        /// to. This value can be null to reset the preview control to its 
        /// initial state.</param>
        /// 
        internal void BindToDataSource(MirrorData mirrorData)
        {
            // First detach the bound data from its view.
            ResetContentViews();

            this.mirrorData = mirrorData;
            this.cachedLargeContent = null; // Reset expanded content.
            this.cachedSmallContent = null; // Reset condensed content.

            // If at the time of data binding the preview control is within the 
            // following states, then its contents need to be updated immediately.
            if (this.IsCondensed)
            {
                RefreshCondensedDisplay();
                BeginViewSizeTransition(ComputeSmallContentSize());
            }
            else if (this.IsExpanded)
            {
                RefreshExpandedDisplay();
                BeginViewSizeTransition(ComputeLargeContentSize());
            }
        }
        protected void AssertValue(MirrorData data, object value)
        {
            if (data.IsCollection)
            {
                if (!(value is IEnumerable))
                {
                    Assert.Fail("Data is collection but expected value is not.");
                }
                AssertCollection(data, value as IEnumerable);
            }
            else if (value == null)
            {
                Assert.IsTrue(data.IsNull, String.Format("Data {0} is not null", data.StringData));
            }
            else if (value is int)
            {
                try
                {
                    int mirrorData = Convert.ToInt32(data.Data);
                    Assert.AreEqual((int)value, mirrorData, String.Format("Integer values are not equal value: {0} and data {1}", value, mirrorData));
                }
                catch (Exception e)
                {
                    Assert.Fail(String.Format("Failed on Int assertion data {0} with this message: {1}", data.StringData, e.Message));
                }
            }
            else if (value is double)
            {
                try
                {
                    double mirrorData = Convert.ToDouble(data.Data);
                    Assert.AreEqual((double)value, mirrorData, 0.00001, String.Format("Double values are not equal value: {0} and data {1}", value, mirrorData));
                }
                catch (Exception e)
                {
                    Assert.Fail(String.Format("Failed on Double assertion data {0} with this message: {1}", data.StringData, e.Message));
                }
            }
            else if (data.IsPointer && data.Class.ClassName == "Function")
            {
                Assert.AreEqual(data.Class.ClassName, value, String.Format("Failed to validate the finding of Function {0},  value {1}", data.Class.ClassName, value));
            }
            else if (data.IsDictionary)
            {
                var thisData = data.Data as DesignScript.Builtin.Dictionary;

                if (value is DesignScript.Builtin.Dictionary)
                {
                    var otherVal = (DesignScript.Builtin.Dictionary)value;

                    Assert.AreEqual(otherVal.Count, thisData.Count, String.Format("The number of elements on the collections (DesignScript.Builtin.Dictionary) didn't match, value size: {0} data size: {1} , so data and expected value are 2 different dictionaries", otherVal.Count, thisData.Count));

                    foreach (var key in otherVal.Keys)
                    {
                        var val = thisData.ValueAtKey(key);

                        Assert.IsNotNull(val, String.Format("Element with key {0} was not found on the  data DesignScript.Builtin.Dictionary, so data and expected value are 2 different dictionaries.", key));

                        if (val.GetType().IsValueType)
                        {
                            Assert.AreEqual(val, thisData.ValueAtKey(key), String.Format("Elements with key {0} are not equal on the dictionaries (DesignScript.Builtin.Dictionary), value element: {1} and data element: {2}", key, val, thisData.ValueAtKey(key)));
                        }
                    }
                }
                else if (value is IDictionary)
                {
                    var otherVal = (IDictionary)value;

                    Assert.AreEqual(otherVal.Count, thisData.Count, String.Format("The number of elements on the collections (IDictionary) didn't match, value size: {0} data size: {1} , so data and expected value are 2 different dictionaries", otherVal.Count, thisData.Count));

                    foreach (var key in otherVal.Keys)
                    {
                        Assert.IsTrue(key is string, String.Format("The key {0} on the value dictionary is not a string", key));

                        var strKey = (string)key;
                        var val    = thisData.ValueAtKey(strKey);

                        Assert.IsNotNull(val, String.Format("Element with key {0} was not found on the  data IDictionary, so data and expected value are 2 different dictionaries.", strKey));

                        if (val.GetType().IsValueType)
                        {
                            Assert.AreEqual(val, thisData.ValueAtKey(strKey), String.Format("Elements with key {0} are not equal on the dictionaries (IDictionary), value element: {1} and data element: {2}", strKey, val, thisData.ValueAtKey(strKey)));
                        }
                    }
                }
            }
            else
            {
                Assert.AreEqual(value, data.Data, String.Format("The value {0} and data {1} are not equal", value, data));
            }
        }
Esempio n. 49
0
        private void GetRenderPackagesFromMirrorData(MirrorData mirrorData, bool displayLabels, bool isNodeSelected, ref List<string> labelMap, ref int count)
        {
            if (mirrorData.IsNull)
            {
                return;
            }

            if (mirrorData.IsCollection)
            {
                foreach (var el in mirrorData.GetElements())
                {
                    GetRenderPackagesFromMirrorData(el, displayLabels, isNodeSelected, ref labelMap, ref count);
                }
            }
            else
            {
                var graphicItem = mirrorData.Data as IGraphicItem;
                if (graphicItem == null)
                {
                    return;
                }

                var package = factory.CreateRenderPackage();
                package.Description = labelMap.Count > count ? labelMap[count] : "?";

                try
                {
                    graphicItem.Tessellate(package, factory.TessellationParameters);

                    if (factory.TessellationParameters.ShowEdges)
                    {
                        var surf = graphicItem as Surface;
                        if (surf != null)
                        {
                            foreach (var curve in surf.PerimeterCurves())
                            {
                                curve.Tessellate(package, factory.TessellationParameters);
                                curve.Dispose();
                            }
                        }

                        var solid = graphicItem as Solid;
                        if (solid != null)
                        {
                            var edges = solid.Edges;
                            foreach (var geom in edges.Select(edge => edge.CurveGeometry))
                            {
                                geom.Tessellate(package, factory.TessellationParameters);
                                geom.Dispose();
                            }
                            edges.ForEach(x => x.Dispose());
                        }
                    }
                    
                    var plane = graphicItem as Plane;
                    if (plane != null)
                    {
                        package.RequiresPerVertexColoration = true;

                        var s = 2.5;

                        var cs = CoordinateSystem.ByPlane(plane);
                        var a = Point.ByCartesianCoordinates(cs, s, s, 0);
                        var b = Point.ByCartesianCoordinates(cs, -s, s, 0);
                        var c = Point.ByCartesianCoordinates(cs, -s, -s, 0);
                        var d = Point.ByCartesianCoordinates(cs, s, -s, 0);

                        // Get rid of the original plane geometry.
                        package.Clear();

                        package.AddTriangleVertex(a.X, a.Y, a.Z);
                        package.AddTriangleVertex(b.X, b.Y, b.Z);
                        package.AddTriangleVertex(c.X, c.Y, c.Z);

                        package.AddTriangleVertex(c.X, c.Y, c.Z);
                        package.AddTriangleVertex(d.X, d.Y, d.Z);
                        package.AddTriangleVertex(a.X, a.Y, a.Z);

                        package.AddTriangleVertexUV(0, 0);
                        package.AddTriangleVertexUV(0, 0);
                        package.AddTriangleVertexUV(0, 0);
                        package.AddTriangleVertexUV(0, 0);
                        package.AddTriangleVertexUV(0, 0);
                        package.AddTriangleVertexUV(0, 0);

                        // Draw plane edges
                        package.AddLineStripVertex(a.X, a.Y, a.Z);
                        package.AddLineStripVertex(b.X, b.Y, b.Z);
                        package.AddLineStripVertex(b.X, b.Y, b.Z);
                        package.AddLineStripVertex(c.X, c.Y, c.Z);
                        package.AddLineStripVertex(c.X, c.Y, c.Z);
                        package.AddLineStripVertex(d.X, d.Y, d.Z);
                        package.AddLineStripVertex(d.X, d.Y, d.Z);
                        package.AddLineStripVertex(a.X, a.Y, a.Z);

                        // Draw normal
                        package.AddLineStripVertex(plane.Origin.X, plane.Origin.Y, plane.Origin.Z);
                        var nEnd = plane.Origin.Add(plane.Normal.Scale(2.5));
                        package.AddLineStripVertex(nEnd.X, nEnd.Y, nEnd.Z);

                        for (var i = 0; i < package.LineVertexCount / 2; i++)
                        {
                            package.AddLineStripVertexCount(2);
                        }

                        for (var i = 0; i < package.LineVertexCount; i ++)
                        {
                            package.AddLineStripVertexColor(MidTone, MidTone, MidTone, 255);
                        }

                        for (var i = 0; i < package.MeshVertexCount; i++)
                        {
                            package.AddTriangleVertexNormal(plane.Normal.X, plane.Normal.Y, plane.Normal.Z);
                        }

                        for (var i = 0; i < package.MeshVertexCount; i++)
                        {
                            package.AddTriangleVertexColor(0, 0, 0, 10);
                        }
                    }

                    // The default color coming from the geometry library for
                    // curves is 255,255,255,255 (White). Because we want a default
                    // color of 0,0,0,255 (Black), we adjust the color components here.
                    if (graphicItem is Curve || graphicItem is Surface || graphicItem is Solid || graphicItem is Point)
                    {
                        if (package.LineVertexCount > 0)
                        {
                            package.ApplyLineVertexColors(CreateColorByteArrayOfSize(package.LineVertexCount, DefR, DefG, DefB, DefA));
                        }

                        if (package.PointVertexCount > 0)
                        {
                            package.ApplyPointVertexColors(CreateColorByteArrayOfSize(package.PointVertexCount, DefR, DefG, DefB, DefA));
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine(
                        "PushGraphicItemIntoPackage: " + e);
                }

                package.DisplayLabels = displayLabels;
                package.IsSelected = isNodeSelected;

                renderPackages.Add(package);
                count++;
            }
        }
Esempio n. 50
0
 private void AddToSizeMap(MirrorData data, ICollection<double> map)
 {
     if (data.IsCollection)
     {
         var list = data.GetElements();
         foreach (MirrorData t in list)
         {
             AddToSizeMap(t, map);
         }
     }
     else if (data.Data is IEnumerable)
     {
         var list = data.Data as IEnumerable;
         AddToSizeMap(list, map);
     }
     else
     {
         map.Add(ComputeBBoxDiagonalSize(data.Data));
     }
 }
        private void BeginNextTransition()
        {
            // A run completed while in transition, we must refresh
            if (queuedRefresh)
            {
                queuedRefresh = false;
                BindToDataSource(queuedMirrorData);
                this.queuedMirrorData = null;
                return;
            }

            if (this.IsInTransition || queuedRequest.Count <= 0)
                return; // Nothing else to do.

            State requestedState = queuedRequest.Dequeue();
            while (requestedState == this.currentState)
            {
                if (queuedRequest.Count <= 0)
                    return; // There's no more request for now.
                requestedState = queuedRequest.Dequeue();
            }

            if (requestedState == State.Hidden)
            {
                BeginFadeOutTransition();
            }
            else if (requestedState == State.Condensed)
            {
                if (this.IsHidden != false)
                    BeginFadeInTransition();
                else if (this.IsExpanded != false)
                    BeginCondenseTransition();
            }
            else if (requestedState == State.Expanded)
            {
                BeginExpandTransition();
            }
        }
Esempio n. 52
0
        private void SelectivelyAssertValues(MirrorData data, Dictionary<int, object> selectedValues)
        {
            Assert.IsTrue(data.IsCollection);

            if (data.IsCollection)
            {
                List<MirrorData> elements = data.GetElements();
                foreach (var pair in selectedValues)
                {
                    AssertValue(elements[pair.Key], pair.Value);
                }
            }
        }
Esempio n. 53
0
        /// <summary>
        /// Convert mirror data objects for nodes to Revit types.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="geoms"></param>
        private void RevitGeometryFromMirrorData(MirrorData data, ref List<GeometryObject> geoms)
        {
            if (data.IsCollection)
            {
                foreach (var md in data.GetElements())
                {
                    try
                    {
                        RevitGeometryFromMirrorData(md, ref geoms);
                    }
                    catch (Exception ex)
                    {
                        this.dynamoModel.Logger.Log(ex.Message);
                    }
                }
            }
            else
            {
                try
                {
                    var geom = data.Data as PolyCurve;
                    if (geom != null)
                    {
                        geoms.AddRange(geom.ToRevitType());
                        return;
                    }

                    var point = data.Data as Point;
                    if (point != null)
                    {
                        geoms.Add(DocumentManager.Instance.CurrentUIApplication.Application.Create.NewPoint(point.ToXyz()));
                        return;
                    }

                    var curve = data.Data as Curve;
                    if (curve != null)
                    {
                        geoms.Add(curve.ToRevitType());
                        return;
                    }
                }
                catch (Exception ex)
                {
                    this.dynamoModel.Logger.Log(ex.Message);
                }
            }
        }
Esempio n. 54
0
 private void AssertMirrorData(MirrorData data1, MirrorData data2)
 {
     if (data1.IsNull)
         Assert.True(data2.IsNull);
     else if (data1.IsCollection)
     {
         Assert.True(data2.IsCollection);
         List<MirrorData> elems1 = data1.GetElements();
         List<MirrorData> elems2 = data2.GetElements();
         Assert.AreEqual(elems1.Count, elems2.Count);
         int i = 0;
         foreach (var item in elems1)
         {
             AssertMirrorData(item, elems2[i++]);
         }
     }
     else
         Assert.AreEqual(data1.Data, data2.Data);
 }
Esempio n. 55
0
        /// <summary>
        /// Counts the number of all collection items of node output and if specified
        /// it generates appropriate view model for compact preview bubble
        /// </summary>
        /// <param name="mirrorData">Data which represents the value of node output</param>
        /// <param name="generateViewModel">Flag to not create unused view models</param>
        /// <returns><cref name="CompactBubbleViewModel"/> instance
        /// if <paramref name="generateViewModel"/> is specified. Otherwise, null</returns>
        private static CompactBubbleViewModel ProcessThing(MirrorData mirrorData, bool generateViewModel)
        {
            if (mirrorData == null)
            {
                return(generateViewModel ? new CompactBubbleViewModel(Resources.NullString, 0) : null);
            }

            if (mirrorData.IsCollection)
            {
                var list = mirrorData.GetElements();

                foreach (var item in list)
                {
                    ProcessThing(item, false);
                }

                return(generateViewModel
                    ? new CompactBubbleViewModel(true)
                {
                    NodeLabel = list.Any() ? WatchViewModel.LIST : WatchViewModel.EMPTY_LIST
                }
                    : null);
            }
            else if (mirrorData.IsPointer && mirrorData.Data is DesignScript.Builtin.Dictionary)
            {
                var dict = mirrorData.Data as DesignScript.Builtin.Dictionary;

                return(generateViewModel
                    ? new CompactBubbleViewModel(true)
                {
                    NodeLabel = dict.Values.Any() ? WatchViewModel.DICTIONARY : WatchViewModel.EMPTY_DICTIONARY
                }
                    : null);
            }

            items++;

            if (!generateViewModel)
            {
                return(null);
            }

            var viewModel = new CompactBubbleViewModel(false);

            if (mirrorData.Data == null && !mirrorData.IsNull && mirrorData.Class != null)
            {
                viewModel.NodeLabel = mirrorData.Class.ClassName;
            }
            else if (mirrorData.Data is Enum)
            {
                viewModel.NodeLabel = ((Enum)mirrorData.Data).GetDescription();
            }
            else
            {
                // Cut StringData so that only the type name remains
                // for example, "Point (Z = 0.000, Y = 0.000, Z = 0.000)" -> "Point"
                viewModel.NodeLabel = string.IsNullOrEmpty(mirrorData.StringData)
                    ? string.Empty
                    : mirrorData.StringData.Split('(')[0];
            }

            return(viewModel);
        }
Esempio n. 56
0
 private void AssertCollection(MirrorData data, IEnumerable collection)
 {
     Assert.IsTrue(data.IsCollection);
     List<MirrorData> elements = data.GetElements();
     int i = 0;
     foreach (var item in collection)
     {
         AssertValue(elements[i++], item);
     }
 }
        /// <summary>
        /// Convert mirror data objects for nodes to Revit types.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="geoms"></param>
        private void RevitGeometryFromMirrorData(MirrorData data, ref List <GeometryObject> geoms)
        {
            if (data.IsCollection)
            {
                foreach (var md in data.GetElements())
                {
                    try
                    {
                        RevitGeometryFromMirrorData(md, ref geoms);
                    }
                    catch (Exception ex)
                    {
                        this.dynamoModel.Logger.Log(ex.Message);
                    }
                }
            }
            else
            {
                try
                {
                    if (data.Data == null)
                    {
                        return;
                    }

                    var geom = data.Data as PolyCurve;
                    if (geom != null)
                    {
                        // We extract the curves explicitly rather than using PolyCurve's ToRevitType
                        // extension method.  There is a potential issue with CurveLoop which causes
                        // this method to introduce corrupt GNodes.
                        foreach (var c in geom.Curves())
                        {
                            // Tesselate the curve.  This greatly improves performance when
                            // we're dealing with NurbsCurve's with high knot count, commonly
                            // results of surf-surf intersections.
                            Tesselate(c, ref geoms);
                        }

                        return;
                    }

                    var point = data.Data as Point;
                    if (point != null)
                    {
                        geoms.Add(DocumentManager.Instance.CurrentUIApplication.Application.Create.NewPoint(point.ToXyz()));
                        return;
                    }

                    var curve = data.Data as Curve;
                    if (curve != null)
                    {
                        // Tesselate the curve.  This greatly improves performance when
                        // we're dealing with NurbsCurve's with high knot count, commonly
                        // results of surf-surf intersections.
                        Tesselate(curve, ref geoms);
                        return;
                    }

                    var surf = data.Data as Surface;
                    if (surf != null)
                    {
                        geoms.AddRange(surf.ToRevitType());
                        return;
                    }

                    var solid = data.Data as Autodesk.DesignScript.Geometry.Solid;
                    if (solid != null)
                    {
                        geoms.AddRange(solid.ToRevitType());
                        return;
                    }
                }
                catch (Exception ex)
                {
                    this.dynamoModel.Logger.Log(ex.Message);
                }
            }
        }
 // Add labels for each of a mirror data object's inner data object to a label map.
 private static void AddToLabelMap(MirrorData data, List<string> map, string tag)
 {
     if (data.IsCollection)
     {
         var index = 0;
         var elements = data.GetElements();
         foreach (var element in elements)
         {
             var newTag = string.Format("{0}:{1}", tag, index++);
             AddToLabelMap(element, map, newTag);
         }
     }
     else if (data.Data is IEnumerable)
     {
         AddToLabelMap(data.Data as IEnumerable, map, tag);
     }
     else
     {
         map.Add(tag);
     }
 }
Esempio n. 59
0
        /// <summary>
        /// WARNING: This method is meant for unit test only. It directly accesses
        /// the EngineController for the mirror data without waiting for any 
        /// possible execution to complete (which, in single-threaded nature of 
        /// unit test, is an okay thing to do). The right way to get the cached 
        /// value for a NodeModel is by going through its RequestValueUpdateAsync
        /// method).
        /// </summary>
        /// <param name="engine">Instance of EngineController from which the node
        /// value is to be retrieved.</param>
        /// <returns>Returns the MirrorData if the node's value is computed, or 
        /// null otherwise.</returns>
        /// 
        internal MirrorData GetCachedValueFromEngine(EngineController engine)
        {
            if (cachedMirrorData != null)
                return cachedMirrorData;

            // Do not have an identifier for preview right now. For an example,
            // this can be happening at the beginning of a code block node creation.
            if (AstIdentifierForPreview.Value == null)
                return null;

            cachedMirrorData = null;

            var runtimeMirror = engine.GetMirror(AstIdentifierForPreview.Value);

            if (runtimeMirror != null)
                cachedMirrorData = runtimeMirror.GetData();

            return cachedMirrorData;
        }
Esempio n. 60
0
        private WatchViewModel ProcessThing(MirrorData data, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
        {
            if (data.IsCollection)
            {
                var list = data.GetElements();

                var node = new WatchViewModel(list.Count == 0 ? "Empty List" : "List", tag, RequestSelectGeometry, true);
                foreach (var e in list.Select((element, idx) => new { element, idx }))
                {
                    node.Children.Add(ProcessThing(e.element, runtimeCore, tag + ":" + e.idx, showRawData, callback));
                }

                return node;
            }
            if (data.Data is Enum)
            {
                return new WatchViewModel(((Enum)data.Data).GetDescription(), tag, RequestSelectGeometry);
            }

            if (data.Data == null)
            {
                // MAGN-3494: If "data.Data" is null, then return a "null" string 
                // representation instead of casting it as dynamic (that leads to 
                // a crash).
                if (data.IsNull)
                    return new WatchViewModel(NULL_STRING, tag, RequestSelectGeometry);
                
                //If the input data is an instance of a class, create a watch node
                //with the class name and let WatchHandler process the underlying CLR data
                var classMirror = data.Class;
                if (null != classMirror)
                {
                    //just show the class name.
                    return ProcessThing(classMirror.ClassName, runtimeCore, tag, showRawData, callback);
                }
            }

            //Finally for all else get the string representation of data as watch content.
            return callback(data.Data, runtimeCore, tag, showRawData);
        }