BALL  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
editableScene.h
Go to the documentation of this file.
1 #ifndef BALL_VIEW_WIDGETS_EDITABLESCENE_H
2 #define BALL_VIEW_WIDGETS_EDITABLESCENE_H
3 
4 
5 #ifndef BALL_KERNEL_SYSTME_H
6 #include <BALL/KERNEL/system.h>
7 #endif
8 
9 #ifndef BALL_VIEW_WIDGETS_SCENE_H
11 #endif
12 
13 #ifndef BALL_KERNEL_MOLECULE_H
14 #include <BALL/KERNEL/molecule.h>
15 #endif
16 
17 #ifndef BALL_VIEW_KERNEL_COMMON_H
18 # include <BALL/VIEW/KERNEL/common.h>
19 #endif
20 
21 #ifndef BALL_MATHS_VECTOR2_H
22 # include <BALL/MATHS/vector2.h>
23 #endif
24 
25 #ifndef BALL_STRUCTURE_FRAGMENTDB_H
27 #endif
28 
29 #include <QtGui/QCursor>
30 
31 namespace BALL
32 {
33  namespace VIEW
34  {
35 
36 class EditSettings;
37 
43  : public Scene
44 {
45  Q_OBJECT //macro for QT-Messages
46 
47  public:
48 
50 
51  // This class represents a single edit operation and stores its type and
52  // parameters. This can be used to implement undo functionality.
54  {
55  public:
56 
58  EditOperation();
59 
61  EditOperation(Atom* atom, Bond* bond, String description= "Added Object", int operation=0);
62 
64  EditOperation(const EditOperation& eOperation);
65 
67  virtual ~EditOperation();
68 
71  {
75  CHANGED__TYPE
76  // DELETED__ATOM
77  // DELETED__BOND
78  //CHANGED__SYSTEM
79  //MOVED__ATOM
80  };
81 
86  };
87 
89  enum EditMode
90  {
91  //
92  EDIT__MODE = PICKING__MODE + 1
93  };
94 
96  EditableScene();
97 
99  EditableScene(QWidget* parent_widget, const char* name = NULL, Qt::WFlags w_flags = 0);
100 
102  EditableScene (const EditableScene& eScene, QWidget* parent_widget = NULL, const char* name = NULL, Qt::WFlags wflags = 0);
103 
105  virtual ~EditableScene();
106 
108  void initializeWidget(MainControl& main_control);
109 
111  void checkMenu(MainControl& main_control);
112 
114  void initializePreferencesTab(Preferences &preferences);
115 
117  void finalizePreferencesTab(Preferences &preferences);
118 
120  virtual void applyPreferences();
121 
123  void showContextMenu(QPoint pos);
124 
126  virtual void setMode(ModeType mode);
127 
128  void addStructure(String name);
129 
131  void setCursor(String c);
132 
134  void setElementCursor();
135 
137  public slots:
138 
139  virtual void mousePressEvent(QMouseEvent* e);
140  virtual void mouseMoveEvent(QMouseEvent *e);
141  virtual void mouseReleaseEvent(QMouseEvent *e);
142  virtual void wheelEvent(QWheelEvent* qmouse_event);
143  void createNewMolecule();
144  void saturateWithHydrogens();
145  void optimizeStructure();
146  void computeBondOrders();
147 
148  // slots for communication with PTEDialog
149  void setEditElementType(int element_number);
150  int getEditElementType();
151 
153  protected slots:
154 
155  virtual void editMode_();
156  void deleteAtom_();
157  void changeElement_();
158  void changeAtomElement_();
159  void createBond_();
160  void deleteBond_();
161  void changeBondOrder_();
162  void activatedOrderItem_(QAction* action);
163  void moveAtom_();
164  void atomProperties_();
165  void createMolecule_();
166  void addStructure_();
167  void setFormalCharge_();
168 
170  signals:
171 
172  // signal for communication with EditOperationDialog
173  void newEditOperation(EditableScene::EditOperation &eo);
174 
176  protected:
177 
178  virtual void addToolBarEntries(QToolBar* tb);
179 
181  virtual void keyPressEvent(QKeyEvent* e);
182  virtual void mouseDoubleClickEvent(QMouseEvent* e);
183  virtual bool reactToKeyEvent_(QKeyEvent* e);
184 
185  virtual void onNotify(Message *message);
186 
192  void insert_(int x_, int y_, PDBAtom &atom_);
193 
194  void merge_(Composite* a1, Composite* a2);
195 
200  TVector2<float> getScreenPosition_(Vector3 vec);
201 
202  void getClickedItems_(int x, int y);
203 
204  void init_();
205 
206  String getBondOrderString_(Index order);
207 
208  std::list<AtomContainer*> getContainers_();
209 
210  void changeBondOrder_(Index delta);
211  void deselect_(bool update=true);
212  void renderGrid_();
213 
214  QAction* edit_id_, *new_molecule_action_, *optimize_action_, *add_hydrogens_action_, *element_action_;
215  QAction* bondorders_action_, *bond_action_;
216 
219 
221 
222  // pick atoms/bonds only in highlighted AtomContainer?
223  static bool only_highlighted_;
224  // element for new atoms
226  // name for newly created atoms
228  // order for new bonds
231  Qt::MouseButtons last_buttons_;
232 
233  //undo stack
234  vector<EditOperation> undo_;
236  QPoint menu_point_;
242 };
243 
244  }//end of namespace
245 } // end of namespace
246 #endif