00001
00002
00003
00004
00005 #ifndef BALL_VIEW_WIDGETS_MOLECULARCONTROL_H
00006 #define BALL_VIEW_WIDGETS_MOLECULARCONTROL_H
00007
00008 #ifndef BALL_VIEW_WIDGETS_GENERICCONTROL_H
00009 # include <BALL/VIEW/WIDGETS/genericControl.h>
00010 #endif
00011
00012 #ifndef BALL_CONCEPT_MOLECULARINFORMATION_H
00013 # include <BALL/CONCEPT/molecularInformation.h>
00014 #endif
00015
00016 #ifndef BALL_VIEW_KERNEL_COMMON_H
00017 # include <BALL/VIEW/KERNEL/common.h>
00018 #endif
00019
00020 #ifndef BALL_MATHS_MATRIX44_H
00021 #include <BALL/MATHS/matrix44.h>
00022 #endif
00023
00024 #include <QtCore/QPoint>
00025 #include <QtGui/QMenu>
00026 #include <QtGui/QTreeView>
00027 #include <QtGui/QComboBox>
00028
00029
00030 namespace BALL
00031 {
00032 namespace VIEW
00033 {
00034
00035 class BondProperties;
00036
00045 class BALL_VIEW_EXPORT MolecularControl
00046 : public GenericControl
00047 {
00048
00049 class MyTreeWidgetItem
00050 : public QTreeWidgetItem
00051 {
00052 public:
00053
00054 MyTreeWidgetItem(QTreeWidget* parent, QStringList& sl, Composite* composite);
00055
00056 MyTreeWidgetItem(QTreeWidgetItem* parent, QStringList& sl, Composite* composite);
00057
00058 void init_();
00059
00060 Composite* composite;
00061 };
00062
00064 enum MolecularMenuEntries
00065 {
00067 CREATE_REPRESENTATION,
00068 OBJECT__MOVE,
00069 SELECT,
00070 DESELECT,
00071 EDIT_MENU,
00072 CUT,
00073 COPY,
00074 DELETE_ENTRY,
00075 PASTE,
00076
00077
00079 CAMERA__CENTER,
00081 COMPOSITE__PROPERTIES,
00083 COUNT__ITEMS,
00085 BOND__PROPERTIES,
00087 COLLAPSE_ALL,
00089 EXPAND_ALL
00090 };
00091
00092 Q_OBJECT
00093
00094 public:
00095
00096 BALL_EMBEDDABLE(MolecularControl,GenericControl)
00097
00098 friend class BondProperties;
00099
00103
00108 MolecularControl(QWidget* parent = 0, const char* name = 0);
00109
00112 virtual ~MolecularControl();
00113
00115
00118
00125 virtual void checkMenu(VIEW::MainControl& main_control);
00126
00133 void addComposite(Composite& composite, String given_name = "");
00134
00137 Size removeComposite(Composite& composite);
00138
00141 const std::list<Composite*>& getSelection() const;
00142
00148 virtual void onNotify(Message *message);
00149
00159 virtual void updateContextMenu(Composite& composite);
00160
00172 virtual void initializeWidget(MainControl& main_control);
00173
00177 Size applySelector(const String& expression);
00178
00180 void writePreferences(INIFile& inifile);
00181
00183 void fetchPreferences(INIFile& inifile);
00184
00186 void showDistance(Atom* a1, Atom* a2);
00187
00189 void showAngle(Atom* a1, Atom* a2, Atom* a3, Atom* a4 = 0);
00190
00191 public slots:
00192
00194
00197
00199 void createRepresentation();
00200
00202 void compositeProperties();
00203
00205 void bondProperties();
00206
00209 void checkResidue();
00210
00213 void buildBonds();
00214
00217 void centerCamera();
00218
00220 void countItems();
00221
00223 void showFilename();
00224
00228 virtual void updateSelection();
00229
00231 void highlightSelection();
00232
00234 void highlight(const std::list<Composite*>& composite);
00235
00245 void cut();
00246
00251 void copy();
00252
00257 void paste();
00258
00261 void clearClipboard();
00262
00265 void select();
00266
00269 void deselect();
00270
00272 void moveItems();
00273
00275 void collapseAll();
00276
00278 void expandAll();
00279
00283 Size applySelector();
00284
00286 void showSelectorHelp();
00287
00289 virtual void deleteCurrentItems();
00290
00292 virtual void clearSelector();
00293
00294 void switchShowSecondaryStructure();
00295
00297 void showAtomOverview();
00298
00300 void showAtomOverviewForSelection();
00301
00303 void showDistance();
00304
00306 void showAngle();
00307
00309
00312 protected slots:
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322 void showGuestContextMenu(const QPoint& pos);
00323
00324
00325 void activatedItem_(QAction* action);
00326
00327
00328 void createRepresentation_();
00329
00330
00331 void onItemClicked(QTreeWidgetItem* item, int);
00332
00333 protected:
00334
00336 void buildContextMenu_();
00337
00344 void setSelection_(bool open, bool force = false);
00345
00353 virtual MolecularInformation& getInformationVisitor_();
00354
00361 virtual void recurseGeneration_(QTreeWidgetItem* item, Composite& composite);
00362
00377 virtual bool reactToMessages_(Message* message);
00378
00392 QTreeWidgetItem* generateListViewItem_(QTreeWidgetItem* parent,
00393 Composite& composite, QString* default_name = 0);
00394
00395
00396 bool pasteAllowedFor_(Composite& composite);
00397
00398
00399 inline void removeRecursive_(QTreeWidgetItem* item);
00400
00401
00402 MolecularControl(const MolecularControl& mc);
00403
00404
00405 std::list<QTreeWidgetItem*> getAllItems_();
00406
00407 void enableUpdates_(bool state);
00408 void newSelection_(std::list<Composite*>& sel, bool selected);
00409
00410 bool allowPaste_();
00411
00413
00416
00417
00418 QAction* cut_id_, *copy_id_, *paste_id_, *delete_id_, *clipboard_id_, *select_id_, *deselect_id_,
00419 *show_ss_id_;
00420
00422
00423 std::list<Composite*> selected_;
00424 std::list<Composite*> copy_list_;
00425
00426 MolecularInformation information_;
00427
00428 QComboBox* selector_edit_;
00429 QComboBox* smarts_edit_;
00430
00431
00432 QMenu context_menu_,
00433 model_menu_,
00434 edit_menu_,
00435 color_menu_[MODEL_LABEL - MODEL_LINES];
00436
00437 Composite* context_composite_;
00438
00439 QTreeWidgetItem* context_item_;
00440
00441 ModelType selected_model_;
00442 ColoringMethod selected_coloring_method_;
00443 std::map<Composite*, MyTreeWidgetItem*> composite_to_item_;
00444
00445
00446 bool was_delete_;
00447
00448 Size nr_items_removed_;
00449
00450 bool show_ss_;
00451 QAction* center_camera_action_, *composite_properties_action_, *bond_propertes_action_,
00452 *select_action_, *deselect_action_, *count_items_action_, *atom_overview_, *atom_overview_selection_,
00453 *angle_action_, *distance_action_, *paste_action_;
00454
00455 bool ignore_messages_;
00456 };
00457
00458 }}
00459
00460 #endif // BALL_VIEW_WIDGETS_MOLECULARCONTROL_H