@@ -236,7 +236,7 @@ D3TimeChart = function (elem, options) {
236236 secondary : {
237237 modifierKey : { metaKey : true } ,
238238 } ,
239- removeForeground : {
239+ remove : {
240240 modifierKey : { ctrlKey : true } ,
241241 } ,
242242 zoom : {
@@ -269,17 +269,14 @@ D3TimeChart = function (elem, options) {
269269 SELECTFOREGROUND : 3 ,
270270 SELECTBACKGROUND : 4 ,
271271 SELECTSECONDARY : 5 ,
272- REMOVEFOREGROUND : 6 ,
273- REMOVEBACKGROUND : 7 ,
274- REMOVESECONDARY : 8 ,
275272 } ) ;
276273
277274 // colors used for highlight rectangles for various selection types.
278275 this . HIGHLIGHT_COLORS = Object . freeze ( {
279276 foreground : "rgb(255, 255, 0)" ,
280277 background : "rgb(0, 255, 255)" ,
281278 secondary : "rgb(0, 128, 0)" ,
282- removeForeground : "rgb(255, 0, 0)" ,
279+ remove : "rgb(255, 0, 0)" ,
283280 // zoom: "rgb(102,102,102)",
284281 } ) ;
285282
@@ -651,32 +648,24 @@ D3TimeChart.prototype.reinitializeChart = function (options) {
651648
652649 // TODO: add analogous touch gestures to add additional touch functionality
653650 var TOUCH_ANALOGOUS_SHIFT = this . usingAddSelectionMode === true ;
651+ var TOUCH_ANALOGOUS_CTRL = this . usingRemoveSelectionMode === true ;
654652 var TOUCH_ANALOGOUS_RIGHTCLICK =
655653 this . userInteractionMode === this . UserInteractionModeEnum . ZOOM ;
656654 var TOUCH_ANALOGOUS_ALTKEYCLICK =
657655 this . userInteractionMode ===
658656 this . UserInteractionModeEnum . SELECTBACKGROUND ;
659- var TOUCH_ANALOGOUS_CTRLKEYCLICK =
660- this . userInteractionMode ===
661- this . UserInteractionModeEnum . REMOVEFOREGROUND ;
662657 var TOUCH_ANALOGOUS_METAKEYCLICK =
663658 this . userInteractionMode === this . UserInteractionModeEnum . SELECTSECONDARY ;
664659
665660 this . shiftKeyHeld =
666661 TOUCH_ANALOGOUS_SHIFT ||
667662 ( d3 . event . sourceEvent && d3 . event . sourceEvent . shiftKey ) ;
668663
664+ this . ctrlKeyHeld =
665+ TOUCH_ANALOGOUS_CTRL ||
666+ ( d3 . event . sourceEvent && d3 . event . sourceEvent . ctrlKey ) ;
667+
669668 if (
670- TOUCH_ANALOGOUS_CTRLKEYCLICK ||
671- ( d3 . event . type == "dragstart" &&
672- window . MouseEvent &&
673- d3 . event . sourceEvent instanceof MouseEvent &&
674- d3 . event . sourceEvent . ctrlKey &&
675- ! this . shiftKeyHeld )
676- ) {
677- this . highlightModifier = "ctrlKey" ;
678- this . mouseDownHighlight ( coords [ 0 ] , "ctrlKey" ) ;
679- } else if (
680669 TOUCH_ANALOGOUS_ALTKEYCLICK ||
681670 ( d3 . event . type == "dragstart" &&
682671 window . MouseEvent &&
@@ -795,14 +784,34 @@ D3TimeChart.prototype.reinitializeChart = function (options) {
795784 shiftKey : 0x1 ,
796785 none : 0x0 ,
797786 } ;
798- this . WtEmit (
799- this . chart . id ,
800- { name : "timedragged" } ,
801- this . state . data . formatted [ 0 ] . sampleNumbers [ lIdx ] ,
802- this . state . data . formatted [ 0 ] . sampleNumbers [ rIdx ] ,
803- keyModifierMap [ this . highlightModifier ] |
804- ( keyModifierMap [ "shiftKey" ] & this . shiftKeyHeld ) // bitwise OR with the shift key modifier if held, 0 otherwise.
805- ) ;
787+
788+ if ( this . shiftKeyHeld ) {
789+ this . WtEmit (
790+ this . chart . id ,
791+ { name : "timedragged" } ,
792+ this . state . data . formatted [ 0 ] . sampleNumbers [ lIdx ] ,
793+ this . state . data . formatted [ 0 ] . sampleNumbers [ rIdx ] ,
794+ keyModifierMap [ this . highlightModifier ] |
795+ keyModifierMap [ "shiftKey" ]
796+ ) ;
797+ } else if ( this . ctrlKeyHeld ) {
798+ this . WtEmit (
799+ this . chart . id ,
800+ { name : "timedragged" } ,
801+ this . state . data . formatted [ 0 ] . sampleNumbers [ lIdx ] ,
802+ this . state . data . formatted [ 0 ] . sampleNumbers [ rIdx ] ,
803+ keyModifierMap [ this . highlightModifier ] |
804+ keyModifierMap [ "ctrlKey" ]
805+ ) ;
806+ } else {
807+ this . WtEmit (
808+ this . chart . id ,
809+ { name : "timedragged" } ,
810+ this . state . data . formatted [ 0 ] . sampleNumbers [ lIdx ] ,
811+ this . state . data . formatted [ 0 ] . sampleNumbers [ rIdx ] ,
812+ keyModifierMap [ this . highlightModifier ]
813+ ) ;
814+ }
806815 }
807816 }
808817 }
@@ -812,6 +821,7 @@ D3TimeChart.prototype.reinitializeChart = function (options) {
812821 brush . clear ( ) ;
813822 this . highlightModifier = null ;
814823 this . shiftKeyHeld = false ;
824+ this . ctrlKeyHeld = false ;
815825 } ;
816826
817827 // touch drag behavior
@@ -2632,10 +2642,20 @@ D3TimeChart.prototype.mouseDownHighlight = function (mouseX, modifier) {
26322642 var foreground = this . highlightOptions . foreground ;
26332643 var background = this . highlightOptions . background ;
26342644 var secondary = this . highlightOptions . secondary ;
2635- var removeForeground = this . highlightOptions . removeForeground ;
26362645 var zoom = this . highlightOptions . zoom ;
26372646
2638- if ( foreground && modifier in foreground . modifierKey ) {
2647+ if ( this . ctrlKeyHeld && ! this . shiftKeyHeld ) {
2648+ this . highlightRect . attr ( "fill" , this . HIGHLIGHT_COLORS . remove ) ;
2649+ var spectrumType = "" ;
2650+ if ( foreground && modifier in foreground . modifierKey ) {
2651+ spectrumType = " foreground" ;
2652+ } else if ( background && modifier in background . modifierKey ) {
2653+ spectrumType = " background" ;
2654+ } else if ( secondary && modifier in secondary . modifierKey ) {
2655+ spectrumType = " secondary" ;
2656+ }
2657+ this . highlightText . text ( "Remove" + spectrumType ) ;
2658+ } else if ( foreground && modifier in foreground . modifierKey ) {
26392659 this . highlightRect . attr ( "fill" , this . HIGHLIGHT_COLORS . foreground ) ;
26402660 this . highlightText . text ( "Select foreground" ) ;
26412661 } else if ( background && modifier in background . modifierKey ) {
@@ -2644,9 +2664,6 @@ D3TimeChart.prototype.mouseDownHighlight = function (mouseX, modifier) {
26442664 } else if ( secondary && modifier in secondary . modifierKey ) {
26452665 this . highlightRect . attr ( "fill" , this . HIGHLIGHT_COLORS . secondary ) ;
26462666 this . highlightText . text ( "Select secondary" ) ;
2647- } else if ( removeForeground && modifier in removeForeground . modifierKey ) {
2648- this . highlightRect . attr ( "fill" , this . HIGHLIGHT_COLORS . removeForeground ) ;
2649- this . highlightText . text ( "Remove foreground" ) ;
26502667 } else if ( zoom && modifier in zoom . modifierKey ) {
26512668 this . highlightRect . classed ( "leftbuttonzoombox" , true ) ;
26522669 // this.highlightRect.attr("fill", this.HIGHLIGHT_COLORS.zoom);
@@ -3201,6 +3218,7 @@ D3TimeChart.prototype.compress = function (data, n) {
32013218 * }
32023219 */
32033220D3TimeChart . prototype . setHighlightRegions = function ( regions ) {
3221+ console . log ( regions ) ;
32043222 if (
32053223 ! this . state . height ||
32063224 ! this . state . width ||
@@ -3386,6 +3404,7 @@ D3TimeChart.prototype.setUserInteractionMode = function (mode) {
33863404 console . log ( "Will set user interaction mode to " + mode ) ;
33873405
33883406 this . usingAddSelectionMode = false ;
3407+ this . usingRemoveSelectionMode = false ;
33893408
33903409 var plotHeight = this . state . height - this . margin . top - this . margin . bottom ;
33913410
@@ -3411,9 +3430,14 @@ D3TimeChart.prototype.setUserInteractionMode = function (mode) {
34113430 this . userInteractionMode = this . UserInteractionModeEnum . SELECTSECONDARY ;
34123431 this . usingAddSelectionMode = true ;
34133432 } else if ( mode === "RemoveForeground" ) {
3414- this . userInteractionMode = this . UserInteractionModeEnum . REMOVEFOREGROUND ;
3433+ this . userInteractionMode = this . UserInteractionModeEnum . SELECTFOREGROUND ;
3434+ this . usingRemoveSelectionMode = true ;
34153435 } else if ( mode === "RemoveBackground" ) {
3436+ this . userInteractionMode = this . UserInteractionModeEnum . SELECTBACKGROUND ;
3437+ this . usingRemoveSelectionMode = true ;
34163438 } else if ( mode === "RemoveSecondary" ) {
3439+ this . userInteractionMode = this . UserInteractionModeEnum . SELECTSECONDARY ;
3440+ this . usingRemoveSelectionMode = true ;
34173441 } else {
34183442 console . log ( "Invalid option passed to setUserInteractionMode" ) ;
34193443 }
0 commit comments