22
33#include < CoreInterface.h>
44
5+ #include < graphics/Bounds.h>
6+ #include < graphics/Vector3f.h>
57#include < util/Exception.h>
68
79#include < vector>
810
911#include < QDebug>
10- #include < QGuiApplication>
11- #include < QMatrix4x4>
1212#include < QOpenGLFramebufferObject>
1313#include < QPainter>
1414#include < QSize>
1515#include < QWheelEvent>
1616#include < QWindow>
1717#include < QRectF>
1818
19- #include < math.h>
20-
2119#include " TransferFunctionPlugin.h"
2220
2321using namespace mv ;
@@ -246,11 +244,11 @@ QRect TransferFunctionWidget::getMousePositionsBounds(QPoint newMousePosition) {
246244 if (!_areaSelectionBounds.isValid ()) {
247245 _areaSelectionBounds = QRect (_mousePositions[0 ], _mousePositions[0 ]);
248246 }
249- int left = std::min (_areaSelectionBounds.left (), newMousePosition.x ());
250- int right = std::max (_areaSelectionBounds.right (), newMousePosition.x ());
251- int top = std::min (_areaSelectionBounds.top (), newMousePosition.y ());
252- int bottom = std::max (_areaSelectionBounds.bottom (), newMousePosition.y ());
253- return QRect ( QPoint (left, top), QPoint (right, bottom)) ;
247+ const int left = std::min (_areaSelectionBounds.left (), newMousePosition.x ());
248+ const int right = std::max (_areaSelectionBounds.right (), newMousePosition.x ());
249+ const int top = std::min (_areaSelectionBounds.top (), newMousePosition.y ());
250+ const int bottom = std::max (_areaSelectionBounds.bottom (), newMousePosition.y ());
251+ return { QPoint (left, top), QPoint (right, bottom) } ;
254252}
255253
256254bool TransferFunctionWidget::isInitialized () const
@@ -508,7 +506,7 @@ void TransferFunctionWidget::updateTfTexture()
508506 return ;
509507
510508
511- QImage materialMap = QImage (_boundsPointsWindow.width (), _boundsPointsWindow.height (), QImage::Format_ARGB32);
509+ auto materialMap = QImage (_boundsPointsWindow.width (), _boundsPointsWindow.height (), QImage::Format_ARGB32);
512510 QPainter painter (&materialMap);
513511 painter.setCompositionMode (QPainter::CompositionMode_SourceOver);
514512
@@ -522,10 +520,10 @@ void TransferFunctionWidget::updateTfTexture()
522520
523521 for (int y = _tfTextureSize - 1 ; y >= 0 ; y--) {
524522 for (int x = 0 ; x < _tfTextureSize; x++) {
525- int normalizedX = x * materialMap.width () / _tfTextureSize;
526- int normalizedY = y * materialMap.height () / _tfTextureSize;
523+ const int normalizedX = x * materialMap.width () / _tfTextureSize;
524+ const int normalizedY = y * materialMap.height () / _tfTextureSize;
527525
528- QColor color = materialMap.pixelColor (normalizedX, normalizedY);
526+ const QColor color = materialMap.pixelColor (normalizedX, normalizedY);
529527 data.push_back (color.redF ());
530528 data.push_back (color.greenF ());
531529 data.push_back (color.blueF ());
@@ -545,7 +543,7 @@ void TransferFunctionWidget::updateMaterialPositionsTexture()
545543 return ;
546544
547545
548- QImage materialMap = QImage (_boundsPointsWindow.width (), _boundsPointsWindow.height (), QImage::Format_ARGB32);
546+ auto materialMap = QImage (_boundsPointsWindow.width (), _boundsPointsWindow.height (), QImage::Format_ARGB32);
549547 QPainter painter (&materialMap);
550548 painter.setCompositionMode (QPainter::CompositionMode_SourceOver);
551549
@@ -561,11 +559,11 @@ void TransferFunctionWidget::updateMaterialPositionsTexture()
561559
562560 for (int y = _materialPositionTextureSize - 1 ; y >= 0 ; y--) {
563561 for (int x = 0 ; x < _materialPositionTextureSize; x++) {
564- int normalizedX = x * materialMap.width () / _materialPositionTextureSize;
565- int normalizedY = y * materialMap.height () / _materialPositionTextureSize;
562+ const int normalizedX = x * materialMap.width () / _materialPositionTextureSize;
563+ const int normalizedY = y * materialMap.height () / _materialPositionTextureSize;
566564
567- QColor color = materialMap.pixelColor (normalizedX, normalizedY);
568- data.push_back (color.red ());
565+ const QColor color = materialMap.pixelColor (normalizedX, normalizedY);
566+ data.push_back (color.redF ());
569567 }
570568 }
571569
@@ -575,7 +573,7 @@ void TransferFunctionWidget::updateMaterialPositionsTexture()
575573 events ().notifyDatasetDataChanged (_materialPositionTexture);
576574}
577575
578- void TransferFunctionWidget::updateMaterialTransitionTexture (std::vector<std::vector<QColor>> transitionsTable)
576+ void TransferFunctionWidget::updateMaterialTransitionTexture (const std::vector<std::vector<QColor>>& transitionsTable)
579577{
580578 if (!_materialTransitionTexture.isValid ())
581579 return ;
@@ -585,11 +583,11 @@ void TransferFunctionWidget::updateMaterialTransitionTexture(std::vector<std::ve
585583 data.reserve (_materialTextureSize * _materialTextureSize * 4 );
586584
587585 // for (int y = _materialTextureSize - 1; y >= 0; y--) {
588- for (int y = 0 ; y < _materialTextureSize; y++) {
589- for (int x = 0 ; x < _materialTextureSize; x++) {
586+ for (size_t y = 0 ; y < _materialTextureSize; y++) {
587+ for (size_t x = 0 ; x < _materialTextureSize; x++) {
590588 if (y < transitionsTable.size () && x < transitionsTable[y].size ()) // If the transition table is not big enough, we fill the rest with black
591589 {
592- QColor color = transitionsTable[y][x];
590+ const QColor color = transitionsTable[y][x];
593591 data.push_back (color.redF ());
594592 data.push_back (color.greenF ());
595593 data.push_back (color.blueF ());
@@ -622,7 +620,7 @@ void TransferFunctionWidget::cleanup()
622620
623621void TransferFunctionWidget::updatePixelRatio ()
624622{
625- float pixelRatio = devicePixelRatio ();
623+ const float pixelRatio = devicePixelRatio ();
626624
627625 // we only update if the ratio actually changed
628626 if ( _pixelRatio != pixelRatio )
0 commit comments