TransferFunctionEditorWidget::TransferFunctionEditorWidget(QWidget *parent) :
  QSplitter(Qt::Vertical, parent)
{

  m_splineEditorWidget = new SplineEditorWidget(this);
  m_gradientEditorWidget = new GradientEditorWidget(this);

  addWidget(m_splineEditorWidget);
  addWidget(m_gradientEditorWidget);

  setChildrenCollapsible(false);

  QObject::connect(m_splineEditorWidget, SIGNAL(giveHistogram(int)),
		   SLOT(changeHistogram(int)));

  QObject::connect(m_gradientEditorWidget, SIGNAL(gradientChanged(QGradientStops)),
		   m_splineEditorWidget, SLOT(setGradientStops(QGradientStops)));

  QObject::connect(m_splineEditorWidget, SIGNAL(selectEvent(QGradientStops)),
		   m_gradientEditorWidget, SLOT(setColorGradient(QGradientStops)));

  QObject::connect(m_splineEditorWidget, SIGNAL(transferFunctionChanged(QImage)),
		   SLOT(transferFunctionChanged(QImage)));

  QObject::connect(m_splineEditorWidget, SIGNAL(applyUndo(bool)),
		   SIGNAL(applyUndo(bool)));

  QObject::connect(m_gradientEditorWidget, SIGNAL(applyUndo(bool)),
		   SIGNAL(applyUndo(bool)));
}
Example #2
0
void TransFuncPlugin::createConnections() {
    for (size_t i = 0; i < editors_.size(); ++i) {
        editors_[i]->createConnections();
        connect(editors_[i], SIGNAL(transferFunctionChanged()), this, SIGNAL(transferFunctionChanged()));
    }
    connect(tabWidget_, SIGNAL(currentChanged(int)), this, SLOT(editorChanged(int)));
}
TransferFunctionEditorWidget::TransferFunctionEditorWidget(QWidget *parent) :  
  QSplitter(Qt::Vertical, parent)
{
  m_parent = parent;

  m_splineEditorWidget = new SplineEditorWidget(this);
  m_gradientEditorWidget = new GradientEditorWidget(this);

  addWidget(m_splineEditorWidget);
  addWidget(m_gradientEditorWidget);

  QList<int> ssz;
  ssz << 150 << 75;
  setSizes(ssz);

  setChildrenCollapsible(false);

  QObject::connect(m_splineEditorWidget, SIGNAL(giveHistogram(int)),
		   this, SLOT(changeHistogram(int)));

  QObject::connect(m_gradientEditorWidget, SIGNAL(gradientChanged(QGradientStops)),
		   m_splineEditorWidget, SLOT(setGradientStops(QGradientStops)));

  QObject::connect(m_splineEditorWidget, SIGNAL(selectEvent(QGradientStops)),
		   m_gradientEditorWidget, SLOT(setColorGradient(QGradientStops)));

  QObject::connect(m_splineEditorWidget, SIGNAL(deselectEvent()),
		   m_gradientEditorWidget, SLOT(resetColorGradient()));

  QObject::connect(m_splineEditorWidget, SIGNAL(transferFunctionChanged(QImage)),
		   this, SLOT(transferFunctionChanged(QImage)));
}
void TransFuncEditorIntensityGradient::resetEditor() {
    if (!supported_)
        return;

    if (property_->get() != transFuncGradient_) {
        LDEBUG("The pointers of property and transfer function do not match."
                << "Creating new transfer function object.....");

        // Need to make the GL context of this context current, as we use it for OpenGL calls
        // with the transFuncGradient_ later on.
        transCanvas_->getGLFocus();
        transFuncGradient_ = new TransFuncIntensityGradient(maximumIntensity_ + 1);
        property_->set(transFuncGradient_);

        painter_->setTransFunc(transFuncGradient_);
    }

    // reset transfer function to default, e.g. empty tf
    painter_->resetTransferFunction();

    // update mapping widget, e.g. canvas
    transCanvas_->update();

    // cause repaint of volume rendering
    property_->notifyChange();
    emit transferFunctionChanged();
}
TransferFunctionEditor::TransferFunctionEditor()
{
	renderer = NULL;

  //! Load color maps.
  loadColorMaps();

  //! Setup UI elments.
  QVBoxLayout * layout = new QVBoxLayout();
  layout->setSizeConstraint(QLayout::SetMinimumSize);
  setLayout(layout);

  //! Form layout.
  QWidget *formWidget = new QWidget();
  QGridLayout *gridLayout = new QGridLayout();
  formWidget->setLayout(gridLayout);
  layout->addWidget(formWidget);

  //! Color map choice.
  for(unsigned int i=0; i<colorMaps.size(); i++)
	{
		std::string name = cmap_name(colorMaps[i].getName());
    colorMapComboBox.addItem(name.c_str());
	}

	gridLayout->addWidget(new QLabel("Colormap"), 0, 0, 1, 1);
	gridLayout->addWidget(&colorMapComboBox, 0, 1, 1, 3);

	gridLayout->addWidget(new QLabel("Min"), 1, 0, 1, 1);
	rangeMin.setValidator(new QDoubleValidator());
	connect(&rangeMin, SIGNAL(returnPressed()), this, SLOT(rangeMinChanged()));
	gridLayout->addWidget(&rangeMin, 1, 1, 1, 1);
	

	gridLayout->addWidget(new QLabel("Max"), 1, 2, 1, 1);
	rangeMax.setValidator(new QDoubleValidator());
	connect(&rangeMax, SIGNAL(returnPressed()), this, SLOT(rangeMaxChanged()));
	gridLayout->addWidget(&rangeMax, 1, 3, 1, 1);

  //! Widget containing opacity transfer function widget and scaling slider.
  QWidget * transferFunctionAlphaGroup = new QWidget();
  QHBoxLayout * hboxLayout = new QHBoxLayout();
  transferFunctionAlphaGroup->setLayout(hboxLayout);

  //! Opacity transfer function widget.
  hboxLayout->addWidget(&transferFunctionAlphaWidget);

  //! Opacity scaling slider, defaults to median value in range.
  transferFunctionAlphaScalingSlider.setValue(int(transferFunction.GetScale() * (transferFunctionAlphaScalingSlider.minimum() + transferFunctionAlphaScalingSlider.maximum())));
  transferFunctionAlphaScalingSlider.setOrientation(Qt::Vertical);
  hboxLayout->addWidget(&transferFunctionAlphaScalingSlider);

  gridLayout->addWidget(transferFunctionAlphaGroup, 2, 0, 1, 4);
  connect(&colorMapComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setColorMapIndex(int)));
  connect(&transferFunctionAlphaWidget, SIGNAL(transferFunctionChanged()), this, SLOT(alphaWidgetChanged()));
  connect(&transferFunctionAlphaScalingSlider, SIGNAL(valueChanged(int)), this, SLOT(alphaWidgetChanged()));

	setColorMapIndex(0);
}
void TransFunc1DKeysEditor::updateTransferFunction() {
    if (!transferFuncIntensity_)
        return;

    transferFuncIntensity_->invalidateTexture();
    property_->notifyChange();
    emit transferFunctionChanged();
}
QWidget* SpatialTransFuncPropertyWidget::createEditorWindowWidget() {
    plugin_ = new SpatialTransFuncPlugin(property_, parentWidget(), Qt::Horizontal);
    plugin_->createWidgets();
    plugin_->createConnections();
    connect(plugin_, SIGNAL(transferFunctionChanged()), this, SIGNAL(modified()));

    return plugin_;
}
void TransFunc1DRampEditor::causeVolumeRenderingRepaint() {
    // this informs the owner about change in transfer function texture
    property_->notifyChange();

    // this signal causes a repaint of the volume rendering
    emit transferFunctionChanged();

    repaintAll();
}
Example #9
0
void
SplineEditorWidget::updateTransferFunction(float tmin, float tmax)
{
  if (m_splineEditor->set16BitPoint(tmin, tmax))
    {
      QImage lookupTable = m_splineEditor->colorMapImage();
      emit transferFunctionChanged(lookupTable);
    }
}
Example #10
0
void TransferFunctionEditor::removeTCP(void)
{
  if (m_cur_tcp_idx != TransferFunction::INVALID_TCP_INDEX)
  {
    m_transfer_func->removeTCP(m_cur_tcp_idx);
    update();
    emit transferFunctionChanged(m_transfer_func);
  }
}
void TransferFunctionEditor::_onTransferFunction( const zeq::Event& tfEvent )
{
    if( !_tfReceived )
    {
        emit transferFunctionChanged( zeq::hbp::deserializeLookupTable1D( tfEvent ));
    }
    _tfReceived = true;
    _controller.deregisterHandler( _zeqSchema,
                                   zeq::vocabulary::EVENT_HEARTBEAT,
                                   boost::bind( &TransferFunctionEditor::_onHeartbeat,
                                   this ));
}
Example #12
0
void TransferFunctionEditor::mouseReleaseEvent(QMouseEvent *event)
{
  //qDebug() << m_transfer_func;

  //m_cur_tcp_idx = TransferFunction::INVALID_TCP_INDEX;
  //update();

  // treba upoznotnit widget, ktory zobrazuje volumetricke data,
  // aby sa prekreslil v plnej kvalite
  emit transferFunctionChanged(m_transfer_func);

  return QWidget::mouseReleaseEvent(event);
}
void QTransferFunctionView::makeConnections()
{
    connect(m_editor, SIGNAL(transferFunctionChanged(TransferFunction)), SLOT(setTransferFunction(TransferFunction)));
    connect(m_editor, SIGNAL(nameChanged(QString)), SLOT(setName(QString)));
    connect(m_editor, SIGNAL(colorTransferFunctionChanged(ColorTransferFunction)), SLOT(setColorTransferFunction(ColorTransferFunction)));
    connect(m_editor, SIGNAL(scalarOpacityTransferFunctionChanged(OpacityTransferFunction)), SLOT(setScalarOpacityTransferFunction(OpacityTransferFunction)));
//    connect(m_editor, SIGNAL(gradientOpacityTransferFunctionChanged(OpacityTransferFunction)),
//            SLOT(setGradientOpacityTransferFunction(OpacityTransferFunction)));
    connect(m_editor, SIGNAL(colorPointAdded(double, QColor)), SLOT(addColorPoint(double, QColor)));
    connect(m_editor, SIGNAL(colorPointRemoved(double)), SLOT(removeColorPoint(double)));
    connect(m_editor, SIGNAL(scalarOpacityPointAdded(double, double)), SLOT(addScalarOpacityPoint(double, double)));
    connect(m_editor, SIGNAL(scalarOpacityPointRemoved(double)), SLOT(removeScalarOpacityPoint(double)));
//    connect(m_editor, SIGNAL(gradientOpacityPointAdded(double,double)), SLOT(addGradientOpacityPoint(double,double)));
//    connect(m_editor, SIGNAL(gradientOpacityPointRemoved(double)), SLOT(removeGradientOpacityPoint(double)));
}
Example #14
0
void TransferFunctionEditor::mouseDoubleClickEvent(QMouseEvent *event)
{
  int idx = m_transfer_func->findByPosition(toTCP(event->pos()),
                                            scaleToTCP(POINT_SEARCH_RADIUS,
                                                       POINT_SEARCH_RADIUS));
  if (idx != TransferFunction::INVALID_TCP_INDEX)
  {
    setTCPColor(idx);
  }
  else
  {
    m_transfer_func->addTCP(toTCP(event->pos()));
  }

  update();
  emit transferFunctionChanged(m_transfer_func);

  return QWidget::mouseDoubleClickEvent(event);
}
void TransFuncEditorIntensityPet::updateFromProperty() {
    // check whether the volume associated with the TransFuncProperty has changed
    const VolumeHandleBase* newHandle = property_->getVolumeHandle();
    if (newHandle != volumeHandle_) {
        volumeHandle_ = newHandle;
        volumeChanged();
    }

    if (transferFuncGradient_) {
        transferFuncGradient_->resize(maximumIntensity_ + 1);

        bool emitRepaint = false;
        // adjust tf when not all keys have maximum alpha
        if (!transferFunctionCorrect()) {
            LINFO("The transfer function contains keys that don't have maximum alpha. "
                   << "The alpha value of these keys is set to 255.");
            rectifyTransferFunction();

            emitRepaint = true;
        }

        // update threshold control elements when necessary
        if (transferFuncIntensity_->getThresholds() != tgt::vec2(0.f, 1.f)) {
            restoreThresholds();
            emitRepaint = true;
        }

        if (emitRepaint) {
            property_->notifyChange();
            emit transferFunctionChanged();
        }

        // repaint control elements
        repaintAll();
    }
    else
        resetEditor();
}
Example #16
0
void TransferFunctionEditor::setTransferFunction(TransferFunction *func)
{
  m_transfer_func = func;
  update();
  emit transferFunctionChanged(m_transfer_func);
}
Example #17
0
void TransferFunctionEditor::contextMenuEvent(QContextMenuEvent *event)
{
#if 0
  // Nastavenie povolenych a zakazanych akcii podla toho kde sa kliklo
  int idx = m_transfer_func->findByPosition(toTCP(event->pos()),
                                            scaleToTCP(POINT_SEARCH_RADIUS,
                                                       POINT_SEARCH_RADIUS));
  if (idx == TransferFunction::INVALID_TCP_INDEX)
  {
    m_act_insert_tcp->setEnabled(true);
    m_act_remove_tcp->setEnabled(false);
    m_act_change_col->setEnabled(false);
    m_act_enable_tcp->setEnabled(false);
  }
  else
  {
    m_act_insert_tcp->setEnabled(false);
    m_act_remove_tcp->setEnabled(!m_transfer_func->isBorderPoint(idx));
    m_act_change_col->setEnabled(true);
  }

  // Vytvorenie kontextoveho menu
  QMenu menu(this);

  menu.addAction(m_act_insert_tcp);
  menu.addAction(m_act_remove_tcp);
  menu.addAction(m_act_change_col);

  // spust menu a spracuj akcie
  QAction *act = menu.exec(event->globalPos());
  if (act == m_act_insert_tcp)
  {
    m_transfer_func->addTCP(toTCP(event->pos()));
    update();
    emit transferFunctionChanged(m_transfer_func);
  }
  else if (act == m_act_remove_tcp)
  {
    m_transfer_func->removeTCP(idx);
    update();
    emit transferFunctionChanged(m_transfer_func);
  }
  else if (act == m_act_change_col)
  {
    setTCPColor(idx);
    update();
    emit transferFunctionChanged(m_transfer_func);
  }
  else
  {
    qDebug() << "No action selected. Menu canceled.";
  }
#else
  QAction act_insert_tcp(tr("Add control point"), this);
  QAction act_remove_tcp(tr("Remove control point"), this);
  QAction act_change_col(tr("Change color"), this);
  QAction act_enable_tcp(tr("Disable"), this);
  bool enabled = true;

  // Nastavenie povolenych a zakazanych akcii podla toho kde sa kliklo
  int idx = m_transfer_func->findByPosition(toTCP(event->pos()),
                                            scaleToTCP(POINT_SEARCH_RADIUS,
                                                       POINT_SEARCH_RADIUS));
  if (idx == TransferFunction::INVALID_TCP_INDEX)
  {
    act_insert_tcp.setEnabled(true);
    act_remove_tcp.setEnabled(false);
    act_change_col.setEnabled(false);
    act_enable_tcp.setEnabled(false);
  }
  else
  {
    act_insert_tcp.setEnabled(false);
    act_remove_tcp.setEnabled(!m_transfer_func->isBorderPoint(idx));
    act_change_col.setEnabled(true);
    act_enable_tcp.setEnabled(true);
    enabled = m_transfer_func->tcp(idx).isEnabled();
    if (!enabled) act_enable_tcp.setText(tr("Enable"));
  }

  // Vytvorenie kontextoveho menu
  QMenu menu(this);

  menu.addAction(&act_insert_tcp);
  menu.addAction(&act_remove_tcp);
  menu.addAction(&act_change_col);
  menu.addAction(&act_enable_tcp);

  // spust menu a spracuj akcie
  QAction *act = menu.exec(event->globalPos());
  if (act == &act_insert_tcp)
  {
    m_transfer_func->addTCP(toTCP(event->pos()));
    update();
    emit transferFunctionChanged(m_transfer_func);
  }
  else if (act == &act_remove_tcp)
  {
    m_transfer_func->removeTCP(idx);
    update();
    emit transferFunctionChanged(m_transfer_func);
  }
  else if (act == &act_change_col)
  {
    setTCPColor(idx);
    update();
    emit transferFunctionChanged(m_transfer_func);
  }
  else if (act == &act_enable_tcp)
  {
    m_transfer_func->setTCPEnabled(idx, !enabled);
    update();
    emit transferFunctionChanged(m_transfer_func);
  }
  else
  {
    qDebug() << "No action selected. Menu canceled.";
  }
#endif
}
Example #18
0
void TransferFunctionEditor::modifiedTransferFunction() {
	if (renderer) transferFunction.commit(renderer);
  emit transferFunctionChanged();
}
void MyRendererTFEditor_TFE::updateTF( void )
{
	TFEMarkers tf_only_markers = m_tfe_markers;
	
	// for convinience, delete the isosurface marker
	for( int i = tf_only_markers.markers.size() - 1 ; i > 0 ; )
		if( tf_only_markers.markers.at( i ).b_iso )
			tf_only_markers.delMarker( i );
		else i--;
	
	// premultiply alpha
	for( int i = tf_only_markers.markers.size() - 1; i > 0; i-- )
	{
		QColor c_l = tf_only_markers.markers.at( i ).color_left;
		tf_only_markers.markers.at( i ).color_left.setRedF( c_l.redF() * c_l.alphaF() );
		tf_only_markers.markers.at( i ).color_left.setBlueF( c_l.blueF() * c_l.alphaF() );
		tf_only_markers.markers.at( i ).color_left.setGreenF( c_l.greenF() * c_l.alphaF() );

		QColor c_r = tf_only_markers.markers.at( i ).color_right;
		tf_only_markers.markers.at( i ).color_right.setRedF( c_r.redF() * c_r.alphaF() );
		tf_only_markers.markers.at( i ).color_right.setBlueF( c_r.blueF() * c_r.alphaF() );
		tf_only_markers.markers.at( i ).color_right.setGreenF( c_r.greenF() * c_r.alphaF() );
	}
/*
	// populate the entire transfer function with correctly interpolated colors
	unsigned char * tf = m_transfer_function;

	for( int i = 0 ; i < TF_SIZE ; i++ )
	{
		for( int j = 0; j < tf_only_markers.markers.size() - 1; j++ )
		{
			if( ( tf_only_markers.markers[j].x <= ( i + 0.5 ) / float(TF_SIZE) ) && 
				( i + 0.5 ) / float(TF_SIZE) <= tf_only_markers.markers[j + 1].x )
			{
				TFEMarker m[2] = { tf_only_markers.markers.at( j ), tf_only_markers.markers.at( j + 1 ) };
			
				float fraction = ( ( i + 0.5 ) / float(TF_SIZE) - m[0].x ) / ( m[1].x - m[0].x );

				*tf++ = ( unsigned char )( 255.f * ( m[0].color_right.redF() + fraction * ( m[1].color_left.redF() - m[0].color_right.redF() ) ) );
                *tf++ = ( unsigned char )( 255.f * ( m[0].color_right.greenF() + fraction * ( m[1].color_left.greenF() - m[0].color_right.greenF() ) ) );
                *tf++ = ( unsigned char )( 255.f * ( m[0].color_right.blueF() + fraction * ( m[1].color_left.blueF() - m[0].color_right.blueF() ) ) );
                *tf++ = ( unsigned char )( 255.f * ( m[0].color_right.alphaF() + fraction * ( m[1].color_left.alphaF() - m[0].color_right.alphaF() ) ) );
			}
		}
	}
*/

    // NOTE: This is Sonny's modified version, where the signal transmits a
    //       TransferFunction object with it
    TransferFunction tf;
    for ( int i = 0; i < tf_only_markers.markers.size(); ++i )
    {
        TFEMarker &m = tf_only_markers.markers[i];

        // note: alpha must be pre-multiplied for correct mipmap averaging
        qreal r, g, b, a;

        m.color_left.getRgbF(&r, &g, &b, &a);
        cml::vector4f cl(r, g, b, a);

        m.color_right.getRgbF(&r, &g, &b, &a);
        cml::vector4f cr(r, g, b, a);

        tf.insert(m.x, cl, cr);
    }

    emit transferFunctionChanged( tf );
}
Example #20
0
//----------------------------------------------------------------------------------------------
//      small functions
//----------------------------------------------------------------------------------------------
void TransFunc1DKeysEditor::causeVolumeRenderingRepaint() {
    // this informs the owner about change in transfer function texture
    property_->notifyChange();
    repaintAll();
    emit transferFunctionChanged();
}
void TransFuncEditorIntensityGradient::repaintSignal() {
    property_->notifyChange();

    emit transferFunctionChanged();
}
Example #22
0
void
SplineEditorWidget::updateTransferFunction()
{
  QImage lookupTable = m_splineEditor->colorMapImage();
  emit transferFunctionChanged(lookupTable);
}