From 7c0ac2e8f66824449ab70ed0b02c14aa0cf98412 Mon Sep 17 00:00:00 2001 From: Ralph Wessel Date: Mon, 28 Oct 2024 17:27:46 +0000 Subject: [PATCH] Updated Xcode projects Added environment Host to represent host BIM application Updated for latest ActiveLib --- .../Connector.xcodeproj/project.pbxproj | 10 ++++- .../Interface/Browser/Bridge/Send/Send.cpp | 5 ++- SpeckleConnector/RINT/ConnectorMenu.grc | 2 +- SpeckleConnector/RINT/SpecklePalette.grc | 4 +- SpeckleLib/Speckle/Environment/Host.cpp | 43 +++++++++++++++++++ SpeckleLib/Speckle/Environment/Host.h | 41 ++++++++++++++++++ .../Interface/Browser/Bridge/BridgeArgument.h | 27 +++++++++++- .../Serialise/JSBase/JSBaseTransport.cpp | 7 ++- .../SpeckleLib.xcodeproj/project.pbxproj | 20 ++++----- SpeckleLib/SpeckleLibDoctest/Guid32Tests.cpp | 6 +-- 10 files changed, 141 insertions(+), 24 deletions(-) create mode 100644 SpeckleLib/Speckle/Environment/Host.cpp create mode 100644 SpeckleLib/Speckle/Environment/Host.h diff --git a/SpeckleConnector/Connector.xcodeproj/project.pbxproj b/SpeckleConnector/Connector.xcodeproj/project.pbxproj index ed016c3..6e94456 100644 --- a/SpeckleConnector/Connector.xcodeproj/project.pbxproj +++ b/SpeckleConnector/Connector.xcodeproj/project.pbxproj @@ -32,6 +32,7 @@ 2192460D2CA3469D00CF5703 /* ProjectCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2192460B2CA3469D00CF5703 /* ProjectCollection.cpp */; }; 219F30422C769283009834E9 /* ConfigTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 219F30402C769282009834E9 /* ConfigTests.cpp */; }; 21A0FB982CB723240023F24E /* FinishProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21A0FB942CB723240023F24E /* FinishProxy.cpp */; }; + 21A79EC92CCDA45C001754E4 /* HighlightModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21A79EC52CCDA45C001754E4 /* HighlightModel.cpp */; }; 21A890BC2CC15C540087E732 /* SelectionInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21A890B22CC15C540087E732 /* SelectionInfo.cpp */; }; 21A890BD2CC15C540087E732 /* GetSelection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21A890B52CC15C540087E732 /* GetSelection.cpp */; }; 21A890BE2CC15C540087E732 /* SelectionBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21A890B72CC15C540087E732 /* SelectionBridge.cpp */; }; @@ -317,6 +318,8 @@ 219F30432C7693B6009834E9 /* Connector-AC27-Debug.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = "Connector-AC27-Debug.xctestplan"; sourceTree = SOURCE_ROOT; }; 21A0FB942CB723240023F24E /* FinishProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FinishProxy.cpp; sourceTree = ""; }; 21A0FB972CB723240023F24E /* FinishProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FinishProxy.h; sourceTree = ""; }; + 21A79EC52CCDA45C001754E4 /* HighlightModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HighlightModel.cpp; sourceTree = ""; }; + 21A79EC82CCDA45C001754E4 /* HighlightModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HighlightModel.h; sourceTree = ""; }; 21A890B22CC15C540087E732 /* SelectionInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SelectionInfo.cpp; sourceTree = ""; }; 21A890B32CC15C540087E732 /* SelectionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectionInfo.h; sourceTree = ""; }; 21A890B52CC15C540087E732 /* GetSelection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetSelection.cpp; sourceTree = ""; }; @@ -1026,6 +1029,8 @@ 21B67CA82C77329800FD64FC /* GetSourceApplicationName.h */, 21B67CA92C77329800FD64FC /* GetSourceApplicationVersion.cpp */, 21B67CAA2C77329800FD64FC /* GetSourceApplicationVersion.h */, + 21A79EC52CCDA45C001754E4 /* HighlightModel.cpp */, + 21A79EC82CCDA45C001754E4 /* HighlightModel.h */, 21D0BDD52C935DAE0077E104 /* RemoveModel.cpp */, 21D0BDD62C935DAE0077E104 /* RemoveModel.h */, 21D0BDD22C935D1A0077E104 /* UpdateModel.cpp */, @@ -1508,6 +1513,7 @@ 214B7A372C764BCD00D586C1 /* UpdateConfig.cpp in Sources */, 21AEF9EC2CAB56E5000B8681 /* SendViaBrowserArgs.cpp in Sources */, 21FF70492CA1A7F400AAD99A /* RecordCollection.cpp in Sources */, + 21A79EC92CCDA45C001754E4 /* HighlightModel.cpp in Sources */, 21B67CC02C775A0D00FD64FC /* GetDocumentInfo.cpp in Sources */, 21D0BDD42C935D1A0077E104 /* UpdateModel.cpp in Sources */, 21A890BD2CC15C540087E732 /* GetSelection.cpp in Sources */, @@ -2065,7 +2071,7 @@ ); LOCALISATION_SUFFIX = "EN-GB"; MACH_O_TYPE = mh_bundle; - MACOSX_DEPLOYMENT_TARGET = 11.0; + MACOSX_DEPLOYMENT_TARGET = 13.3; NNA_WARNING_CPLUSPLUSFLAGS = "-Wno-deprecated"; OBJROOT = ""; ONLY_ACTIVE_ARCH = YES; @@ -2172,7 +2178,7 @@ ); LOCALISATION_SUFFIX = "EN-GB"; MACH_O_TYPE = mh_bundle; - MACOSX_DEPLOYMENT_TARGET = 11.0; + MACOSX_DEPLOYMENT_TARGET = 13.3; NNA_WARNING_CPLUSPLUSFLAGS = "-Wno-deprecated"; OBJROOT = ""; PLUGIN_FOLDER = ""; diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Send.cpp b/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Send.cpp index 82bb4a2..800bcfe 100644 --- a/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Send.cpp +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Send.cpp @@ -64,8 +64,7 @@ void Send::run(const String& modelCardID) const { std::make_unique(connector()->getLocalString(errorString, noProjectOpenID), modelCardID)); return; } - //Build a collection from the selected elements - auto collection = std::make_unique(project); + //Get the selected elements auto elementDatabase = project->getElementDatabase(); auto selected = elementDatabase->getSelection(); if (selected.empty()) { @@ -73,6 +72,8 @@ void Send::run(const String& modelCardID) const { std::make_unique(connector()->getLocalString(errorString, noSelectedModelItemsID), modelCardID)); return; } + //Build a collection from the selected elements + auto collection = std::make_unique(project); for (const auto& link : selected) { if (auto element = elementDatabase->getElement(link); element) collection->addElement(*element); diff --git a/SpeckleConnector/RINT/ConnectorMenu.grc b/SpeckleConnector/RINT/ConnectorMenu.grc index 340795b..f6b0c91 100644 --- a/SpeckleConnector/RINT/ConnectorMenu.grc +++ b/SpeckleConnector/RINT/ConnectorMenu.grc @@ -1,5 +1,5 @@ 'STR#' 32500 "Connector Menu" { - /*[ 1]*/ "Speckle Connector" + /*[ 1]*/ "Speckle Connector^E3^EL^ES^ED^EE^EI^EW^ET^" } diff --git a/SpeckleConnector/RINT/SpecklePalette.grc b/SpeckleConnector/RINT/SpecklePalette.grc index 2a6a44b..29391a6 100644 --- a/SpeckleConnector/RINT/SpecklePalette.grc +++ b/SpeckleConnector/RINT/SpecklePalette.grc @@ -1,7 +1,7 @@ /* --- Dockable browser palette ----------------------------------------------*/ -'GDLG' 32500 Palette | topCaption | close | grow 0 0 450 150 "Speckle Connector" { -/* [ 1] */ Browser 0 0 450 150 +'GDLG' 32500 Palette | topCaption | close | grow 0 0 350 150 "Speckle Connector" { +/* [ 1] */ Browser 0 0 350 150 } 'DLGH' 32500 DLG_32500_Browser_Palette { diff --git a/SpeckleLib/Speckle/Environment/Host.cpp b/SpeckleLib/Speckle/Environment/Host.cpp new file mode 100644 index 0000000..a3be8af --- /dev/null +++ b/SpeckleLib/Speckle/Environment/Host.cpp @@ -0,0 +1,43 @@ +#include "Speckle/Environment/Host.h" + +#ifdef ARCHICAD +#include "DG.h" +#endif + +using namespace speckle::utility; +using namespace speckle::environment; + +namespace { + + //An object representing the active host + Host m_hostInstance; + +} + +/*-------------------------------------------------------------------- + Default constructor + --------------------------------------------------------------------*/ +Host::Host() { +} //Host::Host + + +/*-------------------------------------------------------------------- + Display an alert dialog + + message: The alert message + --------------------------------------------------------------------*/ +void Host::displayAlert(const String& message) const { +#ifdef ARCHICAD + DGAlert(DG_INFORMATION, "Notification", message.data(), "", "OK"); +#endif +} //Host::displayAlert + + +/*-------------------------------------------------------------------- + Get an object representing the parent process/application + + return: The active application instance + --------------------------------------------------------------------*/ +speckle::environment::Host* speckle::environment::host() { + return &m_hostInstance; +} //speckle::environment::host diff --git a/SpeckleLib/Speckle/Environment/Host.h b/SpeckleLib/Speckle/Environment/Host.h new file mode 100644 index 0000000..bf355f9 --- /dev/null +++ b/SpeckleLib/Speckle/Environment/Host.h @@ -0,0 +1,41 @@ +#ifndef SPECKLE_ENVIRONMENT_HOST +#define SPECKLE_ENVIRONMENT_HOST + +#include "Speckle/Utility/String.h" + +namespace speckle::environment { + + /*! + Class to represent a host application (for plugin contexts) + */ + class Host { + public: + + // MARK: Constructors + + /*! + Default constructor + */ + Host(); + + // MARK: Functions (const) + + /*! + Display an alert dialog + @param message The alert message + */ + void displayAlert(const speckle::utility::String& message) const; + + // MARK: Functions (mutating) + + }; + + /*! + Get an object representing the host instance + @return The active host instance (nullptr if the host is not running) + */ + speckle::environment::Host* host(); + +} + +#endif //SPECKLE_ENVIRONMENT_HOST diff --git a/SpeckleLib/Speckle/Interface/Browser/Bridge/BridgeArgument.h b/SpeckleLib/Speckle/Interface/Browser/Bridge/BridgeArgument.h index 401263c..d9d1517 100644 --- a/SpeckleLib/Speckle/Interface/Browser/Bridge/BridgeArgument.h +++ b/SpeckleLib/Speckle/Interface/Browser/Bridge/BridgeArgument.h @@ -62,12 +62,17 @@ namespace speckle::interfac::browser::bridge { @return The number of parameters */ virtual uint32_t parameterCount() const { return 1; } - /*! Get any error message relating to the arguments @return The error message (nullopt if no errors occurred) */ speckle::utility::String::Option errorMessage() const { return m_errorMessage; } + /*! + Write the item data to a string + @param dest The string to write the data to + @return True if the data was successfully written + */ + bool write(active::utility::String& dest) const override { return true; } /*! Fill an inventory with the cargo items @param inventory The inventory to receive the cargo items @@ -83,6 +88,12 @@ namespace speckle::interfac::browser::bridge { // MARK: - Functions (mutating) + /*! + Read the cargo data from the specified string + @param source The string to read + @return True if the data was successfully read + */ + bool read(const active::utility::String& source) override { return true; } /*! Set to the default package content */ @@ -121,12 +132,24 @@ namespace speckle::interfac::browser::bridge { */ JSArgType(const JSArgType& source) : BridgeArgument{source}, T{source} {} - /*! + /*! + Write the item data to a string + @param dest The string to write the data to + @return True if the data was successfully written + */ + bool write(active::utility::String& dest) const override { return true; } + /*! Get the number of parameters in the argument @return The number of parameters */ uint32_t parameterCount() const override { return Params; } + /*! + Read the cargo data from the specified string + @param source The string to read + @return True if the data was successfully read + */ + bool read(const active::utility::String& source) override { return true; } /*! Set to the default package content */ diff --git a/SpeckleLib/Speckle/Serialise/JSBase/JSBaseTransport.cpp b/SpeckleLib/Speckle/Serialise/JSBase/JSBaseTransport.cpp index 8d859e9..6f6f669 100644 --- a/SpeckleLib/Speckle/Serialise/JSBase/JSBaseTransport.cpp +++ b/SpeckleLib/Speckle/Serialise/JSBase/JSBaseTransport.cpp @@ -189,14 +189,14 @@ namespace { switch (item.type().value_or(Item::text)) { case Item::boolean: { BoolValue value; - if (!item.write(value)) + if (!item.writeSetting(value)) throw std::system_error(makeJSBaseError(badValue)); newValue = new JS::Value(value.operator bool()); break; } case Item::number: { DoubleValue value; - if (!item.write(value)) + if (!item.writeSetting(value)) throw std::system_error(makeJSBaseError(badValue)); newValue = new JS::Value(value.operator double()); break; @@ -208,6 +208,9 @@ namespace { newValue = new JS::Value(value); break; } + case Item::package: { + break; //Not currently considered relevant + } } if (destination) addJSBase(newValue, tag, destination); diff --git a/SpeckleLib/SpeckleLib.xcodeproj/project.pbxproj b/SpeckleLib/SpeckleLib.xcodeproj/project.pbxproj index 5e20a76..1d3db79 100644 --- a/SpeckleLib/SpeckleLib.xcodeproj/project.pbxproj +++ b/SpeckleLib/SpeckleLib.xcodeproj/project.pbxproj @@ -15,6 +15,8 @@ 210CC89F2C81E34400610F58 /* Platform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 210CC89D2C81E34400610F58 /* Platform.cpp */; }; 210CC8A02C81E34400610F58 /* Platform.h in Headers */ = {isa = PBXBuildFile; fileRef = 210CC89E2C81E34400610F58 /* Platform.h */; }; 212A88132AE48821001EAFE7 /* libArchicad27.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 21379E082AE47A6400A1584C /* libArchicad27.a */; platformFilters = (macos, ); }; + 21384BAB2CCDA9B400D4602B /* Host.h in Headers */ = {isa = PBXBuildFile; fileRef = 21384BA92CCDA9B400D4602B /* Host.h */; }; + 21384BAC2CCDA9B400D4602B /* Host.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21384BAA2CCDA9B400D4602B /* Host.cpp */; }; 215F08552C99DA8D00CD343B /* Project.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 215F08512C99DA8D00CD343B /* Project.cpp */; }; 215F08562C99DA8D00CD343B /* Project.h in Headers */ = {isa = PBXBuildFile; fileRef = 215F08542C99DA8D00CD343B /* Project.h */; }; 215F08662C9B006800CD343B /* ProjectEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 215F08652C9B006700CD343B /* ProjectEvent.cpp */; }; @@ -196,6 +198,8 @@ 21329F632BFD452C00B5C7AF /* Environment.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = Environment.md; sourceTree = ""; }; 21329F642BFD457000B5C7AF /* Event.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = Event.md; sourceTree = ""; }; 21379E082AE47A6400A1584C /* libArchicad27.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libArchicad27.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 21384BA92CCDA9B400D4602B /* Host.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Host.h; sourceTree = ""; }; + 21384BAA2CCDA9B400D4602B /* Host.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Host.cpp; sourceTree = ""; }; 214EA4C52BA374FD008E5358 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; }; 214EA4C62BA3762D008E5358 /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = SOURCE_ROOT; }; 215F08512C99DA8D00CD343B /* Project.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Project.cpp; sourceTree = ""; }; @@ -493,13 +497,6 @@ path = ArchicadDBase; sourceTree = ""; }; - 218953A92C0F29FB0078F182 /* EventTests */ = { - isa = PBXGroup; - children = ( - ); - name = EventTests; - sourceTree = ""; - }; 219246062CA2D22D00CF5703 /* Element */ = { isa = PBXGroup; children = ( @@ -613,7 +610,6 @@ isa = PBXGroup; children = ( 210CC8912C81AEBB00610F58 /* Guid32Tests.cpp */, - 218953A92C0F29FB0078F182 /* EventTests */, ); path = SpeckleLibDoctest; sourceTree = ""; @@ -911,6 +907,8 @@ 2167E2782C4911E2000827D3 /* CMakeLists.txt */, 21F93AEA2B2F406D009A2C5B /* Addon.cpp */, 21F93AE92B2F406D009A2C5B /* Addon.h */, + 21384BAA2CCDA9B400D4602B /* Host.cpp */, + 21384BA92CCDA9B400D4602B /* Host.h */, 210CC89D2C81E34400610F58 /* Platform.cpp */, 210CC89E2C81E34400610F58 /* Platform.h */, 215F08512C99DA8D00CD343B /* Project.cpp */, @@ -985,6 +983,7 @@ 21D0BDB52C8F8AB60077E104 /* DocumentStoreEngine.h in Headers */, 21A890D02CC1B87C0087E732 /* GenericModelElement.h in Headers */, 21A890C52CC171D80087E732 /* ArchicadPropertyDBaseEngine.h in Headers */, + 21384BAB2CCDA9B400D4602B /* Host.h in Headers */, 21D0BDC52C9241940077E104 /* ProjectSubscriber.h in Headers */, 21AE196A2CC57832004DBCFC /* Propertied.h in Headers */, 2196F2EC2CB4816B00450DFC /* ArchicadAttributeDBaseEngine.h in Headers */, @@ -1177,6 +1176,7 @@ 21F69F3B2C6B880C008B6A06 /* JSBaseTransport.cpp in Sources */, 2196F2EB2CB4816B00450DFC /* ArchicadAttributeDBaseEngine.cpp in Sources */, 21AE19532CC273F1004DBCFC /* Template.cpp in Sources */, + 21384BAC2CCDA9B400D4602B /* Host.cpp in Sources */, 21A0FC042CBE59A80023F24E /* SegmentedColumn.cpp in Sources */, 210CC89F2C81E34400610F58 /* Platform.cpp in Sources */, 21D0BD202C86F0280077E104 /* AccountDatabase.cpp in Sources */, @@ -1317,7 +1317,7 @@ LOCALISATION_SUFFIX = "EN-GB"; LOCALIZATION_PREFERS_STRING_CATALOGS = YES; MACH_O_TYPE = staticlib; - MACOSX_DEPLOYMENT_TARGET = 11.0; + MACOSX_DEPLOYMENT_TARGET = 13.3; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; NNA_WARNING_CPLUSPLUSFLAGS = "-Wno-deprecated"; @@ -1414,7 +1414,7 @@ LOCALISATION_SUFFIX = "EN-GB"; LOCALIZATION_PREFERS_STRING_CATALOGS = YES; MACH_O_TYPE = staticlib; - MACOSX_DEPLOYMENT_TARGET = 11.0; + MACOSX_DEPLOYMENT_TARGET = 13.3; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; NNA_WARNING_CPLUSPLUSFLAGS = "-Wno-deprecated"; diff --git a/SpeckleLib/SpeckleLibDoctest/Guid32Tests.cpp b/SpeckleLib/SpeckleLibDoctest/Guid32Tests.cpp index 1267690..101d73e 100644 --- a/SpeckleLib/SpeckleLibDoctest/Guid32Tests.cpp +++ b/SpeckleLib/SpeckleLibDoctest/Guid32Tests.cpp @@ -1,6 +1,6 @@ #include "ActiveLibDoctest/TestingPlatforms.h" -#include "Speckle/Utility/Guid32.h" +#include "Speckle/Utility/Guid64.h" using namespace speckle::utility; @@ -8,8 +8,8 @@ TEST_SUITE(TESTQ(GuidTests)) TEST_SUITE_OPEN ///Tests for creating/modifying guids TEST_CASE(TESTQ(testGuidContent)) { - Guid32 badGuid{String{"abcd"}}; - CHECK_MESSAGE(!badGuid, TEST_MESSAGE(Guid32 created from bad data)); + Guid64 badGuid{String{"abcd"}}; + CHECK_MESSAGE(!badGuid, TEST_MESSAGE(Guid64 created from bad data)); } TEST_SUITE_CLOSE