Commit b6b6ce08 authored by baoshuang's avatar baoshuang

xiugai

parent 3f9e7d2b
...@@ -85,14 +85,28 @@ class ModuleEdit extends Component { ...@@ -85,14 +85,28 @@ class ModuleEdit extends Component {
}, },
editFlag: false,//编辑模式 editFlag: false,//编辑模式
showRightPanel: false, //是否显示右侧详情 showRightPanel: false, //是否显示右侧详情
simpleTipVisible: false //简单提示 simpleTipVisible: false, //简单提示
dragItem: '' //拖动的节点
}; };
this.nativeProps = { this.nativeProps = {
onMouseDown: this.onMouseDown, onMouseDown: this.onMouseDown,
onMouseMove: this.onMouseMove onMouseMove: this.onMouseMove
}; };
this.drowItem = ''; this.drowItem = '';
this.areas = [] this.areas = [],
this.areaStyles = {
normal:{
regionColor: '#02B00F', // 区域颜色
lineColor: '#00FF70', // 边框颜色
regionOpacity: 0.3
},
noDrop:{
regionColor: '#969696', // 区域颜色
lineColor: '#878787', // 边框颜色
regionOpacity: 0.4
}
},
getObjFromNet(view3dFile, (objs, asyncModels) => { getObjFromNet(view3dFile, (objs, asyncModels) => {
this.setState({ this.setState({
...@@ -155,20 +169,20 @@ class ModuleEdit extends Component { ...@@ -155,20 +169,20 @@ class ModuleEdit extends Component {
// eslint-disable-next-line react/sort-comp // eslint-disable-next-line react/sort-comp
_registerEvents = () => { _registerEvents = () => {
this.r3d.on('dbclick', evt => { this.r3d.on('click', evt => {
if (evt.button !== 0) { if (evt.button !== 0) {
return; return;
} }
const object = evt.object; const object = evt.object;
if (object) { if (object) {
this.cameraFactory.flyTo({ // this.cameraFactory.flyTo({
position: object.position.toArray(), // position: object.position.toArray(),
duration: 6000 // duration: 6000
}); // });
} }
}); });
this.r3d.on('keydown', evt => { this.r3d.on('mousedown', evt => {
// 返回上级 // 返回上级
if (this.lensLevel === LENS_LEVEL.SUB && evt.code === 'Backspace') { if (this.lensLevel === LENS_LEVEL.SUB && evt.code === 'Backspace') {
this.lensJumpFactory.jumpRoot(obj => { this.lensJumpFactory.jumpRoot(obj => {
...@@ -194,14 +208,19 @@ class ModuleEdit extends Component { ...@@ -194,14 +208,19 @@ class ModuleEdit extends Component {
} }
this.setState({ totalDelta }); this.setState({ totalDelta });
} }
pointParamsChange = (object, modeType) => {
console.log("zzzzzzzzzzzzzz",object,modeType)
}
onGraphCreated = ({ cameraFactory, sceneFactory, outlineFactory, r3d, stagePilot }) => { onGraphCreated = ({ cameraFactory, sceneFactory, outlineFactory, r3d, stagePilot }) => {
this.cameraFactory = cameraFactory; this.cameraFactory = cameraFactory;
this.sceneFactory = sceneFactory; this.sceneFactory = sceneFactory;
this.outlineFactory = outlineFactory; this.outlineFactory = outlineFactory;
this.r3d = r3d; this.r3d = r3d;
this.polygonRegion = {};
this.stagePilot = stagePilot; this.stagePilot = stagePilot;
this.positionCtl = stagePilot.positionCtl;
this.positionCtl.addListener('changeDone',this.pointParamsChange)
console.log(this)
// 重新设置 outline 风格 // 重新设置 outline 风格
this.outlineFactory.outlineConfig = { this.outlineFactory.outlineConfig = {
visibleEdgeColor: '#f8a303', visibleEdgeColor: '#f8a303',
...@@ -500,17 +519,38 @@ class ModuleEdit extends Component { ...@@ -500,17 +519,38 @@ class ModuleEdit extends Component {
} }
getAreas = (treeData) => { getAreas = (treeData) => {
// let { treeData } = this.state; let { dragItem } = this.state;
// console.log(treeData) // console.log(treeData)
// let areas = []; // let areas = [];
if (treeData&&treeData.length>0) { if (treeData&&treeData.length>0) {
treeData.map((item) => { treeData.map((item) => {
if (item.isRegion && item.isBind) { if (item.isRegion && item.isBind) {
if (item.children&&item.children.length > 0) { if (item.children&&item.children.length > 0) {
this.areas.push(<PolygonRegion points={JSON.parse(item.routePath)} onCreated={this.onRegionCreated}/>) if (dragItem) {
{this.getAreas(item.children)} if ( dragItem.parentId && dragItem.parentId == item.id) {
this.areas.push(<PolygonRegion {...this.areaStyles.normal} points={JSON.parse(item.routePath)} onCreated={(e) => {this.onRegionCreated(e,item)}}/>)
} else {
this.areas.push(<PolygonRegion {...this.areaStyles.noDrop} points={JSON.parse(item.routePath)} onCreated={(e) => {this.onRegionCreated(e,item)}} />)
}
{this.getAreas(item.children)}
} else {
this.areas.push(<PolygonRegion {...this.areaStyles.normal} points={JSON.parse(item.routePath)} onCreated={(e) => {this.onRegionCreated(e,item)}} />)
{this.getAreas(item.children)}
}
}else {
if (dragItem) {
if ( dragItem&&dragItem.parentId && dragItem.parentId == item.id) {
this.areas.push(<PolygonRegion {...this.areaStyles.normal} points={JSON.parse(item.routePath)} onCreated={(e) => {this.onRegionCreated(e,item)}}/>)
} else {
this.areas.push(<PolygonRegion {...this.areaStyles.noDrop} points={JSON.parse(item.routePath)} onCreated={(e) => {this.onRegionCreated(e,item)}} />)
}
} else {
this.areas.push(<PolygonRegion {...this.areaStyles.normal} points={JSON.parse(item.routePath)} onCreated={(e) => {this.onRegionCreated(e,item)}}/>)
}
} }
this.areas.push(<PolygonRegion points={JSON.parse(item.routePath)} onCreated={this.onRegionCreated}/>)
} else { } else {
if (item.children&&item.children.length > 0) { if (item.children&&item.children.length > 0) {
{this.getAreas(item.children)} {this.getAreas(item.children)}
...@@ -522,15 +562,14 @@ class ModuleEdit extends Component { ...@@ -522,15 +562,14 @@ class ModuleEdit extends Component {
renderAreas = () => { renderAreas = () => {
this.areas = []; this.areas = [];
this.getAreas(this.state.treeData); this.getAreas(this.state.treeData);
// console.log(this.areas) console.log(this.areas)
return this.areas; return this.areas;
} }
onRegionCreated = (polygonRegion, item) => { onRegionCreated = (polygonRegion,item) => {
console.log(polygonRegion) console.log(polygonRegion)
console.log(item)
// console.log(polygonRegion.pointInPolygon) // console.log(polygonRegion.pointInPolygon)
this.polygonRegion = polygonRegion; this.polygonRegion[item.id] = polygonRegion;
// console.log(e) console.log(this.polygonRegion)
} }
//保存区域绑定 //保存区域绑定
saveAreaData = () => { saveAreaData = () => {
...@@ -626,6 +665,18 @@ class ModuleEdit extends Component { ...@@ -626,6 +665,18 @@ class ModuleEdit extends Component {
dragItemChange = (dragItem) => { dragItemChange = (dragItem) => {
this.state.dragItem = dragItem; this.state.dragItem = dragItem;
let { treeData } = this.state;
if (dragItem.isRegion) {
//是区域
} else {
if(dragItem.isBind) {
//已绑定
} else {
let hasRegion = false;
}
}
this.setState({ this.setState({
dragItem dragItem
}) })
...@@ -652,13 +703,21 @@ class ModuleEdit extends Component { ...@@ -652,13 +703,21 @@ class ModuleEdit extends Component {
position = objs[0].point; position = objs[0].point;
} }
// [0,0,0] // [0,0,0]
const isInside = this.polygonRegion.pointInPolygon([position.x,position.y,position.z]) const isInside = this.polygonRegion[dragItem.parentId].pointInPolygon([position.x,position.y,position.z])
console.log(this.polygonRegion) console.log(this.polygonRegion)
console.log(objs) console.log(objs)
console.log(position) console.log(position)
console.log(position.x) console.log(position.x)
console.log(isInside) console.log(isInside)
if (dragItem) { if (dragItem) {
if (isInside == false) {
this.tipMsg = '只能放置在当前区域'
this.setState({
simpleTipVisible: true
})
return false;
}
let uid = UUID.uuidFast() let uid = UUID.uuidFast()
let addPointParam = { let addPointParam = {
type: dragItem.type, type: dragItem.type,
...@@ -706,13 +765,28 @@ class ModuleEdit extends Component { ...@@ -706,13 +765,28 @@ class ModuleEdit extends Component {
simpleTipVisible: false simpleTipVisible: false
}) })
} }
/** 拖拽元素外观(位置、缩放、旋转角度)改变 */
onTransformChange = (object, modeType) => {
modeType === 'translate' && (modeType = 'position');
modeType === 'rotate' && (modeType = 'rotation');
const basicAttr = (object.userData || {}).basicAttr;
basicAttr[modeType] = peelXYZFromObj(object, modeType);
const sketchOptions = {
key: 'basicAttr',
value: basicAttr
};
this.props.trigger(EVENTS_CONSTS.SKETCH_PARAMS_CHANGE, {
sketchId: (object.userData || {}).eid,
sketchOptions
});
};
render() { render() {
const { fireEquipmentPosition, drawing, objs, markers, pageType, pointType, pointTypeArr, editFlag, showRightPanel, selectPoints, selectArea } = this.state; const { fireEquipmentPosition, drawing, objs, markers, pageType, pointType, pointTypeArr, editFlag, showRightPanel, selectPoints, selectArea } = this.state;
console.log(this.state) console.log(this.state)
console.log(this.props) console.log(this.props)
console.log(this)
const { dimension } = this.props; const { dimension } = this.props;
const graphicProps = { const graphicProps = {
...dimension, ...dimension,
...@@ -753,6 +827,7 @@ class ModuleEdit extends Component { ...@@ -753,6 +827,7 @@ class ModuleEdit extends Component {
enableModelParser enableModelParser
disabledEdit disabledEdit
defaultLoading={false} defaultLoading={false}
onTransformChange={this.onTransformChange}
ref={node => (this.a3dRef = node)} ref={node => (this.a3dRef = node)}
baseObjs={objs} baseObjs={objs}
drawing={drawing} drawing={drawing}
...@@ -761,7 +836,7 @@ class ModuleEdit extends Component { ...@@ -761,7 +836,7 @@ class ModuleEdit extends Component {
penProps={penProps} penProps={penProps}
enablePositionCtl enablePositionCtl
> >
<PointsPoolEditPage markers={markers} updateMarker={this.updateMarker} stagePilot={this.stagePilot} /> <PointsPoolEditPage markers={markers} updateMarker={this.updateMarker} stagePilot={this.stagePilot} />
{this.renderAreas()} {this.renderAreas()}
</A3DDesigner> </A3DDesigner>
</div> </div>
...@@ -824,7 +899,7 @@ class ModuleEdit extends Component { ...@@ -824,7 +899,7 @@ class ModuleEdit extends Component {
noDefaultHeader noDefaultHeader
// onCancel={this.simpleTipCancel} // onCancel={this.simpleTipCancel}
onOk = {this.simpleTipOk} onOk = {this.simpleTipOk}
content={<div>内容区域...</div>} content={<div>{this.tipMsg}</div>}
/> />
</div> </div>
......
...@@ -59,18 +59,22 @@ class PointsPoolEditPage extends Component { ...@@ -59,18 +59,22 @@ class PointsPoolEditPage extends Component {
// }); // });
} }
onMarkersCreated = (type, { markersCache }) => { onMarkersCreated = (type, { markersCache }) => {
this.markerList[type] = markersCache; this.markerList[type] = markersCache;
let stagePilot = this.props.stagePilot; let stagePilot = this.props.stagePilot;
if(markersCache&&stagePilot) { if(markersCache&&stagePilot) {
console.log(this.markerList) // console.log(this.markerList)
console.log(markersCache) console.log(markersCache)
console.log(this.props) // console.log(this.props)
markersCache.eachValue(item => stagePilot.positionCtl.objects.push(item.node) ) markersCache.eachValue(item => {
item.node._userData = { ...item.extData };
stagePilot.positionCtl.objects.push(item.node); })
} }
(markersCache || []).forEach(mc => { (markersCache || []).forEach(mc => {
const extData = mc.getExtData(); const extData = mc.getExtData();
// console.log('lllllllllllllllll',mc)
if (extData.hasOwnProperty('visible')){ if (extData.hasOwnProperty('visible')){
let visible = extData.visible; let visible = extData.visible;
if (visible) { if (visible) {
......
...@@ -123,7 +123,6 @@ class PointLeftTree extends Component { ...@@ -123,7 +123,6 @@ class PointLeftTree extends Component {
key={item.id} key={item.id}
dataRef={item} dataRef={item}
onDragStart={() => { onDragStart={() => {
console.log(11)
this.props.dragItemChange(item) this.props.dragItemChange(item)
}}> }}>
{this.renderTreeNodes(item.children)} {this.renderTreeNodes(item.children)}
......
...@@ -48,14 +48,20 @@ export default function marker3DFactory(WrappedComponent = 'div', options){ ...@@ -48,14 +48,20 @@ export default function marker3DFactory(WrappedComponent = 'div', options){
this.markerEvents = { this.markerEvents = {
click: this.onMarkerClick, click: this.onMarkerClick,
mouseover: (marker) => { mouseover: (marker) => {
console.log(marker)
marker.object2DPipe.pipeNode.visible = true; marker.object2DPipe.pipeNode.visible = true;
marker.object2DPipe.pipeNode.elementVisible = true; marker.object2DPipe.pipeNode.elementVisible = true;
}, },
mouseout: (marker) => { mouseout: (marker) => {
marker.object2DPipe.pipeNode.visible = false; marker.object2DPipe.pipeNode.visible = false;
marker.object2DPipe.pipeNode.elementVisible = false; marker.object2DPipe.pipeNode.elementVisible = false;
},
mouseup: (evt) => {
console.log('------------------up')
console.log(evt)
} }
}; };
this.state = { this.state = {
isClick: true isClick: true
}; };
...@@ -71,6 +77,7 @@ export default function marker3DFactory(WrappedComponent = 'div', options){ ...@@ -71,6 +77,7 @@ export default function marker3DFactory(WrappedComponent = 'div', options){
onMarkerClick = (marker, e) => { onMarkerClick = (marker, e) => {
const { isClick } = this.state; const { isClick } = this.state;
console.log("---click",marker)
if (isClick) { if (isClick) {
this.setState({ isClick: false }); //将isClick 变成false,将不会执行处理事件 this.setState({ isClick: false }); //将isClick 变成false,将不会执行处理事件
this.pdRef && this.pdRef.onOpenClick(marker); this.pdRef && this.pdRef.onOpenClick(marker);
...@@ -87,6 +94,7 @@ export default function marker3DFactory(WrappedComponent = 'div', options){ ...@@ -87,6 +94,7 @@ export default function marker3DFactory(WrappedComponent = 'div', options){
const { markers, ...rest } = this.props; const { markers, ...rest } = this.props;
const { planStarted } = this.state; const { planStarted } = this.state;
let dialogStyle = { zIndex: 1000 }; let dialogStyle = { zIndex: 1000 };
// console.log('zzzzzzzzzzzzzzzz')
const result = buildMarkerOptions(markers, markerType, markerParams); const result = buildMarkerOptions(markers, markerType, markerParams);
return ( return (
<WrappedComponent> <WrappedComponent>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment