X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fgraph3dview.cpp;h=909dc101a0afbc5fb48cf2711a085c422daac0d2;hp=fdcb82369e391b49254c8f030a2fcd8bb56f203d;hb=31a835d9aebd8acb367a033cc92efb4c944a7b4d;hpb=ba8635d790ee847d9746c6da24b60bd4cb6d9116 diff --git a/src/graph3dview.cpp b/src/graph3dview.cpp index fdcb823..909dc10 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.1 2001/01/30 07:32:13 kevin Exp $ +** $Id: graph3dview.cpp,v 1.2 2001/01/30 10:58:13 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 @@ -158,7 +158,7 @@ Graph3dFileView::CreateCanvas (wxFrame* parent) { Graph3dFileCanvas* pCanvas; int width, height; - parent->GetClientSize(&width, &height); + parent->GetClientSize (&width, &height); #ifdef __WXMSW__ int *gl_attrib = NULL; @@ -175,7 +175,6 @@ Graph3dFileView::CreateCanvas (wxFrame* parent) pCanvas = new Graph3dFileCanvas (this, parent, wxPoint(0, 0), wxSize(200, 200), 0, gl_attrib); - pCanvas->SetScrollbars(20, 20, 50, 50); pCanvas->SetBackgroundColour(*wxWHITE); pCanvas->Clear(); @@ -187,18 +186,62 @@ Graph3dFileView::CreateCanvas (wxFrame* parent) void Graph3dFileView::DrawSurface() { + int nVertices = GetDocument()->m_nVertices; + glTripleFloat* pVertices = GetDocument()->m_pVertices; + glTripleFloat* pNormals = GetDocument()->m_pNormals; + #ifdef GL_EXT_vertex_array if (m_bUseVertexArrays) { - glDrawArraysEXT( GL_TRIANGLE_STRIP, 0, m_nVerts ); + glDrawArraysEXT( GL_TRIANGLE_STRIP, 0, nVertices ); } else { #endif - glBegin( GL_TRIANGLE_STRIP ); - for (GLint i = 0;i < m_nVerts; i++) { - // glNormal3fv( &m_vecNorms[i] ); - // glVertex3fv( &m_vecVerts[i] ); +#if 0 +// glBegin( GL_TRIANGLE_STRIP ); + //glBegin (GL_QUADS); + //glNormal3f (0.0, 0.0, 1.0); glVertex3f (-1.0, -1.0, 0.0); glVertex3f (0.0, -1.0, 0.0); glVertex3f (0.0, 0.0, 0.0); glVertex3f (-1.0, 0.0, 0.0); glNormal3f (0.0, 0.0, 1.0); glVertex3f (0.0, -1.0, 0.0); glVertex3f (1.0, -1.0, 0.0); glVertex3f (1.0, 0.0, 0.0); glVertex3f (0.0, 0.0, 0.0); glNormal3f (0.0, 0.0, 1.0); glVertex3f (0.0, 0.0, 0.0); glVertex3f (1.0, 0.0, 0.0); glVertex3f (1.0, 1.0, 0.0); glVertex3f (0.0, 1.0, 0.0); glNormal3f (0.0, 0.0, 1.0); glVertex3f (0.0, 0.0, 0.0); glVertex3f (0.0, 1.0, 0.0); glVertex3f (-1.0, 1.0, 0.0); glVertex3f (-1.0, 0.0, 0.0); + glColor3f(1.0,1.0,1.0); + glBegin (GL_POINTS); + for (GLint i = 0;i < nVertices; i++) { + // glNormal3fv( &pNormals[i] ); + glVertex3fv( pVertices[i] ); } glEnd(); +#else + double edge = 1.; + unsigned int nx = GetDocument()->m_nx; + unsigned int ny = GetDocument()->m_ny; + const ImageFileArray v = GetDocument()->m_array; + double actOffset = 0; + +// glNewList(opnListNum++,GL_COMPILE); + for(int ix = 0; ix < nx-1; ix++){ + for(int iy = 0; iy < ny-1; iy++){ + + float p1[3], p2[3], p3[3], p4[3]; + float n1[3], n2[3], n3[3], n4[3]; + glBegin(GL_LINE_LOOP); + + p1[0] = edge*(iy); p1[1] = v[ix][iy] + actOffset; p1[2] = edge*(ix); + p2[0] = edge*(iy+1); p2[1] = v[ix+1][iy] + actOffset; p2[2] = edge*(ix ); + p3[0] = edge*(iy+1); p3[1] = v[ix+1][iy] + actOffset; p3[2] = edge*(ix +1); + p4[0] = edge*(iy); p4[1] = v[ix][iy] + actOffset; p4[2] = edge*(ix +1); + + n1[0] = -(p2[1] - p1[1])*(p3[2] - p1[2]) + (p2[2] - p1[2])*(p3[1] - p2[1]); + n1[1] = -(p2[2] - p1[2])*(p3[0] - p2[0]) + (p2[0] - p1[0])*(p3[2] - p2[2]); + n1[2] = -(p2[0] - p1[0])*(p3[1] - p2[1]) + (p2[1] - p1[1])*(p3[0] - p2[0]); + + glVertex3fv(p1); glNormal3fv(n1); + glVertex3fv(p2); glNormal3fv(n1); + glVertex3fv(p3); glNormal3fv(n1); + glVertex3fv(p4); glNormal3fv(n1); + glEnd(); + } + + } + glEndList(); + +#endif #ifdef GL_EXT_vertex_array } #endif @@ -208,33 +251,10 @@ Graph3dFileView::DrawSurface() void Graph3dFileView::OnProperties (wxCommandEvent& event) { - const ImageFile& rIF = GetDocument()->getImageFile(); - if (rIF.nx() == 0 || rIF.ny() == 0) - *theApp->getLog() << "Properties: empty imagefile\n"; - else { - const std::string& rFilename = rIF.getFilename(); std::ostringstream os; - double min, max, mean, mode, median, stddev; - rIF.statistics (rIF.getArray(), min, max, mean, mode, median, stddev); - os << "Filename: " << rFilename << "\n"; - os << "Size: (" << rIF.nx() << "," << rIF.ny() << ")\n"; - os << "Data type: "; - if (rIF.isComplex()) - os << "Complex\n"; - else - os << "Real\n"; - os << "Minimum: "< 0) { - rIF.printLabelsBrief (os); - } *theApp->getLog() << ">>>>\n" << os.str().c_str() << "<<<<\n"; wxMessageDialog dialogMsg (getFrameForChild(), os.str().c_str(), "Imagefile Properties", wxOK | wxICON_INFORMATION); dialogMsg.ShowModal(); - } } @@ -316,31 +336,26 @@ Graph3dFileView::InitGL () glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glFrustum( -1.0, 1.0, -1.0, 1.0, 5, 25 ); - + glOrtho (-100, 100, -100, 100, -500, 500); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glTranslatef( 0.0, 0.0, -6.0 ); + glTranslatef( 100, -6, 100 ); -#ifdef GL_EXT_vertex_array - if (m_bUseVertexArrays) { - // glVertexPointerEXT( 3, GL_FLOAT, 0, m_nVerts, verts ); - // glNormalPointerEXT( GL_FLOAT, 0, m_nVerts, norms ); - glEnable( GL_VERTEX_ARRAY_EXT ); - glEnable( GL_NORMAL_ARRAY_EXT ); - } -#endif } void Graph3dFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) ) { + int nVertices = GetDocument()->m_nVertices; + glTripleFloat* pVertices = GetDocument()->m_pVertices; + glTripleFloat* pNormals = GetDocument()->m_pNormals; + +#if 0 const ImageFile& rIF = GetDocument()->getImageFile(); ImageFileArrayConst v = rIF.getArray(); int nx = rIF.nx(); int ny = rIF.ny(); if (v != NULL && nx != 0 && ny != 0) { -#if 0 unsigned char* imageData = new unsigned char [nx * ny * 3]; for (int ix = 0; ix < nx; ix++) { for (int iy = 0; iy < ny; iy++) { @@ -360,9 +375,17 @@ Graph3dFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) ) m_pFrame->SetClientSize (xSize, ySize); m_pCanvas->SetScrollbars(20, 20, nx/20, ny/20); m_pCanvas->SetBackgroundColour(*wxWHITE); -#endif } +#endif +#ifdef GL_EXT_vertex_array + if (m_bUseVertexArrays) { + // glVertexPointerEXT( 3, GL_FLOAT, 0, nVertices, pVertices ); + // glNormalPointerEXT( GL_FLOAT, 0, nVertices, pNormals ); + glEnable( GL_VERTEX_ARRAY_EXT ); + glEnable( GL_NORMAL_ARRAY_EXT ); + } +#endif if (m_pCanvas) m_pCanvas->Refresh(); } @@ -416,11 +439,9 @@ Graph3dFileView::CreateChildFrame (wxDocument *doc, wxView *view) m_pFileMenu->Append(wxID_SAVE, "&Save\tCtrl-S"); m_pFileMenu->Append(wxID_SAVEAS, "Save &As..."); m_pFileMenu->Append(wxID_CLOSE, "&Close\tCtrl-W"); - m_pFileMenu->Append(wxID_REVERT, "Re&vert"); m_pFileMenu->AppendSeparator(); m_pFileMenu->Append(IFMENU_FILE_PROPERTIES, "P&roperties"); - m_pFileMenu->Append(IFMENU_FILE_EXPORT, "&Export..."); m_pFileMenu->AppendSeparator(); m_pFileMenu->Append(wxID_PRINT, "&Print..."); @@ -433,36 +454,6 @@ Graph3dFileView::CreateChildFrame (wxDocument *doc, wxView *view) GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu); GetDocumentManager()->FileHistoryUseMenu(m_pFileMenu); - wxMenu *view_menu = new wxMenu; - view_menu->Append(IFMENU_VIEW_SCALE_MINMAX, "Display Scale S&et...\tCtrl-E"); - view_menu->Append(IFMENU_VIEW_SCALE_AUTO, "Display Scale &Auto...\tCtrl-A"); - view_menu->Append(IFMENU_VIEW_SCALE_FULL, "Display F&ull Scale\tCtrl-U"); - - wxMenu* filter_menu = new wxMenu; - filter_menu->Append (IFMENU_FILTER_INVERTVALUES, "&Invert Values"); - filter_menu->Append (IFMENU_FILTER_SQUARE, "&Square"); - filter_menu->Append (IFMENU_FILTER_SQRT, "Square &Root"); - filter_menu->Append (IFMENU_FILTER_LOG, "&Log"); - filter_menu->Append (IFMENU_FILTER_EXP, "&Exp"); - filter_menu->AppendSeparator(); -#ifdef HAVE_FFT - filter_menu->Append (IFMENU_FILTER_FFT, "2D &FFT"); - filter_menu->Append (IFMENU_FILTER_IFFT, "2D &IFFT"); - filter_menu->Append (IFMENU_FILTER_FFT_ROWS, "FFT Rows"); - filter_menu->Append (IFMENU_FILTER_IFFT_ROWS, "IFFT Rows"); - filter_menu->Append (IFMENU_FILTER_FFT_COLS, "FFT Columns"); - filter_menu->Append (IFMENU_FILTER_IFFT_COLS, "IFFT Columns"); - filter_menu->Append (IFMENU_FILTER_FOURIER, "F&ourier"); - filter_menu->Append (IFMENU_FILTER_INVERSE_FOURIER, "Inverse Fo&urier"); -#else - filter_menu->Append (IFMENU_FILTER_FOURIER, "&Fourier"); - filter_menu->Append (IFMENU_FILTER_INVERSE_FOURIER, "&Inverse Fourier"); -#endif - filter_menu->Append (IFMENU_FILTER_SHUFFLEFOURIERTONATURALORDER, "S&huffle Fourier to Natural Order"); - filter_menu->Append (IFMENU_FILTER_SHUFFLENATURALTOFOURIERORDER, "Shu&ffle Natural to Fourier Order"); - filter_menu->Append (IFMENU_FILTER_MAGNITUDE, "&Magnitude"); - filter_menu->Append (IFMENU_FILTER_PHASE, "&Phase"); - wxMenu *help_menu = new wxMenu; help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents\tF1"); help_menu->Append(MAINMENU_HELP_TOPICS, "&Topics\tCtrl-H"); @@ -471,8 +462,6 @@ Graph3dFileView::CreateChildFrame (wxDocument *doc, wxView *view) wxMenuBar *menu_bar = new wxMenuBar; menu_bar->Append(m_pFileMenu, "&File"); - menu_bar->Append(view_menu, "&View"); - menu_bar->Append(filter_menu, "Fi<er"); menu_bar->Append(help_menu, "&Help"); subframe->SetMenuBar(menu_bar);