Scilab Gui Designer (Phase One)
In order to automate the creation of the Scilab Gui I have put together a small program written in Delphi. The source code can be downloaded here -> scilabgui.zip. The program file can be downladed here -> ScilabGUI.exe. If you download these files, you should also choose to save this page (including the graphics), because this web page is the 'help file'.
Most of the code generated by the program is coding for the Scilab gui, while the actual user code is typically the smallest component of the running Scilab program.
It has been some time since I have done the 'drag and drop' routine in a Windows program, and since I am not really interested in Windows programs, but I am very interested in Scilab programs, I decided to come up with a quick hack approach to 'drop' components onto the interface. When you click the mouse on a certain area to the left, the component buttons are enabled. You can then click the appropriate component button to place a component at the x,y coordinates of the mouse click.
When you click on a button to select a component to drop at this location, the component property box comes up. Most of the Scilab Gui code is repetitive, and only specific properties need to be changed.
By selecting the location with a mouse click, and pressing the component buttons, I have placed three edit boxes, and one button onto the design area (as well as including a rotation slider, to rotate the 3-D graph, and a color map, to change the color of the surface display on the finished graph. If you click on a component after it has been placed the property menu for that component will come up, and you can alter the properties assigned to that component. However, there is no 'undo' feature, so if you need to make some major changes, you must restart the program.
I have selected the checkbox to include the 'sample graph', and when the Write Code button is pushed the program writes out the code for the Scilab Gui and includes the sample graph. The Save Code button is enabled and it is possible then to save the code as a Scilab file.
The code writing routine creates a Scilab function containing all the Gui code (shown here with the default name 'FunctionName'. You can change the name of the Function by changing the default text in the edit box on the Gui interface.
At the end of this function, the program creates a function call to the 'CreateGraph' function, and the code for this function follows immediately after.
Embedded within the 'CreateGraph' function is an area where the graph code is inserted. Here the code for the sample graph has been placed (by checking the Sample Graph checkbox on the program interface).
The program also generates 'call backs' (code that will be executed by clicking on components, or pressing the enter key in an edit box. Here the code for the button press has been inserted into the button call back function. First the code must locate the 'handle' for 'edit_2' (the second edit box). Then it must address the 'string' field of the box using the 'dot' operator (similar to addressing fields in a record in Delphi -> eh.string. Then it must convert this string into an integer number (strtod). It then calls the graph function, passing this new value in the variable 'I'. Now whether or not this is 'best practice' and the only way to pass values to some graph in Scilab, that I do not know. However this does work, and if there are better ways of doing all this, what is required is some manual reworking of code (the main purpose of this program is to automatically generate a lot of gui code).
To run the Scilab program, you first load the code into the Scilab editor, and then from the drop down execute menu choose 'Load into Scilab'.
In the Scilab console, type in the name of the function (here it is the default value 'FunctionName()'), and then hit enter to launch the program.
This is a screenshot of the running Scilab program, with the Scilab Gui components arranged on the left hand side of the screen and the graph displayed on the right.
Here I have changed the value in Edit box 2 to '0.25' and then pressed the 'Recalc' button to activate the call back code for the button, and the newly generated graph appears on the right.
The Living Resurrection: A Manifesto