Skip to content

Commit

Permalink
Viewer Panel reads from all feature properties
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman committed Jun 19, 2024
1 parent b278f6c commit 66b0e55
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 39 deletions.
21 changes: 21 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"react-chartjs-2": "^3.3.0",
"react-dom": "^16.13.1",
"react-pdf": "^7.7.3",
"react-resize-detector": "^7.1.2",
"resolve": "1.15.0",
"resolve-url-loader": "^5.0.0",
"semver": "6.3",
Expand Down
73 changes: 42 additions & 31 deletions src/essence/Basics/Layers_/Layers_.js
Original file line number Diff line number Diff line change
Expand Up @@ -3323,37 +3323,48 @@ const L_ = {
}
}
}
//If there isn't one, search all string valued props for image urls
else {
for (var p in props) {
if (
typeof props[p] === 'string' &&
props[p].toLowerCase().match(/\.(jpeg|jpg|gif|png|xml)$/) !=
null
) {
var url = props[p]
if (!F_.isUrlAbsolute(url)) url = L_.missionPath + url
images.push({
url: url,
name: p,
isPanoramic: false,
isModel: false,
})
}
if (
typeof props[p] === 'string' &&
(props[p].toLowerCase().match(/\.(obj)$/) != null ||
props[p].toLowerCase().match(/\.(dae)$/) != null)
) {
var url = props[p]
if (!F_.isUrlAbsolute(url)) url = L_.missionPath + url
images.push({
url: url,
name: p,
isPanoramic: false,
isModel: true,
})
}
//Now search all string valued props for image urls

for (let p in props) {
if (
typeof props[p] === 'string' &&
props[p].toLowerCase().match(/\.(jpeg|jpg|gif|png|xml)$/) !=
null
) {
let url = props[p]
if (!F_.isUrlAbsolute(url)) url = L_.missionPath + url
images.push({
url: url,
name: p,
isPanoramic: false,
isModel: false,
})
} else if (
typeof props[p] === 'string' &&
props[p].toLowerCase().match(/\.(pdf)$/) != null
) {
let url = props[p]
if (!F_.isUrlAbsolute(url)) url = L_.missionPath + url
images.push({
url: url,
name: p,
type: 'document',
isPanoramic: false,
isModel: false,
})
} else if (
typeof props[p] === 'string' &&
(props[p].toLowerCase().match(/\.(obj)$/) != null ||
props[p].toLowerCase().match(/\.(dae)$/) != null)
) {
let url = props[p]
if (!F_.isUrlAbsolute(url)) url = L_.missionPath + url
images.push({
url: url,
name: p,
isPanoramic: false,
isModel: true,
})
}
}

Expand Down
19 changes: 13 additions & 6 deletions src/essence/Basics/Viewer_/PDFViewer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { render } from 'react-dom'
import React, { useState, useEffect } from 'react'
import { Document, Page, pdfjs } from 'react-pdf'
import { useResizeDetector } from 'react-resize-detector'

import 'react-pdf/dist/Page/AnnotationLayer.css'
import 'react-pdf/dist/Page/TextLayer.css'

Expand All @@ -14,25 +16,30 @@ const ReactPDF = (props) => {
const zoomLevels = [0.25, 0.5, 0.75, 1, 1.25, 1.5, 2, 2.5, 3, 4, 5]
const [zoom, setZoom] = useState(3)

function onDocumentLoadSuccess({ numPages }: { numPages: number }): void {
setNumPages(numPages)
}
const { width, height, ref } = useResizeDetector({
handleHeight: false,
refreshMode: 'debounce',
refreshRate: 1000,
})

useEffect(() => {
setZoom(3)
}, [pdfPath])

function onDocumentLoadSuccess({ numPages }: { numPages: number }): void {
setNumPages(numPages)
}
const bcr = document
.getElementById('pdfViewerWrapper')
.getBoundingClientRect()
const width = bcr ? bcr.width - 40 : null
const pageWidth = bcr ? bcr.width - 40 : null
return (
<div>
<div ref={ref}>
<Document file={pdfPath} onLoadSuccess={onDocumentLoadSuccess}>
<Page
pageNumber={pageNumber}
scale={zoomLevels[zoom]}
width={width}
width={pageWidth}
onRenderSuccess={() => {
const container =
document.getElementById('pdfViewerWrapper')
Expand Down
2 changes: 2 additions & 0 deletions src/essence/Tools/Draw/DrawTool_Editing.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var Editing = {
DrawTool.cmLayerMove = Editing.cmLayerMove
},
removeContextMenu: function () {
if (DrawTool.contextMenuLayer)
DrawTool.contextMenuLayer.dragging = false
$('.drawToolContextMenu').remove()
UserInterface_.closeRightPanel()
},
Expand Down
7 changes: 6 additions & 1 deletion src/essence/Tools/Draw/DrawTool_Shapes.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,12 @@ var Shapes = {
$('#drawToolMouseoverText').addClass('active')
$('#drawToolMouseoverText').css({
top: centerPx.y,
left: centerPx.x + 310,
left:
centerPx.x +
20 +
document
.getElementById('mapScreen')
.getBoundingClientRect().left,
})
}
})(layer, index)
Expand Down
2 changes: 1 addition & 1 deletion src/essence/Tools/Draw/DrawTool_Templater.js
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ const DrawTool_Templater = {
typeMarkup = [
`<div class='drawToolTemplaterLiBody_${type}'>`,
`<div class='drawToolTemplaterLiBody_${type}_default'>`,
`<div>Value with a single '#' to place an incrementing number: </div>`,
`<div>Value with single '#' to place incrementing number: </div>`,
`<input id='drawToolTemplaterLiFieldInput_${idx}_default' placeholder='ID-#' type='text' value='${opts.default != null ? opts.default : ''}'></input>`,
"</div>",
"</div>"
Expand Down

0 comments on commit 66b0e55

Please sign in to comment.