Version: 6.3.1
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

SMESHGUI_PatternWidget Class Reference

#include <SMESHGUI_PatternWidget.h>

Inheritance diagram for SMESHGUI_PatternWidget:
Inheritance graph
[legend]

Public Member Functions

 SMESHGUI_PatternWidget (QWidget *=0)
 ~SMESHGUI_PatternWidget ()
void SetPoints (const PointVector &, const QVector< int > &, const ConnectivityVector &)

Protected Member Functions

void paintEvent (QPaintEvent *)

Private Member Functions

QPoint mapCoords (const double, const double)

Private Attributes

PointVector myPoints
QVector< intmyKeys
ConnectivityVector myConnections
double myMinU
double myMaxU
double myMinV
double myMaxV

Detailed Description

Definition at line 48 of file SMESHGUI_PatternWidget.h.


Constructor & Destructor Documentation

SMESHGUI_PatternWidget::SMESHGUI_PatternWidget ( QWidget parent = 0)

Definition at line 41 of file SMESHGUI_PatternWidget.cxx.

References myMaxU, myMaxV, myMinU, and myMinV.

  : QFrame( parent )
{
  myMinU = myMinV = myMaxU = myMaxV = 0;
  setMinimumHeight( 150 );
}
SMESHGUI_PatternWidget::~SMESHGUI_PatternWidget ( )

Definition at line 52 of file SMESHGUI_PatternWidget.cxx.

{
}

Member Function Documentation

QPoint SMESHGUI_PatternWidget::mapCoords ( const double  u,
const double  v 
) [private]

Definition at line 130 of file SMESHGUI_PatternWidget.cxx.

References Border, ex21_lamp.height, myMaxU, myMaxV, myMinU, myMinV, ex13_hole1partial.x, and ex13_hole1partial.y.

Referenced by paintEvent().

{
  int aWidth  = width()  - 2 * Border;
  int aHeight = height() - 2 * Border;

  double aUBound = myMaxU - myMinU;
  double aVBound = myMaxV - myMinV;

  double aUScale = aWidth  / aUBound;
  double aVScale = aHeight / aVBound;

  double aScale;
  aUScale <= aVScale ? aScale = aUScale : aScale = aVScale;

  double aUMiddle = ( myMaxU + myMinU ) / 2;
  double aVMiddle = ( myMaxV + myMinV ) / 2;

  int x = int( aWidth  / 2 + ( u - aUMiddle ) * aScale + Border - Shift );

  int y = int( aHeight / 2 + ( aVMiddle - v ) * aScale + Border + Shift );

  return QPoint( x, y );
}
void SMESHGUI_PatternWidget::paintEvent ( QPaintEvent *  ) [protected]

Definition at line 88 of file SMESHGUI_PatternWidget.cxx.

References mapCoords(), myConnections, myKeys, myPoints, Radius, Shift, SMESH.PointStruct.x, and SMESH.PointStruct.y.

{
  QPainter painter( this );
  painter.setBrush( Qt::SolidPattern );

  // Draw points
  for ( int i = 0; i < myKeys.size() && i < myPoints.size(); i++ ) {
    SMESH::PointStruct aPoint = myPoints[ myKeys[i] ];
    QPoint aQPnt = mapCoords( aPoint.x, aPoint.y );

    painter.drawPie( aQPnt.x() - Radius, aQPnt.y() - Radius, 
                     Radius * 2, Radius * 2, 0, 360 * 16 );
    painter.drawText( aQPnt.x() + Shift, aQPnt.y() - Shift, 
                      QString::number( i+1 ) );
  }

  // Draw lines
  for ( int i = 0; i < myConnections.size(); i++ ) {
    QVector<int> aCVector = myConnections[i];

    if ( aCVector.isEmpty() )
      continue;

    SMESH::PointStruct aPoint = myPoints[ aCVector[0] ];
    const QPoint aBeginPnt = mapCoords( aPoint.x, aPoint.y );
    QPoint aFirstPnt = aBeginPnt, aSecondPnt;

    for ( int j = 1; j < aCVector.size(); j++ ) {
      aPoint = myPoints[ aCVector[j] ];
      aSecondPnt = mapCoords( aPoint.x, aPoint.y );
      painter.drawLine( aFirstPnt, aSecondPnt );
      aFirstPnt = aSecondPnt;
    }

    painter.drawLine( aBeginPnt, aSecondPnt );
  }
}
void SMESHGUI_PatternWidget::SetPoints ( const PointVector thePoints,
const QVector< int > &  theKeys,
const ConnectivityVector theConnections 
)

Definition at line 60 of file SMESHGUI_PatternWidget.cxx.

References myConnections, myKeys, myMaxU, myMaxV, myMinU, myMinV, myPoints, ex13_hole1partial.x, and ex13_hole1partial.y.

Referenced by SMESHGUI_MeshPatternDlg.displayPreview(), SMESHGUI_CreatePatternDlg.displayPreview(), SMESHGUI_MeshPatternDlg.erasePreview(), and SMESHGUI_CreatePatternDlg.erasePreview().

{
  myPoints      = thePoints;
  myKeys        = theKeys;
  myConnections = theConnections;

  if ( myPoints.isEmpty() )
    return;

  myMinU = myMaxU = myPoints[0].x;
  myMinV = myMaxV = myPoints[0].y;

  for ( int i = 1; i < myPoints.size(); i++ ) {
    myMinU = qMin( myPoints[i].x, myMinU );
    myMaxU = qMax( myPoints[i].x, myMaxU );
    myMinV = qMin( myPoints[i].y, myMinV );
    myMaxV = qMax( myPoints[i].y, myMaxV );
  }

  repaint();
}

Field Documentation

Definition at line 63 of file SMESHGUI_PatternWidget.h.

Referenced by paintEvent(), and SetPoints().

QVector<int> SMESHGUI_PatternWidget.myKeys [private]

Definition at line 62 of file SMESHGUI_PatternWidget.h.

Referenced by paintEvent(), and SetPoints().

Definition at line 65 of file SMESHGUI_PatternWidget.h.

Referenced by mapCoords(), SetPoints(), and SMESHGUI_PatternWidget().

Definition at line 65 of file SMESHGUI_PatternWidget.h.

Referenced by mapCoords(), SetPoints(), and SMESHGUI_PatternWidget().

Definition at line 65 of file SMESHGUI_PatternWidget.h.

Referenced by mapCoords(), SetPoints(), and SMESHGUI_PatternWidget().

Definition at line 65 of file SMESHGUI_PatternWidget.h.

Referenced by mapCoords(), SetPoints(), and SMESHGUI_PatternWidget().

Definition at line 61 of file SMESHGUI_PatternWidget.h.

Referenced by paintEvent(), and SetPoints().

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