Commit d1f7f44f authored by David Thompson's avatar David Thompson

Make default-value and invalid-value colors user preferences.

parent a2eadc9f
......@@ -118,11 +118,13 @@ Qt requires that all methods that affect the GUI be performed on the application
To support this pattern, SMTK's Observer pattern has been generalized to a single description (smtk::common::Observers) that adopts a run-time configurable type of polymorphism where consuming code can change the class's behavior, allowing consuming code to redefine the context in which the Observer functors are executed.
##Changes to Views and QT Extensions
###New View Type - Associations
## Changes to the View System and Qt Extensions
### New View Type - Associations
This view has the same syntax as an Attribute View but only allows the user to change the association information of the attribute resulting in taking up less screen Real Estate
###New View Type - Analysis
### New View Type - Analysis
An Analysis View is a specialized view for choosing the types of analyses the user wants to perform. These choices are persistent and can be used by an export operation instead of having the operator ask the user what types of analyses should be performed.
Unlike other views the Analysis View will construct both an Attribute Definition and corresponding Attribute when needed. The Attribute Definition is based on the Analysis Information stored in the Attribute Resource. Any Analysis that is referred to by another will be represented as a Group Item. All other Analyses will be represented as a Void Item.
......@@ -141,9 +143,13 @@ The following is an example of a Analysis View:
* AnalysisAttributeName is the name of the Attribute the view will create to represent the Analysis (if needed)
### Changes to BaseView
* Added the concept of top level categories that represents a set of categories (that can be a subset of those defined in the attribute resource) that can be used to display or filter attribute information.
* The `<DefaultColor>` and `<InvalidColor>` configuration tags are no longer supported by qtBaseView.
They have been turned into user preferences rather than XML/JSON view parameters.
###Changes to Attribute View
* added a new XML attribute "HideAssociations". If set to true the view will not display the association editing widget save screen Real Estate
* If there is only one type of attribute being created/modified then the type column is no longer displayed
* For the time being the view by property feature has been disabled until we can decide on whether it is useful and if so, what is the best way to display the information.
......@@ -151,15 +157,25 @@ The following is an example of a Analysis View:
* Attempting to rename an attribute to a name already is use now generates a warning dialog.
###Changes to Group View
* View no longer displays empty tabs
* Current tabs are now remembered when the group rebuilds its widget - previously this was only true for the top-level tabbed group views
###Changes to UIManager
* Added the ability to enable/disable category filtering
* Added support for top-level categories
* Colors to indicate default and invalid values are now Qt properties
to support ParaView's user preference framework.
* The UI manager now emits a `highlightOnHoverChanged(bool)` signal
when the user preference changes.
The pqSMTKAttributePanel delivers these changes to the UI manager it maintains;
other users of qtUIManager are expected to do the same.
### Item Changes
#### ReadOnly View Items
###Item Changes
####ReadOnly View Items
Added a new ReadOnly Option to Item Views. In the following example the item, absolute-zero, in the attribute physical-constants has been made read only. The current implementation disables the widgets defined by the read only item from being modified but will still display them.
```xml
......
......@@ -78,6 +78,7 @@ pqSMTKAttributePanel::~pqSMTKAttributePanel()
}
}
m_propertyLinks.clear();
delete m_attrUIMgr;
}
......@@ -128,6 +129,7 @@ bool pqSMTKAttributePanel::displayResource(smtk::attribute::ResourcePtr rsrc)
m_rsrc = rsrc;
if (m_attrUIMgr)
{
m_propertyLinks.clear();
delete m_attrUIMgr;
while (QWidget* w = this->widget()->findChild<QWidget*>())
{
......@@ -144,6 +146,36 @@ bool pqSMTKAttributePanel::displayResource(smtk::attribute::ResourcePtr rsrc)
auto hoverBit = m_seln->findOrCreateLabeledValue("hovered");
m_attrUIMgr->setHoverBit(hoverBit);
// Start watching the resource's associate PV server for user preference changes.
pqServer* server = pqActiveObjects::instance().activeServer();
vtkSMSessionProxyManager* pxm = server ? server->proxyManager() : nullptr;
auto paletteProxy = pxm
? vtkSMGlobalPropertiesProxy::SafeDownCast(pxm->GetProxy("global_properties", "ColorPalette"))
: nullptr;
auto defaultValueColorProp =
paletteProxy ? paletteProxy->GetProperty("SMTKDefaultValueBackground") : nullptr;
auto invalidValueColorProp =
paletteProxy ? paletteProxy->GetProperty("SMTKInvalidValueBackground") : nullptr;
if (defaultValueColorProp && invalidValueColorProp)
{
vtkVector3d dc;
vtkSMPropertyHelper(defaultValueColorProp).Get(dc.GetData(), 3);
QVariantList vdc;
vdc << dc[0] << dc[1] << dc[2];
m_attrUIMgr->setDefaultValueColorRgbF(vdc);
vtkVector3d ic;
vtkSMPropertyHelper(invalidValueColorProp).Get(ic.GetData(), 3);
QVariantList vic;
vic << ic[0] << ic[1] << ic[2];
m_attrUIMgr->setInvalidValueColorRgbF(vic);
m_propertyLinks.addPropertyLink(m_attrUIMgr, "defaultValueColorRgbF",
SIGNAL(defaultValueColorChanged()), paletteProxy, defaultValueColorProp);
m_propertyLinks.addPropertyLink(m_attrUIMgr, "invalidValueColorRgbF",
SIGNAL(invalidValueColorChanged()), paletteProxy, invalidValueColorProp);
}
// Fetch the current user preferences and update the UI manager with them.
this->updateSettings();
......
......@@ -14,6 +14,8 @@
#include "smtk/PublicPointerDefs.h"
#include "pqPropertyLinks.h"
#include <QDockWidget>
class pqServer;
......@@ -95,4 +97,5 @@ protected:
smtk::view::SelectionPtr m_seln;
smtk::operation::ManagerPtr m_opManager;
smtk::resource::Observers::Key m_observer;
pqPropertyLinks m_propertyLinks;
};
......@@ -1952,12 +1952,44 @@
</Hints>
</DoubleVectorProperty>
<DoubleVectorProperty
default_values="1.0 1.0 0.5"
label="Background color for items with default values"
name="SMTKDefaultValueBackground"
number_of_elements="3"
panel_widget="color_selector">
<DoubleRangeDomain max="1 1 1"
min="0 0 0"
name="range" />
<Documentation>Color for attribute items holding default values.</Documentation>
<Hints>
<SaveInQSettings both="1"/>
</Hints>
</DoubleVectorProperty>
<DoubleVectorProperty
default_values="1.0 0.5 0.5"
label="Background color for items with invalid values"
name="SMTKInvalidValueBackground"
number_of_elements="3"
panel_widget="color_selector">
<DoubleRangeDomain max="1 1 1"
min="0 0 0"
name="range" />
<Documentation>Color for attribute items holding invalid values.</Documentation>
<Hints>
<SaveInQSettings both="1"/>
</Hints>
</DoubleVectorProperty>
<PropertyGroup label="SMTK Colors">
<Documentation>
Colors used when displaying SMTK model and mesh components.
</Documentation>
<Property name="DefaultFaceColor"/>
<Property name="SMTKHighlightColor"/>
<Property name="SMTKDefaultValueBackground"/>
<Property name="SMTKInvalidValueBackground"/>
</PropertyGroup>
</Extension>
......
......@@ -257,28 +257,6 @@ void qtBaseView::makeTopLevel()
m_topLevelInitialized = true;
int pos;
std::vector<double> vals;
pos = view->details().findChild("DefaultColor");
QColor color;
if (pos != -1)
{
view->details().child(pos).contentsAsVector(vals);
if (vals.size() == 3)
{
color.setRgbF(vals[0], vals[1], vals[2]);
this->uiManager()->setDefaultValueColor(color);
}
}
pos = view->details().findChild("InvalidColor");
if (pos != -1)
{
view->details().child(pos).contentsAsVector(vals);
if (vals.size() == 3)
{
color.setRgbF(vals[0], vals[1], vals[2]);
this->uiManager()->setInvalidValueColor(color);
}
}
pos = view->details().findChild("AdvancedFontEffects");
if (pos != -1)
......
......@@ -570,12 +570,88 @@ bool qtUIManager::advanceFontStyleItalic() const
void qtUIManager::setDefaultValueColor(const QColor& color)
{
if (color == this->DefaultValueColor)
{
return;
}
this->DefaultValueColor = color;
if (m_topView)
{
m_topView->onShowCategory();
}
}
QVariantList qtUIManager::defaultValueColorRgbF() const
{
QVariantList val;
val << this->DefaultValueColor.redF() << this->DefaultValueColor.greenF()
<< this->DefaultValueColor.blueF()
// << this->DefaultValueColor.alphaF()
;
return val;
}
void qtUIManager::setDefaultValueColorRgbF(const QVariantList& color)
{
if (color.size() != 3)
{
smtkErrorMacro(smtk::io::Logger::instance(), "Bad color specification.");
return;
}
auto replacement =
QColor::fromRgbF(color[0].toDouble(), color[1].toDouble(), color[2].toDouble());
if (replacement == this->DefaultValueColor)
{
return;
}
this->DefaultValueColor = replacement;
if (m_topView)
{
m_topView->onShowCategory();
}
}
void qtUIManager::setInvalidValueColor(const QColor& color)
{
if (color == this->InvalidValueColor)
{
return;
}
this->InvalidValueColor = color;
if (m_topView)
{
m_topView->onShowCategory();
}
}
QVariantList qtUIManager::invalidValueColorRgbF() const
{
QVariantList val;
val << this->InvalidValueColor.redF() << this->InvalidValueColor.greenF()
<< this->InvalidValueColor.blueF()
// << this->InvalidValueColor.alphaF()
;
return val;
}
void qtUIManager::setInvalidValueColorRgbF(const QVariantList& color)
{
if (color.size() != 3)
{
smtkErrorMacro(smtk::io::Logger::instance(), "Bad color specification.");
return;
}
auto replacement =
QColor::fromRgbF(color[0].toDouble(), color[1].toDouble(), color[2].toDouble());
if (replacement == this->InvalidValueColor)
{
return;
}
this->InvalidValueColor = replacement;
if (m_topView)
{
m_topView->onShowCategory();
}
}
void qtUIManager::setWidgetColorToInvalid(QWidget* widget)
......
......@@ -19,6 +19,7 @@
#include <QMap>
#include <QPointer>
#include <QTextEdit>
#include <QVariant>
#include <map>
class QTableWidget;
......@@ -46,9 +47,16 @@ typedef qtItem* (*qtItemConstructor)(const AttributeItemInfo& info);
*/
class SMTKQTEXT_EXPORT qtUIManager : public QObject
{
Q_OBJECT
Q_PROPERTY(QColor defaultValueColor READ defaultValueColor WRITE setDefaultValueColor);
Q_PROPERTY(
QVariantList defaultValueColorRgbF READ defaultValueColorRgbF WRITE setDefaultValueColorRgbF);
Q_PROPERTY(QColor invalidValueColor READ invalidValueColor WRITE setInvalidValueColor);
Q_PROPERTY(
QVariantList invalidValueColorRgbF READ invalidValueColorRgbF WRITE setInvalidValueColorRgbF);
public:
qtUIManager(smtk::attribute::ResourcePtr resource);
qtUIManager(
......@@ -85,9 +93,14 @@ public:
// Description:
// Set/Get the color used for indicating items with default values
void setDefaultValueColor(const QColor& color);
void setDefaultValueColorRgbF(const QVariantList& color);
QColor defaultValueColor() const { return this->DefaultValueColor; }
QVariantList defaultValueColorRgbF() const;
void setInvalidValueColor(const QColor& color);
void setInvalidValueColorRgbF(const QVariantList& color);
QColor invalidValueColor() const { return this->InvalidValueColor; }
QVariantList invalidValueColorRgbF() const;
// Description:
// Set the advanced values font to be bold and/or italic
......@@ -224,7 +237,28 @@ signals:
void fileItemCreated(smtk::extension::qtFileItem* fileItem);
void modelEntityItemCreated(smtk::extension::qtModelEntityItem* entItem);
void viewUIChanged(smtk::extension::qtBaseView*, smtk::attribute::ItemPtr);
/**\brief Emitted by the UI manager when the user setting has changed so
* that children can reset any active hovers and update themselves.
*/
void highlightOnHoverChanged(bool);
/**\brief Emitted by the UI manager when the defaultValueColor property is changed internally.
*
* This is currently a dummy signal required by pqPropertyLinks to synchronize
* the vtkSMProperty (used by ParaView to store user preferences) and the
* QColor value (used by the UI manager). Since UI components never change the
* default color, only responding to changes in user preferences, this signal
* is unused but must be present.
*/
void defaultValueColorChanged();
/**\brief Emitted by the UI manager when the invalidValueColor property is changed internally.
*
* This is currently a dummy signal required by pqPropertyLinks to synchronize
* the vtkSMProperty (used by ParaView to store user preferences) and the
* QColor value (used by the UI manager). Since UI components never change the
* invalid color, only responding to changes in user preferences, this signal
* is unused but must be present.
*/
void invalidValueColorChanged();
void refreshEntityItems();
friend class qtBaseView;
......
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