casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QtMouseToolBar.qo.h
Go to the documentation of this file.
1 //# QtMouseToolBar.qo.h: 'mouse-tool' toolbar for qtviewer display panel.
2 //# Copyright (C) 2005
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 
29 #ifndef QTMOUSETOOLBAR_H
30 #define QTMOUSETOOLBAR_H
31 
32 #include <casa/aips.h>
33 #include <casa/BasicSL/String.h>
34 #include <casa/Arrays/Vector.h>
37 #include <map>
38 #include <string>
39 
40 
41 #include <graphics/X11/X_enter.h>
42 # include <QMouseEvent>
43 # include <QContextMenuEvent>
44 # include <QToolBar>
45 # include <QToolButton>
46 # include <QTimer>
47 #include <graphics/X11/X_exit.h>
48 
49 namespace casa {
50 
51  class QtDisplayPanel;
52 
53 
54 
55  class QtMouseToolButton: public QToolButton {
56 
57  Q_OBJECT //# Allows slot/signal definition. Must only occur in
58  //# implement/.../*.h files; also, makefile must include
59  //# name of this file in 'mocs' section.
60 
61  public:
62 
63  QtMouseToolButton(const std::string &type, QWidget* parent = 0);
64  virtual ~QtMouseToolButton() { }
65 
66  virtual std::string getIconStr(int) const;
67 
68  protected:
69 
70  virtual void mousePressEvent(QMouseEvent*);
71  void mouseMoveEvent (QMouseEvent *) { }
72  void mouseReleaseEvent(QMouseEvent *) { }
73 
74  // (Prevents interference with right mouse button).
75  void contextMenuEvent(QContextMenuEvent *event) {
76  event->accept();
77  }
78 
79  signals:
80 
81  void mouseToolBtnPress(casacore::String tool, int btn);
82  void mouseToolBtnState(casacore::String tool, int state);
83 
84  private:
85  std::string tool_;
86 
87  };
88 
89 
90 
92 
93  Q_OBJECT //# Allows slot/signal definition. Must only occur in
94  //# implement/.../*.h files; also, makefile must include
95  //# name of this file in 'mocs' section.
96 
97  public:
98 
99  QtPointToolButton(QWidget* parent = 0);
101  delete timer;
102  }
103 
104  protected:
105 
107 
108  virtual void mousePressEvent(QMouseEvent*);
109  virtual void mouseReleaseEvent(QMouseEvent*);
110 
111  QTimer *timer;
113 
114  protected slots:
115  void show_context_menu( const QPoint & );
116  void popup_options_menu( );
117 
118  };
119 
120 
121 
122 
123  class QtMouseToolBar: public QToolBar {
124 
125  Q_OBJECT //# Allows slot/signal definition. Must only occur in
126  //# implement/.../*.h files; also, makefile must include
127  //# name of this file in 'mocs' section.
128 
129 
130  public:
131 
133  QWidget* parent = 0);
135 
136  QtMouseToolButton *button( const std::string &name );
137 
138 
139  protected slots:
140 
141  // Connected to the QtMouseToolState::mouseBtnChg() signal. Changes the
142  // tool button's (QAction's) state (icon, whether checked), to reflect
143  // the [new] mouse button assignment for a given mouse tool.
144  virtual void chgMouseBtn_(std::string tool, int button);
145 
146  // Overridden from QToolBar, responding to clicks from any mouse button.
147  // Relays that mouse button to central registry for assignment to
148  // desired tool.
149  //void mouseReleaseEvent(QMouseEvent *event);
150 
151 
152  protected:
153 
154  // Holds button state for all mouse-tool bars and display panels.
156 
157  // Names of tools within this toolbar (in order)
159 
160  std::map<std::string,QtMouseToolButton*> buttons_;
161 
162  };
163 
164 
165 } //# NAMESPACE CASA - END
166 
167 #endif
168 
virtual Type type()
Return the type enum.
virtual std::string getIconStr(int) const
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the if a human readable name(i.e."black").In many places throughout the plotter
std::map< std::string, QtMouseToolButton * > buttons_
void mouseToolBtnPress(casacore::String tool, int btn)
QtPointToolButton(QWidget *parent=0)
QtMouseToolState * msbtns_
Overridden from QToolBar, responding to clicks from any mouse button.
void mouseMoveEvent(QMouseEvent *)
QtMouseToolBar(QtMouseToolState *msbtns, QtDisplayPanel *qdp=0, QWidget *parent=0)
void contextMenuEvent(QContextMenuEvent *event)
(Prevents interference with right mouse button).
QtMouseToolButton * button(const std::string &name)
virtual void chgMouseBtn_(std::string tool, int button)
Connected to the QtMouseToolState::mouseBtnChg() signal.
void mouseToolBtnState(casacore::String tool, int state)
virtual void mousePressEvent(QMouseEvent *)
void show_context_menu(const QPoint &)
String: the storage and methods of handling collections of characters.
Definition: String.h:223
QtMouseToolButton(const std::string &type, QWidget *parent=0)
casacore::Vector< casacore::String > tools_
Names of tools within this toolbar (in order)
virtual void mouseReleaseEvent(QMouseEvent *)
void mouseReleaseEvent(QMouseEvent *)
virtual void mousePressEvent(QMouseEvent *)