예제 #1
0
        private void GenerateCustomKnob()
        {
            AxisAngleRotation3D rotation = new AxisAngleRotation3D();

            rotation.Axis = new Vector3D(0.0, 0.0, 1.0);

            RotateTransform3D transform = new RotateTransform3D();

            transform.Rotation = rotation;

            Bar3D bar = new Bar3D();

            bar.SideCount    = 3;
            bar.RoundingRate = 0.15;
            // bar.Material = (Material)Application.Current.TryFindResource("ControlMaterial");

            Knob3D knob = new Knob3D();

            // vMain.Children.Add(knob);

            knob.OverridesDefaultSkin = true;
            knob.Transform            = transform;
            knob.Content = bar;

            Binding b = new Binding("Angle");

            b.Source = knob;
            BindingOperations.SetBinding(rotation, AxisAngleRotation3D.AngleProperty, b);

            vMain.Children.Add(knob);
        }
예제 #2
0
        /**
         * Creates a colored bar.
         * @param range         maximum - minimum value of this attribute
         * @param attributeID   which attribute
         * */
        private Bar3D CreateBar(float value, float range, float widthA = .1f, float widthB = .1f)
        {
            var factory3D = Services.instance.Factory3DPrimitives;

            Bar3D bar = factory3D.CreateBar(value, widthA, widthB).GetComponent <Bar3D>();

            bar.Assign(this);

            bar.SetLabelText(value.ToString());

            return(bar);
        }
예제 #3
0
        private void drawSynchy()
        {
            DiffuseMaterial material  = new DiffuseMaterial(Brushes.Wheat);
            int             lineWidth = 3;

            for (int i = 0; i < GUIComponents.synchyList.Count; ++i)
            {
                if (GUIComponents.synchyList[i].Center.Z == 0)
                {
                    continue;
                }

                if ((bool)parentGUI.show3DCheck.IsChecked)
                {
                    Bar3D baseBar = new Bar3D();
                    baseBar.SideCount = 100;

                    Transform3DGroup transGroupBase = new Transform3DGroup();
                    //   transGroupBase.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), -90)));
                    transGroupBase.Children.Add(new ScaleTransform3D(0.1, 0.1, 0.05));
                    transGroupBase = getSynchyTransGroup(transGroupBase, i);

                    double heightFactor = 1.7;
                    transGroupBase.Children.Add(new TranslateTransform3D(-1 * Vector3D.Divide(GUIComponents.synchyList[i].zPar, heightFactor))); //new Vector3D(height*GUIComponents.synchyList[i].zPar.X, GUIComponents.synchyList[i].zPar.Y, GUIComponents.synchyList[i].zPar.Z)));
                    transGroupBase.Children.Add(new TranslateTransform3D(new Vector3D(GUIComponents.synchyList[i].Center.X, GUIComponents.synchyList[i].Center.Y, GUIComponents.synchyList[i].Center.Z)));
                    baseBar.Transform = transGroupBase;                                                                                          //.Identity;
                    baseBar.Material  = material;
                    show_viewport3D.Children.Add(baseBar);

                    Box3D            bodyBox = new Box3D();
                    double           l = 0.08, w = 0.08, h = 0.12;
                    Transform3DGroup transGroupBody = new Transform3DGroup();
                    transGroupBody.Children.Add(new ScaleTransform3D(l, w, h));
                    transGroupBody.Children.Add(new TranslateTransform3D(new Vector3D(-l / 2, -w / 2, -h / 2))); //new Vector3D(height*GUIComponents.synchyList[i].zPar.X, GUIComponents.synchyList[i].zPar.Y, GUIComponents.synchyList[i].zPar.Z)));

                    transGroupBody = getSynchyTransGroup(transGroupBody, i);
                    transGroupBody.Children.Add(new TranslateTransform3D(new Vector3D(GUIComponents.synchyList[i].Center.X, GUIComponents.synchyList[i].Center.Y, GUIComponents.synchyList[i].Center.Z)));
                    bodyBox.Transform = transGroupBody;
                    bodyBox.Material  = material;
                    show_viewport3D.Children.Add(bodyBox);

                    Spherical3D      headSphere     = new Spherical3D();
                    Transform3DGroup transGroupHead = new Transform3DGroup();
                    transGroupHead.Children.Add(new ScaleTransform3D(0.1, 0.1, 0.1));
                    transGroupHead = getSynchyTransGroup(transGroupHead, i);
                    transGroupHead.Children.Add(new TranslateTransform3D(Vector3D.Divide(GUIComponents.synchyList[i].zPar, heightFactor)));
                    transGroupHead.Children.Add(new TranslateTransform3D(new Vector3D(GUIComponents.synchyList[i].Center.X, GUIComponents.synchyList[i].Center.Y, GUIComponents.synchyList[i].Center.Z)));
                    headSphere.Transform = transGroupHead;
                    headSphere.Material  = material;
                    show_viewport3D.Children.Add(headSphere);

                    ScreenSpaceLines3D x = new ScreenSpaceLines3D();
                    x.Thickness = lineWidth;
                    x.Color     = Colors.Red;
                    Point3D origin = new Point3D(GUIComponents.synchyList[i].Center.X, GUIComponents.synchyList[i].Center.Y, GUIComponents.synchyList[i].Center.Z);
                    Point3D x_unit = new Point3D(GUIComponents.synchyList[i].xUnit.X, GUIComponents.synchyList[i].xUnit.Y, GUIComponents.synchyList[i].xUnit.Z);

                    x.Points.Add(origin);
                    x.Points.Add(x_unit);
                    this.show_viewport3D.Children.Add(x);
                }
                else
                {
                    ScreenSpaceLines3D x = new ScreenSpaceLines3D();
                    ScreenSpaceLines3D y = new ScreenSpaceLines3D();
                    ScreenSpaceLines3D z = new ScreenSpaceLines3D();

                    x.Thickness = lineWidth;
                    x.Color     = Colors.Gray;
                    y.Thickness = lineWidth;
                    y.Color     = Colors.BlueViolet;
                    z.Thickness = lineWidth;
                    z.Color     = Colors.Pink;

                    Point3D origin = new Point3D(GUIComponents.synchyList[i].Center.X, GUIComponents.synchyList[i].Center.Y, GUIComponents.synchyList[i].Center.Z);
                    Point3D x_unit = new Point3D(GUIComponents.synchyList[i].xUnit.X, GUIComponents.synchyList[i].xUnit.Y, GUIComponents.synchyList[i].xUnit.Z);
                    Point3D y_unit = new Point3D(GUIComponents.synchyList[i].yUnit.X, GUIComponents.synchyList[i].yUnit.Y, GUIComponents.synchyList[i].yUnit.Z);
                    Point3D z_unit = new Point3D(GUIComponents.synchyList[i].zUnit.X, GUIComponents.synchyList[i].zUnit.Y, GUIComponents.synchyList[i].zUnit.Z);
                    x.Points.Add(origin);
                    x.Points.Add(x_unit);

                    y.Points.Add(origin);
                    y.Points.Add(y_unit);

                    z.Points.Add(origin);
                    z.Points.Add(z_unit);

                    this.show_viewport3D.Children.Add(x);
                    this.show_viewport3D.Children.Add(y);
                    this.show_viewport3D.Children.Add(z);
                }
            }
        }
예제 #4
0
        // ........................................................................ Initializers
        public override void Init(
            DataSet data,
            string attributeNameX,
            string attributeNameY,
            float lengthA  = 1f,
            float lengthB  = 1f,
            bool isMetaVis = false)
        {
            base.Init(data, isMetaVis);
            this.attributeNameA = attributeNameX;
            this.attributeNameB = attributeNameY;
            this.attributeIDA   = data.IDOf(attributeNameX);
            this.attributeIDB   = data.IDOf(attributeNameY);
            this.lomA           = data.TypeOf(attributeNameX);
            this.lomB           = data.TypeOf(attributeNameY);
            this.max            = 0;
            this.lengthA        = lengthA;
            this.lengthB        = lengthB;

            dictA = new Dictionary <string, int>();
            dictB = new Dictionary <string, int>();

            switch (lomA)
            {
            case LoM.NOMINAL:
                var mN = data.nominalStatistics[attributeNameX];
                uniqueValsA = mN.uniqueValues;
                //distributionA = mN.GetDistributionValues();
                dictA = mN.valueIDs;
                break;

            case LoM.ORDINAL:
                var mO = data.ordinalStatistics[attributeNameX];
                uniqueValsA = mO.uniqueValues;
                //distributionA = mO.GetDistributionValues();
                dictA = mO.orderedIDValues;
                break;

            default:
                throw new Exception("Illegal LoM");
            }

            switch (lomB)
            {
            case LoM.NOMINAL:
                var mN = data.nominalStatistics[attributeNameY];
                uniqueValsB = mN.uniqueValues;
                //distributionB = mN.GetDistributionValues();
                //dictB1 = mN.idValues;
                //dictB2 = mN.valueIDs;
                break;

            case LoM.ORDINAL:
                var mO = data.ordinalStatistics[attributeNameY];
                uniqueValsB = mO.uniqueValues;
                //distributionB = mO.GetDistributionValues();
                //dictB1 = mO.orderedValueIDs;
                //dictB2 = mO.orderedIDValues;
                break;

            default:
                throw new Exception("Illegal LoM");
            }

            dimA = uniqueValsA.Length;
            dimB = uniqueValsB.Length;

            this.absMapValues = new int[dimA, dimB];
            this.barHeights   = new float[dimA, dimB];

            // For every possible value of attribute 1
            for (int vID1 = 0; vID1 < dimA; vID1++)
            {
                string v1 = uniqueValsA[vID1];

                // For every possible value of attribute 2
                for (int vID2 = 0; vID2 < dimB; vID2++)
                {
                    string v2 = uniqueValsB[vID2];

                    // Count how many object match both values
                    int count;

                    if (lomA == LoM.NOMINAL && lomB == LoM.NOMINAL)
                    {
                        count = AttributeProcessor.Nominal.CountObjectsMatchingTwoCattegories(
                            data.infoObjects, attributeIDA, attributeIDB, v1, v2);
                    }
                    else if (lomA == LoM.ORDINAL && lomB == LoM.ORDINAL)
                    {
                        count = AttributeProcessor.Ordinal.CountObjectsMatchingTwoCattegories(
                            data.infoObjects, attributeIDA, attributeIDB, dictA[v1], dictB[v2]);
                    }
                    else if (lomA == LoM.NOMINAL && lomB == LoM.ORDINAL)
                    {
                        count = AttributeProcessor.Categorial.CountObjectsMatchingTwoCategoriesNomOrd(
                            data.infoObjects, attributeNameX, attributeNameY, v1, dictB[v2]);
                    }
                    else if (lomA == LoM.ORDINAL && lomB == LoM.NOMINAL)
                    {
                        count = AttributeProcessor.Categorial.CountObjectsMatchingTwoCategoriesNomOrd(
                            data.infoObjects, attributeNameY, attributeNameX, v2, dictA[v1]);
                    }
                    else
                    {
                        count = 0;
                    }


                    if (count > max)
                    {
                        max = count;
                    }

                    absMapValues[vID1, vID2] = count;
                }
            }

            for (int vID1 = 0; vID1 < dimA; vID1++)
            {
                for (int vID2 = 0; vID2 < dimB; vID2++)
                {
                    barHeights[vID1, vID2] = absMapValues[vID1, vID2] / ((float)max);
                }
            }

            if (max > 0)
            {
                SetUpAxes();
                DrawGraph();

                foreach (var o in data.infoObjects)
                {
                    bool valAMissing = data.IsValueMissing(o, attributeNameA);
                    bool valBMissing = data.IsValueMissing(o, attributeNameB);

                    if (!(valAMissing || valBMissing))
                    {
                        Bar3D bar;

                        if (lomA == LoM.NOMINAL && lomB == LoM.NOMINAL)
                        {
                            bar = bars[
                                dictA[o.NomValueOf(attributeNameA)],
                                dictB[o.NomValueOf(attributeNameB)]
                                  ];
                        }
                        else if (lomA == LoM.ORDINAL && lomB == LoM.ORDINAL)
                        {
                            bar = bars[
                                o.OrdValueOf(attributeNameA),
                                o.OrdValueOf(attributeNameB)
                                  ];
                        }
                        else if (lomA == LoM.NOMINAL && lomB == LoM.ORDINAL)
                        {
                            bar = bars[
                                dictA[o.NomValueOf(attributeNameA)],
                                o.OrdValueOf(attributeNameB)
                                  ];
                        }
                        else if (lomA == LoM.ORDINAL && lomB == LoM.NOMINAL)
                        {
                            bar = bars[
                                o.OrdValueOf(attributeNameA),
                                dictB[o.NomValueOf(attributeNameB)]
                                  ];
                        }
                        else
                        {
                            bar = new Bar3D();
                        }

                        RememberRelationOf(o, bar);
                    }
                }
            }
        }