Version: 6.3.1
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Slots | Protected Member Functions | Protected Attributes | Private Member Functions

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...
enum  SelectionMode { NoSelection, Single, Multiple }
enum  TransformType {
  NoTransform, Reset, FitAll, FitRect,
  FitSelect, Zoom, PanGlobal, Pan,
  Rotate, UserTransform = 100
}
enum  SketchingType { NoSketching, Rect, UserSketching = 100 }
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,
StatesMap
InteractionStyle2StatesMap
typedef QMap< InteractionStyle,
ButtonsMap
InteractionStyle2ButtonsMap

Public Slots

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

Signals

void wheelZoomChange (bool)
 Signal needs for optimum recompute of zoom depending objects Warning: use recompute without update viewer.
void selectionChanged (SelectionChangeStatus)

Public Member Functions

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

Static Public Member Functions

static QString Type ()
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

static InteractionStyle2StatesMap myStateMap
static InteractionStyle2ButtonsMap myButtonMap

Protected Slots

void onMouseEvent (SUIT_ViewWindow *, QMouseEvent *)
virtual void onKeyEvent (SUIT_ViewWindow *, QKeyEvent *)
virtual void onWheelEvent (SUIT_ViewWindow *, QWheelEvent *)
virtual void onSelectionCancel ()
virtual void onSelectionDone (bool add, SelectionChangeStatus status)

Protected Member Functions

GLViewer_SelectorcreateSelector ()
 Returns new selector.
GLViewer_ViewTransformercreateTransformer (int type)
 Returns new Transformer with type.
void transformCoordsToPS (double &x, double &y)
 Transforms point (x,y) in Viewer CS to Post Script CS.
void transformCoordsToHPGL (double &x, double &y)
 Transforms point (x,y) in Viewer CS to HPGL CS.
virtual void startOperations (QMouseEvent *)
 Starts any operations on mouse event.
virtual bool updateOperations (QMouseEvent *)
 Updates started operations on mouse event.
virtual void finishOperations (QMouseEvent *)
 Completes started operations on mouse event.
virtual void startOperations (QWheelEvent *)
 Starts any operations on mouse wheel event.
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.
QList< GLViewer_Drawer * > myDrawers
 Map of active drawers.
GLViewer_SelectormySelector
SelectionMode mySelMode
GLViewer_ViewSketchermySketcher
GLViewer_ViewTransformermyTransformer
SUIT_ViewManagermyViewManager

Private Member Functions

bool testRotation (QMouseEvent *)
 Rotation transformation.

Detailed Description

OpenGL Viewer 2D


Member Typedef Documentation

typedef QMap<HotOperation, Qt::KeyboardModifiers> SUIT_ViewModel.StatesMap [inherited]
typedef QMap<HotOperation, Qt::MouseButtons> SUIT_ViewModel.ButtonsMap [inherited]

Member Enumeration Documentation

Enumerator:
None 
Polyline 
Arc 
Curve 
Scribble 
Oval 
Rectangle 
Enumerator:
POST_SCRIPT 
HPGL 
Enumerator:
A1 
A2 
A3 
A4 
A5 
Enumerator:
NoSelection 
Single 
Multiple 
Enumerator:
NoTransform 
Reset 
FitAll 
FitRect 
FitSelect 
Zoom 
PanGlobal 
Pan 
Rotate 
UserTransform 
Enumerator:
NoSketching 
Rect 
UserSketching 
enum SUIT_ViewModel::HotOperation [inherited]
Enumerator:
PAN 
ZOOM 
ROTATE 
FIT_AREA 
Enumerator:
STANDARD 
KEY_FREE 

Constructor & Destructor Documentation

GLViewer_Viewer2d::GLViewer_Viewer2d ( const QString &  title)

Constructor

Parameters:
title- viewer title

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

GLViewer_Viewer2d::~GLViewer_Viewer2d ( )

Destructor

References GLViewer_TexFont.clearTextBases().


Member Function Documentation

SUIT_ViewWindow * GLViewer_Viewer2d::createView ( SUIT_Desktop theDesktop) [virtual]

Create new instance of view window on desktop theDesktop.

Return values:
SUIT_ViewWindow*- created view window pointer.

Reimplemented from SUIT_ViewModel.

void GLViewer_Viewer2d::addPopupItems ( QMenu thePopup)

Adds item for change background color

Parameters:
thePopup- menu

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

const QList<GLViewer_Drawer*>& GLViewer_Viewer2d.getDrawers ( ) const
GLViewer_Context* GLViewer_Viewer2d.getGLContext ( ) const
void GLViewer_Viewer2d::updateColors ( QColor  colorH,
QColor  colorS 
)

References activateAllDrawers().

void GLViewer_Viewer2d::updateBorders ( GLViewer_Rect theRect)
void GLViewer_Viewer2d::updateBorders ( )
void GLViewer_Viewer2d::updateAll ( )

Redraws all active objects by updating all drawers in all views

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

void GLViewer_Viewer2d::updateDrawers ( GLboolean  update,
GLfloat  scX = 0.0,
GLfloat  scY = 0.0 
)
Parameters:
onlyUpdateis passed to method activateAllDrawers drawers

References activateAllDrawers().

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

Activates drawer for

Parameters:
theObject

References activateDrawers().

void GLViewer_Viewer2d::activateAllDrawers ( bool  onlyUpdate,
GLboolean  swap = GL_FALSE 
)
void GLViewer_Viewer2d::transPoint ( GLfloat &  x,
GLfloat &  y 
)
QRect * GLViewer_Viewer2d::getWinObjectRect ( GLViewer_Object theObject)
GLViewer_Rect GLViewer_Viewer2d::getGLVRect ( const QRect &  theRect) const

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().

QRect GLViewer_Viewer2d::getQRect ( const GLViewer_Rect theRect) const

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().

void GLViewer_Viewer2d::insertHeader ( VectorFileType  aType,
QFile &  hFile 
) [virtual]
Parameters:
aType

Inserts text lines as header for file

Parameters:
aType- file type
hFile- file instance

References HPGL, and POST_SCRIPT.

void GLViewer_Viewer2d::insertEnding ( VectorFileType  aType,
QFile &  hFile 
) [virtual]
Parameters:
aType

Inserts text lines as ending for file

Parameters:
aType- file type
hFile- file instance

References HPGL, and POST_SCRIPT.

bool GLViewer_Viewer2d::translateTo ( VectorFileType  aType,
QString  FileName,
PaperType  aPType,
double  mmLeft,
double  mmRight,
double  mmTop,
double  mmBottom 
) [virtual]
void GLViewer_Viewer2d::repaintView ( GLViewer_ViewFrame theView = NULL,
bool  makeCurrent = false 
)
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, myGLContext, and PyInterp.obj.

void GLViewer_Viewer2d.wheelZoomChange ( bool  ) [signal]
void GLViewer_Viewer2d::onChangeBgColor ( ) [virtual, slot]
void GLViewer_Viewer2d::onCreateGLMarkers ( int  theMarkersNum = 1000,
int  theMarkersRad = 5 
) [slot]
void GLViewer_Viewer2d::onCreateGLPolyline ( int  theAnglesNum = 100,
int  theRadius = 10,
int  thePolylineNumber = 100 
) [slot]
void GLViewer_Viewer2d::onCreateGLText ( QString  theStr = "Text",
int  theTextNumber = 1 
) [slot]
GLViewer_Selector * GLViewer_Viewer2d::createSelector ( ) [protected, virtual]
Returns:
new selector

Reimplemented from GLViewer_Viewer.

References getGLContext().

GLViewer_ViewTransformer * GLViewer_Viewer2d::createTransformer ( int  type) [protected, virtual]
Parameters:
type
Returns:
new Transformer
Parameters:
type- type of new transformer

Reimplemented from GLViewer_Viewer.

void GLViewer_Viewer2d.transformCoordsToPS ( double &  x,
double &  y 
) [protected]
void GLViewer_Viewer2d.transformCoordsToHPGL ( double &  x,
double &  y 
) [protected]
void GLViewer_Viewer2d::startOperations ( QMouseEvent *  e) [protected, virtual]
bool GLViewer_Viewer2d::updateOperations ( QMouseEvent *  e) [protected, virtual]
void GLViewer_Viewer2d::finishOperations ( QMouseEvent *  e) [protected, virtual]
void GLViewer_Viewer2d::startOperations ( QWheelEvent *  e) [protected, virtual]
void GLViewer_Viewer2d::onMouseEvent ( SUIT_ViewWindow ,
QMouseEvent *  e 
) [protected, virtual, slot]

Custom mouse event handler

Reimplemented from GLViewer_Viewer.

References GLViewer_Viewer.getActiveView().

bool GLViewer_Viewer2d::testRotation ( QMouseEvent *  e) [private]
void GLViewer_Viewer::setViewManager ( SUIT_ViewManager theViewManager) [virtual, inherited]

Sets new view manager

Parameters:
theViewManager- new view manager

Reimplemented from SUIT_ViewModel.

References GLViewer_Viewer.onMouseEvent(), and GLViewer_Viewer.onWheelEvent().

virtual QString GLViewer_Viewer.getType ( ) const [virtual, inherited]

Reimplemented from SUIT_ViewModel.

static QString GLViewer_Viewer.Type ( ) [static, inherited]
void GLViewer_Viewer::contextMenuPopup ( QMenu thePopup) [virtual, inherited]

Builds popup for GL viewer

Reimplemented from SUIT_ViewModel.

References GLViewer_Viewer.onChangeBgColor().

void GLViewer_Viewer::setSelectionMode ( GLViewer_Viewer::SelectionMode  mode) [inherited]

Sets the selection mode for this viewer. [ public ]

References GLViewer_Viewer.mySelMode, and GLViewer_Viewer.onSelectionModeChanged().

GLViewer_Viewer::SelectionMode GLViewer_Viewer::getSelectionMode ( ) const [inherited]

Returns the selection mode of this viewer. [ public ]

References GLViewer_Viewer.mySelMode.

GLViewer_Selector * GLViewer_Viewer::getSelector ( ) const [inherited]
void GLViewer_Viewer::update ( int  flags = 0) [virtual, inherited]

Updates all views of this viewer. Use 'flags' to customize update process. [ virtual public ]

References SUIT_ViewModel.getViewManager(), and SUIT_ViewManager.getViews().

void GLViewer_Viewer::activateTransform ( int  type) [inherited]
void GLViewer_Viewer::activateSketching ( int  type) [inherited]
GLViewer_ViewFrame * GLViewer_Viewer::getActiveView ( ) const [inherited]

Returns the active view. [ public ]

References SUIT_ViewManager.getActiveView(), and SUIT_ViewModel.getViewManager().

void GLViewer_Viewer.selectionChanged ( SelectionChangeStatus  ) [signal, inherited]
void GLViewer_Viewer::onSketchingStarted ( ) [protected, virtual, inherited]

Unhilights detected entities. [ virtual protected ]

References GLViewer_Viewer.unhilightDetected().

void GLViewer_Viewer::onSketchingFinished ( ) [protected, virtual, inherited]
void GLViewer_Viewer::onTransformationStarted ( ) [protected, virtual, inherited]

Unhilights detected entities, lock selection, sets event filter on the whole application. [ virtual protected ]

References GLViewer_Viewer.getSelector(), GLViewer_Selector.lock(), GLViewer_Viewer.myTransformer, and GLViewer_Viewer.unhilightDetected().

void GLViewer_Viewer::onTransformationFinished ( ) [protected, virtual, inherited]

Unlock selection, removes event filter. [ virtual protected ]

References GLViewer_Viewer.getSelector(), GLViewer_Selector.lock(), and GLViewer_Viewer.myTransformer.

void GLViewer_Viewer::onSelectionModeChanged ( ) [protected, virtual, inherited]
void GLViewer_Viewer::unhilightDetected ( ) [protected, virtual, inherited]

Unhilights the currect detected objects. [ virtual private ]

References GLViewer_Viewer.getSelector(), and GLViewer_Selector.undetectAll().

bool GLViewer_Viewer::eventFilter ( QObject o,
QEvent e 
) [protected, virtual, inherited]
GLViewer_ViewSketcher * GLViewer_Viewer::createSketcher ( int  type) [protected, virtual, inherited]

Creates default sketcher. [ virtual protected ]

void GLViewer_Viewer::onKeyEvent ( SUIT_ViewWindow ,
QKeyEvent *   
) [protected, virtual, slot, inherited]

Listens to key events of the active view. [ virtual protected slot ]

void GLViewer_Viewer::onWheelEvent ( SUIT_ViewWindow ,
QWheelEvent *  e 
) [protected, virtual, slot, inherited]

Listens to mouse events of the active view. [ virtual protected slot ]

References GLViewer_Viewer.handleWheel().

void GLViewer_Viewer::onSelectionCancel ( ) [protected, virtual, slot, inherited]

Called when selection is cleared in this viewer. [ virtual protected slot ]

References SCS_Invalid, and GLViewer_Viewer.selectionChanged().

void GLViewer_Viewer::onSelectionDone ( bool  bAdded,
SelectionChangeStatus  status 
) [protected, virtual, slot, inherited]

Called when smth is selected in this viewer. [ virtual protected slot ]

References GLViewer_Viewer.selectionChanged().

SUIT_ViewManager * SUIT_ViewModel::getViewManager ( ) const [inherited]

Get view manager.

Returns:
view manager

References SUIT_ViewModel.myViewManager.

void SUIT_ViewModel::setHotButton ( InteractionStyle  theInteractionStyle,
HotOperation  theOper,
Qt::KeyboardModifiers  theState,
Qt::MouseButtons  theButton 
) [static, inherited]

Sets hot button

Parameters:
theOper- hot operation
theState- adding state to state map operations.
theButton- adding state to button map operations.

References SUIT_ViewModel.myButtonMap, and SUIT_ViewModel.myStateMap.

void SUIT_ViewModel::getHotButton ( InteractionStyle  theInteractionStyle,
HotOperation  theOper,
Qt::KeyboardModifiers &  theState,
Qt::MouseButtons &  theButton 
) [static, inherited]

Gets hot button for operation theOper.

Parameters:
theOper- input hot operation
theState- output state from state map operations.
theButton- output state from button map operations.

References SUIT_ViewModel.myButtonMap, and SUIT_ViewModel.myStateMap.


Field Documentation

SelectionMode GLViewer_Viewer.mySelMode [protected, inherited]
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS