Starting from 2021-07-01, all LRZ GitLab users will be required to explicitly accept the GitLab Terms of Service. Please see the detailed information at https://doku.lrz.de/display/PUBLIC/GitLab and make sure that your projects conform to the requirements.

Commit 270fd747 authored by Hossain Mahmud's avatar Hossain Mahmud
Browse files

phew! transfer function docking fixed. crashed once for some reason, couldn't...

phew! transfer function docking fixed. crashed once for some reason, couldn't recreate the condition
parent 22aa4562
......@@ -89,7 +89,13 @@ namespace campvis {
connect(_btnFitDomainToImage, SIGNAL(clicked(bool)), this, SLOT(onFitClicked(bool)));
connect(_cbAutoFitDomainToImage, SIGNAL(stateChanged(int)), this, SLOT(onAutoFitDomainToImageChanged(int)));
property->s_BeforeTFReplace.connect(this, &TransferFunctionPropertyWidget::onBeforeTFReplace);
property->s_AfterTFReplace.connect(this, &TransferFunctionPropertyWidget::onAfterTFReplace);
bool b = connect(this, SIGNAL(s_beforeTFReplace(AbstractTransferFunction*)), this, SLOT(execBeforeTFReplace(AbstractTransferFunction*)));
b = connect(this, SIGNAL(s_afterTFReplace(AbstractTransferFunction*)), this, SLOT(execAfterTFReplace(AbstractTransferFunction*)));
property->s_autoFitWindowToDataChanged.connect(this, &TransferFunctionPropertyWidget::onTransferFunctionAutoFitWindowToDataChanged);
wasVisible = false;
}
TransferFunctionPropertyWidget::~TransferFunctionPropertyWidget() {
......@@ -128,7 +134,7 @@ namespace campvis {
}
void TransferFunctionPropertyWidget::onEditClicked(bool checked) {
if (_editor == 0) {
if (_editor == nullptr) {
TransferFunctionProperty* prop = static_cast<TransferFunctionProperty*>(_property);
_editor = TransferFunctionEditorFactory::createEditor(prop);
......@@ -164,5 +170,47 @@ namespace campvis {
emit s_propertyChanged(_property);
}
void TransferFunctionPropertyWidget::execBeforeTFReplace(AbstractTransferFunction *tf ) {
if (!_dockWidget && !_editor)
return;
if (_dockWidget) {
wasVisible = _dockWidget->isVisible();
_dockWidget->setVisible(false);
}
if (_editor) {
delete _editor;
_editor = nullptr;
}
if (_dockWidget) {
//delete _dockWidget;
//_dockWidget = nullptr;
}
}
void TransferFunctionPropertyWidget::execAfterTFReplace(AbstractTransferFunction *tf ) {
if (!_dockWidget && !_editor)
return;
if (_editor == nullptr && _dockWidget != nullptr) {
TransferFunctionProperty* prop = static_cast<TransferFunctionProperty*>(_property);
_editor = TransferFunctionEditorFactory::createEditor(prop);
//_dockWidget = new QDockWidget("Transfer Function Editor");
_dockWidget->setWidget(_editor);
_dockWidget->setVisible(wasVisible);
//static_cast<CampVisApplication*>(qApp)->registerDockWidget(Qt::BottomDockWidgetArea, _dockWidget);
} else {
_dockWidget->setVisible(true);
}
}
void TransferFunctionPropertyWidget::onBeforeTFReplace( AbstractTransferFunction *tf ) {
emit s_beforeTFReplace(tf);
}
void TransferFunctionPropertyWidget::onAfterTFReplace( AbstractTransferFunction *tf ) {
emit s_afterTFReplace(tf);
}
}
\ No newline at end of file
......@@ -71,6 +71,11 @@ namespace campvis {
*/
void onTransferFunctionAutoFitWindowToDataChanged();
signals:
void s_beforeTFReplace(AbstractTransferFunction* tf);
void s_afterTFReplace(AbstractTransferFunction* tf);
private slots:
/// slot called when one of the intensity domain spin edits has changed
void onDomainChanged(double value);
......@@ -81,6 +86,18 @@ namespace campvis {
/// slot called when _cbAutoFitDomainToImage changed
void onAutoFitDomainToImageChanged(int state);
protected slots:
/// slot called when transfer function is about to be replaced
void execBeforeTFReplace(AbstractTransferFunction *tf);
/// slot called when transfer function just has replaced
void execAfterTFReplace(AbstractTransferFunction *tf);
private:
/// catch slot for tf replace action
void onBeforeTFReplace(AbstractTransferFunction *tf);
/// catch slot for tf replace action
void onAfterTFReplace(AbstractTransferFunction *tf);
private:
QWidget* _widget; ///< Widget grouping the widgets together
QGridLayout* _gridLayout; ///< Layout for _widget
......@@ -94,6 +111,8 @@ namespace campvis {
QDockWidget* _dockWidget; ///< DockWidget for transfer function editor
AbstractTransferFunctionEditor* _editor; ///< Transfer function editor
bool wasVisible; ///< remembers whether _docWidget was visible or not
};
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment