Project

General

Profile

Actions

Refine Refactor documentation » History » Revision 9

« Previous | Revision 9/32 (diff) | Next »
Amber Herold, 08/02/2011 05:17 PM


Refinement Refactor documentation

Sequence Diagram

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.

GUI sequence diagram

Class Diagram

The following class diagram shows the BasicForm class with it's extended classes as well as the FormParameter class and it's extended classes.
It also shows associations among the classes.
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.
Other forms, such as RunParameters and stack prep, just use the base FormParameters class that their parent, BasicForm, uses.

refine class diagram

Steps to add a new refinement method to the pipeline

  1. Create a new class which extends BasicRefineForm
  2. Create a new class which extends RefineFormParameters. This is optional, but recommended.
  3. Decide what information you need to collect from the user and add a form parameter for each item.
    1. example: adding parameters to a new parameter class
      1. 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.
      2. use the addParam(name, value, label) method to add parameters specific to your refine method to your form.
      3. 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.
        class XmippParams extends RefineFormParameters
        {
            function __construct( $id='', $label='', $outerMaskRadius='', $innerMaskRadius='', $outerAlignRadius='', 
                                    $innerAlignRadius='', $symmetry='', $numIters='', $angSampRate='', $percentDiscard='',  
                                    $filterEstimated='', $filterResolution='', $filterComputed='', $filterConstant='',
                                    $mask='', $maxAngularChange='', $maxChangeOffset='', $search5DShift='', $search5DStep='',
                                    $reconMethod='', $ARTLambda='', $doComputeResolution='', $fourierMaxFrequencyOfInterest='' ) 
            {
                parent::__construct($id, $label, $outerMaskRadius, $innerMaskRadius, $outerAlignRadius, 
                                    $innerAlignRadius, $symmetry, $numIters, $angSampRate, $percentDiscard,  
                                    $filterEstimated, $filterResolution, $filterComputed, $filterConstant );
        
                $this->addParam( "mask", $mask, "Mask filename" );
                $this->addParam( "maxAngularChange", $maxAngularChange, "Max. Angular change " );        
                $this->addParam( "maxChangeOffset", $maxChangeOffset, "Maximum change offset " );
                $this->addParam( "search5DShift", $search5DShift, "Search range for 5D translational search " );
                $this->addParam( "search5DStep", $search5DStep, "Step size for 5D translational search " );
                $this->addParam( "reconMethod", $reconMethod, "Reconstruction method " );
                $this->addParam( "ARTLambda", $ARTLambda, "Values of lambda for ART " );
                $this->addParam( "doComputeResolution", $doComputeResolution, "Compute resolution? " );
                $this->addParam( "fourierMaxFrequencyOfInterest", $fourierMaxFrequencyOfInterest, "Initial maximum frequency used by reconstruct fourier " );
        
                // disable any general params that do not apply to this method
                $this->hideParam("innerMaskRadius");        
            }
        
            function validate() 
            {
                $msg = parent::validate();
        
                if ( !empty($this->params["mask"]["value"]) && !empty($this->params["outerMaskRadius"]["value"]) )
                    $msg .= "<b>Error:</b> You may not define both the outer mask raduis and a mask file.";
        
                return $msg;
            }
        }
        
    2. example: adding parameters to the form constructor method
  4. define any restrictions that should be applied to the parameters.
  5. Override the advancedParamForm() function to add a user input field for each one.
  6. Override the buildCommand() function. There is a default implementation available which adds all form parameters as --<name>=<value>.

Updated by Amber Herold over 13 years ago · 9 revisions