00001 #ifndef BALL_VIEW_WIDGETS_EDITABLESCENE_H
00002 #define BALL_VIEW_WIDGETS_EDITABLESCENE_H
00003
00004
00005 #ifndef BALL_KERNEL_SYSTME_H
00006 #include <BALL/KERNEL/system.h>
00007 #endif
00008
00009 #ifndef BALL_VIEW_WIDGETS_SCENE_H
00010 #include <BALL/VIEW/WIDGETS/scene.h>
00011 #endif
00012
00013 #ifndef BALL_KERNEL_MOLECULE_H
00014 #include <BALL/KERNEL/molecule.h>
00015 #endif
00016
00017 #ifndef BALL_VIEW_KERNEL_COMMON_H
00018 # include <BALL/VIEW/KERNEL/common.h>
00019 #endif
00020
00021 #ifndef BALL_MATHS_VECTOR2_H
00022 # include <BALL/MATHS/vector2.h>
00023 #endif
00024
00025 #ifndef BALL_STRUCTURE_FRAGMENTDB_H
00026 # include <BALL/STRUCTURE/fragmentDB.h>
00027 #endif
00028
00029 #include <QtGui/qcursor.h>
00030
00031 namespace BALL
00032 {
00033 namespace VIEW
00034 {
00035
00036 class EditSettings;
00037
00042 class BALL_VIEW_EXPORT EditableScene
00043 : public Scene
00044 {
00045 Q_OBJECT
00046
00047 public:
00048
00049 BALL_EMBEDDABLE(EditableScene, ModularWidget)
00050
00051
00052
00053 class BALL_VIEW_EXPORT EditOperation
00054 {
00055 public:
00056
00058 EditOperation();
00059
00061 EditOperation(Atom* atom, Bond* bond, String description= "Added Object", int operation=0);
00062
00064 EditOperation(const EditOperation& eOperation);
00065
00067 virtual ~EditOperation();
00068
00070 enum OperationType
00071 {
00072 DEFAULT,
00073 ADDED__ATOM,
00074 ADDED__BOND,
00075 CHANGED__TYPE
00076
00077
00078
00079
00080 };
00081
00082 int operationType;
00083 Atom* atom;
00084 Bond* bond;
00085 String description;
00086 };
00087
00089 enum EditMode
00090 {
00091
00092 EDIT__MODE = PICKING__MODE + 1
00093 };
00094
00096 EditableScene();
00097
00099 EditableScene(QWidget* parent_widget, const char* name = NULL, Qt::WFlags w_flags = 0);
00100
00102 EditableScene (const EditableScene& eScene, QWidget* parent_widget = NULL, const char* name = NULL, Qt::WFlags wflags = 0);
00103
00105 virtual ~EditableScene();
00106
00108 void initializeWidget(MainControl& main_control);
00109
00111 void checkMenu(MainControl& main_control);
00112
00114 void initializePreferencesTab(Preferences &preferences);
00115
00117 void finalizePreferencesTab(Preferences &preferences);
00118
00120 virtual void applyPreferences();
00121
00123 void showContextMenu(QPoint pos);
00124
00126 virtual void setMode(ModeType mode);
00127
00128 void addStructure(String name);
00129
00131 void setCursor(String c);
00132
00134 void setElementCursor();
00135
00137 public slots:
00138
00139 virtual void mousePressEvent(QMouseEvent* e);
00140 virtual void mouseMoveEvent(QMouseEvent *e);
00141 virtual void mouseReleaseEvent(QMouseEvent *e);
00142 virtual void wheelEvent(QWheelEvent* qmouse_event);
00143 void createNewMolecule();
00144 void saturateWithHydrogens();
00145 void optimizeStructure();
00146 void computeBondOrders();
00147
00148
00149 void setEditElementType(int element_number);
00150 int getEditElementType();
00151
00153 protected slots:
00154
00155 virtual void editMode_();
00156 void deleteAtom_();
00157 void changeElement_();
00158 void changeAtomElement_();
00159 void createBond_();
00160 void deleteBond_();
00161 void changeBondOrder_();
00162 void activatedOrderItem_(QAction* action);
00163 void moveAtom_();
00164 void atomProperties_();
00165 void createMolecule_();
00166 void addStructure_();
00167 void setFormalCharge_();
00168
00170 signals:
00171
00172
00173 void newEditOperation(EditableScene::EditOperation &eo);
00174
00176 protected:
00177
00178 virtual void addToolBarEntries(QToolBar* tb);
00179
00181 virtual void keyPressEvent(QKeyEvent* e);
00182 virtual void mouseDoubleClickEvent(QMouseEvent* e);
00183 virtual bool reactToKeyEvent_(QKeyEvent* e);
00184
00185 virtual void onNotify(Message *message);
00186
00192 void insert_(int x_, int y_, PDBAtom &atom_);
00193
00194 void merge_(Composite* a1, Composite* a2);
00195
00200 TVector2<float> getScreenPosition_(Vector3 vec);
00201
00202 void getClickedItems_(int x, int y);
00203
00204 void init_();
00205
00206 String getBondOrderString_(Index order);
00207
00208 std::list<AtomContainer*> getContainers_();
00209
00210 void changeBondOrder_(Index delta);
00211 void deselect_(bool update=true);
00212 void renderGrid_();
00213
00214 QAction* edit_id_, *new_molecule_action_, *optimize_action_, *add_hydrogens_action_, *element_action_;
00215 QAction* bondorders_action_, *bond_action_;
00216
00217 Atom* current_atom_;
00218 Bond* current_bond_;
00219
00220 Vector3 atom_pos_;
00221
00222
00223 static bool only_highlighted_;
00224
00225 int atomic_number_;
00226
00227 Position atom_number_;
00228
00229 int bond_order_;
00230 Position last_y_;
00231 Qt::MouseButtons last_buttons_;
00232
00233
00234 vector<EditOperation> undo_;
00235 EditSettings* edit_settings_;
00236 QPoint menu_point_;
00237 FragmentDB fragment_db_;
00238 bool fragment_db_initialized_;
00239 bool temp_move_;
00240 QToolBar* toolbar_edit_controls_;
00241 QList<QAction*> toolbar_actions_edit_controls_;
00242 };
00243
00244 }
00245 }
00246 #endif