Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

DisplayControl.h

Go to the documentation of this file.
00001 //     $Id: DisplayControl.h,v 1.2 2001/01/25 01:36:32 burnett Exp $
00002 //  Author: Toby Burnett
00003 //
00004 //
00005 
00006 #ifndef DISPLAYCONTROL_H
00007 #define DISPLAYCONTROL_H
00008 
00009 
00010 #include <string>
00011 #include <vector>
00012 
00013 #include "gui/Command.h"
00014 #include "gui/Menu.h"
00015 
00016 #include "gui/DisplayRep.h"
00017 #include "gui/DisplayRep2D.h"
00018 
00019 namespace gui {
00020 
00021 class Scene;
00022 class SceneControl;
00023 class Draw2D;
00024 
00025 class DisplayControl  {
00026     // definition of the class DisplayControl--handle event display. It
00027     // has a list of <<DisplayRep>> objects which it manages, and sets up a "Display"
00028     // menu.
00029 
00030 public:
00031 
00032     DisplayControl(Menu& menu, SceneControl* control); 
00033     // constructor with reference to menu, scene controler
00034 
00035     ~DisplayControl();
00036     
00037     GUI::Toggle* add(DisplayRep* arep, const std::string& name=std::string(""), int state=1);
00038     // Add an element to the display
00039     // It the name argument is present, create a  button for it under the "display"
00040     // pull-down menu. If state is 0 or 1 it will be a toggle, starting show/hide. 
00041     // In that case, return pointer to a Toggle that allows independent set/unset
00042     // Otherwise create separate show and hide buttons
00043 
00044     void add(DisplayRep2D* arep, const std::string& name=std::string(""), int state=1);
00045     // add  element to 2-d display
00046 
00047     void setTitle(const std::string& title);
00048     // set the title bar of the associated window
00049 
00050     void setAxisSize(float size=1);
00051 
00052     GraphicsVector& reference_point();
00053     const GraphicsVector& reference_point()const;
00054     // access to current reference point
00055     
00056     void postScript();
00057     // dump current view to a file for postscript (if viewport is a Projector)
00058 
00059     void vrml(std::ostream& out);
00060     // write out a VRML file
00061 
00062     void update();
00063     // ask scene to update
00064 
00065     void redisplay();
00066     // redisplay all objects, if running
00067 
00068     void set_running(bool s){m_running=s;}
00069     // use to temporarily disable redisplay when modifying show/hide bit of many objects
00070          
00071 
00072     void clear();
00073     // clear display (send message to the scene)
00074     
00075     Scene& scene();
00076     const Scene& scene()const;
00077     // access to the 3-d scene
00078 
00079     SubMenu& menu(); 
00080     // return the (sub)menu associated with the display
00081 
00082     void useMenu(SubMenu* s=0);
00083     // set a different submenu (which could be a sub-submenu of this Display menu)
00084     // if no argument, revert to the standard
00085 
00086     // needed to implement interface MenuClient
00087     void finishSetup();    // adds menu items after all user buttons
00088     void quit(){};
00089 
00090     //------------------------------------------------------------------
00091     // Define nested class to handle submenu
00092     class DisplaySubMenu     {
00093         // This is a special SubMenu, containing a pointer to a gui::SubMenu,
00094         // and a list of nested SubMenus (allowing a tree)
00095     public:
00096         ~DisplaySubMenu();
00097         
00098         DisplaySubMenu& subMenu(const std::string& label, DisplayRep* rep=0);
00099         // return reference to a new sub menu, with given button label, and optional rep
00100         // that will be controlled by a "Show All" button at its top.
00101         // This button also applies to all submenus of this
00102 
00103         void add(DisplayRep * rep, const std::string& name="");
00104         // add a rep with optional name to be used for button
00105 
00106     private:
00107         friend class DisplayControl;
00108         void hide();
00109         void hide(bool update);
00110         void show();
00111         void show(bool update);
00112         DisplaySubMenu(DisplayControl* display, DisplaySubMenu* parent, DisplayRep * rep, const std::string& name);
00113         DisplayRep* _rep;  // optional rep
00114         gui::SubMenu* _menu; // 
00115         DisplayControl* _display;
00116         std::vector<DisplaySubMenu*> _submenus;
00117         std::vector<GUI::Toggle*> _rep_list; // list of toggles for reps
00118     };
00119     //------------------------------------------------------------------
00120 
00121     DisplaySubMenu& subMenu(const std::string& label, DisplayRep* rep=0);
00122     // function that returns a new SubMenu
00123 
00124 
00125 private:
00126     void setRefPt(); // called by registered button to get dialog
00127     void setScale(); // called by registered button to get dialog
00128     GUI::Toggle* addButton(DisplayRep* arep, const std::string& name, int state);
00129     // internal routine
00130     
00131     gui::SubMenu*  m_sub_menu; // special sub menu we control
00132     gui::SubMenu*  m_user_menu;// user-settable menu
00133     Menu*       m_menu_bar;     // original menu object
00134 
00135     Scene*      m_scene;        // Scene (3d )
00136     Scene*      m_2d_scene;     // 2d scene
00137     SceneControl* m_control;    // Scene controller
00138     
00139     float       m_axis_size;
00140     bool        m_running;      // used to keep track of startup
00141 
00142     Draw2D*     m_canvas;       // access to the 2-d canvas
00143 
00144     std::vector<DisplaySubMenu*> _submenus; // list to delete.
00145 };
00146 
00147 inline gui::SubMenu& DisplayControl::menu(){return *m_sub_menu;} 
00148 inline gui::Scene&   DisplayControl::scene(){return *m_scene;}
00149 inline const gui::Scene&   DisplayControl::scene()const{return *m_scene;}
00150 
00151 } // namespace gui
00152 #endif 
00153 
00154 

Generated at Mon Nov 26 18:18:10 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000