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
23 changes: 6 additions & 17 deletions DVRTransferFunction/src/InteractiveShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,14 @@ InteractiveShape::InteractiveShape(const QPixmap& pixmap, const QRectF& rect, co
}

void InteractiveShape::draw(QPainter& painter, bool drawBorder, bool useGlobalAlpha, bool normalizeWindow /*true*/, QColor borderColor /* Black */) const {
QRectF adjustedRect;
if (normalizeWindow) {
adjustedRect = getRelativeRect();
} else {
adjustedRect = getAbsoluteRect();
}
const QRectF adjustedRect = normalizeWindow ? getRelativeRect() : getAbsoluteRect();
if (drawBorder) {
QPen pen(borderColor);
pen.setWidth(2);
painter.setPen(pen);
painter.drawRect(adjustedRect);

QRectF topRightRect(adjustedRect.topRight() - QPointF(_threshold, 0), QSizeF(_threshold, _threshold));
const QRectF topRightRect(adjustedRect.topRight() - QPointF(_threshold, 0), QSizeF(_threshold, _threshold));
painter.setPen(pen);
painter.drawRect(topRightRect);
}
Expand All @@ -43,13 +38,7 @@ void InteractiveShape::draw(QPainter& painter, bool drawBorder, bool useGlobalAl
}

void InteractiveShape::drawID(QPainter& painter, bool normalizeWindow, int id) const {
QRectF adjustedRect;
if (normalizeWindow) {
adjustedRect = getRelativeRect();
}
else {
adjustedRect = getAbsoluteRect();
}
const QRectF adjustedRect = normalizeWindow ? getRelativeRect() : getAbsoluteRect();

painter.setCompositionMode(QPainter::CompositionMode_SourceOver);

Expand Down Expand Up @@ -90,7 +79,7 @@ void InteractiveShape::resizeBy(const QPointF& delta, SelectedSide& side) {
break;
}
if (_rect.left() > _rect.right()) {
qreal temp = _rect.left();
const qreal temp = _rect.left();
_rect.setLeft(_rect.right());
_rect.setRight(temp);
if (side == SelectedSide::Left) {
Expand All @@ -99,7 +88,7 @@ void InteractiveShape::resizeBy(const QPointF& delta, SelectedSide& side) {
side = SelectedSide::Left;
}
} else if (_rect.top() > _rect.bottom()) {
qreal temp = _rect.top();
const qreal temp = _rect.top();
_rect.setTop(_rect.bottom());
_rect.setBottom(temp);
if (side == SelectedSide::Top) {
Expand All @@ -111,7 +100,7 @@ void InteractiveShape::resizeBy(const QPointF& delta, SelectedSide& side) {
}

bool InteractiveShape::isNearSide(const QPointF& point, SelectedSide& side) const {
QRectF adjustedRect = getRelativeRect();
const QRectF adjustedRect = getRelativeRect();
if (std::abs(point.x() - adjustedRect.left()) <= _threshold && point.y() <= adjustedRect.bottom() && point.y() >= adjustedRect.top()) {
side = SelectedSide::Left;
return true;
Expand Down
10 changes: 5 additions & 5 deletions DVRTransferFunction/src/MaterialTransitionsAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void MaterialTransitionsAction::initialize(TransferFunctionPlugin* transferFunct

TransferFunctionWidget& widget = transferFunctionPlugin->getTransferFunctionWidget();

connect(&widget, &TransferFunctionWidget::shapeCreated, this, [this, &widget](std::vector<InteractiveShape> interactiveShapes) {
connect(&widget, &TransferFunctionWidget::shapeCreated, this, [this, &widget](const std::vector<InteractiveShape>& interactiveShapes) {
_interactiveShapes = interactiveShapes;

// Resize the table to the new size
Expand All @@ -53,7 +53,7 @@ void MaterialTransitionsAction::initialize(TransferFunctionPlugin* transferFunct
emit headersChanged(interactiveShapes);
});

connect(&widget, &TransferFunctionWidget::shapeDeleted, this, [this, &widget](std::vector<InteractiveShape> interactiveShapes) {
connect(&widget, &TransferFunctionWidget::shapeDeleted, this, [this, &widget](const std::vector<InteractiveShape>& interactiveShapes) {
_interactiveShapes = interactiveShapes;

// Resize the table to the new size
Expand Down Expand Up @@ -157,7 +157,7 @@ MaterialTransitionsAction::Widget::Widget(QWidget* parent, MaterialTransitionsAc
updateTable(transitions);
});

connect(materialTransitionsAction, &MaterialTransitionsAction::headersChanged, this, [this, materialTransitionsAction](std::vector<InteractiveShape> interactiveShapes) {
connect(materialTransitionsAction, &MaterialTransitionsAction::headersChanged, this, [this, materialTransitionsAction](const std::vector<InteractiveShape>& interactiveShapes) {
updateHeaderColors(interactiveShapes);
});

Expand All @@ -173,7 +173,7 @@ MaterialTransitionsAction::Widget::Widget(QWidget* parent, MaterialTransitionsAc
_globalAlphaValue = globalAlphaValue;
});

connect(materialTransitionsAction, &MaterialTransitionsAction::tableUpdateNeeded, this, [this, materialTransitionsAction](std::vector<InteractiveShape> interactiveShapes, std::vector<std::vector<QColor>> transitions
connect(materialTransitionsAction, &MaterialTransitionsAction::tableUpdateNeeded, this, [this, materialTransitionsAction](const std::vector<InteractiveShape>& interactiveShapes, const std::vector<std::vector<QColor>>& transitions
) {
updateTable(transitions);
updateHeaderColors(interactiveShapes);
Expand Down Expand Up @@ -202,7 +202,7 @@ void MaterialTransitionsAction::Widget::updateTable(const std::vector<std::vecto
}
}

void MaterialTransitionsAction::Widget::updateHeaderColors(std::vector<InteractiveShape> interactiveShapes)
void MaterialTransitionsAction::Widget::updateHeaderColors(const std::vector<InteractiveShape>& interactiveShapes)
{
const int size = static_cast<int>(interactiveShapes.size()) + 1;
// Set the background color for the headers
Expand Down
7 changes: 3 additions & 4 deletions DVRTransferFunction/src/MaterialTransitionsAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,13 @@ class MaterialTransitionsAction : public WidgetAction

signals:
void transitionChanged(const std::vector<std::vector<QColor>>& transitions);
void headersChanged(std::vector<InteractiveShape> interactiveShapes);
void headersChanged(const std::vector<InteractiveShape>& interactiveShapes);

void transitionSelected(int row, int column);

void globalAlphaToggled(bool useGlobalAlpha);
void globalAlphaChanged(int globalAlphaValue);
void tableUpdateNeeded(std::vector<InteractiveShape> interactiveShapes, std::vector<std::vector<QColor>> transitions);

void tableUpdateNeeded(const std::vector<InteractiveShape>& interactiveShapes, const std::vector<std::vector<QColor>>& transitions);

protected:
TransferFunctionPlugin* _transferFunctionPlugin; /** Pointer to scatterplot plugin */
Expand All @@ -74,7 +73,7 @@ class MaterialTransitionsAction : public WidgetAction
int _globalAlphaValue = 100;

void updateTable(const std::vector<std::vector<QColor>>& transitions);
void updateHeaderColors(std::vector<InteractiveShape> interactiveShapes);
void updateHeaderColors(const std::vector<InteractiveShape>& interactiveShapes);

friend class MaterialTransitionsAction;
};
Expand Down
5 changes: 0 additions & 5 deletions DVRTransferFunction/src/TransferFunctionPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include <DataHierarchyItem.h>

#include <util/PixelSelectionTool.h>
#include <util/StyledIcon.h>
#include <util/Timer.h>

#include <ClusterData/ClusterData.h>
#include <ColorData/ColorData.h>
Expand All @@ -23,13 +21,10 @@
#include <DatasetsMimeData.h>

#include <QAction>
#include <QApplication>
#include <QDebug>
#include <QMenu>
#include <QMetaType>
#include <QtCore>

#include <algorithm>
#include <functional>
#include <vector>
#include <actions/ViewPluginSamplerAction.h>
Expand Down
44 changes: 21 additions & 23 deletions DVRTransferFunction/src/TransferFunctionWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@

#include <CoreInterface.h>

#include <graphics/Bounds.h>
#include <graphics/Vector3f.h>
#include <util/Exception.h>

#include <vector>

#include <QDebug>
#include <QGuiApplication>
#include <QMatrix4x4>
#include <QOpenGLFramebufferObject>
#include <QPainter>
#include <QSize>
#include <QWheelEvent>
#include <QWindow>
#include <QRectF>

#include <math.h>

#include "TransferFunctionPlugin.h"

using namespace mv;
Expand Down Expand Up @@ -246,11 +244,11 @@ QRect TransferFunctionWidget::getMousePositionsBounds(QPoint newMousePosition) {
if (!_areaSelectionBounds.isValid()) {
_areaSelectionBounds = QRect(_mousePositions[0], _mousePositions[0]);
}
int left = std::min(_areaSelectionBounds.left(), newMousePosition.x());
int right = std::max(_areaSelectionBounds.right(), newMousePosition.x());
int top = std::min(_areaSelectionBounds.top(), newMousePosition.y());
int bottom = std::max(_areaSelectionBounds.bottom(), newMousePosition.y());
return QRect(QPoint(left, top), QPoint(right, bottom));
const int left = std::min(_areaSelectionBounds.left(), newMousePosition.x());
const int right = std::max(_areaSelectionBounds.right(), newMousePosition.x());
const int top = std::min(_areaSelectionBounds.top(), newMousePosition.y());
const int bottom = std::max(_areaSelectionBounds.bottom(), newMousePosition.y());
return { QPoint(left, top), QPoint(right, bottom) };
}

bool TransferFunctionWidget::isInitialized() const
Expand Down Expand Up @@ -508,7 +506,7 @@ void TransferFunctionWidget::updateTfTexture()
return;


QImage materialMap = QImage(_boundsPointsWindow.width(), _boundsPointsWindow.height(), QImage::Format_ARGB32);
auto materialMap = QImage(_boundsPointsWindow.width(), _boundsPointsWindow.height(), QImage::Format_ARGB32);
QPainter painter(&materialMap);
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);

Expand All @@ -522,10 +520,10 @@ void TransferFunctionWidget::updateTfTexture()

for (int y = _tfTextureSize - 1; y >= 0; y--) {
for (int x = 0; x < _tfTextureSize; x++) {
int normalizedX = x * materialMap.width() / _tfTextureSize;
int normalizedY = y * materialMap.height() / _tfTextureSize;
const int normalizedX = x * materialMap.width() / _tfTextureSize;
const int normalizedY = y * materialMap.height() / _tfTextureSize;

QColor color = materialMap.pixelColor(normalizedX, normalizedY);
const QColor color = materialMap.pixelColor(normalizedX, normalizedY);
data.push_back(color.redF());
data.push_back(color.greenF());
data.push_back(color.blueF());
Expand All @@ -545,7 +543,7 @@ void TransferFunctionWidget::updateMaterialPositionsTexture()
return;


QImage materialMap = QImage(_boundsPointsWindow.width(), _boundsPointsWindow.height(), QImage::Format_ARGB32);
auto materialMap = QImage(_boundsPointsWindow.width(), _boundsPointsWindow.height(), QImage::Format_ARGB32);
QPainter painter(&materialMap);
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);

Expand All @@ -561,11 +559,11 @@ void TransferFunctionWidget::updateMaterialPositionsTexture()

for (int y = _materialPositionTextureSize - 1; y >= 0; y--) {
for (int x = 0; x < _materialPositionTextureSize; x++) {
int normalizedX = x * materialMap.width() / _materialPositionTextureSize;
int normalizedY = y * materialMap.height() / _materialPositionTextureSize;
const int normalizedX = x * materialMap.width() / _materialPositionTextureSize;
const int normalizedY = y * materialMap.height() / _materialPositionTextureSize;

QColor color = materialMap.pixelColor(normalizedX, normalizedY);
data.push_back(color.red());
const QColor color = materialMap.pixelColor(normalizedX, normalizedY);
data.push_back(color.redF());
}
}

Expand All @@ -575,7 +573,7 @@ void TransferFunctionWidget::updateMaterialPositionsTexture()
events().notifyDatasetDataChanged(_materialPositionTexture);
}

void TransferFunctionWidget::updateMaterialTransitionTexture(std::vector<std::vector<QColor>> transitionsTable)
void TransferFunctionWidget::updateMaterialTransitionTexture(const std::vector<std::vector<QColor>>& transitionsTable)
{
if (!_materialTransitionTexture.isValid())
return;
Expand All @@ -585,11 +583,11 @@ void TransferFunctionWidget::updateMaterialTransitionTexture(std::vector<std::ve
data.reserve(_materialTextureSize * _materialTextureSize * 4);

//for (int y = _materialTextureSize - 1; y >= 0; y--) {
for (int y = 0; y < _materialTextureSize; y++) {
for (int x = 0; x < _materialTextureSize; x++) {
for (size_t y = 0; y < _materialTextureSize; y++) {
for (size_t x = 0; x < _materialTextureSize; x++) {
if (y < transitionsTable.size() && x < transitionsTable[y].size()) // If the transition table is not big enough, we fill the rest with black
{
QColor color = transitionsTable[y][x];
const QColor color = transitionsTable[y][x];
data.push_back(color.redF());
data.push_back(color.greenF());
data.push_back(color.blueF());
Expand Down Expand Up @@ -622,7 +620,7 @@ void TransferFunctionWidget::cleanup()

void TransferFunctionWidget::updatePixelRatio()
{
float pixelRatio = devicePixelRatio();
const float pixelRatio = devicePixelRatio();

// we only update if the ratio actually changed
if( _pixelRatio != pixelRatio )
Expand Down
15 changes: 3 additions & 12 deletions DVRTransferFunction/src/TransferFunctionWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@

#include <util/PixelSelectionTool.h>

#include <actions/DecimalRectangleAction.h>

#include <graphics/Bounds.h>
#include <graphics/Vector2f.h>
#include <graphics/Vector3f.h>

#include <QOpenGLFunctions_3_3_Core>
#include <QOpenGLWidget>
Expand All @@ -18,7 +14,6 @@
#include "InteractiveShape.h"
#include "ImageData/Images.h"


class TransferFunctionPlugin;

using namespace mv::gui;
Expand Down Expand Up @@ -47,7 +42,7 @@ class TransferFunctionWidget : public QOpenGLWidget, protected QOpenGLFunctions_
bool isInitialized() const;

// This method is public because the UI decides when to update the widget
void updateMaterialTransitionTexture(std::vector<std::vector<QColor>> transitionsTable);
void updateMaterialTransitionTexture(const std::vector<std::vector<QColor>>& transitionsTable);

InteractiveShape* getSelectedObject() { return _selectedObject; }
std::vector<InteractiveShape>& getInteractiveShapes() { return _interactiveShapes; }
Expand Down Expand Up @@ -76,10 +71,6 @@ class TransferFunctionWidget : public QOpenGLWidget, protected QOpenGLFunctions_

void showHighlights(bool show);

mv::Bounds getBounds() const {
return _dataRectangleAction.getBounds();
}

void setGlobalAlphaToggle(bool useGlobalAlpha);
void setGlobalAlphaValue(int globalAlphaValue);

Expand Down Expand Up @@ -154,8 +145,8 @@ class TransferFunctionWidget : public QOpenGLWidget, protected QOpenGLFunctions_

// Signals when a new shape gets selected and passes a pointer of it
void shapeSelected(InteractiveShape* shape);
void shapeCreated(std::vector<InteractiveShape> interactiveShapes);
void shapeDeleted(std::vector<InteractiveShape> interactiveShapes);
void shapeCreated(const std::vector<InteractiveShape>& interactiveShapes);
void shapeDeleted(const std::vector<InteractiveShape>& interactiveShapes);

private slots:
void updatePixelRatio();
Expand Down
6 changes: 2 additions & 4 deletions DVRViewPlugin/src/DVRViewPlugin.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "DVRViewPlugin.h"
#include "DVRWidget.h"

#include "GlobalSettingsAction.h"
#include <DVRVolumeData/VolumeData.h>

#include <graphics/Vector2f.h>
#include "GlobalSettingsAction.h"

#include <DatasetsMimeData.h>

Expand All @@ -12,8 +12,6 @@

#include <random>
#include <numeric>
#include <hnswlib/hnswlib.h>
#include <iostream>
#include <vector>

Q_PLUGIN_METADATA(IID "studio.manivault.DVRViewPlugin")
Expand Down
9 changes: 3 additions & 6 deletions DVRViewPlugin/src/DVRViewPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "SettingsAction.h"

#include <QWidget>
#include <DVRVolumeData/VolumeData.h>
#include <DVRVolumeData/Volumes.h>

/** All plugin related classes are in the ManiVault plugin namespace */
Expand Down Expand Up @@ -67,7 +66,7 @@ class DVRViewPlugin : public ViewPlugin
void updateMaterialPositionsData();

private:
/** We create and publish some data in order to provide an self-contained DVR project */
/** We create and publish some data in order to provide a self-contained DVR project */
std::vector<std::uint32_t> generateSequence(int n);

QString getVolumeDataSetID() const;
Expand All @@ -80,14 +79,12 @@ class DVRViewPlugin : public ViewPlugin
DropWidget* _dropWidget; /** Widget for drag and drop behavior */
DVRWidget* _DVRWidget; /** The OpenGL widget */
SettingsAction _settingsAction; /** Settings action */
mv::Dataset<Volumes> _volumeDataset; /** Volume containg the multivariate dataset */
mv::Dataset<Volumes> _volumeDataset; /** Volume containing the multivariate dataset */
mv::Dataset<Images> _tfTexture; /** Texture containing the color transfer function data */
mv::Dataset<Images> _materialTransitionTexture; /** Texture containing material transition data */
mv::Dataset<Images> _materialPositionTexture; /** Texture containing material position data */
mv::Dataset<Points> _reducedPosDataset; /** Dataset containing the dimensionality recuded locations of all the points in the volume */
mv::Dataset<Points> _reducedPosDataset; /** Dataset containing the dimensionality reduced locations of all the points in the volume */
std::vector<unsigned int> _currentDimensions; /** Stores which dimensions of the current data are shown */
std::vector<float> _spatialData; /** Spatial data */
std::vector<float> _valueData; /** Value data */
};

/**
Expand Down
Loading
Loading