1818#include < widgets/ViewPluginLearningCenterOverlayWidget.h>
1919
2020#include < actions/PluginTriggerAction.h>
21+ #include < actions/ViewPluginSamplerAction.h>
2122
2223#include < DatasetsMimeData.h>
2324
2930#include < QtCore>
3031
3132#include < algorithm>
32- #include < functional >
33+ #include < cassert >
3334#include < vector>
34- #include < actions/ViewPluginSamplerAction.h>
3535
3636#define VIEW_SAMPLING_HTML
3737// #define VIEW_SAMPLING_WIDGET
@@ -172,7 +172,17 @@ ScatterplotPlugin::ScatterplotPlugin(const PluginFactory* factory) :
172172 });
173173 }
174174
175- if (candidateDataset->getNumPoints () == _positionDataset->getNumPoints ()) {
175+ // const auto numPointsCand = candidateDataset->getNumPoints();
176+ // const auto numPointsPos = _positionDataset->getNumPoints();
177+ // const bool sameNumPoints = numPointsCand == numPointsPos;
178+ // bool sameNumPointsAsFull = false;
179+
180+ // if (_positionDataset->isDerivedData()) {
181+ // const auto numPointsSor = _positionDataset->getSourceDataset<Points>()->getNumPoints();
182+ // sameNumPointsAsFull = numPointsCand == numPointsSor;
183+ // }
184+
185+ // if (sameNumPoints || sameNumPointsAsFull) {
176186
177187 // The number of points is equal, so offer the option to use the points dataset as source for points colors
178188 dropRegions << new DropWidget::DropRegion (this , " Point color" , QString (" Colorize %1 points with %2" ).arg (_positionDataset->text (), candidateDataset->text ()), " palette" , true , [this , candidateDataset]() {
@@ -191,7 +201,7 @@ ScatterplotPlugin::ScatterplotPlugin(const PluginFactory* factory) :
191201 _settingsAction.getPlotAction ().getPointPlotAction ().addPointOpacityDataset (candidateDataset);
192202 _settingsAction.getPlotAction ().getPointPlotAction ().getOpacityAction ().setCurrentDataset (candidateDataset);
193203 });
194- }
204+ // }
195205 }
196206 }
197207
@@ -647,15 +657,29 @@ void ScatterplotPlugin::loadColors(const Dataset<Points>& points, const std::uin
647657 // Generate point scalars for color mapping
648658 std::vector<float > scalars;
649659
650- if (_positionDataset->getNumPoints () != _numPoints)
651- {
652- qWarning (" Number of points used for coloring does not match number of points in data, aborting attempt to color plot" );
653- return ;
654- }
655-
656- // Populate point scalars
657660 points->extractDataForDimension (scalars, dimensionIndex);
658661
662+ // if (_positionSourceDataset->getNumPoints() == points->getNumPoints())
663+ // {
664+ std::vector<std::uint32_t > globalIndices;
665+ _positionDataset->getGlobalIndices (globalIndices);
666+
667+ std::vector<float > localScalars (_numPoints, 0 );
668+ std::int32_t localColorIndex = 0 ;
669+
670+ for (const auto & globalIndex : globalIndices)
671+ localScalars[localColorIndex++] = scalars[globalIndex];
672+
673+ std::swap (localScalars, scalars);
674+
675+ // }
676+ // else if (points->getNumPoints() != _numPoints) {
677+ // qWarning("Number of points used for coloring does not match number of points in data, aborting attempt to color plot");
678+ // return;
679+ // }
680+
681+ assert (scalars.size () == _numPoints);
682+
659683 // Assign scalars and scalar effect
660684 _scatterPlotWidget->setScalars (scalars);
661685 _scatterPlotWidget->setScalarEffect (PointEffect::Color);
0 commit comments