Filter Library Camera Interface Physics

ScanFilter.cpp

00001 /*
00002  * ScanFilter.cpp - 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.cpp 190 2005-05-04 15:08:00Z moene $
00013  */
00014 
00015 #include "stdafx.h"                     // for common (pre-compiled) headers
00016 //#include <cfl/stdafx.h>                 // for common (pre-compiled) headers
00017 #include <cfl/resource.h>               // for messages and other resources
00018 
00019 #include <Camera/InterfaceDll.h>        // Camera--Filter Library interface
00020 #include <cfl/ScanBaseBuffer.h>         // for class CScanBaseBuffer
00021 #include <cfl/ScanFilter.h>             // header
00022 
00023 #include <cfl/FilterDlg.h>              // for class CFilterDlg
00024 
00025 #ifdef _DEBUG
00026 #undef THIS_FILE
00027 static char THIS_FILE[]=__FILE__;
00028 #define new DEBUG_NEW
00029 #endif
00030 
00031 LPCTSTR CScanFilter::m_lpcsFilterName = _T("BASECLASS");
00032                                         // this filter's short name
00033 LPCTSTR CScanFilter::m_lpcsShortFilterName = CScanFilter::m_lpcsFilterName;
00034 
00035 IMPLEMENT_SERIAL( CScanFilter, CObject, 0 )
00036 
00037 /**
00038  * a non-intersecting rectangle.
00039  */
00040 const CRect CScanFilter::NonIntersectingRect = CRect( -1, -1, -2, -2 );
00041 
00042 /*
00043  * default constructor.
00044  */
00045 CScanFilter::CScanFilter() :
00046    m_pDlg        ( NULL ),
00047    m_lpsbIn      ( NULL ),
00048    m_lpsbOut     ( NULL ),
00049    m_csFilterName( m_lpcsFilterName )
00050 //   m_bInEditModeless( false )                 // FIXME: kan bee removed
00051 {
00052    ; // do nothing
00053 }
00054 
00055 /*
00056  * destructor; clean-up the dialog if it exists.
00057  */
00058 CScanFilter::~CScanFilter()
00059 {
00060    if ( m_pDlg )
00061    {
00062       m_pDlg->DestroyWindow();
00063       delete m_pDlg; m_pDlg = 0;
00064    }
00065 }
00066 
00067 /*
00068  * default is to not support partial data; override if filter does support it.
00069  */
00070 BOOL CScanFilter::CanDoPartialData() const
00071 {
00072    return FALSE;
00073 }
00074 
00075 /**
00076  * default is to support a dialog; override if filter does not support it.
00077  */
00078 BOOL CScanFilter::CanDoDialogEntry() const
00079 {
00080    return TRUE;
00081 }
00082 
00083 /**
00084  * default is to not support dragging; override if filter does support it.
00085  */
00086 DragSupportType CScanFilter::SupportDragInput() const
00087 {
00088    return SFDS_NONE;
00089 }
00090 
00091 /*
00092  * default is to not require a rectangular) selection before applying filter;
00093  * override if filter does require it.
00094  */
00095 BOOL CScanFilter::NeedRectSelection() const
00096 {
00097    return FALSE;
00098 }
00099 
00100 /*
00101  * the name of this filter.
00102  */
00103 LPCTSTR CScanFilter::GetFilterName() const
00104 {
00105    return m_csFilterName;
00106 }
00107 
00108 #pragma warning( push )
00109 #pragma warning( disable : 4100 )       // unreferenced formal parameter
00110 
00111 /*
00112  * set the rectangular drag area for given L2R or R2L part of frame; override
00113  * for filters that support dragging.
00114  */
00115 void CScanFilter::SetDragInput( BOOL bL2R, CRect rcIn )
00116 {
00117    return;
00118 }
00119 
00120 /*
00121  * default is one input buffer; override of filter uses more.
00122  */
00123 CScanFilter::SizeType CScanFilter::GetNrOfInBuffers() const
00124 {
00125    return 1;
00126 }
00127 
00128 /*
00129  * provide the input buffer for the given index.
00130  */
00131 CScanBaseBuffer *CScanFilter::GetInputBuffer( UINT nNr )
00132 {
00133    Q_ASSERT(  nNr == 0 && "buffernr. can only be zero" );
00134 
00135    return m_lpsbIn;
00136 }
00137 
00138 /*
00139  * set the input buffer for the given index.
00140  */
00141 void CScanFilter::SetInputBuffer( UINT nNr, CScanBaseBuffer *lpsbIn )
00142 {
00143    Q_ASSERT(  nNr == 0      && "input buffer nr. can only be zero" );
00144    Q_ASSERT( NULL != lpsbIn && "valid buffer required"             );
00145 
00146    m_lpsbIn = lpsbIn;
00147 }
00148 
00149 /*
00150  * default is one output buffer; override of filter uses more.
00151  */
00152 CScanFilter::SizeType CScanFilter::GetNrOfOutBuffers() const
00153 {
00154    return 1;
00155 }
00156 
00157 /*
00158  * provide the output buffer for the given index.
00159  */
00160 CScanBaseBuffer *CScanFilter::GetOutputBuffer( UINT nNr )
00161 {
00162    return m_lpsbOut;
00163 }
00164 
00165 /*
00166  * set the output buffer for the given index.
00167  */
00168 void CScanFilter::SetOutputBuffer( UINT nNr, CScanBaseBuffer *lpsbOut )
00169 {
00170    Q_ASSERT(  nNr == 0       && "output buffer nr. can only be zero" );
00171    Q_ASSERT( NULL != lpsbOut && "valid buffer required"              );
00172 
00173    m_lpsbOut = lpsbOut;
00174 }
00175 
00176 /*
00177  * true if a dialog is present
00178  */
00179 bool CScanFilter::IsInteractive() const
00180 {
00181    return NULL != m_pDlg;
00182 }
00183 
00184 /*
00185  * configure filter with default setting or with settings as saved from the
00186  * last invocation (e.g. from registry).
00187  */
00188 void CScanFilter::ReadFilterSettings ()
00189 {
00190    ; // do nothing
00191 }
00192 
00193 /*
00194  * save filter settings e.g. for use with the filterlist window (e.g. via registry).
00195  */
00196 void CScanFilter::WriteFilterSettings () const
00197 {
00198    ; // do nothing
00199 }
00200 
00201 /*
00202  * baseclass can't do this. It should be handled by the derived class.
00203  * Make sure your filter handles these functions.
00204  */
00205 LPCTSTR CScanFilter::GetParameters() const
00206 {
00207    Q_ASSERT( 0 && "CScanFilter::GetParameters() must be overridden" );
00208    return NULL;
00209 }
00210 
00211 /*
00212  * baseclass can't do this. It should be handled by the derived class.
00213  * Make sure your filter handles these functions.
00214  */
00215 BOOL CScanFilter::SetParameters( LPCTSTR lpParameters )
00216 {
00217    Q_ASSERT( 0 && "CScanFilter::SetParameters() must be overridden" );
00218    return FALSE;
00219 }
00220 
00221 /*
00222  * start filter dialog, allow for user input but do not perform filter operations;
00223  * default implementation: return FALSE.
00224  */
00225 BOOL CScanFilter::EditModeless( CWnd* pParentWnd )
00226 {
00227    return FALSE;
00228 }
00229 
00230 /*
00231  * start filter dialog, allow for user input and perform filter operations;
00232  * default implementation: return FALSE.
00233  */
00234 BOOL CScanFilter::RunModeless( CWnd* pParentWnd, CDocument* pDoc )
00235 {
00236    return FALSE;
00237 }
00238 
00239 #pragma warning( pop )
00240 
00241 /*
00242  * perform the filter operation without user interaction; also used to process
00243  * series of buffers.
00244  */
00245 BOOL CScanFilter::Apply()
00246 {
00247    Q_ASSERT( NULL != m_lpsbIn  && "CScanFilter::Apply(): valid input buffer required" );
00248    Q_ASSERT( NULL != m_lpsbOut && "CScanFilter::Apply(): valid output buffer required" );
00249 
00250 //    /*
00251 //     * default Filter behavior is a simple copy function: the scan data is not copied!
00252 //     * copying of the latter should be done in the derived class.
00253 //     */
00254 //
00255 //    m_lpsbOut->CreateOutputBufferFor( *m_lpsbIn );
00256 //    m_lpsbOut->m_dwParameterMask  = 0;                           // Recalculate all temp variables
00257 
00258    return TRUE;
00259 }
00260 
00261 /*
00262  * save or restore filter from archive.
00263  */
00264 void CScanFilter::Serialize( CArchive& ar )
00265 {
00266    CObject::Serialize( ar );
00267 
00268    if( ar.IsStoring() )
00269    {
00270    }
00271    else
00272    {
00273    }
00274 };
00275 
00276 /*
00277  * end of file
00278  */
00279 

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