Exemplo 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);
    }
}
Exemplo 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;
}
/** Initialize the volue parameters with sensible defaults.
 */
OutputVolumeParams::OutputVolumeParams(DoubleBoundingBox3D extent, double inputSpacing, double maxVolumeSize) :
	mInputSpacing(inputSpacing), mMaxVolumeSize(maxVolumeSize), mValid(false)
{
	mImage.setSpacingKeepDim(Eigen::Array3d(inputSpacing, inputSpacing, inputSpacing));
	mImage.setDimKeepBoundsAlignSpacing(extent.range());

	this->constrainVolumeSize();

	if(mImage.getDim().minCoeff() <= 1) //At least one of the dimensions <= 1
		mValid = false;
	else
		mValid = true;
}
Exemplo n.º 4
0
Vector3D CustomMetric::getScale() const
{
	if (!mScaleToP1 || !this->getModel() || this->getModel()->getType() == "image")
		return Vector3D::Ones();

	DoubleBoundingBox3D bounds = this->getModel()->boundingBox();
	bounds = transform(this->getModel()->get_rMd(), bounds);

	std::vector<Vector3D> coords = mArguments->getRefCoords();
	double height = (coords[1] - coords[0]).length();

	Vector3D dir = this->getDirection();
	double p0 = dot(coords[0], dir);
	double p1 = dot(coords[1], dir);

	height = p1 - p0;
	height -= (mOffsetFromP0 + mOffsetFromP1);

	Vector3D scale(1,
				   height/bounds.range()[1],
			1);
	return scale;
}