mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3103 Manual tick marker setting
This commit is contained in:
@@ -18,6 +18,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuProjectPropertyView.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuPropertyViewTabWidget.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuPvtPlotPanel.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuPvtPlotUpdater.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtLinearScaleEngine.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtScalePicker.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtCurvePointTracker.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWheelZoomer.h
|
||||
@@ -92,6 +93,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuProjectPropertyView.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuPropertyViewTabWidget.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuPvtPlotPanel.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuPvtPlotUpdater.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtLinearScaleEngine.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtScalePicker.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtCurvePointTracker.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWheelZoomer.cpp
|
||||
|
||||
33
ApplicationCode/UserInterface/RiuQwtLinearScaleEngine.cpp
Normal file
33
ApplicationCode/UserInterface/RiuQwtLinearScaleEngine.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "RiuQwtLinearScaleEngine.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QwtScaleDiv RiuQwtLinearScaleEngine::divideScale(double x1, double x2, double majorStepInterval, double minorStepInterval)
|
||||
{
|
||||
QwtInterval interval(x1, x2);
|
||||
QwtInterval roundedInterval = this->align(interval, majorStepInterval);
|
||||
QList<double> majorTicks = this->buildMajorTicks(roundedInterval, majorStepInterval);
|
||||
QList<double> minorTicks = this->buildMajorTicks(roundedInterval, minorStepInterval);
|
||||
|
||||
return QwtScaleDiv(x1, x2, minorTicks, minorTicks, majorTicks);
|
||||
}
|
||||
32
ApplicationCode/UserInterface/RiuQwtLinearScaleEngine.h
Normal file
32
ApplicationCode/UserInterface/RiuQwtLinearScaleEngine.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "qwt_scale_engine.h"
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RiuQwtLinearScaleEngine : public QwtLinearScaleEngine
|
||||
{
|
||||
public:
|
||||
QwtScaleDiv divideScale(double x1, double x2, double majorStepInterval, double minorStepInterval);
|
||||
};
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
#include "RiuQwtCurvePointTracker.h"
|
||||
|
||||
#include "RiuQwtLinearScaleEngine.h"
|
||||
|
||||
#include "qwt_legend.h"
|
||||
#include "qwt_plot_curve.h"
|
||||
#include "qwt_plot_grid.h"
|
||||
@@ -35,7 +37,6 @@
|
||||
#include "qwt_plot_marker.h"
|
||||
#include "qwt_plot_picker.h"
|
||||
#include "qwt_scale_draw.h"
|
||||
#include "qwt_scale_engine.h"
|
||||
#include "qwt_symbol.h"
|
||||
#include "qwt_text.h"
|
||||
|
||||
@@ -305,3 +306,55 @@ void RiuWellLogTrack::enableGridLines(bool majorGridLines, bool minorGridLines)
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogTrack::setMajorAndMinorTickIntervals(double majorTickInterval, double minorTickInterval)
|
||||
{
|
||||
RiuQwtLinearScaleEngine* scaleEngine = dynamic_cast<RiuQwtLinearScaleEngine*>(this->axisScaleEngine(QwtPlot::xTop));
|
||||
if (scaleEngine)
|
||||
{
|
||||
QwtInterval currentRange = this->axisInterval(QwtPlot::xTop);
|
||||
QwtScaleDiv scaleDiv = scaleEngine->divideScale(currentRange.minValue(), currentRange.maxValue(), majorTickInterval, minorTickInterval);
|
||||
|
||||
this->setAxisScaleDiv(QwtPlot::xTop, scaleDiv);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogTrack::setAutoTickIntervals(int maxMajorTickIntervals, int maxMinorTickIntervals)
|
||||
{
|
||||
this->setAxisMaxMajor(QwtPlot::xTop, maxMajorTickIntervals);
|
||||
this->setAxisMaxMinor(QwtPlot::xTop, maxMinorTickIntervals);
|
||||
// Reapply axis limits to force Qwt to use the tick settings.
|
||||
QwtInterval currentRange = this->axisInterval(QwtPlot::xTop);
|
||||
this->setAxisScale(QwtPlot::xTop, currentRange.minValue(), currentRange.maxValue());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RiuWellLogTrack::getCurrentMajorTickInterval() const
|
||||
{
|
||||
QwtScaleDiv scaleDiv = this->axisScaleDiv(QwtPlot::xTop);
|
||||
QList<double> majorTicks = scaleDiv.ticks(QwtScaleDiv::MajorTick);
|
||||
if (majorTicks.size() < 2) return 0.0;
|
||||
|
||||
return majorTicks.at(1) - majorTicks.at(0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RiuWellLogTrack::getCurrentMinorTickInterval() const
|
||||
{
|
||||
QwtScaleDiv scaleDiv = this->axisScaleDiv(QwtPlot::xTop);
|
||||
QList<double> minorTicks = scaleDiv.ticks(QwtScaleDiv::MinorTick);
|
||||
if (minorTicks.size() < 2) return 0.0;
|
||||
|
||||
return minorTicks.at(1) - minorTicks.at(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,10 @@ public:
|
||||
void enableVerticalAxisLabelsAndTitle(bool enable);
|
||||
int widthScaleFactor() const;
|
||||
void enableGridLines(bool majorGridLines, bool minorGridLines);
|
||||
void setMajorAndMinorTickIntervals(double majorTickInterval, double minorTickInterval);
|
||||
void setAutoTickIntervals(int maxMajorTickIntervals, int maxMinorTickIntervals);
|
||||
double getCurrentMajorTickInterval() const;
|
||||
double getCurrentMinorTickInterval() const;
|
||||
protected:
|
||||
virtual bool eventFilter(QObject* watched, QEvent* event);
|
||||
virtual QSize sizeHint() const;
|
||||
|
||||
Reference in New Issue
Block a user