BALL  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
molecularControl.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_WIDGETS_MOLECULARCONTROL_H
6 #define BALL_VIEW_WIDGETS_MOLECULARCONTROL_H
7 
8 #ifndef BALL_VIEW_WIDGETS_GENERICCONTROL_H
10 #endif
11 
12 #ifndef BALL_CONCEPT_MOLECULARINFORMATION_H
14 #endif
15 
16 #ifndef BALL_VIEW_KERNEL_COMMON_H
17 # include <BALL/VIEW/KERNEL/common.h>
18 #endif
19 
20 #ifndef BALL_MATHS_MATRIX44_H
21  #include <BALL/MATHS/matrix44.h>
22 #endif
23 
24 #include <QtCore/QPoint>
25 #include <QtGui/QMenu>
26 #include <QtGui/QTreeView>
27 #include <QtGui/QComboBox>
28 
29 
30 namespace BALL
31 {
32  namespace VIEW
33  {
34 
35 class BondProperties;
36 
46  : public GenericControl
47 {
48  // for internal usage only:
50  : public QTreeWidgetItem
51  {
52  public:
53 
54  MyTreeWidgetItem(QTreeWidget* parent, QStringList& sl, Composite* composite);
55 
56  MyTreeWidgetItem(QTreeWidgetItem* parent, QStringList& sl, Composite* composite);
57 
58  void init_();
59 
61  };
62 
65  {
72  CUT,
76 
77 
89  EXPAND_ALL
90  };
91 
92  Q_OBJECT
93 
94  public:
95 
97 
98  friend class BondProperties;
99 
103 
108  MolecularControl(QWidget* parent = 0, const char* name = 0);
109 
112  virtual ~MolecularControl();
113 
115 
118 
125  virtual void checkMenu(VIEW::MainControl& main_control);
126 
133  void addComposite(Composite& composite, String given_name = "");
134 
137  Size removeComposite(Composite& composite);
138 
141  const std::list<Composite*>& getSelection() const;
142 
148  virtual void onNotify(Message *message);
149 
159  virtual void updateContextMenu(Composite& composite);
160 
172  virtual void initializeWidget(MainControl& main_control);
173 
177  Size applySelector(const String& expression);
178 
180  void writePreferences(INIFile& inifile);
181 
183  void fetchPreferences(INIFile& inifile);
184 
186  void showDistance(Atom* a1, Atom* a2);
187 
189  void showAngle(Atom* a1, Atom* a2, Atom* a3, Atom* a4 = 0);
190 
191  public slots:
192 
194 
197 
199  void createRepresentation();
200 
202  void compositeProperties();
203 
205  void bondProperties();
206 
209  void checkResidue();
210 
213  void buildBonds();
214 
217  void centerCamera();
218 
220  void countItems();
221 
223  void showFilename();
224 
228  virtual void updateSelection();
229 
231  void highlightSelection();
232 
234  void highlight(const std::list<Composite*>& composite);
235 
245  void cut();
246 
251  void copy();
252 
257  void paste();
258 
261  void clearClipboard();
262 
265  void select();
266 
269  void deselect();
270 
272  void moveItems();
273 
275  void collapseAll();
276 
278  void expandAll();
279 
283  Size applySelector();
284 
286  void showSelectorHelp();
287 
289  virtual void deleteCurrentItems();
290 
292  virtual void clearSelector();
293 
294  void switchShowSecondaryStructure();
295 
297  void showAtomOverview();
298 
300  void showAtomOverviewForSelection();
301 
303  void showDistance();
304 
306  void showAngle();
307 
309 
312  protected slots:
313 
314  /*_ Controlling method for context menus.
315  Clear the previously created context menu.
316  Calls buildContextMenu for the Composite object belonging
317  to the <tt>item</tt> and executes the context menu if menu entries are available.
318  \param point the position to which the context menu should be drawn
319  \param column not used at the moment
320  \see buildContextMenu
321  */
322  void showGuestContextMenu(const QPoint& pos);
323 
324  //_ called when a model is selected in the context menu
325  void activatedItem_(QAction* action);
326 
327  //_
328  void createRepresentation_();
329 
330  //
331  void onItemClicked(QTreeWidgetItem* item, int);
332 
333  protected:
334 
336  void buildContextMenu_();
337 
344  void setSelection_(bool open, bool force = false);
345 
353  virtual MolecularInformation& getInformationVisitor_();
354 
361  virtual void recurseGeneration_(QTreeWidgetItem* item, Composite& composite);
362 
377  virtual bool reactToMessages_(Message* message);
378 
392  QTreeWidgetItem* generateListViewItem_(QTreeWidgetItem* parent,
393  Composite& composite, QString* default_name = 0);
394 
395  //_ Test, if its allowed to paste the copy liste into the current selected context item.
396  bool pasteAllowedFor_(Composite& composite);
397 
398  //
399  inline void removeRecursive_(QTreeWidgetItem* item);
400 
401  // only for Python Interface
402  MolecularControl(const MolecularControl& mc);
403 
404  //
405  std::list<QTreeWidgetItem*> getAllItems_();
406 
407  void enableUpdates_(bool state);
408  void newSelection_(std::list<Composite*>& sel, bool selected);
409 
410  bool allowPaste_();
411 
413 
416 
417  //_
418  QAction* cut_id_, *copy_id_, *paste_id_, *delete_id_, *clipboard_id_, *select_id_, *deselect_id_,
419  *show_ss_id_;
420 
422 
423  std::list<Composite*> selected_;
424  std::list<Composite*> copy_list_;
425 
426  MolecularInformation information_;
427 
428  QComboBox* selector_edit_;
429  QComboBox* smarts_edit_;
430 
431  // the context menus
432  QMenu context_menu_,
433  model_menu_,
434  edit_menu_,
435  color_menu_[MODEL_LABEL - MODEL_LINES];
436 
437  Composite* context_composite_;
438 
439  QTreeWidgetItem* context_item_;
440 
441  ModelType selected_model_;
442  ColoringMethod selected_coloring_method_;
443  std::map<Composite*, MyTreeWidgetItem*> composite_to_item_;
444 
445  // let cut know to delete the entries, set by deleteCurrentItems()
446  bool was_delete_;
447 
448  Size nr_items_removed_;
449 
450  bool show_ss_;
451  QAction* center_camera_action_, *composite_properties_action_, *bond_propertes_action_,
452  *select_action_, *deselect_action_, *count_items_action_, *atom_overview_, *atom_overview_selection_,
453  *angle_action_, *distance_action_, *paste_action_;
454 
455  bool ignore_messages_;
456 };
457 
458 }} // namespaces
459 
460 #endif // BALL_VIEW_WIDGETS_MOLECULARCONTROL_H