Hi Raj,<div><br></div><div>why don't you get the LUT the first time and then just change the values on it.</div><div><br></div><div><span class="Apple-style-span" style="font-size: medium; "> Lut.setRGBPoints(rgbPoints) ?</span></div>
<div><br></div><div>Seb<br><br><div class="gmail_quote">On Thu, May 19, 2011 at 2:20 PM, Rajvikram Singh <span dir="ltr"><<a href="mailto:rajvikrams@yahoo.com">rajvikrams@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font:inherit">Hi Sebastien<br><br>Here are the two javascript functions used for setting up the volume visualization. The second one (loadXMLColorMap()) is where Jquery is used to read the colormaps from the XML file. The variables Lut, Sof and CurrColormapFile are global. CurrColormapFile is the XML file chosen by the user from the UI :<br>
<br> // **********************************************************************************************<br> // set displayProperties for a particular data to show as volume <br> // **********************************************************************************************<br>
this.setupVolumeView = function (_data, _view) {<br><br>
// load and setup the LUT and SOF before changing representation<br> this.loadXMLColorMap("./colormaps/" + CurrColormapFile);<br><br> pv.SetDisplayProperties( {<br> proxy : _data,<br>
view : _view,<br> SelectMapper : 'GPU',<br> Representation : 'Volume',<br> LookupTable : Lut,<br> ColorArrayName : 'ImageFile',<br> ScalarOpacityFunction : Sof<br>
} );<br><br> }
// end of setDisplayToVolume()<br><br><br> // **********************************************************************************************<br> // Load a Paraview color map from an XML file<br> // **********************************************************************************************<br>
this.loadXMLColorMap = function(_file) {<br><br> var colorSpace = 'None';<br> var nanField;<br> var rgbPointsIdx = 0;<br> var sofPointsIdx = 0;<br> var i, x, o, r, g, b;<br>
<br> var nanColor = new Array();<br> var rgbPoints = new Array();<br> var sofPoints = new Array();<br><br> jQuery.ajax({<br> url : _file,<br> success : function(data) {<br>
// get the color space<br> colorSpace = jQuery(data).find("ColorMap").attr("space");<br><br> // get the values to create LUT and
SOF <br> jQuery(data).find("Point").each(function() {<br> i = jQuery(this);<br> x = parseFloat(i.attr("x"));<br> o = parseFloat(i.attr("o"));<br>
r = parseFloat(i.attr("r"));<br> g = parseFloat(i.attr("g"));<br>
b = parseFloat(i.attr("b"));<br> <br> // Populate the rgbPoints array<br> rgbPoints[rgbPointsIdx++] = x;<br> rgbPoints[rgbPointsIdx++] = r;<br>
rgbPoints[rgbPointsIdx++] = g;<br> rgbPoints[rgbPointsIdx++] = b;<br><br> //Populate the
sof Points array<br> sofPoints[sofPointsIdx++] = x;<br> sofPoints[sofPointsIdx++] = o;<br><br> });<br><br> nanField = jQuery(data).find("NaN");<br>
nanColor[0] = parseFloat(nanField.attr("r"));<br> nanColor[1] = parseFloat(nanField.attr("g"));<br> nanColor[2] =
parseFloat(nanField.attr("b"));<br> },<br> <br> async : false<br> });<br><br> <br> <br> // Create the LUT and SOF needed for the transfer function<div class="im">
<br> Lut = pv.GetLookupTableForArray({arrayname : "ImageFile", num_components : 1, HSVWrap : 0, NanColor : nanColor, RGBPoints : rgbPoints, ColorSpace : colorSpace});<br><br> Sof = pv.CreatePiecewiseFunction( {Points:
sofPoints}); <br><br></div> } // End of loadXMLColorMap()<br><br><br><br>Thanks again.<br>- Raj<br><br><br>--- On <b>Thu, 19/5/11, Sebastien Jourdain <i><<a href="mailto:sebastien.jourdain@kitware.com" target="_blank">sebastien.jourdain@kitware.com</a>></i></b> wrote:<br>
<blockquote style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;padding-left:5px"><br>From: Sebastien Jourdain <<a href="mailto:sebastien.jourdain@kitware.com" target="_blank">sebastien.jourdain@kitware.com</a>><div class="im">
<br>Subject: Re: [Paraview] ParaviewWeb : Repeated calls to GetLookupTableForArray do not change the RGBpoints array<br>To: "Rajvikram Singh" <<a href="mailto:rajvikrams@yahoo.com" target="_blank">rajvikrams@yahoo.com</a>><br>
</div>Cc: "Utkarsh Ayachit" <<a href="mailto:utkarsh.ayachit@kitware.com" target="_blank">utkarsh.ayachit@kitware.com</a>>, <a href="mailto:paraview@paraview.org" target="_blank">paraview@paraview.org</a><br>
Date: Thursday, 19 May, 2011, 10:37 PM<div><div></div><div class="h5"><br><br><div>Hi Raj,<div><br></div><div>could you send the piece of code that update those RGBPoints values
? </div><div><br></div><div>Thanks,</div><div><br></div><div>Seb<br><br><div>On Thu, May 19, 2011 at 12:58 PM, Rajvikram Singh <span dir="ltr"><<a rel="nofollow" href="http://mc/compose?to=rajvikrams@yahoo.com" target="_blank">rajvikrams@yahoo.com</a>></span> wrote:<br>
<blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font:inherit" valign="top"><font size="2">Hi Utkarsh</font><div>
<font size="2"> I'm using Jquery to load the .XML files. It works without any problems the first time and RGBPoints extracted from the XML are applied correctly. </font></div><div><font size="2"><br></font></div><div>
<font size="2">The problem arises when the users selects a different XML file (different colormap). When the GetLookupTableForArray is called again with the new set of RGBPoints, the visualization does not look correct. It looks like the the lookuptable maintained the earlier RGBPoints and merged the new set with the old. </font></div>
<div><font size="2"><br></font></div><div><font size="2">I was wondering if this was a bug or if their
was a way to reset the lut to forget the old RGBPoints</font></div><div><font size="2"><br></font></div><div><font size="2">Thanks</font></div><div><font size="2">Raj</font></div><div style="font-size:10pt"><span style="font-size:medium"><br>
</span></div><div style="font-size:10pt"><br>--- On <b>Thu, 19/5/11, Utkarsh Ayachit <i><<a rel="nofollow" href="http://mc/compose?to=utkarsh.ayachit@kitware.com" target="_blank">utkarsh.ayachit@kitware.com</a>></i></b> wrote:<br>
<blockquote style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;padding-left:5px">
<br>From: Utkarsh Ayachit <<a rel="nofollow" href="http://mc/compose?to=utkarsh.ayachit@kitware.com" target="_blank">utkarsh.ayachit@kitware.com</a>><br>Subject: Re: [Paraview] ParaviewWeb : Repeated calls to GetLookupTableForArray do not change the RGBpoints array<br>
To: "Rajvikram Singh" <<a rel="nofollow" href="http://mc/compose?to=rajvikrams@yahoo.com" target="_blank">rajvikrams@yahoo.com</a>><br>Cc: <a rel="nofollow" href="http://mc/compose?to=paraview@paraview.org" target="_blank">paraview@paraview.org</a><br>
Date: Thursday, 19 May, 2011, 6:49 PM<div>
<div></div><div><br><br><div>How are you loading
the default.xml? Do the best of my knowledge, ParaView Python API has no call to setup LUTs from XML.<div><br></div><div>Utkarsh<br><br><div>On Wed, May 18, 2011 at 8:45 PM, Rajvikram Singh <span dir="ltr"><<a rel="nofollow" href="http://mc/compose?to=rajvikrams@yahoo.com" target="_blank">rajvikrams@yahoo.com</a>></span> wrote:<br>
<blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font:inherit" valign="top">Hi<br> I've a case where the users can load .xml files saved from the Paraview's 'Edit Color Map' widget and apply the color maps (containing R,G,B and Opacity values) to volume rendering.<br>
<br>When I start the application a call is made is load a "default.xml" file and then do a :<br><br>Lut = pv.GetLookupTableForArray({arrayname : "ImageFile", num_components : 1, HSVWrap : 0, NanColor : nanColor, RGBPoints : rgbPoints, ColorSpace : colorSpace});<br>
<br>Sof = pv.CreatePiecewiseFunction( {Points: sofPoints}); <br><br>The variables nanColor, rgbPoints, sofPoints etc are populated by the XML file data. Then the Lookuptable is applied to the DisplayProperties for volume rendering. This part works well. <br>
<br>However when the user changes the .xml color map file from a drop down, the same code is called again and this time it does
something funny. It seems to retain the previous RGBPoints information and adds the new color map to it. So the two lookup tables look like they are merged. Is this expected ?<br><br>Is there a way to reset the lookup table ? I did not see any obvious call within simple.py or pwsimple.py.<br>
<br>Thanks<br>Raj<br></td></tr></tbody></table><br>_______________________________________________<br>
Powered by <a rel="nofollow" href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a rel="nofollow" href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a rel="nofollow" href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a rel="nofollow" href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
<br></blockquote></div><br></div>
</div></div></div></blockquote></div></td></tr></tbody></table><br>_______________________________________________<br>
Powered by <a rel="nofollow" href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a rel="nofollow" href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a rel="nofollow" href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a rel="nofollow" href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
<br></blockquote></div><br></div>
</div></div></div></blockquote></td></tr></tbody></table></blockquote></div><br></div>