Skip to content

Commit

Permalink
Object active flag
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitchenkoSergey committed Mar 19, 2018
1 parent 1fed4de commit 787057d
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 10 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,13 @@ schemeDesigner.render();
</tr>
<tr>
<td>rotation: number</td>
<td></td>
<td>0</td>
<td>Rotation</td>
</tr>
<tr>
<td>active: boolean</td>
<td>true</td>
<td>Active object can hanlde events.</td>
</tr>
<tr>
<td>cursorStyle: string</td>
Expand Down
27 changes: 24 additions & 3 deletions dist/scheme-designer.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ var SchemeDesigner;
return this.visible;
};
/**
* Get active
* Get is active
* @return {boolean}
*/
Layer.prototype.getActive = function () {
Layer.prototype.isActive = function () {
return this.active;
};
/**
Expand Down Expand Up @@ -502,6 +502,10 @@ var SchemeDesigner;
* @param {Object} params
*/
function SchemeObject(params) {
/**
* Is active
*/
this.active = true;
/**
* Rotation
*/
Expand Down Expand Up @@ -698,6 +702,20 @@ var SchemeDesigner;
SchemeObject.prototype.getRotation = function () {
return this.rotation;
};
/**
* Get is active
* @return {boolean}
*/
SchemeObject.prototype.isActive = function () {
return this.active;
};
/**
* Set active
* @param {boolean} value
*/
SchemeObject.prototype.setActive = function (value) {
this.active = value;
};
return SchemeObject;
}());
SchemeDesigner.SchemeObject = SchemeObject;
Expand Down Expand Up @@ -1915,12 +1933,15 @@ var SchemeDesigner;
// search object in node
for (var layerId in nodeObjectsByLayers) {
var layer = this.getLayerById(layerId);
if (!layer.getActive()) {
if (!layer.isActive()) {
continue;
}
var objects = nodeObjectsByLayers[layerId];
for (var _i = 0, objects_1 = objects; _i < objects_1.length; _i++) {
var schemeObject = objects_1[_i];
if (!schemeObject.isActive()) {
continue;
}
var boundingRect = schemeObject.getBoundingRect();
if (SchemeDesigner.Tools.pointInRect({ x: x, y: y }, boundingRect, schemeObject.getRotation())) {
result.push(schemeObject);
Expand Down
4 changes: 2 additions & 2 deletions dist/scheme-designer.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">

<script src="../dist/scheme-designer.min.js?16"></script>
<script src="../dist/scheme-designer.min.js?17"></script>

<!-- data for scheme -->
<script src="./scheme-data.js?1"></script>
Expand Down Expand Up @@ -194,6 +194,7 @@ <h2>Hall scheme example</h2>
y: 0.5 + topOffset,
width: width,
height: height,
active: objectData.ObjectType == 'Place'? true : false,
renderFunction: objectData.ObjectType == 'Place' ? renderPlace : renderLabel,
cursorStyle: objectData.ObjectType == 'Place' ? 'pointer' : 'default',

Expand Down
4 changes: 2 additions & 2 deletions src/Layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ namespace SchemeDesigner {
}

/**
* Get active
* Get is active
* @return {boolean}
*/
public getActive(): boolean
public isActive(): boolean
{
return this.active;
}
Expand Down
23 changes: 23 additions & 0 deletions src/SchemeObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ namespace SchemeDesigner {
*/
protected height: number;

/**
* Is active
*/
protected active: boolean = true;

/**
* Rotation
*/
Expand Down Expand Up @@ -313,5 +318,23 @@ namespace SchemeDesigner {
{
return this.rotation;
}

/**
* Get is active
* @return {boolean}
*/
public isActive(): boolean
{
return this.active;
}

/**
* Set active
* @param {boolean} value
*/
public setActive(value: boolean): void
{
this.active = value;
}
}
}
7 changes: 6 additions & 1 deletion src/managers/StorageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,17 @@ namespace SchemeDesigner {
// search object in node
for (let layerId in nodeObjectsByLayers) {
let layer = this.getLayerById(layerId);
if (!layer.getActive()) {
if (!layer.isActive()) {
continue;
}

let objects = nodeObjectsByLayers[layerId];
for (let schemeObject of objects) {

if (!schemeObject.isActive()) {
continue;
}

let boundingRect = schemeObject.getBoundingRect();
if (Tools.pointInRect({x: x, y: y}, boundingRect, schemeObject.getRotation())) {
result.push(schemeObject)
Expand Down

0 comments on commit 787057d

Please sign in to comment.