Hello
I am trying to work with composite shapes, but I encountered a problem. Let's say I need to create a circle... and in the center of it is another, smaller, circle with label (but I need it to be centered according to both label and smaller circle, that's why I decided to use composite shapes instead of RTLabelled). I am able to create it just fine, problem is when I call update on its RTElement. I'm not sure whether I am even supposed to do it, but I think I should be. I start with just the inner circle with label: | composite view | composite := (RTLabel new text: 'label'; yourself) + (RTEllipse new size: 10; yourself). composite horizontal. element := composite element. view := RTView new. view add: element; open. element update. Before element update, it looks fine, but when I call update, composite layout (horizontal) gets lost. Let's say I can ignore this problem (which I can't), and I will try the same thing with whole shape | composite view subcomposite | subcomposite := (RTLabel new text: 'label'; yourself) + (RTEllipse new size: 10; yourself). subcomposite horizontal. composite := (RTEllipse new size: 50; color: Color transparent; borderColor: Color black; yourself) + subcomposite. element := composite element. view := RTView new. view add: element; open. element update this time I get exception MessageNotUnderstood: TRCompositeShape>>text:on: I will appreciate any help, either by fixing something if it is broken, or explaining how to reach my goal the correct way. Jan |
Hi Jan,
Help me to understand what’s going on :-) Here is a script: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= compo := RTCompositeShape new. compo add: (RTEllipse new size: [ :tupple | tupple third ]; color: Color lightBlue). compo add: (RTEllipse new size: [ :tupple | tupple second ]; color: Color blue). compo add: (RTLabel new text: [ :tupple | tupple first ]; color: Color red). v := RTView new. data := {{ 'hello' . 30 . 50 } . { 'World' . 20 . 70} }. v addAll: (compo elementsOn: data). RTHorizontalLineLayout new alignCenter; on: v elements. v elements @ RTDraggable. v -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= It produces the following: Why do you want to call #update? Alexandre On Mar 19, 2015, at 6:22 PM, Jan B. <[hidden email]> wrote: -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. _______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
Hi, what I written is just an "how to reproduce" example, and there is of course no need for updating.
But I think there are cases when it is, for example, edges do not update by themselves when connected elements are changed, until we call update on them. In your example code, I might want to change label text (which we do, in our application) when it is already in a view. But it does not update in view until I call update on those composite shapes. So I modify your code like this: _____ compo := RTCompositeShape new. compo add: (RTEllipse new size: [ :tupple | tupple third ]; color: Color lightBlue). compo add: (RTEllipse new size: [ :tupple | tupple second ]; color: Color blue). compo add: (RTLabel new text: [ :tupple | tupple first ]; color: Color red). "ADDED LINE to demonstrate it does not keep this layout: " compo vertical. v := RTView new. data := {{ 'hello' . 30 . 50 } . { 'World' . 20 . 70} }. v addAll: (compo elementsOn: data). RTHorizontalLineLayout new alignCenter; on: v elements. v elements @ RTDraggable. "ADDED LINE where I change labels text:" v elements do: [ :elem | |label| label := elem shape allShapes third. label text: 'LABEL'. ]. "ADDED LINE with updating:" "v elements do: [ :elem | elem update ]." v _____ When the elem update line is commented, labels text is not changed. When I uncomment it, labels change to 'LABEL', but composite shapes layout is lost. These are just few occurences when update is needed (at least I think it is) and I am unable to find any else, but to simplify things, we just update everything in view and it worked fine until I tried to play with composite shapes Jan
|
Hi Jan,
Composite shapes could be a nasty beast. This is a part of Roassal for which I am not even sure of which semantics if should have. So, we may end-up in some corner, as you have explained. However, we are luck here: this is a easy problem to solve. The modification you wish to have, which is changing the label has to be done directly on the trachel shape and _not_ the roassal shape. Consider this slightly modified version of the script: -=-=-=-=-=-=-=-=-=-=-=-= compo := RTCompositeShape new. compo add: (RTEllipse new size: [ :tupple | tupple third ]; color: Color lightBlue). compo add: (RTEllipse new size: [ :tupple | tupple second ]; color: Color blue). compo add: (RTLabel new text: [ :tupple | tupple first ]; color: Color red). "ADDED LINE to demonstrate it does not keep this layout: " compo vertical. v := RTView new. data := {{ 'hello' . 30 . 50 } . { 'World' . 20 . 70} }. v addAll: (compo elementsOn: data). RTHorizontalLineLayout new alignCenter; on: v elements. v elements @ RTDraggable. "ADDED LINE where I change labels text:" v elements do: [ :elem | |label| label := elem trachelShape shapes third. label text: 'LABEL'. ]. v -=-=-=-=-=-=-=-=-=-=-=-= And just to make my email more entertaining, here is the screenshot: Alexandre On Mar 20, 2015, at 6:00 AM, Jan B. <[hidden email]> wrote: -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. _______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
Yes, it fully works even in our app this way. Thank you.
Just to understand it correctly, is this avoiding of using update by getting trachelShape just workaround of a problem with composite shapes, right? Should update on composite shapes work in perfect world, and I could use it without any possible problem, yes? Jan
|
hi!
Actually no. Updating the visualization should be done by manipulating trachel shapes. Roassal shapes are good to create elements. Once an element has been created, modifying its shape should not result in an update of the visualization. Because there are some case where one do not want this. Modifying a visualization should be done by modifying trachel shapes. Or building appropriate Roassal interactions. I agree with you, this is not an easy things to grasp. Cheers, Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. > On Mar 20, 2015, at 7:35 PM, Jan B. <[hidden email]> wrote: > > Yes, it fully works even in our app this way. Thank you. > Just to understand it correctly, is this avoiding of using update by getting > trachelShape just workaround of a problem with composite shapes, right? > Should update on composite shapes work in perfect world, and I could use it > without any possible problem, yes? > > Jan > > > abergel wrote >> Hi Jan, >> >> Composite shapes could be a nasty beast. This is a part of Roassal for >> which I am not even sure of which semantics if should have. So, we may >> end-up in some corner, as you have explained. >> However, we are luck here: this is a easy problem to solve. >> >> The modification you wish to have, which is changing the label has to be >> done directly on the trachel shape and _not_ the roassal shape. >> Consider this slightly modified version of the script: >> >> -=-=-=-=-=-=-=-=-=-=-=-= >> compo := RTCompositeShape new. >> compo add: (RTEllipse new size: [ :tupple | tupple third ]; color: Color >> lightBlue). >> compo add: (RTEllipse new size: [ :tupple | tupple second ]; color: Color >> blue). >> compo add: (RTLabel new text: [ :tupple | tupple first ]; color: Color >> red). >> "ADDED LINE to demonstrate it does not keep this layout: " compo vertical. >> >> v := RTView new. >> >> data := {{ 'hello' . 30 . 50 } . { 'World' . 20 . 70} }. >> v addAll: (compo elementsOn: data). >> >> RTHorizontalLineLayout new alignCenter; on: v elements. >> v elements @ RTDraggable. >> >> "ADDED LINE where I change labels text:" v elements do: [ :elem | |label| >> label := elem trachelShape shapes third. label text: 'LABEL'. ]. >> >> v >> -=-=-=-=-=-=-=-=-=-=-=-= >> >> And just to make my email more entertaining, here is the screenshot: >> >> >> Alexandre > > > > > > -- > View this message in context: http://forum.world.st/Roassal-2-updating-CompositeShape-tp4813359p4813737.html > Sent from the Moose mailing list archive at Nabble.com. > _______________________________________________ > Moose-dev mailing list > [hidden email] > https://www.iam.unibe.ch/mailman/listinfo/moose-dev _______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
I think I understand. Unfortunately, I am going to need help with one more thing. As I said, I need to edit this label pretty often. Let's say I edited this label... or some other inner shape of composite shape... therefore it changed its extent. How to properly update the composite shape layout? Consider following code:
| compo elem v | (compo := RTCompositeShape new) add: (RTLabel new text: 'a string'; color: Color red); add: (RTEllipse new size: 20; color: Color blue); horizontal; setAutomaticRelayout. "just tried what it will do" elem := compo element. (v := RTView new) add: elem; open. elem trachelShape shapes first text: 'quite longer string'. v Layout is set according to size of original string, so the longer string interferes with ellipse. What is the best way (if there is any), to keep same distance between these inner shapes? Jan
|
Hi Jan!
The #setAutomaticRelayout method is made to relayout the composite shape, as you have rightfully guessed. You were using labels, and it was buggy actually. Update Roassal and Trachel and the following example should illustrate what you are trying to obtain. -=-=-=-=-=-=-=-=-=-=-=-= s := RTCompositeShape new. b1 := RTBox new color: Color green. b2 := RTBox new color: Color blue; size: 20. b3 := RTLabel new. s add: b1. s add: b2. s add: b3. s horizontal. s setAutomaticRelayout. e := s elementOn: 'click to expand'. view := RTView new. view add: e. e @ RTDraggable. e @ RTPopup. e when: TRMouseClick do: [ :ev | e trachelShape shapes second extent: 45 @ 45. e trachelShape shapes third text: 'hello'. view signalUpdate. ]. view open -=-=-=-=-=-=-=-=-=-=-=-= Keep doing! Alexandre > On Mar 24, 2015, at 5:30 AM, Jan B. <[hidden email]> wrote: > > (compo := RTCompositeShape new) > add: > (RTLabel new > text: 'a string'; > color: Color red); > add: > (RTEllipse new > size: 20; > color: Color blue); > horizontal; > setAutomaticRelayout. "just tried what it will do" > elem := compo element. > (v := RTView new) > add: elem; > open. > elem trachelShape shapes first text: 'quite longer string'. > v -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. _______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
I hate to bring more and more problems, but, well, here it is...
This is probably more related to our discussion about callbacks, but this one is easily shown in your example code. When you change initial string from 'click to expand' to '' (empty string), it now has extent 0@something and when you click on it, it tries to create extent callback from 0@something size, and divides by zero. It seems like a problem only of composite shapes. Jan
|
Hi Jan,
Sorry for replying so late. The problem you describe is apparently not a complex one. I have proposed a fix in the last version of Trachel. Let us know! Cheers, Alexandre > On Mar 24, 2015, at 9:03 PM, Jan B. <[hidden email]> wrote: > > I hate to bring more and more problems, but, well, here it is... > This is probably more related to our discussion about callbacks, but this > one is easily shown in your example code. When you change initial string > from 'click to expand' to '' (empty string), it now has extent 0@something > and when you click on it, it tries to create extent callback from > 0@something size, and divides by zero. It seems like a problem only of > composite shapes. > > Jan > > > abergel wrote >> Hi Jan! >> >> The #setAutomaticRelayout method is made to relayout the composite shape, >> as you have rightfully guessed. You were using labels, and it was buggy >> actually. Update Roassal and Trachel and the following example should >> illustrate what you are trying to obtain. >> >> -=-=-=-=-=-=-=-=-=-=-=-= >> s := RTCompositeShape new. >> b1 := RTBox new color: Color green. >> b2 := RTBox new color: Color blue; size: 20. >> b3 := RTLabel new. >> s add: b1. >> s add: b2. >> s add: b3. >> s horizontal. >> s setAutomaticRelayout. >> >> e := s elementOn: 'click to expand'. >> view := RTView new. >> view add: e. >> >> e @ RTDraggable. >> e @ RTPopup. >> >> e when: TRMouseClick do: [ :ev | >> e trachelShape shapes second extent: 45 @ 45. >> e trachelShape shapes third text: 'hello'. >> view signalUpdate. >> ]. >> >> view open >> -=-=-=-=-=-=-=-=-=-=-=-= >> >> Keep doing! >> >> Alexandre > > > > > > -- > View this message in context: http://forum.world.st/Roassal-2-updating-CompositeShape-tp4813359p4814954.html > Sent from the Moose mailing list archive at Nabble.com. > _______________________________________________ > Moose-dev mailing list > [hidden email] > https://www.iam.unibe.ch/mailman/listinfo/moose-dev -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. _______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
Free forum by Nabble | Edit this page |