2 weeks ago
I am creating an algorithm for graphically adding/subtracting elements of an array (dim_xy[ ][ ]) using hotspots (from the hot_mnu[ ] array).
It seems to me that adding new elements to the dim_xy[ ][ ] array works OK:
😊
But removing elements from the dim_xy[ ][ ] array unfortunately does not work properly because the last removed element of the array is restored:
😕😕😕
I noticed that for removing an element from the dim_xy[ ][ ] array to work, I have to click a hotspot not related to the hotspots hot_mnu[ ] before removing, i.e. remove in two stages:
😎😕
Where is the error? Can someone help?
I am attaching HotspotMenuGsm.zip (Ac27)
Solved! Go to Solution.
a week ago - last edited a week ago
planned goal achieved ! 😃
1 - identification of a dragged hotspot
2 - sample menu of VALUES{2} options connected to the hotspots
(and I also switched the hotmenu tables REAL>INTEGER and changed the names of variables according to my own concept; while dragging hotspots you just have to be careful to "hit" the INTEGER values 1,2,3,-1,-5 etc, because this algorithm is more focused on using the hotmenu than regular dragging)
Thank you very much AllanP and Pertti Paasky for your interest in the subject and substantive help 😃
😃😃😃😃😃😃
────────────────────────
Edit:
for the sake of order and to finish the topic I am attaching the source object developed by Pertti in which it is easy to add new hotspots (drag to the right) and remove hotspots (drag to the left); this object operates with add_remove[] and _add_remove[] arrays and REAL values.
────────────────────────
Edit 2:
In order not to forget the whole idea of the hotspot menu (because I have to leave this fun for later and focus on architecture), I prepared a template for practical use of the hotspot menu, so that it works like LEGO blocks.
This is an example of a library object with two groups of figures - circles and rectangles.
Both groups use their own data tables without any restrictions on the number of figures in the group.
Both groups can use a common universal subroutine (GOSUB "HotSpotMenu") to share the hotspot menu.
The CIRCLES group allows you to perform basic operations using the hotspot menu: moving/adding/removing circles.
The RECTANGLES group is more advanced, it also allows you to copy/paste using the hotspot menu: sizes/pen/rotation.
Of course, there can be more similar groups of "2D/3D figures" with specific properties that can be quickly controlled via the Hotspot menu (without opening the object settings window and wondering which figure I want to grab e.g. dimensions from and paste to another figure). Each group works with several parameters/variables, e.g.:
dim_rect_geom[][] — geometry (position, size of rectangle)
hot_rect_mnu[] — hotspot menu (VALUES{2}...)
hot_rect_mnu2[] — hotspot twin menu (VALUES{2}...)
hot_rect_mnu_id — INT returned number of the clicked hotspot
hot_rect_mnu_val — INT returned code (from VALUE{2}...) of the clicked hotspot
hot_rect_mnu_switch — menu switch 0/1 ..._mnu/..._mnu2
And rectangle properties:
hot_rect_rot[] — orientation angles of individual rectangles
hot_rect_pen[] — pens of individual rectangles
hot_rect_...[] — other rectangle properties
etc.
Of course, this is an object prototype and I understand that I ultimately need a GUI. But in this example I wanted to move some of the editing to where the "figures" are most visible (and accessible) - directly in the project. This is important, especially when there are more than a few "figures" in the library object.
By the way, I fixed some minor bugs in the previous objects (HotspotMenu_Pertti.gsm, HotspotMenu.gsm).
2 weeks ago
You can not remove the edited parameter.
Rather add one array element more than needeed and do not use it.
2 weeks ago - last edited 2 weeks ago
@Pertti Paasky, any example ?
2 weeks ago - last edited 2 weeks ago
Pertti's is suggesting that you increase your array size globally by 1 so that your array parameter is not deleting itself. I have not read the script, but is it that when n = -1 then dim_xy [ n-1 ] [ n-1 ], and when n = 1 then dim_xy [ n+1 ] [ n+1 ]? Given the suggestion, this would then become dim_xy [ n ] [ n ] and dim_xy [ n+2 ] [ n+2 ]
AC22-23 AUS 7000 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win10 | R5 2600 | 16GB | GTX1660 |
2 weeks ago - last edited a week ago by Barry Kelly
I think it's not about dim_xy[][], but hot_mnu[].
In the center of the circles are hostspots dim_xy[][] - it's a simple matter.
And on the circle are hotspots hot_mnu[]. This is of course a simple example of handling two arrays: dim_xy[][] with +/-REAL values and hot_mnu[] with +/-INTEGER values with a limited range of <-1/0/1>.
In the "add new/remove" processes, hotspots related to hot_mnu[] are used. And first changes are made to hot_mnu[], and only then dim_xy[][].
The main problem, it seems to me, is to identify which hotspot hot_mnu[] is used. For this purpose, I use a for...next loop checking in which row the hot_mnu[] value has changed, i.e. <>0. After finding such a row I can perform operations on the main dim_xy[][] array (delete the row or add a new one).
The problem is the order of scripts and various other operations and saving in the hot_idx (the number of the clicked hotspot from hot_mnu[]) and hot_idprocess (=-1/0/1) parameters, and after using them, zeroing these variables.
That's why I included the hot_reset parameter, which appears in 2D instead of hot_mnu[] and helps to reset hot_idx=0, hot_idprocess=0 ("Click to RESET and try again"), before reusing the hotspots hot_mnu[]. I know it's a "prosthesis" but I have no idea (and experience) how to get around the problem and whether it's even possible.
I tried to create hot_mnu[] one element larger than dim_xy[][] but I do not really understand the idea etc.
2 weeks ago
2 weeks ago
@Pertti Paasky,brilliant and simple! Thank you very much!
I also tried comparing the current and previous values to recognize the edited hotspot, e.g.
dx=add_remove[i]-_add_remove[i] !difference
but that was within one two-column array dim[current val][previous val]. Unfortunately, errors in another place discouraged me from further attempts.
OK, I'm now trying to convert your solution from REAL arrays to INT, so that it works like a menu, e.g.
VALUES{2} "add_remove" \
0,">>",
3,"any action...",
2,"any action...",
1,"add new",
-1,"remove",
-2,"remove all" etc...
I'm getting something but not yet satisfactory.
I would like to use such a quick handy hotmenu to e.g. copy/paste materials between different surfaces, e.g. my own add-on to Wall Accessory or create new cutouts/overlays etc.
2 weeks ago
Go ahead, gaba. I think it is ok to change to integers. In addition, my algorithm allows to multiply the same hotspot many times.
2 weeks ago - last edited a week ago by Barry Kelly
@Pertti Paasky wrote:
Go ahead, gaba. I think it is ok to change to integers. In addition, my algorithm allows to multiply the same hotspot many times.
Pertti, your algorithm is great for cloning hotspots!
But I think it has one special feature: it doesn't allow to clone the same (!) hotspot to the same (!) place (i.e. at the same distance) multiple times:
I added to your script zeroing the values in add_remove and _add_remove (after finishing adding a new one etc.) and shortening these arrays according to the number of dim_xy[][] elements, but it doesn't help.
In my opinion the problem lies somewhere in remembering the previous value of the hotspot and then comparing it with the new value (from dragging the hotspot).
That's why for now I don't know if I will implement this algorithm as a hotspot shortcut menu, where constant values and repeating integers 1,2,3... are used.
Because some hotspots will remember once selected INTEGER value (e.g. 1), and then unnecessarily remember it in both add_remove and _add_remove arrays. And then you need to somehow force reset/clear both arrays. Unless someone has an idea for that.
2 weeks ago - last edited a week ago by Barry Kelly
OK, I've come full circle and returned to my original algorithm, despite having to "double click" occasionally to reset the "hotspot memory".
For now, I find it easier to control and extend the VALUES{2} options as INTEGER.