Files
enviPy-bayer/static/js/ketcher2/script/render/restruct/reobject.js
2025-06-23 20:13:54 +02:00

76 lines
2.3 KiB
JavaScript

/****************************************************************************
* Copyright 2017 EPAM Systems
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
var Visel = require('./visel');
var scale = require('../../util/scale');
function ReObject() {
}
ReObject.prototype.init = function (viselType) {
this.visel = new Visel(viselType);
this.highlight = false;
this.highlighting = null;
this.selected = false;
this.selectionPlate = null;
};
// returns the bounding box of a ReObject in the object coordinates
ReObject.prototype.getVBoxObj = function (render) {
var vbox = this.visel.boundingBox;
if (vbox === null)
return null;
if (render.options.offset)
vbox = vbox.translate(render.options.offset.negated());
return vbox.transform(scale.scaled2obj, render.options);
};
ReObject.prototype.setHighlight = function (highLight, render) { // TODO render should be field
if (highLight) {
var noredraw = 'highlighting' in this && this.highlighting != null;// && !this.highlighting.removed;
if (noredraw) {
if (this.highlighting.type == 'set')
noredraw = !this.highlighting[0].removed;
else
noredraw = !this.highlighting.removed;
}
if (noredraw) {
this.highlighting.show();
} else {
render.paper.setStart();
this.drawHighlight(render);
this.highlighting = render.paper.setFinish();
}
} else
if (this.highlighting) {
this.highlighting.hide();
}
this.highlight = highLight;
};
ReObject.prototype.drawHighlight = function () {
console.assert('ReObject.drawHighlight is not overridden'); // eslint-disable-line no-console
};
ReObject.prototype.makeSelectionPlate = function () {
console.assert(null, 'ReObject.makeSelectionPlate is not overridden'); // eslint-disable-line no-console
};
module.exports = ReObject;