Пример #1
0
void
QvisAppearanceWidget::opacityChanged(int opacity, int index)
{
    int MultiCurve = viewer->GetPlotIndex("MultiCurve");
    AttributeSubject *atts = viewer->DelayedState()->GetPlotAttributes(MultiCurve);
    if(atts != 0)
    {
        DataNode root("root");
        atts->CreateNode(&root, true, false);
        DataNode *multiCurveNode = root.GetNode("MultiCurveAttributes");
        DataNode *multiColorNode = multiCurveNode->GetNode("multiColor");
        DataNode *calNode = multiColorNode->GetNode("ColorAttributeList");
        DataNode **children = calNode->GetChildren();

        DataNode *colorNode = children[index]->GetNode("color");
        const unsigned char *oldColor = colorNode->AsUnsignedCharArray();
        unsigned char newColor[4];
        newColor[0] = oldColor[0];
        newColor[1] = oldColor[1];
        newColor[2] = oldColor[2];
        newColor[3] = (unsigned char)opacity;
        colorNode->SetUnsignedCharArray(newColor, 4);

        atts->SetFromNode(&root);
        atts->Notify();
        emit multiCurveChanged(atts);
    }
}
Пример #2
0
void
ColorAttributeList::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("ColorAttributeList");
    if(searchNode == 0)
        return;

    DataNode *node;
    DataNode **children;
    // Clear all the ColorAttributes.
    ClearColors();

    // Go through all of the children and construct a new
    // ColorAttribute for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("ColorAttribute"))
            {
                ColorAttribute temp;
                temp.SetFromNode(children[i]);
                AddColors(temp);
            }
        }
    }

}
void
GaussianControlPointList::SetFromNode(DataNode *parentNode)
{
    int i;
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("GaussianControlPointList");
    if(searchNode == 0)
        return;

    //DataNode *node;
    DataNode **children;
    // Clear all the GaussianControlPoints.
    ClearControlPoints();

    // Go through all of the children and construct a new
    // GaussianControlPoint for each one of them.
    children = searchNode->GetChildren();
    for(i = 0; i < searchNode->GetNumChildren(); ++i)
    {
        if(children[i]->GetKey() == std::string("GaussianControlPoint"))
        {
            GaussianControlPoint temp;
            temp.SetFromNode(children[i]);
            AddControlPoints(temp);
        }
    }

}
Пример #4
0
void
AttributeSubjectMap::ProcessOldVersions(DataNode *parentNode,
    const std::string &configVersion, AttributeSubject *obj)
{
    //
    // Look for the required nodes.
    //
    if(parentNode == 0)
        return;

    DataNode *mapNode = parentNode->GetNode("AttributeSubjectMap");
    if(mapNode == 0)
        return;

    DataNode *indicesNode = mapNode->GetNode("indices");
    if(indicesNode == 0)
        return;

    DataNode *attsNode = mapNode->GetNode("attributes");
    if(attsNode == 0)
        return;

    //
    // Now that we have all of the nodes that we need, process old versions
    // of each of the input data nodes.
    //
    const intVector &iv = indicesNode->AsIntVector();
    DataNode **attsObjects = attsNode->GetChildren();
    const int numAtts = attsNode->GetNumChildren();
    for(int i = 0; i < iv.size(); ++i)
    {
        if(i < numAtts)
            obj->ProcessOldVersions(attsObjects[i], configVersion.c_str());
    }
}
void
DatabaseCorrelationList::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("DatabaseCorrelationList");
    if(searchNode == 0)
        return;

    DataNode *node;
    DataNode **children;

    // Clear all the DatabaseCorrelations if we got any.
    bool clearedCorrelations = false;
    // Go through all of the children and construct a new
    // DatabaseCorrelation for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("DatabaseCorrelation"))
            {
                if (!clearedCorrelations)
                {
                    ClearCorrelations();
                    clearedCorrelations = true;
                }
                DatabaseCorrelation temp;
                temp.SetFromNode(children[i]);
                AddCorrelations(temp);
            }
        }
    }

    if((node = searchNode->GetNode("needPermission")) != 0)
        SetNeedPermission(node->AsBool());
    if((node = searchNode->GetNode("defaultCorrelationMethod")) != 0)
        SetDefaultCorrelationMethod(node->AsInt());
    if((node = searchNode->GetNode("whenToCorrelate")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 3)
                SetWhenToCorrelate(WhenToCorrelate(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            WhenToCorrelate value;
            if(WhenToCorrelate_FromString(node->AsString(), value))
                SetWhenToCorrelate(value);
        }
    }
}
Пример #6
0
void
AttributeSubjectMap::SetFromNode(DataNode *parentNode,
    AttributeSubject *factoryObj)
{
    //
    // Clear the attributes.
    //
    ClearAtts();

    //
    // Look for the required nodes.
    //
    if(parentNode == 0)
        return;

    DataNode *mapNode = parentNode->GetNode("AttributeSubjectMap");
    if(mapNode == 0)
        return;

    DataNode *indicesNode = mapNode->GetNode("indices");
    if(indicesNode == 0)
        return;

    DataNode *attsNode = mapNode->GetNode("attributes");
    if(attsNode == 0)
        return;

    //
    // Now that we have all of the nodes that we need, read in the objects
    // and add them to the "map".
    //
    const intVector &iv = indicesNode->AsIntVector();
    DataNode **attsObjects = attsNode->GetChildren();
    const int numAtts = attsNode->GetNumChildren();
    for(int i = 0; i < iv.size(); ++i)
    {
        if(i < numAtts)
        {
            // Create a fresh AttributeSubject so that its fields are
            // initialized to the default values and not those last read in.
            AttributeSubject *reader = factoryObj->NewInstance(false);

            // Initialize the object using the data node.
            reader->SetFromNode(attsObjects[i]);

            // Add the object to the map.
            SetAtts(iv[i], reader);

            // delete the reader object.
            delete reader;
        }
    }
}
Пример #7
0
void
FileOpenOptions::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("FileOpenOptions");
    if(searchNode == 0)
        return;

    DataNode *node;
    DataNode **children;
    if((node = searchNode->GetNode("typeNames")) != 0)
        SetTypeNames(node->AsStringVector());
    if((node = searchNode->GetNode("typeIDs")) != 0)
        SetTypeIDs(node->AsStringVector());

    // Clear all the DBOptionsAttributess if we got any.
    bool clearedOpenOptions = false;
    // Go through all of the children and construct a new
    // DBOptionsAttributes for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("DBOptionsAttributes"))
            {
                if (!clearedOpenOptions)
                {
                    ClearOpenOptions();
                    clearedOpenOptions = true;
                }
                DBOptionsAttributes temp;
                temp.SetFromNode(children[i]);
                AddOpenOptions(temp);
            }
        }
    }

    if((node = searchNode->GetNode("Enabled")) != 0)
        SetEnabled(node->AsIntVector());
    if((node = searchNode->GetNode("preferredIDs")) != 0)
        SetPreferredIDs(node->AsStringVector());
}
void
AnnotationObjectList::ProcessOldVersions(DataNode *parentNode,
    const char *configVersion)
{
    if (parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("AnnotationObjectList");
    if (searchNode == 0)
        return;

    int nChildren = searchNode->GetNumChildren();
    DataNode **children = searchNode->GetChildren();

    for (int i = 0; i < nChildren; ++i)
    {
        AnnotationObject annot;
        annot.ProcessOldVersions(children[i], configVersion);
    }
}
void
SelectionList::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("SelectionList");
    if(searchNode == 0)
        return;

    DataNode *node;
    DataNode **children;
    if((node = searchNode->GetNode("autoApplyUpdates")) != 0)
        SetAutoApplyUpdates(node->AsBool());

    // Clear all the SelectionPropertiess if we got any.
    bool clearedSelections = false;
    // Go through all of the children and construct a new
    // SelectionProperties for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("SelectionProperties"))
            {
                if (!clearedSelections)
                {
                    ClearSelections();
                    clearedSelections = true;
                }
                SelectionProperties temp;
                temp.SetFromNode(children[i]);
                AddSelections(temp);
            }
        }
    }

    // Clear all the SelectionSummary list.
    ClearSelectionSummarys();
}
void
EngineList::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("EngineList");
    if(searchNode == 0)
        return;

    DataNode *node;
    DataNode **children;
    if((node = searchNode->GetNode("engineName")) != 0)
        SetEngineName(node->AsStringVector());
    if((node = searchNode->GetNode("simulationName")) != 0)
        SetSimulationName(node->AsStringVector());

    // Clear all the EnginePropertiess if we got any.
    bool clearedProperties = false;
    // Go through all of the children and construct a new
    // EngineProperties for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("EngineProperties"))
            {
                if (!clearedProperties)
                {
                    ClearProperties();
                    clearedProperties = true;
                }
                EngineProperties temp;
                temp.SetFromNode(children[i]);
                AddProperties(temp);
            }
        }
    }

}
void
ViewerClientInformation::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("ViewerClientInformation");
    if(searchNode == 0)
        return;

    DataNode *node;
    DataNode **children;

    // Clear all the ViewerClientInformationElements if we got any.
    bool clearedVars = false;
    // Go through all of the children and construct a new
    // ViewerClientInformationElement for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("ViewerClientInformationElement"))
            {
                if (!clearedVars)
                {
                    ClearVars();
                    clearedVars = true;
                }
                ViewerClientInformationElement temp;
                temp.SetFromNode(children[i]);
                AddVars(temp);
            }
        }
    }

    if((node = searchNode->GetNode("supportedFormats")) != 0)
        SetSupportedFormats(node->AsStringVector());
}
void
HostProfileList::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("HostProfileList");
    if(searchNode == 0)
        return;

    DataNode **children;

    // Clear all the MachineProfiles if we got any.
    bool clearedMachines = false;
    // Go through all of the children and construct a new
    // MachineProfile for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("MachineProfile"))
            {
                if (!clearedMachines)
                {
                    ClearMachines();
                    clearedMachines = true;
                }
                MachineProfile temp;
                temp.SetFromNode(children[i]);
                AddMachines(temp);
            }
        }
    }

}
Пример #13
0
void
AnnotationObjectList::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("AnnotationObjectList");
    if(searchNode == 0)
        return;

    DataNode **children;

    // Clear all the AnnotationObjects if we got any.
    bool clearedAnnotations = false;
    // Go through all of the children and construct a new
    // AnnotationObject for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("AnnotationObject"))
            {
                if (!clearedAnnotations)
                {
                    ClearAnnotations();
                    clearedAnnotations = true;
                }
                AnnotationObject temp;
                temp.SetFromNode(children[i]);
                AddAnnotation(temp);
            }
        }
    }

}
void
SILAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("SILAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    DataNode **children;
    if((node = searchNode->GetNode("nSets")) != 0)
        SetNSets(node->AsInt());
    if((node = searchNode->GetNode("setNames")) != 0)
        SetSetNames(node->AsStringVector());
    if((node = searchNode->GetNode("setIds")) != 0)
        SetSetIds(node->AsIntVector());
    if((node = searchNode->GetNode("wholeList")) != 0)
        SetWholeList(node->AsIntVector());
    if((node = searchNode->GetNode("nCollections")) != 0)
        SetNCollections(node->AsInt());
    if((node = searchNode->GetNode("category")) != 0)
        SetCategory(node->AsStringVector());
    if((node = searchNode->GetNode("role")) != 0)
        SetRole(node->AsIntVector());
    if((node = searchNode->GetNode("superset")) != 0)
        SetSuperset(node->AsIntVector());

    // Clear all the NamespaceAttributess if we got any.
    bool clearedNspaces = false;
    // Go through all of the children and construct a new
    // NamespaceAttributes for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("NamespaceAttributes"))
            {
                if (!clearedNspaces)
                {
                    ClearNspaces();
                    clearedNspaces = true;
                }
                NamespaceAttributes temp;
                temp.SetFromNode(children[i]);
                AddNspace(temp);
            }
        }
    }


    // Clear all the SILMatrixAttributess if we got any.
    bool clearedMatrices = false;
    // Go through all of the children and construct a new
    // SILMatrixAttributes for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("SILMatrixAttributes"))
            {
                if (!clearedMatrices)
                {
                    ClearMatrices();
                    clearedMatrices = true;
                }
                SILMatrixAttributes temp;
                temp.SetFromNode(children[i]);
                AddMatrices(temp);
            }
        }
    }


    // Clear all the SILArrayAttributess if we got any.
    bool clearedArrays = false;
    // Go through all of the children and construct a new
    // SILArrayAttributes for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("SILArrayAttributes"))
            {
                if (!clearedArrays)
                {
                    ClearArrays();
                    clearedArrays = true;
                }
                SILArrayAttributes temp;
                temp.SetFromNode(children[i]);
                AddArrays(temp);
            }
        }
    }

    if((node = searchNode->GetNode("order")) != 0)
        SetOrder(node->AsIntVector());
}
Пример #15
0
void
MultiCurveViewer::CreatePlot()
{
    if(generalWidget->GetCurrentVariable() == -1)
        return;

    // Determine the variable.
    std::string var(generalWidget->GetCurrentVariableName().toStdString());

    // Delete the active plots.
    viewer->DelayedMethods()->DeleteActivePlots();

    // Create a title.
    viewer->DelayedMethods()->AddAnnotationObject(AnnotationObject::Text2D, "title0");
    viewer->DelayedMethods()->AddAnnotationObject(AnnotationObject::Text2D, "title1");

    // Create a multi curve plot.
    int MultiCurve = viewer->GetPlotIndex("MultiCurve");
    viewer->DelayedMethods()->AddPlot(MultiCurve, var);
    AttributeSubject *multiCurveAtts = viewer->DelayedState()->GetPlotAttributes(MultiCurve);
    if(multiCurveAtts != 0)
    {
        DataNode root("root");
        multiCurveAtts->CreateNode(&root, true, false);
        DataNode *multiCurveNode = root.GetNode("MultiCurveAttributes");

        DataNode *multiColorNode = multiCurveNode->GetNode("multiColor");
        DataNode *calNode = multiColorNode->GetNode("ColorAttributeList");
        DataNode **children = calNode->GetChildren();

        unsigned char color[4];
        color[0] = 0; color[1] = 100; color[2] = 0; color[3] = 255;
        children[0]->GetNode("color")->SetUnsignedCharArray(color, 4);
        color[0] = 85; color[1] = 107; color[2] = 47;
        children[1]->GetNode("color")->SetUnsignedCharArray(color, 4);
        color[0] = 0; color[1] = 205; color[2] = 208;
        children[2]->GetNode("color")->SetUnsignedCharArray(color, 4);
        color[0] = 0; color[1] = 0; color[2] = 254;
        children[3]->GetNode("color")->SetUnsignedCharArray(color, 4);
        color[0] = 209; color[1] = 105; color[2] = 30;
        children[4]->GetNode("color")->SetUnsignedCharArray(color, 4);
        color[0] = 147; color[1] = 0; color[2] = 210;
        children[5]->GetNode("color")->SetUnsignedCharArray(color, 4);
        color[0] = 83; color[1] = 133; color[2] = 138;
        children[6]->GetNode("color")->SetUnsignedCharArray(color, 4);
        color[0] = 204; color[1] = 38; color[2] = 38;
        children[7]->GetNode("color")->SetUnsignedCharArray(color, 4);
        color[0] = 0; color[1] = 0; color[2] = 0;
        children[8]->GetNode("color")->SetUnsignedCharArray(color, 4);
        color[0] = 220; color[1] = 20; color[2] = 60;
        children[9]->GetNode("color")->SetUnsignedCharArray(color, 4);

        multiCurveNode->GetNode("yAxisTitleFormat")->SetString("%4.2f");
        multiCurveNode->GetNode("useYAxisTickSpacing")->SetBool(true);
        multiCurveNode->GetNode("yAxisTickSpacing")->SetDouble(0.25);
        multiCurveNode->GetNode("markerVariable")->SetString("v");

        multiCurveAtts->SetFromNode(&root);
        multiCurveAtts->Notify();
        viewer->DelayedMethods()->SetPlotOptions(MultiCurve);
    }

    // Add an index select operator.
    int IndexSelect = viewer->GetOperatorIndex("IndexSelect");
    viewer->DelayedMethods()->AddOperator(IndexSelect);
    AttributeSubject *indexSelectAtts = viewer->DelayedState()->GetOperatorAttributes(IndexSelect);
    if(indexSelectAtts != 0)
    {
        indexSelectAtts->SetValue("xMin", 0);
        indexSelectAtts->SetValue("xMax", -1);
        indexSelectAtts->SetValue("yMin", 16);
        indexSelectAtts->SetValue("yMax", 25);
        indexSelectAtts->Notify();
        viewer->DelayedMethods()->SetOperatorOptions(IndexSelect);
    }

    //
    // Issue a timer to finish the plot.
    //
    QTimer::singleShot(20, this, SLOT(finishPlot()));
}
Пример #16
0
void ColorControlPointList::SetFromNode(DataNode* parentNode)
{
  if (parentNode == 0)
    return;

  DataNode* searchNode = parentNode->GetNode("ColorControlPointList");
  if (searchNode == 0)
    return;

  DataNode* node;
  DataNode** children;
  // Clear all the ColorControlPoints.
  ClearControlPoints();

  //
  // Try setting the colors from the compact color and position vectors.
  //
  bool colorsAreSet = false;
  DataNode* compactColorNode = searchNode->GetNode("compactColors");
  DataNode* compactPositionNode = searchNode->GetNode("compactPositions");
  if (compactColorNode != 0 && compactPositionNode != 0)
  {
    const unsignedCharVector& colors = compactColorNode->AsUnsignedCharVector();
    const floatVector& positions = compactPositionNode->AsFloatVector();
    unsigned int npts = static_cast<unsigned int>(colors.size() / 4);
    if (npts > static_cast<unsigned int>(positions.size()))
      npts = static_cast<unsigned int>(positions.size());
    if (npts > 0)
    {
      for (unsigned int i = 0; i < npts; ++i)
      {
        int index = i << 2;
        AddControlPoints(ColorControlPoint(
          positions[i], colors[index], colors[index + 1], colors[index + 2], colors[index + 3]));
      }

      colorsAreSet = true;
    }
  }

  if (!colorsAreSet)
  {
    // Go through all of the children and construct a new
    // ColorControlPoint for each one of them.
    children = searchNode->GetChildren();
    for (int i = 0; i < searchNode->GetNumChildren(); ++i)
    {
      if (children[i]->GetKey() == std::string("ColorControlPoint"))
      {
        ColorControlPoint temp;
        temp.SetFromNode(children[i]);
        AddControlPoints(temp);
      }
    }
  }

  if ((node = searchNode->GetNode("smoothingFlag")) != 0)
    SetSmoothingFlag(node->AsBool());
  if ((node = searchNode->GetNode("equalSpacingFlag")) != 0)
    SetEqualSpacingFlag(node->AsBool());
  if ((node = searchNode->GetNode("discreteFlag")) != 0)
    SetDiscreteFlag(node->AsBool());
  if ((node = searchNode->GetNode("externalFlag")) != 0)
    SetExternalFlag(node->AsBool());
}
void
DBPluginInfoAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("DBPluginInfoAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    DataNode **children;
    if((node = searchNode->GetNode("types")) != 0)
        SetTypes(node->AsStringVector());
    if((node = searchNode->GetNode("hasWriter")) != 0)
        SetHasWriter(node->AsIntVector());

    // Clear all the DBOptionsAttributess if we got any.
    bool clearedDbReadOptions = false;
    // Go through all of the children and construct a new
    // DBOptionsAttributes for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("DBOptionsAttributes"))
            {
                if (!clearedDbReadOptions)
                {
                    ClearDbReadOptions();
                    clearedDbReadOptions = true;
                }
                DBOptionsAttributes temp;
                temp.SetFromNode(children[i]);
                AddDbReadOptions(temp);
            }
        }
    }


    // Clear all the DBOptionsAttributess if we got any.
    bool clearedDbWriteOptions = false;
    // Go through all of the children and construct a new
    // DBOptionsAttributes for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("DBOptionsAttributes"))
            {
                if (!clearedDbWriteOptions)
                {
                    ClearDbWriteOptions();
                    clearedDbWriteOptions = true;
                }
                DBOptionsAttributes temp;
                temp.SetFromNode(children[i]);
                AddDbWriteOptions(temp);
            }
        }
    }

    if((node = searchNode->GetNode("typesFullNames")) != 0)
        SetTypesFullNames(node->AsStringVector());
    if((node = searchNode->GetNode("license")) != 0)
        SetLicense(node->AsStringVector());
    if((node = searchNode->GetNode("host")) != 0)
        SetHost(node->AsString());
}
Пример #18
0
void
QvisAppearanceWidget::UpdateMultiCurveWidgets()
{
    // Get a data node representation of the multi curve attributes.
    DataNode root("root");
    multiCurveAtts->CreateNode(&root, true, false);
    DataNode *multiCurveNode = root.GetNode("MultiCurveAttributes");

    // Update the color type.
    DataNode *colorTypeNode = multiCurveNode->GetNode("colorType");
    int colorType = 1;
    if (colorTypeNode->AsString() == "ColorBySingleColor")
        colorType = 0;
    else if (colorTypeNode->AsString() == "ColorByMultipleColors")
        colorType = 1;
    colorModeButtons->blockSignals(true);
    colorModeButtons->button(colorType)->setChecked(true);
    colorModeButtons->blockSignals(false);

    // Update the single color.
    DataNode *singleColorNode = multiCurveNode->GetNode("singleColor");
    DataNode *colorAttributeNode = singleColorNode->GetNode("ColorAttribute");
    DataNode *colorNode = colorAttributeNode->GetNode("color");
    const unsigned char *color = colorNode->AsUnsignedCharArray();
    QColor tempColor = QColor((int)color[0],
                              (int)color[1],
                              (int)color[2]);
    singleColor->blockSignals(true);
    singleColor->setButtonColor(tempColor);
    singleColor->blockSignals(false);

    singleColorOpacity->blockSignals(true);
    singleColorOpacity->setValue((int)color[3]);
    singleColorOpacity->blockSignals(false);

    // Update the multi color.
    DataNode *multiColorNode = multiCurveNode->GetNode("multiColor");
    DataNode *calNode = multiColorNode->GetNode("ColorAttributeList");
    DataNode **children = calNode->GetChildren();
    int nEntries = calNode->GetNumChildren();

    multipleColors->blockSignals(true);

    if (nEntries == multipleColors->numEntries())
    {
        for (int i = 0; i < nEntries; ++i)
        {
            DataNode *colorNode = children[i]->GetNode("color");
            const unsigned char *color = colorNode->AsUnsignedCharArray();

            QColor temp((int)color[0], (int)color[1], (int)color[2]);

            multipleColors->setColor(i, temp);
            multipleColors->setOpacity(i, (int)color[3]);
        }
    }
    else if (nEntries > multipleColors->numEntries())
    {
        // Set all of the existing colors.
        for (int i = 0; i < multipleColors->numEntries(); ++i)
        {
            DataNode *colorNode = children[i]->GetNode("color");
            const unsigned char *color = colorNode->AsUnsignedCharArray();

            QColor temp((int)color[0], (int)color[1], (int)color[2]);

            multipleColors->setColor(i, temp);
            multipleColors->setOpacity(i, (int)color[3]);
        }

        // Add new entries
        for (int i = multipleColors->numEntries(); i < nEntries; ++i)
        {
            DataNode *colorNode = children[i]->GetNode("color");
            const unsigned char *color = colorNode->AsUnsignedCharArray();

            QColor temp((int)color[0], (int)color[1], (int)color[2]);

            multipleColors->addEntry(QString(""), temp, (int)color[3]);
        }
    }
    else // nEntries < multipleColors->numEntries()
    {
        // Set all of the existing names.
        for (int i = 0; i < nEntries; ++i)
        {
            DataNode *colorNode = children[i]->GetNode("color");
            const unsigned char *color = colorNode->AsUnsignedCharArray();

            QColor temp((int)color[0], (int)color[1], (int)color[2]);

            multipleColors->setColor(i, temp);
            multipleColors->setOpacity(i, (int)color[3]);
        }

        // Remove excess entries.
        int numEntries = multipleColors->numEntries();
        for (int i = nEntries; i < numEntries; ++i)
        {
            multipleColors->removeLastEntry();
        }
    }

    multipleColors->blockSignals(false);

    // Update the line style.
    DataNode *lineStyleNode = multiCurveNode->GetNode("lineStyle");
    lineStyle->blockSignals(true);
    lineStyle->SetLineStyle(lineStyleNode->AsInt());
    lineStyle->blockSignals(false);

    // Update the line width.
    DataNode *lineWidthNode = multiCurveNode->GetNode("lineWidth");
    lineWidth->blockSignals(true);
    lineWidth->SetLineWidth(lineWidthNode->AsInt());
    lineWidth->blockSignals(false);

    // Update the y axis title format.
    DataNode *yAxisTitleFormatNode = multiCurveNode->GetNode("yAxisTitleFormat");
    yAxisTitleFormat->setText(QString(yAxisTitleFormatNode->AsString().c_str()));

    // Update the use y axis range.
    DataNode *useYAxisTickSpacingNode = multiCurveNode->GetNode("useYAxisTickSpacing");
    if (useYAxisTickSpacingNode->AsBool() == true)
    {
        yAxisTickSpacing->setEnabled(true);
    }
    else
    {
        yAxisTickSpacing->setEnabled(false);
    }
    useYAxisTickSpacing->blockSignals(true);
    useYAxisTickSpacing->setChecked(useYAxisTickSpacingNode->AsBool());
    useYAxisTickSpacing->blockSignals(false);

    // Update the y axis range.
    DataNode *yAxisTickSpacingNode = multiCurveNode->GetNode("yAxisTickSpacing");
    yAxisTickSpacing->setText(QString().setNum(yAxisTickSpacingNode->AsDouble()));

    // Update the display markers.
    DataNode *displayMarkersNode = multiCurveNode->GetNode("displayMarkers");
    displayMarkers->blockSignals(true);
    displayMarkers->setChecked(displayMarkersNode->AsBool());
    displayMarkers->blockSignals(false);

    // Update the display ids.
    DataNode *displayIdsNode = multiCurveNode->GetNode("displayIds");
    displayIds->blockSignals(true);
    displayIds->setChecked(displayIdsNode->AsBool());
    displayIds->blockSignals(false);

    // Update the legend.
    DataNode *legendFlagNode = multiCurveNode->GetNode("legendFlag");
    legend->blockSignals(true);
    legend->setChecked(legendFlagNode->AsBool());
    legend->blockSignals(false);
}
bool
AccessViewerSession::GetSourceMap(stringVector &keys, stringVector &values,
    std::map<std::string, stringVector> &uses)
{
    const char *mName = "AccessViewerSession::GetSourceMap: ";

    DataNode *vsNode = GetVSNode();
    bool ret = false;
    if(vsNode != 0)
    {
        DataNode *smNode = vsNode->GetNode("SourceMap");
        if(smNode != 0)
        {
            keys.clear();
            values.clear();

            DataNode **children = smNode->GetChildren();
            for(int i = 0; i < smNode->GetNumChildren(); ++i)
            {
                if(children[i]->GetNodeType() == STRING_NODE)
                {
                    keys.push_back(children[i]->GetKey());
                    values.push_back(children[i]->AsString());
                }
            }

            ret = keys.size() > 0;            
        }
        else
        {
            debug1 << mName << "Could not find SourceMap node." << endl;
        }

        // NOTE: This section knows a lot about viewer session files, which
        //       means that if the viewer session format changes then this
        //       code must also change.
        //
        // Look through the plots in the session file and determine
        // where each source is used so we can give a little more
        // information to the user.
        DataNode *wmNode = vsNode->GetNode("ViewerWindowManager");
        if(wmNode != 0)
        {
            DataNode *winNode = wmNode->GetNode("Windows");
            if(winNode != 0)
            {
                DataNode **wins = winNode->GetChildren();
                for(int i = 0; i < winNode->GetNumChildren(); ++i)
                {
                    if(wins[i]->GetNodeType() == INTERNAL_NODE &&
                       wins[i]->GetKey() == "ViewerWindow")
                    {
                        DataNode *vpl = wins[i]->GetNode("ViewerPlotList");
                        if(vpl != 0)
                        {
                            char tmp[1000];
                            int ploti = 0;
                            DataNode *plotNode = 0;
                            do
                            {
                                SNPRINTF(tmp, 1000, "plot%02d", ploti++);
                                plotNode = vpl->GetNode(tmp);
                                if(plotNode != 0)
                                {
                                    DataNode *pluginIDNode = 0,
                                             *varNameNode = 0,
                                             *sourceIDNode = 0;
                                    pluginIDNode = plotNode->GetNode("pluginID");
                                    sourceIDNode = plotNode->GetNode("sourceID");
                                    varNameNode = plotNode->GetNode("variableName");

                                    if(sourceIDNode != 0 && 
                                       sourceIDNode->GetNodeType() == STRING_NODE &&
                                       pluginIDNode != 0 && 
                                       pluginIDNode->GetNodeType() == STRING_NODE &&
                                       varNameNode != 0 && 
                                       varNameNode->GetNodeType() == STRING_NODE)
                                    {
                                        std::string source(sourceIDNode->AsString());
                                        std::string varName(varNameNode->AsString());
                                        std::string plotName(pluginIDNode->AsString());

                                        std::string::size_type pos = plotName.rfind("_");
                                        if(pos != std::string::npos)
                                            plotName = plotName.substr(0, pos);

                                        SNPRINTF(tmp, 1000, "Window %d, %s plot of %s",
                                            i+1, plotName.c_str(), varName.c_str());

                                        if(uses.find(source) == uses.end())
                                            uses[source] = stringVector();
                                        uses[source].push_back(std::string(tmp));
                                    }
                                    else
                                    {
                                        debug1 << mName << "pluginID, sourceID, or "
                                        "variableName nodes not located or they "
                                        "were the wrong types." << endl;
                                    }
                                }
                            } while(plotNode != 0);
                        }
                    }
                }
            }
        }

    }

    return ret;
}