Skip to content

Commit 65ddfb2

Browse files
committed
Merge branch 'master' of https://github.com/sandialabs/InterSpec
2 parents 60c4320 + bc6b799 commit 65ddfb2

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

InterSpec_resources/D3TimeChart.js

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,11 @@ D3TimeChart = function (elem, options) {
233233
background: {
234234
modifierKey: { altKey: true },
235235
},
236+
removeForeground: {
237+
modifierKey: { ctrlKey: true },
238+
},
236239
zoom: {
237-
modifierKey: { ctrlKey: true, rightClick: true },
240+
modifierKey: { rightClick: true },
238241
},
239242
};
240243

@@ -272,6 +275,7 @@ D3TimeChart = function (elem, options) {
272275
this.HIGHLIGHT_COLORS = Object.freeze({
273276
foreground: "rgb(255, 255, 0)",
274277
background: "rgb(0, 255, 255)",
278+
removeForeground: "rgb(255, 0, 0)",
275279
// zoom: "rgb(102,102,102)",
276280
});
277281

@@ -616,21 +620,23 @@ D3TimeChart.prototype.reinitializeChart = function (options) {
616620
this.userInteractionMode ===
617621
this.UserInteractionModeEnum.SELECTBACKGROUND;
618622
var TOUCH_ANALOGOUS_CTRLCLICK =
619-
this.userInteractionMode === this.UserInteractionModeEnum.ZOOM;
623+
this.userInteractionMode ===
624+
this.UserInteractionModeEnum.REMOVEFOREGROUND;
620625

621626
this.shiftKeyHeld =
622627
TOUCH_ANALOGOUS_SHIFT ||
623628
(d3.event.sourceEvent && d3.event.sourceEvent.shiftKey);
624629

625630
if (
626-
TOUCH_ANALOGOUS_RIGHTCLICK ||
631+
TOUCH_ANALOGOUS_CTRLCLICK ||
627632
(d3.event.type == "dragstart" &&
628633
window.MouseEvent &&
629634
d3.event.sourceEvent instanceof MouseEvent &&
630-
d3.event.sourceEvent.button == 2)
635+
d3.event.sourceEvent.ctrlKey &&
636+
!this.shiftKeyHeld)
631637
) {
632-
this.highlightModifier = "rightClick";
633-
this.mouseDownHighlight(coords[0], "rightClick");
638+
this.highlightModifier = "ctrlKey";
639+
this.mouseDownHighlight(coords[0], "ctrlKey");
634640
} else if (
635641
TOUCH_ANALOGOUS_ALTKEY ||
636642
(d3.event.type == "dragstart" &&
@@ -641,14 +647,15 @@ D3TimeChart.prototype.reinitializeChart = function (options) {
641647
this.highlightModifier = "altKey";
642648
this.mouseDownHighlight(coords[0], "altKey");
643649
} else if (
644-
TOUCH_ANALOGOUS_CTRLCLICK ||
650+
TOUCH_ANALOGOUS_RIGHTCLICK ||
645651
(d3.event.type == "dragstart" &&
646652
window.MouseEvent &&
647653
d3.event.sourceEvent instanceof MouseEvent &&
648-
d3.event.sourceEvent.ctrlKey)
654+
d3.event.sourceEvent.button === 2 &&
655+
d3.event.sourceEvent.ctrlKey === false) // ctrlKey needed to be false, since in FireFox ctrlKey + click triggers button == 2 also (i.e. right-click)
649656
) {
650-
this.highlightModifier = "ctrlKey";
651-
this.mouseDownHighlight(coords[0], "ctrlKey");
657+
this.highlightModifier = "rightClick";
658+
this.mouseDownHighlight(coords[0], "rightClick");
652659
} else {
653660
this.highlightModifier = "none";
654661
this.mouseDownHighlight(coords[0], "none");
@@ -730,9 +737,11 @@ D3TimeChart.prototype.reinitializeChart = function (options) {
730737
// unnecessary check, but added to make it clear that if you wanted to add extra functionality to "simple gesture" mode, then you should handle things differently.
731738
// handle foreground or background selection
732739

740+
// Defined from docs on Wt::KeyboardModifier
733741
var keyModifierMap = {
734742
altKey: 0x4,
735743
shiftKey: 0x1,
744+
ctrlKey: 0x2,
736745
none: 0x0,
737746
};
738747
this.WtEmit(
@@ -2291,7 +2300,9 @@ D3TimeChart.prototype.handleMouseWheel = function (deltaX, deltaY, mouseX) {
22912300
};
22922301
} else {
22932302
// use all data
2294-
var fullDomain = this.state.data.formatted[this.state.data.unzoomedCompressionIndex].domains;
2303+
var fullDomain =
2304+
this.state.data.formatted[this.state.data.unzoomedCompressionIndex]
2305+
.domains;
22952306
}
22962307
var scales = this.getScales(fullDomain);
22972308
brush.setScale(scales.xScale);
@@ -2569,6 +2580,7 @@ D3TimeChart.prototype.mouseDownHighlight = function (mouseX, modifier) {
25692580
} else {
25702581
var foreground = this.highlightOptions.foreground;
25712582
var background = this.highlightOptions.background;
2583+
var removeForeground = this.highlightOptions.removeForeground;
25722584
var zoom = this.highlightOptions.zoom;
25732585

25742586
if (foreground && modifier in foreground.modifierKey) {
@@ -2577,6 +2589,9 @@ D3TimeChart.prototype.mouseDownHighlight = function (mouseX, modifier) {
25772589
} else if (background && modifier in background.modifierKey) {
25782590
this.highlightRect.attr("fill", this.HIGHLIGHT_COLORS.background);
25792591
this.highlightText.text("Select background");
2592+
} else if (removeForeground && modifier in removeForeground.modifierKey) {
2593+
this.highlightRect.attr("fill", this.HIGHLIGHT_COLORS.removeForeground);
2594+
this.highlightText.text("Remove foreground");
25802595
} else if (zoom && modifier in zoom.modifierKey) {
25812596
this.highlightRect.classed("leftbuttonzoombox", true);
25822597
// this.highlightRect.attr("fill", this.HIGHLIGHT_COLORS.zoom);
@@ -3341,6 +3356,7 @@ D3TimeChart.prototype.setUserInteractionMode = function (mode) {
33413356
this.userInteractionMode = this.UserInteractionModeEnum.SELECTSECONDARY;
33423357
this.usingAddSelectionMode = true;
33433358
} else if (mode === "RemoveForeground") {
3359+
this.userInteractionMode = this.UserInteractionModeEnum.REMOVEFOREGROUND;
33443360
} else if (mode === "RemoveBackground") {
33453361
} else if (mode === "RemoveSecondary") {
33463362
} else {

0 commit comments

Comments
 (0)