@@ -167,18 +167,6 @@ ScatterplotWidget::ScatterplotWidget(mv::plugin::ViewPlugin* parentPlugin) :
167167 update ();
168168 });
169169
170- // auto setIsNavigating = [this](bool isNavigating) -> void {
171- // _isNavigating = isNavigating;
172- // _pixelSelectionTool.setEnabled(!isNavigating);
173- // if (isNavigating) {
174- // _samplerPixelSelectionTool.setEnabled(false);
175- // }
176- // else if (_parentPlugin) { // reset to UI-setting
177- // _samplerPixelSelectionTool.setEnabled(_parentPlugin->getSamplerAction().getEnabledAction().isChecked());
178- // }
179-
180- // };
181-
182170 _pointRenderer.getNavigator ().initialize (this );
183171 _densityRenderer.getNavigator ().initialize (this );
184172}
@@ -199,6 +187,37 @@ bool ScatterplotWidget::event(QEvent* event)
199187 }
200188 }
201189
190+ auto setIsNavigating = [this ](bool isNavigating) -> void {
191+ _pixelSelectionTool.setEnabled (getRenderMode () == RenderMode::SCATTERPLOT && !isNavigating);
192+
193+ if (isNavigating) {
194+ _samplerPixelSelectionTool.setEnabled (false );
195+ }
196+ else if (_parentPlugin) {
197+ _samplerPixelSelectionTool.setEnabled (_parentPlugin->getSamplerAction ().getEnabledAction ().isChecked ());
198+ }
199+ };
200+
201+ if (event->type () == QEvent::KeyPress) {
202+ const auto keyEvent = dynamic_cast <QKeyEvent*>(event);
203+
204+ if (keyEvent->key () == Qt::Key_Alt) {
205+ setIsNavigating (true );
206+
207+ return QOpenGLWidget::event (event);
208+ }
209+ }
210+
211+ if (event->type () == QEvent::KeyRelease) {
212+ const auto keyEvent = dynamic_cast <QKeyEvent*>(event);
213+
214+ if (keyEvent->key () == Qt::Key_Alt) {
215+ setIsNavigating (false );
216+
217+ return QOpenGLWidget::event (event);
218+ }
219+ }
220+
202221 return QOpenGLWidget::event (event);
203222}
204223
@@ -285,18 +304,13 @@ void ScatterplotWidget::computeDensity()
285304// by reference then we can upload the data to the GPU, but not store it in the widget.
286305void ScatterplotWidget::setData (const std::vector<Vector2f>* points)
287306{
288- auto dataBounds = getDataBounds (*points);
289-
290- // pass un-adjusted data bounds to renderer for 2D colormapping
291- _pointRenderer.setDataBounds (QRectF (dataBounds.getLeft (), dataBounds.getTop (), dataBounds.getWidth (), dataBounds.getHeight ()));
292-
293- const auto shouldSetBounds = (mv::projects ().isOpeningProject () || mv::projects ().isImportingProject ()) ? false : !_navigationAction.getFreezeZoomAction ().isChecked ();
307+ auto bounds = getDataBounds (*points);
294308
295- // if (shouldSetBounds)
296- // _pointRenderer.setViewBounds(dataBounds);
309+ const auto dataBounds = QRectF (bounds.getLeft (), bounds.getTop (), bounds.getWidth (), bounds.getHeight ());
297310
298- _densityRenderer.setBounds (dataBounds);
299- _dataRectangleAction.setBounds (dataBounds);
311+ _pointRenderer.setDataBounds (dataBounds);
312+ _densityRenderer.setDataBounds (dataBounds);
313+ _dataRectangleAction.setBounds (bounds);
300314
301315 _pointRenderer.setData (*points);
302316 _densityRenderer.setData (points);
@@ -316,7 +330,6 @@ void ScatterplotWidget::setData(const std::vector<Vector2f>* points)
316330 break ;
317331 }
318332 }
319- // _pointRenderer.setSelectionOutlineColor(Vector3f(1, 0, 0));
320333
321334 update ();
322335}
0 commit comments