def main(): import sys QCoreApplication.setOrganizationName("QtExamples") QApplication.setAttribute(Qt.AA_EnableHighDpiScaling) WebUiHandler.registerUrlScheme() app = QApplication(sys.argv) profile = QWebEngineProfile() handler = WebUiHandler() profile.installUrlSchemeHandler(WebUiHandler.schemeName, handler) page = QWebEnginePage(profile) page.load(WebUiHandler.aboutUrl) view = QWebEngineView() view.setPage(page) view.setContextMenuPolicy(Qt.NoContextMenu) view.resize(500, 600) view.show() sys.exit(app.exec_())
class GISOSM_Dialog(QtWidgets.QDialog): def __init__(self, parent=None): super(GISOSM_Dialog, self).__init__(parent) self.sitename = "GIS-Sitedata" #Get/set parameters for GIS self.tempFolderName = "GIStemp/" self.lat = str( GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).WGS84_Latitude) self.lon = str( GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).WGS84_Longitude) self.bboxWidthStart = str( GIS2BIM_FreeCAD.ArchSiteCreateCheck( self.sitename).BoundingboxWidth) self.bboxHeightStart = str( GIS2BIM_FreeCAD.ArchSiteCreateCheck( self.sitename).BoundingboxHeight) #Set Style self.setStyleSheet( "QWidget {background-color: rgb(68, 68, 68)} QPushButton { background-color: black } QGroupBox {border: 1px solid grey; }" ) #margin: 2px; #Download files self.URLmap = GIS2BIM.GetWebServerData("HTMLwfs", "Other", "URL") #self.filepathBaseMap = GIS2BIM.DownloadURL(GIS2BIM_FreeCAD.CreateTempFolder(self.tempFolderName),self.URLmap,"basemapWFS.html") #Basemap from GIS2BIM Repository for preview #self.filepathNewMap = GIS2BIM.DownloadURL(GIS2BIM_FreeCAD.CreateTempFolder(self.tempFolderName),self.URLmap,"mapWFS.html") #Edited Basemap with location and bbox self.filepathBaseMap = "C:/Users/mikev/OneDrive/Bureaublad/TEMP/GIStemp/basemapWFS.html" self.filepathNewMap = "C:/Users/mikev/OneDrive/Bureaublad/TEMP/GIStemp/mapWFS.html" self.tempFolderPath = GIS2BIM_FreeCAD.CreateTempFolder( self.tempFolderName) os.remove(self.filepathNewMap) BaseMap = open(self.filepathBaseMap, "r") BaseMapstr = BaseMap.read() Newstr = BaseMapstr.replace("51LAT", str(self.lat)) Newstr = Newstr.replace("4LONG", str(self.lon)) Newstr = Newstr.replace("WBBOX", self.bboxWidthStart) Newstr = Newstr.replace("HBBOX", self.bboxHeightStart) open(self.filepathNewMap, "x") f1 = open(self.filepathNewMap, "w") f1.write(Newstr) f1.close() #Overall Grid grid = QtWidgets.QGridLayout() grid.addWidget(self.webViewGroup(), 0, 0, 1, 2) grid.addWidget(self.locationGroup(), 3, 0, QtCore.Qt.AlignTop) grid.addLayout(self.buttonGroup(), 4, 0, 1, 2) grid.setRowStretch(0, 2) self.setLayout(grid) self.setWindowTitle("Load 2D Vector Data with WFS(Web Feature Server)") self.resize(920, 910) def webViewGroup(self): groupBox = QtWidgets.QGroupBox("Map") groupBox.setStyleSheet("QGroupBox {border: 1px solid grey;}") radio1 = QtWidgets.QRadioButton("&Radio button 1") radio1.setChecked(True) webFrame = QFrame() webFrame.setFrameShape(QFrame.StyledPanel) vbox = QtWidgets.QVBoxLayout() groupBox.setLayout(vbox) self.webView = QWebEngineView() self.webPage = QWebEnginePage() self.webPage.load(QUrl(QtCore.QUrl(self.filepathNewMap))) self.webView.setObjectName("webView") self.webView.setPage(self.webPage) self.webView.show() vbox.addWidget(self.webView) return groupBox def locationGroup(self): groupBox = QtWidgets.QGroupBox("Location / Boundingbox") latLonLab = QtWidgets.QLabel("lat/lon (WGS-84)") latLon = QtWidgets.QLabel("lat: " + self.lat + ", lon: " + self.lon) bboxWidthLab = QtWidgets.QLabel("Boundingbox Width [m]") self.bboxWidth = QtWidgets.QLineEdit() self.bboxWidth.setText(self.bboxWidthStart) self.bboxWidth.editingFinished.connect(self.onbboxWidth) bboxHeightLab = QtWidgets.QLabel("Boundingbox Height [m]") self.bboxHeight = QtWidgets.QLineEdit() self.bboxHeight.setText(self.bboxHeightStart) self.bboxHeight.editingFinished.connect(self.onbboxHeight) grid = QtWidgets.QGridLayout() grid.addWidget(latLonLab, 0, 0) grid.addWidget(latLon, 0, 1) grid.addWidget(CRSLab, 1, 0) grid.addWidget(CRSText, 1, 1) grid.addWidget(bboxWidthLab, 2, 0) grid.addWidget(self.bboxWidth, 2, 1) grid.addWidget(bboxHeightLab, 3, 0) grid.addWidget(self.bboxHeight, 3, 1) groupBox.setLayout(grid) groupBox.setStyleSheet("QGroupBox {border: 1px solid grey;}") return groupBox def buttonGroup(self): importbtn = QtWidgets.QPushButton("Import") importbtn.clicked.connect(self.onImport) cancelbtn = QtWidgets.QPushButton("Cancel") cancelbtn.clicked.connect(self.onCancel) hbox = QtWidgets.QHBoxLayout() hbox.addWidget(importbtn) hbox.addWidget(cancelbtn) return hbox def onbboxWidth(self): JS2 = open(self.filepathJSUpdate, "r") JS2 = JS2.read() JS2 = JS2.replace("WBBOX", self.bboxWidth.text()) JS2 = JS2.replace("HBBOX", self.bboxHeight.text()) self.webPage.runJavaScript(JS2) # update bboxWidth in mapview self.testWFS() def onbboxHeight(self): JS3 = open(self.filepathJSUpdate, "r") JS3 = JS3.read() JS3 = JS3.replace("WBBOX", self.bboxWidth.text()) JS3 = JS3.replace("HBBOX", self.bboxHeight.text()) self.webPage.runJavaScript(JS3) # update bboxHeight in mapview self.testWFS() def onImport(self): self.bboxString = GIS2BIM.CreateBoundingBox( float(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_x), float(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_y), float(self.bboxWidth.text()), float(self.bboxHeight.text()), 2) url = self.request.text() xpathstr = self.xPathStr.text() closedValue = self.clsPolygon.isChecked() makeFaceValue = self.clsCreateFace.isChecked() drawStyle = str(self.linePattern.currentText()) Curves = GIS2BIM_FreeCAD.CurvesFromWFS(url, self.bboxString, xpathstr, -float(self.X), -float(self.Y), 1000, 3, closedValue, makeFaceValue, drawStyle, (0.7, 0.0, 0.0)) GIS2BIM_FreeCAD.CreateLayer(self.groupName.text()) FreeCAD.activeDocument().getObject( self.groupName.text()).addObjects(Curves) FreeCAD.ActiveDocument.recompute() self.close() def onCancel(self): self.close()