BoxGraphics.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*global define*/
  2. define([
  3. '../Core/defaultValue',
  4. '../Core/defined',
  5. '../Core/defineProperties',
  6. '../Core/DeveloperError',
  7. '../Core/Event',
  8. './createPropertyDescriptor'
  9. ], function(
  10. defaultValue,
  11. defined,
  12. defineProperties,
  13. DeveloperError,
  14. Event,
  15. createPropertyDescriptor) {
  16. "use strict";
  17. /**
  18. * An optionally time-dynamic box.
  19. *
  20. * @alias BoxGraphics
  21. * @constructor
  22. */
  23. var BoxGraphics = function() {
  24. this._dimensions = undefined;
  25. this._dimensionsSubscription = undefined;
  26. this._show = undefined;
  27. this._showSubscription = undefined;
  28. this._fill = undefined;
  29. this._fillSubscription = undefined;
  30. this._material = undefined;
  31. this._materialSubscription = undefined;
  32. this._outline = undefined;
  33. this._outlineSubscription = undefined;
  34. this._outlineColor = undefined;
  35. this._outlineColorSubscription = undefined;
  36. this._outlineWidth = undefined;
  37. this._outlineWidthSubscription = undefined;
  38. this._definitionChanged = new Event();
  39. };
  40. defineProperties(BoxGraphics.prototype, {
  41. /**
  42. * Gets the event that is raised whenever a new property is assigned.
  43. * @memberof BoxGraphics.prototype
  44. *
  45. * @type {Event}
  46. * @readonly
  47. */
  48. definitionChanged : {
  49. get : function() {
  50. return this._definitionChanged;
  51. }
  52. },
  53. /**
  54. * Gets or sets the boolean {@link Property} specifying the box's visibility.
  55. * @memberof BoxGraphics.prototype
  56. * @type {Property}
  57. */
  58. show : createPropertyDescriptor('show'),
  59. /**
  60. * Gets or sets the {@link Cartesian3} {@link Property} specifying the dimensions of the box.
  61. * @memberof BoxGraphics.prototype
  62. * @type {Property}
  63. */
  64. dimensions : createPropertyDescriptor('dimensions'),
  65. /**
  66. * Gets or sets the {@link MaterialProperty} specifying the appearance of the box.
  67. * @memberof BoxGraphics.prototype
  68. * @type {MaterialProperty}
  69. */
  70. material : createPropertyDescriptor('material'),
  71. /**
  72. * Gets or sets the Boolean {@link Property} specifying whether the box should be filled.
  73. * @memberof BoxGraphics.prototype
  74. * @type {Property}
  75. */
  76. fill : createPropertyDescriptor('fill'),
  77. /**
  78. * Gets or sets the Boolean {@link Property} specifying whether the box should be outlined.
  79. * @memberof BoxGraphics.prototype
  80. * @type {Property}
  81. */
  82. outline : createPropertyDescriptor('outline'),
  83. /**
  84. * Gets or sets the Color {@link Property} specifying whether the color of the outline.
  85. * @memberof BoxGraphics.prototype
  86. * @type {Property}
  87. */
  88. outlineColor : createPropertyDescriptor('outlineColor'),
  89. /**
  90. * Gets or sets the Number {@link Property} specifying the width of the outline.
  91. * @memberof BoxGraphics.prototype
  92. * @type {Property}
  93. */
  94. outlineWidth : createPropertyDescriptor('outlineWidth')
  95. });
  96. /**
  97. * Duplicates a BoxGraphics instance.
  98. *
  99. * @param {BoxGraphics} [result] The object onto which to store the result.
  100. * @returns {BoxGraphics} The modified result parameter or a new instance if one was not provided.
  101. */
  102. BoxGraphics.prototype.clone = function(result) {
  103. if (!defined(result)) {
  104. result = new BoxGraphics();
  105. }
  106. result.dimensions = this.dimensions;
  107. result.show = this.show;
  108. result.material = this.material;
  109. result.fill = this.fill;
  110. result.outline = this.outline;
  111. result.outlineColor = this.outlineColor;
  112. result.outlineWidth = this.outlineWidth;
  113. return result;
  114. };
  115. /**
  116. * Assigns each unassigned property on this object to the value
  117. * of the same property on the provided source object.
  118. *
  119. * @param {BoxGraphics} source The object to be merged into this object.
  120. */
  121. BoxGraphics.prototype.merge = function(source) {
  122. //>>includeStart('debug', pragmas.debug);
  123. if (!defined(source)) {
  124. throw new DeveloperError('source is required.');
  125. }
  126. //>>includeEnd('debug');
  127. this.dimensions = defaultValue(this.dimensions, source.dimensions);
  128. this.show = defaultValue(this.show, source.show);
  129. this.material = defaultValue(this.material, source.material);
  130. this.fill = defaultValue(this.fill, source.fill);
  131. this.outline = defaultValue(this.outline, source.outline);
  132. this.outlineColor = defaultValue(this.outlineColor, source.outlineColor);
  133. this.outlineWidth = defaultValue(this.outlineWidth, source.outlineWidth);
  134. };
  135. return BoxGraphics;
  136. });