Added a keystroke for permuting the mouse buttons, very useful on macbook...
authorGary Macbook <gsteele13@gmail.com>
Fri, 23 Aug 2013 06:53:53 +0000 (08:53 +0200)
committerGary Macbook <gsteele13@gmail.com>
Fri, 23 Aug 2013 06:53:53 +0000 (08:53 +0200)
Added a function for swapping endpoints of axis to get around bugs in python software

Improved the default "auto" settings on the hist2d and vi_to_iv widgets.

spyview/ImageData.C
spyview/ImageData.H
spyview/ImageWindow.C
spyview/ImageWindow.H
spyview/help.txt
spyview/spyview.C

index abdb3ad36d5f0b97eaab3cb19ccba397d821c582..6a4c760d91c7eea930625b396649b3ef046e58a8 100644 (file)
@@ -1672,6 +1672,23 @@ void ImageData::plane(double b, double a)
       raw(x,y) -=  a * (x-width/2) + b*(y-height/2);
 }
 
+void ImageData::flip_endpoints(bool flipx, bool flipy)
+{
+  double tmp;
+  if (flipx)
+    {
+      tmp = xmin;
+      xmin = xmax;
+      xmax = tmp;
+    }
+  if (flipy)
+    {
+      tmp = ymin;
+      ymin = ymax;
+      ymax = tmp;
+    }
+}
+
 void ImageData::xflip()
 {
   double tmp[width];
index 5bdb16719e79dfeaf90f94fb57dc81fea0ae99e6..9a21c1fb7837b06ae1aa0a23e2d6f468b5711696 100644 (file)
@@ -316,6 +316,7 @@ public:
   void plane(double b, double a); // subtract a plane
   void xflip();   
   void yflip();
+  void flip_endpoints(bool flipx, bool flipy);
   void rotate_cw();
   void rotate_ccw();
   void grad_mag(double bias); // Replace each pixel with the magnitude of the gradient.  0<bias<1 biases one derv. as more important than the other.
index 9bf8864c4f00387dd266b8b22fdf63f300cb24d4..8cebf7d310c72b37da90a7c00c111cb2834da75e 100644 (file)
@@ -107,6 +107,7 @@ ImageWindow::ImageWindow(int w, int h, const char *title) :
   statusCallback = NULL;
   datamin = 0; datamax = LMAX;
   hmin = 0; hmax = LMAX;
+  mouse_order = 0;
 
   xzoom = yzoom = 1;
   swap_zoom_state=false;
@@ -507,10 +508,21 @@ int ImageWindow::handle(int event)
     }
 
   int n;
-  int button = Fl::event_button();
+  int button;
+
+  button = Fl::event_button();
+  
+  // Mouse order = 0: 1->1 2->2 3->3
+  // Mouse order = 1: 2->1 3->2 1->3
+  // Mouse order = 2: 3->1 1->2 2->3
   
-  if ((button == 3) && (Fl::event_state() & FL_ALT))
-    button = 2;
+  //if (event == FL_PUSH || event == FL_DRAG || event == FL_RELEASE) 
+  //info("Button %d -> ", button);
+  button = button + mouse_order;
+  if (button == 4) button = 1;
+  if (button == 5) button = 2;
+  //if (event == FL_PUSH || event == FL_DRAG || event == FL_RELEASE) 
+  //info("%d\n", button);
  
   switch (event)
     {
@@ -559,6 +571,10 @@ int ImageWindow::handle(int event)
              return 1;
            }
          break;
+       case 'm':
+         mouse_order = (mouse_order+1)%3;
+         external_update();
+         break;
        case 'z':
          if (Fl::event_state() & FL_CTRL)
            exportMTX(false, true);
@@ -692,21 +708,6 @@ int ImageWindow::handle(int event)
     case FL_DRAG: // Falling case!
     case FL_RELEASE:
 
-      // For FL_DRAG, we cannot rely on Fl::event_button() (although
-      // it seems to work on unix) I don't know why I can't replace
-      // the Fl::event_buttion() above with this, but if I do, the
-      // zoom window stops working...
-      if (Fl::event_state() & FL_BUTTON1)
-       button = 1;
-      else if (Fl::event_state() & FL_BUTTON2)
-       button = 2;
-      else if (Fl::event_state() & FL_BUTTON3)
-       {
-         if (Fl::event_state() & FL_ALT)
-           button = 2;
-         else 
-           button = 3;
-       }
       // Let's only eat a non-modified button 1 click
       if(stupid_windows_focus && (button == 1) && !(Fl::event_state() & FL_SHIFT) && !(Fl::event_state() & FL_CTRL)) 
        {
@@ -1690,6 +1691,8 @@ void ImageWindow::runQueue()
              if(op->parameters[1].value)
                id.yflip();
            }
+         else if(op->name == "flip endpoints")
+           id.flip_endpoints(op->parameters[0].value, op->parameters[1].value);
          else if (op->name == "autoflip")
            {
              if (id.xmin > id.xmax)
@@ -1763,6 +1766,7 @@ void ImageWindow::runQueue()
   // have updated the iw width and height properly yet.
 
   pf->calculate();
+  external_update();
 }
 
 // a little procedure
index 4fab1d4814a7f7b1b0b6353a1f7ad42c377d57c4..30e94baca2ea1e36cb2d1f6f01850d329cc403ba 100644 (file)
@@ -212,6 +212,10 @@ public:
   // If this is true, eat initial clicks.
   bool stupid_windows_focus;
 
+  // New feature for permutating mouse button order for poor people
+  // (like me) who have only one mouse button on their MacBook
+  int mouse_order;  // 0 = (123), 1 = (231), 2 = (312)
+
   // These variables store the levels of the 16 bit greymap data that
   // get mapped to the edges of the of the colormap
   int hmin;
index 7b34f0e5c2b2a9e938e8dcaa5a334298b7ab58b3..04f6b354b746db7decf245618bb885f1be7a71bb 100644 (file)
@@ -1,6 +1,11 @@
 Global
 ------
 
+NEW FEATURE FOR PEOPLE WITH LESS THAN 3 MOUSE BUTTONS!
+m        Permutate mouse buttons in image window:
+          (123) -> (231) -> (312) -> (123)
+         Current mouse order is shown in image window title
+
 Left      Next file (also "." or SPACE)
 Right     Prev file (also "," or BACKSPACE)
 e        Reload file
@@ -55,13 +60,14 @@ Alt-s         Snap windowsize to nearest integer zoom
 Ctrl-s   Turn on autonormalize in zoom window
 Shft-s   Normalize based on contents of zoom window
 
+For systems with less than 3 mouse buttons, you can access
+the other features by permutating the mouse button order
+using the "m" shortcut (see above).
+
 B1 = left mouse button
 B2 = middle mouse button
 B3 = right mouse button
 
-For two button mice, hold down the ALT key to emulate the middle
-buttion (B2) using the right mouse button (B3).
-
 B3       Toggle controls
 
 Esc,c    Clear linecut
index e704493bc9df9970a87e247dcebeddce511ebbe1..368016c103bf84651183823a95ddcefd934e8e83 100644 (file)
@@ -276,15 +276,22 @@ void cb_hist2d_autorange(Fl_Widget *w, void *p)
   double tmp;
   char buf[1024];
 
-  tmp = iw->id.quant_to_raw(iw->hmin);
-  snprintf(buf,sizeof(buf),"%e",tmp);
+  double min = iw->id.quant_to_raw(iw->hmin);
+  double max = iw->id.quant_to_raw(iw->hmax);
+
+  if (abs(min)>abs(max))
+    tmp = abs(min);
+  else 
+    tmp = abs(max);
+
+  snprintf(buf,sizeof(buf),"%e", -tmp);
   proc_parameters[0]->value(buf);
 
-  tmp = iw->id.quant_to_raw(iw->hmax);
-  snprintf(buf,sizeof(buf),"%e",tmp);
+  snprintf(buf,sizeof(buf),"%e", tmp);
   proc_parameters[1]->value(buf);
 
-  snprintf(buf,sizeof(buf),"%d",iw->id.height);
+  //snprintf(buf,sizeof(buf),"%d",iw->id.height*50);
+  snprintf(buf,sizeof(buf),"%d",10000);
   proc_parameters[2]->value(buf);
 
   proc_parameters[0]->do_callback();
@@ -553,6 +560,11 @@ int main(int argc, char **argv)
   flip.addParameter("!Flip Y Axis",0);
   Define_Image_Operation(&flip);
 
+  Image_Operation flip_endpoints("flip endpoints","Flip axis endpoints");
+  flip_endpoints.addParameter("!Flip X Axis",0);
+  flip_endpoints.addParameter("!Flip Y Axis",0);
+  Define_Image_Operation(&flip_endpoints);
+
   Image_Operation crop("crop","Crop the Image (0 to keep current, negative possible for lower/right)");
   crop.addParameter("left col #", 0);
   crop.addParameter("right col #", 0);
@@ -979,8 +991,9 @@ void cmapch_cb(Fl_Widget *o, void*)
   index = reinterpret_cast<int>(cmapch->mvalue()->user_data());
 
   static char label[1024];
-  snprintf(label, 1024, "%s - %s", filech->text(), cmapch->text());
-  iw->label(label);
+  // This seems to be an old piece of code: where is the image window
+  // being labelled? 
+  update_title();
   snprintf(label, 1024, "Colormap %s", cmapch->text());
   (iw->colormap_window)->label(label);
 
@@ -1170,13 +1183,15 @@ void update_title()
 {
   char buf[256]; 
   if (iw->id.data3d)
-    snprintf(buf, 256, "%s %.0f (%.3g to %.3g), (%.3g to %.3g)", 
+    snprintf(buf, 256, "%s %s %.0f (%.3g to %.3g), (%.3g to %.3g)", 
             current_filename.c_str(), 
             indexbox->value(),
             xmin->value(), xmax->value(),
             ymin->value(), ymax->value());
   else
-    snprintf(buf, 256, "%s (%.3g to %.3g), (%.3g to %.3g)", 
+    snprintf(buf, 256, "%s %s (%.3g to %.3g), (%.3g to %.3g)", 
+            (iw->mouse_order == 0) ? "(123)" :
+            ((iw->mouse_order == 1) ? "(231)" : "(312)"),
             current_filename.c_str(), 
             xmin->value(), xmax->value(),
             ymin->value(), ymax->value());
@@ -1291,7 +1306,7 @@ void update_widgets()
   max = iw->hmax;
   width = (max - min);
   center = (max + min)/2;
-  
+
   minv->value(min);
   minslider->value(min);
   minroller->value(min);
@@ -1447,7 +1462,7 @@ void update_widgets()
   mtx_zname->value(iw->id.mtx.axisname[2].c_str());
 
   xrange->value(iw->line_cut_xauto);
-
+  update_title();
 }
 
 void Fetch_ProcWindow_Settings(Image_Operation *op)