Commit 85fdf2d4 authored by Timothee Chabat's avatar Timothee Chabat
Browse files

MaterialEditor: add warnings when in CS mode

parent a3ca0f10
......@@ -60,7 +60,11 @@ public:
/**
* do nothing, everything is handled in createEditor method
*/
void setEditorData(QWidget*, const QModelIndex&) const override{};
void setEditorData(QWidget* editor, const QModelIndex& index) const override
{
Q_UNUSED(editor);
Q_UNUSED(index);
};
/**
* Gets data from the editor widget and stores it in the specified model at the item index
......
......@@ -247,8 +247,10 @@ QVariant pqMaterialProxyModel::headerData(int section, Qt::Orientation orientati
}
//-----------------------------------------------------------------------------
int pqMaterialProxyModel::rowCount(const QModelIndex&) const
int pqMaterialProxyModel::rowCount(const QModelIndex& index) const
{
Q_UNUSED(index);
if (!this->MaterialLibrary)
{
return 0;
......@@ -501,6 +503,7 @@ pqMaterialEditor::pqMaterialEditor(QWidget* parentObject)
this->Internals->Ui.SelectMaterial->clear();
this->Internals->MaterialLibrary = nullptr;
bool enable = false;
this->HasWarnedUser = false;
if (server && !server->isRemote())
{
vtkSMProxy* proxy =
......@@ -523,6 +526,12 @@ pqMaterialEditor::pqMaterialEditor(QWidget* parentObject)
}
}
}
if (server && server->isRemote() && this->isVisible())
{
vtkGenericWarningMacro(
"Material Editor disabled because client is connected to a remote server.");
this->HasWarnedUser = true;
}
// Grey out the material editor if CS mode or if we didn't find the ML object
this->Internals->Ui.AddMaterial->setEnabled(enable);
this->Internals->Ui.RemoveMaterial->setEnabled(enable);
......@@ -756,8 +765,11 @@ void pqMaterialEditor::removeAllProperties()
}
//-----------------------------------------------------------------------------
void pqMaterialEditor::propertyChanged(const QModelIndex&, const QModelIndex&)
void pqMaterialEditor::propertyChanged(const QModelIndex& topLeft, const QModelIndex& botRight)
{
Q_UNUSED(topLeft);
Q_UNUSED(botRight);
// update material and render
QString matName = this->currentMaterialName();
......@@ -848,3 +860,16 @@ void pqMaterialEditor::updateCurrentMaterial(const std::string& label)
this->Internals->AttributesModel.setMaterial(ml, label);
this->propertyChanged(QModelIndex(), QModelIndex());
}
//-----------------------------------------------------------------------------
void pqMaterialEditor::showEvent(QShowEvent* event)
{
if (!this->HasWarnedUser && !this->Internals->MaterialLibrary)
{
vtkGenericWarningMacro(
"Material Editor disabled because client is connected to a remote server.");
this->HasWarnedUser = true;
}
this->Superclass::showEvent(event);
}
......@@ -36,7 +36,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QWidget>
#include <string>
#include <string> // for std::string
class vtkOSPRayMaterialLibrary;
class vtkSMProxy;
......@@ -48,7 +48,7 @@ class vtkSMProxy;
* Then, you can customize this material by adding or removing properties, such as the color,
* the roughness, the textures... depending on the available properties that you can see
* in vtkOSPRayMaterialLibrary.
*
* Texture format supported are *.png, *.jpg, *.bmp and *.ppm.
*/
class PQAPPLICATIONCOMPONENTS_EXPORT pqMaterialEditor : public QWidget
{
......@@ -109,11 +109,18 @@ protected:
*/
std::string generateValidMaterialName(const std::string& name);
/**
* Overriden to warn user when material editor is not usable.
*/
void showEvent(QShowEvent* event) override;
private:
Q_DISABLE_COPY(pqMaterialEditor)
class pqInternals;
pqInternals* Internals;
friend class pqInternals;
bool HasWarnedUser = true;
};
#endif
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