Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On click show cordinates #254

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
46ee93b
React 18.2.0
SenzBruntha Jan 11, 2023
c966001
changes implemented to export and imprt json from apis. changes imple…
ParameswaranSajeenthiran Jan 11, 2023
db78536
store to prop
SenzBruntha Jan 11, 2023
8d748c7
blinking action
ParameswaranSajeenthiran Jan 13, 2023
6896802
'isAdmin'
ParameswaranSajeenthiran Jan 18, 2023
b4f908b
'test'
ParameswaranSajeenthiran Jan 19, 2023
2340c2a
Merge pull request #1 from SenzBruntha/panic-button
SenzBruntha Jan 19, 2023
e1d264d
hard code json
ParameswaranSajeenthiran Jan 19, 2023
aa33031
Merge pull request #2 from SenzBruntha/panic-button
SenzBruntha Jan 19, 2023
dd71302
initial loading bug fix
ParameswaranSajeenthiran Jan 23, 2023
aa1dfe6
Merge pull request #3 from SenzBruntha/panic-button
SenzBruntha Jan 23, 2023
937d1ad
implemented hcnages related to render a text box
ParameswaranSajeenthiran Jan 25, 2023
07528ca
Merge pull request #4 from SenzBruntha/panic-button
SenzBruntha Jan 25, 2023
3aa9c98
removed console.logs
ParameswaranSajeenthiran Jan 26, 2023
e7a3383
changes to thet blinking action and onclick on panic button
ParameswaranSajeenthiran Feb 1, 2023
318bd9d
Merge branch 'master' of https://github.com/SenzBruntha/react-planner…
ParameswaranSajeenthiran Feb 1, 2023
368c1d2
Merge pull request #6 from SenzBruntha/panic-button-v2
SenzBruntha Feb 1, 2023
dfee0e3
'save'
ParameswaranSajeenthiran Feb 1, 2023
480e1c1
Merge pull request #7 from SenzBruntha/panic-button-v2
SenzBruntha Feb 1, 2023
ad845e0
added remove outer circle
ParameswaranSajeenthiran Feb 2, 2023
fda7e18
Merge pull request #8 from SenzBruntha/panic-button-v2
SenzBruntha Feb 2, 2023
33255bd
update-json
ParameswaranSajeenthiran Feb 22, 2023
e83113b
Merge pull request #9 from SenzBruntha/update-json
SenzBruntha Feb 22, 2023
c8b7401
min zoom
ParameswaranSajeenthiran Mar 8, 2023
0ef37f9
Merge pull request #10 from SenzBruntha/minZoom
SenzBruntha Mar 8, 2023
0ae4107
version update
ParameswaranSajeenthiran Mar 8, 2023
37be6b7
on click selected revert
ParameswaranSajeenthiran Mar 10, 2023
10e4cc5
Merge pull request #11 from SenzBruntha/minZoom
SenzBruntha Mar 10, 2023
0850c8f
added console.log
ParameswaranSajeenthiran Mar 13, 2023
ead7b5e
resolved conflict
ParameswaranSajeenthiran Mar 13, 2023
d15c7ee
added logic-to-console log the exact point
ParameswaranSajeenthiran Mar 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion es/components/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export default function Content(_ref) {
height = _ref.height,
state = _ref.state,
customContents = _ref.customContents;
var isAdmin=_ref.isAdmin;
var zoom=_ref.zoom;
var centerX=_ref.centerX;
var centerY=_ref.centerY;

var mode = state.get('mode');

Expand All @@ -39,7 +43,7 @@ export default function Content(_ref) {
case constants.MODE_DRAWING_ITEM:
case constants.MODE_DRAGGING_HOLE:
case constants.MODE_ROTATING_ITEM:
return React.createElement(Viewer2D, { state: state, width: width, height: height });
return React.createElement(Viewer2D, { state: state, width: width, height: height,isAdmin:isAdmin ,zoom:zoom,centerX:centerX,centerY:centerY});

case constants.MODE_CONFIGURING_PROJECT:
return React.createElement(ProjectConfigurator, { width: width, height: height, state: state });
Expand Down
3 changes: 3 additions & 0 deletions es/components/toolbar/toolbar-save-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { FaSave as IconSave } from 'react-icons/fa';
import ToolbarButton from './toolbar-button';
import { browserDownload } from '../../utils/browser';
import { Project } from '../../class/export';
import axios from 'axios';

export default function ToolbarSaveButton(_ref, _ref2) {
var state = _ref.state;
Expand All @@ -13,6 +14,8 @@ export default function ToolbarSaveButton(_ref, _ref2) {
var saveProjectToFile = function saveProjectToFile(e) {
e.preventDefault();
state = Project.unselectAll(state).updatedState;
// axios.post("https://agro.senzmate.com/dev/",json)

browserDownload(state.get('scene').toJS());
};

Expand Down
50 changes: 15 additions & 35 deletions es/components/toolbar/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,21 @@ var Toolbar = function (_Component) {
} },
React.createElement(FaPlus, null)
)
}, {
},
// {
// index: 4, condition: true, dom: React.createElement(
// ToolbarButton,
// {
// active: [MODE_3D_VIEW].includes(mode),
// tooltip: translator.t('3D View'),
// onClick: function onClick(event) {
// return viewer3DActions.selectTool3DView();
// } },
// React.createElement(Icon3D, null)
// )
// },
{
index: 4, condition: true, dom: React.createElement(
ToolbarButton,
{
active: [MODE_3D_VIEW].includes(mode),
tooltip: translator.t('3D View'),
onClick: function onClick(event) {
return viewer3DActions.selectTool3DView();
} },
React.createElement(Icon3D, null)
)
}, {
index: 5, condition: true, dom: React.createElement(
ToolbarButton,
{
active: [MODE_IDLE].includes(mode),
Expand All @@ -161,18 +163,7 @@ var Toolbar = function (_Component) {
[MODE_3D_FIRST_PERSON, MODE_3D_VIEW].includes(mode) ? React.createElement(Icon2D, { style: { color: alterateColor } }) : React.createElement(FaMousePointer, { style: { color: alterateColor } })
)
}, {
index: 6, condition: true, dom: React.createElement(
ToolbarButton,
{
active: [MODE_3D_FIRST_PERSON].includes(mode),
tooltip: translator.t('3D First Person'),
onClick: function onClick(event) {
return viewer3DActions.selectTool3DFirstPerson();
} },
React.createElement(MdDirectionsRun, null)
)
}, {
index: 7, condition: true, dom: React.createElement(
index: 5, condition: true, dom: React.createElement(
ToolbarButton,
{
active: false,
Expand All @@ -182,17 +173,6 @@ var Toolbar = function (_Component) {
} },
React.createElement(MdUndo, null)
)
}, {
index: 8, condition: true, dom: React.createElement(
ToolbarButton,
{
active: [MODE_CONFIGURING_PROJECT].includes(mode),
tooltip: translator.t('Configure project'),
onClick: function onClick(event) {
return projectActions.openProjectConfigurator();
} },
React.createElement(MdSettings, null)
)
}];

sorter = sorter.concat(toolbarButtons.map(function (Component, key) {
Expand Down
4 changes: 2 additions & 2 deletions es/components/viewer2d/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export default function Item(_ref) {
'data-layer': layer.id,
'data-part': 'rotation-anchor'
},
React.createElement('circle', { cx: '0', cy: '150', r: '10', style: STYLE_CIRCLE }),
React.createElement('circle', { cx: '0', cy: '0', r: '150', style: STYLE_CIRCLE2 })
null,
null
)
)
);
Expand Down
4 changes: 3 additions & 1 deletion es/components/viewer2d/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ var Scene = function (_Component) {
var _props = this.props,
scene = _props.scene,
catalog = _props.catalog;

var isAdmin=_props.isAdmin;
var height = scene.height,
layers = scene.layers;

Expand All @@ -40,7 +42,7 @@ var Scene = function (_Component) {
return React.createElement(
'g',
null,
React.createElement(Grids, { scene: scene }),
isAdmin? React.createElement(Grids, { scene: scene }):null,
React.createElement(
'g',
{ style: { pointerEvents: 'none' } },
Expand Down
3 changes: 2 additions & 1 deletion es/components/viewer2d/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function State(_ref) {
scene = state.scene;
var width = scene.width,
height = scene.height;
var isAdmin=_ref.isAdmin;


activeSnapElement = activeSnapElement ? React.createElement(Snap, { snap: activeSnapElement, width: scene.width, height: scene.height }) : null;
Expand All @@ -32,7 +33,7 @@ export default function State(_ref) {
React.createElement(
'g',
{ transform: 'translate(0, ' + scene.height + ') scale(1, -1)', id: 'svg-drawing-paper' },
React.createElement(Scene, { scene: scene, catalog: catalog }),
React.createElement(Scene, { scene: scene, catalog: catalog,isAdmin:isAdmin }),
scene.getIn(['guides', 'horizontal']).entrySeq().map(function (_ref2) {
var _ref3 = _slicedToArray(_ref2, 2),
hgKey = _ref3[0],
Expand Down
35 changes: 28 additions & 7 deletions es/components/viewer2d/viewer2d.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect, useRef } from 'react';
import PropTypes from 'prop-types';

import { ReactSVGPanZoom, TOOL_NONE, TOOL_PAN, TOOL_ZOOM_IN, TOOL_ZOOM_OUT, TOOL_AUTO } from 'react-svg-pan-zoom';
Expand Down Expand Up @@ -92,6 +92,13 @@ export default function Viewer2D(_ref, _ref2) {
var state = _ref.state,
width = _ref.width,
height = _ref.height;
var isAdmin=_ref.isAdmin;
var zoom=_ref.zoom;

var centerX=_ref.centerX;

var centerY=_ref.centerY;

var viewer2DActions = _ref2.viewer2DActions,
linesActions = _ref2.linesActions,
holesActions = _ref2.holesActions,
Expand All @@ -106,7 +113,13 @@ export default function Viewer2D(_ref, _ref2) {


var layerID = scene.selectedLayer;
const Viewer=useRef(null)
useEffect(()=>{

console.log(Viewer.current)
Viewer.current.zoom(centerX,centerY,zoom);

},[zoom])
var mapCursorPosition = function mapCursorPosition(_ref3) {
var x = _ref3.x,
y = _ref3.y;
Expand Down Expand Up @@ -175,6 +188,8 @@ export default function Viewer2D(_ref, _ref2) {
var _mapCursorPosition2 = mapCursorPosition(viewerEvent),
x = _mapCursorPosition2.x,
y = _mapCursorPosition2.y;
console.log("x=",_mapCursorPosition2.x)
console.log("y=",_mapCursorPosition2.y)

if (mode === constants.MODE_IDLE) {
var elementData = extractElementData(event.target);
Expand Down Expand Up @@ -340,8 +355,8 @@ export default function Viewer2D(_ref, _ref2) {
gridTemplateRows: rulerSize + 'px ' + (height - rulerSize) + 'px',
position: 'relative'
} },
React.createElement('div', { style: { gridColumn: 1, gridRow: 1, backgroundColor: rulerBgColor } }),
React.createElement(
isAdmin? React.createElement('div', { style: { gridColumn: 1, gridRow: 1, backgroundColor: rulerBgColor } }):null,
isAdmin? React.createElement(
'div',
{ style: { gridRow: 1, gridColumn: 2, position: 'relative', overflow: 'hidden' }, id: 'rulerX' },
sceneWidth ? React.createElement(RulerX, {
Expand All @@ -356,8 +371,8 @@ export default function Viewer2D(_ref, _ref2) {
positiveUnitsNumber: rulerXElements,
negativeUnitsNumber: 0
}) : null
),
React.createElement(
):null,
isAdmin? React.createElement(
'div',
{ style: { gridColumn: 1, gridRow: 2, position: 'relative', overflow: 'hidden' }, id: 'rulerY' },
sceneHeight ? React.createElement(RulerY, {
Expand All @@ -372,7 +387,7 @@ export default function Viewer2D(_ref, _ref2) {
positiveUnitsNumber: rulerYElements,
negativeUnitsNumber: 0
}) : null
),
):null,
React.createElement(
ReactSVGPanZoom,
{
Expand All @@ -382,13 +397,19 @@ export default function Viewer2D(_ref, _ref2) {
value: viewer2D.isEmpty() ? null : viewer2D.toJS(),
onChangeValue: onChangeValue,
tool: mode2Tool(mode),
scaleFactor :0.4,
scaleFactorMin:0.4,
onChangeTool: onChangeTool,
detectAutoPan: mode2DetectAutopan(mode),
onMouseDown: onMouseDown,
onMouseMove: onMouseMove,
onMouseUp: onMouseUp,
background:'white',
miniatureBackground:'white',
miniaturePosition: 'none',
toolbarPosition: 'none'
toolbarPosition: 'none',
ref: Viewer

},
React.createElement(
'svg',
Expand Down
64 changes: 57 additions & 7 deletions es/plugins/autosave.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var TIMEOUT_DELAY = 500;

var timeout = null;

export default function autosave(autosaveKey, delay) {
export default function autosave(autosaveKey, delay,selectPanicButton,plan) {

return function (store, stateExtractor) {

Expand All @@ -15,24 +15,74 @@ export default function autosave(autosaveKey, delay) {
if (!localStorage) return;

//revert
if (localStorage.getItem(autosaveKey) !== null) {
var data = localStorage.getItem(autosaveKey);
var json = JSON.parse(data);
store.dispatch(loadProject(json));
}
// var data = localStorage.getItem(autosaveKey);
// var json = JSON.parse(data);
// console.log(plan,"plan")
// store.dispatch(loadProject(plan));


//update
store.subscribe(function () {
if (timeout) clearTimeout(timeout);
timeout = setTimeout(function () {
var state = stateExtractor(store.getState());
let json=state.scene.toJS()
console.log(state.scene.toJS(),"state")
localStorage.setItem(autosaveKey, JSON.stringify(state.scene.toJS()));


let items =json["layers"]["layer-1"]["items"]
for (var key in items) {
let item= items[key]

if (item["selected"]==true){
selectPanicButton(item["id"],false)


// store.dispatch(loadProject(json));




}


}


let areas=json["layers"]["layer-1"]["areas"]


for (var key in areas) {
let area= areas[key]

if (area["selected"]==true){
let vertices=area["vertices"]
let x=0
let y=0
// console.log("vertices",vertices)
vertices.map((vertex)=>{
x+=json["layers"]["layer-1"]["vertices"][vertex]["x"]
y+=json["layers"]["layer-1"]["vertices"][vertex]["y"]

})

// console.log("x= ",x/vertices.length,"y= ",y/vertices.length)



// store.dispatch(loadProject(json));



}
}
/*let scene = state.sceneHistory.last;
if (scene) {
let json = JSON.stringify(scene.toJS());
localStorage.setItem(autosaveKey, json);
}*/
}, delay);
}, 100);
});
};
}
27 changes: 18 additions & 9 deletions es/react-planner.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var ReactPlanner = function (_Component) {
}, {
key: 'componentWillMount',
value: function componentWillMount() {
var store = this.context.store;
var store = this.props.store;
var _props = this.props,
projectActions = _props.projectActions,
catalog = _props.catalog,
Expand Down Expand Up @@ -94,6 +94,11 @@ var ReactPlanner = function (_Component) {
width = _props2.width,
height = _props2.height,
state = _props2.state,
isAdmin=_props2.isAdmin,
zoom=_props2.zoom,
centerX=_props2.centerX,
centerY=_props2.centerY,

stateExtractor = _props2.stateExtractor,
props = _objectWithoutProperties(_props2, ['width', 'height', 'state', 'stateExtractor']);

Expand All @@ -107,12 +112,12 @@ var ReactPlanner = function (_Component) {
return React.createElement(
'div',
{ style: _extends({}, wrapperStyle, { height: height }) },
React.createElement(Toolbar, _extends({ width: toolbarW, height: toolbarH, state: extractedState }, props)),
React.createElement(Content, _extends({ width: contentW, height: contentH, state: extractedState }, props, { onWheel: function onWheel(event) {
this.props.isAdmin? React.createElement(Toolbar, _extends({ width: toolbarW, height: toolbarH, state: extractedState }, props)):null,
React.createElement(Content, _extends({ width: contentW, height: contentH, state: extractedState,isAdmin:isAdmin ,zoom:zoom,centerX:centerX,centerY:centerY}, props, { onWheel: function onWheel(event) {
return event.preventDefault();
} })),
React.createElement(Sidebar, _extends({ width: sidebarW, height: sidebarH, state: extractedState }, props)),
React.createElement(FooterBar, _extends({ width: width, height: footerBarH, state: extractedState }, props))
this.props.isAdmin? React.createElement(Sidebar, _extends({ width: sidebarW, height: sidebarH, state: extractedState }, props)):null,
this.props.isAdmin? React.createElement(FooterBar, _extends({ width: width, height: footerBarH, state: extractedState }, props)):null
);
}
}]);
Expand All @@ -134,12 +139,16 @@ ReactPlanner.propTypes = {
sidebarComponents: PropTypes.array,
footerbarComponents: PropTypes.array,
customContents: PropTypes.object,
softwareSignature: PropTypes.string
softwareSignature: PropTypes.string,
isAdmin:PropTypes.bool,
zoom:PropTypes.number,
centerX:PropTypes.number,
centerY:PropTypes.number
};

ReactPlanner.contextTypes = {
store: PropTypes.object.isRequired
};
// ReactPlanner.contextTypes = {
// store: PropTypes.object.isRequired
// };

ReactPlanner.childContextTypes = _extends({}, objectsMap(actions, function () {
return PropTypes.object;
Expand Down
Loading