myViewer( vw ),
myVP( 0 )
{
- QFrame* client = new QFrame( this );
+ QFrame* client = new QFrame( this );
setCentralWidget( client );
QBoxLayout* layout = new QHBoxLayout( client );
- layout->setMargin(1);
- layout->setSpacing(1);
+ layout->setMargin( 0 );
+ layout->setSpacing( 0 );
GLViewer_ViewPort2d* vp = new GLViewer_ViewPort2d( client, this );
- //vp->turnGrid( true );
- //vp->turnCompass( true );
- //vp->enablePopup( false );
setViewPort( vp );
setBackgroundColor( Qt::white );
layout->addWidget( vp );
aAction = new QtxAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_DUMP" ) ),
tr( "MNU_DUMP_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_DUMP_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onViewDump()));
+ connect(aAction, SIGNAL(activated()), this, SLOT(onDumpView()));
toolMgr()->registerAction( aAction, DumpId );
// FitAll
/*!
SLOT: called on dump view operation is activated, stores scene to raster file
*/
-void GLViewer_ViewFrame::onViewDump()
-{
- GLViewer_Widget* aWidget = ((GLViewer_ViewPort2d*)myVP)->getGLWidget();
- int width, height;
- width = aWidget->width();
- height = aWidget->height();
-
- int imageSize = width*height*3;
- unsigned char* imageBits = NULL;
-
- int reserve_bytes = width % 4; //32 bits platform
- imageSize = (width+reserve_bytes)*height*3;
- imageBits = new unsigned char[imageSize];
-
-
-#ifdef WIN32
-
- int num;
- HBITMAP hBmp;
- HDC hdc_old, hdc;
- HGLRC hglrc_old, hglrc;
-
- BITMAPINFO bi;
-
- hglrc_old = wglGetCurrentContext();
- hdc_old = wglGetCurrentDC();
-
- hdc = CreateCompatibleDC( hdc_old );
- if( !hdc )
- {
- cout << "Can't create compatible DC. Last Error Code: " << GetLastError() << endl;
- return;
- }
-
- int sizeBmi = Standard_Integer( sizeof(BITMAPINFO) + sizeof(RGBQUAD)*3 );
- PBITMAPINFO pBmi = (PBITMAPINFO)( new char[sizeBmi] );
- ZeroMemory( pBmi, sizeBmi );
-
- pBmi->bmiHeader.biSize = sizeof( BITMAPINFOHEADER ); //sizeBmi
- pBmi->bmiHeader.biWidth = width;
- pBmi->bmiHeader.biHeight = height;
- pBmi->bmiHeader.biPlanes = 1;
- pBmi->bmiHeader.biBitCount = 24;
- pBmi->bmiHeader.biCompression = BI_RGB;
-
- LPVOID ppvBits;
- hBmp = CreateDIBSection ( hdc, pBmi, DIB_RGB_COLORS, &ppvBits, NULL, 0 );
- SelectObject ( hdc, hBmp );
- delete[] pBmi;
-
- PIXELFORMATDESCRIPTOR pfd;
- ZeroMemory( &pfd, sizeof( PIXELFORMATDESCRIPTOR ) );
- pfd.nSize = sizeof( PIXELFORMATDESCRIPTOR );
- pfd.nVersion = 1;
- pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_BITMAP;
- pfd.iPixelType = PFD_TYPE_RGBA;
- pfd.cColorBits = 24;
- pfd.cDepthBits = 32;
- pfd.iLayerType = PFD_MAIN_PLANE;
-
- int iPf = ChoosePixelFormat( hdc, &pfd);
- if( iPf == 0 )
- {
- if ( !DescribePixelFormat ( hdc, iPf, sizeof(PIXELFORMATDESCRIPTOR), &pfd ) )
- {
- cout << "Can't describe Pixel Format. Last Error Code: " << GetLastError() << endl;
- }
- }
- if ( !SetPixelFormat(hdc, iPf, &pfd) )
- {
- cout << "Can't set Pixel Format. Last Error Code: " << GetLastError() << endl;
- }
-
- hglrc = wglCreateContext( hdc );
- if( !hglrc )
- {
- cout << "Can't create new GL Context. Last Error Code: " << GetLastError() << endl;
- return;
- }
- if( !wglMakeCurrent( hdc, hglrc) )
- {
- cout << "Can't make current new context!" << endl;
- return;
- }
-
- glViewport( 0, 0, width, height );
-
- glMatrixMode( GL_PROJECTION );
- glLoadIdentity();
- GLfloat w_c = width / 2., h_c = height / 2.;
-
- gluOrtho2D( -w_c, w_c, -h_c, h_c );
-
- glMatrixMode( GL_MODELVIEW );
- glLoadIdentity();
-
- //set background
- QColor aColor = ((GLViewer_ViewPort2d*)myVP)->backgroundColor();
- glClearColor( ( GLfloat )aColor.red() / 255,
- ( GLfloat )aColor.green() / 255,
- ( GLfloat )aColor.blue() / 255,
- 1.0 );
-
- aWidget->exportRepaint();
-
- memset(&bi, 0, sizeof(BITMAPINFOHEADER));
- bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bi.bmiHeader.biPlanes = 1;
- bi.bmiHeader.biBitCount = 24;
- bi.bmiHeader.biHeight = -height;
- bi.bmiHeader.biWidth = width;
- bi.bmiHeader.biCompression = BI_RGB;
-
- num = GetDIBits(hdc, hBmp, 0, height, imageBits, &bi, DIB_RGB_COLORS);
- wglMakeCurrent( hdc_old, hglrc_old );
- wglDeleteContext( hglrc );
-
-
-#else //XWindows
-#endif
-
- unsigned int* aPix = NULL;
- QImage anImage( width, height, QImage::Format_RGB32 );
- for( int i = 0; i < height; i++ )
- {
- memset( anImage.scanLine( i ), 0, sizeof(unsigned int)*width );
- unsigned char* pos;
- for( int j = 0; j < width; j++ )
- {
- pos = imageBits + i*width*3 + j*3 + reserve_bytes*i;
- aPix = (unsigned int*)anImage.scanLine(i)+j;
- *aPix = qRgb( *pos, *(pos+1), *(pos+2) );
- }
- }
-
- delete [] imageBits;
-
- QString aFilter( "*.bmp\n*.png" );
-
- QFileDialog aFileDlg( this, tr( "DUMP_VIEW_SAVE_FILE_DLG_CAPTION" ), QDir::current().absolutePath(), aFilter );
- aFileDlg.setFileMode( QFileDialog::AnyFile );
-
- if( !aFileDlg.exec() )
- return;
-
- QStringList files = aFileDlg.selectedFiles();
- QString aFileName;
- if ( !files.isEmpty() ) aFileName = files[0];
-
- QString aFileExt = aFileDlg.selectedFilter();
-
- if( aFileName.isEmpty() )
- {
- SUIT_MessageBox::critical( this,
- tr( "DUMP_VIEW_ERROR_DLG_CAPTION" ),
- tr( "DUMP_VIEW_ERROR_DLG_TEXT" ) );
- }
+QImage GLViewer_ViewFrame::dumpView()
+{
+ QImage img;
- QString aSaveOp = "BMP";
- QString aTypedFileExt = QFileInfo( aFileName ).suffix().toLower();
+ GLViewer_Widget* aWidget = ((GLViewer_ViewPort2d*)myVP)->getGLWidget();
+ if ( aWidget )
+ img = aWidget->grabFrameBuffer();
- if( aFileExt == "*.bmp" )
- {
- if( aTypedFileExt.isEmpty() )
- aFileName += ".bmp";
- aSaveOp = "BMP";
- }
- else if( aFileExt == "*.png" )
- if( aTypedFileExt.isEmpty() )
- aFileName += ".png";
- aSaveOp = "PNG";
-
-//#ifdef WIN32
-// if( !anImage.save( aFileName, aSaveOp ) )
-//#else
- if( !aWidget->grabFrameBuffer().save( aFileName, aSaveOp.toLatin1().constData() ) )
-//#endif
- {
- SUIT_MessageBox::critical( this,
- tr( "DUMP_VIEW_ERROR_DLG_CAPTION" ),
- tr( "DUMP_VIEW_ERROR_DLG_TEXT" ) );
- }
+ return img;
}
/*!
Start fit area
*/
void GLViewer_ViewFrame::onViewFitArea()
-{
+{
myViewer->activateTransform( GLViewer_Viewer::FitRect );
}
Start fit selected
*/
void GLViewer_ViewFrame::onViewFitSelect()
-{
+{
myViewer->activateTransform( GLViewer_Viewer::FitSelect );
}
Start global panning
*/
void GLViewer_ViewFrame::onViewGlobalPan()
-{
+{
myViewer->activateTransform( GLViewer_Viewer::PanGlobal );
}
Start rotating
*/
void GLViewer_ViewFrame::onViewRotate()
-{
+{
//myViewer->activateTransform( GLViewer_Viewer::Rotate );
}
Start reset default view aspects
*/
void GLViewer_ViewFrame::onViewReset()
-{
+{
myViewer->activateTransform( GLViewer_Viewer::Reset );
}
-
-/*!
+
+/*!
Dispatches mouse events
*/
void GLViewer_ViewFrame::mouseEvent( QMouseEvent* e )
/*!
Constructor
*/
-GLViewer_ViewPort2d::GLViewer_ViewPort2d( QWidget* parent, GLViewer_ViewFrame* theViewFrame ) :
- GLViewer_ViewPort( parent ),
- myMargin( MARGIN ), myWidth( WIDTH ), myHeight( HEIGHT ),
- myXScale( 1.0 ), myYScale( 1.0 ), myXOldScale( 1.0 ), myYOldScale( 1.0 ),
- myXPan( 0.0 ), myYPan( 0.0 ),
- myIsMouseReleaseBlock( false ),
- myRectBand(0)
+GLViewer_ViewPort2d::GLViewer_ViewPort2d( QWidget* parent, GLViewer_ViewFrame* theViewFrame )
+: GLViewer_ViewPort( parent ),
+ myMargin( MARGIN ), myWidth( WIDTH ), myHeight( HEIGHT ),
+ myXScale( 1.0 ), myYScale( 1.0 ), myXOldScale( 1.0 ), myYOldScale( 1.0 ),
+ myXPan( 0.0 ), myYPan( 0.0 ),
+ myIsMouseReleaseBlock( false ),
+ myRectBand( 0 )
{
- if( theViewFrame == NULL )
- myViewFrame = ( GLViewer_ViewFrame* )parent;
- else
- myViewFrame = theViewFrame;
+ if ( !theViewFrame )
+ myViewFrame = (GLViewer_ViewFrame*)parent;
+ else
+ myViewFrame = theViewFrame;
- myGrid = 0;
- myCompass = 0;
- myBorder = new GLViewer_Rect();
+ myGrid = 0;
+ myCompass = 0;
+ myBorder = new GLViewer_Rect();
- QBoxLayout* qbl = new QHBoxLayout( this );
- myGLWidget = new GLViewer_Widget( this, 0 ) ;
- qbl->addWidget( myGLWidget );
- myGLWidget->setFocusProxy( this );
- setMouseTracking( TRUE );
+ QBoxLayout* qbl = new QHBoxLayout( this );
+ qbl->setSpacing( 0 );
+ qbl->setMargin( 0 );
- myIsDragProcess = noDrag;
- //myCurDragMousePos = QPoint();
- myCurDragPosX = NULL;
- myCurDragPosY = NULL;
+ myGLWidget = new GLViewer_Widget( this, 0 ) ;
+ qbl->addWidget( myGLWidget );
+ myGLWidget->setFocusProxy( this );
+ setMouseTracking( TRUE );
- myIsPulling = false;
+ myIsDragProcess = noDrag;
+ //myCurDragMousePos = QPoint();
+ myCurDragPosX = NULL;
+ myCurDragPosY = NULL;
- myViewPortId = aLastViewPostId;
- aLastViewPostId++;
+ myIsPulling = false;
- mypFirstPoint = NULL;
- mypLastPoint = NULL;
+ myViewPortId = aLastViewPostId;
+ aLastViewPostId++;
+
+ mypFirstPoint = NULL;
+ mypLastPoint = NULL;
// TODO: Porting to Qt4
/*myObjectTip = new QtxToolTip( myGLWidget );///GLViewer_ObjectTip( this );
myCurDragPosX = NULL;
myCurDragPosY = NULL;
return;
- }
+ }
}
/*!
SLOT: cuts object to clipboard
*/
void GLViewer_ViewPort2d::onCutObject()
-{
+{
/*GLViewer_Object* aMovingObject = ((GLViewer_Viewer2d*)getViewFrame()->getViewer())->getGLContext()->getCurrentObject();
- if( aMovingObject )
- {
+ if( aMovingObject )
+ {
GLViewer_MimeSource* aMimeSource = new GLViewer_MimeSource();
aMimeSource->setObject( aMovingObject );
-
+
QClipboard *aClipboard = QApplication::clipboard();
aClipboard->clear();
aClipboard->setData( aMimeSource );
void GLViewer_ViewPort2d::onCopyObject()
{
/*GLViewer_Object* aMovingObject = ((GLViewer_Viewer2d*)getViewFrame()->getViewer())->getGLContext()->getCurrentObject();
- if( aMovingObject )
- {
+ if( aMovingObject )
+ {
GLViewer_MimeSource* aMimeSource = new GLViewer_MimeSource();
aMimeSource->setObject( aMovingObject );
-
+
QClipboard *aClipboard = QApplication::clipboard();
aClipboard->clear();
aClipboard->setData( aMimeSource );
GLViewer_Object* aObject = GLViewer_MimeSource::getObject( anArray, aType );
if( !aObject )
return;
-
+
((GLViewer_Viewer2d*)getViewFrame()->getViewer())->getGLContext()->insertObject( aObject, true );
}
*/
GLViewer_Viewer2d* aViewer = (GLViewer_Viewer2d*)getViewFrame()->getViewer();
GLViewer_Context* aContext = aViewer->getGLContext();
GLViewer_Object* anObject = aContext->getCurrentObject();
-
+
if( !aContext )
return;
float aX = e->pos().x();
float anY = e->pos().y();
aViewer->transPoint( aX, anY );
-
+
if( myCurDragPosX == NULL && myCurDragPosY == NULL )
{
myCurDragPosX = new float(aX);
//QPoint aNewPos = e->pos();
//GLViewer_Viewer2d* aViewer = (GLViewer_Viewer2d*)getViewFrame()->getViewer();
-
+
if( anObject && (e->buttons() & Qt::LeftButton ) )
{
if( aContext->isSelected( anObject ) )
else if( aContext->NbSelected() && (e->buttons() & Qt::MidButton ) )
for( aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected() )
(aContext->SelectedObject())->moveObject( aX - *myCurDragPosX, anY - *myCurDragPosY);
-
+
delete myCurDragPosX;
delete myCurDragPosY;
myCurDragPosX = new float(aX);
- myCurDragPosY = new float(anY);
+ myCurDragPosY = new float(anY);
myGLWidget->updateGL();
}
Emits 'mouseEvent' signal. [ virtual protected ]
*/
void GLViewer_ViewPort2d::mousePressEvent( QMouseEvent* e )
-{
+{
emit vpMouseEvent( e );
-
- GLViewer_Viewer2d* aViewer = (GLViewer_Viewer2d*)getViewFrame()->getViewer();
+
+ GLViewer_Viewer2d* aViewer = (GLViewer_Viewer2d*)getViewFrame()->getViewer();
GLViewer_Context* aContext = aViewer->getGLContext();
GLViewer_Object* anObject = NULL;
if( aContext )
anObject = aContext->getCurrentObject();
-
+
bool accel = e->modifiers() & GLViewer_ViewTransformer::accelKey();
if( ( anObject && !( accel || e->button() == Qt::RightButton ) ) ||
( aContext->NbSelected() && !accel && e->button() == Qt::MidButton ) )
- {
+ {
myIsDragProcess = inDrag;
}
}
void GLViewer_ViewPort2d::mouseMoveEvent( QMouseEvent* e )
{
emit vpMouseEvent( e );
-
+
if( myIsDragProcess == inDrag )
onDragObject( e );
- /*GLViewer_Viewer2d* aViewer = (GLViewer_Viewer2d*)getViewFrame()->getViewer();
+ /*GLViewer_Viewer2d* aViewer = (GLViewer_Viewer2d*)getViewFrame()->getViewer();
GLViewer_Context* aContext = aViewer->getGLContext();
GLViewer_Object* anObj = aContext->getCurrentObject();
Emits 'mouseEvent' signal. [ virtual protected ]
*/
void GLViewer_ViewPort2d::mouseReleaseEvent( QMouseEvent* e )
-{
+{
if ( myIsMouseReleaseBlock )
{
// skip mouse release after double click
//destroyPopup( /*popup*/ );
}
emit vpMouseEvent( e );
-
+
if( myIsDragProcess == inDrag )
{
bool isAnyMoved = false;
if( aMovingObject )
isAnyMoved = aMovingObject->finishMove() || isAnyMoved;
}
-
+
aMovingObject = aContext->getCurrentObject();
if( aMovingObject )
isAnyMoved = aMovingObject->finishMove() || isAnyMoved;
-
+
myIsDragProcess = noDrag;
//myCurDragMousePos.setX( 0 );
//myCurDragMousePos.setY( 0 );
if( on )
{
myGrid = new GLViewer_Grid( 2*WIDTH, 2*HEIGHT,
- 2*WIDTH, 2*HEIGHT,
+ 2*WIDTH, 2*HEIGHT,
GRID_XSIZE, GRID_YSIZE,
myXPan, myYPan,
myXScale, myYScale );
GLfloat h = y;
bool max = FALSE;
- xzoom = (GLfloat)x / myWidth;
- yzoom = (GLfloat)y / myHeight;
+ xzoom = (GLfloat)x / myWidth;
+ yzoom = (GLfloat)y / myHeight;
- if ( ( xzoom < yzoom ) && ( xzoom < 1 ) )
- zoom = xzoom;
- else if ( ( yzoom < xzoom ) && ( yzoom < 1 ) )
- zoom = yzoom;
- else
- {
- max = TRUE;
- zoom = xzoom > yzoom ? xzoom : yzoom;
- }
+ if ( ( xzoom < yzoom ) && ( xzoom < 1 ) )
+ zoom = xzoom;
+ else if ( ( yzoom < xzoom ) && ( yzoom < 1 ) )
+ zoom = yzoom;
+ else
+ {
+ max = TRUE;
+ zoom = xzoom > yzoom ? xzoom : yzoom;
+ }
if ( !max && ( ! ( ( ( myXPan + w/2 ) < xb * myXScale * zoom ) ||
- ( ( myXPan - w/2 ) > xa * myXScale * zoom ) ||
+ ( ( myXPan - w/2 ) > xa * myXScale * zoom ) ||
( ( myYPan + h/2 ) < yb * myYScale * zoom ) ||
- ( ( myYPan - h/2 ) > ya * myYScale * zoom ) ) ) )
- zoom = 1;
+ ( ( myYPan - h/2 ) > ya * myYScale * zoom ) ) ) )
+ zoom = 1;
if ( max && ( ( ( myXPan + w/2 ) < xb * myXScale * zoom ) ||
- ( ( myXPan - w/2 ) > xa * myXScale * zoom ) ||
- ( ( myYPan + h/2 ) < yb * myYScale * zoom ) ||
- ( ( myYPan - h/2 ) > ya * myYScale * zoom ) ) )
- zoom = 1;
-
+ ( ( myXPan - w/2 ) > xa * myXScale * zoom ) ||
+ ( ( myYPan + h/2 ) < yb * myYScale * zoom ) ||
+ ( ( myYPan - h/2 ) > ya * myYScale * zoom ) ) )
+ zoom = 1;
+
myWidth = x;
- myHeight = y;
+ myHeight = y;
- myXScale *= zoom;
- myYScale = myXScale;
+ myXScale *= zoom;
+ myYScale = myXScale;
if ( myGrid )
myGrid->setResize( 2*x, 2*y, zoom );
{
//cout << "GLViewer_ViewPort2d::reset" << endl;
- GLint val[4];
- GLint vpWidth, vpHeight;
+ GLint val[4];
+ GLint vpWidth, vpHeight;
myGLWidget->makeCurrent();
glGetIntegerv( GL_VIEWPORT, val );
- vpWidth = val[2];
- vpHeight = val[3];
+ vpWidth = val[2];
+ vpHeight = val[3];
GLint w = myGLWidget->getWidth();
GLint h = myGLWidget->getHeight();
- GLfloat zoom = vpWidth / ( GLfloat )w < vpHeight / ( GLfloat )h ?
- vpWidth / ( GLfloat )w : vpHeight / ( GLfloat )h;
+ GLfloat zoom = vpWidth / ( GLfloat )w < vpHeight / ( GLfloat )h ?
+ vpWidth / ( GLfloat )w : vpHeight / ( GLfloat )h;
if( myGrid )
{
{
//cout << "GLViewer_ViewPort2d::setCenter" << endl;
- GLint val[4];
- GLint vpWidth, vpHeight;
+ GLint val[4];
+ GLint vpWidth, vpHeight;
myGLWidget->makeCurrent();
glGetIntegerv( GL_VIEWPORT, val );
- vpWidth = val[2];
- vpHeight = val[3];
+ vpWidth = val[2];
+ vpHeight = val[3];
myXPan -= ( x - vpWidth/2 ) / myXScale;
myYPan += ( y - vpHeight/2 ) / myYScale;
void GLViewer_ViewPort2d::zoom( int x0, int y0, int x, int y )
{
//cout << "GLViewer_ViewPort2d::zoom" << endl;
-
+
float dx, dy, zm;
dx = x - x0;
dy = y - y0;
if ( dx == 0. && dy == 0. )
return;
- zm = sqrt(dx * dx + dy * dy) / 100. + 1;
- zm = (dx > 0.) ? zm : 1. / zm;
+ zm = sqrt(dx * dx + dy * dy) / 100. + 1;
+ zm = (dx > 0.) ? zm : 1. / zm;
//backup values
float bX = myXScale;
float bY = myYScale;
- myXScale *= zm;
- myYScale *= zm;
+ myXScale *= zm;
+ myYScale *= zm;
if( myGrid )
{
{// undo
myXScale = bX;
myYScale = bY;
- }
+ }
}
else
{
void GLViewer_ViewPort2d::fitRect( const QRect& rect )
{
float x0, x1, y0, y1;
- float dx, dy, zm, centerX, centerY;
+ float dx, dy, zm, centerX, centerY;
- GLint val[4];
- GLint vpWidth, vpHeight;
+ GLint val[4];
+ GLint vpWidth, vpHeight;
myGLWidget->makeCurrent();
glGetIntegerv( GL_VIEWPORT, val );
- vpWidth = val[2];
- vpHeight = val[3];
+ vpWidth = val[2];
+ vpHeight = val[3];
x0 = rect.left();
x1 = rect.right();
y0 = rect.top();
y1 = rect.bottom();
- dx = fabs( x1 - x0 );
- dy = fabs( y1 - y0 );
- centerX = ( x0 + x1 ) / 2.;
- centerY = ( y0 + y1 ) / 2.;
+ dx = fabs( x1 - x0 );
+ dy = fabs( y1 - y0 );
+ centerX = ( x0 + x1 ) / 2.;
+ centerY = ( y0 + y1 ) / 2.;
if ( dx == 0. || dy == 0. )
return;
- zm = vpWidth / dx < vpHeight / dy ? vpWidth / dx : vpHeight / dy;
+ zm = vpWidth / dx < vpHeight / dy ? vpWidth / dx : vpHeight / dy;
float aDX = ( vpWidth / 2. - centerX ) / myXScale;
float aDY = ( vpHeight / 2. - centerY ) / myYScale;
GLViewer_Context* aContext = aViewer->getGLContext();
if( !aContext )
return;
-
+
QRect aSelRect;
for( aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected() )
aSelRect |= *(aViewer->getWinObjectRect( aContext->SelectedObject() ));
dx = fabs( aBorders[1] - aBorders[0] );
dy = fabs( aBorders[3] - aBorders[2] );
- myXPan = -( aBorders[0] + aBorders[1] ) / 2;
+ myXPan = -( aBorders[0] + aBorders[1] ) / 2;
myYPan = -( aBorders[2] + aBorders[3] ) / 2;
-
+
if( keepScale )
{
xScale = myXScale;
yScale = myYScale;
if( dx && dy )
- zm = vpWidth / dx < vpHeight / dy ? vpWidth / dx : vpHeight / dy;
+ zm = vpWidth / dx < vpHeight / dy ? vpWidth / dx : vpHeight / dy;
else
zm = 1.0;
- myXScale = zm;
- myYScale = zm;
-
+ myXScale = zm;
+ myYScale = zm;
+
if( myGrid )
{
myGrid->setPan( myXPan, myYPan );
if( dx > dy )
myGrid->setZoom( zm / xScale );
- else
+ else
myGrid->setZoom( zm / yScale );
}
float centerX = (xPos/2 - delX - cSize)/xScale;
float centerY = (yPos/2 - delY - cSize)/yScale;
-
+
switch ( cPos )
{
case GLViewer_Compass::TopLeft:
break;
default: break;
}
-
+
float ra, rx, ry, rz;
myGLWidget->getRotation( ra, rx, ry, rz );
GLfloat angle = ra * PI / 180.;
centerY -= yPan;
glColor3f( colorR, colorG, colorB );
- glBegin( GL_POLYGON );
+ glBegin( GL_POLYGON );
//arrow
- x = centerX; y = centerY + cSize / yScale;
+ x = centerX; y = centerY + cSize / yScale;
glVertex2f( x, y );
//point #2
x = centerX + cWidthTop / xScale; y = centerY + ( cSize - cHeightTop ) / yScale ;
glVertex2f( x, y );
- //point #3
+ //point #3
x = centerX + cWidthBot / xScale; y = centerY + ( cSize - cHeightTop ) / yScale ;
glVertex2f( x, y );
//point #4
glVertex2f( x, y );
//point #5
x = centerX; y = centerY - (cSize - cHeightBot) / yScale ;
- glVertex2f( x, y );
+ glVertex2f( x, y );
//point #6
x = centerX - cWidthBot / xScale; y = centerY - cSize/yScale;
glVertex2f( x, y );
{
x = centerX + cos(aCircAngle) * cSize / xScale;
y = centerY + sin(aCircAngle) * cSize / yScale;
- glVertex2f( x, y );
+ glVertex2f( x, y );
aCircAngle += float( STEP ) / 2;
- }
- glEnd();
-
+ }
+ glEnd();
+
GLdouble modelMatrix[16], projMatrix[16];
GLint viewport[4];
GLdouble winxN, winyN, winz;
GLdouble winxE, winyE;
GLdouble winxS, winyS;
GLdouble winxW, winyW;
- GLuint aTextList;
+ GLuint aTextList;
GLViewer_TexFont* aFont = myCompass->getFont();
float widN = (float)aFont->getStringWidth( "N" );
glGetIntegerv (GL_VIEWPORT, viewport);
glGetDoublev (GL_MODELVIEW_MATRIX, modelMatrix);
glGetDoublev (GL_PROJECTION_MATRIX, projMatrix);
-
+
gluProject (centerX, centerY + cSize / yScale, 0, modelMatrix, projMatrix, viewport, &winxN, &winyN, &winz);
gluProject (centerX + cSize / xScale, centerY, 0, modelMatrix, projMatrix, viewport, &winxE, &winyE, &winz);
gluProject (centerX, centerY - cSize / yScale, 0, modelMatrix, projMatrix, viewport, &winxS, &winyS, &winz);
gluProject (centerX - cSize / xScale, centerY, 0, modelMatrix, projMatrix, viewport, &winxW, &winyW, &winz);
- glColor3f( 1.0, 1.0, 1.0 );
+ glColor3f( 1.0, 1.0, 1.0 );
aTextList = glGenLists( 1 );
glNewList( aTextList, GL_COMPILE );
glOrtho(0,viewport[2],0,viewport[3],-100,100);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
- glLoadIdentity();
+ glLoadIdentity();
aFont->drawString( "N", winxN + xGapN, winyN + yGapN );
aFont->drawString( "E", winxE + xGapE, winyE + yGapE );
glEndList();
- if ( aTextList != -1 )
+ if ( aTextList != -1 )
glCallList( aTextList );
}
{
if( myIsDragProcess == inDrag && myCurDragPosX != NULL && myCurDragPosY != NULL)
return BlockStatus(BS_Highlighting | BS_Selection);
-
+
if( mypFirstPoint && mypLastPoint )
return BlockStatus(BS_Highlighting | BS_Selection);
-
+
return BS_NoBlock;
}
if( mypFirstPoint && mypLastPoint )
{
myRectBand->hide(); /* erase */
-
+
mypLastPoint->setX( x );
mypLastPoint->setY( y );
-
+
QRect aRect = selectionRect();
myRectBand->setGeometry( aRect ); /* draw */
myRectBand->setVisible( aRect.isValid() );
gluUnProject( theRect.left(), viewport[3] - theRect.top(), 0, modelMatrix, projMatrix, viewport, &objx1, &objy1, &objz );
gluUnProject( theRect.right(), viewport[3] - theRect.bottom(), 0, modelMatrix, projMatrix, viewport, &objx2, &objy2, &objz );
-
+
aRect.setLeft( objx1 );
aRect.setTop( objy1 );
aRect.setRight( objx2 );
gluProject( theRect.left(), theRect.top(), 0, modelMatrix, projMatrix, viewport, &winx1, &winy1, &winz );
gluProject( theRect.right(), theRect.bottom(), 0, modelMatrix, projMatrix, viewport, &winx2, &winy2, &winz );
-
+
aRect.setLeft( (int)winx1 );
aRect.setTop( viewport[3] - (int)winy1 );
aRect.setRight( (int)winx2 );