BALL 1.5.0
Loading...
Searching...
No Matches
mainControl.h
Go to the documentation of this file.
1// -*- Mode: C++; tab-width: 2; -*-
2// vi: set ts=2:
3//
4
5#ifndef BALL_VIEW_KERNEL_MAINCONTROL_H
6#define BALL_VIEW_KERNEL_MAINCONTROL_H
7
8#ifndef BALL_CONCEPT_EMBEDDABLE_H
10#endif
11
12#ifndef BALL_DATATYPE_HASHMAP_H
14#endif
15
16#ifndef BALL_VIEW_KERNEL_CONNECTIONOBJECT_H
18#endif
19
20#ifndef BALL_VIEW_KERNEL_REPRESENTATIONMANAGER_H
22#endif
23
24#ifndef BALL_VIEW_KERNEL_COMPOSITEMANAGER_H
26#endif
27
28#ifndef BALL_VIEW_KERNEL_SHORTCUTREGISTRY_H
30#endif
31
32#ifndef BALL_VIEW_KERNEL_UIOPERATIONMODE_H
34#endif
35
36#ifndef BALL_VIEW_KERNEL_UIOPERATIONMODE_H
38#endif
39
40#ifndef BALL_FORMAT_INIFILE_H
41# include <BALL/FORMAT/INIFile.h>
42#endif
43
44#ifndef BALL_SYSTEM_FILE_H
45# include <BALL/SYSTEM/file.h>
46#endif
47
48#ifndef BALL_STRUCTURE_FRAGMENTDB_H
50#endif
51
52#include <QtGui/QKeySequence>
53#include <QtWidgets/QMainWindow>
54#include <QtWidgets/QApplication>
55#include <QtWidgets/QMenuBar>
56#include <QtWidgets/QLabel>
57#include <QtCore/QTimer>
58
59class QCloseEvent;
60
61namespace BALL
62{
63 namespace VIEW
64 {
65 class ModelInformation;
66 class ModularWidget;
67 class Preferences;
68 class MainControlPreferences;
69 class OpenSavePreferences;
70 class NetworkPreferences;
71 class GeometricObjectSelectionMessage;
72 class SimulationThread;
73
115 : public QMainWindow,
116 public ConnectionObject,
117 public Embeddable
118 {
120 friend class SimulationThread;
121
122 Q_OBJECT
123
124 public:
125
127
128
137 {
139 FILE = 10001,
140
143
146
149
152
155
157 EDIT = 10100,
158
160 BUILD = 10200,
161
163 DISPLAY = 10300,
164
167
170
173
176
177#ifdef BALL_HAS_RTFACT
179 DISPLAY_CONTINUOUSLOOP,
180#endif
182 MOLECULARMECHANICS = 10400,
183
186
188 TOOLS = 10500,
189
192
195
197 WINDOWS = 10600,
198
200 USER = 10700,
201
203 MACRO = 10750,
204
207 HELP = 10800
208 };
209
211
214
230 MainControl(QWidget* parent = 0, const char* name = 0 , String inifile = ".BALL.preferences");
231
235 virtual ~MainControl();
236
237 // copy ctor needed for Python support only!
238 MainControl(const MainControl& main_control);
239
242 virtual void clear();
243
246 void clearData();
247
249
252
257 { return primitive_manager_;}
258
265
271
277
293 bool updateRepresentationsOf(const Composite& composite, bool rebuild = true, bool force = false);
294
299 void redrawAllRepresentations(bool rebuild_display_lists = false);
300
302
308 ShortcutRegistry& getShortcutRegistry() { return shortcut_registry_;}
309
310
312 //
316
321 { return composite_manager_;}
322
329 bool insert(Composite& composite, String name = "", bool normalize = true);
330
337 bool remove(Composite& composite, bool to_delete = true, bool update = true);
338
347 void update(Composite& composite, bool changed_hierarchy = true);
348
351
354
356 std::list<Composite*>& getMolecularControlSelection();
357
360
362 void selectCompositeRecursive(Composite* composite, bool first_call=false);
363
365 void deselectCompositeRecursive(Composite* composite, bool first_call=false);
366
376
377
379
382
384 void saveBALLViewProjectFile(const String& filename, bool binary = true);
385
387 void loadBALLViewProjectFile(const String& filename);
388
395 virtual void fetchPreferences(INIFile &inifile);
396
404 virtual void writePreferences(INIFile &inifile);
405
407 virtual void restoreWindows();
408
410 virtual void restoreWindows(const INIFile& inifile);
411
415
418 const INIFile& getINIFile() const;
419
424
433 virtual void applyPreferences();
434
435
437
440
453 static MainControl* getMainControl(const QObject* object);
454
461
468
480 virtual void onNotify(Message *message);
481
487 void sendMessage(Message& message);
488
489
491
494
507 QAction* insertMenuEntry(Position parent_id, const String& name, const QObject* receiver = 0,
508 const char* slot = 0, const String& description = "", QKeySequence accel = QKeySequence(),
509 UIOperationMode::OperationMode minimal_mode = UIOperationMode::MODE_ALL);
510
523 QAction* insertMenuEntry(Position parent_id, const QString& name, const QObject* receiver = 0,
524 const char* slot = 0, const QString& description = "", QKeySequence accel = QKeySequence(),
525 UIOperationMode::OperationMode minimal_mode = UIOperationMode::MODE_ALL);
526
528 virtual QMenu* addMenu(const QString& title, UIOperationMode::OperationMode mode = UIOperationMode::MODE_ALL);
529
531 void removeMenuEntry (Index parent_id, QAction* action);
532
540 virtual QMenu* initPopupMenu(int ID, UIOperationMode::OperationMode mode = UIOperationMode::MODE_ALL);
541
547 void insertPopupMenuSeparator(int ID, UIOperationMode::OperationMode mode = UIOperationMode::MODE_ALL);
548
550 void setMenuHint(QAction* id, const String& hint);
551
553 String getMenuHint(QAction* id) const;
554
558 void setDeleteEntryEnabled(bool state);
559
564
566 QAction* getLastHighLightedMenuEntry() { return last_highlighted_menu_entry_;}
567
569
572
577
584
587
590
593
595 bool stopedSimulation() { return stop_simulation_;}
596
603
608
622
624 void setMultithreading(bool state)
625 {multi_threading_mode_ = state;}
626
628 bool isBusy() const;
629
631 void wait();
632
635
636
638
641
649 void setStatusbarText(const String& text, bool important = false, bool beep = false);
650
652 void setStatusbarText(const QString& text, bool important = false, bool beep = false);
653
656
659 { return fragment_db_;}
660
663
666
672 { return working_dir_;}
673
675 void setWorkingDir(const String& dir);
676
680
684
688 void setLoggingFilename(const String& string);
689
692
694 bool isAboutToQuit() { return about_to_quit_;}
695
696
698
701
708 virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
709
717 virtual void openFile(const String& file) ;
718
719
722 virtual QMenu* createPopupMenu();
723
725
728
729 public Q_SLOTS:
730
746 virtual void show();
747
758 virtual void checkMenus();
759
762
765
770
783 virtual void aboutToExit();
784
790 void menuItemHighlighted(QAction* action);
791
793 virtual bool event(QEvent* e);
794
796 virtual void quit(int return_value = 0);
797
799 virtual void resize(int w, int h );
800
802 void setContentSize(int w, int h);
803
806
808 void quickSave();
809
811 void quickLoad();
812
815
818
821
823
824 protected Q_SLOTS:
825
826 /*_ This slot is called internally whenever the apply button
827 of the Preferences dialog is pressed.
828 It calls among other things the method applyPreferences().
829 */
831
832 /*_ This slot is called internally whenever the ok button
833 of the Preferences dialog is pressed.
834 It calls among other things the method applyPreferences().
835 */
836 virtual void okPreferencesClicked_();
837
838 //_ Called by timer to clear the text in the statusbar
840
841 // Connected to the delete entry
842 virtual void deleteClicked();
843
845
846 protected:
847
849
850 //_ Called after receiving an SimulationThreadFinished event
852
855
856 /*_ Remove a composite.
857 Every Representation, which was created for the Composite is deleted, by sending a
858 RepresentationMessage with type RepresentationMessage::REMOVE.\par
859 Redraws representations of the parent of the Composite, if wished.
860 \return bool <tt>true</tt> if the CompositeManager has the Composite
861 */
862 bool remove_(Composite& composite, bool update_representations_of_parent = true,
863 bool to_delete = true);
864
865 /*_ Select the composite parents of the geometric objects.
866 The GeometricObjectSelectionMessage is sent by the Scene.
867 */
869
870 void reduceSelection_(Composite* const composite);
871
872 //_ Called by constructors
873 void setup_();
874
876
879 void setBusyMode_(bool state);
880
881 //_
882 void setPreferencesEnabled_(bool state);
883
884 void init_();
885
886 virtual void closeEvent(QCloseEvent* evt);
887
890
891 //_
893
895
896 /*_ List with the selected composites
897 */
899
900 /*_ List with the selected composites of the control.
901 (Not the one with the checkboxes!)
902 */
903 std::list<Composite*> control_selection_;
904
905 /*_ Message label in the statusbar
906 \see setStatusbarText
907 */
909
913
919
923
925
926 /*_ A list containing all modular widgets.
927 This list is modified by addModularWidget and
928 removeModularWidget.
929 */
930 std::list<ModularWidget*> modular_widgets_;
931
933 QLabel* rep_label_;
934 static const char *simulation_running_xpm_[];
935 static const char *simulation_stoped_xpm_[];
937
939
943
947 QTimer timer_;
950
955 QAction* open_action_;
958
963 QByteArray last_state_;
964};
965
966# ifndef BALL_NO_INLINE_FUNCTIONS
967# include <BALL/VIEW/KERNEL/mainControl.iC>
968# endif
969
970 } // namespace VIEW
971 } // namespace BALL
972
973#endif // BALL_VIEW_KERNEL_MAINCONTROL_H
#define BALL_EMBEDDABLE(TYPE, BASE)
Definition embeddable.h:31
HashMap class based on the STL map (containing serveral convenience functions)
Definition hashMap.h:74
QAction * stop_simulation_action_
virtual void restoreWindows(const INIFile &inifile)
Restore the positions the main window and of all DockWindow's from a given inifile.
ShortcutRegistry & getShortcutRegistry()
virtual void openFile(const String &file)
virtual void dump(std::ostream &s=std::cout, Size depth=0) const
const String & getLoggingFilename() const
See above.
String getStatusbarText() const
void update(Composite &composite, bool changed_hierarchy=true)
bool remove(Composite &composite, bool to_delete=true, bool update=true)
bool insert(Representation &rep)
RepresentationManager primitive_manager_
bool update(Representation &rep)
QAction * last_highlighted_menu_entry_
void loadBALLViewProjectFile(const String &filename)
Load a BALLView project file.
void setContentSize(int w, int h)
OpenSavePreferences * open_save_preferences_
void selectComposites_(GeometricObjectSelectionMessage &message)
virtual void fetchPreferences(INIFile &inifile)
virtual void resize(int w, int h)
overloaded from QT for Python Interface
void stopSimulation()
Stop a currently running calculation.
void setStatusbarText(const String &text, bool important=false, bool beep=false)
void wait()
Wait until the MainControl is not busy anymore.
void sendMessage(Message &message)
virtual void applyPreferences()
NetworkPreferences * network_preferences_
void quickSave()
Create a BALLView project file with the name quick.bvp in the users home dir.
QAction * clear_selection_action_
QAction * getLastHighLightedMenuEntry()
Get the ID of the last highlighted menu entry.
bool stopedSimulation()
Returns true, if the simulation was told to stop, but hasnt done this so far.
Preferences * preferences_dialog_
virtual void clear()
const FragmentDB & getFragmentDB() const
Get a const reference for the fragment database.
void redrawAllRepresentations(bool rebuild_display_lists=false)
QAction * complement_selection_action_
bool compositesAreLocked() const
bool lockCompositesFor(ModularWidget *widget)
virtual void restoreWindows()
Restore the positions the main window and of all DockWindow's from the INIFile assigned to this insta...
SimulationThread * simulation_thread_
void complementSelectionHelper_(Composite &c)
virtual QMenu * initPopupMenu(int ID, UIOperationMode::OperationMode mode=UIOperationMode::MODE_ALL)
const INIFile & getINIFile() const
HashMap< Position, QMenu * > id_to_menu_
QAction * insertMenuEntry(Position parent_id, const QString &name, const QObject *receiver=0, const char *slot=0, const QString &description="", QKeySequence accel=QKeySequence(), UIOperationMode::OperationMode minimal_mode=UIOperationMode::MODE_ALL)
std::list< Composite * > & getMolecularControlSelection()
Get the selection (highlighted items) of the MolecularControl (not the selection with checkboxes)
bool remove(Representation &rep)
void saveBALLViewProjectFile(const String &filename, bool binary=true)
Save the current configuration, structures and representations to a BALLView project file (*....
System * getSelectedSystem()
If exactly one System is selected in the Control, return a pointer to this system,...
virtual void okPreferencesClicked_()
void removeModularWidget(ModularWidget *widget)
bool insert(Composite &composite, String name="", bool normalize=true)
void addModularWidget(ModularWidget *widget)
void setBusyMode_(bool state)
virtual bool event(QEvent *e)
Interface to QT events, e.g. to communicate with other threads.
void menuItemHighlighted(QAction *action)
bool remove_(Composite &composite, bool update_representations_of_parent=true, bool to_delete=true)
void insertPopupMenuSeparator(int ID, UIOperationMode::OperationMode mode=UIOperationMode::MODE_ALL)
void setMenuHint(QAction *id, const String &hint)
Set a hint for a menu entry.
HashSet< Composite * > & getSelection()
Get the HashSet with the selected (e.g. picked) Composite objects.
virtual void closeEvent(QCloseEvent *evt)
virtual void aboutToExit()
HashSet< Composite * > selection_
virtual void quit(int return_value=0)
Make the program exit.
const HashSet< Composite * > & getSelection() const
Get the HashSet with the selected (e.g. picked) Composite objects (const)
void processEvents(Size ms)
Added overloaded method from QApplication for access in Python.
bool unlockCompositesFor(ModularWidget *widget)
Lock the Composites for a given Modular Widget.
ShortcutRegistry shortcut_registry_
RepresentationManager & getRepresentationManager()
const ModelInformation & getModelInformation() const
ModelInformation * model_information_
std::list< Composite * > control_selection_
virtual void writePreferences(INIFile &inifile)
void setDeleteEntryEnabled(bool state)
MainControl(const MainControl &main_control)
virtual void deleteClicked()
virtual void onNotify(Message *message)
void reduceSelection_(Composite *const composite)
virtual QMenu * addMenu(const QString &title, UIOperationMode::OperationMode mode=UIOperationMode::MODE_ALL)
MainControlPreferences * main_control_preferences_
void setModelInformation(ModelInformation *mi)
virtual void initializePreferencesTab_()
SimulationThread * getSimulationThread()
String getMenuHint(QAction *id) const
Get the hint for a menu entry.
virtual void applyPreferencesClicked_()
void deselectCompositeRecursive(Composite *composite, bool first_call=false)
Select a Composite recursive and add all Atom and AtomContainer objects to the selection.
bool updateRepresentationsOf(const Composite &composite, bool rebuild=true, bool force=false)
void setWorkingDir(const String &dir)
Set the working directory for the next file dialog and file operation to the given directory.
ModularWidget * locking_widget_
bool setSimulationThread(SimulationThread *thread)
String getWorkingDir() const
virtual QMenu * createPopupMenu()
void selectCompositeRecursive(Composite *composite, bool first_call=false)
Select a Composite recursive and add all Atom and AtomContainer objects to the selection.
Preferences * getPreferences()
@ CHOOSE_FF
Molmec submenu for force field selection.
@ DISPLAY_STEREO
Display Stereo submenu.
@ FILE_OPEN
File menu sub menu open.
@ FILE_IMPORT
File menu sub menu import [currently unused].
@ DISPLAY_ANIMATION
Display Animation submenu.
@ FILE_OPEN_GRID
File menu sub menu open grid.
@ TOOLS_PYTHON
Python submenu in Tools.
@ FILE_EXPORT
File menu sub menu export.
@ DISPLAY_CREATE
Display Create submenu.
@ TOOLS_GRID
Grid submenu in Tools.
@ DISPLAY_VIEWPOINT
Display Viewpoint submenu.
void setMultithreading(bool state)
See above.
void removeMenuEntry(Index parent_id, QAction *action)
virtual void checkMenus()
MainControl(QWidget *parent=0, const char *name=0, String inifile=".BALL.preferences")
QAction * insertMenuEntry(Position parent_id, const String &name, const QObject *receiver=0, const char *slot=0, const String &description="", QKeySequence accel=QKeySequence(), UIOperationMode::OperationMode minimal_mode=UIOperationMode::MODE_ALL)
static MainControl * getMainControl(const QObject *object)
void setLoggingFilename(const String &string)
void setStatusbarText(const QString &text, bool important=false, bool beep=false)
CompositeManager composite_manager_
bool updateOfRepresentationRunning()
Return true if Representations are (re)calculated.
ModularWidget * getLockingWidget()
Get the ModularWidget with excluse access to the Composites.
void setPreferencesEnabled_(bool state)
CompositeManager & getCompositeManager()
void quickLoad()
Quickload quick.bvp in the users home die (see above)
std::list< ModularWidget * > modular_widgets_
#define BALL_VIEW_EXPORT