Commit 9244eb2f authored by Tobias Neeb's avatar Tobias Neeb
Browse files

[ADD #736] extend the transfer of data to the 2D-TF by setting up...

[ADD #736] extend the transfer of data to the 2D-TF by setting up triangle-data in the update-function
parent d144d5a8
......@@ -122,6 +122,7 @@ void WTransferFunction2DGUIWidget::dataChanged()
{
return;
}
this->updateTransferFunction();
this->setMyBackground();
forceRedraw();
......@@ -161,7 +162,7 @@ void WTransferFunction2DGUIWidget::updateTransferFunction()
{
double isoX = ( w->mapToScene( w->boundingRect().topLeft() ).x() / 300 );
double isoY = ( w->mapToScene( w->boundingRect().topLeft() ).y() / 300 );
double width = ( w->getWidth() / 300 );
double width =( w->getWidth() / 300 );
double height = ( w->getHeight() / 300 );
QColor col( w->getColor().red(), w->getColor().green(), w->getColor().blue(), w->getColor().alpha() );
tf.addBoxWidget( isoX, isoY, width, height, toWColor( col ) );
......@@ -170,19 +171,19 @@ void WTransferFunction2DGUIWidget::updateTransferFunction()
{
double isoX = ( w->mapToScene( w->boundingRect().topLeft() ).x() / 300 );
double isoY = ( w->mapToScene( w->boundingRect().topLeft() ).y() / 300 );
double width = ( ( w->getTriangle().right().x() - w->getTriangle().left().x() ) / 300 );
double height = ( ( w->getTriangle().mid().y() - w->getTriangle().left().y() ) / 300 ); //TODO(T. Neeb): Check for lowest point
double width = ( ( w->getTriangle().getTriangle().boundingRect().width() / 300 ) );
double height = ( ( w->getTriangle().getTriangle().boundingRect().height() / 300 ) );
QColor col( w->getColor().red(), w->getColor().green(), w->getColor().blue(), w->getColor().alpha() );
WTransferFunction2D::PolyPoint points[3] =
{
{
w->getTriangle().left().x(), w->getTriangle().left().y()
},
w->getTriangle().left().x(), w->getTriangle().left().y()
},
{
w->getTriangle().mid().x(), w->getTriangle().mid().y()
w->getTriangle().mid().x(), w->getTriangle().mid().y()
},
{
w->getTriangle().right().x(), w->getTriangle().right().y()
w->getTriangle().right().x(), w->getTriangle().right().y()
}
};
tf.addTriangleWidget( points, isoX, isoY, width, height, toWColor( col ) );
......@@ -212,23 +213,24 @@ void WTransferFunction2DGUIWidget::insertBoxWidget( const QPointF &pos, const do
this->update();
dataChanged();
}
void WTransferFunction2DGUIWidget::insertTriangleWidgetNormalized( const QPointF &pos = QPointF( 0.0, 0.0 ),
const QColor * const color = new QColor( 255.0, 0.0, 0.0, 10.0 ) )
//TODO(T. Neeb): Add points to the insertion to carry over to tf2d
void WTransferFunction2DGUIWidget::insertTriangleWidgetNormalized( QPointF points[], const QPointF &pos = QPointF( 0.0, 0.0 ),
const QColor * const color = new QColor( 0.00, 0.0, 255.0, 20.0 ) )
{
insertTriangleWidget( QPointF( pos.x() * 300., pos.y() * 300. ), color );
points[0].setX( points[0].x() * 10 );
points[0].setY( points[0].y() * 10 );
points[1].setX( points[1].x() * 10 );
points[1].setY( points[1].y() * 10 );
points[2].setX( points[2].x() * 10 );
points[2].setY( points[2].y() * 10 );
insertTriangleWidget( points, QPointF( pos.x() * 300., pos.y() * 300. ), color );
}
void WTransferFunction2DGUIWidget::insertTriangleWidget( const QPointF &pos, const QColor *const color )
void WTransferFunction2DGUIWidget::insertTriangleWidget( QPointF points[], const QPointF &pos, const QColor *const color )
{
WTransferFunction2DTriangleWidget *newTriangle( new WTransferFunction2DTriangleWidget( this, WTransferFunction2DTriangle(), *color ) );
for( QPointF p : newTriangle->getTriangle().getTriangle() )
{
p.setX( p.x() * 100 );
p.setY( p.y() * 100 );
}
WTransferFunction2DTriangleWidget *newTriangle( new WTransferFunction2DTriangleWidget( this,
WTransferFunction2DTriangle( points[0], points[1], points[2] ), *color ) );
newTriangle->setPos( pos );
newTriangle->getTriangle().updateTrianglePoints();
scene->addItem( newTriangle );
m_triangle_widgets.push_back( newTriangle );
this->update();
......@@ -237,7 +239,11 @@ void WTransferFunction2DGUIWidget::insertTriangleWidget( const QPointF &pos, con
void WTransferFunction2DGUIWidget::addTriangleWidget()
{
insertTriangleWidgetNormalized();
QPointF points[3];
points[0] = QPointF( 0.0, 0.0 );
points[1] = QPointF( 4.0, 4.0 );
points[2] = QPointF( 4.0, 0.0 );
insertTriangleWidgetNormalized( points );
}
void WTransferFunction2DGUIWidget::addBoxWidget()
......
......@@ -142,15 +142,17 @@ public:
* Adds a triangle widget to the scene and list of widgets
* \param pos pos of the widget in normalized space
* \param color color of the widget
* \param points points of the triangle
*/
void insertTriangleWidget( const QPointF &pos, const QColor *const color );
void insertTriangleWidget( QPointF points[], const QPointF &pos, const QColor *const color );
/**
* Adds a triangle widget to the scene and list of widgets from normalized space
* \param pos pos of the widget in normalized space
* \param color color of the widget
* \param points points of the triangle
*/
void insertTriangleWidgetNormalized( const QPointF &pos, const QColor * const color );
void insertTriangleWidgetNormalized( QPointF points[], const QPointF &pos, const QColor *const color );
public slots:
/**
......
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