sprk_hca.h
1 // Copyright (c) Tech Soft 3D, Inc.
2 //
3 // The information contained herein is confidential and proprietary to Tech Soft 3D, Inc.,
4 // and considered a trade secret as defined under civil and criminal statutes.
5 // Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of
6 // unauthorized use or misappropriation of its trade secrets. Use of this information
7 // by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under
8 // a written non-disclosure agreement, expressly prescribing the scope and manner of such use.
9 
10 #ifndef SPRK_HCA_H
11 #define SPRK_HCA_H
12 
13 #include "sprk.h"
14 
15 #ifdef _MSC_VER
16 #ifndef STATIC_APP
17 # ifdef SPRK_HCA
18 # define HPS_HCA_API __declspec (dllexport)
19 # else
20 # define HPS_HCA_API __declspec (dllimport)
21 # endif
22 #endif
23 #else
24 # include <stddef.h>
25 #endif
26 
27 #ifndef HPS_HCA_API
28 # define HPS_HCA_API
29 #endif
30 
31 #include <mutex>
32 #include <vector>
33 
34 namespace HPS
35 {
37 class HPS_HCA_API HCA
38 {
39 public:
40 
42  class HPS_HCA_API ImportNotifier : public IONotifier
43  {
44  public:
47 
50  ImportNotifier(ImportNotifier const & in_that);
51 
56  ImportNotifier(IONotifier const & in_that);
57 
61  ImportNotifier(ImportNotifier && in_that);
62 
66  ImportNotifier & operator=(ImportNotifier && in_that);
67 
68  virtual ~ImportNotifier();
69 
70  static const HPS::Type staticType = HPS::Type::HCAImportNotifier;
71  HPS::Type ObjectType() const { return staticType; };
72 
76  ImportNotifier & operator=(ImportNotifier const & in_that);
77 
80  void Assign(ImportNotifier const & in_that);
81 
85  HPS::Model & GetTarget() const;
86  };
87 
89  class HPS_HCA_API ImportOptionsKit : public HPS::Sprocket
90  {
91  public:
94 
97  ImportOptionsKit(ImportOptionsKit const & in_kit);
98 
103 
107  ImportOptionsKit & operator=(ImportOptionsKit && in_that);
108 
109  virtual ~ImportOptionsKit();
110 
111  static const HPS::Type staticType = HPS::Type::HCAImportOptionsKit;
112  HPS::Type ObjectType() const { return staticType; }
113 
117  static ImportOptionsKit GetDefault();
118 
121  void Set(ImportOptionsKit const & in_kit);
122 
125  void Show(ImportOptionsKit & out_kit) const;
126 
130  ImportOptionsKit & operator=(ImportOptionsKit const & in_kit);
131 
134  bool Empty() const;
135 
139  bool Equals(ImportOptionsKit const & in_kit) const;
140 
144  bool operator==(ImportOptionsKit const & in_kit) const;
145 
149  bool operator!=(ImportOptionsKit const & in_kit) const;
150 
154  ImportOptionsKit & SetTarget(HPS::Model const & in_target);
155 
159  ImportOptionsKit & SetView(HPS::View const & in_view);
160 
164  ImportOptionsKit & SetJavascriptPath(HPS::UTF8 const & javascript_path);
165 
169  ImportOptionsKit & SetNetworkPath(HPS::UTF8 const & network_path);
170 
174  ImportOptionsKit & SetNetworkModelName(HPS::UTF8 const & network_model_name);
175 
179  ImportOptionsKit & SetModelBoundingPreviews(bool model_bounding_previews);
180 
184  ImportOptionsKit & SetEjectedBoundingPreviews(bool ejected_bounding_previews);
185 
189  ImportOptionsKit & SetLimitMiB(uint32_t limit_MiB);
190 
191 
195  bool ShowTarget(HPS::Model & out_model) const;
196 
200  bool ShowView(HPS::View & out_view) const;
201 
205  bool ShowJavascriptPath(HPS::UTF8 & out_javascript_path) const;
206 
210  bool ShowNetworkPath(HPS::UTF8 & out_network_path) const;
211 
215  bool ShowNetworkModelName(HPS::UTF8 & out_network_model_name) const;
216 
220  bool ShowModelBoundingPreviews(bool & out_model_bounding_previews) const;
221 
225  bool ShowEjectedBoundingPreviews(bool & out_ejected_bounding_previews) const;
226 
230  bool ShowLimitMiB(uint32_t & out_limit_MiB) const;
231 
232 
235  ImportOptionsKit & UnsetTarget();
236 
237 
240  ImportOptionsKit & UnsetView();
241 
244  ImportOptionsKit & UnsetJavascriptPath();
245 
248  ImportOptionsKit & UnsetNetworkPath();
249 
252  ImportOptionsKit & UnsetNetworkModelName();
253 
256  ImportOptionsKit & UnsetModelBoundingPreviews();
257 
260  ImportOptionsKit & UnsetEjectedBoundingPreviews();
261 
264  ImportOptionsKit & UnsetLimitMiB();
265 
268  ImportOptionsKit & UnsetEverything();
269 
270  };
271 
272 
274  class HPS_HCA_API File
275  {
276  public:
281  static ImportNotifier Import(char const * in_file_name, ImportOptionsKit const & in_options);
282 
283  private:
285  File();
286  };
287 
290 
292  enum class IOResult {
293  Success,
294  ErrorUnknownFailure,
295  ErrorNoHCAView,
296  ErrorCyclicFileDependencies,
297  ErrorSerializationFailure,
298  ErrorDeserializationFailure,
299  ErrorIllegalFileName,
300  ErrorFileSystemFailure,
301  ErrorHCARootAlreadyExists,
302  ErrorInvalidBuffer,
303  };
304 
307 
309  class HPS_HCA_API RequestIdEvent : public Event
310  {
311  public:
312 
315  {
316  channel = GetClassID();
317  consumable = false;
318  }
319 
320  RequestIdEvent(uint32_t in_request_id) : Event(), request_id(in_request_id)
321  {
322  channel = GetClassID();
323  consumable = false;
324  }
325 
328  RequestIdEvent(Event const & in_event) : Event(in_event)
329  {
330  if (in_event.GetChannel() == Object::ClassID<RequestIdEvent>())
331  {
332  auto that = static_cast<RequestIdEvent const &>(in_event);
333  request_id = that.request_id;
334  }
335  else
336  throw HPS::InvalidSpecificationException("Invalid Event Type to Cast From.");
337  }
338 
339  virtual ~RequestIdEvent();
340 
343  Event * Clone() const override
344  {
345  RequestIdEvent * new_event = new RequestIdEvent(*this);
346  return new_event;
347  }
348 
349  uint32_t request_id;
350  };
351 
353 
354 
355  struct InstanceInc {
356  InstanceInc() : inclusion_key(0xFFFFFFFF), instance_key(0xFFFFFFFF) {}
357  InstanceInc(uint32_t inclusion_key, uint32_t instance_key)
358  : inclusion_key(inclusion_key), instance_key(instance_key) {}
359  uint32_t inclusion_key;
360  uint32_t instance_key;
361 
362  bool operator==(InstanceInc const & that) const
363  {
364  return (inclusion_key == that.inclusion_key) && (instance_key == that.instance_key);
365  }
366 
367  bool operator!=(InstanceInc const & that) const
368  {
369  return !operator==(that);
370  }
371  };
372 
373  typedef ::std::vector<InstanceInc, HPS::Allocator<InstanceInc>> InstanceIncArray;
374 
375  class ModelTreeItem;
376  class ModelTree;
377 
378  typedef ::std::shared_ptr<ModelTreeItem> ModelTreeItemPtr;
379  typedef ::std::shared_ptr<ModelTree> ModelTreePtr;
380 
381 
383  class HPS_HCA_API Model {
384 
385  public:
386 
389  Model();
390 
393  Model(HPS::Model const & in_model);
394 
395  Model(Model const & that);
396 
399  Model(Model&& that);
400  ~Model();
401 
402  bool Equals(Model const & other) const;
403  bool operator== (Model const & other) const;
404  bool operator!= (Model const & other) const;
405  Model& operator=(Model&& other);
406 
409  bool Empty();
410 
412 
413  // Waits for the load to complete in a given number of milliseconds (0 means wait indefinitely).
414  // Returns true if successful, false otherwise.
415  // Note: Presently only works for SCS file loading, not network loading.
416  bool WaitForLoadToComplete(unsigned int in_timeout_ms = 0);
417 
418  bool ShowRootNode(int64_t & out_node_id);
419 
420  bool ShowNodeName(int64_t in_node_id, HPS::UTF8 & out_name);
421 
422  bool ShowNodeChildren(int64_t in_node_id, HPS::Int64Array & out_ids);
423 
424  bool ShowNodeParent(int64_t in_node_id, int64_t & out_parent_id);
425 
426  bool ShowInstanceIncs(int64_t in_node_id, InstanceIncArray & out_instance_incs);
427 
428  bool ShowNode(InstanceInc const & in_instance_inc, int64_t & out_node_id);
429 
430  bool ShowIncludePath(HPS::KeyPath & out_key_path);
431 
432  bool ShowInstanceIncReference(InstanceInc const & instance_inc, HPS::KeyArray & out_reference_keys);
433 
434  bool RequestNodeProperties(int64_t in_node_id, uint32_t & out_request_id);
435 
436  bool RetrieveNodeProperties(uint32_t in_request_id,
437  int64_t & out_node_id, bool & out_valid,
438  HPS::UTF8Array & out_keys, HPS::UTF8Array & out_values);
439 
440  bool ShowNodeAndIncFromKeyPath(HPS::KeyPath const & in_key_path, int64_t & in_node_id, HPS::HCA::InstanceInc & out_instanceInc);
441 
442  void Show(HPS::Canvas const & in_canvas, int64_t in_node_id);
443 
444  void Hide(HPS::Canvas const & in_canvas, int64_t in_node_id);
445 
446  void Unhighlight(HPS::Canvas const & in_canvas, int64_t in_node_id);
447 
448  void Highlight(HPS::Canvas const & in_canvas, HighlightOptionsKit const & in_highlight_options, int64_t in_node_id);
449 
450  void Highlight(HPS::Canvas const & in_canvas, HighlightOptionsKit const & in_highlight_options, HPS::Int64Array const & in_node_ids);
451 
452  void Isolate(HPS::Canvas const & in_canvas, int64_t in_node_id);
453 
454  void Zoom(HPS::Canvas const & in_canvas, int64_t in_node_id);
455 
456  void ShowAll(HPS::Canvas const & in_canvas);
457 
458  bool IsHidden(int64_t in_node_id);
459 
460  bool IsHighlighted(int64_t in_node_id);
461 
462  void OnHighlightUnhighlight();
463 
464  void UnhighlightAll(HPS::Canvas const & in_canvas);
465 
466  private:
467 
468  void highlight_internal(
469  HPS::Canvas const & in_canvas,
470  HPS::HighlightOptionsKit const & in_highlight_options,
471  int64_t in_node_id);
472 
473  friend class ModelTreeItem;
475  Model(void * in_opaque);
476  void * opaque;
477  };
478 
481  class HPS_HCA_API ModelTree : public Sprocket
482  {
483  public:
486  enum class ItemType
487  {
488  None,
489  Model,
490  Node,
491  };
492 
494  ModelTree();
495 
499  ModelTree(Canvas const & in_canvas, HCA::Model & hca_model);
500 
503  ModelTree(ModelTree const & in_that);
504 
507  ModelTree(ModelTree && in_that);
508 
509  virtual ~ModelTree();
510 
511  static const HPS::Type staticType = HPS::Type::HCAModelTree;
512  virtual HPS::Type ObjectType() const { return staticType; }
513 
517  ModelTree & operator=(ModelTree const & in_that);
518 
522  ModelTree & operator=(ModelTree && in_that);
523 
527  virtual void Assign(ModelTree const & in_that);
528 
532  bool Equals(ModelTree const & in_that) const;
533 
537  bool operator!=(ModelTree const & in_that) const;
538 
542  bool operator==(ModelTree const & in_that) const;
543 
544 
551  void SetRoot(ModelTreeItemPtr const & in_root);
552 
555  ModelTreeItemPtr GetRoot() const;
556 
557  HCA::Model & GetHCAModel() const;
558 
559  HPS::Canvas & GetCanvas() const;
560 
563  virtual void Flush();
564 
565  virtual void OnHighlightUnhighlight();
566  };
567 
568 
571  class HPS_HCA_API ModelTreeItem : public Sprocket
572  {
573  public:
575  ModelTreeItem();
576 
579  ModelTreeItem(ModelTreeItem const & in_that);
580 
583  ModelTreeItem(ModelTreeItem && in_that);
584 
586  ModelTreeItem(ModelTreePtr const & in_tree, HCA::Model const & in_hca_model);
587 
590  ModelTreeItem(ModelTreePtr const & in_tree, int64_t in_node_id);
591 
592  virtual ~ModelTreeItem();
593 
594  static const HPS::Type staticType = HPS::Type::HCAModelTreeItem;
595  HPS::Type ObjectType() const { return staticType; }
596 
600  ModelTreeItem & operator=(ModelTreeItem const & in_that);
601 
605  ModelTreeItem & operator=(ModelTreeItem && in_that);
606 
610  virtual void Assign(ModelTreeItem const & in_that);
611 
615  bool Equals(ModelTreeItem const & in_that) const;
616 
620  bool operator!=(ModelTreeItem const & in_that) const;
621 
625  bool operator==(ModelTreeItem const & in_that) const;
626 
627 
630  ModelTreePtr GetTree() const;
631 
634  UTF8 GetTitle() const;
635 
638  ModelTree::ItemType GetItemType() const;
639 
642  bool HasChildren() const;
643 
644 
646  virtual ModelTreeItemPtr AddChild(int64_t in_node_id) = 0;
647 
648 
651  virtual void Expand();
652 
655  virtual void Collapse();
656 
657 
659  uint64_t GetNodeId() const;
660 
662  bool IsHidden() const;
663 
665  virtual void OnShowHide() {};
666 
668  void Hide();
669 
671  void Show();
672 
674  void Isolate();
675 
677  void Zoom();
678 
680  void ShowAll();
681 
684  bool IsExpanded() const;
685 
687  bool IsHighlighted() const;
688 
690  virtual void OnHighlightUnhighlight();
691 
693  void Highlight(HighlightOptionsKit const & in_highlight_options);
694 
696  void Unhighlight();
697 
699  bool RequestProperties(uint32_t & out_request_id);
700  };
701 
702 private:
704  HCA();
705 };
706 
707 }
708 
709 #endif
Definition: hps.h:85
Definition: sprk_hca.h:383
Definition: sprk.h:273
An InvalidSpecificationException is thrown when a method is called with non-sensical or contradictory...
Definition: hps.h:5889
Definition: sprk.h:67
Definition: sprk.h:106
IOResult
Definition: sprk_hca.h:292
intptr_t GetChannel() const
Definition: hps.h:6402
Definition: sprk_hca.h:89
Definition: sprk_hca.h:571
Definition: sprk_hca.h:309
HPS::Type ObjectType() const
Definition: sprk_hca.h:112
RequestIdEvent()
Definition: sprk_hca.h:314
Definition: sprk_hca.h:274
Definition: sprk_hca.h:481
HPS::Type ObjectType() const
Definition: sprk_hca.h:71
Definition: hps.h:7164
Event * Clone() const override
Definition: sprk_hca.h:343
Definition: hps.h:48938
Definition: hps.h:45318
Definition: hps.h:6369
std::vector< UTF8, Allocator< UTF8 > > UTF8Array
Array of type HPS::UTF8.
Definition: hps.h:6719
HPS::Type ObjectType() const
Definition: sprk_hca.h:595
Definition: sprk.h:484
std::vector< int64_t, HPS::Allocator< int64_t > > Int64Array
Array of type int64_t.
Definition: hps.h:6767
std::vector< Key, Allocator< Key > > KeyArray
Array of type HPS::Key.
Definition: hps.h:6723
Definition: sprk_hca.h:355
virtual void OnShowHide()
Definition: sprk_hca.h:665
Definition: hps.h:9424
virtual HPS::Type ObjectType() const
Definition: sprk_hca.h:512
RequestIdEvent(Event const &in_event)
Definition: sprk_hca.h:328
Definition: sprk_hca.h:42
ItemType
Definition: sprk_hca.h:486
Definition: sprk_hca.h:37