This is a set of four macros that work together to add new functionality to polyworks. It's not as exciting as that sentence made it sound. (*EDIT* I hate the way this sounds now. Also, it's not exactly true - the functionality is there, just in longer processes. duh)
What it allows me to do is press, for example, '+' and '-' to move back and forth through the images in my align project. I can also press, say, '*' to KEEP the scan at which my + or - key last brought me. Finally, I can press 'k' to set my index to the current selected scan and KEEP that scan.
Enough with the chatter, here's the code:
version "4.0"
declare eList "FIRST"
declare eIndex 1
declare ei 1
declare eTemp
declare eFailed 0
declare eTN
MACRO SHARED_VARIABLE GET_VALUE("eSharedImages", eList)
MACRO SHARED_VARIABLE GET_VALUE("eSharedImageIndex", eIndex)
TREEVIEW IMAGE GET_NB(eTemp)
if $eList == "FIRST"
while $ei <=$eTemp
TREEVIEW IMAGE GET_NAME($ei, eList[$ei])
++ ei
endwhile
set eIndex 1
VIEW VISIBILITY OBJECTS KEEP($eList[$eIndex])
MACRO SHARED_VARIABLE CREATE("eSharedImages", $eList)
MACRO SHARED_VARIABLE CREATE("eSharedImageIndex", $eIndex)
else
#check list against treeview
if size(eList) != $eTemp
set eFailed 1
else
while $ei <= $eTemp
TREEVIEW IMAGE GET_NAME($ei, eTN)
if $eList[$ei] != $eTN
set eFailed 1
endif
++ ei
endwhile
endif
if $eFailed == 1
set ei 1
set eList { "" }
while $ei <=$eTemp
TREEVIEW IMAGE GET_NAME($ei, eList[$ei])
++ ei
endwhile
set eIndex 1
else
++ eIndex
endif
if $eIndex > $eTemp
set eIndex 1
endif
VIEW VISIBILITY OBJECTS KEEP($eList[$eIndex])
MACRO SHARED_VARIABLE SET_VALUE("eSharedImages", $eList)
macro SHARED_VARIABLE SET_VALUE("eSharedImageIndex", $eIndex)
endif
This builds a list of the images in the current project and checks this list against a shared variable's contents. If they don't match, the shared variable gets overwritten. It then saves an index of the current image and, if the lists matched, increments the index by 1 - allowing you to scroll through your images.
This next macro does the same thing, except it scrolls backwards through the images:
version "4.0"
declare eList "FIRST"
declare eIndex 1
declare ei 1
declare eTemp
declare eFailed 0
declare eTN
MACRO SHARED_VARIABLE GET_VALUE("eSharedImages", eList)
MACRO SHARED_VARIABLE GET_VALUE("eSharedImageIndex", eIndex)
TREEVIEW IMAGE GET_NB(eTemp)
if $eList == "FIRST"
while $ei <=$eTemp
TREEVIEW IMAGE GET_NAME($ei, eList[$ei])
++ ei
endwhile
set eIndex 1
VIEW VISIBILITY OBJECTS KEEP($eList[$eIndex])
MACRO SHARED_VARIABLE CREATE("eSharedImages", $eList)
MACRO SHARED_VARIABLE CREATE("eSharedImageIndex", $eIndex)
else
#check list against treeview
if size(eList) != $eTemp
set eFailed 1
else
while $ei <= $eTemp
TREEVIEW IMAGE GET_NAME($ei, eTN)
if $eList[$ei] != $eTN
set eFailed 1
endif
++ ei
endwhile
endif
if $eFailed == 1
set ei 1
set eList { "" }
while $ei <=$eTemp
TREEVIEW IMAGE GET_NAME($ei, eList[$ei])
++ ei
endwhile
set eIndex 1
else
-- eIndex
endif
if $eIndex < 1
set eIndex $eTemp
endif
VIEW VISIBILITY OBJECTS KEEP($eList[$eIndex])
MACRO SHARED_VARIABLE SET_VALUE("eSharedImages", $eList)
macro SHARED_VARIABLE SET_VALUE("eSharedImageIndex", $eIndex)
endif
Both have a check in place so scrolling beyond the first or last image will place you at the opposite end of the list. The next two macros were created a couple weeks later, when I got fed up with scroll up then down again to return to my indexed image.
version "4.0"
declare eIndex
declare eList "FIRST"
MACRO SHARED_VARIABLE GET_VALUE("eSharedImageIndex", eIndex)
MACRO SHARED_VARIABLE GET_VALUE("eSharedImages", eList)
if $eList == "FIRST"
ECHO ("An image list must be initialized to use this macro")
else
VIEW VISIBILITY OBJECTS KEEP($eList[$eIndex])
endif
This one just keeps the image that you last scrolled to. Simple. Granted, it doesn't have the check to see if the treeview had changed, so it isn't perfect. Adding something like this would fix it:
#check list against treeview
if size(eList) != $eTemp
set eFailed 1
else
while $ei <= $eTemp
TREEVIEW IMAGE GET_NAME($ei, eTN)
if $eList[$ei] != $eTN
set eFailed 1
endif
++ ei
endwhile
endif
if $eFailed == 1
macro end
endif
Of course, this isn't complete (you would need to declare and fill many of the variables here), but the idea is there.
This last macro keeps the current selected scan, and sets your index/image list to match it. This is good for defining a starting point.
version "4.0"
declare eList "FIRST"
declare eIndex 1
declare ei 1
declare eTemp
declare eFailed 0
declare eTN
declare eStatus
declare eNBSelected
MACRO SHARED_VARIABLE GET_VALUE("eSharedImages", eList)
MACRO SHARED_VARIABLE GET_VALUE("eSharedImageIndex", eIndex)
TREEVIEW IMAGE GET_NB(eTemp)
TREEVIEW IMAGE GET_NB_SELECTED(eNBSelected)
if $eNBSelected == 1
while $ei <=$eTemp
TREEVIEW IMAGE GET_NAME($ei, eList[$ei])
TREEVIEW IMAGE GET_SELECTION_STATUS($ei, eStatus)
if $eStatus == "On"
set eIndex $ei
set ei $eTemp
endif
++ ei
endwhile
VIEW VISIBILITY OBJECTS KEEP($eList[$eIndex])
MACRO SHARED_VARIABLE CREATE("eSharedImages", $eList)
MACRO SHARED_VARIABLE CREATE("eSharedImageIndex", $eIndex)
MACRO SHARED_VARIABLE SET_VALUE("eSharedImages", $eList)
macro SHARED_VARIABLE SET_VALUE("eSharedImageIndex", $eIndex)
else
VIEW VISIBILITY OBJECTS KEEP
endif
Hmm, looking at this one again, it seems to suffer from the same issue of relying on the list existing already. This was sloppy of me, but so long as you use one of the two scrolling macros first these will all work fine.
On a side note, I added the lines at the bottom so that, should I have multiple images selected, instead of indexing and keeping, it only keeps the selected images. I use this as a lazy shortcut for ctrl+shift+k - just hit 'k'!
*EDIT* for forgetting that some people might be unaware of assigning hotkeys to macros. For now, I'll just say that it's in the customize window (where you go to import macros etc), the keyboard tab, set the category drop box to Macro Scripts. It's pretty straight forward from there. Just remember not to overwrite any existing shortcuts.
Very impressive EFV. While I do not think it is very applicable for me, your code has given me a lot of ideas for future macros and options that I did not know about.
Thanks for post.
Yeah, it's useful for cleaning noise and removing targets on images I get from the Breuckmann stereo scan that I usually use.
I only posted it because it's one of those macros that I put together and find myself using all the time.
I *think* you could adapt it to cycle through subgroups in much the same way.
Yep, it looks like you can use TREEVIEW SUBGROUP GET_NB/SELECT to create boundaries; TREEVIEW IMAGE GET_NB_SELECTED to verify group sizes (detect subgroup changes - though saving a list of image names for each subgroup and comparing them every time would be more accurate); but I don't anticipate a great need for quick swapping between subgroups like that.