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);
    }
}
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);
    }
}
void
SimpleVisApp::setNContours(int nc)
{
    int Contour = viewer->GetPlotIndex("Contour");
    AttributeSubject *contourAtts = viewer->DelayedState()->GetPlotAttributes(Contour);
    if(contourAtts != 0)
    {
        contourAtts->SetValue("contourNLevels", nc);
        contourAtts->Notify();
        viewer->DelayedMethods()->SetPlotOptions(Contour);
    }
}
void
QvisAppearanceWidget::legendChanged(bool val)
{
    int MultiCurve = viewer->GetPlotIndex("MultiCurve");
    AttributeSubject *atts = viewer->DelayedState()->GetPlotAttributes(MultiCurve);
    if(atts != 0)
    {
        atts->SetValue("legendFlag", val);
        atts->Notify();
        emit multiCurveChanged(atts);
    }
}
void
QvisAppearanceWidget::lineWidthChanged(int style)
{
    int MultiCurve = viewer->GetPlotIndex("MultiCurve");
    AttributeSubject *atts = viewer->DelayedState()->GetPlotAttributes(MultiCurve);
    if(atts != 0)
    {
        atts->SetValue("lineWidth", style);
        atts->Notify();
        emit multiCurveChanged(atts);
    }
}
//
// Qt slot functions
//
void
QvisAppearanceWidget::colorModeChanged(int index)
{
    int MultiCurve = viewer->GetPlotIndex("MultiCurve");
    AttributeSubject *atts = viewer->DelayedState()->GetPlotAttributes(MultiCurve);
    if(atts != 0)
    {
        atts->SetValue("colorType", index);
        atts->Notify();
        emit multiCurveChanged(atts);
    }
}
void
QvisPostableWindowObserver::apply()
{
    AttributeSubject *as = (AttributeSubject *)selectedSubject;

    // If the AttributeSubject that we're observing has fields
    // that are selected, make it notify all its observers.
    if(as->NumAttributesSelected() > 0)
    {
        as->Notify();
    }
}
void
QvisAppearanceWidget::yAxisTitleFormatProcessText()
{
    int MultiCurve = viewer->GetPlotIndex("MultiCurve");
    AttributeSubject *atts = viewer->DelayedState()->GetPlotAttributes(MultiCurve);
    if(atts != 0)
    {
        QString temp = yAxisTitleFormat->displayText();
        atts->SetValue("yAxisTitleFormat", temp.toStdString());
        atts->Notify();
        emit multiCurveChanged(atts);
    }
}
void
QvisAppearanceWidget::yAxisTickSpacingProcessText()
{
    int MultiCurve = viewer->GetPlotIndex("MultiCurve");
    AttributeSubject *atts = viewer->DelayedState()->GetPlotAttributes(MultiCurve);
    if(atts != 0)
    {
        double val;
        bool okay = LineEditGetDouble(yAxisTickSpacing, val);
        if (okay)
        {
            atts->SetValue("yAxisTickSpacing", val);
            atts->Notify();
            emit multiCurveChanged(atts);
        }
    }
}
void
QvisAppearanceWidget::useYAxisTickSpacingChanged(bool val)
{
    if (val)
        yAxisTickSpacing->setEnabled(true);
    else
        yAxisTickSpacing->setEnabled(false);

    int MultiCurve = viewer->GetPlotIndex("MultiCurve");
    AttributeSubject *atts = viewer->DelayedState()->GetPlotAttributes(MultiCurve);
    if(atts != 0)
    {
        atts->SetValue("useYAxisTickSpacing", val);
        atts->Notify();
        emit multiCurveChanged(atts);
    }
}
Exemple #11
0
    virtual void Work()
    {
        // Open a database
        GetViewerMethods()->InvertBackgroundColor();
        GetViewerMethods()->OpenDatabase("/usr/gapps/visit/data/noise.silo");
        Synchronize();

        // Create a plot and draw it.
        int plotType = PlotIndex("Pseudocolor");
        if(plotType != INVALID_PLUGIN_INDEX)
        {
            debug1 << "Plot type = " << plotType << endl;
            GetViewerMethods()->AddPlot(plotType, "hardyglobal");
      
            int threeSlice = OperatorIndex("ThreeSlice");
            if(threeSlice != INVALID_PLUGIN_INDEX)
                GetViewerMethods()->AddOperator(threeSlice);
            GetViewerMethods()->DrawPlots();
        }
        Synchronize();

        // Save an image.
        GetViewerMethods()->SaveWindow();

        // Set some pseudocolor plot attributes using the base class'
        // SetValue methods.
        AttributeSubject *pcAtts = GetViewerState()->GetPlotAttributes(plotType);
        if(pcAtts != 0)
        {
            pcAtts->SetValue("min", 1.5);
            pcAtts->SetValue("minFlag", true);
            pcAtts->SetValue("max", 4.5);
            pcAtts->SetValue("maxFlag", true);
            pcAtts->SetValue("colorTableName", "calewhite");
            pcAtts->Notify();
            GetViewerMethods()->SetPlotOptions(plotType);
        }

        // Save an image.
        GetViewerMethods()->SaveWindow();

        // Enter an event loop so the program keeps running and we can
        // interact with the viewer.
        EventLoop();
    }
void ViewerOperatorFactory::SetClientAttsFromDefault(const int type)
{
    //
    // Check that the type is within range and that the type has been
    // registered.
    //
    if (type < 0 || type >= nTypes)
    {
        return;
    }

    //
    // Copy the attributes.
    //
    AttributeSubject *clientAtts  = viewerPluginInfo[type]->GetClientAtts();
    AttributeSubject *defaultAtts = viewerPluginInfo[type]->GetDefaultAtts();

    viewerPluginInfo[type]->CopyAttributes(clientAtts, defaultAtts);
    clientAtts->Notify();
}
void
QvisPostableWindowObserver::loadSubject()
{
    if (!subject)
        return;

    QString filename = QFileDialog::getOpenFileName(this,
                                                    tr("Open Attribute XML"),
                                                    NULL,
                                                    tr("XML Files (*.xml);;"
                                                       "All files (*)"));
    if (filename.isNull())
        return;
    
    AttributeSubject *as = (AttributeSubject *)subject;
    SingleAttributeConfigManager mgr(as);
    mgr.Import(filename.toStdString());
    as->SelectAll();
    as->Notify();
}
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()));
}