<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' version='2.0'><channel><atom:id>tag:blogger.com,1999:blog-7724398106195419987</atom:id><lastBuildDate>Thu, 18 Feb 2010 21:41:39 +0000</lastBuildDate><title>AVA</title><description>My blog on programming, where I'll share code and ideas.</description><link>http://users.telenet.be/ava/blog.html</link><managingEditor>noreply@blogger.com (AVA)</managingEditor><generator>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-7724398106195419987.post-4004522266182674896</guid><pubDate>Tue, 02 Feb 2010 18:35:00 +0000</pubDate><atom:updated>2010-02-02T20:04:51.429+01:00</atom:updated><title>Redirecting std::cout in managed apps</title><description>I &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;recently&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;needed&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;to&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;write&lt;/span&gt; a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;library&lt;/span&gt; in &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;Managed&lt;/span&gt; C++ &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;that&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;wrapped&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;another&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;native&lt;/span&gt; C++ &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;library&lt;/span&gt;. I &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;wanted&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;to&lt;/span&gt; display &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;the&lt;/span&gt; output &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;from&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;the&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;native&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;lib&lt;/span&gt; in a C# &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;application&lt;/span&gt;. &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;With&lt;/span&gt; a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;little&lt;/span&gt; help &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;from&lt;/span&gt; Google I &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;ended&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;up&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_24"&gt;with&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_25"&gt;this&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_26"&gt;&lt;/span&gt;&lt;a href="http://users.telenet.be/ava//redirector.h"&gt;/redirector.h&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;It is simply an implementation of a streambuf, that has a System::String object as an internal buffer and a System.IO.TextWriter to redirect the output to. Thanks to the gcroot functionality that allows us to have a managed reference in an unmanaged class.&lt;br /&gt;&lt;br /&gt;The following code installs the redirector:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;COutputRedirector *redirectedOut = new COutputRedirector(writer);&lt;br /&gt;std::streambuf* stdCout = std::cout.rdbuf(redirectedOut);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;With writer a managed reference to the TextWriter of your choice. Keep a pointer to the standard streambuf to put it back if needed.&lt;br /&gt;&lt;br /&gt;This captures all output to std::cout (and possible std::cerr). But for capturing output with printf we need another trick. I didn't need that yet so I didn't delve into that, but maybe later I will, and then I'll post an update.&lt;br /&gt;&lt;br /&gt;Feel free to comment.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7724398106195419987-4004522266182674896?l=users.telenet.be%2Fava%2Fblog.html' alt='' /&gt;&lt;/div&gt;</description><link>http://users.telenet.be/ava/2010/02/redirecting-stdout-in-managed-apps.html</link><author>noreply@blogger.com (AVA)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-7724398106195419987.post-1986382710523760975</guid><pubDate>Thu, 19 Jul 2007 13:39:00 +0000</pubDate><atom:updated>2007-07-19T16:25:37.078+02:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Max Scripting</category><title>Map Shower</title><description>&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://users.telenet.be/ava/afbe/showinvp.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://users.telenet.be/ava/afbe/showinvp.png" alt="" border="0" /&gt;&lt;/a&gt;In 3DStudio Max you can view a certain map from a certain material in the viewport by clicking the "Show Map in Viewport" button.&lt;br /&gt;&lt;br /&gt;If an artist wants to view all diffuse maps (or normal maps, or specular maps, ...)  in the scene then he needs to select all diffuse maps of all his materials and enable the button. Not really a job one would do very often, although that it is very interesting to view all maps in a scene of a specific type.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://users.telenet.be/ava/afbe/mapshower.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://users.telenet.be/ava/afbe/mapshower.png" alt="" border="0" /&gt;&lt;/a&gt;This macroscript displays a dialog with a list of radio buttons, corresponding to the most used maps in a max material. Just click a button to enable all the maps in the complete scene. You can select None to disable them all.&lt;br /&gt;&lt;br /&gt;If you want to add more or other maps, you can easily alter the script.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://users.telenet.be/ava/data/MapShower.ms"&gt;MapShower.ms&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Enjoy!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7724398106195419987-1986382710523760975?l=users.telenet.be%2Fava%2Fblog.html' alt='' /&gt;&lt;/div&gt;</description><link>http://users.telenet.be/ava/2007/07/map-shower.html</link><author>noreply@blogger.com (AVA)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-7724398106195419987.post-6371442427769017289</guid><pubDate>Thu, 19 Jul 2007 12:41:00 +0000</pubDate><atom:updated>2007-07-19T14:51:36.276+02:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Programming</category><title>Draggable NumericUpDown</title><description>XNumericUpDown inherits from System.Windows.Forms.NumericUpDown. With this control, as you click on the up or down button and then drag up and down, the value is incremented/decremented according whether you go up or down with the mouse.&lt;br /&gt;&lt;br /&gt;I created this behaviour based on the 3d Studio Max up/down controls, which have similar functionality. I use this control in all applications that need to be used by artists working also with Max, it's a feature they really miss elsewhere. And I think it handy too :-).&lt;br /&gt;&lt;br /&gt;Obviously, I've written this in C#, enjoy.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://users.telenet.be/ava/data/XNumericUpDown.cs"&gt;XNumericUpDown.cs&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7724398106195419987-6371442427769017289?l=users.telenet.be%2Fava%2Fblog.html' alt='' /&gt;&lt;/div&gt;</description><link>http://users.telenet.be/ava/2007/07/draggable-numericupdown.html</link><author>noreply@blogger.com (AVA)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item></channel></rss>