Skip to content

Commit

Permalink
Merge pull request #1491 from xeokit/feature/toggle-length-labels
Browse files Browse the repository at this point in the history
Feature/toggle length labels
  • Loading branch information
xeolabs authored May 15, 2024
2 parents 98447d4 + b33017f commit 8a5a8ef
Show file tree
Hide file tree
Showing 15 changed files with 583 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,39 @@ <h3>Assets</h3>
},
{
getTitle: (context) => {
return context.distanceMeasurement.labelsVisible ? "Hide Labels" : "Show Labels";
return context.distanceMeasurement.xLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide X Label" : "Show X Label";
},
doAction: function (context) {
context.distanceMeasurement.xLabelVisible = !context.distanceMeasurement.xLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.yLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Y Label" : "Show Y Label";
},
doAction: function (context) {
context.distanceMeasurement.yLabelVisible = !context.distanceMeasurement.yLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.zLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Z Label" : "Show Z Label";
},
doAction: function (context) {
context.distanceMeasurement.zLabelVisible = !context.distanceMeasurement.zLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.lengthLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Length Label" : "Show Length Label";
},
doAction: function (context) {
context.distanceMeasurement.lengthLabelVisible = !context.distanceMeasurement.lengthLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.labelsVisible ? "Hide All Labels" : "Show All Labels";
},
doAction: function (context) {
context.distanceMeasurement.labelsVisible = !context.distanceMeasurement.labelsVisible;
Expand Down
37 changes: 35 additions & 2 deletions examples/measurement/distance_createWithMouse_nosnapping.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ <h3>Assets</h3>
const sceneModel = xktLoader.load({
id: "myModel",
src: "../../assets/models/xkt/v10/glTF-Embedded/Duplex_A_20110505.glTFEmbedded.xkt",
rotation: [0, 50, 0],
edges: true
});

Expand All @@ -172,7 +173,7 @@ <h3>Assets</h3>
// DistanceMeasurementsPlugin, DistanceMeasurementsMouseControl and PointerLens
//------------------------------------------------------------------------------------------------------------------

const distanceMeasurements = new DistanceMeasurementsPlugin(viewer);
const distanceMeasurements = new DistanceMeasurementsPlugin(viewer, {});

const distanceMeasurementsMouseControl = new DistanceMeasurementsMouseControl(distanceMeasurements, {
pointerLens : new PointerLens(viewer)
Expand Down Expand Up @@ -205,7 +206,39 @@ <h3>Assets</h3>
},
{
getTitle: (context) => {
return context.distanceMeasurement.labelsVisible ? "Hide Labels" : "Show Labels";
return context.distanceMeasurement.xLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide X Label" : "Show X Label";
},
doAction: function (context) {
context.distanceMeasurement.xLabelVisible = !context.distanceMeasurement.xLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.yLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Y Label" : "Show Y Label";
},
doAction: function (context) {
context.distanceMeasurement.yLabelVisible = !context.distanceMeasurement.yLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.zLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Z Label" : "Show Z Label";
},
doAction: function (context) {
context.distanceMeasurement.zLabelVisible = !context.distanceMeasurement.zLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.lengthLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Length Label" : "Show Length Label";
},
doAction: function (context) {
context.distanceMeasurement.lengthLabelVisible = !context.distanceMeasurement.lengthLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.labelsVisible ? "Hide All Labels" : "Show All Labels";
},
doAction: function (context) {
context.distanceMeasurement.labelsVisible = !context.distanceMeasurement.labelsVisible;
Expand Down
34 changes: 33 additions & 1 deletion examples/measurement/distance_createWithMouse_snapping.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,39 @@ <h3>Assets</h3>
},
{
getTitle: (context) => {
return context.distanceMeasurement.labelsVisible ? "Hide Labels" : "Show Labels";
return context.distanceMeasurement.xLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide X Label" : "Show X Label";
},
doAction: function (context) {
context.distanceMeasurement.xLabelVisible = !context.distanceMeasurement.xLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.yLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Y Label" : "Show Y Label";
},
doAction: function (context) {
context.distanceMeasurement.yLabelVisible = !context.distanceMeasurement.yLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.zLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Z Label" : "Show Z Label";
},
doAction: function (context) {
context.distanceMeasurement.zLabelVisible = !context.distanceMeasurement.zLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.lengthLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Length Label" : "Show Length Label";
},
doAction: function (context) {
context.distanceMeasurement.lengthLabelVisible = !context.distanceMeasurement.lengthLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.labelsVisible ? "Hide All Labels" : "Show All Labels";
},
doAction: function (context) {
context.distanceMeasurement.labelsVisible = !context.distanceMeasurement.labelsVisible;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,39 @@ <h3>Assets</h3>
},
{
getTitle: (context) => {
return context.distanceMeasurement.labelsVisible ? "Hide Labels" : "Show Labels";
return context.distanceMeasurement.xLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide X Label" : "Show X Label";
},
doAction: function (context) {
context.distanceMeasurement.xLabelVisible = !context.distanceMeasurement.xLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.yLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Y Label" : "Show Y Label";
},
doAction: function (context) {
context.distanceMeasurement.yLabelVisible = !context.distanceMeasurement.yLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.zLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Z Label" : "Show Z Label";
},
doAction: function (context) {
context.distanceMeasurement.zLabelVisible = !context.distanceMeasurement.zLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.lengthLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Length Label" : "Show Length Label";
},
doAction: function (context) {
context.distanceMeasurement.lengthLabelVisible = !context.distanceMeasurement.lengthLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.labelsVisible ? "Hide All Labels" : "Show All Labels";
},
doAction: function (context) {
context.distanceMeasurement.labelsVisible = !context.distanceMeasurement.labelsVisible;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,39 @@ <h3>Assets</h3>
},
{
getTitle: (context) => {
return context.distanceMeasurement.labelsVisible ? "Hide Labels" : "Show Labels";
return context.distanceMeasurement.xLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide X Label" : "Show X Label";
},
doAction: function (context) {
context.distanceMeasurement.xLabelVisible = !context.distanceMeasurement.xLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.yLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Y Label" : "Show Y Label";
},
doAction: function (context) {
context.distanceMeasurement.yLabelVisible = !context.distanceMeasurement.yLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.zLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Z Label" : "Show Z Label";
},
doAction: function (context) {
context.distanceMeasurement.zLabelVisible = !context.distanceMeasurement.zLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.lengthLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Length Label" : "Show Length Label";
},
doAction: function (context) {
context.distanceMeasurement.lengthLabelVisible = !context.distanceMeasurement.lengthLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.labelsVisible ? "Hide All Labels" : "Show All Labels";
},
doAction: function (context) {
context.distanceMeasurement.labelsVisible = !context.distanceMeasurement.labelsVisible;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,39 @@ <h3>Tutorials</h3>
},
{
getTitle: (context) => {
return context.distanceMeasurement.labelsVisible ? "Hide Labels" : "Show Labels";
return context.distanceMeasurement.xLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide X Label" : "Show X Label";
},
doAction: function (context) {
context.distanceMeasurement.xLabelVisible = !context.distanceMeasurement.xLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.yLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Y Label" : "Show Y Label";
},
doAction: function (context) {
context.distanceMeasurement.yLabelVisible = !context.distanceMeasurement.yLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.zLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Z Label" : "Show Z Label";
},
doAction: function (context) {
context.distanceMeasurement.zLabelVisible = !context.distanceMeasurement.zLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.lengthLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Length Label" : "Show Length Label";
},
doAction: function (context) {
context.distanceMeasurement.lengthLabelVisible = !context.distanceMeasurement.lengthLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.labelsVisible ? "Hide All Labels" : "Show All Labels";
},
doAction: function (context) {
context.distanceMeasurement.labelsVisible = !context.distanceMeasurement.labelsVisible;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,39 @@ <h3>Tutorials</h3>
},
{
getTitle: (context) => {
return context.distanceMeasurement.labelsVisible ? "Hide Labels" : "Show Labels";
return context.distanceMeasurement.xLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide X Label" : "Show X Label";
},
doAction: function (context) {
context.distanceMeasurement.xLabelVisible = !context.distanceMeasurement.xLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.yLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Y Label" : "Show Y Label";
},
doAction: function (context) {
context.distanceMeasurement.yLabelVisible = !context.distanceMeasurement.yLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.zLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Z Label" : "Show Z Label";
},
doAction: function (context) {
context.distanceMeasurement.zLabelVisible = !context.distanceMeasurement.zLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.lengthLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Length Label" : "Show Length Label";
},
doAction: function (context) {
context.distanceMeasurement.lengthLabelVisible = !context.distanceMeasurement.lengthLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.labelsVisible ? "Hide All Labels" : "Show All Labels";
},
doAction: function (context) {
context.distanceMeasurement.labelsVisible = !context.distanceMeasurement.labelsVisible;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,39 @@ <h3>Assets</h3>
},
{
getTitle: (context) => {
return context.distanceMeasurement.labelsVisible ? "Hide Labels" : "Show Labels";
return context.distanceMeasurement.xLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide X Label" : "Show X Label";
},
doAction: function (context) {
context.distanceMeasurement.xLabelVisible = !context.distanceMeasurement.xLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.yLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Y Label" : "Show Y Label";
},
doAction: function (context) {
context.distanceMeasurement.yLabelVisible = !context.distanceMeasurement.yLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.zLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Z Label" : "Show Z Label";
},
doAction: function (context) {
context.distanceMeasurement.zLabelVisible = !context.distanceMeasurement.zLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.lengthLabelVisible && context.distanceMeasurement.labelsVisible ? "Hide Length Label" : "Show Length Label";
},
doAction: function (context) {
context.distanceMeasurement.lengthLabelVisible = !context.distanceMeasurement.lengthLabelVisible;
}
},
{
getTitle: (context) => {
return context.distanceMeasurement.labelsVisible ? "Hide All Labels" : "Show All Labels";
},
doAction: function (context) {
context.distanceMeasurement.labelsVisible = !context.distanceMeasurement.labelsVisible;
Expand Down
Loading

0 comments on commit 8a5a8ef

Please sign in to comment.