** This is part of the CTSim program
** Copyright (c) 1983-2001 Kevin Rosenberg
**
-** $Id: graph3dview.cpp,v 1.32 2003/01/23 23:35:58 kevin Exp $
+** $Id: graph3dview.cpp,v 1.34 2003/01/30 22:02:30 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
Graph3dFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) )
{
m_pFrame = CreateChildFrame(doc, this);
+ SetFrame (m_pFrame);
m_pCanvas = CreateCanvas (m_pFrame);
m_pFrame->SetClientSize (m_pCanvas->GetBestSize());
- SetFrame (m_pFrame);
m_pCanvas->SetClientSize (m_pCanvas->GetBestSize());
m_pFrame->SetTitle("Graph3dFileView");
- m_pCanvas->SetCurrent();
-
- InitGL();
-
- m_pFrame->SetFocus();
- m_pFrame->Show(true);
- Activate(true);
-
+ m_pCanvas->SetCurrent();
+ InitGL();
+ m_pCanvas->SwapBuffers();
+
m_pViewMenu->Check (GRAPH3D_VIEW_COLOR, m_bColor);
m_pViewMenu->Check (GRAPH3D_VIEW_LIGHTING, m_bLighting);
m_pViewMenu->Check (GRAPH3D_VIEW_SMOOTH, m_bSmooth);
m_pViewMenu->Check (GRAPH3D_VIEW_WIREFRAME, m_bWireframe);
+
+ m_pFrame->SetFocus();
+ m_pFrame->Show(true);
+ Activate(true);
+
return true;
}
Graph3dFileCanvas*
Graph3dFileView::CreateCanvas (wxFrame* parent)
{
- Graph3dFileCanvas* pCanvas;
-
- pCanvas = new Graph3dFileCanvas (this, parent, wxPoint(-1,-1), wxSize(-1,-1), 0);
+ Graph3dFileCanvas* pCanvas = new Graph3dFileCanvas (this, parent, wxPoint(-1,-1), wxSize(-1,-1), 0);
pCanvas->SetBackgroundColour(*wxWHITE);
pCanvas->Clear();
{
if (m_pCanvas) {
m_pCanvas->SetCurrent();
+#ifdef DEBUG
+ *theApp->getLog() << "Drawing 3d surface\n";
+#endif
Draw();
m_pCanvas->SwapBuffers();
}
m_dColorScaleMax = max;
}
double dRadius = maxValue<int> (nx, ny) * SQRT2 / 2;
+
+ if (m_pCanvas)
+ m_pCanvas->SetCurrent();
+
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho (-dRadius, dRadius, -dRadius, dRadius, dRadius*5, -dRadius*5);
#endif
CreateDisplayList();
-
- if (m_pCanvas)
+
+ if (m_pCanvas) {
+ m_pCanvas->SwapBuffers();
m_pCanvas->Refresh();
+ }
}
bool
if (deleteWindow) {
delete m_pFrame;
m_pFrame = NULL;
+ if (GetDocument() && GetDocument()->getBadFileOpen())
+ ::wxYield(); // wxWindows bug workaround
}
return true;
}
+void
+Graph3dFileView::setInitialClientSize ()
+{
+ if (m_pFrame && m_pCanvas) {
+ wxSize bestSize = m_pCanvas->GetBestSize();
+
+ m_pFrame->SetClientSize (bestSize);
+ m_pFrame->Show (true);
+ m_pFrame->SetFocus();
+ }
+}
+
void
Graph3dFileView::OnScaleAuto (wxCommandEvent& event)
{
BEGIN_EVENT_TABLE(Graph3dFileCanvas, wxGLCanvas)
-EVT_PAINT(Graph3dFileCanvas::OnDraw)
+EVT_PAINT(Graph3dFileCanvas::OnPaint)
EVT_SIZE(Graph3dFileCanvas::OnSize)
EVT_CHAR(Graph3dFileCanvas::OnChar)
EVT_MOUSE_EVENTS(Graph3dFileCanvas::OnMouseEvent)
-
Graph3dFileCanvas::Graph3dFileCanvas (Graph3dFileView* view, wxWindow *parent, const wxPoint& pos,
- const wxSize& size, long style):
-wxGLCanvas (parent, -1, pos, size, style, _T("Graph3dCanvas")
- ), m_pView(view)
+ const wxSize& size, long style)
+ : wxGLCanvas (parent, -1, pos, size, style), m_pView(view)
{
- parent->Show (true);
- SetCurrent();
+// parent->Show (true);
#if 0
// Make sure server supports the vertex array extension
char* extensions = (char *) glGetString( GL_EXTENSIONS );
}
void
-Graph3dFileCanvas::OnDraw (wxDC& dc)
+Graph3dFileCanvas::OnPaint (wxPaintEvent& event)
{
+ wxPaintDC dc(this);
if (m_pView)
m_pView->OnDraw(& dc);
}
Graph3dFileCanvas::OnSize (wxSizeEvent& event)
{
#ifndef __WXMOTIF__
- if (!GetContext()) return;
+ // if (!GetContext()) return;
#endif
- SetCurrent();
int width, height;
GetClientSize (&width, &height);
Reshape (width, height);
void
Graph3dFileCanvas::Reshape (int width, int height)
{
+ SetCurrent();
glViewport (0, 0, (GLint)width, (GLint)height);
+ SwapBuffers();
}