Skip to content

Commit

Permalink
SimulationExperiment view: can now modify the colour, font size and a…
Browse files Browse the repository at this point in the history
…xes’ scale of a graph panel (#1426).
  • Loading branch information
agarny committed Oct 30, 2017
1 parent 1e068d4 commit 2eefc31
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,15 @@ void SimulationExperimentViewInformationGraphPanelAndGraphsWidget::initialize(Op
mGraphPanelPropertyEditor = new Core::PropertyEditorWidget(false, false, this);
mGraphsPropertyEditor = new Core::PropertyEditorWidget(false, false, this);

// Keep track of the link between our existing graph panel and our new
// graph panel and graphs property editors

mGraphPanels.insert(mGraphPanelPropertyEditor, pGraphPanel);
mGraphPanels.insert(mGraphsPropertyEditor, pGraphPanel);

mGraphPanelPropertyEditors.insert(pGraphPanel, mGraphPanelPropertyEditor);
mGraphsPropertyEditors.insert(pGraphPanel, mGraphsPropertyEditor);

// Populate our graph panel property editor

populateGraphPanelPropertyEditor();
Expand Down Expand Up @@ -247,23 +256,15 @@ void SimulationExperimentViewInformationGraphPanelAndGraphsWidget::initialize(Op

// Keep track of when the user changes a property value

//---ISSUE1426--- CHECK WHETHER WE NEED TO HANDLE THAT SIGNAL FOR OUR GRAPH
// PANEL EDITOR...
connect(mGraphPanelPropertyEditor, SIGNAL(propertyChanged(Core::Property *)),
this, SLOT(graphPanelPropertyChanged()));
connect(mGraphsPropertyEditor, SIGNAL(propertyChanged(Core::Property *)),
this, SLOT(graphsPropertyChanged(Core::Property *)));

// Add our new graphs property editor to ourselves

addWidget(mGraphPanelPropertyEditor);
addWidget(mGraphsPropertyEditor);

// Keep track of the link between our existing graph panel and our new
// graphs property editor

mGraphPanels.insert(mGraphsPropertyEditor, pGraphPanel);

mGraphPanelPropertyEditors.insert(pGraphPanel, mGraphPanelPropertyEditor);
mGraphsPropertyEditors.insert(pGraphPanel, mGraphsPropertyEditor);
}

// Set the value of our property editors' horizontal scroll bar
Expand Down Expand Up @@ -300,9 +301,10 @@ void SimulationExperimentViewInformationGraphPanelAndGraphsWidget::initialize(Op

void SimulationExperimentViewInformationGraphPanelAndGraphsWidget::finalize(OpenCOR::GraphPanelWidget::GraphPanelWidget *pGraphPanel)
{
// Remove track of the link betwen our graph panel and our graphs property
// editor
// Remove track of the link betwen our graph panel and our graph panel and
// graphs property editors

mGraphPanels.remove(mGraphPanelPropertyEditors.value(pGraphPanel));
mGraphPanels.remove(mGraphsPropertyEditors.value(pGraphPanel));

mGraphPanelPropertyEditors.remove(pGraphPanel);
Expand Down Expand Up @@ -758,17 +760,19 @@ void SimulationExperimentViewInformationGraphPanelAndGraphsWidget::populateGraph
{
// Populate our graph panel property editor

mGraphPanelPropertyEditor->addColorProperty();
mGraphPanelPropertyEditor->addDoubleGt0Property();
GraphPanelWidget::GraphPanelPlotWidget *graphPanelPlot = mGraphPanels.value(mGraphPanelPropertyEditor)->plot();

mGraphPanelPropertyEditor->addColorProperty(graphPanelPlot->color());
mGraphPanelPropertyEditor->addDoubleGt0Property(graphPanelPlot->fontSize());

Core::Property *gridLinesProperty = mGraphPanelPropertyEditor->addSectionProperty();

mGraphPanelPropertyEditor->addListProperty(SEDMLSupport::lineStyles(), gridLinesProperty);
mGraphPanelPropertyEditor->addDoubleGt0Property(gridLinesProperty);
mGraphPanelPropertyEditor->addColorProperty(gridLinesProperty);

mGraphPanelPropertyEditor->addBooleanProperty();
mGraphPanelPropertyEditor->addBooleanProperty();
mGraphPanelPropertyEditor->addBooleanProperty(graphPanelPlot->logAxisX());
mGraphPanelPropertyEditor->addBooleanProperty(graphPanelPlot->logAxisY());

Core::Property *pointCoordinatesProperty = mGraphPanelPropertyEditor->addSectionProperty();

Expand Down Expand Up @@ -1057,6 +1061,25 @@ void SimulationExperimentViewInformationGraphPanelAndGraphsWidget::updateGraphIn

//==============================================================================

void SimulationExperimentViewInformationGraphPanelAndGraphsWidget::graphPanelPropertyChanged()
{
// Update our graph panel settings

GraphPanelWidget::GraphPanelPlotWidget *graphPanelPlot = mGraphPanels.value(mGraphPanelPropertyEditor)->plot();

graphPanelPlot->setUpdatesEnabled(false);

graphPanelPlot->setColor(mGraphPanelPropertyEditor->properties()[0]->colorValue());
graphPanelPlot->setFontSize(mGraphPanelPropertyEditor->properties()[1]->integerValue());

graphPanelPlot->setLogAxisX(mGraphPanelPropertyEditor->properties()[3]->booleanValue());
graphPanelPlot->setLogAxisY(mGraphPanelPropertyEditor->properties()[4]->booleanValue());

graphPanelPlot->setUpdatesEnabled(true);
}

//==============================================================================

void SimulationExperimentViewInformationGraphPanelAndGraphsWidget::graphsPropertyChanged(Core::Property *pProperty)
{
// Our graph has changed, which means that either it has been un/selected or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ private slots:
void graphPanelPropertyEditorHorizontalScrollBarValueChanged(const int &pValue);
void graphsPropertyEditorHorizontalScrollBarValueChanged(const int &pValue);

void graphPanelPropertyChanged();
void graphsPropertyChanged(Core::Property *pProperty);

void updateParameterValue();
Expand Down
53 changes: 53 additions & 0 deletions src/plugins/widget/GraphPanelWidget/src/graphpanelplotwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,59 @@ void GraphPanelPlotWidget::resetAction()

//==============================================================================

QColor GraphPanelPlotWidget::color() const
{
// Return our (background) colour

return canvasBackground().color();
}

//==============================================================================

void GraphPanelPlotWidget::setColor(const QColor &pColor)
{
// Set our (background) colour

if (pColor != color()) {
QBrush brush = canvasBackground();

brush.setColor(pColor);

setCanvasBackground(brush);

replot();
}
}

//==============================================================================

int GraphPanelPlotWidget::fontSize() const
{
// Return our font size

return axisFont(QwtPlot::xBottom).pointSize();
}

//==============================================================================

void GraphPanelPlotWidget::setFontSize(const int &pFontSize)
{
// Set our font size

if (pFontSize != fontSize()) {
QFont font = axisFont(QwtPlot::xBottom);

font.setPointSize(pFontSize);

setAxisFont(QwtPlot::xBottom, font);
setAxisFont(QwtPlot::yLeft, font);

replot();
}
}

//==============================================================================

bool GraphPanelPlotWidget::logAxisX() const
{
// Return whether our X axis uses a logarithmic scale
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@ class GRAPHPANELWIDGET_EXPORT GraphPanelPlotWidget : public QwtPlot,
double minY() const;
double maxY() const;

QColor color() const;
void setColor(const QColor &pColor);

int fontSize() const;
void setFontSize(const int &pFontSize);

bool logAxisX() const;
void setLogAxisX(const bool &pLogAxisX);

Expand Down

0 comments on commit 2eefc31

Please sign in to comment.