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

1245 dsm invert x and y axes #1246

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,18 @@ A MooseIDE browser showing a DSM (Dependency Structural Matrix).
- Propagate: <TODO>

Legend:
- A blue cell indicates that the row entity directly depends on the column entity.
- A blue cell indicates that the column entity directly depends on the row entity.
- A pink cell indicates the same + there is a dependency cycle.
- When putting the mouse on a pink cell, it paints in red all the dependencies involved in this particular cycle (there may be more than one dependency cycle, so some other cells may remain pink).

Entities ordered on:
- number of in-dependencies (column blue cells) + out-dependencies (row blue cells).
- if equal, number of out-dependencies (row blue cells).
- number of dependents (row blue cells) + depending-on (column blue cells).
- if equal, number of depending-on (column blue cells).
- if also equal, then alphabetical order of name.

Controls:
- Mouse over to highlight common inner boxes
- Mouse click to keep the highlight
- right click over a box, to use the menu
- right click over the view to use the general menu
- command+click to use the last tag.

- Mouse left to drag
- Arrow keys to move the visualization around
- Scrolls bars to change the view's position
- M to collapse or expand the window
- I to zoom in
- O to zoom out
- Moouse Wheel to zoom in/out
- S to search entities by their name (several search can be applied)
- R to clear all searches
- Mouse over a cell to highlight column and row (and its cycle)
- Double click on a cell to open a detailed DSM
"
Class {
#name : #MiDependencyStructuralMatrixBrowser,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ MiDependencyStructuralMatrixBrowserModel >> buildGraphEdges [
{ #category : #buildGraph }
MiDependencyStructuralMatrixBrowserModel >> buildGraphNodes: aCollection [

graph nodes: (aCollection "asMooseGroup" select: [ :e |
graph nodes: (aCollection select: [ :e |
e usesFamixTrait: TEntityMetaLevelDependency ]).
"nodeDictionary := Dictionary new: aCollection size.
graph nodes do: [ :node | nodeDictionary at: node model put: node ]"

]

{ #category : #testing }
Expand Down Expand Up @@ -113,6 +112,7 @@ MiDependencyStructuralMatrixBrowserModel >> entities [
{ #category : #testing }
MiDependencyStructuralMatrixBrowserModel >> entity: aCandidate belongsTo: anEntity [
"test whether aDependentEntity can be scoped up to anEntity"

^(aCandidate atScope: anEntity class) includes: anEntity
]

Expand Down Expand Up @@ -158,8 +158,8 @@ MiDependencyStructuralMatrixBrowserModel >> getDependenciesFrom: entityX to: ent

{ #category : #api }
MiDependencyStructuralMatrixBrowserModel >> getTupleDependencyWeight: tuple [
"generic algorithm is to take all dependencies of the `tuple key` (row of the DSM) and count
those that can be scoped up to the `tuple value` (column of the DSM)"
"generic algorithm is to take all dependencies of the `tuple key` (column of the DSM) and count
those that can be scoped up to the `tuple value` (row of the DSM)"

^(dependencyDictionary at: (tuple key model -> tuple value model ))
size
Expand Down Expand Up @@ -250,49 +250,16 @@ MiDependencyStructuralMatrixBrowserModel >> newGraph [

{ #category : #actions }
MiDependencyStructuralMatrixBrowserModel >> openDetailedDSMOn: aTuple [
"note: RSDSM calls X the columns (#value of aTuple) and Y the rows (#key of aTuple)"

^(MiDependencyStructuralMatrixBrowser
openWithX: aTuple value model children
withY: aTuple key model children)
openWithX: aTuple key model children
withY: aTuple value model children)

withWindowDo: [ :window |
window title: ('DSM ' , aTuple key model name , ' -> ' , aTuple value model name) ] ;
yourself
]

{ #category : #initialization }
MiDependencyStructuralMatrixBrowserModel >> orderNodes [
"Store ordered nodes in #orderedNodes.
Order is:
- number of combined in and out dependencies
- if equal, number of out dependencies
- if also equal, then name"

orderedNodesX:= graph nodes.
orderedNodesY := graph nodes.

"| incomingEdges |
incomingEdges := Dictionary new: graph nodes size.
graph nodes do: [ :node | incomingEdges at: node put: Set new ].
graph nodes do: [ :node |
node adjacentNodes do: [ :adjacent |
(incomingEdges at: adjacent) add: node
].
]."
"orderedNodes := graph nodes sorted: [ :nodeA :nodeB || outA inA outB inB|
outA := nodeA adjacentNodes size.
inA := (incomingEdges at: nodeA) size.
outB := nodeB adjacentNodes size.
inB := (incomingEdges at: nodeB) size.

(inA + outA) < (inB + outB)
or: [ (inA + outA) = (inB + outB)
ifTrue: [ outA < outB
or: [ outA = outB and: [nodeA model name < nodeB model name] ] ]
ifFalse: [ false ] ] ]."
]

{ #category : #initialization }
MiDependencyStructuralMatrixBrowserModel >> orderNodes: nodeCollection [

Expand Down Expand Up @@ -352,16 +319,16 @@ MiDependencyStructuralMatrixBrowserModel >> sccColor [
{ #category : #api }
MiDependencyStructuralMatrixBrowserModel >> sccTuplesForTuple: tuple [
"gets the SCC owning tuple, then collects all tuples in this SCC
where row entity depends on column entity"
where depending entity depends on depended entity (!)"
| scc graphNode |
graphNode := tuple key.
scc := { graphNode } , graphNode cycleNodes.
^(scc size = 1)
ifTrue: [ #() ]
ifFalse: [
scc flatCollect: [ :rowNode |
rowNode adjacentNodes
collect: [ :columnNode | rowNode -> columnNode ]
scc flatCollect: [ :dependingNode |
dependingNode adjacentNodes
collect: [ :dependedNode | dependingNode -> dependedNode ]
thenSelect: [ :sccTuple | self isCycle: sccTuple ]
]
]
Expand All @@ -375,11 +342,6 @@ MiDependencyStructuralMatrixBrowserModel >> selectedEntities: anObject [
browser updateToolbar
]

{ #category : #settings }
MiDependencyStructuralMatrixBrowserModel >> settings [

]

{ #category : #settings }
MiDependencyStructuralMatrixBrowserModel >> showSCCColor [

Expand All @@ -399,18 +361,19 @@ MiDependencyStructuralMatrixBrowserModel >> showSCCColorForTuple: tuple [

{ #category : #actions }
MiDependencyStructuralMatrixBrowserModel >> userActionOn: aTuple [
| keyModel valModel weight|
keyModel := aTuple key model.
valModel := aTuple value model.
| depending depended weight|
depending := aTuple key model.
depended := aTuple value model.
weight := self getTupleDependencyWeight: aTuple.

self selectedEntities: { keyModel . valModel }.
self selectedEntities: { depending . depended }.

"We open a detailed DSM for a typle only if the tuple key and value are still at the class or package level and the weight is not zero. "
((keyModel usesFamixTrait: FamixTAttribute )
or: [ (keyModel usesFamixTrait: FamixTMethod )
or: [ (valModel usesFamixTrait: FamixTAttribute)
or: [ (valModel usesFamixTrait: FamixTMethod) or: [ weight = 0 ] ] ] ])
self flag: 'might want to review this which is OO dependent'.
((depending usesFamixTrait: FamixTAttribute )
or: [ (depending usesFamixTrait: FamixTMethod )
or: [ (depended usesFamixTrait: FamixTAttribute)
or: [ (depended usesFamixTrait: FamixTMethod) or: [ weight = 0 ] ] ] ])
ifFalse: [self openDetailedDSMOn: aTuple]
ifTrue: [ ]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ MiDependencyStructuralMatrixVisualization >> buildInCanvas: aRSCanvas [
aRSCanvas addInteraction: RSCanvasController new.
dsm := MiRSDependencyStructuralMatrix new.
dsm owner: self.
dsm setShouldFeedY.
dsm labelShapeX textBlock: [ :columnNode | specModel displayValueForNode: columnNode].
dsm labelShapeY textBlock: [ :rowNode | specModel displayValueForNode: rowNode ].
dsm setShouldFeedX.
dsm labelShapeX textBlock: [ :dependingNode | specModel displayValueForNode: dependingNode].
dsm labelShapeY textBlock: [ :dependedNode | specModel displayValueForNode: dependedNode ].
dsm container: aRSCanvas.
dsm objectsX: specModel orderedNodesX.
dsm objectsY: specModel orderedNodesY.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ MiRSDependencyStructuralMatrix >> createLabelShapeY: aRSBox [

{ #category : #hooks }
MiRSDependencyStructuralMatrix >> createShape: tuple [
"1halt."

| weight |
weight := self getTupleDependencyWeight: tuple.

Expand All @@ -51,7 +51,8 @@ MiRSDependencyStructuralMatrix >> getTupleDependencyWeight: tuple [
{ #category : #highlighting }
MiRSDependencyStructuralMatrix >> highlight: evt [
"Probable bug in RSDSM: `super highlight: evt` draws the row and column with bold border
But the borders are shape that should not receive announcement (like mouseEnter/Leave for highlight/unhighlight"
But the borders are shapes that should not receive announcement (like mouseEnter/Leave for highlight/unhighlight"

super highlight: evt.
(self canvas canvas propertyAt: #columnRect) announcer: nil.
(self canvas canvas propertyAt: #rowRect) announcer: nil.
Expand Down