Exemplo n.º 1
0
// ****************************************************************************
//  Method:  avtMoleculeFilter::PostExecute
//
//  Purpose:
//    Now that we know which integral values exist in this data base,
//    apply names to them and make these be the date attribute labels.
//
//  Arguments:
//    none
//
//  Programmer:  Jeremy Meredith
//  Creation:    March 23, 2006
//
//  Modifications:
//    Jeremy Meredith, Mon Aug 28 18:29:47 EDT 2006
//    Account for model number directory prefix.
//
//    Jeremy Meredith, Thu Mar 12 17:32:34 EDT 2009
//    Allow any variable starting with "element" to be treated as
//    an atomic number -- this makes creating new element expressions
//    to override ones in the file possible.
//
//    Jeremy Meredith, Wed May 20 11:49:18 EDT 2009
//    Added a fake "0" element which means "unknown", and hydrogen
//    now starts at 1, so we don't need to correct for 1-origin indices.
//
//    Jeremy Meredith, Tue Aug 25 14:17:15 EDT 2009
//    A strange bug occurs when switching the radius variable to an expression;
//    the plot legend picks up the extents of the radius variable instead of
//    the old primary variable, because it thinks the primary variable has
//    changed.  This is a bug at a different level, but the diagnosis of the
//    fuller problem is complex, and has not yet been replicated in other
//    plots; therefore, I simply set the primary variable again here, just
//    to make sure it's correct, which effectively works around the problem.
//
// ****************************************************************************
void
avtMoleculeFilter::PostExecute()
{
    std::vector<std::string> labels;

    if (name == "element" ||
        (name.length()>7 && name.substr(0,7) == "element") ||
        (name.length()>8 && name.substr(name.length()-8)=="/element"))
    {
        for (std::set<int>::iterator it = used_values.begin();
             it != used_values.end();
             it++)
        {
            labels.push_back(element_names[*it]);
        }
    }
    else if (name == "restype" || (name.length()>8 && name.substr(name.length()-8)=="/restype"))
    {
        // Poke on/off state, and the short and long names of all of 
        // the known residue names into the labels. We send them all 
        // with an on/off flag so we can let the viewer know about 
        // new residues that we've learned about.
        for(int i = 0; i < NumberOfKnownResidues(); ++i)
        {
            const char *rn = NumberToResiduename(i);
            if(rn == 0)
            {
                break;
            }

            if(used_values.find(i) == used_values.end())
                labels.push_back("off");
            else
                labels.push_back("on");
            labels.push_back(rn);
            labels.push_back(ResiduenameToLongName(rn));
        }
    }
    else
    {
        char nm[256];
        for (std::set<int>::iterator it = used_values.begin();
             it != used_values.end();
             it++)
        {
            sprintf(nm, "%d", *it);
            labels.push_back(nm);
        }
    }

    GetOutput()->GetInfo().GetAttributes().SetLabels(labels);
    OutputSetActiveVariable(pipelineVariable);
}
void
avtDatasetToDatasetFilter::PostExecute(void)
{
    if (switchVariables)
    {
        debug5 << GetType() << ": Setting output variable to be " 
               << pipelineVariable << " after execution." << endl;
        OutputSetActiveVariable(pipelineVariable);
        if (removeActiveVariableWhenDone)
        {
            debug5 << GetType() << ": Removing variable " << activeVariable
                   << " after execution." << endl;
            avtDataTree_p tree = GetDataTree();
            bool    success;
            tree->Traverse(CRemoveVariable, (void *)activeVariable, success);
            GetOutput()->GetInfo().GetAttributes(). 
                                                RemoveVariable(activeVariable);
        }
    }

    // Iterate through the secondary variables, removing them when needed.
    for (int i = 0; i < removeSecondaryVariable.size(); i++)
    {
        if (removeSecondaryVariable[i] == true)
        {
            debug5 << GetType() << ": Removing secondary variable "
                   << secondaryVarList[i] << " after execution." << endl;
            avtDataTree_p tree = GetDataTree();
            bool    success;
            tree->Traverse(CRemoveVariable, (void *)secondaryVarList[i],
                           success);
            GetOutput()->GetInfo().GetAttributes(). 
                                           RemoveVariable(secondaryVarList[i]);
        } else
        {
            debug5 << GetType() << ": Leaving secondary variable "
                   << secondaryVarList[i] << " after execution." << endl;
        }
    }

    avtDatasetToDataObjectFilter::PostExecute();
    avtDataObjectToDatasetFilter::PostExecute();
}