Example #1
0
 public MainForm()
 {
     InitializeComponent();
     gViewer1.CurrentLayoutMethod = LayoutMethod.MDS;
     _graphDrawer = new GraphDrawer(gViewer1);
     _analyzer    = new SourceSemanticAnalyzer();
 }
Example #2
0
        public override void OnInspectorGUI()
        {
            if (m_GraphDrawer == null)
            {
                m_GraphDrawer = new GraphDrawer();
            }

            EditorGUILayout.LabelField("Shutter Speed Simulation", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;
            m_GraphDrawer.DrawShutterGraph(m_ShutterAngle.floatValue);
            EditorGUILayout.PropertyField(m_ShutterAngle);
            EditorGUILayout.PropertyField(m_SampleCount);
            EditorGUILayout.PropertyField(m_MaxBlurRadius);
            EditorGUI.indentLevel--;
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Multiple Frame Blending", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;

            float fbValue = m_FrameBlending.floatValue;

            m_GraphDrawer.DrawBlendingGraph(fbValue);
            EditorGUILayout.PropertyField(m_FrameBlending);

            if (fbValue > 0f)
            {
                EditorGUILayout.HelpBox("Multi-Frame Blending lowers precision of the final picture for optimization purposes.", MessageType.Info);
            }


            EditorGUI.indentLevel--;
        }
Example #3
0
        TransferToGraphDrawer
        (
            GraphDrawer graphDrawer
        )
        {
            Debug.Assert(graphDrawer != null);
            AssertValid();

            Font oFont = this.Font;

            System.Windows.Media.Typeface oTypeface =
                WpfGraphicsUtil.FontToTypeface(oFont);

            Double dFontSize = WpfGraphicsUtil.WindowsFormsFontSizeToWpfFontSize(
                oFont.Size);

            VertexDrawer oVertexDrawer = graphDrawer.VertexDrawer;

            oVertexDrawer.SetFont(oTypeface, dFontSize);

            oVertexDrawer.LabelFillColor =
                WpfGraphicsUtil.ColorToWpfColor(this.VertexLabelFillColor);

            oVertexDrawer.LabelPosition      = this.VertexLabelPosition;
            oVertexDrawer.MaximumLabelLength = this.VertexLabelMaximumLength;

            EdgeDrawer oEdgeDrawer = graphDrawer.EdgeDrawer;

            oEdgeDrawer.SetFont(oTypeface, dFontSize);
            oEdgeDrawer.MaximumLabelLength = this.EdgeLabelMaximumLength;
        }
Example #4
0
        CreateNodeXLVisual
        (
            GeneralUserSettings oGeneralUserSettings
        )
        {
            Debug.Assert(oGeneralUserSettings != null);
            AssertValid();

            NodeXLVisual oNodeXLVisual = new NodeXLVisual();

            GraphDrawer oGraphDrawer = oNodeXLVisual.GraphDrawer;

            VertexDrawer oVertexDrawer = oGraphDrawer.VertexDrawer;

            EdgeDrawer oEdgeDrawer = oGraphDrawer.EdgeDrawer;

            oGeneralUserSettings.TransferToGraphDrawer(oGraphDrawer);

            // Override some of the user's settings.

            oVertexDrawer.Shape       = VertexShape.Disk;
            oVertexDrawer.Radius      = 2.0;
            oEdgeDrawer.Width         = 1;
            oEdgeDrawer.SelectedWidth = 1;

            return(oNodeXLVisual);
        }
Example #5
0
        public void SetImage(Bitmap newBitmap)
        {
            BitmapImage = newBitmap;
            graphDrawer = new GraphDrawer(newBitmap);
            graphics    = Graphics.FromImage(newBitmap);

            PictureBox.Image = newBitmap;
        }
        public void TestChangePrecision()
        {
            //Arrange
            GraphDrawer graphDrawer = new GraphDrawer();

            //Act
            graphDrawer.ChangePrecision(55);

            //Assert
            Assert.AreEqual(graphDrawer.GetPrecision(), 55);
        }
        public void TestZoomOutTwice()
        {
            //Arrange
            GraphDrawer graphDrawer = new GraphDrawer();

            //Act
            graphDrawer.ZoomOutTwice();

            //Assert
            Assert.AreEqual(graphDrawer.GetScale(), 25);
        }
Example #8
0
        TransferToGraphDrawer
        (
            GraphDrawer graphDrawer
        )
        {
            Debug.Assert(graphDrawer != null);
            AssertValid();

            this.LabelUserSettings.TransferToGraphDrawer(graphDrawer);

            graphDrawer.BackColor =
                WpfGraphicsUtil.ColorToWpfColor(this.BackColor);

            EdgeDrawer   oEdgeDrawer   = graphDrawer.EdgeDrawer;
            VertexDrawer oVertexDrawer = graphDrawer.VertexDrawer;

            EdgeWidthConverter oEdgeWidthConverter = new EdgeWidthConverter();
            AlphaConverter     oAlphaConverter     = new AlphaConverter();

            oEdgeDrawer.Width =
                oEdgeWidthConverter.WorkbookToGraph(this.EdgeWidth);

            oEdgeDrawer.SelectedWidth =
                oEdgeWidthConverter.WorkbookToGraph(this.SelectedEdgeWidth);

            oEdgeDrawer.Color = WpfGraphicsUtil.ColorToWpfColor(

                Color.FromArgb(oAlphaConverter.WorkbookToGraphAsByte(
                                   this.EdgeAlpha),

                               this.EdgeColor)
                );

            oEdgeDrawer.SelectedColor = WpfGraphicsUtil.ColorToWpfColor(
                this.SelectedEdgeColor);

            oEdgeDrawer.RelativeArrowSize = this.RelativeArrowSize;

            oVertexDrawer.Shape = this.VertexShape;

            oVertexDrawer.Radius = (new VertexRadiusConverter()).WorkbookToGraph(
                this.VertexRadius);

            oVertexDrawer.Color = WpfGraphicsUtil.ColorToWpfColor(

                Color.FromArgb(oAlphaConverter.WorkbookToGraphAsByte(
                                   this.VertexAlpha),

                               this.VertexColor)
                );

            oVertexDrawer.SelectedColor = WpfGraphicsUtil.ColorToWpfColor(
                this.SelectedVertexColor);
        }
        public void GenerateGraphs()
        {
            //Arrange
            PictureBox  pictureBox  = new PictureBox();
            GraphDrawer graphDrawer = new GraphDrawer(pictureBox);

            //Act
            pictureBox.Refresh();

            //Assert
        }
        public void TestSettingMaclaurinSeriesTerms()
        {
            //Arrange
            GraphDrawer graphDrawer = new GraphDrawer();

            //Act
            graphDrawer.SetNumberOfTerms(3);

            //Assert
            Assert.AreEqual(graphDrawer.MaclaurinTerms, 3);
        }
        public void TestMaclaurinSeriesAlgorithmSwitch2()
        {
            //Arrange
            GraphDrawer graphDrawer = new GraphDrawer();

            //Act
            graphDrawer.SwitchMaclaurinSeriesAlgorithm();

            //Assert
            Assert.AreEqual(graphDrawer.IsShowFunctionAnalyticalMaclaurinSeries, false);
            Assert.AreEqual(graphDrawer.IsShowFunctionNewtonMaclaurinSeries, true);
        }
        public void TestIntegralSwitch()
        {
            //Arrange
            GraphDrawer graphDrawer = new GraphDrawer();

            //Act
            graphDrawer.HideIntegral();
            graphDrawer.ShowIntegral();

            //Assert
            Assert.AreEqual(graphDrawer.IsShowFunctionIntegral, true);
        }
        public void TestFunctionSwitch()
        {
            //Arrange
            GraphDrawer graphDrawer = new GraphDrawer();

            //Act
            graphDrawer.HideFunction();
            graphDrawer.ShowFunction();

            //Assert
            Assert.AreEqual(graphDrawer.IsShowFunction, true);
        }
        public void TestMaclaurinSeriesSwitch()
        {
            //Arrange
            GraphDrawer graphDrawer = new GraphDrawer();

            //Act
            graphDrawer.HideMaclaurinSeries();
            graphDrawer.ShowMaclaurinSeries();

            //Assert
            Assert.AreEqual(graphDrawer.IsShowFunctionMaclaurinSeries, true);
        }
        public void TestXYSwitch()
        {
            //Arrange
            GraphDrawer graphDrawer = new GraphDrawer();

            //Act
            graphDrawer.HideXY();
            graphDrawer.ShowXY();

            //Assert
            Assert.AreEqual(graphDrawer.IsShowXY, true);
        }
        public void TestAxesSwitch()
        {
            //Arrange
            GraphDrawer graphDrawer = new GraphDrawer();

            //Act
            graphDrawer.ShowAxes();
            graphDrawer.HideAxes();

            //Assert
            Assert.AreEqual(graphDrawer.IsShowAxes, false);
        }
        public void TestScaleResetting()
        {
            //Arrange
            GraphDrawer graphDrawer = new GraphDrawer();

            //Act
            graphDrawer.ZoomIn();
            graphDrawer.ResetScale();

            //Assert
            Assert.AreEqual(graphDrawer.GetScale(), 50);
        }
        public void TestDerivativeAlgorithmSwitch2()
        {
            //Arrange
            GraphDrawer graphDrawer = new GraphDrawer();

            //Act
            graphDrawer.SwitchDerivativeAlgorithm();

            //Assert
            Assert.AreEqual(graphDrawer.IsShowFunctionAnalyticalDerivative, true);
            Assert.AreEqual(graphDrawer.IsShowFunctionNewtonDerivative, false);
        }
        public void TestVerticalLabelsSwitch()
        {
            //Arrange
            GraphDrawer graphDrawer = new GraphDrawer();

            //Act
            graphDrawer.ShowVerticalLabels();
            graphDrawer.HideVerticalLabels();

            //Assert
            Assert.AreEqual(graphDrawer.IsShowVerticalAxisLabels, false);
        }
        public void TestDerivativeSwitch()
        {
            //Arrange
            GraphDrawer graphDrawer = new GraphDrawer();

            //Act
            graphDrawer.HideDerivative();
            graphDrawer.ShowDerivative();

            //Assert
            Assert.AreEqual(graphDrawer.IsShowFunctionDerivative, true);
        }
Example #21
0
    private void Awake()
    {
        instance = this;

        tetrisBotConnectionColor   = CopyColor(tetrisBotColor);
        tetrisBotConnectionColor.a = 0.5f;

        mctsBotConnectionColor   = CopyColor(mctsBotColor);
        mctsBotConnectionColor.a = 0.5f;

        humanBotConnectionColor   = CopyColor(humanBotColor);
        humanBotConnectionColor.a = 0.5f;
    }
Example #22
0
 public void DisplayGraphic()
 {
     try
     {
         ExpressionTree tree = new ExpressionTree(txt_input.Text);
         if (pbox_function.Image != null)
         {
             pbox_function.Image.Dispose();
         }
         pbox_function.Image = GraphDrawer.Draw(tree, zoom, cameraX, cameraY, pbox_function.Width / 4, pbox_function.Height / 4);
     }
     catch { }
 }
        public override void OnInspectorGUI()
        {
            if (m_GraphDrawer == null)
            {
                m_GraphDrawer = new GraphDrawer();
            }

            EditorGUILayout.LabelField("Shutter Speed Simulation", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;
            m_GraphDrawer.DrawShutterGraph(m_ShutterAngle.floatValue);
            EditorGUILayout.PropertyField(m_ShutterAngle);
            EditorGUILayout.PropertyField(m_SampleCount);
            EditorGUILayout.PropertyField(m_MaxBlurRadius);
            EditorGUI.indentLevel--;
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Multiple Frame Blending", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;
            m_GraphDrawer.DrawBlendingGraph(m_FrameBlending.floatValue);
            EditorGUILayout.PropertyField(m_FrameBlending);
            EditorGUI.indentLevel--;
        }
Example #24
0
        public override void OnInspectorGUI()
        {
            if (m_GraphDrawer == null)
                m_GraphDrawer = new GraphDrawer();

            EditorGUILayout.LabelField("Shutter Speed Simulation", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;
            m_GraphDrawer.DrawShutterGraph(m_ShutterAngle.floatValue);
            EditorGUILayout.PropertyField(m_ShutterAngle);
            EditorGUILayout.PropertyField(m_SampleCount);
            EditorGUI.indentLevel--;
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Multiple Frame Blending", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;

            float fbValue = m_FrameBlending.floatValue;
            m_GraphDrawer.DrawBlendingGraph(fbValue);
            EditorGUILayout.PropertyField(m_FrameBlending);

            if (fbValue > 0f)
                EditorGUILayout.HelpBox("Multi-Frame Blending lowers precision of the final picture for optimization purposes.", MessageType.Info);


            EditorGUI.indentLevel--;
        }
Example #25
0
        TransferToGraphDrawer
        (
            GraphDrawer graphDrawer
        )
        {
            Debug.Assert(graphDrawer != null);
            AssertValid();

            System.Windows.Media.Typeface oTypeface;
            Double dFontSize;

            //***********
            //  Vertex
            //***********

            VertexDrawer oVertexDrawer = graphDrawer.VertexDrawer;

            FontToTypefaceAndFontSize(this.VertexFont,
                                      out oTypeface, out dFontSize);

            oVertexDrawer.SetFont(oTypeface, dFontSize);

            oVertexDrawer.LabelFillColor =
                WpfGraphicsUtil.ColorToWpfColor(this.VertexLabelFillColor);

            oVertexDrawer.LabelPosition      = this.VertexLabelPosition;
            oVertexDrawer.MaximumLabelLength = this.VertexLabelMaximumLength;
            oVertexDrawer.LabelWrapText      = this.VertexLabelWrapText;

            oVertexDrawer.LabelWrapMaxTextWidth =
                this.VertexLabelWrapMaxTextWidth;

            //***********
            //  Edge
            //***********

            EdgeDrawer oEdgeDrawer = graphDrawer.EdgeDrawer;

            FontToTypefaceAndFontSize(this.EdgeFont, out oTypeface, out dFontSize);

            oEdgeDrawer.SetFont(oTypeface, dFontSize);

            oEdgeDrawer.LabelTextColor =
                WpfGraphicsUtil.ColorToWpfColor(this.EdgeLabelTextColor);

            oEdgeDrawer.MaximumLabelLength = this.EdgeLabelMaximumLength;

            //***********
            //  Group
            //***********

            GroupDrawer oGroupDrawer = graphDrawer.GroupDrawer;

            FontToTypefaceAndFontSize(this.GroupFont,
                                      out oTypeface, out dFontSize);

            oGroupDrawer.SetFont(oTypeface, dFontSize);

            oGroupDrawer.LabelTextColor = WpfGraphicsUtil.ColorToWpfColor(

                Color.FromArgb((new AlphaConverter()).WorkbookToGraphAsByte(
                                   this.GroupLabelTextAlpha),

                               this.GroupLabelTextColor)
                );

            oGroupDrawer.LabelPosition = this.GroupLabelPosition;
        }
Example #26
0
        /// <summary>
        /// Run the generator and export the result.
        /// </summary>
        public void Run()
        {
            //md ## Generating the level
            //md To generate the level, we need to create an instance of the `GraphBasedGenerator<TRoom>` class. As we use integers to identify individual rooms, we will substitute the generic type parameter with `int` and pass the level description to the constructor of the generator.

            //md_hide-next
            var levelDescription = GetLevelDescription();

            var generator = new GraphBasedGeneratorGrid2D <int>(levelDescription);

            //md When we have an instance of the generator, we simply call the `GenerateLayout()` method and wait until the generator finds a valid layout based on our level description.

            var layout = generator.GenerateLayout();

            //md The result contains information about all the rooms in the level such as outline of the room or its position.

            //md ## Saving the result
            //md If we want to quickly visualize the result, we can use the `DungeonDrawer<TRoom>` class and export the layout as a PNG image.

            var drawer = new DungeonDrawer <int>();

            drawer.DrawLayoutAndSave(layout, "basics.png", new DungeonDrawerOptions()
            {
                Width  = 2000,
                Height = 2000,
            });

            #region hidden no-clean

            var roomTemplates = levelDescription
                                .GetGraph().Vertices
                                .Select(levelDescription.GetRoomDescription)
                                .Where(x => x.IsCorridor == false)
                                .SelectMany(x => x.RoomTemplates)
                                .Distinct()
                                .ToList();
            var roomTemplatesDrawer = new RoomTemplateDrawer();
            var roomTemplatesBitmap = roomTemplatesDrawer.DrawRoomTemplates(roomTemplates, new DungeonDrawerOptions()
            {
                Width           = 1200,
                Height          = 600,
                PaddingAbsolute = 100,
                FontSize        = 1,
                EnableHatching  = false
            });
            roomTemplatesBitmap.Save(ExamplesGenerator.AssetsFolder + "/room_templates.png");

            var graphDrawer = new GraphDrawer <int>();
            var graphBitmap = graphDrawer.DrawGraph(levelDescription, new Dictionary <int, Vector2Int>()
            {
                { 0, new Vector2Int(0, 0) },
                { 1, new Vector2Int(0, -1) },
                { 2, new Vector2Int(1, -1) },
                { 3, new Vector2Int(1, 0) },
                { 4, new Vector2Int(-1, 0) },
            }, new DungeonDrawerOptions()
            {
                Width           = 2500,
                Height          = 700,
                PaddingAbsolute = 80,
                FontSize        = 3,
            });
            graphBitmap.Save(ExamplesGenerator.AssetsFolder + "/graph.png");

            #endregion
        }
        TransferToGraphDrawer
        (
            GraphDrawer graphDrawer
        )
        {
            Debug.Assert(graphDrawer != null);
            AssertValid();

            this.LabelUserSettings.TransferToGraphDrawer(graphDrawer);

            graphDrawer.BackColor =
                WpfGraphicsUtil.ColorToWpfColor(this.BackColor);

            if (!String.IsNullOrEmpty(this.BackgroundImageUri))
            {
                graphDrawer.BackgroundImage =
                    (new WpfImageUtil()).GetImageSynchronousIgnoreDpi(
                        this.BackgroundImageUri);
            }
            else
            {
                graphDrawer.BackgroundImage = null;
            }

            EdgeDrawer   oEdgeDrawer   = graphDrawer.EdgeDrawer;
            VertexDrawer oVertexDrawer = graphDrawer.VertexDrawer;

            EdgeWidthConverter oEdgeWidthConverter = new EdgeWidthConverter();
            AlphaConverter     oAlphaConverter     = new AlphaConverter();

            oEdgeDrawer.Width =
                oEdgeWidthConverter.WorkbookToGraph(this.EdgeWidth);

            oEdgeDrawer.Color = WpfGraphicsUtil.ColorToWpfColor(

                Color.FromArgb(oAlphaConverter.WorkbookToGraphAsByte(
                                   this.EdgeAlpha),

                               this.EdgeColor)
                );

            oEdgeDrawer.CurveStyle = this.EdgeCurveStyle;

            oEdgeDrawer.BezierDisplacementFactor =
                this.EdgeBezierDisplacementFactor;

            oEdgeDrawer.SelectedColor = WpfGraphicsUtil.ColorToWpfColor(
                this.SelectedEdgeColor);

            oEdgeDrawer.RelativeArrowSize = this.RelativeArrowSize;

            oVertexDrawer.Shape = this.VertexShape;

            oVertexDrawer.Radius = (new VertexRadiusConverter()).WorkbookToGraph(
                this.VertexRadius);

            oVertexDrawer.Effect = this.VertexEffect;
            oVertexDrawer.RelativeOuterGlowSize = this.VertexRelativeOuterGlowSize;

            oVertexDrawer.Color = WpfGraphicsUtil.ColorToWpfColor(

                Color.FromArgb(oAlphaConverter.WorkbookToGraphAsByte(
                                   this.VertexAlpha),

                               this.VertexColor)
                );

            oVertexDrawer.SelectedColor = WpfGraphicsUtil.ColorToWpfColor(
                this.SelectedVertexColor);
        }
        void OnDrawGpuGraph(CanvasControl sender, CanvasDrawEventArgs args)
        {
            var graphDrawer = new GraphDrawer((float)sender.ActualWidth, (float)sender.ActualHeight, Scenarios, e => e.GpuTimeInMs, "GPU");

            graphDrawer.Draw(args.DrawingSession);
        }
Example #29
0
 void OnDrawGpuGraph(CanvasControl sender, CanvasDrawEventArgs args)
 {
     var graphDrawer = new GraphDrawer((float)sender.ActualWidth, (float)sender.ActualHeight, Scenarios, e => e.GpuTimeInMs, "GPU");
     graphDrawer.Draw(args.DrawingSession);
 }