Plugins/PointSprite/ParaViewPlugin/Qvis/ColorTableAttributes.cpp
void
ColorTableAttributes::AddColorTable(const vtkstd::string &name,
    const ColorControlPointList &cpts)
{
    // Remove the color table if it already exists in the list.
    int index = GetColorTableIndex(name);
    if(index != -1)
        RemoveColorTable(index);

    // Append the color table to the list.
    names.push_back(name);
    AddColorTables(cpts);

    // Store the name, colortable pairs into a map.
    vtkstd::map<vtkstd::string, AttributeGroup *> sortMap;
    unsigned int i;
    for(i = 0; i < names.size(); ++i)
        sortMap[names[i]] = colorTables[i];

    // Traverse the map, it will be sorted. Store the names and color table
    // pointer back into the old vectors.
    vtkstd::map<vtkstd::string, AttributeGroup *>::iterator pos;
    for(i = 0, pos = sortMap.begin(); pos != sortMap.end(); ++pos, ++i)
    {
        names[i] = pos->first;
        colorTables[i] = pos->second;
    }

    Select(0, (void *)&names);
}
// ****************************************************************************
// Method: ColorTableAttributes::AddColorTable
//
// Purpose: 
//   Adds a new color table to the list.
//
// Arguments:
//   name : The name of the new color table.
//   cpts : The color control points for the new color table.
//
// Programmer: Brad Whitlock
// Creation:   Sat Jun 16 20:35:43 PST 2001
//
// Modifications:
//   Brad Whitlock, Mon Nov 25 12:00:52 PDT 2002
//   I added code to sort the color table using a map.
//
//   Brad Whitlock, Mon Mar 13 17:14:55 PST 2006
//   Make sure that a pre-existing color table with the same name is removed
//   before adding the new color table.
//
// ****************************************************************************
:AddColorTable
Purpose:
Adds a new color table to the list.

name : The name of the new color table.
cpts : The color control points for the new color table.

Brad Whitlock
Creation:   Sat Jun 16 20:35:43 PST 2001

Brad Whitlock, Mon Nov 25 12:00:52 PDT 2002
I added code to sort the color table using a map.

Brad Whitlock, Mon Mar 13 17:14:55 PST 2006
Make sure that a pre-existing color table with the same name is removed
before adding the new color table.
: AddColorTable Purpose : Adds a new color table to the list . name : The name of the new color table . cpts : The color control points for the new color table . Brad Whitlock Creation : Sat Jun 16 20 : 35 : 43 PST 2001 Brad Whitlock Mon Nov 25 12 : 00 : 52 PDT 2002 I added code to sort the color table using a map . Brad Whitlock Mon Mar 13 17 : 14 : 55 PST 2006 Make sure that a pre - existing color table with the same name is removed before adding the new color table .
void
ColorTableAttributes::AddColorTable(const vtkstd::string &name,
    const ColorControlPointList &cpts)
{
    int index = GetColorTableIndex(name);
    if(index != -1)
        RemoveColorTable(index);
    names.push_back(name);
    AddColorTables(cpts);
    vtkstd::map<vtkstd::string, AttributeGroup *> sortMap;
    unsigned int i;
    for(i = 0; i < names.size(); ++i)
        sortMap[names[i]] = colorTables[i];
    vtkstd::map<vtkstd::string, AttributeGroup *>::iterator pos;
    for(i = 0, pos = sortMap.begin(); pos != sortMap.end(); ++pos, ++i)
    {
        names[i] = pos->first;
        colorTables[i] = pos->second;
    }
    Select(0, (void *)&names);
}
void ColorTableAttributes :: AddColorTable ( const vtkstd :: string & name , const ColorControlPointList & cpts ) { int index = GetColorTableIndex ( name ) ; if ( index != -1 ) RemoveColorTable ( index ) ; names . push_back ( name ) ; AddColorTables ( cpts ) ; vtkstd :: map < vtkstd :: string , AttributeGroup * > sortMap ; unsigned int i ; for ( i = 0 ; i < names . size ( ) ; ++ i ) sortMap [ names [ i ] ] = colorTables [ i ] ; vtkstd :: map < vtkstd :: string , AttributeGroup * > :: iterator pos ; for ( i = 0 , pos = sortMap . begin ( ) ; pos != sortMap . end ( ) ; ++ pos , ++ i ) { names [ i ] = pos -> first ; colorTables [ i ] = pos -> second ; } Select ( 0 , ( void * ) & names ) ; }
Method: ColorTableAttributes::AddColorTable
Purpose:
Adds a new color table to the list.
Method : ColorTableAttributes :: AddColorTable Purpose : Adds a new color table to the list .
// Remove the color table if it already exists in the list. // Append the color table to the list. // Store the name, colortable pairs into a map. // Traverse the map, it will be sorted. Store the names and color table // pointer back into the old vectors.