Hi Sebastien

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 :

        // 
**********************************************************************************************
        // set displayProperties for a particular data to show as volume 
        // 
**********************************************************************************************
        this.setupVolumeView = function (_data, _view) {

            // load and setup the LUT and SOF before changing representation
            this.loadXMLColorMap("./colormaps/" + CurrColormapFile);

            pv.SetDisplayProperties( {
            proxy : _data,
            view  : _view,
            SelectMapper : 'GPU',
            Representation : 'Volume',
            LookupTable : Lut,
            ColorArrayName : 'ImageFile',
            ScalarOpacityFunction : Sof
            } );

        } // end of setDisplayToVolume()


        // 
**********************************************************************************************
        // Load a Paraview color map from an XML file
        // 
**********************************************************************************************
        this.loadXMLColorMap = function(_file) {

            var colorSpace = 'None';
            var nanField;
            var rgbPointsIdx = 0;
            var sofPointsIdx = 0;
            var i, x, o, r, g, b;
            
            var nanColor = new Array();
            var rgbPoints = new Array();
            var sofPoints = new Array();

            jQuery.ajax({
                url : _file,
                success : function(data) {
                    // get the color space
                    colorSpace = jQuery(data).find("ColorMap").attr("space");

                    // get the values to create LUT and SOF    
                    jQuery(data).find("Point").each(function() {
                        i = jQuery(this);
                        x = parseFloat(i.attr("x"));
                        o = parseFloat(i.attr("o"));
                        r = parseFloat(i.attr("r"));
                        g = parseFloat(i.attr("g"));
                        b = parseFloat(i.attr("b"));
    
                        // Populate the rgbPoints array
                        rgbPoints[rgbPointsIdx++] = x;
                        rgbPoints[rgbPointsIdx++] = r;
                        rgbPoints[rgbPointsIdx++] = g;
                        rgbPoints[rgbPointsIdx++] = b;

                        //Populate the sof Points array
                        sofPoints[sofPointsIdx++] = x;
                        sofPoints[sofPointsIdx++] = o;

                    });

                    nanField = jQuery(data).find("NaN");
                    nanColor[0] = parseFloat(nanField.attr("r"));
                    nanColor[1] = parseFloat(nanField.attr("g"));
                    nanColor[2] = parseFloat(nanField.attr("b"));
                    },
                
                async : false
            });

                
            
            // Create the LUT and SOF needed for the transfer function
            Lut = pv.GetLookupTableForArray({arrayname : "ImageFile", 
num_components : 1, HSVWrap : 0, NanColor : nanColor, RGBPoints : rgbPoints, 
ColorSpace : colorSpace});

            Sof = pv.CreatePiecewiseFunction( {Points: sofPoints});            

        } // End of loadXMLColorMap()



Thanks again.
- Raj


--- On Thu, 19/5/11, Sebastien Jourdain <sebastien.jourd...@kitware.com> wrote:

From: Sebastien Jourdain <sebastien.jourd...@kitware.com>
Subject: Re: [Paraview] ParaviewWeb : Repeated calls to GetLookupTableForArray 
do not change the RGBpoints array
To: "Rajvikram Singh" <rajvikr...@yahoo.com>
Cc: "Utkarsh Ayachit" <utkarsh.ayac...@kitware.com>, paraview@paraview.org
Date: Thursday, 19 May, 2011, 10:37 PM

Hi Raj,
could you send the piece of code that update those RGBPoints values ? 
Thanks,
Seb

On Thu, May 19, 2011 at 12:58 PM, Rajvikram Singh <rajvikr...@yahoo.com> wrote:

Hi Utkarsh
    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. 

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. 

I was wondering if this was a bug or if their
 was a way to reset the lut to forget the old RGBPoints
ThanksRaj


--- On Thu, 19/5/11, Utkarsh Ayachit <utkarsh.ayac...@kitware.com> wrote:


From: Utkarsh Ayachit <utkarsh.ayac...@kitware.com>
Subject: Re: [Paraview] ParaviewWeb : Repeated calls to GetLookupTableForArray 
do not change the RGBpoints array

To: "Rajvikram Singh" <rajvikr...@yahoo.com>
Cc: paraview@paraview.org
Date: Thursday, 19 May, 2011, 6:49 PM


How are you loading
 the default.xml? Do the best of my knowledge, ParaView Python API has no call 
to setup LUTs from XML.
Utkarsh

On Wed, May 18, 2011 at 8:45 PM, Rajvikram Singh <rajvikr...@yahoo.com> wrote:


Hi
   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.



When I start the application a call is made is load a "default.xml" file and 
then do a :

Lut = pv.GetLookupTableForArray({arrayname : "ImageFile", num_components : 1, 
HSVWrap : 0, NanColor : nanColor, RGBPoints : rgbPoints, ColorSpace : 
colorSpace});



Sof = pv.CreatePiecewiseFunction( {Points: sofPoints});    

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. 



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 ?

Is there a way to reset the lookup table ? I did not see any obvious call 
within simple.py or pwsimple.py.



Thanks
Raj

_______________________________________________

Powered by www.kitware.com



Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html



Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView



Follow this link to subscribe/unsubscribe:

http://www.paraview.org/mailman/listinfo/paraview





_______________________________________________

Powered by www.kitware.com



Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html



Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView



Follow this link to subscribe/unsubscribe:

http://www.paraview.org/mailman/listinfo/paraview




_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview

Reply via email to