1 Commits

Author SHA1 Message Date
KatKatKateryna 2f15a17566 pop-up warning 2024-03-01 11:31:55 +00:00
11 changed files with 178 additions and 56 deletions
+126
View File
@@ -0,0 +1,126 @@
from typing import Dict, List
from numpy import double
from import UpdateSavedStreams
from import UpdateSelectedStream
using static DesktopUI2.ViewModels.MappingViewModel;
namespace DesktopUI2;
public delegate void UpdateSavedStreams(List<StreamState> streams);
public delegate void UpdateSelectedStream();
class ConnectorBindings():
def __init__(self):
self.ConnectorVersion: str == Assembly.GetAssembly(GetType()).GetNameAndVersion().Version
self.ConnectorName: str == Assembly.GetAssembly(GetType()).GetNameAndVersion().Name
#SavedStreamStates: List<StreamState> == new List<StreamState>()
self.CanReceive: bool = True
'''Indicates if the connector can Receive and if that function has been implemented'''
self.CanPreviewSend: bool == False
'''Indicates if previewing send has been implemented'''
self.CanPreviewReceive: bool == False
'''Indicates if previewing receive has been implemented'''
self.CanOpen3DView: bool == False
'''Returns true if the <see cref="Open3DView"/> method is overwritten and implemented.'''
def UpdateSavedStreams(self, streams: List[StreamState]):
UpdateSavedStreams(streams)
def UpdateSelectedStream(self):
UpdateSelectedStream()
def Open3DView(self, viewCoordinates: List[double], viewName: str = ""):
'''Opens a 3D view in the host application
viewCoordinates: First three values are the camera position, second three the target.
viewName: Id or Name of the view'''
return
def GetHostAppNameVersion(self)-> str:
'''Gets the current host application name with version.'''
return
def GetHostAppName(self) -> str:
'''Gets the current host application name.'''
return
def GetFileName(self) -> str:
'''Gets the current opened/focused file's name.
Make sure to check regarding unsaved/temporary files.'''
return
def GetDocumentId(self) -> str:
'''Gets the current opened/focused file's id.
Generate one in here if the host app does not provide one.'''
return
def GetDocumentLocation(self) -> str:
'''Gets the current opened/focused file's locations.
Make sure to check regarding unsaved/temporary files.'''
return
def ResetDocument(self):
'''Clears the document state of selections and previews'''
return
def GetActiveViewName(self) -> str:
'''Gets the current opened/focused file's view, if applicable.'''
return
def GetStreamsInFile(self) -> List[StreamState]:
'''Returns the serialised clients present in the current open host file.'''
return
def WriteStreamsToFile(self, streams: List[StreamState]):
'''Writes serialised clients to the current open host file.'''
return
def AddNewStream(self, state: StreamState):
'''Adds a new client and persists the info to the host file'''
return
def PersistAndUpdateStreamInFile(self, state: StreamState):
'''Persists the stream info to the host file; if maintaining a local in memory copy, make sure to update it too.'''
return
def SendStream(self, state: StreamState, progress: ProgressViewModel) -> str:
'''Pushes a client's stream'''
return
def PreviewSend(self, state: StreamState, progress: ProgressViewModel):
'''Previews a send operation'''
def ReceiveStream(self, state: StreamState, progress: ProgressViewModel) -> StreamState:
'''Receives stream data from the server'''
def PreviewReceive(self, state: StreamState, progress: ProgressViewModel) -> StreamState:
'''Previews a receive operation'''
def GetSelectedObjects(self) -> List[str]:
'''Adds the current selection to the provided client.'''
def GetObjectsInView(self) -> List[str]:
'''Gets a list of objects in the currently active view'''
def SelectClientObjects(self, objs: List[str], deselect: bool = False):
'''clients should be able to select/preview/hover one way or another their associated objects'''
def GetSelectionFilters(self) -> List[ISelectionFilter]:
'''Should return a list of filters that the application supports.'''
def GetReceiveModes(self) -> List[ReceiveMode]:
'''Should return a list of receive modes that the application supports.'''
def GetCustomStreamMenuItems(self) -> List[MenuItem]:
'''Return a list of custom menu items for stream cards.'''
def GetSettings(self) -> List[ISetting]:
return
def ImportFamilyCommand(self, Mapping: Dict[str, List[MappingValue]] ) -> Dict[str, List[MappingValue]] :
'''Imports family symbols in Revit'''
return
+6 -6
View File
@@ -809,7 +809,7 @@ class SpeckleQGISDialog(QtWidgets.QDockWidget, FORM_CLASS):
self.streamBranchDropdown.clear() # activates "populate commit"
# print(2)
if isinstance(plugin.active_stream[1], SpeckleException):
logToUser("Some Projects cannot be accessed", level=1, plugin=self)
logToUser("Some streams cannot be accessed", level=1, plugin=self)
return
elif (
plugin.active_stream is None
@@ -825,7 +825,7 @@ class SpeckleQGISDialog(QtWidgets.QDockWidget, FORM_CLASS):
[f"{branch.name}" for branch in plugin.active_stream[1].branches.items]
)
# print(4)
self.streamBranchDropdown.addItems(["Create New Model"])
self.streamBranchDropdown.addItems(["Create New Branch"])
# print(5)
if keep_branch is True:
plugin.active_branch = active_branch
@@ -864,13 +864,13 @@ class SpeckleQGISDialog(QtWidgets.QDockWidget, FORM_CLASS):
# print("________populateActiveCommitDropdown")
# print(plugin.active_commit)
if plugin.active_stream is None:
print("Active project is None")
print("Active stream is None")
return
branchName = self.streamBranchDropdown.currentText()
# print(f"CURRENT BRANCH TEXT: {branchName}")
if branchName == "":
return
if branchName == "Create New Model":
if branchName == "Create New Branch":
self.streamBranchDropdown.setCurrentText("main")
plugin.onBranchCreateClicked()
return
@@ -880,7 +880,7 @@ class SpeckleQGISDialog(QtWidgets.QDockWidget, FORM_CLASS):
# print(plugin.active_commit)
self.commitDropdown.clear()
if isinstance(plugin.active_stream[1], SpeckleException):
logToUser("Some Projects cannot be accessed", level=1, plugin=self)
logToUser("Some streams cannot be accessed", level=1, plugin=self)
return
elif plugin.active_stream[1]:
for b in plugin.active_stream[1].branches.items:
@@ -932,7 +932,7 @@ class SpeckleQGISDialog(QtWidgets.QDockWidget, FORM_CLASS):
else:
plugin.active_commit = None
self.commitDropdown.setItemText(0, "Latest version of this model")
self.commitDropdown.setItemText(0, "Latest commit from this branch")
# enable or disable web view button
# print("_________ENABLE OR DISABLE")
# print(plugin.active_commit)
+4 -3
View File
@@ -84,8 +84,8 @@ ui_file_path = os.path.join(
)
class SpeckleGISDialog(QMainWindow):
on_top: bool = False
pin_label: QtWidgets.QPushButton
closingPlugin = pyqtSignal()
@@ -675,6 +675,7 @@ class SpeckleGISDialog(QMainWindow):
self.runButton.setEnabled(True) # by manual selection
elif self.layerSendModeDropdown.currentIndex() == 1:
self.runBtnStatusChanged(plugin) # by saved
except Exception as e:
logToUser(str(e), level=2, func=inspect.stack()[0][3], plugin=self)
@@ -854,7 +855,7 @@ class SpeckleGISDialog(QMainWindow):
[f"{branch.name}" for branch in plugin.active_stream[1].branches.items]
)
# print(4)
self.streamBranchDropdown.addItems(["Create New Model"])
self.streamBranchDropdown.addItems(["Create New Branch"])
# print(5)
if keep_branch is True:
plugin.active_branch = active_branch
@@ -895,7 +896,7 @@ class SpeckleGISDialog(QMainWindow):
# print(f"CURRENT BRANCH TEXT: {branchName}")
if branchName == "":
return
if branchName == "Create New Model":
if branchName == "Create New Branch":
self.streamBranchDropdown.setCurrentText("main")
plugin.onBranchCreateClicked()
return
+1 -1
View File
@@ -25,7 +25,7 @@
<item row="1" column="0">
<widget class="QLabel" name="search_label">
<property name="text">
<string>Search Project by name or URL</string>
<string>Search Stream by name or URL</string>
</property>
</widget>
</item>
+1 -1
View File
@@ -26,7 +26,7 @@
<item row="0" column="0">
<widget class="QLabel" name="name_label">
<property name="text">
<string>Model Name</string>
<string>Branch Name</string>
</property>
</widget>
</item>
+1 -1
View File
@@ -34,7 +34,7 @@
<item row="1" column="0">
<widget class="QLabel" name="name_label">
<property name="text">
<string>Project Name</string>
<string>Stream Name</string>
</property>
</widget>
</item>
+3 -3
View File
@@ -39,7 +39,7 @@
<item row="1" column="0">
<widget class="QLabel" name="streamListLabel">
<property name="text">
<string>Project</string>
<string>Stream</string>
</property>
</widget>
</item>
@@ -77,7 +77,7 @@
<item row="2" column="0">
<widget class="QLabel" name="streamBranchLabel">
<property name="text">
<string>Model</string>
<string>Branch</string>
</property>
</widget>
</item>
@@ -87,7 +87,7 @@
<item row="3" column="0">
<widget class="QLabel" name="commitLabel">
<property name="text">
<string>Version</string>
<string>Commit</string>
</property>
</widget>
</item>
+3 -3
View File
@@ -43,7 +43,7 @@
<item row="1" column="0">
<widget class="QLabel" name="streamListLabel">
<property name="text">
<string>Project</string>
<string>Stream</string>
</property>
</widget>
</item>
@@ -83,7 +83,7 @@
<item row="2" column="0">
<widget class="QLabel" name="streamBranchLabel">
<property name="text">
<string>Model</string>
<string>Branch</string>
</property>
</widget>
</item>
@@ -93,7 +93,7 @@
<item row="3" column="0">
<widget class="QLabel" name="commitLabel">
<property name="text">
<string>Version</string>
<string>Commit</string>
</property>
</widget>
</item>
+15 -8
View File
@@ -2,14 +2,17 @@ import inspect
import os
from typing import List, Union
import urllib.parse
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
from specklepy_qt_ui.qt_ui.utils.logger import displayUserMsg
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 speckle.specklepy_qt_ui.qt_ui.utils.logger import displayUserMsg
from PyQt5 import QtWidgets, uic, QtCore
from PyQt5.QtCore import pyqtSignal
@@ -50,7 +53,7 @@ class AddStreamModalDialog(QtWidgets.QWidget, FORM_CLASS):
)
self.speckle_client = speckle_client
self.setupUi(self)
self.setWindowTitle("Add Speckle Project")
self.setWindowTitle("Add Speckle stream")
self.dialog_button_box.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(False)
@@ -93,7 +96,7 @@ class AddStreamModalDialog(QtWidgets.QWidget, FORM_CLASS):
"Connector Action",
self.dataStorage.active_account,
{
"name": "Project Search By Name",
"name": "Stream Search By Name",
"connector_version": str(self.dataStorage.plugin_version),
},
)
@@ -153,7 +156,7 @@ class AddStreamModalDialog(QtWidgets.QWidget, FORM_CLASS):
"Connector Action",
self.dataStorage.active_account,
{
"name": "Project Search By URL",
"name": "Stream Search By URL",
"connector_version": str(self.dataStorage.plugin_version),
},
)
@@ -167,7 +170,7 @@ class AddStreamModalDialog(QtWidgets.QWidget, FORM_CLASS):
"Connector Action",
self.dataStorage.active_account,
{
"name": "Project Search By Name",
"name": "Stream Search By Name",
"connector_version": str(self.dataStorage.plugin_version),
},
)
@@ -188,6 +191,10 @@ class AddStreamModalDialog(QtWidgets.QWidget, FORM_CLASS):
except Exception as e:
logToUser(e, level=2, func=inspect.stack()[0][3])
if isinstance(e, SpeckleException):
displayUserMsg(e.message, level=2)
else:
displayUserMsg(str(e), level=2)
return
def populateResultsList(self, sw=None):
@@ -195,7 +202,7 @@ class AddStreamModalDialog(QtWidgets.QWidget, FORM_CLASS):
self.search_results_list.clear()
if isinstance(self.stream_results, SpeckleException):
logToUser(
"Some Projects cannot be accessed",
"Some streams cannot be accessed",
level=1,
func=inspect.stack()[0][3],
)
@@ -209,7 +216,7 @@ class AddStreamModalDialog(QtWidgets.QWidget, FORM_CLASS):
if isinstance(stream, SpeckleException):
logToUser(
"Some Projects cannot be accessed",
"Some streams cannot be accessed",
level=1,
func=inspect.stack()[0][3],
)
@@ -227,7 +234,7 @@ class AddStreamModalDialog(QtWidgets.QWidget, FORM_CLASS):
try:
if isinstance(self.stream_results, SpeckleException):
logToUser(
"Selected Project cannot be accessed: "
"Selected stream cannot be accessed: "
+ str(self.stream_results.message),
level=1,
func=inspect.stack()[0][3],
@@ -265,7 +272,7 @@ class AddStreamModalDialog(QtWidgets.QWidget, FORM_CLASS):
self.close()
except Exception as e:
logToUser(
"Some Projects cannot be accessed: " + str(e),
"Some streams cannot be accessed: " + str(e),
level=1,
func=inspect.stack()[0][3],
)
+17 -29
View File
@@ -15,50 +15,39 @@ from specklepy.core.api.client import SpeckleClient
# 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", "create_branch.ui"))
os.path.join(os.path.join(os.path.dirname(__file__), "ui", "create_branch.ui") )
)
class CreateBranchModalDialog(QtWidgets.QWidget, FORM_CLASS):
name_field: QtWidgets.QLineEdit = None
description_field: QtWidgets.QLineEdit = None
dialog_button_box: QtWidgets.QDialogButtonBox = None
speckle_client: Union[SpeckleClient, None] = None
# Events
handleBranchCreate = pyqtSignal(str, str)
#Events
handleBranchCreate = pyqtSignal(str,str)
def __init__(self, parent=None, speckle_client: SpeckleClient = None):
super(CreateBranchModalDialog, self).__init__(
parent, QtCore.Qt.WindowStaysOnTopHint
)
super(CreateBranchModalDialog,self).__init__(parent,QtCore.Qt.WindowStaysOnTopHint)
self.speckle_client = speckle_client
self.setupUi(self)
self.setWindowTitle("Create New Model")
self.setMinimumWidth(300)
self.setWindowTitle("Create New Branch")
self.name_field.textChanged.connect(self.nameCheck)
self.dialog_button_box.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(False)
self.dialog_button_box.button(QtWidgets.QDialogButtonBox.Ok).clicked.connect(
self.onOkClicked
)
self.dialog_button_box.button(
QtWidgets.QDialogButtonBox.Cancel
).clicked.connect(self.onCancelClicked)
self.dialog_button_box.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(False)
self.dialog_button_box.button(QtWidgets.QDialogButtonBox.Ok).clicked.connect(self.onOkClicked)
self.dialog_button_box.button(QtWidgets.QDialogButtonBox.Cancel).clicked.connect(self.onCancelClicked)
def nameCheck(self):
try:
if len(self.name_field.text()) >= 3:
self.dialog_button_box.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(
True
)
else:
self.dialog_button_box.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(
False
)
self.dialog_button_box.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True)
else:
self.dialog_button_box.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(False)
return
except Exception as e:
logToUser(e, level=2, func=inspect.stack()[0][3])
logToUser(e, level = 2, func = inspect.stack()[0][3])
return
def onOkClicked(self):
@@ -68,17 +57,16 @@ class CreateBranchModalDialog(QtWidgets.QWidget, FORM_CLASS):
self.handleBranchCreate.emit(name, description)
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
def onCancelClicked(self):
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
r"""
r'''
def onAccountSelected(self, index):
try:
account = self.speckle_accounts[index]
@@ -87,4 +75,4 @@ class CreateBranchModalDialog(QtWidgets.QWidget, FORM_CLASS):
except Exception as e:
logToUser(e, level = 2, func = inspect.stack()[0][3])
return
"""
'''
+1 -1
View File
@@ -41,7 +41,7 @@ class CreateStreamModalDialog(QtWidgets.QWidget, FORM_CLASS):
)
self.speckle_client = speckle_client
self.setupUi(self)
self.setWindowTitle("Create New Project")
self.setWindowTitle("Create New Stream")
self.name_field.textChanged.connect(self.nameCheck)
self.dialog_button_box.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True)