void medTimeLineToolBox::updateRange()
{
    if (!d->interactors.size())
        return;
    double mintime = 3000;
    double maxtime = -3000;
    double mintimestep = 3000;

    for (int i=0; i<d->interactors.size(); i++)
    {
        double range[2]= {0,0};
        d->interactors[i]->sequencesRange (range);
        mintimestep = std::min (mintimestep, d->interactors[i]->sequencesMinTimeStep ());
        mintime = std::min (mintime, range[0]);
        maxtime = std::max (maxtime, range[1]);
    }

    unsigned int numberofsteps = std::ceil ((maxtime - mintime) / (mintimestep) + 1.0);

    d->timeSlider->setRange (0, numberofsteps - 1);
    d->timeLine->setFrameRange(d->timeSlider->minimum(), d->timeSlider->maximum() );

    d->minTime = mintime;
    d->minTimeStep = mintimestep;
    d->maxTime = maxtime;

    d->timeLine->setDuration((maxtime+mintimestep)*1000);

    d->labelmin->setText( DoubleToQString(( mintime ) / (d->spinBox->value()/100.0)) + QString(" sec"));
    d->labelmax->setText( DoubleToQString(( maxtime ) / (d->spinBox->value()/100.0)) + QString(" sec"));
}
void
QvisSurfacePlotWindow::GetCurrentValues(int which_widget)
{
    bool doAll = (which_widget == -1);
    double val;

    // Do the skew factor.
    if(which_widget == SurfaceAttributes::ID_skewFactor || doAll)
    {
        if(LineEditGetDouble(skewLineEdit, val))
            surfaceAtts->SetSkewFactor(val);
        else
        {
            ResettingError("skew factor", 
                DoubleToQString(surfaceAtts->GetSkewFactor()));
            surfaceAtts->SetSkewFactor(surfaceAtts->GetSkewFactor());
        }
    }

    // Do the coloring minimum value.
    if(which_widget == SurfaceAttributes::ID_min || doAll)
    {
        if(LineEditGetDouble(minLineEdit, val))
            surfaceAtts->SetMin(val);
        else
        {
            ResettingError("minimum", 
                DoubleToQString(surfaceAtts->GetMin()));
            surfaceAtts->SetMin(surfaceAtts->GetMin());
        }
    }

    // Do the coloring maximum value.
    if(which_widget == SurfaceAttributes::ID_max || doAll)
    {
        if(LineEditGetDouble(maxLineEdit, val))
            surfaceAtts->SetMax(val);
        else
        {
            ResettingError("maximum", 
                DoubleToQString(surfaceAtts->GetMax()));
            surfaceAtts->SetMax(surfaceAtts->GetMax());
        }
    }
}
void medTimeLineToolBox::onTimeChanged (int val)
{
    double time = this->getTimeFromSliderValue (val);
    for (int i=0; i<d->interactors.size(); i++)
    {
        d->interactors[i]->setCurrentTime (time);
    }

    d->labelcurr->setText( DoubleToQString(( time ) / (d->spinBox->value()/100.0)) + QString(" sec") );
}
void
QvisTensorPlotWindow::GetCurrentValues(int which_widget)
{
    bool doAll = (which_widget == -1);
    QString msg, temp;

    // Do the scale value.
    if(which_widget == TensorAttributes::ID_scale || doAll)
    {
        double val;
        if(LineEditGetDouble(scaleLineEdit, val))
            tensorAtts->SetScale(val);
        else
        {
            ResettingError("scale value", 
                DoubleToQString(tensorAtts->GetScale()));
            tensorAtts->SetScale(tensorAtts->GetScale());
        }
    }

    // Do the N tensors value.
    if(which_widget == TensorAttributes::ID_nTensors || doAll)
    {
        int val;
        if(LineEditGetInt(nTensorsLineEdit, val))
            tensorAtts->SetNTensors(val);
        else
        {
            ResettingError("number of tensors",
                IntToQString(tensorAtts->GetNTensors()));
            tensorAtts->SetNTensors(tensorAtts->GetNTensors());
        }
    }

    // Do the stride value.
    if(which_widget == TensorAttributes::ID_stride || doAll)
    {
        int val;
        if(LineEditGetInt(strideLineEdit, val))
            tensorAtts->SetStride(val);
        else
        {
            ResettingError("stride", IntToQString(tensorAtts->GetStride()));
            tensorAtts->SetStride(tensorAtts->GetStride());
        }
    }
}
void
QvisSurfacePlotWindow::UpdateWindow(bool doAll)
{
    // Loop through all the attributes and do something for
    // each of them that changed. This function is only responsible
    // for displaying the state values and setting widget sensitivity.
    for(int i = 0; i < surfaceAtts->NumAttributes(); ++i)
    {
        if(!doAll)
        {
            if(!surfaceAtts->IsSelected(i))
            continue;
        }

        switch(i)
        {
        case SurfaceAttributes::ID_legendFlag:
            legendToggle->blockSignals(true);
            legendToggle->setChecked(surfaceAtts->GetLegendFlag());
            legendToggle->blockSignals(false);
            break;

        case SurfaceAttributes::ID_lightingFlag:
            lightingToggle->blockSignals(true);
            lightingToggle->setChecked(surfaceAtts->GetLightingFlag());
            lightingToggle->blockSignals(false);
            break;

        case SurfaceAttributes::ID_surfaceFlag:
            surfaceGroup->blockSignals(true);
            surfaceGroup->setChecked(surfaceAtts->GetSurfaceFlag());
            surfaceGroup->blockSignals(false);
            break;

        case SurfaceAttributes::ID_wireframeFlag:
            wireframeGroup->blockSignals(true);
            wireframeGroup->setChecked(surfaceAtts->GetWireframeFlag());
            wireframeGroup->blockSignals(false);
            break;

        case SurfaceAttributes::ID_limitsMode:
            limitsSelect->blockSignals(true);
            limitsSelect->setCurrentIndex(surfaceAtts->GetLimitsMode());
            limitsSelect->blockSignals(false);
            break;

        case SurfaceAttributes::ID_minFlag:
            minToggle->blockSignals(true);
            minToggle->setChecked(surfaceAtts->GetMinFlag());
            minLineEdit->setEnabled(surfaceAtts->GetMinFlag());
            minToggle->blockSignals(false);
            break;

        case SurfaceAttributes::ID_maxFlag:
            maxToggle->blockSignals(true);
            maxToggle->setChecked(surfaceAtts->GetMaxFlag());
            maxLineEdit->setEnabled(surfaceAtts->GetMaxFlag());
            maxToggle->blockSignals(false);
            break;

        case SurfaceAttributes::ID_colorByZFlag :
            colorModeButtons->button(surfaceAtts->GetColorByZFlag() ? 0:1)->setChecked(true);

            surfaceColor->setEnabled(!surfaceAtts->GetColorByZFlag());
            colorTableWidget->setEnabled(surfaceAtts->GetColorByZFlag());
            break;

        case SurfaceAttributes::ID_scaling:
            scalingButtons->button(surfaceAtts->GetScaling())->setChecked(true);
            skewLineEdit->setEnabled(surfaceAtts->GetScaling() ==
                SurfaceAttributes::Skew);
            break;

        case SurfaceAttributes::ID_lineStyle:
            lineStyle->blockSignals(true);
            lineStyle->SetLineStyle(surfaceAtts->GetLineStyle());
            lineStyle->blockSignals(false);
            break;

        case SurfaceAttributes::ID_lineWidth:
            lineWidth->blockSignals(true);
            lineWidth->SetLineWidth(surfaceAtts->GetLineWidth());
            lineWidth->blockSignals(false);
            break;

        case SurfaceAttributes::ID_surfaceColor:
            { // new scope
            QColor temp(surfaceAtts->GetSurfaceColor().Red(),
                        surfaceAtts->GetSurfaceColor().Green(),
                        surfaceAtts->GetSurfaceColor().Blue());
            surfaceColor->blockSignals(true);
            surfaceColor->setButtonColor(temp);
            surfaceColor->blockSignals(false);
            }
            break;

        case SurfaceAttributes::ID_wireframeColor:
            { // new scope
            QColor temp(surfaceAtts->GetWireframeColor().Red(),
                        surfaceAtts->GetWireframeColor().Green(),
                        surfaceAtts->GetWireframeColor().Blue());
            wireframeColor->blockSignals(true);
            wireframeColor->setButtonColor(temp);
            wireframeColor->blockSignals(false);
            }
            break;

        case SurfaceAttributes::ID_skewFactor:
            skewLineEdit->setText(DoubleToQString(surfaceAtts->GetSkewFactor()));
            break;

        case SurfaceAttributes::ID_min:
            minLineEdit->setText(DoubleToQString(surfaceAtts->GetMin()));
            break;

        case SurfaceAttributes::ID_max:
            maxLineEdit->setText(DoubleToQString(surfaceAtts->GetMax()));
            break;

        case SurfaceAttributes::ID_colorTableName:
            colorTableWidget->setColorTable(
                              surfaceAtts->GetColorTableName().c_str());
            break;
        case SurfaceAttributes::ID_invertColorTable:
            colorTableWidget->setInvertColorTable(
                              surfaceAtts->GetInvertColorTable());
            break;
        }

    } // end for
}
void
QvisLine3DInterface::GetCurrentValues(int which_widget)
{
    bool doAll = (which_widget == -1);
    
    if (doAll || which_widget == 0)
    {
        double v[3];
        if(LineEditGetDoubles(point1Edit, v, 3))
            annot->SetPosition(v);
        else
        {
            QString msg = tr("The start point must be specified as a 3D "
               " coordinate. Resetting to the last good value of %1.").
            arg(DoublesToQString(annot->GetPosition(), 3));
            Error(msg);
            annot->SetPosition(annot->GetPosition());
        }  
    }  
    if (doAll || which_widget == 1)
    {
        double v[3];
        if(LineEditGetDoubles(point2Edit, v, 3))
            annot->SetPosition2(v);
        else
        {
            QString msg = tr("The end point must be specified as a 3D "
               " coordinate. Resetting to the last good value of %1.").
            arg(DoublesToQString(annot->GetPosition2(), 3));
            Error(msg);
            annot->SetPosition2(annot->GetPosition2());
        }
    }  
    if (doAll || which_widget == 2)
    {
        double v;
        doubleVector dv = annot->GetDoubleVector1();
        if(LineEditGetDouble(arrow1Radius, v))
        {
            dv[0] = v;
            annot->SetDoubleVector1(dv);
        }
        else
        {
            QString msg = tr("The radius must be specified as a floating point "
               "value. Resetting to the last good value of %1.").
               arg(DoubleToQString(dv[0]));
            Error(msg);
            annot->SetDoubleVector1(dv);
        }
    }
    if (doAll || which_widget == 3)
    {
        double v;
        doubleVector dv = annot->GetDoubleVector1();
        if(LineEditGetDouble(arrow2Radius, v))
        {
            dv[1] = v;
            annot->SetDoubleVector1(dv);
        }
        else
        {
            QString msg = tr("The radius must be specified as a floating point "
               "value. Resetting to the last good value of %1.").
               arg(DoubleToQString(dv[1]));
            Error(msg);
            annot->SetDoubleVector1(dv);
        }
    }
    if (doAll || which_widget == 4)
    {
        double v;
        doubleVector dv = annot->GetDoubleVector1();
        if(LineEditGetDouble(tubeRadius, v))
        {
            dv[3] = v;
            annot->SetDoubleVector1(dv);
        }
        else
        {
            QString msg = tr("The radius must be specified as a floating point "
               "value. Resetting to the last good value of %1.").
               arg(DoubleToQString(dv[3]));
            Error(msg);
            annot->SetDoubleVector1(dv);
        }
    }
}
void
QvisTensorPlotWindow::UpdateWindow(bool doAll)
{
    // Loop through all the attributes and do something for
    // each of them that changed. This function is only responsible
    // for displaying the state values and setting widget sensitivity.
    for(int i = 0; i < tensorAtts->NumAttributes(); ++i)
    {
        if(!doAll)
        {
            if(!tensorAtts->IsSelected(i))
                continue;
        }

        switch(i)
        {
        case TensorAttributes::ID_useStride:
            reduceButtonGroup->blockSignals(true);
            reduceButtonGroup->button(tensorAtts->GetUseStride()?1:0)->setChecked(true);
            reduceButtonGroup->blockSignals(false);

            nTensorsLineEdit->setEnabled(!tensorAtts->GetUseStride());
            strideLineEdit->setEnabled(tensorAtts->GetUseStride());
            break;
        case TensorAttributes::ID_stride:
            strideLineEdit->setText(IntToQString(tensorAtts->GetStride()));
            break;
        case TensorAttributes::ID_nTensors:
            nTensorsLineEdit->setText(IntToQString(tensorAtts->GetNTensors()));
            break;
        case TensorAttributes::ID_scale:
            scaleLineEdit->setText(DoubleToQString(tensorAtts->GetScale()));
            break;
        case TensorAttributes::ID_scaleByMagnitude:
            scaleByMagnitudeToggle->blockSignals(true);
            scaleByMagnitudeToggle->setChecked(tensorAtts->GetScaleByMagnitude());
            scaleByMagnitudeToggle->blockSignals(false);
            break;
        case TensorAttributes::ID_autoScale:
            autoScaleToggle->blockSignals(true);
            autoScaleToggle->setChecked(tensorAtts->GetAutoScale());
            autoScaleToggle->blockSignals(false);
            break;
        case TensorAttributes::ID_colorByEigenvalues:
            colorButtonGroup->blockSignals(true);
            colorButtonGroup->button(tensorAtts->GetColorByEigenvalues() ? 0 : 1)->setChecked(true);
            colorButtonGroup->blockSignals(false);
            break;
        case TensorAttributes::ID_useLegend:
            legendToggle->blockSignals(true);
            legendToggle->setChecked(tensorAtts->GetUseLegend());
            legendToggle->blockSignals(false);
            break;
        case TensorAttributes::ID_tensorColor:
            { // new scope
            QColor temp(tensorAtts->GetTensorColor().Red(),
                        tensorAtts->GetTensorColor().Green(),
                        tensorAtts->GetTensorColor().Blue());
            tensorColor->blockSignals(true);
            tensorColor->setButtonColor(temp);
            tensorColor->blockSignals(false);
            }
            break;
        case TensorAttributes::ID_colorTableName:
            colorTableWidget->setColorTable(tensorAtts->GetColorTableName().c_str());
            break;
        case TensorAttributes::ID_invertColorTable:
            colorTableWidget->setInvertColorTable(tensorAtts->GetInvertColorTable());
            break;
        }
    } // end for
}