handling Begin, End event types, sending setModelsExpired event to UI
This commit is contained in:
@@ -2,10 +2,22 @@
|
||||
#include "Connector/Interface/Browser/Bridge/Send/GetSendFilters.h"
|
||||
#include "Connector/Interface/Browser/Bridge/Send/GetSendSettings.h"
|
||||
#include "Connector/Interface/Browser/Bridge/Send/Send.h"
|
||||
#include "Connector/Connector.h"
|
||||
#include "Connector/ConnectorResource.h"
|
||||
#include "Connector/Database/ModelCardDatabase.h"
|
||||
#include "Speckle/Event/Type/ElementChangedEvent.h"
|
||||
#include "Speckle/Record/Element/Element.h"
|
||||
#include "Speckle/Database/BIMElementDatabase.h"
|
||||
#include "Speckle/Environment/Project.h"
|
||||
#include "Speckle/Database/Identity/RecordID.h"
|
||||
#include "Active/Serialise/CargoHold.h"
|
||||
#include "Active/Serialise/Package/Wrapper/ContainerWrap.h"
|
||||
|
||||
using namespace speckle::database;
|
||||
using namespace connector::interfac::browser::bridge;
|
||||
using namespace speckle::utility;
|
||||
using namespace speckle::event;
|
||||
using namespace active::serialise;
|
||||
|
||||
/*--------------------------------------------------------------------
|
||||
Default constructor
|
||||
@@ -24,14 +36,38 @@ SendBridge::SendBridge() : BrowserBridge{"sendBinding"} {
|
||||
|
||||
return: True if the event should be closed
|
||||
--------------------------------------------------------------------*/
|
||||
bool SendBridge::handle(const speckle::event::ElementChangedEvent& event) {
|
||||
auto changedElementIDs = event.getChangedElementIDs();
|
||||
bool SendBridge::handle(const ElementChangedEvent& event) {
|
||||
|
||||
auto eventType = event.getEventType();
|
||||
switch (eventType)
|
||||
{
|
||||
case ElementChangedEvent::EventType::Begin: {
|
||||
m_changedElements.clear();
|
||||
} break;
|
||||
case ElementChangedEvent::EventType::End: {
|
||||
auto modelCardDatabase = connector()->getModelCardDatabase();
|
||||
auto modelCards = modelCardDatabase->getCards();
|
||||
|
||||
for (const auto& id : changedElementIDs) {
|
||||
RecordIDList idList;
|
||||
for (const auto& card : modelCards)
|
||||
idList.push_back(card->getID());
|
||||
|
||||
// TODO: search for expired modelcards
|
||||
|
||||
if (idList.empty())
|
||||
return true;
|
||||
|
||||
auto wrapped = std::make_unique<CargoHold<ContainerWrap<RecordIDList>, RecordIDList>>(std::move(idList));
|
||||
sendEvent("setModelsExpired", std::move(wrapped));
|
||||
|
||||
} break;
|
||||
case ElementChangedEvent::EventType::Change:
|
||||
case ElementChangedEvent::EventType::Edit: {
|
||||
auto changedElement = event.getChangedElement();
|
||||
m_changedElements.push_back(changedElement);
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//auto wrapped = std::make_unique<CargoHold<PackageWrap, SelectionInfo>>(std::move(selectionInfo));
|
||||
//sendEvent("setSelection", std::move(wrapped));
|
||||
return true;
|
||||
} //SendBridge::handle
|
||||
|
||||
@@ -174,7 +174,6 @@ BrowserPalette::BrowserPalette() :
|
||||
}
|
||||
|
||||
install<ConfigBridge>();
|
||||
//install<SendBridge>();
|
||||
|
||||
if (auto ref = install<SendBridge>(); ref) {
|
||||
if (auto sendBridgeRef = std::dynamic_pointer_cast<SendBridge>(ref); sendBridgeRef) {
|
||||
|
||||
@@ -14,20 +14,8 @@ BIMLink::BIMLink(const API_Neig& selected, const BIMRecordID& tableID) : base{Gu
|
||||
//More info should be extracted from API_Neig in future (as required) - extract into link settings, e.g. selection target etc
|
||||
} //Link::Link
|
||||
|
||||
/*--------------------------------------------------------------------
|
||||
Constructor
|
||||
|
||||
guid: An Archicad element id
|
||||
tableID: The ID of the parent table
|
||||
--------------------------------------------------------------------*/
|
||||
BIMLink::BIMLink(const Guid& guid, const BIMRecordID& tableID) : base{ guid, tableID } {
|
||||
} //Link::Link
|
||||
|
||||
|
||||
BIMLinkList::BIMLinkList(const ElementIDList& elementIDList) {
|
||||
for (const auto& id : elementIDList)
|
||||
push_back(id);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -38,12 +38,6 @@ namespace speckle::database {
|
||||
@param tableID The ID of the parent table
|
||||
*/
|
||||
BIMLink(const API_Neig& selected, const BIMRecordID& tableID);
|
||||
/*!
|
||||
Constructor
|
||||
@param an Archicad element id
|
||||
@param tableID The ID of the parent table
|
||||
*/
|
||||
BIMLink(const Guid& guid, const BIMRecordID& tableID);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -30,16 +30,19 @@ namespace {
|
||||
{
|
||||
case APINotifyElement_New: {
|
||||
ACAPI_Element_AttachObserver(elemType->elemHead.guid);
|
||||
addon()->publishExternal(ElementChangedEvent{ ElementID{ elemType->elemHead.guid }, ElementChangedEvent::EventType::New });
|
||||
} break;
|
||||
case APINotifyElement_Change: {
|
||||
addon()->publishExternal(ElementChangedEvent{ ElementID{ elemType->elemHead.guid }, ElementChangedEvent::EventType::Change });
|
||||
} break;
|
||||
case APINotifyElement_Change:
|
||||
case APINotifyElement_Edit: {
|
||||
// TODO add IDs to temp List
|
||||
addon()->publishExternal(ElementChangedEvent{ ElementID{ elemType->elemHead.guid }, ElementChangedEvent::EventType::Edit });
|
||||
} break;
|
||||
case APINotifyElement_BeginEvents:
|
||||
// TODO clear the temp List
|
||||
addon()->publishExternal(ElementChangedEvent{ ElementID{}, ElementChangedEvent::EventType::Begin });
|
||||
break;
|
||||
case APINotifyElement_EndEvents: {
|
||||
// TODO send the event
|
||||
addon()->publishExternal(ElementChangedEvent{ ElementID{}, ElementChangedEvent::EventType::End });
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define SPECKLE_EVENT_ELEMENT_CHANGED_SUBSCRIBER
|
||||
|
||||
#include "Active/Event/Subscriber.h"
|
||||
#include "Speckle/Database/Identity/RecordID.h"
|
||||
|
||||
namespace speckle::event {
|
||||
|
||||
@@ -63,6 +64,8 @@ namespace speckle::event {
|
||||
@return True if the event should be closed
|
||||
*/
|
||||
virtual bool handle(const ElementChangedEvent& event) = 0;
|
||||
|
||||
speckle::database::ElementIDList m_changedElements;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#include "Active/Utility/Guid.h"
|
||||
#include "Active/Utility/String.h"
|
||||
#include "Speckle/Database/Identity/BIMLink.h"
|
||||
|
||||
namespace speckle::event {
|
||||
|
||||
@@ -14,6 +13,8 @@ namespace speckle::event {
|
||||
*/
|
||||
class ElementChangedEvent : public active::event::Event {
|
||||
public:
|
||||
|
||||
enum EventType { New, Begin, End, Change, Edit };
|
||||
|
||||
static const inline active::utility::NameID ID{active::utility::String{"element change"},
|
||||
active::utility::Guid{active::utility::String{"ac9366d5-90fd-497e-b7f7-a7b4c8d97c91"}}};
|
||||
@@ -24,7 +25,7 @@ namespace speckle::event {
|
||||
Constructor
|
||||
@param selected A link to a selected element (nullopt if the selection is empty)
|
||||
*/
|
||||
ElementChangedEvent(speckle::database::RecordIDList changed) : Event{ ID }, m_changedElementIDs{ changed } {}
|
||||
ElementChangedEvent(speckle::database::ElementID changed, EventType eventType) : Event{ ID }, m_changedElement{ changed }, m_eventType{ eventType } {}
|
||||
/*!
|
||||
Copy constructor
|
||||
@param source The object to copy
|
||||
@@ -41,17 +42,17 @@ namespace speckle::event {
|
||||
Determine if the event selection is empty
|
||||
@return True if the event selection is empty
|
||||
*/
|
||||
bool empty() const { return m_changedElementIDs.empty(); }
|
||||
bool empty() const { return m_changedElement.empty(); }
|
||||
/*!
|
||||
Get a link to the last selected element
|
||||
@return A link to the last selected element (nullopt if the event selection is empty)
|
||||
*/
|
||||
speckle::database::RecordIDList getChangedElementIDs() const { return m_changedElementIDs; }
|
||||
speckle::database::ElementID getChangedElement() const { return m_changedElement; }
|
||||
EventType getEventType() const { return m_eventType; }
|
||||
|
||||
private:
|
||||
//speckle::database::BIMLink::Option m_changedLink;
|
||||
speckle::database::RecordIDList m_changedElementIDs;
|
||||
//RecordIDList
|
||||
speckle::database::ElementID m_changedElement;
|
||||
EventType m_eventType;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user