Skip to content

Commit

Permalink
Merge branch 'master' into dataServiceRef
Browse files Browse the repository at this point in the history
  • Loading branch information
FernandoES authored Oct 30, 2017
2 parents 8806991 + 8443eb8 commit f622ed1
Show file tree
Hide file tree
Showing 31 changed files with 1,339 additions and 635 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,27 @@ and this project adheres to [Semantic Versioning](http://semver.org/)

## [Unreleased]
### Added

### Changed

### Removed

### Fixed

## [1.5.0] - 2017-10-24
### Added
- experimental delta functionality
- loading multiple maps
- experimental margin slider

### Changed
- faster rendering

### Removed
- nwjs packages and native apps due to a bug

### Fixed
- using color metric instead of height metric for color range slider ceil

## [1.4.0] - 2017-09-14
### Added
Expand Down
2 changes: 1 addition & 1 deletion analysis/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Project-wide Gradle settings.

currentVersion=1.4.0
currentVersion=1.5.0

# The Gradle daemon aims to improve the startup and execution time of Gradle.
# When set to true the Gradle daemon is to run the build.
Expand Down
2 changes: 1 addition & 1 deletion visualization/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ module.exports = function (grunt) {
grunt.registerTask("default", ["build"]);
grunt.registerTask("build", ["clean:webpack", "webpack:prod"]);
grunt.registerTask("serve", ["clean:webpack", "webpack:dev"]);
grunt.registerTask("package", ["clean:package", "nwjs", "force:compress", "clean:packageTmp"]);
grunt.registerTask("package", ["clean:package", /*"nwjs",*/ "compress:web", "clean:packageTmp"]);
grunt.registerTask("doc", ["clean:doc", "exec:doc"]);
grunt.registerTask("test", ["clean:coverage", "clean:reports", "exec:karmaSingle"]);
grunt.registerTask("test:auto", ["clean:coverage", "clean:reports", "exec:karmaAuto"]);
Expand Down
1 change: 1 addition & 0 deletions visualization/app/codeCharta/codeChartaController.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class CodeChartaController {
// set loaded data
dataLoadingService.loadMapFromFileContent(urlService.getParam("file"), data, 0).then(
() => {
ctx.loadingFinished();
settingsService.updateSettingsFromUrl();
},
(r) => {
Expand Down
14 changes: 14 additions & 0 deletions visualization/app/codeCharta/codeChartaController.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,14 @@ describe("app.codeCharta.codeChartaController", function() {
.respond(200, "someData");

dataService.setFileData = sinon.spy();
dataService.setReferenceMap = sinon.spy();
dataService.setComparisonMap = sinon.spy();
settingsService.applySettings = sinon.spy();
codeChartaController = $controller("codeChartaController", {dataService: dataService, urlService: urlService, settingsService:settingsService, scenarioService:scenarioService});
expect(dataService.setFileData.calledWithExactly("someData"));
expect(dataService.setComparisonMap.called);
expect(dataService.setReferenceMap.called);
expect(settingsService.applySettings.called);

});

Expand All @@ -95,10 +101,18 @@ describe("app.codeCharta.codeChartaController", function() {
.respond(200, "someData");

settingsService.onSettingsChanged = sinon.spy();
dataService.setFileData = sinon.spy();
dataService.setReferenceMap = sinon.spy();
dataService.setComparisonMap = sinon.spy();
settingsService.applySettings = sinon.spy();

codeChartaController = $controller("codeChartaController", {dataService: dataService, urlService: urlService, settingsService:settingsService, scenarioService:scenarioService});

expect(dataService.setFileData.calledWithExactly("someData"));
expect(settingsService.onSettingsChanged.calledOnce);
expect(dataService.setComparisonMap.called);
expect(dataService.setReferenceMap.called);
expect(settingsService.applySettings.called);

});

Expand Down
2 changes: 1 addition & 1 deletion visualization/app/codeCharta/codeMap/codeMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "../core/core.js";
import {CodeMapDirective} from "./codeMapDirective.js";
import {CodeMapService} from "./codeMapService.js";
import {CodeMapAssetService} from "./codeMapAssetService.js";
import {CodeMapController} from "./codeMapController";
import {CodeMapController} from "./codeMapController.js";

angular.module("app.codeCharta.codeMap",["app.codeCharta.codeMap.threeViewer", "app.codeCharta.core"]);

Expand Down
158 changes: 31 additions & 127 deletions visualization/app/codeCharta/codeMap/codeMapController.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"use strict";

import * as THREE from "three";

/**
* Controls the codeMapDirective
*/
Expand Down Expand Up @@ -57,12 +55,6 @@ class CodeMapController {
*/
this.$rootScope = $rootScope;

/**
*
* @type {Raycaster}
*/
this.raycaster = new THREE.Raycaster();

/**
* current mouse position
* @type {{x: number, y: number}}
Expand All @@ -73,7 +65,6 @@ class CodeMapController {
document.addEventListener("click", this.onDocumentMouseDown.bind(this), false);

threeUpdateCycleService.updatables.push(this.update.bind(this));

}

/**
Expand All @@ -82,27 +73,27 @@ class CodeMapController {
update() {
this.cameraService.camera.updateMatrixWorld();

this.raycaster.setFromCamera(this.mouse, this.cameraService.camera);

var intersects = this.raycaster.intersectObjects(this.sceneService.scene.children, true);
if (this.sceneService.getMapMesh() != null)
{
let intersectionResult = this.sceneService.getMapMesh().checkMouseRayMeshIntersection(this.mouse, this.cameraService.camera);

var from = this.hovered;
let from = this.hovered;
let to = null;

if ( intersects.length > 0 ) {
if (intersectionResult.intersectionFound == true)
{
to = intersectionResult.building;
}
else
{
to = null;
}

if ( this.hovered !== intersects[ 0 ].object) {
this.hovered =intersects[ 0 ].object;
this.onBuildingHovered(from, this.hovered);
/**
* a lock to prevent event spamming
* @type {boolean}
*/
this.lock = false;
if (from != to)
{
this.onBuildingHovered(from, to);
this.hovered = to;
}
} else if(!this.lock){
this.hovered = null;
this.onBuildingHovered(from, null);
this.lock = true;
}
}

Expand All @@ -119,7 +110,6 @@ class CodeMapController {
* updates {CodeMapController} on mouse down
*/
onDocumentMouseDown() {

var from = this.selected;

if (this.hovered) {
Expand All @@ -141,7 +131,6 @@ class CodeMapController {
* @emits {building-hovered} on hover
*/
onBuildingHovered(from, to){

/*
if the hovered node does not have useful data, then we should look at its parent. If the parent has useful data
then this parent is a delta node which is made of two seperate, data-free nodes. This quick fix helps us to
Expand All @@ -156,103 +145,14 @@ class CodeMapController {

this.$rootScope.$broadcast("building-hovered", {to: to, from: from});

this.unhoverGroup(from);
this.hoverGroup(to);

}

/**
* Unhovers a group
* @param {object} mesh
*/
unhoverGroup(mesh) {

let ctx = this;

if(mesh && mesh.parent) {
// buildings are grouped in parent meshes, therefore we should look only at these

mesh.parent.children.forEach((c)=> {
if (c && c.material && c.material.emissive){
c.material.emissive.setHex(0x000000);
}
});

if (to !== null)
{
this.sceneService.getMapMesh().setHighlighted([to]);
}

}

/**
* Checks if the given mesh is in meshes array. Ignores itself in meshes array
* @param {object} meshes
* @param {object} mesh
* @param {object} current
* @return {boolean} true if found, false if not
*/
meshIsInMeshesWithoutCurrent(meshes, mesh, current){
meshes.forEach((m)=>{
if (m===mesh && m!==current){
return true;
}
});
return false;
}

/**
* Hovers a group.
* @param {object} mesh
*/
hoverGroup(mesh) {

if(mesh && mesh.parent){
// buildings are grouped in parent meshes, therefore we should look only at these
mesh.parent.children.forEach((c)=>{
if (c && c.material && c.material.emissive) {
c.material.emissive.setHex(0x666666);
}
});

}

}

/**
* unselects a group
* @param {object} mesh
*/
unselectGroup(mesh) {

if (mesh && mesh.parent) {

// buildings are grouped in parent meshes, therefore we should look only at these
mesh.parent.children.forEach((c)=> {
if (c && c.originalMaterial) {
c.material = c.originalMaterial.clone();
}
});

else
{
this.sceneService.getMapMesh().clearHighlight();
}

}

/**
* selects a group
* @param {object} mesh
*/
selectGroup(mesh) {

// the floors parent is root and floors do not have deltacubes.
if(mesh && mesh.parent) {

// buildings are grouped in parent meshes, therefore we should look only at these
mesh.parent.children.forEach((c)=> {
if (c && c.selectedMaterial) {
c.material = c.selectedMaterial.clone();
}
});

}

}

/**
Expand All @@ -262,12 +162,16 @@ class CodeMapController {
* @emits {building-selected} when building is selected
*/
onBuildingSelected(from, to){

this.$rootScope.$broadcast("building-selected", {to: to, from:from});

this.unselectGroup(from);
this.selectGroup(to);

if (to !== null)
{
this.sceneService.getMapMesh().setSelected([to]);
}
else
{
this.sceneService.getMapMesh().clearSelected();
}
}

}
Expand Down
Loading

0 comments on commit f622ed1

Please sign in to comment.