Project

General

Profile

Refine Refactor documentation » History » Version 8

Dmitry Lyumkis, 08/01/2011 12:36 PM

1 8 Dmitry Lyumkis
h1. Refinement Refactor documentation
2 2 Amber Herold
3 5 Amber Herold
h2. Sequence Diagram
4
5
The following sequence diagram shows how the Form and Parameter classes work together to display a form, validate the user input, and create a command string.
6
7 3 Amber Herold
!refine_sequence_diagram.png!
8 5 Amber Herold
9
h2. Class Diagram
10
11
The following class diagram shows the BasicForm class with it's extended classes as well as the FormParameter class and it's extended classes.
12
It also shows associations among the classes.
13
Notice that the specific refine parameter classes use polymorphism to override the validate() function. This allows the extended classes to provide more complex validations than a typical form requires.
14
Other forms, such as RunParameters and stack prep, just use the base FormParameters class that their parent, BasicForm, uses.
15 4 Amber Herold
16
!refineClassDiagram.png!
17 6 Amber Herold
18
h2. Steps to add a new refinement method to the pipeline
19
20
# Create a new class which extends BasicRefineForm
21
# Create a new class which extends RefineFormParameters. This is optional, but recommended.
22
# Decide what information you need to collect from the user and add a form parameter for each item.
23
## example: adding parameters to a new parameter class
24
### note that the parent constuctor is called first, passing any default values along. The RefineFormParameters base class defines parameters that are common to most refinement methods. You only need to add parameters that are not already defined in the base class.
25
### use the addParam(name, value, label) method to add parameters specific to your refine method to your form.
26
### if you find that the base class includes a parameter that your method does not need, you can remove the parameter from the form with the hideParam(name) method.
27
<pre>
28
class XmippParams extends RefineFormParameters
29
{
30
	function __construct( $id='', $label='', $outerMaskRadius='', $innerMaskRadius='', $outerAlignRadius='', 
31
							$innerAlignRadius='', $symmetry='', $numIters='', $angSampRate='', $percentDiscard='',  
32
							$filterEstimated='', $filterResolution='', $filterComputed='', $filterConstant='',
33
							$mask='', $maxAngularChange='', $maxChangeOffset='', $search5DShift='', $search5DStep='',
34
							$reconMethod='', $ARTLambda='', $doComputeResolution='', $fourierMaxFrequencyOfInterest='' ) 
35
	{
36
		parent::__construct($id, $label, $outerMaskRadius, $innerMaskRadius, $outerAlignRadius, 
37
							$innerAlignRadius, $symmetry, $numIters, $angSampRate, $percentDiscard,  
38
							$filterEstimated, $filterResolution, $filterComputed, $filterConstant );
39
									
40
		$this->addParam( "mask", $mask, "Mask filename" );
41
		$this->addParam( "maxAngularChange", $maxAngularChange, "Max. Angular change " );		
42
		$this->addParam( "maxChangeOffset", $maxChangeOffset, "Maximum change offset " );
43
		$this->addParam( "search5DShift", $search5DShift, "Search range for 5D translational search " );
44
		$this->addParam( "search5DStep", $search5DStep, "Step size for 5D translational search " );
45
		$this->addParam( "reconMethod", $reconMethod, "Reconstruction method " );
46
		$this->addParam( "ARTLambda", $ARTLambda, "Values of lambda for ART " );
47
		$this->addParam( "doComputeResolution", $doComputeResolution, "Compute resolution? " );
48
		$this->addParam( "fourierMaxFrequencyOfInterest", $fourierMaxFrequencyOfInterest, "Initial maximum frequency used by reconstruct fourier " );
49
		
50
		// disable any general params that do not apply to this method
51
		$this->hideParam("innerMaskRadius");		
52
	}
53
	
54
	function validate() 
55
	{
56
		$msg = parent::validate();
57
58
		if ( !empty($this->params["mask"]["value"]) && !empty($this->params["outerMaskRadius"]["value"]) )
59
			$msg .= "<b>Error:</b> You may not define both the outer mask raduis and a mask file.";
60
				
61
		return $msg;
62
	}
63
}
64
</pre>
65 7 Amber Herold
## example: adding parameters to the form constructor method
66
# define any restrictions that should be applied to the parameters.