QtMouseToolBar.qo.h

Go to the documentation of this file.
00001 //# QtMouseToolBar.qo.h: 'mouse-tool' toolbar for qtviewer display panel.
00002 //# Copyright (C) 2005
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id$
00027 
00028 
00029 #ifndef QTMOUSETOOLBAR_H
00030 #define QTMOUSETOOLBAR_H
00031 
00032 #include <casa/aips.h>
00033 #include <casa/BasicSL/String.h>
00034 #include <casa/Arrays/Vector.h>
00035 #include <display/QtViewer/QtMouseToolState.qo.h>
00036 #include <display/Utilities/Lowlevel.h>
00037 #include <map>
00038 #include <string>
00039 
00040 
00041 #include <graphics/X11/X_enter.h>
00042 #  include <QMouseEvent>
00043 #  include <QContextMenuEvent>
00044 #  include <QToolBar>
00045 #  include <QToolButton>
00046 #  include <QTimer>
00047 #include <graphics/X11/X_exit.h>
00048 
00049 namespace casa {
00050 
00051         class QtDisplayPanel;
00052 
00053 
00054 
00055         class QtMouseToolButton: public QToolButton {
00056 
00057                 Q_OBJECT        //# Allows slot/signal definition.  Must only occur in
00058                 //# implement/.../*.h files; also, makefile must include
00059                 //# name of this file in 'mocs' section.
00060 
00061         public:
00062 
00063                 QtMouseToolButton(const std::string &type, QWidget* parent = 0);
00064                 virtual ~QtMouseToolButton() {  }
00065 
00066                 virtual std::string getIconStr(Int) const;
00067 
00068         protected:
00069 
00070                 virtual void mousePressEvent(QMouseEvent*);
00071                 void mouseMoveEvent   (QMouseEvent *) {  }
00072                 void mouseReleaseEvent(QMouseEvent *) {  }
00073 
00074                 // (Prevents interference with right mouse button).
00075                 void contextMenuEvent(QContextMenuEvent *event) {
00076                         event->accept();
00077                 }
00078 
00079         signals:
00080 
00081                 void mouseToolBtnPress(String tool, Int btn);
00082                 void mouseToolBtnState(String tool, Int state);
00083 
00084         private:
00085                 std::string tool_;
00086 
00087         };
00088 
00089 
00090 
00091         class QtPointToolButton: public QtMouseToolButton {
00092 
00093                 Q_OBJECT        //# Allows slot/signal definition.  Must only occur in
00094                 //# implement/.../*.h files; also, makefile must include
00095                 //# name of this file in 'mocs' section.
00096 
00097         public:
00098 
00099                 QtPointToolButton(QWidget* parent = 0);
00100                 ~QtPointToolButton() {
00101                         delete timer;
00102                 }
00103 
00104         protected:
00105 
00106                 Casarc &rc;
00107 
00108                 virtual void mousePressEvent(QMouseEvent*);
00109                 virtual void mouseReleaseEvent(QMouseEvent*);
00110 
00111                 QTimer *timer;
00112                 QPoint popup_menu_pos;
00113 
00114         protected slots:
00115                 void show_context_menu( const QPoint & );
00116                 void popup_options_menu( );
00117 
00118         };
00119 
00120 
00121 
00122 
00123         class QtMouseToolBar: public QToolBar {
00124 
00125                 Q_OBJECT        //# Allows slot/signal definition.  Must only occur in
00126                 //# implement/.../*.h files; also, makefile must include
00127                 //# name of this file in 'mocs' section.
00128 
00129 
00130         public:
00131 
00132                 QtMouseToolBar(QtMouseToolState* msbtns, QtDisplayPanel* qdp = 0,
00133                                QWidget* parent = 0);
00134                 ~QtMouseToolBar() {  }
00135 
00136                 QtMouseToolButton *button( const std::string &name );
00137 
00138 
00139         protected slots:
00140 
00141                 // Connected to the QtMouseToolState::mouseBtnChg() signal.  Changes the
00142                 // tool button's (QAction's) state (icon, whether checked), to reflect
00143                 // the [new] mouse button assignment for a given mouse tool.
00144                 virtual void chgMouseBtn_(std::string tool, Int button);
00145 
00146                 // Overridden from QToolBar, responding to clicks from any mouse button.
00147                 // Relays that mouse button to central registry for assignment to
00148                 // desired tool.
00149                 //void mouseReleaseEvent(QMouseEvent *event);
00150 
00151 
00152         protected:
00153 
00154                 // Holds button state for all mouse-tool bars and display panels.
00155                 QtMouseToolState* msbtns_;
00156 
00157                 // Names of tools within this toolbar (in order)
00158                 Vector<String> tools_;
00159 
00160                 std::map<std::string,QtMouseToolButton*> buttons_;
00161 
00162         };
00163 
00164 
00165 } //# NAMESPACE CASA - END
00166 
00167 #endif
00168 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1