From: Pablo d'A. <da...@us...> - 2006-05-04 06:25:46
|
Update of /cvsroot/hugin/hugin/src/hugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17446/hugin Modified Files: ImagesList.cpp ImagesPanel.cpp LensPanel.cpp Log Message: moved crop button back to lens panel. crop is mainly used with circular fisheye images. slight reorganisation of edit controls in lens tab Index: LensPanel.cpp =================================================================== RCS file: /cvsroot/hugin/hugin/src/hugin/LensPanel.cpp,v retrieving revision 1.93 retrieving revision 1.94 diff -u -d -r1.93 -r1.94 --- LensPanel.cpp 17 Mar 2006 04:53:08 -0000 1.93 +++ LensPanel.cpp 4 May 2006 06:25:40 -0000 1.94 @@ -91,6 +91,7 @@ EVT_TEXT_ENTER ( XRCID("lens_val_K2a"), LensPanel::OnVarChanged ) EVT_TEXT_ENTER ( XRCID("lens_val_K2b"), LensPanel::OnVarChanged ) // EVT_BUTTON ( XRCID("lens_button_center"), LensPanel::SetCenter ) + EVT_BUTTON ( XRCID("lens_button_crop"), LensPanel::OnCrop) EVT_BUTTON ( XRCID("lens_button_vig"), LensPanel::EditVigCorr ) EVT_BUTTON ( XRCID("lens_button_loadEXIF"), LensPanel::OnReadExif ) EVT_BUTTON ( XRCID("lens_button_save"), LensPanel::OnSaveLensParameters ) @@ -164,7 +165,7 @@ // resize only the images list, and keep the control parameters at the same size m_lens_splitter->SetSashGravity(1); #endif - m_lens_splitter->SetMinimumPaneSize(20); + m_lens_splitter->SetMinimumPaneSize(200); #endif // dummy to disable controls @@ -461,7 +462,7 @@ // not reachable DEBUG_ASSERT(0); } - + wxString ctrl_name(wxT("lens_val_")); ctrl_name.append(wxString(varname.c_str(), *wxConvCurrent)); double val; @@ -602,6 +603,7 @@ XRCCTRL(*this, "lens_button_newlens", wxButton)->Disable(); XRCCTRL(*this, "lens_button_changelens", wxButton)->Disable(); XRCCTRL(*this, "lens_button_vig", wxButton)->Disable(); + XRCCTRL(*this, "lens_button_crop", wxButton)->Disable(); } else { // m_editImageNr = *sel.begin(); @@ -638,6 +640,7 @@ XRCCTRL(*this, "lens_button_loadEXIF", wxButton)->Enable(); XRCCTRL(*this, "lens_button_newlens", wxButton)->Enable(); XRCCTRL(*this, "lens_button_changelens", wxButton)->Enable(); + XRCCTRL(*this, "lens_button_crop", wxButton)->Enable(); } if (m_selectedImages.size() == 1) { @@ -904,6 +907,74 @@ } } +void LensPanel::OnCrop ( wxCommandEvent & e ) +{ +// wxLogError(_("temporarily disabled")); + const UIntSet & selectedImages = images_list->GetSelected(); + if (images_list->GetSelected().size() > 0) { + ImgCenter dlg(this); + int imgNr = *(selectedImages.begin()); + const PanoImage & img = pano.getImage(imgNr); + // show an image preview + wxImage * wximg = ImageCache::getInstance().getImage( + img.getFilename()); + bool circular_crop = pano.getLens(img.getLensNr()).getProjection() == PT::Lens::CIRCULAR_FISHEYE; + + ImageOptions opts = img.getOptions(); + dlg.SetImage(*wximg); + VariableMap vars = pano.getImageVariables(imgNr); + int dx = roundi(map_get(vars,"d").getValue()); + int dy = roundi(map_get(vars,"e").getValue()); + vigra::Point2D center(wximg->GetWidth()/2 + dx, wximg->GetHeight()/2 + dy); + + dlg.SetParameters(opts.cropRect, circular_crop, center, opts.autoCenterCrop); +// dlg.CentreOnParent (); +// dlg->Refresh(); + if ( dlg.ShowModal() == wxID_OK ) { + // get crop parameters + opts.cropRect = dlg.getCrop(); + if (! opts.cropRect.isEmpty()) { + opts.docrop = true; + } else { + opts.docrop = false; + } + if (dlg.getCenterOnDE()) { + opts.autoCenterCrop = true; + } else { + opts.autoCenterCrop = false; + } + + // set image options. + GlobalCmdHist::getInstance().addCommand( + new PT::SetImageOptionsCmd(pano, opts, selectedImages) + ); + + // allow setting of the d,e if automatic centering on d and e is switched off. + if (wxConfigBase::Get()->Read(wxT("LensPanel/CropSetsCenter"), HUGIN_CROP_SETS_CENTER ) && ! opts.autoCenterCrop) +// if (opts.autoCenterCrop) + { + double centerx = opts.cropRect.left() + opts.cropRect.width() / 2.0; + double centery = opts.cropRect.top() + opts.cropRect.height() / 2.0; + if (centerx != 0.0 && centery != 0.0) { + VariableMapVector vars(selectedImages.size()); + UIntSet::const_iterator iNrIt = selectedImages.begin(); + for (VariableMapVector::iterator it = vars.begin(); it != vars.end(); ++it) + { + const PanoImage & pimg = pano.getImage(*iNrIt); + (*it).insert(make_pair(std::string("d"), Variable("d", centerx - pimg.getWidth()/2.0 ))); + (*it).insert(make_pair(std::string("e"), Variable("e", centery - pimg.getHeight()/2.0 ))); + iNrIt++; + } + GlobalCmdHist::getInstance().addCommand( + new PT::UpdateImagesVariablesCmd(pano, selectedImages, vars) + ); + } + } + } + } + DEBUG_TRACE ("") +} + bool initLensFromFile(const std::string & filename, double &cropFactor, Lens & l) Index: ImagesList.cpp =================================================================== RCS file: /cvsroot/hugin/hugin/src/hugin/ImagesList.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- ImagesList.cpp 29 Apr 2006 17:50:51 -0000 1.35 +++ ImagesList.cpp 4 May 2006 06:25:40 -0000 1.36 @@ -306,7 +306,6 @@ InsertColumn( 6, _("roll (r)"), wxLIST_FORMAT_RIGHT, 40 ); InsertColumn( 7, _("Anchor"), wxLIST_FORMAT_RIGHT, 40 ); InsertColumn( 8, _("# Ctrl Pnts"), wxLIST_FORMAT_RIGHT, 40); - InsertColumn( 9, _("Crop"), wxLIST_FORMAT_RIGHT,100); //get saved width for ( int j=0; j < GetColumnCount() ; j++ ) @@ -351,12 +350,6 @@ } } SetItem(imgNr, 8, wxString::Format(wxT("%d"), nCP)); - wxString cropstr(wxT("-")); - if ( img.getOptions().docrop ) { - vigra::Rect2D c = img.getOptions().cropRect; - cropstr.Printf(wxT("%d,%d,%d,%d"), c.left(), c.right(), c.top(), c.bottom()); - } - SetItem(imgNr, 9, cropstr); } ImagesListLens::ImagesListLens(wxWindow * parent, Panorama * pano) @@ -375,6 +368,7 @@ InsertColumn( 9, _("e"), wxLIST_FORMAT_RIGHT, 40 ); InsertColumn( 10, _("g"), wxLIST_FORMAT_RIGHT, 40 ); InsertColumn( 11, _("t"), wxLIST_FORMAT_RIGHT, 40 ); + InsertColumn( 12, _("Crop"), wxLIST_FORMAT_RIGHT,100); //get saved width for ( int j=0; j < GetColumnCount() ; j++ ) @@ -412,4 +406,11 @@ SetItem(imgNr, 9, doubleTowxString( map_get(var, "e").getValue(),m_pixelDigits)); SetItem(imgNr, 10, doubleTowxString( map_get(var, "g").getValue(),m_distDigits)); SetItem(imgNr, 11, doubleTowxString( map_get(var, "t").getValue(),m_distDigits)); + + wxString cropstr(wxT("-")); + if ( img.getOptions().docrop ) { + vigra::Rect2D c = img.getOptions().cropRect; + cropstr.Printf(wxT("%d,%d,%d,%d"), c.left(), c.right(), c.top(), c.bottom()); + } + SetItem(imgNr, 12, cropstr); } Index: ImagesPanel.cpp =================================================================== RCS file: /cvsroot/hugin/hugin/src/hugin/ImagesPanel.cpp,v retrieving revision 1.94 retrieving revision 1.95 diff -u -d -r1.94 -r1.95 --- ImagesPanel.cpp 12 Mar 2006 20:53:19 -0000 1.94 +++ ImagesPanel.cpp 4 May 2006 06:25:40 -0000 1.95 @@ -78,8 +78,6 @@ EVT_BUTTON ( XRCID("action_remove_images"), ImagesPanel::OnRemoveImages) EVT_BUTTON ( XRCID("images_move_image_down"), ImagesPanel::OnMoveImageDown) EVT_BUTTON ( XRCID("images_move_image_up"), ImagesPanel::OnMoveImageUp) - EVT_BUTTON ( XRCID("images_button_crop"), ImagesPanel::OnCrop) - EVT_TEXT_ENTER ( XRCID("images_text_yaw"), ImagesPanel::OnYawTextChanged ) EVT_TEXT_ENTER ( XRCID("images_text_pitch"), ImagesPanel::OnPitchTextChanged ) EVT_TEXT_ENTER ( XRCID("images_text_roll"), ImagesPanel::OnRollTextChanged ) @@ -459,7 +457,6 @@ m_moveUpButton->Disable(); XRCCTRL(*this, "images_reset_pos", wxButton)->Disable(); XRCCTRL(*this, "action_remove_images", wxButton)->Disable(); - XRCCTRL(*this, "images_button_crop", wxButton)->Disable(); } void ImagesPanel::EnableImageCtrls() @@ -474,7 +471,6 @@ m_moveUpButton->Enable(); XRCCTRL(*this, "images_reset_pos", wxButton)->Enable(); XRCCTRL(*this, "action_remove_images", wxButton)->Enable(); - XRCCTRL(*this, "images_button_crop", wxButton)->Enable(); } } @@ -734,72 +730,5 @@ } } -void ImagesPanel::OnCrop ( wxCommandEvent & e ) -{ -// wxLogError(_("temporarily disabled")); - const UIntSet & selectedImages = images_list->GetSelected(); - if (images_list->GetSelected().size() > 0) { - ImgCenter dlg(this); - int imgNr = *(selectedImages.begin()); - const PanoImage & img = pano.getImage(imgNr); - // show an image preview - wxImage * wximg = ImageCache::getInstance().getImage( - img.getFilename()); - bool circular_crop = pano.getLens(img.getLensNr()).getProjection() == PT::Lens::CIRCULAR_FISHEYE; - - ImageOptions opts = img.getOptions(); - dlg.SetImage(*wximg); - VariableMap vars = pano.getImageVariables(imgNr); - int dx = roundi(map_get(vars,"d").getValue()); - int dy = roundi(map_get(vars,"e").getValue()); - vigra::Point2D center(wximg->GetWidth()/2 + dx, wximg->GetHeight()/2 + dy); - - dlg.SetParameters(opts.cropRect, circular_crop, center, opts.autoCenterCrop); -// dlg.CentreOnParent (); -// dlg->Refresh(); - if ( dlg.ShowModal() == wxID_OK ) { - // get crop parameters - opts.cropRect = dlg.getCrop(); - if (! opts.cropRect.isEmpty()) { - opts.docrop = true; - } else { - opts.docrop = false; - } - if (dlg.getCenterOnDE()) { - opts.autoCenterCrop = true; - } else { - opts.autoCenterCrop = false; - } - - // set image options. - GlobalCmdHist::getInstance().addCommand( - new PT::SetImageOptionsCmd(pano, opts, selectedImages) - ); - - // allow setting of the d,e if automatic centering on d and e is switched off. - if (wxConfigBase::Get()->Read(wxT("LensPanel/CropSetsCenter"), HUGIN_CROP_SETS_CENTER ) && ! opts.autoCenterCrop) -// if (opts.autoCenterCrop) - { - double centerx = opts.cropRect.left() + opts.cropRect.width() / 2.0; - double centery = opts.cropRect.top() + opts.cropRect.height() / 2.0; - if (centerx != 0.0 && centery != 0.0) { - VariableMapVector vars(selectedImages.size()); - UIntSet::const_iterator iNrIt = selectedImages.begin(); - for (VariableMapVector::iterator it = vars.begin(); it != vars.end(); ++it) - { - const PanoImage & pimg = pano.getImage(*iNrIt); - (*it).insert(make_pair(std::string("d"), Variable("d", centerx - pimg.getWidth()/2.0 ))); - (*it).insert(make_pair(std::string("e"), Variable("e", centery - pimg.getHeight()/2.0 ))); - iNrIt++; - } - GlobalCmdHist::getInstance().addCommand( - new PT::UpdateImagesVariablesCmd(pano, selectedImages, vars) - ); - } - } - } - } - DEBUG_TRACE ("") -} |