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

Roassal rubber-banding #849

Closed
seandenigris opened this issue Aug 3, 2015 · 7 comments
Closed

Roassal rubber-banding #849

seandenigris opened this issue Aug 3, 2015 · 7 comments

Comments

@seandenigris
Copy link
Contributor

Originally reported on Google Code with ID 849

As a new feature for Roassal, I would like to be able to interactively drag what I term
a rubberband (you may have a better one?) from one element to another to create and
edge between them.

I had previously implemented this on original Mondrian but I think only in my image.
I don't think it made it to the Mondrian trunk.

As a starting point of discussion I have attached an extracted changeset from my image
- mostly so that it can be browsed for inspiration in a plain text editor.

One key part of the Mondrian implementation was using MOCanvas>>drawOn: to draw the
rubberband every cycle as well as being outside of the main graph.  However there is
no corresponding #drawOn: on any of the RO-canvases.

The changeset shows the use by the application of two entry points #dropRubberBandFrom
and #dropRubberBandOn:.  Rubber bands can be dragged from EpcimTerminal elements to
EpcimConnectivityNode elements.  Method #addSubViewTo: was my own application-way of
splitting up graph creation to the elements of the graph.  I've done this a bit different
for updating my application from Mondrian to Roassal and the reference implementation
for this should preferably use "GLMRossalInteractive"

I have manually re-ordered the changeset so that the order that methods are used go
generally from top to bottom. However the best starting point would be to scroll down
to look at MOCanvas>>drawOn: and MOCanvas>>rubberBand:, then back up to look at the
EpCim* classes,
the the two MOAnnouncer methods.

Reported by benjamin.t.coman on 2012-10-07 23:08:21

@seandenigris
Copy link
Contributor Author

oh, the changeset attached.

Reported by benjamin.t.coman on 2012-10-07 23:09:58


- _Attachment: [Mondrian Rubberband.4.cs](https://storage.googleapis.com/google-code-attachments/moose-technology/issue-849/comment-1/Mondrian Rubberband.4.cs)_

@seandenigris
Copy link
Contributor Author

I spent a few minutes on this:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"Preambule. It includes the initialization. "
| rawView view el1 el2 line tmpElement |
rawView := ROView new.
view := ROMondrianViewBuilder view: rawView.
"enter your script below"
"-------------"
"-------------"

el1 := ROElement new + ROBorder red.
el2 := ROElement new + ROBorder red.
el1 extent: 50 @ 50.
el2 extent: 50 @ 50.

rawView add: el1.
rawView add: el2. 

el2 translateTo: 250 @ 80.

el1 on: ROMouseDragging do: [ :event |
    line ifNil: [ 
        tmpElement := ROElement new.
        line := ROEdge lineFrom: event element to: tmpElement.
        rawView add: line. 
        rawView add: tmpElement. ].

    tmpElement translateTo: (event position - ( 0 @ 30)).
    rawView signalUpdate
].

"-------------"
"-------------"
"Below is the initiation of the menu and opening the visualization"
ROEaselMorphic new populateMenuOn: view.
view open
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

I think a number of points have to be considered:
  - You need to have a mode when you want to drag the edge. Maybe a button that set
the "draw line" modes, and another to drag and drop the element. Or maybe using the
right click for this. 
  - You need to look for the nodes in which the invisible element is dragged into.
If there is an element, then you remove the invisible element, and make the edge
  - I have the impression we need a finer way to tell what is going on when drag and
dropping. It is important to have a precise idea about what we need. This is tricky
but important.

Reported by alexandre.bergel on 2012-10-08 01:44:24

  • Labels added: Component-Roassal

@seandenigris
Copy link
Contributor Author

The following scripts seems to do the thing

"Preambule. It includes the initialization. "
| rawView view el1 el2 line tmpElement |
rawView := ROView new.
view := ROMondrianViewBuilder view: rawView.
"enter your script below"
"-------------"
"-------------"

el1 := ROElement new + ROBorder red.
el2 := ROElement new + ROBorder red.
el1 extent: 50 @ 50.
el2 extent: 50 @ 50.

rawView add: el1.
rawView add: el2. 

el2 translateTo: 250 @ 80.

el1 on: ROMouseDragging do: [ :event |
    | relativePosition |
    line ifNil: [ 
        tmpElement := ROElement new.
        line := ROEdge lineFrom: event element to: tmpElement.
        rawView add: line. 
        rawView add: tmpElement. ].

    relativePosition := rawView camera realToVirtualPoint: (event position).
    tmpElement translateTo: (relativePosition   ).
    rawView signalUpdate
].

el1 on: ROMouseDragged do: [ :event | 
    | element |
    tmpElement remove.
    line remove.
    line := nil.
    tmpElement := nil.

    element := (rawView elementAtRealPosition: event position) .
    (element isKindOf: ROElement)
        ifTrue: [ rawView add: (ROEdge lineFrom: event element to: element )].

    rawView signalUpdate.
].

"-------------"
"-------------"
"Below is the initiation of the menu and opening the visualization"
ROEaselMorphic new populateMenuOn: view.
view open

Reported by alexandre.bergel on 2012-10-08 02:18:08

@seandenigris
Copy link
Contributor Author

Alexandre,  I have implemented your example as an interaction RORubberBanding, as well
as an example ROExample>>rubberBanding.  I hope I've achieved a good balance of conciseness
and flexibility in the application code. In particular, I have left opportunity for
the application code to apply a shape to the new edge.  However there is a problem
with this in ROExample>>rubberBandingOn: that I could not work out...
---
rawNewEdge + (ROLine "new attachPoint: ROVerticalAttachPoint " ).   "Bit commented
out is locking image"
---
I have attached a mcz of this. 

Reported by benjamin.t.coman on 2012-10-08 07:25:27


- _Attachment: [Roassal-BenComan.341.mcz](https://storage.googleapis.com/google-code-attachments/moose-technology/issue-849/comment-4/Roassal-BenComan.341.mcz)_

@seandenigris
Copy link
Contributor Author

In your .mcz, the class ROAbstractCanvas has been augmented with two variables: rubberBandStart
rubberBandEnd
Is there a reason for this? I've removed it and included it in Roassal 1.161

Reported by alexandre.bergel on 2012-10-08 12:00:47

  • Status changed: Fixed

@seandenigris
Copy link
Contributor Author

> In your .mcz, the class ROAbstractCanvas has been augmented with two variables: rubberBandStart
rubberBandEnd
> Is there a reason for this? I've removed it and included it in Roassal 1.161

They were a leftover from my attempt to move my original-Mondrian implementation to
Roassal, that I failed to remove.  The solution you came up with is much better, that
made those instance variables redundant.  

Reported by benjamin.t.coman on 2012-10-08 13:05:50

@seandenigris
Copy link
Contributor Author

Reported by tudor@tudorgirba.com on 2013-03-03 13:04:39

  • Labels added: Milestone-4.7

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

No branches or pull requests

1 participant