From: <hug...@li...> - 2011-03-17 17:47:36
|
branch: details: http://hugin.hg.sourceforge.net/hgweb/hugin/hugin/hgrepo/h/hu/hugin/hugin/rev/1d3d0a820d2c changeset: 5138:1d3d0a820d2c user: boyd date: Wed Mar 16 12:23:28 2011 -0700 description: Fixes bug #712802, so that identify in the preview updates the overview and vice versa. diffstat: src/hugin1/hugin/GLPreviewFrame.cpp | 6 + src/hugin1/hugin/GLPreviewFrame.h | 2 +- src/hugin1/hugin/PreviewIdentifyTool.cpp | 126 +++++++++++++++++-------------- src/hugin1/hugin/PreviewIdentifyTool.h | 2 + 4 files changed, 78 insertions(+), 58 deletions(-) diffs (200 lines): diff -r 351dd7aea158 -r 1d3d0a820d2c src/hugin1/hugin/GLPreviewFrame.cpp --- a/src/hugin1/hugin/GLPreviewFrame.cpp Tue Mar 15 21:22:54 2011 +0100 +++ b/src/hugin1/hugin/GLPreviewFrame.cpp Wed Mar 16 12:23:28 2011 -0700 @@ -2589,3 +2589,9 @@ cfg->Flush(); e.Skip(); }; + +void GLPreviewFrame::UpdateIdentifyTools(std::set<unsigned int> new_image_set){ + identify_tool->UpdateWithNewImageSet(new_image_set); + panosphere_overview_identify_tool->UpdateWithNewImageSet(new_image_set); + plane_overview_identify_tool->UpdateWithNewImageSet(new_image_set); +} diff -r 351dd7aea158 -r 1d3d0a820d2c src/hugin1/hugin/GLPreviewFrame.h --- a/src/hugin1/hugin/GLPreviewFrame.h Tue Mar 15 21:22:54 2011 +0100 +++ b/src/hugin1/hugin/GLPreviewFrame.h Wed Mar 16 12:23:28 2011 -0700 @@ -245,7 +245,7 @@ * @param blueFactor multiplies all WhiteBalanceBlue of individuel images with this factor */ void UpdateGlobalWhiteBalance(double redFactor, double blueFactor); - + void UpdateIdentifyTools(std::set<unsigned int> new_image_set); protected: bool GLresize; diff -r 351dd7aea158 -r 1d3d0a820d2c src/hugin1/hugin/PreviewIdentifyTool.cpp --- a/src/hugin1/hugin/PreviewIdentifyTool.cpp Tue Mar 15 21:22:54 2011 +0100 +++ b/src/hugin1/hugin/PreviewIdentifyTool.cpp Wed Mar 16 12:23:28 2011 -0700 @@ -215,8 +215,7 @@ } image_set.clear(); stopUpdating = true; - helper->GetVisualizationStatePtr()->ForceRequireRedraw(); - helper->GetVisualizationStatePtr()->Redraw(); + ForceRedraw(); } void PreviewIdentifyTool::ContinueUpdating() { @@ -298,59 +297,16 @@ if (stopUpdating) { return; } - - // If we are currently showing indicators for some of the images, we want - // to work out which ones are not in the new set, so we can set their - // buttons back to the system colour. + std::set<unsigned int> new_image_set = helper->GetImageNumbersUnderMouse(); - std::vector<unsigned int>::iterator end; - { - std::vector<unsigned int> difference(image_set.size()); - end = difference.begin(); - end = std::set_difference (image_set.begin(), image_set.end(), - new_image_set.begin(), new_image_set.end(), - difference.begin()); - DEBUG_ASSERT(end >= difference.begin() && end <= difference.end()); - if (difference.begin() != end) - { - std::vector<unsigned int>::iterator iterator; - for (iterator = difference.begin(); iterator != end; iterator++) - { - DEBUG_ASSERT(*iterator < helper->GetPanoramaPtr()->getNrOfImages()); - // reset this button to its default system colour. - preview_frame->SetImageButtonColour(*iterator, 0, 0, 0); - // remove the notification - helper->DoNotNotifyMeBeforeDrawing(*iterator, this); - } - } - } - // now request to be notified when drawing the new ones. - { - std::vector<unsigned int> difference(new_image_set.size()); - end = difference.begin(); - end = std::set_difference (new_image_set.begin(), new_image_set.end(), - image_set.begin(), image_set.end(), - difference.begin()); - DEBUG_ASSERT(end >= difference.begin() && end <= difference.end()); - if (difference.begin() != end) - { - std::vector<unsigned int>::iterator iterator; - for (iterator = difference.begin(); iterator != end; iterator++) - { - DEBUG_ASSERT(*iterator < helper->GetPanoramaPtr()->getNrOfImages()); - // get notification of when this is about to be drawn. - helper->NotifyMeBeforeDrawing(*iterator, this); - } - } - } - // remember the new set. - image_set.swap(new_image_set); - // Redraw with new indicators. Since the indicators aren't part of the - // panorama and none of it is likely to change, we have to persuade the - // viewstate that a redraw is required. - helper->GetVisualizationStatePtr()->ForceRequireRedraw(); - helper->GetVisualizationStatePtr()->Redraw(); + //UpdateIdentifyTools() will unrequest notification for the old indicators, + //reset the button colors, request notification for the new ones, swap in + //image_set with new_image_set, and force a redraw for all three + //PreviewIdentifyTool objects in GLPreviewFrame. This has the effect of + //displaying the indicators in both the preview and overview when you move + //your mouse over either when the Identify button is toggled on. + preview_frame->UpdateIdentifyTools(new_image_set); // if there is exactly two images, tell the user they can click to edit CPs. if (image_set.size() == 2) @@ -482,8 +438,7 @@ // we want notification of when it is drawn so we can delay drawing. helper->NotifyMeBeforeDrawing(image, this); // now we want a redraw. - helper->GetVisualizationStatePtr()->ForceRequireRedraw(); - helper->GetVisualizationStatePtr()->Redraw(); + ForceRedraw(); } mouse_over_image = image; mouse_is_over_button = true; @@ -498,8 +453,7 @@ helper->DoNotNotifyMeBeforeDrawing(mouse_over_image, this); image_set.erase(mouse_over_image); // now redraw without the indicator. - helper->GetVisualizationStatePtr()->ForceRequireRedraw(); - helper->GetVisualizationStatePtr()->Redraw(); + ForceRedraw(); mouse_is_over_button = false; } } @@ -581,3 +535,61 @@ } +void PreviewIdentifyTool::UpdateWithNewImageSet(std::set<unsigned int> new_image_set) +{ + // If we are currently showing indicators for some of the images, we want + // to work out which ones are not in the new set, so we can set their + // buttons back to the system colour. + std::vector<unsigned int>::iterator end; + { + std::vector<unsigned int> difference(image_set.size()); + end = difference.begin(); + end = std::set_difference (image_set.begin(), image_set.end(), + new_image_set.begin(), new_image_set.end(), + difference.begin()); + DEBUG_ASSERT(end >= difference.begin() && end <= difference.end()); + if (difference.begin() != end) + { + std::vector<unsigned int>::iterator iterator; + for (iterator = difference.begin(); iterator != end; iterator++) + { + DEBUG_ASSERT(*iterator < helper->GetPanoramaPtr()->getNrOfImages()); + // reset this button to its default system colour. + preview_frame->SetImageButtonColour(*iterator, 0, 0, 0); + // remove the notification + helper->DoNotNotifyMeBeforeDrawing(*iterator, this); + } + } + } + + // now request to be notified when drawing the new ones. + std::vector<unsigned int> difference(new_image_set.size()); + end = difference.begin(); + end = std::set_difference (new_image_set.begin(), new_image_set.end(), + image_set.begin(), image_set.end(), + difference.begin()); + DEBUG_ASSERT(end >= difference.begin() && end <= difference.end()); + if (difference.begin() != end) + { + std::vector<unsigned int>::iterator iterator; + for (iterator = difference.begin(); iterator != end; iterator++) + { + DEBUG_ASSERT(*iterator < helper->GetPanoramaPtr()->getNrOfImages()); + // get notification of when this is about to be drawn. + helper->NotifyMeBeforeDrawing(*iterator, this); + } + } + // remember the new set. + image_set.swap(new_image_set); + + // Redraw with new indicators. Since the indicators aren't part of the + // panorama and none of it is likely to change, we have to persuade the + // viewstate that a redraw is required. + ForceRedraw(); +} + +void PreviewIdentifyTool::ForceRedraw() +{ + helper->GetVisualizationStatePtr()->ForceRequireRedraw(); + helper->GetVisualizationStatePtr()->Redraw(); +} diff -r 351dd7aea158 -r 1d3d0a820d2c src/hugin1/hugin/PreviewIdentifyTool.h --- a/src/hugin1/hugin/PreviewIdentifyTool.h Tue Mar 15 21:22:54 2011 +0100 +++ b/src/hugin1/hugin/PreviewIdentifyTool.h Wed Mar 16 12:23:28 2011 -0700 @@ -63,6 +63,8 @@ void setConstantOn(bool constant_on_in); + void UpdateWithNewImageSet(std::set<unsigned int> new_image_set); + void ForceRedraw(); private: /// Generate a colour given how many colours we need and an index. void HighlightColour(unsigned int index, unsigned int count, |