Пример #1
0
    void VolumeModel::init(const ModelInfo::Params & params) {
        AbstractModelWithPoints::init(params);

        VolumeInfo::PhysicalSize physicalSize = params["physicalSize"].value<VolumeInfo::PhysicalSize>();
        VolumeInfo::Size size = params["size"].value<VolumeInfo::Size>();
        VolumeInfo::Scaling scaling = params["scaling"].value<VolumeInfo::Scaling>();

        scale(scaling);

        setSlope(params["slope"].value<VolumeInfo::Slope>());
        setIntercept(params["intercept"].value<VolumeInfo::Intercept>());

        setWindowCenter(params["windowCenter"].value<VolumeInfo::WindowCenter>());
        setWindowWidth(params["windowWidth"].value<VolumeInfo::WindowWidth>());

        setHuRange(params["huRange"].value<VolumeInfo::HuRange>());
        setValueRange(params["valueRange"].value<VolumeInfo::ValueRange>());

        ModelInfo::VerticesVTPtr vertices = new ModelInfo::VerticesVT;
        ModelInfo::IndicesPtr indices = new ModelInfo::Indices;

        GLfloat scalingFactor = (GLfloat) scene()->scalingFactor();

        GLfloat zCurrent = - physicalSize.z() * scaling.z() / scalingFactor / 2.0f;
        
        GLfloat step = - (zCurrent * 2.0f) / size.z();
        GLfloat stepTexture = 1.0f / size.z();

        GLfloat zCurrentTexture = 0.0f;

        GLfloat w = physicalSize.x() / 2.0f * scaling.x() / scalingFactor;
        GLfloat h = physicalSize.y() / 2.0f * scaling.y() / scalingFactor;

        for (int i = 0; i != (int) size.z(); ++ i) {
            vertices->push_back(ModelInfo::VertexVT(- w, - h, zCurrent, 0.0f, 1.0f, zCurrentTexture));
            vertices->push_back(ModelInfo::VertexVT(- w, h, zCurrent, 0.0f, 0.0f, zCurrentTexture));
            vertices->push_back(ModelInfo::VertexVT(w, h, zCurrent, 1.0f, 0.0f, zCurrentTexture));
            vertices->push_back(ModelInfo::VertexVT(w, - h, zCurrent, 1.0f, 1.0f, zCurrentTexture));

            indices->push_back(4 * i);
            indices->push_back(4 * i + 2);
            indices->push_back(4 * i + 1);
            indices->push_back(4 * i);
            indices->push_back(4 * i + 3);
            indices->push_back(4 * i + 2);

            zCurrent += step;
            zCurrentTexture += stepTexture;
        };

        ModelInfo::BuffersVT buffers;

        buffers.vertices = ModelInfo::VerticesVTPointer(vertices);
        buffers.indices = ModelInfo::IndicesPointer(indices);
        
        fillBuffers<ModelInfo::BuffersVT>(buffers);
    }
Пример #2
0
    void VolumeModel::invoke(const QString & name, const ModelInfo::Params & params) {
        if (name == "setHuRange") {
            setHuRange(params["range"].value<VolumeInfo::HuRange>());
            return;
        }

        if (name == "setWindowCenter") {
            setWindowCenter(params["windowCenter"].value<VolumeInfo::WindowCenter>());
            return;
        }

        if (name == "setWindowWidth") {
            setWindowWidth(params["windowWidth"].value<VolumeInfo::WindowWidth>());
            return;
        }

        AbstractModelWithPoints::invoke(name, params);
    }
Пример #3
0
int Dialog::show()
{
    setWindowCenter();
    QWidget::show();
}