Added Project class
Addon class now manages an active project instance that can be accessed with getActiveProject GetDocumentInfo now uses information extracted from the active project Updated ProjectSubscriber and ProjectEvent accordingly "Send" bridge method now throws exception reporting no selected elements (placeholder until we implement a real send process)
This commit is contained in:
@@ -1365,7 +1365,7 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "mkdir -p \"$HEADER_PATH_3/ResourceObjects\"\npython3 \"$HEADER_PATH_5/Tools/CompileResources.py\" INT \"$HEADER_PATH_5/..\" \"$HEADER_PATH_6\" \"$SRCROOT\" \"$HEADER_PATH_3/ResourceObjects\" \"$SYMROOT/$CONFIGURATION/$PRODUCT_NAME.$WRAPPER_EXTENSION/Contents/Resources\"\ncp \"$HEADER_PATH_5/Inc/PkgInfo\" \"$SYMROOT/$CONFIGURATION/$PRODUCT_NAME.$WRAPPER_EXTENSION/Contents/PkgInfo\"\ntouch \"$HEADER_PATH_3/ResourceObjects/AddOnResources.stamp\"\n";
|
||||
shellScript = "mkdir -p \"$HEADER_PATH_6/ResourceObjects\"\npython3 \"$HEADER_PATH_5/Tools/CompileResources.py\" INT \"$HEADER_PATH_5/..\" \"$HEADER_PATH_6\" \"$SRCROOT\" \"$HEADER_PATH_6/ResourceObjects\" \"$SYMROOT/$CONFIGURATION/$PRODUCT_NAME.$WRAPPER_EXTENSION/Contents/Resources\"\npython3 \"$HEADER_PATH_5/Tools/CompileResources.py\" INT \"$HEADER_PATH_5/..\" \"$HEADER_PATH_3\" \"$SRCROOT\" \"$HEADER_PATH_6/ResourceObjects\" \"$SYMROOT/$CONFIGURATION/$PRODUCT_NAME.$WRAPPER_EXTENSION/Contents/Resources\"\ncp \"$HEADER_PATH_5/Inc/PkgInfo\" \"$SYMROOT/$CONFIGURATION/$PRODUCT_NAME.$WRAPPER_EXTENSION/Contents/PkgInfo\"\ntouch \"$HEADER_PATH_6/ResourceObjects/AddOnResources.stamp\"\n";
|
||||
};
|
||||
213CC3A12B1101F500088049 /* Install */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "Connector/Interface/Browser/Bridge/Base/GetDocumentInfo.h"
|
||||
|
||||
#include "Active/Serialise/CargoHold.h"
|
||||
#include "Connector/Connector.h"
|
||||
#include "Connector/Interface/Browser/Bridge/Base/Arg/DocumentInfo.h"
|
||||
#include "Speckle/Environment/Project.h"
|
||||
|
||||
using namespace active::container;
|
||||
using namespace active::serialise;
|
||||
@@ -29,6 +31,13 @@ GetDocumentInfo::GetDocumentInfo() : BridgeMethod{"GetDocumentInfo", [&]() {
|
||||
--------------------------------------------------------------------*/
|
||||
std::unique_ptr<Cargo> GetDocumentInfo::run() const {
|
||||
///TODO: Get the document info here - returning mocked values for now
|
||||
DocumentInfo docInfo{"Somewhere", "Something", String{active::utility::Guid{true}.operator active::utility::String()}};
|
||||
DocumentInfo docInfo;
|
||||
if (auto project = connector()->getActiveProject().lock(); project) {
|
||||
auto info = project->getInfo();
|
||||
docInfo.name = info.name;
|
||||
if (info.path)
|
||||
docInfo.location = *info.path;
|
||||
//TODO: No suitable project ID is currently available
|
||||
}
|
||||
return std::make_unique<WrappedValue>(docInfo);
|
||||
} //GetDocumentInfo::run
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "Active/Serialise/CargoHold.h"
|
||||
#include "Active/Serialise/Package/Wrapper/PackageWrap.h"
|
||||
#include "Speckle/Utility/Exception.h"
|
||||
|
||||
using namespace active::serialise;
|
||||
using namespace connector::interfac::browser::bridge;
|
||||
@@ -21,5 +22,6 @@ Send::Send() : BridgeMethod{"Send", [&](UpdateArgs args) {
|
||||
modelCardID: The ID of the madel to send
|
||||
--------------------------------------------------------------------*/
|
||||
void Send::run(const String& modelCardID) const {
|
||||
///TODO: Send the requested model
|
||||
///TODO: Find and send selected elements - the following is a placeholder
|
||||
throw Exception{"No objects were found to convert. Please update your publish filter!"};
|
||||
} //Send::run
|
||||
|
||||
@@ -56,8 +56,8 @@ bool SendFilter::fillInventory(Inventory& inventory) const {
|
||||
inventory.merge(Inventory{
|
||||
{
|
||||
{ fieldID[nameID], nameID, element },
|
||||
{ fieldID[summaryID], summaryID, element },
|
||||
{ fieldID[defaultID], defaultID, element },
|
||||
{ fieldID[summaryID], summaryID, element, !m_summary.empty() },
|
||||
{ fieldID[defaultID], defaultID, element, m_isDefault },
|
||||
},
|
||||
}.withType(&typeid(SendFilter)));
|
||||
return true;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
'STR#' 32600 "Title strings" {
|
||||
/* [ 1] */ "Speckle Connector"
|
||||
/* [ 2] */ "Connector to share model content with Speckle"
|
||||
'STR#' 32700 "Title strings" {
|
||||
/* [ 1] */ "Untitled"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
'STR#' 32600 "Title strings" {
|
||||
/* [ 1] */ "Speckle Connector"
|
||||
/* [ 2] */ "Connector to share model content with Speckle"
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "Active/Utility/Memory.h"
|
||||
#include "Active/Utility/String.h"
|
||||
#include "Speckle/Environment/Addon.h"
|
||||
#include "Speckle/Environment/Project.h"
|
||||
#include "Speckle/Event/Type/DocStoreMergeEvent.h"
|
||||
#include "Speckle/Event/Type/ProjectEvent.h"
|
||||
#include "Speckle/Utility/Guid.h"
|
||||
@@ -174,18 +175,17 @@ bool DocumentStoreCore::handle(const DocStoreMergeEvent& event) {
|
||||
return: True if the event should be closed
|
||||
--------------------------------------------------------------------*/
|
||||
bool DocumentStoreCore::handle(const event::ProjectEvent& event) {
|
||||
#ifdef ARCHICAD
|
||||
using enum ProjectEvent::Type;
|
||||
switch (event.getType()) {
|
||||
case APINotify_Close:
|
||||
case close:
|
||||
resetStore(); //Wipe the cache, forcing a full reload when the data is requested again (after a project is opened)
|
||||
break;
|
||||
case APINotify_PreSave: case APINotify_SendChanges:
|
||||
case presave: case send:
|
||||
writeStore(); //Ensure the data is stored with the save/send
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
} //DocumentStoreCore::handle
|
||||
|
||||
@@ -221,6 +221,10 @@ active::utility::Memory DocumentStoreCore::readStore() const {
|
||||
--------------------------------------------------------------------*/
|
||||
void DocumentStoreCore::writeStore() {
|
||||
#ifdef ARCHICAD
|
||||
auto activeProject = addon()->getActiveProject();
|
||||
bool shared = false;
|
||||
if (auto project = activeProject.lock(); project && project->getInfo().isShared)
|
||||
shared = true;
|
||||
//Ensure a suitable data store exists
|
||||
if (!isExistingStore(m_id)) {
|
||||
//Create when missing
|
||||
@@ -230,7 +234,7 @@ void DocumentStoreCore::writeStore() {
|
||||
m_id.id = Guid{acID};
|
||||
}
|
||||
//Reserve the storage object in TW
|
||||
if (addon()->isSharedDocument()) {
|
||||
if (shared) {
|
||||
GS::HashTable<API_Guid, short> conflicts;
|
||||
if (auto statusCode = convertArchicadError(ACAPI_AddOnObject_ReserveObjects({Guid{m_id.id}}, &conflicts)); statusCode != nominal)
|
||||
throw std::system_error(makeError(statusCode));
|
||||
@@ -244,7 +248,7 @@ void DocumentStoreCore::writeStore() {
|
||||
if (auto statusCode = convertArchicadError(ACAPI_AddOnObject_ModifyObject(Guid{m_id.id}, nullptr, &output)); statusCode != nominal)
|
||||
throw std::system_error(makeError(statusCode));
|
||||
//Release the storage object in TW
|
||||
if (addon()->isSharedDocument()) {
|
||||
if (shared) {
|
||||
if (auto statusCode = convertArchicadError(ACAPI_AddOnObject_ReleaseObjects({Guid{m_id.id}})); statusCode != nominal)
|
||||
throw std::system_error(makeError(statusCode));
|
||||
}
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
#include "Speckle/Environment/Addon.h"
|
||||
|
||||
#include "Speckle/Environment/Project.h"
|
||||
#include "Speckle/Event/Type/ProjectEvent.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
#ifdef ARCHICAD
|
||||
#include <ACAPinc.h>
|
||||
#endif
|
||||
|
||||
using namespace speckle::environment;
|
||||
using namespace speckle::event;
|
||||
using namespace speckle::utility;
|
||||
|
||||
namespace {
|
||||
@@ -52,19 +58,15 @@ String Addon::getLocalString(short itemIndex, short resourceIndex) const {
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------
|
||||
Determine if the active document is shared (in collaborative environments)
|
||||
Get the active project
|
||||
|
||||
return: True if the active document is shared
|
||||
return: The active project (nullptr = no open project)
|
||||
--------------------------------------------------------------------*/
|
||||
bool Addon::isSharedDocument() const {
|
||||
#ifdef ARCHICAD
|
||||
API_ProjectInfo pi{};
|
||||
ACAPI_ProjectOperation_Project(&pi);
|
||||
return pi.teamwork;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
} //Addon::isSharedDocument
|
||||
std::weak_ptr<Project> Addon::getActiveProject() const {
|
||||
if (m_activeProject)
|
||||
return m_activeProject;
|
||||
return std::weak_ptr<Project>{};
|
||||
} //Addon::getActiveProject
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------
|
||||
@@ -76,7 +78,9 @@ void Addon::publishExternal(const active::event::Event& event) {
|
||||
if (!logCallback())
|
||||
return;
|
||||
try {
|
||||
preprocessEvent(event);
|
||||
publish(event);
|
||||
postprocessEvent(event);
|
||||
} catch (...) {
|
||||
//Add error logging in future
|
||||
}
|
||||
@@ -147,7 +151,7 @@ speckle::environment::Addon* speckle::environment::addon() {
|
||||
|
||||
return: True if the callback can continue (false on error)
|
||||
--------------------------------------------------------------------*/
|
||||
bool speckle::environment::Addon::logCallback(bool initialise) {
|
||||
bool Addon::logCallback(bool initialise) {
|
||||
if (initialise)
|
||||
m_callDepth = 1;
|
||||
else
|
||||
@@ -162,3 +166,53 @@ bool speckle::environment::Addon::logCallback(bool initialise) {
|
||||
}
|
||||
return true;
|
||||
} //Addon::publishExternalEvent
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------
|
||||
Preprocess an external event (allowing key add-on operations to act before other subscribers)
|
||||
|
||||
event: An incoming event
|
||||
|
||||
return: True if the event should be closed, i.e. not passed to other subscribers
|
||||
--------------------------------------------------------------------*/
|
||||
bool Addon::preprocessEvent(const active::event::Event& event) {
|
||||
if (auto projectEvent = dynamic_cast<const ProjectEvent*>(&event); projectEvent != nullptr) {
|
||||
using enum ProjectEvent::Type;
|
||||
switch (projectEvent->getType()) {
|
||||
case newDocument: case newAndReset: case open:
|
||||
m_activeProject = makeProject(); //Ensure a project object is available
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} //Addon::preprocessEvent
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------
|
||||
Postprocess an external event (allowing key add-on operations to act after all other subscribers are complete)
|
||||
|
||||
event: An incoming (completed) event
|
||||
--------------------------------------------------------------------*/
|
||||
void Addon::postprocessEvent(const active::event::Event& event) {
|
||||
if (auto projectEvent = dynamic_cast<const ProjectEvent*>(&event); projectEvent != nullptr) {
|
||||
using enum ProjectEvent::Type;
|
||||
switch (projectEvent->getType()) {
|
||||
case close: case quit:
|
||||
m_activeProject.reset(); //Release the active project on close/quit
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} //Addon::postprocessEvent
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------
|
||||
Make a new new project. Allows Addon subclasses to define a Project subclass with additional functions/databases
|
||||
|
||||
return: A new project instance
|
||||
--------------------------------------------------------------------*/
|
||||
std::shared_ptr<Project> Addon::makeProject() const {
|
||||
auto project = new Project; //make_shared can't use protected constructor
|
||||
return std::shared_ptr<Project>{project};
|
||||
} //Addon::makeProject
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
#include "Speckle/Utility/String.h"
|
||||
|
||||
namespace speckle::environment {
|
||||
|
||||
|
||||
class Project;
|
||||
|
||||
/*!
|
||||
A base class for an addon
|
||||
*/
|
||||
@@ -19,11 +21,7 @@ namespace speckle::environment {
|
||||
@param identity Optional name/ID for the subscriber
|
||||
*/
|
||||
Addon(const active::utility::NameID& identity);
|
||||
/*!
|
||||
Copy constructor
|
||||
@param source The object to copy
|
||||
*/
|
||||
Addon(const App& source) : App{source} {}
|
||||
Addon(const App&) = delete;
|
||||
/*!
|
||||
Destructor
|
||||
*/
|
||||
@@ -39,10 +37,10 @@ namespace speckle::environment {
|
||||
*/
|
||||
speckle::utility::String getLocalString(short itemIndex, short resourceIndex) const;
|
||||
/*!
|
||||
Determine if the active document is shared (in collaborative environments)
|
||||
@return True if the active document is shared
|
||||
Get the active project
|
||||
@return The active project (nullptr = no open project)
|
||||
*/
|
||||
bool isSharedDocument() const;
|
||||
std::weak_ptr<Project> getActiveProject() const;
|
||||
|
||||
// MARK: - Functions (mutating)
|
||||
|
||||
@@ -50,7 +48,7 @@ namespace speckle::environment {
|
||||
Set the add-on name
|
||||
@param nm The add-on name
|
||||
*/
|
||||
void setName(const speckle::utility::String& nm) { name = nm; }
|
||||
void setName(const speckle::utility::String& nm) { App::name = nm; }
|
||||
/*!
|
||||
Publish an event from an external source to subscribers
|
||||
@param event The event to publish
|
||||
@@ -75,6 +73,7 @@ namespace speckle::environment {
|
||||
Shut down event handling
|
||||
*/
|
||||
void stop() override;
|
||||
|
||||
protected:
|
||||
/*!
|
||||
Log a callback into the add-on (allows checking of re-entry)
|
||||
@@ -82,8 +81,27 @@ namespace speckle::environment {
|
||||
@return True if the callback can continue (false on error)
|
||||
*/
|
||||
bool logCallback(bool initialise = true);
|
||||
/*!
|
||||
Preprocess an external event (allowing key add-on operations to act before other subscribers)
|
||||
@param event An incoming event
|
||||
@return True if the event should be closed, i.e. not passed to other subscribers
|
||||
*/
|
||||
virtual bool preprocessEvent(const active::event::Event& event);
|
||||
/*!
|
||||
Postprocess an external event (allowing key add-on operations to act after all other subscribers are complete)
|
||||
@param event An incoming (completed) event
|
||||
*/
|
||||
virtual void postprocessEvent(const active::event::Event& event);
|
||||
/*!
|
||||
Make a new new project. Allows Addon subclasses to define a Project subclass with additional functions/databases
|
||||
@return A new project instance
|
||||
*/
|
||||
virtual std::shared_ptr<Project> makeProject() const;
|
||||
|
||||
private:
|
||||
///The active project
|
||||
std::shared_ptr<Project> m_activeProject;
|
||||
///The depth of nested callbacks - the root call starts at depth 0 (important for some entry-point initialisation)
|
||||
uint32_t m_callDepth = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
#include "Speckle/Environment/Project.h"
|
||||
|
||||
#include "Speckle/Environment/Addon.h"
|
||||
#include "Speckle/SpeckleResource.h"
|
||||
|
||||
#ifdef ARCHICAD
|
||||
#include <ACAPinc.h>
|
||||
#endif
|
||||
|
||||
using namespace speckle::environment;
|
||||
using namespace speckle::utility;
|
||||
|
||||
namespace {
|
||||
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------
|
||||
Constructor (NB: this object is assumed to be the active instance)
|
||||
|
||||
identity: Optional name/ID for the subscriber
|
||||
--------------------------------------------------------------------*/
|
||||
Project::Project() {
|
||||
} //Project::Project
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------
|
||||
Destructor
|
||||
--------------------------------------------------------------------*/
|
||||
Project::~Project() {
|
||||
} //Project::~Project
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------
|
||||
Get information about the project
|
||||
|
||||
return: Project information
|
||||
--------------------------------------------------------------------*/
|
||||
Project::Info Project::getInfo() const {
|
||||
//Start with an untitled project - this will be replaced if a saved project is active
|
||||
Info result{addon()->getLocalString(titleStringLib, untitledProjectID)};
|
||||
#ifdef ARCHICAD
|
||||
API_ProjectInfo projectInfo;
|
||||
if (ACAPI_ProjectOperation_Project(&projectInfo) == NoError) {
|
||||
if (projectInfo.projectName != nullptr)
|
||||
result.name = *projectInfo.projectName;
|
||||
result.isShared = projectInfo.teamwork;
|
||||
if (projectInfo.teamwork) {
|
||||
if (projectInfo.projectPath != nullptr)
|
||||
result.path = String{*projectInfo.projectPath};
|
||||
else if (projectInfo.location_team != nullptr) {
|
||||
GS::UniString path;
|
||||
if (projectInfo.location_team->ToPath(&path) == NoError)
|
||||
result.path = String{path};
|
||||
}
|
||||
} else {
|
||||
if (projectInfo.projectPath != nullptr)
|
||||
result.path = String{*projectInfo.projectPath};
|
||||
else if (projectInfo.location != nullptr) {
|
||||
GS::UniString path;
|
||||
if (projectInfo.location->ToPath(&path) == NoError)
|
||||
result.path = String{path};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
} //Project::getInfo
|
||||
@@ -0,0 +1,69 @@
|
||||
#ifndef SPECKLE_ENVIRONMENT_PROJECT
|
||||
#define SPECKLE_ENVIRONMENT_PROJECT
|
||||
|
||||
#include "Active/File/Path.h"
|
||||
#include "Speckle/Utility/String.h"
|
||||
|
||||
namespace speckle::environment {
|
||||
|
||||
class Addon;
|
||||
|
||||
/*!
|
||||
A BIM project
|
||||
|
||||
This class is currently skeletal, but is intended to be the primnary conduit for any document-based data, e.g. elements, attributes, properties
|
||||
etc. Any databases managing document-based content should be retrieved from this class rather than Add-on (or subclasses) or static functions.
|
||||
*/
|
||||
class Project {
|
||||
public:
|
||||
|
||||
// MARK: - Types
|
||||
|
||||
///Shared pointer
|
||||
using Shared = std::shared_ptr<Project>;
|
||||
///Weak pointer
|
||||
using Weak = std::weak_ptr<Project>;
|
||||
///Project information
|
||||
struct Info {
|
||||
//The project name
|
||||
utility::String name;
|
||||
//The project ID
|
||||
utility::String ID;
|
||||
//Either local path or server URL where the project is stored (nullopt if memory-based only, i.e. unsaved)
|
||||
active::file::Path::Option path;
|
||||
//True if the project is shared (cloud-based)
|
||||
bool isShared = false;
|
||||
};
|
||||
|
||||
// MARK: - Constructors
|
||||
|
||||
Project(const Project&) = delete;
|
||||
/*!
|
||||
Destructor
|
||||
*/
|
||||
~Project();
|
||||
|
||||
// MARK: - Functions (const)
|
||||
|
||||
/*!
|
||||
Get information about the project
|
||||
@return Project information
|
||||
*/
|
||||
Info getInfo() const;
|
||||
|
||||
// MARK: - Functions (mutating)
|
||||
|
||||
protected:
|
||||
friend class speckle::environment::Addon;
|
||||
|
||||
/*!
|
||||
Default constructor
|
||||
|
||||
NB: Only the Addon class can create projects. Clients can get the active project from the running add-on.
|
||||
*/
|
||||
Project();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //SPECKLE_ENVIRONMENT_PROJECT
|
||||
@@ -17,8 +17,9 @@ namespace speckle::event {
|
||||
|
||||
/*!
|
||||
Default constructor
|
||||
*/
|
||||
ProjectSubscriber() = default;
|
||||
@param priority The subscriber priority (determines the order in which subscribers receive events)
|
||||
*/
|
||||
ProjectSubscriber(int32_t priority = 0) : active::event::Subscriber{priority} {}
|
||||
/*!
|
||||
Copy constructor
|
||||
@param source The object to copy
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#include "Speckle/Event/Type/ProjectEvent.h"
|
||||
|
||||
using namespace speckle::event;
|
||||
|
||||
#ifdef ARCHICAD
|
||||
/*--------------------------------------------------------------------
|
||||
Convert an Archicad project event type
|
||||
|
||||
return: The equivalent Speckle event type
|
||||
--------------------------------------------------------------------*/
|
||||
std::optional<ProjectEvent::Type> ProjectEvent::convert(API_NotifyEventID acEventType) {
|
||||
using enum ProjectEvent::Type;
|
||||
switch (acEventType) {
|
||||
case APINotify_New:
|
||||
return newDocument;
|
||||
case APINotify_NewAndReset:
|
||||
return newAndReset;
|
||||
case APINotify_Open:
|
||||
return open;
|
||||
case APINotify_PreSave:
|
||||
return presave;
|
||||
case APINotify_Save:
|
||||
return save;
|
||||
case APINotify_Close:
|
||||
return close;
|
||||
case APINotify_Quit:
|
||||
return quit;
|
||||
case APINotify_TempSave:
|
||||
return tempSave;
|
||||
case APINotify_SendChanges:
|
||||
return send;
|
||||
case APINotify_ReceiveChanges:
|
||||
return receive;
|
||||
default:
|
||||
return std::nullopt;
|
||||
} //ProjectEvent::convert
|
||||
}
|
||||
#endif
|
||||
@@ -6,6 +6,10 @@
|
||||
#include "Active/Utility/Guid.h"
|
||||
#include "Active/Utility/String.h"
|
||||
|
||||
#ifdef ARCHICAD
|
||||
#include <ACAPinc.h>
|
||||
#endif
|
||||
|
||||
namespace speckle::event {
|
||||
|
||||
/*!
|
||||
@@ -14,6 +18,23 @@ namespace speckle::event {
|
||||
class ProjectEvent : public active::event::Event {
|
||||
public:
|
||||
|
||||
// MARK: - Types
|
||||
|
||||
///Common project event types
|
||||
enum class Type {
|
||||
unknown,
|
||||
newDocument,
|
||||
newAndReset,
|
||||
open,
|
||||
presave,
|
||||
save,
|
||||
close,
|
||||
quit,
|
||||
tempSave,
|
||||
send,
|
||||
receive,
|
||||
};
|
||||
|
||||
static const inline active::utility::NameID ID{active::utility::String{"project event"},
|
||||
active::utility::Guid{active::utility::String{"0ffb9ec5-2164-4fc2-aa57-17b5a1f15355"}}};
|
||||
|
||||
@@ -30,15 +51,17 @@ namespace speckle::event {
|
||||
@param param An additional parameter relevant to some project events
|
||||
*/
|
||||
ProjectEvent(API_NotifyEventID notifyEvent, int32_t param) : Event{ID} {
|
||||
m_eventID = notifyEvent;
|
||||
m_eventID = convert(notifyEvent).value_or(Type::unknown);
|
||||
m_param = param;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
Get the event type
|
||||
@return The event type
|
||||
*/
|
||||
API_NotifyEventID getType() const { return m_eventID; }
|
||||
Type getType() const { return m_eventID; }
|
||||
#ifdef ARCHICAD
|
||||
/*!
|
||||
Get the event parameter
|
||||
@return The event parameter
|
||||
@@ -46,10 +69,17 @@ namespace speckle::event {
|
||||
int32_t getParam() const { return m_param; }
|
||||
#endif
|
||||
|
||||
private:
|
||||
///The event type
|
||||
Type m_eventID;
|
||||
#ifdef ARCHICAD
|
||||
//Incoming document objects to merge
|
||||
API_NotifyEventID m_eventID;
|
||||
///An additional event parameter
|
||||
int32_t m_param;
|
||||
/*!
|
||||
Convert an Archicad project event type
|
||||
@return The equivalent Speckle event type
|
||||
*/
|
||||
static std::optional<ProjectEvent::Type> convert(API_NotifyEventID acEventType);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
#ifndef SPECKLE_RESOURCE
|
||||
#define SPECKLE_RESOURCE
|
||||
|
||||
//String resource IDs
|
||||
enum SpeckleStringResource {
|
||||
titleStringLib = 32700,
|
||||
generalStringLib,
|
||||
notifyStringLib,
|
||||
warningStringLib,
|
||||
errorStringLib,
|
||||
};
|
||||
|
||||
|
||||
//Title strings (UI title/label for dialogs, controls, menu items etc)
|
||||
enum SpeckleTitleString {
|
||||
untitledProjectID = 1,
|
||||
};
|
||||
|
||||
|
||||
//Help strings
|
||||
enum SpecklePromptString {
|
||||
};
|
||||
|
||||
|
||||
//Information strings (in UI content, logging, reports)
|
||||
enum SpeckleInfoString {
|
||||
};
|
||||
|
||||
|
||||
//Notification strings (advice displayed in alerts)
|
||||
enum SpeckleNotifyString {
|
||||
};
|
||||
|
||||
|
||||
//Warning strings (warnings displayed in alerts)
|
||||
enum SpeckleWarningString {
|
||||
};
|
||||
|
||||
|
||||
//Error strings (errors displayed in alerts)
|
||||
enum SpeckleErrorString {
|
||||
};
|
||||
|
||||
#endif //SPECKLE_RESOURCE
|
||||
@@ -15,6 +15,9 @@
|
||||
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, ); };
|
||||
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 */; };
|
||||
2193517B2C624FC100E5A69C /* MenuSubscriber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 219351782C624FC100E5A69C /* MenuSubscriber.cpp */; };
|
||||
2193519B2C6278D900E5A69C /* SelectionSubscriber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 219351992C6278D900E5A69C /* SelectionSubscriber.cpp */; };
|
||||
219351B12C62CC1A00E5A69C /* Guid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 219351AC2C62CC1A00E5A69C /* Guid.cpp */; };
|
||||
@@ -106,6 +109,11 @@
|
||||
21379E082AE47A6400A1584C /* libArchicad27.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libArchicad27.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
214EA4C52BA374FD008E5358 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
|
||||
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 = "<group>"; };
|
||||
215F08542C99DA8D00CD343B /* Project.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Project.h; sourceTree = "<group>"; };
|
||||
215F085B2C9AE23200CD343B /* SpeckleResource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SpeckleResource.h; sourceTree = "<group>"; };
|
||||
215F08622C9AE3D200CD343B /* Speckle.grc */ = {isa = PBXFileReference; lastKnownFileType = text; path = Speckle.grc; sourceTree = "<group>"; };
|
||||
215F08652C9B006700CD343B /* ProjectEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProjectEvent.cpp; sourceTree = "<group>"; };
|
||||
2167E2782C4911E2000827D3 /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
|
||||
2167E2792C4911EB000827D3 /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
|
||||
2167E27C2C49121F000827D3 /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
|
||||
@@ -207,6 +215,7 @@
|
||||
21F69F1B2C6A0FE2008B6A06 /* Interface */,
|
||||
21F69F952C71087A008B6A06 /* Record */,
|
||||
212A834E2AE47AD9001EAFE7 /* Serialise */,
|
||||
215F085B2C9AE23200CD343B /* SpeckleResource.h */,
|
||||
219351B02C62CC1A00E5A69C /* Utility */,
|
||||
218953A32C0C9CB00078F182 /* Version.h */,
|
||||
);
|
||||
@@ -231,6 +240,7 @@
|
||||
21F69F012C66C229008B6A06 /* Doxyfile */,
|
||||
21379E092AE47A6400A1584C /* Products */,
|
||||
21329F472BFA611C00B5C7AF /* README.md */,
|
||||
215F08612C9AE3D200CD343B /* RINT */,
|
||||
212A83422AE47AD9001EAFE7 /* Speckle */,
|
||||
219987FA2BD708BC0035E5EA /* SpeckleLibDoctest */,
|
||||
);
|
||||
@@ -245,6 +255,14 @@
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
215F08612C9AE3D200CD343B /* RINT */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
215F08622C9AE3D200CD343B /* Speckle.grc */,
|
||||
);
|
||||
path = RINT;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
218953A92C0F29FB0078F182 /* EventTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -281,6 +299,7 @@
|
||||
children = (
|
||||
21D0BDBE2C90F36B0077E104 /* DocStoreMergeEvent.h */,
|
||||
219351892C62655700E5A69C /* MenuEvent.h */,
|
||||
215F08652C9B006700CD343B /* ProjectEvent.cpp */,
|
||||
21D0BDC62C9245E40077E104 /* ProjectEvent.h */,
|
||||
2193519C2C627E3100E5A69C /* SelectionEvent.h */,
|
||||
);
|
||||
@@ -467,6 +486,8 @@
|
||||
21F93AE92B2F406D009A2C5B /* Addon.h */,
|
||||
210CC89D2C81E34400610F58 /* Platform.cpp */,
|
||||
210CC89E2C81E34400610F58 /* Platform.h */,
|
||||
215F08512C99DA8D00CD343B /* Project.cpp */,
|
||||
215F08542C99DA8D00CD343B /* Project.h */,
|
||||
21329F632BFD452C00B5C7AF /* Environment.md */,
|
||||
);
|
||||
path = Environment;
|
||||
@@ -491,6 +512,7 @@
|
||||
21B67D002C7CE15100FD64FC /* Exception.h in Headers */,
|
||||
21D0BD2C2C86FC350077E104 /* Record.h in Headers */,
|
||||
21D0BDB42C8F8AB60077E104 /* DocumentStoreCore.h in Headers */,
|
||||
215F08562C99DA8D00CD343B /* Project.h in Headers */,
|
||||
210CC8802C80CD2A00610F58 /* BridgeChild.h in Headers */,
|
||||
21D0BD4D2C8901A00077E104 /* ServerInfo.h in Headers */,
|
||||
21D0BDB52C8F8AB60077E104 /* DocumentStoreEngine.h in Headers */,
|
||||
@@ -626,6 +648,7 @@
|
||||
21F69F812C6FF3B0008B6A06 /* BridgeArgumentWrap.cpp in Sources */,
|
||||
2193517B2C624FC100E5A69C /* MenuSubscriber.cpp in Sources */,
|
||||
21F69F612C6D0286008B6A06 /* GetBindingsMethodNames.cpp in Sources */,
|
||||
215F08662C9B006800CD343B /* ProjectEvent.cpp in Sources */,
|
||||
21D0BDBD2C90F2830077E104 /* DocStoreSubscriber.cpp in Sources */,
|
||||
21D0BDB32C8F8AB60077E104 /* DocumentStoreCore.cpp in Sources */,
|
||||
21F93AEC2B2F406E009A2C5B /* Addon.cpp in Sources */,
|
||||
@@ -641,6 +664,7 @@
|
||||
219351B32C62CC1A00E5A69C /* String.cpp in Sources */,
|
||||
219351B12C62CC1A00E5A69C /* Guid.cpp in Sources */,
|
||||
21F69F512C6CCC25008B6A06 /* BrowserBridge.cpp in Sources */,
|
||||
215F08552C99DA8D00CD343B /* Project.cpp in Sources */,
|
||||
21F69F3B2C6B880C008B6A06 /* JSBaseTransport.cpp in Sources */,
|
||||
210CC89F2C81E34400610F58 /* Platform.cpp in Sources */,
|
||||
21D0BD202C86F0280077E104 /* AccountDatabase.cpp in Sources */,
|
||||
|
||||
Reference in New Issue
Block a user