Explorar el Código

Merge branch 'crosshairAndMagnificationWidgetsOnVisualStudio'

* crosshairAndMagnificationWidgetsOnVisualStudio:
  STYLE: Remove unnecessary semi-colons.
  BUG: Visual studio doesn't implement round()
  BUG: Initializing class constants of type double is illegal C++.
Danielle Pace hace 14 años
padre
commit
49d2348235

+ 9 - 8
Libs/Visualization/VTK/Widgets/ctkVTKMagnifyView.cpp

@@ -31,6 +31,7 @@
 
 // VTK includes
 #include <QVTKWidget.h>
+#include <vtkMath.h>
 #include <vtkRenderWindow.h>
 #include <vtkUnsignedCharArray.h>
 
@@ -386,16 +387,16 @@ void ctkVTKMagnifyViewPrivate::updatePixmap()
 
   // When cropping the Qt image, the 'adjust' variables are in Qt coordinates,
   // not render window coordinates (bottom and top switch).
-  int cropIndexLeft = round(errorLeft);
-  int cropIndexRight = imageSize.width() - round(errorRight) - 1;
-  int cropIndexTop = round(errorTop);
-  int cropIndexBottom = imageSize.height() - round(errorBottom) - 1;
+  int cropIndexLeft = vtkMath::Round(errorLeft);
+  int cropIndexRight = imageSize.width() - vtkMath::Round(errorRight) - 1;
+  int cropIndexTop = vtkMath::Round(errorTop);
+  int cropIndexBottom = imageSize.height() - vtkMath::Round(errorBottom) - 1;
 
   // Handle case when label size and magnification are not both even or odd
   // (errorLeft/errorRight/errorBottom/errorTop will have fractional component,
   // so cropped image wouldn't be the correct size unless we adjust further).
-  int requiredWidth = round((posRight - posLeft + 1) * this->Magnification);
-  int requiredHeight = round((posTop - posBottom + 1) * this->Magnification);
+  int requiredWidth = vtkMath::Round((posRight - posLeft + 1) * this->Magnification);
+  int requiredHeight = vtkMath::Round((posTop - posBottom + 1) * this->Magnification);
   int actualWidth = cropIndexRight - cropIndexLeft + 1;
   int actualHeight = cropIndexBottom - cropIndexTop + 1;
   int diffWidth = requiredWidth - actualWidth;
@@ -455,7 +456,7 @@ ctkVTKMagnifyView::~ctkVTKMagnifyView()
 }
 
 // --------------------------------------------------------------------------
-CTK_GET_CPP(ctkVTKMagnifyView, double, magnification, Magnification);
+CTK_GET_CPP(ctkVTKMagnifyView, double, magnification, Magnification)
 
 // --------------------------------------------------------------------------
 void ctkVTKMagnifyView::setMagnification(double newMagnification)
@@ -472,7 +473,7 @@ void ctkVTKMagnifyView::setMagnification(double newMagnification)
 
 // --------------------------------------------------------------------------
 CTK_GET_CPP(ctkVTKMagnifyView, bool,
-            observeRenderWindowEvents, ObserveRenderWindowEvents);
+            observeRenderWindowEvents, ObserveRenderWindowEvents)
 
 // --------------------------------------------------------------------------
 void ctkVTKMagnifyView::setObserveRenderWindowEvents(bool newObserve)

+ 4 - 4
Libs/Visualization/VTK/Widgets/ctkVTKMagnifyView.h

@@ -42,9 +42,9 @@ class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKMagnifyView
   : public ctkCrosshairLabel
 {
   Q_OBJECT
-  Q_PROPERTY(double magnification READ magnification WRITE setMagnification);
+  Q_PROPERTY(double magnification READ magnification WRITE setMagnification)
   Q_PROPERTY(bool observeRenderWindowEvents
-             READ observeRenderWindowEvents WRITE setObserveRenderWindowEvents);
+             READ observeRenderWindowEvents WRITE setObserveRenderWindowEvents)
   Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval)
 
 public:
@@ -109,8 +109,8 @@ signals:
   void leftObservedWidget(QVTKWidget * widget);
 
 private:
-  Q_DECLARE_PRIVATE(ctkVTKMagnifyView);
-  Q_DISABLE_COPY(ctkVTKMagnifyView);
+  Q_DECLARE_PRIVATE(ctkVTKMagnifyView)
+  Q_DISABLE_COPY(ctkVTKMagnifyView)
 }; 
 
 #endif

+ 13 - 8
Libs/Widgets/ctkCrosshairLabel.cpp

@@ -39,7 +39,7 @@ static ctkLogger logger("org.commontk.visualization.vtk.widgets.ctkCrosshairLabe
 //-----------------------------------------------------------------------------
 class ctkCrosshairLabelPrivate
 {
-  Q_DECLARE_PUBLIC(ctkCrosshairLabel);
+  Q_DECLARE_PUBLIC(ctkCrosshairLabel)
 protected:
   ctkCrosshairLabel* const q_ptr;
 public:
@@ -50,14 +50,19 @@ public:
   void drawSimpleCrosshair(QPainter& painter);
   void drawBullsEyeCrosshair(QPainter& painter);
 
+  static int round(double f)
+    { return static_cast<int>( f + ( f >= 0 ? 0.5 : -0.5 ) ); }
+
   bool      ShowCrosshair;
   QPen      CrosshairPen;
   ctkCrosshairLabel::CrosshairTypes CrosshairType;
   int       BullsEyeWidth;
 
-  static const double BULLS_EYE_BLANK_FRACTION = 0.1;
+  static const double BULLS_EYE_BLANK_FRACTION;
 };
 
+const double ctkCrosshairLabelPrivate::BULLS_EYE_BLANK_FRACTION = 0.1;
+
 // --------------------------------------------------------------------------
 // ctkCrosshairLabelPrivate methods
 
@@ -146,8 +151,8 @@ void ctkCrosshairLabelPrivate::drawBullsEyeCrosshair(QPainter& painter)
   // Draw the lines
   double halfWidth = (size.width()-1.0) / 2.0;
   double halfHeight = (size.height()-1.0) / 2.0;
-  double blank = round(std::min(halfWidth, halfHeight)
-                       * this->BULLS_EYE_BLANK_FRACTION);
+  double blank = ctkCrosshairLabelPrivate::round(
+        std::min(halfWidth, halfHeight) * this->BULLS_EYE_BLANK_FRACTION);
 
   painter.drawLine(QPointF(0, halfHeight), QPointF(x-blank-1.0, halfHeight));
   painter.drawLine(QPointF(x+bullsEye+blank, halfHeight),
@@ -175,7 +180,7 @@ ctkCrosshairLabel::~ctkCrosshairLabel()
 }
 
 // --------------------------------------------------------------------------
-CTK_GET_CPP(ctkCrosshairLabel, bool, showCrosshair, ShowCrosshair);
+CTK_GET_CPP(ctkCrosshairLabel, bool, showCrosshair, ShowCrosshair)
 
 // --------------------------------------------------------------------------
 void ctkCrosshairLabel::setShowCrosshair(bool newShow)
@@ -191,7 +196,7 @@ void ctkCrosshairLabel::setShowCrosshair(bool newShow)
 }
 
 // --------------------------------------------------------------------------
-CTK_GET_CPP(ctkCrosshairLabel, QPen, crosshairPen, CrosshairPen);
+CTK_GET_CPP(ctkCrosshairLabel, QPen, crosshairPen, CrosshairPen)
 
 // --------------------------------------------------------------------------
 void ctkCrosshairLabel::setCrosshairPen(const QPen& newPen)
@@ -248,7 +253,7 @@ void ctkCrosshairLabel::setLineWidth(int newWidth)
 
 // --------------------------------------------------------------------------
 CTK_GET_CPP(ctkCrosshairLabel, ctkCrosshairLabel::CrosshairTypes,
-            crosshairType, CrosshairType);
+            crosshairType, CrosshairType)
 
 // --------------------------------------------------------------------------
 void ctkCrosshairLabel::setCrosshairType(const CrosshairTypes& newType)
@@ -289,7 +294,7 @@ void ctkCrosshairLabel::setMarginColor(const QColor& newColor)
 }
 
 // --------------------------------------------------------------------------
-CTK_GET_CPP(ctkCrosshairLabel, int, bullsEyeWidth, BullsEyeWidth);
+CTK_GET_CPP(ctkCrosshairLabel, int, bullsEyeWidth, BullsEyeWidth)
 
 // --------------------------------------------------------------------------
 void ctkCrosshairLabel::setBullsEyeWidth(int newWidth)

+ 2 - 2
Libs/Widgets/ctkCrosshairLabel.h

@@ -123,8 +123,8 @@ protected:
   virtual void paintEvent(QPaintEvent * event);
 
 private:
-  Q_DECLARE_PRIVATE(ctkCrosshairLabel);
-  Q_DISABLE_COPY(ctkCrosshairLabel);
+  Q_DECLARE_PRIVATE(ctkCrosshairLabel)
+  Q_DISABLE_COPY(ctkCrosshairLabel)
 }; 
 
 #endif