Esempio n. 1
0
void TransFunc1DKeysEditor::createConnections() {
    // Buttons
    connect(clearButton_, SIGNAL(clicked()), this, SLOT(clearButtonClicked()));
    connect(loadButton_, SIGNAL(clicked()), this, SLOT(loadTransferFunction()));
    connect(saveButton_, SIGNAL(clicked()), this, SLOT(saveTransferFunction()));
    connect(makeRampButton_, SIGNAL(clicked()), this, SLOT(makeRamp()));

    // signals from transferMappingCanvas
    connect(transCanvas_, SIGNAL(changed()), this, SLOT(updateTransferFunction()));
    connect(transCanvas_, SIGNAL(loadTransferFunction()), this, SLOT(loadTransferFunction()));
    connect(transCanvas_, SIGNAL(saveTransferFunction()), this, SLOT(saveTransferFunction()));
    connect(transCanvas_, SIGNAL(resetTransferFunction()), this, SLOT(clearButtonClicked()));
    connect(transCanvas_, SIGNAL(toggleInteractionMode(bool)), this, SLOT(toggleInteractionMode(bool)));

    // signals for colorPicker
    connect(transCanvas_, SIGNAL(colorChanged(const QColor&)),
            colorPicker_, SLOT(setCol(const QColor)));
    connect(transCanvas_, SIGNAL(colorChanged(const QColor&)),
            colorLumPicker_, SLOT(setCol(const QColor)));
    connect(colorPicker_, SIGNAL(newCol(int,int)),
            colorLumPicker_, SLOT(setCol(int,int)));
    connect(colorLumPicker_, SIGNAL(newHsv(int,int,int)),
            this, SLOT(markerColorChanged(int,int,int)));
    connect(colorPicker_, SIGNAL(toggleInteractionMode(bool)), this, SLOT(toggleInteractionMode(bool)));
    connect(colorLumPicker_, SIGNAL(toggleInteractionMode(bool)), this, SLOT(toggleInteractionMode(bool)));

    // doubleslider
    connect(doubleSlider_, SIGNAL(valuesChanged(float, float)), this, SLOT(applyThreshold()));
    connect(doubleSlider_, SIGNAL(toggleInteractionMode(bool)), this, SLOT(toggleInteractionMode(bool)));

    connect(lowerMappingSpin_, SIGNAL(valueChanged(double)), this, SLOT(lowerMappingChanged(double)));
    connect(upperMappingSpin_, SIGNAL(valueChanged(double)), this, SLOT(upperMappingChanged(double)));
    connect(fitDomainToData_, SIGNAL(clicked()), this, SLOT(fitDomainToData()));
    connect(alwaysFit_, SIGNAL(stateChanged(int)), this, SLOT(alwaysFitChanged(int)));
}
void TransFunc1DRampEditor::createConnections() {
    // Buttons
    connect(clearButton_, SIGNAL(clicked()), this, SLOT(clearButtonClicked()));
    connect(loadButton_, SIGNAL(clicked()), this, SLOT(loadTransferFunction()));
    connect(saveButton_, SIGNAL(clicked()), this, SLOT(saveTransferFunction()));

    // signals from transferMappingCanvas
    connect(transCanvas_, SIGNAL(changed()), this, SLOT(updateTransferFunction()));
    connect(transCanvas_, SIGNAL(loadTransferFunction()), this, SLOT(loadTransferFunction()));
    connect(transCanvas_, SIGNAL(saveTransferFunction()), this, SLOT(saveTransferFunction()));
    connect(transCanvas_, SIGNAL(resetTransferFunction()), this, SLOT(clearButtonClicked()));
    connect(transCanvas_, SIGNAL(toggleInteractionMode(bool)), this, SLOT(toggleInteractionMode(bool)));

    // signals for colorPicker
    connect(transCanvas_, SIGNAL(colorChanged(const QColor&)),
            colorPicker_, SLOT(setCol(const QColor)));
    connect(transCanvas_, SIGNAL(colorChanged(const QColor&)),
            colorLumPicker_, SLOT(setCol(const QColor)));
    connect(colorPicker_, SIGNAL(newCol(int,int)),
            colorLumPicker_, SLOT(setCol(int,int)));
    connect(colorLumPicker_, SIGNAL(newHsv(int,int,int)),
            this, SLOT(markerColorChanged(int,int,int)));
    connect(colorPicker_, SIGNAL(toggleInteractionMode(bool)), this, SLOT(toggleInteractionMode(bool)));
    connect(colorLumPicker_, SIGNAL(toggleInteractionMode(bool)), this, SLOT(toggleInteractionMode(bool)));

    // doubleslider
    connect(doubleSlider_, SIGNAL(valuesChanged(float, float)), this, SLOT(thresholdChanged(float, float)));
    connect(doubleSlider_, SIGNAL(toggleInteractionMode(bool)), this, SLOT(toggleInteractionMode(bool)));

    // threshold spinboxes
    connect(lowerThresholdSpin_, SIGNAL(valueChanged(int)), this, SLOT(lowerThresholdSpinChanged(int)));
    connect(upperThresholdSpin_, SIGNAL(valueChanged(int)), this, SLOT(upperThresholdSpinChanged(int)));

    connect(checkClipThresholds_, SIGNAL(toggled(bool)), transCanvas_, SLOT(toggleClipThresholds(bool)));

    //ramp slider and spinboxes
    connect(sliderRampCenter_, SIGNAL(valueChanged(int)), this, SLOT(updateRampCenter(int)));
    connect(spinRampCenter_,   SIGNAL(valueChanged(int)), this, SLOT(updateRampCenter(int)));
    connect(spinRampWidth_,    SIGNAL(valueChanged(int)), this, SLOT(updateRampWidth(int)));
    connect(sliderRampWidth_,  SIGNAL(valueChanged(int)), this, SLOT(updateRampWidth(int)));

    connect(sliderRampCenter_, SIGNAL(sliderPressed()),  this, SLOT(startTracking()));
    connect(sliderRampWidth_,  SIGNAL(sliderPressed()),  this, SLOT(startTracking()));
    connect(sliderRampCenter_, SIGNAL(sliderReleased()), this, SLOT(stopTracking()));
    connect(sliderRampWidth_,  SIGNAL(sliderReleased()), this, SLOT(stopTracking()));
}
Esempio n. 3
0
void TransFunc1DKeysEditor::resetEditor() {
    if (property_->get() != transferFuncIntensity_) {
        LDEBUG("The pointers of property and transfer function do not match."
                << "Creating new transfer function object.....");
        transferFuncIntensity_ = new TransFunc1DKeys(1024);//TODO
        property_->set(transferFuncIntensity_);

        // propagate transfer function to mapping canvas and texture painter
        texturePainter_->setTransFunc(transferFuncIntensity_);
        transCanvas_->setTransFunc(transferFuncIntensity_);
    }

    // reset transfer function and thresholds
    resetTransferFunction();

    causeVolumeRenderingRepaint();
}
void TransFunc1DRampEditor::resetEditor() {
    if (property_->get() != transferFuncIntensity_) {
        LDEBUG("The pointers of property and transfer function do not match."
                << "Creating new transfer function object.....");
        transferFuncIntensity_ = new TransFunc1DKeys(maximumIntensity_ + 1);
        property_->set(transferFuncIntensity_);

        // propagate transfer function to mapping canvas and gradient
        texturePainter_->setTransFunc(transferFuncIntensity_);
        transCanvas_->setTransFunc(transferFuncIntensity_);
    }

    checkClipThresholds_->setChecked(false);
    // reset transfer function and thresholds
    resetThresholds();
    resetTransferFunction();

    causeVolumeRenderingRepaint();
}
void TransFuncEditorIntensityPet::resetEditor() {
    if (property_->get() != transferFuncIntensity_) {
        LDEBUG("The pointers of property and transfer function do not match."
                << "Creating new transfer function object.....");
        transferFuncIntensity_ = new TransFuncIntensity(maximumIntensity_ + 1);
        property_->set(transferFuncIntensity_);
        delete transferFuncGradient_;
        transferFuncGradient_ = new TransFuncIntensity(*transferFuncIntensity_);

        // propagate transfer functions to the gradients
        completeTexturePainter_->setTransFunc(transferFuncIntensity_);
        expandedTexturePainter_->setTransFunc(transferFuncGradient_);
    }

    resetTransferFunction();
    resetThresholds();

    causeVolumeRenderingRepaint();
}
void TransFuncEditorIntensityGradient::createConnections() {
    if (!supported_)
        return;

    // buttons
    connect(loadButton_,  SIGNAL(clicked()), this, SLOT(loadTransferFunction()));
    connect(saveButton_,  SIGNAL(clicked()), this, SLOT(saveTransferFunction()));
    connect(clearButton_, SIGNAL(clicked()), painter_, SLOT(resetTransferFunction()));

    connect(gridEnabledButton_,      SIGNAL(clicked()), this, SLOT(toggleShowGrid()));
    connect(histogramEnabledButton_, SIGNAL(clicked()), this, SLOT(toggleShowHistogram()));

    connect(quadButton_,   SIGNAL(clicked()), painter_, SLOT(addQuadPrimitive()));
    connect(bananaButton_, SIGNAL(clicked()), painter_, SLOT(addBananaPrimitive()));
    connect(deleteButton_, SIGNAL(clicked()), painter_, SLOT(deletePrimitive()));
    connect(colorButton_,  SIGNAL(clicked()), painter_, SLOT(colorizePrimitive()));

    connect(histogramBrightness_, SIGNAL(sliderMoved(int)), painter_, SLOT(histogramBrightnessChanged(int)));
    connect(histogramLog_, SIGNAL(stateChanged(int)), painter_, SLOT(toggleHistogramLogarithmic(int)));

    // slider
    connect(fuzziness_, SIGNAL(valueChanged(int)), painter_, SLOT(fuzzinessChanged(int)));
    connect(transparency_, SIGNAL(valueChanged(int)), painter_, SLOT(transparencyChanged(int)));

    connect(fuzziness_, SIGNAL(sliderPressed()), this, SLOT(startTracking()));
    connect(transparency_, SIGNAL(sliderPressed()), this, SLOT(startTracking()));

    connect(fuzziness_, SIGNAL(sliderReleased()), this, SLOT(stopTracking()));
    connect(transparency_, SIGNAL(sliderReleased()), this, SLOT(stopTracking()));

    connect(painter_, SIGNAL(setTransparencySlider(int)), this, SLOT(setTransparency(int)));
    connect(painter_, SIGNAL(primitiveDeselected()), this, SLOT(primitiveDeselected()));
    connect(painter_, SIGNAL(primitiveSelected()), this, SLOT(primitiveSelected()));
    connect(painter_, SIGNAL(toggleInteractionMode(bool)), this, SLOT(toggleInteractionMode(bool)));
    connect(painter_, SIGNAL(repaintSignal()), this, SLOT(repaintSignal()));

}
void TransferFunctionPropertyDialog::generateWidget() {
    vec2 minEditorDims = vec2(255.0f, 100.0f);

    tfEditorView_ = new TransferFunctionEditorView(tfProperty_);
    tfProperty_->get().addObserver(tfEditorView_);
    // put origin to bottom left corner
    tfEditorView_->scale(1.0, -1.0);
    tfEditorView_->setAlignment(Qt::AlignLeft | Qt::AlignBottom);
    tfEditorView_->setMinimumSize(minEditorDims.x, minEditorDims.y);
    tfEditorView_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    tfEditorView_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    
    tfEditor_ = new TransferFunctionEditor(&tfProperty_->get(), tfEditorView_);
    connect(tfEditor_, SIGNAL(doubleClick()), this, SLOT(showColorDialog()));
    connect(tfEditor_, SIGNAL(selectionChanged()), this, SLOT(updateColorWheel()));
    tfEditorView_->setScene(tfEditor_);

    zoomVSlider_ = new RangeSliderQt(Qt::Vertical, this);
    zoomVSlider_->setRange(0, sliderRange_);
    zoomVSlider_->setMinSeparation(5);
    // flip slider values to compensate for vertical slider layout
    zoomVSlider_->setValue(sliderRange_ - static_cast<int>(tfProperty_->getZoomV().y*sliderRange_),
                           sliderRange_ - static_cast<int>(tfProperty_->getZoomV().x*sliderRange_));
    connect(zoomVSlider_, SIGNAL(valuesChanged(int, int)),
            this, SLOT(changeVerticalZoom(int, int)));
    
    zoomHSlider_ = new RangeSliderQt(Qt::Horizontal, this);
    zoomHSlider_->setRange(0, sliderRange_);
    zoomHSlider_->setMinSeparation(5);
    zoomHSlider_->setValue(static_cast<int>(tfProperty_->getZoomH().x*sliderRange_),
                           static_cast<int>(tfProperty_->getZoomH().y*sliderRange_));
    connect(zoomHSlider_, SIGNAL(valuesChanged(int, int)),
            this, SLOT(changeHorizontalZoom(int, int)));

    maskSlider_ = new RangeSliderQt(Qt::Horizontal, this);
    maskSlider_->setRange(0, sliderRange_);
    maskSlider_->setValue(static_cast<int>(tfProperty_->getMask().x*sliderRange_),
                          static_cast<int>(tfProperty_->getMask().y*sliderRange_));
    connect(maskSlider_, SIGNAL(valuesChanged(int, int)),
            this, SLOT(changeMask(int, int)));
    
    colorWheel_ = new ColorWheel();
    connect(colorWheel_, SIGNAL(colorChange(QColor)), this, SLOT(setPointColor(QColor)));
    
    btnClearTF_ = new QPushButton("Reset");
    connect(btnClearTF_, SIGNAL(clicked()), tfEditor_, SLOT(resetTransferFunction()));
    btnClearTF_->setStyleSheet(QString("min-width: 30px; padding-left: 7px; padding-right: 7px;"));
    
    btnImportTF_ = new QPushButton("Import");
    connect(btnImportTF_, SIGNAL(clicked()), this, SLOT(importTransferFunction()));
    btnImportTF_->setStyleSheet(QString("min-width: 30px; padding-left: 7px; padding-right: 7px;"));
    
    btnExportTF_ = new QPushButton("Export");
    connect(btnExportTF_, SIGNAL(clicked()), this, SLOT(exportTransferFunction()));
    btnExportTF_->setStyleSheet(QString("min-width: 30px; padding-left: 7px; padding-right: 7px;"));

    tfPreview_ = new QLabel();
    tfPreview_->setMinimumSize(1,20);
    QSizePolicy sliderPol = tfPreview_->sizePolicy();
    sliderPol.setHorizontalStretch(3);
    tfPreview_->setSizePolicy(sliderPol);
    
    cmbInterpolation_ = new QComboBox();
    cmbInterpolation_->addItem("Interpolation: Linear");
    //cmbInterpolation_->addItem("Interpolation: Cubic"); // Not implemented... (yet)
    cmbInterpolation_->setCurrentIndex(tfProperty_->get().getInterpolationType());
    connect(cmbInterpolation_, SIGNAL(currentIndexChanged(int)),
            this, SLOT(switchInterpolationType(int)));
    
    chkShowHistogram_ = new QComboBox();
    chkShowHistogram_->addItem("Histogram: Off");
    chkShowHistogram_->addItem("Histogram: 100%");
    chkShowHistogram_->addItem("Histogram: 99%");
    chkShowHistogram_->addItem("Histogram: 95%");
    chkShowHistogram_->addItem("Histogram: 90%");
    chkShowHistogram_->addItem("Histogram: Log");
    chkShowHistogram_->setCurrentIndex(tfProperty_->getShowHistogram());
    connect(chkShowHistogram_, SIGNAL(currentIndexChanged(int)), this, SLOT(showHistogram(int)));
    
    pointMoveMode_ = new QComboBox();
    pointMoveMode_->addItem("Point Movement: Free");
    pointMoveMode_->addItem("Point Movement: Restrict");
    pointMoveMode_->addItem("Point Movement: Push");
    pointMoveMode_->setCurrentIndex(0);
    connect(pointMoveMode_, SIGNAL(currentIndexChanged(int)), this, SLOT(changeMoveMode(int)));

    colorDialog_ = new QColorDialog(this);
    colorDialog_->hide();
    colorDialog_->setOption(QColorDialog::ShowAlphaChannel, true);
    colorDialog_->setOption(QColorDialog::NoButtons, true);
    colorDialog_->setWindowModality(Qt::NonModal);
    colorDialog_->setWindowTitle(QString::fromStdString(tfProperty_->getDisplayName()));
    connect(colorDialog_, SIGNAL(currentColorChanged(QColor)),
            this, SLOT(setPointColorDialog(QColor)));
    
    QFrame* leftPanel = new QFrame(this);
    QGridLayout* leftLayout = new QGridLayout();
    leftLayout->setContentsMargins(0, 0, 0, 0);
    leftLayout->setSpacing(7);
    leftLayout->addWidget(zoomVSlider_,  0, 0);
    leftLayout->addWidget(tfEditorView_, 0, 1);
    leftLayout->addWidget(zoomHSlider_,  1, 1);
    leftLayout->addWidget(tfPreview_,    2, 1);
    leftLayout->addWidget(maskSlider_,   3, 1);
    leftPanel->setLayout(leftLayout);
    
    QFrame* rightPanel = new QFrame(this);
    QVBoxLayout* rightLayout = new QVBoxLayout();
    rightLayout->setContentsMargins(0, 0, 0, 0);
    rightLayout->setSpacing(7);
    rightLayout->setAlignment(Qt::AlignTop);
    rightLayout->addWidget(colorWheel_);
    rightLayout->addWidget(cmbInterpolation_);
    rightLayout->addWidget(chkShowHistogram_);
    rightLayout->addWidget(pointMoveMode_);
    rightLayout->addStretch(3);
    QHBoxLayout* rowLayout = new QHBoxLayout();
    rowLayout->addWidget(btnClearTF_);
    rowLayout->addWidget(btnImportTF_);
    rowLayout->addWidget(btnExportTF_);
    rightLayout->addLayout(rowLayout);


    rightPanel->setLayout(rightLayout);
    
    QWidget* mainPanel = new QWidget(this);
    QHBoxLayout* mainLayout = new QHBoxLayout();
    mainLayout->setContentsMargins(7, 7, 7, 7);
    mainLayout->setSpacing(7);
    mainLayout->addWidget(leftPanel);
    mainLayout->addWidget(rightPanel);
    mainPanel->setLayout(mainLayout);
    
    setWidget(mainPanel);
    connect(this, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)),
            this, SLOT(dockLocationChanged(Qt::DockWidgetArea)));
    
    initialize(tfProperty_);
    setFloating(true);
    setVisible(false);
}
void TransFunc1DRampEditor::clearButtonClicked() {
    resetThresholds();
    resetTransferFunction();

    causeVolumeRenderingRepaint();
}
void TransFuncEditorIntensityPet::resetButtonClicked() {
    resetTransferFunction();
    resetThresholds();

    causeVolumeRenderingRepaint();
}
Esempio n. 10
0
void TransFunc1DKeysEditor::clearButtonClicked() {
    resetTransferFunction();
    causeVolumeRenderingRepaint();
}