Filter Library Camera Interface Physics

ScanFilter.h

00001 /*
00002  * ScanFilter.h - scan filter base class.
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, Leiden Probe Microscopy.
00008  * Copyright (C) 2004, Universiteit Leiden.
00009  *
00010  * Authors: M. Seynen (original), Martin J. Moene
00011  *
00012  * $Id: ScanFilter.h 382 2006-07-05 14:51:03Z moene $
00013  */
00014 
00015 #ifndef CFILTLIB_SCANFILTER_H
00016 #define CFILTLIB_SCANFILTER_H
00017 
00018 #if _MSC_VER > 1000
00019 #pragma once
00020 #endif // _MSC_VER > 1000
00021 
00022 /**
00023  * drag support type.
00024  */
00025 enum _eDragSupportType
00026 {
00027    SFDS_NONE = 0,       ///< no drag support
00028    SFDS_RECT,           ///< rectangular drag support
00029    SFDS_POINT           ///< point-wise drag support
00030 };
00031 
00032 /**
00033  * drag support type.
00034  */
00035 typedef _eDragSupportType DragSupportType;
00036 
00037 /**
00038  * Pi.
00039  */
00040 const double g_PI = 3.1415926535897932384626433832795;
00041 
00042 /**
00043  * two Pi.
00044  */
00045 const double g_2PI = 2.0 * g_PI;
00046 
00047 #define CAMERAFILTERFILE _T("Camera.CFiltLib")
00048 
00049 /**
00050  * base class for filters.
00051  *
00052  * Class CScanFilter is the base clas for the filters of the Camera Filter Library.
00053  *
00054  * \version 3.2 IMPORTANT: order of members has changed; affects main application.
00055  */
00056 
00057 class CScanFilter : public CObject
00058 {
00059    /**
00060     * class CFilterDlg requires access to m_lpsbIn and m_lpsbOut; instead we
00061     * also could use GetInputBuffer(0) and GetOutputBuffer(0); 
00062     * \todo remove friend class CFilterDlg requirement.
00063     */
00064    friend class CFilterDlg;
00065 
00066 public:
00067    /**
00068     * this type.
00069     */
00070    typedef short Self;
00071 
00072    /**
00073     * the class derived from.
00074     */
00075    typedef CObject Super;
00076 
00077    /**
00078     * the filter's size type.
00079     */
00080    typedef DWORD SizeType;
00081 
00082    ///
00083    /// \name Construction
00084    /// @{
00085 
00086    /**
00087     * default constructor.
00088     */
00089    CScanFilter();
00090 
00091    /**
00092     * destructor.
00093     */
00094    virtual ~CScanFilter();
00095 
00096    /// @}
00097    /// \name Predicates
00098    /// @{
00099 
00100    /**
00101     * default is to not support partial data; override if filter does support it.
00102     */
00103    virtual BOOL CanDoPartialData() const;
00104 
00105    /**
00106     * default is to support a dialog; override if filter does not support it.
00107     */
00108    virtual BOOL CanDoDialogEntry() const;
00109 
00110    /**
00111     * default is to not support dragging; override if filter does support it.
00112     */
00113    virtual DragSupportType SupportDragInput() const;
00114 
00115    /**
00116     * default is to not require a rectangular) selection before applying filter;
00117     * override if filter does require it.
00118     */
00119    virtual BOOL NeedRectSelection() const;
00120 
00121    /// @}
00122    /// \name Accessors
00123    /// @{
00124 
00125    /**
00126     * the name of this filter.
00127     */
00128    virtual LPCTSTR GetFilterName() const;
00129 
00130    /// @}
00131    /// \name Mutators
00132    /// @{
00133 
00134    /**
00135     * set the rectangular drag area for given L2R or R2L part of frame; override
00136     * for filters that support dragging.
00137     */
00138    virtual void SetDragInput( BOOL bL2R, CRect rcIn );
00139 
00140    /// @}
00141    /// \name Input Buffers
00142    /// @{
00143 
00144    /**
00145     * default is one input buffer; override of filter uses more.
00146     */
00147    virtual SizeType GetNrOfInBuffers() const;
00148 
00149    /**
00150     * provide the input buffer for the given index.
00151     */
00152    virtual CScanBaseBuffer* GetInputBuffer( UINT nNr );
00153 
00154    /**
00155     * set the input buffer for the given index.
00156     */
00157    virtual void SetInputBuffer( UINT nNr, CScanBaseBuffer* lpsbIn );
00158 
00159    /// @}
00160    /// \name Output Buffers
00161    /// @{
00162 
00163    /**
00164     * default is one output buffer; override of filter uses more.
00165     */
00166    virtual SizeType GetNrOfOutBuffers() const;
00167 
00168    /**
00169     * provide the output buffer for the given index.
00170     */
00171    virtual CScanBaseBuffer* GetOutputBuffer( UINT nNr );
00172 
00173    /**
00174     * set the output buffer for the given index.
00175     */
00176    virtual void SetOutputBuffer( UINT nNr, CScanBaseBuffer* lpsbOut );
00177 
00178    /// @}
00179    /// \name Filtering
00180    /// @{
00181 
00182    /**
00183     * true if a dialog is present.
00184     */
00185    virtual bool IsInteractive() const;
00186 
00187    /**
00188     * \brief configure filter with default setting or with settings as saved
00189     * from the last invocation (e.g. from registry).
00190     *
00191     * This method configures the filter with it's default values or, if available,
00192     * with the settings as saved from the last invocation.
00193     *
00194     * No filter configuration happens if the filter does not override this method.
00195     *
00196     * ReadFilterSettings() is usually called from the constructor of the filter.
00197     *
00198     * \version 3.2
00199     */
00200    virtual void ReadFilterSettings();
00201 
00202    /**
00203     * \brief save filter settings e.g. for use with the filterlist window
00204     * (e.g. via registry).
00205     *
00206     * WriteFilterSettings() is called from the filter dialog's OnOK message handler.
00207     *
00208     * \version 3.2
00209     */
00210    virtual void WriteFilterSettings() const;
00211 
00212    /**
00213     * provode current filter parameter(s) for filter-scripting capture
00214     * in the main application.
00215     *
00216     * Analogous to GetInitParameters(), this method returns filter parameters, in
00217     * this case for the filter-scripting capture operation in the main application.
00218     *
00219     * \return C-string with parameter values, e.g. "1.23,4.56"
00220     * \see GetInitParameters().
00221     * \note caller is responsible for \c delete-ing returned string storage.
00222     */
00223    virtual LPCTSTR GetParameters() const;
00224 
00225    /**
00226     * set parameters for filter-script execution of filter; may throw _T("message").
00227     *
00228     * This method initializes the filter parameters for filter-script execution of
00229     * the filter to the given parameters.
00230     *
00231     * \param lpParameters a C-string specifying the filter parameter values, e.g. "1.23,4.56".
00232     * \return TRUE (Success), FALSE (Failure)
00233     * \throw C-string if the filter does not support this operation, this method may throw _T("message");
00234     */
00235    virtual BOOL SetParameters( LPCTSTR lpParameters );
00236 
00237    /**
00238     * start filter dialog, allow for user input but do not perform filter operations;
00239     * default implementation: return FALSE.
00240     */
00241    virtual BOOL EditModeless( CWnd *pParentWnd );
00242 
00243    /**
00244     * start filter dialog, allow for user input and perform filter operations;
00245     * default implementation: return FALSE.
00246     */
00247    virtual BOOL RunModeless( CWnd *pParentWnd, CDocument *pDoc );
00248 
00249    /**
00250     * perform the filter operation without user interaction; also used to
00251     * process series of buffers.
00252     */
00253    virtual BOOL Apply();
00254 
00255    /// @} Filtering
00256 
00257 protected:
00258    /**
00259     * set parameters for filter-script execution of filter; may throw _T("message").
00260     *
00261     * This method initializes the filter parameters for filter-script execution of
00262     * the filter toe the parameters specified.
00263     *
00264     * \param lpParameters a C-string specifying the filter parameter values, e.g. "1.23,4.56".
00265     * \return TRUE (Success), FALSE (Failure)
00266     * \throw C-string if the filter does not support this operation, this method may throw _T("message");
00267     */
00268    virtual void Serialize(CArchive &ar);
00269 
00270    /**
00271     * implement the serialization.
00272     */
00273    DECLARE_SERIAL(CScanFilter)
00274 
00275 private:
00276    ///
00277    /// \name Prohibited
00278    /// @{
00279 
00280    /**
00281     * prevent copy-assignment; virtual destructor requires canonical form
00282     * \ref coplien_1991 "[Coplien]".
00283     */
00284    CScanFilter( const Self& rhs );
00285 
00286    /**
00287     * prevent assignment; virtual destructor requires canonical form
00288     * \ref coplien_1991 "[Coplien]".
00289     */
00290    Self& operator= ( const Self& rhs );
00291 
00292    /// @}
00293 
00294 protected:
00295    /**
00296     * the filter dialog.
00297     */
00298    CDialog* m_pDlg;
00299 
00300    /**
00301     * FIXME: the filter view.
00302     */
00303    CView* m_pView;
00304 
00305    /**
00306     * the (first) input buffer.
00307     */
00308    CScanBaseBuffer *m_lpsbIn;
00309 
00310    /**
00311     * the (first) output buffer.
00312     */
00313    CScanBaseBuffer *m_lpsbOut;
00314 
00315    /**
00316     * the class filtername (orig.comment: saves memory (???mo) ).
00317     */
00318    static LPCTSTR m_lpcsFilterName;
00319 
00320    /**
00321     * the class short filtername.
00322     */
00323    static LPCTSTR m_lpcsShortFilterName;
00324 
00325    /**
00326     * the individual filtername.
00327     */
00328    LPCTSTR m_csFilterName;
00329 
00330    /**
00331     * a non-intersecting rectangle.
00332     */
00333    static const CRect NonIntersectingRect;
00334 };
00335 
00336 /* -----------------------------------------------------------------------
00337 ** inline methods:
00338 */
00339 
00340 /* -----------------------------------------------------------------------
00341 ** other:
00342 */
00343 
00344 /**
00345  * type to support the export of filters to from the FilterLib to the main program.
00346  */
00347 struct _tFilterList
00348 {
00349    BOOL           bHasEditModeless;     ///< the filter supports EditModeless dialog
00350    BOOL           bIsOnlineFilter;      ///< the filter can be used as an online filter
00351    BOOL           bIsViewingFilter;     ///< the filter can be used as a viewing filter
00352    BOOL           bIsInteractiveFilter; ///< include the filter in the filter menu
00353    LPCTSTR        lpcsFilterMenuName;   ///< the filter menu name
00354    LPCTSTR        lpcsFilterName;       ///< the filter name
00355    CRuntimeClass* lpRuntimeClass;       ///< the filter class
00356 };
00357 
00358 /**
00359  * the filter list type.
00360  */
00361 typedef _tFilterList FilterListType;
00362 
00363 /**
00364  * the product name.
00365  */
00366 extern LPCTSTR GetFilterLibraryName();
00367 
00368 /**
00369  * the product description.
00370  */
00371 extern LPCTSTR GetFilterLibraryDescription();
00372 
00373 /**
00374  * the product version string.
00375  */
00376 extern LPCTSTR GetFilterLibraryVersionString();
00377 
00378 /**
00379  * \deprecated replaced by GetTotalNumberOfFilters(); 
00380  * the number of available filters: all or filters with EditModeless capability only.
00381  */
00382 extern int GetNumberOfFilters( BOOL bEditModelessFiltersOnly );
00383 
00384 /**
00385  * \deprecated replaced by GetXXXFilters() for various XXX;
00386  * interface to main application to communicate about the available filters.
00387  */
00388 extern BOOL GetScanDataFilters( DWORD& dwNrOfFilters, _tFilterList* lpList, BOOL bEditModelessFiltersOnly );
00389 
00390 /**
00391  * the number of available filters: online, viewing and other filters.
00392  */
00393 extern int GetTotalNumberOfFilters();
00394 
00395 /**
00396  * the number of filters that implement EditModeless().
00397  */
00398 extern int GetNumberOfEditModelessFilters();
00399 
00400 /**
00401  * the number of online filters.
00402  */
00403 extern int GetNumberOfOnlineFilters();
00404 
00405 /**
00406  * the number of viewing filters.
00407  */
00408 extern int GetNumberOfViewingFilters();
00409 
00410 /**
00411  * the number of filters in the filter menu.
00412  */
00413 extern int GetNumberOfInteractiveFilters();
00414 
00415 /**
00416  * obtain all filters: online, viewing and other filters;
00417  * reports actual number of filters obtained in count.
00418  */
00419 extern BOOL GetAllFilters( FilterListType* lpList, DWORD& count );
00420 
00421 /**
00422  * obtain online filters;
00423  * reports actual number of filters obtained in count.
00424  */
00425 extern BOOL GetEditModelessFilters( FilterListType* lpList, DWORD& count );
00426 
00427 /**
00428  * obtain online filters;
00429  * reports actual number of filters obtained in count.
00430  */
00431 extern BOOL GetOnlineFilters( FilterListType* lpList, DWORD& count );
00432 
00433 /**
00434  * obtain viewing filters;
00435  * reports actual number of filters obtained in count.
00436  */
00437 extern BOOL GetViewingFilters( FilterListType* lpList, DWORD& count );
00438 
00439 /**
00440  * obtain interactive filters;
00441  * reports actual number of filters obtained in count.
00442  */
00443 extern BOOL GetInteractiveFilters( FilterListType* lpList, DWORD& count );
00444 
00445 /**
00446  * obtain an image shift calculator object.
00447  */
00448 extern CRuntimeClass* GetImageShiftCalculator();
00449 
00450 #endif // ifndef CFILTLIB_SCANFILTER_H
00451 
00452 /*
00453  * end of file
00454  */
00455 

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