-
Notifications
You must be signed in to change notification settings - Fork 635
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
DYN-5018 wires disappear when moving group #12997
DYN-5018 wires disappear when moving group #12997
Conversation
@@ -260,6 +262,15 @@ public bool IsExpanded | |||
AddGroupToGroupCommand.RaiseCanExecuteChanged(); | |||
RaisePropertyChanged(nameof(IsExpanded)); | |||
RedrawConnectors(); | |||
ReportNodesPosition(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node.ReportPosition
is an expensive operation when dealing with a lot of nodes under the same group.
Please check the performance with (there should be a .dyn you can use in this jira taks
Also take a look at what code paths might be calling the IsExpanded setter (to get a better idea what to test) - could be direct function calls or RaisePropertyChanges...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not call UpdateProxyPortsPosition
directly...instead of having to go through the nodeModel's position ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is no performance penalty in doing "node.ReportPosition" then it is fine.
The fix would be to make the Connectors redraw when the corresponding NodeModels(start or end) change their IsProxyPort flag
https://github.com/DynamoDS/Dynamo/blob/master/src/DynamoCoreWpf/ViewModels/Core/ConnectorViewModel.cs#L1209
|
||
// calculate new position for the proxy inports. | ||
model.Center = CalculatePortPosition(model, i); | ||
var originalPort = originalPortViewModels.FirstOrDefault(x => x.PortModel.GUID == group.GUID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm, confused by this, but not super familiar with this code, when would the guid of a group equal the guid of a port model?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the group's port. I will change the variable to groupPort to avoid confusion. Thanks.
@@ -245,9 +245,11 @@ public bool IsExpanded | |||
set | |||
{ | |||
annotationModel.IsExpanded = value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a possible improvement:
If the IsExpanded flag can be changed from other places in Dynamo ....I think would be better to listen to the model.IsExpanded OnPropertyChanged...and only keep the annotationModel.IsExpanded = value;
in the setter.
annotationModel.PropertyChanged += OnModelPropertyChanged;
OnModelPropertyChanged(sender, e) {
if (e.PropertyName == "IsExpanded") {
InPorts.Clear();
OutPorts.Clear();
if (value)
{
this.ShowGroupContents();
}
else
{
this.SetGroupInputPorts();
this.SetGroupOutPorts();
this.CollapseGroupContents(true);
RaisePropertyChanged(nameof(NodeContentCount));
}
WorkspaceViewModel.HasUnsavedChanges = true;
.............the whole setter content............
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let's do that on another PR
@@ -1081,10 +1097,12 @@ private void model_PropertyChanged(object sender, System.ComponentModel.Property | |||
RaisePropertyChanged("Width"); | |||
RaisePropertyChanged(nameof(ModelAreaRect)); | |||
UpdateAllGroupedGroups(); | |||
UpdateProxyPortsPosition(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check performance here...
When moving a group (drag with mouse) ...these properties can get changed a lot of times
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will check an alternative for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check if performance is an issue first...then check alternatives
No use in doing premature optimization
Instead of calling the |
@@ -536,11 +547,15 @@ private bool CanChangeFontSize(object obj) | |||
public AnnotationViewModel(WorkspaceViewModel workspaceViewModel, AnnotationModel model) | |||
{ | |||
annotationModel = model; | |||
var modelBase = (ModelBase)model; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need to cast it to ModelBase ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
this.WorkspaceViewModel = workspaceViewModel; | ||
this.preferenceSettings = WorkspaceViewModel.DynamoViewModel.PreferenceSettings; | ||
model.PropertyChanged += model_PropertyChanged; | ||
model.RemovedFromGroup += OnModelRemovedFromGroup; | ||
model.AddedToGroup += OnModelAddedToGroup; | ||
modelBase.PropertyChanged += ModelBase_PropertyChanged; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there already is a handler for the model PropertyChange event
model.PropertyChanged += model_PropertyChanged;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
switch (e.PropertyName) | ||
{ | ||
case nameof(annotationModel.Position): | ||
UpdateProxyPortsPosition(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to move this to model_PropertyChanged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
@@ -625,7 +649,6 @@ internal void SetGroupInputPorts() | |||
/// </summary> | |||
internal void SetGroupOutPorts() | |||
{ | |||
OutPorts.Clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you remove OutPorts.Clear();
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because now it is called at the beginning of the isExpanded
property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so now SetGroupInputPorts
and SetGroupOutPorts
will always append ports to OutPorts
and InPorts
. I hope nobody uses these functions expecting the port arrays to be re-set
...as the func names suggest. Can you make these functions private and maybe add to the description that they always append to the respective port arrays ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, they were edited.
internal void SetGroupInputPorts() | ||
{ | ||
InPorts.Clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you remove InPorts.Clear();
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
/// Creates input ports for the group based on its Nodes. | ||
/// Input ports that either is connected to a Node outside of the | ||
/// group, or has a port that is not connected will be used for the group. | ||
/// </summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like the formatting got messed up
Purpose
In this PR, the position of the wires is calculated based on the height of the port that is created after the group is collapsed.
Previously, we were assuming that all the ports have the same height, causing a mispositioning of the wires.
Declarations
Check these if you believe they are true
*.resx
filesReviewers
@QilongTang @pinzart @reddyashish