ENH: paraFoam --help => immediate pass-through to paraview --help

ENH: Paraview modules.

- Update props with int, not bool (for more versatility)
- Set properties and tool-tips directly on widgets instead of buttons
This commit is contained in:
Mark Olesen 2017-05-23 08:02:25 +02:00
parent 2495fcb42e
commit 96d98cd2de
6 changed files with 137 additions and 61 deletions

View File

@ -148,7 +148,7 @@
<!-- Use VTK Polyhedron (check-box) --> <!-- Use VTK Polyhedron (check-box) -->
<IntVectorProperty animateable="0" <IntVectorProperty animateable="0"
name="UseVTKPolyhedron" name="UseVTKPolyhedron"
label="Use VTK Polyhedron" label="VTK Polyhedra"
command="SetUseVTKPolyhedron" command="SetUseVTKPolyhedron"
default_values="0" default_values="0"
number_of_elements="1" number_of_elements="1"

View File

@ -37,18 +37,20 @@ License
#include "vtkSMIntVectorProperty.h" #include "vtkSMIntVectorProperty.h"
#include "vtkSMPropertyGroup.h" #include "vtkSMPropertyGroup.h"
#include "vtkSMSourceProxy.h" #include "vtkSMSourceProxy.h"
#include "vtkSMEnumerationDomain.h"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
// file-scope // file-scope
static QAbstractButton* setButtonProperties // Widget properties
static QWidget* setWidgetProperties
( (
QAbstractButton* b, QWidget* widget,
vtkSMProperty* prop vtkSMProperty* prop
) )
{ {
QString tip; widget->setFocusPolicy(Qt::NoFocus); // avoid dotted border
vtkSMDocumentation* doc = prop->GetDocumentation(); vtkSMDocumentation* doc = prop->GetDocumentation();
if (doc) if (doc)
@ -56,21 +58,33 @@ static QAbstractButton* setButtonProperties
const char* txt = doc->GetDescription(); const char* txt = doc->GetDescription();
if (txt) if (txt)
{ {
tip = QString(txt).simplified(); QString tip = QString(txt).simplified();
if (tip.size())
{
widget->setToolTip(tip);
}
} }
} }
return widget;
}
// file-scope
// Button properties
static QAbstractButton* setButtonProperties
(
QAbstractButton* b,
vtkSMProperty* prop
)
{
setWidgetProperties(b, prop);
b->setText(prop->GetXMLLabel()); b->setText(prop->GetXMLLabel());
if (tip.size())
{
b->setToolTip(tip);
}
b->setFocusPolicy(Qt::NoFocus); // avoid dotted border
vtkSMIntVectorProperty* intProp = vtkSMIntVectorProperty* intProp =
vtkSMIntVectorProperty::SafeDownCast(prop); vtkSMIntVectorProperty::SafeDownCast(prop);
// initial checked state for integer (bool) properties // Initial checked state for integer (bool) properties
if (intProp) if (intProp)
{ {
b->setChecked(intProp->GetElement(0)); b->setChecked(intProp->GetElement(0));
@ -102,12 +116,12 @@ static vtkSMIntVectorProperty* lookupIntProp
void pqFoamReaderControls::fireCommand void pqFoamReaderControls::fireCommand
( (
vtkSMIntVectorProperty* prop, vtkSMIntVectorProperty* prop,
bool checked int val
) )
{ {
vtkSMProxy* pxy = this->proxy(); vtkSMProxy* pxy = this->proxy();
prop->SetElement(0, checked); // Toogle bool prop->SetElement(0, val); // Set int value, toogle bool, etc
// Fire off command // Fire off command
prop->Modified(); prop->Modified();
@ -140,9 +154,9 @@ void pqFoamReaderControls::refreshPressed()
} }
void pqFoamReaderControls::cacheMesh(bool checked) void pqFoamReaderControls::cacheMesh(int val)
{ {
fireCommand(cacheMesh_, checked); fireCommand(cacheMesh_, val);
} }
@ -222,7 +236,10 @@ pqFoamReaderControls::pqFoamReaderControls
setButtonProperties(b, zeroTime); setButtonProperties(b, zeroTime);
form->addWidget(b, row, 1, Qt::AlignLeft); form->addWidget(b, row, 1, Qt::AlignLeft);
addPropertyLink(b, "checked", SIGNAL(toggled(bool)), zeroTime); addPropertyLink
(
b, "checked", SIGNAL(toggled(bool)), zeroTime
);
} }
// LINE // LINE
@ -244,8 +261,14 @@ pqFoamReaderControls::pqFoamReaderControls
setButtonProperties(b, includeSets_); setButtonProperties(b, includeSets_);
form->addWidget(b, row, 0, Qt::AlignLeft); form->addWidget(b, row, 0, Qt::AlignLeft);
addPropertyLink(b, "checked", SIGNAL(toggled(bool)), includeSets_); addPropertyLink
connect(b, SIGNAL(toggled(bool)), this, SLOT(includeSets(bool))); (
b, "checked", SIGNAL(toggled(bool)), includeSets_
);
connect
(
b, SIGNAL(toggled(bool)), this, SLOT(includeSets(bool))
);
} }
if (showGroupsOnly_) if (showGroupsOnly_)
@ -254,8 +277,14 @@ pqFoamReaderControls::pqFoamReaderControls
setButtonProperties(b, showGroupsOnly_); setButtonProperties(b, showGroupsOnly_);
form->addWidget(b, row, 1, Qt::AlignLeft); form->addWidget(b, row, 1, Qt::AlignLeft);
addPropertyLink(b, "checked", SIGNAL(toggled(bool)), showGroupsOnly_); addPropertyLink
connect(b, SIGNAL(toggled(bool)), this, SLOT(showGroupsOnly(bool))); (
b, "checked", SIGNAL(toggled(bool)), showGroupsOnly_
);
connect
(
b, SIGNAL(toggled(bool)), this, SLOT(showGroupsOnly(bool))
);
} }
@ -269,8 +298,14 @@ pqFoamReaderControls::pqFoamReaderControls
setButtonProperties(b, includeZones_); setButtonProperties(b, includeZones_);
form->addWidget(b, row, 0, Qt::AlignLeft); form->addWidget(b, row, 0, Qt::AlignLeft);
addPropertyLink(b, "checked", SIGNAL(toggled(bool)), includeZones_); addPropertyLink
connect(b, SIGNAL(toggled(bool)), this, SLOT(includeZones(bool))); (
b, "checked", SIGNAL(toggled(bool)), includeZones_
);
connect
(
b, SIGNAL(toggled(bool)), this, SLOT(includeZones(bool))
);
} }
if (showPatchNames_) if (showPatchNames_)
@ -279,7 +314,10 @@ pqFoamReaderControls::pqFoamReaderControls
setButtonProperties(b, showPatchNames_); setButtonProperties(b, showPatchNames_);
form->addWidget(b, row, 1, Qt::AlignLeft); form->addWidget(b, row, 1, Qt::AlignLeft);
connect(b, SIGNAL(toggled(bool)), this, SLOT(showPatchNames(bool))); connect
(
b, SIGNAL(toggled(bool)), this, SLOT(showPatchNames(bool))
);
} }
// LINE // LINE
@ -302,7 +340,10 @@ pqFoamReaderControls::pqFoamReaderControls
setButtonProperties(b, interpolate); setButtonProperties(b, interpolate);
form->addWidget(b, row, 0, Qt::AlignLeft); form->addWidget(b, row, 0, Qt::AlignLeft);
addPropertyLink(b, "checked", SIGNAL(toggled(bool)), interpolate); addPropertyLink
(
b, "checked", SIGNAL(toggled(bool)), interpolate
);
} }
intProp* extrapolate = lookupIntProp(group, "ExtrapolatePatches"); intProp* extrapolate = lookupIntProp(group, "ExtrapolatePatches");
@ -312,7 +353,10 @@ pqFoamReaderControls::pqFoamReaderControls
setButtonProperties(b, extrapolate); setButtonProperties(b, extrapolate);
form->addWidget(b, row, 1, Qt::AlignLeft); form->addWidget(b, row, 1, Qt::AlignLeft);
addPropertyLink(b, "checked", SIGNAL(toggled(bool)), extrapolate); addPropertyLink
(
b, "checked", SIGNAL(toggled(bool)), extrapolate
);
} }
// LINE // LINE
@ -335,7 +379,10 @@ pqFoamReaderControls::pqFoamReaderControls
setButtonProperties(b, updateGui); setButtonProperties(b, updateGui);
form->addWidget(b, row, 0, Qt::AlignLeft); form->addWidget(b, row, 0, Qt::AlignLeft);
addPropertyLink(b, "checked", SIGNAL(clicked()), updateGui); addPropertyLink
(
b, "checked", SIGNAL(clicked()), updateGui
);
} }
intProp* usePolyhedron = lookupIntProp(group, "UseVTKPolyhedron"); intProp* usePolyhedron = lookupIntProp(group, "UseVTKPolyhedron");
@ -345,7 +392,10 @@ pqFoamReaderControls::pqFoamReaderControls
setButtonProperties(b, usePolyhedron); setButtonProperties(b, usePolyhedron);
form->addWidget(b, row, 1, Qt::AlignLeft); form->addWidget(b, row, 1, Qt::AlignLeft);
addPropertyLink(b, "checked", SIGNAL(toggled(bool)), usePolyhedron); addPropertyLink
(
b, "checked", SIGNAL(toggled(bool)), usePolyhedron
);
} }
if (cacheMesh_) if (cacheMesh_)
@ -353,8 +403,10 @@ pqFoamReaderControls::pqFoamReaderControls
QCheckBox* b = new QCheckBox(this); QCheckBox* b = new QCheckBox(this);
setButtonProperties(b, cacheMesh_); setButtonProperties(b, cacheMesh_);
form->addWidget(b, row, 2, Qt::AlignLeft); form->addWidget(b, row, 2, Qt::AlignLeft);
connect
connect(b, SIGNAL(toggled(bool)), this, SLOT(cacheMesh(bool))); (
b, SIGNAL(toggled(bool)), this, SLOT(cacheMesh(bool))
);
} }
} }

View File

@ -78,8 +78,8 @@ class pqFoamReaderControls
//- Update property //- Update property
void fireCommand(vtkSMProperty* prop); void fireCommand(vtkSMProperty* prop);
//- Toggle and update bool property //- Update int property or toggle bool property
void fireCommand(vtkSMIntVectorProperty* prop, bool checked); void fireCommand(vtkSMIntVectorProperty* prop, int val);
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct

View File

@ -40,13 +40,13 @@ License
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
// file-scope // file-scope
static QAbstractButton* setButtonProperties static QWidget* setWidgetProperties
( (
QAbstractButton* b, QWidget* widget,
vtkSMProperty* prop vtkSMProperty* prop
) )
{ {
QString tip; widget->setFocusPolicy(Qt::NoFocus); // avoid dotted border
vtkSMDocumentation* doc = prop->GetDocumentation(); vtkSMDocumentation* doc = prop->GetDocumentation();
if (doc) if (doc)
@ -54,22 +54,32 @@ static QAbstractButton* setButtonProperties
const char* txt = doc->GetDescription(); const char* txt = doc->GetDescription();
if (txt) if (txt)
{ {
tip = QString(txt).simplified(); QString tip = QString(txt).simplified();
if (tip.size())
{
widget->setToolTip(tip);
}
} }
} }
b->setText(prop->GetXMLLabel()); return widget;
if (tip.size()) }
{
b->setToolTip(tip);
}
b->setFocusPolicy(Qt::NoFocus); // avoid dotted border
// file-scope
static QAbstractButton* setButtonProperties
(
QAbstractButton* b,
vtkSMProperty* prop
)
{
setWidgetProperties(b, prop);
b->setText(prop->GetXMLLabel());
vtkSMIntVectorProperty* intProp = vtkSMIntVectorProperty* intProp =
vtkSMIntVectorProperty::SafeDownCast(prop); vtkSMIntVectorProperty::SafeDownCast(prop);
// initial checked state for integer (bool) properties // Initial checked state for integer (bool) properties
if (intProp) if (intProp)
{ {
b->setChecked(intProp->GetElement(0)); b->setChecked(intProp->GetElement(0));
@ -111,12 +121,12 @@ void pqFoamBlockMeshControls::fireCommand(vtkSMProperty* prop)
void pqFoamBlockMeshControls::fireCommand void pqFoamBlockMeshControls::fireCommand
( (
vtkSMIntVectorProperty* prop, vtkSMIntVectorProperty* prop,
bool checked int val
) )
{ {
vtkSMProxy* pxy = this->proxy(); vtkSMProxy* pxy = this->proxy();
prop->SetElement(0, checked); // Toogle bool prop->SetElement(0, val); // Set int value, toogle bool, etc
// Fire off command // Fire off command
prop->Modified(); prop->Modified();
@ -200,7 +210,10 @@ pqFoamBlockMeshControls::pqFoamBlockMeshControls
setButtonProperties(b, refresh_); setButtonProperties(b, refresh_);
form->addWidget(b, 0, 0, Qt::AlignLeft); form->addWidget(b, 0, 0, Qt::AlignLeft);
connect(b, SIGNAL(clicked()), this, SLOT(refreshPressed())); connect
(
b, SIGNAL(clicked()), this, SLOT(refreshPressed())
);
} }
if (showPatchNames_) if (showPatchNames_)
@ -209,7 +222,10 @@ pqFoamBlockMeshControls::pqFoamBlockMeshControls
setButtonProperties(b, showPatchNames_); setButtonProperties(b, showPatchNames_);
form->addWidget(b, 0, 1, Qt::AlignLeft); form->addWidget(b, 0, 1, Qt::AlignLeft);
connect(b, SIGNAL(toggled(bool)), this, SLOT(showPatchNames(bool))); connect
(
b, SIGNAL(toggled(bool)), this, SLOT(showPatchNames(bool))
);
} }
if (showPointNumbers_) if (showPointNumbers_)
@ -218,7 +234,10 @@ pqFoamBlockMeshControls::pqFoamBlockMeshControls
setButtonProperties(b, showPointNumbers_); setButtonProperties(b, showPointNumbers_);
form->addWidget(b, 0, 2, Qt::AlignLeft); form->addWidget(b, 0, 2, Qt::AlignLeft);
connect(b, SIGNAL(toggled(bool)), this, SLOT(showPointNumbers(bool))); connect
(
b, SIGNAL(toggled(bool)), this, SLOT(showPointNumbers(bool))
);
} }
} }

View File

@ -71,8 +71,8 @@ class pqFoamBlockMeshControls
//- Update property //- Update property
void fireCommand(vtkSMProperty* prop); void fireCommand(vtkSMProperty* prop);
//- Toggle and update bool property //- Update int property or toggle bool property
void fireCommand(vtkSMIntVectorProperty* prop, bool checked); void fireCommand(vtkSMIntVectorProperty* prop, int val);
//- Update "BlockArrayStatus", "CurvedEdgesArrayStatus" information //- Update "BlockArrayStatus", "CurvedEdgesArrayStatus" information
void updateParts(); void updateParts();

View File

@ -26,10 +26,10 @@
# paraFoam # paraFoam
# #
# Description # Description
# start paraview with the OpenFOAM libraries # Start paraview with the OpenFOAM libraries and reader modules.
# #
# Note # Note
# combining -block or -builtin options with the -region option yields # Combining -block or -builtin options with -region option yields
# undefined behaviour # undefined behaviour
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
usage() { usage() {
@ -37,7 +37,7 @@ usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE cat<<USAGE
Usage: ${0##*/} [OPTION] [PARAVIEW_OPTION] Usage: ${0##*/} [OPTION] [--] [PARAVIEW_OPTION]
options: options:
-block use blockMesh reader (uses .blockMesh extension) -block use blockMesh reader (uses .blockMesh extension)
-case <dir> specify alternative case directory, default is the cwd -case <dir> specify alternative case directory, default is the cwd
@ -46,10 +46,10 @@ options:
-touchAll create .blockMesh, .OpenFOAM files (and for all regions) -touchAll create .blockMesh, .OpenFOAM files (and for all regions)
-vtk | -builtin use VTK builtin OpenFOAM reader (uses .foam extension) -vtk | -builtin use VTK builtin OpenFOAM reader (uses .foam extension)
-help print the usage -help print the usage
--help paraview help
Paraview options start with a double dashes. Start paraview with the OpenFOAM libraries and reader modules.
Note that paraview options begin with double dashes.
* start paraview with the OpenFOAM libraries
paraview=$(command -v paraview) paraview=$(command -v paraview)
@ -57,12 +57,9 @@ USAGE
exit 1 exit 1
} }
# We want to do nice exit when running paraview to give paraview opportunity # Do a nice exit to give paraview an opportunity to clean up
# to clean up
unset FOAM_ABORT unset FOAM_ABORT
unset regionName optTouch
# Hack: change all locale to 'C' i.e. using '.' for decimal point. This is # Hack: change all locale to 'C' i.e. using '.' for decimal point. This is
# only needed temporarily until paraview is locale aware. (git version is # only needed temporarily until paraview is locale aware. (git version is
# already 2010-07) # already 2010-07)
@ -73,18 +70,19 @@ extension=OpenFOAM
plugin=PVFoamReader plugin=PVFoamReader
# Parse options # Parse options
unset regionName optTouch
while [ "$#" -gt 0 ] while [ "$#" -gt 0 ]
do do
case "$1" in case "$1" in
-h | -help) -h | -help)
usage usage
;; ;;
-block | -blockMesh) -block*)
extension=blockMesh extension=blockMesh
plugin=PVblockMeshReader plugin=PVblockMeshReader
shift shift
;; ;;
-builtin | -vtk) -vtk | -built*)
extension=foam extension=foam
unset plugin unset plugin
shift shift
@ -113,6 +111,11 @@ do
shift shift
break # Stop here, treat balance as paraview options break # Stop here, treat balance as paraview options
;; ;;
--help) # Emit paraview help directly
exec paraview "$@"
echo "Error: could not exec paraview" 1>&2
exit 1 # This should not have happened
;;
--*) --*)
break # Stop here, treat this and balance as paraview options break # Stop here, treat this and balance as paraview options
;; ;;
@ -253,6 +256,8 @@ then
# Has --data=.., send directly to paraview # Has --data=.., send directly to paraview
exec paraview "$@" exec paraview "$@"
echo "Error: could not exec paraview" 1>&2
exit 1 # This should not have happened
else else