This commit is contained in:
2025-03-28 19:40:11 +06:00
parent af559092bf
commit 1d062a087f
26 changed files with 360 additions and 514 deletions

View File

@@ -47,16 +47,16 @@ except AttributeError:
import PVPlantResources
def makeCable(base = None):
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "Cable")
def makeCable(name="Cable"):
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", name)
obj.Label = name
Cable(obj)
ViewProviderCable(obj.ViewObject)
if base:
obj.Base = base
return obj
class Cable(ArchComponent.Component):
"A Base Frame Obcject - Class"
"A Cable Obcject - Class"
def __init__(self, obj):
ArchComponent.Component.__init__(self, obj)
@@ -254,48 +254,10 @@ class Cable(ArchComponent.Component):
return val.Placement.Base
def execute(self, obj):
import Part, DraftGeomUtils
import Draft
if obj.Base:
w = obj.Base.Shape.SubShapes[1].SubShapes[0]
w = DraftGeomUtils.filletWire(w, 150)
else:
return
"""if obj.Base:
# Si tiene ruta, dibujar ruteado
import PVPlantTrench as trench
if isinstance(obj.Base, trench.Trench):
w = obj.Base.Shape.SubShapes[0]
else:
w = obj.Base.Shape
elif obj.From and obj.Name:
'''line = Part.LineSegment()
line.StartPoint = getPoint(obj.From)
line.EndPoint = getPoint(obj.To)
w = Part.Wire(line.toShape())'''
w = Part.makePolygon([self.getPoint(obj.From), self.getPoint(obj.To)])
else:
return"""
r = obj.ExternalDiameter.Value / 2
p = Part.Wire([Part.Circle(FreeCAD.Vector(0, 0, 0),
FreeCAD.Vector(0, 1, 0),
r).toShape()])
c = obj.Offset
c.x -= r
c.z += r
v1 = w.Vertexes[1].Point - w.Vertexes[0].Point
v2 = DraftGeomUtils.getNormal(p)
p.Placement.Base = w.Vertexes[0].Point + c
p.Placement.Rotation = FreeCAD.Rotation(v2, v1)
obj.Shape = w.makePipeShell([p], True, False, 0)
obj.Distance = w.Length
''' No hacer nada. Es un componente sin shape'''
class ViewProviderCable(ArchComponent.ViewProviderComponent):
class ViewProviderCable(ArchComponent.ViewProviderComponent): #hace falta??
def __init__(self, vobj):
ArchComponent.ViewProviderComponent.__init__(self, vobj)
@@ -311,15 +273,7 @@ class CommandCable:
'ToolTip': QT_TRANSLATE_NOOP("Placement", "Calcular el BOQ de la")}
def Activated(self):
import Draft
sel = FreeCADGui.Selection.getSelection()
wire = None
for obj in sel:
if Draft.getType(obj) == "Wire":
wire = obj
break
makeCable(wire)
makeCable()
FreeCAD.ActiveDocument.recompute()
def IsActive(self):

View File

@@ -59,7 +59,7 @@ def makeBOQCivil():
class _CommandBOQCivil:
class CommandBOQCivil:
def GetResources(self):
return {'Pixmap': str(os.path.join(DirIcons, "boqc.svg")),
@@ -76,5 +76,5 @@ class _CommandBOQCivil:
else:
return False
if FreeCAD.GuiUp:
FreeCADGui.addCommand('BOQCivil', _CommandBOQCivil())
'''if FreeCAD.GuiUp:
FreeCADGui.addCommand('BOQCivil', _CommandBOQCivil())'''

View File

@@ -83,7 +83,8 @@ def makeBOQElectrical():
b = mgb.get_boundary(m)
Part.show(b)
class _CommandBOQElectrical:
class CommandBOQElectrical:
def GetResources(self):
return {'Pixmap': str(os.path.join(DirIcons, "boqe.svg")),
'Accel': "R, E",
@@ -100,5 +101,5 @@ class _CommandBOQElectrical:
return False
if FreeCAD.GuiUp:
FreeCADGui.addCommand('BOQElectrical', _CommandBOQElectrical())
'''if FreeCAD.GuiUp:
FreeCADGui.addCommand('BOQElectrical', _CommandBOQElectrical())'''

View File

@@ -294,7 +294,7 @@ def spreadsheetBOQPanelCollision(sheet, sel):
sheet['G{0}'.format(ind + 2)] = sel[ind].Placement.Rotation.toEuler()[1]
sheet['H{0}'.format(ind + 2)] = sel[ind].NumberPole.Value
class _CommandBOQMechanical:
class CommandBOQMechanical:
def GetResources(self):
return {'Pixmap': str(os.path.join(PVPlantResources.DirIcons, "boqm.svg")),
'Accel': "R, M",
@@ -340,5 +340,5 @@ class _CommandBOQMechanical:
else:
return False
if FreeCAD.GuiUp:
FreeCADGui.addCommand('BOQMechanical', _CommandBOQMechanical())
'''if FreeCAD.GuiUp:
FreeCADGui.addCommand('BOQMechanical', CommandBOQMechanical())'''

View File

@@ -186,8 +186,8 @@ def createPVPanel(name):
typpvpanel.noct = 45.0 # SINTC (double) (Cº)
typpvpanel.manuf = "" # Fabricante
typpypanel.chr_name = "" # Nombre característico
typpypanel.appr_status = 1 # Estado: 0: No aprobado, 1: aprobado
typpvpanel.chr_name = "" # Nombre característico
typpvpanel.appr_status = 1 # Estado: 0: No aprobado, 1: aprobado
return typpvpanel

View File

@@ -46,15 +46,10 @@ except AttributeError:
from PVPlantResources import DirIcons as DirIcons
## @package importDAE
# \ingroup ARCH
# \brief DAE (Collada) file format importer and exporter
#
# This module provides tools to import and export Collada (.dae) files.
__title__ = "FreeCAD Collada importer"
__author__ = "Yorik van Havre"
__url__ = "http://www.freecadweb.org"
__title__ = "FreeCAD PVSyst importer"
__author__ = "Javier"
#__url__ = "http://www.freecadweb.org"
try:
# Python 2 forward compatibility
@@ -453,7 +448,7 @@ def exportToPVC(path, exportTerrain = False):
array = SubElement(axis, 'float_array')
array.set('id', 'tracker{0}AxisFloatArray1'.format(ind))
array.set('count', '3')
array.text = '{0:.6f} {1:.6f} {2:.6f}'.format(centers[i].x, centers[i].y, centers[i].z)
array.text = '{0:.6f} {1:.6f} {2:.6f}'.format(centers[ind].x, centers[ind].y, centers[ind].z)
min_phi = SubElement(frame, 'min_phi')
min_phi.text = '{0}'.format(int(obj.Setup.MinPhi.Value))
@@ -529,11 +524,10 @@ def exportToPVC(path, exportTerrain = False):
frame_setup["footprint"] = ""
objind = 0
# TODO: revisar
for type in frameType:
isTracker = "tracker" in type.Proxy.Type.lower()
#TODO: Sólo para los proyectos de NAcho. Borrar
isTracker = False
for typ in frameType:
isTracker = "tracker" in typ.Proxy.Type.lower()
objectlist = FreeCAD.ActiveDocument.findObjects(Name="Tracker")
tmp = []
@@ -545,7 +539,7 @@ def exportToPVC(path, exportTerrain = False):
objectlist = tmp.copy()
for obj in objectlist:
if obj.Setup == type:
if obj.Setup == typ:
findex = numpy.array([])
modules = obj.Setup.Shape.SubShapes[0].SubShapes[0]
@@ -726,26 +720,26 @@ def exportToH2P(path): # sólo válido para mesas
#for obj in objects:
grouptype.append(objects[0])
for type in grouptype:
for typ in grouptype:
st += 'TABLE\n' \
'10\n'
st += f3.format(type.Width.Value) + ',' + f3.format(type.Length.Value) + ',' + \
st += f3.format(typ.Width.Value) + ',' + f3.format(typ.Length.Value) + ',' + \
f3.format(0) + ',' + f3.format(0) + ',' + f3.format(0) + ',' + f3.format(0) + "\n"
#'#{ f3 %pvsyst.ilb.to_mm },#{f3 %pvsyst.irb.to_mm},#{f3 %pvsyst.itb.to_mm},' \
#'#{f3 %pvsyst.ibb.to_mm}\n'
st += '20\n'
st += str(int(type.ModulesCols.Value)) + ',' + str(int(type.ModulesRows.Value)) + ',' + \
str(type.ModuleColGap.Value) + ',' + str(type.ModuleRowGap.Value) + ',' + '30\n'
st += str(int(typ.ModulesCols.Value)) + ',' + str(int(typ.ModulesRows.Value)) + ',' + \
str(typ.ModuleColGap.Value) + ',' + str(typ.ModuleRowGap.Value) + ',' + '30\n'
st += '30\n'
st += '1,' + f3.format(type.ModuleWidth.Value) + ',' + f3.format(type.ModuleHeight.Value) + ',' + \
f3.format(type.ModuleThick.Value) + ',' + f2.format(450) + '\n' #f2.format(type.ModulePower.Value) + '\n'
st += '1,' + f3.format(typ.ModuleWidth.Value) + ',' + f3.format(typ.ModuleHeight.Value) + ',' + \
f3.format(typ.ModuleThick.Value) + ',' + f2.format(450) + '\n' #f2.format(typ.ModulePower.Value) + '\n'
# cornerdown = find_component_sizes(group.cdef)[1]
# pvorigin = Geom::Point3d.new(cornerdown.x, cornerdown.y, 0)
# group.instances.each{ | ins | str += pvsyst_insert(ins, pvorigin)}
for obj in objects:
if obj.CloneOf == type:
if obj.CloneOf == typ:
st += H2PInsert(obj)
## TODO: Bucle para buscar objetos que den sombra y el terreno. Todos llaman a H2PMesh
@@ -778,12 +772,12 @@ def H2PInsert(obj):
return st
def H2PMesh(mesh, type):
def H2PMesh(mesh, typ):
scale = 0.001 ## ver como se puede hacer para que sea general. Pasar de mm a m
f3 = '{:.3f}'
st = ''
if type:
if typ:
st = 'ShadowObject\nFence\n'
else:
st = 'DGM\n'
@@ -799,7 +793,7 @@ def H2PMesh(mesh, type):
return st
class _PVSystTaskPanel:
class PVSystTaskPanel:
def __init__(self):
self.form = FreeCADGui.PySideUic.loadUi(os.path.dirname(__file__) + "/exportPVSyst.ui")
@@ -812,7 +806,7 @@ class _PVSystTaskPanel:
def accept(self):
import datetime
x = datetime.datetime.now()
date = x.strftime("%y%m%d%H%M%S")
date = x.strftime("%Y%m%d%H%M%S")
overwrite = True
path = os.path.join(os.path.dirname(FreeCAD.ActiveDocument.FileName), "outputs", "PVSyst")
@@ -820,8 +814,8 @@ class _PVSystTaskPanel:
os.makedirs(path)
name = FreeCAD.ActiveDocument.Label
if not overwrite:
name = date + "-" + name
#if not overwrite:
name = date + "-" + name
filename = os.path.join(path, name)
#if self.form.cbDAE.isChecked():
@@ -840,7 +834,7 @@ class _PVSystTaskPanel:
FreeCADGui.Control.closeDialog()
return True
class _CommandExportToPVSyst:
'''class _CommandExportToPVSyst:
"Export to PVSyst"
def GetResources(self):
@@ -861,4 +855,4 @@ class _CommandExportToPVSyst:
return False
if FreeCAD.GuiUp:
FreeCADGui.addCommand('ExportToPVSyst', _CommandExportToPVSyst())
FreeCADGui.addCommand('ExportToPVSyst', _CommandExportToPVSyst())'''

View File

@@ -28,33 +28,10 @@ from pathlib import Path
import sys
import os
import FreeCADGui
import FreeCAD
FreeCADGui.updateLocale()
try:
import PVPlantGeoreferencing, PVPlantPlacement, \
PVPlantTerrainAnalisys, PVPlantSite, PVPlantImportGrid, PVPlantFence, \
PVPlantFoundation, PVPlantCreateTerrainMesh, \
PVPlantTreeGenerator, PVPlantBuilding, PVPlantTrench, PVPlantEarthWorks, \
PVPlantStringing, \
PVPlantPad, PVPlantRoad, PVPlantTerrain, PVPlantManhole, \
GraphProfile, Utils.PVPlantTrace, \
reload
import PVPlantRackChecking
from Project.Area import PVPlantArea, PVPlantAreaUtils
from Project import ProjectSetup
from Importer import importDXF
from Mechanical.Frame import PVPlantFrame
from Electrical.Cable import PVPlantCable, PVPlantElectricalLine
from Electrical.CombinerBox import PVPlantStringBox
from Electrical.Inverter import PVPlantInverter
except ImportError as e:
print(f"Error importing modules: {e}")
class PVPlantWorkbench(Workbench):
from PVPlantResources import DirIcons as DirIcons
@@ -66,49 +43,22 @@ class PVPlantWorkbench(Workbench):
#sys.path.append(r"C:\Users\javie\AppData\Roaming\FreeCAD\Mod")
sys.path.append(os.path.join(FreeCAD.getUserAppDataDir(), 'Mod'))
import PVPlantTools
import PVPlantTools, reload
self.projectlist = PVPlantTools.projectlist
self.projectlist.insert(0, 'Reload')
self.projectlist.insert(1, 'Separator')
self.framelist = PVPlantTools.pv_list
from Export import ExporterCommands
self.inportExportlist = ExporterCommands.Exportlist
# A list of command names created in the line above
'''self.projectlist = ["Reload",
"PVPlantSite",
"PVPlantGeoreferencing",
"ProjectSetup",
# "ImportGrid",
"Terrain",
"PointsGroup",
"PVPlantCreateTerrainMesh",
"PVPlantAreas",
"SplitArea",
"TerrainAnalisys",
"Trenches",
"PVPlantEarthworks",
"PVPlantPad",
"PVPlantRoad",
"PVPlantManhole",
# "PVPlantFoundation"
"GraphTerrainProfile",
"Trace",
]'''
self.framelist = [
"RackType",
"PVPlantRackCheck",
"Separator",
"PVPlantPlacement",
"PVPlantAdjustToTerrain",
"PVPlantConvertTo",
"PVArea"
]
self.objectlist = [
"PVPlantTree",
"PVPlantBuilding",
"PVPlantFenceGroup",
]
from Export import ExporterCommands
self.inportExportlist = ExporterCommands.Exportlist
self.electricalList = ["PVPlantStringBox",
"PVPlantCable",
"PVPlanElectricalLine",
@@ -119,7 +69,6 @@ class PVPlantWorkbench(Workbench):
]
self.roads = ["PVPlantRoad",
]
self.pads = ["PVPlantPad",

View File

@@ -33,7 +33,7 @@ except AttributeError:
import os, math
from PVPlantResources import DirIcons as DirIcons
class _TaskPanel:
class TaskPanel:
def __init__(self, obj = None):
self.obj = None
self.select = 0
@@ -251,7 +251,7 @@ def Open3DTriangle(point_cloud):
#p_mesh_crop = mesh.crop(bbox)
return mesh
class _PVPlantCreateTerrainMesh:
'''class _PVPlantCreateTerrainMesh:
def GetResources(self):
return {'Pixmap': str(os.path.join(DirIcons, "surface.svg")),
@@ -268,4 +268,4 @@ class _PVPlantCreateTerrainMesh:
if FreeCAD.GuiUp:
FreeCADGui.addCommand('PVPlantCreateTerrainMesh', _PVPlantCreateTerrainMesh())
FreeCADGui.addCommand('PVPlantCreateTerrainMesh', _PVPlantCreateTerrainMesh())'''

View File

@@ -488,7 +488,7 @@ class ViewProviderEarthWorksVolume:
return None
class _EarthWorksTaskPanel:
class EarthWorksTaskPanel:
def __init__(self):
self.To = None
@@ -827,7 +827,7 @@ def searchTool(obj, tools):
return tool
class _CommandCalculateEarthworks:
'''class _CommandCalculateEarthworks:
def GetResources(self):
return {'Pixmap': str(os.path.join(PVPlantResources.DirIcons, "pico.svg")),
@@ -846,7 +846,7 @@ class _CommandCalculateEarthworks:
return active
if FreeCAD.GuiUp:
FreeCADGui.addCommand('PVPlantEarthworks', _CommandCalculateEarthworks())
FreeCADGui.addCommand('PVPlantEarthworks', _CommandCalculateEarthworks())'''
def accept():

View File

@@ -27,8 +27,7 @@ if FreeCAD.GuiUp:
import FreeCADGui
from PySide import QtCore, QtGui
from PySide.QtCore import QT_TRANSLATE_NOOP
from PySide2.QtWebEngineWidgets import QWebEngineView
from PySide2.QtWebChannel import QWebChannel
import os
else:
# \cond
@@ -47,13 +46,19 @@ class MapWindow(QtGui.QWidget):
def __init__(self, WinTitle="MapWindow"):
super(MapWindow, self).__init__()
self.raise_()
self.lat = 0
self.lon = 0
self.lat = None
self.lon = None
self.minLat = None
self.maxLat = None
self.minLon = None
self.maxLon = None
self.WinTitle = WinTitle
self.setupUi()
def setupUi(self):
from PySide2.QtWebEngineWidgets import QWebEngineView
from PySide2.QtWebChannel import QWebChannel
self.ui = FreeCADGui.PySideUic.loadUi(PVPlantResources.__dir__ + "/PVPlantGeoreferencing.ui", self)
self.resize(1200, 800)
@@ -144,6 +149,9 @@ class MapWindow(QtGui.QWidget):
RightLayout.addWidget(self.groupbox)
# ------------------------
self.checkboxImportGis = QtGui.QCheckBox("Importar datos GIS")
RightLayout.addWidget(self.checkboxImportGis)
verticalSpacer = QtGui.QSpacerItem(20, 48, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
RightLayout.addItem(verticalSpacer)
@@ -169,7 +177,6 @@ class MapWindow(QtGui.QWidget):
geolocator = Nominatim(user_agent="http")
location = geolocator.geocode(self.valueSearch.text())
print(location.raw)
self.valueSearch.setText(location.address)
self.panMap(location.longitude, location.latitude, location.raw['boundingbox'])
@@ -196,6 +203,13 @@ class MapWindow(QtGui.QWidget):
' | UTM: ' + str(zone_number) + zone_letter +
', {:.5f}m E, {:.5f}m N'.format(x, y))
@QtCore.Slot(float, float, float, float)
def onMapZoom(self, minLat, minLon, maxLat, maxLon):
self.minLat = min([minLat, maxLat])
self.maxLat = max([minLat, maxLat])
self.minLon = min([minLon, maxLon])
self.maxLon = max([minLon, maxLon])
@QtCore.Slot(float, float)
def georeference(self, lat, lng):
import PVPlantSite
@@ -228,13 +242,20 @@ class MapWindow(QtGui.QWidget):
import geojson
import PVPlantImportGrid as ImportElevation
import Draft
import PVPlantSite
Site = PVPlantSite.get()
offset = FreeCAD.Vector(0, 0, 0)
if not (self.lat is None or self.lon is None):
offset = FreeCAD.Vector(Site.Origin)
offset.z = 0
items = geojson.loads(drawnItems)
for item in items['features']:
if item['geometry']['type'] == "Point": # 1. if the feature is a Point or Circle:
coord = item['geometry']['coordinates']
point = ImportElevation.getElevationFromOE([[coord[0], coord[1]],])
c = FreeCAD.Vector(point[0][0], point[0][1], point[0][2])
c = FreeCAD.Vector(point[0][0], point[0][1], point[0][2]).sub(offset)
if item['properties'].get('radius'):
r = round(item['properties']['radius'] * 1000, 0)
p = FreeCAD.Placement()
@@ -252,34 +273,67 @@ class MapWindow(QtGui.QWidget):
name = "Area"
lp = item['geometry']['coordinates'][0]
pts = []
for cords in lp:
pts.append([cords[1], cords[0]])
pts = [[cords[1], cords[0]] for cords in lp]
tmp = ImportElevation.getElevationFromOE(pts)
pts = []
for p in tmp:
pts.append(p.sub(FreeCAD.ActiveDocument.Site.Origin))
pts = [p.sub(offset) for p in tmp]
obj = Draft.makeWire(pts, closed=cw, face=False)
obj.Placement.Base = FreeCAD.ActiveDocument.Site.Origin
#obj.Placement.Base = offset
obj.Label = name
Draft.autogroup(obj)
if item['properties'].get('name'):
obj.Label = item['properties']['name']
FreeCAD.activeDocument().recompute()
FreeCADGui.updateGui()
FreeCADGui.SendMsgToActiveView("ViewFit")
if self.checkboxImportGis.isChecked():
self.getDataFromOSM(self.minLat, self.minLon, self.maxLat, self.maxLon)
def panMap(self, lng, lat, geometry=""):
def getDataFromOSM(self, min_lat, min_lon, max_lat, max_lon):
import Importer.importOSM as importOSM
import PVPlantSite
site = PVPlantSite.get()
offset = FreeCAD.Vector(0, 0, 0)
if not (self.lat is None or self.lon is None):
offset = FreeCAD.Vector(site.Origin)
offset.z = 0
importer = importOSM.OSMImporter(offset)
osm_data = importer.get_osm_data(f"{min_lat},{min_lon},{max_lat},{max_lon}")
importer.process_osm_data(osm_data)
'''FreeCAD.activeDocument().recompute()
FreeCADGui.updateGui()
FreeCADGui.SendMsgToActiveView("ViewFit")'''
def panMap_old(self, lng, lat, geometry=""):
frame = self.view.page()
bbox = "[{0}, {1}], [{2}, {3}]".format(float(geometry[0]), float(geometry[2]),
float(geometry[1]), float(geometry[3]))
command = 'map.panTo(L.latLng({lt}, {lg}));'.format(lt=lat, lg=lng)
command = 'map.panTo(L.latLng({lt}, {lg}));'.format(lt=lat, lg=lng)
command += 'map.fitBounds([{box}]);'.format(box=bbox)
frame.runJavaScript(command)
# deepseek
def panMap(self, lng, lat, geometry=None):
frame = self.view.page()
# 1. Validación del parámetro geometry
if not geometry or len(geometry) < 4:
# Pan básico sin ajuste de bounds
command = f'map.panTo(L.latLng({lat}, {lng}));'
else:
try:
# 2. Mejor manejo de coordenadas (Leaflet usa [lat, lng])
# Asumiendo que geometry es [min_lng, min_lat, max_lng, max_lat]
southwest = f"{float(geometry[1])}, {float(geometry[0])}" # min_lat, min_lng
northeast = f"{float(geometry[3])}, {float(geometry[2])}" # max_lat, max_lng
command = f'map.panTo(L.latLng({lat}, {lng}));'
command += f'map.fitBounds(L.latLngBounds([{southwest}], [{northeast}]));'
except (IndexError, ValueError, TypeError) as e:
print(f"Error en geometry: {str(e)}")
command = f'map.panTo(L.latLng({lat}, {lng}));'
frame.runJavaScript(command)
def importKML(self):
file = QtGui.QFileDialog.getOpenFileName(None, "FileDialog", "", "Google Earth (*.kml *.kmz)")[0]
@@ -287,11 +341,11 @@ class MapWindow(QtGui.QWidget):
layers = kmz_convert(file, "", )
frame = self.view.page()
for layer in layers:
command = "drawnItems.addLayer(L.geoJSON({0}));".format(layer)
command = "var geoJsonLayer = L.geoJSON({0}); drawnItems.addLayer(geoJsonLayer); map.fitBounds(geoJsonLayer.getBounds());".format( layer)
frame.runJavaScript(command)
class _CommandPVPlantGeoreferencing:
class CommandPVPlantGeoreferencing:
def GetResources(self):
return {'Pixmap': str(os.path.join(DirIcons, "Location.svg")),
@@ -309,6 +363,6 @@ class _CommandPVPlantGeoreferencing:
else:
return False
if FreeCAD.GuiUp:
'''if FreeCAD.GuiUp:
FreeCADGui.addCommand('PVPlantGeoreferencing',_CommandPVPlantGeoreferencing())
'''

View File

@@ -57,14 +57,14 @@
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="lineEdit">
<widget class="QLineEdit" name="search_bar">
<property name="placeholderText">
<string>Search...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<widget class="QPushButton" name="search_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -80,10 +80,7 @@
</widget>
</item>
<item>
<widget class="QWebEngineView" name="widget_4" native="true"/>
</item>
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="coordinates_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -91,7 +88,7 @@
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
<string>coordenadas:</string>
</property>
</widget>
</item>
@@ -111,7 +108,7 @@
<widget class="QWidget" name="widget_5" native="true">
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QPushButton" name="pushButton_4">
<widget class="QPushButton" name="kmz_button">
<property name="text">
<string>PushButton</string>
</property>
@@ -124,20 +121,27 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Georeferenciar</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxGeoreference">
<property name="text">
<string>Georeferenciar</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxImportGis">
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -164,7 +168,7 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_3">
<widget class="QPushButton" name="accept_button">
<property name="text">
<string>Aceptar</string>
</property>
@@ -178,14 +182,6 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QWebEngineView</class>
<extends>QWidget</extends>
<header>qwebengineview.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -1,213 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Georeferencing</class>
<widget class="QDialog" name="Georeferencing">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>574</width>
<height>350</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Create Surface</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QWidget" name="widgetLeft" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="widgetSearch" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="lineEdit">
<property name="placeholderText">
<string>Search...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Search</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWebEngineView" name="widget_4" native="true"/>
</item>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widgetRight" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Configuraciones:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Georeferenciar</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Cargar un archivo KMZ/KML:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_4">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QListWidget" name="listWidget">
<item>
<property name="text">
<string>New Item</string>
</property>
<property name="checkState">
<enum>Unchecked</enum>
</property>
</item>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QWidget" name="widget_6" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>Cancelar</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>Aceptar</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QWebEngineView</class>
<extends>QWidget</extends>
<header>qwebengineview.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -40,7 +40,70 @@ from PVPlantResources import DirIcons as DirIcons
import PVPlantSite
def get_elevation_from_oe(coordinates): # v1 deepseek
"""Obtiene elevaciones de Open-Elevation API y devuelve vectores FreeCAD en coordenadas UTM.
Args:
coordinates (list): Lista de tuplas con coordenadas (latitud, longitud)
Returns:
list: Lista de vectores FreeCAD con coordenadas UTM y elevación (en milímetros)
o lista vacía en caso de error.
"""
if not coordinates:
return []
import requests
import utm
from requests.exceptions import RequestException
# Construcción más eficiente de parámetros
locations = "|".join([f"{lat:.6f},{lon:.6f}" for lat, lon in coordinates])
try:
response = requests.get(
url="https://api.open-elevation.com/api/v1/lookup",
params={'locations': locations},
timeout=20,
verify=True
)
response.raise_for_status() # Lanza excepción para códigos 4xx/5xx
except RequestException as e:
print(f"Error en la solicitud: {str(e)}")
return []
try:
data = response.json()
except ValueError:
print("Respuesta JSON inválida")
return []
if "results" not in data or len(data["results"]) != len(coordinates):
print("Formato de respuesta inesperado")
return []
points = []
for result in data["results"]:
try:
# Conversión UTM con manejo de errores
easting, northing, _, _ = utm.from_latlon(
result["latitude"],
result["longitude"]
)
points.append(FreeCAD.Vector(round(easting), # Convertir metros a milímetros
round(northing),
round(result["elevation"])) * 1000)
except Exception as e:
print(f"Error procesando coordenadas: {str(e)}")
continue
return points
def getElevationFromOE(coordinates):
"""Obtiene elevaciones de Open-Elevation API y devuelve vectores FreeCAD en coordenadas UTM."""
from requests.exceptions import RequestException
if len(coordinates) == 0:
return None
@@ -54,7 +117,16 @@ def getElevationFromOE(coordinates):
if i != total:
str += '|'
query = 'https://api.open-elevation.com/api/v1/lookup?locations=' + str
r = get(query, timeout=20)
try:
r = get(query, timeout=20, verify=False)
except RequestException as e:
points = []
for i, point in enumerate(coordinates):
c = utm.from_latlon(point[0], point[1])
points.append(FreeCAD.Vector(round(c[0] * 1000, 0),
round(c[1] * 1000, 0),
0))
return points
# Only get the json response in case of 200 or 201
points = []
@@ -82,7 +154,7 @@ def getSinglePointElevationFromBing(lat, lng):
# +# to do: error handling - wait and try again
s = json.loads(ans)
res = s['resourceSets'][0]['resources'][0]['elevations']
import utm
for elevation in res:
c = utm.from_latlon(lat, lng)

View File

@@ -180,7 +180,7 @@ class _ViewProviderManhole(ArchComponent.ViewProviderComponent):
import draftguitools.gui_tool_utils as gui_tool_utils
class _ManholeTaskPanel:
class ManholeTaskPanel:
def __init__(self, obj=None):
self.new = False
if obj is None:
@@ -249,7 +249,7 @@ class _ManholeTaskPanel:
self.view.removeEventCallback("SoEvent", self.call)
class _CommandManhole:
'''class _CommandManhole:
"the Arch Building command definition"
def GetResources(self):
@@ -274,5 +274,5 @@ class _CommandManhole:
if FreeCAD.GuiUp:
FreeCADGui.addCommand('PVPlantManhole', _CommandManhole())
FreeCADGui.addCommand('PVPlantManhole', _CommandManhole())'''

View File

@@ -22,7 +22,6 @@
import FreeCAD
import Part
import numpy as np
if FreeCAD.GuiUp:
import FreeCADGui, os
@@ -47,6 +46,8 @@ except AttributeError:
import PVPlantResources
import PVPlantSite
version = "0.1.0"
def selectionFilter(sel, objtype):
print("type: ", objtype)
@@ -119,8 +120,8 @@ class _PVPlantPlacementTaskPanel:
for idx in range(len(placements)):
newrack = PVPlantFrame.makeTracker(setup=types[idx])
newrack.Label = "Tracker"
newrack.Visibility = False
newrack.Placement = placements[idx]
newrack.Visibility = True
MechanicalGroup.addObject(newrack)
frames.append(newrack)
if self.PVArea.Name.startswith("FrameArea"):
@@ -136,6 +137,8 @@ class _PVPlantPlacementTaskPanel:
else:
from Utils import PVPlantUtils as utils
wire = utils.simplifyWire(utils.getProjected(shape))
if wire.isClosed():
wire = wire.removeSplitter()
return Part.Face(wire)
def calculateWorkingArea(self):
@@ -180,8 +183,8 @@ class _PVPlantPlacementTaskPanel:
starty = int(refh.BoundBox.YMin + self.offsetY + self.gap_row * steps)
# todo end ----------------------------------------------------------------------------------
return np.arange(startx, self.Area.BoundBox.XMax, self.gap_col, dtype=int), \
np.arange(starty, self.Area.BoundBox.YMin, -self.gap_row, dtype=int)
return np.arange(startx, self.Area.BoundBox.XMax, self.gap_col, dtype=np.int64), \
np.arange(starty, self.Area.BoundBox.YMin, -self.gap_row, dtype=np.int64)
def adjustToTerrain(self, coordinates):
mode = 1
@@ -241,7 +244,7 @@ class _PVPlantPlacementTaskPanel:
df["regression"] = linregression
# 01. Grouping:
from scipy.ndimage import sclabel
from scipy.ndimage import label as sclabel
import pandas as pd
tmp = []
for c, col in enumerate(coordinates):
@@ -389,6 +392,7 @@ class _PVPlantPlacementTaskPanel:
return False
def calculateAlignedArray(self):
import FreeCAD
pointsx, pointsy = self.getAligments()
footprints = []
@@ -536,6 +540,11 @@ class _PVPlantPlacementTaskPanel:
from datetime import datetime
starttime = datetime.now()
params = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Document")
auto_save_enabled = params.GetBool("AutoSaveEnabled")
params.SetBool("AutoSaveEnabled", False)
FreeCAD.ActiveDocument.RecomputesFrozen = True
items = []
for x in range(self.form.listFrameSetups.count()):
items.append(FreeCAD.ActiveDocument.getObject(self.form.listFrameSetups.item(x).text()))
@@ -565,15 +574,16 @@ class _PVPlantPlacementTaskPanel:
dataframe = self.calculateNonAlignedArray()
# last step: ------------------------------
FreeCAD.ActiveDocument.RecomputesFrozen = True
self.createFrameFromPoints(dataframe)
FreeCAD.ActiveDocument.RecomputesFrozen = False
params.SetBool("AutoSaveEnabled", auto_save_enabled)
self.createFrameFromPoints(dataframe)
total_time = datetime.now() - starttime
print(" -- Tiempo tardado:", total_time)
FreeCADGui.Control.closeDialog()
FreeCAD.ActiveDocument.recompute()
return True
#return True
# ----------------------------------------------------------------------------------------------------------------------
@@ -1066,7 +1076,7 @@ def ConvertObjectsTo(sel, objTo):
## Comandos: -----------------------------------------------------------------------------------------------------------
class _CommandPVPlantPlacement:
class CommandPVPlantPlacement:
def GetResources(self):
return {'Pixmap': str(os.path.join(PVPlantResources.DirIcons, "way.svg")),
@@ -1085,7 +1095,7 @@ class _CommandPVPlantPlacement:
return False
class _CommandAdjustToTerrain:
class CommandAdjustToTerrain:
def GetResources(self):
return {'Pixmap': str(os.path.join(PVPlantResources.DirIcons, "adjust.svg")),
@@ -1108,7 +1118,7 @@ class _CommandAdjustToTerrain:
return False
class _CommandConvert:
class CommandConvert:
def GetResources(self):
return {'Pixmap': str(os.path.join(PVPlantResources.DirIcons, "convert.svg")),
'Accel': "P, C",
@@ -1126,7 +1136,7 @@ class _CommandConvert:
FreeCADGui.Control.showDialog(taskd)
if FreeCAD.GuiUp:
'''if FreeCAD.GuiUp:
FreeCADGui.addCommand('PVPlantPlacement', _CommandPVPlantPlacement())
FreeCADGui.addCommand('PVPlantAdjustToTerrain', _CommandAdjustToTerrain())
FreeCADGui.addCommand('PVPlantConvertTo', _CommandConvert())
FreeCADGui.addCommand('PVPlantConvertTo', _CommandConvert())'''

View File

@@ -1171,7 +1171,7 @@ class _ViewProviderSite:
'''
class _CommandPVPlantSite:
'''class _CommandPVPlantSite:
"the Arch Site command definition"
def GetResources(self):
@@ -1189,4 +1189,4 @@ class _CommandPVPlantSite:
return
if FreeCAD.GuiUp:
FreeCADGui.addCommand('PVPlantSite', _CommandPVPlantSite())
FreeCADGui.addCommand('PVPlantSite', _CommandPVPlantSite())'''

View File

@@ -670,7 +670,7 @@ class ViewProviderTerrain:
return None
class _CommandTerrain:
'''class _CommandTerrain:
"the PVPlant Terrain command definition"
def GetResources(self):
@@ -692,4 +692,4 @@ class _CommandTerrain:
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Terrain', _CommandTerrain())
FreeCADGui.addCommand('Terrain', _CommandTerrain())'''

View File

@@ -23,6 +23,7 @@ except AttributeError:
import os
from PVPlantResources import DirIcons as DirIcons
def Mest2FemMesh(obj):
import Fem
@@ -44,6 +45,7 @@ def Mest2FemMesh(obj):
FreeCAD.activeDocument().recompute()
return obj2
def makeContours(land, minor = 1000, mayor = 5000,
minorColor=(0.0, 0.00, 0.80), mayorColor=(0.00, 0.00, 1.00),
minorThickness = 2, mayorThickness = 5,
@@ -58,6 +60,7 @@ def makeContours(land, minor = 1000, mayor = 5000,
FreeCAD.ActiveDocument.recompute()
def Contours_Mesh(Mesh, minor, mayor,
minorColor, mayorColor,
minorLineWidth, mayorLineWidth,
@@ -144,6 +147,7 @@ def Contours_Mesh(Mesh, minor, mayor,
calculateSection(minor_array)
calculateSection(mayor_array)
def Contours_Part(Terrain, minor, mayor,
minorColor, mayorColor,
minorLineWidth, mayorLineWidth,
@@ -235,6 +239,8 @@ def Contours_Part(Terrain, minor, mayor,
calculateSection(mayor_array)
# Base widget for task panel terrain analisys
class _generalTaskPanel:
'''The TaskPanel for Slope setup'''
@@ -324,7 +330,7 @@ class _generalTaskPanel:
self.ranges[curentIndex.row()][2] = (color.red()/255, color.green()/255, color.blue()/255)
# Contours Analisys: ---------------------------------------------------------------------------------
class _ContourTaskPanel():
class ContourTaskPanel():
'''The editmode TaskPanel for contours generator'''
def __init__(self):
@@ -480,7 +486,7 @@ class _ContourTaskPanel():
return True
# Height Analisys: ---------------------------------------------------------------------------------
class _HeightTaskPanel(_generalTaskPanel):
class HeightTaskPanel(_generalTaskPanel):
'''The TaskPanel for Slope setup'''
def __init__(self):
@@ -513,7 +519,7 @@ class _HeightTaskPanel(_generalTaskPanel):
return True
# Slope Analisys: ---------------------------------------------------------------------------------
class _SlopeTaskPanel(_generalTaskPanel):
class SlopeTaskPanel(_generalTaskPanel):
'''The TaskPanel for Slope setup'''
def __init__(self):
@@ -603,7 +609,7 @@ class _SlopeTaskPanel(_generalTaskPanel):
return True
# Orientation Analisys: ---------------------------------------------------------------------------------
class _OrientationTaskPanel(_generalTaskPanel):
class OrientationTaskPanel(_generalTaskPanel):
'''The TaskPanel for Orientation setup'''
def __init__(self):
@@ -707,7 +713,7 @@ class _OrientationTaskPanel(_generalTaskPanel):
## Commands ----------------------------------------------------------------------------------------------------------
## 1. Contours:
class _CommandContours:
'''class _CommandContours:
def GetResources(self):
return {'Pixmap': str(os.path.join(DirIcons, "TerrainContours.svg")),
'Accel': "T, C",
@@ -803,4 +809,4 @@ if FreeCAD.GuiUp:
FreeCADGui.addCommand('SlopeAnalisys', _CommandSlopeAnalisys())
FreeCADGui.addCommand('HeightAnalisys', _CommandHeightAnalisys())
FreeCADGui.addCommand('OrientationAnalisys', _CommandOrientationAnalisys())
FreeCADGui.addCommand('TerrainAnalisys', CommandTerrainAnalisysGroup())
FreeCADGui.addCommand('TerrainAnalisys', CommandTerrainAnalisysGroup())'''

View File

@@ -56,7 +56,7 @@ class CommandPVPlantSite:
return
class CommandPVPlantGeoreferencing:
'''class CommandPVPlantGeoreferencing:
@staticmethod
def GetResources():
return {'Pixmap': str(os.path.join(DirIcons, "Location.svg")),
@@ -74,8 +74,10 @@ class CommandPVPlantGeoreferencing:
@staticmethod
def Activated():
import PVPlantGeoreferencing
form = PVPlantGeoreferencing.MapWindow()
form.show()
taskd = PVPlantGeoreferencing.MapWindow()
#taskd.setParent(FreeCADGui.getMainWindow())
#taskd.setWindowFlags(QtCore.Qt.Window)
taskd.show()#exec_()'''
class CommandProjectSetup:
@@ -187,8 +189,8 @@ class CommandBoundary:
from Project.Area import PVPlantArea
sel = FreeCADGui.Selection.getSelection()[0]
obj = PVPlantArea.makeArea([ver.Point for ver in sel.Shape.Vertexes])
#taskd = _PVPlantPlacementTaskPanel()
#FreeCADGui.Control.showDialog(taskd)
# taskd = _PVPlantPlacementTaskPanel()
# FreeCADGui.Control.showDialog(taskd)
class CommandFrameArea:
@@ -249,6 +251,7 @@ class CommandPVSubplant:
return True
else:
return False
@staticmethod
def Activated():
from Project.Area import PVPlantArea
@@ -524,7 +527,7 @@ class CommandManhole:
@staticmethod
def IsActive():
return not FreeCAD.ActiveDocument is None
return not (FreeCAD.ActiveDocument is None)
if FreeCAD.ActiveDocument is not None:
if FreeCADGui.Selection.getCompleteSelection():
for ob in FreeCAD.ActiveDocument.Objects:
@@ -534,29 +537,30 @@ class CommandManhole:
@staticmethod
def Activated():
import PVPlantManhole
TaskPanel = PVPlantManhole._ManholeTaskPanel()
FreeCADGui.Control.showDialog(TaskPanel)
task_panel = PVPlantManhole._ManholeTaskPanel()
FreeCADGui.Control.showDialog(task_panel)
return
if FreeCAD.GuiUp:
FreeCADGui.addCommand('PVPlantSite', CommandPVPlantSite())
FreeCADGui.addCommand('PVPlantGeoreferencing', CommandPVPlantGeoreferencing())
import PVPlantGeoreferencing
FreeCADGui.addCommand('PVPlantGeoreferencing', PVPlantGeoreferencing.CommandPVPlantGeoreferencing())
FreeCADGui.addCommand('ProjectSetup', CommandProjectSetup())
FreeCADGui.addCommand('Terrain', CommandTerrain())
FreeCADGui.addCommand('PVPlantCreateTerrainMesh', CommandCreateTerrainMesh())
class CommandAreaGroup:
@staticmethod
def GetCommands():
return tuple([#'Area',
'FrameArea',
'ForbiddenArea',
'PVSubplant',
'OffsetArea'
])
return tuple([ # 'Area',
'FrameArea',
'ForbiddenArea',
'PVSubplant',
'OffsetArea'
])
@staticmethod
def GetResources():
@@ -568,7 +572,8 @@ if FreeCAD.GuiUp:
def IsActive():
return not FreeCAD.ActiveDocument is None
#FreeCADGui.addCommand('Area', CommandBoundary())
# FreeCADGui.addCommand('Area', CommandBoundary())
FreeCADGui.addCommand('FrameArea', CommandFrameArea())
FreeCADGui.addCommand('ForbiddenArea', CommandProhibitedArea())
FreeCADGui.addCommand('PVSubplant', CommandPVSubplant())
@@ -578,6 +583,7 @@ if FreeCAD.GuiUp:
FreeCADGui.addCommand('SplitArea', CommandSplitArea())
FreeCADGui.addCommand('JoinAreas', CommandJoinAreas())
class CommandTerrainAnalisysGroup:
@staticmethod
def GetCommands():
@@ -589,20 +595,22 @@ if FreeCAD.GuiUp:
@staticmethod
def GetResources():
return { 'MenuText': QT_TRANSLATE_NOOP("",'Terrain Analisys'),
'ToolTip': QT_TRANSLATE_NOOP("",'Terrain Analisys')
}
return {'MenuText': QT_TRANSLATE_NOOP("", 'Terrain Analisys'),
'ToolTip': QT_TRANSLATE_NOOP("", 'Terrain Analisys')
}
@staticmethod
def IsActive():
return not FreeCAD.ActiveDocument is None
FreeCADGui.addCommand('Contours', CommandContours())
FreeCADGui.addCommand('SlopeAnalisys', CommandSlopeAnalisys())
FreeCADGui.addCommand('HeightAnalisys', CommandHeightAnalisys())
FreeCADGui.addCommand('OrientationAnalisys', CommandOrientationAnalisys())
FreeCADGui.addCommand('TerrainAnalisys', CommandTerrainAnalisysGroup())
class CommandTrenchGroup:
@staticmethod
def GetCommands():
@@ -625,33 +633,48 @@ if FreeCAD.GuiUp:
active = active and not (FreeCAD.ActiveDocument.getObject("Terrain").Mesh is None)
return active
FreeCADGui.addCommand('PVPlantTrench', CommandTrench())
FreeCADGui.addCommand('PVPlantSemiAutomaticTrench', CommandSemiAutomaticTrench())
FreeCADGui.addCommand('Trenches', CommandTrenchGroup())
FreeCADGui.addCommand('PVPlantEarthworks', CommandCalculateEarthworks())
FreeCADGui.addCommand('PVPlantManhole', _ommandManhole())
FreeCADGui.addCommand('PVPlantManhole', CommandManhole())
projectlist = [ #"Reload",
"PVPlantSite",
"ProjectSetup",
"PVPlantGeoreferencing",
"Separator",
# "ImportGrid",
"Terrain",
"TerrainAnalisys",
"PVPlantCreateTerrainMesh",
"Separator",
#"PointsGroup",
"PVPlantAreas",
"SplitArea",
"Separator",
"Trenches",
"PVPlantEarthworks",
#"PVPlantPad",
#"PVPlantRoad",
#"PVPlantManhole",
#"PVPlantFoundation"
#"GraphTerrainProfile",
#"Trace",
]
import PVPlantPlacement
FreeCADGui.addCommand('PVPlantPlacement', PVPlantPlacement.CommandPVPlantPlacement())
FreeCADGui.addCommand('PVPlantAdjustToTerrain', PVPlantPlacement.CommandAdjustToTerrain())
FreeCADGui.addCommand('PVPlantConvertTo', PVPlantPlacement.CommandConvert())
projectlist = [ # "Reload",
"PVPlantSite",
"ProjectSetup",
"PVPlantGeoreferencing",
"Separator",
# "ImportGrid",
"Terrain",
"TerrainAnalisys",
"PVPlantCreateTerrainMesh",
"Separator",
# "PointsGroup",
"PVPlantAreas",
"SplitArea",
"Separator",
"Trenches",
"PVPlantEarthworks",
# "PVPlantPad",
# "PVPlantRoad",
"PVPlantManhole",
# "PVPlantFoundation"
# "GraphTerrainProfile",
# "Trace",
]
pv_list = [
# "RackType",
# "PVPlantRackCheck",
# "Separator",
"PVPlantPlacement",
"PVPlantAdjustToTerrain",
"PVPlantConvertTo",
# "PVArea"
]

View File

@@ -1018,7 +1018,7 @@ class semiAutomaticTrench:
self.unregister_editing_callbacks()
class CommandTrench: # V1:
'''class CommandTrench: # V1:
"""Gui command for the Line tool."""
def GetResources(self):
@@ -1107,5 +1107,5 @@ if FreeCAD.GuiUp:
FreeCADGui.addCommand('PVPlantTrench', CommandTrench())
FreeCADGui.addCommand('PVPlantSemiAutomaticTrench', CommandSemiAutomaticTrench())
FreeCADGui.addCommand('Trenches', CommandTrenchGroup())
FreeCADGui.addCommand('Trenches', CommandTrenchGroup())'''

View File

@@ -372,7 +372,7 @@ class ViewProviderOffsetArea(_ViewProviderArea):
def makeProhibitedArea(base = None):
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "ProhibitedArea")
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "Exclusions")
ProhibitedArea(obj)
ViewProviderForbiddenArea(obj.ViewObject)
if base:
@@ -702,8 +702,8 @@ class CommandFrameArea:
'ToolTip': "Frame Area"}
def Activated(self):
sel = FreeCADGui.Selection.getSelection()
makeFramedArea(None, sel)
for base in FreeCADGui.Selection.getSelection():
makeFramedArea(None, base)
def IsActive(self):
if FreeCAD.ActiveDocument:
@@ -720,8 +720,8 @@ class CommandProhibitedArea:
'ToolTip': "Prohibited Area"}
def Activated(self):
sel = FreeCADGui.Selection.getSelection()
makeProhibitedArea(sel[0])
for base in FreeCADGui.Selection.getSelection():
makeProhibitedArea(base)
def IsActive(self):
if FreeCAD.ActiveDocument:
@@ -763,11 +763,8 @@ class CommandOffsetArea:
'ToolTip': "OffsetArea"}
def Activated(self):
sel = FreeCADGui.Selection.getSelection()
base = None
if sel:
base = sel[0]
obj = makeOffsetArea(base)
for base in FreeCADGui.Selection.getSelection():
makeOffsetArea(base)
def IsActive(self):
if FreeCAD.ActiveDocument:
@@ -776,7 +773,7 @@ class CommandOffsetArea:
return False
if FreeCAD.GuiUp:
'''if FreeCAD.GuiUp:
class CommandAreaGroup:
def GetCommands(self):
@@ -800,4 +797,4 @@ if FreeCAD.GuiUp:
FreeCADGui.addCommand('ForbiddenArea', CommandProhibitedArea())
FreeCADGui.addCommand('PVSubplant', CommandPVSubplant())
FreeCADGui.addCommand('OffsetArea', CommandOffsetArea())
FreeCADGui.addCommand('PVPlantAreas', CommandAreaGroup())
FreeCADGui.addCommand('PVPlantAreas', CommandAreaGroup())'''

View File

@@ -128,7 +128,7 @@ def joinAreas(areas):
shape.fuse(shapes)
return shape
class CommandSplitArea:
'''class CommandSplitArea:
def GetResources(self):
return {'Pixmap': str(os.path.join(PVPlantResources.DirIcons, "split_area.svg")),
'Accel': "A, S",
@@ -162,6 +162,6 @@ class CommandJoinAreas:
if FreeCAD.GuiUp:
FreeCADGui.addCommand('SplitArea', CommandSplitArea())
FreeCADGui.addCommand('JoinAreas', CommandJoinAreas())
FreeCADGui.addCommand('JoinAreas', CommandJoinAreas())'''

View File

@@ -138,7 +138,7 @@ class ProjectSetupDialog(QtGui.QWidget):
def closeForm(self):
self.close()
class CommandProjectSetup:
'''class CommandProjectSetup:
def GetResources(self):
return {'Pixmap': str(os.path.join(DirIcons, "flash.svg")),
'Accel': "P, S",
@@ -159,5 +159,5 @@ class CommandProjectSetup:
if FreeCAD.GuiUp:
FreeCADGui.addCommand('ProjectSetup', CommandProjectSetup())
FreeCADGui.addCommand('ProjectSetup', CommandProjectSetup())'''

View File

@@ -38,7 +38,10 @@ new QWebChannel(qt.webChannelTransport, function (channel)
map.on('mousemove', function(e)
{
MyApp.onMapMove(e.latlng.lat, e.latlng.lng)
MyApp.onMapMove(e.latlng.lat, e.latlng.lng);
const bounds = map.getBounds();
MyApp.onMapZoom(bounds.getSouth(), bounds.getWest(), bounds.getNorth(), bounds.getEast());
});
var DrawShapes;

View File

@@ -201,8 +201,8 @@ def simplifyWire(wire):
else:
i += 1
if closed:
points.append(FreeCAD.Vector(points[0]))
#if closed:
points.append(FreeCAD.Vector(points[0]))
pol = Part.makePolygon(points)
return pol