anatomist 6.0.4
3D neuroimaging data viewer
controlswitch.h
Go to the documentation of this file.
1/* This software and supporting documentation are distributed by
2 * Institut Federatif de Recherche 49
3 * CEA/NeuroSpin, Batiment 145,
4 * 91191 Gif-sur-Yvette cedex
5 * France
6 *
7 * This software is governed by the CeCILL-B license under
8 * French law and abiding by the rules of distribution of free software.
9 * You can use, modify and/or redistribute the software under the
10 * terms of the CeCILL-B license as circulated by CEA, CNRS
11 * and INRIA at the following URL "http://www.cecill.info".
12 *
13 * As a counterpart to the access to the source code and rights to copy,
14 * modify and redistribute granted by the license, users are provided only
15 * with a limited warranty and the software's author, the holder of the
16 * economic rights, and the successive licensors have only limited
17 * liability.
18 *
19 * In this respect, the user's attention is drawn to the risks associated
20 * with loading, using, modifying and/or developing or reproducing the
21 * software by the user in light of its specific status of free software,
22 * that may mean that it is complicated to manipulate, and that also
23 * therefore means that it is reserved for developers and experienced
24 * professionals having in-depth computer knowledge. Users are therefore
25 * encouraged to load and test the software's suitability as regards their
26 * requirements in conditions enabling the security of their systems and/or
27 * data to be ensured and, more generally, to use and operate it in the
28 * same conditions as regards security.
29 *
30 * The fact that you are presently reading this means that you have had
31 * knowledge of the CeCILL-B license and that you accept its terms.
32 */
33
34
35#ifndef ANATOMIST_CONTROLER_CONTROLSWITCH_H
36#define ANATOMIST_CONTROLER_CONTROLSWITCH_H
37
38
44
45#include <qobject.h>
46#include <qpushbutton.h>
47#include <qlayout.h>
48#include <qlabel.h>
49#include <QGestureEvent>
50
51#include <vector>
52#include <list>
53
54
55class ControlSwitch;
56class QTextBrowser;
57
58
59namespace anatomist
60{
61
63 {
64 public:
67
68 virtual void updateAvailableControls( ) {}
69 virtual void updateActivableControls( ) {}
70 virtual void updateActiveControl() {}
71 virtual void updateActions( ) {}
72
73 protected:
74 };
75
76}
77
78class ToolBox : public QWidget
79{
80
81 Q_OBJECT
82
83public:
84 ToolBox( const std::string& activeControlDescription = "" );
85 virtual ~ToolBox();
86
87 void resetActions( );
88 void updateActiveControl( const std::string& activeControlDescription );
89
90 void addTab( QWidget * child, const QString & label,
91 const std::string & actionid = "" );
92 void showPage ( QWidget * w );
93 void showPage( const std::string & label );
94 const std::set<std::string> & actions() const;
95
96private slots :
97 void switchControlDescriptionActivation();
98
99private:
100 struct Private;
101
102 QTabWidget * myActionTab;
103 QPushButton * myControlDescriptionActivation;
104 std::string myControlDescription;
105 QTextBrowser * myControlDescriptionWidget;
106 QLabel *l1, *l2, *l3, *l4;
107
108 bool myDescriptionActivated;
109 Private *d;
110};
111
112
113class ControlSwitch : public QObject
114{
115
116 Q_OBJECT
117
118public:
119 virtual ~ControlSwitch();
120
121 friend class anatomist::View;
122
125
130
131 const std::map<int, std::string>& activableControls( ) const;
132 const std::map<int, std::string>& availableControls( ) const;
133 const std::set<std::string>& activableControlGroups( ) const;
134 const std::set<std::string>& availableControlGroups( ) const;
135 const std::set<std::string>& actions() const;
136 std::string controlDescription( const std::string & ctrlname ) const;
137
138 //vector<ControlPtr>::iterator iterator;
139 typedef std::map<std::string, anatomist::ControlPtr>::const_iterator
141 typedef std::map<std::string, anatomist::ControlPtr>::iterator
143
144 //iterator begin();
146 //iterator end();
148 void setActiveControl( const std::string& );
149 const std::string& activeControl() const;
151
152 void keyPressEvent( QKeyEvent *);
153 void keyReleaseEvent( QKeyEvent *);
154 void mousePressEvent ( QMouseEvent * );
155 void mouseReleaseEvent ( QMouseEvent * );
156 void mouseDoubleClickEvent ( QMouseEvent * );
157 void mouseMoveEvent ( QMouseEvent * );
158 void wheelEvent ( QWheelEvent * );
159 void focusInEvent ( QFocusEvent * );
160 void focusOutEvent ( QFocusEvent * );
161 void enterEvent ( QEvent * );
162 void leaveEvent ( QEvent * );
163 void paintEvent ( QPaintEvent * );
164 void moveEvent ( QMoveEvent * );
165 void resizeEvent ( QResizeEvent * );
166 void dragEnterEvent ( QDragEnterEvent * );
167 void dragMoveEvent ( QDragMoveEvent * );
168 void dragLeaveEvent ( QDragLeaveEvent * );
169 void dropEvent ( QDropEvent * );
170 void showEvent ( QShowEvent * );
171 void hideEvent ( QHideEvent * );
173 //void customEvent ( QCustomEvent * );
174 void gestureEvent( QGestureEvent * );
175 void touchEvent( QTouchEvent * );
176
177 void setAvailableControls( const std::list<std::string>& objects );
178 void setActivableControls( bool init = false);
179
180 // void setControlBarButtons();
181
183 // private slots:
184 // void clicked( int id );
185
188
189 bool isToolBoxVisible() const;
192
193 anatomist::Action* getAction( const std::string& actionName );
194
195 void activateKeyPressAction( const std::string & methodname ) const;
196 void activateKeyReleaseAction( const std::string & methodname ) const;
198 const std::string & methodname,
199 int x, int y ) const;
201 const std::string & methodname,
202 int x, int y ) const;
204 const std::string & methodname,
205 int x, int y ) const;
207 const std::string & methodname,
208 int x, int y ) const;
209
210protected:
212
213private:
214 void init( );
215 void getSelectedObjectNames();
216
217 anatomist::ActionPool * myActionPool;
218 // QHButtonGroup * myControlBar;
219 std::string myViewType;
220 std::map<std::string, anatomist::ControlPtr> myControls;
221
222 std::map<int, std::string> myAvailableControls;
223 std::map<int, std::string> myActivableControls;
224
225 std::set<std::string> myAvailableControlGroups;
226 std::set<std::string> myActivableControlGroups;
227 std::list<std::string> mySelectedObjects;
228
229 std::list<anatomist::ControlSwitchObserver *> myObservers;
230
231 bool myControlEnabled;
232 std::string myActiveControl;
233
234 ToolBox * myToolBox;
235
236private slots:
237 void toolBoxDestroyed();
238
239};
240
241#endif
#define slots
void dragMoveEvent(QDragMoveEvent *)
const std::map< int, std::string > & availableControls() const
void activateKeyPressAction(const std::string &methodname) const
void notifyActiveControlChange()
void focusInEvent(QFocusEvent *)
const std::string & activeControl() const
void mouseDoubleClickEvent(QMouseEvent *)
anatomist::ControlPtr activeControlInstance() const
const std::set< std::string > & actions() const
void activateMousePressAction(const std::string &methodname, int x, int y) const
void hideEvent(QHideEvent *)
void dragEnterEvent(QDragEnterEvent *)
void moveEvent(QMoveEvent *)
void activateMouseDoubleClickAction(const std::string &methodname, int x, int y) const
void keyReleaseEvent(QKeyEvent *)
virtual ~ControlSwitch()
void showEvent(QShowEvent *)
std::map< std::string, anatomist::ControlPtr >::iterator iterator
void mouseReleaseEvent(QMouseEvent *)
void activateMouseMoveAction(const std::string &methodname, int x, int y) const
std::map< std::string, anatomist::ControlPtr >::const_iterator const_iterator
void setActiveControl(const std::string &)
bool isToolBoxVisible() const
anatomist::Action * getAction(const std::string &actionName)
void dragLeaveEvent(QDragLeaveEvent *)
void wheelEvent(QWheelEvent *)
const_iterator begin() const
void focusOutEvent(QFocusEvent *)
void selectionChangedEvent()
void enterEvent(QEvent *)
void updateControlDescription()
void updateToolBox()
void leaveEvent(QEvent *)
void keyPressEvent(QKeyEvent *)
const std::set< std::string > & availableControlGroups() const
void notifyActivableControlChange()
const std::set< std::string > & activableControlGroups() const
void notifyAvailableControlChange()
void activateMouseReleaseAction(const std::string &methodname, int x, int y) const
void activateKeyReleaseAction(const std::string &methodname) const
void touchEvent(QTouchEvent *)
const std::map< int, std::string > & activableControls() const
void dropEvent(QDropEvent *)
std::string controlDescription(const std::string &ctrlname) const
ToolBox * toolBox()
void mousePressEvent(QMouseEvent *)
bool attach(anatomist::ControlSwitchObserver *window)
void paintEvent(QPaintEvent *)
void mouseMoveEvent(QMouseEvent *)
void setActivableControls(bool init=false)
bool detach(anatomist::ControlSwitchObserver *window)
void setAvailableControls(const std::list< std::string > &objects)
void printControls()
void switchToolBoxVisible()
void gestureEvent(QGestureEvent *)
const_iterator end() const
ControlSwitch(anatomist::View *view)
void notifyActionChange()
void resizeEvent(QResizeEvent *)
void addTab(QWidget *child, const QString &label, const std::string &actionid="")
ToolBox(const std::string &activeControlDescription="")
void resetActions()
virtual ~ToolBox()
void updateActiveControl(const std::string &activeControlDescription)
const std::set< std::string > & actions() const
void showPage(const std::string &label)
void showPage(QWidget *w)
Control * ControlPtr
Definition control.h:62