|
@@ -1,3 +1,17 @@
|
|
|
|
+/*
|
|
|
|
+ * iGeom by LInE
|
|
|
|
+ * Free software to student private data
|
|
|
|
+ *
|
|
|
|
+ * http://www.matematica.br/igeom
|
|
|
|
+ * http://www.usp.br/line
|
|
|
|
+ *
|
|
|
|
+ * Starting point of iGeomJS
|
|
|
|
+ *
|
|
|
|
+ * ./app/app.js
|
|
|
|
+ *
|
|
|
|
+ * @version 2020/06/16
|
|
|
|
+ */
|
|
|
|
+
|
|
import { APP_STATE } from "./core/enums/app-state-enum";
|
|
import { APP_STATE } from "./core/enums/app-state-enum";
|
|
import { stageManager as Stages } from "./core/application/stage-manager";
|
|
import { stageManager as Stages } from "./core/application/stage-manager";
|
|
import { objects as Objects } from "./core/application/objects";
|
|
import { objects as Objects } from "./core/application/objects";
|
|
@@ -7,9 +21,17 @@ import { menu as Menu } from "./core/application/menu";
|
|
import Konva from "konva";
|
|
import Konva from "konva";
|
|
import { COMPONENT_TYPE } from "./core/enums/component-type-enum";
|
|
import { COMPONENT_TYPE } from "./core/enums/component-type-enum";
|
|
import { headerMenu } from "./core/application/header-menu";
|
|
import { headerMenu } from "./core/application/header-menu";
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+const iGeomVersion = "2023/08/26";
|
|
|
|
+console.log("app.js: starting iGeomJS version " + iGeomVersion);
|
|
|
|
+
|
|
export const app = (function () {
|
|
export const app = (function () {
|
|
|
|
+
|
|
let _selectedTool = [];
|
|
let _selectedTool = [];
|
|
- function _bootstrap() {
|
|
|
|
|
|
+
|
|
|
|
+ function _bootstrap () {
|
|
|
|
+ console.log("app.js!_bootstrap(): starting");
|
|
Konva.showWarnings = false;
|
|
Konva.showWarnings = false;
|
|
headerMenu.bootstrap();
|
|
headerMenu.bootstrap();
|
|
Selector.bootstrap();
|
|
Selector.bootstrap();
|
|
@@ -18,71 +40,73 @@ export const app = (function () {
|
|
$("body").on("mouseenter", ".li-content", e => $(e.currentTarget).parent().find('.level-1').css("background-color", "#d4d4d4"));
|
|
$("body").on("mouseenter", ".li-content", e => $(e.currentTarget).parent().find('.level-1').css("background-color", "#d4d4d4"));
|
|
$("body").on("mouseleave", ".li-content", e => $(e.currentTarget).parent().find('.level-1').css("background-color", "transparent"));
|
|
$("body").on("mouseleave", ".li-content", e => $(e.currentTarget).parent().find('.level-1').css("background-color", "transparent"));
|
|
;
|
|
;
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- function _currentLayer() {
|
|
|
|
|
|
+ function _currentLayer () {
|
|
return Stages.getCurrentKonvaLayer();
|
|
return Stages.getCurrentKonvaLayer();
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- function _setSelectedTool(tool) {
|
|
|
|
|
|
+ function _setSelectedTool (tool) {
|
|
_clearSelectedTool(tool != undefined);
|
|
_clearSelectedTool(tool != undefined);
|
|
_setState(APP_STATE.TOOL_SELECTED);
|
|
_setState(APP_STATE.TOOL_SELECTED);
|
|
if (tool.options.id != undefined) {
|
|
if (tool.options.id != undefined) {
|
|
document.getElementById("btn-" + tool.options.id).disabled = true;
|
|
document.getElementById("btn-" + tool.options.id).disabled = true;
|
|
- }
|
|
|
|
|
|
+ }
|
|
_selectedTool.push(tool);
|
|
_selectedTool.push(tool);
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- function _clearSelectedTool(force) {
|
|
|
|
|
|
+ function _clearSelectedTool (force) {
|
|
let tool = _getSelectedTool();
|
|
let tool = _getSelectedTool();
|
|
if (tool != undefined) {
|
|
if (tool != undefined) {
|
|
if (!force && tool.options.type == COMPONENT_TYPE.SELECTOR) {
|
|
if (!force && tool.options.type == COMPONENT_TYPE.SELECTOR) {
|
|
return;
|
|
return;
|
|
- }
|
|
|
|
|
|
+ }
|
|
if (tool.options.id != undefined) {
|
|
if (tool.options.id != undefined) {
|
|
document.getElementById("btn-" + tool.options.id).disabled = false;
|
|
document.getElementById("btn-" + tool.options.id).disabled = false;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
_selectedTool = [];
|
|
_selectedTool = [];
|
|
_setStatus("");
|
|
_setStatus("");
|
|
_setState(APP_STATE.NONE);
|
|
_setState(APP_STATE.NONE);
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- function _getSelectedTool() {
|
|
|
|
|
|
+ function _getSelectedTool () {
|
|
if (_selectedTool.length > 0) return _selectedTool[0];
|
|
if (_selectedTool.length > 0) return _selectedTool[0];
|
|
return undefined;
|
|
return undefined;
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- function _getRelativePointerPosition() {
|
|
|
|
|
|
+ function _getRelativePointerPosition () {
|
|
const stage = Stages.getCurrentKonvaStage();
|
|
const stage = Stages.getCurrentKonvaStage();
|
|
return stage.getPointerPosition();
|
|
return stage.getPointerPosition();
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- function _setStatus(status) {
|
|
|
|
|
|
+ function _setStatus (status) {
|
|
document.getElementById("status").innerHTML = status;
|
|
document.getElementById("status").innerHTML = status;
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- function _pushObject(object) {
|
|
|
|
|
|
+ function _pushObject (object) {
|
|
return;
|
|
return;
|
|
Objects.add(object);
|
|
Objects.add(object);
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- function _getObjects() {
|
|
|
|
|
|
+ function _getObjects () {
|
|
return Objects.get();
|
|
return Objects.get();
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- function _setState(e) {
|
|
|
|
|
|
+ function _setState (e) {
|
|
State.setState(e);
|
|
State.setState(e);
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- function _refreshMenu() {
|
|
|
|
|
|
+ function _refreshMenu () {
|
|
Menu.refresh();
|
|
Menu.refresh();
|
|
- }
|
|
|
|
- function requireAll(r) {
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function requireAll (r) {
|
|
r.keys().forEach(r);
|
|
r.keys().forEach(r);
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
_bootstrap();
|
|
_bootstrap();
|
|
|
|
+
|
|
return {
|
|
return {
|
|
stage: Stages.getCurrentKonvaStage,
|
|
stage: Stages.getCurrentKonvaStage,
|
|
currentLayer: _currentLayer,
|
|
currentLayer: _currentLayer,
|
|
@@ -95,5 +119,5 @@ export const app = (function () {
|
|
pushObject: _pushObject,
|
|
pushObject: _pushObject,
|
|
getObjects: _getObjects,
|
|
getObjects: _getObjects,
|
|
setState: _setState
|
|
setState: _setState
|
|
- };
|
|
|
|
-})();
|
|
|
|
|
|
+ };
|
|
|
|
+ })();
|