contrib/brl/bbas/bgui3d/bgui3d_examiner_tableau.h
Go to the documentation of this file.
00001  // This is brl/bbas/bgui3d/bgui3d_examiner_tableau.h
00002 #ifndef bgui3d_examiner_tableau_h_
00003 #define bgui3d_examiner_tableau_h_
00004 //:
00005 // \file
00006 // \brief  Examiner viewer tableau for 3D scenes
00007 // \author Matt Leotta (mleotta@lems.brown.edu)
00008 // \date   May 25, 2004
00009 //
00010 // \verbatim
00011 //  Modifications
00012 //   <none yet>
00013 // \endverbatim
00014 
00015 #include "bgui3d_fullviewer_tableau.h"
00016 #include "bgui3d_examiner_tableau_sptr.h"
00017 #include <Inventor/SbLinear.h>
00018 #include <Inventor/nodes/SoText2.h>
00019 #include <Inventor/nodes/SoSwitch.h>
00020 
00021 class SbSphereSheetProjector;
00022 class SbRotation;
00023 class SoTimerSensor;
00024 class SoCone;
00025 
00026 enum Process
00027 {
00028   SPIN=0,
00029   DRAG,
00030   PAN,
00031   ZOOM,
00032   IDLE,
00033   SEEK
00034 };
00035 
00036 struct Log
00037 {
00038   int size;
00039   SbVec2f pos1;
00040   SbVec2f pos2;
00041   SbVec2f pos3;
00042 };
00043 
00044 //:  Examiner viewer tableau for 3D scenes
00045 class bgui3d_examiner_tableau : public bgui3d_fullviewer_tableau
00046 {
00047  public:
00048   enum SeekDistance
00049   {
00050     SEEK_FAR,
00051     SEEK_HALF,
00052     SEEK_NEAR,
00053     SEEK_ZERO
00054   };
00055 
00056   //: Constructor
00057   bgui3d_examiner_tableau(SoNode * scene_root = NULL);
00058 
00059   //: Destructor
00060   virtual ~bgui3d_examiner_tableau();
00061 
00062   //: Handle vgui events
00063   virtual bool handle(const vgui_event& event);
00064 
00065   //: Return the type name of this tableau
00066   vcl_string type_name() const;
00067 
00068   //: Builds a popup menu
00069   virtual void get_popup(const vgui_popup_params&, vgui_menu &m);
00070 
00071   //: Render the scene graph (called on draw events)
00072   virtual bool render();
00073 
00074   //: Pans the camera
00075   void pan(const SbVec2f & currpos, const SbVec2f & prevpos, const float aspect_ratio);
00076 
00077   //: Zooms the camera
00078   void zoom( float aspectratio );
00079 
00080   //: Spins the camera around the scene
00081   void spin(const SbVec2f& currpos, const SbVec2f &prevpos);
00082 
00083   //: Reorients the camera to the specified rotation
00084   void reorient_camera(const SbRotation & rot);
00085 
00086   //: Updates position log
00087   void update_log(SbVec2f pos);
00088 
00089   //: Resets position log
00090   void reset_log();
00091 
00092   //: Seeks for the object under a mouse click and zooms to it
00093   void seek_to_point(SbVec2s pos);
00094 
00095   //: What to do if events are idle, if enabled
00096   bool idle();
00097 
00098   //: Set the visibility of the axis cross
00099   void set_axis_visible(bool state);
00100 
00101   //: Return true if the axis cross is visible
00102   bool axis_visible() const;
00103 
00104   void set_seek_distance( SeekDistance seek );
00105 
00106   //void seeksensorCB(void * data, SoSensor * s);
00107 
00108  protected:
00109   // these are made protected (instead of private) so that child classes
00110   // can access them
00111   vgui_button last_down_button_;
00112   SbVec2f last_pos_;
00113   Process last_process_;
00114   int last_timestamp_;
00115 
00116   //: draw the axis
00117   void draw_axis_cross();
00118 
00119   //: Draw an arrow for the axis representation
00120   void draw_arrow();
00121 
00122   //: Determine the scale of the scene
00123   void find_scale();
00124 
00125  private:
00126   SbSphereSheetProjector* spin_projector_;
00127   int spin_sample_counter_;
00128   SbRotation spin_increment_;
00129   Log log_;
00130   SeekDistance seek_distance_;
00131   SoTimerSensor* seekSensor_;
00132 
00133   // The scale of the scene
00134   float scale_;
00135 
00136   bool axis_visible_;
00137 
00138  public:
00139   SbRotation fromRot_;
00140   SbRotation toRot_;
00141   SbVec3f fromPos_;
00142   SbVec3f toPos_;
00143 };
00144 
00145 
00146 //: Create a smart pointer to a bgui3d_examiner_tableau.
00147 struct bgui3d_examiner_tableau_new : public bgui3d_examiner_tableau_sptr
00148 {
00149   typedef bgui3d_examiner_tableau_sptr base;
00150   bgui3d_examiner_tableau_new(SoNode* scene_root = NULL)
00151    : base(new bgui3d_examiner_tableau(scene_root)) {}
00152 };
00153 
00154 
00155 #endif // bgui3d_examiner_tableau_h_