Commit bb9148a6 authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[REFAC #736] Used constants instead of number literals to be more expressive

parent a24e86f7
......@@ -47,10 +47,6 @@ WTransferFunction2DGUIWidget::WTransferFunction2DGUIWidget( QWidget* qparent, WT
initialized( false )
{
// std::cout << "new widget" << std::endl;
const int xMin( 0 );
const int yMin( 0 );
const int xMax( 300 );
const int yMax( 300 );
// set up the scene and the parameters that define how we paint things
setMinimumSize( xMax-xMin+20, yMax - yMin + 30 );
......@@ -160,19 +156,19 @@ void WTransferFunction2DGUIWidget::updateTransferFunction()
// Serialize the current TF into the 2D TF object in normalized space
for( auto const &w : m_box_widgets )
{
double isoX = ( w->mapToScene( w->boundingRect().topLeft() ).x() / 300 );
double isoY = ( w->mapToScene( w->boundingRect().topLeft() ).y() / 300 );
double width =( w->getWidth() / 300 );
double height = ( w->getHeight() / 300 );
double isoX = ( w->mapToScene( w->boundingRect().topLeft() ).x() / xMax );
double isoY = ( w->mapToScene( w->boundingRect().topLeft() ).y() / yMax );
double width =( w->getWidth() / xMax );
double height = ( w->getHeight() / yMax );
QColor col( w->getColor().red(), w->getColor().green(), w->getColor().blue(), w->getColor().alpha() );
tf.addBoxWidget( isoX, isoY, width, height, toWColor( col ) );
}
for( auto const &w : m_triangle_widgets )
{
double isoX = ( w->mapToScene( w->boundingRect().topLeft() ).x() / 300 );
double isoY = ( w->mapToScene( w->boundingRect().topLeft() ).y() / 300 );
double width = ( ( w->getTriangle().getTriangle().boundingRect().width() / 300 ) );
double height = ( ( w->getTriangle().getTriangle().boundingRect().height() / 300 ) );
double isoX = ( w->mapToScene( w->boundingRect().topLeft() ).x() / xMax );
double isoY = ( w->mapToScene( w->boundingRect().topLeft() ).y() / yMax );
double width = ( ( w->getTriangle().getTriangle().boundingRect().width() / xMax ) );
double height = ( ( w->getTriangle().getTriangle().boundingRect().height() / yMax ) );
QColor col( w->getColor().red(), w->getColor().green(), w->getColor().blue(), w->getColor().alpha() );
WTransferFunction2D::PolyPoint points[3] =
{
......@@ -199,8 +195,7 @@ void WTransferFunction2DGUIWidget::insertBoxWidgetNormalized( const QPointF &pos
const double height = .167,
const QColor *const color = new QColor( 255., 0., 0., 10. ) )
{
// Scene width and height are 300.
insertBoxWidget( QPointF( pos.x()*300., pos.y()*300. ), width*300., height*300., color );
insertBoxWidget( QPointF( pos.x()*xMax, pos.y()*yMax ), width*xMax, height*yMax, color );
}
void WTransferFunction2DGUIWidget::insertBoxWidget( const QPointF &pos, const double width, const double height,
......@@ -223,7 +218,7 @@ void WTransferFunction2DGUIWidget::insertTriangleWidgetNormalized( QPointF point
points[1].setY( points[1].y() );
points[2].setX( points[2].x() );
points[2].setY( points[2].y() );
insertTriangleWidget( points, QPointF( pos.x() * 300., pos.y() * 300. ), color );
insertTriangleWidget( points, QPointF( pos.x() * xMax, pos.y() * yMax ), color );
}
void WTransferFunction2DGUIWidget::insertTriangleWidget( QPointF points[], const QPointF &pos, const QColor *const color )
......
......@@ -205,6 +205,11 @@ private:
WTransferFunction2DBackground *background; /*!< background that displays the 2D histogram */
std::shared_ptr< WHistogram2D > hist; /*!< 2D histogram which is displayed on the background */
bool initialized; /*!< set to true after initialization */
const int xMin = 0; /*!< Minimum x-coordinate of widget */
const int yMin = 0; /*!< Minimum y-coordinate of widget */
const int xMax = 300; /*!< Maximum x-coordinate of widget */
const int yMax = 300; /*!< Maximum y-coordinate of widget */
};
#endif // WTRANSFERFUNCTION2DGUIWIDGET_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment