@mlightcad/graphic-interface
Version:
The graphic-interface package provides the graphics interface for controlling how AutoCAD entities are displayed on screen. This package offers a simplified API compared to AutoCAD ObjectARX's AcGi classes, making it more developer-friendly while maintain
199 lines • 6.5 kB
JavaScript
import { AcGeBox2d, AcGePoint3d } from '@mlightcad/geometry-engine';
/**
* This class ised used to pass back information to the user about the viewing characteristics of the
* current viewport.
*/
var AcGiViewport = /** @class */ (function () {
function AcGiViewport() {
this._number = -1;
this._id = '';
this._groupId = '';
this._centerPoint = new AcGePoint3d();
this._height = 0;
this._width = 0;
this._viewCenter = new AcGePoint3d();
this._viewHeight = 0;
}
Object.defineProperty(AcGiViewport.prototype, "number", {
/**
* The viewport ID number. If the viewport is inactive, -1 is returned.
*/
get: function () {
return this._number;
},
set: function (value) {
this._number = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(AcGiViewport.prototype, "id", {
/**
* The id of the viewport.
*/
get: function () {
return this._id;
},
set: function (value) {
this._id = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(AcGiViewport.prototype, "groupId", {
/**
* The id of the group which this viewport belongs to.
*/
get: function () {
return this._groupId;
},
set: function (value) {
this._groupId = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(AcGiViewport.prototype, "centerPoint", {
/**
* The center point of the viewport entity in WCS coordinates (within Paper Space).
*/
get: function () {
return this._centerPoint;
},
set: function (value) {
this._centerPoint.copy(value);
},
enumerable: false,
configurable: true
});
Object.defineProperty(AcGiViewport.prototype, "height", {
/**
* The height of the viewport entity's window in drawing units.
*/
get: function () {
return this._height;
},
set: function (value) {
this._height = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(AcGiViewport.prototype, "width", {
/**
* The width of the viewport entity's window in drawing units. This is the width in Paper Space
* of the viewport itself, not the width of the Model Space view within the viewport.
*/
get: function () {
return this._width;
},
set: function (value) {
this._width = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(AcGiViewport.prototype, "box", {
/**
* The bounding box (in world coordinate system coordinates) of the viewport.
*/
get: function () {
var box = new AcGeBox2d();
box.setFromCenterAndSize(this.centerPoint, {
x: this.width,
y: this.height
});
return box;
},
enumerable: false,
configurable: true
});
Object.defineProperty(AcGiViewport.prototype, "viewCenter", {
/**
* The view center (in display coordinate system coordinates) of the view in the viewport.
*/
get: function () {
return this._viewCenter;
},
set: function (value) {
this._viewCenter.copy(value);
},
enumerable: false,
configurable: true
});
Object.defineProperty(AcGiViewport.prototype, "viewHeight", {
/**
* The height (in display coordinate system coordinates) of the Model Space view within the viewport.
* Zooming the view out within the viewport increases this value and zooming in decreases this value.
*/
get: function () {
return this._viewHeight;
},
set: function (value) {
this._viewHeight = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(AcGiViewport.prototype, "viewWidth", {
/**
* The width (in display coordinate system coordinates) of the Model Space view within the viewport.
* This is one computed property based on 'viewHeight' and viewport ratio of width and height.
*/
get: function () {
return this.viewHeight * (this.width / this.height);
},
enumerable: false,
configurable: true
});
Object.defineProperty(AcGiViewport.prototype, "viewBox", {
/**
* The bounding box (in display coordinate system coordinates) of the Model Space view within the viewport.
*/
get: function () {
var box = new AcGeBox2d();
box.setFromCenterAndSize(this.viewCenter, {
x: this.viewWidth,
y: this.viewHeight
});
return box;
},
enumerable: false,
configurable: true
});
/**
* Clone this viewport
* @returns Return the cloned instance of this viewport
*/
AcGiViewport.prototype.clone = function () {
var viewport = new AcGiViewport();
viewport.id = this.id;
viewport.groupId = this.groupId;
viewport.number = this.number;
viewport.centerPoint.copy(this.centerPoint);
viewport.height = this.height;
viewport.width = this.width;
viewport.viewCenter.copy(this.viewCenter);
viewport.viewHeight = this.viewHeight;
return viewport;
};
/**
* Copy the property values of the passed viewport to this viewport.
* @param viewport Input one viewport instance
* @returns Return this viewport
*/
AcGiViewport.prototype.copy = function (viewport) {
this.id = viewport.id;
this.groupId = viewport.groupId;
this.number = viewport.number;
this.centerPoint.copy(viewport.centerPoint);
this.height = viewport.height;
this.width = viewport.width;
this.viewCenter.copy(viewport.viewCenter);
this.viewHeight = viewport.viewHeight;
return this;
};
return AcGiViewport;
}());
export { AcGiViewport };
//# sourceMappingURL=AcGiViewport.js.map