Filter Library Camera Interface Physics

ScanFilterMath.h

00001 /*
00002  * ScanFilterMath.h - math filter.
00003  *
00004  * This file is part of the Camera Filter Library.
00005  * Computer Aided Measurement Environment for Realtime Atomic imaging (Camera)
00006  *
00007  * Copyright (C) 2004-2005, Leiden Probe Microscopy.
00008  * Copyright (C) 2004-2005, Universiteit Leiden.
00009  *
00010  * Authors: M. Seynen (original), Martin J. Moene
00011  *
00012  * $Id: ScanFilterMath.h 270 2005-10-19 15:00:48Z moene $
00013  */
00014 
00015 #ifndef CFL_SCANFILTERMATH_H
00016 #define CFL_SCANFILTERMATH_H
00017 
00018 #if _MSC_VER > 1000
00019 #pragma once
00020 #endif // _MSC_VER > 1000
00021 
00022 #include <cfl/ScanFilter.h>             // for base class
00023 #include <cfl/ScanBaseBuffer.h>         // for ValueType
00024 
00025 /**
00026  * \addtogroup cfl_filtermath Math Filter
00027  * \brief add or subtract buffers.
00028  *
00029 
00030 <h3>Purpose</h3>
00031 
00032 <h3>Description</h3>
00033 
00034 <h3>Algorithm</h3>
00035 
00036 
00037 \f[
00038    \textrm{B} = \textrm{A}
00039 \f]
00040 
00041 <h3>Examples</h3>
00042 Try to find some interesting pictures for most filters.
00043 
00044 <h3>Contact</h3>
00045 Dipl.phys. M.J. Rost<br>
00046 Huygens Laboratorium<br>
00047 Universiteit Leiden<br>
00048 Niels Bohrweg 2<br>
00049 2333 CA Leiden, The Netherlands<br>
00050 <br>
00051 Tel: +31 71 5275600<br>
00052 Fax: +31 71 5275404<br>
00053 <br>
00054 E-mail: rost@physics.LeidenUniv.nl<br>
00055 Web: http://www.geocities.com/marcel_rost/<br>
00056 
00057  *
00058  * @{
00059  */
00060 
00061 DECLARE_CLASS( CScanFilterMath );         // create various types
00062 
00063 /**
00064  * \brief add or subtract buffers.
00065  *
00066  */
00067 class CScanFilterMath : public CScanFilter
00068 {
00069    /**
00070     * its dialog class.
00071     */
00072    friend class FilterDlg_Math;
00073 
00074 public:
00075    /**
00076     * the value type.
00077     */
00078    typedef CScanBaseBuffer::ValueType ValueType;
00079 
00080    /**
00081     * the pointer type.
00082     */
00083    typedef ValueType* Pointer;
00084 
00085    /**
00086     * the const pointer type.
00087     */
00088    typedef const ValueType* ConstPointer;
00089 
00090    /**
00091     * the size type.
00092     */
00093    typedef CSize SizeType;
00094 
00095    /**
00096     * the size element type.
00097     */
00098    typedef DWORD SizeElementType;
00099 
00100    /**
00101     * math types to perform.
00102     */
00103    enum MathOperationType
00104    {
00105       MATH_ADD,         ///< A + B
00106       MATH_SUBAB,       ///< A - B
00107       MATH_SUBBA,       ///< B - A
00108       MATH_MUL,         ///< A * B
00109    };
00110 
00111    ///
00112    /// \name Construction
00113    /// @{
00114 
00115    /**
00116     * default constructor.
00117     */
00118    CScanFilterMath();
00119 
00120    /**
00121     * destructor.
00122     */
00123    virtual ~CScanFilterMath();
00124 
00125    /// @}
00126    /// \name Camera--Filter Interface
00127    /// @{
00128 
00129    /**
00130     * \brief configure filter with settings as provided by the application on the
00131     * filterlist window (e.g. via registry); see also CScanFilterNull::ReadFilterSettings().
00132     */
00133    virtual void ReadFilterSettings( );
00134 
00135    /**
00136     * \brief save filter settings e.g. for use with the filterlist window (e.g. via registry);
00137     * see also ReadFilterSettings().
00138     */
00139    virtual void WriteFilterSettings( ) const;
00140 
00141    /**
00142     * provide current filter parameter(s) for filter-scripting capture
00143     * in the main application;
00144     * see also CScanFilterNull::GetParameters().
00145     */
00146    virtual LPCTSTR GetParameters() const;
00147 
00148    /**
00149     * set parameters for filter-script execution of filter; 
00150     * see also CScanFilterNull::SetParameters().
00151     */
00152    virtual BOOL SetParameters( LPCTSTR lpParameters );
00153 
00154    /**
00155     * start filter dialog to edit parameters; no filter operations;
00156     * see also CScanFilterNull::EditModeless().
00157     */
00158 //   virtual BOOL EditModeless( CWnd *pParentWnd );
00159 
00160    /**
00161     * create filter dialog and pre Apply() filter to view result;
00162     * see also CScanFilterNull::RunModeless().
00163     */
00164    virtual BOOL RunModeless( CWnd *pParentWnd, CDocument *pDoc );
00165 
00166    /**
00167     * check parameters, take care of a properly sized output buffer,
00168     * set its name and copy filter parameters and process;
00169     * see also CScanFilterNull::ApplyCore().
00170     */
00171    virtual BOOL Apply();
00172 
00173    /**
00174     * the number of input buffers is 2.
00175     */
00176    virtual DWORD GetNrOfInBuffers() const;
00177 
00178    /**
00179     * the requested input buffer.
00180     */
00181    virtual CScanBaseBuffer* GetInputBuffer( UINT nNr );
00182 
00183    /**
00184     * set the given input buffer.
00185     */
00186    virtual void SetInputBuffer( UINT nNr, CScanBaseBuffer *lpsbIn );
00187 
00188    /// @}
00189    /// \name Predicates
00190    /// @{
00191 
00192    /// @}
00193    /// \name Accessors
00194    /// @{
00195 
00196    MathOperationType GetMathOperation() const;
00197 
00198    /// @}
00199    /// \name Mutators
00200    /// @{
00201 
00202    void SetMathOperation( MathOperationType );
00203 
00204    /// @}
00205 
00206 public:
00207    /**
00208     * the filter name.
00209     */
00210    static LPCTSTR m_lpcsFilterName;
00211 
00212    /**
00213     * the class short filtername.
00214     */
00215    static LPCTSTR m_lpcsShortFilterName;
00216 
00217    /**
00218     * the default offset.
00219     */
00220    static const MathOperationType def_MathOperation;
00221 
00222 protected:
00223    /**
00224     * store or retrieve the object's settings.
00225     */
00226    virtual void Serialize( CArchive& ar );
00227    DECLARE_SERIAL( CScanFilterMath )
00228 
00229    /**
00230     * process the given frame part (L2R, R2L frame part).
00231     */
00232    void Process( ConstPointer in1, ConstPointer end1, ConstPointer in2, Pointer out );
00233 
00234 protected:
00235    /**
00236     * the second input buffer.
00237     */
00238    CScanBaseBuffer *m_lpsbIn2;
00239 
00240    /**
00241     * current math setting.
00242     */
00243    MathOperationType m_MathOperation;
00244 };
00245 
00246 /// @}  cfl_filtermath
00247 
00248 /**
00249  * the current offset.
00250  */
00251 inline CScanFilterMath::MathOperationType CScanFilterMath::GetMathOperation() const
00252 {
00253    return m_MathOperation;
00254 }
00255 
00256 /**
00257  * set the offset.
00258  */
00259 inline void CScanFilterMath::SetMathOperation( MathOperationType op )
00260 {
00261    m_MathOperation = op;
00262 }
00263 
00264 #endif // CFL_SCANFILTERMATH_H
00265 
00266 /*
00267  * end of file
00268  */
00269 

Camera Filter Library documentation © 2004-2007 by Leiden Probe Microscopy