~ubuntu-branches/ubuntu/trusty/hugin/trusty-proposed

« back to all changes in this revision

Viewing changes to src/hugin1/hugin/OptimizePanel.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Metzler
  • Date: 2011-01-06 14:28:24 UTC
  • mfrom: (1.1.9 upstream) (0.1.21 experimental)
  • Revision ID: james.westby@ubuntu.com-20110106142824-zn9lxylg5z44dynn
* Drop Cyril Brulebois from Uploaders. Thank you very much for your work.
* Bump package version. (rc3 was re-released as 2010.4.0).

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
    EVT_BUTTON(XRCID("opt_y_clear"), OptimizePanel::OnListButton)
64
64
    EVT_BUTTON(XRCID("opt_z_select"), OptimizePanel::OnListButton)
65
65
    EVT_BUTTON(XRCID("opt_z_clear"), OptimizePanel::OnListButton)
 
66
    EVT_BUTTON(XRCID("opt_v_select"), OptimizePanel::OnListButton)
 
67
    EVT_BUTTON(XRCID("opt_v_clear"), OptimizePanel::OnListButton)
 
68
    EVT_BUTTON(XRCID("opt_a_select"), OptimizePanel::OnListButton)
 
69
    EVT_BUTTON(XRCID("opt_a_clear"), OptimizePanel::OnListButton)
 
70
    EVT_BUTTON(XRCID("opt_b_select"), OptimizePanel::OnListButton)
 
71
    EVT_BUTTON(XRCID("opt_b_clear"), OptimizePanel::OnListButton)
 
72
    EVT_BUTTON(XRCID("opt_c_select"), OptimizePanel::OnListButton)
 
73
    EVT_BUTTON(XRCID("opt_c_clear"), OptimizePanel::OnListButton)
 
74
    EVT_BUTTON(XRCID("opt_d_select"), OptimizePanel::OnListButton)
 
75
    EVT_BUTTON(XRCID("opt_d_clear"), OptimizePanel::OnListButton)
 
76
    EVT_BUTTON(XRCID("opt_e_select"), OptimizePanel::OnListButton)
 
77
    EVT_BUTTON(XRCID("opt_e_clear"), OptimizePanel::OnListButton)
66
78
 
67
79
    EVT_CHOICE(XRCID("optimize_panel_mode"), OptimizePanel::OnChangeMode)
68
80
//    EVT_BUTTON(XRCID("opt_roll_equalize"), OptimizePanel::OnEqRoll)
82
94
 
83
95
// local optimize definition. need to be in sync with the xrc file
84
96
enum OptimizeMode { OPT_PAIRWISE=0, OPT_YRP, OPT_YRP_XYZ, OPT_YRP_V, OPT_YRP_XYZ_V,
85
 
                    OPT_YRP_B, OPT_YRP_XYZ_B, OPT_YRP_BV, OPT_YRP_XYZ_BV, OPT_ALL_NOTXYZ, OPT_ALL, OPT_CUSTOM,
 
97
                    OPT_YRP_B, OPT_YRP_XYZ_B, OPT_YRP_BV, OPT_YRP_XYZ_BV, OPT_ALL_NOTXYZ, OPT_CUSTOM,
86
98
                    OPT_END_MARKER};
87
99
 
88
100
OptimizePanel::OptimizePanel()
209
221
        SetCheckMark(m_z_list,true);
210
222
    } else if (e.GetId() == XRCID("opt_z_clear")) {
211
223
        SetCheckMark(m_z_list,false);
 
224
    } else if (e.GetId() == XRCID("opt_v_select")) {
 
225
        SetCheckMark(m_v_list,true);
 
226
    } else if (e.GetId() == XRCID("opt_v_clear")) {
 
227
        SetCheckMark(m_v_list,false);
 
228
    } else if (e.GetId() == XRCID("opt_a_select")) {
 
229
        SetCheckMark(m_a_list,true);
 
230
    } else if (e.GetId() == XRCID("opt_a_clear")) {
 
231
        SetCheckMark(m_a_list,false);
 
232
    } else if (e.GetId() == XRCID("opt_b_select")) {
 
233
        SetCheckMark(m_b_list,true);
 
234
    } else if (e.GetId() == XRCID("opt_b_clear")) {
 
235
        SetCheckMark(m_b_list,false);
 
236
    } else if (e.GetId() == XRCID("opt_c_select")) {
 
237
        SetCheckMark(m_c_list,true);
 
238
    } else if (e.GetId() == XRCID("opt_c_clear")) {
 
239
        SetCheckMark(m_c_list,false);
 
240
    } else if (e.GetId() == XRCID("opt_d_select")) {
 
241
        SetCheckMark(m_d_list,true);
 
242
    } else if (e.GetId() == XRCID("opt_d_clear")) {
 
243
        SetCheckMark(m_d_list,false);
 
244
    } else if (e.GetId() == XRCID("opt_e_select")) {
 
245
        SetCheckMark(m_e_list,true);
 
246
    } else if (e.GetId() == XRCID("opt_e_clear")) {
 
247
        SetCheckMark(m_e_list,false);
 
248
 
212
249
    } else {
213
250
        DEBUG_FATAL("An error has occured");
214
251
    }
320
357
 
321
358
void OptimizePanel::panoramaChanged(PT::Panorama & pano)
322
359
{
323
 
        DEBUG_TRACE("");
 
360
  DEBUG_TRACE("");
324
361
    // make sure all the lens numbers are correct.
325
362
    variable_groups->update();
326
363
    setOptimizeVector(pano.getOptimizeVector());
337
374
    // make sure all the lens numbers are correct.
338
375
    variable_groups->update();
339
376
    DEBUG_TRACE("nr of changed images: " << imgNr.size());
340
 
        if (pano.getNrOfImages() == 0)
341
 
        {
342
 
          XRCCTRL(*this, "optimize_frame_optimize", wxButton)->Disable();
343
 
          m_mode_cb->Disable();
344
 
          m_edit_cb->Disable();
345
 
        } else {
346
 
          XRCCTRL(*this, "optimize_frame_optimize", wxButton)->Enable();
347
 
          m_mode_cb->Enable();
348
 
          m_edit_cb->Enable();
349
 
        }
 
377
    if (pano.getNrOfImages() == 0)
 
378
    {
 
379
        XRCCTRL(*this, "optimize_frame_optimize", wxButton)->Disable();
 
380
        m_mode_cb->Disable();
 
381
        m_edit_cb->Disable();
 
382
    } else {
 
383
        XRCCTRL(*this, "optimize_frame_optimize", wxButton)->Enable();
 
384
        m_mode_cb->Enable();
 
385
        m_edit_cb->Enable();
 
386
    }
350
387
    // update lens values
351
388
    int nrLensList = m_v_list->GetCount();
352
389
    assert(nrLensList >=0);
613
650
        optvars2.insert("y");
614
651
        optvars2.insert("p");
615
652
        optvars2.insert("r");
616
 
        // TODO: check tilt mode here, before inserting the parameters.
 
653
  // TODO: check tilt mode here, before inserting the parameters.
617
654
        /* optvars2.insert("TrX");
618
655
        optvars2.insert("TrY");
619
656
        optvars2.insert("TrZ"); */
750
787
    DEBUG_TRACE("");
751
788
    int mode = m_mode_cb->GetSelection();
752
789
    DEBUG_ASSERT(mode >= 0 && mode < OPT_END_MARKER);
753
 
        if (m_pano->getNrOfImages() == 0)
754
 
        {
755
 
          XRCCTRL(*this, "opt_yaw_select", wxButton)->Disable();
756
 
          XRCCTRL(*this, "opt_roll_select", wxButton)->Disable();
757
 
          XRCCTRL(*this, "opt_pitch_select", wxButton)->Disable();
758
 
      XRCCTRL(*this, "opt_x_select", wxButton)->Disable();
759
 
      XRCCTRL(*this, "opt_y_select", wxButton)->Disable();
760
 
      XRCCTRL(*this, "opt_z_select", wxButton)->Disable();
761
 
          XRCCTRL(*this, "opt_yaw_clear", wxButton)->Disable();
762
 
          XRCCTRL(*this, "opt_roll_clear", wxButton)->Disable();
763
 
          XRCCTRL(*this, "opt_pitch_clear", wxButton)->Disable();
764
 
      XRCCTRL(*this, "opt_x_clear", wxButton)->Disable();
765
 
      XRCCTRL(*this, "opt_y_clear", wxButton)->Disable();
766
 
      XRCCTRL(*this, "opt_z_clear", wxButton)->Disable();
767
 
        } else {
768
 
      switch (mode) {
769
 
            case OPT_PAIRWISE:
770
 
          // smart auto optimize
771
 
          SetCheckMark(m_yaw_list,true);
772
 
          SetCheckMark(m_roll_list,true);
773
 
          SetCheckMark(m_pitch_list,true);
774
 
          SetCheckMark(m_x_list,false);
775
 
          SetCheckMark(m_y_list,false);
776
 
          SetCheckMark(m_z_list,false);
777
 
          SetCheckMark(m_v_list,false);
778
 
          SetCheckMark(m_a_list,false);
779
 
          SetCheckMark(m_b_list,false);
780
 
          SetCheckMark(m_c_list,false);
781
 
          SetCheckMark(m_d_list,false);
782
 
          SetCheckMark(m_e_list,false);
783
 
          break;
784
 
        case OPT_YRP:
785
 
          // simple position
786
 
          SetCheckMark(m_yaw_list,true);
787
 
          SetCheckMark(m_roll_list,true);
788
 
          SetCheckMark(m_pitch_list,true);
789
 
          SetCheckMark(m_x_list,false);
790
 
          SetCheckMark(m_y_list,false);
791
 
          SetCheckMark(m_z_list,false);
792
 
          SetCheckMark(m_v_list,false);
793
 
          SetCheckMark(m_a_list,false);
794
 
          SetCheckMark(m_b_list,false);
795
 
          SetCheckMark(m_c_list,false);
796
 
          SetCheckMark(m_d_list,false);
797
 
          SetCheckMark(m_e_list,false);
798
 
          break;
799
 
        case OPT_YRP_XYZ:
800
 
          // position + translation
801
 
          SetCheckMark(m_yaw_list,true);
802
 
          SetCheckMark(m_roll_list,true);
803
 
          SetCheckMark(m_pitch_list,true);
804
 
          SetCheckMark(m_x_list,true);
805
 
          SetCheckMark(m_y_list,true);
806
 
          SetCheckMark(m_z_list,true);
807
 
          SetCheckMark(m_v_list,false);
808
 
          SetCheckMark(m_a_list,false);
809
 
          SetCheckMark(m_b_list,false);
810
 
          SetCheckMark(m_c_list,false);
811
 
          SetCheckMark(m_d_list,false);
812
 
          SetCheckMark(m_e_list,false);
813
 
          break;
814
 
            case OPT_YRP_V:
815
 
          // v + position
816
 
          SetCheckMark(m_yaw_list,true);
817
 
          SetCheckMark(m_roll_list,true);
818
 
          SetCheckMark(m_pitch_list,true);
819
 
          SetCheckMark(m_x_list,false);
820
 
          SetCheckMark(m_y_list,false);
821
 
          SetCheckMark(m_z_list,false);
822
 
          SetCheckMark(m_v_list,true);
823
 
          SetCheckMark(m_a_list,false);
824
 
          SetCheckMark(m_b_list,false);
825
 
          SetCheckMark(m_c_list,false);
826
 
          SetCheckMark(m_d_list,false);
827
 
          SetCheckMark(m_e_list,false);
828
 
          break;
829
 
        case OPT_YRP_XYZ_V:
830
 
          // v + position + translation
831
 
          SetCheckMark(m_yaw_list,true);
832
 
          SetCheckMark(m_roll_list,true);
833
 
          SetCheckMark(m_pitch_list,true);
834
 
          SetCheckMark(m_x_list,true);
835
 
          SetCheckMark(m_y_list,true);
836
 
          SetCheckMark(m_z_list,true);
837
 
          SetCheckMark(m_v_list,true);
838
 
          SetCheckMark(m_a_list,false);
839
 
          SetCheckMark(m_b_list,false);
840
 
          SetCheckMark(m_c_list,false);
841
 
          SetCheckMark(m_d_list,false);
842
 
          SetCheckMark(m_e_list,false);
843
 
          break;
844
 
            case OPT_YRP_B:
845
 
          // important lens distortion + position
846
 
          SetCheckMark(m_yaw_list,true);
847
 
          SetCheckMark(m_roll_list,true);
848
 
          SetCheckMark(m_pitch_list,true);
849
 
          SetCheckMark(m_x_list,false);
850
 
          SetCheckMark(m_y_list,false);
851
 
          SetCheckMark(m_z_list,false);
852
 
          SetCheckMark(m_v_list,false);
853
 
          SetCheckMark(m_a_list,false);
854
 
          SetCheckMark(m_b_list,true);
855
 
          SetCheckMark(m_c_list,false);
856
 
          SetCheckMark(m_d_list,false);
857
 
          SetCheckMark(m_e_list,false);
858
 
          break;
859
 
        case OPT_YRP_XYZ_B:
860
 
          // important lens distortion + position + translation
861
 
          SetCheckMark(m_yaw_list,true);
862
 
          SetCheckMark(m_roll_list,true);
863
 
          SetCheckMark(m_pitch_list,true);
864
 
          SetCheckMark(m_x_list,true);
865
 
          SetCheckMark(m_y_list,true);
866
 
          SetCheckMark(m_z_list,true);
867
 
          SetCheckMark(m_v_list,false);
868
 
          SetCheckMark(m_a_list,false);
869
 
          SetCheckMark(m_b_list,true);
870
 
          SetCheckMark(m_c_list,false);
871
 
          SetCheckMark(m_d_list,false);
872
 
          SetCheckMark(m_e_list,false);
873
 
          break;
874
 
            case OPT_YRP_BV:
875
 
          // important lens distortion + v + position
876
 
          SetCheckMark(m_yaw_list,true);
877
 
          SetCheckMark(m_roll_list,true);
878
 
          SetCheckMark(m_pitch_list,true);
879
 
          SetCheckMark(m_x_list,false);
880
 
          SetCheckMark(m_y_list,false);
881
 
          SetCheckMark(m_z_list,false);
882
 
          SetCheckMark(m_v_list,true);
883
 
          SetCheckMark(m_a_list,false);
884
 
          SetCheckMark(m_b_list,true);
885
 
          SetCheckMark(m_c_list,false);
886
 
          SetCheckMark(m_d_list,false);
887
 
          SetCheckMark(m_e_list,false);
888
 
          break;
889
 
        case OPT_YRP_XYZ_BV:
890
 
          // important lens distortion + v + position + translation
891
 
          SetCheckMark(m_yaw_list,true);
892
 
          SetCheckMark(m_roll_list,true);
893
 
          SetCheckMark(m_pitch_list,true);
894
 
          SetCheckMark(m_x_list,true);
895
 
          SetCheckMark(m_y_list,true);
896
 
          SetCheckMark(m_z_list,true);
897
 
          SetCheckMark(m_v_list,true);
898
 
          SetCheckMark(m_a_list,false);
899
 
          SetCheckMark(m_b_list,true);
900
 
          SetCheckMark(m_c_list,false);
901
 
          SetCheckMark(m_d_list,false);
902
 
          SetCheckMark(m_e_list,false);
903
 
          break;
904
 
            case OPT_ALL_NOTXYZ:
905
 
          // everything
906
 
          SetCheckMark(m_yaw_list,true);
907
 
          SetCheckMark(m_roll_list,true);
908
 
          SetCheckMark(m_pitch_list,true);
909
 
          SetCheckMark(m_x_list,false);
910
 
          SetCheckMark(m_y_list,false);
911
 
          SetCheckMark(m_z_list,false);
912
 
          SetCheckMark(m_v_list,true);
913
 
          SetCheckMark(m_a_list,true);
914
 
          SetCheckMark(m_b_list,true);
915
 
          SetCheckMark(m_c_list,true);
916
 
          SetCheckMark(m_d_list,true);
917
 
          SetCheckMark(m_e_list,true);
918
 
          break;
919
 
            case OPT_ALL:
920
 
          // everything
921
 
          SetCheckMark(m_yaw_list,true);
922
 
          SetCheckMark(m_roll_list,true);
923
 
          SetCheckMark(m_pitch_list,true);
924
 
          SetCheckMark(m_x_list,true);
925
 
          SetCheckMark(m_y_list,true);
926
 
          SetCheckMark(m_z_list,true);
927
 
          SetCheckMark(m_v_list,true);
928
 
          SetCheckMark(m_a_list,true);
929
 
          SetCheckMark(m_b_list,true);
930
 
          SetCheckMark(m_c_list,true);
931
 
          SetCheckMark(m_d_list,true);
932
 
          SetCheckMark(m_e_list,true);
933
 
          break;
934
 
            case OPT_CUSTOM:
935
 
          break;
936
 
          }
937
 
      // do not try to do anything on our own
938
 
      // if the user selected custom
939
 
      if (mode != OPT_CUSTOM && m_pano->getNrOfImages() > 0)
940
 
          {
941
 
        // get anchor image and images linked to its position.
942
 
        unsigned int refImg = m_pano->getOptions().optimizeReferenceImage;
943
 
        std::vector<unsigned int> refImgs;
944
 
        const HuginBase::SrcPanoImage & refImage = m_pano->getImage(refImg);
945
 
        for (unsigned int imgNr = 0; imgNr < m_pano->getNrOfImages(); imgNr++)
946
 
        {
947
 
            const HuginBase::SrcPanoImage & compImage = m_pano->getImage(imgNr);
948
 
            if (refImage.RollisLinkedWith(compImage) &&
949
 
                refImage.PitchisLinkedWith(compImage) &&
950
 
                refImage.YawisLinkedWith(compImage))
951
 
            {
952
 
                refImgs.push_back(imgNr);
953
 
            }
954
 
        }
955
 
 
956
 
        // count number of vertical/horizontal control points
957
 
        int nHCP = 0;
958
 
        int nVCP = 0;
959
 
        const CPVector & cps = m_pano->getCtrlPoints();
960
 
        for (CPVector::const_iterator it = cps.begin(); it != cps.end(); it++)
961
 
            {
962
 
          // control points
963
 
          if (it->mode == ControlPoint::X)
964
 
                {
965
 
              nVCP++;
966
 
            } else if (it->mode == ControlPoint::Y)
967
 
                      {
968
 
                nHCP++;
969
 
              }
970
 
        }
971
 
 
972
 
        // try to select sensible position optimisation parameters,
973
 
        // dependent on output projection
974
 
        bool linkRefImgsYaw, linkRefImgsPitch, linkRefImgsRoll;
975
 
        switch (m_pano->getOptions().getProjection()) {
976
 
          case PT::PanoramaOptions::RECTILINEAR:
977
 
            linkRefImgsRoll = nVCP + nHCP >= 1;
978
 
            linkRefImgsYaw = nVCP + nHCP >= 3 && nVCP >= 1 && nHCP >= 1;
979
 
            linkRefImgsPitch = nVCP + nHCP >= 2;
980
 
            for (std::vector<unsigned int>::iterator it = refImgs.begin();
981
 
                 it != refImgs.end(); it++)
982
 
            {
983
 
                m_roll_list->Check(*it, linkRefImgsRoll);
984
 
                m_yaw_list->Check(*it, linkRefImgsYaw);
985
 
                m_pitch_list->Check(*it, linkRefImgsPitch);
986
 
            }
987
 
            break;
988
 
          case PT::PanoramaOptions::CYLINDRICAL:
989
 
          case PT::PanoramaOptions::EQUIRECTANGULAR:
990
 
            linkRefImgsPitch =  nHCP + nVCP > 1;
991
 
            linkRefImgsRoll = nHCP + nVCP >= 1;
992
 
            for (std::vector<unsigned int>::iterator it = refImgs.begin();
993
 
                 it != refImgs.end(); it++)
994
 
            {
995
 
                m_roll_list->Check(*it, linkRefImgsRoll);
996
 
                m_yaw_list->Check(*it, false);
997
 
                m_pitch_list->Check(*it, linkRefImgsPitch);
998
 
            }
999
 
            break;
1000
 
          default:
1001
 
            break;
1002
 
        }
1003
 
        bool optXYZ=m_x_list->IsChecked(0) || m_y_list->IsChecked(0) || m_z_list->IsChecked(0);
1004
 
        // don't optimize translation of anchor image
1005
 
        // if translation should be optimized, then also optimise yaw and pitch of anchor
1006
 
        for (std::vector<unsigned int>::iterator it = refImgs.begin();
1007
 
             it != refImgs.end(); it++)
1008
 
        {
1009
 
            m_x_list->Check(*it, false);
1010
 
            m_y_list->Check(*it, false);
1011
 
            m_z_list->Check(*it, false);
1012
 
            if(optXYZ)
1013
 
            {
1014
 
                m_yaw_list->Check(*it,true);
1015
 
                m_pitch_list->Check(*it,true);
1016
 
            };
1017
 
        }
1018
 
            // disable all manual settings
1019
 
            m_yaw_list->Disable();
1020
 
            m_pitch_list->Disable();
1021
 
            m_roll_list->Disable();
1022
 
            m_x_list->Disable();
1023
 
            m_y_list->Disable();
1024
 
            m_z_list->Disable();
1025
 
            m_v_list->Disable();
1026
 
            m_a_list->Disable();
1027
 
            m_b_list->Disable();
1028
 
            m_c_list->Disable();
1029
 
            m_d_list->Disable();
1030
 
            m_e_list->Disable();
1031
 
            XRCCTRL(*this, "opt_yaw_select", wxButton)->Disable();
1032
 
            XRCCTRL(*this, "opt_roll_select", wxButton)->Disable();
1033
 
            XRCCTRL(*this, "opt_pitch_select", wxButton)->Disable();
 
790
    if (m_pano->getNrOfImages() == 0)
 
791
    {
 
792
        XRCCTRL(*this, "opt_yaw_select", wxButton)->Disable();
 
793
        XRCCTRL(*this, "opt_roll_select", wxButton)->Disable();
 
794
        XRCCTRL(*this, "opt_pitch_select", wxButton)->Disable();
1034
795
        XRCCTRL(*this, "opt_x_select", wxButton)->Disable();
1035
796
        XRCCTRL(*this, "opt_y_select", wxButton)->Disable();
1036
797
        XRCCTRL(*this, "opt_z_select", wxButton)->Disable();
1037
 
            XRCCTRL(*this, "opt_yaw_clear", wxButton)->Disable();
1038
 
            XRCCTRL(*this, "opt_roll_clear", wxButton)->Disable();
1039
 
            XRCCTRL(*this, "opt_pitch_clear", wxButton)->Disable();
 
798
        XRCCTRL(*this, "opt_v_select", wxButton)->Disable();
 
799
        XRCCTRL(*this, "opt_a_select", wxButton)->Disable();
 
800
        XRCCTRL(*this, "opt_b_select", wxButton)->Disable();
 
801
        XRCCTRL(*this, "opt_c_select", wxButton)->Disable();
 
802
        XRCCTRL(*this, "opt_d_select", wxButton)->Disable();
 
803
        XRCCTRL(*this, "opt_e_select", wxButton)->Disable();
 
804
        XRCCTRL(*this, "opt_yaw_clear", wxButton)->Disable();
 
805
        XRCCTRL(*this, "opt_roll_clear", wxButton)->Disable();
 
806
        XRCCTRL(*this, "opt_pitch_clear", wxButton)->Disable();
1040
807
        XRCCTRL(*this, "opt_x_clear", wxButton)->Disable();
1041
808
        XRCCTRL(*this, "opt_y_clear", wxButton)->Disable();
1042
809
        XRCCTRL(*this, "opt_z_clear", wxButton)->Disable();
1043
 
      } else {
1044
 
            m_yaw_list->Enable();
1045
 
            m_pitch_list->Enable();
1046
 
            m_roll_list->Enable();
1047
 
            m_x_list->Enable();
1048
 
            m_y_list->Enable();
1049
 
            m_z_list->Enable();
1050
 
            m_v_list->Enable();
1051
 
            m_a_list->Enable();
1052
 
            m_b_list->Enable();
1053
 
            m_c_list->Enable();
1054
 
            m_d_list->Enable();
1055
 
            m_e_list->Enable();
1056
 
        XRCCTRL(*this, "opt_yaw_select", wxButton)->Enable();
1057
 
        XRCCTRL(*this, "opt_roll_select", wxButton)->Enable();
1058
 
        XRCCTRL(*this, "opt_pitch_select", wxButton)->Enable();
1059
 
        XRCCTRL(*this, "opt_x_select", wxButton)->Enable();
1060
 
        XRCCTRL(*this, "opt_y_select", wxButton)->Enable();
1061
 
        XRCCTRL(*this, "opt_z_select", wxButton)->Enable();
1062
 
        XRCCTRL(*this, "opt_yaw_clear", wxButton)->Enable();
1063
 
        XRCCTRL(*this, "opt_roll_clear", wxButton)->Enable();
1064
 
        XRCCTRL(*this, "opt_pitch_clear", wxButton)->Enable();
1065
 
        XRCCTRL(*this, "opt_x_clear", wxButton)->Enable();
1066
 
        XRCCTRL(*this, "opt_y_clear", wxButton)->Enable();
1067
 
        XRCCTRL(*this, "opt_z_clear", wxButton)->Enable();
1068
 
      }
1069
 
        }
 
810
        XRCCTRL(*this, "opt_v_clear", wxButton)->Disable();
 
811
        XRCCTRL(*this, "opt_a_clear", wxButton)->Disable();
 
812
        XRCCTRL(*this, "opt_b_clear", wxButton)->Disable();
 
813
        XRCCTRL(*this, "opt_c_clear", wxButton)->Disable();
 
814
        XRCCTRL(*this, "opt_d_clear", wxButton)->Disable();
 
815
        XRCCTRL(*this, "opt_e_clear", wxButton)->Disable();
 
816
    } else {
 
817
        switch (mode) {
 
818
            case OPT_PAIRWISE:
 
819
                // smart auto optimize
 
820
                SetCheckMark(m_yaw_list,true);
 
821
                SetCheckMark(m_roll_list,true);
 
822
                SetCheckMark(m_pitch_list,true);
 
823
                SetCheckMark(m_x_list,false);
 
824
                SetCheckMark(m_y_list,false);
 
825
                SetCheckMark(m_z_list,false);
 
826
                SetCheckMark(m_v_list,false);
 
827
                SetCheckMark(m_a_list,false);
 
828
                SetCheckMark(m_b_list,false);
 
829
                SetCheckMark(m_c_list,false);
 
830
                SetCheckMark(m_d_list,false);
 
831
                SetCheckMark(m_e_list,false);
 
832
                break;
 
833
            case OPT_YRP:
 
834
                // simple position
 
835
                SetCheckMark(m_yaw_list,true);
 
836
                SetCheckMark(m_roll_list,true);
 
837
                SetCheckMark(m_pitch_list,true);
 
838
                SetCheckMark(m_x_list,false);
 
839
                SetCheckMark(m_y_list,false);
 
840
                SetCheckMark(m_z_list,false);
 
841
                SetCheckMark(m_v_list,false);
 
842
                SetCheckMark(m_a_list,false);
 
843
                SetCheckMark(m_b_list,false);
 
844
                SetCheckMark(m_c_list,false);
 
845
                SetCheckMark(m_d_list,false);
 
846
                SetCheckMark(m_e_list,false);
 
847
                break;
 
848
            case OPT_YRP_XYZ:
 
849
                // position + translation
 
850
                SetCheckMark(m_yaw_list,true);
 
851
                SetCheckMark(m_roll_list,true);
 
852
                SetCheckMark(m_pitch_list,true);
 
853
                SetCheckMark(m_x_list,true);
 
854
                SetCheckMark(m_y_list,true);
 
855
                SetCheckMark(m_z_list,true);
 
856
                SetCheckMark(m_v_list,false);
 
857
                SetCheckMark(m_a_list,false);
 
858
                SetCheckMark(m_b_list,false);
 
859
                SetCheckMark(m_c_list,false);
 
860
                SetCheckMark(m_d_list,false);
 
861
                SetCheckMark(m_e_list,false);
 
862
                break;
 
863
            case OPT_YRP_V:
 
864
                // v + position
 
865
                SetCheckMark(m_yaw_list,true);
 
866
                SetCheckMark(m_roll_list,true);
 
867
                SetCheckMark(m_pitch_list,true);
 
868
                SetCheckMark(m_x_list,false);
 
869
                SetCheckMark(m_y_list,false);
 
870
                SetCheckMark(m_z_list,false);
 
871
                SetCheckMark(m_v_list,true);
 
872
                SetCheckMark(m_a_list,false);
 
873
                SetCheckMark(m_b_list,false);
 
874
                SetCheckMark(m_c_list,false);
 
875
                SetCheckMark(m_d_list,false);
 
876
                SetCheckMark(m_e_list,false);
 
877
                break;
 
878
            case OPT_YRP_XYZ_V:
 
879
                // v + position + translation
 
880
                SetCheckMark(m_yaw_list,true);
 
881
                SetCheckMark(m_roll_list,true);
 
882
                SetCheckMark(m_pitch_list,true);
 
883
                SetCheckMark(m_x_list,true);
 
884
                SetCheckMark(m_y_list,true);
 
885
                SetCheckMark(m_z_list,true);
 
886
                SetCheckMark(m_v_list,true);
 
887
                SetCheckMark(m_a_list,false);
 
888
                SetCheckMark(m_b_list,false);
 
889
                SetCheckMark(m_c_list,false);
 
890
                SetCheckMark(m_d_list,false);
 
891
                SetCheckMark(m_e_list,false);
 
892
                break;
 
893
            case OPT_YRP_B:
 
894
                // important lens distortion + position
 
895
                SetCheckMark(m_yaw_list,true);
 
896
                SetCheckMark(m_roll_list,true);
 
897
                SetCheckMark(m_pitch_list,true);
 
898
                SetCheckMark(m_x_list,false);
 
899
                SetCheckMark(m_y_list,false);
 
900
                SetCheckMark(m_z_list,false);
 
901
                SetCheckMark(m_v_list,false);
 
902
                SetCheckMark(m_a_list,false);
 
903
                SetCheckMark(m_b_list,true);
 
904
                SetCheckMark(m_c_list,false);
 
905
                SetCheckMark(m_d_list,false);
 
906
                SetCheckMark(m_e_list,false);
 
907
                break;
 
908
            case OPT_YRP_XYZ_B:
 
909
                // important lens distortion + position + translation
 
910
                SetCheckMark(m_yaw_list,true);
 
911
                SetCheckMark(m_roll_list,true);
 
912
                SetCheckMark(m_pitch_list,true);
 
913
                SetCheckMark(m_x_list,true);
 
914
                SetCheckMark(m_y_list,true);
 
915
                SetCheckMark(m_z_list,true);
 
916
                SetCheckMark(m_v_list,false);
 
917
                SetCheckMark(m_a_list,false);
 
918
                SetCheckMark(m_b_list,true);
 
919
                SetCheckMark(m_c_list,false);
 
920
                SetCheckMark(m_d_list,false);
 
921
                SetCheckMark(m_e_list,false);
 
922
                break;
 
923
            case OPT_YRP_BV:
 
924
                // important lens distortion + v + position
 
925
                SetCheckMark(m_yaw_list,true);
 
926
                SetCheckMark(m_roll_list,true);
 
927
                SetCheckMark(m_pitch_list,true);
 
928
                SetCheckMark(m_x_list,false);
 
929
                SetCheckMark(m_y_list,false);
 
930
                SetCheckMark(m_z_list,false);
 
931
                SetCheckMark(m_v_list,true);
 
932
                SetCheckMark(m_a_list,false);
 
933
                SetCheckMark(m_b_list,true);
 
934
                SetCheckMark(m_c_list,false);
 
935
                SetCheckMark(m_d_list,false);
 
936
                SetCheckMark(m_e_list,false);
 
937
                break;
 
938
            case OPT_YRP_XYZ_BV:
 
939
                // important lens distortion + v + position + translation
 
940
                SetCheckMark(m_yaw_list,true);
 
941
                SetCheckMark(m_roll_list,true);
 
942
                SetCheckMark(m_pitch_list,true);
 
943
                SetCheckMark(m_x_list,true);
 
944
                SetCheckMark(m_y_list,true);
 
945
                SetCheckMark(m_z_list,true);
 
946
                SetCheckMark(m_v_list,true);
 
947
                SetCheckMark(m_a_list,false);
 
948
                SetCheckMark(m_b_list,true);
 
949
                SetCheckMark(m_c_list,false);
 
950
                SetCheckMark(m_d_list,false);
 
951
                SetCheckMark(m_e_list,false);
 
952
                break;
 
953
            case OPT_ALL_NOTXYZ:
 
954
                // everything but translation
 
955
                SetCheckMark(m_yaw_list,true);
 
956
                SetCheckMark(m_roll_list,true);
 
957
                SetCheckMark(m_pitch_list,true);
 
958
                SetCheckMark(m_x_list,false);
 
959
                SetCheckMark(m_y_list,false);
 
960
                SetCheckMark(m_z_list,false);
 
961
                SetCheckMark(m_v_list,true);
 
962
                SetCheckMark(m_a_list,true);
 
963
                SetCheckMark(m_b_list,true);
 
964
                SetCheckMark(m_c_list,true);
 
965
                SetCheckMark(m_d_list,true);
 
966
                SetCheckMark(m_e_list,true);
 
967
                break;
 
968
            case OPT_CUSTOM:
 
969
                break;
 
970
        }
 
971
        // do not try to do anything on our own
 
972
        // if the user selected custom
 
973
        if (mode != OPT_CUSTOM && m_pano->getNrOfImages() > 0)
 
974
        {
 
975
            // get anchor image and images linked to its position.
 
976
            unsigned int refImg = m_pano->getOptions().optimizeReferenceImage;
 
977
            std::vector<unsigned int> refImgs;
 
978
            const HuginBase::SrcPanoImage & refImage = m_pano->getImage(refImg);
 
979
            for (unsigned int imgNr = 0; imgNr < m_pano->getNrOfImages(); imgNr++)
 
980
            {
 
981
                const HuginBase::SrcPanoImage & compImage = m_pano->getImage(imgNr);
 
982
                if (refImage.RollisLinkedWith(compImage) &&
 
983
                    refImage.PitchisLinkedWith(compImage) &&
 
984
                    refImage.YawisLinkedWith(compImage))
 
985
                {
 
986
                    refImgs.push_back(imgNr);
 
987
                }
 
988
            }
 
989
 
 
990
            // count number of vertical/horizontal control points
 
991
            int nHCP = 0;
 
992
            int nVCP = 0;
 
993
            const CPVector & cps = m_pano->getCtrlPoints();
 
994
            for (CPVector::const_iterator it = cps.begin(); it != cps.end(); it++)
 
995
            {
 
996
              // control points
 
997
              if (it->mode == ControlPoint::X)
 
998
              {
 
999
                  nVCP++;
 
1000
              } else if (it->mode == ControlPoint::Y)
 
1001
              {
 
1002
                    nHCP++;
 
1003
              }
 
1004
            }
 
1005
 
 
1006
            // try to select sensible position optimisation parameters,
 
1007
            // dependent on output projection
 
1008
            bool linkRefImgsYaw, linkRefImgsPitch, linkRefImgsRoll;
 
1009
            switch (m_pano->getOptions().getProjection()) {
 
1010
                case PT::PanoramaOptions::RECTILINEAR:
 
1011
                    linkRefImgsRoll = nVCP + nHCP >= 1;
 
1012
                    linkRefImgsYaw = nVCP + nHCP >= 3 && nVCP >= 1 && nHCP >= 1;
 
1013
                    linkRefImgsPitch = nVCP + nHCP >= 2;
 
1014
                    for (std::vector<unsigned int>::iterator it = refImgs.begin();
 
1015
                        it != refImgs.end(); it++)
 
1016
                    {
 
1017
                        m_roll_list->Check(*it, linkRefImgsRoll);
 
1018
                        m_yaw_list->Check(*it, linkRefImgsYaw);
 
1019
                        m_pitch_list->Check(*it, linkRefImgsPitch);
 
1020
                    }
 
1021
                    break;
 
1022
                case PT::PanoramaOptions::CYLINDRICAL:
 
1023
                case PT::PanoramaOptions::EQUIRECTANGULAR:
 
1024
                    linkRefImgsPitch =  nHCP + nVCP > 1;
 
1025
                    linkRefImgsRoll = nHCP + nVCP >= 1;
 
1026
                    for (std::vector<unsigned int>::iterator it = refImgs.begin();
 
1027
                        it != refImgs.end(); it++)
 
1028
                    {
 
1029
                        m_roll_list->Check(*it, linkRefImgsRoll);
 
1030
                        m_yaw_list->Check(*it, false);
 
1031
                        m_pitch_list->Check(*it, linkRefImgsPitch);
 
1032
                    }
 
1033
                    break;
 
1034
                default:
 
1035
                    break;
 
1036
            }
 
1037
            bool optXYZ=m_x_list->IsChecked(0) || m_y_list->IsChecked(0) || m_z_list->IsChecked(0);
 
1038
            // don't optimize translation of anchor image
 
1039
            // if translation should be optimized, then also optimise yaw and pitch of anchor
 
1040
            for (std::vector<unsigned int>::iterator it = refImgs.begin();
 
1041
                it != refImgs.end(); it++)
 
1042
            {
 
1043
                m_x_list->Check(*it, false);
 
1044
                m_y_list->Check(*it, false);
 
1045
                m_z_list->Check(*it, false);
 
1046
                if(optXYZ)
 
1047
                {
 
1048
                    m_yaw_list->Check(*it,true);
 
1049
                    m_pitch_list->Check(*it,true);
 
1050
                };
 
1051
            }
 
1052
            // disable all manual settings
 
1053
            m_yaw_list->Disable();
 
1054
            m_pitch_list->Disable();
 
1055
            m_roll_list->Disable();
 
1056
            m_x_list->Disable();
 
1057
            m_y_list->Disable();
 
1058
            m_z_list->Disable();
 
1059
            m_v_list->Disable();
 
1060
            m_a_list->Disable();
 
1061
            m_b_list->Disable();
 
1062
            m_c_list->Disable();
 
1063
            m_d_list->Disable();
 
1064
            m_e_list->Disable();
 
1065
            XRCCTRL(*this, "opt_yaw_select", wxButton)->Disable();
 
1066
            XRCCTRL(*this, "opt_roll_select", wxButton)->Disable();
 
1067
            XRCCTRL(*this, "opt_pitch_select", wxButton)->Disable();
 
1068
            XRCCTRL(*this, "opt_x_select", wxButton)->Disable();
 
1069
            XRCCTRL(*this, "opt_y_select", wxButton)->Disable();
 
1070
            XRCCTRL(*this, "opt_z_select", wxButton)->Disable();
 
1071
            XRCCTRL(*this, "opt_v_select", wxButton)->Disable();
 
1072
            XRCCTRL(*this, "opt_a_select", wxButton)->Disable();
 
1073
            XRCCTRL(*this, "opt_b_select", wxButton)->Disable();
 
1074
            XRCCTRL(*this, "opt_c_select", wxButton)->Disable();
 
1075
            XRCCTRL(*this, "opt_d_select", wxButton)->Disable();
 
1076
            XRCCTRL(*this, "opt_e_select", wxButton)->Disable();
 
1077
            XRCCTRL(*this, "opt_yaw_clear", wxButton)->Disable();
 
1078
            XRCCTRL(*this, "opt_roll_clear", wxButton)->Disable();
 
1079
            XRCCTRL(*this, "opt_pitch_clear", wxButton)->Disable();
 
1080
            XRCCTRL(*this, "opt_x_clear", wxButton)->Disable();
 
1081
            XRCCTRL(*this, "opt_y_clear", wxButton)->Disable();
 
1082
            XRCCTRL(*this, "opt_z_clear", wxButton)->Disable();
 
1083
            XRCCTRL(*this, "opt_v_clear", wxButton)->Disable();
 
1084
            XRCCTRL(*this, "opt_a_clear", wxButton)->Disable();
 
1085
            XRCCTRL(*this, "opt_b_clear", wxButton)->Disable();
 
1086
            XRCCTRL(*this, "opt_c_clear", wxButton)->Disable();
 
1087
            XRCCTRL(*this, "opt_d_clear", wxButton)->Disable();
 
1088
            XRCCTRL(*this, "opt_e_clear", wxButton)->Disable();
 
1089
        } else {
 
1090
            m_yaw_list->Enable();
 
1091
            m_pitch_list->Enable();
 
1092
            m_roll_list->Enable();
 
1093
            m_x_list->Enable();
 
1094
            m_y_list->Enable();
 
1095
            m_z_list->Enable();
 
1096
            m_v_list->Enable();
 
1097
            m_a_list->Enable();
 
1098
            m_b_list->Enable();
 
1099
            m_c_list->Enable();
 
1100
            m_d_list->Enable();
 
1101
            m_e_list->Enable();
 
1102
            XRCCTRL(*this, "opt_yaw_select", wxButton)->Enable();
 
1103
            XRCCTRL(*this, "opt_roll_select", wxButton)->Enable();
 
1104
            XRCCTRL(*this, "opt_pitch_select", wxButton)->Enable();
 
1105
            XRCCTRL(*this, "opt_x_select", wxButton)->Enable();
 
1106
            XRCCTRL(*this, "opt_y_select", wxButton)->Enable();
 
1107
            XRCCTRL(*this, "opt_z_select", wxButton)->Enable();
 
1108
            XRCCTRL(*this, "opt_v_select", wxButton)->Enable();
 
1109
            XRCCTRL(*this, "opt_a_select", wxButton)->Enable();
 
1110
            XRCCTRL(*this, "opt_b_select", wxButton)->Enable();
 
1111
            XRCCTRL(*this, "opt_c_select", wxButton)->Enable();
 
1112
            XRCCTRL(*this, "opt_d_select", wxButton)->Enable();
 
1113
            XRCCTRL(*this, "opt_e_select", wxButton)->Enable();
 
1114
            XRCCTRL(*this, "opt_yaw_clear", wxButton)->Enable();
 
1115
            XRCCTRL(*this, "opt_roll_clear", wxButton)->Enable();
 
1116
            XRCCTRL(*this, "opt_pitch_clear", wxButton)->Enable();
 
1117
            XRCCTRL(*this, "opt_x_clear", wxButton)->Enable();
 
1118
            XRCCTRL(*this, "opt_y_clear", wxButton)->Enable();
 
1119
            XRCCTRL(*this, "opt_z_clear", wxButton)->Enable();
 
1120
            XRCCTRL(*this, "opt_v_clear", wxButton)->Enable();
 
1121
            XRCCTRL(*this, "opt_a_clear", wxButton)->Enable();
 
1122
            XRCCTRL(*this, "opt_b_clear", wxButton)->Enable();
 
1123
            XRCCTRL(*this, "opt_c_clear", wxButton)->Enable();
 
1124
            XRCCTRL(*this, "opt_d_clear", wxButton)->Enable();
 
1125
            XRCCTRL(*this, "opt_e_clear", wxButton)->Enable();
 
1126
        }
 
1127
    }
1070
1128
    m_edit_cb->Enable(mode != OPT_PAIRWISE);
1071
1129
}
1072
1130
 
1076
1134
    DEBUG_TRACE("");
1077
1135
    GlobalCmdHist::getInstance().addCommand(
1078
1136
            new PT::UpdateOptimizeVectorCmd(*m_pano,getOptimizeVector()));
1079
 
    
1080
1137
}
1081
1138
 
1082
1139