Commit 96d98cd2 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

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
parent 2495fcb4
......@@ -148,7 +148,7 @@
<!-- Use VTK Polyhedron (check-box) -->
<IntVectorProperty animateable="0"
name="UseVTKPolyhedron"
label="Use VTK Polyhedron"
label="VTK Polyhedra"
command="SetUseVTKPolyhedron"
default_values="0"
number_of_elements="1"
......
......@@ -37,18 +37,20 @@ License
#include "vtkSMIntVectorProperty.h"
#include "vtkSMPropertyGroup.h"
#include "vtkSMSourceProxy.h"
#include "vtkSMEnumerationDomain.h"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
// file-scope
static QAbstractButton* setButtonProperties
// Widget properties
static QWidget* setWidgetProperties
(
QAbstractButton* b,
QWidget* widget,
vtkSMProperty* prop
)
{
QString tip;
widget->setFocusPolicy(Qt::NoFocus); // avoid dotted border
vtkSMDocumentation* doc = prop->GetDocumentation();
if (doc)
......@@ -56,21 +58,33 @@ static QAbstractButton* setButtonProperties
const char* txt = doc->GetDescription();
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());
if (tip.size())
{
b->setToolTip(tip);
}
b->setFocusPolicy(Qt::NoFocus); // avoid dotted border
vtkSMIntVectorProperty* intProp =
vtkSMIntVectorProperty::SafeDownCast(prop);
// initial checked state for integer (bool) properties
// Initial checked state for integer (bool) properties
if (intProp)
{
b->setChecked(intProp->GetElement(0));
......@@ -102,12 +116,12 @@ static vtkSMIntVectorProperty* lookupIntProp
void pqFoamReaderControls::fireCommand
(
vtkSMIntVectorProperty* prop,
bool checked
int val
)
{
vtkSMProxy* pxy = this->proxy();
prop->SetElement(0, checked); // Toogle bool
prop->SetElement(0, val); // Set int value, toogle bool, etc
// Fire off command
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);
form->addWidget(b, row, 1, Qt::AlignLeft);
addPropertyLink(b, "checked", SIGNAL(toggled(bool)), zeroTime);
addPropertyLink
(
b, "checked", SIGNAL(toggled(bool)), zeroTime
);
}
// LINE
......@@ -244,8 +261,14 @@ pqFoamReaderControls::pqFoamReaderControls
setButtonProperties(b, includeSets_);
form->addWidget(b, row, 0, Qt::AlignLeft);
addPropertyLink(b, "checked", SIGNAL(toggled(bool)), includeSets_);
connect(b, SIGNAL(toggled(bool)), this, SLOT(includeSets(bool)));
addPropertyLink
(
b, "checked", SIGNAL(toggled(bool)), includeSets_
);
connect
(
b, SIGNAL(toggled(bool)), this, SLOT(includeSets(bool))
);
}
if (showGroupsOnly_)
......@@ -254,8 +277,14 @@ pqFoamReaderControls::pqFoamReaderControls
setButtonProperties(b, showGroupsOnly_);
form->addWidget(b, row, 1, Qt::AlignLeft);
addPropertyLink(b, "checked", SIGNAL(toggled(bool)), showGroupsOnly_);
connect(b, SIGNAL(toggled(bool)), this, SLOT(showGroupsOnly(bool)));
addPropertyLink
(
b, "checked", SIGNAL(toggled(bool)), showGroupsOnly_
);
connect
(
b, SIGNAL(toggled(bool)), this, SLOT(showGroupsOnly(bool))
);
}
......@@ -269,8 +298,14 @@ pqFoamReaderControls::pqFoamReaderControls
setButtonProperties(b, includeZones_);
form->addWidget(b, row, 0, Qt::AlignLeft);
addPropertyLink(b, "checked", SIGNAL(toggled(bool)), includeZones_);
connect(b, SIGNAL(toggled(bool)), this, SLOT(includeZones(bool)));
addPropertyLink
(
b, "checked", SIGNAL(toggled(bool)), includeZones_
);
connect
(
b, SIGNAL(toggled(bool)), this, SLOT(includeZones(bool))
);
}
if (showPatchNames_)
......@@ -279,7 +314,10 @@ pqFoamReaderControls::pqFoamReaderControls
setButtonProperties(b, showPatchNames_);
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
......@@ -302,7 +340,10 @@ pqFoamReaderControls::pqFoamReaderControls
setButtonProperties(b, interpolate);
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");
......@@ -312,7 +353,10 @@ pqFoamReaderControls::pqFoamReaderControls
setButtonProperties(b, extrapolate);
form->addWidget(b, row, 1, Qt::AlignLeft);
addPropertyLink(b, "checked", SIGNAL(toggled(bool)), extrapolate);
addPropertyLink
(
b, "checked", SIGNAL(toggled(bool)), extrapolate
);
}
// LINE
......@@ -335,7 +379,10 @@ pqFoamReaderControls::pqFoamReaderControls
setButtonProperties(b, updateGui);
form->addWidget(b, row, 0, Qt::AlignLeft);
addPropertyLink(b, "checked", SIGNAL(clicked()), updateGui);
addPropertyLink
(
b, "checked", SIGNAL(clicked()), updateGui
);
}
intProp* usePolyhedron = lookupIntProp(group, "UseVTKPolyhedron");
......@@ -345,7 +392,10 @@ pqFoamReaderControls::pqFoamReaderControls
setButtonProperties(b, usePolyhedron);
form->addWidget(b, row, 1, Qt::AlignLeft);
addPropertyLink(b, "checked", SIGNAL(toggled(bool)), usePolyhedron);
addPropertyLink
(
b, "checked", SIGNAL(toggled(bool)), usePolyhedron
);
}
if (cacheMesh_)
......@@ -353,8 +403,10 @@ pqFoamReaderControls::pqFoamReaderControls
QCheckBox* b = new QCheckBox(this);
setButtonProperties(b, cacheMesh_);
form->addWidget(b, row, 2, Qt::AlignLeft);
connect(b, SIGNAL(toggled(bool)), this, SLOT(cacheMesh(bool)));
connect
(
b, SIGNAL(toggled(bool)), this, SLOT(cacheMesh(bool))
);
}
}
......
......@@ -78,8 +78,8 @@ class pqFoamReaderControls
//- Update property
void fireCommand(vtkSMProperty* prop);
//- Toggle and update bool property
void fireCommand(vtkSMIntVectorProperty* prop, bool checked);
//- Update int property or toggle bool property
void fireCommand(vtkSMIntVectorProperty* prop, int val);
//- Disallow default bitwise copy construct
......
......@@ -40,13 +40,13 @@ License
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
// file-scope
static QAbstractButton* setButtonProperties
static QWidget* setWidgetProperties
(
QAbstractButton* b,
QWidget* widget,
vtkSMProperty* prop
)
{
QString tip;
widget->setFocusPolicy(Qt::NoFocus); // avoid dotted border
vtkSMDocumentation* doc = prop->GetDocumentation();
if (doc)
......@@ -54,22 +54,32 @@ static QAbstractButton* setButtonProperties
const char* txt = doc->GetDescription();
if (txt)
{
tip = QString(txt).simplified();
QString tip = QString(txt).simplified();
if (tip.size())
{
widget->setToolTip(tip);
}
}
}
b->setText(prop->GetXMLLabel());
if (tip.size())
{
b->setToolTip(tip);
}
b->setFocusPolicy(Qt::NoFocus); // avoid dotted border
return widget;
}
// file-scope
static QAbstractButton* setButtonProperties
(
QAbstractButton* b,
vtkSMProperty* prop
)
{
setWidgetProperties(b, prop);
b->setText(prop->GetXMLLabel());
vtkSMIntVectorProperty* intProp =
vtkSMIntVectorProperty::SafeDownCast(prop);
// initial checked state for integer (bool) properties
// Initial checked state for integer (bool) properties
if (intProp)
{
b->setChecked(intProp->GetElement(0));
......@@ -111,12 +121,12 @@ void pqFoamBlockMeshControls::fireCommand(vtkSMProperty* prop)
void pqFoamBlockMeshControls::fireCommand
(
vtkSMIntVectorProperty* prop,
bool checked
int val
)
{
vtkSMProxy* pxy = this->proxy();
prop->SetElement(0, checked); // Toogle bool
prop->SetElement(0, val); // Set int value, toogle bool, etc
// Fire off command
prop->Modified();
......@@ -200,7 +210,10 @@ pqFoamBlockMeshControls::pqFoamBlockMeshControls
setButtonProperties(b, refresh_);
form->addWidget(b, 0, 0, Qt::AlignLeft);
connect(b, SIGNAL(clicked()), this, SLOT(refreshPressed()));
connect
(
b, SIGNAL(clicked()), this, SLOT(refreshPressed())
);
}
if (showPatchNames_)
......@@ -209,7 +222,10 @@ pqFoamBlockMeshControls::pqFoamBlockMeshControls
setButtonProperties(b, showPatchNames_);
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_)
......@@ -218,7 +234,10 @@ pqFoamBlockMeshControls::pqFoamBlockMeshControls
setButtonProperties(b, showPointNumbers_);
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))
);
}
}
......
......@@ -71,8 +71,8 @@ class pqFoamBlockMeshControls
//- Update property
void fireCommand(vtkSMProperty* prop);
//- Toggle and update bool property
void fireCommand(vtkSMIntVectorProperty* prop, bool checked);
//- Update int property or toggle bool property
void fireCommand(vtkSMIntVectorProperty* prop, int val);
//- Update "BlockArrayStatus", "CurvedEdgesArrayStatus" information
void updateParts();
......
......@@ -26,10 +26,10 @@
# paraFoam
#
# Description
# start paraview with the OpenFOAM libraries
# Start paraview with the OpenFOAM libraries and reader modules.
#
# Note
# combining -block or -builtin options with the -region option yields
# Combining -block or -builtin options with -region option yields
# undefined behaviour
#------------------------------------------------------------------------------
usage() {
......@@ -37,7 +37,7 @@ usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: ${0##*/} [OPTION] [PARAVIEW_OPTION]
Usage: ${0##*/} [OPTION] [--] [PARAVIEW_OPTION]
options:
-block use blockMesh reader (uses .blockMesh extension)
-case <dir> specify alternative case directory, default is the cwd
......@@ -46,10 +46,10 @@ options:
-touchAll create .blockMesh, .OpenFOAM files (and for all regions)
-vtk | -builtin use VTK builtin OpenFOAM reader (uses .foam extension)
-help print the usage
--help paraview help
Paraview options start with a double dashes.
* start paraview with the OpenFOAM libraries
Start paraview with the OpenFOAM libraries and reader modules.
Note that paraview options begin with double dashes.
paraview=$(command -v paraview)
......@@ -57,12 +57,9 @@ USAGE
exit 1
}
# We want to do nice exit when running paraview to give paraview opportunity
# to clean up
# Do a nice exit to give paraview an opportunity to clean up
unset FOAM_ABORT
unset regionName optTouch
# 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
# already 2010-07)
......@@ -73,18 +70,19 @@ extension=OpenFOAM
plugin=PVFoamReader
# Parse options
unset regionName optTouch
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
;;
-block | -blockMesh)
-block*)
extension=blockMesh
plugin=PVblockMeshReader
shift
;;
-builtin | -vtk)
-vtk | -built*)
extension=foam
unset plugin
shift
......@@ -113,6 +111,11 @@ do
shift
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
;;
......@@ -253,6 +256,8 @@ then
# Has --data=.., send directly to paraview
exec paraview "$@"
echo "Error: could not exec paraview" 1>&2
exit 1 # This should not have happened
else
......
Supports Markdown
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