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
6 changes: 2 additions & 4 deletions src/ScatterplotPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ void ScatterplotPlugin::selectPoints()
auto& pixelSelectionTool = _scatterPlotWidget->getPixelSelectionTool();

// Only proceed with a valid points position dataset and when the pixel selection tool is active
if (!_positionDataset.isValid() || !pixelSelectionTool.isActive() || _scatterPlotWidget->isNavigating())
if (!_positionDataset.isValid() || !pixelSelectionTool.isActive() || _scatterPlotWidget->isNavigating() || !pixelSelectionTool.isEnabled())
return;

auto selectionAreaImage = pixelSelectionTool.getAreaPixmap().toImage();
Expand Down Expand Up @@ -424,13 +424,11 @@ void ScatterplotPlugin::samplePoints()
{
auto& samplerPixelSelectionTool = _scatterPlotWidget->getSamplerPixelSelectionTool();

if (!_positionDataset.isValid() || _scatterPlotWidget->isNavigating())
if (!_positionDataset.isValid() || !samplerPixelSelectionTool.isActive() || _scatterPlotWidget->isNavigating() || !samplerPixelSelectionTool.isEnabled())
return;

auto selectionAreaImage = samplerPixelSelectionTool.getAreaPixmap().toImage();

auto selectionSet = _positionDataset->getSelection<Points>();

std::vector<std::uint32_t> targetSelectionIndices;

targetSelectionIndices.reserve(_positionDataset->getNumPoints());
Expand Down
2 changes: 1 addition & 1 deletion src/ScatterplotPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class ScatterplotPlugin : public ViewPlugin

private:
mv::gui::DropWidget* _dropWidget; /** Widget for dropping datasets */
ScatterplotWidget* _scatterPlotWidget; /** THe visualization widget */
ScatterplotWidget* _scatterPlotWidget; /** The visualization widget */

Dataset<Points> _positionDataset; /** Smart pointer to points dataset for point position */
Dataset<Points> _positionSourceDataset; /** Smart pointer to source of the points dataset for point position (if any) */
Expand Down
45 changes: 30 additions & 15 deletions src/ScatterplotWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <math.h>

#include "ScatterplotPlugin.h"
#include <ViewPlugin.h>

using namespace mv;

Expand Down Expand Up @@ -48,7 +48,7 @@ namespace
}
}

ScatterplotWidget::ScatterplotWidget() :
ScatterplotWidget::ScatterplotWidget(mv::plugin::ViewPlugin* parentPlugin) :
QOpenGLWidget(),
_pointRenderer(),
_densityRenderer(DensityRenderer::RenderMode::DENSITY),
Expand All @@ -65,7 +65,8 @@ ScatterplotWidget::ScatterplotWidget() :
_pixelRatio(1.0),
_mousePositions(),
_isNavigating(false),
_weightDensity(false)
_weightDensity(false),
_parentPlugin(parentPlugin)
{
setContextMenuPolicy(Qt::CustomContextMenu);
setAcceptDrops(true);
Expand Down Expand Up @@ -152,19 +153,33 @@ bool ScatterplotWidget::event(QEvent* event)
if (!event)
return QOpenGLWidget::event(event);

auto setIsNavigating = [this](bool isNavigating) -> void {
_isNavigating = isNavigating;
_pixelSelectionTool.setEnabled(!isNavigating);
if (isNavigating) {
_samplerPixelSelectionTool.setEnabled(false);
}
else if (_parentPlugin) { // reset to UI-setting
_samplerPixelSelectionTool.setEnabled(_parentPlugin->getSamplerAction().isEnabled());
}

};

// Set navigation flag on Alt press/release
if (event->type() == QEvent::KeyRelease)
{
if (const auto* keyEvent = static_cast<QKeyEvent*>(event))
if (keyEvent->key() == Qt::Key_Alt)
_isNavigating = false;
if (event->type() == QEvent::KeyRelease) {
if (const auto* keyEvent = static_cast<QKeyEvent*>(event)) {
if (keyEvent->key() == Qt::Key_Alt) {
setIsNavigating(false);
}
}

}
else if (event->type() == QEvent::KeyPress)
{
if (const auto* keyEvent = static_cast<QKeyEvent*>(event))
if (keyEvent->key() == Qt::Key_Alt)
_isNavigating = true;
else if (event->type() == QEvent::KeyPress) {
if (const auto* keyEvent = static_cast<QKeyEvent*>(event)) {
if (keyEvent->key() == Qt::Key_Alt) {
setIsNavigating(true);
}
}

}

Expand Down Expand Up @@ -192,7 +207,7 @@ bool ScatterplotWidget::event(QEvent* event)
// Navigation
if (mouseEvent->buttons() == Qt::LeftButton)
{
_pixelSelectionTool.setEnabled(false);
setIsNavigating(true);
setCursor(Qt::ClosedHandCursor);
_mousePositions << mouseEvent->pos();
update();
Expand All @@ -204,7 +219,7 @@ bool ScatterplotWidget::event(QEvent* event)

case QEvent::MouseButtonRelease:
{
_pixelSelectionTool.setEnabled(true);
setIsNavigating(false);
setCursor(Qt::ArrowCursor);
_mousePositions.clear();
update();
Expand Down
11 changes: 8 additions & 3 deletions src/ScatterplotWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
#include <QOpenGLWidget>
#include <QPoint>

class ScatterplotPlugin;

using namespace mv::gui;
using namespace mv::util;

namespace mv::plugin
{
class ViewPlugin;
}

struct widgetSizeInfo {
float width;
float height;
Expand Down Expand Up @@ -49,7 +52,7 @@ class ScatterplotWidget : public QOpenGLWidget, protected QOpenGLFunctions_3_3_C
};

public:
ScatterplotWidget();
ScatterplotWidget(mv::plugin::ViewPlugin* parentPlugin = nullptr);

~ScatterplotWidget();

Expand Down Expand Up @@ -323,5 +326,7 @@ private slots:
bool _isNavigating; /** Boolean determining whether view navigation is currently taking place or not */
bool _weightDensity; /** Use point scalar sizes to weight density */

mv::plugin::ViewPlugin* _parentPlugin = nullptr;

friend class NavigationAction;
};