private void setSeriesValues(CurveData <ScatterXValue, ScatterYValue> series, DataRow row, string yFieldName)
        {
            // find row with yField / data for y-Values
            var pkValues = row.GetPrimaryKeyValues();

            pkValues[0] = yFieldName;
            DataRow yFieldRow = _data.Rows.Find(pkValues);

            var xValues = (float[])row[_aggregationName];
            var yValues = (float[])yFieldRow[_aggregationName];

            if (xValues.Length != yValues.Length)
            {
                throw new InvalidDataException(PKSimConstants.Error.DifferentVectorLengths);
            }

            for (int i = 0; i < xValues.Length; i++)
            {
                var scatterValue = new ScatterYValue(yValues[i]);
                if (scatterValue.IsValid)
                {
                    series.Add(new ScatterXValue(xValues[i]), scatterValue);
                }
            }
        }
 public void SetCurveAddress(CurveData data)
 {
     curveData = data;
     process   = 0;
     offset    = 0;
     angle     = 0;
 }
    public void ToCurveAddress(CurveData data, Action action = null)
    {
        if (data != null && data != curveData)
        {
            manaul          = false;
            inTransition    = true;
            transitionCurve = data;


            nearPosition  = target.position;
            nearDirection = directionCurve.Evaluate((process / positionCurve.length) * directionCurve.length + offset);

            float minDis = float.MaxValue;
            float length = 0;
            toProcess = 0;
            for (int i = 0; i < data.position.smoothCount - 1; i++)
            {
                length += Vector3.Distance(data.position.GetSmoothPoint(i), data.position.GetSmoothPoint(i + 1));
                float distance = Vector3.Distance(nearPosition, data.position.GetSmoothPoint(i));
                if (distance < minDis)
                {
                    minDis    = distance;
                    toProcess = length;
                }
            }
            toPosition  = data.position.Evaluate(toProcess);
            toDirection = data.direction.Evaluate(toProcess / data.position.length * data.direction.length);

            toEndAction = action;
            StartCoroutine(InTransition());
        }
    }
        private IEnumerable <DataRow> addSpecificChartValues <TX, TY>(DataRow row, CurveData <TX, TY> curveData, bool exportForPivot)
            where TX : TimeProfileXValue
            where TY : ITimeProfileYValue
        {
            var newRows = new List <DataRow>();

            for (var i = 0; i < curveData.XValues.Count; i++)
            {
                var newRow = row.Table.NewRow();
                newRow.ItemArray = row.ItemArray;
                var xValue = ValueForDataTableFor(curveData.XAxis, curveData.XValues[i].X);

                if (exportForPivot)
                {
                    newRow[_xValueColumn] = xValue.ConvertedTo <string>();
                }
                else
                {
                    newRow[_xValueColumn] = xValue;
                }

                newRow[_yLowerValueColumn] = ValueForDataTableFor(curveData.YAxis, curveData.YValues[i].LowerValue);
                newRow[_yValueColumn]      = ValueForDataTableFor(curveData.YAxis, curveData.YValues[i].Y);
                newRow[_yUpperValueColumn] = ValueForDataTableFor(curveData.YAxis, curveData.YValues[i].UpperValue);
                newRows.Add(newRow);
            }
            return(newRows);
        }
Exemple #5
0
    private void RemoveSelected()
    {
        bool flag = false;
        List <CurveSelection> selectedCurves = this.m_CurveEditor.selectedCurves;

        for (int i = 0; i < selectedCurves.Count; i++)
        {
            int curveID = selectedCurves[i].curveID;
            for (int j = 0; j < this.m_AddedCurves.Count; j++)
            {
                CurveData data = this.m_AddedCurves[j];
                if ((data.m_MaxId == curveID) || (data.m_MinId == curveID))
                {
                    flag |= this.Remove(j);
                    break;
                }
            }
        }
        if (flag)
        {
            this.ContentChanged();
            this.UpdateRangeBasedOnShownCurves();
        }
        this.m_CurveEditor.SelectNone();
    }
Exemple #6
0
        private List <CurveData> MergeCachedAndRealTimesCurves(List <CurveData> cache, List <CurveData> realtime)
        {
            List <CurveData> list = new List <CurveData>();
            Dictionary <string, CurveData> dictionary  = new Dictionary <string, CurveData>();
            Dictionary <string, CurveData> dictionary2 = new Dictionary <string, CurveData>();

            foreach (CurveData data in realtime)
            {
                dictionary[data.Key] = data;
            }
            foreach (CurveData data in cache)
            {
                dictionary2[data.Key] = data;
                if (dictionary.ContainsKey(data.Key))
                {
                    CurveData data2 = dictionary[data.Key];
                    data.Points.AddRange(data2.Points);
                }
                list.Add(data);
            }
            foreach (CurveData data in realtime)
            {
                if (!dictionary2.ContainsKey(data.Key))
                {
                    list.Add(data);
                }
            }
            return(list);
        }
Exemple #7
0
        protected override void SetCurveSettings(CurveData <TimeProfileXValue, TimeProfileYValue> series, DataRow row)
        {
            var outputField = _analysis.FieldByName(row[_dataColumnName].ToString()).DowncastTo <PopulationAnalysisOutputField>();

            series.Color = outputField.Color;

            var statisticalAggregation = row[STATISTICAL_AGGREGATION].DowncastTo <StatisticalAggregation>();

            series.LineStyle = statisticalAggregation.LineStyle;

            var colorField = _analysis.ColorField;

            if (colorField == null)
            {
                return;
            }

            var groupitem = colorField.GroupingByName(row[colorField.Name].ToString());

            if (groupitem == null)
            {
                return;
            }
            series.Color = groupitem.Color;
        }
    IEnumerator InTransition()
    {
        float nowTime = 0;
        float value   = 0;

        while (nowTime <= toTime)
        {
            value           = nowTime / toTime;
            target.position = Vector3.Lerp(nearPosition, toPosition, value * value);
            target.LookAt(Vector3.Lerp(nearDirection, toDirection, value), Vector3.up);

            nowTime += Time.deltaTime;
            yield return(new WaitForEndOfFrame());
        }

        offset       = 0;
        angle        = 0;
        process      = toProcess;
        curveData    = transitionCurve;
        inTransition = false;
        manaul       = true;

        if (toEndAction != null)
        {
            Action action = toEndAction;
            action.Invoke();
            toEndAction = null;
        }
    }
    private void RemoveSelected()
    {
        bool anyRemoved = false;
        List <CurveSelection> selection = m_CurveEditor.selectedCurves;

        for (int i = 0; i < selection.Count; ++i)
        {
            int curveId = selection[i].curveID;
            for (int j = 0; j < m_AddedCurves.Count; ++j)
            {
                CurveData cd = m_AddedCurves[j];
                if (cd.m_MaxId == curveId || cd.m_MinId == curveId)
                {
                    anyRemoved |= Remove(j);
                    break;
                }
            }
        }
        if (anyRemoved)
        {
            ContentChanged();
            UpdateRangeBasedOnShownCurves();
        }
        m_CurveEditor.SelectNone();
    }
Exemple #10
0
        protected override IReadOnlyList <Series> CreateCurveSeriesList(CurveData <ScatterXValue, ScatterYValue> curveData)
        {
            var series = CreateSeries(curveData, ViewType.Point)
                         .WithPoints(CreateSeriesPoints(curveData, y => y.Value));

            return(new[] { series });
        }
 private void SetTopMostCurve(DoubleCurve doubleCurve)
 {
     int num;
     if (this.m_CurveEditor.GetTopMostCurveID(out num))
     {
         for (int i = 0; i < this.m_AddedCurves.Count; i++)
         {
             CurveData data = this.m_AddedCurves[i];
             if ((data.m_MaxId == num) || (data.m_MinId == num))
             {
                 if (doubleCurve.signedRange == data.m_SignedRange)
                 {
                     if (data.m_MaxId > 0)
                     {
                         this.SetCurve(this.m_CurveEditor.GetCurveFromID(data.m_MaxId), doubleCurve.maxCurve);
                     }
                     if (data.m_MinId > 0)
                     {
                         this.SetCurve(this.m_CurveEditor.GetCurveFromID(data.m_MinId), doubleCurve.minCurve);
                     }
                 }
                 else
                 {
                     Debug.LogWarning("Cannot assign a curves with different signed range");
                 }
             }
         }
     }
 }
 private CurveWrapper[] CreateCurveWrapperArray()
 {
     List<CurveWrapper> list = new List<CurveWrapper>();
     int num = 0;
     for (int i = 0; i < this.m_AddedCurves.Count; i++)
     {
         CurveData data = this.m_AddedCurves[i];
         if (data.m_Visible)
         {
             int regionId = -1;
             if (data.IsRegion())
             {
                 regionId = ++num;
             }
             if (data.m_Max != null)
             {
                 list.Add(this.CreateCurveWrapper(data.m_Max, data.m_MaxId, regionId, data.m_Color, data.m_SignedRange, data.m_GetAxisScalarsCallback, data.m_SetAxisScalarsCallback));
             }
             if (data.m_Min != null)
             {
                 list.Add(this.CreateCurveWrapper(data.m_Min, data.m_MinId, regionId, data.m_Color, data.m_SignedRange, data.m_GetAxisScalarsCallback, data.m_SetAxisScalarsCallback));
             }
         }
     }
     return list.ToArray();
 }
 private DoubleCurve CreateDoubleCurveFromTopMostCurve()
 {
     int num;
     if (this.m_CurveEditor.GetTopMostCurveID(out num))
     {
         for (int i = 0; i < this.m_AddedCurves.Count; i++)
         {
             CurveData data = this.m_AddedCurves[i];
             if ((data.m_MaxId == num) || (data.m_MinId == num))
             {
                 AnimationCurve maxCurve = null;
                 AnimationCurve minCurve = null;
                 if (data.m_Min != null)
                 {
                     minCurve = data.m_Min.animationCurveValue;
                 }
                 if (data.m_Max != null)
                 {
                     maxCurve = data.m_Max.animationCurveValue;
                 }
                 return new DoubleCurve(minCurve, maxCurve, data.m_SignedRange);
             }
         }
     }
     return null;
 }
    DoubleCurve CreateDoubleCurveFromTopMostCurve()
    {
        int topMostCurveID;

        if (m_CurveEditor.GetTopMostCurveID(out topMostCurveID))
        {
            for (int j = 0; j < m_AddedCurves.Count; ++j)
            {
                CurveData cd = m_AddedCurves[j];
                if (cd.m_MaxId == topMostCurveID || cd.m_MinId == topMostCurveID)
                {
                    AnimationCurve maxCurve = null, minCurve = null;
                    if (cd.m_Min != null)
                    {
                        minCurve = cd.m_Min.animationCurveValue;
                    }
                    if (cd.m_Max != null)
                    {
                        maxCurve = cd.m_Max.animationCurveValue;
                    }
                    return(new DoubleCurve(minCurve, maxCurve, cd.m_SignedRange));
                }
            }
        }
        return(null);
    }
Exemple #15
0
        public static CurveData <BoxWhiskerXValue, BoxWhiskerYValue> CreateBoxWhiskerCurveData(PaneData <BoxWhiskerXValue, BoxWhiskerYValue> paneData, string name, IList <BoxWhiskerXYValue> bwValues)
        {
            var curveData = new CurveData <BoxWhiskerXValue, BoxWhiskerYValue>(new Dictionary <string, string> {
                { name, name }
            })
            {
                Id      = name,
                Caption = name
            };

            foreach (var v in bwValues)
            {
                var X = new BoxWhiskerXValue(new List <string>()
                {
                    v.X1, v.X2
                });
                var Y = new BoxWhiskerYValue
                {
                    LowerWhisker = new ValueWithIndvividualId(v.LW),
                    LowerBox     = new ValueWithIndvividualId(v.LW),
                    Median       = new ValueWithIndvividualId(v.M),
                    UpperBox     = new ValueWithIndvividualId(v.LW),
                    UpperWhisker = new ValueWithIndvividualId(v.LW),
                };
                curveData.Add(X, Y);
            }

            return(curveData);
        }
    public void Save()
    {
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.dataPath + "/ProceduralTracks/CurvesSavedData/" + gameObject.name + transform.parent.GetComponent <Track>().id + ".curve");

        CurveData data = new CurveData();

        List <NodeData> _nodesData = new List <NodeData>();

        if (nodes != null)
        {
            foreach (Node n in nodes)
            {
                _nodesData.Add(n.Serialize());
            }
        }
        data.nodesData = _nodesData.ToArray();

        List <BezierData> _splinesData = new List <BezierData>();

        foreach (BezierSpline b in splines)
        {
            _splinesData.Add(b.GetData());
        }
        data.splinesData = _splinesData.ToArray();

        data.closed    = this.closed;
        data.invisible = this.invisible;

        bf.Serialize(file, data);
        file.Close();
    }
        void ConvertCamera(UsdCamera cam, string path)
        {
            if (cam == null)
            {
                return;
            }

            var tcam = typeof(Camera);
            var cvs  = new CurveData[] {
                new CurveData(tcam, path, "near clip plane", epsilon_Camera),
                new CurveData(tcam, path, "far clip plane", epsilon_Camera),
                new CurveData(tcam, path, "field of view", epsilon_Camera),
            };

            usdi.usdiCameraEachSample(cam.nativeCameraPtr, (ref usdi.CameraData data, double t_) =>
            {
                float t = (float)t_ * m_rcpTimeScale;
                cvs[0].curve.AddKey(t, data.near_clipping_plane);
                cvs[1].curve.AddKey(t, data.far_clipping_plane);
                cvs[2].curve.AddKey(t, data.field_of_view);
            });

            if (m_keyframeReduction)
            {
                foreach (var c in cvs)
                {
                    DoReduction(c);
                }
            }
            foreach (var c in cvs)
            {
                c.Set(m_animClip);
            }
        }
Exemple #18
0
        private void setCurveDataValues(CurveData <RangeXValue, RangeYValue> series, DataRow xFieldRow, string yFieldName)
        {
            // find row with yField / data for y-Values
            var pkValues = xFieldRow.GetPrimaryKeyValues();

            pkValues[0] = yFieldName; // DATA_FIELD-column first, see CreatePrimaryKey
            DataRow yFieldRow = _data.Rows.Find(pkValues);

            var xValues = xFieldRow[_aggreationName] as float[];
            var yValues = yFieldRow[_aggreationName] as float[];

            //possible if no values are defined for the row filter
            if (xValues == null || yValues == null)
            {
                return;
            }

            if (xValues.Length != yValues.Length)
            {
                throw new InvalidDataException(PKSimConstants.Error.DifferentVectorLengths);
            }

            // create range curve on grid. Do not allow uniform interval distribution as data might be misleading
            var xValueIntervals = _binIntervalsCreator.CreateIntervalsFor(xValues.ToDoubleArray());

            foreach (var xValueInterval in xValueIntervals)
            {
                var yValuesForXInterval = yValues.Where((y, i) => xValueInterval.Contains(xValues[i])).ToList();
                var rangeYValue         = createRangeYValue(yValuesForXInterval);
                if (rangeYValue.IsValid)
                {
                    series.Add(createRangeXValue(xValueInterval, yValuesForXInterval.Count), rangeYValue);
                }
            }
        }
    void SetTopMostCurve(DoubleCurve doubleCurve)
    {
        int topMostCurveID;

        if (m_CurveEditor.GetTopMostCurveID(out topMostCurveID))
        {
            for (int j = 0; j < m_AddedCurves.Count; ++j)
            {
                CurveData cd = m_AddedCurves[j];
                if (cd.m_MaxId == topMostCurveID || cd.m_MinId == topMostCurveID)
                {
                    if (doubleCurve.signedRange == cd.m_SignedRange)
                    {
                        if (cd.m_MaxId > 0)
                        {
                            SetCurve(m_CurveEditor.GetCurveWrapperFromID(cd.m_MaxId), doubleCurve.maxCurve);
                        }

                        if (cd.m_MinId > 0)
                        {
                            SetCurve(m_CurveEditor.GetCurveWrapperFromID(cd.m_MinId), doubleCurve.minCurve);
                        }
                    }
                    else
                    {
                        Debug.LogWarning("Cannot assign a curves with different signed range");
                    }
                }
            }
        }
    }
Exemple #20
0
        private IReadOnlyList <SeriesPoint> createSeriesPoints <TXValue, TYValue>(CurveData <TXValue, TYValue> curveData, Func <TYValue, IEnumerable <float> > yProperty, bool addYValuesAsSeparateSeriesPoint)
            where TYValue : IYValue
            where TXValue : IXValue
        {
            var yAxis        = curveData.YAxis;
            var xAxis        = curveData.XAxis;
            var seriesPoints = new List <SeriesPoint>();

            for (int i = 0; i < curveData.XValues.Count; i++)
            {
                var xValue  = xAxis.ConvertToDisplayUnit(curveData.XValues[i].X);
                var yValues = yProperty(curveData.YValues[i]);

                double[] yConvertedValues = yValues.Select(y => yAxis.ConvertToDisplayUnit(y)).ToArray();

                if (!valuesAreValidForAxes(xAxis, xValue, yAxis, yConvertedValues))
                {
                    continue;
                }

                if (addYValuesAsSeparateSeriesPoint)
                {
                    seriesPoints.AddRange(yConvertedValues.Select(yValue => new SeriesPoint(xValue, yValue)));
                }
                else
                {
                    seriesPoints.Add(new SeriesPoint(xValue, yConvertedValues));
                }
            }
            return(seriesPoints);
        }
        protected override void Context()
        {
            base.Context();
            var timeDimension = DomainHelperForSpecs.TimeDimensionForSpecs();
            var concDimension = DomainHelperForSpecs.ConcentrationDimensionForSpecs();

            _xAxis = new AxisData(timeDimension, timeDimension.DefaultUnit, Scalings.Linear)
            {
                Caption = "X"
            };
            _yAxis = new AxisData(concDimension, concDimension.DefaultUnit, Scalings.Linear)
            {
                Caption = "Y"
            };
            _chartData = new ChartData <TimeProfileXValue, TimeProfileYValue>(_xAxis, null, null, null);
            var pane1 = new PaneData <TimeProfileXValue, TimeProfileYValue>(_yAxis)
            {
                Caption = "Male"
            };
            var pane2 = new PaneData <TimeProfileXValue, TimeProfileYValue>(_yAxis)
            {
                Caption = "Female"
            };

            _chartData.AddPane(pane1);
            _chartData.AddPane(pane2);
            var curve1 = new CurveData <TimeProfileXValue, TimeProfileYValue> {
                Caption = "Liver"
            };

            curve1.Add(new TimeProfileXValue(1), new TimeProfileYValue {
                Y = 10
            });
            curve1.Add(new TimeProfileXValue(2), new TimeProfileYValue {
                LowerValue = 20, UpperValue = 30
            });
            pane1.AddCurve(curve1);

            var curve2 = new CurveData <TimeProfileXValue, TimeProfileYValue> {
                Caption = "Kidney"
            };

            curve2.Add(new TimeProfileXValue(3), new TimeProfileYValue {
                Y = 40
            });
            pane2.AddCurve(curve2);

            _observedData = DomainHelperForSpecs.ObservedData();
            var displayPathMapper   = A.Fake <IQuantityPathToQuantityDisplayPathMapper>();
            var dimensionRepository = A.Fake <IDimensionRepository>();
            var observedDataMapper  = new DataRepositoryToObservedCurveDataMapper(displayPathMapper, dimensionRepository);
            var obserevdDataCurves  = observedDataMapper.MapFrom(_observedData, new ObservedDataCollection(), concDimension);

            obserevdDataCurves.Each(pane1.AddObservedCurve);
            observedDataMapper.MapFrom(_observedData, new ObservedDataCollection(), concDimension).Each(curve =>
            {
                curve.Visible = false;
                pane1.AddObservedCurve(curve);
            });
        }
        private DataTable getPivotedTable(DataTable table, CurveData <TXValue, TYValue> firstCurve)
        {
            const string tableNameSuffix = " Pivoted";

            if (firstCurve == null)
            {
                return(new DataTable(tableNameSuffix));
            }

            var pivoter    = new Pivoter();
            var dataFields = GetDataFields(firstCurve);
            var aggregate  = new Aggregate <float, float>
            {
                Aggregation = floats => floats.FirstOrDefault(),
                Name        = dataFields.Count == 1 ? dataFields[0] : string.Empty
            };

            var pivotInfo = new PivotInfo(rowFields: GetRowFields(firstCurve),
                                          dataFields: dataFields,
                                          columnFields: new[] { PANE_CAPTION, CURVE_CAPTION },
                                          aggregates: new[] { aggregate });

            var pivotTable = pivoter.PivotData(table.DefaultView, pivotInfo);

            pivotTable.TableName += tableNameSuffix;

            //purge empty columns
            foreach (var column in getEmptyColumns(pivotTable))
            {
                pivotTable.Columns.Remove(column);
            }

            PerformSpecificTransformationOnPivotedTable(pivotTable);
            return(pivotTable);
        }
Exemple #23
0
        protected void GetScopeCurve(string pathprefix)
        {
            try
            {
                device.Write("Curv?");

                device.ReadByteArray(1);
                int       count     = Convert.ToInt32(System.Text.Encoding.ASCII.GetString(device.ReadByteArray(1)));
                int       npt       = Convert.ToInt32(System.Text.Encoding.ASCII.GetString(device.ReadByteArray(count)));
                Byte[]    waveform  = device.ReadByteArray(npt);
                var       data      = device.ReadString();
                CurveData curvedata = new CurveData()
                {
                    MetaData = meta,
                    Points   = new List <CurvePoint>(),
                    Orginal  = new List <int>()
                };
                // int length = Convert.ToInt32(data[1].ToString());
                for (int j = 0; j < npt; j++)
                {
                    int pointData = (int)waveform[j] - 128;
                    curvedata.Orginal.Add(pointData);
                    CurvePoint point = new CurvePoint()
                    {
                        X = meta.Xzero + meta.Xincr * (j - meta.Ptoff),
                        Y = meta.Yzero + meta.YMult * (pointData - meta.Yoff)
                    };
                    curvedata.Points.Add(point);
                    //sum up
                    if (curveNumber == 0)
                    {
                        sumDData.Add(point);
                    }
                    else
                    {
                        sumDData[j].Y += point.Y;
                    }
                }

                //raw.Trace(JsonConvert.SerializeObject(curvedata.Orginal));
                //translated.Debug(JsonConvert.SerializeObject(curvedata.Points));
                Clients.All.getData(curvedata);
                if (!string.IsNullOrEmpty(pathprefix))
                {
                    Task.Run(() => File.WriteAllText(System.IO.Path.Combine(pathprefix, $"raw_{curveNumber}"), JsonConvert.SerializeObject(curvedata.Orginal), System.Text.Encoding.ASCII));
                }
                //curveNumber++;
                Interlocked.Increment(ref curveNumber);
            }
            catch (Exception)
            {
            }
            finally
            {
                device.Clear();
                //may need sleep to allow camera
                //Thread.Sleep(1000);
            }
        }
    void LoadAnimationData()
    {
        //if (animFig_ == null) {
        //    Debug.Log("please assign animation fig");
        //    return;
        //}

        //ClipData clipData = new ClipData();

        //TranversCollectJoints_r(animFig_, -1, clipData.Joints);
        //foreach(var j in clipData.Joints) {
        //    Debug.Log(j.Name);
        //}

        var bindings = AnimationUtility.GetCurveBindings(animation_);

        for (int i = 0; i < bindings.Length; i++)
        {
            var binding = bindings[i];
            //Debug.Log(i + " " + binding.path + "$" + binding.propertyName);

            if (binding.propertyName == "m_LocalScale.x" ||
                binding.propertyName == "m_LocalScale.y" ||
                binding.propertyName == "m_LocalScale.z")
            {
                continue;
            }

            AnimationCurve curveFrom = AnimationUtility.GetEditorCurve(animation_, binding);
            CurveData      curveTo   = new CurveData {
                Path    = binding.path,
                Channel = GetChannelType(binding.propertyName)
            };
            //Debug.Log("number of keys " + curveFrom.length);


            for (int j = 0; j < curveFrom.length; j++)
            {
                Keyframe      frame = curveFrom.keys[j];
                CurveData.Key key   = new CurveData.Key {
                    Time    = frame.time,
                    Value   = frame.value,
                    Tangent = frame.inTangent
                };

                //string key = string.Format("key: time {0} value {1} inTanget {2} outTanget{3}", frame.time, frame.value, frame.inTangent, frame.outTangent);
                //Debug.Log(key);
                curveTo.Datas.Add(key);
            }

            //clipData.Curves.Add(curveTo);
        }

        //Debug.Log("got curves " + clipData.Curves.Count);

        //using (var file = File.Create("I:/clipData.bin")) {
        //    Serializer.Serialize(file, clipData);
        //}
    }
 private void Add(CurveData cd)
 {
     this.m_CurveEditor.SelectNone();
     this.m_AddedCurves.Add(cd);
     this.ContentChanged();
     SessionState.SetVector3(cd.m_UniqueName, new Vector3(cd.m_Color.r, cd.m_Color.g, cd.m_Color.b));
     this.UpdateRangeBasedOnShownCurves();
 }
 private void Add(CurveData cd)
 {
     this.m_CurveEditor.SelectNone();
     this.m_AddedCurves.Add(cd);
     this.ContentChanged();
     SessionState.SetVector3(cd.m_UniqueName, new Vector3(cd.m_Color.r, cd.m_Color.g, cd.m_Color.b));
     this.UpdateRangeBasedOnShownCurves();
 }
        void DoReduction(CurveData cv)
        {
            int before = cv.length;

            AnimationCurveKeyReducer.DoReduction(cv.curve, cv.epsilon);
            int after = cv.length;

            m_reporter.Write("  key reduction: " + cv.field + " " + before + " -> " + after + "\n");
        }
        void ConvertXform(UsdXform xf, string path)
        {
            if (xf == null)
            {
                return;
            }

            var ttrans = typeof(Transform);
            var cvs    = new CurveData[] {
                new CurveData(ttrans, path, "m_LocalPosition.x", m_epsilon_Position),
                new CurveData(ttrans, path, "m_LocalPosition.y", m_epsilon_Position),
                new CurveData(ttrans, path, "m_LocalPosition.z", m_epsilon_Position),
                new CurveData(ttrans, path, "m_LocalRotation.x", m_epsilon_Rotation),
                new CurveData(ttrans, path, "m_LocalRotation.y", m_epsilon_Rotation),
                new CurveData(ttrans, path, "m_LocalRotation.z", m_epsilon_Rotation),
                new CurveData(ttrans, path, "m_LocalRotation.w", m_epsilon_Rotation),
                new CurveData(ttrans, path, "m_LocalScale.x", m_epsilon_Scale),
                new CurveData(ttrans, path, "m_LocalScale.y", m_epsilon_Scale),
                new CurveData(ttrans, path, "m_LocalScale.z", m_epsilon_Scale),
            };

            usdi.usdiXformEachSample(xf.nativeXformPtr, (ref usdi.XformData data, double t_) => {
                float t = (float)t_ * m_rcpTimeScale;
                if (data.flags.updatedPosition)
                {
                    cvs[0].curve.AddKey(t, data.position.x);
                    cvs[1].curve.AddKey(t, data.position.y);
                    cvs[2].curve.AddKey(t, data.position.z);
                }
                if (data.flags.updatedRotation)
                {
                    cvs[3].curve.AddKey(t, data.rotation.x);
                    cvs[4].curve.AddKey(t, data.rotation.y);
                    cvs[5].curve.AddKey(t, data.rotation.z);
                    cvs[6].curve.AddKey(t, data.rotation.w);
                }
                if (data.flags.updatedScale)
                {
                    cvs[7].curve.AddKey(t, data.scale.x);
                    cvs[8].curve.AddKey(t, data.scale.y);
                    cvs[9].curve.AddKey(t, data.scale.z);
                }
            });

            if (m_keyframeReduction)
            {
                foreach (var c in cvs)
                {
                    DoReduction(c);
                }
            }
            foreach (var c in cvs)
            {
                c.Set(m_animClip);
            }
        }
        protected override void Context()
        {
            base.Context();
            var timeDimension = DomainHelperForSpecs.TimeDimensionForSpecs();
            var concDimension = DomainHelperForSpecs.ConcentrationDimensionForSpecs();

            _xAxis = new AxisData(timeDimension, timeDimension.DefaultUnit, Scalings.Linear)
            {
                Caption = "X"
            };
            _yAxis = new AxisData(concDimension, concDimension.DefaultUnit, Scalings.Linear)
            {
                Caption = "Y"
            };
            _chartData = new ChartData <RangeXValue, RangeYValue>(_xAxis, null);
            var pane1 = new PaneData <RangeXValue, RangeYValue>(_yAxis)
            {
                Caption = "Male"
            };
            var pane2 = new PaneData <RangeXValue, RangeYValue>(_yAxis)
            {
                Caption = "Female"
            };

            _chartData.AddPane(pane1);
            _chartData.AddPane(pane2);
            var curve1 = new CurveData <RangeXValue, RangeYValue> {
                Caption = "Liver"
            };

            curve1.Add(new RangeXValue(1)
            {
                Minimum = 0, Maximum = 1.5f, NumberOfItems = 5
            }, new RangeYValue {
                LowerPercentile = 10, Median = 20, UpperPercentile = 30
            });
            curve1.Add(new RangeXValue(2)
            {
                Minimum = 1.8f, Maximum = 2.5f, NumberOfItems = 10
            }, new RangeYValue {
                LowerPercentile = 20, Median = 30, UpperPercentile = 40
            });
            pane1.AddCurve(curve1);

            var curve2 = new CurveData <RangeXValue, RangeYValue> {
                Caption = "Kidney"
            };

            curve2.Add(new RangeXValue(3)
            {
                Minimum = 2f, Maximum = 4f, NumberOfItems = 15
            }, new RangeYValue {
                LowerPercentile = 30, Median = 40, UpperPercentile = 50
            });
            pane2.AddCurve(curve2);
        }
 protected override void AddSpecificChartColumns(DataTable dataTable, CurveData <BoxWhiskerXValue, BoxWhiskerYValue> curveData, bool exportForPivot)
 {
     dataTable.AddColumn(_xValue);
     dataTable.AddColumn <float>(_lowerWhisker);
     dataTable.AddColumn <float>(_lowerBox);
     dataTable.AddColumn <float>(_median);
     dataTable.AddColumn <float>(_upperBox);
     dataTable.AddColumn <float>(_upperWhisker);
     dataTable.AddColumn(_variable);
 }
        protected override IReadOnlyList <Series> CreateCurveSeriesList(CurveData <RangeXValue, RangeYValue> curveData)
        {
            var rangeAreaSeries = CreateRangeAreaSeries(curveData)
                                  .WithPoints(CreateSeriesPoints(curveData, y => y.LowerPercentile, y => y.UpperPercentile));

            var medianAreaSeries = CreateLineSeries(curveData)
                                   .WithPoints(CreateSeriesPoints(curveData, y => y.Median));

            return(new[] { rangeAreaSeries, medianAreaSeries });
        }
 public void AddCurveDataIfNeeded(string curveName, CurveData curveData)
 {
     Vector3 vector = SessionState.GetVector3(curveName, Vector3.zero);
     if (vector != Vector3.zero)
     {
         Color color = new Color(vector.x, vector.y, vector.z);
         curveData.m_Color = color;
         this.AddCurve(curveData);
         for (int i = 0; i < this.m_AvailableColors.Count; i++)
         {
             if (SameColor(this.m_AvailableColors[i], color))
             {
                 this.m_AvailableColors.RemoveAt(i);
                 break;
             }
         }
     }
 }
 public void AddCurve(CurveData curveData)
 {
     this.Add(curveData);
 }
Exemple #34
0
 private void DrawCurve(string snapshotName, CurveData curveData, ref int colorIndex)
 {
     if (curveData.Curve == null)
     {
         PointPairList points = new PointPairList();
         for (int i = 0; i < curveData.Data.Count; i++)
         {
             points.Add((double) i, (double) curveData.Data[i]);
         }
         LineItem item = this.m_ZedGraph.GraphPane.AddCurve(snapshotName + "_" + curveData.Label, points, ViewConstant.COLOR_ARRAY[colorIndex % ViewConstant.COLOR_ARRAY.Length], SymbolType.None);
         curveData.Curve = item;
         colorIndex++;
     }
     else
     {
         this.m_ZedGraph.GraphPane.CurveList.Add(curveData.Curve);
     }
 }
    public void Save()
    {
        BinaryFormatter bf = new BinaryFormatter();
        FileStream file = File.Create(Application.dataPath + "/ProceduralTracks/CurvesSavedData/" + gameObject.name + transform.parent.GetComponent<Track>().id + ".curve");

        CurveData data = new CurveData();

        List<NodeData> _nodesData = new List<NodeData>();
        if (nodes != null)
        {
            foreach (Node n in nodes)
            {
                _nodesData.Add(n.Serialize());
            }
        }
        data.nodesData = _nodesData.ToArray();

        List<BezierData> _splinesData = new List<BezierData>();
        foreach (BezierSpline b in splines)
        {
            _splinesData.Add(b.GetData());
        }
        data.splinesData = _splinesData.ToArray();

        data.closed = this.closed;
        data.invisible = this.invisible;

        bf.Serialize(file, data);
        file.Close();
    }