mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: update blockMesh reader (issue #337)
- use property group customization instead of individual pqPropertyWidget
This commit is contained in:
@ -1,75 +1,65 @@
|
||||
# Create a plugin to add a reader to the ParaView GUI
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
|
||||
FIND_PACKAGE(ParaView REQUIRED)
|
||||
INCLUDE(${PARAVIEW_USE_FILE})
|
||||
find_package(ParaView REQUIRED)
|
||||
include(${PARAVIEW_USE_FILE})
|
||||
|
||||
LINK_DIRECTORIES(
|
||||
link_directories(
|
||||
$ENV{FOAM_LIBBIN}
|
||||
$ENV{FOAM_EXT_LIBBIN}
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
include_directories(
|
||||
$ENV{WM_PROJECT_DIR}/src/OpenFOAM/lnInclude
|
||||
$ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}/lnInclude
|
||||
$ENV{WM_PROJECT_DIR}/src/meshing/blockMesh/lnInclude
|
||||
${PROJECT_SOURCE_DIR}/../vtkPVblockMesh
|
||||
)
|
||||
|
||||
ADD_DEFINITIONS(
|
||||
add_definitions(
|
||||
-std=c++11
|
||||
-DWM_$ENV{WM_PRECISION_OPTION}
|
||||
-DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
|
||||
)
|
||||
|
||||
# Set output library destination to plugin directory
|
||||
SET(
|
||||
set(
|
||||
LIBRARY_OUTPUT_PATH $ENV{PV_PLUGIN_PATH}
|
||||
CACHE INTERNAL
|
||||
"Single output directory for building all libraries."
|
||||
)
|
||||
|
||||
|
||||
IF (PARAVIEW_QT_VERSION VERSION_GREATER "4")
|
||||
QT5_WRAP_CPP(MOC_SRCS
|
||||
pqRefreshProperty.h
|
||||
pqShowPointNumbersProperty.h
|
||||
if (PARAVIEW_QT_VERSION VERSION_GREATER "4")
|
||||
qt5_wrap_cpp(MOC_SRCS
|
||||
pqFoamBlockMeshControls.h
|
||||
)
|
||||
ELSE()
|
||||
QT4_WRAP_CPP(MOC_SRCS
|
||||
pqRefreshProperty.h
|
||||
pqShowPointNumbersProperty.h
|
||||
else()
|
||||
qt4_wrap_cpp(MOC_SRCS
|
||||
pqFoamBlockMeshControls.h
|
||||
)
|
||||
ENDIF()
|
||||
endif()
|
||||
|
||||
ADD_PARAVIEW_PROPERTY_WIDGET(IFACES0 IFACES0_SRCS
|
||||
TYPE "openfoam_refresh_button"
|
||||
CLASS_NAME pqRefreshProperty
|
||||
add_paraview_property_group_widget(IFACES0 IFACES0_SRCS
|
||||
TYPE "openfoam_blockMesh_general_controls"
|
||||
CLASS_NAME pqFoamBlockMeshControls
|
||||
)
|
||||
|
||||
ADD_PARAVIEW_PROPERTY_WIDGET(IFACES1 IFACES1_SRCS
|
||||
TYPE "openfoam_show_point_numbers"
|
||||
CLASS_NAME pqShowPointNumbersProperty
|
||||
)
|
||||
|
||||
ADD_PARAVIEW_PLUGIN(
|
||||
add_paraview_plugin(
|
||||
PVblockMeshReader_SM "1.0"
|
||||
SERVER_MANAGER_XML PVblockMeshReader_SM.xml
|
||||
SERVER_MANAGER_SOURCES vtkPVblockMeshReader.cxx
|
||||
GUI_INTERFACES
|
||||
${IFACES0}
|
||||
${IFACES1}
|
||||
SOURCES
|
||||
${IFACES0_SRCS}
|
||||
${IFACES1_SRCS}
|
||||
${MOC_SRCS}
|
||||
pqRefreshProperty.cxx
|
||||
pqShowPointNumbersProperty.cxx
|
||||
pqFoamBlockMeshControls.cxx
|
||||
)
|
||||
|
||||
|
||||
TARGET_LINK_LIBRARIES(
|
||||
target_link_libraries(
|
||||
PVblockMeshReader_SM
|
||||
LINK_PUBLIC
|
||||
vtkPVblockMesh
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
name="Refresh"
|
||||
command="SetRefresh"
|
||||
default_values="0"
|
||||
panel_widget="openfoam_refresh_button"
|
||||
number_of_elements="1"
|
||||
panel_visibility="default">
|
||||
<BooleanDomain name="bool"/>
|
||||
@ -31,7 +30,6 @@
|
||||
name="ShowPointNumbers"
|
||||
command="SetShowPointNumbers"
|
||||
default_values="1"
|
||||
panel_widget="openfoam_show_point_numbers"
|
||||
number_of_elements="1"
|
||||
panel_visibility="default">
|
||||
<BooleanDomain name="bool"/>
|
||||
@ -94,7 +92,9 @@
|
||||
file_description="OpenFOAM blockMesh"/>
|
||||
</Hints>
|
||||
|
||||
<PropertyGroup label="General Controls">
|
||||
<PropertyGroup
|
||||
label="General Controls"
|
||||
panel_widget="openfoam_blockMesh_general_controls">
|
||||
<Property name="Refresh"/>
|
||||
<Property name="ShowPointNumbers"/>
|
||||
</PropertyGroup>
|
||||
|
||||
@ -23,21 +23,24 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "pqRefreshProperty.h"
|
||||
#include "pqFoamBlockMeshControls.h"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QCheckBox>
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "pqApplicationCore.h"
|
||||
#include "pqView.h"
|
||||
#include "vtkSMDocumentation.h"
|
||||
#include "vtkSMIntVectorProperty.h"
|
||||
#include "vtkSMPropertyGroup.h"
|
||||
#include "vtkSMSourceProxy.h"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
// file-scope
|
||||
static void setButtonProperties
|
||||
static QAbstractButton* setButtonProperties
|
||||
(
|
||||
QAbstractButton* b,
|
||||
vtkSMIntVectorProperty* prop,
|
||||
@ -68,12 +71,31 @@ static void setButtonProperties
|
||||
{
|
||||
b->setChecked(prop->GetElement(0));
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
static vtkSMIntVectorProperty* lookupIntProp
|
||||
(
|
||||
vtkSMPropertyGroup* group,
|
||||
const char* name
|
||||
)
|
||||
{
|
||||
vtkSMProperty* prop = group->GetProperty(name);
|
||||
|
||||
if (prop)
|
||||
{
|
||||
return vtkSMIntVectorProperty::SafeDownCast(prop);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void pqRefreshProperty::refreshPressed()
|
||||
void pqFoamBlockMeshControls::refreshPressed()
|
||||
{
|
||||
// Update everything
|
||||
refresh_->Modified();
|
||||
@ -85,35 +107,61 @@ void pqRefreshProperty::refreshPressed()
|
||||
}
|
||||
|
||||
|
||||
void pqFoamBlockMeshControls::showPointNumbers(bool checked)
|
||||
{
|
||||
showPointNumbers_->SetElement(0, checked);
|
||||
|
||||
// Update the active view
|
||||
if (this->view())
|
||||
{
|
||||
this->view()->render();
|
||||
}
|
||||
|
||||
// OR: update all views
|
||||
// pqApplicationCore::instance()->render();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
pqRefreshProperty::pqRefreshProperty
|
||||
pqFoamBlockMeshControls::pqFoamBlockMeshControls
|
||||
(
|
||||
vtkSMProxy* proxy,
|
||||
vtkSMProperty* prop,
|
||||
vtkSMPropertyGroup* group,
|
||||
QWidget* parent
|
||||
)
|
||||
:
|
||||
Superclass(proxy, parent),
|
||||
refresh_(vtkSMIntVectorProperty::SafeDownCast(prop))
|
||||
refresh_(lookupIntProp(group, "Refresh")),
|
||||
showPointNumbers_(lookupIntProp(group, "ShowPointNumbers"))
|
||||
{
|
||||
// Replace with our UI content
|
||||
this->setShowLabel(false);
|
||||
|
||||
QGridLayout* form = new QGridLayout(this);
|
||||
|
||||
QPushButton* b = new QPushButton(this);
|
||||
setButtonProperties(b, refresh_, false);
|
||||
form->addWidget(b, 0, 0, Qt::AlignLeft);
|
||||
if (refresh_)
|
||||
{
|
||||
QPushButton* b = new QPushButton(this);
|
||||
setButtonProperties(b, refresh_, false);
|
||||
form->addWidget(b, 0, 0, Qt::AlignLeft);
|
||||
|
||||
connect(b, SIGNAL(clicked()), this, SLOT(refreshPressed()));
|
||||
refresh_->SetImmediateUpdate(true);
|
||||
connect(b, SIGNAL(clicked()), this, SLOT(refreshPressed()));
|
||||
refresh_->SetImmediateUpdate(true);
|
||||
}
|
||||
|
||||
if (showPointNumbers_)
|
||||
{
|
||||
QCheckBox* b = new QCheckBox(this);
|
||||
setButtonProperties(b, showPointNumbers_);
|
||||
form->addWidget(b, 0, 1, Qt::AlignLeft);
|
||||
|
||||
connect(b, SIGNAL(toggled(bool)), this, SLOT(showPointNumbers(bool)));
|
||||
showPointNumbers_->SetImmediateUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
pqRefreshProperty::~pqRefreshProperty()
|
||||
pqFoamBlockMeshControls::~pqFoamBlockMeshControls()
|
||||
{}
|
||||
|
||||
|
||||
@ -22,17 +22,19 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
pqShowPointNumbersProperty
|
||||
pqFoamBlockMeshControls
|
||||
|
||||
Description
|
||||
Custom UI handling of show-points (ParaView blockMesh reader)
|
||||
Customized property controls for the ParaView blockMesh reader.
|
||||
|
||||
Refresh and ShowPointNumbers.
|
||||
|
||||
SourceFiles
|
||||
pqShowPointNumbersProperty.cxx
|
||||
pqFoamBlockMeshControls.cxx
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
#ifndef pqShowPointNumbersProperty_h
|
||||
#define pqShowPointNumbersProperty_h
|
||||
#ifndef pqFoamBlockMeshControls_h
|
||||
#define pqFoamBlockMeshControls_h
|
||||
|
||||
#include "pqPropertyWidget.h"
|
||||
|
||||
@ -41,10 +43,10 @@ class vtkSMIntVectorProperty;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class pqShowPointNumbersProperty Declaration
|
||||
Class pqFoamBlockMeshControls Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class pqShowPointNumbersProperty
|
||||
class pqFoamBlockMeshControls
|
||||
:
|
||||
public pqPropertyWidget
|
||||
{
|
||||
@ -53,14 +55,29 @@ class pqShowPointNumbersProperty
|
||||
|
||||
// Private data
|
||||
|
||||
//- Refresh (bool property - as push button)
|
||||
vtkSMIntVectorProperty* refresh_;
|
||||
|
||||
//- Show Point Numbers (bool property)
|
||||
vtkSMIntVectorProperty* showPointNumbers_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
pqFoamBlockMeshControls(const pqFoamBlockMeshControls&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const pqFoamBlockMeshControls&) = delete;
|
||||
|
||||
|
||||
protected slots:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Trigger refresh
|
||||
void refreshPressed();
|
||||
|
||||
//- Sync property with changed checkbox state, update rendered view(s)
|
||||
void showPointNumbers(bool checked);
|
||||
|
||||
@ -68,16 +85,16 @@ protected slots:
|
||||
public:
|
||||
|
||||
//- Construct from components
|
||||
pqShowPointNumbersProperty
|
||||
pqFoamBlockMeshControls
|
||||
(
|
||||
vtkSMProxy* proxy,
|
||||
vtkSMProperty* prop,
|
||||
vtkSMPropertyGroup* group,
|
||||
QWidget* parent = nullptr
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~pqShowPointNumbersProperty();
|
||||
virtual ~pqFoamBlockMeshControls();
|
||||
|
||||
};
|
||||
|
||||
@ -1,89 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
pqRefreshProperty
|
||||
|
||||
Description
|
||||
Custom refresh button (ParaView blockMesh reader)
|
||||
|
||||
SourceFiles
|
||||
pqRefreshProperty.cxx
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
#ifndef pqRefreshProperty_h
|
||||
#define pqRefreshProperty_h
|
||||
|
||||
#include "pqPropertyWidget.h"
|
||||
|
||||
// Forward declarations (ParaView)
|
||||
class vtkSMIntVectorProperty;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class pqRefreshProperty Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class pqRefreshProperty
|
||||
:
|
||||
public pqPropertyWidget
|
||||
{
|
||||
Q_OBJECT;
|
||||
typedef pqPropertyWidget Superclass;
|
||||
|
||||
// Private data
|
||||
|
||||
//- Refresh (bool property - as push button)
|
||||
vtkSMIntVectorProperty* refresh_;
|
||||
|
||||
|
||||
protected slots:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Trigger refresh
|
||||
void refreshPressed();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Construct from components
|
||||
pqRefreshProperty
|
||||
(
|
||||
vtkSMProxy* proxy,
|
||||
vtkSMProperty* prop,
|
||||
QWidget* parent = nullptr
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~pqRefreshProperty();
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,122 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "pqShowPointNumbersProperty.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QGridLayout>
|
||||
|
||||
#include "pqApplicationCore.h"
|
||||
#include "pqView.h"
|
||||
#include "vtkSMDocumentation.h"
|
||||
#include "vtkSMIntVectorProperty.h"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
// file-scope
|
||||
static void setButtonProperties
|
||||
(
|
||||
QAbstractButton* b,
|
||||
vtkSMIntVectorProperty* prop,
|
||||
bool initChecked = true
|
||||
)
|
||||
{
|
||||
QString tip;
|
||||
|
||||
vtkSMDocumentation* doc = prop->GetDocumentation();
|
||||
if (doc)
|
||||
{
|
||||
const char* txt = doc->GetDescription();
|
||||
if (txt)
|
||||
{
|
||||
tip = QString(txt).simplified();
|
||||
}
|
||||
}
|
||||
|
||||
b->setText(prop->GetXMLLabel());
|
||||
if (tip.size())
|
||||
{
|
||||
b->setToolTip(tip);
|
||||
}
|
||||
b->setFocusPolicy(Qt::NoFocus); // avoid dotted border
|
||||
|
||||
// initial checked state
|
||||
if (initChecked)
|
||||
{
|
||||
b->setChecked(prop->GetElement(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void pqShowPointNumbersProperty::showPointNumbers(bool checked)
|
||||
{
|
||||
showPointNumbers_->SetElement(0, checked);
|
||||
|
||||
// Update the active view
|
||||
if (this->view())
|
||||
{
|
||||
this->view()->render();
|
||||
}
|
||||
|
||||
// OR: update all views
|
||||
// pqApplicationCore::instance()->render();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
pqShowPointNumbersProperty::pqShowPointNumbersProperty
|
||||
(
|
||||
vtkSMProxy* proxy,
|
||||
vtkSMProperty* prop,
|
||||
QWidget* parent
|
||||
)
|
||||
:
|
||||
Superclass(proxy, parent),
|
||||
showPointNumbers_(vtkSMIntVectorProperty::SafeDownCast(prop))
|
||||
{
|
||||
// Replace with our UI content
|
||||
this->setShowLabel(false);
|
||||
|
||||
QGridLayout* form = new QGridLayout(this);
|
||||
|
||||
QCheckBox* b = new QCheckBox(this);
|
||||
setButtonProperties(b, showPointNumbers_);
|
||||
form->addWidget(b, 0, 0, Qt::AlignLeft);
|
||||
|
||||
connect(b, SIGNAL(toggled(bool)), this, SLOT(showPointNumbers(bool)));
|
||||
showPointNumbers_->SetImmediateUpdate(true);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
pqShowPointNumbersProperty::~pqShowPointNumbersProperty()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user