casa
5.7.0-16
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
casa
code
display
QtViewer
QtMouseToolState.qo.h
Go to the documentation of this file.
1
//# QtMouseToolState.qo.h: constants and [global] mouse-button state
2
//# for the qtviewer 'mouse-tools' used by its display panel[s].
3
//# Copyright (C) 2005
4
//# Associated Universities, Inc. Washington DC, USA.
5
//#
6
//# This library is free software; you can redistribute it and/or modify it
7
//# under the terms of the GNU Library General Public License as published by
8
//# the Free Software Foundation; either version 2 of the License, or (at your
9
//# option) any later version.
10
//#
11
//# This library is distributed in the hope that it will be useful, but WITHOUT
12
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14
//# License for more details.
15
//#
16
//# You should have received a copy of the GNU Library General Public License
17
//# along with this library; if not, write to the Free Software Foundation,
18
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
19
//#
20
//# Correspondence concerning AIPS++ should be addressed as follows:
21
//# Internet email: aips2-request@nrao.edu.
22
//# Postal address: AIPS++ Project Office
23
//# National Radio Astronomy Observatory
24
//# 520 Edgemont Road
25
//# Charlottesville, VA 22903-2475 USA
26
//#
27
//# $Id$
28
29
30
#ifndef QTMOUSETOOLSTATE_QO_H_
31
#define QTMOUSETOOLSTATE_QO_H_
32
33
#include <
casa/aips.h
>
34
#include <
casa/BasicSL/String.h
>
35
#include <
display/Display/MouseToolState.h
>
36
#include <
display/Utilities/Lowlevel.h
>
37
38
#include <
graphics/X11/X_enter.h
>
39
# include <QObject>
40
#include <
graphics/X11/X_exit.h
>
41
#include <map>
42
43
namespace
casa {
//# NAMESPACE CASA - BEGIN
44
45
46
class
QtViewerBase;
47
48
49
// <synopsis>
50
// QtMouseToolState records the currently-active mouse button (if any)
51
// of each type of Qt mouse tool. There may be a QtMouseToolBar for each
52
// QtDisplayPanel (and in principle each may display a different subset
53
// of all the possible tools, though this is not implemented yet (7/06)).
54
// However, each mouse button (Left, Middle, Right) may be assigned to
55
// at most one type of tool type, and that assignment should be the same
56
// on each QtMouseToolBar.
57
//
58
// To accomplish that, this class signals current button assignments
59
// whenever such assignments change. All display panels and/or their mouse
60
// tool bars may connect to this signal to keep Toolbar button icons and the
61
// actual core library mouse tools (such as MWCZoomer) in sync.
62
//
63
// This button state is therefore also essentially global or static, but this
64
// class cannot be purely static because it must be a real QObject
65
// to send out such a signal. Instead, there should be only one
66
// QtMouseToolState object (managed by the [one] QtViewer[Base] object),
67
// and all listeners should use that object for setting and responding to
68
// current mouse tool button state.
69
// </synopsis>
70
71
class
QtMouseToolState
:
public
QObject {
72
73
74
Q_OBJECT
//# Allows slot/signal definition. Must only occur in
75
//# implement/.../*.h files; also, makefile must include
76
//# name of this file in 'mocs' section.
77
78
79
public
:
80
81
// Returns button currently assigned to a tool (0 = no button assigned).
82
int
buttonOf
(
casacore::String
tool) {
83
return
mousebtns_
[
QtMouseToolNames::toolIndex
(tool)];
84
}
85
86
// Returns name of tool currently assigned to a mouse button (1, 2, or 3).
87
// (Returns NONE if passed mousebtn is 0 or no tool is assigned to it).
88
casacore::String
toolOnButton
(
int
mousebtn) {
89
return
QtMouseToolNames::toolName
(
toolIndexOnButton_
(mousebtn));
90
}
91
92
int
getButtonState
(
const
std::string &tool)
const
;
93
94
95
public
slots:
96
97
// Request reassignment of a given mouse button to a tool.
98
// NB: _This_ is where guis, etc. should request a button change, so that
99
// all stay on the same page (not directly to tool or displaypanel, e.g.).
100
void
chgMouseBtn
(
casacore::String
tool,
int
mousebtn);
101
void
mouseBtnStateChg
(
casacore::String
tool,
int
state);
102
103
// Request signalling of the current mouse button setting for every
104
// type of tool. Call this if you want to assure that everyone's
105
// up-to-date on mouse button settings.
106
void
emitBtns
();
107
108
109
signals:
110
111
// Notification of a tool's [new] mouse button.
112
void
mouseBtnChg
(std::string tool,
int
mousebtn);
113
114
115
protected
:
116
casacore::Casarc
&
rc
;
117
118
// Only QtviewerBase is intended to create/destroy
119
// a [single] instance of this class.
120
QtMouseToolState
();
121
~QtMouseToolState
() { }
122
friend
class
QtViewerBase
;
123
124
// Returns index of tool currently assigned to a mouse button (1, 2, or 3).
125
// (Returns nTools if passed mousebtn is 0 or no tool is assigned to it).
126
int
toolIndexOnButton_
(
int
mousebtn);
127
128
129
// The button currently assigned to the various types of mouse tool.
130
//
131
// mousebtns_ value Corresp. internal library value
132
// ---------------- -------------------------------
133
// 0: <no button> Display::K_None
134
// 1: LeftButton Display::K_Pointer_Button1
135
// 2: MidButton Display::K_Pointer_Button2
136
// 3: RightButton Display::K_Pointer_Button3
137
static
int
mousebtns_
[
QtMouseToolNames::nTools
+1];
138
//# Initial values; correspond to QtMouseToolNames::tools[], above.
139
//# mousebtns_[nTools] is an entry for an invalid tool.
140
//# At most one of the above will be 1,2,3; the rest will be 0.
141
142
private
:
143
std::map<std::string,int>
tool_state
;
144
void
initButtonState
( std::string,
int
);
145
void
initToolState
( );
146
147
};
148
149
}
//# NAMESPACE CASA - END
150
151
#endif
casacore::Casarc
Definition:
Casarc.h:40
casa::QtMouseToolState::mousebtns_
static int mousebtns_[QtMouseToolNames::nTools+1]
The button currently assigned to the various types of mouse tool.
Definition:
QtMouseToolState.qo.h:137
aips.h
X_enter.h
X_exit.h
Lowlevel.h
casa::QtMouseToolState::QtMouseToolState
QtMouseToolState()
Only QtviewerBase is intended to create/destroy a [single] instance of this class.
casa::QtMouseToolState::chgMouseBtn
void chgMouseBtn(casacore::String tool, int mousebtn)
Request reassignment of a given mouse button to a tool.
casa::QtViewerBase
Definition:
QtViewerBase.qo.h:65
casa::QtMouseToolNames::toolName
std::string toolName(int toolindex)
Definition:
MouseToolState.h:59
casa::QtMouseToolState::initButtonState
void initButtonState(std::string, int)
casa::QtMouseToolState::initToolState
void initToolState()
MouseToolState.h
casa::QtMouseToolNames::nTools
Definition:
MouseToolState.h:43
casa::QtMouseToolState::~QtMouseToolState
~QtMouseToolState()
Definition:
QtMouseToolState.qo.h:121
casa::QtMouseToolState::emitBtns
void emitBtns()
Request signalling of the current mouse button setting for every type of tool.
casa::QtMouseToolState::mouseBtnChg
void mouseBtnChg(std::string tool, int mousebtn)
Notification of a tool's [new] mouse button.
casa::QtMouseToolNames::toolIndex
int toolIndex(std::string tool)
Return index of named tool within the master list.
Definition:
MouseToolState.h:54
casa::QtMouseToolState::toolIndexOnButton_
int toolIndexOnButton_(int mousebtn)
Returns index of tool currently assigned to a mouse button (1, 2, or 3).
casa::QtMouseToolState::buttonOf
int buttonOf(casacore::String tool)
Returns button currently assigned to a tool (0 = no button assigned).
Definition:
QtMouseToolState.qo.h:82
casa::QtMouseToolState::mouseBtnStateChg
void mouseBtnStateChg(casacore::String tool, int state)
casa::QtMouseToolState::getButtonState
int getButtonState(const std::string &tool) const
casa::QtMouseToolState::rc
casacore::Casarc & rc
Definition:
QtMouseToolState.qo.h:116
casa::QtMouseToolState
Definition:
QtMouseToolState.qo.h:71
casa::QtMouseToolState::tool_state
std::map< std::string, int > tool_state
Definition:
QtMouseToolState.qo.h:143
casacore::String
String: the storage and methods of handling collections of characters.
Definition:
String.h:223
String.h
casa::QtMouseToolState::toolOnButton
casacore::String toolOnButton(int mousebtn)
Returns name of tool currently assigned to a mouse button (1, 2, or 3).
Definition:
QtMouseToolState.qo.h:88
Generated on Sun Sep 1 2019 23:32:33 for casa by
1.8.5