// $Id: D0ve.hpp,v 1.30 2002/08/18 21:50:18 burnett Exp $ // Author: Toby Burnett // #ifndef D0VE_H #define D0VE_H #include "d0ve/SubMenu.hpp" #include "d0ve/PrintControl.hpp" #include "d0ve/DisplayControl.hpp" #include "d0ve/GUI.hpp" #include #include namespace d0ve { class Command; // Sets up a D0 visualization and control environment. // // D0ve also has a command source, encapsulated by a Menu and the // output devices: DisplayControl and PrintControl. class D0ve { public: D0ve( float size=2000, int initial_view=1, int pause_interval=0 , int winsize=500, std::string background_color="lightgray"); // Constructors: size will be the initial size of the display viewport // which should enclose subsequent volumes // initial view is the starting view number ~D0ve(); void begin_event(const std::string& label=""); // should be called at start of event. label, if present, is used for window title void end_event(); // must be called at the end of an event to allow regaining control void break_point(const std::string& title_bar_text = "[user pause]"); // if called from a user program, will update and refresh the display, // then, if D0ve is in a paused state, go into a GUI wait loop until CR or spacebar. // The optional title bar text will be put on the title. Call with empty string to // keep same display. bool done() const; // return true if end of run, false to continue void run(bool paused=true,bool threaded=false); // start the message loop, in perhaps a running condition. // pass threaded info to GUI static D0ve* instance(); // Access to singleton instance GUI& gui()const; // Returns the GUI DisplayControl& display()const; // Returns the DisplayControl PrintControl& printer()const; // Returns the PrintControl Menu& menu()const; // Returns the Menu SubMenu& sub_menu()const; // returns the eventloop submenu float size()const; // access to world size // these needed to implement MenuClient interface void quit(); void finishSetup(){}; // dummy // these connected to keys, buttons void pause(); // set status to pause on next loop (or single step) void resume(); // set status to skip next loop (or resume if paused) /// access to the control for modifying intial setup, etc. SceneControl& sceneControl()const; void quitCheck(); // quit if user wants private: void stop_loop(); void queryPause(); enum {INITIAL, RUNNING, PAUSED, DONE, TIMER } m_state; GUI* m_gui; Menu* m_menu; DisplayControl* m_display; PrintControl* m_print; float m_size; SubMenu* m_sub_menu; int m_pause_interval; SceneControl* m_scene_control; void setup(float size, int initial_view, int pause_interval); static D0ve* s_instance; Command *m_c1, *m_c2; // commands }; // inline trivial access functions inline float D0ve::size()const {return m_size;} inline GUI& D0ve::gui()const {return *m_gui; } inline DisplayControl& D0ve::display()const{return *m_display;} inline PrintControl& D0ve::printer()const{return *m_print;} inline Menu& D0ve::menu()const {return *m_menu;} inline SubMenu& D0ve::sub_menu()const{return *m_sub_menu;} inline bool D0ve::done()const {return m_state==DONE;} inline SceneControl& D0ve::sceneControl()const{return *m_scene_control;} // inline the constructor to force the GUI::createGUI call into the user's // application inline D0ve::D0ve( float size, int initial_view, int pause_interval, int winsize, std::string background_color) :m_gui(GUI::createGUI("D0ve", "D0ve", winsize, background_color)) { setup(size,initial_view,pause_interval); } } // namespace d0ve #endif