public void ShouldBeSame()
        {
            var builder = new SimpleExprBuilder(true);

            var dummyV = SymbooglixLibTests.MapProxyTests.GetVariable("dummy", BPLType.Int);

            // Hack
            dummyV.SetMetadata((int)Symbooglix.Annotation.AnnotationIndex.PROGRAM_LOCATION, new ProgramLocation(dummyV));
            var v  = new SymbolicVariable("foo", dummyV);
            var id = builder.Identifier(v);

            var c0     = new Constraint(builder.Gt(id, builder.ConstantInt(0)));
            var c0Copy = new Constraint(builder.Gt(id, builder.ConstantInt(0)));
            var c1     = new Constraint(builder.Lt(id, builder.ConstantInt(10)));
            var c1Copy = new Constraint(builder.Lt(id, builder.ConstantInt(10)));

            var CM0 = new ConstraintManager();

            Assert.AreEqual(0, CM0.GetHashCode());
            CM0.AddConstraint(c0);
            var firstHashCode = CM0.GetHashCode();

            CM0.AddConstraint(c1);
            Assert.AreNotEqual(firstHashCode, CM0.GetHashCode());

            var CM1 = new ConstraintManager();

            CM1.AddConstraint(c0Copy);
            Assert.AreEqual(firstHashCode, CM1.GetHashCode());
            CM1.AddConstraint(c1Copy);
            Assert.AreEqual(CM0.GetHashCode(), CM1.GetHashCode());

            Assert.IsTrue(CM0.Equals(CM1));
        }
        /// <summary>
        /// Util method for drawing a consistent constraints section.
        /// Use this method in a component inspector for linking to a constraint manager.
        /// </summary>
        /// <param name="gameObject">Game object the constraint manager is attached to.</param>
        /// <param name="managerEnabled">Serialized property for enabling the manager - needs to be of type bool.</param>
        /// <param name="managerRef">Serialized property of the constraint manager component link - needs to be type of ConstraintManager.</param>
        /// <param name="isExpanded">Flag for indicating if the constraint foldout was previously collapsed or expanded.</param>
        /// <returns>Current state of expanded or collapsed constraint foldout. Returns true if expanded / contents visible.</returns>
        static public bool DrawConstraintManagerFoldout(GameObject gameObject, SerializedProperty managerEnabled, SerializedProperty managerRef, bool isExpanded)
        {
            isExpanded = EditorGUILayout.Foldout(isExpanded, "Constraints", true);

            if (isExpanded)
            {
                EditorGUILayout.PropertyField(managerEnabled);
                GUI.enabled = managerEnabled.boolValue;
                // Make sure we're having at least one constraint manager available.
                // Usually this should be ensured by the component requirement. However
                // for components that had this requirement added after they were serialized
                // this won't work out of the box.
                gameObject.EnsureComponent <ConstraintManager>();
                var constraintManagers = gameObject.GetComponents <ConstraintManager>();

                int selected = 0;

                string[] options = new string[constraintManagers.Length];

                int manualSelectionCount = 0;
                for (int i = 0; i < constraintManagers.Length; ++i)
                {
                    var manager = constraintManagers[i];
                    if (managerRef.objectReferenceValue == manager)
                    {
                        selected = i;
                    }

                    // popups will only show unique elements
                    // in case of auto selection we don't care which one we're selecting as the behavior will be the same.
                    // in case of manual selection users might want to differentiate which constraintmanager they are referring to.
                    if (manager.AutoConstraintSelection == true)
                    {
                        options[i] = manager.GetType().Name + " (auto)";
                    }
                    else
                    {
                        manualSelectionCount++;
                        options[i] = manager.GetType().Name + " (manual " + manualSelectionCount + ")";
                    }
                }

                using (new EditorGUILayout.HorizontalScope())
                {
                    selected = EditorGUILayout.Popup("Constraint Manager", selected, options, GUILayout.ExpandWidth(true));
                    ConstraintManager selectedConstraintManager = constraintManagers[selected];
                    managerRef.objectReferenceValue = selectedConstraintManager;
                    if (GUILayout.Button("Go to component"))
                    {
                        EditorGUIUtility.PingObject(selectedConstraintManager);
                        Highlighter.Highlight("Inspector", $"ComponentId: {selectedConstraintManager.GetInstanceID()}");
                        EditorGUIUtility.ExitGUI();
                    }
                }

                GUI.enabled = true;
            }

            return(isExpanded);
        }
        protected override void SetupHandler()
        {
            CreateLayout();

            OptionGroup generalGroup = Handler.AddGroup(GENERAL);

            generalGroup.AddList(CENTER_STRATEGY, centerNodeStrategies.Keys, CENTER_WEIGHTED_CENTRAL);
            generalGroup.AddList(LAYERING_STRATEGY, layeringStrategies.Keys, LAYERING_BFS);
            generalGroup.AddDouble(MINIMAL_LAYER_DISTANCE, (int)layout.MinimumLayerDistance, 1, 1000);
            generalGroup.AddDouble(MINIMAL_NODE_DISTANCE, (int)layout.MinimumNodeToNodeDistance, 0, 300);
            generalGroup.AddDouble(MAXIMAL_CHILD_SECTOR_SIZE, (int)layout.MaximumChildSectorAngle, 15, 360);

            OptionItem routingStrategyItem = generalGroup.AddList(EDGE_ROUTING_STRATEGY, edgeRoutingStrategies, EDGE_ARC);

            int smoothness =
                (int)
                Math.Min(MAXIMUM_SMOOTHNESS,
                         (1 + MAXIMUM_SMOOTHNESS * SMOOTHNESS_ANGLE_FACTOR - layout.MinimumBendAngle) / SMOOTHNESS_ANGLE_FACTOR);
            IOptionItem       smoothnessItem = generalGroup.AddInt(EDGE_SMOOTHNESS, smoothness, MINIMUM_SMOOTHNESS, MAXIMUM_SMOOTHNESS);
            ConstraintManager cm             = new ConstraintManager(Handler);

            cm.SetEnabledOnValueEquals(routingStrategyItem, EDGE_ARC, smoothnessItem);
            var bundlingStrength = generalGroup.AddDouble(EDGE_BUNDLING_STRENGTH, 0.99, 0, 1);

            cm.SetEnabledOnValueEquals(routingStrategyItem, EDGE_BUNDLES, bundlingStrength);
            generalGroup.AddBool(CONSIDER_NODE_LABELS, layout.ConsiderNodeLabels);
        }
Esempio n. 4
0
        public override MBoolResponse AssignInstruction(MInstruction instruction, MSimulationState avatarState)
        {
            //Initialize the ik service
            this.ServiceAccess.IKService.Setup(this.AvatarDescription, new Dictionary <string, string>());

            //Create a new constraint manager
            this.constraintManager = new ConstraintManager(this.SceneAccess);

            //Assign the instruction
            this.instruction = instruction;

            //Set state to ik
            this.state           = ReleaseMotionState.IK;
            this.trajectoryIndex = 0;

            //Parse the parameters
            MBoolResponse response = this.ParseParameters(instruction);

            if (!response.Successful)
            {
                return(response);
            }


            return(new MBoolResponse(true));
        }
        public void GetSubSet()
        {
            var builder = new SimpleExprBuilder(true);

            var dummyV = SymbooglixLibTests.MapProxyTests.GetVariable("dummy", BPLType.Int);

            // Hack
            dummyV.SetMetadata((int)Symbooglix.Annotation.AnnotationIndex.PROGRAM_LOCATION, new ProgramLocation(dummyV));
            var v  = new SymbolicVariable("foo", dummyV);
            var id = builder.Identifier(v);

            var c0 = new Constraint(builder.Gt(id, builder.ConstantInt(0)));
            var c1 = new Constraint(builder.Lt(id, builder.ConstantInt(10)));

            var CM0      = new ConstraintManager();
            var CMSubset = new ConstraintManager();

            CM0.AddConstraint(c0);
            CM0.AddConstraint(c1);

            CMSubset.AddConstraint(c1);

            var getSubset = CM0.GetSubSet(new HashSet <Constraint>()
            {
                c1
            });

            // Check they are the same
            Assert.AreEqual(1, getSubset.Count);
            Assert.AreEqual(1, CMSubset.Count);
            Assert.AreEqual(CMSubset.GetHashCode(), getSubset.GetHashCode());
            Assert.IsTrue(CMSubset.Equals(getSubset));
        }
        protected override void SetupHandler()
        {
            OptionGroup toplevelGroup = Handler.AddGroup(TOP_LEVEL);

            //the toplevel group will show neither in Table view nor in dialog view explicitely
            //it's children will be shown one level above
            toplevelGroup.SetAttribute(TableEditorFactory.RENDERING_HINTS_ATTRIBUTE,
                                       (int)TableEditorFactory.RenderingHints.Invisible);
            toplevelGroup.SetAttribute(DefaultEditorFactory.RENDERING_HINTS_ATTRIBUTE,
                                       (int)DefaultEditorFactory.RenderingHints.Invisible);

            OptionGroup spcg = toplevelGroup.AddGroup(SourcePortConstraints);

            spcg.AddGeneric(PortConstraintStr, PortConstraintType.Any).SetAttribute(OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE,
                                                                                    false);
            spcg.AddBool(StrongPortConstraint, false);
            OptionGroup tpcg = toplevelGroup.AddGroup(TargetPortConstraints);

            tpcg.AddGeneric(PortConstraintStr, PortConstraintType.Any).SetAttribute(OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE,
                                                                                    false);
            tpcg.AddBool(StrongPortConstraint, false);
            CollectionOptionItem <string> scopeItem = toplevelGroup.AddList(Scope, scopes, ScopeAllEdges);
            BoolOptionItem    clearItem             = toplevelGroup.AddBool(ClearAllConstraints, false);
            ConstraintManager cm = new ConstraintManager(Handler);

            cm.SetEnabledOnValueEquals(clearItem, false, spcg);
            cm.SetEnabledOnValueEquals(clearItem, false, scopeItem);
            cm.SetEnabledOnValueEquals(clearItem, false, tpcg);
        }
Esempio n. 7
0
        ///<inheritdoc/>
        protected override void SetupHandler()
        {
            OptionGroup scopeGroup = Handler.AddGroup(SCOPE);

            scopeGroup.AddBool(PLACE_NODE_LABELS, true);
            scopeGroup.AddBool(PLACE_EDGE_LABELS, true);
            scopeGroup.AddBool(CONSIDER_SELECTED_FEATURES_ONLY, false);

            OptionGroup qualityGroup = Handler.AddGroup(QUALITY);

            qualityGroup.AddBool(USE_OPTIMIZATION, false);
            qualityGroup.AddOptionItem(new OptionItem(OPTIMIZATION_STRATEGY)
            {
                Value = OptimizationStrategy.Balanced, Type = typeof(OptimizationStrategy)
            });
            qualityGroup.AddBool(ALLOW_NODE_OVERLAPS, false);
            qualityGroup.AddBool(ALLOW_EDGE_OVERLAPS, true);
            qualityGroup.AddBool(USE_POSTPROCESSING, false);

            var edgeLabelGroup   = Handler.AddGroup(MODEL);
            var labelModelItem   = edgeLabelGroup.AddList(EDGE_LABEL_MODEL, edgeLabelModel, BEST);
            var autoRotationItem = edgeLabelGroup.AddBool(AUTO_ROTATE, true);
            ConstraintManager cm = new ConstraintManager(Handler);

            cm.SetEnabledOnCondition(cm.CreateValueIsOneOfCondition(labelModelItem, CENTER_SLIDER, SIDE_SLIDER), autoRotationItem);
        }
Esempio n. 8
0
        ///<inheritdoc/>
        protected override void SetupHandler()
        {
            createRouter();
            OptionGroup layoutGroup = Handler.AddGroup(GROUP_LAYOUT);

            ConstraintManager cm = new ConstraintManager(Handler);

            //Layout options
            layoutGroup.AddList(SCOPE, new[] { ALL, SUBSET_BUS, SUBSET, PARTIAL }, ALL);
            layoutGroup.AddList(BUSES, new[] { SINGLE, LABEL, TAG, CUSTOM }, SINGLE);
            IOptionItem gridEnabledItem = layoutGroup.AddBool(GRID_ENABLED, router.GridRouting);
            IOptionItem gridSpacingItem = layoutGroup.AddInt(GRID_SPACING, router.GridSpacing, 1, int.MaxValue);

            layoutGroup.AddInt(MIN_DISTANCE_TO_NODES, router.MinimumDistanceToNode, 1, int.MaxValue);
            layoutGroup.AddInt(MIN_DISTANCE_TO_EDGES, router.MinimumDistanceToEdge, 1, int.MaxValue);
            cm.SetEnabledOnValueEquals(gridEnabledItem, true, gridSpacingItem);

            //Selection options
            OptionGroup selectionGroup = Handler.AddGroup(GROUP_SELECTION);

            selectionGroup.AddInt(PREFERRED_BACKBONE_COUNT, router.PreferredBackboneSegmentCount, 1, int.MaxValue);
            selectionGroup.AddDouble(MINIMUM_BACKBONE_LENGTH, router.MinimumBackboneSegmentLength, 1, double.MaxValue);

            //Routing options
            OptionGroup routingGroup = Handler.AddGroup(GROUP_ROUTING);

            routingGroup.AddDouble(CROSSING_COST, router.CrossingCost, 0, double.MaxValue);
            routingGroup.AddBool(CROSSING_REROUTING, router.Rerouting);
            routingGroup.AddInt(MINIMUM_CONNECTIONS_COUNT, router.MinimumBusConnectionsCount, 0, int.MaxValue);
        }
Esempio n. 9
0
        ///<inheritdoc/>
        protected override void SetupHandler()
        {
            ConstraintManager cm            = new ConstraintManager(Handler);
            OptionGroup       toplevelGroup = Handler.AddGroup(TOP_LEVEL);

            //the toplevel group will show neither in Table view nor in dialog view explicitely
            //it's children will be shown one level above
            toplevelGroup.SetAttribute(TableEditorFactory.RENDERING_HINTS_ATTRIBUTE,
                                       (int)TableEditorFactory.RenderingHints.Invisible);
            toplevelGroup.SetAttribute(DefaultEditorFactory.RENDERING_HINTS_ATTRIBUTE,
                                       (int)DefaultEditorFactory.RenderingHints.Invisible);

            OptionGroup generalGroup  = toplevelGroup.AddGroup(GENERAL);
            OptionItem  operationItem = generalGroup.AddList(OPERATION, operationEnum.Keys, SCALE);

            generalGroup.AddBool(ACT_ON_SELECTION_ONLY, false);

            OptionGroup rotateGroup = toplevelGroup.AddGroup(ROTATE);

            cm.SetEnabledOnValueEquals(operationItem, ROTATE, rotateGroup);
            rotateGroup.AddInt(ROTATION_ANGLE, (int)transformer.RotationAngle, -360, 360);
            rotateGroup.AddBool(APPLY_BEST_FIT_ROTATION, applyBestFitRotation);

            OptionGroup scaleGroup = toplevelGroup.AddGroup(SCALE);

            cm.SetEnabledOnValueEquals(operationItem, SCALE, scaleGroup);
            scaleGroup.AddDouble(SCALE_FACTOR, transformer.ScaleFactorX, 0.1, 10.0);
            scaleGroup.AddBool(SCALE_NODE_SIZE, transformer.ScaleNodeSize);

            OptionGroup translateGroup = toplevelGroup.AddGroup(TRANSLATE);

            cm.SetEnabledOnValueEquals(operationItem, TRANSLATE, translateGroup);
            translateGroup.AddDouble(TRANSLATE_X, transformer.TranslateX);
            translateGroup.AddDouble(TRANSLATE_Y, transformer.TranslateY);
        }
Esempio n. 10
0
        public void ConstraintDifferent()
        {
            var builder = new SimpleExprBuilder(true);

            var dummyV = SymbooglixLibTests.MapProxyTests.GetVariable("dummy", BPLType.Int);

            // Hack
            dummyV.SetMetadata((int)Symbooglix.Annotation.AnnotationIndex.PROGRAM_LOCATION, new ProgramLocation(dummyV));
            var v  = new SymbolicVariable("foo", dummyV);
            var id = builder.Identifier(v);

            var c0     = new Constraint(builder.Gt(id, builder.ConstantInt(0)));
            var c0Copy = new Constraint(builder.Gt(id, builder.ConstantInt(0)));
            var c1     = new Constraint(builder.Lt(id, builder.ConstantInt(10)));
            var c1diff = new Constraint(builder.Le(id, builder.ConstantInt(10)));

            var CM0 = new ConstraintManager();
            var CM1 = new ConstraintManager();

            CM0.AddConstraint(c0);
            CM0.AddConstraint(c1);
            CM1.AddConstraint(c0Copy);
            CM1.AddConstraint(c1diff);

            var queryExpr0 = builder.Eq(id, builder.ConstantInt(5));
            var queryExpr1 = builder.Eq(id, builder.ConstantInt(5));

            var query0 = new Symbooglix.Solver.Query(CM0, new Constraint(queryExpr0));
            var query1 = new Symbooglix.Solver.Query(CM1, new Constraint(queryExpr1));

            Assert.AreNotEqual(query0.GetHashCode(), query1.GetHashCode());

            Assert.IsFalse(query0.Equals(query1));
        }
        private List <int> indicesToRemove = new List <int>(); // list for deferred deletion in our selected constraint list to not break unity GUI layout

        private void OnEnable()
        {
            constraintManager = (ConstraintManager)target;

            autoConstraintSelection = serializedObject.FindProperty("autoConstraintSelection");
            selectedConstraints     = serializedObject.FindProperty("selectedConstraints");
        }
        public void DoClone()
        {
            var builder = new SimpleExprBuilder(true);

            var dummyV = SymbooglixLibTests.MapProxyTests.GetVariable("dummy", BPLType.Int);

            // Hack
            dummyV.SetMetadata((int)Symbooglix.Annotation.AnnotationIndex.PROGRAM_LOCATION, new ProgramLocation(dummyV));
            var v  = new SymbolicVariable("foo", dummyV);
            var id = builder.Identifier(v);

            var c0 = new Constraint(builder.Gt(id, builder.ConstantInt(0)));
            var c1 = new Constraint(builder.Lt(id, builder.ConstantInt(10)));

            var CM0 = new ConstraintManager();

            CM0.AddConstraint(c0);
            CM0.AddConstraint(c1);

            var copy = CM0.Clone();

            Assert.AreNotSame(CM0, copy);
            Assert.AreEqual(CM0.Count, copy.Count);
            Assert.AreEqual(CM0.GetHashCode(), copy.GetHashCode());
            Assert.IsTrue(CM0.Equals(copy));

            // Modify original and check copy has not changed
            CM0.AddConstraint(new Constraint(builder.Lt(id, builder.ConstantInt(8))));
            Assert.AreNotEqual(copy.GetHashCode(), CM0.GetHashCode());
            Assert.IsFalse(CM0.Equals(copy));
            Assert.AreEqual(2, copy.Count);
            Assert.AreEqual(3, CM0.Count);
        }
        /// <summary>
        /// Initializes the option handler for the export
        /// </summary>
        private void SetupHandler()
        {
            handler = new OptionHandler(LayoutOptions);
            OptionItem componentItem = handler.AddList(ComponentAssignment,
                                                       new[]
            {
                ComponentAssignmentStrategy.Single,
                ComponentAssignmentStrategy.Connected
            },
                                                       ComponentAssignmentStrategy.Single);
            OptionItem subgraphItem = handler.AddList(SubgraphLayout, SubGraphLayouts.Keys, LayoutIncremental);

            handler.AddGeneric(SubgraphPositioning, SubgraphPlacement.Barycenter).SetAttribute(
                OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE, false);
            handler.AddGeneric(EdgeRouting, EdgeRoutingStrategy.Automatic).SetAttribute(
                OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE, false);
            handler.AddGeneric(LayoutOrientationStrategy, LayoutOrientation.TopToBottom).SetAttribute(
                OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE, false);
            handler.AddInt(MinimumNodeDistance, 5, 0, int.MaxValue);
            handler.AddBool(AllowMirroring, true);
            handler.AddBool(NodeSnapping, true);
            var cm = new ConstraintManager(Handler);

            cm.SetEnabledOnValueEquals(componentItem, ComponentAssignmentStrategy.Connected, subgraphItem);
        }
Esempio n. 14
0
        ///<inheritdoc/>
        protected override void SetupHandler()
        {
            BalloonLayout balloonLayout = new BalloonLayout();

            OptionGroup generalGroup = Handler.AddGroup(GENERAL);

            generalGroup.AddList(ROOT_NODE_POLICY, enumRoot.Keys, DIRECTED_ROOT);
            IOptionItem       allowNonTreeItem = generalGroup.AddBool(ALLOW_NON_TREE_EDGES, true);
            IOptionItem       nonTreeStyleItem = generalGroup.AddList(ROUTING_STYLE_FOR_NON_TREE_EDGES, enumRoute, ROUTE_ORTHOGONAL);
            ConstraintManager cm = new ConstraintManager(Handler);

            cm.SetEnabledOnValueEquals(allowNonTreeItem, true, nonTreeStyleItem);
            IOptionItem ebs = generalGroup.AddDouble(EDGE_BUNDLING_STRENGTH, 0.99, 0, 1);

            cm.SetEnabledOnValueEquals(nonTreeStyleItem, ROUTE_BUNDLED, ebs);
            generalGroup.AddBool(ACT_ON_SELECTION_ONLY, false);
            generalGroup.AddInt(PREFERRED_CHILD_WEDGE, balloonLayout.PreferredChildWedge, 1, 359);
            generalGroup.AddInt(PREFERRED_ROOT_WEDGE, balloonLayout.PreferredRootWedge, 1, 360);
            generalGroup.AddInt(MINIMAL_EDGE_LENGTH, balloonLayout.MinimumEdgeLength, 10, int.MaxValue);
            generalGroup.AddDouble(COMPACTNESS_FACTOR, balloonLayout.CompactnessFactor, 0.1, 0.9);
            generalGroup.AddBool(ALLOW_OVERLAPS, balloonLayout.AllowOverlaps);
            generalGroup.AddBool(BALLOON_FROM_SKETCH, balloonLayout.FromSketchMode);
            generalGroup.AddBool(PLACE_CHILDREN_INTERLEAVED, balloonLayout.InterleavedMode == InterleavedMode.AllNodes);
            generalGroup.AddBool(STRAIGHTEN_CHAINS, balloonLayout.ChainStraighteningMode);

            OptionGroup labelingGroup = Handler.AddGroup(LABELING);

            labelingGroup.AddBool(INTEGRATED_EDGE_LABELING, true);
            labelingGroup.AddList(NODE_LABELING_STYLE, nodeLabelingPolicies, nodeLabelingPolicies[3]);
        }
Esempio n. 15
0
        /// <summary>
        /// Populates this instance from scratch using a provided selection provider.
        /// </summary>
        /// <remarks>This instance will be cleared, and all constraints on it will be reset.
        /// The builder inspects the first <see cref="IPropertyItemDescriptor{T}"/> from
        /// <paramref name="selectionProvider"/> and creates an <see cref="IOptionBuilder"/> instance
        /// that will <see cref="IOptionBuilder.AddItems"/> to this instance via the builder.
        /// </remarks>
        /// <param name="selectionProvider"></param>
        /// <param name="contextLookup">The lookup tunnel through to the created
        /// <see cref="IOptionBuilderContext"/> that will be used to query the <see cref="IOptionBuilder"/>
        /// instances for recursive sets of properties.</param>
        public virtual void BuildFromSelection <T>(ISelectionProvider <T> selectionProvider, IContextLookup contextLookup)
        {
            StartContentChange();
            try {
                Clear();
                DefaultOptionBuilderContext <T> context;
                context = new DefaultOptionBuilderContext <T>(selectionProvider, this);
                context.ContextLookup = contextLookup;

                ConstraintManager constraintManager = this.Lookup <ConstraintManager>();
                if (constraintManager == null)
                {
                    constraintManager = new ConstraintManager(this);
                    this.SetLookup(typeof(ConstraintManager), constraintManager);
                }
                constraintManager.Clear();
                IEnumerator <IPropertyItemDescriptor <T> > enumerator = selectionProvider.Selection.GetEnumerator();
                if (enumerator.MoveNext())
                {
                    IPropertyItemDescriptor <T> descriptor = enumerator.Current;
                    T item;
                    item = descriptor.Item;
                    IOptionBuilder builder = context.GetOptionBuilder(item);
                    if (builder != null)
                    {
                        builder.AddItems(context, item.GetType(), item);
                    }
                }
            } finally {
                EndContentChange();
            }
        }
Esempio n. 16
0
        ///<inheritdoc/>
        protected override void SetupHandler()
        {
            CreateLayout();
            ConstraintManager cm = new ConstraintManager(Handler);
            var topLevelGroup    = Handler.AddGroup("TOP_LEVEL");

            topLevelGroup.Attributes[TableEditorFactory.RenderingHintsAttribute]   = TableEditorFactory.RenderingHints.Invisible;
            topLevelGroup.Attributes[DefaultEditorFactory.RenderingHintsAttribute] = DefaultEditorFactory.RenderingHints.Invisible;

            topLevelGroup.AddList(STYLE, styleEnum.Keys, STYLE_ROWS);
            topLevelGroup.AddBool(NO_OVERLAP,
                                  (componentLayout.Style & ComponentArrangementStyles.ModifierNoOverlap) != 0);
            topLevelGroup.AddBool(FROM_SKETCH, (componentLayout.Style & ComponentArrangementStyles.ModifierAsIs) != 0);
            YDimension  size = componentLayout.PreferredSize;
            IOptionItem useScreenRationItem = topLevelGroup.AddBool(USE_SCREEN_RATIO, true);
            IOptionItem aspectRationItem    = topLevelGroup.AddDouble(ASPECT_RATIO, size.Width / size.Height);

            cm.SetEnabledOnValueEquals(useScreenRationItem, false, aspectRationItem);

            topLevelGroup.AddDouble(COMPONENT_SPACING, componentLayout.ComponentSpacing, 0.0d, double.MaxValue);
            IOptionItem gridEnabledItem = topLevelGroup.AddBool(GRID_ENABLED, componentLayout.GridSpacing > 0);
            IOptionItem gridSpacingItem =
                topLevelGroup.AddDouble(GRID_SPACING,
                                        componentLayout.GridSpacing > 0 ? componentLayout.GridSpacing : 20.0d);

            cm.SetEnabledOnValueEquals(gridEnabledItem, true, gridSpacingItem);
        }
Esempio n. 17
0
        protected override void SetupHandler()
        {
            OptionGroup toplevelGroup = Handler.AddGroup(TOP_LEVEL);

            //the toplevel group will show neither in Table view nor in dialog view explicitely
            //it's children will be shown one level above
            ((IOptionItem)toplevelGroup).Attributes[TableEditorFactory.RenderingHintsAttribute]   = TableEditorFactory.RenderingHints.Invisible;
            ((IOptionItem)toplevelGroup).Attributes[DefaultEditorFactory.RenderingHintsAttribute] = DefaultEditorFactory.RenderingHints.Invisible;

            OptionGroup spcg = toplevelGroup.AddGroup(SourcePortConstraints);

            spcg.Add(PortConstraintStr, PortConstraintType.Any).Attributes[OptionItem.SupportNullValueAttribute] = false;
            spcg.AddBool(StrongPortConstraint, false);
            OptionGroup tpcg = toplevelGroup.AddGroup(TargetPortConstraints);

            tpcg.Add(PortConstraintStr, PortConstraintType.Any).Attributes[OptionItem.SupportNullValueAttribute] = false;
            tpcg.AddBool(StrongPortConstraint, false);
            CollectionOptionItem <string> scopeItem = toplevelGroup.AddList(Scope, scopes, ScopeAllEdges);
            var clearItem        = toplevelGroup.AddBool(ClearAllConstraints, false);
            ConstraintManager cm = new ConstraintManager(Handler);

            cm.SetEnabledOnValueEquals(clearItem, false, spcg);
            cm.SetEnabledOnValueEquals(clearItem, false, scopeItem);
            cm.SetEnabledOnValueEquals(clearItem, false, tpcg);
        }
Esempio n. 18
0
        /// <summary>
        /// Initializes the option handler for the export
        /// </summary>
        private void SetupHandler()
        {
            handler = new OptionHandler(IMAGE_EXPORT);
            handler.PropertyChanged += handler_PropertyChanged;
            OptionGroup currentGroup = handler.AddGroup(OUTPUT);
            OptionItem  formatItem   = currentGroup.AddList(FORMAT, Formats.Keys, FORMAT_JPG);

            currentGroup.AddBool(HIDE_DECORATIONS, true);
            currentGroup.AddBool(EXPORT_RECTANGLE, true);
            currentGroup = handler.AddGroup(BOUNDS);


            OptionItem  sizeItem   = currentGroup.AddList(SIZE, SizeModes, USE_ORIGINAL_SIZE);
            IOptionItem widthItem  = currentGroup.AddInt(WIDTH, DefaultWidth, 1, int.MaxValue);
            IOptionItem heightItem = currentGroup.AddInt(HEIGHT, DefaultHeight, 1, Int32.MaxValue);

            currentGroup.AddDouble(SCALE, DefaultScale);

            currentGroup = handler.AddGroup(MARGINS);

            currentGroup.AddInt(LEFT_MARGIN, DefaultMargins);
            currentGroup.AddInt(RIGHT_MARGIN, DefaultMargins);
            currentGroup.AddInt(TOP_MARGIN, DefaultMargins);
            currentGroup.AddInt(BOTTOM_MARGIN, DefaultMargins);

            currentGroup = handler.AddGroup(JPG);
            IOptionItem qualityItem = currentGroup.AddDouble(QUALITY, DefaultQuality);

            currentGroup = handler.AddGroup(TIFF);
            OptionItem compressionItem = currentGroup.AddList(COMPRESSION,
                                                              Compressions.Keys, DefaultCompression);


            currentGroup = handler.AddGroup(PNG);
            var transparentItem = currentGroup.AddBool(TRANSPARENT, false);

            var cm = new ConstraintManager(Handler);

            cm.SetEnabledOnValueEquals(sizeItem, SPECIFY_WIDTH, widthItem);
            cm.SetEnabledOnValueEquals(sizeItem, SPECIFY_HEIGHT, heightItem);

            cm.SetEnabledOnValueEquals(formatItem, FORMAT_PNG, transparentItem);

            cm.SetEnabledOnValueEquals(formatItem, FORMAT_JPG, qualityItem);
            cm.SetEnabledOnValueEquals(formatItem, FORMAT_TIFF, compressionItem);

            // localization
            var rm =
                new ResourceManager("Demo.yFiles.ImageExport.ImageExport",
                                    Assembly.GetExecutingAssembly());
            var rmf = new ResourceManagerI18NFactory();

            rmf.AddResourceManager(Handler.Name, rm);
            Handler.I18nFactory = rmf;
        }
Esempio n. 19
0
        public void RemoveNoConstraintsBasedOnVars()
        {
            IConstraintManager CM      = new ConstraintManager();
            IExprBuilder       builder = GetBuilder();

            // Dummy Boogie variable
            var bv8TypeIdent = new TypedIdent(Token.NoToken, "bv8", Microsoft.Boogie.Type.GetBvType(8));
            var dummyVarBv   = new GlobalVariable(Token.NoToken, bv8TypeIdent);

            // dummyVar needs a programLocation, otherwise SymbolicVariable constructor raises an exception
            var progLoc = new ProgramLocation(dummyVarBv);

            dummyVarBv.SetMetadata <ProgramLocation>((int)Symbooglix.Annotation.AnnotationIndex.PROGRAM_LOCATION, progLoc);

            var s0 = new SymbolicVariable("s0", dummyVarBv).Expr;
            var s1 = new SymbolicVariable("s1", dummyVarBv).Expr;
            var s2 = new SymbolicVariable("s2", dummyVarBv).Expr;

            // Construct some constraints
            Expr c0 = builder.Eq(builder.BVAND(s0, s1), builder.ConstantBV(0, 8));
            Expr c1 = builder.Eq(s2, builder.ConstantBV(1, 8));

            CM.AddConstraint(c0, progLoc);
            CM.AddConstraint(c1, progLoc);

            var mockSolver      = new MockSolver();
            var indepenceSolver = new Symbooglix.Solver.ConstraintIndependenceSolver(mockSolver);

            Expr queryExpr = builder.Eq(builder.BVAND(s1, s2), builder.ConstantBV(0, 8));

            indepenceSolver.ComputeSatisfiability(new Solver.Query(CM, new Constraint(queryExpr)));

            // Check no constraints were removed
            Assert.AreEqual(2, mockSolver.Constraints.Count);
            Assert.AreSame(queryExpr, mockSolver.QueryExpr);

            bool c0Found = false;
            bool c1Found = false;

            foreach (var constraint in mockSolver.Constraints)
            {
                if (c0 == constraint.Condition)
                {
                    c0Found = true;
                }

                if (c1 == constraint.Condition)
                {
                    c1Found = true;
                }
            }

            Assert.IsTrue(c0Found);
            Assert.IsTrue(c1Found);
        }
Esempio n. 20
0
        static OptionHandler CreateHandler(GraphEditorForm form)
        {
            GraphControl         gc   = form.GraphControl;
            IGraph               g    = form.Graph;
            GraphEditorInputMode geim = form.GraphEditorInputMode;


            OptionHandler handler      = new OptionHandler(NAME);
            OptionGroup   controlGroup = handler.AddGroup(UI_DEFAULTS);

            controlGroup.AddDouble(HitTestRadius, gc.HitTestRadius);
            controlGroup.AddBool(AutoRemoveEmptyLabels, geim.AutoRemoveEmptyLabels);

//      var gridEnabledItem = controlGroup.AddBool(GridEnabled, form.Grid.Enabled);
            var gridVisibleItem  = controlGroup.AddBool(GridVisible, form.GridVisible);
            var gridWidthItem    = controlGroup.AddInt(GridWidth, form.GridWidth);
            var gridSnapTypeItem = controlGroup.AddList <GridSnapTypes>(GridSnapeType, new List <GridSnapTypes>
            {
                GridSnapTypes.All, GridSnapTypes.GridPoints, GridSnapTypes.HorizontalLines, GridSnapTypes.Lines, GridSnapTypes.None, GridSnapTypes.VerticalLines
            }, form.GridSnapType);

            ConstraintManager cm = new ConstraintManager(handler);

            cm.SetEnabledOnCondition(
                ConstraintManager.LogicalCondition.Or(cm.CreateValueEqualsCondition(gridVisibleItem, true),
                                                      cm.CreateValueEqualsCondition(gridVisibleItem, true)),
                gridWidthItem);
            cm.SetEnabledOnValueEquals(gridVisibleItem, true, gridSnapTypeItem);

            if (g != null)
            {
                OptionGroup graphGroup = handler.AddGroup(GRAPH_SETTINGS);
                graphGroup.AddBool(AutoAdjustPreferredLabelSize, g.NodeDefaults.Labels.AutoAdjustPreferredSize);
                graphGroup.AddBool(AutoCleanupPorts, g.NodeDefaults.Ports.AutoCleanUp);
                OptionGroup sharingGroup = graphGroup.AddGroup(SHARING_SETTINGS);

                sharingGroup.AddBool(ShareDefaultNodeStyleInstance, g.NodeDefaults.ShareStyleInstance);
                sharingGroup.AddBool(ShareDefaultEdgeStyleInstance, g.EdgeDefaults.ShareStyleInstance);
                sharingGroup.AddBool(ShareDefaultNodeLabelStyleInstance, g.NodeDefaults.Labels.ShareStyleInstance);
                sharingGroup.AddBool(ShareDefaultEdgeLabelStyleInstance, g.EdgeDefaults.Labels.ShareStyleInstance);
                sharingGroup.AddBool(ShareDefaultPortStyleInstance, g.NodeDefaults.Ports.ShareStyleInstance);
                sharingGroup.AddBool(ShareDefaultNodeLabelModelParameter, g.NodeDefaults.Labels.ShareLayoutParameterInstance);
                sharingGroup.AddBool(ShareDefaultEdgeLabelModelParameter, g.EdgeDefaults.Labels.ShareLayoutParameterInstance);
            }
            OptionGroup miscGroup  = handler.AddGroup(MISC_SETTINGS);
            UndoEngine  undoEngine = form.Graph.GetUndoEngine();

            if (undoEngine != null)
            {
                miscGroup.AddInt(UndoEngine_Size, undoEngine.Size);
            }
            return(handler);
        }
Esempio n. 21
0
        /// <summary>
        /// Initialization method -> just call the base class
        /// </summary>
        /// <param name="avatarDescription"></param>
        /// <param name="properties"></param>
        /// <returns></returns>
        public override MBoolResponse Initialize(MAvatarDescription avatarDescription, Dictionary <string, string> properties)
        {
            MBoolResponse res = base.Initialize(avatarDescription, properties);

            // Added new intermediate skeleton representation.
            this.SkeletonAccess = new IntermediateSkeleton();
            this.SkeletonAccess.InitializeAnthropometry(avatarDescription);

            this.constraintManager = new ConstraintManager(this.SceneAccess);

            return(res);
        }
Esempio n. 22
0
        /// <summary>
        /// Initialization method -> just call the base class
        /// </summary>
        /// <param name="avatarDescription"></param>
        /// <param name="properties"></param>
        /// <returns></returns>
        public override MBoolResponse Initialize(MAvatarDescription avatarDescription, Dictionary <string, string> properties)
        {
            MBoolResponse response = base.Initialize(avatarDescription, properties);

            //Setuo the skeleton access
            this.SkeletonAccess = new IntermediateSkeleton();
            this.SkeletonAccess.InitializeAnthropometry(avatarDescription);

            //Create a new constraint manager
            this.constraintManager = new ConstraintManager(this.SceneAccess);

            return(response);
        }
Esempio n. 23
0
 private void SetConstraintsData()
 {
     foreach (Constraint constraint in ConstraintManager.GetAllConstraints())
     {
         ConstraintData constraintData = new ConstraintData
         {
             type = constraint.constraintType
         };
         Utils.GetTransformRelativePathTo(constraint.gobject.transform, rootTransform, out constraintData.source);
         Utils.GetTransformRelativePathTo(constraint.target.transform, rootTransform, out constraintData.target);
         SceneData.Current.constraints.Add(constraintData);
     }
 }
        ///<inheritdoc/>
        protected override void SetupHandler()
        {
            createRouter();
            OptionGroup toplevelGroup = Handler.AddGroup(TOP_LEVEL);

            //the toplevel group will show neither in Table view nor in dialog view explicitely
            toplevelGroup.SetAttribute(TableEditorFactory.RENDERING_HINTS_ATTRIBUTE,
                                       (int)TableEditorFactory.RenderingHints.Invisible);
            toplevelGroup.SetAttribute(DefaultEditorFactory.RENDERING_HINTS_ATTRIBUTE,
                                       (int)DefaultEditorFactory.RenderingHints.Invisible);
            OptionGroup layoutGroup = toplevelGroup.AddGroup(LAYOUT_OPTIONS);
            OptionGroup costGroup   = toplevelGroup.AddGroup(COST);

            if (router.PathFinderStrategy is OrthogonalPatternEdgeRouter)
            {
                OrthogonalPatternEdgeRouter oper = (OrthogonalPatternEdgeRouter)router.PathFinderStrategy;
                layoutGroup.AddList(PATHFINDER, pathFinderList, ORTHOGONAL_PATTERN_PATH_FINDER);
                layoutGroup.AddList(SCOPE, scopes, SCOPE_ALL_EDGES);
                layoutGroup.AddDouble(MINIMUM_DISTANCE, oper.MinimumDistance);
                layoutGroup.AddBool(ACTIVATE_GRID_ROUTING, oper.GridRouting);
                layoutGroup.AddDouble(GRID_SPACING, oper.GridSpacing, 2.0, Double.MaxValue);

                ConstraintManager cm = new ConstraintManager(Handler);
                cm.SetEnabledOnValueEquals(layoutGroup[ACTIVATE_GRID_ROUTING], true, layoutGroup[GRID_SPACING]);

                costGroup.AddDouble(BEND_COST, oper.BendCost);
                cm.SetEnabledOnValueEquals(layoutGroup[PATHFINDER], ORTHOGONAL_PATTERN_PATH_FINDER, costGroup[BEND_COST]);
                costGroup.AddDouble(EDGE_CROSSING_COST, oper.EdgeCrossingCost);
                cm.SetEnabledOnValueEquals(layoutGroup[PATHFINDER], ORTHOGONAL_PATTERN_PATH_FINDER, costGroup[EDGE_CROSSING_COST]);
                costGroup.AddDouble(NODE_CROSSING_COST, oper.NodeCrossingCost);
                cm.SetEnabledOnValueEquals(layoutGroup[PATHFINDER], ORTHOGONAL_PATTERN_PATH_FINDER, costGroup[NODE_CROSSING_COST]);
            }
            else
            {
                layoutGroup.AddList(PATHFINDER, pathFinderList, ORTHOGONAL_PATTERN_PATH_FINDER);
                layoutGroup.AddList(SCOPE, scopes, SCOPE_ALL_EDGES);
                layoutGroup.AddDouble(MINIMUM_DISTANCE, 10);
                layoutGroup.AddBool(ACTIVATE_GRID_ROUTING, true);
                layoutGroup.AddDouble(GRID_SPACING, 20);

                ConstraintManager cm = new ConstraintManager(Handler);
                cm.SetEnabledOnValueEquals(layoutGroup[ACTIVATE_GRID_ROUTING], true, layoutGroup[GRID_SPACING]);

                costGroup.AddDouble(BEND_COST, 1);
                cm.SetEnabledOnValueEquals(layoutGroup[PATHFINDER], ORTHOGONAL_PATTERN_PATH_FINDER, costGroup[BEND_COST]);
                costGroup.AddDouble(EDGE_CROSSING_COST, 5);
                cm.SetEnabledOnValueEquals(layoutGroup[PATHFINDER], ORTHOGONAL_PATTERN_PATH_FINDER, costGroup[EDGE_CROSSING_COST]);
                costGroup.AddDouble(NODE_CROSSING_COST, 50);
                cm.SetEnabledOnValueEquals(layoutGroup[PATHFINDER], ORTHOGONAL_PATTERN_PATH_FINDER, costGroup[NODE_CROSSING_COST]);
            }
        }
Esempio n. 25
0
        public void WhenEqualsConstraintExists_givenPairwiseDisjunctive_thenConstraintNotMatch()
        {
            var variables = new List <Variable>()
            {
                new Variable("A", null),
                new Variable("B", null)
            };
            var constraints = new List <Constraint>
            {
                new Constraint(1, variables[0], CompareEnum.Equals, variables[1])
            };

            Approvals.Verify(ConstraintManager.GetNotMatchedConstraints(constraints, true).ToPrettyString());
        }
        ///<inheritdoc/>
        protected override void SetupHandler()
        {
            OptionGroup generalGroup = Handler.AddGroup(GENERAL);

            generalGroup.AddList(LAYOUT_STYLE, enumStyle, DIRECTED);
            IOptionItem       allowNonTreeItem = generalGroup.AddBool(ALLOW_NON_TREE_EDGES, true);
            IOptionItem       nonTreeStyleItem = generalGroup.AddList(ROUTING_STYLE_FOR_NON_TREE_EDGES, enumRoute, ROUTE_ORTHOGONAL);
            ConstraintManager cm = new ConstraintManager(Handler);

            cm.SetEnabledOnValueEquals(allowNonTreeItem, true, nonTreeStyleItem);

            generalGroup.AddBool(ACT_ON_SELECTION_ONLY, false);
            var bundlingStrength = generalGroup.AddDouble(EDGE_BUNDLING_STRENGTH, 0.99, 0, 1);

            cm.SetEnabledOnValueEquals(nonTreeStyleItem, ROUTE_BUNDLED, bundlingStrength);

            ClassicTreeLayout treeLayout    = new ClassicTreeLayout();
            OptionGroup       directedGroup = Handler.AddGroup(DIRECTED);

            directedGroup.AddInt(MINIMAL_NODE_DISTANCE, (int)treeLayout.MinimumNodeDistance, 1, int.MaxValue);
            directedGroup.AddInt(MINIMAL_LAYER_DISTANCE, (int)treeLayout.MinimumLayerDistance, 10, int.MaxValue);
            directedGroup.AddList(ORIENTATION, enumOrient.Keys, TOP_TO_BOTTOM);
            directedGroup.AddList(PORT_STYLE, enumPortStyle.Keys, NODE_CENTER_PORTS);

            directedGroup.AddBool(INTEGRATED_NODE_LABELING, false);
            directedGroup.AddBool(INTEGRATED_EDGE_LABELING, false);

            IOptionItem edgeRoutingOption  = directedGroup.AddBool(ORTHOGONAL_EDGE_ROUTING, false);
            IOptionItem busAlignmentOption = directedGroup.AddDouble(BUS_ALIGNMENT, 0.5, 0, 1);

            directedGroup.AddDouble(VERTICAL_ALIGNMENT, 0.5, 0, 1);
            var childPolicyItem    = directedGroup.AddList(CHILD_PLACEMENT_POLICY, childPlacementPolicies.Keys, SIBLINGS_ON_SAME_LAYER);
            var globalLayeringItem = directedGroup.AddBool(ENFORCE_GLOBAL_LAYERING, false);

            cm.SetEnabledOnCondition(ConstraintManager.LogicalCondition.And(cm.CreateValueEqualsCondition(edgeRoutingOption, true),
                                                                            ConstraintManager.LogicalCondition.Or(cm.CreateValueEqualsCondition(globalLayeringItem, true),
                                                                                                                  cm.CreateValueEqualsCondition(childPolicyItem, ALL_LEAVES_ON_SAME_LAYER))),
                                     busAlignmentOption);

            var         ar      = new AspectRatioTreeLayout();
            OptionGroup arGroup = Handler.AddGroup(AR);

            arGroup.AddInt(HORIZONTAL_SPACE, (int)ar.HorizontalDistance);
            arGroup.AddInt(VERTICAL_SPACE, (int)ar.VerticalDistance);
            arGroup.AddInt(BEND_DISTANCE, (int)ar.BendDistance);
            IOptionItem ratioItem   = arGroup.AddDouble(ASPECT_RATIO, ar.AspectRatio);
            IOptionItem useViewItem = arGroup.AddBool(USE_VIEW_ASPECT_RATIO, true);

            cm.SetEnabledOnValueEquals(useViewItem, false, ratioItem);
        }
Esempio n. 27
0
        /// <summary>
        /// sets up the option handler for specifying the layout parameters.
        /// </summary>
        protected override void SetupHandler()
        {
            // global layout options
            OptionGroup layoutGroup = Handler.AddGroup(LAYOUT);

            layoutGroup.AddList(STYLE, styles.Keys, NORMAL);
            layoutGroup.AddInt(GRID, 25, 1, int.MaxValue);
            layoutGroup.AddBool(LENGTH_REDUCTION, true);
            var fromSketchItem = layoutGroup.AddBool(USE_EXISTING_DRAWING_AS_SKETCH, false);

            layoutGroup.AddBool(CROSSING_POSTPROCESSING, true);
            layoutGroup.AddBool(PERCEIVED_BENDS_POSTPROCESSING, true);
            layoutGroup.AddBool(USE_RANDOMIZATION, true);
            layoutGroup.AddBool(USE_FACE_MAXIMIZATION, false);

            //edge label options
            OptionGroup labelingGroup = Handler.AddGroup(LABELING);

            labelingGroup.AddList(EDGE_LABELING, edgeLabeling, NONE);
            labelingGroup.AddList(EDGE_LABEL_MODEL, edgeLabelModel, BEST);
            labelingGroup.AddBool(CONSIDER_NODE_LABELS, false);

            ConstraintManager cm = new ConstraintManager(Handler);

            //edge options
            OptionGroup edgeGroup     = Handler.AddGroup(EDGES);
            var         selection     = edgeGroup.AddBool(DRAW_SELECTED_EDGES_UPWARDS, false);
            var         busRouting    = edgeGroup.AddBool(UPWARD_EDGE_BUS_ROUTING, true);
            var         directionEnum = edgeGroup.AddList(ORIENTATION, orientEnum.Keys, TOP_TO_BOTTOM);

            cm.SetEnabledOnValueEquals(selection, true, busRouting);
            cm.SetEnabledOnValueEquals(selection, true, directionEnum);

            edgeGroup.AddDouble(MINIMUM_FIRST_SEGMENT_LENGTH, 15, 1, 500);
            edgeGroup.AddDouble(MINIMUM_SEGMENT_LENGTH, 15, 1, 500);
            edgeGroup.AddDouble(MINIMUM_LAST_SEGMENT_LENGTH, 15, 1, 500);

            // node grouping options
            OptionGroup groupingGroup = Handler.AddGroup(GROUPING);

            groupingGroup.AddList(GROUP_LAYOUT_POLICY, groupPolicy, LAYOUT_GROUPS);

            var c = cm.CreateValueEqualsCondition(fromSketchItem, false);

            cm.SetEnabledOnCondition(c, layoutGroup[CROSSING_POSTPROCESSING]);
            cm.SetEnabledOnCondition(c, layoutGroup[PERCEIVED_BENDS_POSTPROCESSING]);
            cm.SetEnabledOnCondition(c, layoutGroup[STYLE]);
            cm.SetEnabledOnCondition(c, layoutGroup[USE_RANDOMIZATION]);
        }
Esempio n. 28
0
        ///<inheritdoc/>
        protected override void ConfigureLayout()
        {
            OptionGroup layoutGroup = Handler.GetGroupByName(TOP_LEVEL);

            router.AdjustLeadingEdge     = false;
            router.DirectedMode          = (bool)layoutGroup[CONSIDER_EDGE_DIRECTION].Value;
            router.AdaptiveLineDistances = (bool)layoutGroup[USE_ADAPTIVE_LINE_DISTANCE].Value;
            router.LineDistance          = (int)layoutGroup[LINE_DISTANCE].Value;
            router.JoinEnds           = (bool)layoutGroup[JOINS_ENDS].Value;
            router.AbsJoinEndDistance = (int)layoutGroup[JOIN_DISTANCE].Value;
            ConstraintManager cm = new ConstraintManager(Handler);

            cm.SetEnabledOnValueEquals(layoutGroup[JOINS_ENDS], true, layoutGroup[JOIN_DISTANCE]);
            LayoutAlgorithm = router;
        }
Esempio n. 29
0
        /// <summary>
        /// Basic initialization function
        /// </summary>
        /// <param name="avatarDescription"></param>
        /// <param name="properties"></param>
        /// <returns></returns>
        public override MBoolResponse Initialize(MAvatarDescription avatarDescription, Dictionary <string, string> properties)
        {
            //Call the base class
            base.Initialize(avatarDescription, properties);

            this.avatarDescription = avatarDescription;
            this.ActiveHands       = new List <HandContainer>();

            // Added new intermediate skeleton representation.
            this.SkeletonAccess = new IntermediateSkeleton();
            this.SkeletonAccess.InitializeAnthropometry(avatarDescription);

            this.constraintManager = new ConstraintManager(this.SceneAccess);

            return(new MBoolResponse(true));
        }
Esempio n. 30
0
        ///<inheritdoc/>
        protected override void SetupHandler()
        {
            CreateRouter();

            // tab layout
            var   layoutGroup = Handler.AddGroup(LAYOUT);
            Scope scope       = router.Scope;

            layoutGroup.AddList(SCOPE, scopeTypes, scopeTypes[scope == Scope.RouteAllEdges ? 0 : 1]);
            layoutGroup.AddList(OPTIMIZATION_STRATEGY, strategies, strategies[0]);
            layoutGroup.AddList(MONOTONIC_RESTRICTION, monotonyFlags, monotonyFlags[0]);
            layoutGroup.AddBool(CONSIDER_NODE_LABELS, router.ConsiderNodeLabels);
            layoutGroup.AddBool(CONSIDER_EDGE_LABELS, router.ConsiderEdgeLabels);
            layoutGroup.AddBool(ENABLE_REROUTING, router.Rerouting);
            layoutGroup.AddInt(MAXIMUM_DURATION, 30);

            // tab distances
            var distancesGroup = Handler.AddGroup(MINIMAL_DISTANCES);

            EdgeLayoutDescriptor descriptor = router.DefaultEdgeLayoutDescriptor;

            distancesGroup.AddDouble(MINIMAL_EDGE_TO_EDGE_DISTANCE, descriptor.MinimumEdgeToEdgeDistance);
            distancesGroup.AddDouble(MINIMAL_NODE_TO_EDGE_DISTANCE, router.MinimumNodeToEdgeDistance);
            distancesGroup.AddDouble(MINIMAL_NODE_CORNER_DISTANCE, descriptor.MinimumNodeCornerDistance);
            distancesGroup.AddDouble(MINIMAL_FIRST_SEGMENT_LENGTH, descriptor.MinimumFirstSegmentLength);
            distancesGroup.AddDouble(MINIMAL_LAST_SEGMENT_LENGTH, descriptor.MinimumLastSegmentLength);

            // tab grid
            var  gridGroup = Handler.AddGroup(GRID_SETTINGS);
            Grid grid      = router.Grid;

            var gridEnabledItem = gridGroup.AddBool(GRID_ENABLED, grid != null);
            var gridSpacingItem = gridGroup.AddDouble(GRID_SPACING, grid != null ? grid.Spacing : 10);


            // tab polyline routing
            var polylineGroup             = Handler.AddGroup(POLYLINE_ROUTING);
            var polyLineItem              = polylineGroup.AddBool(ENABLE_POLYLINE_ROUTING, true);
            var polyLineSegmentLengthItem = polylineGroup.AddDouble(PREFERRED_POLYLINE_SEGMENT_LENGTH,
                                                                    router.PreferredPolylineSegmentLength);

            // some constraints to enable/disable values that depends on other values
            ConstraintManager cm = new ConstraintManager(Handler);

            cm.SetEnabledOnValueEquals(gridEnabledItem, true, gridSpacingItem);
            cm.SetEnabledOnValueEquals(polyLineItem, true, polyLineSegmentLengthItem);
        }
Esempio n. 31
0
    void Start()
    {
        GameObject globalObj = GameObject.FindGameObjectWithTag("GlobalTag");

        lineManager = globalObj.GetComponent("ConstraintManager") as ConstraintManager;
        graphManager = globalObj.GetComponent("GraphManager") as GraphManager;
        guiManager = globalObj.GetComponent("GUIManager") as GUIManager;
        globalVals = globalObj.GetComponent("GlobalValues") as GlobalValues;
        ballClass = globalObj.GetComponent("Player_Ball") as Player_Ball;
        endPoint = GameObject.Find("EndPoint");
    }
Esempio n. 32
0
 public void Awake()
 {
     guiManager = GameObject.FindGameObjectWithTag("GlobalTag").GetComponent("GUIManager") as GUIManager;
     globalVals = GameObject.FindGameObjectWithTag("GlobalTag").GetComponent("GlobalValues") as GlobalValues;
     constraintManager = GameObject.FindGameObjectWithTag("GlobalTag").GetComponent("ConstraintManager") as ConstraintManager;
 }
Esempio n. 33
0
 void Start()
 {
     ballCam = Camera.main;
     guiManager = GameObject.Find("Globals").GetComponent("GUIManager") as GUIManager;
     globalVals = GameObject.Find("Globals").GetComponent("GlobalValues") as GlobalValues;
     playerBall = GameObject.Find("Globals").GetComponent("Player_Ball") as Player_Ball;
     pathManager = GameObject.Find("Globals").GetComponent("ConstraintManager") as ConstraintManager;
     graphManager = GameObject.Find("Globals").GetComponent("GraphManager") as GraphManager;
     meta = GameObject.Find("Globals").GetComponent("GameMetaManager") as GameMetaManager;
 }