ENH: update blockMesh reader for paraview 5.2 (issue #337)

- although this is not the final desired form, since it uses
  individual pqPropertyWidget customizations (ie, ugly layout, too
  many bits of code), but is an interesting intermediate solution
  that may be useful in other contexts.
This commit is contained in:
Mark Olesen 2017-01-04 10:48:13 +01:00
parent 801076f8d0
commit 71ea6bec62
15 changed files with 484 additions and 388 deletions

View File

@ -1,11 +1,4 @@
# create a plugin that adds a reader to the ParaView GUI
# it is added in the file dialog when doing opens/saves.
# The qrc file is processed by Qt's resource compiler (rcc)
# the qrc file must have a resource prefix of "/ParaViewResources"
# and ParaView will read anything contained under that prefix
# the pqReader.xml file contains xml defining readers with their
# file extensions and descriptions.
# Create a plugin to add a reader to the ParaView GUI
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
@ -25,7 +18,7 @@ INCLUDE_DIRECTORIES(
)
ADD_DEFINITIONS(
-std=c++0x
-std=c++11
-DWM_$ENV{WM_PRECISION_OPTION}
-DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
)
@ -37,44 +30,44 @@ SET(
"Single output directory for building all libraries."
)
#
# Define combined plugin
#
# Extend the auto-generated panel
QT4_WRAP_CPP(MOC_SRCS pqPVblockMeshReaderPanel.h)
ADD_PARAVIEW_OBJECT_PANEL(IFACES IFACE_SRCS
CLASS_NAME pqPVblockMeshReaderPanel
XML_NAME PVblockMeshReader # name of SourceProxy in *SM.xml
XML_GROUP sources
)
# Separate GUI_RESOURCE_FILES deprecated with paraview 4.3
# so check if version < 4.4
IF(("${PARAVIEW_VERSION_MAJOR}" LESS 5) AND ("${PARAVIEW_VERSION_MINOR}" LESS 4))
ADD_PARAVIEW_PLUGIN(
PVblockMeshReader_SM "1.0"
SERVER_MANAGER_XML PVblockMeshReader_SM.xml
SERVER_MANAGER_SOURCES vtkPVblockMeshReader.cxx
GUI_INTERFACES ${IFACES}
GUI_SOURCES pqPVblockMeshReaderPanel.cxx
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
GUI_RESOURCE_FILES PVblockMeshReader.xml
)
IF (PARAVIEW_QT_VERSION VERSION_GREATER "4")
QT5_WRAP_CPP(MOC_SRCS
pqRefreshProperty.h
pqShowPointNumbersProperty.h
)
ELSE()
ADD_PARAVIEW_PLUGIN(
PVblockMeshReader_SM "1.0"
SERVER_MANAGER_XML PVblockMeshReader_SM.xml
SERVER_MANAGER_SOURCES vtkPVblockMeshReader.cxx
GUI_INTERFACES ${IFACES}
GUI_SOURCES pqPVblockMeshReaderPanel.cxx
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
)
QT4_WRAP_CPP(MOC_SRCS
pqRefreshProperty.h
pqShowPointNumbersProperty.h
)
ENDIF()
# Build the client-side plugin
ADD_PARAVIEW_PROPERTY_WIDGET(IFACES0 IFACES0_SRCS
TYPE "openfoam_refresh_button"
CLASS_NAME pqRefreshProperty
)
ADD_PARAVIEW_PROPERTY_WIDGET(IFACES1 IFACES1_SRCS
TYPE "openfoam_show_point_numbers"
CLASS_NAME pqShowPointNumbersProperty
)
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
)
TARGET_LINK_LIBRARIES(
PVblockMeshReader_SM

View File

@ -1,5 +0,0 @@
<RCC>
<qresource prefix="/ParaViewResources" >
<file>PVblockMeshReader.xml</file>
</qresource>
</RCC>

View File

@ -1,7 +0,0 @@
<ParaViewReaders>
<!-- deprecated with paraview-4.3, use hints in *SM.xml -->
<Reader name="PVblockMeshReader"
extensions="blockMesh"
file_description="OpenFOAM blockMesh reader">
</Reader>
</ParaViewReaders>

View File

@ -5,45 +5,38 @@
class="vtkPVblockMeshReader">
<!-- File name - compulsory -->
<StringVectorProperty
<StringVectorProperty animateable="0"
name="FileName"
command="SetFileName"
number_of_elements="1"
animateable="0">
panel_visibility="never">
<FileListDomain name="files"/>
<Documentation>
Specifies the filename for the OpenFOAM blockMesh Reader.
</Documentation>
<Documentation>The filename for the OpenFOAM blockMesh reader.</Documentation>
</StringVectorProperty>
<!-- Show Point Numbers check-box -->
<IntVectorProperty
name="UiShowPointNumbers"
command="SetShowPointNumbers"
number_of_elements="1"
default_values="1"
is_internal="1"
animateable="0">
<BooleanDomain name="bool"/>
<Documentation>
Show point numbers in render window.
</Documentation>
</IntVectorProperty>
<!-- Refresh button -->
<IntVectorProperty
name="UiRefresh"
<!-- Refresh button (push button) -->
<IntVectorProperty animateable="0"
name="Refresh"
command="SetRefresh"
number_of_elements="1"
is_internal="0"
default_values="0"
animateable="0">
panel_widget="openfoam_refresh_button"
number_of_elements="1"
panel_visibility="default">
<BooleanDomain name="bool"/>
<Documentation>
Rescan for updated blockMeshDict.
</Documentation>
<Documentation>Rescan for updated blockMeshDict.</Documentation>
</IntVectorProperty>
<!-- Show Point Numbers (check-box) -->
<IntVectorProperty animateable="0"
name="ShowPointNumbers"
command="SetShowPointNumbers"
default_values="1"
panel_widget="openfoam_show_point_numbers"
number_of_elements="1"
panel_visibility="default">
<BooleanDomain name="bool"/>
<Documentation>Show point numbers in render window.</Documentation>
</IntVectorProperty>
<!--
| Selections
@ -55,7 +48,7 @@
information_only="1">
<ArraySelectionInformationHelper attribute_name="Block"/>
</StringVectorProperty>
<StringVectorProperty
<StringVectorProperty animateable="0"
name="BlockStatus"
label="Blocks"
command="SetBlockArrayStatus"
@ -63,16 +56,13 @@
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="BlockArrayStatus"
animateable="0">
information_property="BlockArrayStatus">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property name="BlockArrayStatus" function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
<Documentation>
This property contains a list of the blocks
</Documentation>
<Documentation>The list of blocks</Documentation>
</StringVectorProperty>
<!-- Available CurvedEdges array -->
@ -81,7 +71,7 @@
information_only="1">
<ArraySelectionInformationHelper attribute_name="CurvedEdges"/>
</StringVectorProperty>
<StringVectorProperty
<StringVectorProperty animateable="0"
name="CurvedEdgesStatus"
label="Curved Edges"
command="SetCurvedEdgesArrayStatus"
@ -89,26 +79,33 @@
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="CurvedEdgesArrayStatus"
animateable="0">
information_property="CurvedEdgesArrayStatus">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property name="CurvedEdgesArrayStatus" function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
<Documentation>
This property contains a list of the curved edges
</Documentation>
<Documentation>The list of curved edges</Documentation>
</StringVectorProperty>
<Hints>
<Property name="FileName" show="0"/>
<Property name="UiRefresh" show="0"/>
<Property name="UiShowPointNumbers" show="0"/>
<ReaderFactory extensions="blockMesh"
file_description="OpenFOAM blockMesh"/>
<ReaderFactory
extensions="blockMesh"
file_description="OpenFOAM blockMesh"/>
</Hints>
<PropertyGroup label="General Controls">
<Property name="Refresh"/>
<Property name="ShowPointNumbers"/>
</PropertyGroup>
<PropertyGroup label="Selections">
<Property name="BlockArrayStatus"/>
<Property name="BlockStatus"/>
<Property name="CurvedEdgesArrayStatus"/>
<Property name="CurvedEdgesStatus"/>
</PropertyGroup>
</SourceProxy>
</ProxyGroup>
</ServerManagerConfiguration>

View File

@ -1,143 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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 "pqPVblockMeshReaderPanel.h"
// QT
#include <QGridLayout>
#include <QCheckBox>
#include <QLabel>
#include <QLayout>
#include <QString>
#include <QPushButton>
#include <QtDebug>
// Paraview <-> QT UI
#include "pqAnimationScene.h"
#include "pqApplicationCore.h"
#include "pqPipelineRepresentation.h"
#include "pqServerManagerModel.h"
#include "pqView.h"
// Paraview Server Manager
#include "vtkSMDoubleVectorProperty.h"
#include "vtkSMIntVectorProperty.h"
#include "vtkSMProperty.h"
#include "vtkSMSourceProxy.h"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
pqPVblockMeshReaderPanel::pqPVblockMeshReaderPanel
(
pqProxy *proxy,
QWidget *p
)
:
pqAutoGeneratedObjectPanel(proxy, p)
{
// Create first sublayout (at top of the panel)
QGridLayout *form = new QGridLayout();
this->PanelLayout->addLayout(form, 0, 0, 1, -1);
vtkSMProperty* prop = 0;
// Refresh button for updating blocks
if ((prop = this->proxy()->GetProperty("UiRefresh")) != 0)
{
prop->SetImmediateUpdate(1);
QPushButton* refresh = new QPushButton("Refresh");
refresh->setToolTip("Rescan for updated blockMeshDict.");
form->addWidget(refresh, 0, 0, Qt::AlignLeft);
QObject::connect
(
refresh,
SIGNAL(clicked()),
this,
SLOT(RefreshPressed())
);
}
// Checkbox for showing point numbers
if ((prop = this->proxy()->GetProperty("UiShowPointNumbers")) != 0)
{
prop->SetImmediateUpdate(true);
ShowPointNumbers_ = new QCheckBox("Show Point Numbers");
ShowPointNumbers_->setToolTip("Show point numbers in render window.");
ShowPointNumbers_->setChecked
(
vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0)
);
form->addWidget(ShowPointNumbers_);
connect
(
ShowPointNumbers_,
SIGNAL(stateChanged(int)),
this,
SLOT(ShowPointNumbersToggled())
);
}
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void pqPVblockMeshReaderPanel::ShowPointNumbersToggled()
{
vtkSMIntVectorProperty::SafeDownCast
(
this->proxy()->GetProperty("UiShowPointNumbers")
)->SetElement(0, ShowPointNumbers_->isChecked());
// Update the active view
if (this->view())
{
this->view()->render();
}
// OR: update all views
// pqApplicationCore::instance()->render();
}
void pqPVblockMeshReaderPanel::RefreshPressed()
{
// Update everything
vtkSMIntVectorProperty::SafeDownCast
(
this->proxy()->GetProperty("UiRefresh")
)->Modified();
vtkSMSourceProxy::SafeDownCast(this->proxy())->UpdatePipeline();
// Render all views
pqApplicationCore::instance()->render();
}
// ************************************************************************* //

View File

@ -0,0 +1,120 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "pqRefreshProperty.h"
#include <QPushButton>
#include <QGridLayout>
#include "pqApplicationCore.h"
#include "pqView.h"
#include "vtkSMDocumentation.h"
#include "vtkSMIntVectorProperty.h"
#include "vtkSMSourceProxy.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 pqRefreshProperty::refreshPressed()
{
// Update everything
refresh_->Modified();
vtkSMSourceProxy::SafeDownCast(this->proxy())->UpdatePipeline();
// Render all views
pqApplicationCore::instance()->render();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
pqRefreshProperty::pqRefreshProperty
(
vtkSMProxy* proxy,
vtkSMProperty* prop,
QWidget* parent
)
:
Superclass(proxy, parent),
refresh_(vtkSMIntVectorProperty::SafeDownCast(prop))
{
// 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);
connect(b, SIGNAL(clicked()), this, SLOT(refreshPressed()));
refresh_->SetImmediateUpdate(true);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
pqRefreshProperty::~pqRefreshProperty()
{}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,60 +22,63 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
pqPVblockMeshReaderPanel
pqRefreshProperty
Description
GUI modifications for the ParaView reader panel
A custom panel for the PVblockMeshReader.
Custom refresh button (ParaView blockMesh reader)
SourceFiles
pqPVblockMeshReaderPanel.cxx
pqRefreshProperty.cxx
\*---------------------------------------------------------------------------*/
#ifndef pqPVblockMeshReaderPanel_h
#define pqPVblockMeshReaderPanel_h
#ifndef pqRefreshProperty_h
#define pqRefreshProperty_h
#include "pqAutoGeneratedObjectPanel.h"
#include "pqPropertyWidget.h"
// Forward declaration of QT classes
class QCheckBox;
class QLineEdit;
class QTimer;
class QToolButton;
// Forward declaration of ParaView classes
class vtkSMSourceProxy;
// Forward declarations (ParaView)
class vtkSMIntVectorProperty;
/*---------------------------------------------------------------------------*\
Class pqPVblockMeshReaderPanel Declaration
Class pqRefreshProperty Declaration
\*---------------------------------------------------------------------------*/
class pqPVblockMeshReaderPanel
class pqRefreshProperty
:
public pqAutoGeneratedObjectPanel
public pqPropertyWidget
{
// Private data
Q_OBJECT;
typedef pqAutoGeneratedObjectPanel Superclass;
typedef pqPropertyWidget Superclass;
// Private data
//- Refresh (bool property - as push button)
vtkSMIntVectorProperty* refresh_;
//- Show Point Numbers checkbox
QCheckBox* ShowPointNumbers_;
protected slots:
void ShowPointNumbersToggled();
void RefreshPressed();
// Protected Member Functions
//- Trigger refresh
void refreshPressed();
public:
// Constructors
//- Construct from components
pqRefreshProperty
(
vtkSMProxy* proxy,
vtkSMProperty* prop,
QWidget* parent = nullptr
);
//- Destructor
virtual ~pqRefreshProperty();
//- Construct from components
pqPVblockMeshReaderPanel(pqProxy*, QWidget*);
};

View File

@ -0,0 +1,122 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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()
{}
// ************************************************************************* //

View File

@ -0,0 +1,89 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
pqShowPointNumbersProperty
Description
Custom UI handling of show-points (ParaView blockMesh reader)
SourceFiles
pqShowPointNumbersProperty.cxx
\*---------------------------------------------------------------------------*/
#ifndef pqShowPointNumbersProperty_h
#define pqShowPointNumbersProperty_h
#include "pqPropertyWidget.h"
// Forward declarations (ParaView)
class vtkSMIntVectorProperty;
/*---------------------------------------------------------------------------*\
Class pqShowPointNumbersProperty Declaration
\*---------------------------------------------------------------------------*/
class pqShowPointNumbersProperty
:
public pqPropertyWidget
{
Q_OBJECT;
typedef pqPropertyWidget Superclass;
// Private data
//- Show Point Numbers (bool property)
vtkSMIntVectorProperty* showPointNumbers_;
protected slots:
// Protected Member Functions
//- Sync property with changed checkbox state, update rendered view(s)
void showPointNumbers(bool checked);
public:
//- Construct from components
pqShowPointNumbersProperty
(
vtkSMProxy* proxy,
vtkSMProperty* prop,
QWidget* parent = nullptr
);
//- Destructor
virtual ~pqShowPointNumbersProperty();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -59,7 +59,7 @@ vtkPVblockMeshReader::vtkPVblockMeshReader()
FileName = nullptr;
foamData_ = nullptr;
ShowPointNumbers = 1;
ShowPointNumbers = true;
BlockSelection = vtkDataArraySelection::New();
CurvedEdgesSelection = vtkDataArraySelection::New();
@ -92,7 +92,7 @@ vtkPVblockMeshReader::vtkPVblockMeshReader()
vtkPVblockMeshReader::~vtkPVblockMeshReader()
{
vtkDebugMacro(<<"Deconstructor");
vtkDebugMacro(<<"Destructor");
if (foamData_)
{
@ -106,8 +106,8 @@ vtkPVblockMeshReader::~vtkPVblockMeshReader()
delete [] FileName;
}
BlockSelection->RemoveObserver(this->SelectionObserver);
CurvedEdgesSelection->RemoveObserver(this->SelectionObserver);
BlockSelection->RemoveAllObservers();
CurvedEdgesSelection->RemoveAllObservers();
SelectionObserver->Delete();
BlockSelection->Delete();
@ -218,7 +218,7 @@ int vtkPVblockMeshReader::RequestData
}
void vtkPVblockMeshReader::SetRefresh(int val)
void vtkPVblockMeshReader::SetRefresh(bool val)
{
// Delete the current blockMesh to force re-read and update
if (foamData_)
@ -232,7 +232,7 @@ void vtkPVblockMeshReader::SetRefresh(int val)
}
void vtkPVblockMeshReader::SetShowPointNumbers(const int val)
void vtkPVblockMeshReader::SetShowPointNumbers(bool val)
{
if (ShowPointNumbers != val)
{

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -73,12 +73,12 @@ public:
// Description:
// Display corner point labels
virtual void SetShowPointNumbers(int);
vtkGetMacro(ShowPointNumbers, int);
virtual void SetShowPointNumbers(bool);
vtkGetMacro(ShowPointNumbers, bool);
// Description:
// Refresh blockMesh from changes to blockMeshDict
virtual void SetRefresh(int);
virtual void SetRefresh(bool);
// Description:
// Blocks selection list control
@ -144,25 +144,23 @@ protected:
private:
//- Disallow default bitwise copy construct
vtkPVblockMeshReader(const vtkPVblockMeshReader&);
vtkPVblockMeshReader(const vtkPVblockMeshReader&) = delete;
//- Disallow default bitwise assignment
void operator=(const vtkPVblockMeshReader&);
void operator=(const vtkPVblockMeshReader&) = delete;
//- Add/remove point numbers to/from the view
void updatePointNumbersView(const bool show);
//- Show Point Numbers
int ShowPointNumbers;
bool ShowPointNumbers;
vtkDataArraySelection* BlockSelection;
vtkDataArraySelection* CurvedEdgesSelection;
//BTX
Foam::vtkPVblockMesh* foamData_;
//ETX
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -63,13 +63,15 @@ void Foam::vtkPVblockMesh::updateInfoBlocks
vtkDataArraySelection* arraySelection
)
{
arrayRange& range = arrayRangeBlocks_;
if (debug)
{
Info<< "<beg> Foam::vtkPVblockMesh::updateInfoBlocks"
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]" << endl;
}
arrayRangeBlocks_.reset( arraySelection->GetNumberOfArrays() );
range.reset(arraySelection->GetNumberOfArrays());
const blockMesh& blkMesh = *meshPtr_;
@ -80,21 +82,20 @@ void Foam::vtkPVblockMesh::updateInfoBlocks
// Display either blockI as a number or with its name
// (looked up from blockMeshDict)
OStringStream os;
blockDescriptor::write(os, blockI, blkMesh.meshDict());
word partName(os.str());
OStringStream ostr;
blockDescriptor::write(ostr, blockI, blkMesh.meshDict());
// append the (optional) zone name
if (!blockDef.zoneName().empty())
{
partName += " - " + blockDef.zoneName();
ostr << " - " << blockDef.zoneName();
}
// Add blockId and zoneName to GUI list
arraySelection->AddArray(partName.c_str());
// Add "blockId" or "blockId - zoneName" to GUI list
arraySelection->AddArray(ostr.str().c_str());
}
arrayRangeBlocks_ += nBlocks;
range += nBlocks;
if (debug)
{
@ -111,18 +112,19 @@ void Foam::vtkPVblockMesh::updateInfoEdges
vtkDataArraySelection* arraySelection
)
{
arrayRange& range = arrayRangeEdges_;
if (debug)
{
Info<< "<beg> Foam::vtkPVblockMesh::updateInfoEdges"
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]" << endl;
}
arrayRangeEdges_.reset( arraySelection->GetNumberOfArrays() );
range.reset(arraySelection->GetNumberOfArrays());
const blockMesh& blkMesh = *meshPtr_;
const blockEdgeList& edges = blkMesh.edges();
const int nEdges = edges.size();
forAll(edges, edgeI)
{
OStringStream ostr;
@ -135,7 +137,7 @@ void Foam::vtkPVblockMesh::updateInfoEdges
arraySelection->AddArray(ostr.str().c_str());
}
arrayRangeEdges_ += nEdges;
range += edges.size();
if (debug)
{
@ -281,18 +283,14 @@ void Foam::vtkPVblockMesh::updateInfo()
resetCounters();
vtkDataArraySelection* blockSelection = reader_->GetBlockSelection();
vtkDataArraySelection* edgeSelection = reader_->GetCurvedEdgesSelection();
vtkDataArraySelection* edgeSelection = reader_->GetCurvedEdgesSelection();
// enable 'internalMesh' on the first call
// or preserve the enabled selections
stringList enabledParts;
stringList enabledEdges;
bool firstTime = false;
if (!blockSelection->GetNumberOfArrays() && !meshPtr_)
{
firstTime = true;
}
else
const bool firstTime = (!blockSelection->GetNumberOfArrays() && !meshPtr_);
if (!firstTime)
{
enabledParts = getSelectedArrayEntries(blockSelection);
enabledEdges = getSelectedArrayEntries(edgeSelection);
@ -306,10 +304,10 @@ void Foam::vtkPVblockMesh::updateInfo()
updateFoamMesh();
// Update mesh parts list
updateInfoBlocks( blockSelection );
updateInfoBlocks(blockSelection);
// Update curved edges list
updateInfoEdges( edgeSelection );
updateInfoEdges(edgeSelection);
// restore the enabled selections
if (!firstTime)

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -41,18 +41,11 @@ SourceFiles
#ifndef vtkPVblockMesh_H
#define vtkPVblockMesh_H
// do not include legacy strstream headers
#ifndef VTK_EXCLUDE_STRSTREAM_HEADERS
# define VTK_EXCLUDE_STRSTREAM_HEADERS
#endif
#include "className.H"
#include "fileName.H"
#include "stringList.H"
#include "wordList.H"
#include "primitivePatch.H"
// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
class vtkDataArraySelection;
@ -198,6 +191,7 @@ class vtkPVblockMesh
//- List of point numbers for rendering to window
List<vtkTextActor*> pointNumberTextActorsPtrs_;
// Private Member Functions
// Convenience method use to convert the readers from VTK 5
@ -211,23 +205,6 @@ class vtkPVblockMesh
const std::string& datasetName
);
// Convenience method use to convert the readers from VTK 5
// multiblock API to the current composite data infrastructure
static vtkDataSet* GetDataSetFromBlock
(
vtkMultiBlockDataSet* output,
const arrayRange&,
const label datasetNo
);
// Convenience method use to convert the readers from VTK 5
// multiblock API to the current composite data infrastructure
static label GetNumberOfDataSets
(
vtkMultiBlockDataSet* output,
const arrayRange&
);
//- Update boolList from GUI selection
static void updateBoolListStatus
(
@ -294,10 +271,10 @@ class vtkPVblockMesh
//- Disallow default bitwise copy construct
vtkPVblockMesh(const vtkPVblockMesh&);
vtkPVblockMesh(const vtkPVblockMesh&) = delete;
//- Disallow default bitwise assignment
void operator=(const vtkPVblockMesh&);
void operator=(const vtkPVblockMesh&) = delete;
public:

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -52,7 +52,7 @@ void Foam::vtkPVblockMesh::convertMeshBlocks
vtkDataArraySelection* selection = reader_->GetBlockSelection();
arrayRange& range = arrayRangeBlocks_;
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
label datasetNo = 0; // restart at dataset 0
const blockMesh& blkMesh = *meshPtr_;
const Foam::pointField& blockPoints = blkMesh.vertices();
@ -234,7 +234,6 @@ void Foam::vtkPVblockMesh::convertMeshEdges
}
}
// anything added?
if (datasetNo)
{
@ -286,7 +285,7 @@ void Foam::vtkPVblockMesh::convertMeshCorners
scaleFactor
);
vtkcells->InsertNextCell(1, &pointId);
vtkcells->InsertNextCell(1, &pointId); // VTK_VERTEX
pointId++;
}
@ -296,11 +295,7 @@ void Foam::vtkPVblockMesh::convertMeshCorners
vtkmesh->SetVerts(vtkcells);
vtkcells->Delete();
AddToBlock
(
output, vtkmesh, range, datasetNo,
arrayRangeCorners_.name()
);
AddToBlock(output, vtkmesh, range, datasetNo, range.name());
vtkmesh->Delete();
datasetNo++;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -126,47 +126,6 @@ void Foam::vtkPVblockMesh::AddToBlock
}
vtkDataSet* Foam::vtkPVblockMesh::GetDataSetFromBlock
(
vtkMultiBlockDataSet* output,
const arrayRange& range,
const label datasetNo
)
{
const int blockNo = range.block();
vtkDataObject* blockDO = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
if (block)
{
return vtkDataSet::SafeDownCast(block->GetBlock(datasetNo));
}
return 0;
}
// ununsed at the moment
Foam::label Foam::vtkPVblockMesh::GetNumberOfDataSets
(
vtkMultiBlockDataSet* output,
const arrayRange& range
)
{
const int blockNo = range.block();
vtkDataObject* blockDO = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
if (block)
{
return block->GetNumberOfBlocks();
}
return 0;
}
Foam::wordHashSet Foam::vtkPVblockMesh::getSelected
(
vtkDataArraySelection* select