Exemple #1
0
        public Editor(
            IControlHostService controlHostService,
            ICommandService commandService,
            IContextRegistry contextRegistry,
            IDocumentRegistry documentRegistry,
            IDocumentService documentService,
            PrototypeLister prototypeLister,
            LayerLister layerLister,
            SchemaLoader schemaLoader)
        {
            m_controlHostService = controlHostService;
            m_commandService = commandService;
            m_contextRegistry = contextRegistry;
            m_documentRegistry = documentRegistry;
            m_documentService = documentService;
            m_prototypeLister = prototypeLister;
            m_layerLister = layerLister;
            
            m_schemaLoader = schemaLoader;

            string initialDirectory = Path.Combine(Directory.GetCurrentDirectory(), "..\\..\\..\\..\\components\\wws_atf\\Samples\\CircuitEditor\\data");
            EditorInfo.InitialDirectory = initialDirectory;
            m_theme = new D2dDiagramTheme();
            m_circuitRenderer = new D2dCircuitRenderer<Module, Connection, ICircuitPin>(m_theme, documentRegistry);
            m_subGraphRenderer = new D2dSubCircuitRenderer<Module, Connection, ICircuitPin>(m_theme);

            // create d2dcontrol for displaying sub-circuit            
            m_d2dHoverControl = new D2dAdaptableControl();
            m_d2dHoverControl.Dock = DockStyle.Fill;
            var xformAdapter = new TransformAdapter();
            xformAdapter.EnforceConstraints = false;//to allow the canvas to be panned to view negative coordinates
            m_d2dHoverControl.Adapt(xformAdapter, new D2dGraphAdapter<Module, Connection, ICircuitPin>(m_circuitRenderer, xformAdapter));
            m_d2dHoverControl.DrawingD2d += new EventHandler(m_d2dHoverControl_DrawingD2d);
        }
Exemple #2
0
        public Editor(
            IControlHostService controlHostService,
            ICommandService commandService,
            IContextRegistry contextRegistry,
            IDocumentRegistry documentRegistry,
            IDocumentService documentService,
            PrototypeLister prototypeLister,
            LayerLister layerLister,
            SchemaLoader schemaLoader)
        {
            m_controlHostService = controlHostService;
            m_commandService     = commandService;
            m_contextRegistry    = contextRegistry;
            m_documentRegistry   = documentRegistry;
            m_documentService    = documentService;
            m_prototypeLister    = prototypeLister;
            m_layerLister        = layerLister;

            m_schemaLoader = schemaLoader;

            string initialDirectory = Path.Combine(Directory.GetCurrentDirectory(), "..\\..\\..\\..\\components\\wws_atf\\Samples\\CircuitEditor\\data");

            EditorInfo.InitialDirectory = initialDirectory;
            m_theme            = new D2dDiagramTheme();
            m_circuitRenderer  = new D2dCircuitRenderer <Module, Connection, ICircuitPin>(m_theme, documentRegistry);
            m_subGraphRenderer = new D2dSubCircuitRenderer <Module, Connection, ICircuitPin>(m_theme);

            //// Note: Santa Monica uses following render settings:
            //m_circuitRenderer.TitleBackgroundFilled = true;
            //m_circuitRenderer.RoundedBorder = false;
            //m_circuitRenderer.PinDrawStyle = D2dCircuitRenderer<Module, Connection, ICircuitPin>.PinStyle.OnBorderFilled;

            //m_subGraphRenderer.TitleBackgroundFilled = true;
            //m_subGraphRenderer.RoundedBorder = false;
            //m_subGraphRenderer.PinDrawStyle = D2dCircuitRenderer<Module, Connection, ICircuitPin>.PinStyle.OnBorderFilled;

            // create d2dcontrol for displaying sub-circuit
            m_d2dHoverControl      = new D2dAdaptableControl();
            m_d2dHoverControl.Dock = DockStyle.Fill;
            var xformAdapter = new TransformAdapter();

            xformAdapter.EnforceConstraints = false;//to allow the canvas to be panned to view negative coordinates
            m_d2dHoverControl.Adapt(xformAdapter, new D2dGraphAdapter <Module, Connection, ICircuitPin>(m_circuitRenderer, xformAdapter));
            m_d2dHoverControl.DrawingD2d += new EventHandler(m_d2dHoverControl_DrawingD2d);
        }
Exemple #3
0
        private IList <GroupPinData> GetGroupPinChainData(D2dCircuitRenderer <TElement, TWire, TPin> circuitRender, Point worldOffset, D2dGraphics g)
        {
            var connection = DomNode.Cast <Wire>();
            var dataPoints = new List <GroupPinData>();

            if (circuitRender != null)
            {
                var relativePath = new List <ICircuitGroupType <TElement, TWire, TPin> >();

                // --- edge starts from the output pin
                var group = connection.OutputElement.As <ICircuitGroupType <TElement, TWire, TPin> >();
                foreach (var groupPin in connection.OutputPinSinkChain)
                {
                    var pt = circuitRender.GetPinPositionCenterY(group.Cast <TElement>(), groupPin.Index, false, g);
                    pt.Offset(worldOffset);
                    pt.Offset(circuitRender.WorldOffset(relativePath.AsIEnumerable <TElement>()));
                    relativePath.Add(group);
                    dataPoints.Add(new GroupPinData {
                        Pos = pt, Group = group, GroupPin = groupPin
                    });
                    if (!group.Expanded)
                    {
                        break;
                    }
                    group = groupPin.InternalElement.As <ICircuitGroupType <TElement, TWire, TPin> >();
                }

                dataPoints.Reverse(); // upward
                if (relativePath.Any())
                {
                    var startGroup = relativePath.Last();
                    if (startGroup.Expanded) // the edge starts from an expanded group pin, need to draw the virtual link
                    {
                        // the first data starts from sub-node/pin
                        var   firstGroupPin = dataPoints[0].GroupPin;
                        Point p0            = circuitRender.GetPinPositionCenterY(firstGroupPin.InternalElement.Cast <TElement>(), firstGroupPin.InternalPinIndex, false, g);
                        p0.Offset(worldOffset);
                        p0.Offset(circuitRender.WorldOffset(relativePath.AsIEnumerable <TElement>()));
                        dataPoints.Insert(0, new GroupPinData {
                            Pos = p0
                        });
                    }
                }
                else // edge starts from a non-expanded node
                {
                    Point p0 = circuitRender.GetPinPositionCenterY(connection.OutputElement.Cast <TElement>(), connection.OutputPin.Index, false, g);
                    p0.Offset(worldOffset);
                    dataPoints.Add(new GroupPinData {
                        Pos = p0
                    });
                }

                int numInputPoints = dataPoints.Count;
                dataPoints[dataPoints.Count - 1].IsReal = true;

                // --- edge ends at the input pin
                relativePath.Clear();
                group = connection.InputElement.As <ICircuitGroupType <TElement, TWire, TPin> >();
                foreach (var groupPin in connection.InputPinSinkChain)
                {
                    var pt = circuitRender.GetPinPositionCenterY(group.Cast <TElement>(), groupPin.Index, true, g);
                    pt.Offset(worldOffset);
                    pt.Offset(circuitRender.WorldOffset(relativePath.AsIEnumerable <TElement>()));
                    relativePath.Add(group);
                    dataPoints.Add(new GroupPinData {
                        Pos = pt, Group = group, GroupPin = groupPin
                    });
                    if (!group.Expanded)
                    {
                        break;
                    }
                    group = groupPin.InternalElement.As <ICircuitGroupType <TElement, TWire, TPin> >();
                }

                if (relativePath.Any())
                {
                    var lastGroupPin = dataPoints[dataPoints.Count - 1].GroupPin;
                    var lastGroup    = dataPoints[dataPoints.Count - 1].Group;
                    if (lastGroup.Expanded) // the edge ends at an expanded group pin, need to draw the virtual link to subnode
                    {
                        // the last data ends at sub-node/pin
                        Point pn = circuitRender.GetPinPositionCenterY(lastGroupPin.InternalElement.Cast <TElement>(), lastGroupPin.InternalPinIndex, true, g);
                        pn.Offset(worldOffset);
                        pn.Offset(circuitRender.WorldOffset(relativePath.AsIEnumerable <TElement>()));
                        dataPoints.Add(new GroupPinData {
                            Pos = pn
                        });
                    }
                }
                else // edge ends at a non-expanded node
                {
                    Point pn = circuitRender.GetPinPositionCenterY(connection.InputElement.Cast <TElement>(), connection.InputPin.Index, true, g);
                    pn.Offset(worldOffset);
                    dataPoints.Add(new GroupPinData {
                        Pos = pn
                    });
                }

                dataPoints[numInputPoints].IsReal = true;
            }

            return(dataPoints);
        }