home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-10 | 35.2 KB | 1,310 lines |
- /*************************************************************\
- / \
- ObjectEdit V1.0, by Reinhard Grams © 1994
- \ /
- \*************************************************************/
-
- macro_name="ObjectEdit V1.0"
- macro_path="/OBED"
-
- /**************************************************************/
- call InitVariables()
- /**************************************************************/
-
- help.GERMAN.1="Dieses Makro dient zum Bearbeiten von ObjektSequenzen, die mit"
- help.GERMAN.2="den vom Modeler bekannten Funktionen editiert werden. Sie können"
- help.GERMAN.3="den Flex-Bereich auf Automatik schalten, oder den Bereich in den"
- help.GERMAN.4="Eingabefeldern Flex Start,End individuell einstellen. Den Flex-"
- help.GERMAN.5="Verlauf wählen Sie mit dem Schalter für die Ease Direction aus"
- help.GERMAN.6="Ebenso legen Sie in dem ersten Requester den Deform Radius für"
- help.GERMAN.7="alle Achsen fest. Die meisten Funktionen haben ein Wirkungszen-"
- help.GERMAN.8="trum, die Position dieses Zentrums legen Sie in den Eingabefel-"
- help.GERMAN.9="dern Center fest. "
- help.GERMAN.10="[PAGE]"
- help.GERMAN.11="In den nächsten beiden Requestern wählen Sie die Editierfunktio-"
- help.GERMAN.12="nen; es können beliebig viele kombiniert werden. Für jede ange-"
- help.GERMAN.13="wählte Funktion erscheint ein zusätzlicher Requester, in dem Sie"
- help.GERMAN.14="die jeweiligen Parameter eingeben können. Die Parameter ent-"
- help.GERMAN.15="sprechen denen der Modelerfunktionen, wenn Sie dort die numeri-"
- help.GERMAN.16="sche Eingabe wählen. "
- help.GERMAN.17="[PAGE]"
- help.GERMAN.18="Die Objekte können in das Quellverzeichnis zurückgeschrieben"
- help.GERMAN.19="werden, Sie können diese aber auch kopieren, indem Sie ein ande-"
- help.GERMAN.20="res Zielverzeichnis wählen. Dadurch bleiben die Originale erhal-"
- help.GERMAN.21="ten und oft auch Ihre gute Laune. "
- help.GERMAN.22="[END]"
-
- help.ENGLISH.1="This macro is intended for working on sequences of objects,"
- help.ENGLISH.2="which are edited with the functions you know from the modeler."
- help.ENGLISH.3="You can set the flex-area to automatic or adjust the area in the"
- help.ENGLISH.4="input-fields ""Flex Start"" and ""End"" individualy. The flex-"
- help.ENGLISH.5="course is selected with the switch for Ease Direction. The same"
- help.ENGLISH.6="way you specify the Deform Radius for all axis in the first re-"
- help.ENGLISH.7="quester. Most of the functions have a effect-center, you can"
- help.ENGLISH.8="specify its position with the inputfield ""Center""."
- help.ENGLISH.9="[PAGE]"
- help.ENGLISH.10="In the next both requesters the edit-functions are choosen; you"
- help.ENGLISH.11="can combine as many as you like. For each selected function a"
- help.ENGLISH.12="new requester pops up where you can enter its parameters. The"
- help.ENGLISH.13="parameters are equal to the modelerfunctions, if you select nu-"
- help.ENGLISH.14="merical input there."
- help.ENGLISH.15="[PAGE]"
- help.ENGLISH.16="The objects can be written back into the source drawer, but you"
- help.ENGLISH.17="can also specify an other destination drawer. In that case the"
- help.ENGLISH.18="original objects are not overwritten and the operation can be"
- help.ENGLISH.19="redone."
- help.ENGLISH.20="[END]"
-
- /**************************************************************/
-
- do_autoflex=1
-
- do_move=0
- do_scale=0
- do_align=0
- do_flip=0
- do_unify=0
- do_merge=0
- do_rotate=0
- do_magnet=0
- do_twist=0
-
- do_vortex=0
- do_shear=0
- do_taper=0
- do_pole=0
- do_bend=0
- do_jitter=0
- do_smooth=0
- do_quantize=0
- do_surface=0
-
- flex_x1=-10
- flex_x2=10
- flex_y1=-10
- flex_y2=10
- flex_z1=-10
- flex_z2=10
-
- deform_x=10
- deform_y=10
- deform_z=10
-
- center_x=0
- center_y=0
- center_z=0
-
- move_x=0
- move_y=0
- move_z=0
-
- shear_x=0
- shear_y=0
- shear_z=0
-
- magnet_x=0
- magnet_y=0
- magnet_z=0
-
- rotate_x=0
- rotate_y=0
- rotate_z=0
-
- twist_x=0
- twist_y=0
- twist_z=0
-
- vortex_x=0
- vortex_y=0
- vortex_z=0
-
- size_x=1
- size_y=1
- size_z=1
-
- taper_x=0
- taper_y=0
- taper_z=0
-
- pole_x=0
- pole_y=0
- pole_z=0
-
- quantize_x=1
- quantize_y=1
- quantize_z=1
-
- jitter_x=0.1
- jitter_y=0.1
- jitter_z=0.1
-
- bend_angle=0
- bend_direction=0
- smooth_iterations=1
- smooth_strength=1
- surface_name="Surface"
-
- GAUSSIAN=1
- UNIFORM=2
- NORMAL=3
- RADIAL=4
-
- jitter.1="GAUSSIAN"
- jitter.2="UNIFORM"
- jitter.3="NORMAL"
- jitter.4="RADIAL"
- jitter_type=GAUSSIAN
-
- EASE_IN=1
- EASE_OUT=2
-
- ease.1="i"
- ease.2="o"
- ease_direction=EASE_IN
-
- /**************************************************************/
-
- call OpenLibs()
- call GlobalsRequester(macro_name)
- call HelpRequester(macro_name,"help",language)
-
- call LoadConfig()
- call Requester1()
- call Requester2()
- call Requester3()
-
- if (do_move) then call MoveRequester()
- if (do_scale) then call ScaleRequester()
- if (do_rotate) then call RotateRequester()
- if (do_magnet) then call MagnetRequester()
- if (do_twist) then call TwistRequester()
- if (do_vortex) then call VortexRequester()
- if (do_shear) then call ShearRequester()
- if (do_taper) then call TaperRequester()
- if (do_pole) then call PoleRequester()
- if (do_bend) then call BendRequester()
- if (do_jitter) then call JitterRequester()
- if (do_smooth) then call SmoothRequester()
- if (do_quantize) then call QuantizeRequester()
- if (do_surface) then call SurfaceRequester()
-
- call SaveConfig()
-
- selected=SelectSequence("OBJECTS","3D:Objects",1,10000,selection1,selection2,selectionl,ST_SEQUENCE)
- if (selected=0) then call CleanExit()
-
- out_path=SelectFile(messages.language.OUTPUT_MESS,"3D:Objects","",selection3,"DRAWER")
- if (out_path="") then call CleanExit()
-
- call DoEdit()
-
- call CloseLibs()
- exit 0
-
- /**************************************************************/
-
- Requester1:
-
- call req_begin(macro_name)
-
- id_au=req_addcontrol("Use AutoFlex", 'b')
- id_ea=req_addcontrol("Ease", 'ch',"In Out")
- id_f1=req_addcontrol("Flex X Start,End", 'v')
- id_f2=req_addcontrol("Flex Y Start,End", 'v')
- id_f3=req_addcontrol("Flex Z Start,End", 'v')
- id_de=req_addcontrol("Deform Radius X,Y,Z", 'v',1)
- id_ce=req_addcontrol("Center X,Y,Z", 'v',1)
-
- call req_setval(id_au, do_autoflex)
- call req_setval(id_ea, ease_direction)
- call req_setval(id_f1, flex_x1 flex_x2 0)
- call req_setval(id_f2, flex_y1 flex_y2 0)
- call req_setval(id_f3, flex_z1 flex_z2 0)
- call req_setval(id_de, deform_x deform_y deform_z)
- call req_setval(id_ce, center_x center_y center_z)
-
- if (~req_post()) then call CleanExit()
-
- do_autoflex=req_getval(id_au)
- ease_direction=req_getval(id_ea)
- parse value req_getval(id_f1) with flex_x1 flex_x2 .
- parse value req_getval(id_f2) with flex_y1 flex_y2 .
- parse value req_getval(id_f3) with flex_z1 flex_z2 .
- parse value req_getval(id_de) with deform_x deform_y deform_z .
- parse value req_getval(id_ce) with center_x center_y center_z .
-
- call req_end()
-
- return 1
-
- /**************************************************************/
-
- Requester2:
-
- call req_begin(macro_name)
-
- id_a1=req_addcontrol("Move",'b')
- id_a2=req_addcontrol("Shear",'b')
- id_a3=req_addcontrol("Magnet",'b')
- id_a4=req_addcontrol("Rotate",'b')
- id_a5=req_addcontrol("Twist",'b')
- id_a6=req_addcontrol("Vortex",'b')
- id_a7=req_addcontrol("Scale",'b')
- id_a8=req_addcontrol("Taper",'b')
- id_a9=req_addcontrol("Pole",'b')
-
- call req_setval(id_a1, do_move)
- call req_setval(id_a2, do_shear)
- call req_setval(id_a3, do_magnet)
- call req_setval(id_a4, do_rotate)
- call req_setval(id_a5, do_twist)
- call req_setval(id_a6, do_vortex)
- call req_setval(id_a7, do_scale)
- call req_setval(id_a8, do_taper)
- call req_setval(id_a9, do_pole)
-
- if (~req_post()) then call CleanExit()
-
- do_move=req_getval(id_a1)
- do_shear=req_getval(id_a2)
- do_magnet=req_getval(id_a3)
- do_rotate=req_getval(id_a4)
- do_twist=req_getval(id_a5)
- do_vortex=req_getval(id_a6)
- do_scale=req_getval(id_a7)
- do_taper=req_getval(id_a8)
- do_pole=req_getval(id_a9)
-
- call req_end()
-
- return 1
-
- /**************************************************************/
-
- Requester3:
-
- call req_begin(macro_name)
-
- id_a1=req_addcontrol("Bend",'b')
- id_a2=req_addcontrol("Jitter",'b')
- id_a3=req_addcontrol("Smooth",'b')
- id_a4=req_addcontrol("Quantize",'b')
- id_a5=req_addcontrol("Merge",'b')
- id_a6=req_addcontrol("Align",'b')
- id_a7=req_addcontrol("Flip",'b')
- id_a8=req_addcontrol("Unify",'b')
- id_a9=req_addcontrol("Surface",'b')
-
- call req_setval(id_a1, do_bend)
- call req_setval(id_a2, do_jitter)
- call req_setval(id_a3, do_smooth)
- call req_setval(id_a4, do_quantize)
- call req_setval(id_a5, do_merge)
- call req_setval(id_a6, do_align)
- call req_setval(id_a7, do_flip)
- call req_setval(id_a8, do_unify)
- call req_setval(id_a9, do_surface)
-
- if (~req_post()) then call CleanExit()
-
- do_bend=req_getval(id_a1)
- do_jitter=req_getval(id_a2)
- do_smooth=req_getval(id_a3)
- do_quantize=req_getval(id_a4)
- do_merge=req_getval(id_a5)
- do_align=req_getval(id_a6)
- do_flip=req_getval(id_a7)
- do_unify=req_getval(id_a8)
- do_surface=req_getval(id_a9)
-
- call req_end()
-
- return 1
-
- /**************************************************************/
-
- MoveRequester:
-
- call req_begin(macro_name)
- id_a1=req_addcontrol("Move Distance XYZ",'v',1)
- call req_setval(id_a1, move_x move_y move_z)
- if (~req_post()) then call CleanExit()
- parse value req_getval(id_a1) with move_x move_y move_z .
- call req_end()
- return 1
-
- /**************************************************************/
-
- ScaleRequester:
-
- call req_begin(macro_name)
- id_a1=req_addcontrol("Scale Factor XYZ",'v')
- call req_setval(id_a1, size_x size_y size_z)
- if (~req_post()) then call CleanExit()
- parse value req_getval(id_a1) with size_x size_y size_z .
- call req_end()
- return 1
-
- /**************************************************************/
-
- RotateRequester:
-
- call req_begin(macro_name)
- id_a1=req_addcontrol("Rotate XYZ °",'v')
- call req_setval(id_a1, rotate_x rotate_y rotate_z)
- if (~req_post()) then call CleanExit()
- parse value req_getval(id_a1) with rotate_x rotate_y rotate_z .
- call req_end()
- return 1
-
- /**************************************************************/
-
- MagnetRequester:
-
- call req_begin(macro_name)
- id_a1=req_addcontrol("Magnet Offset XYZ",'v',1)
- call req_setval(id_a1, magnet_x magnet_y magnet_z)
- if (~req_post()) then call CleanExit()
- parse value req_getval(id_a1) with magnet_x magnet_y magnet_z .
- call req_end()
- return 1
-
- /**************************************************************/
-
- ShearRequester:
-
- call req_begin(macro_name)
- id_a1=req_addcontrol("Shear Offset XYZ",'v',1)
- call req_setval(id_a1, shear_x shear_y shear_z)
- if (~req_post()) then call CleanExit()
- parse value req_getval(id_a1) with shear_x shear_y shear_z .
- call req_end()
- return 1
-
- /**************************************************************/
-
- TwistRequester:
-
- call req_begin(macro_name)
- id_a1=req_addcontrol("Twist XYZ °",'v')
- call req_setval(id_a1, twist_x twist_y twist_z)
- if (~req_post()) then call CleanExit()
- parse value req_getval(id_a1) with twist_x twist_y twist_z .
- call req_end()
- return 1
-
- /**************************************************************/
-
- VortexRequester:
-
- call req_begin(macro_name)
- id_a1=req_addcontrol("Vortex XYZ °",'v')
- call req_setval(id_a1, vortex_x vortex_y vortex_z)
- if (~req_post()) then call CleanExit()
- parse value req_getval(id_a1) with vortex_x vortex_y vortex_z .
- call req_end()
- return 1
-
- /**************************************************************/
-
- TaperRequester:
-
- call req_begin(macro_name)
- id_a1=req_addcontrol("Taper Factor XYZ",'v')
- call req_setval(id_a1, taper_x taper_y taper_z)
- if (~req_post()) then call CleanExit()
- parse value req_getval(id_a1) with taper_x taper_y taper_z .
- call req_end()
- return 1
-
- /**************************************************************/
-
- PoleRequester:
-
- call req_begin(macro_name)
- id_a1=req_addcontrol("Pole Factor XYZ",'v')
- call req_setval(id_a1, pole_x pole_y pole_z)
- if (~req_post()) then call CleanExit()
- parse value req_getval(id_a1) with pole_x pole_y pole_z .
- call req_end()
- return 1
-
- /**************************************************************/
-
- BendRequester:
-
- call req_begin(macro_name)
- id_a1=req_addcontrol("Bend Angle °",'n')
- id_a2=req_addcontrol("Bend Direction",'n')
- call req_setval(id_a1, bend_angle)
- call req_setval(id_a2, bend_direction)
- if (~req_post()) then call CleanExit()
- bend_angle=req_getval(id_a1)
- bend_direction=req_getval(id_a2)
- call req_end()
- return 1
-
- /**************************************************************/
-
- JitterRequester:
-
- call req_begin(macro_name)
- id_a1=req_addcontrol("Jitter Radius",'v',1)
- id_a2=req_addcontrol("Jitter Type",'cv',"Gaussian Uniform Normal Radial")
- call req_setval(id_a1, jitter_x jitter_y jitter_z)
- call req_setval(id_a2, jitter_type)
- if (~req_post()) then call CleanExit()
- parse value req_getval(id_a1) with jitter_x jitter_y jitter_z .
- jitter_type=req_getval(id_a2)
- call req_end()
- return 1
-
- /**************************************************************/
-
- SmoothRequester:
-
- call req_begin(macro_name)
- id_a1=req_addcontrol("Smooth Iterations",'n')
- id_a2=req_addcontrol("Smooth Strength",'n')
- call req_setval(id_a1, smooth_iterations)
- call req_setval(id_a2, smooth_strength)
- if (~req_post()) then call CleanExit()
- smooth_iterations=req_getval(id_a1)
- smooth_strength=req_getval(id_a2)
- call req_end()
- return 1
-
- /**************************************************************/
-
- QuantizeRequester:
-
- call req_begin(macro_name)
- id_a1=req_addcontrol("Quantize XYZ",'v',1)
- call req_setval(id_a1, quantize_x quantize_y quantize_z)
- if (~req_post()) then call CleanExit()
- parse value req_getval(id_a1) with quantize_x quantize_y quantize_z .
- call req_end()
- return 1
-
- /**************************************************************/
-
- SurfaceRequester:
-
- call req_begin(macro_name)
- id_a1=req_addcontrol("Surface",'r')
- call req_setval(id_a1, surface_name)
- if (~req_post()) then call CleanExit()
- surface_name=req_getval(id_a1)
- call req_end()
- return 1
-
- /**************************************************************/
-
- SaveConfig:
- if (open(state, config, 'W')) then do
- call writeln(state, "CONF")
- call writeln(state, do_autoflex,
- do_move do_shear do_magnet do_rotate do_twist,
- do_vortex do_scale do_taper do_pole,
- do_bend do_jitter do_smooth do_quantize do_merge,
- do_align do_flip do_unify do_surface)
- call writeln(state, ease_direction,
- flex_x1 flex_x2 flex_y1 flex_y2 flex_z1 flex_z2,
- deform_x deform_y deform_z center_x center_y center_z)
- call writeln(state, ,
- move_x move_y move_z shear_x shear_y shear_z,
- magnet_x magnet_y magnet_z rotate_x rotate_y rotate_z,
- twist_x twist_y twist_z vortex_x vortex_y vortex_z,
- size_x size_y size_z taper_x taper_y taper_z,
- pole_x pole_y pole_z quantize_x quantize_y quantize_z,
- bend_angle bend_direction jitter_x jitter_y jitter_z,
- jitter_type smooth_iterations smooth_strength)
- call writeln(state,surface_name)
- call close state
- end
- return
-
- /**************************************************************/
-
- LoadConfig:
-
- if (exists(config)) then do
- if (open(state, config, 'R')) then do
- if (readln(state)="CONF") then do
- parse value readln(state) with do_autoflex,
- do_move do_shear do_magnet do_rotate do_twist,
- do_vortex do_scale do_taper do_pole,
- do_bend do_jitter do_smooth do_quantize do_merge,
- do_align do_flip do_unify do_surface .
- parse value readln(state) with ease_direction,
- flex_x1 flex_x2 flex_y1 flex_y2 flex_z1 flex_z2,
- deform_x deform_y deform_z center_x center_y center_z .
- parse value readln(state) with,
- move_x move_y move_z shear_x shear_y shear_z,
- magnet_x magnet_y magnet_z rotate_x rotate_y rotate_z,
- twist_x twist_y twist_z vortex_x vortex_y vortex_z,
- size_x size_y size_z taper_x taper_y taper_z,
- pole_x pole_y pole_z quantize_x quantize_y quantize_z,
- bend_angle bend_direction jitter_x jitter_y jitter_z,
- jitter_type smooth_iterations smooth_strength .
- surface_name=readln(state)
- end
- end
- call close state
- end
- return
-
- /**************************************************************/
- /**************************************************************/
-
- DoEdit:
-
- if (do_autoflex) then do
- call autoflex("X","+",ease.ease_direction)
- call autoflex("Y","+",ease.ease_direction)
- call autoflex("Z","+",ease.ease_direction)
- call autoflex("X","-",ease.ease_direction)
- call autoflex("Y","-",ease.ease_direction)
- call autoflex("Z","-",ease.ease_direction)
- end
- else do
- call fixedflex("X",flex_x1,flex_x2,ease.ease_direction)
- call fixedflex("Y",flex_y1,flex_y2,ease.ease_direction)
- call fixedflex("Z",flex_z1,flex_z2,ease.ease_direction)
- end
-
- call deformregion(deform_x deform_y deform_z,center_x center_y center_z)
-
- do object=1 to selected
- in_name=sequence_name.object
- out_name=LW_ADDFILE(out_path,LW_FILE(in_name))
- call EditObject()
- end
-
- if (verbose) then do
- call notify(1,! trunc(selected) vmes.language.1)
- end
-
- return
-
- /**************************************************************/
-
- EditObject:
-
- call cut(); call cut()
-
- call load(in_name)
-
- call sel_mode("USER")
-
- if (do_move) then do
- call move(move_x move_y move_z)
- end
-
- if (do_shear) then do
- call shear(shear_x shear_y shear_z)
- end
-
- if (do_magnet) then do
- call magnet(magnet_x magnet_y magnet_z)
- end
-
- if (do_rotate) then do
- call rotate(rotate_x,"X",center_x center_y center_z)
- call rotate(rotate_y,"Y",center_x center_y center_z)
- call rotate(rotate_z,"Z",center_x center_y center_z)
- end
-
- if (do_twist) then do
- call twist(twist_x,"X",center_x center_y center_z)
- call twist(twist_y,"Y",center_x center_y center_z)
- call twist(twist_z,"Z",center_x center_y center_z)
- end
-
- if (do_vortex) then do
- call vortex(vortex_x,"X",center_x center_y center_z)
- call vortex(vortex_y,"Y",center_x center_y center_z)
- call vortex(vortex_z,"Z",center_x center_y center_z)
- end
-
- if (do_scale) then do
- call scale(size_x size_y size_z,center_x center_y center_z)
- end
-
- if (do_taper) then do
- call taper(taper_x taper_y taper_z,center_x center_y center_z)
- end
-
- if (do_pole) then do
- call pole(pole_x pole_y pole_z,center_x center_y center_z)
- end
-
- if (do_bend) then do
- call bend(bend_angle,bend_direction,center_x center_y center_z)
- end
-
- if (do_jitter) then do
- call jitter(jitter_radius,jitter.jitter_type,center_x center_y center_z)
- end
-
- if (do_smooth) then do
- call smooth(smooth_iterations,smooth_strength)
- end
-
- if (do_quantize) then do
- call quantize(quantize_x quantize_y quantize_z)
- end
-
- if (do_merge) then do
- call mergepoints()
- end
-
- if (do_align) then do
- call alignpols()
- end
-
- if (do_flip) then do
- call flip()
- end
-
- if (do_unify) then do
- call unifypols()
- end
-
- if (do_surface) then do
- call changesurface(surface_name)
- end
-
- call save(out_name)
-
- return
-
- /**************************************************************/
- /**************************************************************/
-
- ErrorMessage: parse arg status, add_string, user_cancel
-
- continue=0
- if (status~="") then do
- if (user_cancel~="") then user_sel=2; else user_sel=1
- if (verify(status,"0123456789")=0) then do
- if (status>0 & status<INTERNAL_ERR) then do
- if (add_string~="") then do
- continue=notify(user_sel,! errors.language.status"!",add_string)
- end
- else do
- continue=notify(user_sel,! errors.language.status"!")
- end
- end
- else do
- continue=notify(1,! errors.language.INTERNAL_ERR"!")
- end
- end
- else do
- if (add_string~="") then continue=notify(user_sel,! status,add_string)
- else continue=notify(user_sel,! status)
- end
- end
- return continue
-
- /**************************************************************/
-
- CleanExit: parse arg status, add_string, user_cancel
-
- call end_all()
- call ErrorMessage(status, add_string, user_cancel)
- call CloseLibs()
- exit 0
-
- /**************************************************************/
-
- OpenLibs:
-
- if (~show('L',rexxlib)) then do
- if ~addlib(rexxlib,0,-30,0) then do
- call ErrorMessage(OPEN_LIB_ERR,rexxlib)
- exit 10
- end
- if (~show('L',rexxlib)) then do
- call ErrorMessage(OPEN_LIB_ERR,rexxlib)
- exit 10
- end
- end
- if (~show('L',mathlib)) then do
- if ~addlib(mathlib,0,-30,0) then do
- call ErrorMessage(OPEN_LIB_ERR,mathlib)
- exit 10
- end
- if (~show('L',mathlib)) then do
- call ErrorMessage(OPEN_LIB_ERR,mathlib)
- exit 10
- end
- end
- if (~show('L',supplib)) then do
- if ~addlib(supplib,0,-30,0) then do
- call ErrorMessage(OPEN_LIB_ERR,supplib)
- exit 10
- end
- if (~show('L',supplib)) then do
- call ErrorMessage(OPEN_LIB_ERR,mathlib)
- exit 10
- end
- end
- port=addlib("LWModelerARexx.port",0)
- return
-
- /**************************************************************/
-
- CloseLibs:
-
- if (port~="") then call remlib("LWModelerARexx.port")
- return
-
- /**************************************************************/
-
- SelectFile: PROCEDURE EXPOSE selected_file selected_drawer
- parse arg title, drawer_name, file_name, config_file, mode
-
- if (exists(config_file)) then do
- if (open(state,config_file,'R')) then do
- if (readln(state)="FSEL") then do
- drawer_name=readln(state)
- file_name=readln(state)
- end
- call close state
- end
- end
- if (mode=DRAWER) then choice=getfilename(title,drawer_name,"")
- else choice=getfilename(title,drawer_name,file_name)
- if (choice="(none)") then return ""
- selected_drawer=LW_Drawer(choice)
- selected_file=LW_File(choice)
- if (mode~="DRAWER") then do
- if (selected_file="") then return ""
- end
- if (open(state,config_file,'W')) then do
- call writeln(state, "FSEL")
- call writeln(state, selected_drawer)
- call writeln(state, selected_file)
- call close(state)
- end
- select
- when (mode="DRAWER") then choice=selected_drawer
- when (mode="FILE") then choice=selected_file
- otherwise nop
- end
-
- return choice
-
- /**************************************************************/
-
- HelpRequester: parse arg title, text_array, language
-
- select
- when (help_type=HELP_NEVER) then return
- when (help_type=HELP_FIRST) then do
- if (exists(config)) then return
- end
- otherwise nop
- end
- if (~TextRequester(title,text_array,language)) then do
- call GlobalsRequester(title,1)
- end
- return
-
- /**************************************************************/
-
- TextRequester: parse arg title, text_array, language
-
- hpages=1
- hline=1
- do until (str="[END]")
- interpret("str="text_array"."language"."hline)
- if (str="[PAGE]") then hpages=hpages+1
- hline=hline+1
- end
- call req_begin(title||pmes.language.1 "1" pmes.language.2 hpages)
- hline=1; continue=1; hpage=1
- do while (continue)
- interpret("htext="text_array"."language"."hline)
- select
- when (htext="[PAGE]") then do
- go_on=req_post()
- call req_end()
- if (go_on) then do
- hpage=hpage+1
- call req_begin(title||pmes.language.1 hpage pmes.language.2 hpages)
- end
- else continue=0
- end
- when (htext="[END]") then do
- go_on=req_post()
- call req_end()
- continue=0
- end
- otherwise do
- id.hline=req_addcontrol("",'t',htext)
- end
- end
- hline=hline+1
- end
- return go_on
-
- /**************************************************************/
-
- SaveSettings: PROCEDURE EXPOSE ENV_ERR envpath globals language,
- help_type verbose extension_digits
-
- if (~exists(envpath)) then do
- address command "makedir" envpath
- if (~exists(envpath)) then call CleanExit(ENV_ERR)
- end
- ok=0
- if (open(state, globals, 'W')) then do
- call writeln(state, "GLBS")
- call writeln(state, language help_type verbose extension_digits)
- call close(state)
- ok=1
- end
- return ok
-
- /**************************************************************/
-
- LoadSettings: PROCEDURE EXPOSE ENV_ERR envpath globals language,
- help_type verbose extension_digits
-
- if (~exists(envpath)) then do
- address command "makedir" envpath
- if (~exists(envpath)) then call CleanExit(ENV_ERR)
- end
- ok=0
- if (exists(globals)) then do
- if (open(state, globals, 'R')) then do
- if (readln(state)="GLBS") then do
- parse value readln(state) with language help_type,
- verbose extension_digits .
- ok=1
- end
- call close(state)
- end
- end
- return ok
-
- /**************************************************************/
-
- GlobalsRequester: PROCEDURE EXPOSE ENV_ERR envpath globals language,
- help_type verbose extension_digits
- parse arg title, force
-
- loaded=LoadSettings()
- if (force="") then do
- if (loaded) then return
- end
- call req_begin(title": Globals")
- id_la=req_addcontrol("Language", 'ch',"English German")
- id_he=req_addcontrol("Help", 'ch',"First Always Never")
- id_ve=req_addcontrol("Verbose", 'b')
- id_ex=req_addcontrol("Ext. Digits", 'n')
- call req_setval(id_la, language)
- call req_setval(id_he, help_type)
- call req_setval(id_ve, verbose)
- call req_setval(id_ex, extension_digits)
- if (~req_post()) then do; call req_end(); return 0; end
- language=req_getval(id_la)
- help_type=req_getval(id_he)
- verbose=req_getval(id_ve)
- extension_digits=req_getval(id_ex)
- call req_end()
- if (extension_digits<2) then extension_digits=2
- call SaveSettings()
- return
-
- /**************************************************************/
-
- GetExtension: PROCEDURE; parse arg exname
-
- l=length(exname)
- s=verify(reverse(exname),"0123456789")
- if (s>l) then return exname
- if (s<2) then return ""
- return substr(exname,length(exname)+2-s)
-
- /**************************************************************/
-
- GetBaseName: PROCEDURE; parse arg exname
-
- b=length(exname)-length(GetExtension(exname))
- return substr(exname,1,b)
-
- /**************************************************************/
-
- GetExtensionDigits: PROCEDURE; parse arg exname
-
- return length(GetExtension(exname))
-
- /**************************************************************/
-
- MakeExtension: PROCEDURE; parse arg exname, ext_digits
-
- return right(exname,ext_digits,'0')
-
- /**************************************************************/
-
- SaveSelection: PROCEDURE EXPOSE sequence_name.
- parse arg selected, select_file, select_type
-
- ok=0
- if (open(state, select_file, 'W')) then do
- call writeln(state, "SSEL")
- call writeln(state, select_type)
- call writeln(state, selected)
- c=1
- do while (c<=selected)
- call writeln(state, sequence_name.c); c=c+1
- end
- call close(state)
- ok=1
- end
- return ok
-
- /**************************************************************/
-
- LoadSelection: PROCEDURE EXPOSE select_type sequence_name.
- parse arg select_file
-
- selected=0
- if (exists(select_file)) then do
- if (open(state, select_file, 'R')) then do
- if (readln(state)="SSEL") then do
- select_type=readln(state)
- selected=readln(state)
- c=1
- do while (c<=selected)
- sequence_name.c=readln(state); c=c+1
- end
- end
- call close(state)
- end
- end
- return selected
-
- /**************************************************************/
-
- SelectSequence: PROCEDURE EXPOSE language sequence_name.,
- EXTENSION_ERR SEQUENCE_ERR FILE_ERR READ_ERR GERMAN ENGLISH errors.,
- ST_SEQUENCE ST_SPECIFY ST_LIST ST_DIRECTORY ST_READ ST_REPEAT
- parse arg title, default_drawer, minimum_files, maximum_files,,
- selection1, selection2, select_file, select_type
-
- mes.ENGLISH.1="Select First"
- mes.ENGLISH.2="Select Last"
- mes.ENGLISH.3="Select Next (or CANCEL)"
- mes.ENGLISH.4="Select List"
- mes.ENGLISH.5="Select Directory"
- mes.ENGLISH.6="Need at least"
- mes.ENGLISH.7="File(s)"
- mes.ENGLISH.8="Maximum of"
- mes.ENGLISH.9="Files selected"
-
- mes.GERMAN.1="Wählen Sie die erste Datei"
- mes.GERMAN.2="Wählen Sie die letzte Datei"
- mes.GERMAN.3="Nächste Datei (oder CANCEL)"
- mes.GERMAN.4="Wählen Sie die Liste"
- mes.GERMAN.5="Wählen Sie das Verzeichnis"
- mes.GERMAN.6="Wählen Sie bitte mindestens"
- mes.GERMAN.7="Datei(en)"
- mes.GERMAN.8="Bitte nur maximal"
- mes.GERMAN.9="Datei(en) ausgewählt"
-
- old_selected=LoadSelection(select_file)
- select_type=TypeRequester(title,select_type,old_selected)
- if (select_type=0) then return 0
- if (title~="") then title=title": "
- seq_files=0
-
- select
- when (select_type=ST_SEQUENCE) then do
- name1=SelectFile(title||mes.language.1,default_drawer,"",selection1)
- if (name1="") then return 0
- name2=SelectFile(title||mes.language.2,selected_drawer,"",selection2)
- if (name2="") then return 0
-
- start_sequence=GetExtension(name1)
- end_sequence=GetExtension(name2)
- if (start_sequence="" | end_sequence="") then do
- call CleanExit(EXTENSION_ERR)
- end
- if (start_sequence>end_sequence) then do
- temp=start_sequence
- start_sequence=end_sequence
- end_sequence=temp
- end
- base_name=GetBaseName(name1)
- extension_digits=GetExtensionDigits(name1)
- if (upper(base_name)~=upper(GetBaseName(name2))) then do
- call CleanExit(SEQUENCE_ERR)
- end
- if (extension_digits~=GetExtensionDigits(name2)) then do
- extension_digits=0
- end
- do o=start_sequence to end_sequence
- seq_files=seq_files+1
- sequence_name.seq_files=base_name||MakeExtension(o,extension_digits)
- end
- end
-
- when (select_type=ST_SPECIFY) then do
-
- done=0
- do until (done)
- name=SelectFile(title||mes.language.3,default_drawer,"",selection1)
- if (name="") then do
- if (seq_files=0) then return 0
- else done=1
- end
- if (~done) then do
- seq_files=seq_files+1
- sequence_name.seq_files=name
- end
- end
- end
-
- when (select_type=ST_LIST) then do
-
- name=SelectFile(title||mes.language.4,"RAM:","",selection1)
- if (name="") then return 0
- if (~exists(name)) then call CleanExit(FILE_ERR)
- if (~open(state,name,'R')) then call CleanExit(READ_ERR)
- do until (name="")
- name=readln(state)
- if (name~="") then do
- seq_files=seq_files+1
- sequence_name.seq_files=name
- end
- end
- call close(state)
- end
-
- when (select_type=ST_DIRECTORY) then do
-
- drawer=SelectFile(title||mes.language.5,default_drawer,"",selection1,"DRAWER")
- if (drawer="") then return 0
- list=DeleteInfo(showdir(drawer,'F'))
- seq_files=words(list)
- do sequence=1 to seq_files
- name=LW_AddFile(drawer,word(list,sequence))
- sequence_name.sequence=name
- end
- end
-
- when (select_type=ST_READ) then do
-
- name1=SelectFile(title||mes.language.1,default_drawer,"",selection1)
- if (name1="") then return 0
- name2=SelectFile(title||mes.language.2,selected_drawer,"",selection2)
- if (name2="") then return 0
-
- drawer=LW_DRAWER(name1)
- list=DeleteInfo(showdir(drawer,'F'))
- list=LW_SortList(list,words(list))
- files=words(list)
- do_add=0
- do sequence=1 to files
- name=LW_AddFile(drawer,word(list,sequence))
- if (name=name1) then do_add=1
- if (do_add) then do
- seq_files=seq_files+1
- sequence_name.seq_files=name
- end
- if (name=name2) then leave
- end
- end
-
- when (select_type=ST_REPEAT) then do
- seq_files=old_selected
- end
- end
-
- if (seq_files<minimum_files) then do
- call notify(1,! mes.language.6 minimum_files mes.language.7); return 0
- end
- if (seq_files>maximum_files) then do
- call notify(1,! mes.language.8 maximum_files mes.language.7); return 0
- end
- if (~notify(2,! seq_files mes.language.9)) then return 0
-
- SaveSelection(seq_files,select_file,select_type)
- return seq_files
-
- /**************************************************************/
-
- DeleteInfo: parse arg flist
-
- elist=""
- if (flist~="") then do
- do i=1 to words(flist)
- w=word(flist,i)
- if (pos(".info",w,length(w)-5)=0) then elist=elist w
- end
- end
- return elist
-
- /**************************************************************/
-
- TypeRequester: PROCEDURE EXPOSE language ENGLISH GERMAN
- parse arg title, select_type, old_selected
-
- mes.ENGLISH.1=": Selection Type"
- mes.ENGLISH.2="Type of File Selection"
- mes.GERMAN.1=": Art der Auswahl"
- mes.GERMAN.2="Art der Dateiauswahl"
-
- if (title~="") then tstring=title||mes.language.1
- else tstring=mes.language.2
- cstring="Sequence Specify List Directory AlphaSort"
- if (old_selected>0) then cstring=cstring "Repeat"
- return VariableChoice(tstring,"TYPE",cstring,words(cstring),select_type)
-
- /**************************************************************/
-
- VariableChoice: PROCEDURE EXPOSE language ENGLISH GERMAN pmes.
- parse arg title, descriptor, array, visible, selected
-
- vchoice=0
- to_show=words(array); coffset=1; cpage=1; cpages=to_show/visible;
- if ((to_show//visible)>0) then cpages=cpages+1; cpages=trunc(cpages)
- do while (to_show>0)
- if (to_show>visible) then citems=visible; else citems=to_show
- vc=""; do i=coffset to citems+coffset-1; vc=vc word(array,i); end
- if (cpages>1) then call req_begin(title||pmes.language.1 cpage pmes.language.2 cpages)
- else call req_begin(title)
- vci=req_addcontrol(descriptor,'cv',vc)
- call req_setval(vci,selected)
- if (~req_post()) then do; call req_end(); return 0; end
- vchoice=req_getval(vci)
- call req_end()
- to_show=to_show-citems; coffset=coffset+citems
- end
- return vchoice
-
- /**************************************************************/
-
- error:
- syntax:
-
- t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
- call CleanExit()
-
- /**************************************************************/
- /**************************************************************/
-
- InitVariables:
-
- mathlib="rexxmathlib.library"
- rexxlib="rexxsupport.library"
- supplib="LWE.library"
- port=""
-
- envpath="ENV:LWEnhancer"
- globals=envpath"/LWEN.GLB"
- envname=envpath||macro_path
- config=envname".CNF"
-
- selection1=envname".1"
- selection2=envname".2"
- selection3=envname".3"
- selectionl=envname".L"
-
- /**************************************************************/
-
- ENGLISH=1
- GERMAN=2
-
- HELP_FIRST=1
- HELP_ALWAYS=2
- HELP_NEVER=3
-
- help_type=HELP_FIRST
- language=ENGLISH
- verbose=1
- extension_digits=3
-
- /**************************************************************/
-
- ST_SEQUENCE=1
- ST_SPECIFY=2
- ST_LIST=3
- ST_DIRECTORY=4
- ST_READ=5
- ST_REPEAT=6
-
- /**************************************************************/
-
- vmes.ENGLISH.1="Object(s) edited"
- vmes.GERMAN.1="Objekt(e) editiert"
-
- pmes.ENGLISH.1=": Page"
- pmes.ENGLISH.2="from"
- pmes.GERMAN.1=": Seite"
- pmes.GERMAN.2="von"
-
- NO_ERROR=0
- FILE_ERR=1
- OPEN_LIB_ERR=2
- READ_ERR=3
- WRITE_ERR=4
- EXTENSION_ERR=5
- SEQUENCE_ERR=6
- ENV_ERR=7
- MAX_ERR=8
- INTERNAL_ERR=9
-
- errors.ENGLISH.FILE_ERR="File not found"
- errors.ENGLISH.OPEN_LIB_ERR="Can't open Library"
- errors.ENGLISH.READ_ERR="Read Error"
- errors.ENGLISH.WRITE_ERR="Write Error"
- errors.ENGLISH.EXTENSION_ERR="Numeric Extension Error"
- errors.ENGLISH.SEQUENCE_ERR="Base Names are different"
- errors.ENGLISH.ENV_ERR="Can't create"
- errors.ENGLISH.MAX_ERR="Maximum of 32767 Points"
- errors.ENGLISH.INTERNAL_ERR="Internal Error"
-
- errors.GERMAN.FILE_ERR="Datei nicht gefunden"
- errors.GERMAN.OPEN_LIB_ERR="Kann Library nicht öffnen"
- errors.GERMAN.READ_ERR="Fehler beim Lesen der Datei"
- errors.GERMAN.WRITE_ERR="Fehler beim Schreiben der Datei"
- errors.GERMAN.EXTENSION_ERR="Keine gültige numerische Extension"
- errors.GERMAN.SEQUENCE_ERR="Sequenz mit unterschiedlichen Basisnamen"
- errors.GERMAN.ENV_ERR="Kann Verzeichnis nicht anlegen"
- errors.GERMAN.MAX_ERR="Anzahl der Punkte maximal 32767"
- errors.GERMAN.INTERNAL_ERR="Interner Fehler"
-
- /**************************************************************/
-
- SELECT_MESS=1
- MOTION_MESS=2
- OBJECT_MESS=3
- OUTPUT_MESS=4
- SEQUENCE_MESS=5
-
- messages.ENGLISH.SELECT_MESS="Please select File"
- messages.ENGLISH.MOTION_MESS="Please select Motion File"
- messages.ENGLISH.OBJECT_MESS="Please select Object File"
- messages.ENGLISH.OUTPUT_MESS="Please select Output Directory"
- messages.ENGLISH.SEQUENCE_MESS="Please select File Sequence"
-
- messages.GERMAN.SELECT_MESS="Bitte wählen Sie eine Datei"
- messages.GERMAN.MOTION_MESS="Bitte wählen Sie eine Motion-Datei"
- messages.GERMAN.OBJECT_MESS="Bitte wählen Sie eine Objekt-Datei"
- messages.GERMAN.OUTPUT_MESS="Bitte wählen Sie das Zielverzeichnis"
- messages.GERMAN.SEQUENCE_MESS="Wählen Sie eine Sequenz von Dateien"
-
- /**************************************************************/
-
- PI=3.14159265358; PI180=pi/180; PI2=pi*2; DegrPerRad=180/pi
-
- /**************************************************************/
-
- return
-
-