#include <mainControl.h>
Inheritance diagram for VIEW::MainControl:
Management of ModularWidget(s) and Message(s) | |
void | addModularWidget (ModularWidget *widget) throw () |
Add a new ModularWidget to this MainControl. | |
void | removeModularWidget (ModularWidget *widget) throw () |
Remove a ModularWidget from the MainControl. | |
virtual void | onNotify (Message *message) throw () |
Message handling method. | |
void | sendMessage (Message &message) throw () |
Send a Message from Python. | |
MainControl * | getMainControl (const QObject *object) throw () |
Return the MainControl of an QObject. | |
Public Types | |
Enumerations | |
enum | PopUpID { FILE = 10001, FILE_OPEN, FILE_OPEN_GRID, FILE_IMPORT, FILE_EXPORT, FILE_MONITOR, EDIT = 10100, BUILD = 10200, DISPLAY = 10300, DISPLAY_CREATE, DISPLAY_VIEWPOINT, DISPLAY_STEREO, DISPLAY_ANIMATION, MOLECULARMECHANICS = 10400, CHOOSE_FF, TOOLS = 10500, TOOLS_GRID, TOOLS_PYTHON, WINDOWS = 10600, USER = 10700, MACRO = 10750, HELP = 10800 } |
Standard Popup menu IDs. More... | |
Public Slots | |
Public slots | |
virtual void | show () |
Initialize all registered ModularWidget objects. | |
virtual void | checkMenus () |
Menu checking method. | |
void | stopSimulation () |
Stop a currently running calculation. | |
void | complementSelection () |
virtual void | aboutToExit () |
Last second cleanup. | |
void | menuItemHighlighted (QAction *action) throw () |
Slot that is called when a menu item is highlighted. | |
virtual bool | event (QEvent *e) |
Interface to QT events, e.g. to communicate with other threads. | |
virtual void | quit (int return_value=0) |
Make the program exit. | |
virtual void | resize (int w, int h) |
overloaded from QT for Python Interface | |
void | setContentSize (int w, int h) |
void | toggleFullScreen () |
void | quickSave () |
Create a BALLView project file with the name quick.bvp in the users home dir. | |
void | quickLoad () |
Quickload quick.bvp in the users home die (see above). | |
void | saveBALLViewProjectFile () throw () |
void | loadBALLViewProjectFile () throw () |
void | quickLoadConfirm () |
Public Member Functions | |
Constructors and Destructor | |
MainControl (QWidget *parent=0, const char *name=0, String inifile=".BALL.preferences") throw () | |
Default Constructor. | |
virtual | ~MainControl () throw () |
Destructor. | |
MainControl (const MainControl &main_control) throw () | |
virtual void | clear () throw () |
Clear all data fast, to be called at exit only! | |
void | clearData () throw () |
Clear all data, can be called at any time. | |
Methods to manage Representation(s) | |
RepresentationManager & | getRepresentationManager () throw () |
Get the primitive manager. | |
bool | insert (Representation &rep) throw () |
Insert a Representation The Representation must be created on the heap!!! A RepresentationMessage with type NEW is send. | |
bool | remove (Representation &rep) throw () |
Remove a Representation A RepresentationMessage with type REMOVE is send. | |
bool | update (Representation &rep) throw () |
Update a Representation A RepresentationMessage with type UPDATE and a SceneMessage is send. | |
bool | updateRepresentationsOf (const Composite &composite, bool rebuild=true, bool force=false) throw () |
Redraws all Representation objects for a Composite. | |
void | redrawAllRepresentations (bool rebuild_display_lists=false) throw () |
Redraws all inserted Representation, but doesnt change the Models. | |
Methods to manage Composite(s) | |
CompositeManager & | getCompositeManager () throw () |
Get the composite manager. | |
bool | insert (Composite &composite, String name="") throw () |
Insert a Composite and notify all ModularWidget. | |
bool | remove (Composite &composite, bool to_delete=true, bool update=true) throw () |
Remove a Composite and notify all ModularWidget. | |
void | update (Composite &composite, bool changed_hierarchy=true) throw () |
Update a Composite in all ModularWidget. | |
const HashSet< Composite * > & | getSelection () const throw () |
Get the HashSet with the selected (e.g. picked) Composite objects (const). | |
HashSet< Composite * > & | getSelection () throw () |
Get the HashSet with the selected (e.g. picked) Composite objects. | |
List< Composite * > & | getMolecularControlSelection () throw () |
Get the selection (highlighted items) of the MolecularControl (not the selection with checkboxes). | |
System * | getSelectedSystem () throw () |
If exactly one System is selected in the Control, return a pointer to this system, otherwise 0. | |
void | selectCompositeRecursive (Composite *composite, bool first_call=false) throw () |
Select a Composite recursive and add all Atom and AtomContainer objects to the selection. | |
void | deselectCompositeRecursive (Composite *composite, bool first_call=false) throw () |
Select a Composite recursive and add all Atom and AtomContainer objects to the selection. | |
void | clearSelection () throw () |
Clear Selection Deselect all Composites and clear the selection list in the MainControl. | |
void | printSelectionInfos () throw () |
Print some informations for the selection in the statusbar. | |
Preferences and Configuration files | |
void | saveBALLViewProjectFile (const String &filename) |
Save the current configuration, structures and representations to a BALLView project file (*.bvp). | |
void | loadBALLViewProjectFile (const String &filename) throw () |
Load a BALLView project file. | |
virtual void | fetchPreferences (INIFile &inifile) throw () |
Fetch the preferences from the INIfile. | |
virtual void | writePreferences (INIFile &inifile) throw () |
Writes the widgets preferences to the INIFile. | |
virtual void | restoreWindows (const INIFile &inifile) throw () |
Restore the positions the main window and of all DockWindow's from the INIFile. | |
INIFile & | getINIFile () throw () |
Mutable inspection of the INIFile. | |
const INIFile & | getINIFile () const throw () |
Non-mutable inspection of the INIFile. | |
Preferences * | getPreferences () throw () |
Mutable inspection of the preferences dialog. | |
virtual void | applyPreferences () throw () |
Apply all preferences. | |
Menu entries handling | |
QAction * | insertMenuEntry (Position parent_id, const String &name, const QObject *receiver=0, const char *slot=0, QKeySequence accel=QKeySequence()) throw () |
Insert a new menu entry into menu ID (creates a new menu if ID not existent). | |
void | removeMenuEntry (Index parent_id, QAction *action) throw () |
virtual QMenu * | initPopupMenu (int ID) throw () |
Initialize a new popup menu ID. | |
void | insertPopupMenuSeparator (int ID) throw () |
Insert a separator into the popup menu ID. | |
void | setMenuHint (QAction *id, const String &hint) throw () |
Set a hint for a menu entry. | |
String | getMenuHint (QAction *id) const throw () |
Get the hint for a menu entry. | |
void | setDeleteEntryEnabled (bool state) throw () |
Enable the delete entry for GenericControls. | |
void | insertDeleteEntry () throw () |
Insert the delete entry for GenericControls. | |
QAction * | getLastHighLightedMenuEntry () |
Get the ID of the last highlighted menu entry (used for the HelpViewer). | |
Methods for multithreading | |
bool | compositesAreLocked () const throw () |
Check wheter the stored composites can be modified at the moment. | |
bool | lockCompositesFor (ModularWidget *widget) throw () |
Lock the Composites for a given Modular Widget. | |
bool | unlockCompositesFor (ModularWidget *widget) throw () |
Lock the Composites for a given Modular Widget. | |
ModularWidget * | getLockingWidget () throw () |
Get the ModularWidget with excluse access to the Composites. | |
bool | updateOfRepresentationRunning () throw () |
Return true if Representations are (re)calculated. | |
bool | stopedSimulation () |
Returns true, if the simulation was told to stop, but hasnt done this so far. | |
bool | setSimulationThread (SimulationThread *thread) throw () |
Set the simulation thread. | |
SimulationThread * | getSimulationThread () throw () |
Get the currently running SimulationThread or zero pointer if no simulation running. | |
bool | useMultithreading () throw () |
Method to query if multithreading is enabled. | |
void | setMultithreading (bool state) throw () |
See above. | |
bool | isBusy () const |
void | wait () |
Wait until the MainControl is not busy anymore. | |
void | processEvents (Size ms) |
Added overloaded method from QApplication for access in Python. | |
Accessors and Settings | |
void | setStatusbarText (const String &text, bool important=false, bool beep=false) throw () |
Sets the text in the statusbar. | |
String | getStatusbarText () const throw () |
const FragmentDB & | getFragmentDB () const throw () |
Get a const reference for the fragment database. | |
const ModelInformation & | getModelInformation () const |
void | setModelInformation (ModelInformation *mi) |
String | getWorkingDir () const throw () |
BALLView stores the directory of the last file operation, e.g. | |
void | setWorkingDir (const String &dir) throw () |
Set the working directory for the next file dialog and file operation to the given directory. | |
void | enableLoggingToFile () throw () |
This enables logging to an file for all messages send per LogStream .e.g. | |
void | disableLoggingToFile () throw () |
This disables logging to an file for all messages send per LogStream .e.g. | |
void | setLoggingFilename (const String &string) throw () |
Set the name for the logging file (see above) to the given name. | |
const String & | getLoggingFilename () const throw () |
See above. | |
void | setProxy (const String &host, Position port) |
Set the proxy for HTTP and FTP operations. | |
String | getProxy () const |
Get the hostname for the proxy. | |
Position | getProxyPort () const |
Get the port for the proxy. | |
bool | isAboutToQuit () |
Debugging and Diagnostics | |
virtual void | dump (std::ostream &s=std::cout, Size depth=0) const throw () |
Internal state dump. | |
virtual void | openFile (const String &file) throw () |
Open a file. | |
Protected Slots | |
virtual void | applyPreferencesClicked_ () |
void | clearStatusBarText_ () |
virtual void | deleteClicked () |
void | updateRepLabel_ () |
Protected Member Functions | |
virtual void | initializePreferencesTab_ () throw () |
void | stopedSimulation_ () |
void | lockComposites_ () |
bool | remove_ (Composite &composite, bool update_representations_of_parent=true, bool to_delete=true) throw () |
void | selectComposites_ (GeometricObjectSelectionMessage &message) throw () |
void | reduceSelection_ (Composite *const composite) |
void | setup_ () throw () |
void | complementSelectionHelper_ (Composite &c) |
void | setBusyMode_ (bool state) |
Show a busy cursor and a busy icon in the statusbar. | |
void | setPreferencesEnabled_ (bool state) |
void | init_ () |
Protected Attributes | |
bool | about_to_quit_ |
FragmentDB | fragment_db_ |
ModelInformation * | model_information_ |
HashSet< Composite * > | selection_ |
List< Composite * > | control_selection_ |
QLabel * | message_label_ |
RepresentationManager | primitive_manager_ |
CompositeManager | composite_manager_ |
MainControlPreferences * | main_control_preferences_ |
NetworkPreferences * | network_preferences_ |
Preferences * | preferences_dialog_ |
INIFile | preferences_file_ |
bool | composites_locked_ |
ModularWidget * | locking_widget_ |
bool | stop_simulation_ |
SimulationThread * | simulation_thread_ |
bool | multi_threading_mode_ |
List< ModularWidget * > | modular_widgets_ |
QLabel * | simulation_icon_ |
QLabel * | rep_label_ |
Position | rep_label_nr_ |
String | working_dir_ |
String | logging_file_name_ |
bool | logging_to_file_ |
File | logging_file_ |
bool | important_text_in_statusbar_ |
bool | was_not_busy_ |
Index | rep_label_delta_ |
QTimer | timer_ |
QTimer | render_timer_ |
QMutex | composites_locked_mutex_ |
String | proxy_ |
Position | proxy_port_ |
QAction * | stop_simulation_action_ |
QAction * | complement_selection_action_ |
QAction * | open_action_ |
QAction * | save_project_action_ |
QAction * | preferences_action_ |
QAction * | delete_action_ |
QAction * | qload_action_ |
QAction * | qsave_action_ |
QAction * | last_highlighted_menu_entry_ |
HashMap< Position, QMenu * > | id_to_menu_ |
bool | fullscreen_ |
QPoint | last_point_ |
QSize | last_size_ |
QByteArray | last_state_ |
Static Protected Attributes | |
const char * | simulation_running_xpm_ [] |
const char * | simulation_stoped_xpm_ [] |
Friends | |
class | RepresentationManager |
class | SimulationThread |
MainControl is also derived from Qt::QMainWindow and therefore the main widget of an application must be derived from this class. Further it has the necessary interface methods to create and update the menus of the main application.
MainControl is also a storage facility for Composite objects, the graphical Representation and the inserted ModularWidget. The interface for the Composite administration is implemented in CompositeManager, and for the Representation 's in RepresentationManager. Specialized methods exists for the adding, updateing and removing of Composites as well as Representations. (see the update, insert and remove methods)
This class is also the root ConnectionObject and thus it is responsible for the handling of all messages. To add ModularWidgets all that is necessary are the creation of the derived modular widgets with the MainControl as their parents like e.g.
new DisplayProperties(this, "DisplayProperties");
For examples have a look at BALL/source/APPLICATIONS/mainframe.C
MainControl also handles the Preferences dialog (and it's tab entry for some general preferences) and notifies all registered ModularWidgets if the preferences have changed. The content of the Preferences dialog with all setup options is stored in an INIFile. The default name of this file is ".BALLView".
loadBALLViewProjectFile
Caveat: Due to a peculiarity of the QT Meta Object Compiler (MOC) you have to specify the full namespace qualified name of this class when deriving from it.
class foo : public MainControl
; but class foo : public VIEW::MainControl
instead.
|
Standard Popup menu IDs. This enum defines symbolic names for the menu IDs of the most common popup menus. The popups are created, if a menu entry is requested for any of the popups.
|
|
Default Constructor.
Reads the the INIFile
|
|
Destructor. Calls clear |
|
Last second cleanup. This method will be called internally if the MainControl is about to be destroyed. This method stores the preferences and finalizes all ModularWidget objects and the MainControl. Must be called after your own cleanup routine if you override this method.
|
|
Add a new ModularWidget to this MainControl. This method will be called internally by the ModularWidget registration process. So, if you dont know exactly what this method does, you will not need it!
|
|
Apply all preferences. This method is called automatically by applyPreferencesClicked() and calls applyPreferences() for all registered ModularWidgets. Note: If this method is overridden, call this method at the end of the overriden method to make sure that the general preferences are applied.
|
|
Menu checking method. This method checks, enables or disables all inserted menu entries of the registered ModularWidget objects. If this method is overridden make sure that it will be called at the end of the new checkMenus() method. See ModularWidget for further information concerning menu structure creation.
|
|
Check wheter the stored composites can be modified at the moment. This method returns true e.g. while a MD simulation is running. |
|
This disables logging to an file for all messages send per LogStream .e.g. Log().error() |
|
Internal state dump. Dump the current internal state of this mainControl to the output ostream s with dumping depth depth.
Reimplemented from Embeddable. |
|
This enables logging to an file for all messages send per LogStream .e.g. Log().error() |
|
Fetch the preferences from the INIfile. Calls fetchPreferences() for all registered ModularWidgets. Note:If this method is overridden, call this method at the end of the overriden method to make sure that the general preferences are fetched.
|
|
Get the composite manager. The class CompositeManager is the owner of all Composite objects. |
|
Non-mutable inspection of the INIFile.
|
|
Mutable inspection of the INIFile.
|
|
Return the MainControl of an QObject. This method returns the MainControl that should be the root of the ConnectionObject tree from a given widget or dialog QObject. Because we use the qt library, every widget or dialog has QObject as a base class. MainControl is the main application and therefore all widgets and dialogs are its children. We use the qt QObject tree mechanism to return the MainControl for a given QObject.
|
|
Mutable inspection of the preferences dialog.
|
|
Get the primitive manager. The class RepresentationManager contains all Representation objects and GeometricObject. |
|
Get the currently running SimulationThread or zero pointer if no simulation running.
|
|
BALLView stores the directory of the last file operation, e.g. when a PDB file is opened or saved. This saves the user some time, since he doesnt have to change the folders in the file dialogs as often. This method returns the last directory. |
|
Initialize a new popup menu ID. If the MainControl has already the popup menu ID that QPopupMenu is returned. See the documentation of the qt library for more information concerning the class QPopupMenu.
|
|
Insert a Composite and notify all ModularWidget. The Composite has to be created on the heap!!! A CompositeMessage with type NEW_COMPOSITE is send and CompositeManager::insert called.
|
|
Insert a Representation The Representation must be created on the heap!!! A RepresentationMessage with type NEW is send.
|
|
Insert the delete entry for GenericControls. Called by all GenericControls. |
|
Insert a new menu entry into menu ID (creates a new menu if ID not existent). See the documentation of the qt library for more information concerning menu creation.
|
|
Insert a separator into the popup menu ID. If the menu ID is not existent, it will be created first.
|
|
Lock the Composites for a given Modular Widget. This allows exclusive acces e.g. to delete or modify Composites and prevents those nasty segfaults if an other thread works on the Composites. true if the exclusive lock on the composites could be obtained |
|
Slot that is called when a menu item is highlighted. It is used to show a hint for every menu entry.
|
|
Message handling method. Handles messages sent by other registered ModularWidget objects. Virtual function for overriden the message handling system. Take care to call this function in your own ModularWidget. There is no need to call this function, because it will be called from the message handling mechanism. Remember: A ModularWidget is not notified by the Messages it sends itself!
Reimplemented from VIEW::ConnectionObject. |
|
Open a file. This method is called to parse any command line arguments. It iterates over all ModularWidgets and calls ModularWidget::canHandle with the files extension (the suffix after the dot in the filename). If one ModularWidget can handle the format, ModularWidget::openFile is called. |
|
Print some informations for the selection in the statusbar. Called by selectComposites_(). If one Atom is selected, its position is printed. If two Atom objects are selected, their distance, for three Atom 's their angle and for four Atom 's their torsion angle. Else the number of items is printed. |
|
Redraws all inserted Representation, but doesnt change the Models.
|
|
Remove a Composite and notify all ModularWidget. A CompositeMessage with type REMOVED_COMPOSITE is send and CompositeManager::remove called.
|
|
Remove a Representation A RepresentationMessage with type REMOVE is send.
|
|
Remove a ModularWidget from the MainControl. This method will be called internally by the ModularWidget registration process. So, if you dont know exactly what this method does, you will not need it!
|
|
Send a Message from Python. Otherwise, you should prefer to use ModularWidget::notify_. The MainControl itself also reacts to a Message, send with this method. The Message will be deleted, after it was send to all ModularWidget's. |
|
Show a busy cursor and a busy icon in the statusbar.
|
|
Enable the delete entry for GenericControls. Called by a GenericControl, if it has a selection, that can be deleted. |
|
Set the name for the logging file (see above) to the given name. This file is stored in the users home dir. |
|
Set the simulation thread. The instance of SimulationThread will be deleted after it has finished. If an other simulation is still running, this method returns false. |
|
Sets the text in the statusbar. The statusbar has a label, whose text is set to the given argument. It is possible to notify the user with a beep sound.
|
|
Initialize all registered ModularWidget objects. It initializes the menu structure, the preferences dialogs and connects every ModularWidget with the MainControl. This method also creates the first menu entry FILE with its subentry EXIT to exit the application. See ModularWidget for further information concerning menu structure creation and preferences handling.
|
|
Update a Composite in all ModularWidget. This method differs wheter the composites hierarchy was changed or not. The update is faster if the hierarchy is unchanged, because e.g. the MolecularControl doesnt have to rebuild the ListViewItem tree. A CompositeMessage with type CHANGED_COMPOSITE or CHANGED_COMPOSITE_HIERARCHY is send and updateRepresentationsOf(composite) is called.
|
|
Update a Representation A RepresentationMessage with type UPDATE and a SceneMessage is send.
|
|
Redraws all Representation objects for a Composite.
If the Composite is not inserted into this MainControl
|
|
Method to query if multithreading is enabled. Multithreaded code is used for serveral functions:
|
|
Writes the widgets preferences to the INIFile. Calls writePreferences() for all registered ModularWidgets and Preferences::savePreferences(). Note: If this method is overridden, call this method at the end of the overriden method to make sure that the general preferences are written.
|