예제 #1
1
QTabWidget* ResultsPage::createDataTabWidget()
{
    QTabWidget *tabWidget = new QTabWidget;

    // Plot
    m_plot = new QwtPlot(tabWidget);
    m_plot->setCanvasBackground(Qt::white);
    m_plot->setContextMenuPolicy(Qt::CustomContextMenu);
    m_plot->setAutoReplot(false);

    connect(m_plot, SIGNAL(customContextMenuRequested(QPoint)),
            this, SLOT(showPlotContextMenu(QPoint)));
    
    // Picker to allow for selection of the closest curve and displays curve
    // coordinates with a cross rubber band.
    QwtPlotPicker *picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
                                              QwtPicker::CrossRubberBand, QwtPicker::ActiveOnly,
                                              m_plot->canvas());
    picker->setStateMachine(new QwtPickerDragPointMachine());

    connect(picker, SIGNAL(appended(QPoint)), this, SLOT(pointSelected(QPoint)));

    // Legend
    QwtLegend* legend = new QwtLegend;
    legend->setFrameStyle(QFrame::Box | QFrame::Sunken);
    m_plot->insertLegend(legend, QwtPlot::BottomLegend);
#if QWT_VERSION >= 0x060100
    connect(m_plot,
            SIGNAL(legendDataChanged(QVariant,QList<QwtLegendData>)),
            legend,
            SLOT(updateLegend(QVariant,QList<QwtLegendData>)));
#endif

    // Add the generic curves to the legend
    QList<QPair<QString, Qt::GlobalColor> > pairs;
    pairs << qMakePair(tr("Unselected Realization"), Qt::darkGray)
          << qMakePair(tr("Selected and Enabled Realization"), Qt::darkGreen)
          << qMakePair(tr("Selected and Disabled Realization"), Qt::darkRed);

    QPair<QString, Qt::GlobalColor> pair;
    foreach (pair, pairs) {
        QwtPlotCurve *curve = new QwtPlotCurve(pair.first);

        curve->setLegendIconSize(QSize(32, 8));
        curve->setPen(QPen(QBrush(pair.second), 2));
        curve->setLegendAttribute(QwtPlotCurve::LegendShowLine);
#if QWT_VERSION < 0x060100
        curve->updateLegend(legend);
#else
        m_plot->updateLegend(curve);
#endif
    }
예제 #2
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
RimLegendConfig::RimLegendConfig() 
    :   m_globalAutoMax(cvf::UNDEFINED_DOUBLE),
        m_globalAutoMin(cvf::UNDEFINED_DOUBLE),
        m_localAutoMax(cvf::UNDEFINED_DOUBLE),
        m_localAutoMin(cvf::UNDEFINED_DOUBLE)
{
    CAF_PDM_InitObject("Legend Definition", ":/Legend.png", "", "");
    CAF_PDM_InitField(&m_numLevels, "NumberOfLevels", 8, "Number of levels", "", "","");
    CAF_PDM_InitField(&m_precision, "Precision", 6, "Precision", "", "","");
    CAF_PDM_InitField(&m_colorRangeMode, "ColorRangeMode", ColorRangeEnum(NORMAL) , "Color range", "", "", "");
    CAF_PDM_InitField(&m_mappingMode, "MappingMode", MappingEnum(LINEAR_CONTINUOUS) , "Mapping", "", "", "");
    CAF_PDM_InitField(&m_rangeMode, "RangeType", caf::AppEnum<RimLegendConfig::RangeModeType>(AUTOMATIC_ALLTIMESTEPS), "Legend range type", "", "Switches between automatic and user defined range on the legend", "");
    CAF_PDM_InitField(&m_userDefinedMaxValue, "UserDefinedMax", 1.0, "Max", "", "Min value of the legend", "");
    CAF_PDM_InitField(&m_userDefinedMinValue, "UserDefinedMin", 0.0, "Min", "", "Max value of the legend", "");
    CAF_PDM_InitField(&resultVariableName, "ResultVariableUsage", QString(""), "", "", "", "");
    resultVariableName.setUiHidden(true);

    m_linDiscreteScalarMapper = new cvf::ScalarMapperDiscreteLinear;
    m_logDiscreteScalarMapper = new cvf::ScalarMapperDiscreteLog;
    m_linSmoothScalarMapper = new cvf::ScalarMapperContinuousLinear;
    m_logSmoothScalarMapper = new cvf::ScalarMapperContinuousLog;

    m_currentScalarMapper = m_linDiscreteScalarMapper;


    cvf::FixedAtlasFont* font = new cvf::FixedAtlasFont(cvf::FixedAtlasFont::STANDARD);
    m_legend = new cvf::OverlayScalarMapperLegend(font);
    m_position = cvf::Vec2ui(20, 50);

    updateFieldVisibility();
    updateLegend();
}
예제 #3
0
TimeAnalysisWidget::TimeAnalysisWidget(QWidget *parent) :
    QWidget(parent),
    _ui(new Ui::TimeAnalysisWidget)
{
    _ui->setupUi(this);
    _ui->legendGroupBox->setLayout(new QFormLayout);

    // read data
    loadLowAndHighData(std::string(DATA_DIR) + "perDay.low");
    //
    initTransitionGraphs();

    //
    _ui->projectionWidget->setMainUI(this);
    _ui->projectionWidget->setRadiusFactor(_ui->radiusSlider->value());
    _ui->projectionWidget->setOpacity(_ui->opacitySlider->value());

    // Autoexclude the Selection Modes
    QButtonGroup *buttonGroup = new QButtonGroup;
    buttonGroup->addButton(_ui->singleSelection, 0);
    buttonGroup->addButton(_ui->groupSelection, 1);
    connect(buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(selectionModeChanges(int)));

    //
    fillScalarComboBox();
    _selectedScalar = _scalars[0];
    _ui->colorByComboBox->setCurrentIndex(_selectedScalar->index());

    connect(_ui->colorByComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changeSelectedScalar(int)));
    connect(_ui->projectionWidget,SIGNAL(selectionChanged(QList<int>)), _ui->calendarWidget,SLOT(updateSelectedDays(QList<int>)));
    connect(_ui->projectionWidget,SIGNAL(selectionChanged(QList<int>)), _ui->graphWidget,SLOT(updateSelectedDays(QList<int>)));
    connect(_ui->calendarWidget, SIGNAL(changedSelectedDays(QList<int>)), _ui->projectionWidget, SLOT(updateSelectedPoints(QList<int>)));

    updateLegend();
}
예제 #4
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
    if (changedField == &m_numLevels)
    {
        int upperLimit = std::numeric_limits<int>::max();
        m_numLevels = cvf::Math::clamp(m_numLevels.v(), 1, upperLimit);
    }
    else if (changedField == &m_rangeMode)
    {
        if (m_rangeMode == USER_DEFINED)
        {
            if (m_userDefinedMaxValue == m_userDefinedMaxValue.defaultValue() && m_globalAutoMax != cvf::UNDEFINED_DOUBLE)
            {
                m_userDefinedMaxValue = roundToNumSignificantDigits(m_globalAutoMax, m_precision);
            }
            if (m_userDefinedMinValue == m_userDefinedMinValue.defaultValue() && m_globalAutoMin != cvf::UNDEFINED_DOUBLE)
            {   
                m_userDefinedMinValue = roundToNumSignificantDigits(m_globalAutoMin, m_precision);
            }
        }

        updateFieldVisibility();
    }

    updateLegend();

    if (m_reservoirView) m_reservoirView->updateCurrentTimeStepAndRedraw();
}
예제 #5
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimLegendConfig::setIntegerCategories(const std::vector<int>& categories)
{
    m_categories = categories;
    m_categoryNames.clear();

    updateLegend();
}
예제 #6
0
void LegendProxy::newUpdateAttr(QList<QColor> colors, QList<qreal> widths)
{
	for (int i=0; i<mElements.size(); ++i)
	{
		mElements[i].setElementColor1(colors[i]);
		mElements[i].setElementSize(widths[i]);
	}
	updateLegend();
}
//! Call QwtPlot::autoRefresh for the parent plot
void QwtPlotItem::itemChanged()
{
    if ( d_data->plot )
    {
        if ( d_data->plot->legend() )
            updateLegend(d_data->plot->legend());

        d_data->plot->autoRefresh();
    }
}
예제 #8
0
void LegendProxy::newUpdateAttr(QList<QColor> colorList1, QList<QColor> colorList2, QList<qreal> sizeList)
{
	for (int i=0; i<mElements.size(); ++i)
	{
		mElements[i].setElementColor1(colorList1[i]);
		mElements[i].setElementColor2(colorList2[i]);
		mElements[i].setElementSize(sizeList[i]);
	}
	updateLegend();
}
void EnvelopeHandleComponent::mouseEnter(const MouseEvent& e)
{
	(void)e;
#ifdef MYDEBUG
	printf("MyEnvelopeHandleComponent::mouseEnter\n");
#endif
	
	setMouseCursor(MouseCursor::CrosshairCursor);	
	updateLegend();
}
예제 #10
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimLegendConfig::setAutomaticRanges(double globalMin, double globalMax, double localMin, double localMax)
{
    m_globalAutoMin = adjust(globalMin, m_precision);
    m_globalAutoMax = adjust(globalMax, m_precision);

    m_localAutoMin = adjust(localMin, m_precision);
    m_localAutoMax = adjust(localMax, m_precision);

    updateLegend();
}
예제 #11
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimLegendConfig::recreateLegend()
{
    // Due to possible visualization bug, we need to recreate the legend if the last viewer 
    // has been removed, (and thus the opengl resources has been deleted) The text in 
    // the legend disappeared because of this, so workaround: recreate the legend when needed:

    cvf::Font* standardFont = RiaApplication::instance()->standardFont();
    m_legend = new cvf::OverlayScalarMapperLegend(standardFont);

    updateLegend();
}
예제 #12
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimLegendConfig::recreateLegend()
{
    // Due to possible visualization bug, we need to recreate the legend if the last viewer 
    // has been removed, (and thus the opengl resources has been deleted) The text in 
    // the legend disappeared because of this, so workaround: recreate the legend when needed:

    cvf::FixedAtlasFont* font = new cvf::FixedAtlasFont(cvf::FixedAtlasFont::STANDARD);
    m_legend = new cvf::OverlayScalarMapperLegend(font);

    updateLegend();
}
예제 #13
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimTernaryLegendConfig::recreateLegend()
{
    // Due to possible visualization bug, we need to recreate the legend if the last viewer 
    // has been removed, (and thus the opengl resources has been deleted) The text in 
    // the legend disappeared because of this, so workaround: recreate the legend when needed:

    cvf::Font* standardFont = RiaApplication::instance()->standardFont();
    m_legend = new RivTernarySaturationOverlayItem(standardFont);
    m_legend->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_LEFT);

    updateLegend();
}
예제 #14
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
RimTernaryLegendConfig::RimTernaryLegendConfig() 
{
    CAF_PDM_InitObject("Ternary Legend Definition", ":/Legend.png", "", "");

    CAF_PDM_InitField(&precision, "Precision", 2, "Significant digits", "", "The number of significant digits displayed in the legend numbers","");
    CAF_PDM_InitField(&rangeMode, "RangeType", RangeModeEnum(USER_DEFINED), "Range type", "", "Switches between automatic and user defined range on the legend", "");

    CAF_PDM_InitFieldNoDefault(&applyLocalMinMax,   "m_applyLocalMinMax", "", "", "", "");
    applyLocalMinMax.setIOWritable(false);
    applyLocalMinMax.setIOReadable(false);
    applyLocalMinMax.setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName());
    applyLocalMinMax.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
    applyLocalMinMax = false;

    CAF_PDM_InitFieldNoDefault(&applyGlobalMinMax,   "m_applyGlobalMinMax", "", "", "", "");
    applyGlobalMinMax.setIOWritable(false);
    applyGlobalMinMax.setIOReadable(false);
    applyGlobalMinMax.setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName());
    applyGlobalMinMax.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
    applyGlobalMinMax = false;

    CAF_PDM_InitFieldNoDefault(&applyFullRangeMinMax,   "m_applyFullRangeMinMax", "", "", "", "");
    applyFullRangeMinMax.setIOWritable(false);
    applyFullRangeMinMax.setIOReadable(false);
    applyFullRangeMinMax.setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName());
    applyFullRangeMinMax.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
    applyFullRangeMinMax = false;

    CAF_PDM_InitFieldNoDefault(&ternaryRangeSummary,        "ternaryRangeSummary", "Range summary", "", "", "");
    ternaryRangeSummary.setUiEditorTypeName(caf::PdmUiTextEditor::uiEditorTypeName());
    ternaryRangeSummary.setUiLabelPosition(caf::PdmUiItemInfo::TOP);


    CAF_PDM_InitField(&userDefinedMaxValueSoil, "UserDefinedMaxSoil", 1.0, "Max", "", "Min value of the legend", "");
    CAF_PDM_InitField(&userDefinedMinValueSoil, "UserDefinedMinSoil", 0.0, "Min", "", "Max value of the legend", "");

    CAF_PDM_InitField(&userDefinedMaxValueSgas, "UserDefinedMaxSgas", 1.0, "Max", "", "Min value of the legend", "");
    CAF_PDM_InitField(&userDefinedMinValueSgas, "UserDefinedMinSgas", 0.0, "Min", "", "Max value of the legend", "");

    CAF_PDM_InitField(&userDefinedMaxValueSwat, "UserDefinedMaxSwat", 1.0, "Max", "", "Min value of the legend", "");
    CAF_PDM_InitField(&userDefinedMinValueSwat, "UserDefinedMinSwat", 0.0, "Min", "", "Max value of the legend", "");

    m_globalAutoMin.resize(3, 0.0);
    m_globalAutoMax.resize(3, 1.0);
    m_localAutoMin.resize(3, 0.0);
    m_localAutoMax.resize(3, 1.0);

    recreateLegend();
    updateLegend();
}
예제 #15
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimLegendConfig::setNamedCategoriesInverse(const std::vector<QString>& categoryNames)
{
    std::vector<int> nameIndices;
    std::vector<cvf::String> names;
    for(int i =  static_cast<int>(categoryNames.size()) - 1; i >= 0; --i)
    {
        nameIndices.push_back(i);
        names.push_back(cvfqt::Utils::toString(categoryNames[i]));
    }
    
    m_categories = nameIndices;
    m_categoryNames = names;

    updateLegend();
}
void EnvelopeHandleComponent::mouseDrag(const MouseEvent& e)
{
	if(ignoreDrag == true) return;
	
	if(e.mods.isAltDown()) {

		int moveX = e.x-offsetX;
		int moveY = offsetY-e.y;
		
		offsetTimeAndValue(moveX * FINETUNE, moveY * FINETUNE, FINETUNE);
		ignoreDrag = true;
		setMousePositionToThisHandle();
		ignoreDrag = false;
		
	} else {
				
		dragger.dragComponent(this, e, &resizeLimits);
	}
	
	updateLegend();
	getParentComponent()->repaint();
	getParentComponent()->sendChangeMessage();
	
	if(lastX == getX() && lastY == getY()) {	
		setMousePositionToThisHandle();
#ifdef MYDEBUG
		int x, y;
		Desktop::getMousePosition(x, y);	
		printf("screen pos (and mouse pos): %d (%d) %d (%d)\n", getScreenX(), x, getScreenY(), y);
#endif	
	}

	lastX = getX();
	lastY = getY();
	
#ifdef MYDEBUG
	double domain = getParentComponent()->convertPixelsToDomain(getX());
	double value = getParentComponent()->convertPixelsToValue(getY());
	printf("MyEnvelopeHandleComponent::mouseDrag(%d, %d) [%f, %f] (%d, %d)\n", e.x, e.y, 
		   domain,
		   value,
		   getParentComponent()->convertDomainToPixels(domain),
		   getParentComponent()->convertValueToPixels(value));
#endif
	
}
예제 #17
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimLegendConfig::setAutomaticRanges(double globalMin, double globalMax, double localMin, double localMax)
{
    double candidateGlobalAutoMin = roundToNumSignificantDigits(globalMin, m_precision);
    double candidateGlobalAutoMax = roundToNumSignificantDigits(globalMax, m_precision);

    double candidateLocalAutoMin = roundToNumSignificantDigits(localMin, m_precision);
    double candidateLocalAutoMax = roundToNumSignificantDigits(localMax, m_precision);

    bool needsUpdate = false;
    const double epsilon = std::numeric_limits<double>::epsilon();
    
    if (cvf::Math::abs(candidateGlobalAutoMax - m_globalAutoMax) > epsilon)
    {
        needsUpdate = true;
    }

    if (cvf::Math::abs(candidateGlobalAutoMin - m_globalAutoMin) > epsilon)
    {
        needsUpdate = true;
    }

    if (cvf::Math::abs(candidateLocalAutoMax - m_localAutoMax) > epsilon)
    {
        needsUpdate = true;
    }

    if (cvf::Math::abs(candidateLocalAutoMin - m_localAutoMin) > epsilon)
    {
        needsUpdate = true;
    }

    if (needsUpdate)
    {
        m_globalAutoMin = candidateGlobalAutoMin;
        m_globalAutoMax = candidateGlobalAutoMax;

        m_localAutoMin = candidateLocalAutoMin;
        m_localAutoMax = candidateLocalAutoMax;

        updateLegend();
    }
}
예제 #18
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimTernaryLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
    if (changedField == &applyLocalMinMax)
    {
        userDefinedMaxValueSoil = m_localAutoMax[TERNARY_SOIL_IDX];
        userDefinedMinValueSoil = m_localAutoMin[TERNARY_SOIL_IDX];
        userDefinedMaxValueSgas = m_localAutoMax[TERNARY_SGAS_IDX];
        userDefinedMinValueSgas = m_localAutoMin[TERNARY_SGAS_IDX];
        userDefinedMaxValueSwat = m_localAutoMax[TERNARY_SWAT_IDX];
        userDefinedMinValueSwat = m_localAutoMin[TERNARY_SWAT_IDX];
        
        applyLocalMinMax = false;
    }
    else if (changedField == &applyGlobalMinMax)
    {
        userDefinedMaxValueSoil = m_globalAutoMax[TERNARY_SOIL_IDX];
        userDefinedMinValueSoil = m_globalAutoMin[TERNARY_SOIL_IDX];
        userDefinedMaxValueSgas = m_globalAutoMax[TERNARY_SGAS_IDX];
        userDefinedMinValueSgas = m_globalAutoMin[TERNARY_SGAS_IDX];
        userDefinedMaxValueSwat = m_globalAutoMax[TERNARY_SWAT_IDX];
        userDefinedMinValueSwat = m_globalAutoMin[TERNARY_SWAT_IDX];

        applyGlobalMinMax = false;
    }
    else if (changedField == &applyFullRangeMinMax)
    {
        userDefinedMaxValueSoil = 1.0;
        userDefinedMinValueSoil = 0.0;
        userDefinedMaxValueSgas = 1.0;
        userDefinedMinValueSgas = 0.0;
        userDefinedMaxValueSwat = 1.0;
        userDefinedMinValueSwat = 0.0;

        applyFullRangeMinMax = false;
    }

    updateLabelText();
    updateLegend();

    if (m_reservoirView) m_reservoirView->updateCurrentTimeStepAndRedraw();
}
예제 #19
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
RimLegendConfig::RimLegendConfig() 
    :   m_globalAutoMax(cvf::UNDEFINED_DOUBLE),
        m_globalAutoMin(cvf::UNDEFINED_DOUBLE),
        m_localAutoMax(cvf::UNDEFINED_DOUBLE),
        m_localAutoMin(cvf::UNDEFINED_DOUBLE),
        m_globalAutoPosClosestToZero(0),
        m_globalAutoNegClosestToZero(0),
        m_localAutoPosClosestToZero(0),
        m_localAutoNegClosestToZero(0)
{
    CAF_PDM_InitObject("Legend Definition", ":/Legend.png", "", "");
    CAF_PDM_InitField(&m_numLevels, "NumberOfLevels", 8, "Number of levels", "", "A hint on how many tick marks you whish.","");
    CAF_PDM_InitField(&m_precision, "Precision", 4, "Significant digits", "", "The number of significant digits displayed in the legend numbers","");
    CAF_PDM_InitField(&m_tickNumberFormat, "TickNumberFormat", caf::AppEnum<RimLegendConfig::NumberFormatType>(FIXED), "Number format", "", "","");

    CAF_PDM_InitField(&m_colorRangeMode, "ColorRangeMode", ColorRangeEnum(NORMAL) , "Colors", "", "", "");
    CAF_PDM_InitField(&m_mappingMode, "MappingMode", MappingEnum(LINEAR_CONTINUOUS) , "Mapping", "", "", "");
    CAF_PDM_InitField(&m_rangeMode, "RangeType", RangeModeEnum(AUTOMATIC_ALLTIMESTEPS), "Range type", "", "Switches between automatic and user defined range on the legend", "");
    CAF_PDM_InitField(&m_userDefinedMaxValue, "UserDefinedMax", 1.0, "Max", "", "Min value of the legend", "");
    CAF_PDM_InitField(&m_userDefinedMinValue, "UserDefinedMin", 0.0, "Min", "", "Max value of the legend", "");
    CAF_PDM_InitField(&resultVariableName, "ResultVariableUsage", QString(""), "", "", "", "");
    resultVariableName.uiCapability()->setUiHidden(true);

    m_linDiscreteScalarMapper = new cvf::ScalarMapperDiscreteLinear;
    m_logDiscreteScalarMapper = new cvf::ScalarMapperDiscreteLog;
    m_linSmoothScalarMapper = new cvf::ScalarMapperContinuousLinear;
    m_logSmoothScalarMapper = new cvf::ScalarMapperContinuousLog;

    m_currentScalarMapper = m_linDiscreteScalarMapper;

    m_categoryMapper = new caf::CategoryMapper;

    cvf::Font* standardFont = RiaApplication::instance()->standardFont();
    m_scalarMapperLegend = new cvf::OverlayScalarMapperLegend(standardFont);
    m_categoryLegend = new caf::CategoryLegend(standardFont, m_categoryMapper.p());

    updateFieldVisibility();
    updateLegend();
}
예제 #20
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimLegendConfig::setClosestToZeroValues(double globalPosClosestToZero, double globalNegClosestToZero, double localPosClosestToZero, double localNegClosestToZero)
{
    bool needsUpdate = false;
    const double epsilon = std::numeric_limits<double>::epsilon();

    if (cvf::Math::abs(globalPosClosestToZero - m_globalAutoPosClosestToZero) > epsilon)
    {
        needsUpdate = true;
    }
    if (cvf::Math::abs(globalNegClosestToZero - m_globalAutoNegClosestToZero) > epsilon)
    {
        needsUpdate = true;
    }
    if (cvf::Math::abs(localPosClosestToZero - m_localAutoPosClosestToZero) > epsilon)
    {
        needsUpdate = true;
    }
    if (cvf::Math::abs(localNegClosestToZero - m_localAutoNegClosestToZero) > epsilon)
    {
        needsUpdate = true;
    }

    if (needsUpdate)
    {
        m_globalAutoPosClosestToZero = globalPosClosestToZero;
        m_globalAutoNegClosestToZero = globalNegClosestToZero;
        m_localAutoPosClosestToZero = localPosClosestToZero;
        m_localAutoNegClosestToZero = localNegClosestToZero;

        if (m_globalAutoPosClosestToZero == HUGE_VAL) m_globalAutoPosClosestToZero = 0;
        if (m_globalAutoNegClosestToZero == -HUGE_VAL) m_globalAutoNegClosestToZero = 0; 
        if (m_localAutoPosClosestToZero == HUGE_VAL) m_localAutoPosClosestToZero = 0;
        if (m_localAutoNegClosestToZero == -HUGE_VAL) m_localAutoNegClosestToZero = 0;

        updateLegend();
    }
}
예제 #21
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimLegendConfig::setColorRangeMode(ColorRangesType colorMode)
{
    m_colorRangeMode = colorMode;
    updateLegend();
}
예제 #22
0
/*!
  \brief Insert a legend

  If the position legend is \c QwtPlot::LeftLegend or \c QwtPlot::RightLegend
  the legend will be organized in one column from top to down.
  Otherwise the legend items will be placed in a table
  with a best fit number of columns from left to right.

  insertLegend() will set the plot widget as parent for the legend.
  The legend will be deleted in the destructor of the plot or when 
  another legend is inserted.

  Legends, that are not inserted into the layout of the plot widget
  need to connect to the legendDataChanged() signal. Calling updateLegend()
  initiates this signal for an initial update. When the application code
  wants to implement its own layout this also needs to be done for
  rendering plots to a document ( see QwtPlotRenderer ).

  \param legend Legend
  \param pos The legend's position. For top/left position the number
             of columns will be limited to 1, otherwise it will be set to
             unlimited.

  \param ratio Ratio between legend and the bounding rectangle
               of title, canvas and axes. The legend will be shrunk
               if it would need more space than the given ratio.
               The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0
               it will be reset to the default ratio.
               The default vertical/horizontal ratio is 0.33/0.5.

  \sa legend(), QwtPlotLayout::legendPosition(),
      QwtPlotLayout::setLegendPosition()
*/
void QwtPlot::insertLegend( QwtAbstractLegend *legend,
    QwtPlot::LegendPosition pos, double ratio )
{
    d_data->layout->setLegendPosition( pos, ratio );

    if ( legend != d_data->legend )
    {
        if ( d_data->legend && d_data->legend->parent() == this )
            delete d_data->legend;

        d_data->legend = legend;

        if ( d_data->legend )
        {
            connect( this, 
                SIGNAL( legendDataChanged( 
                    const QVariant &, const QList<QwtLegendData> & ) ),
                d_data->legend, 
                SLOT( updateLegend( 
                    const QVariant &, const QList<QwtLegendData> & ) ) 
            );

            if ( d_data->legend->parent() != this )
                d_data->legend->setParent( this );

            qwtEnableLegendItems( this, false );
            updateLegend();
            qwtEnableLegendItems( this, true );

            QwtLegend *lgd = qobject_cast<QwtLegend *>( legend );
            if ( lgd )
            {
                switch ( d_data->layout->legendPosition() )
                {
                    case LeftLegend:
                    case RightLegend:
                    {
                        if ( lgd->maxColumns() == 0     )
                            lgd->setMaxColumns( 1 ); // 1 column: align vertical
                        break;
                    }
                    case TopLegend:
                    case BottomLegend:
                    {
                        lgd->setMaxColumns( 0 ); // unlimited
                        break;
                    }
                    default:
                        break;
                }
            }

            QWidget *previousInChain = NULL;
            switch ( d_data->layout->legendPosition() )
            {
                case LeftLegend:
                {
                    previousInChain = axisWidget( QwtPlot::xTop );
                    break;
                }
                case TopLegend:
                {
                    previousInChain = this;
                    break;
                }
                case RightLegend:
                {
                    previousInChain = axisWidget( QwtPlot::yRight );
                    break;
                }
                case BottomLegend:
                {
                    previousInChain = footerLabel();
                    break;
                }
            }

            if ( previousInChain )
                qwtSetTabOrder( previousInChain, legend, true );
        }
    }
예제 #23
0
파일: Plot.cpp 프로젝트: hsoerensen/qctools
//---------------------------------------------------------------------------
Plot::Plot( size_t streamPos, size_t Type, size_t Group, QWidget *parent ) :
    QwtPlot( parent ),
    m_streamPos( streamPos ),
    m_type( Type ),
    m_group( Group )
{
    setAutoReplot( false );

    QwtPlotCanvas* canvas = dynamic_cast<QwtPlotCanvas*>( this->canvas() );
    if ( canvas )
    {
        canvas->setFrameStyle( QFrame::Plain | QFrame::Panel );
        canvas->setLineWidth( 1 );
#if 1
        canvas->setPalette( QColor("Cornsilk") );
#endif
    }

    setAxisMaxMajor( QwtPlot::yLeft, 0 );
    setAxisMaxMinor( QwtPlot::yLeft, 0 );
    setAxisScaleDraw( QwtPlot::yLeft, new PlotScaleDrawY() );

    enableAxis( QwtPlot::xBottom, false );

    // something invalid
    setAxisScale( QwtPlot::xBottom, -1, 0 );
    setAxisScale( QwtPlot::yLeft, -1, 0 );

    // Plot grid
    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->enableXMin( true );
    grid->enableYMin( true );
    grid->setMajorPen( Qt::darkGray, 0, Qt::DotLine );
    grid->setMinorPen( Qt::gray, 0 , Qt::DotLine );
    grid->attach( this );

    m_cursor = new PlotCursor( canvas );
    m_cursor->setPosition( 0 );

    // curves

    for( unsigned j = 0; j < PerStreamType[m_type].PerGroup[m_group].Count; ++j )
    {
        QwtPlotCurve* curve = new QwtPlotCurve( PerStreamType[m_type].PerItem[PerStreamType[m_type].PerGroup[m_group].Start + j].Name );

        curve->setPen( curveColor( j ) );
        curve->setRenderHint( QwtPlotItem::RenderAntialiased );
        curve->setZ( curve->z() - j ); //Invert data order (e.g. MAX before MIN)
        curve->attach( this );

        m_curves += curve;
    }

    // visual helpers
    if ( m_type == Type_Video )
    switch (m_group)
    {
        case Group_Y :
                        Plot_AddHLine( this,  16,  61,  89, 171);
                        Plot_AddHLine( this, 235, 220,  20,  60);
                        break;
        case Group_U :
        case Group_V :
                        Plot_AddHLine( this,  16,  61,  89, 171);
                        Plot_AddHLine( this, 240, 220,  20,  60);
                        break;
        case Group_Sat :
                        Plot_AddHLine( this,  88, 255,   0, 255);
                        Plot_AddHLine( this, 118, 220,  20,  60);
                        break;
        default      :  ;  
    }

    PlotPicker* picker = new PlotPicker( canvas, &PerStreamType[m_type], m_group, &m_curves );
    connect( picker, SIGNAL( moved( const QPointF& ) ), SLOT( onPickerMoved( const QPointF& ) ) );
    connect( picker, SIGNAL( selected( const QPointF& ) ), SLOT( onPickerMoved( const QPointF& ) ) );

    connect( axisWidget( QwtPlot::xBottom ), SIGNAL( scaleDivChanged() ), SLOT( onXScaleChanged() ) );

    // legend
    m_legend = new PlotLegend();
    
    connect( this, SIGNAL( legendDataChanged( const QVariant &, const QList<QwtLegendData> & ) ),
         m_legend, SLOT( updateLegend( const QVariant &, const QList<QwtLegendData> & ) ) );

    updateLegend();
}
예제 #24
0
void TimeAnalysisWidget::changeSelectedScalar(int index)
{
    _selectedScalar = _scalars[index];
    updateLegend();
    repaint();
}
예제 #25
0
void QgsComposerLegendWidget::on_mUpdateAllPushButton_clicked()
{
  updateLegend();
}
예제 #26
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimLegendConfig::setPosition(cvf::Vec2ui position)
{
    m_position = position;
    updateLegend();
}
예제 #27
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimLegendConfig::setMappingMode(MappingType mappingType)
{
    m_mappingMode = mappingType;
    updateLegend();
}