Back to index

salome-gui  6.5.0
Public Member Functions | Private Attributes
OCCViewer_Trihedron Class Reference

The class for the presentation of the UserDraw object. More...

#include <OCCViewer_Trihedron.h>

List of all members.

Public Member Functions

 OCCViewer_Trihedron (const PrsMgr_TypeOfPresentation3d=PrsMgr_TOP_AllView)
 Constructor.
virtual ~OCCViewer_Trihedron ()
 Destructor.
virtual void Compute (const Handle(PrsMgr_PresentationManager3d)&, const Handle(Prs3d_Presentation)&, const Standard_Integer)
 Redefined method.
virtual void ComputeSelection (const Handle(SelectMgr_Selection)&, const Standard_Integer)
 Redefined method.
virtual void bounds (Graphic3d_CBounds &) const
 Sets the bounding box (MinMax values).
virtual void display ()
 Displays trihedron.

Private Attributes

unsigned int myTextList

Detailed Description

The class for the presentation of the UserDraw object.

Definition at line 33 of file OCCViewer_Trihedron.h.


Constructor & Destructor Documentation

OCCViewer_Trihedron::OCCViewer_Trihedron ( const PrsMgr_TypeOfPresentation3d  t = PrsMgr_TOP_AllView)

Constructor.

Definition at line 54 of file OCCViewer_Trihedron.cxx.

  : AIS_InteractiveObject( t ),
    myTextList( 0 )
{
}

Destructor.

Definition at line 63 of file OCCViewer_Trihedron.cxx.

{
  if( myTextList )
    glDeleteLists( myTextList, 256 );
}

Member Function Documentation

void OCCViewer_Trihedron::bounds ( Graphic3d_CBounds &  aMinMax) const [virtual]

Sets the bounding box (MinMax values).

Definition at line 72 of file OCCViewer_Trihedron.cxx.

{
  Standard_Real aXMin = -1, aYMin = -1, aZMin = -1;
  Standard_Real aXMax =  1, aYMax =  1, aZMax =  1;
  
  if( aMinMax.XMin > aXMin ) aMinMax.XMin = aXMin;
  if( aMinMax.YMin > aYMin ) aMinMax.YMin = aYMin;
  if( aMinMax.ZMin > aZMin ) aMinMax.ZMin = aZMin;
  if( aMinMax.XMax < aXMax ) aMinMax.XMax = aXMax;
  if( aMinMax.YMax < aYMax ) aMinMax.YMax = aYMax;
  if( aMinMax.ZMax < aZMax ) aMinMax.ZMax = aZMax;
}
void OCCViewer_Trihedron::Compute ( const Handle(PrsMgr_PresentationManager3d)&  ,
const Handle(Prs3d_Presentation)&  aPrs,
const Standard_Integer  aMode 
) [virtual]

Redefined method.

Calculates the object presentation.

Definition at line 88 of file OCCViewer_Trihedron.cxx.

{
  if( aPrs.IsNull() )
    return;

  Handle( Graphic3d_Group ) aGroup = Prs3d_Root::CurrentGroup( aPrs );
  aGroup->UserDraw( this );
}

Here is the call graph for this function:

void OCCViewer_Trihedron::ComputeSelection ( const Handle(SelectMgr_Selection)&  theSelection,
const Standard_Integer  theMode 
) [virtual]

Redefined method.

Does nothing.

Definition at line 102 of file OCCViewer_Trihedron.cxx.

{
}

Displays trihedron.

Definition at line 173 of file OCCViewer_Trihedron.cxx.

{
  GLdouble TriedronOrigin[3] = { 0.0, 0.0, 0.0 };

  GLdouble TriedronAxeX[3] = { 1.0, 0.0, 0.0 };
  GLdouble TriedronAxeY[3] = { 0.0, 1.0, 0.0 };
  GLdouble TriedronAxeZ[3] = { 0.0, 0.0, 1.0 };

  GLfloat TriedronColorX[3] = { 1.0, 0.0, 0.0 };
  GLfloat TriedronColorY[3] = { 0.0, 1.0, 0.0 };
  GLfloat TriedronColorZ[3] = { 0.0, 0.0, 1.0 };

  GLfloat TriedronLetterColorX[3] = { 1.0, 1.0, 1.0 };
  GLfloat TriedronLetterColorY[3] = { 1.0, 1.0, 1.0 };
  GLfloat TriedronLetterColorZ[3] = { 1.0, 1.0, 1.0 };

  GLfloat TriedronLineWidth = 2.0;
  GLdouble TriedronScale = 0.15;

  GLdouble U, V, minUV;
  GLint aViewPort[4];
  glGetIntegerv(GL_VIEWPORT, aViewPort);
  U = aViewPort[2];
  V = aViewPort[3];

  if( U < V )
    minUV = U;
  else
    minUV = V;

  GLdouble L = minUV * TriedronScale;

  TriedronOrigin[0]= 0.0; 
  TriedronOrigin[1]= 0.0;
  TriedronOrigin[2]= 0.0; 

  TriedronAxeX[0] = TriedronOrigin[0] + L;
  TriedronAxeX[1] = TriedronOrigin[1] + 0.0;
  TriedronAxeX[2] = TriedronOrigin[2] + 0.0;

  TriedronAxeY[0] = TriedronOrigin[0] + 0.0;
  TriedronAxeY[1] = TriedronOrigin[1] + L;
  TriedronAxeY[2] = TriedronOrigin[2] + 0.0;

  TriedronAxeZ[0] = TriedronOrigin[0] + 0.0;
  TriedronAxeZ[1] = TriedronOrigin[1] + 0.0;
  TriedronAxeZ[2] = TriedronOrigin[2] + L;

  glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT | GL_LIGHTING_BIT | GL_LINE_BIT | GL_VIEWPORT_BIT );

  glDepthRange( 0, 0 );
  glDisable( GL_LIGHTING );
  glDisable( GL_COLOR_MATERIAL );
  for( int i = 0; i < GL_MAX_CLIP_PLANES; i++ )
    glDisable( GL_CLIP_PLANE0 + i  );

  glLineWidth( TriedronLineWidth );

  glColor3fv( TriedronColorX );
  glBegin( GL_LINES );
  glVertex3dv( TriedronOrigin );
  glVertex3dv( TriedronAxeX );
  glEnd();

  glColor3fv( TriedronColorY );
  glBegin( GL_LINES );
  glVertex3dv( TriedronOrigin );
  glVertex3dv( TriedronAxeY );
  glEnd();

  glColor3fv( TriedronColorZ );
  glBegin( GL_LINES );
  glVertex3dv( TriedronOrigin );
  glVertex3dv( TriedronAxeZ );
  glEnd();

  GLdouble l = L - L/4.;
  GLdouble rayon = L/20.;
  GLint ii, NbFacettes = 12;
  GLdouble Angle = 2. * PI / NbFacettes;
  GLdouble TriedronCoord[3] = { 1.0, 0.0, 0.0 };

  if( myTextList == 0 )
    myTextList = generateTextList();

  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

  glColor3fv( TriedronColorX );
  glBegin( GL_TRIANGLE_FAN );
  glVertex3dv( TriedronAxeX );
  TriedronCoord[0] = TriedronOrigin[0] + l ;
  ii = NbFacettes;
  while (ii >= 0 ) {
    TriedronCoord[1] = TriedronOrigin[1] + ( rayon * sin(ii * Angle) );
    TriedronCoord[2] = TriedronOrigin[2] + ( rayon * cos(ii * Angle) );
    glVertex3dv( TriedronCoord );
    ii--;
  }
  glEnd();

  drawText( myTextList, "X", TriedronAxeX, TriedronLetterColorX );

  glColor3fv( TriedronColorY );
  glBegin( GL_TRIANGLE_FAN );
  glVertex3dv( TriedronAxeY );
  TriedronCoord[1] = TriedronOrigin[1] + l ;
  ii = NbFacettes;
  while (ii >= 0 ) {
    TriedronCoord[0] = TriedronOrigin[0] + (rayon * cos(ii * Angle) );
    TriedronCoord[2] = TriedronOrigin[2] + (rayon * sin(ii * Angle) );
    glVertex3dv( TriedronCoord );
    ii--;
  }
  glEnd();

  drawText( myTextList, "Y", TriedronAxeY, TriedronLetterColorY );

  glColor3fv( TriedronColorZ );
  glBegin( GL_TRIANGLE_FAN );
  glVertex3dv( TriedronAxeZ );
  TriedronCoord[2] = TriedronOrigin[2] + l ;
  ii = NbFacettes;
  while (ii >= 0 ) {
    TriedronCoord[0] = TriedronOrigin[0] + ( rayon * sin(ii * Angle) );
    TriedronCoord[1] = TriedronOrigin[1] + ( rayon * cos(ii * Angle) );
    glVertex3dv( TriedronCoord );
    ii--;
  }
  glEnd();

  drawText( myTextList, "Z", TriedronAxeZ, TriedronLetterColorZ );

  glPopAttrib();
}

Here is the call graph for this function:


Member Data Documentation

unsigned int OCCViewer_Trihedron::myTextList [private]

Definition at line 53 of file OCCViewer_Trihedron.h.


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