|
| 1 | +<!-- saved from url=(0024)http://docs.autodesk.com --> |
| 2 | +<html> |
| 3 | +<head><script src="../scripts/yepnope.1.5.4-min.js" type="text/javascript"></script><script src="../scripts/lib/jquery-1.11.1.min.js" type="text/javascript"></script><meta content="text/html; charset=utf-8" http-equiv="Content-Type"/><meta content="MOBPRO" name="product"/><meta content="2018" name="release"/><meta content="GeneralUser" name="book"/><meta content="2017-09-08" name="created"/><meta content="GUID-02FA7DD3-6C7A-4C6A-B7BC-824765AE1CB2" name="topicid"/><meta content="concept" name="topic-type"/> |
| 4 | +<title>AutoExtract/AutoExtract.cpp</title> |
| 5 | +</head> |
| 6 | +<body height="100%"><div class="body_content" id="body-content"><link href="../style/navtree.css" rel="stylesheet" type="text/css"/><link href="../style/doxygen.css" rel="stylesheet" type="text/css"/><link href="../style/tabs.css" rel="stylesheet" type="text/css"/><link href="../style/adsk.cpm.css" rel="stylesheet" type="text/css"/><script language="javascript">var index = 'index.html';</script><script>$(document).ready(function() { yepnope.injectJs("./scripts/ac_common.js"); });</script><script type="text/javascript"> |
| 7 | +var tocSystemNeedsToBeLoaded = typeof(cpp_ref_adsk_ref_toc) == 'undefined'; |
| 8 | +var weAreIn21 = $('div#main.view-active').length; |
| 9 | +var tocPrefix = ''; |
| 10 | +if (weAreIn21) |
| 11 | +{ tocPrefix = 'cpp_ref/'; } |
| 12 | +function cpp_ref_initializeToc(forceTrigger) { |
| 13 | + cpp_ref_adsk_ref_toc.initResizable(); |
| 14 | + cpp_ref_adsk_ref_toc.initNavTree('_auto_extract_2_auto_extract_8cpp-example.html', tocPrefix); |
| 15 | + dQuery(document).trigger('toc_initialized'); |
| 16 | +} |
| 17 | +if (tocSystemNeedsToBeLoaded) |
| 18 | +{ |
| 19 | + yepnope([{ |
| 20 | + load:[tocPrefix + 'json3.min.js', tocPrefix + 'jquery.js', tocPrefix + 'ref-toc-controller.js', tocPrefix + 'dynsections.js'], |
| 21 | + complete: function() { |
| 22 | + if (typeof(dQuery) == 'undefined') |
| 23 | + { |
| 24 | + dQuery = jQuery.noConflict(true); |
| 25 | + } |
| 26 | + else { jQuery.noConflict(true); } |
| 27 | + $(document).ready(cpp_ref_initializeToc); |
| 28 | + } |
| 29 | + }]) |
| 30 | +} |
| 31 | +if (!weAreIn21) { // if in AKN... |
| 32 | +$(window).load( function() { |
| 33 | + setTimeout( function() { |
| 34 | + var content = $('body > div').not('#body-content'); // take any divs under body that are not id=body-content |
| 35 | + content.each( function() { |
| 36 | + $(this).css( { 'padding-left': $(this).css('margin-left') } ); // and if they have any padding-left already, move it to margin-left. |
| 37 | + } ); |
| 38 | + var width = cpp_ref_adsk_ref_toc.readFromStorage('width'); |
| 39 | + content.css({marginLeft:parseInt(width)+6+"px"}); |
| 40 | + }, 100); |
| 41 | +} ); |
| 42 | +} |
| 43 | +</script><script>$("div#WidgetFloaterPanels,link[href*='microsofttranslator.com'],script[src*='microsofttranslator.com'],script[src*='bing.com']").remove();</script><script type="text/javascript">$("div#navigation,div#breadcrumbs,div#banner").attr("translate","no"); var mtLocation = ((location && location.href && location.href.indexOf('https') == 0)?'https://ssl.microsofttranslator.com':'http://www.microsofttranslator.com')+'/ajax/v3/WidgetV3.ashx?ctf=True&ui=true&settings=Manual&from=en&hidelanguages='; yepnope.injectJs(mtLocation, function() {}, { charset:'utf-8', type:'text/javascript' } );</script><script> |
| 44 | + if (!tocSystemNeedsToBeLoaded) { cpp_ref_initializeToc(); } |
| 45 | + </script><!-- begin MT --> |
| 46 | +<div class="Dark" id="MicrosoftTranslatorWidget" style="float:right;z-index:100;color:white;background-color:#bbbbbb;height:58px;overflow:hidden"></div> |
| 47 | +<div> |
| 48 | +<div class="head"> |
| 49 | +<h1>AutoExtract/AutoExtract.cpp</h1> |
| 50 | +</div> |
| 51 | +<div id="top"><!-- Generated by Doxygen 1.8.10 --> |
| 52 | +<div class="tabs" id="navrow1"> |
| 53 | +<ul class="tablist"> |
| 54 | +<li><a href="./index.html"><span>Main Page</span></a></li> |
| 55 | +<li><a href="./pages.html"><span>Topics</span></a></li> |
| 56 | +<li><a href="./modules.html"><span>Modules</span></a></li> |
| 57 | +<li><a href="./namespaces.html"><span>Namespaces</span></a></li> |
| 58 | +<li><a href="./annotated.html"><span>Classes</span></a></li> |
| 59 | +<li><a href="./files.html"><span>Files</span></a></li> |
| 60 | +<li><a href="./examples.html"><span>Examples</span></a></li> |
| 61 | +</ul> |
| 62 | +</div> |
| 63 | +</div><!-- top --> |
| 64 | +<div class="ui-resizable side-nav-resizable" id="side-nav"> |
| 65 | +<div id="nav-tree"> |
| 66 | +<div id="nav-tree-contents"> |
| 67 | +<div class="sync" id="nav-sync"></div> |
| 68 | +</div> |
| 69 | +</div> |
| 70 | +<div class="ui-resizable-handle" id="splitbar" style="-moz-user-select:none;"> |
| 71 | +</div> |
| 72 | +</div> |
| 73 | +<div id="doc-content"> |
| 74 | +<div class="header"> |
| 75 | +<div class="headertitle"> |
| 76 | +<div class="title">AutoExtract/AutoExtract.cpp</div> </div> |
| 77 | +</div><!--header--> |
| 78 | +<div class="contents"> |
| 79 | +<div class="fragment"><div class="line"><span class="preprocessor">#include "AutoExtract.h"</span></div> |
| 80 | +<div class="line"></div> |
| 81 | +<div class="line"><span class="comment">// The single instance of this class will sit in the memory for the whole session, and watch for map extraction nodes.</span></div> |
| 82 | +<div class="line"><span class="comment">// When it finds a map extraction node with a specific name, it will execute it, then exit mudbox.</span></div> |
| 83 | +<div class="line">AutoExtract g_cInstance;</div> |
| 84 | +<div class="line"></div> |
| 85 | +<div class="line"><a name="a0"></a><a class="code" href="./node_8h.html#a1d51ad935ab5d26fe95dff62601b602c">IMPLEMENT_CLASS</a>( AutoExtract, Node, <span class="stringliteral">"autoextract"</span> );</div> |
| 86 | +<div class="line"></div> |
| 87 | +<div class="line">AutoExtract::AutoExtract( <span class="keywordtype">void</span> ) :</div> |
| 88 | +<div class="line"> FileEvent( this )</div> |
| 89 | +<div class="line">{</div> |
| 90 | +<div class="line"> <span class="comment">// The FileEvent attribute of this node is connected to Mudbox's main FileEvent node.</span></div> |
| 91 | +<div class="line"> <span class="comment">// When anything happens involving files, this node will be notified, and the OnNodeEvent</span></div> |
| 92 | +<div class="line"> <span class="comment">// method will be called.</span></div> |
| 93 | +<div class="line"> FileEvent.Connect( <a name="a1"></a><a class="code" href="./namespacemudbox.html#ae9df9ee935ec6744f98a1585d9db01df">Kernel</a>()->FileEvent );</div> |
| 94 | +<div class="line">};</div> |
| 95 | +<div class="line"></div> |
| 96 | +<div class="line"><span class="keywordtype">void</span> AutoExtract::OnNodeEvent( <span class="keyword">const</span> Attribute &<a class="code" href="./_g_lee_8h.html#ac8729153468b5dcf13f971b21d84d4e5">a</a>, <a name="a2"></a><a class="code" href="./namespacemudbox.html#a8d88d2a841f889dace76ffcd8d6b06da">NodeEventType</a> <a class="code" href="./_g_lee_8h.html#a653819996e713edf9c01a5b564199189">t</a> )</div> |
| 97 | +<div class="line">{</div> |
| 98 | +<div class="line"> <span class="comment">// This method is called when any kind of event happens to any attribute of this node.</span></div> |
| 99 | +<div class="line"> <span class="comment">// So we need to check to make sure it is the right kind of event on the right</span></div> |
| 100 | +<div class="line"> <span class="comment">// attribute. We are interested in the "post-read" event, which is called after any kind of file</span></div> |
| 101 | +<div class="line"> <span class="comment">// is read into Mudbox. We look at the file name to be sure it is a scene (.mud) file, because</span></div> |
| 102 | +<div class="line"> <span class="comment">// this same event will be triggered when Mudbox reads image files, stamps, stencils, etc.</span></div> |
| 103 | +<div class="line"> <span class="keywordflow">if</span> ( t == <a name="a3"></a><a class="code" href="./namespacemudbox.html#a8d88d2a841f889dace76ffcd8d6b06daa274758890f9a27906be7336f4b8e4780">etValueChanged</a> && a == FileEvent && FileEvent.Value() )</div> |
| 104 | +<div class="line"> {</div> |
| 105 | +<div class="line"> <span class="keywordflow">if</span> ( FileEvent->m_eType == FileEventNotifier::typePostRead && FileEvent->m_sFileName.right( 4 ) == <a name="a4"></a><a class="code" href="./i18n_8h.html#a1b7f65502ea5b58cca15f85d9e78ca06">NTRQ</a>( <span class="stringliteral">".mud"</span> ) )</div> |
| 106 | +<div class="line"> {</div> |
| 107 | +<div class="line"> <span class="comment">// We could go ahead here and do the extraction, but instead we are going to</span></div> |
| 108 | +<div class="line"> <span class="comment">// request a "deferred" event, just in case Mudbox is still in the middle of</span></div> |
| 109 | +<div class="line"> <span class="comment">// setting up the new scene. When you do this, the same event is sent back</span></div> |
| 110 | +<div class="line"> <span class="comment">// when Mudbox is idle, with "t" set to "etDeferred". This allows you to </span></div> |
| 111 | +<div class="line"> <span class="comment">// process the event when everything has settled down.</span></div> |
| 112 | +<div class="line"> <span class="comment">//</span></div> |
| 113 | +<div class="line"> RequestDeferredEvent( FileEvent );</div> |
| 114 | +<div class="line"> };</div> |
| 115 | +<div class="line"> };</div> |
| 116 | +<div class="line"></div> |
| 117 | +<div class="line"> <span class="comment">// If we have received the deferred event, it is time to extract the maps.</span></div> |
| 118 | +<div class="line"> <span class="keywordflow">if</span> ( t == <a name="a5"></a><a class="code" href="./namespacemudbox.html#a8d88d2a841f889dace76ffcd8d6b06daae018520c41749d40418c6d9dcd72fde9">etDeferred</a> && a == FileEvent )</div> |
| 119 | +<div class="line"> {</div> |
| 120 | +<div class="line"> <span class="keywordtype">bool</span> bHadExtraction = <span class="keyword">false</span>;</div> |
| 121 | +<div class="line"></div> |
| 122 | +<div class="line"> <span class="comment">// Look at all the nodes in the mudbox scene, and find the map extraction nodes.</span></div> |
| 123 | +<div class="line"> <span class="comment">// (An "operation" in the UI is stored as a Node in the scene.)</span></div> |
| 124 | +<div class="line"> <span class="keywordflow">for</span> ( Node *pNode = Node::First(); pNode; pNode = pNode->Next() )</div> |
| 125 | +<div class="line"> {</div> |
| 126 | +<div class="line"> <span class="keywordflow">if</span> ( pNode->IsKindOf( MapExtractor::StaticClass() ) )</div> |
| 127 | +<div class="line"> {</div> |
| 128 | +<div class="line"> MapExtractor *pE = <span class="keyword">dynamic_cast<</span>MapExtractor *<span class="keyword">></span>( pNode );</div> |
| 129 | +<div class="line"> <a name="a6"></a><a class="code" href="./mudbox_8h.html#a99d9d5b4fd434c7a38c2add8217e4c14">MB_SAFELY</a>( pE )</div> |
| 130 | +<div class="line"> {</div> |
| 131 | +<div class="line"> <span class="comment">// Look for the string "autoextract" in the node's name, and disregard</span></div> |
| 132 | +<div class="line"> <span class="comment">// any nodes that do not contain it.</span></div> |
| 133 | +<div class="line"> <a name="_a7"></a><a class="code" href="./class_q_string.html">QString</a> sName = pE->Name();</div> |
| 134 | +<div class="line"> <span class="keywordflow">if</span> ( sName.<a name="a8"></a><a class="code" href="./class_q_string.html#aaa6704aa527a375c50ac92dbb25b3a5a">indexOf</a>( <span class="stringliteral">"autoextract"</span> ) != -1 )</div> |
| 135 | +<div class="line"> {</div> |
| 136 | +<div class="line"> <span class="comment">// Execute the map extraction in silent mode, which means the UI will not be visible (but the progress bar will)</span></div> |
| 137 | +<div class="line"> <span class="comment">// and there will be no confirmation dialog boxes that could stop it from running.</span></div> |
| 138 | +<div class="line"> pE->Execute( <span class="keyword">false</span> );</div> |
| 139 | +<div class="line"></div> |
| 140 | +<div class="line"> bHadExtraction = <span class="keyword">true</span>;</div> |
| 141 | +<div class="line"> };</div> |
| 142 | +<div class="line"> };</div> |
| 143 | +<div class="line"> };</div> |
| 144 | +<div class="line"> };</div> |
| 145 | +<div class="line"></div> |
| 146 | +<div class="line"> <span class="comment">// If any extractions were done, quit mudbox.</span></div> |
| 147 | +<div class="line"> <span class="keywordflow">if</span> ( bHadExtraction )</div> |
| 148 | +<div class="line"> <a name="a9"></a><a class="code" href="./class_q_core_application.html#aaa27c80c06b25695d1038ef540fea485">QCoreApplication::exit</a>();</div> |
| 149 | +<div class="line"> };</div> |
| 150 | +<div class="line">};</div> |
| 151 | +</div><!-- fragment --> </div><!-- contents --> |
| 152 | +</div><!-- doc-content --> |
| 153 | +<div class="footer-block"><a class="comments-anchor" href="../html/ac.cmtdialog.htm" target="_blank"><span class="comments-link">Please send us your comment about this page</span></a></div></div> |
| 154 | +</div></body> |
| 155 | +</html> |
0 commit comments