示例#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
QvisAppearanceWidget::singleColorOpacityChanged(int opacity)
{
    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 *singleColorNode = multiCurveNode->GetNode("singleColor");
        DataNode *colorAttributeNode = singleColorNode->GetNode("ColorAttribute");
        DataNode *colorNode = colorAttributeNode->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;
        DataNode *newColorNode = new DataNode("color", newColor, 4);
        colorAttributeNode->RemoveNode(colorNode);
        colorAttributeNode->AddNode(newColorNode);
        atts->SetFromNode(&root);
        atts->Notify();
        emit multiCurveChanged(atts);
    }
}
示例#3
0
void
ColorControlPoint::SetFromNode(DataNode *parentNode)
{
    //int i;
    if(parentNode == 0)
        return;

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

    DataNode *node;
    if((node = searchNode->GetNode("colors")) != 0)
        SetColors(node->AsUnsignedCharArray());
    if((node = searchNode->GetNode("position")) != 0)
        SetPosition(node->AsFloat());
}
示例#4
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);
}