@@ -40,6 +40,16 @@ DatasetsAction::DatasetsAction(QObject* parent, const QString& title) :
4040 return ;
4141
4242 setupPositionDatasetPickerAction (scatterplotPlugin);
43+ setupColorDatasetPickerAction (scatterplotPlugin);
44+ setupPointSizeDatasetPickerAction (scatterplotPlugin);
45+ setupPointOpacityDatasetPickerAction (scatterplotPlugin);
46+
47+ connect (&mv::projects (), &AbstractProjectManager::projectOpened, this , [this , scatterplotPlugin]() -> void {
48+ setupPositionDatasetPickerAction (scatterplotPlugin);
49+ setupColorDatasetPickerAction (scatterplotPlugin);
50+ setupPointSizeDatasetPickerAction (scatterplotPlugin);
51+ setupPointOpacityDatasetPickerAction (scatterplotPlugin);
52+ });
4353}
4454
4555void DatasetsAction::connectToPublicAction (WidgetAction* publicAction, bool recursive)
@@ -117,127 +127,94 @@ void DatasetsAction::setupColorDatasetPickerAction(ScatterplotPlugin* scatterplo
117127 return (dataset->getDataType () == PointType || dataset->getDataType () == ColorType || dataset->getDataType () == ClusterType);
118128 });
119129
120- /*
121130 auto & coloringAction = settingsAction.getColoringAction ();
122131
123- connect(&_colorDatasetPickerAction, &DatasetPickerAction::datasetPicked, [this, &coloringAction](Dataset<DatasetImpl> pickedDataset) -> void {
124- coloringAction.getColorByAction().setCurrentIndex(pickedDataset.isValid() ? 2 : 0);
125-
126- if (pickedDataset.isValid() && !mv::projects().isOpeningProject())
127- coloringAction.setCurrentColorDataset(pickedDataset);
128- });
129-
130- connect(&settingsAction.getColoringAction(), &ColoringAction::currentColorDatasetChanged, this, [this](Dataset<DatasetImpl> currentColorDataset) -> void {
131- _colorDatasetPickerAction.setCurrentDataset(currentColorDataset);
132- });
133-
134- const auto currentColorDatasetChanged = [this](Dataset<DatasetImpl> currentColorDataset) -> void {
132+ connect (&_colorDatasetPickerAction, &DatasetPickerAction::datasetPicked, [this , &coloringAction, scatterplotPlugin](Dataset<DatasetImpl> pickedDataset) -> void {
135133 if (_colorDataset.isValid ())
136134 disconnect (&_colorDataset, &Dataset<>::guiNameChanged, this , nullptr );
137135
138- _colorDataset = currentColorDataset;
139-
140- connect(&_colorDataset, &Dataset<>::guiNameChanged, this, &ScatterplotPlugin::updateHeadsUpDisplay);
136+ _colorDataset = pickedDataset;
141137
142- //updateHeadsUpDisplay();
143- };
138+ connect (&_colorDataset, &Dataset<>::guiNameChanged, scatterplotPlugin, &ScatterplotPlugin::updateHeadsUpDisplay);
144139
145- connect(&settingsAction.getColoringAction(), &ColoringAction::currentColorDatasetChanged, this, currentColorDatasetChanged );
140+ coloringAction. setCurrentColorDataset (pickedDataset );
146141
147- connect(&settingsAction.getColoringAction().getColorByAction(), &OptionAction::currentIndexChanged, this, [this, &settingsAction, currentColorDatasetChanged](const std::int32_t& currentIndex) -> void {
148- _colorDataset = settingsAction.getColoringAction().getCurrentColorDataset();
142+ if (!pickedDataset.isValid ())
143+ coloringAction.getColorByAction ().setCurrentIndex (0 );
144+ });
149145
150- updateHeadsUpDisplay();
146+ connect (&settingsAction.getColoringAction (), &ColoringAction::currentColorDatasetChanged, this , [this ](Dataset<DatasetImpl> currentColorDataset) -> void {
147+ _colorDatasetPickerAction.setCurrentDataset (currentColorDataset);
151148 });
152- */
153149}
154150
155- void DatasetsAction::setupPointSizeDataset (ScatterplotPlugin* scatterplotPlugin)
151+ void DatasetsAction::setupPointSizeDatasetPickerAction (ScatterplotPlugin* scatterplotPlugin)
156152{
157153 auto & settingsAction = scatterplotPlugin->getSettingsAction ();
158154
159155 _pointSizeDatasetPickerAction.setFilterFunction ([this ](mv::Dataset<DatasetImpl> dataset) -> bool {
160156 return dataset->getDataType () == PointType;
161157 });
162158
163- /*
164- auto& pointPlotAction = scatterplotPlugin->getSettingsAction().getPlotAction().getPointPlotAction();
165- auto& pointSizeAction = pointPlotAction.getSizeAction();
166- auto& pointOpacityAction = pointPlotAction.getOpacityAction();
159+ auto & pointPlotAction = settingsAction.getPlotAction ().getPointPlotAction ();
160+ auto & pointSizeAction = pointPlotAction.getSizeAction ();
161+
162+
163+ connect (&pointSizeAction, &ScalarAction::sourceSelectionChanged, this , [this , &pointSizeAction, scatterplotPlugin](const uint32_t & sourceSelectionIndex) -> void {
164+ if (_pointSizeDataset.isValid ())
165+ disconnect (&_pointSizeDataset, &Dataset<>::guiNameChanged, this , nullptr );
166+
167+ _pointSizeDataset = pointSizeAction.getCurrentDataset ();
168+
169+ connect (&_pointSizeDataset, &Dataset<>::guiNameChanged, scatterplotPlugin, &ScatterplotPlugin::updateHeadsUpDisplay);
167170
168- const auto pointSizeSourceChanged = [this, &pointSizeAction]() -> void {
169171 _pointSizeDatasetPickerAction.setCurrentDataset (pointSizeAction.isSourceDataset () ? pointSizeAction.getCurrentDataset () : nullptr );
170172
171173 if (!pointSizeAction.isSourceDataset ())
172174 _pointSizeDatasetPickerAction.setCurrentIndex (-1 );
173- };
174-
175- connect(&pointSizeAction, &ScalarAction::sourceSelectionChanged, this, pointSizeSourceChanged);
176- connect(&pointSizeAction, &ScalarAction::sourceDataChanged, this, pointSizeSourceChanged);
175+ });
177176
178177 connect (&_pointSizeDatasetPickerAction, &DatasetPickerAction::currentIndexChanged, this , [this , &pointSizeAction](const int32_t & currentIndex) -> void {
179178 pointSizeAction.setCurrentDataset (_pointSizeDatasetPickerAction.getCurrentDataset ());
180179
181180 if (currentIndex < 0 )
182181 pointSizeAction.setCurrentSourceIndex (ScalarSourceModel::DefaultRow::Constant);
183- });
184-
185- const auto pointOpacitySourceChanged = [this, &pointOpacityAction]() -> void {
186- _pointOpacityDatasetPickerAction.setCurrentDataset(pointOpacityAction.isSourceDataset() ? pointOpacityAction.getCurrentDataset() : nullptr);
187-
188- if (!pointOpacityAction.isSourceDataset())
189- _pointOpacityDatasetPickerAction.setCurrentIndex(-1);
190- };
191-
192- connect(&pointOpacityAction, &ScalarAction::sourceSelectionChanged, this, pointOpacitySourceChanged);
193- connect(&pointOpacityAction, &ScalarAction::sourceDataChanged, this, pointOpacitySourceChanged);
194-
195- connect(&_pointOpacityDatasetPickerAction, &DatasetPickerAction::currentIndexChanged, this, [this, &pointOpacityAction](const int32_t& currentIndex) -> void {
196- pointOpacityAction.setCurrentDataset(_pointOpacityDatasetPickerAction.getCurrentDataset());
197-
198- if (currentIndex < 0)
199- pointOpacityAction.setCurrentSourceIndex(ScalarSourceModel::DefaultRow::Constant);
200- });
201-
202-
182+ });
183+ }
203184
204- const auto currentPointSizeDatasetChanged = [this]() -> void {
205- auto currentPointSizeDataset = _settingsAction.getPlotAction().getPointPlotAction().getSizeAction().getCurrentDataset();
185+ void DatasetsAction::setupPointOpacityDatasetPickerAction (ScatterplotPlugin* scatterplotPlugin)
186+ {
187+ auto & settingsAction = scatterplotPlugin->getSettingsAction ();
188+ auto & pointPlotAction = settingsAction.getPlotAction ().getPointPlotAction ();
189+ auto & pointOpacityAction = pointPlotAction.getOpacityAction ();
206190
207- if (_pointSizeDataset.isValid())
208- disconnect(&_pointSizeDataset, &Dataset<>::guiNameChanged, this, nullptr);
191+ _pointOpacityDatasetPickerAction.setFilterFunction ([this , scatterplotPlugin](mv::Dataset<DatasetImpl> dataset) -> bool {
192+ if (dataset->getDataType () != PointType)
193+ return false ;
194+
195+ const auto positionDataset = scatterplotPlugin->getPositionSourceDataset ();
209196
210- _pointSizeDataset = currentPointSizeDataset;
197+ if (!positionDataset.isValid ())
198+ return false ;
211199
212- connect(&_pointSizeDataset, & Dataset<>::guiNameChanged, this, &ScatterplotPlugin::updateHeadsUpDisplay );
200+ const mv:: Dataset<Points> candidatePoints (dataset );
213201
214- updateHeadsUpDisplay();
215- } ;
202+ if (candidatePoints-> getNumPoints () != positionDataset-> getNumPoints ())
203+ return false ;
216204
217- connect(&_settingsAction.getPlotAction().getPointPlotAction().getSizeAction(), &ScalarAction::sourceSelectionChanged, this, currentPointSizeDatasetChanged);
205+ return true ;
206+ });
218207
219- const auto currentPointOpacityDatasetChanged = [this]( ) -> void {
220- auto currentPointOpacityDataset = _settingsAction.getPlotAction().getPointPlotAction().getOpacityAction() .getCurrentDataset();
208+ connect (&_pointOpacityDatasetPickerAction, &DatasetPickerAction::datasetPicked, this , [this , &pointPlotAction, &pointOpacityAction, scatterplotPlugin](mv::Dataset<> pickedDataset ) -> void {
209+ const auto & pointOpacityDataset = _pointOpacityDatasetPickerAction .getCurrentDataset ();
221210
222- if (_pointOpacityDataset .isValid())
211+ if (pointOpacityDataset .isValid ())
223212 disconnect (&_pointOpacityDataset, &Dataset<>::guiNameChanged, this , nullptr );
224213
225- _pointOpacityDataset = currentPointOpacityDataset ;
214+ _pointOpacityDataset = pointOpacityDataset ;
226215
227- connect(&_pointOpacityDataset, &Dataset<>::guiNameChanged, this, &ScatterplotPlugin::updateHeadsUpDisplay);
228-
229- updateHeadsUpDisplay();
230- };
231-
232- connect(&_settingsAction.getPlotAction().getPointPlotAction().getOpacityAction(), &ScalarAction::sourceSelectionChanged, this, currentPointOpacityDatasetChanged);*/
233- }
216+ connect (&_pointOpacityDataset, &Dataset<>::guiNameChanged, scatterplotPlugin, &ScatterplotPlugin::updateHeadsUpDisplay);
234217
235- void DatasetsAction::setupPointOpacityDataset (ScatterplotPlugin* scatterplotPlugin)
236- {
237- auto & settingsAction = scatterplotPlugin->getSettingsAction ();
238-
239- _pointOpacityDatasetPickerAction.setFilterFunction ([this ](mv::Dataset<DatasetImpl> dataset) -> bool {
240- return dataset->getDataType () == PointType;
218+ pointPlotAction.setCurrentPointOpacityDataset (_pointOpacityDataset);
241219 });
242-
243220}
0 commit comments