1 #include <iostream>
2 #include <sstream>
3 #include "bwm_tableau_rat_cam.h"
4 
5 #include <bwm/bwm_popup_menu.h>
6 #include <bwm/bwm_observer_mgr.h>
7 #include <bwm/algo/bwm_utils.h>
8 
9 #include <vsol/vsol_point_2d.h>
10 #include "vul/vul_file.h"
11 #ifdef _MSC_VER
12 #  include "vcl_msvc_warnings.h"
13 #endif
14 
handle(const vgui_event & e)15 bool bwm_tableau_rat_cam::handle(const vgui_event &e)
16 {
17   return bwm_tableau_cam::handle(e);
18 }
19 
get_popup(vgui_popup_params const & params,vgui_menu & menu)20 void bwm_tableau_rat_cam::get_popup(vgui_popup_params const &params, vgui_menu &menu)
21 {
22   menu.clear();
23 
24   bwm_popup_menu pop(this);
25   vgui_menu submenu;
26   pop.get_menu(menu);
27 }
28 
define_lvcs()29 void bwm_tableau_rat_cam::define_lvcs()
30 {
31   float x1, y1;
32   pick_point(&x1, &y1);
33   my_observer_->define_lvcs(x1, y1);
34 }
35 
adjust_camera_offset()36 void bwm_tableau_rat_cam::adjust_camera_offset()
37 {
38   float x1, y1;
39   pick_point(&x1, &y1);
40   vsol_point_2d_sptr img_point = new vsol_point_2d(x1, y1);
41   my_observer_->adjust_camera_offset(img_point);
42 }
43 
adjust_camera_to_world_pt()44 void bwm_tableau_rat_cam::adjust_camera_to_world_pt()
45 {
46   my_observer_->adjust_camera_to_world_pt();
47 }
48 
center_pos()49 void bwm_tableau_rat_cam::center_pos()
50 {
51   my_observer_->center_pos();
52 }
53 
save()54 void bwm_tableau_rat_cam::save()
55 {
56   my_observer_->save();
57 }
58 
project_edges_from_master()59 void bwm_tableau_rat_cam::project_edges_from_master()
60 {
61   my_observer_->project_edges_from_master();
62 }
63 
register_search_to_master()64 void bwm_tableau_rat_cam::register_search_to_master()
65 {
66   my_observer_->register_search_to_master();
67 }
68 
save_camera()69 std::string bwm_tableau_rat_cam::save_camera()
70 {
71   std::string img_path = this->img_path();
72   std::string cam_path = my_observer_->camera_path();
73 
74   // see if the camera is adjusted
75   if (my_observer_->camera_adjusted()) {
76     //need to save the new camera
77     std::string new_cam_path = vul_file::strip_extension(cam_path);
78     std::string::size_type pos = new_cam_path.find("_v", 0);
79     if (pos != std::string::npos) {
80       new_cam_path.erase(pos, new_cam_path.length()-1);
81     }
82     std::stringstream strm;
83     strm << std::fixed << timer_.real();
84     std::string str(strm.str());
85     new_cam_path += "_v" + str + vul_file::extension(cam_path);
86     my_observer_->camera().save(new_cam_path);
87 
88     // camera is saved and no need to save the next time
89     my_observer_->set_camera_path(new_cam_path);
90     my_observer_->set_camera_adjusted(false);
91 
92     return new_cam_path;
93   }
94   else {
95     std::cout << "bwm_tableau_rat_cam::save_camera -- Camera has not changed, not saving!" << std::endl;
96     return cam_path;
97   }
98 }
99