Developer Documentation
keyHandling.cc
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 
43 
44 #include "CoreWidget.hh"
45 
47 
48 //-----------------------------------------------------------------------------
49 
50 KeyBinding CoreWidget::getKeyBinding(QObject* _plugin, int _keyIndex ){
51  if (_plugin == 0)
52  return coreKeys_[_keyIndex];
53 
54  for (uint i=0; i < plugins().size(); i++){
55  if (plugins()[i].plugin == _plugin)
56  return plugins()[i].keys[_keyIndex];
57  }
58 
59  emit log(LOGERR,tr("ERROR: could not get KeyBinding"));
60  return KeyBinding();
61 }
62 
63 QString CoreWidget::getRPCName(QObject* _plugin ){
64  if (_plugin == 0)
65  return "";
66 
67  for (uint i=0; i < plugins().size(); i++){
68  if (plugins()[i].plugin == _plugin)
69  return plugins()[i].rpcName;
70  }
71 
72  emit log(LOGERR,tr("ERROR: could not get rpcname"));
73  return "";
74 }
75 
77 void CoreWidget::keyPressEvent(QKeyEvent* _e)
78 {
79  std::pair< int,Qt::KeyboardModifiers > key = std::make_pair(_e->key(), _e->modifiers() );
80 
81  //iterate over all assigned keys
82  KeyRange range = keys_.equal_range(key);
83 
84  KeyMap::iterator it;
85  for (it=range.first; it != range.second; ++it){
86 
87  QObject* plugin = (*it).second.first;
88  KeyBinding binding = getKeyBinding( plugin, (*it).second.second );
89 
90  //check if its a core Key
91  if (plugin == 0){
92 
93  //the key belongs to a slot
94  if (binding.slot){
95  bool ok;
96  emit call("core." + binding.description, ok);
97  return;
98  }
99 
100  // =================================================================================
101  // Map event to the cores key and modifier.
102  // Call the core key handler with the mapped event.
103  // =================================================================================
104  QKeyEvent mappedEvent (_e->type(),binding.key, binding.modifiers,
105  _e->text(), _e->isAutoRepeat(), _e->count() );
106 
107  coreKeyPressEvent(&mappedEvent);
108 
109  //if the key is multiUse also check other assigned keys
110  if (binding.multiUse)
111  continue;
112  else
113  return;
114  }
115 
116  //it's a plugin key
117 
118  //the key belongs to a slot
119  if (binding.slot){
120  bool ok;
121  emit call(getRPCName(plugin) +"."+ binding.description, ok);
122  return;
123  }
124 
125  //the key was specified through keyInterface
126  KeyInterface* keyPlugin = qobject_cast< KeyInterface * >(plugin);
127 
128  if (keyPlugin){
129 
130  // =================================================================================
131  // Map event to the plugins key and modifier.
132  // Call it with the mapped event.
133  // =================================================================================
134  QKeyEvent mappedEvent(_e->type(),binding.key, binding.modifiers,
135  _e->text(), _e->isAutoRepeat(), _e->count() );
136 
137  keyPlugin->slotKeyEvent(&mappedEvent);
138  }
139 
140  //if its not a multiUse key we are ready
141  if (!binding.multiUse)
142  return;
143  }
144 }
145 
146 //-----------------------------------------------------------------------------
147 
149 void CoreWidget::keyReleaseEvent(QKeyEvent* _e) {
150 
151  if (_e->isAutoRepeat()) return; //consider only "real" release events
152 
153  std::pair< int,Qt::KeyboardModifiers > key = std::make_pair(_e->key(), _e->modifiers() );
154 
155  //iterate over all assigned keys
156  KeyRange range = keys_.equal_range(key);
157 
158  KeyMap::iterator it;
159  for (it=range.first; it != range.second; ++it){
160 
161  QObject* plugin = (*it).second.first;
162  KeyBinding binding = getKeyBinding( plugin, (*it).second.second );
163 
164  if (plugin == 0){
165 
166  // =================================================================================
167  // Map event to the cores key and modifier.
168  // Call the core key handler with the mapped event.
169  // =================================================================================
170  QKeyEvent mappedEvent (_e->type(),binding.key, binding.modifiers,
171  _e->text(), _e->isAutoRepeat(), _e->count() );
172  coreKeyReleaseEvent(&mappedEvent);
173 
174  //if the key is multiUse also check other assigned keys
175  if (binding.multiUse)
176  continue;
177  else
178  return;
179  }
180 
181  //it's a plugin key
182  KeyInterface* keyPlugin = qobject_cast< KeyInterface * >(plugin);
183 
184  if (keyPlugin){
185 
186  // =================================================================================
187  // Map event to the plugins key and modifier.
188  // Call the plugin with the mapped event.
189  // =================================================================================
190 
191  QKeyEvent mappedEvent (_e->type(),binding.key, binding.modifiers,
192  _e->text(), _e->isAutoRepeat(), _e->count() );
193 
194  keyPlugin->slotKeyReleaseEvent(&mappedEvent);
195  }
196 
197  //if its not a multiUse key we are ready
198  if (!binding.multiUse)
199  return;
200  }
201 }
202 
203 //-----------------------------------------------------------------------------
204 
206 void CoreWidget::slotRegisterKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse){
207 
208  //first check if the key is already registered by the coreWidget
209  bool found = false;
210  bool multi = false;
211  QString name;
212  for (uint i=0; i < coreKeys_.size(); i++)
213  if (coreKeys_[i].key == _key && coreKeys_[i].modifiers == _modifiers){
214  found = true;
215  multi = coreKeys_[i].multiUse;
216  name = "Core";
217  break;
218  }
219 
220  //then check if the key is already registered by a different plugin
221  if (!found)
222  for (uint i=0; i < plugins().size(); i++)
223  for (int k=0; k < plugins()[i].keys.count(); k++)
224  if (plugins()[i].keys[k].key == _key
225  && plugins()[i].keys[k].modifiers == _modifiers){
226  found = true;
227  multi = plugins()[i].keys[k].multiUse;
228  name = plugins()[i].name;
229  break;
230  }
231 
232  if (found && !multi)
233  emit log(LOGERR, tr("Key already registered by '%1'").arg( name ) );
234 
235  //check if its a key for the core
236  if (sender() == this){
237  KeyBinding kb;
238  kb.key = _key;
239  kb.modifiers = _modifiers;
240  kb.description = _description;
241  kb.multiUse = multi || _multiUse;
242  kb.slot = false;
243 
244  if (multi && !_multiUse)
245  emit log(LOGERR, tr("Key already registered by '%1'. Forced registration as multiUse key.").arg( name ));
246 
247  coreKeys_.push_back( kb );
248 
249  keys_.insert( std::make_pair( std::make_pair(_key, _modifiers) , std::make_pair ((QObject*)0, int(coreKeys_.size()-1 ) ) )) ;
250  invKeys_.insert( std::make_pair( std::make_pair ((QObject*)0, int(coreKeys_.size()-1) ) , std::make_pair(_key, _modifiers) ) );
251  return;
252  }
253 
254  //find plugin
255  PluginInfo* pluginInfo = 0;
256 
257  for (uint i=0; i < plugins().size(); i++)
258  if (plugins()[i].plugin == sender())
259  pluginInfo = &plugins()[i];
260 
261  if (pluginInfo == 0){
262  emit log(LOGERR, tr("Unable to register key. Plugin not found!"));
263  return;
264  }
265 
266  KeyBinding kb;
267  kb.key = _key;
268  kb.modifiers = _modifiers;
269  kb.description = _description;
270  kb.multiUse = multi || _multiUse;
271  kb.slot = false;
272 
273  if (multi && !_multiUse)
274  emit log(LOGERR, tr("Key already registered by '%1'. Forced registration as multiUse key.").arg( name ));
275 
276  pluginInfo->keys.append( kb );
277 
278  keys_.insert( std::make_pair( std::make_pair(_key, _modifiers) , std::make_pair(pluginInfo->plugin, pluginInfo->keys.size()-1) ) );
279  invKeys_.insert( std::make_pair( std::make_pair(pluginInfo->plugin, pluginInfo->keys.size()-1) , std::make_pair(_key, _modifiers) ) );
280 }
281 
284 
285  //check the core slots
286  for (int i=0; i < coreSlots_.count(); i++){
287 
288  //only consider functions without arguments
289  if ( !coreSlots_.at(i).slotName.contains( "()" ) )
290  continue;
291 
292  KeyBinding kb;
293  kb.key = -1;
294  kb.modifiers = 0;
295  kb.description = coreSlots_.at(i).slotName;
296  kb.multiUse = true;
297  kb.slot = true;
298 
299  coreKeys_.push_back( kb );
300 
301  keys_.insert( std::make_pair( std::make_pair(-1, (QFlags<Qt::KeyboardModifier>)0) , std::make_pair ((QObject*)0, int(coreKeys_.size()-1) ) )) ;
302  invKeys_.insert( std::make_pair( std::make_pair ((QObject*)0, int(coreKeys_.size()-1) ) , std::make_pair(-1, (QFlags<Qt::KeyboardModifier>)0) ) );
303  }
304 
305  //check all plugins
306  for (uint i=0; i < plugins().size(); i++)
307 
308  for (int j=0; j < plugins()[i].rpcFunctions.count(); j++){
309 
310  //only consider functions without arguments
311  if ( !plugins()[i].rpcFunctions[j].contains( "()" )
312  || plugins()[i].rpcFunctions[j] == "version()")
313  continue;
314 
315  KeyBinding kb;
316  kb.key = -1;
317  kb.modifiers = 0;
318  kb.description = plugins()[i].rpcFunctions[j];
319  kb.multiUse = true;
320  kb.slot = true;
321 
322  plugins()[i].keys.append( kb );
323 
324  keys_.insert( std::make_pair( std::make_pair(-1, (QFlags<Qt::KeyboardModifier>)0) , std::make_pair(plugins()[i].plugin, plugins()[i].keys.size()-1) ) );
325  invKeys_.insert( std::make_pair( std::make_pair(plugins()[i].plugin, plugins()[i].keys.size()-1) , std::make_pair(-1, (QFlags<Qt::KeyboardModifier>)0) ) );
326  }
327 }
328 
330 void CoreWidget::slotAddKeyMapping(int _key, Qt::KeyboardModifiers _modifiers, QObject* _plugin, int _keyBindingID){
331 
332  std::pair< int,Qt::KeyboardModifiers > keyCombi = std::make_pair(_key, _modifiers );
333  std::pair< int,Qt::KeyboardModifiers > oldCombi;
334  std::pair< QObject*, int > oldTarget;
335 
336  bool replace = false;
337 
338  //and check if the key is already assigned without multiUse
339  KeyMap::iterator it;
340  for (it=keys_.begin(); it != keys_.end(); ++it){
341 
342  int key = (*it).first.first;
343  Qt::KeyboardModifiers modifiers = (*it).first.second;
344  QObject* plugin = (*it).second.first;
345  int bindingID = (*it).second.second;
346  KeyBinding binding = getKeyBinding(plugin, bindingID);
347 
348  //check if its the keyBinding we want to map/replace
349  if (plugin == _plugin && bindingID == _keyBindingID){
350  replace = true;
351  oldCombi = (*it).first;
352  oldTarget = (*it).second;
353  continue;
354  }
355 
356  //check if the mapping is conflicting with other mappings
357  if (_key == key && _modifiers == modifiers ){
358 
359  if (!binding.multiUse){
360  if (plugin == 0)
361  emit log(LOGERR, tr("Could not add key mapping. Key already assigned to the core."));
362  else{
363  BaseInterface* basePlugin = qobject_cast< BaseInterface * >(plugin);
364 
365  if (basePlugin)
366  emit log(LOGERR, tr("Could not add key mapping. Key already assigned to %1").arg( basePlugin->name() ) );
367  else
368  emit log(LOGERR, tr("Could not add key mapping. Key already assigned to an unknown plugin."));
369  }
370  return;
371  }
372  }
373  }
374 
375  KeyBinding keyBinding = getKeyBinding(_plugin, _keyBindingID);
376 
377  //check if new binding doesn't allow multiUse but other assignments for the key exist
378  if (!keyBinding.multiUse)
379  if ( (replace && keys_.count(keyCombi) > 1) || (!replace && keys_.count(keyCombi) > 0) ){
380  emit log(LOGERR, tr("Could not add (single usage) key mapping. Key already assigned."));
381  return;
382  }
383 
384  if (replace){
385  keys_.erase(oldCombi);
386  invKeys_.erase(oldTarget);
387  }
388 
389  //now we can add the mapping
390  keys_.insert ( std::make_pair( keyCombi , std::make_pair(_plugin, _keyBindingID) ));
391  invKeys_.insert( std::make_pair( std::make_pair(_plugin, _keyBindingID), keyCombi ));
392 
393 }
394 
397 
398  QVector< int > keys;
399  QVector< int > modifiers;
400  QStringList pluginNames;
401  QVector< int > bindingIDs;
402 
403  //first load everything from INI file
404  if ( !_ini.section_exists("KeyBindings") )
405  return;
406 
407  int keyCount;
408  if (_ini.get_entry(keyCount,"KeyBindings","KeyCount") ){
409 
410  int key;
411  int mod;
412  QString name;
413  int binding;
414 
415  for (int i=0; i < keyCount; i++){
416 
417  if (!_ini.get_entry(key, "KeyBindings","Key" + QString::number(i) ) ) continue;
418  if (!_ini.get_entry(mod, "KeyBindings","KeyModifiers" + QString::number(i) ) ) continue;
419  if (!_ini.get_entry(name, "KeyBindings","KeyTarget" + QString::number(i) ) ) continue;
420  if (!_ini.get_entry(binding, "KeyBindings","KeyBinding" + QString::number(i) ) ) continue;
421 
422  keys.push_back( key );
423  modifiers.push_back( mod );
424  pluginNames.push_back( name );
425  bindingIDs.push_back( binding );
426  }
427  }
428 
429  //add the keyMapping
430  for (int i=0; i < keys.count(); i++){
431 
432  //first we need the plugin
433  QObject* plugin = 0;
434 
435  if (pluginNames[i] != "Core" ){
436  //search for the plugin
437  for (uint i=0; i < plugins().size(); i++)
438  if (plugins()[i].rpcName == pluginNames[i] ){
439  plugin = plugins()[i].plugin;
440  break;
441  }
442 
443  if (plugin == 0)
444  continue; //because plugin was not found
445  }
446 
447  slotAddKeyMapping( keys[i], (Qt::KeyboardModifiers) modifiers[i], plugin, bindingIDs[i] );
448  }
449 
450 }
451 
454 
455  QVector< int > keys;
456  QVector< int > modifiers;
457  QStringList pluginNames;
458  QVector< int > bindingIDs;
459 
460  //first get all keys with custom assignments
461  KeyMap::iterator it;
462  for (it=keys_.begin(); it != keys_.end(); ++it){
463 
464  int key = (*it).first.first;
465  Qt::KeyboardModifiers mod = (*it).first.second;
466  QObject* plugin = (*it).second.first;
467  int bindingID = (*it).second.second;
468  KeyBinding binding = getKeyBinding(plugin, bindingID);
469 
470  //check if current key assignment and original assignment differ
471  if (key != binding.key || mod != binding.modifiers){
472 
473  //get the pluginName
474  QString name;
475 
476  if (plugin == 0)
477  name = "Core";
478  else
479  name = getRPCName(plugin);
480 
481  //store key assignment
482  keys.push_back( key );
483  modifiers.push_back( mod );
484  pluginNames.push_back( name );
485  bindingIDs.push_back( bindingID );
486  }
487  }
488 
489  //finally store everything to INI file
490  _ini.add_entry("KeyBindings","KeyCount", keys.count());
491 
492  for (int i=0; i < keys.count(); i++){
493 
494  _ini.add_entry("KeyBindings","Key" + QString::number(i) , keys[i] );
495  _ini.add_entry("KeyBindings","KeyModifiers" + QString::number(i), modifiers[i] );
496  _ini.add_entry("KeyBindings","KeyTarget" + QString::number(i) , pluginNames[i] );
497  _ini.add_entry("KeyBindings","KeyBinding" + QString::number(i) , bindingIDs[i] );
498  }
499 }
500 
503 
504  //register keys for coreWidget
505  connect(this , SIGNAL( registerKey(int, Qt::KeyboardModifiers, QString, bool) ),
506  this , SLOT(slotRegisterKey(int, Qt::KeyboardModifiers, QString, bool)) );
507 
508  emit registerKey(Qt::Key_Print , Qt::NoModifier, "Create Snapshot");
509  emit registerKey(Qt::Key_Escape , Qt::NoModifier, "Switch to last action mode ( Move,Picking,Light or Info Mode)");
510  emit registerKey(Qt::Key_Space , Qt::NoModifier, "Toggle between multiview and single view");
511 
512  emit registerKey(Qt::Key_S , Qt::ControlModifier, "Save Object");
513  emit registerKey(Qt::Key_O , Qt::ControlModifier, "Open Object");
514  emit registerKey(Qt::Key_L , Qt::ControlModifier, "Show/Hide Logger");
515  emit registerKey(Qt::Key_T , Qt::ControlModifier, "Show/Hide Toolbox");
516  emit registerKey(Qt::Key_F , Qt::ControlModifier, "Toggle Fullscreen");
517  emit registerKey(Qt::Key_B , Qt::ControlModifier, "Show/Hide StatusBar");
518  emit registerKey(Qt::Key_N , Qt::ControlModifier, "Show/Hide ToolBar");
519  emit registerKey(Qt::Key_M , Qt::ControlModifier, "Show/Hide MenuBar");
520 
521 
522  if ( OpenFlipper::Options::isLinux() ) {
523  emit registerKey(Qt::Key_Meta , Qt::MetaModifier, "Use Navigation mode while key is pressed");
524  emit registerKey(Qt::Key_Meta , Qt::NoModifier, "Use Navigation mode while key is pressed");
525  emit registerKey(Qt::Key_Super_L , Qt::NoModifier, "Use Navigation mode while key is pressed");
526  emit registerKey(Qt::Key_Super_L , Qt::MetaModifier, "Use Navigation mode while key is pressed");
527  emit registerKey(Qt::Key_Super_R , Qt::NoModifier, "Use Navigation mode while key is pressed");
528  emit registerKey(Qt::Key_Super_R , Qt::MetaModifier, "Use Navigation mode while key is pressed");
529  } else {
530  emit registerKey(Qt::Key_Alt , Qt::AltModifier, "Use Navigation mode while key is pressed");
531  emit registerKey(Qt::Key_Alt , Qt::NoModifier, "Use Navigation mode while key is pressed");
532  }
533 
534  emit registerKey(Qt::Key_Shift , Qt::ShiftModifier, "Apply context menu action to all Viewers", true);
535  emit registerKey(Qt::Key_Shift , Qt::NoModifier, "Apply context menu action to all Viewers", true);
536 
537 
538  emit registerKey(Qt::Key_A , Qt::NoModifier, "First Person view strafe left");
539  emit registerKey(Qt::Key_D , Qt::NoModifier, "First Person view strafe right");
540  emit registerKey(Qt::Key_W , Qt::NoModifier, "First Person view move forward");
541  emit registerKey(Qt::Key_S , Qt::NoModifier, "First Person view move back");
542 
543 }
544 
546 void CoreWidget::coreKeyPressEvent (QKeyEvent* _e){
547  //emit log(LOGERR,"Key Press");
548  if ( (( _e->key() == Qt::Key_Meta ) || (_e->key() == Qt::Key_Super_L) || (_e->key() == Qt::Key_Super_R))
549  && OpenFlipper::Options::isLinux() ) {
550 
551  if ( lastActionMode() == actionMode()) {
552  if (actionMode() == Viewer::PickingMode)
553  setActionMode( Viewer::ExamineMode );
554  else
555  setActionMode( Viewer::PickingMode );
556  }
557  else
559  }
560 
561  if ( ( _e->key() == Qt::Key_Alt ) && ! OpenFlipper::Options::isLinux() ) {
562  //emit log(LOGERR,"Switch to examine mode");
563  if ( lastActionMode() == actionMode()) {
564  if (actionMode() == Viewer::PickingMode)
565  setActionMode( Viewer::ExamineMode );
566  else
567  setActionMode( Viewer::PickingMode );
568  }
569  else
571  }
572 
573 
574  if (_e->modifiers() & Qt::ControlModifier ) {
575  switch (_e->key()) {
576  case Qt::Key_B :
577  toggleStatusBar();
578  return;
579 
580  case Qt::Key_F :
582  return;
583 
584  case Qt::Key_L :
585  toggleLogger();
586  return;
587 
588  case Qt::Key_T :
589  toggleToolbox();
590  return;
591 
592  case Qt::Key_M :
593  toggleMenuBar();
594  return;
595 
596  case Qt::Key_N:
597  toggleToolBar();
598  return;
599 
600  case Qt::Key_O :
601  loadMenu();
602  return;
603 
604  case Qt::Key_S :
605  saveMenu();
606  default:
607  return;
608  }
609 
610  }
611 
612  switch (_e->key()) {
613 
614  case Qt::Key_Escape:
616  break;
617 
618  case Qt::Key_Print:
619  std::cerr << "Todo : On Print Screen, create a snapshot for all viewers" << std::endl;
620  break;
621 
622  case Qt::Key_Space:
624  break;
625 
626  case Qt::Key_A:
627  strafeLeft();
628  break;
629 
630  case Qt::Key_D:
631  strafeRight();
632  break;
633 
634  case Qt::Key_W:
635  moveForward();
636  break;
637 
638  case Qt::Key_S:
639  moveBack();
640  break;
641 
642  case Qt::Key_Shift :
643  shiftPressed_ = true;
644  break;
645 
646  default:
647  shiftPressed_ = false;
648  return;
649  }
650 }
651 
654 
655  if ( (( _e->key() == Qt::Key_Meta ) || (_e->key() == Qt::Key_Super_L) || (_e->key() == Qt::Key_Super_R))
656  && OpenFlipper::Options::isLinux() ) {
658  }
659 
660  //emit log(LOGERR,"Key release");
661 
662  if ( ( _e->key() == Qt::Key_Alt ) && !OpenFlipper::Options::isLinux() ) {
664  }
665 
666 
667  switch (_e->key()) {
668  case Qt::Key_Shift :
669  shiftPressed_ = false;
670  break;
671  default:
672  return;
673  }
674 }
void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse=false)
internal signal to register CoreWidget keys
void slotAddKeyMapping(int _key, Qt::KeyboardModifiers _modifiers, QObject *_plugin, int _keyBindingID)
add a new key Mapping
Definition: keyHandling.cc:330
QObject * plugin
Pointer to the loaded plugin (Already casted when loading it)
Definition: PluginInfo.hh:125
void toggleFullscreen()
Set application to Fullscreen and back.
Definition: CoreWidget.cc:670
bool shiftPressed_
Store the state of the shift key.
Definition: CoreWidget.hh:431
virtual void keyPressEvent(QKeyEvent *_e)
Handle key events.
Definition: keyHandling.cc:77
void call(QString _expression, bool &_success)
call a scripting function
void toggleStatusBar()
Change visibility of the Status Bar.
Definition: StatusBar.cc:144
void slotRegisterKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse=false)
key registration
Definition: keyHandling.cc:206
virtual void slotKeyEvent(QKeyEvent *_event)
Key Event from Main App.
Definition: KeyInterface.hh:80
bool section_exists(const QString &_section) const
Check if given section exists in the current INI file.
Definition: INIFile.cc:227
void toggleToolBar()
Hide or show current toolbar.
Definition: CoreWidget.cc:811
void slotRegisterSlotKeyBindings()
register scripting slots to allow keyBindings
Definition: keyHandling.cc:283
virtual void slotKeyReleaseEvent(QKeyEvent *_event)
Key Release Event from Main App.
Definition: KeyInterface.hh:87
void coreKeyReleaseEvent(QKeyEvent *_e)
if a keyReleaseEvent belongs to the core this functions is called
Definition: keyHandling.cc:653
std::vector< PluginInfo > & plugins()
Convenient way to access plugin list.
Definition: CoreWidget.cc:661
void setActionMode(const Viewer::ActionMode _am)
Definition: picking.cc:62
void log(Logtype _type, QString _message)
Logg with OUT,WARN or ERR as type.
void moveForward()
When using first person mode move forward.
virtual QString name()=0
Return a name for the plugin.
void saveKeyBindings(INIFile &_ini)
Store current key assignments to a given INI file.
Definition: keyHandling.cc:453
void loadKeyBindings(INIFile &_ini)
Load key assignments from a given INI file.
Definition: keyHandling.cc:396
std::vector< KeyBinding > coreKeys_
vector of keys registered to the core
Definition: CoreWidget.hh:386
void coreKeyPressEvent()
handle key events for the core
QString getRPCName(QObject *_plugin)
typedefs
Definition: keyHandling.cc:63
QList< SlotInfo > & coreSlots_
list of scripting slots from core
Definition: CoreWidget.hh:395
KeyMap keys_
mapping of all keys to registered keys and the corresponding plugins
Definition: CoreWidget.hh:389
Interface class from which all plugins have to be created.
void moveBack()
When using first person mode move backward.
Viewer::ActionMode lastActionMode()
Definition: CoreWidget.hh:1471
void add_entry(const QString &_section, const QString &_key, const QString &_value)
Addition / modification of a string entry.
Definition: INIFile.cc:257
QList< KeyBinding > keys
List of registered keys with description.
Definition: PluginInfo.hh:155
Keyboard Event Interface.
Definition: KeyInterface.hh:59
void registerCoreKeys()
Register all events related to the core.
Definition: keyHandling.cc:502
virtual void keyReleaseEvent(QKeyEvent *_e)
passes keyReleaseEvents to either the Core or a Plugin depending on who has registered the key ...
Definition: keyHandling.cc:149
InverseKeyMap invKeys_
mapping of all registered keys and the corresponding plugins to currently assigned keys ...
Definition: CoreWidget.hh:392
std::pair< KeyMap::iterator, KeyMap::iterator > KeyRange
typedefs
Definition: CoreWidget.hh:366
void toggleToolbox()
Hide or show toolbox area.
Definition: CoreWidget.cc:729
void toggleMenuBar()
Hide or show menu bar.
Definition: CoreWidget.cc:803
Viewer::ActionMode actionMode()
Definition: CoreWidget.hh:1470
void toggleLogger()
Hide or show logging area.
void strafeLeft()
When using first person mode strafe to the left.
KeyBinding getKeyBinding(QObject *_plugin, int _keyIndex)
typedefs
Definition: keyHandling.cc:50
Class for the handling of simple configuration files.
Definition: INIFile.hh:99
bool get_entry(QString &_val, const QString &_section, const QString &_key) const
Access to a string entry.
Definition: INIFile.cc:433
void strafeRight()
When using first person mode strafe to the right.
void nextViewerLayout()
Switches over to the next view mode.
Definition: CoreWidget.cc:938