<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The ILNumerics Blog &#187; groups</title>
	<atom:link href="https://ilnumerics.net/blog/tag/groups/feed/" rel="self" type="application/rss+xml" />
	<link>https://ilnumerics.net/blog</link>
	<description>The Productivity Machine  &#124;  A fresh attempt for scientific computing  &#124;  http://ilnumerics.net</description>
	<lastBuildDate>Thu, 05 Dec 2024 09:09:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.41</generator>
	<item>
		<title>Getting to know your Scene Graph</title>
		<link>https://ilnumerics.net/blog/getting-to-know-your-scene-graph/</link>
		<comments>https://ilnumerics.net/blog/getting-to-know-your-scene-graph/#comments</comments>
		<pubDate>Mon, 29 Dec 2014 12:21:09 +0000</pubDate>
		<dc:creator><![CDATA[haymo]]></dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[ILNumerics]]></category>
		<category><![CDATA[Usage]]></category>
		<category><![CDATA[Visualization]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[groups]]></category>
		<category><![CDATA[scene graph]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://ilnumerics.net/blog/?p=703</guid>
		<description><![CDATA[<p>Did you ever miss a certain feature in your ILNumerics scene graph? You probably did. But did you know, that most of the missing &#8220;features&#8221; mean nothing more than a missing &#8220;property&#8221;? Often enough, there is only a convenient access to a certain scene graph object needed in order to finalize a required configuration. Recently, &#8230; <a href="https://ilnumerics.net/blog/getting-to-know-your-scene-graph/" class="more-link">Continue reading <span class="screen-reader-text">Getting to know your Scene Graph</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/getting-to-know-your-scene-graph/">Getting to know your Scene Graph</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Did you ever miss a certain feature in your <a href="/Visualization-API.html">ILNumerics scene graph</a>? You probably did. But did you know, that most of the missing &#8220;features&#8221; mean nothing more than a missing &#8220;property&#8221;? Often enough, there is only a convenient access to a certain scene graph object needed in order to finalize a required configuration.</p>
<p>Recently, a user asked how to turn the background of a legend object in ILNumerics plots transparent. There doesn&#8217;t seem to be a straight forward way to that. One might expect code like the following to work:</p>
<pre class="brush: csharp; title: ; notranslate">
var legend = new ILLegend(&quot;Line 1&quot;, &quot;Line 2&quot;);
legend.Background.Color = Color.FromArgb(200, Color.White);
</pre>
<p><span id="more-703"></span>Unfortunately, it does not. Legend objects do not implement a &#8216;Background&#8217; property which would give convenient access to the background object. However, the background object obviously exists. And ILLegend &#8211; likewise most of the more complex scene graph / plotting objects in ILNumerics &#8211; is derived from ILGroup! <a href="http://ilnumerics.net/group-nodes.html">Group nodes</a> represent the common way to store and manage any number of child objects. At the same time, group nodes gives the user flexible access to their children.<br />
In case of ILLegend we can utilize one of the access methods of ILGroup in order to access the scene graph node which implements the background of the legend. Once we have the background object, we can go out and manipulate it freely. In order to do that, let&#8217;s first investigate, which nodes exist inside a legend object!</p>
<h2>Stepping into living Scene Graphs</h2>
<p>ILNumerics and Visual Studio make it very easy to investigate even complex scenes. Let&#8217;s create a simple line plot application first! We start with a fresh new C# Windows Forms Application and add a Plotting Form Template to it. A detailed instruction is given on the getting started page, at &#8220;<a href="/Getting-Started-with-ILNumerics.html">Creating Visualizations with ILNumerics</a>&#8220;.<br />
Double click on the auto-generated Program.cs file and change the last line to read:</p>
<pre class="brush: csharp; title: ; notranslate">
    Application.Run(new Plotting_Form1());
</pre>
<p>Starting the project via F5 brings up the newly generated example plot. We make one more addition. Double click the Plotting_Form1.cs to show the form in the designer. Now, double click on the white panel1 background to go to the code implementing the scene setup. At the end of the code creating the new plot cube and adding the line plot we add another line which adds a new legend object:</p>
<pre class="brush: csharp; title: ; notranslate">
// Initial plot setup, modify this as needed
private void ilPanel1_Load(object sender, EventArgs e) {

    // create some test data, using our private computation module as inner class
    ILArray&lt;float&gt; Pos = Computation.CreateData(4, 300);

    // setup the plot (modify as needed)
    ilPanel1.Scene.Add(new ILPlotCube(twoDMode: false) {
        new ILLinePlot(Pos, tag: &quot;mylineplot&quot;) {
            Line = {
                Width = 2,
                Color = Color.Red,
                Antialiasing = true,
                DashStyle = DashStyle.Dotted
            }
        }, new ILLegend(&quot;MyLineItem&quot;)
    });
    // register event handler for allowing updates on right mouse click:
    ilPanel1.Scene.First&lt;ILLinePlot&gt;().MouseClick += (_s, _a) =&gt; {
        if (_a.Button == MouseButtons.Right)
            Update(ILMath.rand(3, 30));
    };
}
</pre>
<p>Starting via F5 should give a form similar like this:<br />
<a href="http://ilnumerics.net/blog/wp-content/uploads/2014/12/PlotFormPlain.png"><img class="aligncenter size-full wp-image-704" src="http://ilnumerics.net/blog/wp-content/uploads/2014/12/PlotFormPlain.png" alt="PlotFormPlain" width="675" height="562" /></a>Now, let&#8217;s start the fun! Investigating living objects works best when the objects are alive, right? So let&#8217;s set a breakpoint in Visual Studio right after the legend has been created:</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2014/12/2014-12-29-12_51_22-WindowsFormsApplication4-Debugging-Microsoft-Visual-Studio.png"><img class="aligncenter size-full wp-image-705" src="http://ilnumerics.net/blog/wp-content/uploads/2014/12/2014-12-29-12_51_22-WindowsFormsApplication4-Debugging-Microsoft-Visual-Studio.png" alt="2014-12-29 12_51_22-WindowsFormsApplication4 (Debugging) - Microsoft Visual Studio" width="655" height="292" /></a>As you know, Visual Studio allows for a nice feature &#8216;Edit and Continue&#8217;. Let&#8217;s add a variable as reference to our legend right in Debug mode! This is not really necessary, but eases the inspection. Note, it does not matter, where to add the code line, as long as we step over it in the debugger:</p>
<pre class="brush: csharp; title: ; notranslate">
    var leg = ilPanel1.Scene.First&lt;ILLegend&gt;();
</pre>
<p>Scene graph nodes are clever enough to give reasonable insights into their state and content at runtime. Just hover over the newly created variable &#8216;leg&#8217; with the mouse and Visual Studio will display helpful debugger visualizers. Expand any node to show its content:</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2014/12/2014-12-29-12_57_16-WindowsFormsApplication4-Debugging-Microsoft-Visual-Studio.png"><img class="aligncenter size-full wp-image-706" src="http://ilnumerics.net/blog/wp-content/uploads/2014/12/2014-12-29-12_57_16-WindowsFormsApplication4-Debugging-Microsoft-Visual-Studio.png" alt="2014-12-29 12_57_16-WindowsFormsApplication4 (Debugging) - Microsoft Visual Studio" width="616" height="306" /></a>Inspecting the legend object that way makes it immediately clear, which object legends are made out of: a triangle shape realizes the background, a line strip shape the border. A common group holds the individual legend items and will be filled dynamically at rendering time.</p>
<h2>Configuration Flexibility at its Extreme</h2>
<p>Having access to every single child item in the scene graph obviously brings an extreme flexibility for configurations. Now it is easy to change the color of the background object to make the legend transparent:</p>
<pre class="brush: csharp; title: ; notranslate">
var leg = ilPanel1.Scene.First&lt;ILLegend&gt;();
leg.First&lt;ILTriangles&gt;(&quot;ScreenObjectBackground&quot;).Color = Color.FromArgb(200, Color.White);
</pre>
<p>Which gives us our transparent legend:</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2014/12/2014-12-29-13_10_50-Form1.png"><img class="aligncenter size-full wp-image-707" src="http://ilnumerics.net/blog/wp-content/uploads/2014/12/2014-12-29-13_10_50-Form1.png" alt="2014-12-29 13_10_50-Form1" width="520" height="253" /></a></p>
<h2>Do not stop here!</h2>
<p>This is the message to take away: any object in any visualization and any plot in ILNumerics is composed out of individual smaller objects. You can access them and manipulate them freely without limits! Most &#8216;convenience&#8217; properties like &#8220;colorbar.Background&#8221; barely do more than we have done here: they give easy access to inner children (and add Intellisense support, of course). But if you need access &#8211; you can easily gain it yourself by inspecting the scene graph and its objects by the methods described here.</p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/getting-to-know-your-scene-graph/">Getting to know your Scene Graph</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://ilnumerics.net/blog/getting-to-know-your-scene-graph/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
