Skip to content

Commit 5817b98

Browse files
authored
Merge pull request #187 from ManiVaultStudio/feature/coloringDimensionPickerUpdateBug
Add dimension changed event to coloring point dataset
2 parents e7cffe7 + 5512ee4 commit 5817b98

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

src/ColoringAction.cpp

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,33 @@ ColoringAction::ColoringAction(QObject* parent, const QString& title) :
7272

7373
const auto currentColorDataset = getCurrentColorDataset();
7474

75-
if (currentColorDataset.isValid()) {
76-
const auto currentColorDatasetTypeIsPointType = currentColorDataset->getDataType() == PointType;
75+
if (_currentColorPointsDataset.isValid()) {
76+
disconnect(&_currentColorPointsDataset, &Dataset<Points>::dataDimensionsChanged, this, nullptr);
77+
}
7778

78-
_dimensionAction.setPointsDataset(currentColorDatasetTypeIsPointType ? Dataset<Points>(currentColorDataset) : Dataset<Points>());
79+
_currentColorPointsDataset = Dataset<Points>();
80+
81+
if (currentColorDataset.isValid()) {
82+
if (currentColorDataset->getDataType() == PointType) {
83+
_currentColorPointsDataset = currentColorDataset.get<Points>();
84+
85+
if (_currentColorPointsDataset.isValid()) {
86+
connect(&_currentColorPointsDataset, &Dataset<Points>::dataDimensionsChanged, this, [this]() {
87+
if (_currentColorPointsDataset.isValid()) {
88+
_dimensionAction.setPointsDataset(_currentColorPointsDataset);
89+
updateScatterPlotWidgetColors();
90+
}
91+
});
92+
93+
_dimensionAction.setPointsDataset(_currentColorPointsDataset);
94+
}
95+
else {
96+
_dimensionAction.setPointsDataset(Dataset<Points>());
97+
}
98+
}
99+
else {
100+
_dimensionAction.setPointsDataset(Dataset<Points>());
101+
}
79102
//_dimensionAction.setVisible(currentColorDatasetTypeIsPointType);
80103

81104
emit currentColorDatasetChanged(currentColorDataset);

src/ColoringAction.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,14 @@ class ColoringAction : public VerticalGroupAction
127127
void currentColorDatasetChanged(Dataset<DatasetImpl> currentColorDataset);
128128

129129
private:
130-
ScatterplotPlugin* _scatterplotPlugin; /** Pointer to scatter plot plugin */
131-
ColorSourceModel _colorByModel; /** Color by model (model input for the color by action) */
132-
OptionAction _colorByAction; /** Action for picking the coloring type */
133-
ColorAction _constantColorAction; /** Action for picking the constant color */
134-
DimensionPickerAction _dimensionAction; /** Dimension picker action */
135-
ColorMap1DAction _colorMap1DAction; /** One-dimensional color map action */
136-
ColorMap2DAction _colorMap2DAction; /** Two-dimensional color map action */
130+
ScatterplotPlugin* _scatterplotPlugin; /** Pointer to scatter plot plugin */
131+
ColorSourceModel _colorByModel; /** Color by model (model input for the color by action) */
132+
OptionAction _colorByAction; /** Action for picking the coloring type */
133+
ColorAction _constantColorAction; /** Action for picking the constant color */
134+
DimensionPickerAction _dimensionAction; /** Dimension picker action */
135+
ColorMap1DAction _colorMap1DAction; /** One-dimensional color map action */
136+
ColorMap2DAction _colorMap2DAction; /** Two-dimensional color map action */
137+
Dataset<Points> _currentColorPointsDataset; /** Current color dataset */
137138

138139
/** Default constant color */
139140
static const QColor DEFAULT_CONSTANT_COLOR;

0 commit comments

Comments
 (0)