Hi,

Here is the patch that I have proposed earlier.

It basically adds two things:

1. it includes a new drag mode in the fast preview for mosaic panoramas where instead of changing orientation parameters it changes Tr parameters 2. it keeps consistency in images on rolling when Tr parameters are non zero (for yaw and pitch consistency cannot be preserved for non-zero Tr parameters)

Basically I've added a option choice in the drag tab in the fast preview window where the user can choose between normal and mosaic mode.

I know this is not the perfect way to switch between these modes as ideally it should be in some upper level or maybe even automatic. Also what is still needs to be done is that while in mosiac mode the manual changing of orientation parameters (yaw, pitch, roll) needs to be switched to manual changes of Tr parameters. Also maybe some interface for changing the TrZ parameter as now only TrY and TrX parameters are changed.


The system works in a simple manner. It uses the previous implementation of finding the angles that correspond to the points on the screen, and so I'm using these angles to determine the correspondent points on the virtual plane and then calculate the shift.

For the keeping of consistency in rolling the corresponding AngleStore class and its move method were changed to handle TrX and TrY parameters. I could have also easily added the TrZ parameter, however this would help much.

Best,
Darko
-- 
You received this message because you are subscribed to the Google Groups 
"hugin and other free panoramic software" group.
A list of frequently asked questions is available at: 
http://wiki.panotools.org/Hugin_FAQ
To post to this group, send email to hugin-ptx@googlegroups.com
To unsubscribe from this group, send email to 
hugin-ptx+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/hugin-ptx

To unsubscribe, reply using "remove me" as the subject.
Index: src/hugin1/hugin/xrc/preview_frame.xrc
===================================================================
--- src/hugin1/hugin/xrc/preview_frame.xrc	(revision 5107)
+++ src/hugin1/hugin/xrc/preview_frame.xrc	(working copy)
@@ -542,6 +542,24 @@
                   <flag>wxLEFT|wxRIGHT|wxALIGN_CENTRE_VERTICAL</flag>
                   <border>5</border>
                 </object>
+                <object class="sizeritem">
+                  <object class="wxBoxSizer">
+                    <orient>wxHORIZONTAL</orient>
+                    <object class="sizeritem">
+                      <object class="wxStaticText">
+                        <label>Drag mode:</label>
+                      </object>
+                      <flag>wxLEFT|wxRIGHT|wxALIGN_CENTRE_VERTICAL</flag>
+                      <border>5</border>
+                    </object>
+                    <object class="sizeritem">
+                      <object class="wxChoice" name="drag_mode_choice">
+                        <content/>
+                      </object>
+                    </object>
+                  </object>
+                  <flag>wxALIGN_CENTRE_VERTICAL</flag>
+                </object>                
               </object>
               <tooltip>Move the panorama or drag images into position</tooltip>
             </object>
@@ -641,4 +659,4 @@
       </object>
     </object>
   </object>
-</resource>
\ No newline at end of file
+</resource>
Index: src/hugin1/hugin/PreviewDragTool.cpp
===================================================================
--- src/hugin1/hugin/PreviewDragTool.cpp	(revision 5107)
+++ src/hugin1/hugin/PreviewDragTool.cpp	(working copy)
@@ -41,6 +41,28 @@
 {
 }
 
+void PreviewDragTool::setDragMode(PreviewDragTool::DragMode dmode)
+{
+	drag_mode = dmode;
+}
+
+PreviewDragTool::DragMode PreviewDragTool::getDragMode()
+{
+	return drag_mode;
+}
+
+//find Tr parameters shift based on polar coordinates
+void PreviewDragTool::getTranslationShift(double &delta_x, double &delta_y)
+{
+	double startx = atan(DEG_TO_RAD(start_coordinates.x));
+	double starty = atan(DEG_TO_RAD(start_coordinates.y));
+	double shiftx = atan(DEG_TO_RAD(shift_coordinates.x));
+	double shifty = atan(DEG_TO_RAD(shift_coordinates.y));
+	delta_x = shiftx - startx;
+	delta_y = shifty - starty;
+}
+
+
 void PreviewDragTool::Activate()
 {
     drag_yaw = false; drag_pitch = false; drag_roll = false;
@@ -86,21 +108,41 @@
         {
             shift_angle = atan2(y - centre.y, x- centre.x) - start_angle;
         }
+                        
         // move the selected images on the tempory copies for display.
+
         // first calculate a matrix representing the transformation
-        SetRotationMatrix(shift_coordinates.x, shift_coordinates.y, shift_angle,
-                          start_coordinates.x,  start_coordinates.y,  0.0);
-        // now transform the images in the ViewState (not the panorama yet)
-        std::map<unsigned int, AngleStore>::iterator i;
-        for (i = image_angles.begin(); i != image_angles.end(); i++ )
-        {
-            HuginBase::SrcPanoImage img = *helper->GetViewStatePtr()->
-                                                          GetSrcImage(i->first);
-            double new_yaw, new_pitch, new_roll;
-            i->second.Move(&rotation_matrix, new_yaw, new_pitch, new_roll);
-            img.setYaw(new_yaw); img.setPitch(new_pitch); img.setRoll(new_roll);
-            helper->GetViewStatePtr()->SetSrcImage(i->first, &img);
-        }
+        if (drag_mode == drag_mode_mosaic) {
+        	//if in mosaic drag mode do not adjust yaw and pitch, just roll
+			SetRotationMatrix(0,0,shift_angle, 0,0,0);
+		} else {
+		    SetRotationMatrix(shift_coordinates.x, shift_coordinates.y, shift_angle,
+		                      start_coordinates.x,  start_coordinates.y,  0.0);
+		}     
+
+	    std::map<unsigned int, ParamStore>::iterator i;
+	    for (i = image_params.begin(); i != image_params.end(); i++ )
+	    {
+	        HuginBase::SrcPanoImage img = *helper->GetViewStatePtr()->
+	                                                      GetSrcImage(i->first);
+	        double new_yaw, new_pitch, new_roll, new_TrX, new_TrY;
+	
+        	if (drag_mode == drag_mode_mosaic) {
+        		//if in mosaic mode shift TrX and TrY parameters based on modified yaw and pitch
+	        	double shift_x, shift_y;
+				getTranslationShift(shift_x, shift_y);
+				i->second.TrX = img.getX() + shift_x;
+				i->second.TrY = img.getY() + shift_y;
+			}
+	        i->second.Move(&rotation_matrix, new_yaw, new_pitch, new_roll, new_TrX, new_TrY);
+        	img.setX(new_TrX);
+        	img.setY(new_TrY);
+	    	img.setYaw(new_yaw); 
+	    	img.setPitch(new_pitch); 
+        	img.setRoll(new_roll);
+	        helper->GetViewStatePtr()->SetSrcImage(i->first, &img);
+	    }
+                          
         // redraw
         helper->GetViewStatePtr()->Redraw();
     }
@@ -193,7 +235,7 @@
                 ViewState *view_state_ptr = helper->GetViewStatePtr();
                 for (unsigned int i = 0; i < imgs; i++)
                 {
-                    image_angles[i].Set(view_state_ptr->GetSrcImage(i));
+                    image_params[i].Set(view_state_ptr->GetSrcImage(i));
                 };
             } else
             {
@@ -217,7 +259,7 @@
                         end = draging_images.end();
                         for (i = draging_images.begin(); i != end; i++)
                         {
-                            image_angles[*i].Set(
+                            image_params[*i].Set(
                                     helper->GetViewStatePtr()->GetSrcImage(*i));
                         }
                         break;
@@ -231,23 +273,25 @@
     } else {
         // check this wasn't an attempt to drag empty space.
         if (! (drag_pitch || drag_roll || drag_yaw)) return;
-        
+	        
         // Finished draging images:
         drag_yaw = false; drag_pitch = false; drag_roll = false;
         // Apply the rotations permanently.
         // find where the images end up.
         std::vector<HuginBase::SrcPanoImage> src_images(draging_images.size() + 1);
-        std::map<unsigned int, AngleStore>::iterator i;
+        std::map<unsigned int, ParamStore>::iterator i;
         unsigned int count = 0;
-        for (i = image_angles.begin(); i != image_angles.end(); i++)
+        for (i = image_params.begin(); i != image_params.end(); i++)
         {
-            double nyaw, npitch, nroll;
-            i->second.Move(&rotation_matrix, nyaw, npitch, nroll);
+            double nyaw, npitch, nroll, nx, ny;
+            i->second.Move(&rotation_matrix, nyaw, npitch, nroll, nx, ny);
             src_images[count] = helper->GetPanoramaPtr()->getSrcImage(i->first);
-            src_images[count].setYaw(nyaw);
-            src_images[count].setPitch(npitch);
-            src_images[count].setRoll(nroll);
-            count++;
+			src_images[count].setX(nx);
+			src_images[count].setY(ny);
+	        src_images[count].setYaw(nyaw);
+	        src_images[count].setPitch(npitch);
+	        src_images[count].setRoll(nroll);
+	        count++;
         }
         GlobalCmdHist::getInstance().addCommand(
             new PT::UpdateSrcImagesCmd(*helper->GetPanoramaPtr(),
@@ -255,10 +299,12 @@
                                             src_images)
             );
         // stop dragging
-        image_angles.clear();
+        image_params.clear();
         
         helper->SetStatusMessage(_("Drag to move images (optionally use shift to constrain), or roll with right-drag or ctrl-drag."));
     }
+    
+
 }
 
 void PreviewDragTool::ReallyAfterDrawImagesEvent()
@@ -323,16 +369,18 @@
 }
 
 
-void PreviewDragTool::AngleStore::Set(HuginBase::SrcPanoImage *img)
+void PreviewDragTool::ParamStore::Set(HuginBase::SrcPanoImage *img)
 {
     yaw = img->getYaw();
     pitch = img->getPitch();
     roll = img->getRoll();
+    TrX = img->getX();
+    TrY = img->getY();
 }
 
-void PreviewDragTool::AngleStore::Move(Matrix3 *matrix,
+void PreviewDragTool::ParamStore::Move(Matrix3 *matrix,
                                        double &yaw_out, double &pitch_out,
-                                       double &roll_out)
+                                       double &roll_out, double &TrX_out, double &TrY_out)
 {
     Matrix3 start, output_matrix;
     // convert the location of this image to a matrix.
@@ -344,8 +392,16 @@
     yaw_out = RAD_TO_DEG(yaw_out);
     pitch_out = RAD_TO_DEG(pitch_out);
     roll_out = RAD_TO_DEG(roll_out);
+    
+	//for non zero Tr parameters correspondence can be kept only for rolling, so adjust TrX and TrY parameters accordingly
+    Vector3 vec(0, TrY, TrX);
+    Vector3 res = matrix->TransformVector(vec);
+    TrX_out = res.z;
+    TrY_out = res.y;
+    
 }
 
+
 void PreviewDragTool::SetRotationMatrix(double yaw_shift, double pitch_shift,
                                         double roll_shift,
                                         double yaw_start, double pitch_start,
Index: src/hugin1/hugin/GLPreviewFrame.h
===================================================================
--- src/hugin1/hugin/GLPreviewFrame.h	(revision 5107)
+++ src/hugin1/hugin/GLPreviewFrame.h	(working copy)
@@ -129,6 +129,7 @@
     void OnIncreaseExposure( wxSpinEvent & e );
 
     void OnBlendChoice(wxCommandEvent & e);
+    void OnDragChoice(wxCommandEvent & e);
     void OnProjectionChoice(wxCommandEvent & e);
     /** event handler for changed roi */
     void OnROIChanged(wxCommandEvent & e);
@@ -168,6 +169,7 @@
     wxTextCtrl * m_ROITopTxt;
     wxTextCtrl * m_ROIBottomTxt;
     wxChoice * m_BlendModeChoice;
+    wxChoice * m_DragModeChoice;
     wxChoice * m_ProjectionChoice;
     // No HDR display yet.
     // wxChoice * m_outputModeChoice;
@@ -179,7 +181,7 @@
     int m_oldProjFormat;
     // index of difference mode
     int m_differenceIndex;
-
+	
 	  wxScrolledWindow * m_ButtonPanel;
 	  wxBoxSizer * m_ButtonSizer;
 	  wxStaticBoxSizer * m_ToggleButtonSizer;
Index: src/hugin1/hugin/GLPreviewFrame.cpp
===================================================================
--- src/hugin1/hugin/GLPreviewFrame.cpp	(revision 5107)
+++ src/hugin1/hugin/GLPreviewFrame.cpp	(working copy)
@@ -115,6 +115,7 @@
     EVT_SPIN_DOWN(XRCID("exposure_spin"), GLPreviewFrame::OnDecreaseExposure)
     EVT_SPIN_UP(XRCID("exposure_spin"), GLPreviewFrame::OnIncreaseExposure)
     EVT_CHOICE(XRCID("blend_mode_choice"), GLPreviewFrame::OnBlendChoice)
+    EVT_CHOICE(XRCID("drag_mode_choice"), GLPreviewFrame::OnDragChoice)
     EVT_CHOICE(XRCID("projection_choice"), GLPreviewFrame::OnProjectionChoice)
 #ifndef __WXMAC__
     // wxMac does not process these
@@ -357,6 +358,11 @@
     m_BlendModeChoice->Append(_("normal"));
     m_BlendModeChoice->SetSelection(0);
 
+	m_DragModeChoice = XRCCTRL(*this, "drag_mode_choice", wxChoice);
+	m_DragModeChoice->Append(_("normal"));
+	m_DragModeChoice->Append(_("mosaic"));
+	m_DragModeChoice->SetSelection(0);
+
     // TODO implement hdr display in OpenGL, if possible?
     // Disabled until someone can figure out HDR display in OpenGL.
     /*
@@ -1002,7 +1008,30 @@
     }
 }
 
+void GLPreviewFrame::OnDragChoice(wxCommandEvent & e)
+{
+    if (e.GetEventObject() == m_DragModeChoice)
+    {
+        if (drag_tool) {
+        
+		    int index = m_DragModeChoice->GetSelection();
+		    switch (index) {
+		    	case 0: //normal
+		    		drag_tool->setDragMode(PreviewDragTool::drag_mode_normal);
+		    	break; 
+		    	case 1: //mosaic
+		    		drag_tool->setDragMode(PreviewDragTool::drag_mode_mosaic);
+		    	break;
+		    }        
+        }
+    }
+    else
+    {
+        // FIXME DEBUG_WARN("wxChoice event from unknown object received");
+    }
+}
 
+
 void GLPreviewFrame::OnDefaultExposure( wxCommandEvent & e )
 {
     if (m_pano.getNrOfImages() > 0) {
@@ -1572,4 +1601,4 @@
         m_GLViewer->SetLayoutScale(10.0-sqrt(scale_factor));
         m_GLViewer->Refresh();
     };
-};
\ No newline at end of file
+};
Index: src/hugin1/hugin/PreviewDragTool.h
===================================================================
--- src/hugin1/hugin/PreviewDragTool.h	(revision 5107)
+++ src/hugin1/hugin/PreviewDragTool.h	(working copy)
@@ -46,6 +46,8 @@
  * alt moves windows on some window managers, leaving shift as the only common
  * modifier suitable for constrained drag.
  */
+ 
+ 
 class PreviewDragTool : public PreviewTool
 {
 public:
@@ -54,16 +56,28 @@
     void MouseMoveEvent(double x, double y, wxMouseEvent & e);
     void MouseButtonEvent(wxMouseEvent &e);
     void ReallyAfterDrawImagesEvent();
-    class AngleStore
+    class ParamStore
     {
     public:
-        double yaw, pitch, roll;
+        double yaw, pitch, roll, TrX, TrY;
         void Set(HuginBase::SrcPanoImage *img);
         void Move(Matrix3 *matrix,
-                  double &yaw_out,  double &pitch_out,  double &roll_out);
+                  double &yaw_out,  double &pitch_out,  double &roll_out, double &TrX_out, double &TrY_out);
+
     };
+
+	//dragging mode
+	enum DragMode {
+		drag_mode_normal,
+		drag_mode_mosaic
+	};
+    void setDragMode(DragMode drag_mode);
+    DragMode getDragMode();
+    
+    void getTranslationShift(double &delta_x, double &delta_y);
+    
 private:
-    std::map<unsigned int, AngleStore> image_angles;
+    std::map<unsigned int, ParamStore> image_params;
     std::set<unsigned int> draging_images;
     bool drag_yaw, drag_pitch, drag_roll;
     double start_angle, shift_angle;
@@ -74,6 +88,7 @@
                            double roll_shift,
                            double yaw_start, double pitch_start,
                            double roll_start);
+    DragMode drag_mode;
 };
 
 #endif

Reply via email to