X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=src%2Fgraph3dview.cpp;h=fee78aa84c77c21d021d19221aa468981343e75e;hb=305ea081c3308c3d936c801dedddabdbc9b0c37d;hp=c9b28f70e0bf6e4fd4ac571d682a94fce2c38f30;hpb=f692b2d39f56ffbafc04283f32233c098aa2978b;p=ctsim.git diff --git a/src/graph3dview.cpp b/src/graph3dview.cpp index c9b28f7..fee78aa 100644 --- a/src/graph3dview.cpp +++ b/src/graph3dview.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: graph3dview.cpp,v 1.5 2001/02/02 00:46:38 kevin Exp $ +** $Id: graph3dview.cpp,v 1.9 2001/02/03 18:43:43 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 @@ -154,10 +154,10 @@ Graph3dFileView::Graph3dFileView () m_bLighting = true; m_bSurface = true; m_bLighting = true; - m_bColor = true; - m_dXRotate = 0; + m_bColor = false; + m_dXRotate = -45; m_dYRotate = 0; - m_dZRotate = 0; + m_dZRotate = -45; } Graph3dFileView::~Graph3dFileView() @@ -242,13 +242,14 @@ Graph3dFileView::DrawSurface() if (nx == 0 || ny == 0 || ! v) return; - glRotatef( m_dXRotate, 1.0, 0.0, 0.0 ); - glRotatef( m_dZRotate, 0.0, 1.0, 0.0 ); - glRotatef( m_dYRotate, 0.0, 0.0, 1.0 ); - glTranslatef (-static_cast(nx) / 2., 0, -static_cast(ny) / 2.); - InitMaterials(); + glRotatef( m_dXRotate, 1.0, 0.0, 0.0 ); + glRotatef( m_dZRotate, 0.0, 1.0, 0.0 ); + glRotatef( m_dYRotate, 0.0, 0.0, 1.0 ); + glTranslatef (-static_cast(nx) / 2., 0., -static_cast(ny) / 2.); + + if (m_bSmooth) { glShadeModel (GL_SMOOTH); } else { @@ -392,10 +393,11 @@ Graph3dFileView::OnDraw (wxDC* dc) if (! m_pCanvas->GetContext()) return; #endif + m_pCanvas->SwapBuffers(); Draw(); std::ostringstream os; os << "Xangle=" << m_dXRotate << ", Yangle=" << m_dYRotate << ", Zangle=" << m_dZRotate; - m_statusBar.SetStatusText (os.str().c_str()); + m_pStatusBar->SetStatusText (os.str().c_str()); m_pCanvas->SwapBuffers(); } @@ -423,8 +425,10 @@ Graph3dFileView::InitMaterials() #if 1 static float ambient[] = {0.1, 0.1, 0.1, 1.0}; static float diffuse[] = {1.0, 1.0, 1.0, 1.0}; - static float position0[] = {0, 0, -nx/4, 0, 0.0}; - static float position1[] = {nx/2, ny/2, nx/4, 0.0}; + static float position0[] = {-nx/2, -ny/2, -ny/2, 0, 0.0}; + static float position1[] = {-nx/2, -ny/2, ny/2, 0.0}; + static float ambient1[] = {0.5, 0.5, 0.5, 1.0}; + static float diffuse1[] = {1.0, 1.0, 1.0, 1.0}; // static float position0[] = {0.0, 0.0, 20.0, 0.0}; // static float position1[] = {0.0, 0.0, -20.0, 0.0}; static float front_mat_shininess[] = {5.0}; @@ -438,13 +442,17 @@ Graph3dFileView::InitMaterials() static float lmodel_ambient[] = {1.0, 1.0, 1.0, 1.0}; static float lmodel_twoside[] = {GL_FALSE}; + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + glHint(GL_LINE_SMOOTH, GL_DONT_CARE); + glEnable(GL_NORMALIZE); + glLightfv (GL_LIGHT0, GL_AMBIENT, ambient); glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuse); glLightfv (GL_LIGHT0, GL_POSITION, position0); glEnable (GL_LIGHT0); - glLightfv (GL_LIGHT1, GL_AMBIENT, ambient); - glLightfv (GL_LIGHT1, GL_DIFFUSE, diffuse); + glLightfv (GL_LIGHT1, GL_AMBIENT, ambient1); + glLightfv (GL_LIGHT1, GL_DIFFUSE, diffuse1); glLightfv (GL_LIGHT1, GL_POSITION, position1); glEnable (GL_LIGHT1); @@ -571,6 +579,11 @@ Graph3dFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) ) int maxDim = maxValue (nx, ny); glOrtho (-maxDim * 0.71, maxDim * 0.71, -maxDim * 0.71, maxDim * 0.71, maxDim * 0.71, -maxDim * 0.71); + GLfloat eyep[3], lookp[3], up[3]; + eyep[0] = -nx/2; eyep[1] = 0; eyep[2] = -ny/2; + lookp[1] = 0; lookp[1] = 0, lookp[2] = 0; + up[0] = 0; up[1] = 1; up[2] = 0; + //gluLookAt (eyep[0], eyep[1], eyep[2], lookp[0], lookp[1], lookp[2], up[0], up[1], up[2]); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); @@ -596,6 +609,7 @@ Graph3dFileView::OnClose (bool deleteWindow) Activate (false); if (m_pCanvas) { + // m_pCanvas->Show(false); m_pCanvas->setView(NULL); m_pCanvas = NULL; } @@ -606,10 +620,11 @@ Graph3dFileView::OnClose (bool deleteWindow) SetFrame(NULL); if (deleteWindow) { - m_pFrame->Destroy(); + // m_pFrame->Show(false); + delete m_pFrame; m_pFrame = NULL; - if (GetDocument() && GetDocument()->getBadFileOpen()) - ::wxYield(); // wxWindows bug workaround + // if (GetDocument() && GetDocument()->getBadFileOpen()) + // ::wxYield(); // wxWindows bug workaround } return true; @@ -629,8 +644,8 @@ Graph3dFileView::CreateChildFrame (wxDocument *doc, wxView *view) #endif theApp->setIconForFrame (subframe); - m_statusBar.Create (subframe, -1); - subframe->SetStatusBar (&m_statusBar); + m_pStatusBar = new wxStatusBar (subframe, -1); + subframe->SetStatusBar (m_pStatusBar); m_pFileMenu = new wxMenu; @@ -820,7 +835,7 @@ Graph3dFileCanvas::OnMouseEvent(wxMouseEvent& event) void Graph3dFileCanvas::OnEraseBackground(wxEraseEvent& event) { - // Do nothing: avoid flashing. +// wxGLCanvas::OnEraseBackground(event); // Do nothing: avoid flashing. }