void TransFuncEditorIntensityPet::maxBoxChanged(int value) { if (value-1 > currentRange_.x) { //increment minimum of upper spin when minimum was reached and we are above lower range if (value == upperThresholdSpin_->minimum()) upperThresholdSpin_->setMinimum(value - 1); //update maximum of lower spin lowerThresholdSpin_->blockSignals(true); lowerThresholdSpin_->setMaximum(value); lowerThresholdSpin_->blockSignals(false); } //increment value of lower spin when it equals value of upper spin if (value == lowerThresholdSpin_->value()) { lowerThresholdSpin_->blockSignals(true); lowerThresholdSpin_->setValue(value - 1); lowerThresholdSpin_->blockSignals(false); } //update doubleSlider to new maxValue float sliderMax = (value - currentRange_.x) / static_cast<float>(currentRange_.y - currentRange_.x); doubleSlider_->blockSignals(true); doubleSlider_->setMaxValue(sliderMax); doubleSlider_->blockSignals(false); //apply threshold to both transfer functions applyThreshold(); updateTransferFunction(); }
void TransFuncEditorIntensityPet::loadTransferFunction() { // create filter with supported file formats QString filter = "transfer function ("; for (size_t i = 0; i < transferFuncIntensity_->getLoadFileFormats().size(); ++i) { std::string temp = "*." + transferFuncIntensity_->getLoadFileFormats()[i] + " "; filter.append(temp.c_str()); } filter.replace(filter.length()-1, 1, ")"); QString fileName = getOpenFileName(filter); if (!fileName.isEmpty()) { if (transferFuncIntensity_->load(fileName.toStdString()) && transferFuncGradient_->load(fileName.toStdString())) { if (!transferFunctionCorrect()) { rectifyTransferFunction(); std::string error = "The transfer function contains keys which alpha value is not "; error += "255.\nThe alpha value of these keys will be set to 255."; QMessageBox::critical(this, tr("Error"), tr(error.c_str())); LINFO(error); } ranges_.clear(); currentRange_ = tgt::ivec2(0, maximumIntensity_); oldThreshold_ = tgt::vec2(0.f, 1.f); if (transferFuncIntensity_->getThresholds() != tgt::vec2(0.f, 1.f)) restoreThresholds(); updateTransferFunction(); } else { QMessageBox::critical(this, tr("Error"), "The selected transfer function could not be loaded."); LERROR("The selected transfer function could not be loaded. Maybe the file is corrupt."); } } }
void TransFunc1DKeysEditor::loadTransferFunction() { if (!transferFuncIntensity_) { LWARNING("No valid transfer function assigned"); return; } //create filter with supported file formats QString filter = "transfer function ("; for (size_t i = 0; i < transferFuncIntensity_->getLoadFileFormats().size(); ++i) { std::string temp = "*." + transferFuncIntensity_->getLoadFileFormats()[i] + " "; filter.append(temp.c_str()); } filter.replace(filter.length()-1, 1, ")"); QString fileName = getOpenFileName(filter); if (!fileName.isEmpty()) { if (transferFuncIntensity_->load(fileName.toStdString())) { updateMappingSpin(true); updateThresholdFromProperty(); updateTransferFunction(); } else { QMessageBox::critical(this, tr("Error"), "The selected transfer function could not be loaded."); LERROR("The selected transfer function could not be loaded. Maybe the file is corrupt."); } } }
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))); }
/** Constructor. @param vd volume description @param m render geometry (default: automatic) */ vvStingray::vvStingray(vvVolDesc* vd, vvRenderState renderState) : vvRenderer(vd, renderState) { vvDebugMsg::msg(1, "vvStingray::vvStingray()"); cerr << "vvStingray::vvStingray() called." << endl; rendererType = STINGRAY; interpolation = true; mip = 0; gammaCorrection = false; rgbaTF = new float[4096 * 4]; rgbaLUT = new uchar[4096 * 4]; //****************** initialize Stingray renderer // if mip==0 then alpha blending should be used, // if mip==1 maximum intensity projection should be use // // if interpolation==true: linear interpolation // if false: nearest neighbor _stingRay = new fvStingRayCaveRenderer(); unsigned char* test = new unsigned char[32 * 32 * 32]; memset(test, 128, 32*32*32); // _stingRay->initializeRenderer(2, 2, fvStingRayCaveRenderer::F_ISOSURFACE, // fvStingRayCaveRenderer::F_PERSPECTIVE, vd->getRaw(), vd->vox[0], vd->vox[1], vd->vox[2]); _stingRay->initializeRenderer(2, 2, fvStingRayCaveRenderer::F_ISOSURFACE, fvStingRayCaveRenderer::F_PERSPECTIVE, test, 32, 32, 32); updateTransferFunction(); cerr << "vvStingray::vvStingray() done" << endl; }
void TransFunc1DKeysEditor::fitDomainToData() { property_->fitDomainToData(); if(volume_) { updateMappingSpin(true); updateThresholdFromProperty(); updateTransferFunction(); } }
void TransFunc1DKeysEditor::mappingChanged() { if (!transferFuncIntensity_) return; updateMappingSpin(false); updateThresholdFromProperty(); updateTransferFunction(); checkDomainVersusData(); }
void TransFunc1DKeysEditor::applyThreshold() { if (!transferFuncIntensity_) return; float min = doubleSlider_->getMinValue(); float max = doubleSlider_->getMaxValue(); transCanvas_->setThreshold(min, max); transferFuncIntensity_->setThresholds(min, max); updateTransferFunction(); }
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())); }
void TransFuncEditorIntensityPet::sliderChanged(float min, float max) { //consider expand factor min = min * (currentRange_.y - currentRange_.x) + currentRange_.x; max = max * (currentRange_.y - currentRange_.x) + currentRange_.x; //sync with spinboxes int val = tgt::iround(max); if ((val != upperThresholdSpin_->value())) upperThresholdSpin_->setValue(val); val = tgt::iround(min); if ((val != lowerThresholdSpin_->value())) lowerThresholdSpin_->setValue(val); //apply threshold to both transfer functions applyThreshold(); updateTransferFunction(); }
void TransFuncEditorIntensityPet::expandGradient() { //save old range ranges_.push_back(currentRange_); //new range of spinboxes currentRange_ = tgt::ivec2(lowerThresholdSpin_->value(), upperThresholdSpin_->value()); //set minimum and maximum of thresholdspins lowerThresholdSpin_->setMinimum(lowerThresholdSpin_->value()); lowerThresholdSpin_->setMaximum(upperThresholdSpin_->value() - 1); upperThresholdSpin_->setMinimum(lowerThresholdSpin_->value() + 1); upperThresholdSpin_->setMaximum(upperThresholdSpin_->value()); //reset doubleslider doubleSlider_->blockSignals(true); doubleSlider_->setValues(0.f, 1.f); doubleSlider_->setMinimalAllowedSliderDistance(1.f / static_cast<float>(currentRange_.y - currentRange_.x)); doubleSlider_->blockSignals(false); applyThreshold(); updateTransferFunction(); }
void TransFunc1DRampEditor::loadTransferFunction() { if (!transferFuncIntensity_) { LWARNING("No valid transfer function assigned"); return; } //create filter with supported file formats QString filter = "transfer function ("; for (size_t i = 0; i < transferFuncIntensity_->getLoadFileFormats().size(); ++i) { std::string temp = "*." + transferFuncIntensity_->getLoadFileFormats()[i] + " "; filter.append(temp.c_str()); } filter.replace(filter.length()-1, 1, ")"); QString fileName = getOpenFileName(filter); if (!fileName.isEmpty()) { if (transferFuncIntensity_->load(fileName.toStdString())) { if (transferFuncIntensity_->getNumKeys() > 2) { clearButtonClicked(); std::string error = "The loaded transfer function contains more than 2 keys.\n"; error += "The editor does not support this kind of transfer functions.\n"; error += "The transfer function is reset to default."; QMessageBox::critical(this, tr("Error"), tr(error.c_str())); LERROR(error); } else { restoreThresholds(); updateTransferFunction(); } } else { QMessageBox::critical(this, tr("Error"), tr("The selected transfer function could not be loaded.")); LERROR("The selected transfer function could not be loaded. Maybe the file is corrupt."); } } }
void TransFuncEditorIntensityPet::collapseGradient() { if (ranges_.empty()) return; //restore old range currentRange_ = ranges_[ranges_.size() - 1]; ranges_.pop_back(); //reset minimum and maximum values of spinboxes to values before last expand lowerThresholdSpin_->setMinimum(currentRange_.x); lowerThresholdSpin_->setMaximum(currentRange_.y - 1); upperThresholdSpin_->setMinimum(currentRange_.x + 1); upperThresholdSpin_->setMaximum(currentRange_.y); //reset double slider to range before last expand doubleSlider_->blockSignals(true); doubleSlider_->setMinimalAllowedSliderDistance(1.f / static_cast<float>(currentRange_.y - currentRange_.x)); doubleSlider_->setValues((lowerThresholdSpin_->value() - currentRange_.x) / static_cast<float>(currentRange_.y - currentRange_.x), (upperThresholdSpin_->value() - currentRange_.x) / static_cast<float>(currentRange_.y - currentRange_.x)); doubleSlider_->blockSignals(false); applyThreshold(); updateTransferFunction(); }
SplineEditorWidget::SplineEditorWidget(QWidget *parent) : QWidget(parent) { m_parent = parent; QPen m_pointPen; QBrush m_pointBrush; QPen m_connectionPen; m_pointPen = QPen(QColor(0, 0, 0, 255), 1); m_connectionPen = QPen(QColor(200, 200, 200, 150), 1); m_pointBrush = QBrush(QColor(255, 255, 255, 200)); m_1dHist = new QRadioButton("1D", this); m_2dHist = new QRadioButton("2D", this); m_vol1 = new QRadioButton("V1", this); m_vol2 = new QRadioButton("V2", this); m_vol3 = new QRadioButton("V3", this); m_vol4 = new QRadioButton("V4", this); QButtonGroup *butGrp1 = new QButtonGroup(this); butGrp1->setExclusive(true); butGrp1->addButton(m_1dHist); butGrp1->addButton(m_2dHist); QButtonGroup *butGrp2 = new QButtonGroup(this); butGrp2->setExclusive(true); butGrp2->addButton(m_vol1); butGrp2->addButton(m_vol2); butGrp2->addButton(m_vol3); butGrp2->addButton(m_vol4); m_2dHist->setChecked(true); m_vol1->setChecked(true); QHBoxLayout *hbox = new QHBoxLayout(); hbox->addStretch(); hbox->addWidget(m_vol4); hbox->addWidget(m_vol3); hbox->addWidget(m_vol2); hbox->addWidget(m_vol1); m_gbotValue = new QLineEdit("1.0"); m_gbotValue->setMaximumSize(30, 25); QRegExp rx("(\\-?\\d*\\.?\\d*\\s?)"); QRegExpValidator *validator = new QRegExpValidator(rx,0); m_gbotValue->setValidator(validator); m_gtopValue = new QLineEdit("1.0"); m_gtopValue->setMaximumSize(30, 25); m_gtopValue->setValidator(validator); QHBoxLayout *hboxt = new QHBoxLayout(); hboxt->addWidget(m_gbotValue); hboxt->addStretch(); hboxt->addWidget(m_1dHist); hboxt->addWidget(m_2dHist); hboxt->addStretch(); hboxt->addWidget(m_gtopValue); m_gbotSlider = new QSlider(Qt::Vertical); m_gbotSlider->setRange(0, 255); m_gbotSlider->setValue(0); m_gtopSlider = new QSlider(Qt::Vertical); m_gtopSlider->setRange(0, 255); m_gtopSlider->setValue(255); m_16bitEditor = new RemapHistogramWidget(this); m_16bitEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_splineEditor = new SplineEditor(this); m_splineEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QHBoxLayout *hbox1 = new QHBoxLayout; hbox1->addWidget(m_gbotSlider); hbox1->addWidget(m_splineEditor); hbox1->addWidget(m_16bitEditor); hbox1->addWidget(m_gtopSlider); QVBoxLayout *vbox = new QVBoxLayout(); vbox->addLayout(hboxt); vbox->addLayout(hbox1); vbox->addLayout(hbox); setLayout(vbox); m_vol1->hide(); m_vol2->hide(); m_vol3->hide(); m_vol4->hide(); m_splineEditor->setShapePen(m_pointPen); m_splineEditor->setConnectionPen(m_connectionPen); m_splineEditor->setShapeBrush(m_pointBrush); connect(m_gtopSlider, SIGNAL(sliderReleased()), this, SLOT(gtopSliderReleased())); connect(m_gbotSlider, SIGNAL(sliderReleased()), this, SLOT(gbotSliderReleased())); connect(m_gtopValue, SIGNAL(editingFinished()), this, SLOT(gValueChanged())); connect(m_gbotValue, SIGNAL(editingFinished()), this, SLOT(gValueChanged())); connect(m_1dHist, SIGNAL(toggled(bool)), this, SLOT(hist1DClicked(bool))); connect(m_2dHist, SIGNAL(toggled(bool)), this, SLOT(hist2DClicked(bool))); connect(m_vol1, SIGNAL(toggled(bool)), this, SLOT(vol1Clicked(bool))); connect(m_vol2, SIGNAL(toggled(bool)), this, SLOT(vol2Clicked(bool))); connect(m_vol3, SIGNAL(toggled(bool)), this, SLOT(vol3Clicked(bool))); connect(m_vol4, SIGNAL(toggled(bool)), this, SLOT(vol4Clicked(bool))); connect(m_splineEditor, SIGNAL(refreshDisplay()), this, SLOT(update())); connect(m_splineEditor, SIGNAL(splineChanged()), this, SLOT(updateTransferFunction())); connect(m_splineEditor, SIGNAL(selectEvent(QGradientStops)), this, SLOT(selectSpineEvent(QGradientStops))); connect(m_splineEditor, SIGNAL(deselectEvent()), this, SLOT(deselectSpineEvent())); connect(m_splineEditor, SIGNAL(applyUndo(bool)), this, SIGNAL(applyUndo(bool))); connect(m_16bitEditor, SIGNAL(newMapping(float, float)), this, SLOT(updateTransferFunction(float, float))); setMinimumSize(200, 200); m_16bitEditor->hide(); }
void TransFunc1DKeysEditor::makeRamp() { if (transferFuncIntensity_) { transferFuncIntensity_->makeRamp(); updateTransferFunction(); } }
ViewerWindow::ViewerWindow(): fileLoaded_(false){ setupUi( this ); #ifdef WIN32 //Reposition console window QRect myRegion=frameGeometry(); QPoint putAt=myRegion.topRight(); SetWindowPos(GetConsoleWindow(),winId(),putAt.x()+1,putAt.y(),0,0,SWP_NOSIZE); #endif mProdconn.ConnectConsumer( mViewer->InputPort()[0] ); mViewer->SetColorTransformType( M4D::GUI::ctTransferFunction1D ); action2D->setChecked(true); //---TF Editor--- std::vector<M4D::GUI::TF::Size> dataCT1D(1, 4096); //default CT editingSystem_ = M4D::GUI::TFPalette::Ptr(new M4D::GUI::TFPalette(this, dataCT1D)); editingSystem_->setupDefault(); bool previewUpdateConnected = QObject::connect(&(*editingSystem_), SIGNAL(UpdatePreview(M4D::GUI::TF::Size)), this, SLOT(updatePreview(M4D::GUI::TF::Size))); tfAssert(previewUpdateConnected); QDockWidget* dockWidget = new QDockWidget("Transfer Function Palette", this); dockWidget->setWidget( &(*editingSystem_) ); dockWidget->setFeatures(QDockWidget::AllDockWidgetFeatures); dockWidget->setAllowedAreas(Qt::AllDockWidgetAreas); addDockWidget(Qt::LeftDockWidgetArea, dockWidget); dockWidget->setFloating(true); //---Timer--- changeChecker_.setInterval( 500 ); QObject::connect( &changeChecker_, SIGNAL( timeout() ), this, SLOT( updateTransferFunction() ) ); //---Viewer Switch--- QActionGroup *viewerTypeSwitch = new QActionGroup( this ); QSignalMapper *viewerTypeSwitchSignalMapper = new QSignalMapper( this ); viewerTypeSwitch->setExclusive( true ); viewerTypeSwitch->addAction( action2D ); viewerTypeSwitch->addAction( action3D ); viewerTypeSwitchSignalMapper->setMapping( action2D, M4D::GUI::rt2DAlignedSlices ); viewerTypeSwitchSignalMapper->setMapping( action3D, M4D::GUI::rt3D ); QObject::connect( action2D, SIGNAL( triggered() ), viewerTypeSwitchSignalMapper, SLOT( map() ) ); QObject::connect( action3D, SIGNAL( triggered() ), viewerTypeSwitchSignalMapper, SLOT( map() ) ); QObject::connect( viewerTypeSwitchSignalMapper, SIGNAL( mapped ( int ) ), this, SLOT( changeViewerType( int ) ) ); //---Mouse info--- QLabel *infoLabel = new QLabel(); statusbar->addWidget( infoLabel ); mViewer->setMouseTracking ( true ); QObject::connect( mViewer, SIGNAL( MouseInfoUpdate( const QString & ) ), infoLabel, SLOT( setText( const QString & ) ) ); //---Default buffer--- buffer_ = Buffer1D::Ptr(new Buffer1D(4096, Interval(0.0f, 4095.0f))); #ifdef TF_NDEBUG showMaximized(); #endif #ifndef TF_NDEBUG show(); #endif //show must be called before setting transfer function buffer mViewer->SetTransferFunctionBuffer(buffer_); }