def onChanged(self, obj, prop): ''' Do something when a data property has changed. ''' if prop == "Points": points = obj.getPropertyByName("Points") if points: origin = geo_origin.get(points[0])
def onOk(self): # Find latest version of temp.txt which contains the chosen coordinates filenames = [] filestamps = [] for filename in os.listdir(self.tempFolderPath): if filename.endswith(".txt"): filenames.append(filename) i = os.path.getmtime(self.tempFolderPath + "/" + filename) filestamps.append( time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(i))) latest = max(filestamps) indexof = filestamps.index(latest) latestfile = filenames[indexof] filepathTempfileLATLONData = self.tempFolderPath + "/" + latestfile #most recent file tempFileCoordinates = open(filepathTempfileLATLONData, "r") CoordinatesString = tempFileCoordinates.read() tempFileCoordinates.close() strsplit = re.split("[(, )]", CoordinatesString) self.lat = strsplit[1] self.lon = strsplit[3] SiteObject = GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename) CRS_EPSG_SRID = SiteObject.CRS_EPSG_SRID = GIS2BIM_CRS.inputChars[ self.cboCRS.currentIndex()] SiteObject.WGS84_Longitude = self.lon SiteObject.WGS84_Latitude = self.lat SiteObject.Longitude = float(self.lon) SiteObject.Latitude = float(self.lat) Transformation = GIS2BIM.TransformCRS_epsg("4326", CRS_EPSG_SRID, self.lon, self.lat) SiteObject.CRS_x = float(Transformation[0]) SiteObject.CRS_y = float(Transformation[1]) SiteObject.BoundingboxWidth = float(self.bboxWidth.text()) SiteObject.BoundingboxHeight = float(self.bboxHeight.text()) SiteObject.CRS_EPSG_Description = GIS2BIM_CRS.getCRSdata(CRS_EPSG_SRID) #Set GeoOrigin if self.CBGeoOrigin.isChecked() is True: obj = geo_origin.get() obj.Origin = FreeCAD.Vector( float(Transformation[0]) * 1000, float(Transformation[1]) * 1000, 0) if self.CBAerialphoto.isChecked() is True: fileLocationTMS = self.tempFolderPath + 'ESRI_aerialphoto.jpg' TMS = GIS2BIM.TMS_WMTSCombinedMapFromLatLonBbox( float(self.lat), float(self.lon), float(self.bboxWidth.text()), float(self.bboxHeight.text()), 17, 256, 0, "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}.png" ) TMS[0].save(fileLocationTMS) ImageMap = GIS2BIM_FreeCAD.ImportImage( fileLocationTMS, float(self.bboxWidth.text()), float(self.bboxHeight.text()), 1000, "ESRI aerialMap", 0, 0) GIS2BIM_FreeCAD.CreateLayer("GIS_Raster") FreeCAD.ActiveDocument.recompute() FreeCAD.activeDocument().getObject("GIS_Raster").addObject( FreeCAD.activeDocument().getObject(ImageMap.Label)) self.close()
def create(): """ Factory method for Surfaces. """ main = geo_origin.get() obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython", 'Surfaces') obj.Label = "Surfaces" Surfaces(obj) ViewProviderSurfaces(obj.ViewObject) main.addObject(obj) FreeCAD.ActiveDocument.recompute() return obj
def onChanged(self, obj, prop): ''' Do something when a data property has changed. ''' points = [] pgs = obj.getPropertyByName("PointGroups") for pg in pgs: points.extend(pg.Points) if points: origin = geo_origin.get(points[0]) else: origin = geo_origin.get() if prop =="PointGroups": if len(points) > 2: obj.Delaunay = self.triangulate(points) else: obj.Mesh = Mesh.Mesh() if prop == "Delaunay" or prop == "MaxLength" or prop == "MaxAngle": delaunay = obj.getPropertyByName("Delaunay") lmax = obj.getPropertyByName("MaxLength") amax = obj.getPropertyByName("MaxAngle") if delaunay: obj.Mesh = self.test_delaunay( origin.Origin, points, delaunay, lmax, amax) if prop == "Mesh" or prop == "ContourInterval": deltaH = obj.getPropertyByName("ContourInterval") mesh = obj.getPropertyByName("Mesh") coords, num_vert = self.contour_points(origin.Origin, mesh, deltaH) obj.ContourPoints = coords obj.ContourVertices = num_vert
def updateData(self, obj, prop): ''' Update Object visuals when a data property changed. ''' if prop == "Points": points = obj.getPropertyByName("Points") if points: origin = geo_origin.get(points[0]) geo_system = ["UTM", origin.UtmZone, "FLAT"] self.geo_coords.geoSystem.setValues(geo_system) self.geo_coords.point.values = points if prop == "Marker": marker = obj.getPropertyByName("Marker") self.markers.markerIndex = marker_dict[marker]
def onChanged(self, vobj, prop): ''' Update Object visuals when a view property changed. ''' labels = vobj.getPropertyByName("Labels") self.point_labels.removeAllChildren() if labels: if prop == "Labels" or prop == "Name" or prop == "NortingEasting"\ or prop == "Elevation" or prop == "Description": origin = geo_origin.get(vobj.Object.Points[0]) show_name = vobj.getPropertyByName("Name") show_ne = vobj.getPropertyByName("NortingEasting") show_z = vobj.getPropertyByName("Elevation") show_des = vobj.getPropertyByName("Description") for vector in vobj.Object.Points: font = coin.SoFont() font.size = 1000 point_label = coin.SoSeparator() location = coin.SoTranslation() text = coin.SoAsciiText() index = vobj.Object.Points.index(vector) labels =[] if show_name: labels.append(vobj.Object.PointNames[index]) if show_ne: labels.extend([str(round(vector.x/1000, 3)), str(round(vector.y/1000,3))]) if show_z: labels.append(str(round(vector.z/1000,3))) if show_des and vobj.Object.Descriptions: labels.append(vobj.Object.Descriptions[index]) location.translation = vector.sub(FreeCAD.Vector(origin.Origin.x, origin.Origin.y, 0)) text.string.setValues(labels) point_label.addChild(font) point_label.addChild(location) point_label.addChild(text) self.point_labels.addChild(point_label) if prop == "PointSize": size = vobj.getPropertyByName("PointSize") self.point_style.pointSize = size if prop == "PointColor": color = vobj.getPropertyByName("PointColor") self.color_mat.diffuseColor = (color[0],color[1],color[2])
def onOk(self): # Find latest version of temp.txt which contains the chosen coordinates filenames = [] filestamps = [] for filename in os.listdir(self.tempFolderPath): if filename.endswith(".txt"): filenames.append(filename) i = os.path.getmtime(self.tempFolderPath + "/" + filename) filestamps.append( time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(i))) latest = max(filestamps) indexof = filestamps.index(latest) latestfile = filenames[indexof] filepathTempfileLATLONData = self.tempFolderPath + "/" + latestfile #most recent file tempFileCoordinates = open(filepathTempfileLATLONData, "r") CoordinatesString = tempFileCoordinates.read() tempFileCoordinates.close() strsplit = re.split("[(, )]", CoordinatesString) self.lat = strsplit[1] self.lon = strsplit[3] SiteObject = GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename) CRS_EPSG_SRID = SiteObject.CRS_EPSG_SRID = GIS2BIM_CRS.inputChars[ self.cboCRS.currentIndex()] SiteObject.WGS84_Longitude = self.lon SiteObject.WGS84_Latitude = self.lat SiteObject.Longitude = float(self.lon) SiteObject.Latitude = float(self.lat) Transformation = GIS2BIM.TransformCRS_epsg("4326", CRS_EPSG_SRID, self.lon, self.lat) SiteObject.CRS_x = float(Transformation[0]) SiteObject.CRS_y = float(Transformation[1]) SiteObject.BoundingboxWidth = float(self.bboxWidth.text()) SiteObject.BoundingboxHeight = float(self.bboxHeight.text()) SiteObject.CRS_EPSG_Description = GIS2BIM_CRS.getCRSdata(CRS_EPSG_SRID) #Set GeoOrigin if self.CBGeoOrigin: obj = geo_origin.get() obj.Origin = FreeCAD.Vector( float(Transformation[0]) * 1000, float(Transformation[1]) * 1000, 0) self.close()
def create(): """ Factory method for alignment group """ #return an existing instance of the same name, if found obj = App.ActiveDocument.getObject('Alignments') if obj: return obj.Proxy main = geo_origin.get() obj = App.ActiveDocument.addObject("App::DocumentObjectGroupPython", 'Alignments') fpo = _AlignmentGroup(obj) _ViewProviderAlignmentGroup(obj.ViewObject) main.addObject(obj) return fpo
def updateData(self, obj, prop): ''' Update Object visuals when a data property changed. ''' if prop == "Mesh": mesh = obj.getPropertyByName("Mesh") topo_points = mesh.Topology[0] topo_tri = mesh.Topology[1] # Get GeoOrigin. points = [] triangles = [] origin = geo_origin.get() base = copy.deepcopy(origin.Origin) base.z = 0 for i in topo_points: point = copy.deepcopy(i) points.append(point.add(base)) for i in topo_tri: triangles.extend(list(i)) triangles.append(-1) # Set GeoCoords. geo_system = ["UTM", origin.UtmZone, "FLAT"] self.geo_coords.geoSystem.setValues(geo_system) self.geo_coords.point.values = points #Set contour system. self.cont_coords.geoSystem.setValues(geo_system) self.triangles.coordIndex.values = triangles if prop == "Mesh" or prop == "ContourInterval": cont_points = obj.getPropertyByName("ContourPoints") cont_vert = obj.getPropertyByName("ContourVertices") self.cont_coords.point.values = cont_points self.cont_lines.numVertices.values = cont_vert
def create(): """ Factory method for Guide Line Clusters. """ main = geo_origin.get() alignments = FreeCAD.ActiveDocument.getObject('Alignments') alignment_group = FreeCAD.ActiveDocument.getObject('AlignmentGroup') if alignments: alignment_group = alignments elif not alignment_group: alignment_group = FreeCAD.ActiveDocument.addObject( "App::DocumentObjectGroup", 'AlignmentGroup') alignment_group.Label = "Alignment Group" main.addObject(alignment_group) obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython", 'GuideLineClusters') obj.Label = "Guide Line Clusters" alignment_group.addObject(obj) GuideLineClusters(obj) ViewProviderGuideLineClusters(obj.ViewObject) FreeCAD.ActiveDocument.recompute() return obj