1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

Merge branch 'topology-widget-tweaks' into develop

This commit is contained in:
Steffen Vogel 2018-06-14 19:50:25 +02:00
commit 8f92685397
2 changed files with 26 additions and 7 deletions

View file

@ -149,6 +149,10 @@ var cimview = cimview || (function() {
}
};
var fit = function() {
setViewBox(svgNode.getElementById('diagrams').getBBox());
};
var getViewBox = function() {
let rect = {};
viewBoxString = svgNode.getAttribute("viewBox");
@ -184,19 +188,25 @@ var cimview = cimview || (function() {
};
var init = function(svg) {
svgNode = svg;
svgNode = svg;
let rect = { x: "-100", y: "-100", width: "1024", height: "768" };
setViewBox(rect);
};
var setSVG = function(svg) {
svgNode = svg;
}
/*
* Specify the functions that this module exports
*/
return {
init,
pan,
fit,
zoomIn,
zoomOut,
setSVG
};
}());

View file

@ -84,17 +84,21 @@ class WidgetTopology extends React.Component {
super(props);
this.svgElem = null;
this.Viewer = null;
this.state = {
visualizationState: 'initial'
};
}
setSVG(svg) {
this.svgElem = svg;
window.cimsvg.setSVG(svg); // function not available in upstream source
window.cimview.setSVG(svg); // function not available in upstream source
}
componentDidMount() {
if (this.svgElem) {
window.cimjson.setImagePathBase(process.env.PUBLIC_URL + '/Pintura/');
window.cimsvg.setSVG(this.svgElem); // function not available in upstream source
window.cimview.init(this.svgElem);
window.onMouseLeave = function() {};
window.onMouseOver = function() {};
window.onMouseLeave = function() {};
@ -120,8 +124,9 @@ class WidgetTopology extends React.Component {
this.setState({'visualizationState': 'ready' });
window.cimxml.clearXmlData()
window.cimsvg.setFileCount(1);
return response.text().then( contents => {
return response.text().then( contents => {
window.cimsvg.loadFile(contents);
window.cimview.fit();
attachComponentEvents();
});
} else {
@ -156,11 +161,15 @@ class WidgetTopology extends React.Component {
markup = (<div>
<ReactSVGPanZoom
ref={Viewer => this.Viewer = Viewer}
style={{outline: "1px solid black"}}
style={{outline: "1px solid grey"}}
detectAutoPan={false}
miniaturePosition="none"
toolbarPosition="none"
background="white"
tool="pan"
width={this.props.widget.width-2} height={this.props.widget.height-2} >
<svg width={this.props.widget.width} height={this.props.widget.height}>
<svg ref={ c => this.svgElem = c }width={this.props.widget.width} height={this.props.widget.height}>
<svg ref={ c => this.setSVG(c) } width={this.props.widget.width} height={this.props.widget.height}>
<rect id="backing" style={pinturaBackingStyle} />
<g id="grid" style={pinturaGridStyle} />
<g id="diagrams"/>