** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: procsignal.cpp,v 1.19 2001/01/12 16:41:56 kevin Exp $
+** $Id: procsignal.cpp,v 1.20 2001/01/12 21:53:27 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
// ProcessSignal
//
ProcessSignal::ProcessSignal (const char* szFilterName, const char* szFilterMethodName, double dBandwidth,
- double dSignalIncrement, int nSignalPoints, double dFilterParam, const char* szDomainName,
- const char* szFilterGenerationName, int iZeropad, int iPreinterpolationFactor, int iTraceLevel,
- int iGeometry, double dFocalLength, SGP* pSGP)
-: m_adFourierCosTable(NULL), m_adFourierSinTable(NULL), m_adFilter(NULL), m_fail(false)
+ double dSignalIncrement, int nSignalPoints, double dFilterParam, const char* szDomainName,
+ const char* szFilterGenerationName, int iZeropad, int iPreinterpolationFactor, int iTraceLevel,
+ int iGeometry, double dFocalLength, SGP* pSGP)
+ : m_adFourierCosTable(NULL), m_adFourierSinTable(NULL), m_adFilter(NULL), m_fail(false)
{
m_idFilterMethod = convertFilterMethodNameToID (szFilterMethodName);
if (m_idFilterMethod == FILTER_METHOD_INVALID) {
}
init (m_idFilter, m_idFilterMethod, dBandwidth, dSignalIncrement, nSignalPoints, dFilterParam, m_idDomain,
- m_idFilterGeneration, iZeropad, iPreinterpolationFactor, iTraceLevel, iGeometry, dFocalLength, pSGP);
+ m_idFilterGeneration, iZeropad, iPreinterpolationFactor, iTraceLevel, iGeometry, dFocalLength, pSGP);
}
void
ProcessSignal::init (const int idFilter, const int idFilterMethod, double dBandwidth, double dSignalIncrement,
- int nSignalPoints, double dFilterParam, const int idDomain, const int idFilterGeneration,
- const int iZeropad, const int iPreinterpolationFactor, int iTraceLevel, int iGeometry,
- double dFocalLength, SGP* pSGP)
+ int nSignalPoints, double dFilterParam, const int idDomain, const int idFilterGeneration,
+ const int iZeropad, const int iPreinterpolationFactor, int iTraceLevel, int iGeometry,
+ double dFocalLength, SGP* pSGP)
{
int i;
m_idFilter = idFilter;
m_adFilter = new double[ m_nFilterPoints ];
double* adFrequencyFilter = new double [m_nFilterPoints];
filter.copyFilterData (adFrequencyFilter, 0, m_nFilterPoints);
-#ifdef HAVE_SGP
- EZPlot* pEZPlot = NULL;
- if (pSGP && m_traceLevel >= Trace::TRACE_PLOT) {
- pEZPlot = new EZPlot ();
- pEZPlot->ezset ("title Filter Response: Natural Order");
- pEZPlot->ezset ("ylength 0.25");
- pEZPlot->addCurve (adFrequencyFilter, m_nFilterPoints);
- pEZPlot->plot (pSGP);
+#if defined(HAVE_WXWINDOWS) && (defined(DEBUG) || defined(_DEBUG))
+ EZPlotDialog* pEZPlotDlg = NULL;
+ if (g_bRunningWXWindows && m_traceLevel > 0) {
+ EZPlotDialog dlgEZPlot;
+ dlgEZPlot.getEZPlot()->ezset ("title Filter Response: Natural Order");
+ dlgEZPlot.getEZPlot()->addCurve (adFrequencyFilter, m_nFilterPoints);
+ dlgEZPlot.ShowModal();
}
#endif
Fourier::shuffleNaturalToFourierOrder (adFrequencyFilter, m_nFilterPoints);
#ifdef HAVE_SGP
- if (pEZPlot && m_traceLevel >= Trace::TRACE_PLOT) {
- pEZPlot->ezset ("title Filter Response: Fourier Order");
- pEZPlot->ezset ("ylength 0.25");
- pEZPlot->ezset ("yporigin 0.25");
- pEZPlot->addCurve (adFrequencyFilter, m_nFilterPoints);
- pEZPlot->plot (pSGP);
+ if (g_bRunningWXWindows && m_traceLevel > 0) {
+ EZPlotDialog dlgEZPlot;
+ dlgEZPlot.getEZPlot()->ezset ("title Filter Response: Fourier Order");
+ dlgEZPlot.getEZPlot()->addCurve (adFrequencyFilter, m_nFilterPoints);
+ dlgEZPlot.ShowModal();
}
#endif
ProcessSignal::finiteFourierTransform (adFrequencyFilter, m_adFilter, m_nFilterPoints, FORWARD);
delete adFrequencyFilter;
-#ifdef HAVE_SGP
- if (pEZPlot && m_traceLevel >= Trace::TRACE_PLOT) {
- pEZPlot->ezset ("title Inverse Fourier Frequency: Fourier Order");
- pEZPlot->ezset ("ylength 0.25");
- pEZPlot->ezset ("yporigin 0.50");
- pEZPlot->addCurve (m_adFilter, m_nFilterPoints);
- pEZPlot->plot (pSGP);
+#if defined(HAVE_WXWINDOWS) && (defined(DEBUG) || defined(_DEBUG))
+ if (g_bRunningWXWindows && m_traceLevel > 0) {
+ EZPlotDialog dlgEZPlot;
+ dlgEZPlot.getEZPlot()->ezset ("title Inverse Fourier Frequency: Fourier Order");
+ dlgEZPlot.getEZPlot()->addCurve (m_adFilter, m_nFilterPoints);
+ dlgEZPlot.ShowModal();
}
#endif
Fourier::shuffleFourierToNaturalOrder (m_adFilter, m_nFilterPoints);
-#ifdef HAVE_SGP
- if (pEZPlot && m_traceLevel >= Trace::TRACE_PLOT) {
- pEZPlot->ezset ("title Inverse Fourier Frequency: Natural Order");
- pEZPlot->ezset ("ylength 0.25");
- pEZPlot->ezset ("yporigin 0.75");
- pEZPlot->addCurve (m_adFilter, m_nFilterPoints);
- pEZPlot->plot (pSGP);
- delete pEZPlot;
+#if defined(HAVE_WXWINDOWS) && (defined(DEBUG) || defined(_DEBUG))
+ if (g_bRunningWXWindows && m_traceLevel > 0) {
+ EZPlotDialog dlgEZPlot;
+ dlgEZPlot.getEZPlot()->ezset ("title Inverse Fourier Frequency: Natural Order");
+ dlgEZPlot.getEZPlot()->addCurve (m_adFilter, m_nFilterPoints);
+ dlgEZPlot.ShowModal();
}
#endif
for (i = 0; i < m_nFilterPoints; i++) {
} else if (m_idGeometry == Scanner::GEOMETRY_EQUIANGULAR) {
for (i = 0; i < m_nFilterPoints; i++) {
int iDetFromZero = i - ((m_nFilterPoints - 1) / 2);
- double sinScale = sin (iDetFromZero * m_dSignalInc);
- if (fabs(sinScale) < 1E-7)
- sinScale = 1;
- else
- sinScale = (iDetFromZero * m_dSignalInc) / sinScale;
+ double sinScale = 1 / SignalFilter::sinc (iDetFromZero * m_dSignalInc);
double dScale = 0.5 * sinScale * sinScale;
m_adFilter[i] *= dScale;
}
+#if defined(HAVE_WXWINDOWS) && (defined(DEBUG) || defined(_DEBUG))
+ if (g_bRunningWXWindows && m_traceLevel > 0) {
+ EZPlotDialog dlgEZPlot;
+ dlgEZPlot.getEZPlot()->ezset ("title Scaled Inverse Fourier Frequency: Natural Order");
+ dlgEZPlot.getEZPlot()->addCurve (m_adFilter, m_nFilterPoints);
+ dlgEZPlot.ShowModal();
+ }
+#endif
} // if (geometry)
} // if (spatial filtering)
nextPowerOf2++;
nextPowerOf2 += (m_iZeropad - 1);
m_nFilterPoints = 1 << nextPowerOf2;
-#ifdef DEBUG
+#if defined(DEBUG) || defined(_DEBUG)
if (m_traceLevel >= Trace::TRACE_CONSOLE)
- std::cout << "nFilterPoints = " << m_nFilterPoints << endl;
+ sys_error (ERR_TRACE, "nFilterPoints = %d", m_nFilterPoints);
#endif
}
m_nOutputPoints = m_nFilterPoints * m_iPreinterpolationFactor;
}
SignalFilter filter (m_idFilter, m_dFilterMin, m_dFilterMax, m_nFilterPoints, m_dBandwidth,
- m_dFilterParam, SignalFilter::DOMAIN_FREQUENCY);
+ m_dFilterParam, SignalFilter::DOMAIN_FREQUENCY);
m_adFilter = new double [m_nFilterPoints];
filter.copyFilterData (m_adFilter, 0, m_nFilterPoints);
- // This doesn't work!
- // Need to add filtering for divergent geometries & Frequency/Direct filtering
- // Jan 2001: Direct seems to work for equilinear and equiangular
- // however, inverse_fourier doesn't work for equiangular on all versions of CTSim tested
+#if defined(HAVE_WXWINDOWS) && (defined(DEBUG) || defined(_DEBUG))
+ if (g_bRunningWXWindows && m_traceLevel > 0) {
+ EZPlotDialog dlgEZPlot;
+ dlgEZPlot.getEZPlot()->ezset ("title Frequency Filter: Natural Order");
+ dlgEZPlot.getEZPlot()->addCurve (m_adFilter, m_nFilterPoints);
+ dlgEZPlot.ShowModal();
+ }
+#endif
+ // This doesn't work: Need to add filtering for divergent geometries & Frequency/Direct filtering
+ // Jan 2001: Direct seems to work for equilinear and equiangular
+ // however, inverse_fourier doesn't work for equiangular on all versions of CTSim tested
+ // Scaling is done with data in frequency space, natural order
if (m_idGeometry == Scanner::GEOMETRY_EQUILINEAR) {
for (i = 0; i < m_nFilterPoints; i++)
m_adFilter[i] *= 0.5;
} else if (m_idGeometry == Scanner::GEOMETRY_EQUIANGULAR) {
for (i = 0; i < m_nFilterPoints; i++) {
int iDetFromZero = i - ((m_nFilterPoints - 1) / 2);
- double sinScale = sin (iDetFromZero * m_dSignalInc);
- if (fabs(sinScale) < 1E-7)
- sinScale = 1;
- else
- sinScale = (iDetFromZero * m_dSignalInc) / sinScale;
+ double sinScale = 1 / SignalFilter::sinc (iDetFromZero * m_dSignalInc);
double dScale = 0.5 * sinScale * sinScale;
m_adFilter[i] *= dScale;
}
}
-#ifdef HAVE_SGP
- EZPlot* pEZPlot = NULL;
- if (pSGP && m_traceLevel >= Trace::TRACE_PLOT) {
- pEZPlot = new EZPlot;
- pEZPlot->ezset ("title Filter Filter: Natural Order");
- pEZPlot->ezset ("ylength 0.50");
- pEZPlot->ezset ("yporigin 0.00");
- pEZPlot->addCurve (m_adFilter, m_nFilterPoints);
- pEZPlot->plot (pSGP);
+#if defined(HAVE_WXWINDOWS) && (defined(DEBUG) || defined(_DEBUG))
+ if (g_bRunningWXWindows && m_traceLevel > 0) {
+ EZPlotDialog dlgEZPlot;
+ dlgEZPlot.getEZPlot()->ezset ("title Filter Geometry Scaled: Natural Order");
+ dlgEZPlot.getEZPlot()->addCurve (m_adFilter, m_nFilterPoints);
+ dlgEZPlot.ShowModal();
}
#endif
Fourier::shuffleNaturalToFourierOrder (m_adFilter, m_nFilterPoints);
-#ifdef HAVE_SGP
- if (pEZPlot && m_traceLevel >= Trace::TRACE_PLOT) {
- pEZPlot->ezset ("title Filter Filter: Fourier Order");
- pEZPlot->ezset ("ylength 0.50");
- pEZPlot->ezset ("yporigin 0.50");
- pEZPlot->addCurve (m_adFilter, m_nFilterPoints);
- pEZPlot->plot (pSGP);
- delete pEZPlot;
+#if defined(HAVE_WXWINDOWS) && (defined(DEBUG) || defined(_DEBUG))
+ if (g_bRunningWXWindows && m_traceLevel > 0) {
+ EZPlotDialog dlgEZPlot;
+ dlgEZPlot.getEZPlot()->ezset ("title Filter Geometry Scaled: Fourier Order");
+ dlgEZPlot.getEZPlot()->addCurve (m_adFilter, m_nFilterPoints);
+ dlgEZPlot.ShowModal();
}
#endif
+
+ // FILTERING: FREQUENCY - INVERSE FOURIER
+
} else if (m_idFilterGeneration == FILTER_GENERATION_INVERSE_FOURIER) {
// calculate number of filter points with zeropadding
int nSpatialPoints = 2 * (m_nSignalPoints - 1) + 1;
m_nFilterPoints = 1 << nextPowerOf2;
}
m_nOutputPoints = m_nFilterPoints * m_iPreinterpolationFactor;
-#ifdef DEBUG
+#if defined(DEBUG) || defined(_DEBUG)
if (m_traceLevel >= Trace::TRACE_CONSOLE)
- std::cout << "nFilterPoints = " << m_nFilterPoints << endl;
+ sys_error (ERR_TRACE, "nFilterPoints = %d", m_nFilterPoints);
#endif
double* adSpatialFilter = new double [m_nFilterPoints];
SignalFilter filter (m_idFilter, m_dFilterMin, m_dFilterMax, nSpatialPoints, m_dBandwidth,
- m_dFilterParam, SignalFilter::DOMAIN_SPATIAL);
+ m_dFilterParam, SignalFilter::DOMAIN_SPATIAL);
filter.copyFilterData (adSpatialFilter, 0, nSpatialPoints);
-#if defined(HAVE_WXWINDOWS) && defined(DEBUG)
- EZPlotDialog pEZPlotDlg = NULL;
+#if defined(HAVE_WXWINDOWS) && (defined(DEBUG) || defined(_DEBUG))
if (g_bRunningWXWindows && m_traceLevel > 0) {
- pEZPlotDlg = new EZPlotDialog;
- pEZPlot->getEZPlot()->ezset ("title Spatial Filter: Natural Order");
- pEZPlot->getEZPlot()->ezset ("ylength 0.50");
- pEZPlot->getEZPlot()->ezset ("yporigin 0.00");
- pEZPlot->getEZPlot()->addCurve (adSpatialFilter, nSpatialPoints);
+ EZPlotDialog dlgEZPlot;;
+ dlgEZPlot.getEZPlot()->ezset ("title Spatial Filter: Natural Order");
+ dlgEZPlot.getEZPlot()->addCurve (adSpatialFilter, nSpatialPoints);
+ dlgEZPlot.ShowModal();
}
#endif
-
-// #define PRE_JAN_2001 1
+
+#define PRE_JAN_2001 1
#ifdef PRE_JAN_2001
if (m_idGeometry == Scanner::GEOMETRY_EQUILINEAR) {
- for (i = 0; i < m_nFilterPoints; i++)
+ for (i = 0; i < nSpatialPoints; i++)
adSpatialFilter[i] *= 0.5;
} else if (m_idGeometry == Scanner::GEOMETRY_EQUIANGULAR) {
- for (i = 0; i < m_nFilterPoints; i++) {
- int iDetFromZero = i - ((m_nFilterPoints - 1) / 2);
+ for (i = 0; i < nSpatialPoints; i++) {
+ int iDetFromZero = i - ((nSpatialPoints - 1) / 2);
double sinScale = sin (iDetFromZero * m_dSignalInc);
if (fabs(sinScale) < 1E-7)
sinScale = 1;
adSpatialFilter[i] *= dScale;
}
}
+#if defined(HAVE_WXWINDOWS) && (defined(DEBUG) || defined(_DEBUG))
+ if (g_bRunningWXWindows && m_traceLevel > 0) {
+ EZPlotDialog dlgEZPlot;;
+ dlgEZPlot.getEZPlot()->ezset ("title Scaled Spatial Filter: Natural Order");
+ dlgEZPlot.getEZPlot()->addCurve (adSpatialFilter, nSpatialPoints);
+ dlgEZPlot.ShowModal();
+ }
+#endif
for (i = nSpatialPoints; i < m_nFilterPoints; i++)
adSpatialFilter[i] = 0;
for (i = 0; i < m_nFilterPoints; i++)
m_adFilter[i] = std::abs (acInverseFilter[i]) * m_dSignalInc;
delete acInverseFilter;
+#if defined(HAVE_WXWINDOWS) && (defined(DEBUG) || defined(_DEBUG))
+ if (g_bRunningWXWindows && m_traceLevel > 0) {
+ EZPlotDialog dlgEZPlot;
+ dlgEZPlot.getEZPlot()->ezset ("title Fourier Scaled Spatial Filter: Fourier Order");
+ dlgEZPlot.getEZPlot()->addCurve (m_adFilter, m_nFilterPoints);
+ dlgEZPlot.ShowModal();
+ }
+#endif
+
#else
for (i = nSpatialPoints; i < m_nFilterPoints; i++)
adSpatialFilter[i] = 0;
-
-// for (i = 0; i < m_nFilterPoints; i++)
-// adSpatialFilter[i] /= m_dSignalInc;
-
+
std::complex<double>* acInverseFilter = new std::complex<double> [m_nFilterPoints];
finiteFourierTransform (adSpatialFilter, acInverseFilter, m_nFilterPoints, FORWARD);
delete adSpatialFilter;
m_adFilter = new double [m_nFilterPoints];
for (i = 0; i < m_nFilterPoints; i++)
- m_adFilter[i] = std::abs(acInverseFilter[i]);
+ m_adFilter[i] = std::abs(acInverseFilter[i]);
delete acInverseFilter;
-
+
+#if defined(HAVE_WXWINDOWS) && (defined(DEBUG) || defined(_DEBUG))
+ if (g_bRunningWXWindows && m_traceLevel > 0) {
+ EZPlotDialog dlgEZPlot;
+ dlgEZPlot.getEZPlot()->ezset ("title Inverse Spatial Filter: Fourier order");
+ dlgEZPlot.getEZPlot()->addCurve (m_adFilter, m_nFilterPoints);
+ dlgEZPlot.ShowModal();
+ }
+#endif
+ Fourier::shuffleFourierToNaturalOrder(m_adFilter, m_nFilterPoints);
+#if defined(HAVE_WXWINDOWS) && (defined(DEBUG) || defined(_DEBUG))
+ if (g_bRunningWXWindows && m_traceLevel > 0) {
+ EZPlotDialog dlgEZPlot;
+ dlgEZPlot.getEZPlot()->ezset ("title Inverse Spatial Filter: Natural order");
+ dlgEZPlot.getEZPlot()->addCurve (m_adFilter, m_nFilterPoints);
+ dlgEZPlot.ShowModal();
+ }
+#endif
if (m_idGeometry == Scanner::GEOMETRY_EQUILINEAR) {
for (i = 0; i < m_nFilterPoints; i++)
m_adFilter[i] *= 0.5;
} else if (m_idGeometry == Scanner::GEOMETRY_EQUIANGULAR) {
for (i = 0; i < m_nFilterPoints; i++) {
int iDetFromZero = i - ((m_nFilterPoints - 1) / 2);
- double sinScale = sin (iDetFromZero * m_dSignalInc);
- if (fabs(sinScale) < 1E-7)
- sinScale = 1;
- else
- sinScale = (iDetFromZero * m_dSignalInc) / sinScale;
- double dScale = 0.5 * sinScale * sinScale;
- m_adFilter[i] *= dScale;
+ if (abs(iDetFromZero) < m_nSignalPoints) {
+ double sinScale = 1 / SignalFilter::sinc (iDetFromZero * m_dSignalInc);
+ double dScale = 0.5 * sinScale * sinScale;
+ m_adFilter[i] *= dScale;
+ }
}
}
+#if defined(HAVE_WXWINDOWS) && (defined(DEBUG) || defined(_DEBUG))
+ if (g_bRunningWXWindows && m_traceLevel > 0) {
+ EZPlotDialog dlgEZPlot;
+ dlgEZPlot.getEZPlot()->ezset ("title Scaled Inverse Spatial Filter: Natural order");
+ dlgEZPlot.getEZPlot()->addCurve (m_adFilter, m_nFilterPoints);
+ dlgEZPlot.ShowModal();
+ }
+#endif
+ Fourier::shuffleNaturalToFourierOrder(m_adFilter, m_nFilterPoints);
#endif
-#if defined(HAVE_WXWINDOWS) && defined(DEBUG)
- if (g_bRunningWXWindows && pEZPlotDlg && m_traceLevel > 0) {
- pEZPlotDlg->getEZPlot()->ezset ("title Spatial Filter: Inverse");
- pEZPlotDlg->getEZPlot()->ezset ("ylength 0.50");
- pEZPlotDlg->getEZPlot()->ezset ("yporigin 0.50");
- pEZPlotDlg->getEZPlot()->addCurve (m_adFilter, m_nFilterPoints);
- pEZPlotDlg->ShowModal();
- delete pEZPlotDlg;
+#if defined(HAVE_WXWINDOWS) && (defined(DEBUG) || defined(_DEBUG))
+ if (g_bRunningWXWindows && m_traceLevel > 0) {
+ EZPlotDialog dlgEZPlot;
+ dlgEZPlot.getEZPlot()->ezset ("title Spatial Filter Inverse Post Geometry Filtering");
+ dlgEZPlot.getEZPlot()->addCurve (m_adFilter, m_nFilterPoints);
+ dlgEZPlot.ShowModal();
}
#endif
}
** This is part of the CTSim program
** Copyright (C) 1983-2001 Kevin Rosenberg
**
-** $Id: dlgezplot.cpp,v 1.1 2001/01/12 16:41:56 kevin Exp $
+** $Id: dlgezplot.cpp,v 1.2 2001/01/12 21:53:27 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
#include "wx/timer.h"
#endif
-#include "dlgezplot.h"
#include "ct.h"
+#include "ctsim.h"
+#include "dlgezplot.h"
static const int LAYOUT_X_MARGIN = 4;
static const int LAYOUT_Y_MARGIN = 4;
-BEGIN_EVENT_TABLE(EZPlotDialog, wxDialog)
-EVT_BUTTON(wxID_CANCEL, EZPlotDialog::OnCancel)
-EVT_CLOSE(EZPlotDialog::OnClose)
-EVT_PAINT(EZPlotDialog::OnPaint)
+BEGIN_EVENT_TABLE(EZPlotControl, wxPanel)
+EVT_PAINT(EZPlotControl::OnPaint)
END_EVENT_TABLE()
-IMPLEMENT_CLASS(EZPlotDialog, wxDialog)
+IMPLEMENT_CLASS(EZPlotControl, wxPanel)
-EZPlotDialog::EZPlotDialog (wxWindow *parent)
-: wxDialog(parent, -1, wxString("EZPlot"), wxDefaultPosition, wxDefaultSize, wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE),
- m_pEZPlot(0), m_pSGPDriver(0), m_pSGP(0), m_pDC(0)
+EZPlotControl::EZPlotControl (wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style,
+ const wxValidator& validator, const wxString& name)
+ : m_pEZPlot(0), m_pSGPDriver(0), m_pSGP(0), m_pDC(0)
{
- m_parentTop = parent;
- while ( m_parentTop && m_parentTop->GetParent() )
- m_parentTop = m_parentTop->GetParent();
-
- wxLayoutConstraints* c = new wxLayoutConstraints;
- c->right.SameAs(this, wxRight, 2*LAYOUT_X_MARGIN);
- c->bottom.SameAs(this, wxBottom, 2*LAYOUT_Y_MARGIN);
-
- wxSize sizeBtn = wxButton::GetDefaultSize();
- c->width.Absolute(sizeBtn.x);
- c->height.Absolute(sizeBtn.y);
-
- SetAutoLayout(TRUE);
- Layout();
-
- wxSize sizeDlg (500,500);
- if (sizeDlg.x != sizeDlg.y) {
- sizeDlg.x = max(sizeDlg.x,sizeDlg.y);
- sizeDlg.y = max(sizeDlg.x,sizeDlg.y);
- }
-
- m_iClientX = sizeDlg.x;
- m_iClientY = sizeDlg.y;
- SetClientSize(sizeDlg);
-
- Centre(wxCENTER_FRAME | wxBOTH);
-
- if ( m_parentTop )
- m_parentTop->Enable(FALSE);
-
- Show(TRUE);
- Enable(TRUE); // enable this window
-
- m_pDC = dynamic_cast<wxDC*> (new wxClientDC (this));
- int x, y;
- this->GetClientSize(&x, &y);
- m_pSGPDriver = new SGPDriver (m_pDC, x, y);
- m_pSGP = new SGP (*m_pSGPDriver);
- m_pSGP->setTextPointSize(10);
- m_pEZPlot = new EZPlot;
-
-#ifdef __WXMAC__
- MacUpdateImmediately();
-#endif
-}
+ Create(parent, id, pos, size, style, name);
+
+ SetSize (GetBestSize());
+ m_pEZPlot = new EZPlot;
+}
-void EZPlotDialog::OnClose(wxCloseEvent& event)
+wxSize
+EZPlotControl::GetBestSize () const
{
+ return wxSize (500,500);
+}
+
+EZPlotControl::~EZPlotControl()
+{
+ delete m_pEZPlot;
+ delete m_pSGP;
+ delete m_pSGPDriver;
+ delete m_pDC;
}
void
-EZPlotDialog::OnPaint (wxPaintEvent& event)
+EZPlotControl::OnPaint (wxPaintEvent& event)
{
- m_pEZPlot->plot (m_pSGP);
+ wxPaintDC dc(this);
+ GetClientSize (&m_iClientX, &m_iClientY);
+ m_pSGPDriver = new SGPDriver (&dc, m_iClientX, m_iClientY);
+ m_pSGP = new SGP (*m_pSGPDriver);
+ m_pSGP->setTextPointSize(10);
+ if (m_pEZPlot && m_pSGP) {
+ m_pSGP->eraseWindow();
+ m_pEZPlot->plot (m_pSGP);
+ }
}
+EZPlotDialog::EZPlotDialog (wxWindow *parent)
+: wxDialog((parent ? parent : theApp->getMainFrame()), -1, wxString("EZPlot"), wxDefaultPosition, wxDefaultSize, wxDIALOG_MODAL),
+ m_parentTop(0)
+{
+ if (! parent)
+ parent = theApp->getMainFrame();
+
+ m_parentTop = parent;
+ while ( m_parentTop && m_parentTop->GetParent() )
+ m_parentTop = m_parentTop->GetParent();
+
+ wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
+
+ pTopSizer->Add (m_pEZPlotCtrl = new EZPlotControl (this), 0, wxALIGN_CENTER | wxALL, 5);
+
+ wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
+ wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
+ wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
+ pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
+ pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
+
+ pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
+
+ SetAutoLayout (true);
+ SetSizer (pTopSizer);
+ pTopSizer->Fit (this);
+ pTopSizer->SetSizeHints (this);
+}
+
+
+
/////////////////////////////////////////////////////
// destruction
EZPlotDialog::~EZPlotDialog()
{
- if ( m_parentTop )
- m_parentTop->Enable(TRUE);
-
- delete m_pEZPlot;
- delete m_pSGP;
- delete m_pSGPDriver;
- delete m_pDC;
+ if ( m_parentTop )
+ m_parentTop->Enable(TRUE);
}