Commit b2263cbb authored by Tobias Neeb's avatar Tobias Neeb
Browse files

[FIX 759] correctly updating and loading the triangle, fixing range-error

parent 538ab454
......@@ -164,6 +164,28 @@ namespace PROPERTY_TYPE_HELPER
string_utils::fromString< double >( innerTokens[ 8 ].c_str() ) ) // Alpha
);
}
if( innerTokens[ 9 ] == "d")
{
WTransferFunction2D::PolyPoint points[3];
points[0].x = string_utils::fromString<double>(innerTokens[18].c_str());
points[0].y = string_utils::fromString<double>(innerTokens[19].c_str());
points[1].x = string_utils::fromString<double>(innerTokens[20].c_str());
points[1].y = string_utils::fromString<double>(innerTokens[21].c_str());
points[2].x = string_utils::fromString<double>(innerTokens[22].c_str());
points[2].y = string_utils::fromString<double>(innerTokens[23].c_str());
tf.addTriangleWidget(
points,
string_utils::fromString<double>(innerTokens[10].c_str()), // isoX
string_utils::fromString<double>(innerTokens[11].c_str()), // isoY
string_utils::fromString<double>(innerTokens[12].c_str()), // width
string_utils::fromString<double>(innerTokens[13].c_str()),
WColor(
string_utils::fromString<double>(innerTokens[14].c_str()), // Red
string_utils::fromString<double>(innerTokens[15].c_str()), // Green
string_utils::fromString<double>(innerTokens[16].c_str()), // Blue
string_utils::fromString<double>(innerTokens[17].c_str())) // Alpha
);
}
idx++;
}
}
......@@ -179,11 +201,24 @@ namespace PROPERTY_TYPE_HELPER
{
double isoX = tf.getIsovalueX( BOX, i );
double isoY = tf.getIsovalueY( BOX, i );
double width = tf.getWidth( i );
double height = tf.getHeight( i );
WColor c = tf.getColor( i );
double width = tf.getWidth( BOX, i );
double height = tf.getHeight( BOX, i );
WColor c = tf.getColor( BOX, i );
out << "c:" << isoX << ":" << isoY << ":" << width << ":" << height << ":"
<< c[ 0 ] << ":" << c[ 1 ] << ":" << c[ 2 ] << ":" << c[ 3 ] << ";";
<< c[ 0 ] << ":" << c[ 1 ] << ":" << c[ 2 ] << ":" << c[ 3 ];
}
size_t ntWidgets = tf.numTriangleWidgets();
for (size_t i = 0; i < ntWidgets; i++)
{
WColor c = tf.getColor(TRIANGLE, i);
double isoX = tf.getIsovalueX(TRIANGLE, i);
double isoY = tf.getIsovalueY(TRIANGLE, i);
double width = tf.getWidth(TRIANGLE, i);
double height = tf.getHeight(TRIANGLE, i);
std::vector<WTransferFunction2D::PolyPoint> points = tf.getPoints( i );
out << "d:" << isoX << ":" << isoY << ":" << width << ":" << height << ":"
<< c[0] << ":" << c[1] << ":" << c[2] << ":" << c[3] << ":" << points[0].x << ":" << points[0].y << ":"
<< points[1].x << ":" << points[1].y << ":" << points[2].x << ":" << points[2].y << ":" << ";";
}
return out.str();
}
......
......@@ -190,9 +190,9 @@ std::ostream& operator << ( std::ostream& out, const WTransferFunction2D& tf )
{
double isoX = tf.getIsovalueX( BOX, i );
double isoY = tf.getIsovalueY( BOX, i );
double width = tf.getWidth( i );
double height = tf.getHeight( i );
WColor c = tf.getColor( i );
double width = tf.getWidth( BOX, i );
double height = tf.getHeight( BOX, i );
WColor c = tf.getColor( BOX, i );
out << "c:" << isoX << ":" << isoY << ":" << width << ":" << height << ":"
<< c[ 0 ] << ":" << c[ 1 ] << ":" << c[ 2 ] << ":" << c[ 3 ] << ";";
}
......
......@@ -220,9 +220,21 @@ public:
* \param i the index widget in the list.
* \returns the width of the widget at index i
*/
double getWidth( size_t i ) const
double getWidth( Shapes shape, size_t i ) const
{
return m_widget.at( i ).width;
switch( shape )
{
case BOX:
return m_widget.at( i ).width;
break;
case TRIANGLE:
return m_triangle_widgets.at( i ).width;
break;
default:
return 0.0;
break;
}
}
/**
......@@ -231,9 +243,21 @@ public:
* \param i the index widget in the list.
* \returns the height of the widget at index i
*/
double getHeight( size_t i ) const
double getHeight( Shapes shape, size_t i ) const
{
return m_widget.at( i ).height;
switch( shape )
{
case BOX:
return m_widget.at( i ).height;
break;
case TRIANGLE:
return m_triangle_widgets.at( i ).height;
break;
default:
return 0.0;
break;
}
}
/**
......@@ -242,7 +266,7 @@ public:
* @param i
* @return std::vector<PolyPoint>
*/
std::vector<PolyPoint> getPoints( size_t i )
std::vector<PolyPoint> getPoints( size_t i ) const
{
std::vector<PolyPoint> pointsVec;
......@@ -258,9 +282,21 @@ public:
* \param i the index widget in the list.
* \returns the color of the widget at index i
*/
WColor getColor( size_t i ) const
WColor getColor( Shapes shape, size_t i ) const
{
return m_widget.at( i ).color;
switch( shape )
{
case BOX:
return m_widget.at( i ).color;
break;
case TRIANGLE:
return m_triangle_widgets.at( i ).color;
break;
default:
return WColor(0.0, 255.0, 0.0, 10.0);
break;
}
}
/**
......
......@@ -102,9 +102,9 @@ void WPropertyTransferFunction2DWidget::update()
QColor c;
for( size_t i = 0; i < nbWidgets; ++i )
{
c = toQColor( tf.getColor( i ) );
double width = tf.getWidth( i );
double height = tf.getHeight( i );
c = toQColor( tf.getColor( BOX, i ) );
double width = tf.getWidth( BOX, i );
double height = tf.getHeight( BOX, i );
double isoX = tf.getIsovalueX( BOX, i );
double isoY = tf.getIsovalueY( BOX, i );
m_transferFunction.insertBoxWidgetNormalized( QPointF( isoX, isoY ), width, height, &c );
......@@ -112,16 +112,16 @@ void WPropertyTransferFunction2DWidget::update()
size_t ntWidgets = tf.numTriangleWidgets();
for( size_t i = 0; i < ntWidgets; i++ )
{
c = toQColor( tf.getColor( i ) );
c = toQColor(tf.getColor(TRIANGLE, i));
double isoX = tf.getIsovalueX( TRIANGLE, i );
double isoY = tf.getIsovalueY( TRIANGLE, i );
QPointF points[3];
points[0].setX( tf.getPoints( i )[0].x );
points[0].setY( tf.getPoints( i )[0].y );
points[1].setX( tf.getPoints( i )[1].x );
points[1].setY( tf.getPoints( i )[1].y );
points[2].setX( tf.getPoints( i )[2].x );
points[2].setY( tf.getPoints( i )[2].y );
points[0].setX( tf.getPoints( i )[0].x);
points[0].setY( tf.getPoints( i )[0].y);
points[1].setX( tf.getPoints( i )[1].x);
points[1].setY( tf.getPoints( i )[1].y);
points[2].setX( tf.getPoints( i )[2].x);
points[2].setY( tf.getPoints( i )[2].y);
m_transferFunction.insertTriangleWidgetNormalized( points, QPointF( isoX, isoY ), &c );
}
}
......
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