Version: 9.15.0
GLViewer_ViewPort2d Class Reference

#include <GLViewer_ViewPort2d.h>

Inheritance diagram for GLViewer_ViewPort2d:
Inheritance graph

Signals

void vpUpdateValues ()
 Emits after any transformation. More...
 
void objectMoved ()
 
- Signals inherited from GLViewer_ViewPort
void vpKeyEvent (QKeyEvent *)
 
void vpMouseEvent (QMouseEvent *)
 
void vpWheelEvent (QWheelEvent *)
 
void vpDrawExternal (QPainter *)
 
void contextMenuRequested (QContextMenuEvent *)
 

Public Member Functions

 GLViewer_ViewPort2d (QWidget *parent, GLViewer_ViewFrame *theViewFrame=NULL)
 
 ~GLViewer_ViewPort2d ()
 
void turnGrid (GLboolean on)
 On/off rectangular grid. More...
 
GLViewer_GridgetGrid () const
 Returns rectangular grid. More...
 
void setGridColor (const QColor gridColor, const QColor axisColor)
 Returns grid color. More...
 
GLViewer_ViewFramegetViewFrame () const
 Returns parent window. More...
 
GLViewer_WidgetgetGLWidget () const
 Returns painted widget. More...
 
virtual QPaintDevice * getPaintDevice ()
 
void setBackgroundColor (const QColor &color)
 Sets background color. More...
 
QColor backgroundColor () const
 Returns background color. More...
 
void setBorder (GLViewer_Rect *border)
 Sets borders of scene. More...
 
GLViewer_RectgetBorder () const
 Get current borders of scene. More...
 
void setMargin (GLfloat margin)
 Sets margin of borders. More...
 
GLfloat getMargin () const
 Returns margin of borders. More...
 
int getWidth () const
 Returns width of view. More...
 
int getHeight () const
 Returns height of view. More...
 
void getScale (GLfloat &xSc, GLfloat &ySc) const
 Returns scale factors. More...
 
void getPan (GLfloat &xPan, GLfloat &yPan) const
 returns offsets More...
 
void initResize (int width, int height)
 Resize view. More...
 
void startRotation (int, int)
 Begins rotation. More...
 
void rotate (int, int)
 Process rotation. More...
 
void endRotation ()
 Completes rotation. More...
 
bool isDragProcess ()
 Checks of dragging process state. More...
 
void turnCompass (GLboolean on)
 On/off compass. More...
 
void drawCompass ()
 Draws compass. More...
 
int getViewPortId ()
 Returns unique ID of ViewPort. More...
 
virtual BlockStatus currentBlock ()
 Redefined method. More...
 
void startSelectByRect (int x, int y)
 Initializes before selecting by rect. More...
 
void drawSelectByRect (int x, int y)
 Draw selecting rectandle. More...
 
void finishSelectByRect ()
 Pass rect into selector and update. More...
 
bool startPulling (GLViewer_Pnt)
 \warnign It is for ouv More...
 
void drawPulling (GLViewer_Pnt)
 \warnign It is for ouv More...
 
void finishPulling ()
 \warnign It is for ouv More...
 
bool isPulling () const
 \warnign It is for ouv More...
 
QRect selectionRect ()
 Returns selection by rect. More...
 
GLViewer_Rect win2GLV (const QRect &) const
 Transforms window rect to global rect. More...
 
QRect GLV2win (const GLViewer_Rect &) const
 Transforms global rect to window rect. More...
 
- Public Member Functions inherited from GLViewer_ViewPort
 GLViewer_ViewPort (QWidget *parent)
 
 ~GLViewer_ViewPort ()
 
void setSketchingEnabled (bool)
 Activates/deactivates sketching. More...
 
bool isSketchingEnabled () const
 Checks active status of sketcher. More...
 
void setTransformEnabled (bool)
 Activates/deactivates transformer. More...
 
bool isTransformEnabled () const
 Checks active status of transformer. More...
 
void redrawPainters ()
 Redraw external pa inters. More...
 
virtual void onUpdate ()
 Updates view. More...
 

Protected Slots

void onStartDragObject ()
 Initializes drag process. More...
 
void onPasteObject ()
 Pastes object from clipboard. More...
 
void onCutObject ()
 Cuts object to clipboard. More...
 
void onCopyObject ()
 Copies object to clipboard. More...
 
void onMaybeTip (QPoint thePoint, QString &text, QFont &font, QRect &theTextReg, QRect &theViewReg)
 Sets tool tip with. More...
 
- Protected Slots inherited from GLViewer_ViewPort
virtual void onChangeBgColor ()
 

Protected Member Functions

void onDragObject (QMouseEvent *)
 
virtual void mouseMoveEvent (QMouseEvent *)
 
virtual void mousePressEvent (QMouseEvent *)
 
virtual void mouseReleaseEvent (QMouseEvent *)
 
virtual void mouseDoubleClickEvent (QMouseEvent *)
 
virtual void paintEvent (QPaintEvent *)
 
virtual void resizeEvent (QResizeEvent *)
 
virtual void reset ()
 Returns view to begin state. More...
 
virtual void pan (int dx, int dy)
 Sets offset to view. More...
 
virtual void setCenter (int x, int y)
 Sets view center in global coords. More...
 
virtual void zoom (int x0, int y0, int x1, int y1)
 Process zoming transformation with mouse tracking from ( x0, y0 ) to ( x1, y1 ) More...
 
virtual void fitRect (const QRect &)
 Transforms view by rectangle. More...
 
virtual void fitSelect ()
 Transforms view by selection. More...
 
virtual void fitAll (bool keepScale=false, bool withZ=true)
 Transform view by view borders ( if. More...
 
- Protected Member Functions inherited from GLViewer_ViewPort
void selectVisualId (ViewType)
 
virtual void contextMenuEvent (QContextMenuEvent *e)
 
virtual void keyPressEvent (QKeyEvent *)
 
virtual void keyReleaseEvent (QKeyEvent *)
 
virtual void wheelEvent (QWheelEvent *)
 

Protected Attributes

GLViewer_ViewFramemyViewFrame
 
GLViewer_WidgetmyGLWidget
 
GLViewer_RectmyBorder
 
QColor myBackgroundColor
 
GLfloat myMargin
 
int myHeight
 
int myWidth
 
GLfloat myXScale
 
GLfloat myYScale
 
GLfloat myXOldScale
 
GLfloat myYOldScale
 
GLfloat myXPan
 
GLfloat myYPan
 
GLViewer_GridmyGrid
 
GLViewer_CompassmyCompass
 
int myIsDragProcess
 
float * myCurDragPosX
 
float * myCurDragPosY
 
QPoint * mypFirstPoint
 
QPoint * mypLastPoint
 
bool myIsPulling
 
GLViewer_ObjectmyPullingObject
 
int myViewPortId
 
QtxToolTipmyObjectTip
 
bool myIsMouseReleaseBlock
 flag to block mouse release event just after mouse double-click More...
 
QRubberBand * myRectBand
 selection rectangle rubber band More...
 
- Protected Attributes inherited from GLViewer_ViewPort
bool myEnableSketching
 
bool myEnableTransform
 
bool myPaintersRedrawing
 

Private Types

enum  vpDragState { noDrag , initDrag , inDrag }
 Dragging states. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from GLViewer_ViewPort
static QCursor * getDefaultCursor ()
 
static void setDefaultCursor (const QCursor &newCursor)
 
static QCursor * getRotCursor ()
 
static void setRotCursor (const QCursor &newCursor)
 
static QCursor * getSketchCursor ()
 
static void setSketchCursor (const QCursor &newCursor)
 
- Protected Types inherited from GLViewer_ViewPort
enum  ViewType { Type2D , Type3D }
 
- Static Protected Member Functions inherited from GLViewer_ViewPort
static void createCursors ()
 STATICS. More...
 
static void destroyCursors ()
 
static QCursor * getHandCursor ()
 
static void setHandCursor (const QCursor &newCursor)
 
static QCursor * getPanCursor ()
 
static void setPanCursor (const QCursor &newCursor)
 
static QCursor * getPanglCursor ()
 
static void setPanglCursor (const QCursor &newCursor)
 
static QCursor * getZoomCursor ()
 
static void setZoomCursor (const QCursor &newCursor)
 

Detailed Description

Class GLViewer_ViewPort 2D visualisation canvas of GLViewer

Member Enumeration Documentation

◆ vpDragState

Dragging states.

Enumerator
noDrag 
initDrag 
inDrag 

Constructor & Destructor Documentation

◆ GLViewer_ViewPort2d()

GLViewer_ViewPort2d::GLViewer_ViewPort2d ( QWidget parent,
GLViewer_ViewFrame theViewFrame = NULL 
)

◆ ~GLViewer_ViewPort2d()

GLViewer_ViewPort2d::~GLViewer_ViewPort2d ( )

Destructor

References myBorder, myCompass, myGLWidget, myGrid, and myRectBand.

Member Function Documentation

◆ backgroundColor()

QColor GLViewer_ViewPort2d::backgroundColor ( ) const
virtual

Returns background color.

Returns
background color

Reimplemented from GLViewer_ViewPort.

References GLViewer_ViewPort::backgroundColor().

◆ currentBlock()

BlockStatus GLViewer_ViewPort2d::currentBlock ( )
virtual

Redefined method.

Returns
blocking status for current started operations

Reimplemented from GLViewer_ViewPort.

References BS_Highlighting, BS_NoBlock, BS_Selection, inDrag, myCurDragPosX, myCurDragPosY, myIsDragProcess, mypFirstPoint, and mypLastPoint.

◆ drawCompass()

◆ drawPulling()

◆ drawSelectByRect()

void GLViewer_ViewPort2d::drawSelectByRect ( int  x,
int  y 
)

Draw selecting rectandle.

Draws rectangle selection

Parameters
x,y- current point

References mypFirstPoint, mypLastPoint, myRectBand, and selectionRect().

◆ endRotation()

void GLViewer_ViewPort2d::endRotation ( )

Completes rotation.

Finishes rotation

References GLViewer_Widget::getRotation(), myGLWidget, rx, ry, and GLViewer_Widget::setRotationAngle().

◆ finishPulling()

void GLViewer_ViewPort2d::finishPulling ( )

◆ finishSelectByRect()

void GLViewer_ViewPort2d::finishSelectByRect ( )

Pass rect into selector and update.

Finishes rectangle selection

References mypFirstPoint, mypLastPoint, and myRectBand.

◆ fitAll()

void GLViewer_ViewPort2d::fitAll ( bool  keepScale = false,
bool  withZ = true 
)
protectedvirtual

◆ fitRect()

void GLViewer_ViewPort2d::fitRect ( const QRect &  rect)
protectedvirtual

Transforms view by rectangle.

Transforms view by rectangle

Parameters
rect- rectangle

Implements GLViewer_ViewPort.

References GLViewer_Widget::getRotation(), myGLWidget, myGrid, myXPan, myXScale, myYPan, myYScale, PI, rx, ry, GLViewer_Grid::setPan(), GLViewer_Widget::setPan(), GLViewer_Widget::setScale(), and GLViewer_Grid::setZoom().

◆ fitSelect()

◆ getBorder()

GLViewer_Rect* GLViewer_ViewPort2d::getBorder ( ) const
inline

Get current borders of scene.

References myBorder.

◆ getGLWidget()

GLViewer_Widget* GLViewer_ViewPort2d::getGLWidget ( ) const
inline

Returns painted widget.

References myGLWidget.

◆ getGrid()

GLViewer_Grid* GLViewer_ViewPort2d::getGrid ( ) const
inline

Returns rectangular grid.

References myGrid.

◆ getHeight()

int GLViewer_ViewPort2d::getHeight ( ) const
inline

Returns height of view.

References myHeight.

◆ getMargin()

GLfloat GLViewer_ViewPort2d::getMargin ( ) const
inline

Returns margin of borders.

References myMargin.

◆ getPaintDevice()

virtual QPaintDevice* GLViewer_ViewPort2d::getPaintDevice ( )
inlinevirtual

Reimplemented from GLViewer_ViewPort.

References myGLWidget.

◆ getPan()

void GLViewer_ViewPort2d::getPan ( GLfloat &  xPan,
GLfloat &  yPan 
) const
inline

returns offsets

References myXPan, and myYPan.

◆ getScale()

void GLViewer_ViewPort2d::getScale ( GLfloat &  xSc,
GLfloat &  ySc 
) const
inline

Returns scale factors.

References myXScale, and myYScale.

◆ getViewFrame()

GLViewer_ViewFrame* GLViewer_ViewPort2d::getViewFrame ( ) const
inline

Returns parent window.

References myViewFrame.

◆ getViewPortId()

int GLViewer_ViewPort2d::getViewPortId ( )
inline

Returns unique ID of ViewPort.

References myViewPortId.

◆ getWidth()

int GLViewer_ViewPort2d::getWidth ( ) const
inline

Returns width of view.

References myWidth.

◆ GLV2win()

QRect GLViewer_ViewPort2d::GLV2win ( const GLViewer_Rect theRect) const

Transforms global rect to window rect.

Convert rectangle in GL co-ordinates to window co-ordinates

Returns
converted rectangle

References GLViewer_Rect::bottom(), GLViewer_Rect::left(), modelMatrix, GLViewer_Rect::right(), and GLViewer_Rect::top().

◆ initResize()

◆ isDragProcess()

bool GLViewer_ViewPort2d::isDragProcess ( )
inline

Checks of dragging process state.

References myIsDragProcess.

◆ isPulling()

bool GLViewer_ViewPort2d::isPulling ( ) const
inline

\warnign It is for ouv

References myIsPulling.

◆ mouseDoubleClickEvent()

void GLViewer_ViewPort2d::mouseDoubleClickEvent ( QMouseEvent *  e)
protectedvirtual

Custom mouse double click event handler

Reimplemented from GLViewer_ViewPort.

References GLViewer_ViewPort::mouseDoubleClickEvent(), and myIsMouseReleaseBlock.

◆ mouseMoveEvent()

void GLViewer_ViewPort2d::mouseMoveEvent ( QMouseEvent *  e)
protectedvirtual

Emits 'mouseEvent' signal. [ virtual protected ]

Reimplemented from GLViewer_ViewPort.

References inDrag, myIsDragProcess, onDragObject(), and GLViewer_ViewPort::vpMouseEvent().

◆ mousePressEvent()

void GLViewer_ViewPort2d::mousePressEvent ( QMouseEvent *  e)
protectedvirtual

◆ mouseReleaseEvent()

◆ objectMoved

void GLViewer_ViewPort2d::objectMoved ( )
signal

◆ onCopyObject

void GLViewer_ViewPort2d::onCopyObject ( )
protectedslot

◆ onCutObject

◆ onDragObject()

◆ onMaybeTip

void GLViewer_ViewPort2d::onMaybeTip ( QPoint  thePoint,
QString &  theText,
QFont &  theFont,
QRect &  theTextReg,
QRect &  theRegion 
)
protectedslot

Sets tool tip with.

Parameters
textto
theTextRegand on
theViewRegwhan mouse is on
thePointSLOT: called when tooltip should be shown

References GLViewer_Context::getCurrentObject(), GLViewer_Object::getName(), GLViewer_Object::getToolTipText(), GLViewer_ViewFrame::getViewer(), getViewFrame(), and GLViewer_Object::isTooTipHTML().

◆ onPasteObject

void GLViewer_ViewPort2d::onPasteObject ( )
protectedslot

Pastes object from clipboard.

SLOT: pastes object from clipboard

◆ onStartDragObject

void GLViewer_ViewPort2d::onStartDragObject ( )
protectedslot

Initializes drag process.

SLOT: initializes drag process

References initDrag, myCurDragPosX, myCurDragPosY, myIsDragProcess, and noDrag.

◆ paintEvent()

void GLViewer_ViewPort2d::paintEvent ( QPaintEvent *  e)
protectedvirtual

Custom paint event handler

Reimplemented from GLViewer_ViewPort.

References myGLWidget, and GLViewer_ViewPort::paintEvent().

◆ pan()

void GLViewer_ViewPort2d::pan ( int  dx,
int  dy 
)
protectedvirtual

Sets offset to view.

Sets offset to view

Parameters
dx- X offset
dy- Y offset

Implements GLViewer_ViewPort.

References GLViewer_Widget::getRotation(), myGLWidget, myGrid, myXPan, myXScale, myYPan, myYScale, PI, rx, ry, GLViewer_Grid::setPan(), GLViewer_Widget::setPan(), and GLViewer_Widget::setScale().

◆ reset()

◆ resizeEvent()

void GLViewer_ViewPort2d::resizeEvent ( QResizeEvent *  e)
protectedvirtual

Custom resize event handler

◆ rotate()

void GLViewer_ViewPort2d::rotate ( int  intX,
int  intY 
)

Process rotation.

Performs rotation

Parameters
intX,intY- current point

References GLViewer_Widget::getRotation(), GLViewer_Widget::getRotationAngle(), GLViewer_Widget::getRotationStart(), myGLWidget, PI, rx, ry, and GLViewer_Widget::setRotation().

◆ selectionRect()

QRect GLViewer_ViewPort2d::selectionRect ( )

Returns selection by rect.

Returns
rectangle selection

References mypFirstPoint, and mypLastPoint.

◆ setBackgroundColor()

void GLViewer_ViewPort2d::setBackgroundColor ( const QColor &  color)
virtual

Sets background color.

Changes background color

Parameters
color- new background color

Reimplemented from GLViewer_ViewPort.

References OCCViewer::color(), myGLWidget, and GLViewer_ViewPort::setBackgroundColor().

◆ setBorder()

void GLViewer_ViewPort2d::setBorder ( GLViewer_Rect border)
inline

Sets borders of scene.

References myBorder.

◆ setCenter()

void GLViewer_ViewPort2d::setCenter ( int  x,
int  y 
)
protectedvirtual

Sets view center in global coords.

Sets view center in global coords

Parameters
x,y- global co-ordinates of center

Implements GLViewer_ViewPort.

References myGLWidget, myGrid, myXOldScale, myXPan, myXScale, myYOldScale, myYPan, myYScale, GLViewer_Grid::setPan(), GLViewer_Widget::setPan(), GLViewer_Widget::setScale(), and GLViewer_Grid::setZoom().

◆ setGridColor()

void GLViewer_ViewPort2d::setGridColor ( const QColor  gridColor,
const QColor  axisColor 
)

Returns grid color.

Changes grid color

Parameters
gridColor- new grid color
axisColor- new axis color

References myGrid, GLViewer_Grid::setAxisColor(), and GLViewer_Grid::setGridColor().

◆ setMargin()

void GLViewer_ViewPort2d::setMargin ( GLfloat  margin)
inline

Sets margin of borders.

References myMargin.

◆ startPulling()

◆ startRotation()

void GLViewer_ViewPort2d::startRotation ( int  x,
int  y 
)

Begins rotation.

Begins rotation

Parameters
x,y- start point

References myGLWidget, and GLViewer_Widget::setRotationStart().

◆ startSelectByRect()

void GLViewer_ViewPort2d::startSelectByRect ( int  x,
int  y 
)

Initializes before selecting by rect.

Initializes rectangle selection

Parameters
x,y- start point

References mypFirstPoint, mypLastPoint, myRectBand, and Plot2d::Rectangle.

◆ turnCompass()

void GLViewer_ViewPort2d::turnCompass ( GLboolean  on)

On/off compass.

Creates or deletes compass

Parameters
on- if it is true, then to create

References myCompass, and GLViewer_Compass::TopRight.

◆ turnGrid()

void GLViewer_ViewPort2d::turnGrid ( GLboolean  on)

On/off rectangular grid.

Creates or deletes grid

Parameters
on- if it is true, then to create

References GRID_XSIZE, GRID_YSIZE, HEIGHT, myGrid, myXPan, myXScale, myYPan, myYScale, and WIDTH.

◆ vpUpdateValues

void GLViewer_ViewPort2d::vpUpdateValues ( )
signal

Emits after any transformation.

◆ win2GLV()

GLViewer_Rect GLViewer_ViewPort2d::win2GLV ( const QRect &  theRect) const

Transforms window rect to global rect.

Convert rectangle in window co-ordinates to GL co-ordinates

Returns
converted rectangle

References modelMatrix, GLViewer_Rect::setBottom(), GLViewer_Rect::setLeft(), GLViewer_Rect::setRight(), and GLViewer_Rect::setTop().

◆ zoom()

void GLViewer_ViewPort2d::zoom ( int  x0,
int  y0,
int  x,
int  y 
)
protectedvirtual

Process zoming transformation with mouse tracking from ( x0, y0 ) to ( x1, y1 )

Process zoming transformation with mouse tracking from ( x0, y0 ) to ( x1, y1 )

Implements GLViewer_ViewPort.

References myGLWidget, myGrid, myXPan, myXScale, myYPan, myYScale, GLViewer_Widget::setPan(), GLViewer_Widget::setScale(), and GLViewer_Grid::setZoom().

Member Data Documentation

◆ myBackgroundColor

QColor GLViewer_ViewPort2d::myBackgroundColor
protected

◆ myBorder

GLViewer_Rect* GLViewer_ViewPort2d::myBorder
protected

◆ myCompass

GLViewer_Compass* GLViewer_ViewPort2d::myCompass
protected

◆ myCurDragPosX

float* GLViewer_ViewPort2d::myCurDragPosX
protected

◆ myCurDragPosY

float* GLViewer_ViewPort2d::myCurDragPosY
protected

◆ myGLWidget

GLViewer_Widget* GLViewer_ViewPort2d::myGLWidget
protected

◆ myGrid

GLViewer_Grid* GLViewer_ViewPort2d::myGrid
protected

◆ myHeight

int GLViewer_ViewPort2d::myHeight
protected

◆ myIsDragProcess

int GLViewer_ViewPort2d::myIsDragProcess
protected

◆ myIsMouseReleaseBlock

bool GLViewer_ViewPort2d::myIsMouseReleaseBlock
protected

flag to block mouse release event just after mouse double-click

◆ myIsPulling

bool GLViewer_ViewPort2d::myIsPulling
protected

◆ myMargin

GLfloat GLViewer_ViewPort2d::myMargin
protected

◆ myObjectTip

QtxToolTip* GLViewer_ViewPort2d::myObjectTip
protected

◆ mypFirstPoint

QPoint* GLViewer_ViewPort2d::mypFirstPoint
protected

◆ mypLastPoint

QPoint* GLViewer_ViewPort2d::mypLastPoint
protected

◆ myPullingObject

GLViewer_Object* GLViewer_ViewPort2d::myPullingObject
protected

◆ myRectBand

QRubberBand* GLViewer_ViewPort2d::myRectBand
protected

selection rectangle rubber band

◆ myViewFrame

GLViewer_ViewFrame* GLViewer_ViewPort2d::myViewFrame
protected

◆ myViewPortId

int GLViewer_ViewPort2d::myViewPortId
protected

◆ myWidth

int GLViewer_ViewPort2d::myWidth
protected

◆ myXOldScale

GLfloat GLViewer_ViewPort2d::myXOldScale
protected

◆ myXPan

GLfloat GLViewer_ViewPort2d::myXPan
protected

◆ myXScale

GLfloat GLViewer_ViewPort2d::myXScale
protected

◆ myYOldScale

GLfloat GLViewer_ViewPort2d::myYOldScale
protected

◆ myYPan

GLfloat GLViewer_ViewPort2d::myYPan
protected

◆ myYScale

GLfloat GLViewer_ViewPort2d::myYScale
protected

The documentation for this class was generated from the following files: