Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of new linkage report #764

Merged
merged 21 commits into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
130742a
Initial code to generate phase tree for report
tadkollar May 11, 2022
bcacc65
Added ability to control whether all vars are displayed
tadkollar May 11, 2022
eaf75c7
Added docstrings
tadkollar May 11, 2022
21dfddc
Multiple derived JS classes; changed where fixing is detected; applie…
tadkollar May 18, 2022
cc7ee19
Removed some unusued code
tadkollar May 18, 2022
ca4442a
Phase box grids are working, still fixing transitions
tadkollar May 20, 2022
eeafb88
Fixed transition for returning grid box
tadkollar May 20, 2022
1eac1b5
Matrix background grid partially works
tadkollar May 27, 2022
faafc83
Fixed up background square transitions
tadkollar May 27, 2022
175613f
Mark directly connected linkages with a C; show title at top
tadkollar May 31, 2022
8f6803b
Moved styles to own file, fixed filtering issue
tadkollar Jun 1, 2022
1159714
Replaced C inconnected linkages with double-arrow
tadkollar Jun 3, 2022
65b988e
Created a customized legend
tadkollar Jun 8, 2022
ee9e501
Fixed filter handling
tadkollar Jun 10, 2022
072f01b
Removed need for DmLinkageLayout.js
tadkollar Jun 10, 2022
ff26c11
Changed arrow type, remove arrow from linkage cell
tadkollar Jun 15, 2022
d42386a
Added a test for the Dymos linkage report GUI
tadkollar Jun 15, 2022
df6d374
Merge branch 'OpenMDAO:master' into diag
tadkollar Jul 6, 2022
7874ae4
Merge branch 'OpenMDAO:master' into diag
tadkollar Jul 7, 2022
c0b6c65
Merge branch 'OpenMDAO:master' into diag
tadkollar Jul 12, 2022
17633b3
Merge branch 'OpenMDAO:master' into diag
tadkollar Jul 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
90 changes: 90 additions & 0 deletions dymos/visualization/linkage/js/DmLinkageCellRenderer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// <<hpp_insert gen/CellRenderer.js>>

class DmLinkageConditionCell extends GroupBase {
constructor(color, id) {
super(color, id);
}
}

class DmLinkagePhaseCell extends GroupBase {
constructor(color, id) {
super(color, id);
}
}

class DmLinkageConnectedCell extends VectorBase {
constructor(color, id) {
super(color, id);
}

/**
* Select the element with D3 if not already done, attach a transition
* and resize the shape.
* @param svgGroup Reference to SVG <g> element associated with data.
* @param {Object} dims The cell spec to use while resizing/repositioning.
*/
update(svgGroup, dims) {
const d3Group = d3.select(svgGroup);

d3Group.select('rect').transition(sharedTransition)
.attr("x", dims.topLeft.x * dims.size.percent)
.attr("y", dims.topLeft.y * dims.size.percent)
.attr("width", dims.bottomRight.x * dims.size.percent * 2)
.attr("height", dims.bottomRight.y * dims.size.percent * 2);

d3Group.select('text').transition(sharedTransition)
.attr("x", 0)
.attr("y", 0)
.style('font-size', `${dims.bottomRight.x * dims.size.percent * 2}px`);


return d3Group.selectAll('*');
}

/**
* Get the D3 selection for the appropriate group and append a filled rectangle.
* @param {Object} svgGroup Reference to SVG <g> element associated with data.
* @param {Object} dims The cell spec to use while rendering.
*/
render(svgGroup, dims) {
const d3Group = d3.select(svgGroup);

d3Group
.append('rect')
.attr("class", this.className)
.attr("id", this.id)
.style("fill", this.color);

d3Group
.append('text')
.attr('class', 'connected-variable-text')
.attr('id', `${this.id}-text`)
.html('&#x2794;');

return this.update(svgGroup, dims);
}
}

class DmLinkageVariableCell extends VectorBase {
constructor(color, id) {
super(color, id);
}
}

class DmLinkageCell extends VectorBase {
constructor(color, id) {
super(color, id);
}
}

class DmLinkageGroupCell extends GroupBase {
constructor(color, id) {
super(color, id);
}
}

class DmLinkageRootCell extends GroupBase {
constructor(color, id) {
super(color, id);
}
}
43 changes: 43 additions & 0 deletions dymos/visualization/linkage/js/DmLinkageDiagram.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// <<hpp_insert gen/Diagram.js>>
// <<hpp_insert gen/Layout.js>>
// <<hpp_insert js/DmLinkageStyle.js>>
// <<hpp_insert js/DmLinkageUserInterface.js>>
// <<hpp_insert js/DmLinkageMatrix.js>>

/**
* Manage all components of the application. The model data, the CSS styles, the
* user interface, the layout of the matrix, and the matrix grid itself are
* all member objects. DmLinkageDiagram adds handling for solvers.
* @typedef DmLinkageDiagram
*/
class DmLinkageDiagram extends Diagram {
/**
* Set initial values.
* @param {Object} modelJSON The decompressed model structure.
*/
constructor(modelJSON) {
super(modelJSON);

}

_newModelData() {
this.model = new DmLinkageModelData(this.modelData);
}

/** Create a new DmLinkageMatrix object. Overrides superclass method. */
_newMatrix(lastClickWasLeft, prevCellSize = null) {
return new DmLinkageMatrix(this.model, this.layout, this.dom.diagGroups,
this.arrowMgr, lastClickWasLeft, this.ui.findRootOfChangeFunction, prevCellSize);
}

/**
* Separate these calls from the constructor so that subclasses can
* set values before execution.
*/
_init() {
this.style = new DmLinkageStyle(this.dom.svgStyle, this.dims.size.font);
this.layout = this._newLayout();
this.ui = new DmLinkageUserInterface(this);
this.matrix = this._newMatrix(true);
}
}
93 changes: 93 additions & 0 deletions dymos/visualization/linkage/js/DmLinkageLegend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// <<hpp_insert gen/Legend.js>>

/**
* Draw a symbol describing each of the element types.
* @typedef DmLinkageLegend
* @property {Boolean} shown Whether the legend is currently drawn or not.
*/
class DmLinkageLegend extends Legend {
/**
* Initializes the legend object.
* @param {ModelData} modelData In the base class, symbols only appear if they're in the model
*/
constructor(modelData) {
super(modelData);
}

/** Define all the legend items, colors, and styles. */
_initItemTypes() {

this.nodeTypes = [
{
'name': 'Phase',
'color': DmLinkageStyle.color.phase
},
{
'name': 'Initial Condition/Variable',
'color': DmLinkageStyle.color.initial
},
{
'name': 'Final Condition/Variable',
'color': DmLinkageStyle.color.final
},
{
'name': 'Collapsed',
'color': DmLinkageStyle.color.collapsed
}
]

this.cellTypes = [
{
'name': 'Variable',
'color': DmLinkageStyle.color.variableCell,
'cssClass': 'dm-legend-box'
},
{
'name': 'Fixed Variable',
'color': DmLinkageStyle.color.fixedUnlinkedVariableCell,
'cssClass': 'dm-legend-box'
},
{
'name': 'Fixed, Linked Variable',
'color': DmLinkageStyle.color.fixedLinkedVariableCell,
'cssClass': 'dm-legend-box'
},
{
'name': 'Linkage',
'color': DmLinkageStyle.color.linkageCell,
'cssClass': 'dm-legend-cell'
},
{
'name': 'Fixed Linkage',
'color': DmLinkageStyle.color.fixedLinkageCell,
'cssClass': 'dm-legend-cell'
},
{
'name': 'Connected',
'color': 'none',
'cssClass': 'dm-legend-connected'
}
];
}

_setDisplayBooleans() { }

/** Add symbols for all of the items that were defined */
_setupContents() {
const nodeLegend = d3.select('#tree-nodes-legend');
for (const nodeType of this.nodeTypes) {
this._addItem(nodeType, nodeLegend);
}

nodeLegend.style('width', nodeLegend.node().scrollWidth + 'px')

const cellLegend = d3.select('#matrix-cells-legend');
for (const cellType of this.cellTypes) {
this._addItem(cellType, cellLegend, cellType.cssClass);
}

cellLegend.style('width', cellLegend.node().scrollWidth + 'px')

}

}