Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
conan-password: ${{secrets.LKEB_UPLOAD_USER_PASSWORD}}
conan-pem: ${{secrets.LKEB_UPLOAD_CERT_CHAIN}}
rs_ssh_key: ${{ secrets.RULESSUPPORT_DEPLOY_KEY }}
sentry-upload: startsWith(github.ref, 'refs/heads/release/')
sentry-url: ${{secrets.LKEB_SENTRY_URL }}
sentry-org: ${{secrets.LKEB_SENTRY_ORG }}
sentry-project: ${{secrets.LKEB_SENTRY_PROJECT }}
Expand Down
28 changes: 17 additions & 11 deletions src/ColoringAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,24 +127,29 @@ ColoringAction::ColoringAction(QObject* parent, const QString& title) :
connect(&_scatterplotPlugin->getPositionDataset(), &Dataset<Points>::childAdded, this, &ColoringAction::updateColorByActionOptions);
connect(&_scatterplotPlugin->getPositionDataset(), &Dataset<Points>::childRemoved, this, &ColoringAction::updateColorByActionOptions);

connect(&_scatterplotPlugin->getScatterplotWidget(), &ScatterplotWidget::renderModeChanged, this, &ColoringAction::updateScatterPlotWidgetColors);
connect(&_scatterplotPlugin->getScatterplotWidget(), &ScatterplotWidget::coloringModeChanged, this, &ColoringAction::updateScatterPlotWidgetColors);
connect(&_scatterplotPlugin->getScatterplotWidget(), &ScatterplotWidget::coloringModeChanged, this, [this](const ScatterplotWidget::ColoringMode& coloringMode) {
updateScatterPlotWidgetColors();
updateColorMapActionsReadOnly();
});

connect(&_scatterplotPlugin->getScatterplotWidget(), &ScatterplotWidget::renderModeChanged, this, [this](const ScatterplotWidget::RenderMode& renderMode) {
updateScatterPlotWidgetColors();
updateColorMapActionsReadOnly();
});

connect(&_dimensionAction, &DimensionPickerAction::currentDimensionIndexChanged, this, &ColoringAction::updateScatterPlotWidgetColors);
connect(&_dimensionAction, &DimensionPickerAction::currentDimensionIndexChanged, this, &ColoringAction::updateColorMapActionScalarRange);
connect(&_dimensionAction, &DimensionPickerAction::currentDimensionIndexChanged, this, [this](const int32_t& currentDimensionIndex) {
updateScatterPlotWidgetColors();
updateColorMapActionsReadOnly();
updateColorMapActionScalarRange();
});

connect(&_constantColorAction, &ColorAction::colorChanged, this, &ColoringAction::updateScatterplotWidgetColorMap);
connect(&_colorMap1DAction, &ColorMapAction::imageChanged, this, &ColoringAction::updateScatterplotWidgetColorMap);
connect(&_colorMap2DAction, &ColorMapAction::imageChanged, this, &ColoringAction::updateScatterplotWidgetColorMap);
connect(&_scatterplotPlugin->getScatterplotWidget(), &ScatterplotWidget::coloringModeChanged, this, &ColoringAction::updateScatterplotWidgetColorMap);
connect(&_scatterplotPlugin->getScatterplotWidget(), &ScatterplotWidget::renderModeChanged, this, &ColoringAction::updateScatterplotWidgetColorMap);

connect(&_colorMap1DAction.getRangeAction(ColorMapAction::Axis::X), &DecimalRangeAction::rangeChanged, this, &ColoringAction::updateScatterPlotWidgetColorMapRange);
connect(&_colorMap2DAction.getRangeAction(ColorMapAction::Axis::X), &DecimalRangeAction::rangeChanged, this, &ColoringAction::updateScatterPlotWidgetColorMapRange);

connect(&_scatterplotPlugin->getScatterplotWidget(), &ScatterplotWidget::coloringModeChanged, this, &ColoringAction::updateColorMapActionsReadOnly);
connect(&_scatterplotPlugin->getScatterplotWidget(), &ScatterplotWidget::renderModeChanged, this, &ColoringAction::updateColorMapActionsReadOnly);

const auto updateReadOnly = [this]() {
setEnabled(_scatterplotPlugin->getPositionDataset().isValid() && _scatterplotPlugin->getScatterplotWidget().getRenderMode() == ScatterplotWidget::SCATTERPLOT);
};
Expand Down Expand Up @@ -276,7 +281,8 @@ void ColoringAction::updateScatterplotWidgetColorMap()
{
case ScatterplotWidget::SCATTERPLOT:
{
if (_colorByAction.getCurrentIndex() == 0) {
const int32_t currentIndex = _colorByAction.getCurrentIndex();
if (currentIndex == 0) {
QPixmap colorPixmap(1, 1);

colorPixmap.fill(_constantColorAction.getColor());
Expand All @@ -285,7 +291,7 @@ void ColoringAction::updateScatterplotWidgetColorMap()
scatterplotWidget.setScalarEffect(PointEffect::Color);
scatterplotWidget.setColoringMode(ScatterplotWidget::ColoringMode::Constant);
}
else if (_colorByAction.getCurrentIndex() == 1) {
else if (currentIndex == 1) {
scatterplotWidget.setColorMap(_colorMap2DAction.getColorMapImage());
scatterplotWidget.setScalarEffect(PointEffect::Color2D);
scatterplotWidget.setColoringMode(ScatterplotWidget::ColoringMode::Scatter);
Expand Down
67 changes: 51 additions & 16 deletions src/ScatterplotPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,30 @@ ScatterplotPlugin::ScatterplotPlugin(const PluginFactory* factory) :
});
}
else {

// Use the clusters set for points color
dropRegions << new DropWidget::DropRegion(this, "Color", description, "palette", true, [this, candidateDataset]() {
_settingsAction.getColoringAction().addColorDataset(candidateDataset);
_settingsAction.getColoringAction().setCurrentColorDataset(candidateDataset);
});
if (candidateDataset.isValid())
{
// Check to set whether the number of data points comprised throughout all clusters is the same number
// as the number of data points in the dataset we are trying to color
int totalNumIndices = 0;
for (const Cluster& cluster : candidateDataset->getClusters())
{
totalNumIndices += cluster.getIndices().size();
}

if (totalNumIndices == _positionDataset->getNumPoints())
{
// Use the clusters set for points color
dropRegions << new DropWidget::DropRegion(this, "Color", description, "palette", true, [this, candidateDataset]() {
_settingsAction.getColoringAction().addColorDataset(candidateDataset);
_settingsAction.getColoringAction().setCurrentColorDataset(candidateDataset);
});
}
else
{
// Number of indices in clusters doesn't match point dataset
dropRegions << new DropWidget::DropRegion(this, "Incompatible data", "Cluster data does not match number of data points", "exclamation-circle", false);
}
}
}
}
else {
Expand All @@ -264,8 +282,6 @@ ScatterplotPlugin::ScatterplotPlugin(const PluginFactory* factory) :
getLearningCenterAction().addVideos(QStringList({ "Practitioner", "Developer" }));

setOverlayActionsTargetWidget(_scatterPlotWidget);


}

ScatterplotPlugin::~ScatterplotPlugin()
Expand Down Expand Up @@ -376,6 +392,10 @@ void ScatterplotPlugin::init()
connect(&_settingsAction.getColoringAction().getColorByAction(), &OptionAction::currentIndexChanged, this, &ScatterplotPlugin::updateHeadsUpDisplay);
connect(&_settingsAction.getPlotAction().getPointPlotAction().getSizeAction(), &ScalarAction::sourceDataChanged, this, &ScatterplotPlugin::updateHeadsUpDisplay);
connect(&_settingsAction.getPlotAction().getPointPlotAction().getOpacityAction(), &ScalarAction::sourceDataChanged, this, &ScatterplotPlugin::updateHeadsUpDisplay);

updateHeadsUpDisplayTextColor();

connect(&_settingsAction.getMiscellaneousAction().getBackgroundColorAction(), &ColorAction::colorChanged, this, &ScatterplotPlugin::updateHeadsUpDisplayTextColor);
}

void ScatterplotPlugin::loadData(const Datasets& datasets)
Expand Down Expand Up @@ -795,25 +815,24 @@ void ScatterplotPlugin::loadColors(const Dataset<Clusters>& clusters)
if (!clusters.isValid() || !_positionDataset.isValid())
return;

// Mapping from local to global indices
std::vector<std::uint32_t> globalIndices;

// Get global indices from the position dataset
int totalNumPoints = 0;
if (_positionDataset->isDerivedData())
totalNumPoints = _positionSourceDataset->getFullDataset<Points>()->getNumPoints();
else
totalNumPoints = _positionDataset->getFullDataset<Points>()->getNumPoints();

// Mapping from local to global indices
std::vector<std::uint32_t> globalIndices;
_positionDataset->getGlobalIndices(globalIndices);

// Generate color buffer for global and local colors
std::vector<Vector3f> globalColors(totalNumPoints);
std::vector<Vector3f> localColors(_positions.size());
std::vector<Vector3f> localColors(_numPoints);

const auto& clusterVec = clusters->getClusters();

if (totalNumPoints == _positions.size() && clusterVec.size() == totalNumPoints)
if (totalNumPoints == _numPoints && clusterVec.size() == totalNumPoints)
{
for (size_t i = 0; i < static_cast<size_t>(clusterVec.size()); i++)
{
Expand All @@ -824,14 +843,15 @@ void ScatterplotPlugin::loadColors(const Dataset<Clusters>& clusters)
}

}
else
else if(globalIndices.size() == _numPoints)
{
// Loop over all clusters and populate global colors
for (const auto& cluster : clusterVec)
{
const auto color = cluster.getColor();
const auto color = cluster.getColor();
const auto colVec = Vector3f(color.redF(), color.greenF(), color.blueF());
for (const auto& index : cluster.getIndices())
globalColors[index] = Vector3f(color.redF(), color.greenF(), color.blueF());
globalColors[index] = colVec;

}

Expand Down Expand Up @@ -993,6 +1013,19 @@ void ScatterplotPlugin::updateHeadsUpDisplay()
}
}

void ScatterplotPlugin::updateHeadsUpDisplayTextColor()
{
if (auto headsUpDisplayWidget = getWidget().findChild<QWidget*>("HeadsUpDisplayWidget")) {
if (auto headsUpDisplayWidgetTreeView = headsUpDisplayWidget->findChild<QTreeView*>("TreeView")) {
QPalette palette = headsUpDisplayWidgetTreeView->palette();

palette.setColor(QPalette::Text, _settingsAction.getMiscellaneousAction().getBackgroundColorAction().getColor().lightnessF() > .5f ? Qt::black : Qt::white);

headsUpDisplayWidgetTreeView->setPalette(palette);
}
}
}

void ScatterplotPlugin::fromVariantMap(const QVariantMap& variantMap)
{
ViewPlugin::fromVariantMap(variantMap);
Expand All @@ -1014,6 +1047,8 @@ void ScatterplotPlugin::fromVariantMap(const QVariantMap& variantMap)

_scatterPlotWidget->update();
}

updateHeadsUpDisplayTextColor();
}

QVariantMap ScatterplotPlugin::toVariantMap() const
Expand Down
1 change: 1 addition & 0 deletions src/ScatterplotPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class ScatterplotPlugin : public ViewPlugin
void updateSelection();

void updateHeadsUpDisplay();
void updateHeadsUpDisplayTextColor();

public: // Serialization

Expand Down
6 changes: 4 additions & 2 deletions src/ScatterplotWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ ScatterplotWidget::ScatterplotWidget(mv::plugin::ViewPlugin* parentPlugin) :
_pointRenderer(this),
_isInitialized(false),
_renderMode(SCATTERPLOT),
_scalarEffect(PointEffect::Color),
_backgroundColor(255, 255, 255, 255),
_coloringMode(ColoringMode::Constant),
_dataRectangleAction(this, "Data rectangle"),
Expand Down Expand Up @@ -334,7 +335,7 @@ void ScatterplotWidget::setScalars(const std::vector<float>& scalars)
void ScatterplotWidget::setColors(const std::vector<Vector3f>& colors)
{
_pointRenderer.setColors(colors);
_pointRenderer.setScalarEffect(None);
setScalarEffect(PointEffect::None);

update();
}
Expand Down Expand Up @@ -367,6 +368,7 @@ void ScatterplotWidget::setPointScaling(mv::gui::PointScaling scalingMode)
void ScatterplotWidget::setScalarEffect(PointEffect effect)
{
_pointRenderer.setScalarEffect(effect);
_scalarEffect = effect;

update();
}
Expand Down Expand Up @@ -621,7 +623,7 @@ void ScatterplotWidget::initializeGL()
_densityRenderer.init();

// Set a default color map for both renderers
_pointRenderer.setScalarEffect(PointEffect::Color);
_pointRenderer.setScalarEffect(_scalarEffect);

_pointRenderer.setPointScaling(Absolute);
_pointRenderer.setSelectionOutlineColor(Vector3f(1, 0, 0));
Expand Down
1 change: 1 addition & 0 deletions src/ScatterplotWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ private slots:
private:
bool _isInitialized; /** Boolean determining whether the widget it properly initialized or not */
RenderMode _renderMode; /** Current render mode */
PointEffect _scalarEffect; /** Current scalar effect */
QColor _backgroundColor; /** Background color */
ColoringMode _coloringMode; /** Type of point/density coloring */
DecimalRectangleAction _dataRectangleAction; /** Rectangle action for the bounds of the loaded data */
Expand Down