///**************************************************************************** //! \file glview.cpp //! \date 23-05-2003 //***************************************************************************** // This file is part of the Dataview. // // Dataview is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // The Dataview is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with DataView; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "glview.hpp" //*************************************************************************** // GLView methods //*************************************************************************** // public methods //*************************************************************************** //*************************************************************************** GLView::GLView( QWidget *parent, char const *name): WEngine(parent,name), pSize( 1.0), obj( true), col( true), boxmode( false), nl( 0), op( false), ssel( false) //*************************************************************************** { } //*************************************************************************** GLView::~GLView() //*************************************************************************** { } //*************************************************************************** void GLView::setupReplayMode( const bool r, const QString file, const int s, const bool d, const Tcoord *koo) //*************************************************************************** { if( RFile.is_open()) RFile.close(); if( r) { if( koo) Cam->copy( *koo); else resetKoo(); Replaypps = s; Replaydel = d; RFile.open( file.latin1()); dellen = finddel(); op = true; replaylist = pointl[ listn[ of]]; }else { RFile.close(); RFile.clear(); stop(); } Replay = r; pInFile = 0; } //*************************************************************************** // public slots //*************************************************************************** //*************************************************************************** void GLView::UpdateObj() //*************************************************************************** { open( of, numPCpoints, Cam, true); update(); } //*************************************************************************** int GLView::open( const QString filename, const int points) //*************************************************************************** { int tr; boxmode = false; if( listn.count( filename)) { QMessageBox::critical( this, "Alert", "Could not open File: \n Allready open", QMessageBox::Ok, QMessageBox::NoButton); tr = -1; }else { Cam->copy( Tcoord( 0, 0, -15, 0, 0, 0, 0, 0, 0, 0, 0, 0)); ois.clear(); op = true; of = filename; tr = LoadPoints( filename, points); if( boxmode)ois.push_back( *( new TGLObject( &boxl, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))); ois.push_back( *( new TGLObject( &pointl[listn[filename]], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))); drawStatic(); } return tr; } //*************************************************************************** int GLView::open( const QString filename, const int points, const Tcoord *koo, const bool ro) //*************************************************************************** { int tr; Cam->copy( *koo); ois.clear(); op = true; of = filename; boxmode = false; if( listn.count( filename) && ro)tr = LoadPoints( filename, points); if( boxmode)ois.push_back( *( new TGLObject( &boxl, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))); ois.push_back( *( new TGLObject( &pointl[listn[filename]], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))); drawStatic(); //cerr<copy( Tcoord( 0, 0, -15, 0, 0, 0, 0, 0, 0, 0, 0, 0)); ois.clear(); update(); } //*************************************************************************** Tcoord GLView::currentConfig() const //*************************************************************************** { Tcoord erg( *Cam); return erg; } //*************************************************************************** void GLView::enableSectSel( bool sw) //*************************************************************************** { boxmode = sw; if( boxmode) { setMouseTracking( true); cxh = this->width()/2.; cx1 = .55/cxh; cyh = this->height()/2.; cy1 = .35/cyh; curs2 = cursor().shape(); if( curs2==Qt::BlankCursor) curs2 = Qt::ArrowCursor; setCursor( Qt::BlankCursor); hidecursor = true; cursx = cursy = cursz = 0; boxlen = 2.; drawBox(); ois.push_back( *( new TGLObject( &boxl, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))); drawStatic(); } else { setMouseTracking( false); setCursor( curs2); hidecursor = false; boxPos[0] = cursx - boxlen; boxPos[1] = cursz - boxlen; boxPos[2] = cursy - boxlen; boxPos[3] = cursx + boxlen; boxPos[4] = cursz + boxlen; boxPos[5] = cursy + boxlen; } } //*************************************************************************** // protected methods //*************************************************************************** //*************************************************************************** int GLView::LoadPoints( const QString fname, const int inPCp) { numPCpoints = inPCp; int i = 0; int j = 0; RFile.open( fname.latin1()); dellen = finddel(); int col1 = 255; int col2 = 0; int col3 = 0; int m = 1; int sPCpoints2; if( numPCpoints>499) sPCpoints2 = numPCpoints/499; else { sPCpoints2 = 1; m = 499/numPCpoints; } bool t = true; if( !listn.count( fname)) { listn[fname]=nl; pointl[nl] = glGenLists( 1); ++nl; } glNewList( pointl[listn[fname]], GL_COMPILE ); qglColor( white); glPointSize( pSize); if( !obj)glBegin( GL_POINTS); if( !ssel) { do { if( RFile.peek()=='#') { RFile.getline( tr2, 256); std::cout<>p[0]; RFile.read( tr2, dellen); RFile>>p[1]; RFile.read( tr2, dellen); RFile>>p[2]; RFile.getline( tr2, 256); ++i; drawPoint( p); }while( ( RFile.good()) && (i>p[0]; RFile.read( tr2, dellen); RFile>>p[1]; RFile.read( tr2, dellen); RFile>>p[2]; RFile.getline( tr2, 256); ++j; if( (p[0]>boxPos[0]) && (p[1]>boxPos[1]) && (p[2]>boxPos[2]) && (p[0]