ModelGraphics.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 model.
  19. *
  20. * @alias ModelGraphics
  21. * @constructor
  22. */
  23. var ModelGraphics = function() {
  24. this._show = undefined;
  25. this._showSubscription = undefined;
  26. this._scale = undefined;
  27. this._scaleSubscription = undefined;
  28. this._minimumPixelSize = undefined;
  29. this._minimumPixelSizeSubscription = undefined;
  30. this._uri = undefined;
  31. this._uriSubscription = undefined;
  32. this._definitionChanged = new Event();
  33. };
  34. defineProperties(ModelGraphics.prototype, {
  35. /**
  36. * Gets the event that is raised whenever a new property is assigned.
  37. * @memberof ModelGraphics.prototype
  38. *
  39. * @type {Event}
  40. * @readonly
  41. */
  42. definitionChanged : {
  43. get : function() {
  44. return this._definitionChanged;
  45. }
  46. },
  47. /**
  48. * Gets or sets the boolean {@link Property} specifying the model's visibility.
  49. * @memberof ModelGraphics.prototype
  50. * @type {Property}
  51. */
  52. show : createPropertyDescriptor('show'),
  53. /**
  54. * Gets or sets the Number {@link Property} specifying the model's scale.
  55. * @memberof ModelGraphics.prototype
  56. * @type {Property}
  57. */
  58. scale : createPropertyDescriptor('scale'),
  59. /**
  60. * Gets or sets the Number {@link Property} specifying the model's approximate minimum pixel size regardless of zoom.
  61. * @memberof ModelGraphics.prototype
  62. * @type {Property}
  63. */
  64. minimumPixelSize : createPropertyDescriptor('minimumPixelSize'),
  65. /**
  66. * Gets or sets the string {@link Property} specifying the model's uri.
  67. * @memberof ModelGraphics.prototype
  68. * @type {Property}
  69. */
  70. uri : createPropertyDescriptor('uri')
  71. });
  72. /**
  73. * Duplicates a ModelGraphics instance.
  74. *
  75. * @param {ModelGraphics} [result] The object onto which to store the result.
  76. * @returns {ModelGraphics} The modified result parameter or a new instance if one was not provided.
  77. */
  78. ModelGraphics.prototype.clone = function(result) {
  79. if (!defined(result)) {
  80. result = new ModelGraphics();
  81. }
  82. result.show = this.show;
  83. result.scale = this.scale;
  84. result.minimumPixelSize = this.minimumPixelSize;
  85. result.uri = this.uri;
  86. return result;
  87. };
  88. /**
  89. * Assigns each unassigned property on this object to the value
  90. * of the same property on the provided source object.
  91. *
  92. * @param {ModelGraphics} source The object to be merged into this object.
  93. */
  94. ModelGraphics.prototype.merge = function(source) {
  95. //>>includeStart('debug', pragmas.debug);
  96. if (!defined(source)) {
  97. throw new DeveloperError('source is required.');
  98. }
  99. //>>includeEnd('debug');
  100. this.show = defaultValue(this.show, source.show);
  101. this.scale = defaultValue(this.scale, source.scale);
  102. this.minimumPixelSize = defaultValue(this.minimumPixelSize, source.minimumPixelSize);
  103. this.uri = defaultValue(this.uri, source.uri);
  104. };
  105. return ModelGraphics;
  106. });