Skip to content

Commit

Permalink
Merge 6d505a0 into e58a330
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Aug 23, 2018
2 parents e58a330 + 6d505a0 commit ccd2465
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 33 deletions.
1 change: 1 addition & 0 deletions doc/downloads/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var jsonData = { "versions": [
],
"changes": [
{ "change": "<strong>General:</strong> Clang code model related cleaning up (see issue <a href=\"https://github.com/opencor/opencor/issues/1747\">#1747</a>). Allow the use of another Qt style (see issue <a href=\"https://github.com/opencor/opencor/issues/1761\">#1761</a>). Improved HiDPI support (see issue <a href=\"https://github.com/opencor/opencor/issues/1763\">#1763</a>)." },
{ "change": "<strong>Graph Panel widget:</strong> only reset axes when needed (see issue <a href=\"https://github.com/opencor/opencor/issues/1777\">#1777</a>)." },
{ "change": "<strong>Core plugin:</strong> fixed a problem with the menu items for recently opened files potentially appearing as disabled on macOS (see issue <a href=\"https://github.com/opencor/opencor/issues/1633\">#1633</a>)." },
{ "change": "<strong>Simulation Experiment view:</strong> added some basic preferences for graph panels and graphs (see issue <a href=\"https://github.com/opencor/opencor/issues/1772\">#1772</a>)." },
{ "change": "<strong>Third-party libraries:</strong> upgraded the <a href=\"http://computation.llnl.gov/projects/sundials\">SUNDIALS</a> library to version 3.1.2 (see issue <a href=\"https://github.com/opencor/opencor/issues/1743\">#1743</a>). Renamed our BioSignalML plugin to libBioSignalML (see issue <a href=\"https://github.com/opencor/opencor/issues/1754\">#1754</a>). Upgraded <a href=\"https://www.openssl.org/\">OpenSSL</a> to version 1.0.2p (see issue <a href=\"https://github.com/opencor/opencor/issues/1767\">#1767</a>)." }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3373,7 +3373,7 @@ void SimulationExperimentViewSimulationWidget::simulationPropertyChanged(Core::P
// updated at once...

foreach (GraphPanelWidget::GraphPanelPlotWidget *plot, mPlots) {
if (updatePlot(plot))
if (updatePlot(plot, true, false, false))
needProcessingEvents = true;
}

Expand Down Expand Up @@ -3500,7 +3500,8 @@ void SimulationExperimentViewSimulationWidget::graphAdded(GraphPanelWidget::Grap
for (int i = 0, iMax = mSimulation->runsCount(); i < iMax; ++i)
updateGraphData(pGraph, mSimulation->results()->size(i), i);

if (updatePlot(plot) || plot->drawGraphFrom(pGraph, 0)) {
if ( updatePlot(plot, true, false, false)
|| plot->drawGraphFrom(pGraph, 0)) {
processEvents();
// Note: this ensures that our plot is updated at once...
}
Expand Down Expand Up @@ -3530,7 +3531,7 @@ void SimulationExperimentViewSimulationWidget::graphsRemoved(GraphPanelWidget::G

GraphPanelWidget::GraphPanelPlotWidget *plot = pGraphPanel->plot();

updatePlot(plot, true, true);
updatePlot(plot, true, false, true);

processEvents();
// Note: this ensures that our plot is updated at once...
Expand Down Expand Up @@ -3584,7 +3585,7 @@ void SimulationExperimentViewSimulationWidget::graphsUpdated(const GraphPanelWid

if (mCanUpdatePlotsForUpdatedGraphs) {
foreach (GraphPanelWidget::GraphPanelPlotWidget *plot, plots) {
updatePlot(plot, true, true);
updatePlot(plot, true, false, true);
// Note: even if the axes' values of the plot haven't changed, we
// still want to replot the plot since at least one of its
// graphs has been updated...
Expand Down Expand Up @@ -3619,6 +3620,7 @@ void SimulationExperimentViewSimulationWidget::removePlot(GraphPanelWidget::Grap

bool SimulationExperimentViewSimulationWidget::updatePlot(GraphPanelWidget::GraphPanelPlotWidget *pPlot,
bool pCanSetAxes,
bool pForceAxesSetting,
bool pForceReplot)
{
// Retrieve the current axes' linear and log values or use some default
Expand Down Expand Up @@ -3750,7 +3752,7 @@ bool SimulationExperimentViewSimulationWidget::updatePlot(GraphPanelWidget::Grap
if ( pCanSetAxes
&& pPlot->setAxes(logAxisX?minLogX:minX, logAxisX?maxLogX:maxX,
logAxisY?minLogY:minY, logAxisY?maxLogY:maxY,
true, true, false)) {
true, true, false, pForceAxesSetting)) {
return true;
} else if (pForceReplot) {
pPlot->replot();
Expand Down Expand Up @@ -3831,7 +3833,7 @@ void SimulationExperimentViewSimulationWidget::updateGui(bool pCheckVisibility)
mNeedUpdatePlots = false;

foreach (GraphPanelWidget::GraphPanelPlotWidget *plot, mPlots)
updatePlot(plot, true, true);
updatePlot(plot, true, false, true);

processEvents();
// Note: this ensures that our plots are all updated at once...
Expand Down Expand Up @@ -3975,7 +3977,7 @@ void SimulationExperimentViewSimulationWidget::updateSimulationResults(Simulatio
// to be drawn straightaway (e.g. when we start a
// simulation)...

updatePlot(plot, needFullUpdatePlot, true);
updatePlot(plot, needFullUpdatePlot, true, true);

needProcessingEvents = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ class SimulationExperimentViewSimulationWidget : public Core::Widget

void removePlot(GraphPanelWidget::GraphPanelPlotWidget *pPlot);
bool updatePlot(GraphPanelWidget::GraphPanelPlotWidget *pPlot,
bool pCanSetAxes = true, bool pForceReplot = false);
bool pCanSetAxes, bool pForceAxesSetting,
bool pForceReplot);

double * data(SimulationSupport::Simulation *pSimulation,
CellMLSupport::CellmlFileRuntimeParameter *pParameter,
Expand Down
62 changes: 43 additions & 19 deletions src/plugins/widget/GraphPanelWidget/src/graphpanelplotwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,8 @@ GraphPanelPlotWidget::GraphPanelPlotWidget(const GraphPanelPlotWidgets &pNeighbo
mDefaultMaxLogX(DefaultMaxAxis),
mDefaultMinLogY(DefaultMinLogAxis),
mDefaultMaxLogY(DefaultMaxAxis),
mNeighbors(pNeighbors)
mNeighbors(pNeighbors),
mDirtyAxes(false)
{
// Keep track of when our grand parent (i.e. a GraphPanelsWidget object)
// gets destroyed
Expand Down Expand Up @@ -1570,7 +1571,8 @@ GraphPanelPlotWidget::GraphPanelPlotWidget(const GraphPanelPlotWidgets &pNeighbo
// Note: we are not all initialised yet, so we don't want setAxes() to
// replot ourselves...

setAxes(DefaultMinAxis, DefaultMaxAxis, DefaultMinAxis, DefaultMaxAxis, false, false, false);
setAxes(DefaultMinAxis, DefaultMaxAxis, DefaultMinAxis, DefaultMaxAxis,
false, false, false, true);

// We want our legend to be active by default

Expand Down Expand Up @@ -2627,9 +2629,14 @@ void GraphPanelPlotWidget::setDefaultAxesValues(double pDefaultMinX,
bool GraphPanelPlotWidget::setAxes(double pMinX, double pMaxX, double pMinY,
double pMaxY, bool pSynchronizeAxes,
bool pCanReplot, bool pEmitSignal,
bool pForceXAxisSetting,
bool pForceYAxisSetting)
bool pForceAxesSetting)
{
// Axes can only be set if they are not dirty or if we want to force the
// setting of our X/Y axes

if (mDirtyAxes && !pForceAxesSetting)
return false;

// Keep track of our axes' old values

double oldMinX = minX();
Expand All @@ -2647,13 +2654,13 @@ bool GraphPanelPlotWidget::setAxes(double pMinX, double pMaxX, double pMinY,
bool xAxisValuesChanged = false;
bool yAxisValuesChanged = false;

if (pForceXAxisSetting || !qIsNull(pMinX-oldMinX) || !qIsNull(pMaxX-oldMaxX)) {
if (pForceAxesSetting || !qIsNull(pMinX-oldMinX) || !qIsNull(pMaxX-oldMaxX)) {
setAxis(QwtPlot::xBottom, pMinX, pMaxX);

xAxisValuesChanged = true;
}

if (pForceYAxisSetting || !qIsNull(pMinY-oldMinY) || !qIsNull(pMaxY-oldMaxY)) {
if (pForceAxesSetting || !qIsNull(pMinY-oldMinY) || !qIsNull(pMaxY-oldMaxY)) {
setAxis(QwtPlot::yLeft, pMinY, pMaxY);

yAxisValuesChanged = true;
Expand All @@ -2665,21 +2672,28 @@ bool GraphPanelPlotWidget::setAxes(double pMinX, double pMaxX, double pMinY,

if (xAxisValuesChanged || yAxisValuesChanged) {
mCanDirectPaint = false;
mDirtyAxes = pForceAxesSetting;

if (xAxisValuesChanged || yAxisValuesChanged)
updateActions();

if (pSynchronizeAxes) {
if ( mSynchronizeXAxisAction->isChecked()
&& mSynchronizeYAxisAction->isChecked()) {
foreach (GraphPanelPlotWidget *plot, mNeighbors)
plot->setAxes(pMinX, pMaxX, pMinY, pMaxY, false, false, false);
foreach (GraphPanelPlotWidget *plot, mNeighbors) {
plot->setAxes(pMinX, pMaxX, pMinY, pMaxY,
false, false, false, true);
}
} else if (xAxisValuesChanged && mSynchronizeXAxisAction->isChecked()) {
foreach (GraphPanelPlotWidget *plot, mNeighbors)
plot->setAxes(pMinX, pMaxX, plot->minY(), plot->maxY(), false, false, false);
foreach (GraphPanelPlotWidget *plot, mNeighbors) {
plot->setAxes(pMinX, pMaxX, plot->minY(), plot->maxY(),
false, false, false, true);
}
} else if (yAxisValuesChanged && mSynchronizeYAxisAction->isChecked()) {
foreach (GraphPanelPlotWidget *plot, mNeighbors)
plot->setAxes(plot->minX(), plot->maxX(), pMinY, pMaxY, false, false, false);
foreach (GraphPanelPlotWidget *plot, mNeighbors) {
plot->setAxes(plot->minX(), plot->maxX(), pMinY, pMaxY,
false, false, false, true);
}
}

alignWithNeighbors(pCanReplot,
Expand All @@ -2705,8 +2719,13 @@ bool GraphPanelPlotWidget::resetAxes()

QRectF dRect = realDataRect();

return setAxes(dRect.left(), dRect.left()+dRect.width(),
dRect.top(), dRect.top()+dRect.height());
bool res= setAxes(dRect.left(), dRect.left()+dRect.width(),
dRect.top(), dRect.top()+dRect.height(),
true, true, true, true);

mDirtyAxes = false;

return res;
}

//==============================================================================
Expand Down Expand Up @@ -2790,8 +2809,10 @@ void GraphPanelPlotWidget::scaleAxes(const QPoint &pPoint, Scaling pScalingX,
// Note: we want to make both calls to scaleAxis(), hence they are not part
// of the if() statement below...

if (scaledAxisX || scaledAxisY)
setAxes(newMinX, newMaxX, newMinY, newMaxY);
if (scaledAxisX || scaledAxisY) {
setAxes(newMinX, newMaxX, newMinY, newMaxY,
true, true, true, true);
}
}

//==============================================================================
Expand Down Expand Up @@ -2907,7 +2928,8 @@ void GraphPanelPlotWidget::mouseMoveEvent(QMouseEvent *pEvent)
setAxes(canvasMapX.invTransform(canvasMapX.transform(minX())-shiftX),
canvasMapX.invTransform(canvasMapX.transform(maxX())-shiftX),
canvasMapY.invTransform(canvasMapY.transform(minY())-shiftY),
canvasMapY.invTransform(canvasMapY.transform(maxY())-shiftY));
canvasMapY.invTransform(canvasMapY.transform(maxY())-shiftY),
true, true, true, true);

break;
}
Expand Down Expand Up @@ -3055,7 +3077,8 @@ void GraphPanelPlotWidget::mouseReleaseEvent(QMouseEvent *pEvent)

if (!qIsNull(zoomRegion.width()) && !qIsNull(zoomRegion.height())) {
setAxes(zoomRegion.left(), zoomRegion.left()+zoomRegion.width(),
zoomRegion.top()+zoomRegion.height(), zoomRegion.top());
zoomRegion.top()+zoomRegion.height(), zoomRegion.top(),
true, true, true, true);
}

break;
Expand Down Expand Up @@ -3481,7 +3504,8 @@ void GraphPanelPlotWidget::customAxes()

if ( !qIsNull(newMinX-oldMinX) || !qIsNull(newMaxX-oldMaxX)
|| !qIsNull(newMinY-oldMinY) || !qIsNull(newMaxY-oldMaxY)) {
setAxes(newMinX, newMaxX, newMinY, newMaxY);
setAxes(newMinX, newMaxX, newMinY, newMaxY,
true, true, true, true);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,8 @@ class GRAPHPANELWIDGET_EXPORT GraphPanelPlotWidget : public QwtPlot,
double pDefaultMinLogY, double pDefaultMaxLogY);

bool setAxes(double pMinX, double pMaxX, double pMinY, double pMaxY,
bool pSynchronizeAxes = true, bool pCanReplot = true,
bool pEmitSignal = true, bool pForceXAxisSetting = false,
bool pForceYAxisSetting = false);
bool pSynchronizeAxes, bool pCanReplot, bool pEmitSignal,
bool pForceAxesSetting);

bool drawGraphFrom(GraphPanelPlotGraph *pGraph, quint64 pFrom);

Expand Down Expand Up @@ -602,6 +601,8 @@ class GRAPHPANELWIDGET_EXPORT GraphPanelPlotWidget : public QwtPlot,

GraphPanelPlotWidgets mNeighbors;

bool mDirtyAxes;

void checkAxisValues(bool pLogAxis, double &pMin, double &pMax);

void updateActions();
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/widget/GraphPanelWidget/src/graphpanelswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ GraphPanelWidget * GraphPanelsWidget::addGraphPanel(const GraphPanelWidgetProper
activeGraphPanelPlot->maxX(),
activeGraphPanelPlot->minY(),
activeGraphPanelPlot->maxY(),
true, true, true, true, true);
true, true, true, true);

// Make sure that our graph panel is visible
// Note: indeed, for some reasons, this may not always be the case when
Expand Down Expand Up @@ -404,7 +404,7 @@ void GraphPanelsWidget::synchronizeXAxis()
activeGraphPanelPlot->maxX(),
activeGraphPanelPlot->minY(),
activeGraphPanelPlot->maxY(),
true, true, true, true, false);
true, true, true, true);
}
}

Expand All @@ -422,7 +422,7 @@ void GraphPanelsWidget::synchronizeYAxis()
activeGraphPanelPlot->maxX(),
activeGraphPanelPlot->minY(),
activeGraphPanelPlot->maxY(),
true, true, true, false, true);
true, true, true, true);
}
}

Expand Down

0 comments on commit ccd2465

Please sign in to comment.