7#include <bsoncxx/builder/basic/array.hpp>
13EntityResultTable<T>::EntityResultTable(
ot::UID ID, EntityBase *parent, EntityObserver *obs, ModelState *ms, ClassFactoryHandler* factory,
const std::string &owner) :
14 EntityBase(
ID, parent, obs, ms, factory, owner),
15 tableDataStorageId(-1),
16 tableDataStorageVersion(-1)
22EntityResultTable<T>::~EntityResultTable()
27bool EntityResultTable<T>::getEntityBox(
double &xmin,
double &xmax,
double &ymin,
double &ymax,
double &zmin,
double &zmax)
33void EntityResultTable<T>::StoreToDataBase(
void)
35 EntityBase::StoreToDataBase();
39void EntityResultTable<T>::AddStorageData(bsoncxx::builder::basic::document &storage)
42 EntityBase::AddStorageData(storage);
46 bsoncxx::builder::basic::kvp(
"TableDataID", tableDataStorageId),
47 bsoncxx::builder::basic::kvp(
"TableDataVersion", tableDataStorageVersion),
48 bsoncxx::builder::basic::kvp(
"MinCol", _minCol),
49 bsoncxx::builder::basic::kvp(
"MaxCol", _maxCol),
50 bsoncxx::builder::basic::kvp(
"MinRow", _minRow),
51 bsoncxx::builder::basic::kvp(
"MaxRow", _maxRow)
57void EntityResultTable<T>::readSpecificDataFromDataBase(bsoncxx::document::view &doc_view, std::map<ot::UID, EntityBase *> &entityMap)
60 EntityBase::readSpecificDataFromDataBase(doc_view, entityMap);
62 if (tableData.use_count() == 0 && tableData !=
nullptr)
68 tableDataStorageId = doc_view[
"TableDataID"].get_int64();
69 tableDataStorageVersion = doc_view[
"TableDataVersion"].get_int64();
70 _minCol = doc_view[
"MinCol"].get_int32();
71 _maxCol = doc_view[
"MaxCol"].get_int32();
72 _minRow = doc_view[
"MinRow"].get_int32();
73 _maxRow = doc_view[
"MaxRow"].get_int32();
79void EntityResultTable<T>::addVisualizationNodes()
81 OldTreeIcon treeIcons;
83 treeIcons.visibleIcon =
"TableVisible";
84 treeIcons.hiddenIcon =
"TableHidden";
92 treeIcons.addToJsonDoc(doc);
94 getObserver()->sendMessageToViewer(doc);
98 EntityBase::addVisualizationNodes();
103void EntityResultTable<T>::addVisualizationItem(
bool isHidden)
105 OldTreeIcon treeIcons;
107 treeIcons.visibleIcon =
"TableVisible";
108 treeIcons.hiddenIcon =
"TableHidden";
120 treeIcons.addToJsonDoc(doc);
122 getObserver()->sendMessageToViewer(doc);
127void EntityResultTable<T>::createProperties()
129 const std::string visibleTableSize =
"Visible Table Dimensions";
131 EntityPropertiesInteger::createProperty(visibleTableSize,
"Min Row", _minRow,
"default", getProperties());
132 EntityPropertiesInteger::createProperty(visibleTableSize,
"Max Row", _maxRow,
"default", getProperties());
133 EntityPropertiesInteger::createProperty(visibleTableSize,
"Min Column", _minCol,
"default", getProperties());
134 EntityPropertiesInteger::createProperty(visibleTableSize,
"Max Column", _maxCol,
"default", getProperties());
135 getProperties().forceResetUpdateForAllProperties();
139bool EntityResultTable<T>::updateFromProperties()
142 assert(getProperties().anyPropertyNeedsUpdate());
147 getProperties().forceResetUpdateForAllProperties();
153std::shared_ptr<EntityResultTableData<T>> EntityResultTable<T>::getTableData()
155 EnsureTableDataLoaded();
160void EntityResultTable<T>::EnsureTableDataLoaded()
162 if (tableData ==
nullptr)
164 if (tableDataStorageId != -1)
166 if (tableDataStorageVersion != -1)
168 std::map<ot::UID, EntityBase*> entitymap;
169 auto tempPtr =
dynamic_cast<EntityResultTableData<T>*
>(readEntityFromEntityIDAndVersion(
this, tableDataStorageId, tableDataStorageVersion, entitymap));
170 if (tempPtr !=
nullptr)
172 tableData = std::shared_ptr <EntityResultTableData<T>>(tempPtr);
176 throw std::exception(
"Failed to load the Table Data.");
181 assert(tableData !=
nullptr);
186void EntityResultTable<T>::setTableData(std::shared_ptr<EntityResultTableData<T>> data)
193 tableDataStorageId = tableData->getEntityID();
194 tableDataStorageVersion = tableData->getEntityStorageVersion();
199inline int EntityResultTable<T>::getMinColumn()
201 auto propBase = getProperties().getProperty(
"Min Column");
202 auto intProp =
dynamic_cast<EntityPropertiesInteger*
>(propBase);
203 return intProp->getValue();
207inline int EntityResultTable<T>::getMinRow()
209 auto propBase = getProperties().getProperty(
"Min Row");
210 auto intProp =
dynamic_cast<EntityPropertiesInteger*
>(propBase);
211 return intProp->getValue();
215inline int EntityResultTable<T>::getMaxColumn()
217 auto propBase = getProperties().getProperty(
"Max Column");
218 auto intProp =
dynamic_cast<EntityPropertiesInteger*
>(propBase);
219 return intProp->getValue();
223inline int EntityResultTable<T>::getMaxRow()
225 auto propBase = getProperties().getProperty(
"Max Row");
226 auto intProp =
dynamic_cast<EntityPropertiesInteger*
>(propBase);
227 return intProp->getValue();
231inline void EntityResultTable<T>::setMinColumn(
int minCol)
233 auto propBase = getProperties().getProperty(
"Min Column");
234 auto intProp =
dynamic_cast<EntityPropertiesInteger*
>(propBase);
235 intProp->setValue(minCol);
236 intProp->setNeedsUpdate();
240inline void EntityResultTable<T>::setMinRow(
int minRow)
242 auto propBase = getProperties().getProperty(
"Min Row");
243 auto intProp =
dynamic_cast<EntityPropertiesInteger*
>(propBase);
244 intProp->setValue(minRow);
245 intProp->setNeedsUpdate();
249inline void EntityResultTable<T>::setMaxColumn(
int maxCol)
251 auto propBase = getProperties().getProperty(
"Max Column");
252 auto intProp =
dynamic_cast<EntityPropertiesInteger*
>(propBase);
253 intProp->setValue(maxCol);
254 intProp->setNeedsUpdate();
258inline void EntityResultTable<T>::setMaxRow(
int maxRow)
260 auto propBase = getProperties().getProperty(
"Max Row");
261 auto intProp =
dynamic_cast<EntityPropertiesInteger*
>(propBase);
262 intProp->setValue(maxRow);
263 intProp->setNeedsUpdate();
267void EntityResultTable<T>::deleteTableData(
void)
270 tableDataStorageId = -1;
271 tableDataStorageVersion = -1;
277void EntityResultTable<T>::releaseTableData(
void)
279 if (tableData ==
nullptr)
#define OT_ACTION_MEMBER
Definition ActionTypes.h:11
#define OT_ACTION_CMD_UI_VIEW_OBJ_AddSceneNode
Definition ActionTypes.h:255
#define OT_ACTION_PARAM_MODEL_EntityID
Definition ActionTypes.h:477
#define OT_ACTION_PARAM_UI_TREE_Name
Definition ActionTypes.h:380
#define OT_ACTION_PARAM_MODEL_ITM_IsEditable
Definition ActionTypes.h:517
#define OT_ACTION_CMD_UI_VIEW_AddContainerNode
Definition ActionTypes.h:228
JSON document.
Definition JSON.h:276
JSON String value.
Definition JSON.h:84
static std::string getTypeName()
Definition TemplateTypeName.hpp:9
Definition VisualisationTypes.h:13
void addToJsonObject(ot::JsonValue &_object, ot::JsonAllocator &_allocator) const override
Add the object contents to the provided JSON object.
Definition VisualisationTypes.cpp:26
void addTableVisualisation()
Definition VisualisationTypes.cpp:9
int ID
The ID datatype used for items.
Definition globalDataTypes.h:68
unsigned long UID
Unique identifier (32 bit unsigned integer)
Definition CoreTypes.h:27