#include <SMESHGUI_PatternWidget.h>

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< int > | myKeys |
| ConnectivityVector | myConnections |
| double | myMinU |
| double | myMaxU |
| double | myMinV |
| double | myMaxV |
Definition at line 48 of file SMESHGUI_PatternWidget.h.
| SMESHGUI_PatternWidget::SMESHGUI_PatternWidget | ( | QWidget * | parent = 0 | ) |
| SMESHGUI_PatternWidget::~SMESHGUI_PatternWidget | ( | ) |
Definition at line 52 of file SMESHGUI_PatternWidget.cxx.
{
}
| 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();
}
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().
double SMESHGUI_PatternWidget.myMaxU [private] |
Definition at line 65 of file SMESHGUI_PatternWidget.h.
Referenced by mapCoords(), SetPoints(), and SMESHGUI_PatternWidget().
double SMESHGUI_PatternWidget.myMaxV [private] |
Definition at line 65 of file SMESHGUI_PatternWidget.h.
Referenced by mapCoords(), SetPoints(), and SMESHGUI_PatternWidget().
double SMESHGUI_PatternWidget.myMinU [private] |
Definition at line 65 of file SMESHGUI_PatternWidget.h.
Referenced by mapCoords(), SetPoints(), and SMESHGUI_PatternWidget().
double SMESHGUI_PatternWidget.myMinV [private] |
Definition at line 65 of file SMESHGUI_PatternWidget.h.
Referenced by mapCoords(), SetPoints(), and SMESHGUI_PatternWidget().
PointVector SMESHGUI_PatternWidget.myPoints [private] |
Definition at line 61 of file SMESHGUI_PatternWidget.h.
Referenced by paintEvent(), and SetPoints().