Commit 71e69d8a authored by Mathieu Westphal's avatar Mathieu Westphal

Improvement to PointGaussianRepresentation

Better default configuration now managed by the domain
Multiple corrections to the widget/dialog duality
Added a "Reset to domain" button
Updated tests
Fix #18561
parent c59a1f2f
......@@ -27,9 +27,11 @@
<pqcheck object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/DisplayFrame/ProxyPanel/OpacityArray/ComboBox" property="currentText" arguments="thickness9" />
<pqcompareview object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport" baseline="$PARAVIEW_DATA_ROOT/Baseline/PointGaussianScaleOpacityArrayA.png" threshold="5" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/DisplayFrame/ProxyPanel/ScaleTransferFunction/1QPushButton0" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/ScaleTransferFunction/groupBox/resetButton/QAction0" command="activate" arguments="" />
<pqcheck object="pqClientMainWindow/ScaleTransferFunction/groupBox/minX" property="text" arguments="-2.02298" />
<pqcheck object="pqClientMainWindow/ScaleTransferFunction/groupBox/maxX" property="text" arguments="5.05441" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/DisplayFrame/ProxyPanel/ScaleArrayComponent/ComboBox" command="activated" arguments="X" />
<pqevent object="pqClientMainWindow/ScaleTransferFunction/groupBox/resetButton/QAction0" command="activate" arguments="" />
<pqcheck object="pqClientMainWindow/ScaleTransferFunction/groupBox/minX" property="text" arguments="0" />
<pqcheck object="pqClientMainWindow/ScaleTransferFunction/groupBox/maxX" property="text" arguments="5.10369" />
<pqevent object="pqClientMainWindow/ScaleTransferFunction/TransferFunctionEditor/1QVTKWidget0" command="mousePress" arguments="(0.15,0.54065,1,1,0)" />
......@@ -40,6 +42,7 @@
<pqevent object="pqClientMainWindow/ScaleTransferFunction/TransferFunctionEditor/1QVTKWidget0" command="mouseRelease" arguments="(0.789474,0.626016,1,0,0)" />
<pqevent object="pqClientMainWindow/ScaleTransferFunction/ButtonBox/1QPushButton0" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/DisplayFrame/ProxyPanel/OpacityTransferFunction/1QPushButton0" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/OpacityTransferFunction/groupBox/resetButton/QAction0" command="activate" arguments="" />
<pqcheck object="pqClientMainWindow/OpacityTransferFunction/groupBox/minX" property="text" arguments="0.126328" />
<pqcheck object="pqClientMainWindow/OpacityTransferFunction/groupBox/maxX" property="text" arguments="1.14768" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/DisplayFrame/ProxyPanel/OpacityArray/ComboBox" command="activated" arguments="thickness7" />
......@@ -49,6 +52,7 @@
<pqevent object="pqClientMainWindow/OpacityTransferFunction/TransferFunctionEditor/1QVTKWidget0" command="mousePress" arguments="(0.45,0.353659,1,1,0)" />
<pqevent object="pqClientMainWindow/OpacityTransferFunction/TransferFunctionEditor/1QVTKWidget0" command="mouseMove" arguments="(0.45,0.353659,1,0,0)" />
<pqevent object="pqClientMainWindow/OpacityTransferFunction/TransferFunctionEditor/1QVTKWidget0" command="mouseRelease" arguments="(0.45,0.353659,1,0,0)" />
<pqevent object="pqClientMainWindow/OpacityTransferFunction/groupBox/resetButton/QAction0" command="activate" arguments="" />
<pqcheck object="pqClientMainWindow/OpacityTransferFunction/groupBox/minX" property="text" arguments="0.340609" />
<pqcheck object="pqClientMainWindow/OpacityTransferFunction/groupBox/maxX" property="text" arguments="0.907029" />
<pqevent object="pqClientMainWindow/OpacityTransferFunction/ButtonBox/1QPushButton0" command="activate" arguments="" />
......
......@@ -104,7 +104,6 @@ set (Module_SRCS
vtkSMProxyProperty.cxx
vtkSMProxySelectionModel.cxx
vtkSMRangeDomainTemplate.txx
vtkSMRangedTransferFunctionDomain.cxx
vtkSMReaderFactory.cxx
vtkSMRemoteObject.cxx
vtkSMRemoteObjectUpdateUndoElement.cxx
......
......@@ -56,6 +56,7 @@ set (Module_SRCS
vtkSMPlotMatrixViewProxy.cxx
vtkSMPVRepresentationProxy.cxx
vtkSMRenderViewProxy.cxx
vtkSMRangedTransferFunctionDomain.cxx
vtkSMRepresentationProxy.cxx
vtkSMRepresentationTypeDomain.cxx
vtkSMRepresentedArrayListDomain.cxx
......
......@@ -18,6 +18,8 @@
#include "vtkNew.h"
#include "vtkObjectFactory.h"
#include "vtkSMArrayRangeDomain.h"
#include "vtkSMProxyProperty.h"
#include "vtkSMTransferFunctionProxy.h"
class vtkSMRangedTransferFunctionDomainInternals
{
......@@ -132,3 +134,50 @@ void vtkSMRangedTransferFunctionDomain::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
//-----------------------------------------------------------------------------
int vtkSMRangedTransferFunctionDomain::SetDefaultValues(
vtkSMProperty* prop, bool use_unchecked_values)
{
vtkSMProxyProperty* proxyProp = vtkSMProxyProperty::SafeDownCast(prop);
vtkSMTransferFunctionProxy* transferFunctionProxy = nullptr;
if (proxyProp)
{
if (use_unchecked_values)
{
if (proxyProp->GetNumberOfUncheckedProxies() > 0)
{
transferFunctionProxy =
vtkSMTransferFunctionProxy::SafeDownCast(proxyProp->GetUncheckedProxy(0));
}
}
else
{
if (proxyProp->GetNumberOfProxies() > 0)
{
transferFunctionProxy = vtkSMTransferFunctionProxy::SafeDownCast(proxyProp->GetProxy(0));
}
}
}
if (transferFunctionProxy)
{
double rangeMin = 0.0;
double rangeMax = 1.0;
if (this->GetRangeMinimumExists(0) && this->GetRangeMaximumExists(0))
{
rangeMin = this->GetRangeMinimum(0);
rangeMax = this->GetRangeMaximum(0);
}
else if (this->GetRangeMinimumExists(0))
{
rangeMin = rangeMax = this->GetRangeMinimum(0);
}
else if (this->GetRangeMaximumExists(0))
{
rangeMin = rangeMax = this->GetRangeMaximum(0);
}
transferFunctionProxy->RescaleTransferFunction(rangeMin, rangeMax, false);
}
return this->Superclass::SetDefaultValues(prop, use_unchecked_values);
}
......@@ -36,13 +36,14 @@
#ifndef vtkSMRangedTransferFunctionDomain_h
#define vtkSMRangedTransferFunctionDomain_h
#include "vtkClientServerID.h" // needed for saving animation in batch script
#include "vtkPVServerManagerCoreModule.h" //needed for exports
#include "vtkClientServerID.h" // needed for saving animation in batch script
#include "vtkPVServerManagerRenderingModule.h" //needed for exports
#include "vtkSMProxyListDomain.h"
class vtkSMRangedTransferFunctionDomainInternals;
class VTKPVSERVERMANAGERCORE_EXPORT vtkSMRangedTransferFunctionDomain : public vtkSMProxyListDomain
class VTKPVSERVERMANAGERRENDERING_EXPORT vtkSMRangedTransferFunctionDomain
: public vtkSMProxyListDomain
{
public:
static vtkSMRangedTransferFunctionDomain* New();
......@@ -71,6 +72,7 @@ public:
bool GetRangeMaximumExists(unsigned int idx);
//@}
//@{
/**
* Returns the range minimum/maximum value, is exists, otherwise
* 0 is returned. Use GetMaximumExists() GetMaximumExists() to make sure that
......@@ -86,6 +88,13 @@ public:
int not_used;
return this->GetRangeMaximum(idx, not_used);
}
//@}
/**
* If prop is a vtkSMProxyProperty containing a vtkSMTransferFunctionProxy
* this set its range based on this domain min and max values.
*/
int SetDefaultValues(vtkSMProperty* prop, bool use_unchecked_values) override;
protected:
vtkSMRangedTransferFunctionDomain();
......
......@@ -56,6 +56,9 @@
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="pqHighlightableToolButton" name="resetButton"/>
</item>
</layout>
</widget>
</item>
......@@ -72,6 +75,11 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>pqHighlightableToolButton</class>
<extends>QToolButton</extends>
<header>pqHighlightableToolButton.h</header>
</customwidget>
<customwidget>
<class>pqTransferFunctionWidget</class>
<extends>QWidget</extends>
......
......@@ -34,9 +34,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqTransferFunctionWidgetPropertyWidget.h"
#include "vtkPiecewiseFunction.h"
#include <QString>
#include <QAction>
#include <QDoubleValidator>
#include <QString>
#include <QStyle>
class pqTransferFunctionWidgetPropertyDialog::pqInternals
{
......@@ -47,7 +49,7 @@ public:
};
pqTransferFunctionWidgetPropertyDialog::pqTransferFunctionWidgetPropertyDialog(const QString& label,
double* xrange, vtkPiecewiseFunction* transferFunction, QWidget* propertyWdg, QWidget* parentWdg)
vtkPiecewiseFunction* transferFunction, QWidget* propertyWdg, QWidget* parentWdg)
: QDialog(parentWdg)
, TransferFunction(transferFunction)
, PropertyWidget(propertyWdg)
......@@ -62,32 +64,45 @@ pqTransferFunctionWidgetPropertyDialog::pqTransferFunctionWidgetPropertyDialog(c
QDoubleValidator* validator = new QDoubleValidator(this);
this->Internals->Ui.minX->setValidator(validator);
this->Internals->Ui.maxX->setValidator(validator);
this->Internals->Ui.minX->setText(QString::number(xrange[0]));
this->Internals->Ui.maxX->setText(QString::number(xrange[1]));
this->updateRange();
QObject::connect(this->Internals->Ui.minX, SIGNAL(textChangedAndEditingFinished()), this,
SLOT(onRangeChanged()));
QObject::connect(this->Internals->Ui.maxX, SIGNAL(textChangedAndEditingFinished()), this,
SLOT(onRangeChanged()));
QObject::connect(
this->Internals->Ui.minX, SIGNAL(textChangedAndEditingFinished()), this, SLOT(onRangeEdited()));
QObject::connect(
this->Internals->Ui.maxX, SIGNAL(textChangedAndEditingFinished()), this, SLOT(onRangeEdited()));
QObject::connect(this->Internals->Ui.TransferFunctionEditor, SIGNAL(controlPointsModified()),
this->PropertyWidget, SLOT(propagateProxyPointsProperty()));
QObject::connect(this->PropertyWidget, SIGNAL(domainChanged()), this, SLOT(onDomainChanged()));
QAction* resetActn = new QAction(this->Internals->Ui.resetButton);
resetActn->setToolTip("Reset using current data values");
resetActn->setIcon(
this->Internals->Ui.resetButton->style()->standardIcon(QStyle::SP_BrowserReload));
this->Internals->Ui.resetButton->addAction(resetActn);
this->Internals->Ui.resetButton->setDefaultAction(resetActn);
QObject::connect(this->PropertyWidget, SIGNAL(domainChanged()), this->Internals->Ui.resetButton,
SLOT(highlight()));
QObject::connect(this->Internals->Ui.resetButton, SIGNAL(clicked()),
this->Internals->Ui.resetButton, SLOT(clear()));
QObject::connect(
resetActn, SIGNAL(triggered(bool)), this->PropertyWidget, SLOT(resetRangeToDomainDefault()));
QObject::connect(resetActn, SIGNAL(triggered(bool)), this, SLOT(updateRange()));
}
pqTransferFunctionWidgetPropertyDialog::~pqTransferFunctionWidgetPropertyDialog()
{
}
void pqTransferFunctionWidgetPropertyDialog::onDomainChanged()
void pqTransferFunctionWidgetPropertyDialog::updateRange()
{
pqTransferFunctionWidgetPropertyWidget* propertyWdg =
qobject_cast<pqTransferFunctionWidgetPropertyWidget*>(this->PropertyWidget);
const double* range = propertyWdg->getRange();
double range[2];
propertyWdg->getRange(range);
this->Internals->Ui.minX->setText(QString::number(range[0]));
this->Internals->Ui.maxX->setText(QString::number(range[1]));
}
void pqTransferFunctionWidgetPropertyDialog::onRangeChanged()
void pqTransferFunctionWidgetPropertyDialog::onRangeEdited()
{
pqTransferFunctionWidgetPropertyWidget* propertyWdg =
qobject_cast<pqTransferFunctionWidgetPropertyWidget*>(this->PropertyWidget);
......
......@@ -44,13 +44,13 @@ class PQAPPLICATIONCOMPONENTS_EXPORT pqTransferFunctionWidgetPropertyDialog : pu
Q_OBJECT
public:
pqTransferFunctionWidgetPropertyDialog(const QString& label, double* xrange,
pqTransferFunctionWidgetPropertyDialog(const QString& label,
vtkPiecewiseFunction* transferFunction, QWidget* propertyWdg, QWidget* parentWdg = NULL);
~pqTransferFunctionWidgetPropertyDialog();
protected slots:
void onRangeChanged();
void onDomainChanged();
void onRangeEdited();
void updateRange();
private:
vtkSmartPointer<vtkPiecewiseFunction> TransferFunction;
......
......@@ -79,8 +79,6 @@ pqTransferFunctionWidgetPropertyWidget::pqTransferFunctionWidgetPropertyWidget(
return;
}
this->TFProxy = vtkSMTransferFunctionProxy::SafeDownCast(pxy);
this->Range[0] = 0.0;
this->Range[1] = 1.0;
this->Connection = vtkEventQtSlotConnect::New();
this->Domain =
......@@ -88,9 +86,8 @@ pqTransferFunctionWidgetPropertyWidget::pqTransferFunctionWidgetPropertyWidget(
if (this->Domain)
{
this->Connection->Connect(
this->Domain, vtkCommand::DomainModifiedEvent, this, SLOT(onDomainChanged()));
this->Domain, vtkCommand::DomainModifiedEvent, this, SIGNAL(domainChanged()));
}
this->onDomainChanged();
QVBoxLayout* l = new QVBoxLayout;
l->setMargin(0);
......@@ -111,36 +108,26 @@ pqTransferFunctionWidgetPropertyWidget::~pqTransferFunctionWidgetPropertyWidget(
{
this->Connection->Delete();
}
delete this->Dialog;
}
void pqTransferFunctionWidgetPropertyWidget::onDomainChanged()
void pqTransferFunctionWidgetPropertyWidget::resetRangeToDomainDefault()
{
this->Range[0] = 0.0;
this->Range[1] = 1.0;
if (this->Domain)
{
if (this->Domain->GetRangeMinimumExists(0) && this->Domain->GetRangeMaximumExists(0))
{
this->Range[0] = this->Domain->GetRangeMinimum(0);
this->Range[1] = this->Domain->GetRangeMaximum(0);
}
else if (this->Domain->GetRangeMinimumExists(0))
{
this->Range[0] = this->Range[1] = this->Domain->GetRangeMinimum(0);
}
else if (this->Domain->GetRangeMaximumExists(0))
{
this->Range[0] = this->Range[1] = this->Domain->GetRangeMaximum(0);
}
}
emit this->domainChanged();
this->property()->ResetToDomainDefaults();
emit this->changeAvailable();
emit this->changeFinished();
}
void pqTransferFunctionWidgetPropertyWidget::getRange(double range[2])
{
this->TFProxy->GetRange(range);
}
void pqTransferFunctionWidgetPropertyWidget::setRange(const double& min, const double& max)
{
this->Range[0] = min;
this->Range[1] = max;
this->updateRange();
this->TFProxy->RescaleTransferFunction(min, max, false);
emit this->changeAvailable();
emit this->changeFinished();
}
void pqTransferFunctionWidgetPropertyWidget::propagateProxyPointsProperty()
......@@ -165,19 +152,6 @@ void pqTransferFunctionWidgetPropertyWidget::propagateProxyPointsProperty()
emit this->changeFinished();
}
void pqTransferFunctionWidgetPropertyWidget::updateRange()
{
this->TFProxy->RescaleTransferFunction(this->Range[0], this->Range[1], false);
emit this->changeAvailable();
emit this->changeFinished();
}
void pqTransferFunctionWidgetPropertyWidget::UpdateProperty()
{
this->propagateProxyPointsProperty();
this->updateRange();
}
void pqTransferFunctionWidgetPropertyWidget::buttonClicked()
{
delete this->Dialog;
......@@ -185,9 +159,8 @@ void pqTransferFunctionWidgetPropertyWidget::buttonClicked()
vtkObjectBase* object = this->TFProxy->GetClientSideObject();
vtkPiecewiseFunction* transferFunction = vtkPiecewiseFunction::SafeDownCast(object);
this->Dialog = new pqTransferFunctionWidgetPropertyDialog(this->property()->GetXMLLabel(),
&this->Range[0], transferFunction, this, pqCoreUtilities::mainWidget());
this->Dialog = new pqTransferFunctionWidgetPropertyDialog(
this->property()->GetXMLLabel(), transferFunction, this, pqCoreUtilities::mainWidget());
this->Dialog->setObjectName(this->property()->GetXMLName());
this->Dialog->show();
this->UpdateProperty();
}
......@@ -38,6 +38,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
class vtkSMTransferFunctionProxy;
class vtkEventQtSlotConnect;
class vtkSMRangedTransferFunctionDomain;
class pqTransferFunctionWidgetPropertyDialog;
/**
* A property widget for editing a transfer function.
......@@ -55,8 +56,7 @@ public:
vtkSMProxy* proxy, vtkSMProperty* property, QWidget* parent = 0);
~pqTransferFunctionWidgetPropertyWidget() override;
const double* getRange() { return this->Range; };
void setRange(const double& min, const double& max);
friend pqTransferFunctionWidgetPropertyDialog;
signals:
void domainChanged();
......@@ -64,18 +64,19 @@ signals:
protected:
void UpdateProperty();
void getRange(double range[2]);
void setRange(const double& min, const double& max);
protected slots:
void buttonClicked();
void updateRange();
void propagateProxyPointsProperty();
void onDomainChanged();
void resetRangeToDomainDefault();
private:
vtkEventQtSlotConnect* Connection;
vtkSMTransferFunctionProxy* TFProxy;
QDialog* Dialog;
vtkSMRangedTransferFunctionDomain* Domain;
double Range[2];
};
#endif // _pqTransferFunctionWidgetPropertyWidget_h
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