public override void SetEditor(SelectionContainer selectedEntity, ActionsGraph actionsGraph)
        {
            SelectionContainer = selectedEntity;
            var entities = selectedEntity.Entities;

            if (entities.Count == 0)
            {
                return;
            }
            SelectedNode = entities[entities.Count - 1].Node;
            var name = FunctionUtils.GetFunctionName(entities[entities.Count - 1].Node);

            if (!_handlers.ContainsKey(name))
            {
                if (selectedEntity.CurrentSelectionMode != TopAbsShapeEnum.TopAbs_FACE)
                {
                    DeactivateEditingHandler();
                    return;
                }
                else
                {
                    _currentHandler = _handlers[FunctionNames.Face];
                    _currentHandler.SetSelectedEntity(entities[entities.Count - 1]);
                }
            }
            else
            {
                _currentHandler = _handlers[name];
            }

            _currentHandler.SetNode(entities[entities.Count - 1].Node);
            _currentHandler.DisplayHandles();

            ViewUpdate();
        }
Esempio n. 2
0
        private void SetupChangedShapeEvent()
        {
            var noneAction = _actionGraph.ModifierContainer.Get(ModifierNames.None) as None;

            if (noneAction == null)
            {
                throw new Exception("Action None shoud exist");
            }
            noneAction.OnChangedShapeClick +=
                delegate(Node node)
            {
                var functionName = String.Empty;
                if (node != null)
                {
                    functionName = FunctionUtils.GetFunctionName(node);
                }
                _attachedView.ContextManager.BuildShapeContext(functionName);
                _lastSelectedNode = node;
            };
            _attachedView.ContextManager.OnClick += ContextualOnClick;

            _shapesActionMapping[FunctionNames.Circle]    = ModifierNames.DrawCircle;
            _shapesActionMapping[FunctionNames.Rectangle] = ModifierNames.RectangleTwoPoints;
            _shapesActionMapping[FunctionNames.Extrude]   = ModifierNames.Extrude;
        }
Esempio n. 3
0
        private TreeViewItem NewItem(string nodeText, Node node, bool showIcon)
        {
            var functionName = FunctionUtils.GetFunctionName(node);
            var pan          = new StackPanel {
                Orientation = Orientation.Horizontal
            };

            if (showIcon)
            {
                var iconName = GetIconName(functionName);
                if (!String.IsNullOrEmpty(iconName))
                {
                    var image = new Image {
                        Height = 16, Width = 16, Source = _imageBitmapCache.GetImageFromName(iconName)
                    };

                    pan.Children.Add(image);
                    image.VerticalAlignment = VerticalAlignment.Center;
                }
            }
            SetTextBlock(node, nodeText, pan);
            return(new TreeViewItem
            {
                Header = pan,
                IsExpanded = false,
                Tag = node
            });
        }
Esempio n. 4
0
        private bool SetTreeLabel(HeaderedItemsControl treeNode, Node node, bool showIcon)
        {
            try
            {
                var functionName = FunctionUtils.GetFunctionName(node);
                var text         = node.Get <StringInterpreter>().Value;
                var pan          = new StackPanel {
                    Orientation = Orientation.Horizontal
                };

                if (showIcon)
                {
                    var iconName = GetIconName(functionName);
                    if (!String.IsNullOrEmpty(iconName))
                    {
                        var image = new Image
                        {
                            Height = 16, Width = 16, Source = _imageBitmapCache.GetImageFromName(iconName)
                        };

                        pan.Children.Add(image);
                        image.VerticalAlignment = VerticalAlignment.Center;
                    }
                }
                SetTextBlock(node, text, pan);

                treeNode.Header = pan;
                treeNode.Tag    = node;
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        public override bool AcceptEntity(SelectionContainer entity)
        {
            var node         = entity.Entities[0].Node;
            var functionName = FunctionUtils.GetFunctionName(node);
            var descriptor   = DescriptorsFactory.Instance.GetFunctionTab(functionName);

            return(descriptor != null);
        }
        private void OnPointSelection(int stepIndex)
        {
            var source    = Dependency.Steps[stepIndex].Get <SceneSelectedEntity>();
            var shapeNode = source.Node;

            Ensure.IsTrue(FunctionUtils.GetFunctionName(shapeNode) == FunctionNames.Point, "Invalid point");
            var builder = Dependency.DocumentNodeBuilder;

            builder[stepIndex].ReferenceData = source;
        }
Esempio n. 7
0
        private void FillSpecificShapeDescriptor(Node shapeNode, int tabIndex)
        {
            var functionName = FunctionUtils.GetFunctionName(shapeNode);

            if (string.IsNullOrEmpty(functionName))
            {
                return;
            }
            var tab = DescriptorsFactory.Instance.GetFunctionTab(functionName);

            if (tab == null)
            {
                return;
            }
            AddControlToExpander(tab, shapeNode);
            tab.TabChildCount = 0;
            tab.SetTabOrder(tabIndex);
            _gvTabIndex = _gvTabIndex + tab.TabChildCount;
        }
Esempio n. 8
0
        private void FillConstraintsDescriptor(Node shapeNode1, Node shapeNode2, int tabIndex)
        {
            var functionName1 = FunctionUtils.GetFunctionName(shapeNode1);
            var functionName2 = FunctionUtils.GetFunctionName(shapeNode2);

            if (string.IsNullOrEmpty(functionName1) || string.IsNullOrEmpty(functionName2))
            {
                return;
            }
            var tab = DescriptorsFactory.Instance.GetConstraintTab(functionName1, functionName2);

            if (tab == null)
            {
                return;
            }
            AddControlToExpander(tab, shapeNode1, shapeNode2);
            tab.TabChildCount = 0;
            tab.SetTabOrder(tabIndex);
            _gvTabIndex = _gvTabIndex + tab.TabChildCount;
        }
Esempio n. 9
0
        private void BuildReferencesNode(int level, ref bool passFiltering,
                                         ref TreeViewItem childNode, Node childLabel, bool showIcon)
        {
            if (childLabel.Get <ReferenceInterpreter>() != null && childLabel.Get <ReferenceInterpreter>().Node != null)
            {
                var referenceNode = childLabel.Get <ReferenceInterpreter>().Node;
                var functionName  = FunctionUtils.GetFunctionName(referenceNode);
                if (functionName == FunctionNames.SubShape)
                {
                    referenceNode = new NodeBuilder(referenceNode)[0].Reference;
                }
                if (BlockCircularReferences(childLabel, referenceNode))
                {
                    BuildReferencedChildNode(level, ref passFiltering, ref childNode, referenceNode, showIcon);
                }
            }

            if (childLabel.Get <ReferenceListInterpreter>() != null)
            {
                BuildReferencedListChildrenNodes(level, ref passFiltering, ref childNode, childLabel, showIcon);
            }
        }
        public SolverGeometricObject ExtractGeometry(Node node)
        {
            if (!SolverGeometryExtracter.HasShapeOrInteractive(node))
            {
                return(null);
            }
            var functionName = FunctionUtils.GetFunctionName(node);

            if (string.IsNullOrEmpty(functionName))
            {
                return(null);
            }
            if (IsHidden(node))
            {
                return(null);
            }
            SolverGeometryExtracter extracter;
            var tryExtracter = GeometryExtracters.TryGetValue(functionName, out extracter);

            return(!tryExtracter
                       ? _genericExtracter.ExtractSolverGeometry(node)
                       : extracter.ExtractSolverGeometry(node));
        }
        protected override void PopulateExtendedView(StackPanel panel, SelectionContainer entity)
        {
            var node         = entity.Entities[0].Node;
            var functionName = FunctionUtils.GetFunctionName(node);
            var descriptor   = DescriptorsFactory.Instance.GetFunctionTab(functionName);

            descriptor.RefreshNode(panel, node, ViewInfo, new List <string>());
            ViewInfo.Document.Changed += OnDocumentChange;

            var gradient = new LinearGradientBrush
            {
                StartPoint    = new Point(0, 0),
                EndPoint      = new Point(0, 1),
                GradientStops = new GradientStopCollection
                {
                    new GradientStop(Colors.White, 0),
                    new GradientStop(Colors.DarkGray, 0.3),
                    new GradientStop(Colors.LightBlue, 1)
                }
            };

            panel.Background = gradient;
        }