[Insight-users] [PATCH] FltkImageViewer physical units display

Gavin Baker gavinb+xtk at cs.mu.OZ.AU
Thu Jul 15 00:49:28 EDT 2004


Hello,

The co-ordinates of the crosshairs in FltkImageViewer curently display only
the image index of the point selected.  I enclose a patch that adds the
ability to display these coordinates in physical units (ie. taking into
account the image spacing and origin).  The default behaviour remains
unchanged, but the new display can be toggled with P, and can be recognised
by a suffix (defaulting to "mm") appended to the numbers.  It includes an
entry in the help text, and should conform to the local coding style.

For your consideration... regards,

  :: Gavin

-- 
Gavin Baker                                      Complex Systems Group
http://www.cs.mu.oz.au/~gavinb             The University of Melbourne
-------------- next part --------------
Index: GLSliceView.h
===================================================================
RCS file: /cvsroot/Insight/InsightApplications/Auxiliary/FltkImageViewer/GLSliceView.h,v
retrieving revision 1.17
diff -u -r1.17 GLSliceView.h
--- a/GLSliceView.h	20 Dec 2003 23:55:05 -0000	1.17
+++ b/GLSliceView.h	15 Jul 2004 04:43:09 -0000
@@ -175,7 +175,10 @@
   cSpacing[0]=cImData->GetSpacing()[0];
   cSpacing[1]=cImData->GetSpacing()[1];
   cSpacing[2]=cImData->GetSpacing()[2];
-    
+  cOrigin[0]=cImData->GetOrigin()[0];
+  cOrigin[1]=cImData->GetOrigin()[1];
+  cOrigin[2]=cImData->GetOrigin()[2];
+
   //calculating cDataMax and cDataMin    
   IndexType ind;
   ind[0] = 0; 
@@ -936,21 +939,36 @@
       glColor4f(0.1, 0.64, 0.2, (float)0.75);
       gl_font(FL_TIMES_BOLD, 12);
       char s[80];
+      float px, py, pz, val = cClickSelectV;
+      char* suffix = "";
+      if( cViewValuePhysicalUnits )
+        {
+        px = cOrigin[0]+cSpacing[0]*cClickSelect[0];
+        py = cOrigin[1]+cSpacing[1]*cClickSelect[1];
+        pz = cOrigin[2]+cSpacing[2]*cClickSelect[2];
+        suffix = cPhysicalUnitsName;
+        }
+      else
+        {
+        px = cClickSelect[0];
+        py = cClickSelect[1];
+        pz = cClickSelect[2];
+        }
       if((ImagePixelType)1.5==1.5)
         {
-        sprintf(s, "(%0.1f,  %0.1f,  %0.1f) = %0.3f", 
-          cClickSelect[0],
-          cClickSelect[1], 
-          cClickSelect[2], 
-          (float)cClickSelectV);
+        sprintf(s, "(%0.1f%s,  %0.1f%s,  %0.1f%s) = %0.3f",
+          px, suffix,
+          py, suffix,
+          pz, suffix,
+          val);
         }
       else
         {
-        sprintf(s, "(%0.1f,  %0.1f,  %0.1f) = %d", 
-          cClickSelect[0],
-          cClickSelect[1], 
-          cClickSelect[2], 
-          (int)cClickSelectV);
+        sprintf(s, "(%0.1f%s,  %0.1f%s,  %0.1f%s) = %d", 
+          px, suffix,
+          py, suffix,
+          pz, suffix,
+          (int)val);
         }
       gl_draw( s,
         (int)(cW-(gl_width(s)+2)), 2);
Index: SliceView.h
===================================================================
RCS file: /cvsroot/Insight/InsightApplications/Auxiliary/FltkImageViewer/SliceView.h,v
retrieving revision 1.15
diff -u -r1.15 SliceView.h
--- a/SliceView.h	8 Feb 2004 19:01:19 -0000	1.15
+++ b/SliceView.h	15 Jul 2004 04:43:10 -0000
@@ -121,6 +121,7 @@
     bool                     cViewImData;
     ImagePointer             cImData;
     unsigned long            cDimSize[3];
+    float                    cOrigin[3];
     float                    cSpacing[3];
     void                    (* cViewImDataCallBack)(void);
     void                     * cViewImDataArg;
@@ -179,6 +180,8 @@
     bool        cViewOverlayData;
     bool        cViewCrosshairs;
     bool        cViewValue;
+    bool        cViewValuePhysicalUnits;
+    char*       cPhysicalUnitsName;
     bool        cViewDetails;
     
     int   cWinMinX;
@@ -489,8 +492,9 @@
   cViewDetails = true;
   cViewCrosshairs = true;
   cViewValue = true;
-  
-  
+  cViewValuePhysicalUnits = false;
+  cPhysicalUnitsName = "mm";
+
   cWinMinX = 0;
   cWinMaxX = 0;
   cWinSizeX = 0;
@@ -1799,6 +1803,11 @@
               this->update();
               return 1;
               break;
+          case 'P':
+              cViewValuePhysicalUnits = !cViewValuePhysicalUnits;
+              this->update();
+              return 1;
+              break;
           case 'D':
               cViewDetails = !cViewDetails;
               this->update();
@@ -1854,6 +1863,7 @@
   A - View axis labels: P=posterior, L=left, S=superior\n \
   C - View crosshairs that illustrate last user-click in the window\n \
   I - View image values as the user clicks in the window\n \
+  P - Toggle coordinates display between index and physical units\n \
   D - View image details as an overlay on the image\n \
   O - View a color overlay (application dependent)\n \
   \n \


More information about the Insight-users mailing list