Skip to content

Fixed code block output port alignment issue#5119

Closed
benglin wants to merge 10 commits intoDynamoDS:masterfrom
benglin:MAGN-7391
Closed

Fixed code block output port alignment issue#5119
benglin wants to merge 10 commits intoDynamoDS:masterfrom
benglin:MAGN-7391

Conversation

@benglin
Copy link
Contributor

@benglin benglin commented Aug 15, 2015

Purpose

This pull request is meant to fix a problem where output ports of a code block node do not completely lined up with their corresponding statements. The defect is being tracked internally as:

  • MAGN-7391 Code block output ports do not align with their corresponding statements

This problem is introduced by slight offset accumulated along the way as output ports are placed in their container ItemsControl. This accumulative error is unavoidable as one double value counts on another previous double value.

To address this problem, instead of having the default StackPanel (inside an ItemsControl) arranging each output port, we now make use of a new Panel derived class: InOutPortPanel. This panel is aware of each PortViewModel (and indirectly, PortModel and PortData) object it contains so it is capable of arranging the ports accurately.

In order not to lose any precision, the vertical offset values are no longer computed in an accumulative way:

double offset = 0.0;
foreach (var port in ports)
{
    // Adding double values accumulates error.
    offset = offset + port.Height;
}

Instead, a new property PortModel.LineIndex (replacing PortModel.VerticalMargin property) is introduced for lossless offset computation. The value of PortModel.LineIndex is assigned when CodeBlockNodeModel generates its output ports (i.e. when it has the knowledge of statement indices too). Error on a port does not get carried over for calculating offset of the next port:

foreach (var port in ports)
{
    double offset = port.LineIndex * port.Height;
}

This is how it looks after the fix:

port-alignment

### Declarations

Check these if you believe they are true

  • The code base is in a better state after this PR
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files

Reviewers

Hi @aparajit-pratap, since you were previously dealing with this, please take a look. Thanks!

FYIs

@riteshchandawar, it's done!

@benglin benglin added the PTAL Please Take A Look 👀 label Aug 15, 2015
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was simply updated to honor PortModel.LineIndex if it is specified, or PortModel.Index otherwise. No more differentiation between in/out ports.

@aparajit-pratap
Copy link
Contributor

@benglin don't have any other comments other than the questions above. The Panel subclass used for ItemsPanelTemplate is applied to an individual element of the ItemsControl. Is that what you did if I describe this XAML code in English? LGTM in that case.

@benglin
Copy link
Contributor Author

benglin commented Aug 17, 2015

Hi @aparajit-pratap, the right description would look something like this in English:

<ItemsControl>
    <InOutPortPanel>
        <Item 00>
        <Item 01>
        ....
        <Item N - 1>

It is a panel that hosts all the list items, which is why it can dictate the accurate item positions. Thanks again for helping with the review!

@benglin benglin added LGTM and removed PTAL Please Take A Look 👀 labels Aug 17, 2015
@benglin
Copy link
Contributor Author

benglin commented Aug 17, 2015

Closing this as it is replaced by #5123.

@benglin benglin closed this Aug 17, 2015
@riteshchandawar
Copy link
Contributor

@benglin Is this merged for RC branch?

  • Ritesh

@monikaprabhu
Copy link
Contributor

@benglin - Ive tested this on 0.8.3 - please cross merge this on 0.8.2 RC branch.

@marcellosgamb
Copy link

@riteshchandawar
Copy link
Contributor

Thanks @marcellosgamb, I am able to reproduce the issue on latest build with fix.
Just curious, why are you using point data from CBN, excel will work better right?

Thanks,
Ritesh

@monikaprabhu
Copy link
Contributor

Seems to be fixed at my end on latest 0.8.3 (both initial bug and the one reported by marcello) - @marcellosgamb - please retest when the build is posted. Tx

@benglin
Copy link
Contributor Author

benglin commented Aug 19, 2015

marcello

Originally I thought it was a DPI related issue, but this works just fine on a Mac Bootcamp. @marcellosgamb, if you can try out on the latest build that'll be very helpful. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants