Version: 9.12.0
GLViewer_Viewer2d Class Reference

#include <GLViewer_Viewer2d.h>

Inheritance diagram for GLViewer_Viewer2d:
Inheritance graph

Public Types

enum  GLSketchingType {
  None , Polyline , Arc , Curve ,
  Scribble , Oval , Rectangle
}
 Type of sketcher operation
More...
 
enum  VectorFileType { POST_SCRIPT , HPGL }
 Type of export vector file. More...
 
enum  PaperType {
  A1 =0 , A2 , A3 , A4 ,
  A5
}
 Type of paper for export to vector format. More...
 
- Public Types inherited from GLViewer_Viewer
enum  SelectionMode { NoSelection , Single , Multiple }
 
enum  TransformType {
  NoTransform , Reset , FitAll , FitRect ,
  FitSelect , Zoom , PanGlobal , Pan ,
  Rotate , UserTransform = 100
}
 
enum  SketchingType { NoSketching , Rect , UserSketching = 100 }
 
- Public Types inherited from SUIT_ViewModel
enum  HotOperation { PAN , ZOOM , ROTATE , FIT_AREA }
 
enum  InteractionStyle { STANDARD , KEY_FREE }
 
typedef QMap< HotOperation, Qt::KeyboardModifiers > StatesMap
 
typedef QMap< HotOperation, Qt::MouseButtons > ButtonsMap
 
typedef QMap< InteractionStyle, StatesMapInteractionStyle2StatesMap
 
typedef QMap< InteractionStyle, ButtonsMapInteractionStyle2ButtonsMap
 

Public Slots

void onChangeBgColor ()
 Changes background color. More...
 
void onCreateGLMarkers (int number=1000, int size=5)
 Creates set of marker number. More...
 
void onCreateGLPolyline (int number=100, int angles=10, int size=100)
 Creates set of polyline number. More...
 
void onCreateGLText (QString text="Text", int number=1)
 Creates set of text number. More...
 

Signals

void wheelZoomChange (bool)
 Signal needs for optimum recompute of zoom depending objects Warning: use recompute without update viewer. More...
 
- Signals inherited from GLViewer_Viewer
void selectionChanged (SelectionChangeStatus)
 

Public Member Functions

 GLViewer_Viewer2d (const QString &title)
 A constructor. More...
 
 ~GLViewer_Viewer2d ()
 A destructor. More...
 
virtual SUIT_ViewWindowcreateView (SUIT_Desktop *)
 Redefined method. More...
 
void addPopupItems (QMenu *)
 Adds item for change background color. More...
 
const QList< GLViewer_Drawer * > & getDrawers () const
 Returns all drawers. More...
 
GLViewer_ContextgetGLContext () const
 Returns context. More...
 
void updateColors (QColor colorH, QColor colorS)
 Updates colors for all drawers (does not work) More...
 
void updateBorders (GLViewer_Rect *theRect)
 Updates rect of global scene by adding new rect. More...
 
void updateBorders ()
 Recomputes global scene rect. More...
 
void updateAll ()
 Redraws all active objects by updating all drawers in all views. More...
 
void updateDrawers (GLboolean onlyUpdate, GLfloat scX=0.0, GLfloat scY=0.0)
 Updates all drawers with new scale factor. More...
 
void activateDrawers (QList< GLViewer_Object * > &theObjects, bool onlyUpdate, GLboolean swap=GL_FALSE)
 Activates drawers for objects from list. More...
 
void activateDrawer (GLViewer_Object *theObject, bool onlyUpdate, GLboolean swap=GL_FALSE)
 Activates drawer for. More...
 
void activateAllDrawers (bool onlyUpdate, GLboolean swap=GL_FALSE)
 Updates all drawers with new scale factor. More...
 
void transPoint (GLfloat &x, GLfloat &y)
 Translates point (x,y) from global CS to curreent viewer CS. More...
 
QRect * getWinObjectRect (GLViewer_Object *theObject)
 Returns object rect in window CS. More...
 
GLViewer_Rect getGLVRect (const QRect &) const
 Translates rect in window CS to rect in global CS. More...
 
QRect getQRect (const GLViewer_Rect &) const
 Translates rect in global CS to rect in window CS. More...
 
virtual void insertHeader (VectorFileType aType, QFile &hFile)
 Inserts common text lines starting file of. More...
 
virtual void insertEnding (VectorFileType aType, QFile &hFile)
 Inserts common text lines ending file of. More...
 
virtual bool translateTo (VectorFileType aType, QString FileName, PaperType aPType, double mmLeft, double mmRight, double mmTop, double mmBottom)
 Translates current view content to vector file. More...
 
void repaintView (GLViewer_ViewFrame *theView=NULL, bool makeCurrent=false)
 Repaints view. More...
 
- Public Member Functions inherited from GLViewer_Viewer
 GLViewer_Viewer (const QString &title)
 
 ~GLViewer_Viewer ()
 
virtual void setViewManager (SUIT_ViewManager *theViewManager)
 
virtual QString getType () const
 
virtual void contextMenuPopup (QMenu *)
 
void setSelectionMode (SelectionMode)
 
SelectionMode getSelectionMode () const
 
GLViewer_SelectorgetSelector () const
 
virtual void update (int=0)
 
void activateTransform (int)
 
void activateSketching (int)
 
GLViewer_ViewFramegetActiveView () const
 
- Public Member Functions inherited from SUIT_ViewModel
 SUIT_ViewModel ()
 
virtual ~SUIT_ViewModel ()
 
SUIT_ViewManagergetViewManager () const
 

Protected Slots

void onMouseEvent (SUIT_ViewWindow *, QMouseEvent *)
 
- Protected Slots inherited from GLViewer_Viewer
virtual void onKeyEvent (SUIT_ViewWindow *, QKeyEvent *)
 
virtual void onMouseEvent (SUIT_ViewWindow *, QMouseEvent *)
 
virtual void onWheelEvent (SUIT_ViewWindow *, QWheelEvent *)
 
virtual void onSelectionCancel ()
 
virtual void onSelectionDone (bool add, SelectionChangeStatus status)
 
virtual void onChangeBgColor ()
 

Protected Member Functions

GLViewer_SelectorcreateSelector ()
 Returns new selector. More...
 
GLViewer_ViewTransformercreateTransformer (int type)
 Returns new Transformer with type. More...
 
void transformCoordsToPS (double &x, double &y)
 Transforms point (x,y) in Viewer CS to Post Script CS. More...
 
void transformCoordsToHPGL (double &x, double &y)
 Transforms point (x,y) in Viewer CS to HPGL CS. More...
 
virtual void startOperations (QMouseEvent *)
 Starts any operations on mouse event. More...
 
virtual bool updateOperations (QMouseEvent *)
 Updates started operations on mouse event. More...
 
virtual void finishOperations (QMouseEvent *)
 Completes started operations on mouse event. More...
 
virtual void startOperations (QWheelEvent *)
 Starts any operations on mouse wheel event. More...
 
- Protected Member Functions inherited from GLViewer_Viewer
virtual void onSketchingStarted ()
 
virtual void onSketchingFinished ()
 
virtual void onTransformationStarted ()
 
virtual void onTransformationFinished ()
 
virtual void onSelectionModeChanged ()
 
virtual void unhilightDetected ()
 
virtual bool eventFilter (QObject *, QEvent *)
 
virtual GLViewer_ViewSketchercreateSketcher (int)
 

Protected Attributes

GLViewer_ContextmyGLContext
 Current context. More...
 
QList< GLViewer_Drawer * > myDrawers
 Map of active drawers. More...
 
- Protected Attributes inherited from GLViewer_Viewer
GLViewer_SelectormySelector
 
SelectionMode mySelMode
 
GLViewer_ViewSketchermySketcher
 
GLViewer_ViewTransformermyTransformer
 
- Protected Attributes inherited from SUIT_ViewModel
SUIT_ViewManagermyViewManager
 

Private Member Functions

bool testRotation (QMouseEvent *)
 Rotation transformation. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from GLViewer_Viewer
static QString Type ()
 
- Static Public Member Functions inherited from SUIT_ViewModel
static void setHotButton (InteractionStyle theInteractionStyle, HotOperation theOper, Qt::KeyboardModifiers theState, Qt::MouseButtons theButton)
 
static void getHotButton (InteractionStyle theInteractionStyle, HotOperation theOper, Qt::KeyboardModifiers &theState, Qt::MouseButtons &theButton)
 
- Static Public Attributes inherited from SUIT_ViewModel
static InteractionStyle2StatesMap myStateMap
 
static InteractionStyle2ButtonsMap myButtonMap
 

Detailed Description

OpenGL Viewer 2D

Member Enumeration Documentation

◆ GLSketchingType

Type of sketcher operation

Enumerator
None 
Polyline 
Arc 
Curve 
Scribble 
Oval 
Rectangle 

◆ PaperType

Type of paper for export to vector format.

Enumerator
A1 
A2 
A3 
A4 
A5 

◆ VectorFileType

Type of export vector file.

Enumerator
POST_SCRIPT 
HPGL 

Constructor & Destructor Documentation

◆ GLViewer_Viewer2d()

GLViewer_Viewer2d::GLViewer_Viewer2d ( const QString &  title)

A constructor.

Constructor

Parameters
title- viewer title

References createSelector(), GLViewer_Viewer::Multiple, myDrawers, myGLContext, and GLViewer_Viewer::mySelMode.

◆ ~GLViewer_Viewer2d()

GLViewer_Viewer2d::~GLViewer_Viewer2d ( )

A destructor.

Destructor

References GLViewer_TexFont::clearTextBases().

Member Function Documentation

◆ activateAllDrawers()

void GLViewer_Viewer2d::activateAllDrawers ( bool  onlyUpdate,
GLboolean  swap = GL_FALSE 
)

Updates all drawers with new scale factor.

Parameters
onlyUpdateis passed to drawers

References activateDrawers(), GLViewer_Viewer::getActiveView(), GLViewer_Context::getObjects(), GLViewer_Object::getVisible(), and myGLContext.

◆ activateDrawer()

void GLViewer_Viewer2d::activateDrawer ( GLViewer_Object theObject,
bool  onlyUpdate,
GLboolean  swap = GL_FALSE 
)

Activates drawer for.

Parameters
theObjectActivates drawer for
theObject

References activateDrawers().

◆ activateDrawers()

void GLViewer_Viewer2d::activateDrawers ( QList< GLViewer_Object * > &  theObjects,
bool  onlyUpdate,
GLboolean  swap = GL_FALSE 
)

◆ addPopupItems()

void GLViewer_Viewer2d::addPopupItems ( QMenu thePopup)

Adds item for change background color.

Adds item for change background color

Parameters
thePopup- menu

References GLViewer_Viewer::getSelector(), and onChangeBgColor().

◆ createSelector()

GLViewer_Selector * GLViewer_Viewer2d::createSelector ( )
protectedvirtual

Returns new selector.

Returns
new selector

Reimplemented from GLViewer_Viewer.

References getGLContext().

◆ createTransformer()

GLViewer_ViewTransformer * GLViewer_Viewer2d::createTransformer ( int  type)
protectedvirtual

Returns new Transformer with type.

Parameters
type
Returns
new Transformer
Parameters
type- type of new transformer

Reimplemented from GLViewer_Viewer.

◆ createView()

SUIT_ViewWindow * GLViewer_Viewer2d::createView ( SUIT_Desktop theDesktop)
virtual

Redefined method.

Create new instance of view window on desktop theDesktop.

Return values
SUIT_ViewWindow*- created view window pointer.

Reimplemented from SUIT_ViewModel.

◆ finishOperations()

void GLViewer_Viewer2d::finishOperations ( QMouseEvent *  e)
protectedvirtual

◆ getDrawers()

const QList<GLViewer_Drawer*>& GLViewer_Viewer2d::getDrawers ( ) const
inline

Returns all drawers.

◆ getGLContext()

GLViewer_Context* GLViewer_Viewer2d::getGLContext ( ) const
inline

Returns context.

◆ getGLVRect()

GLViewer_Rect GLViewer_Viewer2d::getGLVRect ( const QRect &  theRect) const

Translates rect in window CS to rect in global CS.

Translates rect in window CS to rect in global CS

Parameters
theRect- rectangle to be translated
Returns
transformed rect

References GLViewer_Viewer::getActiveView(), GLViewer_ViewFrame::getViewPort(), and GLViewer_ViewPort2d::win2GLV().

◆ getQRect()

QRect GLViewer_Viewer2d::getQRect ( const GLViewer_Rect theRect) const

Translates rect in global CS to rect in window CS.

Translates rect in global CS to rect in window CS

Parameters
theRect- rectangle to be translated
Returns
transformed rect

References GLViewer_Viewer::getActiveView(), GLViewer_ViewFrame::getViewPort(), and GLViewer_ViewPort2d::GLV2win().

◆ getWinObjectRect()

◆ insertEnding()

void GLViewer_Viewer2d::insertEnding ( VectorFileType  aType,
QFile hFile 
)
virtual

Inserts common text lines ending file of.

Parameters
aTypeInserts text lines as ending for file
aType- file type
hFile- file instance

References HPGL, and POST_SCRIPT.

◆ insertHeader()

void GLViewer_Viewer2d::insertHeader ( VectorFileType  aType,
QFile hFile 
)
virtual

Inserts common text lines starting file of.

Parameters
aTypeInserts text lines as header for file
aType- file type
hFile- file instance

References HPGL, and POST_SCRIPT.

◆ onChangeBgColor

void GLViewer_Viewer2d::onChangeBgColor ( )
slot

◆ onCreateGLMarkers

void GLViewer_Viewer2d::onCreateGLMarkers ( int  theMarkersNum = 1000,
int  theMarkersRad = 5 
)
slot

◆ onCreateGLPolyline

void GLViewer_Viewer2d::onCreateGLPolyline ( int  theAnglesNum = 100,
int  theRadius = 10,
int  thePolylineNumber = 100 
)
slot

◆ onCreateGLText

void GLViewer_Viewer2d::onCreateGLText ( QString  theStr = "Text",
int  theTextNumber = 1 
)
slot

◆ onMouseEvent

void GLViewer_Viewer2d::onMouseEvent ( SUIT_ViewWindow ,
QMouseEvent *  e 
)
protectedslot

Custom mouse event handler

References GLViewer_Viewer::getActiveView(), and GLViewer_Viewer::onMouseEvent().

◆ repaintView()

void GLViewer_Viewer2d::repaintView ( GLViewer_ViewFrame theView = NULL,
bool  makeCurrent = false 
)

Repaints view.

Parameters
theView.If
theView= NULL repaints all views.

Repaints view

Parameters
theView- view to be repainted. If it is NULL then all views will be repainted

References GLViewer_Drawer::addObject(), GLViewer_Viewer::getActiveView(), GLViewer_ViewPort2d::getGLWidget(), GLViewer_Context::getObjects(), GLViewer_ViewPort2d::getScale(), GLViewer_ViewFrame::getViewPort(), GLViewer_Object::getVisible(), myDrawers, and myGLContext.

◆ startOperations() [1/2]

void GLViewer_Viewer2d::startOperations ( QMouseEvent *  e)
protectedvirtual

◆ startOperations() [2/2]

void GLViewer_Viewer2d::startOperations ( QWheelEvent *  e)
protectedvirtual

◆ testRotation()

bool GLViewer_Viewer2d::testRotation ( QMouseEvent *  e)
private

◆ transformCoordsToHPGL()

void GLViewer_Viewer2d::transformCoordsToHPGL ( double &  x,
double &  y 
)
protected

Transforms point (x,y) in Viewer CS to HPGL CS.

◆ transformCoordsToPS()

void GLViewer_Viewer2d::transformCoordsToPS ( double &  x,
double &  y 
)
protected

Transforms point (x,y) in Viewer CS to Post Script CS.

◆ translateTo()

bool GLViewer_Viewer2d::translateTo ( VectorFileType  aType,
QString  FileName,
PaperType  aPType,
double  mmLeft,
double  mmRight,
double  mmTop,
double  mmBottom 
)
virtual

◆ transPoint()

void GLViewer_Viewer2d::transPoint ( GLfloat &  x,
GLfloat &  y 
)

Translates point (x,y) from global CS to curreent viewer CS.

Translates point from global CS to curreent viewer CS

Parameters
x,y- co-ordinates to be translated

References GLViewer_Viewer::getActiveView(), GLViewer_ViewPort2d::getGLWidget(), GLViewer_ViewPort2d::getHeight(), GLViewer_ViewPort2d::getPan(), GLViewer_Widget::getRotationAngle(), GLViewer_ViewPort2d::getScale(), GLViewer_ViewFrame::getViewPort(), GLViewer_ViewPort2d::getWidth(), and PI.

◆ updateAll()

void GLViewer_Viewer2d::updateAll ( )

Redraws all active objects by updating all drawers in all views.

Redraws all active objects by updating all drawers in all views

References GLViewer_Viewer::getActiveView(), SUIT_ViewModel::getViewManager(), and SUIT_ViewManager::getViews().

◆ updateBorders() [1/2]

◆ updateBorders() [2/2]

void GLViewer_Viewer2d::updateBorders ( GLViewer_Rect theRect)

Updates rect of global scene by adding new rect.

Updates rect of global scene by adding new rectangle

Parameters
theRect- rectangle

References GLViewer_Rect::bottom(), SUIT_ViewModel::getViewManager(), SUIT_ViewManager::getViews(), GLViewer_Rect::left(), GLViewer_Rect::right(), GLViewer_Rect::setBottom(), GLViewer_Rect::setLeft(), GLViewer_Rect::setRight(), GLViewer_Rect::setTop(), and GLViewer_Rect::top().

◆ updateColors()

void GLViewer_Viewer2d::updateColors ( QColor  colorH,
QColor  colorS 
)

Updates colors for all drawers (does not work)

Updates colors for all drawers (does not work)

References activateAllDrawers().

◆ updateDrawers()

void GLViewer_Viewer2d::updateDrawers ( GLboolean  update,
GLfloat  scX = 0.0,
GLfloat  scY = 0.0 
)

Updates all drawers with new scale factor.

Parameters
onlyUpdateis passed to method activateAllDrawers drawers

References activateAllDrawers(), and GLViewer_Viewer::update().

◆ updateOperations()

bool GLViewer_Viewer2d::updateOperations ( QMouseEvent *  e)
protectedvirtual

◆ wheelZoomChange

void GLViewer_Viewer2d::wheelZoomChange ( bool  )
signal

Signal needs for optimum recompute of zoom depending objects Warning: use recompute without update viewer.

Member Data Documentation

◆ myDrawers

QList<GLViewer_Drawer*> GLViewer_Viewer2d::myDrawers
protected

Map of active drawers.

◆ myGLContext

GLViewer_Context* GLViewer_Viewer2d::myGLContext
protected

Current context.


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