(#592) Plots and tracks are now autoscaled on curve drag, drop, delete, toggled

This commit is contained in:
Jacob Støren
2015-10-28 16:49:52 +01:00
parent bc85ecd6ab
commit 07916f55ce
11 changed files with 115 additions and 93 deletions

View File

@@ -256,7 +256,7 @@ void RimWellLogExtractionCurve::updatePlotData()
}
m_qwtPlotCurve->setCurveData(m_curveData.p());
updateTrackAndPlotFromCurveData();
zoomAllOwnerTrackAndPlot();
if (m_ownerQwtTrack) m_ownerQwtTrack->replot();
}

View File

@@ -99,7 +99,7 @@ void RimWellLogFileCurve::updatePlotData()
m_qwtPlotCurve->setCurveData(m_curveData.p());
updateTrackAndPlotFromCurveData();
zoomAllOwnerTrackAndPlot();
if (m_ownerQwtTrack) m_ownerQwtTrack->replot();
}

View File

@@ -291,18 +291,18 @@ void RimWellLogPlot::calculateAvailableDepthRange()
double minTrackDepth = HUGE_VAL;
double maxTrackDepth = -HUGE_VAL;
if (m_tracks[tIdx]->availableDepthRange(&minTrackDepth, &maxTrackDepth))
{
if (minTrackDepth < minDepth)
{
minDepth = minTrackDepth;
}
m_tracks[tIdx]->availableDepthRange(&minTrackDepth, &maxTrackDepth);
if (maxTrackDepth > maxDepth)
{
maxDepth = maxTrackDepth;
}
if (minTrackDepth < minDepth)
{
minDepth = minTrackDepth;
}
if (maxTrackDepth > maxDepth)
{
maxDepth = maxTrackDepth;
}
}
m_minAvailableDepth = minDepth;

View File

@@ -62,9 +62,12 @@ RimWellLogPlotCurve::RimWellLogPlotCurve()
RimWellLogPlotCurve::~RimWellLogPlotCurve()
{
m_qwtPlotCurve->detach();
if (m_ownerQwtTrack) m_ownerQwtTrack->replot();
delete m_qwtPlotCurve;
if (m_ownerQwtTrack)
{
m_ownerQwtTrack->replot();
}
}
//--------------------------------------------------------------------------------------------------
@@ -121,6 +124,21 @@ void RimWellLogPlotCurve::updateCurveVisibility()
{
m_qwtPlotCurve->detach();
}
RimWellLogPlot* wellLogPlot;
this->firstAnchestorOrThisOfType(wellLogPlot);
if (wellLogPlot)
{
wellLogPlot->calculateAvailableDepthRange();
}
RimWellLogPlotTrack* wellLogPlotTrack;
this->firstAnchestorOrThisOfType(wellLogPlotTrack);
if (wellLogPlotTrack)
{
wellLogPlotTrack->zoomAllXAndZoomAllDepthOnOwnerPlot();
}
}
//--------------------------------------------------------------------------------------------------
@@ -164,7 +182,7 @@ bool RimWellLogPlotCurve::depthRange(double* minimumDepth, double* maximumDepth)
{
CVF_ASSERT(minimumDepth && maximumDepth);
CVF_ASSERT(m_qwtPlotCurve);
if (m_qwtPlotCurve->data()->size() < 1)
{
return false;
@@ -230,7 +248,7 @@ void RimWellLogPlotCurve::updatePlotTitle()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellLogPlotCurve::isCurveVisible()
bool RimWellLogPlotCurve::isCurveVisible() const
{
return m_showCurve;
}
@@ -246,7 +264,7 @@ void RimWellLogPlotCurve::initAfterRead()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlotCurve::updateTrackAndPlotFromCurveData()
void RimWellLogPlotCurve::zoomAllOwnerTrackAndPlot()
{
RimWellLogPlot* wellLogPlot;
firstAnchestorOrThisOfType(wellLogPlot);
@@ -260,7 +278,7 @@ void RimWellLogPlotCurve::updateTrackAndPlotFromCurveData()
firstAnchestorOrThisOfType(plotTrack);
if (plotTrack)
{
plotTrack->alignDepthZoomToPlotAndZoomAllX();
plotTrack->zoomAllXAndZoomAllDepthOnOwnerPlot();
}
}

View File

@@ -52,7 +52,7 @@ public:
void setQwtTrack(RiuWellLogTrackPlot* plot);
void detachQwtCurve();
bool isCurveVisible();
bool isCurveVisible() const;
QwtPlotCurve* plotCurve() const;
const RigWellLogCurveData* curveData() const;
@@ -71,7 +71,7 @@ protected:
void updatePlotConfiguration();
void updateCurveVisibility();
void updateTrackAndPlotFromCurveData();
void zoomAllOwnerTrackAndPlot();
void updateOptionSensitivity();
// Overridden PDM methods

View File

@@ -145,31 +145,6 @@ void RimWellLogPlotTrack::removeCurve(RimWellLogPlotCurve* curve)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlotTrack::moveCurves(RimWellLogPlotCurve* insertAfterCurve, const std::vector<RimWellLogPlotCurve*>& curvesToMove)
{
for (size_t cIdx = 0; cIdx < curvesToMove.size(); cIdx++)
{
RimWellLogPlotCurve* curve = curvesToMove[cIdx];
RimWellLogPlotTrack* wellLogPlotTrack;
curve->firstAnchestorOrThisOfType(wellLogPlotTrack);
if (wellLogPlotTrack)
{
wellLogPlotTrack->removeCurve(curve);
wellLogPlotTrack->updateConnectedEditors();
}
}
size_t index = curves.index(insertAfterCurve) + 1;
for (size_t cIdx = 0; cIdx < curvesToMove.size(); cIdx++)
{
insertCurve(curvesToMove[cIdx], index + cIdx);
}
}
//--------------------------------------------------------------------------------------------------
///
@@ -182,47 +157,34 @@ RiuWellLogTrackPlot* RimWellLogPlotTrack::viewer()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellLogPlotTrack::availableDepthRange(double* minimumDepth, double* maximumDepth)
void RimWellLogPlotTrack::availableDepthRange(double* minimumDepth, double* maximumDepth)
{
double minDepth = HUGE_VAL;
double maxDepth = -HUGE_VAL;
size_t curveCount = curves.size();
if (curveCount < 1)
{
return false;
}
bool rangeUpdated = false;
for (size_t cIdx = 0; cIdx < curveCount; cIdx++)
{
double minCurveDepth = HUGE_VAL;
double maxCurveDepth = -HUGE_VAL;
if (curves[cIdx]->depthRange(&minCurveDepth, &maxCurveDepth))
if (curves[cIdx]->isCurveVisible() && curves[cIdx]->depthRange(&minCurveDepth, &maxCurveDepth))
{
if (minCurveDepth < minDepth)
{
minDepth = minCurveDepth;
rangeUpdated = true;
}
if (maxCurveDepth > maxDepth)
{
maxDepth = maxCurveDepth;
rangeUpdated = true;
}
}
}
if (rangeUpdated)
{
*minimumDepth = minDepth;
*maximumDepth = maxDepth;
}
return rangeUpdated;
*minimumDepth = minDepth;
*maximumDepth = maxDepth;
}
//--------------------------------------------------------------------------------------------------
@@ -272,6 +234,26 @@ void RimWellLogPlotTrack::detachAllCurves()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlotTrack::zoomAllXAndZoomAllDepthOnOwnerPlot()
{
if (m_wellLogTrackPlotWidget)
{
RimWellLogPlot* wellLogPlot;
firstAnchestorOrThisOfType(wellLogPlot);
if (wellLogPlot)
{
wellLogPlot->zoomAllDepth();
}
zoomAllXAxis();
m_wellLogTrackPlotWidget->replot();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -308,7 +290,7 @@ void RimWellLogPlotTrack::zoomAllXAxis()
double minCurveValue = HUGE_VAL;
double maxCurveValue = -HUGE_VAL;
if (curves[cIdx]->valueRange(&minCurveValue, &maxCurveValue))
if (curves[cIdx]->isCurveVisible() && curves[cIdx]->valueRange(&minCurveValue, &maxCurveValue))
{
if (minCurveValue < minValue)
{
@@ -363,3 +345,11 @@ void RimWellLogPlotTrack::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder
gridGroup->add(&m_visibleXRangeMin);
gridGroup->add(&m_visibleXRangeMax);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RimWellLogPlotTrack::curveIndex(RimWellLogPlotCurve* curve)
{
return curves.index(curve);
}

View File

@@ -48,7 +48,7 @@ public:
void addCurve(RimWellLogPlotCurve* curve);
void insertCurve(RimWellLogPlotCurve* curve, size_t index);
void removeCurve(RimWellLogPlotCurve* curve);
void moveCurves(RimWellLogPlotCurve* insertAfterCurve, const std::vector<RimWellLogPlotCurve*>& curvesToMove);
size_t curveIndex(RimWellLogPlotCurve* curve);
size_t curveCount() { return curves.size(); }
void recreateViewer();
@@ -56,7 +56,8 @@ public:
void loadDataAndUpdate();
bool availableDepthRange(double* minimumDepth, double* maximumDepth);
void availableDepthRange(double* minimumDepth, double* maximumDepth);
void zoomAllXAndZoomAllDepthOnOwnerPlot();
void alignDepthZoomToPlotAndZoomAllX();
RiuWellLogTrackPlot* viewer();
@@ -73,7 +74,6 @@ protected:
private:
void zoomAllXAxis();
private:
caf::PdmField<bool> m_show;
caf::PdmField<QString> m_userName;