Commit 2cebe9ca authored by Henry Weller's avatar Henry Weller
Browse files

PVblockMeshReader: Added "Refresh" button to update the blockMesh

Reconstructs the blockMesh and updates the display from the current
blockMeshDict so that any changes can viewed without exiting
paraFoam -block
parent bd11543d
......@@ -106,10 +106,6 @@ public:
//- Construct from components
pqPVFoamReaderPanel(pqProxy*, QWidget*);
//- Destructor
// virtual ~pqPVFoamReaderPanel();
};
......
......@@ -43,6 +43,20 @@
</Documentation>
</IntVectorProperty>
<!-- Refresh button -->
<IntVectorProperty
name="UiRefresh"
command="SetRefresh"
number_of_elements="1"
is_internal="0"
default_values="0"
animateable="0">
<BooleanDomain name="bool"/>
<Documentation>
Rescan for updated blockMeshDict.
</Documentation>
</IntVectorProperty>
<!--
| Selections
......
......@@ -58,12 +58,30 @@ pqPVblockMeshReaderPanel::pqPVblockMeshReaderPanel
:
pqAutoGeneratedObjectPanel(proxy, p)
{
// create first sublayout (at top of the panel)
// Create first sublayout (at top of the panel)
QGridLayout *form = new QGridLayout();
this->PanelLayout->addLayout(form, 0, 0, 1, -1);
vtkSMProperty* prop = 0;
// checkbox for showing point numbers
// 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);
......@@ -97,7 +115,7 @@ void pqPVblockMeshReaderPanel::ShowPointNumbersToggled()
this->proxy()->GetProperty("UiShowPointNumbers")
)->SetElement(0, ShowPointNumbers_->isChecked());
// update the active view
// Update the active view
if (this->view())
{
this->view()->render();
......@@ -107,4 +125,19 @@ void pqPVblockMeshReaderPanel::ShowPointNumbersToggled()
}
void pqPVblockMeshReaderPanel::RefreshPressed()
{
// Update everything
vtkSMIntVectorProperty::SafeDownCast
(
this->proxy()->GetProperty("UiRefresh")
)->Modified();
vtkSMSourceProxy::SafeDownCast(this->proxy())->UpdatePipeline();
// Render all views
pqApplicationCore::instance()->render();
}
// ************************************************************************* //
......@@ -67,6 +67,7 @@ class pqPVblockMeshReaderPanel
protected slots:
void ShowPointNumbersToggled();
void RefreshPressed();
public:
......@@ -75,10 +76,6 @@ public:
//- Construct from components
pqPVblockMeshReaderPanel(pqProxy*, QWidget*);
//- Destructor
// virtual ~pqPVblockMeshReaderPanel();
};
......
......@@ -97,7 +97,7 @@ vtkPVblockMeshReader::~vtkPVblockMeshReader()
if (foamData_)
{
// remove point numbers
// Remove point numbers
updatePointNumbersView(false);
delete foamData_;
}
......@@ -117,7 +117,6 @@ vtkPVblockMeshReader::~vtkPVblockMeshReader()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
// Do everything except set the output info
int vtkPVblockMeshReader::RequestInformation
(
vtkInformation* vtkNotUsed(request),
......@@ -158,23 +157,10 @@ int vtkPVblockMeshReader::RequestInformation
foamData_->updateInfo();
}
// might need some other type of error handling
// {
// vtkErrorMacro("could not find valid OpenFOAM blockMesh");
//
// // delete foamData and flag it as fatal error
// delete foamData_;
// foamData_ = nullptr;
// return 0;
// }
return 1;
}
// Set the output info
int vtkPVblockMeshReader::RequestData
(
vtkInformation* vtkNotUsed(request),
......@@ -190,7 +176,7 @@ int vtkPVblockMeshReader::RequestData
return 0;
}
// catch previous error
// Catch previous error
if (!foamData_)
{
vtkErrorMacro("Reader failed - perhaps no mesh?");
......@@ -233,6 +219,18 @@ int vtkPVblockMeshReader::RequestData
}
void vtkPVblockMeshReader::SetRefresh(int val)
{
// Delete the current blockMesh to force re-read and update
if (foamData_)
{
delete foamData_;
foamData_ = 0;
}
Modified();
}
void vtkPVblockMeshReader::SetShowPointNumbers(const int val)
{
......@@ -248,7 +246,7 @@ void vtkPVblockMeshReader::updatePointNumbersView(const bool show)
{
pqApplicationCore* appCore = pqApplicationCore::instance();
// need to check this, since our destructor calls this
// Need to check this, since our destructor calls this
if (!appCore)
{
return;
......@@ -273,7 +271,7 @@ void vtkPVblockMeshReader::updatePointNumbersView(const bool show)
);
}
// use refresh here?
// Use refresh here?
}
......
......@@ -81,6 +81,9 @@ public:
vtkSetMacro(UpdateGUI, int);
vtkGetMacro(UpdateGUI, int);
// Description:
// Refresh blockMesh from changes to blockMeshDict
virtual void SetRefresh(int);
// Description:
// Blocks selection list control
......
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