コード例 #1
0
void
avtParallelCoordinatesPlot::SetColors()
{
    int redID, red, green, blue;
    ColorAttribute colorAtt;
    ColorAttributeList colorAttList;

    if (true) // TODO: !atts.GetDoTime()
    {
        int numColorEntries = 4 * 2 * PCP_CTX_BRIGHTNESS_LEVELS;
        unsigned char *plotColors = new unsigned char[numColorEntries];

        for (redID = 0; redID < numColorEntries; redID += 4)
        {
            float scale;
            if (redID < numColorEntries/2)
                scale = ((redID)/4.)/float(PCP_CTX_BRIGHTNESS_LEVELS);
            else
                scale = ((redID-numColorEntries/2)/4.)/float(PCP_CTX_BRIGHTNESS_LEVELS);
            int bgred   = int(bgColor[0]*255);
            int bggreen = int(bgColor[1]*255);
            int bgblue  = int(bgColor[2]*255);
            int hired, higreen, hiblue;
            if (redID < numColorEntries/2)
            {
                hired   = atts.GetContextColor().Red();
                higreen = atts.GetContextColor().Green();
                hiblue  = atts.GetContextColor().Blue();
            }
            else
            {
                hired   = atts.GetLinesColor().Red();
                higreen = atts.GetLinesColor().Green();
                hiblue  = atts.GetLinesColor().Blue();
            }
            red   = int(scale*hired   + (1.-scale)*bgred);
            green = int(scale*higreen + (1.-scale)*bggreen);
            blue  = int(scale*hiblue  + (1.-scale)*bgblue);

            colorAtt.SetRgba(red, green, blue, 255);
            colorAttList.AddColors(colorAtt);

            plotColors[redID  ] = (unsigned char)red;
            plotColors[redID+1] = (unsigned char)green;
            plotColors[redID+2] = (unsigned char)blue;
            plotColors[redID+3] = 255;
        }

        avtLUT->SetLUTColorsWithOpacity(plotColors, 2*PCP_CTX_BRIGHTNESS_LEVELS);
        levelsMapper->SetColors(colorAttList, needsRecalculation);
        delete [] plotColors;
    }
    else
    {
        // Not implemented.....
    }
}
コード例 #2
0
void
avtWellBorePlot::SetColors()
{
    if (atts.GetColorType() == WellBoreAttributes::ColorBySingleColor)
    {
        const ColorAttribute ca = atts.GetSingleColor();
        ColorAttributeList cal;
        cal.AddColors(atts.GetSingleColor());
        avtLUT->SetLUTColorsWithOpacity(ca.GetColor(), 1);
        levelsMapper->SetColors(cal);
    }
    else if (atts.GetColorType() == WellBoreAttributes::ColorByMultipleColors)
    {
        const ColorAttributeList &cal = atts.GetMultiColor();
        unsigned char *colors = new unsigned char[atts.GetNWellBores() * 4];
        unsigned char *cptr = colors;
        for(int i = 0; i < atts.GetNWellBores(); i++)
        {
            *cptr++ = (char)cal[i].Red();
            *cptr++ = (char)cal[i].Green();
            *cptr++ = (char)cal[i].Blue();
            *cptr++ = (char)cal[i].Alpha();
        }

        avtLUT->SetLUTColorsWithOpacity(colors, atts.GetNWellBores());
        levelsMapper->SetColors(cal);

        delete [] colors;
    }
    else // ColorByColorTable
    {
        ColorAttributeList cal(atts.GetMultiColor());
        unsigned char *colors = new unsigned char[atts.GetNWellBores() * 4];
        unsigned char *cptr = colors;
        avtColorTables *ct = avtColorTables::Instance();
        const int opacity = 255;

        //
        // Detect if we're using the default color table or a color table
        // that does not exist anymore.
        //
        std::string ctName(atts.GetColorTableName());
        if(ctName == "Default")
            ctName = std::string(ct->GetDefaultDiscreteColorTable());
        else if(!ct->ColorTableExists(ctName.c_str()))
        {
            delete [] colors;
            EXCEPTION1(InvalidColortableException, ctName);
        }

        bool invert = atts.GetInvertColorTable();

        //
        // Add a color for each subset name.
        //
        if(ct->IsDiscrete(ctName.c_str()))
        {
            // The CT is discrete, get its color color control points.
            for(int i = 0; i < atts.GetNWellBores(); ++i)
            {
                unsigned char rgb[3] = {0,0,0};
                ct->GetControlPointColor(ctName.c_str(), i, rgb, invert);
                *cptr++ = rgb[0];
                *cptr++ = rgb[1];
                *cptr++ = rgb[2];
                *cptr++ = opacity;

                cal[i].SetRgba(rgb[0], rgb[1], rgb[2], opacity);
            }
        }
        else
        {
            // The CT is continuous, sample the CT so we have a unique color
            // for each element.
            unsigned char *rgb = ct->GetSampledColors(ctName.c_str(),
                                                      atts.GetNWellBores(),
                                                      invert);
            if(rgb)
            {
                for(int i = 0; i < atts.GetNWellBores(); ++i)
                {
                     int j = i * 3;
                     *cptr++ = rgb[j];
                     *cptr++ = rgb[j+1];
                     *cptr++ = rgb[j+2];
                     *cptr++ = opacity;

                     cal[i].SetRgba(rgb[j], rgb[j+1], rgb[j+2], opacity);
                }
                delete [] rgb;
            }
        }

        avtLUT->SetLUTColorsWithOpacity(colors, atts.GetNWellBores());
        levelsMapper->SetColors(cal);

        delete [] colors;
    }
}
コード例 #3
0
void 
avtSubsetPlot::SetColors()
{
    vector < string > allLabels = atts.GetSubsetNames();
    vector < string > labels; 
    LevelColorMap levelColorMap;

    behavior->GetInfo().GetAttributes().GetLabels(labels);
   
    if (labels.size() == 0)
    {
        levelsLegend->SetColorBarVisibility(0);
        levelsLegend->SetMessage("No subsets present");
    }  
    else 
    {
        levelsLegend->SetColorBarVisibility(1);
        levelsLegend->SetMessage(NULL);
    }  

    if (atts.GetColorType() == SubsetAttributes::ColorBySingleColor)
    {
        ColorAttribute ca(atts.GetSingleColor());
        ca.SetAlpha((unsigned char)(float(ca.Alpha()) * atts.GetOpacity()));
        ColorAttributeList cal;
        cal.AddColors(ca);

        avtLUT->SetLUTColorsWithOpacity(ca.GetColor(), 1);
        levelsMapper->SetColors(cal);

        // 
        //  Send an empty color map, rather than one where all
        //  entries map to same value. 
        //
        levelsLegend->SetLabelColorMap(levelColorMap);
        levelsLegend->SetLevels(labels);

        return;
    }
    else if (atts.GetColorType() == SubsetAttributes::ColorByMultipleColors)
    {
        ColorAttributeList cal(atts.GetMultiColor());
        int numColors = cal.GetNumColors();

        //
        //  Create colors from original color table. 
        //
        unsigned char *colors = new unsigned char[numColors * 4];
        unsigned char *cptr = colors;
        for(int i = 0; i < numColors; i++)
        {
            unsigned char c = (unsigned char)(cal[i].Alpha() * atts.GetOpacity());
            cal[i].SetAlpha(c);
            *cptr++ = (unsigned char)cal[i].Red();
            *cptr++ = (unsigned char)cal[i].Green();
            *cptr++ = (unsigned char)cal[i].Blue();
            *cptr++ = (unsigned char)cal[i].Alpha();

            //
            //  Create a label-to-color-index mapping 
            //
            levelColorMap.insert(LevelColorMap::value_type(allLabels[i], i));
        }

        avtLUT->SetLUTColorsWithOpacity(colors, numColors);
        levelsMapper->SetColors(cal);
        levelsLegend->SetLevels(labels);

        levelsMapper->SetLabelColorMap(levelColorMap);
        levelsLegend->SetLabelColorMap(levelColorMap);

        delete [] colors;
    }
    else // ColorByColorTable
    {
        ColorAttributeList cal(atts.GetMultiColor());
        int numColors = cal.GetNumColors();
        unsigned char *colors = new unsigned char[numColors * 4];
        unsigned char *cptr = colors;
        avtColorTables *ct = avtColorTables::Instance();
        int opacity = int((float)atts.GetOpacity()*255.f);

        //
        // Detect if we're using the default color table or a color table
        // that does not exist anymore.
        //
        string ctName(atts.GetColorTableName());
        if(ctName == "Default")
            ctName = string(ct->GetDefaultDiscreteColorTable());
        else if(!ct->ColorTableExists(ctName.c_str()))
        {
            delete [] colors;
            EXCEPTION1(InvalidColortableException, ctName);
        }

        //
        //  Create a label-to-color-index mapping 
        //
        for(int i = 0; i < numColors; ++i)
            levelColorMap.insert(LevelColorMap::value_type(allLabels[i], i));

        bool invert = atts.GetInvertColorTable();
        // 
        // Add a color for each subset name.
        //
        if(ct->IsDiscrete(ctName.c_str()))
        {
            // The CT is discrete, get its color color control points.
            for(int i = 0; i < numColors; ++i)
            {
                unsigned char rgb[3] = {0,0,0};
                ct->GetControlPointColor(ctName.c_str(), i, rgb, invert);
                *cptr++ = rgb[0];
                *cptr++ = rgb[1];
                *cptr++ = rgb[2];
                *cptr++ = opacity;

                cal[i].SetRgba(rgb[0], rgb[1], rgb[2], opacity);
            }
        }
        else
        {
            // The CT is continuous, sample the CT so we have a unique color
            // for each element.
            unsigned char *rgb = ct->GetSampledColors(ctName.c_str(), numColors, invert);
            if(rgb)
            {
                for(int i = 0; i < numColors; ++i)
                {
                     int j = i * 3;
                     *cptr++ = rgb[j];
                     *cptr++ = rgb[j+1];
                     *cptr++ = rgb[j+2];
                     *cptr++ = opacity;

                     cal[i].SetRgba(rgb[j], rgb[j+1], rgb[j+2], opacity);
                }
                delete [] rgb;
            }
        }

        avtLUT->SetLUTColorsWithOpacity(colors, numColors);
        levelsMapper->SetColors(cal);
        levelsLegend->SetLevels(labels);

        levelsMapper->SetLabelColorMap(levelColorMap);
        levelsLegend->SetLabelColorMap(levelColorMap);

        delete [] colors;
    }
}
コード例 #4
0
void
SubsetViewerPluginInfo::PrivateSetPlotAtts(AttributeSubject *atts, 
    const ViewerPlot *plot)
{
    SubsetAttributes *subsetAtts = (SubsetAttributes *)atts;

    //
    // Get the meta-data and initialize the subset names and colors in the
    // new SubsetAttributes object.
    //
    const avtDatabaseMetaData *md = plot->GetMetaData();
    if (md == NULL)
    {
        return;
    }

    avtDatabaseMetaData *nonConstmd = const_cast <avtDatabaseMetaData *>(md);

    std::string vn(plot->GetVariableName());

    const avtMaterialMetaData *mat = NULL;
    const avtScalarMetaData *smd = NULL;

    std::string meshName = nonConstmd->MeshForVar(vn);
    avtMeshMetaData *mesh = 
        const_cast <avtMeshMetaData *> (md->GetMesh(meshName));


    stringVector       sv;
    stringVector::const_iterator pos;
    std::set<int> groupSet;
    std::vector<int> gIDS;
    char temp[512];

    // 
    // Create subset names, based on Subset Type 
    // 
    avtSubsetType subT = nonConstmd->DetermineSubsetType(vn);
    switch (subT)
    {
      case AVT_DOMAIN_SUBSET : 
          debug5 << "Variable for subset plot is a domain Mesh." << endl; 
          subsetAtts->SetSubsetType(SubsetAttributes::Domain);
          defaultAtts->SetSubsetType(SubsetAttributes::Domain);
          if (mesh->blockNames.empty())
          {
              for (int i = 0; i < mesh->numBlocks; i++)
              { 
                  sprintf(temp, "%d", i+mesh->blockOrigin);
                  sv.push_back(temp);
              }
          }
          else
          {
              for(pos = mesh->blockNames.begin();
                  pos != mesh->blockNames.end(); ++pos)
              {
                  sv.push_back(*pos);
              }
          }
          break;

      case AVT_GROUP_SUBSET :
          debug5 << "Variable for subset plot is a group Mesh." << endl; 
          subsetAtts->SetSubsetType(SubsetAttributes::Group);
          defaultAtts->SetSubsetType(SubsetAttributes::Group);
          if (!mesh->groupNames.empty())
          {
              for (size_t i = 0; i < mesh->groupNames.size(); ++i)
              {
                  sv.push_back(mesh->groupNames[i]);
              }
          }
          else if (mesh->groupIds.size() > 0)
          {
              for (size_t i = 0; i < mesh->groupIds.size(); i++)
              {
                  if (groupSet.count(mesh->groupIds[i]) == 0)
                  {
                      groupSet.insert(mesh->groupIds[i]);
                      gIDS.push_back(mesh->groupIds[i]);
                  }
              }
              for (size_t i = 0; i < gIDS.size(); i++)
              {
                  sprintf(temp, "%d", gIDS[i]);
                  sv.push_back(temp);
              }
          }
          else
          {
              int origin = mesh->groupOrigin;
              int nGroups = (int)mesh->groupIdsBasedOnRange.size()-1;
              for (int i = 0; i < nGroups; i++)
              {
                  groupSet.insert(origin+i);
                  gIDS.push_back(origin+i);
                  sprintf(temp, "%d", origin+i);
                  sv.push_back(temp);
              }
          }
          break;

      case AVT_MATERIAL_SUBSET :
          debug5 << "Variable for subset plot is a Material." << endl; 
          subsetAtts->SetSubsetType(SubsetAttributes::Material);
          defaultAtts->SetSubsetType(SubsetAttributes::Material);
          mat = md->GetMaterial(vn);
          if (mat != NULL)
          {
              for(pos = mat->materialNames.begin();
                  pos != mat->materialNames.end(); ++pos)
              {
                  sv.push_back(*pos);
              }
          }
          break;

      case AVT_ENUMSCALAR_SUBSET :
          debug5 << "Variable for subset plot is an enumerated Scalar."<<endl; 
          subsetAtts->SetSubsetType(SubsetAttributes::EnumScalar);
          defaultAtts->SetSubsetType(SubsetAttributes::EnumScalar);
          smd = md->GetScalar(vn);
          if (smd != NULL)
          {
              for(pos = smd->enumNames.begin();
                  pos != smd->enumNames.end(); ++pos)
              {
                  sv.push_back(*pos);
              }
          }
          break;

      default:
          if (vn == meshName)
          {
              debug5 << "Variable for subset plot is a mesh."<<endl; 
              subsetAtts->SetSubsetType(SubsetAttributes::Mesh);
              defaultAtts->SetSubsetType(SubsetAttributes::Mesh);
              sprintf(temp, "Whole mesh (%s)", vn.c_str());
              sv.push_back(temp);
          }
          else
          {
              EXCEPTION1(InvalidVariableException, vn);
          }
          break;
    }
    
    // 
    // Add a color for each subset name.
    //
    ColorAttribute *ca = new ColorAttribute[sv.size() + 1];
    avtColorTables *ct = avtColorTables::Instance();
    if(ct->IsDiscrete(ct->GetDefaultDiscreteColorTable()))
    {
        // The CT is discrete, get its color color control points.
        for(size_t i = 0; i < sv.size(); ++i)
        {
            unsigned char rgb[3] = {0,0,0};
            ct->GetControlPointColor(ct->GetDefaultDiscreteColorTable(), (int)i, rgb);
            ca[i].SetRed(int(rgb[0]));
            ca[i].SetGreen(int(rgb[1]));
            ca[i].SetBlue(int(rgb[2]));
        }
    }
    else
    {
        // The CT is continuous, sample the CT so we have a unique color
        // for each element in sv.
        unsigned char *rgb = ct->GetSampledColors(
            ct->GetDefaultDiscreteColorTable(), (int)sv.size());
        if(rgb)
        {
            for(size_t i = 0; i < sv.size(); ++i)
            {
                ca[i].SetRed(int(rgb[i*3]));
                ca[i].SetGreen(int(rgb[i*3+1]));
                ca[i].SetBlue(int(rgb[i*3+2]));
            }
            delete [] rgb;
        }
    }

    ColorAttributeList cal;
    int idx = 0;
    for(pos = sv.begin(); pos != sv.end(); ++pos)
    {
        if (idx < subsetAtts->GetMultiColor().GetNumColors())
        {
            // The meshIndex is within the defaultAtts' color
            // vector size.
            cal.AddColors(subsetAtts->GetMultiColor()[idx]);
        }
        else
        {
            // The meshIndex is greater than the size of the
            // defaultAtts' color vector. Use colors from the
            // default discrete color table.
            cal.AddColors(ca[idx]);
        }
        ++idx;
    }

    delete [] ca;

    // Set the subset names and colors in the subsetAtts.
    subsetAtts->SetSubsetNames(sv);
    subsetAtts->SetMultiColor(cal);
    defaultAtts->SetSubsetNames(sv);
    defaultAtts->SetMultiColor(cal);
}
コード例 #5
0
ファイル: test3.C プロジェクト: burlen/visit_vtk_7_src
bool
Run_Test1(bool verbose, int *subtest, int *nsubtests)
{
    // We have 5 subtests
    *nsubtests = 5;

#ifdef VERBOSE
    if(verbose)
    {
        cout << "=================================================" << endl;
        cout << "Running Test 1" << endl;
        cout << "=================================================" << endl;
    }
#endif

    // Create a list of ColorAttribute.
    ColorAttributeList cal;

    // Add some ColorAttribute to it.
    ColorAttribute c1(255, 0, 0), c2(255,255,0), c3(0, 255, 0), c4(0,0,255);
    if(verbose)
       cout << "Before 1st addition: " << cal << endl;
    cal.AddColorAttribute(c1);
    if(verbose)
       cout << "After 1st addition: " << cal << endl;
    cal.AddColorAttribute(c2);
    if(verbose)
       cout << "After 2nd addition: " << cal << endl;
    cal.AddColorAttribute(c3);
    if(verbose)
       cout << "After 3rd addition: " << cal << endl;
    cal.AddColorAttribute(c4);
    if(verbose)
       cout << "After 4th addition: " << cal << endl << endl;
    if(cal.GetNumColorAttributes() != 4)
        return false;

    // Test the copy constructor.
    *subtest = 2;
    ColorAttributeList cal2(cal);
    if(verbose)
    {
        cout << "Original:" << cal << endl;
        cout << "Copy:" << cal2 << endl << endl;
    }
    if(cal != cal2)
        return false;

    // Test ClearColorAttribute.
    *subtest = 3;
    if(verbose)
        cout << "Before clear:" << cal2 << endl;
    cal2.ClearColorAttributes();
    if(verbose)
        cout << "After clear:" << cal2 << endl << endl;
    if(cal2.GetNumColorAttributes() != 0)
         return false;

    // Test RemoveColorAttribute.
    *subtest = 4;
    ColorAttributeList calRem(cal);
    if(verbose)
        cout << "Before removal:" << calRem << endl;
    bool retval = true;
    for(int i = 0; i < 4 && !retval; ++i)
    {
        calRem.RemoveColorAttribute(0);
        if(verbose)
            cout << calRem << endl;
        switch(i)
        {
        case 0:
            retval = (calRem[0] == c2);
            break;
        case 1:
            retval = (calRem[0] == c3);
            break;
        case 2:
            retval = (calRem[0] == c4);
            break;
        case 3:
            retval = true;
            break;
        }
    }
    if(verbose)
        cout << "After all removals: " << calRem << endl << endl;
    if(!retval)
        return false;

    // Try writing the ColorAttribute to a list and reading them back.
    *subtest = 5;
    BufferConnection buf;
    cal.Write(buf);
    ColorAttributeList reader;
    reader.Read(buf);
    if(verbose)
    {
        cout << "Writer: " << cal << endl;
        cout << "Reader: " << reader << endl;
    }
    if(!(cal == reader))
        return false;

    return true;
}
コード例 #6
0
void
avtFilledBoundaryPlot::SetColors()
{
    vector < string > allLabels = atts.GetBoundaryNames();
    vector < string > labels;
    LevelColorMap levelColorMap;

    behavior->GetInfo().GetAttributes().GetLabels(labels);

    if (labels.size() == 0)
    {
        levelsLegend->SetColorBarVisibility(0);
        levelsLegend->SetMessage("No subsets present");
    }
    else
    {
        levelsLegend->SetColorBarVisibility(1);
        levelsLegend->SetMessage(NULL);
    }

    if (atts.GetColorType() == FilledBoundaryAttributes::ColorBySingleColor)
    {
        ColorAttribute ca(atts.GetSingleColor());
        ca.SetAlpha((unsigned char)(float(ca.Alpha()) * atts.GetOpacity()));
        ColorAttributeList cal;
        cal.AddColors(ca);

        avtLUT->SetLUTColorsWithOpacity(ca.GetColor(), 1);
        levelsMapper->SetColors(cal, needsRecalculation);
        //
        //  Send an empty color map, rather than one where all
        //  entries map to same value.
        //
        levelsLegend->SetLabelColorMap(levelColorMap);
        levelsLegend->SetLevels(labels);
    }
    else if (atts.GetColorType() == FilledBoundaryAttributes::ColorByMultipleColors)
    {
        ColorAttributeList cal(atts.GetMultiColor());

        //
        // If we are doing clean-zones-only, we will need a mixed color
        //
        allLabels.push_back("mixed");
        cal.AddColors(atts.GetMixedColor());

        int numColors = cal.GetNumColors();

        //
        //  Create colors from original color table.
        //
        unsigned char *colors = new unsigned char[numColors * 4];
        unsigned char *cptr = colors;
        for(int i = 0; i < numColors; i++)
        {
            unsigned char c = (unsigned char)(cal[i].Alpha() * atts.GetOpacity());
            cal[i].SetAlpha(c);
            *cptr++ = (unsigned char)cal[i].Red();
            *cptr++ = (unsigned char)cal[i].Green();
            *cptr++ = (unsigned char)cal[i].Blue();
            *cptr++ = (unsigned char)cal[i].Alpha();

            //
            //  Create a label-to-color-index mapping
            //
            levelColorMap.insert(LevelColorMap::value_type(allLabels[i], i));
        }

        avtLUT->SetLUTColorsWithOpacity(colors, numColors);
        levelsMapper->SetColors(cal, needsRecalculation);
        levelsLegend->SetLevels(labels);

        levelsMapper->SetLabelColorMap(levelColorMap);
        levelsLegend->SetLabelColorMap(levelColorMap);

        delete [] colors;
    }
    else // ColorByColorTable
    {
        ColorAttributeList cal(atts.GetMultiColor());

        //
        // If we are doing clean-zones-only, we will need a mixed color
        //
        allLabels.push_back("mixed");
        cal.AddColors(atts.GetMixedColor());

        //
        // It is a litte more complicated to handle c.z.o. here relative
        // to when using MultiColor, because we want to interpolate the
        // color table using only the size of array *before* adding the
        // mixed color.  We use two "numColors" variables to handle this.
        //
        int numColorsFull = cal.GetNumColors();
        int numColors     = numColorsFull - 1;
        unsigned char *colors = new unsigned char[numColorsFull * 4];
        unsigned char *cptr = colors;
        avtColorTables *ct = avtColorTables::Instance();
        int opacity = int((float)atts.GetOpacity()*255.f);

        //
        // Detect if we're using the default color table or a color table
        // that does not exist anymore.
        //
        string ctName(atts.GetColorTableName());
        if(ctName == "Default")
            ctName = string(ct->GetDefaultDiscreteColorTable());
        else if(!ct->ColorTableExists(ctName.c_str()))
        {
            delete [] colors;
            EXCEPTION1(InvalidColortableException, ctName);
        }

        //
        //  Create a label-to-color-index mapping
        //
        for(int i = 0; i < numColorsFull; ++i)
            levelColorMap.insert(LevelColorMap::value_type(allLabels[i], i));

        bool invert = atts.GetInvertColorTable();

        //
        // Add a color for each boundary name.
        //
        if(ct->IsDiscrete(ctName.c_str()))
        {
            // The CT is discrete, get its color color control points.
            for(int i = 0; i < numColors; ++i)
            {
                unsigned char rgb[3] = {0,0,0};
                ct->GetControlPointColor(ctName.c_str(), i, rgb, invert);
                *cptr++ = rgb[0];
                *cptr++ = rgb[1];
                *cptr++ = rgb[2];
                *cptr++ = opacity;

                cal[i].SetRgba(rgb[0], rgb[1], rgb[2], opacity);
            }
        }
        else
        {
            // The CT is continuous, sample the CT so we have a unique color
            // for each element.
            unsigned char *rgb = ct->GetSampledColors(ctName.c_str(), numColors, invert);
            if(rgb)
            {
                for(int i = 0; i < numColors; ++i)
                {
                    int j = i * 3;
                    *cptr++ = rgb[j];
                    *cptr++ = rgb[j+1];
                    *cptr++ = rgb[j+2];
                    *cptr++ = opacity;

                    cal[i].SetRgba(rgb[j], rgb[j+1], rgb[j+2], opacity);
                }
                delete [] rgb;
            }
        }
        *cptr++ = (unsigned char)cal[numColors].Red();
        *cptr++ = (unsigned char)cal[numColors].Green();
        *cptr++ = (unsigned char)cal[numColors].Blue();
        *cptr++ = (unsigned char)cal[numColors].Alpha();

        avtLUT->SetLUTColorsWithOpacity(colors, numColorsFull);
        levelsMapper->SetColors(cal, needsRecalculation);
        levelsLegend->SetLevels(labels);

        levelsMapper->SetLabelColorMap(levelColorMap);
        levelsLegend->SetLabelColorMap(levelColorMap);

        delete [] colors;
    }
}