molecularControl.h

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // $Id: molecularControl.h,v 1.51.12.2 2007/03/26 07:51:48 amoll Exp $
00005 //
00006 
00007 #ifndef BALL_VIEW_WIDGETS_MOLECULARCONTROL_H
00008 #define BALL_VIEW_WIDGETS_MOLECULARCONTROL_H
00009 
00010 #ifndef BALL_VIEW_WIDGETS_GENERICCONTROL_H
00011 # include <BALL/VIEW/WIDGETS/genericControl.h>
00012 #endif
00013 
00014 #ifndef BALL_CONCEPT_MOLECULARINFORMATION_H
00015 # include <BALL/CONCEPT/molecularInformation.h>
00016 #endif
00017 
00018 #ifndef BALL_VIEW_KERNEL_COMMON_H
00019 # include <BALL/VIEW/KERNEL/common.h>
00020 #endif
00021 
00022 #ifndef BALL_MATHS_MATRIX44_H
00023  #include <BALL/MATHS/matrix44.h>
00024 #endif
00025 
00026 #include <QtCore/qpoint.h>
00027 #include <QtGui/qmenu.h>
00028 #include <QtGui/qtreeview.h>
00029 #include <QtGui/qcombobox.h>
00030 
00031 
00032 namespace BALL
00033 {
00034   namespace VIEW
00035   {
00036 
00037 class BondProperties;
00038 
00047 class BALL_VIEW_EXPORT MolecularControl
00048   : public GenericControl
00049 {     
00050   // for internal usage only:
00051   class MyTreeWidgetItem
00052     : public QTreeWidgetItem
00053   {
00054     public:
00055 
00056       MyTreeWidgetItem(QTreeWidget* parent, QStringList& sl, Composite* composite);
00057 
00058       MyTreeWidgetItem(QTreeWidgetItem* parent, QStringList& sl, Composite* composite);
00059 
00060       void init_();
00061 
00062       Composite* composite;
00063   };
00064 
00066   enum MolecularMenuEntries
00067   {
00069     CREATE_REPRESENTATION,
00070     OBJECT__MOVE,
00071     SELECT,
00072     DESELECT,
00073     EDIT_MENU,
00074     CUT,
00075     COPY,
00076     DELETE_ENTRY,
00077     PASTE,
00078 
00079 
00081     CAMERA__CENTER,
00083     COMPOSITE__PROPERTIES,
00085     COUNT__ITEMS,
00087     BOND__PROPERTIES,
00089     COLLAPSE_ALL,
00091     EXPAND_ALL
00092   };
00093 
00094   Q_OBJECT
00095 
00096   public:
00097   
00098   BALL_EMBEDDABLE(MolecularControl,GenericControl)
00099   
00100   friend class BondProperties;
00101 
00105 
00110   MolecularControl(QWidget* parent = 0, const char* name = 0);
00111   
00114   virtual ~MolecularControl();
00115   
00117 
00120   
00127   virtual void checkMenu(VIEW::MainControl& main_control);
00128 
00135   void addComposite(Composite& composite, String given_name = "");
00136 
00139   Size removeComposite(Composite& composite);
00140 
00143   const List<Composite*>& getSelection() const;
00144   
00150   virtual void onNotify(Message *message);
00151 
00161   virtual void updateContextMenu(Composite& composite);
00162 
00174   virtual void initializeWidget(MainControl& main_control);
00175 
00179   Size applySelector(const String& expression);
00180 
00182   void writePreferences(INIFile& inifile);
00183 
00185   void fetchPreferences(INIFile& inifile);
00186 
00188   void showDistance(Atom* a1, Atom* a2);
00189   
00191   void showAngle(Atom* a1, Atom* a2, Atom* a3, Atom* a4 = 0);
00192 
00193   public slots:
00194     
00196 
00199   
00201   void createRepresentation();
00202 
00204   void compositeProperties();
00205 
00207   void bondProperties();
00208 
00211   void checkResidue();
00212 
00215   void buildBonds();
00216   
00219   void centerCamera();
00220 
00222   void countItems();
00223 
00225   void showFilename();
00226 
00230   virtual void updateSelection();
00231 
00233   void highlightSelection();
00234 
00236   void highlight(const List<Composite*>& composite);
00237 
00247   void cut();
00248 
00253   void copy();
00254 
00259   void paste();
00260 
00263   void clearClipboard();
00264 
00267   void select();
00268   
00271   void deselect();
00272 
00274   void moveItems();
00275   
00277   void collapseAll();
00278 
00280   void expandAll();
00281 
00285   Size applySelector();
00286 
00288   void showSelectorHelp();
00289 
00291   virtual void deleteCurrentItems();
00292 
00294   virtual void clearSelector();
00295 
00296   void switchShowSecondaryStructure();
00297 
00299   void showAtomOverview();
00300 
00302   void showAtomOverviewForSelection();
00303 
00305   void showDistance();
00306   
00308   void showAngle();
00309   
00311 
00314   protected slots:
00315 
00316   /*_ Controlling method for context menus.
00317       Clear the previously created context menu.
00318       Calls buildContextMenu for the Composite object belonging
00319       to the <tt>item</tt> and executes the context menu if menu entries are available.
00320       \param  point the position to which the context menu should be drawn
00321       \param  column not used at the moment
00322       \see    buildContextMenu
00323   */
00324   void showGuestContextMenu(const QPoint& pos);
00325   
00326   //_ called when a model is selected in the context menu
00327   void activatedItem_(QAction* action);
00328 
00329   //_
00330   void createRepresentation_();
00331 
00332   //
00333   void onItemClicked(QTreeWidgetItem* item, int);
00334 
00335   protected:
00336 
00338   void buildContextMenu_();
00339 
00346   void setSelection_(bool open, bool force = false);
00347 
00355   virtual MolecularInformation& getInformationVisitor_();
00356   
00363   virtual void recurseGeneration_(QTreeWidgetItem* item, Composite& composite);
00364 
00379   virtual bool reactToMessages_(Message* message);
00380 
00394   QTreeWidgetItem* generateListViewItem_(QTreeWidgetItem* parent, 
00395                                           Composite& composite, QString* default_name = 0);
00396   
00397   //_ Test, if its allowed to paste the copy liste into the current selected context item.
00398   bool pasteAllowedFor_(Composite& composite);
00399 
00400   //
00401   inline void removeRecursive_(QTreeWidgetItem* item);
00402 
00403   // only for Python Interface
00404   MolecularControl(const MolecularControl& mc);
00405 
00406   //
00407   List<QTreeWidgetItem*> getAllItems_();
00408 
00409   void enableUpdates_(bool state);
00410   void newSelection_(List<Composite*>& sel, bool selected);
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   List<Composite*>        selected_;
00424   List<Composite*>        copy_list_;
00425   
00426   MolecularInformation    information_;
00427   
00428   QComboBox*              selector_edit_;
00429   QComboBox*              smarts_edit_;
00430 
00431   // the context menus
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   // let cut know to delete the entries, set by deleteCurrentItems()
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_;
00454 
00455   bool ignore_messages_;
00456 };
00457   
00458 }} // namespaces
00459 
00460 #endif // BALL_VIEW_WIDGETS_MOLECULARCONTROL_H