support other CRS data structures; saved layers in MainWindow
This commit is contained in:
+16
-10
@@ -21,9 +21,11 @@ try:
|
||||
BACKGR_ERROR_COLOR,
|
||||
BACKGR_ERROR_COLOR_LIGHT,
|
||||
)
|
||||
from specklepy_qt_ui.qt_ui.widget_dependencies_upgrade import DependenciesUpgradeDialog
|
||||
from specklepy_qt_ui.qt_ui.widget_dependencies_upgrade import (
|
||||
DependenciesUpgradeDialog,
|
||||
)
|
||||
from specklepy_qt_ui.qt_ui.widget_report import ReportDialog
|
||||
except ModuleNotFoundError:
|
||||
except ModuleNotFoundError:
|
||||
from speckle.specklepy_qt_ui.qt_ui.utils.global_resources import (
|
||||
BACKGR_COLOR,
|
||||
BACKGR_COLOR_LIGHT,
|
||||
@@ -35,7 +37,9 @@ except ModuleNotFoundError:
|
||||
BACKGR_ERROR_COLOR,
|
||||
BACKGR_ERROR_COLOR_LIGHT,
|
||||
)
|
||||
from speckle.specklepy_qt_ui.qt_ui.widget_dependencies_upgrade import DependenciesUpgradeDialog
|
||||
from speckle.specklepy_qt_ui.qt_ui.widget_dependencies_upgrade import (
|
||||
DependenciesUpgradeDialog,
|
||||
)
|
||||
from speckle.specklepy_qt_ui.qt_ui.widget_report import ReportDialog
|
||||
|
||||
|
||||
@@ -283,20 +287,22 @@ class LogWidget(QWidget):
|
||||
|
||||
def getNextBtn(self):
|
||||
index = len(self.used_btns) # get the next "free" button
|
||||
# print(index)
|
||||
# print(self.btns)
|
||||
|
||||
if index >= len(self.btns):
|
||||
# remove first button
|
||||
print(self.layout.itemAt(0).widget())
|
||||
self.layout.itemAt(0).widget().setParent(None)
|
||||
|
||||
# self.used_btns.clear()
|
||||
self.createBtns()
|
||||
index = 0
|
||||
|
||||
btn = self.btns[index]
|
||||
# print(btn)
|
||||
|
||||
return btn, index
|
||||
|
||||
def getLastBtn(self):
|
||||
index = len(self.used_btns) - 1 # get the next "free" button
|
||||
btn = None
|
||||
if index > 0:
|
||||
btn = self.btns[index]
|
||||
|
||||
return btn, index
|
||||
|
||||
def getBtnByKeyword(self, keyword: str):
|
||||
|
||||
+18
-27
@@ -380,6 +380,7 @@ class SpeckleGISDialog(QMainWindow):
|
||||
def addMsg(self, obj: dict):
|
||||
try:
|
||||
self.msgLog.addButton(obj)
|
||||
# last_btn, index = self.msgLog.getLastBtn()
|
||||
except Exception as e:
|
||||
logToUser(str(e), level=2, func=inspect.stack()[0][3], plugin=self)
|
||||
|
||||
@@ -665,15 +666,16 @@ class SpeckleGISDialog(QMainWindow):
|
||||
try:
|
||||
self.layersWidget.clear()
|
||||
nameDisplay = []
|
||||
project = plugin.project
|
||||
project = plugin.dataStorage.project
|
||||
|
||||
if bySelection is False: # read from project data
|
||||
print("populate layers from saved data")
|
||||
# print(project)
|
||||
# print(project.activeMap)
|
||||
|
||||
all_layers_ids = [l.dataSource for l in getAllProjLayers(project)]
|
||||
for layer_tuple in plugin.current_layers:
|
||||
all_layers = getAllProjLayers(plugin)
|
||||
if all_layers is None:
|
||||
return
|
||||
|
||||
all_layers_ids = [l.dataSource for l in all_layers]
|
||||
for layer_tuple in plugin.dataStorage.saved_layers:
|
||||
if layer_tuple[1].dataSource in all_layers_ids:
|
||||
listItem = self.fillLayerList(layer_tuple[1])
|
||||
self.layersWidget.addItem(listItem)
|
||||
@@ -682,16 +684,17 @@ class SpeckleGISDialog(QMainWindow):
|
||||
# Fetch selected layers
|
||||
print("populate layers from selection")
|
||||
|
||||
plugin.current_layers = []
|
||||
layers = getLayers(plugin, bySelection) # List[QgsLayerTreeNode]
|
||||
plugin.dataStorage.current_layers = []
|
||||
layers = getLayers(plugin, bySelection=True) # List[QgsLayerTreeNode]
|
||||
print(layers)
|
||||
for i, layer in enumerate(layers):
|
||||
plugin.current_layers.append((layer.name, layer))
|
||||
listItem = self.fillLayerList(layer)
|
||||
self.layersWidget.addItem(listItem)
|
||||
print("populate layers from selection 2")
|
||||
set_project_layer_selection(plugin)
|
||||
print("populate layers from selection 3")
|
||||
if layers is not None:
|
||||
for i, layer in enumerate(layers):
|
||||
plugin.dataStorage.current_layers.append((layer.name, layer))
|
||||
listItem = self.fillLayerList(layer)
|
||||
self.layersWidget.addItem(listItem)
|
||||
print("populate layers from selection 2")
|
||||
set_project_layer_selection(plugin)
|
||||
print("populate layers from selection 3")
|
||||
|
||||
self.layersWidget.setIconSize(QSize(20, 20))
|
||||
self.runBtnStatusChanged(plugin)
|
||||
@@ -704,18 +707,6 @@ class SpeckleGISDialog(QMainWindow):
|
||||
print("Fill layer list")
|
||||
|
||||
try:
|
||||
ICON_XXL = os.path.dirname(os.path.abspath(__file__)) + "/size-xxl.png"
|
||||
ICON_RASTER = (
|
||||
os.path.dirname(os.path.abspath(__file__)) + "/legend_raster.png"
|
||||
)
|
||||
ICON_POLYGON = (
|
||||
os.path.dirname(os.path.abspath(__file__)) + "/legend_polygon.png"
|
||||
)
|
||||
ICON_LINE = os.path.dirname(os.path.abspath(__file__)) + "/legend_line.png"
|
||||
ICON_POINT = (
|
||||
os.path.dirname(os.path.abspath(__file__)) + "/legend_point.png"
|
||||
)
|
||||
|
||||
listItem = QListWidgetItem(layer.name)
|
||||
# print(listItem)
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save current layer selection</string>
|
||||
<string>Save visible layers as selection</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -6,7 +6,7 @@ try:
|
||||
from specklepy_qt_ui.qt_ui.DataStorage import DataStorage
|
||||
from specklepy_qt_ui.qt_ui.utils.logger import logToUser
|
||||
from specklepy_qt_ui.qt_ui.utils.global_resources import COLOR
|
||||
except ModuleNotFoundError:
|
||||
except ModuleNotFoundError:
|
||||
from speckle.specklepy_qt_ui.qt_ui.DataStorage import DataStorage
|
||||
from speckle.specklepy_qt_ui.qt_ui.utils.logger import logToUser
|
||||
from speckle.specklepy_qt_ui.qt_ui.utils.global_resources import COLOR
|
||||
@@ -26,7 +26,7 @@ FORM_CLASS, _ = uic.loadUiType(
|
||||
|
||||
class CustomCRSDialog(QtWidgets.QWidget, FORM_CLASS):
|
||||
name_field: QtWidgets.QLineEdit = None
|
||||
description_field: QtWidgets.QLineEdit = None
|
||||
description: QtWidgets.QLineEdit = None
|
||||
dialog_button_box: QtWidgets.QDialogButtonBox = None
|
||||
saveSurveyPoint: QtWidgets.QPushButton = None
|
||||
speckle_client: Union[SpeckleClient, None] = None
|
||||
@@ -84,6 +84,7 @@ class CustomCRSDialog(QtWidgets.QWidget, FORM_CLASS):
|
||||
self.offsetYDegreeSign.show()
|
||||
|
||||
units = self.dataStorage.currentOriginalUnits
|
||||
print(units)
|
||||
if units == "degrees":
|
||||
self.offsetXDegreeSign.setText("°")
|
||||
self.offsetYDegreeSign.setText("°")
|
||||
@@ -94,9 +95,17 @@ class CustomCRSDialog(QtWidgets.QWidget, FORM_CLASS):
|
||||
self.offsetXDegreeSign.hide()
|
||||
self.offsetYDegreeSign.hide()
|
||||
|
||||
try:
|
||||
authid = self.dataStorage.currentCRS.authid()
|
||||
except:
|
||||
try:
|
||||
authid = self.dataStorage.currentCRS.name
|
||||
except:
|
||||
authid = str(self.dataStorage.currentCRS)
|
||||
|
||||
text = f"Use this option when your project requires a use of a specific CRS. \
|
||||
\n\nThis will only affect Speckle data properties, not your Project CRS.\
|
||||
\n\nHint: your current project CRS is '{self.dataStorage.currentCRS.authid()}' and using units '{self.dataStorage.currentOriginalUnits}'."
|
||||
\n\nHint: your current project CRS is '{authid}' and using units '{self.dataStorage.currentOriginalUnits}'."
|
||||
|
||||
if units == "degrees":
|
||||
text += "\nThis CRS is not recommended if data was sent or needs to be \
|
||||
|
||||
Reference in New Issue
Block a user