21#ifndef __vtkMRMLLayerDMWidgetEventTranslationNode_h
22#define __vtkMRMLLayerDMWidgetEventTranslationNode_h
24#include "vtkSlicerLayerDMModuleMRMLExport.h"
31#include <vtkCommand.h>
52 void PrintSelf(ostream& os, vtkIndent indent)
override;
59 void WriteXML(ostream& of,
int indent)
override;
75 void SetTranslation(
int widgetState,
unsigned long interactionEvent,
unsigned long widgetEvent,
int modifier = vtkEvent::NoModifier);
79 unsigned long interactionEvent,
80 int widgetStateDragging,
81 unsigned long widgetStartEvent,
82 unsigned long widgetEndEvent,
83 int modifiers = vtkEvent::NoModifier);
87 const std::string& keySym,
88 unsigned long widgetEvent,
89 int modifier = vtkEvent::NoModifier,
91 unsigned long keyEvent = vtkCommand::KeyPressEvent);
134 bool operator==(
const EventKey& other)
const {
return this->AsTuple() == other.AsTuple(); }
135 bool operator<(
const EventKey& other)
const {
return this->AsTuple() < other.AsTuple(); }
136 std::tuple<int, unsigned long, int, int, std::string> AsTuple()
const
138 return std::make_tuple(this->WidgetState, this->EventId, this->Modifier, this->RepeatCount, this->KeySym);
143 static int ThresholdRepeatCount(
int repeatCount) {
return std::max(1, repeatCount); }
146 unsigned long EventId{ vtkCommand::NoEvent };
147 int Modifier{ vtkEvent::NoModifier };
148 int RepeatCount{ 1 };
152 void SetTranslation(
const EventKey& key,
unsigned long widgetEvent);
153 unsigned long Translate(EventKey key)
const;
154 bool IsWidgetEventBlocked(
unsigned long widgetEvent)
const;
155 unsigned long GetWidgetEvent(
const EventKey& key)
const;
157 static std::string ToString(
const std::map<EventKey, unsigned long>& eventMap,
const vtkIndent* indent,
const std::string& eol);
158 static std::string ToString(
const std::pair<EventKey, unsigned long>& eventPair);
160 static std::map<EventKey, unsigned long> EventMapFromString(
const std::string& value);
161 static std::pair<EventKey, unsigned long> EventPairFromString(
const std::string& value);
163 std::map<EventKey, unsigned long> EventMap;
164 std::set<unsigned long> BlockedEvents;