ACD Systems Home
 

Developers' Guide

 
=======================
Initalization and Main
=======================
[Input] (Null)
[Output] VRScilab main window
[File] \routines\VRscilab.tcl
\routines\VRScilab_global.tcl
\routines\start.tcl
[Type] TCL script
[Call by] \VRScilab.sce
\routines\VRScilab.tcl
\routines\VRScilab.tcl

[Function]
@ Get vrScilab currdir(rootdir) , set global variables
@ Set font size according to system platform
@ Load icons
@ Show main window (show code editor window)
@ Define procedures (all procedures required in main window are defined here )
@ Load packages vrScilab_balloon 1.0 (creat balloon message when move over button)
Undoer 1.0 (Realize Redo & Undo)
vSpeedup 1.0 (Slove wish 8.0 interpretor problems in Scilab)
@ Source VRScilab_global.tcl ,Initalize variables
@ Try to load the last-opened file ,set font size as last time (source start.tcl)
@ Disable some important buttons when VRScilab is converting script.

[Implement]
At the beginning of VRScilab.tcl -- our central program, We get the directory of
the script itself. And the directory used later on are all based on it.Calling vrScilab_global.tcl,
we initialize global variable . Next, we check $tcl_platform(platform) to give a default font size
according to the OS. The loading of icons is followed, all pictures will be store in a buffer.
Before procedure defination, we declare some global variables which will be used in
our whole process. The most important variable is vrScilab. Next, we define many procedure
each has its own function, all of them will be called in a proper time.
In the procedure main{}, we load 3 packages (balloon,Undoer,Speedup). You can find them
in \lib.Balloon helps us show balloon message when mouse move over certain button,Undoer realizes undoing and Redoing operation for more than one time, Speed up is a little tool we developed.(More information, see "About SpeeUp"). Next, main{} source start.tcl which store the last-opened files name and the font size used last time. In order to avoid unpredictable accident, we disable some buttons when "Convert to VRML" is pressed.
At the end of VRScilab.tcl, we give the window defination.(Binding events, placing and packing objects, Setting help messages,etc.)For a detailer look, read VRScilab.tcl.

VRScilab.tcl show main window and do some initializations.
VRScilab_global.tcl initialize global variables.
start.tcl read the last-opened file name and last-used font size.

See also :
Scilab script Input & Edit
Report window

=======================
Scilab script Input & Edit
=======================
[Input] .sci file or user manual typing in code editor windows
[Output] sotre final Scilab script in the code editor
[File] \routines\VRScilab.tcl
\rourines\find&replace.tcl
[Type] TCL script
[Call by] \VRScilab.sce
\routines\VRScilab.tcl

[Functions]
@ VRScilab provide a friendly development environment for writing Scilab script
@ We developed common tools in editing a text. All source codes are produced by ourselves.
@ User can also write it before and import it into VRScilab use command open in file menu

[Implement]
We developed a program for writing Scilab script in friendly editor window. TK/TCL gave us
great help in doing this task.
We defined some procedures in file management such as open{},Save{},etc.pkgReUodo is a package used for editor redoing or undoing their operation. Font size changes can help you see your codes more conveniently. Method tk_textCopy is uesd to copy character blocks into clipboard , as well as tk_textCut & tk_textPaste.
For another, We developed a simple tool find&replace to solve the finding problem in long script editing task (see find&replace.tcl). Beacuse the Tcl interpreter in Scilab 2.6 (Windows version) is wish 8.0 which has a bug in responding keyboard & mouse event , we faced a great problem in working out the developer environment. At last, we designed a little tool "SpeedUp" to solve this problem.
For more information, see (About SpeedUp)No matter user imports pre-edited script or types it immediately in code editor, VRScilab use TK's text handle to store whole script into a character array. Later on, scitonewsci.tcl will read it and convert to a proper form which will call surf.tcl & envi.tcl in need.

See also:
Initalization and Main

=======================
Convert to temp_sci
=======================
[Input] Contents in the editor window (Scilab Script Input)
[Output] temp_sci.sci
[File] \routines\scitonewsci.tcl
[Type] TCL script
[Call by] \routines\VRScilab.tcl


[Function]
@ Get source scripts from code editor window , translate to temp_sci.sci
@ Run temp_sci.sci in Scilab Environment

[Implement]
Read the scilab script and store it in a stream. Insert some commands we need at the top and
end of the stream. Then use the regular expression to replace the commands we need to transfer.
For more information, read a temp_sci.sci in directory \temp when VRScilab is running.

See also:
Vfunctions
3D object settings
Environment settings


=======================
3D object settings
=======================
[Input] Matrices & Indexs temp files
[Output] VRML shapes with user defined property
[File] \routines\surf.tcl
\routines\all2vrml.tcl
[Type] TCL script
[Call by] \vfunctions\v*.sci
\routines\surf.tcl


[Function]
@ Get the matrices & indexs files generated by vfunctions and store them into temp VRML files
@ Show 3D-object settings window, wait for user's respond.
@ Convert the settings to VRML acceptable form , store them.
@ Write complete VRML shapes into temp .wrl files

[Implement]
surf.tcl:

Called by vfunction() (vfunctions are scilab scripts that plot 3d graphs)
The global variable used in this file: vrScilab(plotnum),vrScilab(allplotnum),vrScilab(plotnamelist),vrScilab(plottype)……………

Function: set the Object Color, Specula Color, Ambient Intensity, Shininess, Transparency, and if the type of object is not line, user can set the Crease Angle and decide whether to use a picture as texture of the object, if used ,then user can chose the picture.

Implement: When the object property setting window is showed, the properties are setted in default way by the procedure vrScilab:suf_Default. And user can change them, Then when user presses the OK button, it calls the procedure vrScilab:surf_Ok, it gets the properties of the object and stores them in the corresponding variables, then the vrScilab(plotname) is appended to the vrScilab(plotnamelist) and the alltovrml file is executed. The alltovrml file is also a tcl script, it produces the vrml file that describes the object; when the Cancel button was pressed the alltovrml script won’t be executed; and when the OktoAll button was pressed, it calls the procedure vrScilab:surf_OktoAll, there is a variable remembering this, it indicates that the next objects which will be produced in the same file will use the same properties, so the object property setting windows will not pop up, and its other function is similar to the Ok button; and the Canceltoall button will not create the vrml files for this and the next objects that are in the same files, and there is also a variable remembering this.

all2vrml.tcl:
First of all, this module create the vrml_tmp$vrScilab(filenum) file in the temp directory. Then write the file with the given pattern. When the value of property, matrix and index are needed, they can be directory got from the variable (the value of properties) or temp file (the value of matrix and index). The temp file is created by vfunctions. It transfers the value that the Scilab function provides to the fixed pattern the vrml need (more detail is available in the vfunction document). And in the end, when the values are gotten, the temp file will be deleted. And there is a procedure called hextoten to transfer the value of color from hex to decimal.

See also:
Convert to temp_sci
Environment settings

=======================
Environment settings
=======================
[Input] temp VRML files generated by 3D object settings
[Output] final VRML files
[File] \routines\final.tcl
\routines\envi.tcl
\routines\creatvrml.tcl

[Type] TCL script
[Call by] \temp\temp_sci.sci
\routines\final.tcl
\routines\envi.tcl

[Function]
@ Read temp files containing VRML shapes and write it into final .wrl file
@ Show environment setting window, wait for user's respond.
@ Convert the environment settings to VRML acceptable form, store them.
@ Read axis.tmp , plot axis if needed.
@ Generate rotational VRML codes if mouse move on.

[Implement]
Before final.tcl was called, one or more shapes have been defined by surf.tcl.
At the beginning of the routine, VRScilab reads all shapes and save them into the
final file given by user. Next, it will show a window for user to do some environment
settings. All the property will be checked and converted into VRML acceptabled form.
Then all of them will be stored into the final .wrl file.
After your settings, you can preview the result, and change some of them and get a
better view. When everything is ok, press button "Done". The final VRML will be available
soon in the given directory with the given name. Of course, in oreder to help user copy
the results or upload them to the website, we copy the pictures needed in the VRML files
into \<filename>_pic . ( For example, we creat file c:\VRScilab\test.wrl, all pictures will be
copied to c:\VRScilab\test_pic\ ) In addition, we can draw axises for a certain VRML file. We get the max and min value of X,Y and Z, multiply by 1.5 and get the length of axises. You can set the color of axises and characters in the environment settings window.
On the other hand, we add a short routine at the end of .wrl file in order to keep the
shape in autorotation when mouse is moved over.

More details about creatvrml.tcl:
First of all, to create the file by the requirement of user (with the right file name and
file path that user appoint). And then write this file with the fixed pattern of vrml. This
module write the environment properties (gotten from variable that is set in the envi module),
the object descriptions (gotten from the temp file vrml_tmp$vrScilab(filenum)) together to form
the final vrml file that can be interpreted by the vrml interpreter. And user can open this final
vrml file directory in Explorer (the vrml interpreter has been installed).

final.tcl judge whether a shape is defined.
envi.tcl show the window and wait for user's settings.
creatvrml.tcl generate the final VRML files.

See also:
Convert to temp_sci
3D object settings

=======================
Report window
=======================
[Input] vrScilab(reportlist)
[Output] report window
[File] \routines\report.tcl
[Type] TCL script
[Call by] \temp\temp_sci.sci


[Function]
@ Get report information from vrScilab(reportlist)
@ Show essential message in report window
@ Save report into .txt files if necessary
@ Enable buttons in main window


[Implement]
When surf.tcl and envi.tcl were called, character array vrScilab(reportlist) will be initialized and appended. In report.tcl, the whole report has been constructed. report.tcl gives a title ,adds other information and show the report in the window.
If necessary, the report can be saved into a .txt file using file hand in TCL script.
At the end of report.tcl, we enable buttons disabled during convert process.

See also:
3D object settings
Environment settings


=======================
Vfunctions
=======================
[Input] parameters the same as Scilab plot functions (plot3d for example)
[Output] temp files containing matrices and indexs needed by VRML
[File] \vfunctions\*.sci
[Type] Scilab Functions
[Call by] temp_sci.sci


[Function]
@ Get the parameters from temp_sci.sci.
@ Use Scilab's great power in matrix calculation to generate matrices & indexs
@ Save the result into temp files
@ Call surf.tcl to set the property of the 3D-object

[Implement]
In fact, these vfunctions is the core of VRScilab.
We construct many vfunctions as the form of certain plot funtions in Scilab.
(Vplot3d -> plot3d,for example)We replace all plot funtions with our vfunctions in
scitonewsci.tcl (linked Convert to temp_sci), then interpret them in the Scilab environment. When vfuntions is called, the parameters which will be given to plot functions are "stolen". So we get vectors, matrices or lists in our own funtions. In this way, we get enough information to define the spape of 3D-objects. "We leave complex calculating task to Scilab, and get the information needed from the parameters of vfuntions which will be sent to former Scilab plot funtions." Vfunctions convert the vectors,matrices and lists into a VRMl acceptabled form, and store them in 2 or 4 temp files in \temp. These will be used by all2vrml.tcl (linked 3d-object settings) later.( For more information, see functions referrance)

See also:
Convert to temp_sci
3D object settings

ACD Systems Newsletters



Home | A Letter | Introduction | System Requirements
2 Minutes' Guide | Users' Guide | Developers' Guide | Function Reference
FAQ | Known Bugs | More Information | Acknowledgement | About Us

Copyleft © 2003 XMU Scilab Group, China