** Date Started: Jan 2001
**
** This is part of the CTSim program
-** Copyright (c) 1983-2001 Kevin Rosenberg
-**
-** $Id$
+** Copyright (c) 1983-2009 Kevin Rosenberg
**
** 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
: m_pFileMenu(NULL), m_pViewMenu(NULL), m_pStatusBar(NULL), m_pCanvas(NULL),
m_dXRotate(-180), m_dYRotate(-210), m_dZRotate(195),
m_bDoubleBuffer(true), m_bSmooth(true), m_bWireframe(false),
- m_bLighting(false), m_bColor(true), m_bUseVertexArrays(false),
+ m_bLighting(false), m_bColor(true),
m_bColorScaleMinSet(false), m_bColorScaleMaxSet(false),
- m_pFrame(NULL)
+ m_pGLContext(NULL), m_pFrame(NULL)
{}
Graph3dFileView::~Graph3dFileView()
{
GetDocumentManager()->FileHistoryRemoveMenu (m_pFileMenu);
- GetDocumentManager()->ActivateView(this, false, true);
+ GetDocumentManager()->ActivateView(this, false);
+ if (m_pGLContext)
+ delete m_pGLContext;
}
bool
{
m_pFrame = CreateChildFrame(doc, this);
SetFrame (m_pFrame);
- m_pCanvas = CreateCanvas (m_pFrame);
-
- m_pFrame->SetClientSize (m_pCanvas->GetBestSize());
- m_pCanvas->SetClientSize (m_pCanvas->GetBestSize());
- m_pFrame->SetTitle("Graph3dFileView");
-
- m_pCanvas->SetCurrent();
- InitGL();
- m_pCanvas->SwapBuffers();
m_pViewMenu->Check (GRAPH3D_VIEW_COLOR, m_bColor);
m_pViewMenu->Check (GRAPH3D_VIEW_LIGHTING, m_bLighting);
m_pFrame->Show(true);
Activate(true);
+#if 1
+ m_pCanvas = CreateCanvas (m_pFrame);
+ m_pGLContext = new wxGLContext (m_pCanvas);
+ m_pFrame->SetClientSize (m_pCanvas->GetBestSize());
+ m_pCanvas->SetClientSize (m_pCanvas->GetBestSize());
+ m_pFrame->SetTitle(doc->GetFilename());
+
+ m_pCanvas->SetCurrent(*m_pGLContext);
+ InitGL(); // Crash
+ m_pCanvas->SwapBuffers();
+#endif
+
return true;
}
Graph3dFileCanvas*
Graph3dFileView::CreateCanvas (wxFrame* parent)
{
- Graph3dFileCanvas* pCanvas = new Graph3dFileCanvas (this, parent, wxPoint(-1,-1), wxSize(-1,-1), 0);
+ Graph3dFileCanvas* pCanvas =
+ new Graph3dFileCanvas (this, parent, NULL,
+ wxDefaultPosition, wxDefaultSize,
+ wxFULL_REPAINT_ON_RESIZE);
pCanvas->SetBackgroundColour(*wxWHITE);
- pCanvas->Clear();
+ pCanvas->ClearBackground();
return pCanvas;
}
void
Graph3dFileView::OnProperties (wxCommandEvent& event)
{
- std::ostringstream os;
- *theApp->getLog() << ">>>>\n" << os.str().c_str() << "<<<<\n";
- wxMessageDialog dialogMsg (getFrameForChild(), os.str().c_str(),
- "Imagefile Properties", wxOK | wxICON_INFORMATION);
+ wxString os;
+ *theApp->getLog() << _T(">>>>\n") << os << _T("<<<<\n");
+ wxMessageDialog dialogMsg (getFrameForChild(), os,
+ _T("Imagefile Properties"),
+ wxOK | wxICON_INFORMATION);
dialogMsg.ShowModal();
}
Graph3dFileView::OnDraw (wxDC* dc)
{
if (m_pCanvas) {
- m_pCanvas->SetCurrent();
+ m_pCanvas->SetCurrent(*m_pGLContext);
#ifdef DEBUG
- *theApp->getLog() << "Drawing 3d surface\n";
+ *theApp->getLog() << _T("Drawing 3d surface\n");
#endif
Draw();
m_pCanvas->SwapBuffers();
}
if (m_pStatusBar) {
- std::ostringstream os;
- os << "Xangle=" << m_dXRotate << ", Yangle=" << m_dYRotate
- << ", Zangle=" << m_dZRotate;
- m_pStatusBar->SetStatusText (os.str().c_str());
+ wxString os;
+ os << _T("Xangle=") << m_dXRotate << _T(", Yangle=") << m_dYRotate
+ << _T(", Zangle=") << m_dZRotate;
+ m_pStatusBar->SetStatusText (os);
}
}
double dRadius = maxValue<int> (nx, ny) * SQRT2 / 2;
if (m_pCanvas)
- m_pCanvas->SetCurrent();
+ m_pCanvas->SetCurrent(*m_pGLContext);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (m_bColorScaleMaxSet)
dMax = m_dColorScaleMax;
- DialogGetMinMax dialogMinMax (getFrameForChild(), "Set Color Scale Minimum & Maximum", dMin, dMax);
+ DialogGetMinMax dialogMinMax (getFrameForChild(), _T("Set Color Scale Minimum & Maximum"), dMin, dMax);
int retVal = dialogMinMax.ShowModal();
if (retVal == wxID_OK) {
m_bColorScaleMinSet = true;
Graph3dFileView::CreateChildFrame (wxDocument *doc, wxView *view)
{
#if CTSIM_MDI
- wxDocMDIChildFrame* subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Graph3dFile Frame", wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
+ wxDocMDIChildFrame* subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, _T("Graph3dFile Frame"), wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
#else
- wxDocChildFrame* subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "Graph3dFile Frame", wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
+ wxDocChildFrame* subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, _T("Graph3dFile Frame"), wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
#endif
theApp->setIconForFrame (subframe);
m_pFileMenu = new wxMenu;
- m_pFileMenu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...\tCtrl-P");
- m_pFileMenu->Append(MAINMENU_FILE_CREATE_FILTER, "Create &Filter...\tCtrl-F");
- m_pFileMenu->Append(wxID_OPEN, "&Open...\tCtrl-O");
- m_pFileMenu->Append(wxID_CLOSE, "&Close\tCtrl-W");
+ m_pFileMenu->Append(MAINMENU_FILE_CREATE_PHANTOM, _T("Cr&eate Phantom...\tCtrl-P"));
+ m_pFileMenu->Append(MAINMENU_FILE_CREATE_FILTER, _T("Create &Filter...\tCtrl-F"));
+ m_pFileMenu->Append(wxID_OPEN, _T("&Open...\tCtrl-O"));
+ m_pFileMenu->Append(wxID_CLOSE, _T("&Close\tCtrl-W"));
m_pFileMenu->AppendSeparator();
- m_pFileMenu->Append(IFMENU_FILE_PROPERTIES, "P&roperties");
+ m_pFileMenu->Append(IFMENU_FILE_PROPERTIES, _T("P&roperties"));
m_pFileMenu->AppendSeparator();
- m_pFileMenu->Append(wxID_PRINT, "&Print...");
- m_pFileMenu->Append(wxID_PRINT_SETUP, "Print &Setup...");
- m_pFileMenu->Append(wxID_PREVIEW, "Print Preview");
+ m_pFileMenu->Append(wxID_PRINT, _T("&Print..."));
+ m_pFileMenu->Append(wxID_PRINT_SETUP, _T("Print &Setup..."));
+ m_pFileMenu->Append(wxID_PREVIEW, _T("Print Preview"));
m_pFileMenu->AppendSeparator();
- m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces...");
- m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
+ m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, _T("Prefere&nces..."));
+ m_pFileMenu->Append(MAINMENU_FILE_EXIT, _T("E&xit"));
GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
GetDocumentManager()->FileHistoryUseMenu(m_pFileMenu);
m_pViewMenu = new wxMenu;
- m_pViewMenu->Append(GRAPH3D_VIEW_WIREFRAME, "Wi&reframe\tCtrl-R", "", true);
- m_pViewMenu->Append(GRAPH3D_VIEW_SMOOTH, "S&mooth\tCtrl-M", "", true);
- m_pViewMenu->Append(GRAPH3D_VIEW_COLOR, "Co&lor\tCtrl-L", "", true);
- m_pViewMenu->Append(GRAPH3D_VIEW_LIGHTING, "Li&ghting\tCtrl-G", "", true);
+ m_pViewMenu->Append(GRAPH3D_VIEW_WIREFRAME, _T("Wi&reframe\tCtrl-R"), _T(""), true);
+ m_pViewMenu->Append(GRAPH3D_VIEW_SMOOTH, _T("S&mooth\tCtrl-M"), _T(""), true);
+ m_pViewMenu->Append(GRAPH3D_VIEW_COLOR, _T("Co&lor\tCtrl-L"), _T(""), true);
+ m_pViewMenu->Append(GRAPH3D_VIEW_LIGHTING, _T("Li&ghting\tCtrl-G"), _T(""), true);
m_pViewMenu->AppendSeparator();
- m_pViewMenu->Append(GRAPH3D_VIEW_SCALE_MINMAX, "Color Scale S&et Min/Max...\tCtrl-E");
- m_pViewMenu->Append(GRAPH3D_VIEW_SCALE_AUTO, "Color Scale &Auto...\tCtrl-A");
- m_pViewMenu->Append(GRAPH3D_VIEW_SCALE_FULL, "Color F&ull Scale\tCtrl-U");
+ m_pViewMenu->Append(GRAPH3D_VIEW_SCALE_MINMAX, _T("Color Scale S&et Min/Max...\tCtrl-E"));
+ m_pViewMenu->Append(GRAPH3D_VIEW_SCALE_AUTO, _T("Color Scale &Auto...\tCtrl-A"));
+ m_pViewMenu->Append(GRAPH3D_VIEW_SCALE_FULL, _T("Color F&ull Scale\tCtrl-U"));
wxMenu *help_menu = new wxMenu;
- help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents\tF1");
- help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
+ help_menu->Append(MAINMENU_HELP_CONTENTS, _T("&Contents\tF1"));
+ help_menu->Append(MAINMENU_HELP_ABOUT, _T("&About"));
wxMenuBar *menu_bar = new wxMenuBar;
- menu_bar->Append(m_pFileMenu, "&File");
- menu_bar->Append(m_pViewMenu, "&View");
- menu_bar->Append(help_menu, "&Help");
+ menu_bar->Append(m_pFileMenu, _T("&File"));
+ menu_bar->Append(m_pViewMenu, _T("&View"));
+ menu_bar->Append(help_menu, _T("&Help"));
subframe->SetMenuBar(menu_bar);
END_EVENT_TABLE()
-
-Graph3dFileCanvas::Graph3dFileCanvas (Graph3dFileView* view, wxWindow *parent, const wxPoint& pos,
+Graph3dFileCanvas::Graph3dFileCanvas (Graph3dFileView* view, wxWindow *parent,
+ int* attribList,
+ const wxPoint& pos,
const wxSize& size, long style)
- : wxGLCanvas (parent, -1, pos, size, style), m_pView(view)
+: wxGLCanvas (parent, wxID_ANY, attribList, pos, size, style), m_pView(view)
{
-// parent->Show (true);
-#if 0
- // Make sure server supports the vertex array extension
- char* extensions = (char *) glGetString( GL_EXTENSIONS );
- if (!extensions || !strstr( extensions, "GL_EXT_vertex_array" )) {
- m_pView->m_bUseVertexArrays = GL_FALSE;
- }
-#endif
}
int width, height;
GetClientSize (&width, &height);
- Reshape (width, height);
+ Reshape (width, height); // Crash
}
void
return;
wxCommandEvent dummyEvent;
- switch (event.KeyCode()) {
+ switch (event.GetKeyCode()) {
case WXK_LEFT:
m_pView->m_dZRotate += 15.0;
Refresh (false);
void
Graph3dFileCanvas::Reshape (int width, int height)
{
- SetCurrent();
+ SetCurrent(*m_pView->m_pGLContext);
glViewport (0, 0, (GLint)width, (GLint)height);
SwapBuffers();
}