Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 8:05 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Opus diagram drawing
PostPosted: April 21st, 2009, 4:21 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi,

I've been working on improving diagram drawing, using Opus, and am stuck thinking of a better way to draw connecting lines between diagram shapes.

The shapes and connecting lines need to be clones of the original items. Clones of shapes are dragged and dropped to wherever needed in the diagram's drop zone. Then straight connecting lines (line clones) would need to be "drawn" between shapes by the user in runtime. After the user creates a diagram as a work in progress, they would need to save it with all cloned shapes and connecting lines and then be able to read/reload these so they can continue to work on the diagram next time.

Since cloned shapes, needing connecting, can be at various distances or angles (for example at 45 degrees or any other angle) from each other, cloned lines could be set up to stretch and rotate.

However, a much better option: if the cloned line could be set up in such a way as to mouse drag either of its ends and give the illusion of "drawing" it. This necessitates a script not only create the drawing illusion, but also to save each cloned line's unique name, length, angle, position so these can be read and reloaded. Way beyond my scripting skill. Have not been able to get my brain around this.

I am hoping that someone can suggest a better or easier way to create this. Possibly, I have missed a more basic design or someone can provide sample save/reload scripts upon which I can build the solution.

Any suggestions welcome.

A sample diagram IMP is attached to illustrate the challenges.

Kind Regards,



So far,


You do not have the required permissions to view the files attached to this post.

_________________
Stephen


Top
 Profile  
 
 Post subject:
PostPosted: April 21st, 2009, 8:48 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Hi Stephen,

You once had an approach where the line would be drawn by User clicking on one object A and then the next B and you generated a line connecting A--B. I take it you've abandoned that?

Let me think-out-loud, and this may be 'not a solution' anyway.
1. drag and place the Shapes A and B
2. User 'sketches' a CRUDE line between the two objects. (see 'breadcrumbs' below)
3. User 'Accepts' his rough line, or chooses to 'Redo' the line.
4. When accepted, let the script create the Clone of the Vector Line. The 2 end-points of the Crude breadcrumb line are easily captured, and those x1,y1 and x2,y2 pairs define the opposite corners of the Cloned line. Clone's center is (x1+x2)/2 for x, and (y1+y2)/2 for y. Clone's size or dimensions can also be derived from these points ( e.g. x2-x1 for a width).

So what that looks like, is I pencil draw a 'bitmap' line. And when finished, the Cloned line (vector) appears as a 'snap to' line. And the Crude bitmap line is erased. (it's not really 'bitmap' but is many vector dots)

The 'breadcrumbs' idea pre-dates the version of Opus with the feature to Draw polygon lines. So you could do that instead, but I think the downside of Opus Draw is that each drawn object has to have its own frame. The breadcrumbs on the other hand are a series of cloned 'dots' -- so you can take the position x,y of the first and last clone dot, and eventually destroy all clones in that series.
Here's the original link and sample: viewtopic.php?t=1314&highlight=breadcrumb

I did further refine my trial pub somewhat, but that work was done on a now dead PC. Let me know if this approach is something you'd want to develop, and I'll dig through some archive volumes.

Stephen wrote:
Quote:
Any suggestions welcome.


Cheers,
Larry

p.s. while you're at it, you could define 'anchor points' for Circle A and Square B -- that is, calculate one end-point of Cloned line RELATIVE to Center of 'A'. Ditto for 'B'. Then if Circle A is later moved, the Cloned line can be recreated with the alternative set of end-points if desired.

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: April 21st, 2009, 9:38 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi Larry,

What an interesting idea! I'll check to see if I can adapt it.

Previously...

In my online searching through JavaScript drawing, I've found a script here and there that can draw a straight line with the illusion of realtime drawing by using some trig maths. I may be able to find these again if I search.

Problem is my weakness in scripting complex scripts to get each drag-and-dropped cloned line's unique name, and store its Object Dimensions for top, bottom, left and right (equals length), and Display Data for its angle in a symbol(for example, comma)-delimited array that can then be read back from to reload every line in their dropped position, length and angle. That's where I get lost.

Right you are about the Opus drawing needing a separate frame for each item: OK for runtime basic drawing, but not useful for saving/reloading.

Again, thanks for your suggestion.

Kind Regards,

_________________
Stephen


Top
 Profile  
 
 Post subject:
PostPosted: April 21st, 2009, 10:11 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Stephen,

I'll dig out the 'breadcrumb' .imp for you.

It was originally set-up to leave a trail behind an animated object following a path. I'll replace that with GetMousePosition().

Quote:
my weakness in scripting complex scripts to get each drag-and-dropped cloned line's unique name

There has been some good forum posts on OOPs and the use of Arrays. (Search OOP). I think a couple Posts illustrates just that --- you do not need to get to the unique name. Just capture the object clone at time of creation in the Loop (or other event).

so... let's say a 'breadcrumb' line consists of 100 'dots'. My idea is an Array captures these during the 'while loop'. Use the 1st and last array Elements for the end-points. Later a simple 'maintenance' routine (loop) runs thru the array and Destroys each clone (breadcrumb dot).

Quote:
and store its Object Dimensions for top, bottom, left and right (equals length), and Display Data for its angle

Also in the OOP discussions, explains the advantage of using an Array ELEMENT to store ONE Object, and each Object will have several '.property' characteristics. All can be stored, saved to DB, and retrieved --- simple since array INDEX aligns these 'together' as sets.

Very Good: viewtopic.php?t=3521

I think I am at the very same stage of perplexation (?) -- though my landscape is different. My mental obstacles include sequence of triggers and events to carry-out the 're-population processes'. A bit daunting.

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: April 21st, 2009, 10:59 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi Larry,

Thanks again for these leads and suggestions.

I think I may be able to find a script to draw the line with the illusion of realtime drawing. Or, the breadcrumb dots. Or another drawing method. So, the issue is not likely to be the line creating.

The main issue is getting my brain around that complex scripting, with maths (for example a formula to derive length from the x's and y's), to store each cloned/drawn line's length (top, bottom, left, right in GetObjectDimensions), angle (from GetDisplayData) in a delimited array, probably a new line for each cloned line (the reason for a unique name for each). So [0] may be name, [1] top, [2] bottom, [3] left, [4] right, [5]angle, (and any more items needed to save and reload each "drawn" line). I can conceptualize it, but writing a model script that actually does this, and can be used to test, is another story. :?

Kind Regards,

_________________
Stephen


Top
 Profile  
 
 Post subject:
PostPosted: April 22nd, 2009, 12:58 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Stephen,

Here is a working example to get you started. Self-explanatory in the Pub page comments and script comments. The script might look a little more complex than it really is, as I used long names to help keep things sensible. I hope.

Readily adaptable.

Calling for some more help here folks: Pub works. Could use a keen eye and your expertise to improve the 'keep alive' part of the script (currently is: WHILE Rt-mouse down), and improve loop timing.

Thx in advance.

Larry


You do not have the required permissions to view the files attached to this post.

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: April 22nd, 2009, 1:12 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Attached ver 5 .imp now 'erases' the dotted-line.

[Edit:] there is a math error -- yet to be fixed. see below/later.


You do not have the required permissions to view the files attached to this post.

_________________
_good things come to those who wait(0)_


Last edited by Lar_123 on April 22nd, 2009, 4:20 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: April 22nd, 2009, 2:00 am 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi Larry,

Thanks for digging this out. It's very interesting and will take some time for me to better understand.

I also want to see if I can practice setting up (1) naming cloned lines, (2) getting the needed characteristics (top, bottom, left, right, angle), saving these in an array (new line in TXT file for each line, delimited by @), then reading these back to reload the lines. That would be a major step forward, since it would allow me to save and relaod line clones, unrelated to how they are "drawn." I think if I can get these save and reload functions working, the drawing part will fall into place.

Any sample save/reload functions and scripts, using arrays, welcome.

Kind Regards,

_________________
Stephen


Top
 Profile  
 
 Post subject:
PostPosted: April 22nd, 2009, 3:06 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Stephen,

Quote:
(2) getting the needed characteristics (top, bottom, left, right, angle)
As I see it, you can use DisplayData type of characteristics (referencing sides), or you can use object position and dimensions (ref. center and sizes). For 'specifying' the cloned vector line, I used (you simply need) its CenterX, CenterY, WidthX, and HeightY. (whatever you want to name them).


from the 'breadcrumb' script, the 'pattern' is this:
Code:
arrayABC[ idx] = someClonedOBJECT ;  //the object itself
arrayABC[ idx].Xwidth =  someValue1 ;
arrayABC[ idx].Yheight = someValue2 ;
arrayABC[ idx].Xcenter = someOtherValue10 ;
arrayABC[ idx].Ycenter = someOtherValue22 ;


For Squares and Circles, or complex Vectors, I can see where you might want sides and angles. Using similar arrayname[idx].property1 etc can also be used here of course.

Quote:
saving these in an array (new line in TXT file for each line, delimited by @),

maybe this:

Code:
var theWriteLine = arrayABC[ idx] +","+ arrayABC[ idx].Xwidth +","+ arrayABC[ idx].Yheight +","+ arrayABC[ idx].Xcenter +","+ arrayABC[ idx].Ycenter +"@" ;

But instead of the '@' separator, why not "+\n" for generating a new line? The Elements of the array would be 'comma-delimited' but you could use alternative character of course. (BTW, I'm being more explicit than needed in case some new readers ever mull this over)



Quote:
(1) naming cloned lines

Mack's post: viewtopic.php?t=2753&highlight=clone+array

From the recent posts I mentioned, I thought I read/understood that catching the 'name' of the clone was not important. Just keep each clonedObject in its Array by index (not same as you just outlined with each index pointing to a separate property of the clone). You can see this at-work in the breadcrumbs. But better as it is EXPLAINED in post 3521.

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: April 22nd, 2009, 4:25 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
I just discovered a math or logic error in the scripts.

The drawing works fine in the general area between the two vectors on the demo page. But if you draw a breadcrumb line from somewhere upper Left to lower Right, the cloned line is placed at some angle to the breadcrumb line.

I'll have to work out the x, y --- and the 'sign' of some values.

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: April 22nd, 2009, 4:41 am 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Thanks, Larry.

I'll look at this in depth, see if I can figure it out, apply it to what I am trying to develop.

(Having some difficulty with my machine, so will have to care for it first.)

Again, thanks.

Kind Regards,

_________________
Stephen


Top
 Profile  
 
 Post subject:
PostPosted: April 22nd, 2009, 6:19 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Regarding the math/logic error, I have a fix for that. I just want to take a break and will come back to it to clean-up and tweak the script. Stay tuned.

Stephen, play HW geek.
That last pub is still 'okay' to test and get into.
When I revise it, it will have some extra IF statements to handle things.

Cheers,
Larry

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: April 22nd, 2009, 9:17 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Okay. Updated sample Pub is 'fixed'. Can now draw lines in any direction.

I split the Pub into two pages. The first Page is the main focus. (the 2nd page is not very interesting -- unless you want to see only the breadcrumb line drawing, without clone of Vectored Line.)

I chose a certain way to solve and handle the line direction problem. I set-up two different Lines first, and later have logic to choose which one to Clone for the straight connecting line. An alternative (or perhaps primary) method would have been to rotate the Vector Line or the Clone?

Remaining to do: It would be nice to get some other hands on the script to improve triggers and timing so it is a bit more Robust.

Cheers.

Attach = fixed sample .imp

[Edit:] here's is a correction for a very minor error. (currently gets the next-to-last dot). Replace script Lines 80, 81 with code:
Code:
setXz = DottedLine_ar[DottedLEN-1].x0 ;
setYz = DottedLine_ar[DottedLEN-1].y0;


You do not have the required permissions to view the files attached to this post.

_________________
_good things come to those who wait(0)_


Last edited by Lar_123 on April 22nd, 2009, 9:34 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: April 22nd, 2009, 12:06 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Thanks, Larry.

I'll take a look.

Kind Regards,

_________________
Stephen


Top
 Profile  
 
 Post subject:
PostPosted: May 6th, 2009, 8:42 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Stephen,

Quote:
give the illusion of "drawing" it. This necessitates a script not only create the drawing illusion, but also to save each cloned line's unique name, length, angle, position so these can be read and reloaded.


I am just beginning to get a bit comfortable with clones. But nowhere near the scale of the project you've embarked on. I wanted to mention for you and others tackling clones (and early in one's learning curve) that the script file I posted recently does a nice job of 'snapshotting' what is going-on on an Opus page (well, what objects there are existing)... and that includes Clones. Sample output attached as image.

I gained a bit of insight and it removed some of the mystery of clones for me. (in the Breadcrumb example... it successfully showed ~80 clones before the destroy action, and when called again it showed the 2 remaining end-point clones.). Can of course add other info to the output.
viewtopic.php?p=16031#16031

Cheers,
Larry


You do not have the required permissions to view the files attached to this post.

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 35 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group