[Insight-users] [Patch] GLSliceView: display clicked points

Gavin Baker gavinb+xtk at cs.mu.OZ.AU
Mon Oct 4 01:19:25 EDT 2004


Hello all,

I enclose a patch for GLSliceView (from
InsightApplications/Auxiliary/FltkImageViewer) to display the clicked points
on the currently viewed slice.

 ..

As the user clicks on the image, the points are remembered and can be saved
to a text file for later processing.  This patch will display these
remembered points as red dots.  This is on by default, and can be turned off
with 'T' (rapidly running out of good letters).

The patch was written against the CVS version of InsightApplications, and
was tested with several types of volumes (incl with anisotropic).

Regards -

  :: Gavin

-- 
Gavin Baker                                      Complex Systems Group
http://www.cs.mu.oz.au/~gavinb             The University of Melbourne
-------------- next part --------------
--- Orig/SliceView.h	2004-10-04 14:51:12.000000000 +1000
+++ SliceView.h	2004-10-04 14:57:14.000000000 +1000
@@ -119,6 +119,7 @@
     
     bool                     cValidImData;
     bool                     cViewImData;
+    bool                     cViewClickedPoints;
     ImagePointer             cImData;
     unsigned long            cDimSize[3];
     float                    cOrigin[3];
@@ -437,6 +438,7 @@
   cClickBoxCallBack = NULL;
   cClickBoxArg = NULL;
   cClickBoxArgCallBack = NULL;
+  cViewClickedPoints = true;
   
   cIWMin = 0;
   cIWMax = 0;
@@ -1823,6 +1825,11 @@
               this->saveClickedPointsStored();
               return 1;
               break;
+          case 'T':
+              cViewClickedPoints = !cViewClickedPoints;
+              this->update();
+              return 1;
+              break;
           case 'h':
             ifuShowText(" \
 SliceViewer\n \
@@ -1864,6 +1871,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 \
+  T - Toggle display of clicked points\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 \
--- Orig/GLSliceView.h	2004-10-04 14:50:44.000000000 +1000
+++ GLSliceView.h	2004-10-04 15:00:22.000000000 +1000
@@ -98,7 +98,12 @@
   void SetColorTable(ColorTablePointer newColorTable);
 
 
-  
+  /*! Turn on/off the display of clicked points */
+  void ViewClickedPoints( bool newViewClickedPoints );
+
+  /*! Status of clicked points display - on/off */
+  bool ViewClickedPoints();
+
   virtual void clickSelect(float x, float y, float z);
   
   virtual void size(int w, int h);
@@ -394,6 +399,23 @@
   }
 
 
+template <class ImagePixelType, class OverlayPixelType>
+void 
+GLSliceView<ImagePixelType, OverlayPixelType>::
+ViewClickedPoints( bool newViewClickedPoints )
+{
+    cViewClickedPoints = newViewClickedPoints;
+
+    this->redraw();
+}
+
+template <class ImagePixelType, class OverlayPixelType>
+bool
+GLSliceView<ImagePixelType, OverlayPixelType>::
+ViewClickedPoints()
+{
+    return cViewClickedPoints;
+}
 
 
 //
@@ -892,7 +914,52 @@
         GL_UNSIGNED_BYTE, cWinOverlayData);
       glDisable(GL_BLEND);
       }
-    
+
+    if( cViewClickedPoints )
+    {
+        glColor3f( 0.8, 0.4, 0.4 );
+        glPointSize( 3.0 );
+        glBegin(GL_POINTS);
+        {
+            for ( int i = 0; i < numClickedPointsStored(); i++ )
+            {
+                ClickPoint p;
+                getClickedPoint( i, p );
+                float pts[3] = { p.x, p.y, p.z };
+
+                if ( static_cast<int>( pts[cWinOrder[2]] ) ==
+                     (int)sliceNum() )
+                {
+                    float x = 0;
+                    if(cFlipX[cWinOrientation])
+                    {
+                        x = cW - (pts[cWinOrder[0]] - cWinMinX) * scale0
+                            - originX;
+                    }
+                    else
+                    {
+                        x = (pts[cWinOrder[0]] - cWinMinX) * scale0
+                            + originX;
+                    }
+
+                    float y = 0;
+                    if(cFlipY[cWinOrientation])
+                    {
+                        y = cH - (pts[cWinOrder[1]] - cWinMinY) * scale1
+                            - originY;
+                    }
+                    else
+                    {
+                        y = (pts[cWinOrder[1]] - cWinMinY) * scale1
+                             + originY;
+                    }
+                    glVertex2f( x, y );
+                }
+            }
+        }
+        glEnd();
+    }
+
     if( cViewAxisLabel ) 
       {
       glEnable(GL_BLEND);


More information about the Insight-users mailing list