On September 22, 2010 05:43:19 am Bart van Andel wrote:
> I just read your patch, to see if I could spot a bug

Thank you, Bart!  You spotted right.  With your fix it no longer segfaults on 
my tests.

Attached is the fixed patch.  If there are no further bug reports I'll commit 
it soon.

Yuv
diff -r 87f53098e31e src/hugin1/PT/PanoCommand.h
--- a/src/hugin1/PT/PanoCommand.h	Tue Sep 21 11:30:08 2010 +0200
+++ b/src/hugin1/PT/PanoCommand.h	Wed Sep 22 12:56:42 2010 -0400
@@ -503,7 +503,7 @@
     //=========================================================================
 
 
-    /** center panorama horizontically */
+    /** straighten panorama horizontically */
     class StraightenPanoCmd : public PanoCommand
     {
     public:
@@ -521,7 +521,7 @@
         
         virtual std::string getName() const
             {
-                return "center panorama";
+                return "straighten panorama";
             }
 
     private:
@@ -718,7 +718,7 @@
         
         virtual std::string getName() const
             {
-                return "change lens";
+                return "change active images";
             }
 
     private:
@@ -820,8 +820,7 @@
     //=========================================================================
     //=========================================================================
 
-    /** set image options for a set of images.
-     *  just sets the @p options given for all images in @p imgs
+    /** update source image
      */
     class UpdateSrcImageCmd : public PanoCommand
     {
@@ -840,7 +839,7 @@
             
         virtual std::string getName() const
             {
-                return "set image options";
+                return "update source image";
             }
     
     private:
@@ -851,8 +850,7 @@
     //=========================================================================
     //=========================================================================
 
-    /** set image options for a set of images.
-     *  just sets the @p options given for all images in @p imgs
+    /** update source images
      */
     class UpdateSrcImagesCmd : public PanoCommand
     {
@@ -877,7 +875,7 @@
             
         virtual std::string getName() const
             {
-                return "set multiple image options";
+                return "update source images";
             }
     
     private:
@@ -889,8 +887,7 @@
     //=========================================================================
     //=========================================================================
 
-    /** set image options for a set of images.
-     *  just sets the @p options given for all images in @p imgs
+    /** update image options
      */
     class UpdateImageOptionsCmd : public PanoCommand
     {
@@ -946,7 +943,7 @@
         
         virtual std::string getName() const
             {
-                return "unnamed command";
+                return "set panorama options";
             }
 
     private:
@@ -1034,7 +1031,7 @@
             
         virtual std::string getName() const
             {
-                return "set image options";
+                return "set flatfield correction parameters for all images of a lens";
             }
     
     private:
@@ -1069,7 +1066,7 @@
         
         virtual std::string getName() const
             {
-                return "set image options";
+                return "rotate panorama";
             }
 
     private:
diff -r 87f53098e31e src/hugin1/hugin/CommandHistory.cpp
--- a/src/hugin1/hugin/CommandHistory.cpp	Tue Sep 21 11:30:08 2010 +0200
+++ b/src/hugin1/hugin/CommandHistory.cpp	Wed Sep 22 12:56:42 2010 -0400
@@ -24,12 +24,21 @@
  *
  */
 
+// for debugging
+#include <iostream>
+#include <stdio.h>
+
 // standard include
 #include <config.h>
 #include "panoinc_WX.h"
 #include "panoinc.h"
 #include "hugin/CommandHistory.h"
 
+// for sophisticated undo
+#include "hugin/huginApp.h"
+//#include <panodata/PanoramaData.h>
+
+
 CommandHistory::CommandHistory()
     : nextCmd(0)
 {
@@ -83,25 +92,58 @@
 
 
 
-void CommandHistory::undo()
+void CommandHistory::undo(PT::Panorama & pano)
 {
     if (nextCmd > 0) {
         // undo the current command
         DEBUG_DEBUG("undo: " << commands[nextCmd-1]->getName());
+        // get the currently active images
+        UIntSet activeImgs = pano.getActiveImages();
         commands[nextCmd-1]->undo();
         nextCmd--;
+        while ( (commands[nextCmd]->getName()=="change active images") && (nextCmd > 0) ) {
+            commands[nextCmd-1]->undo();
+            nextCmd--;
+        }
+        // restore the currently active images
+        UIntSet::iterator it;
+        for (unsigned int i = 0; i < pano.getNrOfImages(); i++) {
+            if (set_contains(activeImgs, i)) {
+                pano.activateImage(i, true);
+            } else {
+                pano.activateImage(i, false);
+            }
+         }
+         pano.changeFinished();
     } else {
         wxLogError(_("no command in undo history"));
     }
+//    std::cerr << "UNDO: " << commands[nextCmd]->getName();
 }
 
 
-void CommandHistory::redo()
+void CommandHistory::redo(PT::Panorama & pano)
 {
     if (nextCmd < commands.size()) {
         DEBUG_DEBUG("redo: " << commands[nextCmd]->getName());
+        // get the currently active images
+        UIntSet activeImgs = pano.getActiveImages();
         commands[nextCmd]->execute();
         nextCmd++;
+        while ( (nextCmd < commands.size()) && (commands[nextCmd]->getName()=="change active images") ) {
+            commands[nextCmd]->execute();
+            nextCmd++;
+        }
+        // restore the currently active images
+        UIntSet::iterator it;
+        for (unsigned int i = 0; i < pano.getNrOfImages(); i++) {
+            if (set_contains(activeImgs, i)) {
+                pano.activateImage(i, true);
+            } else {
+                pano.activateImage(i, false);
+            }
+         }
+         pano.changeFinished();
     } else {
         wxLogError(_("no command in redo history"));
     }
diff -r 87f53098e31e src/hugin1/hugin/CommandHistory.h
--- a/src/hugin1/hugin/CommandHistory.h	Tue Sep 21 11:30:08 2010 +0200
+++ b/src/hugin1/hugin/CommandHistory.h	Wed Sep 22 12:56:42 2010 -0400
@@ -68,11 +68,11 @@
     /**
      * Undoes the last action.
      */
-    virtual void undo();
+    virtual void undo(PT::Panorama & pano);
     /**
      * Redoes the last undone action.
      */
-    virtual void redo();
+    virtual void redo(PT::Panorama & pano);
 
 private:
     // our commands
diff -r 87f53098e31e src/hugin1/hugin/MainFrame.cpp
--- a/src/hugin1/hugin/MainFrame.cpp	Tue Sep 21 11:30:08 2010 +0200
+++ b/src/hugin1/hugin/MainFrame.cpp	Wed Sep 22 12:56:42 2010 -0400
@@ -1563,13 +1563,13 @@
 void MainFrame::OnUndo(wxCommandEvent & e)
 {
     DEBUG_TRACE("OnUndo");
-    GlobalCmdHist::getInstance().undo();
+    GlobalCmdHist::getInstance().undo(pano);
 }
 
 void MainFrame::OnRedo(wxCommandEvent & e)
 {
     DEBUG_TRACE("OnRedo");
-    GlobalCmdHist::getInstance().redo();
+    GlobalCmdHist::getInstance().redo(pano);
 }
 
 

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to