Compare commits
17 Commits
kate/dashboards
...
2.18
| Author | SHA1 | Date | |
|---|---|---|---|
| 240efef89a | |||
| 6db462df3c | |||
| 876068a39a | |||
| d0c464d736 | |||
| ea76011ed2 | |||
| 51b1de4587 | |||
| 2a577de45c | |||
| 937ff8a878 | |||
| d2451a41d8 | |||
| 912ba2d734 | |||
| 99a1c99422 | |||
| 62733b13d8 | |||
| 3ebe5c478d | |||
| fd340a2026 | |||
| b73753d15c | |||
| 90285387f9 | |||
| f773b1b7c6 |
@@ -1,13 +1,17 @@
|
||||
|
||||
from datetime import datetime
|
||||
import inspect
|
||||
from typing import List, Optional, Tuple, Union, Any
|
||||
import webbrowser
|
||||
|
||||
from speckle.utils.panel_logging import logToUser
|
||||
try:
|
||||
from specklepy_qt_ui.qt_ui.utils.logger import logToUser
|
||||
except ModuleNotFoundError:
|
||||
from speckle.specklepy_qt_ui.qt_ui.utils.logger import logToUser
|
||||
|
||||
from specklepy.core.api.credentials import get_local_accounts
|
||||
|
||||
|
||||
class DataStorage:
|
||||
|
||||
plugin_version = "0.0.99"
|
||||
|
||||
project = None
|
||||
@@ -21,65 +25,78 @@ class DataStorage:
|
||||
|
||||
custom_lat: Optional[float] = None
|
||||
custom_lon: Optional[float] = None
|
||||
|
||||
crs_offset_x: Optional[float] = 0
|
||||
crs_offset_y: Optional[float] = 0
|
||||
crs_rotation: Optional[float] = 0
|
||||
|
||||
current_layer_crs_offset_x: Optional[float] = None
|
||||
current_layer_crs_offset_y: Optional[float] = None
|
||||
current_layer_crs_rotation: Optional[float] = None
|
||||
crs_offset_x: Optional[float] = 0
|
||||
crs_offset_y: Optional[float] = 0
|
||||
crs_rotation: Optional[float] = 0
|
||||
|
||||
current_layers: Union[List[Tuple[Any, str, str]], None] = None
|
||||
saved_layers: Union[List, None] = None
|
||||
all_layers: Union[List, None] = None
|
||||
current_layer_crs_offset_x: Optional[float] = None
|
||||
current_layer_crs_offset_y: Optional[float] = None
|
||||
current_layer_crs_rotation: Optional[float] = None
|
||||
|
||||
elevationLayer: None
|
||||
current_layers: Union[List[Tuple[Any, str, str]], None] = None
|
||||
saved_layers: Union[List, None] = None
|
||||
all_layers: Union[List, None] = None
|
||||
|
||||
elevationLayer: None
|
||||
savedTransforms: Union[List, None] = None
|
||||
transformsCatalog: Union[List, None] = None
|
||||
|
||||
matrix = None # if receiving instance with transform
|
||||
matrix = None # if receiving instance with transform
|
||||
|
||||
latestHostApp: str = ""
|
||||
latestActionReport: Optional[list] = None
|
||||
latestActionFeaturesReport: Optional[list] = None
|
||||
latestActionReport: Optional[list] = None
|
||||
latestActionFeaturesReport: Optional[list] = None
|
||||
latestActionTime: str = ""
|
||||
latestActionLayers: Optional[list] = None
|
||||
latestTransferTime: datetime = None
|
||||
latestConversionTime: datetime = None
|
||||
latestActionLayers: Optional[list] = None
|
||||
latestActionUnits: str = ""
|
||||
|
||||
def __init__(self):
|
||||
#print("hello")
|
||||
#self.streamsToFollow.append(("https://speckle.xyz/streams/17b0b76d13/branches/random_tests", "", "09a0f3e41a"))
|
||||
self.transformsCatalog = ["Convert Raster Elevation to a 3d Mesh",
|
||||
"Set Raster as a Texture for the Elevation Layer",
|
||||
"Extrude polygons by selected attribute (randomly populate NULL values)",
|
||||
"Extrude polygons by selected attribute (ignore NULL values)",
|
||||
"Extrude polygons by selected attribute (randomly populate NULL values) and project on 3d elevation",
|
||||
"Extrude polygons by selected attribute (ignore NULL values) and project on 3d elevation"
|
||||
]
|
||||
# print("hello")
|
||||
# self.streamsToFollow.append(("https://speckle.xyz/streams/17b0b76d13/branches/random_tests", "", "09a0f3e41a"))
|
||||
self.transformsCatalog = [
|
||||
"Convert Raster Elevation to a 3d Mesh",
|
||||
"Set Raster as a Texture for the Elevation Layer",
|
||||
"Extrude polygons by selected attribute (randomly populate NULL values)",
|
||||
"Extrude polygons by selected attribute (ignore NULL values)",
|
||||
"Extrude polygons by selected attribute (randomly populate NULL values) and project on 3d elevation",
|
||||
"Extrude polygons by selected attribute (ignore NULL values) and project on 3d elevation",
|
||||
]
|
||||
self.savedTransforms = []
|
||||
self.all_layers = []
|
||||
self.current_layers = []
|
||||
self.saved_layers = []
|
||||
self.accounts = []
|
||||
self.elevationLayer = None
|
||||
self.accounts = []
|
||||
self.elevationLayer = None
|
||||
self.latestActionReport = []
|
||||
self.latestActionFeaturesReport = []
|
||||
self.latestActionLayers = []
|
||||
|
||||
def check_for_accounts(self):
|
||||
try:
|
||||
|
||||
def go_to_manager():
|
||||
webbrowser.open("https://speckle-releases.netlify.app/")
|
||||
|
||||
accounts = get_local_accounts()
|
||||
self.accounts = accounts
|
||||
if len(accounts) == 0:
|
||||
logToUser("No accounts were found. Please remember to install the Speckle Manager and setup at least one account", level = 1, url="https://speckle-releases.netlify.app/", func = inspect.stack()[0][3], plugin = self.dockwidget) #, action_text="Download Manager", callback=go_to_manager)
|
||||
logToUser(
|
||||
"No accounts were found. Please remember to install the Speckle Manager and setup at least one account",
|
||||
level=1,
|
||||
url="https://speckle-releases.netlify.app/",
|
||||
func=inspect.stack()[0][3],
|
||||
plugin=self.dockwidget,
|
||||
) # , action_text="Download Manager", callback=go_to_manager)
|
||||
return False
|
||||
for acc in accounts:
|
||||
if acc.isDefault:
|
||||
self.default_account = acc
|
||||
self.active_account = acc
|
||||
break
|
||||
if acc.isDefault:
|
||||
self.default_account = acc
|
||||
self.active_account = acc
|
||||
break
|
||||
return True
|
||||
except Exception as e:
|
||||
logToUser(e, level = 2, func = inspect.stack()[0][3])
|
||||
logToUser(e, level=2, func=inspect.stack()[0][3])
|
||||
return
|
||||
|
||||
@@ -9,19 +9,34 @@ import webbrowser
|
||||
from specklepy.logging import metrics
|
||||
from specklepy.core.api.credentials import Account
|
||||
|
||||
from specklepy_qt_ui.qt_ui.global_resources import (
|
||||
BACKGR_COLOR,
|
||||
BACKGR_COLOR_LIGHT,
|
||||
BACKGR_COLOR_GREY,
|
||||
BACKGR_COLOR_TRANSPARENT,
|
||||
BACKGR_COLOR_HIGHLIGHT,
|
||||
NEW_GREY,
|
||||
NEW_GREY_HIGHLIGHT,
|
||||
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_report import ReportDialog
|
||||
try:
|
||||
from specklepy_qt_ui.qt_ui.utils.global_resources import (
|
||||
BACKGR_COLOR,
|
||||
BACKGR_COLOR_LIGHT,
|
||||
BACKGR_COLOR_GREY,
|
||||
BACKGR_COLOR_TRANSPARENT,
|
||||
BACKGR_COLOR_HIGHLIGHT,
|
||||
NEW_GREY,
|
||||
NEW_GREY_HIGHLIGHT,
|
||||
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_report import ReportDialog
|
||||
except ModuleNotFoundError:
|
||||
from speckle.specklepy_qt_ui.qt_ui.utils.global_resources import (
|
||||
BACKGR_COLOR,
|
||||
BACKGR_COLOR_LIGHT,
|
||||
BACKGR_COLOR_GREY,
|
||||
BACKGR_COLOR_TRANSPARENT,
|
||||
BACKGR_COLOR_HIGHLIGHT,
|
||||
NEW_GREY,
|
||||
NEW_GREY_HIGHLIGHT,
|
||||
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_report import ReportDialog
|
||||
|
||||
|
||||
class LogWidget(QWidget):
|
||||
@@ -31,7 +46,6 @@ class LogWidget(QWidget):
|
||||
btns: List[QPushButton]
|
||||
max_msg: int
|
||||
sendMessage = pyqtSignal(object)
|
||||
dataStorage = None
|
||||
reportBtn = None
|
||||
|
||||
active_account: Account
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
import os
|
||||
|
||||
# colors
|
||||
COLOR_HIGHLIGHT = (210,210,210,1)
|
||||
SPECKLE_COLOR = (59,130,246,1)
|
||||
SPECKLE_COLOR_LIGHT = (69,140,255,1)
|
||||
ICON_LOGO = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "logo-slab-white@0.5x.png")
|
||||
|
||||
ERROR_COLOR = (255,150,150,1)
|
||||
ERROR_COLOR_LIGHT = (255,210,210,1)
|
||||
|
||||
COLOR = f"color: rgba{str(SPECKLE_COLOR)};"
|
||||
BACKGR_COLOR_TRANSPARENT = f"background-color: rgba(0,0,0,0);"
|
||||
BACKGR_COLOR_HIGHLIGHT = f"background-color: rgba{str(COLOR_HIGHLIGHT)};"
|
||||
BACKGR_COLOR = f"background-color: rgba{str(SPECKLE_COLOR)};"
|
||||
BACKGR_COLOR_LIGHT = f"background-color: rgba{str(SPECKLE_COLOR_LIGHT)};"
|
||||
BACKGR_COLOR_GREY = f"background-color: rgba(220,220,220,1);"
|
||||
|
||||
BACKGR_ERROR_COLOR = f"background-color: rgba{str(ERROR_COLOR)};"
|
||||
BACKGR_ERROR_COLOR_LIGHT = f"background-color: rgba{str(ERROR_COLOR_LIGHT)};"
|
||||
|
||||
NEW_GREY = BACKGR_COLOR_GREY.replace("1);","0.2);")
|
||||
NEW_GREY_HIGHLIGHT = BACKGR_COLOR_HIGHLIGHT.replace("1);","0.3);")
|
||||
|
||||
# images
|
||||
ICON_SEARCH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "magnify.png")
|
||||
ICON_OPEN_WEB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "open-in-new.png")
|
||||
ICON_REPORT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "chart-line.png")
|
||||
|
||||
ICON_DELETE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "delete.png")
|
||||
ICON_DELETE_BLUE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "delete-blue.png")
|
||||
|
||||
ICON_SEND = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "cube-send.png")
|
||||
ICON_RECEIVE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "cube-receive.png")
|
||||
|
||||
ICON_SEND_BLACK = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "cube-send-black.png")
|
||||
ICON_RECEIVE_BLACK = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "cube-receive-black.png")
|
||||
|
||||
ICON_SEND_BLUE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "cube-send-blue.png")
|
||||
ICON_RECEIVE_BLUE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "cube-receive-blue.png")
|
||||
|
||||
ICON_XXL = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "/size-xxl.png")
|
||||
ICON_RASTER = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "/legend_raster.png")
|
||||
ICON_POLYGON = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "/legend_polygon.png")
|
||||
ICON_LINE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "/legend_line.png")
|
||||
ICON_POINT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "/legend_point.png")
|
||||
ICON_GENERIC = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "/legend_generic.png")
|
||||
@@ -50,14 +50,24 @@ except:
|
||||
|
||||
|
||||
# This loads your .ui file so that PyQt can populate your plugin with the elements from Qt Designer
|
||||
from specklepy_qt_ui.qt_ui.global_resources import (
|
||||
try:
|
||||
from specklepy_qt_ui.qt_ui.global_resources import (
|
||||
COLOR_HIGHLIGHT,
|
||||
SPECKLE_COLOR, SPECKLE_COLOR_LIGHT,
|
||||
ICON_LOGO, ICON_SEARCH, ICON_DELETE, ICON_DELETE_BLUE,
|
||||
ICON_SEND, ICON_RECEIVE, ICON_SEND_BLACK, ICON_RECEIVE_BLACK,
|
||||
ICON_SEND_BLUE, ICON_RECEIVE_BLUE,
|
||||
COLOR, BACKGR_COLOR, BACKGR_COLOR_LIGHT,
|
||||
)
|
||||
)
|
||||
except ModuleNotFoundError:
|
||||
from speckle.specklepy_qt_ui.qt_ui.global_resources import (
|
||||
COLOR_HIGHLIGHT,
|
||||
SPECKLE_COLOR, SPECKLE_COLOR_LIGHT,
|
||||
ICON_LOGO, ICON_SEARCH, ICON_DELETE, ICON_DELETE_BLUE,
|
||||
ICON_SEND, ICON_RECEIVE, ICON_SEND_BLACK, ICON_RECEIVE_BLACK,
|
||||
ICON_SEND_BLUE, ICON_RECEIVE_BLUE,
|
||||
COLOR, BACKGR_COLOR, BACKGR_COLOR_LIGHT,
|
||||
)
|
||||
|
||||
ui_class = uic.loadUiType(
|
||||
os.path.join(os.path.dirname(__file__), os.path.join("ui", "mainWindow.ui") )
|
||||
@@ -416,7 +426,7 @@ class SpeckleGISDialog(QMainWindow):
|
||||
try:
|
||||
from speckle.ui.project_vars import set_project_layer_selection
|
||||
except:
|
||||
from speckle_toolbox.esri.toolboxes.speckle.ui.project_vars import set_project_layer_selection
|
||||
from speckle_toolbox.esri.toolboxes.speckle.speckle.ui.project_vars import set_project_layer_selection
|
||||
|
||||
try:
|
||||
self.layersWidget.clear()
|
||||
@@ -518,7 +528,7 @@ class SpeckleGISDialog(QMainWindow):
|
||||
try:
|
||||
from speckle.ui.project_vars import set_project_streams
|
||||
except:
|
||||
from speckle_toolbox.esri.toolboxes.speckle.ui.project_vars import set_project_streams
|
||||
from speckle_toolbox.esri.toolboxes.speckle.speckle.ui.project_vars import set_project_streams
|
||||
|
||||
try:
|
||||
if not self: return
|
||||
|
||||
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 345 B After Width: | Height: | Size: 345 B |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 400 B After Width: | Height: | Size: 400 B |
@@ -0,0 +1,83 @@
|
||||
import os
|
||||
|
||||
# colors
|
||||
COLOR_HIGHLIGHT = (210, 210, 210, 1)
|
||||
SPECKLE_COLOR = (59, 130, 246, 1)
|
||||
SPECKLE_COLOR_LIGHT = (69, 140, 255, 1)
|
||||
ICON_LOGO = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "assets", "logo-slab-white@0.5x.png"
|
||||
)
|
||||
|
||||
ERROR_COLOR = (255, 150, 150, 1)
|
||||
ERROR_COLOR_LIGHT = (255, 210, 210, 1)
|
||||
|
||||
COLOR = f"color: rgba{str(SPECKLE_COLOR)};"
|
||||
BACKGR_COLOR_TRANSPARENT = f"background-color: rgba(0,0,0,0);"
|
||||
BACKGR_COLOR_HIGHLIGHT = f"background-color: rgba{str(COLOR_HIGHLIGHT)};"
|
||||
BACKGR_COLOR = f"background-color: rgba{str(SPECKLE_COLOR)};"
|
||||
BACKGR_COLOR_LIGHT = f"background-color: rgba{str(SPECKLE_COLOR_LIGHT)};"
|
||||
BACKGR_COLOR_GREY = f"background-color: rgba(220,220,220,1);"
|
||||
|
||||
BACKGR_ERROR_COLOR = f"background-color: rgba{str(ERROR_COLOR)};"
|
||||
BACKGR_ERROR_COLOR_LIGHT = f"background-color: rgba{str(ERROR_COLOR_LIGHT)};"
|
||||
|
||||
NEW_GREY = BACKGR_COLOR_GREY.replace("1);", "0.2);")
|
||||
NEW_GREY_HIGHLIGHT = BACKGR_COLOR_HIGHLIGHT.replace("1);", "0.3);")
|
||||
|
||||
# images
|
||||
ICON_SEARCH = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "assets", "magnify.png"
|
||||
)
|
||||
ICON_OPEN_WEB = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "assets", "open-in-new.png"
|
||||
)
|
||||
ICON_REPORT = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "assets", "chart-line.png"
|
||||
)
|
||||
|
||||
ICON_DELETE = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "assets", "delete.png"
|
||||
)
|
||||
ICON_DELETE_BLUE = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "assets", "delete-blue.png"
|
||||
)
|
||||
|
||||
ICON_SEND = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "assets", "cube-send.png"
|
||||
)
|
||||
ICON_RECEIVE = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "assets", "cube-receive.png"
|
||||
)
|
||||
|
||||
ICON_SEND_BLACK = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "assets", "cube-send-black.png"
|
||||
)
|
||||
ICON_RECEIVE_BLACK = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "assets", "cube-receive-black.png"
|
||||
)
|
||||
|
||||
ICON_SEND_BLUE = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "assets", "cube-send-blue.png"
|
||||
)
|
||||
ICON_RECEIVE_BLUE = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "assets", "cube-receive-blue.png"
|
||||
)
|
||||
|
||||
ICON_XXL = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "assets", "size-xxl.png"
|
||||
)
|
||||
ICON_RASTER = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "assets", "legend_raster.png"
|
||||
)
|
||||
ICON_POLYGON = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "assets", "legend_polygon.png"
|
||||
)
|
||||
ICON_LINE = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "assets", "legend_line.png"
|
||||
)
|
||||
ICON_POINT = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "assets", "legend_point.png"
|
||||
)
|
||||
ICON_GENERIC = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "assets", "legend_generic.png"
|
||||
)
|
||||
@@ -1,7 +1,7 @@
|
||||
from PyQt5.QtWidgets import QMessageBox
|
||||
from PyQt5 import QtCore
|
||||
|
||||
from specklepy_qt_ui.qt_ui.utils import splitTextIntoLines
|
||||
try:
|
||||
from specklepy_qt_ui.qt_ui.utils.utils import splitTextIntoLines
|
||||
except ModuleNotFoundError:
|
||||
from speckle.specklepy_qt_ui.qt_ui.utils.utils import splitTextIntoLines
|
||||
|
||||
|
||||
def logToUser(
|
||||
@@ -55,6 +55,9 @@ def displayUserMsg(msg: str, func=None, level: int = 2):
|
||||
|
||||
def createWindow(msg_old: str, func=None, level: int = 2):
|
||||
# print("Create window")
|
||||
from PyQt5.QtWidgets import QMessageBox
|
||||
from PyQt5 import QtCore
|
||||
|
||||
window = None
|
||||
try:
|
||||
# https://www.techwithtim.net/tutorials/pyqt5-tutorial/messageboxes/
|
||||
@@ -1,9 +1,9 @@
|
||||
from textwrap import wrap
|
||||
from typing import Union
|
||||
import requests
|
||||
|
||||
|
||||
def splitTextIntoLines(text: str = "", number: int = 40) -> str:
|
||||
# print("__splitTextIntoLines")
|
||||
# print(text)
|
||||
msg = ""
|
||||
try:
|
||||
if len(text) > number:
|
||||
@@ -27,8 +27,10 @@ def splitTextIntoLines(text: str = "", number: int = 40) -> str:
|
||||
|
||||
|
||||
def constructCommitURL(
|
||||
streamWrapper, branch_id: str = None, commit_id: str = None
|
||||
) -> str:
|
||||
streamWrapper,
|
||||
branch_id: Union[str, None] = None,
|
||||
commit_id: Union[str, None] = None,
|
||||
) -> Union[str, None]:
|
||||
import requests
|
||||
|
||||
try:
|
||||
@@ -40,7 +42,7 @@ def constructCommitURL(
|
||||
url = streamUrl
|
||||
# check for frontend2
|
||||
try:
|
||||
header = r.headers["x-speckle-frontend-2"]
|
||||
header = r.headers["x-speckle-frontend-2"] # will throw Exception in FE1
|
||||
url = (
|
||||
streamUrl.replace("streams", "projects")
|
||||
+ "/models/"
|
||||
@@ -52,26 +54,21 @@ def constructCommitURL(
|
||||
url = streamUrl.replace("projects", "streams") + "/commits/" + commit_id
|
||||
return url
|
||||
except:
|
||||
pass
|
||||
return None
|
||||
|
||||
|
||||
def constructCommitURLfromServerCommit(serverURL: str, stream_id: str) -> str:
|
||||
import requests
|
||||
|
||||
r = requests.get(serverURL)
|
||||
|
||||
# check for frontend2
|
||||
# only check the url string
|
||||
try:
|
||||
header = r.headers["x-speckle-frontend-2"]
|
||||
# url = streamUrl.replace("streams", "projects") + "/models/" + branch_id + "@" + commit_id
|
||||
url = (
|
||||
serverURL + "/projects/" + stream_id
|
||||
) # replace with 'projects' after it's implemented in Specklepy
|
||||
except:
|
||||
serverURL
|
||||
+ "/projects/"
|
||||
+ stream_id # + "/models/" + branch_id + "@" + commit_id
|
||||
)
|
||||
except KeyError:
|
||||
url = serverURL + "/streams/" + stream_id
|
||||
return url
|
||||
|
||||
|
||||
# def removeSpecialCharacters(text: str) -> str:
|
||||
# new_text = text.replace("[","_").replace("]","_").replace(" ","_").replace("-","_").replace("(","_").replace(")","_").replace(":","_").replace("\\","_").replace("/","_").replace("\"","_").replace("&","_").replace("@","_").replace("$","_").replace("%","_").replace("^","_")
|
||||
# return new_text
|
||||
@@ -2,9 +2,14 @@ import inspect
|
||||
import os
|
||||
from typing import List, Union
|
||||
import urllib.parse
|
||||
|
||||
from specklepy_qt_ui.qt_ui.DataStorage import DataStorage
|
||||
from specklepy_qt_ui.qt_ui.logger import logToUser
|
||||
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.utils import constructCommitURLfromServerCommit
|
||||
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.utils import constructCommitURLfromServerCommit
|
||||
|
||||
from PyQt5 import QtWidgets, uic, QtCore
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
@@ -16,7 +21,6 @@ from specklepy.core.api.credentials import get_local_accounts # , StreamWrapper
|
||||
from specklepy.core.api.wrapper import StreamWrapper
|
||||
from specklepy.logging import metrics
|
||||
|
||||
from specklepy_qt_ui.qt_ui.utils import constructCommitURLfromServerCommit
|
||||
|
||||
# This loads your .ui file so that PyQt can populate your plugin with the elements from Qt Designer
|
||||
FORM_CLASS, _ = uic.loadUiType(
|
||||
@@ -117,61 +121,33 @@ class AddStreamModalDialog(QtWidgets.QWidget, FORM_CLASS):
|
||||
streams = []
|
||||
branch = None
|
||||
commit = None
|
||||
# print("_____ onSearchClicked___")
|
||||
if "http" in query and len(query.split("/")) >= 3: # URL
|
||||
sw = StreamWrapper(query)
|
||||
sw = StreamWrapper(
|
||||
query,
|
||||
)
|
||||
stream = sw.get_client().stream.get(
|
||||
id=sw.stream_id, branch_limit=100, commit_limit=100
|
||||
)
|
||||
if isinstance(stream, Stream):
|
||||
streams = [stream]
|
||||
|
||||
if "/branches/" in query:
|
||||
# print("branches")
|
||||
branch_name = (
|
||||
query.split("/branches/")[
|
||||
len(query.split("/branches/")) - 1
|
||||
]
|
||||
.split("/")[0]
|
||||
.split("?")[0]
|
||||
.split("&")[0]
|
||||
.split("@")[0]
|
||||
)
|
||||
# print(branch_name)
|
||||
# print(stream)
|
||||
# print(len(stream.branches.items))
|
||||
if sw.type == "branch":
|
||||
branch_name = sw.branch_name
|
||||
for br in stream.branches.items:
|
||||
name = urllib.parse.quote(br.name)
|
||||
# print(name)
|
||||
if name == branch_name:
|
||||
if br.name == branch_name:
|
||||
branch = br
|
||||
break
|
||||
elif "/commits/" in query:
|
||||
# print("commits")
|
||||
commit_id = (
|
||||
query.split("/commits/")[len(query.split("/commits/")) - 1]
|
||||
.split("/")[0]
|
||||
.split("?")[0]
|
||||
.split("&")[0]
|
||||
.split("@")[0]
|
||||
)
|
||||
if sw.type == "commit":
|
||||
commit_id = sw.commit_id
|
||||
for br in stream.branches.items:
|
||||
for com in br.commits.items:
|
||||
if com.id == commit_id:
|
||||
branch = br
|
||||
commit = com
|
||||
# print(branch)
|
||||
# print(commit)
|
||||
break
|
||||
elif isinstance(stream, Exception):
|
||||
print(stream)
|
||||
# if "/commits/" in query:
|
||||
# branch_id = query.split("/commits/")[len(query.split("/commits/"))-1].split("/")[0].split("?")[0].split("&")[0].split("@")[0]
|
||||
# for com in stream.
|
||||
# if br.id == branch_id:
|
||||
# branch = br
|
||||
# break
|
||||
|
||||
try:
|
||||
metrics.track(
|
||||
"Connector Action",
|
||||
@@ -260,13 +236,12 @@ class AddStreamModalDialog(QtWidgets.QWidget, FORM_CLASS):
|
||||
else:
|
||||
try:
|
||||
index = self.search_results_list.currentIndex().row()
|
||||
stream = self.stream_results[index]
|
||||
# stream = self.stream_results[index]
|
||||
item = self.search_results_list.item(index)
|
||||
url = constructCommitURLfromServerCommit(
|
||||
item.text().split(" | ")[1],
|
||||
item.text().split(", ")[1].split(" | ")[0],
|
||||
)
|
||||
# url = item.text().split(" | ")[1] + "/streams/" + item.text().split(", ")[1].split(" | ")[0]
|
||||
sw = StreamWrapper(url)
|
||||
|
||||
try:
|
||||
@@ -294,9 +269,11 @@ class AddStreamModalDialog(QtWidgets.QWidget, FORM_CLASS):
|
||||
level=1,
|
||||
func=inspect.stack()[0][3],
|
||||
)
|
||||
print(e)
|
||||
return
|
||||
except Exception as e:
|
||||
logToUser(e, level=2, func=inspect.stack()[0][3])
|
||||
print(e)
|
||||
return
|
||||
|
||||
def onCancelClicked(self):
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import inspect
|
||||
import os
|
||||
from typing import List, Tuple, Union
|
||||
from specklepy_qt_ui.qt_ui.logger import logToUser
|
||||
|
||||
try:
|
||||
from specklepy_qt_ui.qt_ui.utils.logger import logToUser
|
||||
except ModuleNotFoundError:
|
||||
from speckle.specklepy_qt_ui.qt_ui.utils.logger import logToUser
|
||||
|
||||
from PyQt5 import QtWidgets, uic, QtCore
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import inspect
|
||||
import os
|
||||
from typing import List, Tuple, Union
|
||||
from specklepy_qt_ui.qt_ui.logger import logToUser
|
||||
|
||||
try:
|
||||
from specklepy_qt_ui.qt_ui.utils.logger import logToUser
|
||||
except ModuleNotFoundError:
|
||||
from speckle.specklepy_qt_ui.qt_ui.utils.logger import logToUser
|
||||
|
||||
from PyQt5 import QtWidgets, uic, QtCore
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
|
||||
@@ -1,80 +1,90 @@
|
||||
import inspect
|
||||
import os
|
||||
from typing import List, Tuple, Union
|
||||
from specklepy_qt_ui.qt_ui.DataStorage import DataStorage
|
||||
from specklepy_qt_ui.qt_ui.logger import logToUser
|
||||
|
||||
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:
|
||||
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
|
||||
|
||||
from PyQt5 import QtWidgets, uic, QtCore
|
||||
from PyQt5.QtWidgets import QCheckBox, QListWidgetItem, QHBoxLayout, QWidget
|
||||
from PyQt5.QtWidgets import QCheckBox, QListWidgetItem, QHBoxLayout, QWidget
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
|
||||
from specklepy.core.api.client import SpeckleClient
|
||||
|
||||
from specklepy_qt_ui.qt_ui.global_resources import COLOR
|
||||
|
||||
# This loads your .ui file so that PyQt can populate your plugin with the elements from Qt Designer
|
||||
FORM_CLASS, _ = uic.loadUiType(
|
||||
os.path.join(os.path.join(os.path.dirname(__file__), "ui", "custom_crs.ui") )
|
||||
os.path.join(os.path.join(os.path.dirname(__file__), "ui", "custom_crs.ui"))
|
||||
)
|
||||
|
||||
class CustomCRSDialog(QtWidgets.QWidget, FORM_CLASS):
|
||||
|
||||
class CustomCRSDialog(QtWidgets.QWidget, FORM_CLASS):
|
||||
name_field: QtWidgets.QLineEdit = None
|
||||
description_field: QtWidgets.QLineEdit = None
|
||||
dialog_button_box: QtWidgets.QDialogButtonBox = None
|
||||
saveSurveyPoint: QtWidgets.QPushButton = None
|
||||
speckle_client: Union[SpeckleClient, None] = None
|
||||
dataStorage: DataStorage = None
|
||||
dataStorage: DataStorage = None
|
||||
|
||||
#Events
|
||||
#handleCRSCreate = pyqtSignal(str,str)
|
||||
# Events
|
||||
# handleCRSCreate = pyqtSignal(str,str)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
|
||||
super(CustomCRSDialog,self).__init__(parent, QtCore.Qt.WindowStaysOnTopHint)
|
||||
super(CustomCRSDialog, self).__init__(parent, QtCore.Qt.WindowStaysOnTopHint)
|
||||
self.setupUi(self)
|
||||
self.setWindowTitle("Set project center on Send/Receive")
|
||||
|
||||
#self.dialog_button_box.button(QtWidgets.QDialogButtonBox.Close).clicked.connect(self.onCancelClicked)
|
||||
self.dialog_button_box.button(QtWidgets.QDialogButtonBox.Cancel).setText("More Info")
|
||||
self.setWindowTitle("Set project center on Send/Receive")
|
||||
|
||||
# self.dialog_button_box.button(QtWidgets.QDialogButtonBox.Close).clicked.connect(self.onCancelClicked)
|
||||
self.dialog_button_box.button(QtWidgets.QDialogButtonBox.Cancel).setText(
|
||||
"More Info"
|
||||
)
|
||||
self.modeDropdown.currentIndexChanged.connect(self.onModeChanged)
|
||||
|
||||
|
||||
def onModeChanged(self):
|
||||
try:
|
||||
if not self: return
|
||||
if not self:
|
||||
return
|
||||
index = self.modeDropdown.currentIndex()
|
||||
if index == 1: # custom crs
|
||||
if index == 1: # custom crs
|
||||
self.surveyPointLat.show()
|
||||
self.surveyPointLon.show()
|
||||
self.degreeSignX.show()
|
||||
self.degreeSignY.show()
|
||||
self.label_survey.show()
|
||||
|
||||
|
||||
self.offsetX.hide()
|
||||
self.offsetY.hide()
|
||||
self.label_offsets.hide()
|
||||
self.offsetXDegreeSign.hide()
|
||||
self.offsetYDegreeSign.hide()
|
||||
self.description.setText("Use this option when you don't have to use a specific CRS.\
|
||||
self.description.setText(
|
||||
"Use this option when you don't have to use a specific CRS.\
|
||||
\n\nThis will change your Project CRS to a new custom CRS.\
|
||||
\n\nHint: right-click on the canvas -> Copy Coordinate -> EPSG:4326. ")
|
||||
\n\nHint: right-click on the canvas -> Copy Coordinate -> EPSG:4326. "
|
||||
)
|
||||
|
||||
elif index == 0: # offsets
|
||||
elif index == 0: # offsets
|
||||
self.surveyPointLat.hide()
|
||||
self.surveyPointLon.hide()
|
||||
self.degreeSignX.hide()
|
||||
self.degreeSignY.hide()
|
||||
self.label_survey.hide()
|
||||
|
||||
|
||||
self.offsetX.show()
|
||||
self.offsetY.show()
|
||||
self.label_offsets.show()
|
||||
#if self.dataStorage.currentOriginalUnits == 'degrees':
|
||||
# if self.dataStorage.currentOriginalUnits == 'degrees':
|
||||
self.offsetXDegreeSign.show()
|
||||
self.offsetYDegreeSign.show()
|
||||
|
||||
|
||||
units = self.dataStorage.currentOriginalUnits
|
||||
if units == 'degrees':
|
||||
if units == "degrees":
|
||||
self.offsetXDegreeSign.setText("°")
|
||||
self.offsetYDegreeSign.setText("°")
|
||||
elif units is not None:
|
||||
@@ -83,49 +93,56 @@ class CustomCRSDialog(QtWidgets.QWidget, FORM_CLASS):
|
||||
else:
|
||||
self.offsetXDegreeSign.hide()
|
||||
self.offsetYDegreeSign.hide()
|
||||
|
||||
|
||||
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}'."
|
||||
|
||||
if units == 'degrees':
|
||||
if units == "degrees":
|
||||
text += "\nThis CRS is not recommended if data was sent or needs to be \
|
||||
\nreceived in a non-GIS application."
|
||||
|
||||
|
||||
self.description.setText(text)
|
||||
|
||||
|
||||
self.populateSurveyPoint()
|
||||
self.populateOffsets()
|
||||
self.populateRotation()
|
||||
|
||||
except Exception as e:
|
||||
logToUser(e, level = 2, func = inspect.stack()[0][3])
|
||||
logToUser(e, level=2, func=inspect.stack()[0][3])
|
||||
return
|
||||
|
||||
|
||||
def populateModeDropdown(self):
|
||||
if not self: return
|
||||
if not self:
|
||||
return
|
||||
try:
|
||||
self.modeDropdown.clear()
|
||||
self.modeDropdown.addItems(
|
||||
["Add offsets / rotation to the current Project CRS", "Create custom CRS"]
|
||||
[
|
||||
"Add offsets / rotation to the current Project CRS",
|
||||
"Create custom CRS",
|
||||
]
|
||||
)
|
||||
except Exception as e:
|
||||
logToUser(e, level = 2, func = inspect.stack()[0][3], plugin=self)
|
||||
logToUser(e, level=2, func=inspect.stack()[0][3], plugin=self)
|
||||
return
|
||||
|
||||
|
||||
def populateSurveyPoint(self):
|
||||
if not self:
|
||||
return
|
||||
try:
|
||||
self.surveyPointLat.clear()
|
||||
self.surveyPointLon.clear()
|
||||
if self.dataStorage.custom_lat is not None and self.dataStorage.custom_lon is not None:
|
||||
if (
|
||||
self.dataStorage.custom_lat is not None
|
||||
and self.dataStorage.custom_lon is not None
|
||||
):
|
||||
self.surveyPointLat.setText(str(self.dataStorage.custom_lat))
|
||||
self.surveyPointLon.setText(str(self.dataStorage.custom_lon))
|
||||
except Exception as e:
|
||||
logToUser(e, level = 2, func = inspect.stack()[0][3], plugin=self)
|
||||
logToUser(e, level=2, func=inspect.stack()[0][3], plugin=self)
|
||||
return
|
||||
|
||||
|
||||
def populateRotation(self):
|
||||
if not self:
|
||||
return
|
||||
@@ -134,19 +151,22 @@ class CustomCRSDialog(QtWidgets.QWidget, FORM_CLASS):
|
||||
if self.dataStorage.crs_rotation is not None:
|
||||
self.rotation.setText(str(self.dataStorage.crs_rotation))
|
||||
except Exception as e:
|
||||
logToUser(e, level = 2, func = inspect.stack()[0][3], plugin=self)
|
||||
logToUser(e, level=2, func=inspect.stack()[0][3], plugin=self)
|
||||
return
|
||||
|
||||
def populateOffsets(self):
|
||||
try:
|
||||
self.offsetX.clear()
|
||||
self.offsetY.clear()
|
||||
if self.dataStorage.crs_offset_x is not None and self.dataStorage.crs_offset_y is not None:
|
||||
if (
|
||||
self.dataStorage.crs_offset_x is not None
|
||||
and self.dataStorage.crs_offset_y is not None
|
||||
):
|
||||
self.offsetX.setText(str(self.dataStorage.crs_offset_x))
|
||||
self.offsetY.setText(str(self.dataStorage.crs_offset_y))
|
||||
|
||||
|
||||
except Exception as e:
|
||||
logToUser(e, level = 2, func = inspect.stack()[0][3], plugin=self)
|
||||
logToUser(e, level=2, func=inspect.stack()[0][3], plugin=self)
|
||||
return
|
||||
|
||||
def onOkClicked(self):
|
||||
@@ -154,5 +174,5 @@ class CustomCRSDialog(QtWidgets.QWidget, FORM_CLASS):
|
||||
try:
|
||||
self.close()
|
||||
except Exception as e:
|
||||
logToUser(e, level = 2, func = inspect.stack()[0][3])
|
||||
logToUser(e, level=2, func=inspect.stack()[0][3])
|
||||
return
|
||||
|
||||
@@ -3,7 +3,11 @@ import urllib3
|
||||
import requests
|
||||
import requests_toolbelt
|
||||
from specklepy.logging import metrics
|
||||
from specklepy_qt_ui.qt_ui.DataStorage import DataStorage
|
||||
|
||||
try:
|
||||
from specklepy_qt_ui.qt_ui.DataStorage import DataStorage
|
||||
except ModuleNotFoundError:
|
||||
from speckle.specklepy_qt_ui.qt_ui.DataStorage import DataStorage
|
||||
|
||||
from PyQt5 import QtWidgets, uic, QtCore
|
||||
|
||||
@@ -91,23 +95,17 @@ To do it manually, you can run 2 following commands from QGIS Plugins panel->Pyt
|
||||
|
||||
result1 = subprocess.run(
|
||||
[path(), "-m", "pip", "install", "requests==2.31.0"],
|
||||
shell=True,
|
||||
timeout=1000,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
result2 = subprocess.run(
|
||||
[path(), "-m", "pip", "install", "urllib3==1.26.16"],
|
||||
shell=True,
|
||||
timeout=1000,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
result3 = subprocess.run(
|
||||
[path(), "-m", "pip", "install", "requests_toolbelt==0.10.1"],
|
||||
shell=True,
|
||||
timeout=1000,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
return result1, result2, result3
|
||||
|
||||
@@ -1,70 +1,79 @@
|
||||
import inspect
|
||||
import os
|
||||
from typing import List, Tuple, Union
|
||||
from specklepy_qt_ui.qt_ui.DataStorage import DataStorage
|
||||
#from specklepy_qt_ui.qt_ui.logger import logToUser
|
||||
|
||||
try:
|
||||
from specklepy_qt_ui.qt_ui.DataStorage import DataStorage
|
||||
from specklepy_qt_ui.qt_ui.utils.global_resources import COLOR
|
||||
except ModuleNotFoundError:
|
||||
from speckle.specklepy_qt_ui.qt_ui.DataStorage import DataStorage
|
||||
from speckle.specklepy_qt_ui.qt_ui.utils.global_resources import COLOR
|
||||
|
||||
# from specklepy_qt_ui.qt_ui.utils.logger import logToUser
|
||||
|
||||
from PyQt5 import QtWidgets, uic, QtCore
|
||||
from PyQt5.QtWidgets import QCheckBox, QListWidgetItem, QHBoxLayout, QWidget
|
||||
from PyQt5.QtWidgets import QCheckBox, QListWidgetItem, QHBoxLayout, QWidget
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
|
||||
from specklepy.core.api.client import SpeckleClient
|
||||
|
||||
from specklepy_qt_ui.qt_ui.global_resources import COLOR
|
||||
|
||||
# This loads your .ui file so that PyQt can populate your plugin with the elements from Qt Designer
|
||||
FORM_CLASS, _ = uic.loadUiType(
|
||||
os.path.join(os.path.join(os.path.dirname(__file__), "ui", "report.ui") )
|
||||
os.path.join(os.path.join(os.path.dirname(__file__), "ui", "report.ui"))
|
||||
)
|
||||
|
||||
class ReportDialog(QtWidgets.QWidget, FORM_CLASS):
|
||||
|
||||
class ReportDialog(QtWidgets.QWidget, FORM_CLASS):
|
||||
report_label: QtWidgets.QLabel = None
|
||||
report_text: QtWidgets.QTextEdit = None
|
||||
dataStorage: DataStorage = None
|
||||
|
||||
def __init__(self, parent=None):
|
||||
|
||||
super(ReportDialog,self).__init__(parent, QtCore.Qt.WindowStaysOnTopHint)
|
||||
super(ReportDialog, self).__init__(parent, QtCore.Qt.WindowStaysOnTopHint)
|
||||
self.setupUi(self)
|
||||
self.runAllSetup()
|
||||
|
||||
|
||||
def runAllSetup(self):
|
||||
self.setWindowTitle("Report (Speckle)")
|
||||
self.setWindowTitle("Report (Speckle)")
|
||||
self.setMinimumWidth(500)
|
||||
self.setMinimumHeight(600)
|
||||
self.report_label.setWordWrap(True)
|
||||
self.dialog_button_box.button(QtWidgets.QDialogButtonBox.Ok).clicked.connect(self.onOkClicked)
|
||||
self.dialog_button_box.button(QtWidgets.QDialogButtonBox.Ok).clicked.connect(
|
||||
self.onOkClicked
|
||||
)
|
||||
|
||||
return
|
||||
#self.dialog_button_box.button(QtWidgets.QDialogButtonBox.Cancel).setText("More Info")
|
||||
|
||||
# self.dialog_button_box.button(QtWidgets.QDialogButtonBox.Cancel).setText("More Info")
|
||||
|
||||
def assembleReport(self):
|
||||
try:
|
||||
if self.dataStorage is None: return
|
||||
if self.dataStorage is None:
|
||||
return
|
||||
reportList = self.dataStorage.latestActionReport
|
||||
if reportList is None: return
|
||||
if reportList is None:
|
||||
return
|
||||
|
||||
operation = ""
|
||||
total_layers = 0
|
||||
total_objects = 0
|
||||
text = ""
|
||||
sending = True
|
||||
|
||||
# details
|
||||
|
||||
# details
|
||||
last_report = ""
|
||||
last_report += "Details:" + "\n"
|
||||
for item in reportList:
|
||||
line = "✅ "
|
||||
try: # if sending
|
||||
try: # if sending
|
||||
line += f'{item["feature_id"]}: {item["obj_type"]}'
|
||||
operation = f"Sent at {self.dataStorage.latestActionTime}"
|
||||
except: # if receiving
|
||||
except: # if receiving
|
||||
sending = False
|
||||
line += f'{item["speckle_id"]}: {item["obj_type"]}'
|
||||
operation = f"Received at {self.dataStorage.latestActionTime}"
|
||||
|
||||
# edit based on the type
|
||||
|
||||
# edit based on the type
|
||||
if "Layer" in item["obj_type"]:
|
||||
total_layers += 1
|
||||
if item["errors"] != "":
|
||||
@@ -75,61 +84,75 @@ class ReportDialog(QtWidgets.QWidget, FORM_CLASS):
|
||||
if item["errors"] != "":
|
||||
line += f', errors: {item["errors"]}'
|
||||
line = "❌ " + line[1:]
|
||||
else: total_objects += 1
|
||||
else:
|
||||
total_objects += 1
|
||||
line = "__ " + line
|
||||
|
||||
last_report += line + "\n"
|
||||
|
||||
text += f"Operation: {operation}\n"
|
||||
text += f"Total: {total_layers} layer{'' if str(total_layers).endswith('1') else 's'}, {total_objects} feature{'' if str(total_objects).endswith('1') else 's'}\n\n"
|
||||
if sending is False:
|
||||
if sending is False:
|
||||
try:
|
||||
text += f"Host application: {self.dataStorage.latestHostApp}\n\n"
|
||||
except: pass
|
||||
except:
|
||||
pass
|
||||
|
||||
# layers and transformations (if applicable)
|
||||
text += "Layers and transformations (if applicable):" + "\n"
|
||||
for i, layer in enumerate(self.dataStorage.latestActionLayers):
|
||||
#print(self.dataStorage.latestActionLayers)
|
||||
name = layer #if isinstance(layer, str) else layer.name()
|
||||
try:
|
||||
# print(self.dataStorage.latestActionLayers)
|
||||
name = layer # if isinstance(layer, str) else layer.name()
|
||||
try:
|
||||
transformExists = 0
|
||||
for item in self.dataStorage.savedTransforms:
|
||||
layer_name = item.split(" -> ")[0].split(" (\'")[0]
|
||||
layer_name = item.split(" -> ")[0].split(" ('")[0]
|
||||
transform_name = item.split(" -> ")[1]
|
||||
if layer_name == name:
|
||||
text += f"{i+1}. {layer_name} -> '{transform_name}'" + "\n"
|
||||
text += (
|
||||
f"{i+1}. {layer_name} -> '{transform_name}'" + "\n"
|
||||
)
|
||||
transformExists += 1
|
||||
break
|
||||
if transformExists==0:
|
||||
break
|
||||
if transformExists == 0:
|
||||
text += f"{i+1}. {name} \n"
|
||||
except Exception as e: print(e)
|
||||
text += "\n"
|
||||
except Exception as e:
|
||||
print(e)
|
||||
text += "\n"
|
||||
|
||||
# add info about the offsets
|
||||
text += "Project CRS: " + self.dataStorage.project.crs().authid() + "\n"
|
||||
units = self.dataStorage.latestActionUnits
|
||||
text += "Project CRS units: " + units + f"{' (not supported, treated as Meters)' if 'degrees' in units else ''}" + "\n"
|
||||
text += "Project CRS WKT: \n" + self.dataStorage.project.crs().toWkt() + "\n\n"
|
||||
text += f"CRS offsets: x={self.dataStorage.crs_offset_x}, y={self.dataStorage.crs_offset_y}" + "\n"
|
||||
text += f"CRS rotation: {self.dataStorage.crs_rotation}°" + "\n\n"
|
||||
text += (
|
||||
"Project CRS units: "
|
||||
+ units
|
||||
+ f"{' (not supported, treated as Meters)' if 'degrees' in units else ''}"
|
||||
+ "\n"
|
||||
)
|
||||
text += (
|
||||
"Project CRS WKT: \n" + self.dataStorage.project.crs().toWkt() + "\n\n"
|
||||
)
|
||||
text += (
|
||||
f"CRS offsets: x={self.dataStorage.crs_offset_x}, y={self.dataStorage.crs_offset_y}"
|
||||
+ "\n"
|
||||
)
|
||||
text += f"CRS rotation: {self.dataStorage.crs_rotation}°" + "\n\n"
|
||||
|
||||
text += last_report
|
||||
|
||||
return operation, total_layers, total_objects, text
|
||||
return operation, total_layers, total_objects, text
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return
|
||||
return
|
||||
|
||||
def applyReport(self):
|
||||
def applyReport(self):
|
||||
result = self.assembleReport()
|
||||
if result is None:
|
||||
print("no report generated")
|
||||
return
|
||||
return
|
||||
operation, total_layers, total_objects, report = result
|
||||
#self.report_label.setText(f"Operation: {operation}\nTotal: {total_layers} layer{'' if str(total_layers).endswith('1') else 's'}, {total_objects} feature{'' if str(total_objects).endswith('1') else 's'}")
|
||||
# self.report_label.setText(f"Operation: {operation}\nTotal: {total_layers} layer{'' if str(total_layers).endswith('1') else 's'}, {total_objects} feature{'' if str(total_objects).endswith('1') else 's'}")
|
||||
self.report_text.setText(report)
|
||||
|
||||
|
||||
def onOkClicked(self):
|
||||
self.close()
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
|
||||
import os
|
||||
from specklepy_qt_ui.qt_ui.DataStorage import DataStorage
|
||||
|
||||
try:
|
||||
from specklepy_qt_ui.qt_ui.DataStorage import DataStorage
|
||||
except ModuleNotFoundError:
|
||||
from speckle.specklepy_qt_ui.qt_ui.DataStorage import DataStorage
|
||||
|
||||
from PyQt5 import QtWidgets, uic, QtCore
|
||||
|
||||
|
||||