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; } }
void VisItDataServerPrivate::ReadData(const std::string &var) { // Set some defaults. MaterialAttributes mAtts; ExpressionList combinedExprList(exprList); MeshManagementAttributes meshAtts; bool treatAllDbsAsTimeVarying = false; bool ignoreExtents = true; std::string selectionName; int windowID = 0; // // Tickle the engine to create a vis window. Works around a bug in engine! // if(!createdVisWin) { createdVisWin = true; // Set some defaults. WindowAttributes windowAtts; windowAtts.SetColorTables(*avtColorTables::Instance()->GetColorTables()); AnnotationAttributes annotationAtts; AnnotationObjectList annotationObjectList; std::string extStr("?"); VisualCueList visCues; int frameAndState[] = {0,0,0,0,0,0,0}; double viewExtents[] = {0., 1., 0., 1., 0., 1.}; std::string ctName("hot"); engine.GetEngineMethods()->SetWinAnnotAtts(&windowAtts, &annotationAtts, &annotationObjectList, extStr, &visCues, frameAndState, viewExtents, ctName, windowID); } // // Determine the name of the mesh for this variable. // const avtDatabaseMetaData *md = GetMetaData(openFile); if(md == NULL) { EXCEPTION1(VisItException, "Can't get the metadata."); } std::string mesh = md->MeshForVar(var); // Add the metadata expressions to the known expressions. for(int i = 0; i < md->GetNumberOfExpressions(); ++i) combinedExprList.AddExpressions(*md->GetExpression(i)); // // Get the SIL so we can make a SIL restriction. // const SILAttributes *silAtts = mdserver.GetMDServerMethods()->GetSIL(openFile, openTimeState, treatAllDbsAsTimeVarying); if(silAtts == NULL) { EXCEPTION1(VisItException, "Can't get the SIL."); } avtSIL sil(*silAtts); avtSILRestriction_p silr = new avtSILRestriction(&sil); silr->SetTopSet(mesh.c_str()); // // Start a new network // engine.GetEngineMethods()->ReadDataObject(openFileFormat, openFile, var, openTimeState, silr, mAtts, // lots of junk! combinedExprList, meshAtts, treatAllDbsAsTimeVarying, ignoreExtents, selectionName, windowID); }