(#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

@ -121,7 +121,7 @@ void RicDeleteItemExec::redo()
parentObj->firstAnchestorOrThisOfType(wellLogPlotTrack); parentObj->firstAnchestorOrThisOfType(wellLogPlotTrack);
if (wellLogPlotTrack) if (wellLogPlotTrack)
{ {
wellLogPlotTrack->alignDepthZoomToPlotAndZoomAllX(); wellLogPlotTrack->zoomAllXAndZoomAllDepthOnOwnerPlot();
} }
RimWellLogPlotCollection* wellLogPlotCollection = NULL; RimWellLogPlotCollection* wellLogPlotCollection = NULL;

View File

@ -30,38 +30,53 @@
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack(RimWellLogPlotTrack* wellLogPlotTrack, const std::vector<RimWellLogPlotCurve*>& curves) void RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack(RimWellLogPlotTrack* destTrack,
const std::vector<RimWellLogPlotCurve*>& curves,
RimWellLogPlotCurve* insertAfterCurve)
{ {
CVF_ASSERT(wellLogPlotTrack); CVF_ASSERT(destTrack );
std::set<RimWellLogPlotTrack*> srcTracks;
std::set<RimWellLogPlot*> srcPlots;
for (size_t cIdx = 0; cIdx < curves.size(); cIdx++) for (size_t cIdx = 0; cIdx < curves.size(); cIdx++)
{ {
RimWellLogPlotTrack* oldPlotTrack; RimWellLogPlotCurve* curve = curves[cIdx];
curves[cIdx]->firstAnchestorOrThisOfType(oldPlotTrack);
if (oldPlotTrack) RimWellLogPlotTrack* wellLogPlotTrack;
curve->firstAnchestorOrThisOfType(wellLogPlotTrack);
if (wellLogPlotTrack)
{ {
oldPlotTrack->removeCurve(curves[cIdx]); wellLogPlotTrack->removeCurve(curve);
oldPlotTrack->updateConnectedEditors(); wellLogPlotTrack->updateConnectedEditors();
srcTracks.insert(wellLogPlotTrack);
RimWellLogPlot* plot;
wellLogPlotTrack->firstAnchestorOrThisOfType(plot);
if (plot) srcPlots.insert(plot);
} }
wellLogPlotTrack->insertCurve(curves[cIdx], cIdx);
} }
wellLogPlotTrack->loadDataAndUpdate();
wellLogPlotTrack->alignDepthZoomToPlotAndZoomAllX();
wellLogPlotTrack->updateConnectedEditors();
}
//-------------------------------------------------------------------------------------------------- size_t insertionStartIndex = 0;
/// if (insertAfterCurve) insertionStartIndex = destTrack->curveIndex(insertAfterCurve) + 1;
//--------------------------------------------------------------------------------------------------
void RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack(RimWellLogPlotTrack* wellLogPlotTrack, const std::vector<RimWellLogPlotCurve*>& curves, RimWellLogPlotCurve* insertAfterCurve)
{
CVF_ASSERT(wellLogPlotTrack && insertAfterCurve);
wellLogPlotTrack->moveCurves(insertAfterCurve, curves); for (size_t cIdx = 0; cIdx < curves.size(); cIdx++)
wellLogPlotTrack->loadDataAndUpdate(); {
wellLogPlotTrack->alignDepthZoomToPlotAndZoomAllX(); destTrack->insertCurve(curves[cIdx], insertionStartIndex + cIdx);
wellLogPlotTrack->updateConnectedEditors(); }
for (std::set<RimWellLogPlot*>::iterator pIt = srcPlots.begin(); pIt != srcPlots.end(); ++pIt)
{
(*pIt)->calculateAvailableDepthRange();
}
for (std::set<RimWellLogPlotTrack*>::iterator tIt = srcTracks.begin(); tIt != srcTracks.end(); ++tIt)
{
(*tIt)->zoomAllXAndZoomAllDepthOnOwnerPlot();
}
destTrack->loadDataAndUpdate();
destTrack->zoomAllXAndZoomAllDepthOnOwnerPlot();
destTrack->updateConnectedEditors();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -32,8 +32,7 @@ class RicWellLogPlotTrackFeatureImpl
{ {
public: public:
static void moveCurvesToWellLogPlotTrack(RimWellLogPlotTrack* wellLogPlotTrack, const std::vector<RimWellLogPlotCurve*>& curves); static void moveCurvesToWellLogPlotTrack(RimWellLogPlotTrack* dstTrack, const std::vector<RimWellLogPlotCurve*>& curves, RimWellLogPlotCurve* insertAfterCurve);
static void moveCurvesToWellLogPlotTrack(RimWellLogPlotTrack* wellLogPlotTrack, const std::vector<RimWellLogPlotCurve*>& curves, RimWellLogPlotCurve* insertAfterCurve);
static void moveTracksToWellLogPlot(RimWellLogPlot* wellLogPlot, const std::vector<RimWellLogPlotTrack*>& tracks); static void moveTracksToWellLogPlot(RimWellLogPlot* wellLogPlot, const std::vector<RimWellLogPlotTrack*>& tracks);
static void moveTracks(RimWellLogPlotTrack* insertAfterTrack, const std::vector<RimWellLogPlotTrack*>& tracks); static void moveTracks(RimWellLogPlotTrack* insertAfterTrack, const std::vector<RimWellLogPlotTrack*>& tracks);
}; };

View File

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

View File

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

View File

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

View File

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

View File

@ -52,7 +52,7 @@ public:
void setQwtTrack(RiuWellLogTrackPlot* plot); void setQwtTrack(RiuWellLogTrackPlot* plot);
void detachQwtCurve(); void detachQwtCurve();
bool isCurveVisible(); bool isCurveVisible() const;
QwtPlotCurve* plotCurve() const; QwtPlotCurve* plotCurve() const;
const RigWellLogCurveData* curveData() const; const RigWellLogCurveData* curveData() const;
@ -71,7 +71,7 @@ protected:
void updatePlotConfiguration(); void updatePlotConfiguration();
void updateCurveVisibility(); void updateCurveVisibility();
void updateTrackAndPlotFromCurveData(); void zoomAllOwnerTrackAndPlot();
void updateOptionSensitivity(); void updateOptionSensitivity();
// Overridden PDM methods // 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 minDepth = HUGE_VAL;
double maxDepth = -HUGE_VAL; double maxDepth = -HUGE_VAL;
size_t curveCount = curves.size(); size_t curveCount = curves.size();
if (curveCount < 1)
{
return false;
}
bool rangeUpdated = false;
for (size_t cIdx = 0; cIdx < curveCount; cIdx++) for (size_t cIdx = 0; cIdx < curveCount; cIdx++)
{ {
double minCurveDepth = HUGE_VAL; double minCurveDepth = HUGE_VAL;
double maxCurveDepth = -HUGE_VAL; double maxCurveDepth = -HUGE_VAL;
if (curves[cIdx]->depthRange(&minCurveDepth, &maxCurveDepth)) if (curves[cIdx]->isCurveVisible() && curves[cIdx]->depthRange(&minCurveDepth, &maxCurveDepth))
{ {
if (minCurveDepth < minDepth) if (minCurveDepth < minDepth)
{ {
minDepth = minCurveDepth; minDepth = minCurveDepth;
rangeUpdated = true;
} }
if (maxCurveDepth > maxDepth) if (maxCurveDepth > maxDepth)
{ {
maxDepth = maxCurveDepth; maxDepth = maxCurveDepth;
rangeUpdated = true;
} }
} }
} }
if (rangeUpdated) *minimumDepth = minDepth;
{ *maximumDepth = maxDepth;
*minimumDepth = minDepth;
*maximumDepth = maxDepth;
}
return rangeUpdated;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -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 minCurveValue = HUGE_VAL;
double maxCurveValue = -HUGE_VAL; double maxCurveValue = -HUGE_VAL;
if (curves[cIdx]->valueRange(&minCurveValue, &maxCurveValue)) if (curves[cIdx]->isCurveVisible() && curves[cIdx]->valueRange(&minCurveValue, &maxCurveValue))
{ {
if (minCurveValue < minValue) if (minCurveValue < minValue)
{ {
@ -363,3 +345,11 @@ void RimWellLogPlotTrack::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder
gridGroup->add(&m_visibleXRangeMin); gridGroup->add(&m_visibleXRangeMin);
gridGroup->add(&m_visibleXRangeMax); 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 addCurve(RimWellLogPlotCurve* curve);
void insertCurve(RimWellLogPlotCurve* curve, size_t index); void insertCurve(RimWellLogPlotCurve* curve, size_t index);
void removeCurve(RimWellLogPlotCurve* curve); void removeCurve(RimWellLogPlotCurve* curve);
void moveCurves(RimWellLogPlotCurve* insertAfterCurve, const std::vector<RimWellLogPlotCurve*>& curvesToMove); size_t curveIndex(RimWellLogPlotCurve* curve);
size_t curveCount() { return curves.size(); } size_t curveCount() { return curves.size(); }
void recreateViewer(); void recreateViewer();
@ -56,7 +56,8 @@ public:
void loadDataAndUpdate(); void loadDataAndUpdate();
bool availableDepthRange(double* minimumDepth, double* maximumDepth); void availableDepthRange(double* minimumDepth, double* maximumDepth);
void zoomAllXAndZoomAllDepthOnOwnerPlot();
void alignDepthZoomToPlotAndZoomAllX(); void alignDepthZoomToPlotAndZoomAllX();
RiuWellLogTrackPlot* viewer(); RiuWellLogTrackPlot* viewer();
@ -73,7 +74,6 @@ protected:
private: private:
void zoomAllXAxis(); void zoomAllXAxis();
private: private:
caf::PdmField<bool> m_show; caf::PdmField<bool> m_show;
caf::PdmField<QString> m_userName; caf::PdmField<QString> m_userName;

View File

@ -350,7 +350,7 @@ bool RiuDragDrop::handleWellLogPlotTrackDrop(Qt::DropAction action, caf::PdmObje
{ {
if (action == Qt::MoveAction) if (action == Qt::MoveAction)
{ {
RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack(wellLogPlotTrack, wellLogPlotCurves); RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack(wellLogPlotTrack, wellLogPlotCurves, NULL);
return true; return true;
} }
} }