Ejemplo n.º 1
0
void MetricNamesRep::setColoredTextList(std::vector<std::pair<QColor, QString> > text, Eigen::Array2d pos, vtkViewport *vp)
{
    mDisplayText.clear();

    if (vp==0)
    {
        vp = this->getRenderer();
    }
//	if (vp==0)
//	{
//		return;
//	}

    DoubleBoundingBox3D bb;
    bb = this->findNormalizedBoundingBoxAroundText(text, pos, vp);
    double meanHeight = bb.range()[1]/text.size();

    for (unsigned i=0; i<text.size(); ++i)
    {
        TextDisplayPtr rep;
        rep.reset( new TextDisplay( text[i].second, text[i].first, 	mFontSize) );
        rep->textProperty()->SetJustificationToLeft();
        rep->getActor()->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();

        Vector3D currentPos = bb.bottomLeft() + (meanHeight*i)*Eigen::Vector3d::UnitY();
        rep->setPosition(currentPos);
        rep->setRenderer(this->getRenderer());

        mDisplayText.push_back(rep);
    }
}
Ejemplo n.º 2
0
/**Normalize volume defined by in to volume defined by out.
 *
 * This is intended for creating transforms from one viewport to another, i.e.
 * the two boxes should be aligned and differ only in translation + scaling.
 */
Transform3D createTransformNormalize(const DoubleBoundingBox3D& in, const DoubleBoundingBox3D& out)
{
	// translate input bottomleft to origin, scale, translate back to output bottomleft.
	Transform3D T0 = createTransformTranslate(-in.bottomLeft());
	Vector3D inrange = in.range();
	Vector3D outrange = out.range();
	Vector3D scale;

	// check for zero input dimensions
	for (unsigned i = 0; i < scale.size(); ++i)
	{
		if (fabs(inrange[i]) < 1.0E-5)
			scale[i] = 0;
		else
			scale[i] = outrange[i] / inrange[i];
	}
	Transform3D S = createTransformScale(scale);
	Transform3D T1 = createTransformTranslate(out.bottomLeft());
	Transform3D M = T1 * S * T0;
	return M;
}
Ejemplo n.º 3
0
bool similar(const DoubleBoundingBox3D& a, const DoubleBoundingBox3D& b, double tol)
{
	return similar(a.bottomLeft(), b.bottomLeft(), tol) && similar(a.topRight(), b.topRight(), tol);
}
Ejemplo n.º 4
0
/**Transform bb using the transform m.
 * Only the two defining corners are actually transformed.
 */
DoubleBoundingBox3D transform(const Transform3D& m, const DoubleBoundingBox3D& bb)
{
	Vector3D a = m.coord(bb.bottomLeft());
	Vector3D b = m.coord(bb.topRight());
	return DoubleBoundingBox3D(a, b);
}