}
if( updateViewer )
- myGLViewer2d->activateDrawer( object, TRUE, TRUE );
+ {
+ if( myUpdateAll )
+ myGLViewer2d->updateAll();
+ else
+ myGLViewer2d->activateDrawer( object, TRUE, TRUE );
+ }
}
/*!
}
#endif
-/*!
- Draws rectangle
- \param rect - instance of primitive
- \param lineWidth - width of line
- \param gap - gap of rectangle
- \param color - color of primitive
- \param filled - if it is true, then rectangle will be drawn filled with color "fillingColor"
- \param fillingColor - color of filling
-*/
-void GLViewer_Drawer::drawRectangle( GLViewer_Rect* rect, GLfloat lineWidth, GLfloat gap,
- QColor color, bool filled, QColor fillingColor )
-{
- if( !rect )
- return;
-
- float x1 = rect->left() - gap;
- float x2 = rect->right() + gap;
- float y1 = rect->bottom() - gap;
- float y2 = rect->top() + gap;
-
- if( filled )
- {
- glColor3f( ( GLfloat )fillingColor.red() / 255,
- ( GLfloat )fillingColor.green() / 255,
- ( GLfloat )fillingColor.blue() / 255 );
- glBegin( GL_POLYGON );
- glVertex2f( x1, y1 );
- glVertex2f( x1, y2 );
- glVertex2f( x2, y2 );
- glVertex2f( x2, y1 );
- glEnd();
- }
-
- glColor3f( ( GLfloat )color.red() / 255,
- ( GLfloat )color.green() / 255,
- ( GLfloat )color.blue() / 255 );
- glLineWidth( lineWidth );
-
- glBegin( GL_LINE_LOOP );
- glVertex2f( x1, y1 );
- glVertex2f( x1, y2 );
- glVertex2f( x2, y2 );
- glVertex2f( x2, y1 );
- glEnd();
-}
-
/*!
Draws contour
\param pntList - list of points
static void drawFilledRectangle( GLViewer_Rect*, QColor = Qt::black );
protected:
- //! Draw basic primitives: rectangle, contour, polygon, vertex, cross, arrow
- //* with predefined color
- static void drawRectangle( GLViewer_Rect*, GLfloat, GLfloat = 0, QColor = Qt::black,
- bool = false, QColor = Qt::white );
static void drawContour( GLViewer_Rect*, QColor, GLfloat, GLushort, bool );
static void drawContour( const GLViewer_PntList&, QColor, GLfloat );
static void drawPolygon( GLViewer_Rect*, QColor, GLushort, bool );
}
/*!
- Performs zoom change by step
+ Performs vertical zoom change by step
\param zoomIn - to increase to decrease zoom
*/
GLboolean GLViewer_Object::updateZoom( bool zoomIn )
return img;
}
+/*!
+ Saves image to file according to the format
+ \param image - image
+ \param fileName - name of file
+ \param format - string contains name of format (for example, "BMP"(default) or "JPEG", "JPG")
+*/
+bool GLViewer_ViewFrame::dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format )
+{
+ bool ok = SUIT_ViewWindow::dumpViewToFormat( img, fileName, format );
+ if( ok )
+ emit vfViewDumped( img, fileName, format );
+ return ok;
+}
+
/*!
Start panning
*/
signals:
void vfDrawExternal( QPainter* );
void vfViewClosing( QCloseEvent* );
+ void vfViewDumped( const QImage&, const QString&, const QString& );
+
+protected:
+ virtual bool dumpViewToFormat( const QImage&, const QString& fileName, const QString& format );
protected:
GLViewer_Viewer* myViewer;
{
emit vpMouseEvent( e );
+ if( isPulling() )
+ return;
+
if( myIsDragProcess == inDrag )
onDragObject( e );
}
emit vpMouseEvent( e );
+ if( isPulling() )
+ return;
+
if( myIsDragProcess == inDrag )
{
bool isAnyMoved = false;
}
+/*!
+ Returns tue if selection by rect is preformed
+*/
+bool GLViewer_ViewPort2d::isSelectByRect() const
+{
+ return mypFirstPoint && mypLastPoint;
+}
+
/*!
Finishes rectangle selection
*/
theTextReg = QRect( thePoint.x(), thePoint.y() + cur_height,
aSize.width(), aSize.height() );
theRegion = QRect( thePoint.x(), thePoint.y(), 1, 1 );
+
+ QPoint aBottomRightGlobal = mapToGlobal( theTextReg.bottomRight() );
+ int dx = aBottomRightGlobal.x() - QApplication::desktop()->screenGeometry().width();
+ int dy = aBottomRightGlobal.y() - QApplication::desktop()->screenGeometry().height();
+ dx = dx < 0 ? 0 : -dx;
+ dy = dy < 0 ? 0 : -dy;
+ theTextReg.translate( dx, dy );
}
}
}
class GLViewer_ViewPort2d: public GLViewer_ViewPort
{
Q_OBJECT
+ friend class GLViewer_Widget;
+public:
//! Dragging states
- enum vpDragState{ noDrag, initDrag, inDrag };
+ enum vpDragState{ noDrag = 0, initDrag, inDrag };
public:
GLViewer_ViewPort2d( QWidget* parent, GLViewer_ViewFrame* theViewFrame = NULL );
void endRotation();
//! Checks of dragging process state
- bool isDragProcess(){ return myIsDragProcess; }
+ int isDragProcess(){ return myIsDragProcess; }
//! On/off compass
void turnCompass( GLboolean on );
//! Pass rect into selector and update
void finishSelectByRect();
+ //! Pass rect into selector and update
+ bool isSelectByRect() const;
+
//! \warnign It is for ouv
bool startPulling( GLViewer_Pnt );
//! \warnign It is for ouv
virtual void startOperations( QMouseEvent* ) {}
virtual bool updateOperations( QMouseEvent* ) { return false; }
- virtual void finishOperations( QMouseEvent* ) {}
+ virtual bool finishOperations( QMouseEvent* ) { return false; }
virtual void startOperations( QWheelEvent* ) {}
protected slots:
transPoint( x, y );
GLViewer_Pnt point( x, y );
- if( e->button() == Qt::LeftButton && !myGLContext->getCurrentObject() && vp->startPulling( point ) )
+ // Try to start pooling if rectangular selection is performed
+ if( e->button() == Qt::LeftButton && !vp->isSelectByRect() &&
+ !vp->isDragProcess() && vp->startPulling( point ) )
+ {
+ vp->finishSelectByRect();
return;
+ }
+ // Start rectangular selection if pulling was not started
if( e->button() == Qt::LeftButton && !(vp->currentBlock() & BS_Selection) && !myGLContext->getCurrentObject() )
vp->startSelectByRect( e->x(), e->y() );
}
{
GLViewer_ViewPort2d* vp = ( GLViewer_ViewPort2d* )((GLViewer_ViewFrame*)getActiveView())->getViewPort();
+ float x = e->pos().x();
+ float y = e->pos().y();
+ transPoint( x, y );
+ GLViewer_Pnt point( x, y );
+
if( vp->isPulling() )
{
- float x = e->pos().x();
- float y = e->pos().y();
- transPoint( x, y );
-
- vp->drawPulling( GLViewer_Pnt( x, y ) );
+ vp->drawPulling( point );
updateAll();
return true;
}
+ /*if( vp->isDragProcess() == GLViewer_ViewPort2d::inDrag )
+ return true;*/
+
+ if( e->button() == Qt::LeftButton )
+ {
+ if( !vp->isSelectByRect() && !vp->isDragProcess() && vp->startPulling( point ) )
+ {
+ vp->finishSelectByRect();
+ return true;
+ }
+ }
+
if( !myGLContext->getCurrentObject() )
{
vp->drawSelectByRect( e->x(), e->y() );
}
/*!
- Completes started operation on mouse event
+ Completes started operation on mouse event, Returns true if operation is considered
+ as completely finished and there is no point in performing other actions after finish
+ the operation.
*/
-void GLViewer_Viewer2d::finishOperations( QMouseEvent* e )
+bool GLViewer_Viewer2d::finishOperations( QMouseEvent* e )
{
GLViewer_ViewPort2d* vp = ( GLViewer_ViewPort2d* )((GLViewer_ViewFrame*)getActiveView())->getViewPort();
{
vp->finishPulling();
updateAll();
- return;
+ // Although operation is finished, FALSE is returned because base class try to
+ // perform selection in this case. In the other case it is impossible to perform
+ // selection of pulled port
+ return false;
}
if( !myGLContext->getCurrentObject() )
{
bool append = bool ( e->modifiers() & GLViewer_Selector::appendKey() );
getSelector()->select( aSelRect, append );
+ return true;
}
}
+
+ return false;
}
/*!
//! Updates started operations on mouse event
virtual bool updateOperations( QMouseEvent* );
//! Completes started operations on mouse event
- virtual void finishOperations( QMouseEvent* );
+ virtual bool finishOperations( QMouseEvent* );
//! Starts any operations on mouse wheel event
virtual void startOperations( QWheelEvent* );
if( w < 1 ) w = 1;
glViewport( 0, 0, w, h);
+ myViewPort->initResize( w, h );
+
if( myStart )
{
myWidth = w;
myHeight = h;
+ myViewPort->fitAll();
myStart = GL_FALSE;
}
- myViewPort->initResize( w, h );
-
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
GLfloat w_c = w / 2., h_c = h / 2.;