« Return to Thread: hugin-0.8.0_rc1 released

Re: hugin-0.8.0_rc1 released

by James Legg :: Rate this Message:

Reply to Author | View in Thread

On Thu, 2009-05-07 at 08:39 +0200, Guido Kohlmeyer wrote:
> Furthermore the identify feature in OpenGL preview won't work properly on
> Windows. The images are surrounded with a colored line but the buttons to
> enable the images are not colored accordingly. So far as I know this is a
> limitation of wxWidgets on Windows platform. After fixing the OpenGL
> detection bug (see above) I tried to find a way to overcome this
> limitation, cause it's in the same sources. Unfortunately there is no
> simple solution available. I have some ideas to implement a button array
> that is capable to show colored buttons, but this will take some
> development time ... Damn I need some more free time.

I've made a patch (attached) that should make the Identify tool more
useful on windows, and possibly satisfy feature request 2781075
(http://sourceforge.net/tracker/?func=detail&atid=550444&aid=2781075&group_id=77506 Identifying images in large pano doesn't work).

With this patch, when using the identify tool to find the image numbers,
the buttons for the images not under the mouse are hidden.

This means windows users can tell which images are under the mouse, but
cannot see which highlighted image belongs to which image number as the
buttons still look the same.

Also with large projects, it is very unlikely that you can't see all the
identified images' buttons highlighted. Before they would be mostly
hidden, as the buttons had a scrollable box where only a few were
visible.

If I get confirmation that this is acceptable on Windows (and doesn't
break anything on OS X?) I'll commit it to the trunk.

James

--~--~---------~--~----~------------~-------~--~----~
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@...
To unsubscribe from this group, send email to hugin-ptx-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/hugin-ptx
-~----------~----~----~----~------~----~------~--~---



Index: src/hugin1/hugin/PreviewIdentifyTool.cpp
===================================================================
--- src/hugin1/hugin/PreviewIdentifyTool.cpp (revision 3836)
+++ src/hugin1/hugin/PreviewIdentifyTool.cpp (working copy)
@@ -204,6 +204,11 @@
             }
         }
     }
+    if (new_image_set.size() == 0)
+    {
+        // unhide the image buttons in the preview when no images highlighted.
+        preview_frame->CleanButtonColours();
+    }
     // now request to be notified when drawing the new ones.
     {
         std::vector<unsigned int> difference(new_image_set.size());
Index: src/hugin1/hugin/GLPreviewFrame.h
===================================================================
--- src/hugin1/hugin/GLPreviewFrame.h (revision 3836)
+++ src/hugin1/hugin/GLPreviewFrame.h (working copy)
@@ -38,6 +38,7 @@
 class wxSpinEvent;
 class wxChoice;
 
+class GLPreviewFrame;
 class PreviewToolHelper;
 class PreviewTool;
 class PreviewCropTool;
@@ -59,7 +60,8 @@
                                   PreviewIdentifyTool **identify_tool,
                                   unsigned int identify_tool_id,
                                   wxToolBar *tool_bar,
-                                  PT::Panorama * m_pano);
+                                  PT::Panorama * m_pano,
+                                  GLPreviewFrame *preview_frame);
     void OnChange(wxCommandEvent &e);
 protected:
     void OnEnter(wxMouseEvent & e);
@@ -70,6 +72,7 @@
     PreviewIdentifyTool **identify_tool;
     unsigned int identify_tool_id;
     wxToolBar *tool_bar;
+    GLPreviewFrame *preview_frame;
     PT::Panorama * m_pano;
 };
 
@@ -82,6 +85,7 @@
  */
 class GLPreviewFrame : public wxFrame, public PT::PanoramaObserver, public utils::MultiProgressDisplay
 {
+    friend class ImageToogleButtonEventHandler;
 public:
 
     /** ctor.
@@ -101,6 +105,7 @@
     void SetImageButtonColour(unsigned int image_nr, unsigned char red,
                               unsigned char green, unsigned char blue);
     void SetStatusMessage(wxString message);
+    void CleanButtonColours();
 protected:
     void OnClose(wxCloseEvent& e);
 
@@ -174,8 +179,10 @@
     PreviewIdentifyTool *identify_tool;
     PreviewDifferenceTool *difference_tool;
     PreviewPanoMaskTool *pano_mask_tool;
+    
+    bool hiding_image_buttons;
+    bool identify_number_to_position;
     void TurnOffTools(std::set<PreviewTool*> tools);
-    void CleanButtonColours();
 };
 
 
Index: src/hugin1/hugin/GLPreviewFrame.cpp
===================================================================
--- src/hugin1/hugin/GLPreviewFrame.cpp (revision 3836)
+++ src/hugin1/hugin/GLPreviewFrame.cpp (working copy)
@@ -398,6 +398,10 @@
     SetIcon(myIcon);
 
     m_pano.addObserver(this);
+    
+    // don't hide image buttons at the start.
+    hiding_image_buttons = false;
+    identify_number_to_position = false;
 
     RestoreFramePosition(this, wxT("GLPreviewFrame"));
     
@@ -571,7 +575,7 @@
                 ImageToogleButtonEventHandler * event_handler = new
                     ImageToogleButtonEventHandler(*it, &identify_tool,
                                                   identify_tool_id, m_ToolBar,
-                                                  &m_pano);
+                                                  &m_pano, this);
                 toogle_button_event_handlers.push_back(event_handler);
                 but->PushEventHandler(event_handler);
                 wxSize sz = but->GetSize();
@@ -1103,28 +1107,46 @@
                                                     wxColour(red, green, blue));
         // black should be visible on the button's vibrant colours.
         m_ToggleButtons[image_nr]->SetForegroundColour(wxColour(0, 0, 0));
+        if (!(hiding_image_buttons || identify_number_to_position))
+        {
+            // hide image buttons when identifing image numbers from position.
+            hiding_image_buttons = true;
+            unsigned int nr_images = m_pano.getNrOfImages();
+            for (unsigned image = 0; image < nr_images; image++)
+            {
+                m_ToggleButtons[image]->Show(false);
+            }
+        }
+        m_ToggleButtons[image_nr]->Show(true);
     } else {
-        // return to the normal colour
+        // return to the normal colour and show.
         m_ToggleButtons[image_nr]->SetBackgroundStyle(wxBG_STYLE_SYSTEM);
         m_ToggleButtons[image_nr]->SetBackgroundColour(wxNullColour);
         m_ToggleButtons[image_nr]->SetForegroundColour(wxNullColour);
+        // hide again?
+        if (hiding_image_buttons)
+        {
+            m_ToggleButtons[image_nr]->Show(false);
+        }
     }
-    m_ToggleButtons[image_nr]->Refresh();
+    m_ButtonSizer->SetVirtualSizeHints(m_ButtonPanel);
 }
 
 void GLPreviewFrame::CleanButtonColours()
 {
     // when we turn off the identification tool, any buttons that were coloured
     // to match the image in the preview should be given back the system themed
-    // colours.
+    // colours, and unhidden.
     unsigned int nr_images = m_pano.getNrOfImages();
     for (unsigned image = 0; image < nr_images; image++)
     {
         m_ToggleButtons[image]->SetBackgroundStyle(wxBG_STYLE_SYSTEM);
         m_ToggleButtons[image]->SetBackgroundColour(wxNullColour);
         m_ToggleButtons[image]->SetForegroundColour(wxNullColour);
-        m_ToggleButtons[image]->Refresh();
+        m_ToggleButtons[image]->Show(true);
     }
+    m_ButtonSizer->SetVirtualSizeHints(m_ButtonPanel);
+    hiding_image_buttons = false;
 }
 
 ImageToogleButtonEventHandler::ImageToogleButtonEventHandler(
@@ -1132,13 +1154,15 @@
                                   PreviewIdentifyTool **identify_tool_in,
                                   unsigned int identify_tool_id_in,
                                   wxToolBar *tool_bar_in,
-                                  PT::Panorama * m_pano_in)
+                                  PT::Panorama * m_pano_in,
+                                  GLPreviewFrame * preview_frame_in)
 {
     image_number = image_number_in;
     identify_tool = identify_tool_in;
     identify_tool_id = identify_tool_id_in;
     tool_bar = tool_bar_in;
     m_pano = m_pano_in;
+    preview_frame = preview_frame_in;
 }
 
 void ImageToogleButtonEventHandler::OnEnter(wxMouseEvent & e)
@@ -1149,6 +1173,7 @@
     if (   tool_bar->GetToolState(identify_tool_id)
         && m_pano->getActiveImages().count(image_number))
     {
+        preview_frame->identify_number_to_position = true;
         (*identify_tool)->ShowImageNumber(image_number);
     }
     e.Skip();
@@ -1162,6 +1187,7 @@
         && m_pano->getActiveImages().count(image_number))
     {
         (*identify_tool)->StopShowingImages();
+        preview_frame->identify_number_to_position = false;
     }
     e.Skip();
 }

 « Return to Thread: hugin-0.8.0_rc1 released