diff --git a/src/ColoringAction.cpp b/src/ColoringAction.cpp index 0ade6d0..6463937 100644 --- a/src/ColoringAction.cpp +++ b/src/ColoringAction.cpp @@ -72,10 +72,33 @@ ColoringAction::ColoringAction(QObject* parent, const QString& title) : const auto currentColorDataset = getCurrentColorDataset(); - if (currentColorDataset.isValid()) { - const auto currentColorDatasetTypeIsPointType = currentColorDataset->getDataType() == PointType; + if (_currentColorPointsDataset.isValid()) { + disconnect(&_currentColorPointsDataset, &Dataset::dataDimensionsChanged, this, nullptr); + } - _dimensionAction.setPointsDataset(currentColorDatasetTypeIsPointType ? Dataset(currentColorDataset) : Dataset()); + _currentColorPointsDataset = Dataset(); + + if (currentColorDataset.isValid()) { + if (currentColorDataset->getDataType() == PointType) { + _currentColorPointsDataset = currentColorDataset.get(); + + if (_currentColorPointsDataset.isValid()) { + connect(&_currentColorPointsDataset, &Dataset::dataDimensionsChanged, this, [this]() { + if (_currentColorPointsDataset.isValid()) { + _dimensionAction.setPointsDataset(_currentColorPointsDataset); + updateScatterPlotWidgetColors(); + } + }); + + _dimensionAction.setPointsDataset(_currentColorPointsDataset); + } + else { + _dimensionAction.setPointsDataset(Dataset()); + } + } + else { + _dimensionAction.setPointsDataset(Dataset()); + } //_dimensionAction.setVisible(currentColorDatasetTypeIsPointType); emit currentColorDatasetChanged(currentColorDataset); diff --git a/src/ColoringAction.h b/src/ColoringAction.h index 2cc75b2..4a1d480 100644 --- a/src/ColoringAction.h +++ b/src/ColoringAction.h @@ -127,13 +127,14 @@ class ColoringAction : public VerticalGroupAction void currentColorDatasetChanged(Dataset currentColorDataset); private: - ScatterplotPlugin* _scatterplotPlugin; /** Pointer to scatter plot plugin */ - ColorSourceModel _colorByModel; /** Color by model (model input for the color by action) */ - OptionAction _colorByAction; /** Action for picking the coloring type */ - ColorAction _constantColorAction; /** Action for picking the constant color */ - DimensionPickerAction _dimensionAction; /** Dimension picker action */ - ColorMap1DAction _colorMap1DAction; /** One-dimensional color map action */ - ColorMap2DAction _colorMap2DAction; /** Two-dimensional color map action */ + ScatterplotPlugin* _scatterplotPlugin; /** Pointer to scatter plot plugin */ + ColorSourceModel _colorByModel; /** Color by model (model input for the color by action) */ + OptionAction _colorByAction; /** Action for picking the coloring type */ + ColorAction _constantColorAction; /** Action for picking the constant color */ + DimensionPickerAction _dimensionAction; /** Dimension picker action */ + ColorMap1DAction _colorMap1DAction; /** One-dimensional color map action */ + ColorMap2DAction _colorMap2DAction; /** Two-dimensional color map action */ + Dataset _currentColorPointsDataset; /** Current color dataset */ /** Default constant color */ static const QColor DEFAULT_CONSTANT_COLOR;