Project

General

Profile

How to add an AppionLoop GUI page » History » Version 19

Amber Herold, 07/10/2014 03:37 PM

1 1 Amber Herold
h1. How to add an AppionLoop GUI page
2
3
See feature #2634 for more information on the code that supports these directions.
4
5
# *Add a wiki page to the [[Appion_Processing|Appion User Guide]] describing how to use this feature*
6 9 Amber Herold
 
7 10 Amber Herold
** You can just add a shell and a description of what it does to start. You can add screen shots and parameter details after adding the GUI completely. You just need to have the URL available for subsequent steps in this guide. If you are at a total loss, just link to the main table of contents: [[Appion Processing]]
8
 
9 1 Amber Herold
# *Add a publication reference for the package you are using*
10
 
11 15 Amber Herold
## Edit source:/trunk/myamiweb/processing/inc/publicationList.inc to include an entry for any references you need to add to your launch page.
12 1 Amber Herold
 
13
# *Create a new form class for your feature*
14 2 Amber Herold
 
15 1 Amber Herold
** Create a new file in myami/myamiweb/processing/inc/forms. Call it coolFeatureForm.inc.
16
** Create a class in this file that extends the BasicLoopForm class like this:
17
<pre>
18
require_once "basicLoopForm.inc";
19
20 11 Amber Herold
class CoolFeatureForm extends BasicLoopForm
21 17 Amber Herold
{trunk/myamiweb/processing/inc/forms/makeDDStackForm.inc
22 1 Amber Herold
...
23
</pre>
24 17 Amber Herold
** Examples are available in source:/trunk/myamiweb/processing/inc/forms/autoMaskForm.inc and source:trunk/myamiweb/processing/inc/forms/makeDDStackForm.inc
25 12 Amber Herold
** Use the following class diagram as reference
26
!guiclassdiagram.jpg!
27 2 Amber Herold
&nbsp;
28 4 Amber Herold
# *Set parameters needed by the BasicLoopForm class in the constructor*
29 1 Amber Herold
&nbsp;
30
<pre>
31
//------ Set Parameters for the parent class, BasicLoopForm (general Appion params) -----//
32
		
33
// Set the publications to be references on the web pages
34
$pubList = array('appion'); // The publication reference key that you added to publicationList.inc
35
$this->setPublications( $pubList );
36
37
// Job Type should be unique to Appion. Used in the database to determine the type of job being run.
38
$this->setJobType( 'maskmaker' ); 
39
40
// The name of the folder that all runs of this job type will be stored in.
41
$this->setOutputDirectory( 'mask' );  
42
43
// A portion of the run name that will be common (by default) to all runs of this job type. A unique number is appended to individual run names.
44
$this->setBaseRunName( 'maskrun' ); 
45
46
// The title on the web page for this feature.
47
$this->setTitle( 'Auto Masking Launcher' ); 
48
49
// The Heading on the web page for this feature.
50
$this->setHeading( 'Automated Masking with EM Hole Finder' ); 
51
52
// The name of the python executable file that this GUI corresponds to. It should be based on the AppionLoop class and located in the myami/appion/bin folder.
53
$this->setExeFile( 'automasker.py' );
54
55
// A URL corresponding to a wiki page in the Appion User Guide with information on running this feature.  
56
$this->setGuideURL( "http://emg.nysbc.org/projects/appion/wiki/Appion_Processing" );
57 2 Amber Herold
58
// True to activate "test single image" field of Appion Loop parameters.
59
$this->setTestable( True ); 
60
61
// The output directory will be created in the Appion run directory rather than Leginon.
62
$this->setUseLegOutDir( False );
63
64
// Flag to hide the description field of the run parameters. True enables the description field.
65
$this->setShowDesc( False ); 
66 1 Amber Herold
</pre>
67 3 Amber Herold
&nbsp;
68
# *Take an inventory of the parameters that are specific to your new feature and are passed into your python executable file*
69
** Make a list of all the parameters that your GUI needs to expose to the user. For each parameter decide on:
70
### *id* I might also call it a parameter key or name. This should match the name of the parameter as it appears on the command line. So a flag in a command that looks like "--mycoolflag" should be named "mycoolflag" in this class.
71
### *default value*
72
### *label* This is the text that is actually shown to the user in the GUI next to the GUI element associated with it (check box, selection, text, etc)
73
### *help text* A longer description of the parameter and tips for what a user should set it to.
74
### *validations* Decide what should be considered valid values for this parameter. Is it required? Does it have to be a number or greater than zero? 
75
&nbsp;
76
# *Add your parameters help text to myami/myamiweb/processing/js/help.js*
77
&nbsp;
78 19 Amber Herold
** Open source:/trunk/myamiweb/processing/js/help.js
79 3 Amber Herold
** Add a new namespace for your form, you can copy the 'simple' section. Don't forget any commas.
80
** add a help string for each of the parameter keys in your form
81
&nbsp;
82 5 Amber Herold
# *Add your parameters to your form class constructor*
83 3 Amber Herold
&nbsp;
84
** Back in the class that you created to extend BasicLoopForm, add your parameters.
85
** First set the help section using the namespace that you just added to help.js.
86
<pre>
87
// Get an instance of the form parameters associated with this class
88
$params = $this->getFormParams();
89
		
90
// The help section corresponds to the array key for these parameters found in help.js for popup help.
91
$params->setHelpSection( "em_hole_finder" );
92
</pre>
93 5 Amber Herold
** Add a line for each of the parameters in your form. The first parameter of the addParam() function is the id of the param, followed by the default value (passed into the constructor), followed by the label (what is shown to the user in the GUI).
94 3 Amber Herold
<pre>
95
$params->addParam( "downsample", $downsample, "Downsample" );
96 1 Amber Herold
$params->addParam( "compsizethresh", $compsizethresh, "Component size thresholding" );
97
</pre>
98 5 Amber Herold
** Add any validation requirements that are needed for your parameters. Use the addValidation() function of the FormParameter class. The first field is the parameter id. The second field is a key word that corresponds to the type of validation needed. 
99
<pre>
100
$params->addValidation( "numpart", "req" );
101
</pre>
102
** Avaialble validation types are as follows, and updates can be found in myami/myamiweb/inc/formValidator.php
103
<pre>
104
// available validations, check formValidator.php for changes:
105
/*
106
	 * required : 					addValidation("variableName", "req");
107
	 * MaxLengh : 					addValidation("variableName", "maxlen=10");
108
	 * MinLengh : 					addValidation("variableName", "mixlen=3");
109
	 * Email	: 					addValidation("variableName", "email");
110
	 * Numeric	: 					addValidation("variableName", "num");
111
	 * Alphabetic : 				addValidation("variableName", "alpha");
112
	 * Alphabetic and spaces : 		addValidation("variableName", "alpha_s");
113
	 * Alpha-numeric and spaces: 	addValidation("variableName", "alnum_s");
114
	 * Float: 						addValidation("variableName", "float");
115
	 * absolute path: path_exist: 	addValidation("variableName", "abs_path");
116
	 * path existence : 			addValidation("variableName", "path_exist");
117
	 * folder permission : 			addValidation("variableName", "folder_permission");
118
	 * file existence : 			addValidation("variableName", "file_exist");
119
	 * Float w/fixed decimal space: addValidation("variableName", "float_d=2");
120
*/
121
</pre>
122
&nbsp;
123 7 Amber Herold
# *Generate a form for the parameters that are specific to this program (not AppionLoop params)*
124
&nbsp;
125 6 Amber Herold
** There are 2 places avalable for adding your own parameters to the GUI page. The most common place is to the Right Hand side of the Appion Loop parameters. To add your parameters to this section of the screen, override the function called *generateAdditionalFormRight()* in your form class extending BasicLoopForm. You may also add parameters to the space on the left directly below the Appion Loop parameters by overriding the function called *generateAdditionalFormLeft()*.
126
** These functions return the HTML code required to display your parameter GUI elements to the user. You may add HTML here directly. To add an input element for your parameter, use one of the functions available in the FormParameters class. The first field of these functions is always the parameter id.
127
<pre>
128
	public function generateAdditionalFormRight()
129
	{
130
                // Calling updateFormParams() will check the php $_POST array for any values that were previously set for the parameters in this form. 
131
		$this->updateFormParams();
132
		$params = $this->getFormParams();
133
		
134
		$fieldSize = 3;
135
		
136
		$html .= "<b>Make DD stack params:</b><br />\n";
137
		
138
		$html.= $params->insertCheckboxField( "align" );
139
		$html.= $params->insertCheckboxField( "defergpu" );
140
		$html.= $params->insertCheckboxField( "no_keepstack" );
141
		$html.= $params->insertTextFieldInRow( "bin", $fieldSize );
142
		
143
		return $html;
144
	}	
145 1 Amber Herold
</pre>
146 7 Amber Herold
&nbsp;
147
# *If you have implemented "test single image" on the python side, add code to display the test results in your class extending BasicLoopForm*
148
&nbsp;
149
** You can use the getTestResults() function in autoMaskForm.inc as an example.
150
<pre>
151
	// getTestResults() should return the HTML code needed to display test results any way this method
152
	// prefers to have them displayed. The results will be placed below a printout of the test command and 
153
	// above the launch form. Note that an instance of this class is not required to use this function.
154
	static public function getTestResults( $outdir, $runname, $testfilename )
155
	{
156
...
157
</pre>
158
&nbsp;
159
# *Add a link to your page in the menuprocessing.php file or from another page*
160
&nbsp;
161
** The menuprocessing file is a bit tricky to work with.If you do not link to your page from there, look for the appropriate php page where your feature should launch from.
162 8 Amber Herold
** You will add a link to runAppionLoop.php and pass the experiment ID and the name of your new form class in the URL. Here are a couple of examples with the MakeDDStackForm class and the AutoMaskForm Class:
163 7 Amber Herold
<pre>
164
$ddStackform = "MakeDDStackForm";
165
'name'=>"<a href='runAppionLoop.php?expId=$sessionId&form=$ddStackform'>Create frame stack</a>",
166
</pre>
167
<pre>
168
$form = "AutoMaskForm";
169
echo "  <h3><a href='runAppionLoop.php?expId=$expId&form=$form'>Auto Masking</a></h3>\n";
170 1 Amber Herold
</pre>
171 8 Amber Herold
** Note that the name of the class MUST match the name of the PHP file that the class is defined in. So if you extended the BasicLoopForm to a class named CoolFeatureForm, the file where that class lives must be at myami/myamiweb/processing/inc/forms/coolFeatureForm.inc.
172 1 Amber Herold
&nbsp;
173 10 Amber Herold
# *Add installation instructions for any new 3rd party software required*
174
&nbsp;
175
** If this feature requires 3rd party software on the python side on the processing host, add directions for installing this software now. It should have a new wiki page under the [[Processing Server Installation]] instructions.
176 7 Amber Herold
&nbsp;