diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/PVFoamReader_SM.xml b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/PVFoamReader_SM.xml index 82b3384a28c255fe3fdfcab40bec5a2c74ba849d..a82c81850fa35a282bd566069b67469b21018d01 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/PVFoamReader_SM.xml +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/PVFoamReader_SM.xml @@ -27,20 +27,17 @@ </Documentation> </DoubleVectorProperty> - <!-- Refresh button --> - <IntVectorProperty animateable="0" + <!-- Refresh (push button) --> + <Property name="Refresh" - command="SetRefresh" - default_values="0" - number_of_elements="1" + command="Refresh" panel_visibility="default"> - <BooleanDomain name="bool"/> - <Documentation> - Rescan for updated times/fields. - </Documentation> - </IntVectorProperty> + <Documentation>Rescan for updated times/fields.</Documentation> + </Property> + +<!-- General Controls --> - <!-- Skip Zero Time check-box --> + <!-- Skip Zero Time (check-box) --> <IntVectorProperty animateable="0" name="ZeroTime" label="Skip Zero Time" @@ -54,7 +51,7 @@ </Documentation> </IntVectorProperty> - <!-- Include Sets check-box --> + <!-- Include Sets (check-box) --> <IntVectorProperty animateable="0" name="IncludeSets" command="SetIncludeSets" @@ -67,7 +64,7 @@ </Documentation> </IntVectorProperty> - <!-- Include Zones check-box --> + <!-- Include Zones (check-box) --> <IntVectorProperty animateable="0" name="IncludeZones" command="SetIncludeZones" @@ -81,7 +78,7 @@ </Documentation> </IntVectorProperty> - <!-- Show Groups Only check-box --> + <!-- Show Groups Only (check-box) --> <IntVectorProperty animateable="0" name="ShowGroupsOnly" label="Groups Only" @@ -95,7 +92,7 @@ </Documentation> </IntVectorProperty> - <!-- Show Patch Names check-box --> + <!-- Show Patch Names (check-box) --> <IntVectorProperty animateable="0" name="ShowPatchNames" label="Patch Names" @@ -109,7 +106,7 @@ </Documentation> </IntVectorProperty> - <!-- Interpolate Fields check-box --> + <!-- Interpolate Fields (check-box) --> <IntVectorProperty animateable="0" name="InterpolateFields" command="SetInterpolateVolFields" @@ -122,7 +119,7 @@ </Documentation> </IntVectorProperty> - <!-- Extrapolate Patches check-box --> + <!-- Extrapolate Patches (check-box) --> <IntVectorProperty animateable="0" name="ExtrapolatePatches" command="SetExtrapolatePatches" @@ -135,7 +132,7 @@ </Documentation> </IntVectorProperty> - <!-- Force GUI update check box --> + <!-- Force GUI update (check-box) --> <IntVectorProperty animateable="0" name="UpdateGUI" command="SetUpdateGUI" @@ -148,7 +145,7 @@ </Documentation> </IntVectorProperty> - <!-- Use VTK Polyhedron check-box --> + <!-- Use VTK Polyhedron (check-box) --> <IntVectorProperty animateable="0" name="UseVTKPolyhedron" label="Use VTK Polyhedron" @@ -162,7 +159,7 @@ </Documentation> </IntVectorProperty> - <!-- Cache Mesh check-box --> + <!-- Cache Mesh (check-box) --> <IntVectorProperty animateable="0" name="CacheMesh" command="SetCacheMesh" @@ -175,9 +172,23 @@ </Documentation> </IntVectorProperty> - <!-- - | Selections - --> + <PropertyGroup + label="General Controls" + panel_widget="openfoam_reader_general_controls"> + <Property name="Refresh"/> + <Property name="ZeroTime"/> + <Property name="IncludeSets"/> + <Property name="IncludeZones"/> + <Property name="InterpolateFields"/> + <Property name="ExtrapolatePatches"/> + <Property name="ShowGroupsOnly"/> + <Property name="ShowPatchNames"/> + <Property name="UpdateGUI"/> + <Property name="UseVTKPolyhedron"/> + <Property name="CacheMesh"/> + </PropertyGroup> + +<!-- Parts Selections --> <!-- Available Parts (volume, patches, lagrangian) array --> <StringVectorProperty @@ -204,6 +215,13 @@ </Documentation> </StringVectorProperty> + <PropertyGroup label="Parts"> + <Property name="PartArrayStatus"/> + <Property name="PartStatus"/> + </PropertyGroup> + +<!-- Fields Selections --> + <!-- Available volFields array --> <StringVectorProperty name="VolFieldArrayStatus" @@ -273,6 +291,17 @@ <Documentation>The list of point fields.</Documentation> </StringVectorProperty> + <PropertyGroup label="Fields"> + <Property name="VolFieldArrayStatus"/> + <Property name="VolFieldStatus"/> + <Property name="LagrangianFieldArrayStatus"/> + <Property name="LagrangianFieldStatus"/> + <Property name="PointFieldArrayStatus"/> + <Property name="PointFieldStatus"/> + </PropertyGroup> + +<!-- Miscellaneous --> + <!-- Print button --> <Property animateable="0" name="PrintInfo" @@ -290,36 +319,6 @@ file_description="OpenFOAM reader module" /> </Hints> - <PropertyGroup - label="General Controls" - panel_widget="openfoam_reader_general_controls"> - <Property name="Refresh"/> - <Property name="ZeroTime"/> - <Property name="IncludeSets"/> - <Property name="IncludeZones"/> - <Property name="InterpolateFields"/> - <Property name="ExtrapolatePatches"/> - <Property name="ShowGroupsOnly"/> - <Property name="ShowPatchNames"/> - <Property name="UpdateGUI"/> - <Property name="UseVTKPolyhedron"/> - <Property name="CacheMesh"/> - </PropertyGroup> - - <PropertyGroup label="Parts"> - <Property name="PartArrayStatus"/> - <Property name="PartStatus"/> - </PropertyGroup> - - <PropertyGroup label="Fields"> - <Property name="VolFieldArrayStatus"/> - <Property name="VolFieldStatus"/> - <Property name="LagrangianFieldArrayStatus"/> - <Property name="LagrangianFieldStatus"/> - <Property name="PointFieldArrayStatus"/> - <Property name="PointFieldStatus"/> - </PropertyGroup> - </SourceProxy> </ProxyGroup> </ServerManagerConfiguration> diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/pqFoamReaderControls.cxx b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/pqFoamReaderControls.cxx index 95c3002d7438654b246400eb69fc68d2b161ac7c..3b6fe3da972e3c0e8d2b5607122c23a7ab5bacee 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/pqFoamReaderControls.cxx +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/pqFoamReaderControls.cxx @@ -30,7 +30,7 @@ License #include <QGridLayout> #include <QPushButton> -#include "pqApplicationCore.h" +#include "pqPVApplicationCore.h" #include "pqPipelineRepresentation.h" #include "pqView.h" #include "vtkSMDocumentation.h" @@ -45,8 +45,7 @@ License static QAbstractButton* setButtonProperties ( QAbstractButton* b, - vtkSMIntVectorProperty* prop, - bool initChecked = true + vtkSMProperty* prop ) { QString tip; @@ -68,10 +67,13 @@ static QAbstractButton* setButtonProperties } b->setFocusPolicy(Qt::NoFocus); // avoid dotted border - // initial checked state - if (initChecked) + vtkSMIntVectorProperty* intProp = + vtkSMIntVectorProperty::SafeDownCast(prop); + + // initial checked state for integer (bool) properties + if (intProp) { - b->setChecked(prop->GetElement(0)); + b->setChecked(intProp->GetElement(0)); } return b; @@ -97,19 +99,27 @@ static vtkSMIntVectorProperty* lookupIntProp // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void pqFoamReaderControls::updatePartsStatus() +void pqFoamReaderControls::fireCommand +( + vtkSMIntVectorProperty* prop, + bool checked +) { - vtkSMProperty* prop = this->proxy()->GetProperty("PartArrayStatus"); - if (prop) - { - this->proxy()->UpdatePropertyInformation(prop); - } + vtkSMProxy* pxy = this->proxy(); + + prop->SetElement(0, checked); // Toogle bool + + // Fire off command + prop->Modified(); + pxy->UpdateProperty(pxy->GetPropertyName(prop)); } -void pqFoamReaderControls::updatePartsStatus(bool) +void pqFoamReaderControls::updateParts() { - updatePartsStatus(); + vtkSMProxy* pxy = this->proxy(); + + pxy->UpdatePropertyInformation(pxy->GetProperty("PartArrayStatus")); } @@ -117,25 +127,28 @@ void pqFoamReaderControls::updatePartsStatus(bool) void pqFoamReaderControls::refreshPressed() { - // Update everything + vtkSMProxy* pxy = this->proxy(); + + // Fire off command refresh_->Modified(); + pxy->UpdateProperty(pxy->GetPropertyName(refresh_)); - vtkSMSourceProxy::SafeDownCast(this->proxy())->UpdatePipeline(); + vtkSMSourceProxy::SafeDownCast(pxy)->UpdatePipeline(); - // Update all views - pqApplicationCore::instance()->render(); + // Trigger a rendering (all views) + pqPVApplicationCore::instance()->render(); } void pqFoamReaderControls::cacheMesh(bool checked) { - cacheMesh_->SetElement(0, checked); + fireCommand(cacheMesh_, checked); } void pqFoamReaderControls::showPatchNames(bool checked) { - showPatchNames_->SetElement(0, checked); + fireCommand(showPatchNames_, checked); // update the active view if (this->view()) @@ -143,28 +156,28 @@ void pqFoamReaderControls::showPatchNames(bool checked) this->view()->render(); } // OR: update all views - // pqApplicationCore::instance()->render(); + // pqPVApplicationCore::instance()->render(); } void pqFoamReaderControls::showGroupsOnly(bool checked) { - showGroupsOnly_->SetElement(0, checked); - updatePartsStatus(); + fireCommand(showGroupsOnly_, checked); + updateParts(); } void pqFoamReaderControls::includeSets(bool checked) { - includeSets_->SetElement(0, checked); - updatePartsStatus(); + fireCommand(includeSets_, checked); + updateParts(); } void pqFoamReaderControls::includeZones(bool checked) { - includeZones_->SetElement(0, checked); - updatePartsStatus(); + fireCommand(includeZones_, checked); + updateParts(); } @@ -178,7 +191,7 @@ pqFoamReaderControls::pqFoamReaderControls ) : Superclass(proxy, parent), - refresh_(lookupIntProp(group, "Refresh")), + refresh_(group->GetProperty("Refresh")), showPatchNames_(lookupIntProp(group, "ShowPatchNames")), showGroupsOnly_(lookupIntProp(group, "ShowGroupsOnly")), includeSets_(lookupIntProp(group, "IncludeSets")), @@ -196,11 +209,10 @@ pqFoamReaderControls::pqFoamReaderControls if (refresh_) { QPushButton* b = new QPushButton(this); - setButtonProperties(b, refresh_, false); + setButtonProperties(b, refresh_); form->addWidget(b, row, 0, Qt::AlignLeft); connect(b, SIGNAL(clicked()), this, SLOT(refreshPressed())); - refresh_->SetImmediateUpdate(true); } intProp* zeroTime = lookupIntProp(group, "ZeroTime"); @@ -233,9 +245,7 @@ pqFoamReaderControls::pqFoamReaderControls form->addWidget(b, row, 0, Qt::AlignLeft); addPropertyLink(b, "checked", SIGNAL(toggled(bool)), includeSets_); - connect(b, SIGNAL(toggled(bool)), this, SLOT(includeSets(bool))); - includeSets_->SetImmediateUpdate(true); } if (showGroupsOnly_) @@ -245,9 +255,7 @@ pqFoamReaderControls::pqFoamReaderControls form->addWidget(b, row, 1, Qt::AlignLeft); addPropertyLink(b, "checked", SIGNAL(toggled(bool)), showGroupsOnly_); - connect(b, SIGNAL(toggled(bool)), this, SLOT(showGroupsOnly(bool))); - showGroupsOnly_->SetImmediateUpdate(true); } @@ -262,9 +270,7 @@ pqFoamReaderControls::pqFoamReaderControls form->addWidget(b, row, 0, Qt::AlignLeft); addPropertyLink(b, "checked", SIGNAL(toggled(bool)), includeZones_); - connect(b, SIGNAL(toggled(bool)), this, SLOT(includeZones(bool))); - includeZones_->SetImmediateUpdate(true); } if (showPatchNames_) @@ -274,7 +280,6 @@ pqFoamReaderControls::pqFoamReaderControls form->addWidget(b, row, 1, Qt::AlignLeft); connect(b, SIGNAL(toggled(bool)), this, SLOT(showPatchNames(bool))); - showPatchNames_->SetImmediateUpdate(true); } // LINE @@ -327,7 +332,7 @@ pqFoamReaderControls::pqFoamReaderControls if (updateGui) { QPushButton* b = new QPushButton(this); - setButtonProperties(b, updateGui, false); + setButtonProperties(b, updateGui); form->addWidget(b, row, 0, Qt::AlignLeft); addPropertyLink(b, "checked", SIGNAL(clicked()), updateGui); @@ -350,7 +355,6 @@ pqFoamReaderControls::pqFoamReaderControls form->addWidget(b, row, 2, Qt::AlignLeft); connect(b, SIGNAL(toggled(bool)), this, SLOT(cacheMesh(bool))); - cacheMesh_->SetImmediateUpdate(true); } } diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/pqFoamReaderControls.h b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/pqFoamReaderControls.h index dd958f5e8cb118b611a27a3e436c90fd3c6245ec..fc3c8d4044b7eca2ba4cb6ffccf73f6dc5624d64 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/pqFoamReaderControls.h +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/pqFoamReaderControls.h @@ -37,6 +37,7 @@ SourceFiles #include "pqPropertyWidget.h" // Forward declarations +class vtkSMProperty; class vtkSMIntVectorProperty; @@ -53,8 +54,8 @@ class pqFoamReaderControls // Private data - //- Refresh (bool property - as push button) - vtkSMIntVectorProperty* refresh_; + //- Refresh (push button) + vtkSMProperty* refresh_; //- Show Patch Names (bool property) vtkSMIntVectorProperty* showPatchNames_; @@ -72,15 +73,28 @@ class pqFoamReaderControls vtkSMIntVectorProperty* cacheMesh_; + // Private Member Functions + + //- Update property + void fireCommand(vtkSMProperty* prop); + + //- Toggle and update bool property + void fireCommand(vtkSMIntVectorProperty* prop, bool checked); + + + //- Disallow default bitwise copy construct + pqFoamReaderControls(const pqFoamReaderControls&) = delete; + + //- Disallow default bitwise assignment + void operator=(const pqFoamReaderControls&) = delete; + + private slots: // Private Member Functions //- Update "PartArrayStatus" property information - void updatePartsStatus(); - - //- Update "PartArrayStatus" property information - void updatePartsStatus(bool unused); + void updateParts(); protected slots: diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/vtkPVFoamReader.cxx b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/vtkPVFoamReader.cxx index ecfffe09e2e63325c01ae21f35d4a7b8427e9a91..46c01d92f7dfb5bff0a28e31fb9dd764374eda30 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/vtkPVFoamReader.cxx +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/vtkPVFoamReader.cxx @@ -80,7 +80,6 @@ vtkPVFoamReader::vtkPVFoamReader() TimeStepRange[1] = 0; CacheMesh = true; - Refresh = false; SkipZeroTime = false; ExtrapolatePatches = false; @@ -138,9 +137,11 @@ vtkPVFoamReader::~vtkPVFoamReader() if (backend_) { - // remove patch names + // Remove text actors updatePatchNamesView(false); + delete backend_; + backend_ = nullptr; } if (FileName) @@ -202,13 +203,13 @@ int vtkPVFoamReader::RequestInformation } } - if (!backend_) + if (backend_) { - backend_ = new Foam::vtkPVFoam(FileName, this); + backend_->updateInfo(); } else { - backend_->updateInfo(); + backend_ = new Foam::vtkPVFoam(FileName, this); } std::vector<double> times = backend_->findTimes(this->SkipZeroTime); @@ -450,7 +451,7 @@ void vtkPVFoamReader::PrintInfo() } -void vtkPVFoamReader::SetRefresh(bool val) +void vtkPVFoamReader::Refresh() { Modified(); } diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/vtkPVFoamReader.h b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/vtkPVFoamReader.h index 28a68445cd667a1d8f2676659feb767e26ca8860..c634f667fbed06eef77307d64b11170c2f5a73ef 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/vtkPVFoamReader.h +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/vtkPVFoamReader.h @@ -88,7 +88,7 @@ public: // Description: // OpenFOAM refresh times/fields - virtual void SetRefresh(bool); + virtual void Refresh(); // Description: // OpenFOAM skip/include the 0/ time directory @@ -231,7 +231,6 @@ private: void updatePatchNamesView(const bool show); int TimeStepRange[2]; - bool Refresh; bool CacheMesh; bool SkipZeroTime; diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/vtkPVFoam.C b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/vtkPVFoam.C index 9ec5d92e71ea27e51db8d479092da1dbef577eb1..2b7ab51888cf65e035a4f71c7450c9c4328119e6 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/vtkPVFoam.C +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/vtkPVFoam.C @@ -45,6 +45,35 @@ namespace Foam defineTypeNameAndDebug(vtkPVFoam, 0); } + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +vtkTextActor* Foam::vtkPVFoam::createTextActor +( + const string& s, + const point& pt +) +{ + vtkTextActor* txt = vtkTextActor::New(); + txt->SetInput(s.c_str()); + + // Set text properties + vtkTextProperty* tprop = txt->GetTextProperty(); + tprop->SetFontFamilyToArial(); + tprop->BoldOn(); + tprop->ShadowOff(); + tprop->SetLineSpacing(1.0); + tprop->SetFontSize(14); + tprop->SetColor(1.0, 0.0, 1.0); + tprop->SetJustificationToCentered(); + + txt->GetPositionCoordinate()->SetCoordinateSystemToWorld(); + txt->GetPositionCoordinate()->SetValue(pt.x(), pt.y(), pt.z()); + + return txt; +} + + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::vtkPVFoam::resetCounters() @@ -606,11 +635,6 @@ void Foam::vtkPVFoam::renderPatchNames const bool show ) { - if (!meshPtr_) - { - return; - } - // always remove old actors first forAll(patchTextActorsPtrs_, patchi) @@ -620,7 +644,7 @@ void Foam::vtkPVFoam::renderPatchNames } patchTextActorsPtrs_.clear(); - if (show) + if (show && meshPtr_) { // get the display patches, strip off any suffix hashedWordList selectedPatches = getSelected @@ -737,17 +761,16 @@ void Foam::vtkPVFoam::renderPatchNames { const polyPatch& pp = pbMesh[patchi]; - label globalZoneI = 0; - // Only selected patches will have a non-zero number of zones - label nDisplayZones = min(MAXPATCHZONES, nZones[patchi]); + const label nDisplayZones = min(MAXPATCHZONES, nZones[patchi]); label increment = 1; if (nZones[patchi] >= MAXPATCHZONES) { increment = nZones[patchi]/MAXPATCHZONES; } - for (label i = 0; i < nDisplayZones; i++) + label globalZoneI = 0; + for (label i = 0; i < nDisplayZones; ++i, globalZoneI += increment) { if (debug) { @@ -756,45 +779,24 @@ void Foam::vtkPVFoam::renderPatchNames << "globalZoneI = " << globalZoneI << endl; } - vtkTextActor* txt = vtkTextActor::New(); - - txt->SetInput(pp.name().c_str()); - - // Set text properties - vtkTextProperty* tprop = txt->GetTextProperty(); - tprop->SetFontFamilyToArial(); - tprop->BoldOff(); - tprop->ShadowOff(); - tprop->SetLineSpacing(1.0); - tprop->SetFontSize(14); - tprop->SetColor(1.0, 0.0, 1.0); - tprop->SetJustificationToCentered(); - - // Set text to use 3-D world co-ordinates - txt->GetPositionCoordinate()->SetCoordinateSystemToWorld(); - - txt->GetPositionCoordinate()->SetValue + // Into a list for later removal + patchTextActorsPtrs_[displayZoneI++] = createTextActor ( - zoneCentre[patchi][globalZoneI].x(), - zoneCentre[patchi][globalZoneI].y(), - zoneCentre[patchi][globalZoneI].z() + pp.name(), + zoneCentre[patchi][globalZoneI] ); - - // Add text to each renderer - renderer->AddViewProp(txt); - - // Maintain a list of text labels added so that they can be - // removed later - patchTextActorsPtrs_[displayZoneI] = txt; - - globalZoneI += increment; - displayZoneI++; } } // Resize the patch names list to the actual number of patch names added patchTextActorsPtrs_.setSize(displayZoneI); } + + // Add text to each renderer + forAll(patchTextActorsPtrs_, actori) + { + renderer->AddViewProp(patchTextActorsPtrs_[actori]); + } } diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/vtkPVFoam.H b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/vtkPVFoam.H index 17322e44c7a0a9f1930f8c687f04fd02d7b2336a..3f0a1ad55d700ca1d6df81dbb4bac32e427bbe52 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/vtkPVFoam.H +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/vtkPVFoam.H @@ -223,6 +223,9 @@ class vtkPVFoam // Private Member Functions + //- Create a text actor + static vtkTextActor* createTextActor(const string& s, const point& pt); + //- Reset data counters void resetCounters(); diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/PVblockMeshReader_SM.xml b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/PVblockMeshReader_SM.xml index e782c4371f556afaeebdb5f35ccc14e086dff3a7..e0110552eec69b4fba45e2129e9efd47010f4535 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/PVblockMeshReader_SM.xml +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/PVblockMeshReader_SM.xml @@ -14,20 +14,32 @@ <Documentation>The filename for the OpenFOAM blockMesh reader.</Documentation> </StringVectorProperty> - <!-- Refresh button (push button) --> - <IntVectorProperty animateable="0" + <!-- Refresh (push button) --> + <Property name="Refresh" - command="SetRefresh" + command="Refresh" + panel_visibility="default"> + <Documentation>Rescan for updated blockMeshDict.</Documentation> + </Property> + +<!-- General Controls --> + + <!-- Show Patch Names (check-box) --> + <IntVectorProperty animateable="0" + name="ShowPatchNames" + label="Patch Names" + command="SetShowPatchNames" default_values="0" number_of_elements="1" panel_visibility="default"> <BooleanDomain name="bool"/> - <Documentation>Rescan for updated blockMeshDict.</Documentation> + <Documentation>Show patch names in render window.</Documentation> </IntVectorProperty> <!-- Show Point Numbers (check-box) --> <IntVectorProperty animateable="0" name="ShowPointNumbers" + label="Point Numbers" command="SetShowPointNumbers" default_values="1" number_of_elements="1" @@ -36,9 +48,15 @@ <Documentation>Show point numbers in render window.</Documentation> </IntVectorProperty> - <!-- - | Selections - --> + <PropertyGroup + label="General Controls" + panel_widget="openfoam_blockMesh_general_controls"> + <Property name="Refresh"/> + <Property name="ShowPatchNames"/> + <Property name="ShowPointNumbers"/> + </PropertyGroup> + +<!-- Selections --> <!-- Available Blocks array --> <StringVectorProperty @@ -86,19 +104,6 @@ <Documentation>The list of curved edges</Documentation> </StringVectorProperty> - <Hints> - <ReaderFactory - extensions="blockMesh" - file_description="OpenFOAM blockMesh"/> - </Hints> - - <PropertyGroup - label="General Controls" - panel_widget="openfoam_blockMesh_general_controls"> - <Property name="Refresh"/> - <Property name="ShowPointNumbers"/> - </PropertyGroup> - <PropertyGroup label="Selections"> <Property name="BlockArrayStatus"/> <Property name="BlockStatus"/> @@ -106,6 +111,12 @@ <Property name="CurvedEdgesStatus"/> </PropertyGroup> + <Hints> + <ReaderFactory + extensions="blockMesh" + file_description="OpenFOAM blockMesh"/> + </Hints> + </SourceProxy> </ProxyGroup> </ServerManagerConfiguration> diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/pqFoamBlockMeshControls.cxx b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/pqFoamBlockMeshControls.cxx index 911ad839884434af2fc7bb90e2c8d0d526664608..ab4a6517066433378fa09cf288e8f54d28b683df 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/pqFoamBlockMeshControls.cxx +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/pqFoamBlockMeshControls.cxx @@ -29,7 +29,7 @@ License #include <QGridLayout> #include <QPushButton> -#include "pqApplicationCore.h" +#include "pqPVApplicationCore.h" #include "pqView.h" #include "vtkSMDocumentation.h" #include "vtkSMIntVectorProperty.h" @@ -43,8 +43,7 @@ License static QAbstractButton* setButtonProperties ( QAbstractButton* b, - vtkSMIntVectorProperty* prop, - bool initChecked = true + vtkSMProperty* prop ) { QString tip; @@ -66,10 +65,14 @@ static QAbstractButton* setButtonProperties } b->setFocusPolicy(Qt::NoFocus); // avoid dotted border - // initial checked state - if (initChecked) + + vtkSMIntVectorProperty* intProp = + vtkSMIntVectorProperty::SafeDownCast(prop); + + // initial checked state for integer (bool) properties + if (intProp) { - b->setChecked(prop->GetElement(0)); + b->setChecked(intProp->GetElement(0)); } return b; @@ -93,23 +96,76 @@ static vtkSMIntVectorProperty* lookupIntProp } +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void pqFoamBlockMeshControls::fireCommand(vtkSMProperty* prop) +{ + vtkSMProxy* pxy = this->proxy(); + + // Fire off command + prop->Modified(); + pxy->UpdateProperty(pxy->GetPropertyName(prop)); +} + + +void pqFoamBlockMeshControls::fireCommand +( + vtkSMIntVectorProperty* prop, + bool checked +) +{ + vtkSMProxy* pxy = this->proxy(); + + prop->SetElement(0, checked); // Toogle bool + + // Fire off command + prop->Modified(); + pxy->UpdateProperty(pxy->GetPropertyName(prop)); +} + + +void pqFoamBlockMeshControls::updateParts() +{ + vtkSMProxy* pxy = this->proxy(); + + pxy->UpdatePropertyInformation(pxy->GetProperty("BlockArrayStatus")); + pxy->UpdatePropertyInformation(pxy->GetProperty("CurvedEdgesArrayStatus")); +} + + // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // void pqFoamBlockMeshControls::refreshPressed() { - // Update everything - refresh_->Modified(); + fireCommand(refresh_); vtkSMSourceProxy::SafeDownCast(this->proxy())->UpdatePipeline(); - // Render all views - pqApplicationCore::instance()->render(); + // Trigger a rendering (all views) + pqPVApplicationCore::instance()->render(); + + updateParts(); +} + + +void pqFoamBlockMeshControls::showPatchNames(bool checked) +{ + fireCommand(showPatchNames_, checked); + + // Update the active view + if (this->view()) + { + this->view()->render(); + } + + // OR: update all views + // pqPVApplicationCore::instance()->render(); } void pqFoamBlockMeshControls::showPointNumbers(bool checked) { - showPointNumbers_->SetElement(0, checked); + fireCommand(showPointNumbers_, checked); // Update the active view if (this->view()) @@ -118,7 +174,7 @@ void pqFoamBlockMeshControls::showPointNumbers(bool checked) } // OR: update all views - // pqApplicationCore::instance()->render(); + // pqPVApplicationCore::instance()->render(); } @@ -132,7 +188,8 @@ pqFoamBlockMeshControls::pqFoamBlockMeshControls ) : Superclass(proxy, parent), - refresh_(lookupIntProp(group, "Refresh")), + refresh_(group->GetProperty("Refresh")), + showPatchNames_(lookupIntProp(group, "ShowPatchNames")), showPointNumbers_(lookupIntProp(group, "ShowPointNumbers")) { QGridLayout* form = new QGridLayout(this); @@ -140,21 +197,28 @@ pqFoamBlockMeshControls::pqFoamBlockMeshControls if (refresh_) { QPushButton* b = new QPushButton(this); - setButtonProperties(b, refresh_, false); + setButtonProperties(b, refresh_); form->addWidget(b, 0, 0, Qt::AlignLeft); connect(b, SIGNAL(clicked()), this, SLOT(refreshPressed())); - refresh_->SetImmediateUpdate(true); + } + + if (showPatchNames_) + { + QCheckBox* b = new QCheckBox(this); + setButtonProperties(b, showPatchNames_); + form->addWidget(b, 0, 1, Qt::AlignLeft); + + connect(b, SIGNAL(toggled(bool)), this, SLOT(showPatchNames(bool))); } if (showPointNumbers_) { QCheckBox* b = new QCheckBox(this); setButtonProperties(b, showPointNumbers_); - form->addWidget(b, 0, 1, Qt::AlignLeft); + form->addWidget(b, 0, 2, Qt::AlignLeft); connect(b, SIGNAL(toggled(bool)), this, SLOT(showPointNumbers(bool))); - showPointNumbers_->SetImmediateUpdate(true); } } diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/pqFoamBlockMeshControls.h b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/pqFoamBlockMeshControls.h index 0ec7150d5c31b6a8d6e153e1a9a9cf9d1ea6e320..a46cdc30528cdfdfa4fd47b1453a065d31be4467 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/pqFoamBlockMeshControls.h +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/pqFoamBlockMeshControls.h @@ -27,7 +27,7 @@ Class Description Customized property controls for the ParaView blockMesh reader. - Refresh and ShowPointNumbers. + Refresh, ShowPatchNames, ShowPointNumbers. SourceFiles pqFoamBlockMeshControls.cxx @@ -39,6 +39,7 @@ SourceFiles #include "pqPropertyWidget.h" // Forward declarations (ParaView) +class vtkSMProperty; class vtkSMIntVectorProperty; @@ -55,8 +56,11 @@ class pqFoamBlockMeshControls // Private data - //- Refresh (bool property - as push button) - vtkSMIntVectorProperty* refresh_; + //- Refresh (push button) + vtkSMProperty* refresh_; + + //- Show Patch Names (bool property) + vtkSMIntVectorProperty* showPatchNames_; //- Show Point Numbers (bool property) vtkSMIntVectorProperty* showPointNumbers_; @@ -64,6 +68,16 @@ class pqFoamBlockMeshControls // Private Member Functions + //- Update property + void fireCommand(vtkSMProperty* prop); + + //- Toggle and update bool property + void fireCommand(vtkSMIntVectorProperty* prop, bool checked); + + //- Update "BlockArrayStatus", "CurvedEdgesArrayStatus" information + void updateParts(); + + //- Disallow default bitwise copy construct pqFoamBlockMeshControls(const pqFoamBlockMeshControls&) = delete; @@ -78,6 +92,9 @@ protected slots: //- Trigger refresh void refreshPressed(); + //- Sync property with changed checkbox state, update rendered view(s) + void showPatchNames(bool checked); + //- Sync property with changed checkbox state, update rendered view(s) void showPointNumbers(bool checked); diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/vtkPVblockMeshReader.cxx b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/vtkPVblockMeshReader.cxx index 51f2fd806195853d110f23d4e2a1b561966d44ac..2c8c1ce453d2ca3c3a763cfcbe7af46d9904782f 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/vtkPVblockMeshReader.cxx +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/vtkPVblockMeshReader.cxx @@ -59,6 +59,7 @@ vtkPVblockMeshReader::vtkPVblockMeshReader() FileName = nullptr; backend_ = nullptr; + ShowPatchNames = false; ShowPointNumbers = true; BlockSelection = vtkDataArraySelection::New(); @@ -95,9 +96,12 @@ vtkPVblockMeshReader::~vtkPVblockMeshReader() if (backend_) { - // Remove point numbers + // Remove text actors + updatePatchNamesView(false); updatePointNumbersView(false); + delete backend_; + backend_ = nullptr; } if (FileName) @@ -110,6 +114,7 @@ vtkPVblockMeshReader::~vtkPVblockMeshReader() SelectionObserver->Delete(); BlockSelection->Delete(); + CurvedEdgesSelection->Delete(); } @@ -124,35 +129,25 @@ int vtkPVblockMeshReader::RequestInformation { vtkDebugMacro(<<"RequestInformation"); - if (Foam::vtkPVblockMesh::debug) - { - cout<<"REQUEST_INFORMATION\n"; - } - if (!FileName) { vtkErrorMacro("FileName has to be specified!"); return 0; } - int nInfo = outputVector->GetNumberOfInformationObjects(); - if (Foam::vtkPVblockMesh::debug) { - cout<<"RequestInformation with " << nInfo << " item(s)\n"; - for (int infoI = 0; infoI < nInfo; ++infoI) - { - outputVector->GetInformationObject(infoI)->Print(cout); - } + cout<<"REQUEST_INFORMATION\n"; + outputVector->GetInformationObject(0)->Print(cout); } - if (!backend_) + if (backend_) { - backend_ = new Foam::vtkPVblockMesh(FileName, this); + backend_->updateInfo(); } else { - backend_->updateInfo(); + backend_ = new Foam::vtkPVblockMesh(FileName, this); } return 1; @@ -181,15 +176,10 @@ int vtkPVblockMeshReader::RequestData return 0; } - int nInfo = outputVector->GetNumberOfInformationObjects(); - if (Foam::vtkPVblockMesh::debug) { - cout<<"RequestData with " << nInfo << " item(s)\n"; - for (int infoI = 0; infoI < nInfo; ++infoI) - { - outputVector->GetInformationObject(infoI)->Print(cout); - } + cout<<"REQUEST_DATA:\n"; + outputVector->GetInformationObject(0)->Print(cout); } vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast @@ -207,6 +197,8 @@ int vtkPVblockMeshReader::RequestData } backend_->Update(output); + + updatePatchNamesView(ShowPatchNames); updatePointNumbersView(ShowPointNumbers); // Do any cleanup on the OpenFOAM side @@ -216,17 +208,30 @@ int vtkPVblockMeshReader::RequestData } -void vtkPVblockMeshReader::SetRefresh(bool val) +void vtkPVblockMeshReader::Refresh() { // Delete the current blockMesh to force re-read and update if (backend_) { + // Remove text actors + updatePatchNamesView(false); updatePointNumbersView(false); + delete backend_; backend_ = nullptr; } - Modified(); + this->Modified(); +} + + +void vtkPVblockMeshReader::SetShowPatchNames(bool val) +{ + if (ShowPatchNames != val) + { + ShowPatchNames = val; + updatePatchNamesView(ShowPatchNames); + } } @@ -240,7 +245,7 @@ void vtkPVblockMeshReader::SetShowPointNumbers(bool val) } -void vtkPVblockMeshReader::updatePointNumbersView(const bool show) +void vtkPVblockMeshReader::updatePatchNamesView(const bool show) { pqApplicationCore* appCore = pqApplicationCore::instance(); @@ -257,6 +262,37 @@ void vtkPVblockMeshReader::updatePointNumbersView(const bool show) return; } + // Get all the pqRenderView instances + QList<pqRenderView*> renderViews = smModel->findItems<pqRenderView*>(); + for (int viewI=0; viewI<renderViews.size(); ++viewI) + { + backend_->renderPatchNames + ( + renderViews[viewI]->getRenderViewProxy()->GetRenderer(), + show + ); + } + + // Use refresh here? +} + + +void vtkPVblockMeshReader::updatePointNumbersView(const bool show) +{ + pqApplicationCore* appCore = pqApplicationCore::instance(); + + // Need to check this, since our destructor calls this + if (!appCore) + { + return; + } + + // Server manager model for querying items in the server manager + pqServerManagerModel* smModel = appCore->getServerManagerModel(); + if (!smModel || !backend_) + { + return; + } // Get all the pqRenderView instances QList<pqRenderView*> renderViews = smModel->findItems<pqRenderView*>(); @@ -290,39 +326,30 @@ void vtkPVblockMeshReader::PrintSelf(ostream& os, vtkIndent indent) vtkDataArraySelection* vtkPVblockMeshReader::GetBlockSelection() { - vtkDebugMacro(<<"GetBlockSelection"); return BlockSelection; } - int vtkPVblockMeshReader::GetNumberOfBlockArrays() { - vtkDebugMacro(<<"GetNumberOfBlockArrays"); return BlockSelection->GetNumberOfArrays(); } - const char* vtkPVblockMeshReader::GetBlockArrayName(int index) { - vtkDebugMacro(<<"GetBlockArrayName"); return BlockSelection->GetArrayName(index); } - int vtkPVblockMeshReader::GetBlockArrayStatus(const char* name) { - vtkDebugMacro(<<"GetBlockArrayStatus"); return BlockSelection->ArrayIsEnabled(name); } - void vtkPVblockMeshReader::SetBlockArrayStatus ( const char* name, int status ) { - vtkDebugMacro(<<"SetBlockArrayStatus"); if (status) { BlockSelection->EnableArray(name); @@ -339,39 +366,30 @@ void vtkPVblockMeshReader::SetBlockArrayStatus vtkDataArraySelection* vtkPVblockMeshReader::GetCurvedEdgesSelection() { - vtkDebugMacro(<<"GetCurvedEdgesSelection"); return CurvedEdgesSelection; } - int vtkPVblockMeshReader::GetNumberOfCurvedEdgesArrays() { - vtkDebugMacro(<<"GetNumberOfCurvedEdgesArrays"); return CurvedEdgesSelection->GetNumberOfArrays(); } - const char* vtkPVblockMeshReader::GetCurvedEdgesArrayName(int index) { - vtkDebugMacro(<<"GetCurvedEdgesArrayName"); return CurvedEdgesSelection->GetArrayName(index); } - int vtkPVblockMeshReader::GetCurvedEdgesArrayStatus(const char* name) { - vtkDebugMacro(<<"GetCurvedEdgesArrayStatus"); return CurvedEdgesSelection->ArrayIsEnabled(name); } - void vtkPVblockMeshReader::SetCurvedEdgesArrayStatus ( const char* name, int status ) { - vtkDebugMacro(<<"SetCurvedEdgesArrayStatus"); if (status) { CurvedEdgesSelection->EnableArray(name); diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/vtkPVblockMeshReader.h b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/vtkPVblockMeshReader.h index 1cb24d7baf8d639605f42bc0aea745e53b54f36a..66805716eec674fac90a804ea2e7887f93149732 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/vtkPVblockMeshReader.h +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/vtkPVblockMeshReader.h @@ -71,6 +71,11 @@ public: vtkSetStringMacro(FileName); vtkGetStringMacro(FileName); + // Description: + // Display patch names + virtual void SetShowPatchNames(bool); + vtkGetMacro(ShowPatchNames, bool); + // Description: // Display corner point labels virtual void SetShowPointNumbers(bool); @@ -78,22 +83,22 @@ public: // Description: // Refresh blockMesh from changes to blockMeshDict - virtual void SetRefresh(bool); + virtual void Refresh(); // Description: // Blocks selection list control vtkDataArraySelection* GetBlockSelection(); int GetNumberOfBlockArrays(); - int GetBlockArrayStatus(const char*); - void SetBlockArrayStatus(const char*, int status); + int GetBlockArrayStatus(const char* name); + void SetBlockArrayStatus(const char* name, int status); const char* GetBlockArrayName(int index); // Description: // CurvedEdges selection list control vtkDataArraySelection* GetCurvedEdgesSelection(); int GetNumberOfCurvedEdgesArrays(); - int GetCurvedEdgesArrayStatus(const char*); - void SetCurvedEdgesArrayStatus(const char*, int status); + int GetCurvedEdgesArrayStatus(const char* name); + void SetCurvedEdgesArrayStatus(const char* name, int status); const char* GetCurvedEdgesArrayName(int index); // Description: @@ -119,17 +124,17 @@ protected: //- Return information about mesh, times, etc without loading anything virtual int RequestInformation ( - vtkInformation*, - vtkInformationVector**, - vtkInformationVector* + vtkInformation* unusedRequest, + vtkInformationVector** unusedInputVector, + vtkInformationVector* outputVector ); - //- Get the mesh/fields for a particular time + //- Get the mesh for a particular time virtual int RequestData ( - vtkInformation*, - vtkInformationVector**, - vtkInformationVector* + vtkInformation* unusedRequest, + vtkInformationVector** unusedInputVector, + vtkInformationVector* outputVector ); //- Fill in additional port information @@ -149,15 +154,20 @@ private: //- Disallow default bitwise assignment void operator=(const vtkPVblockMeshReader&) = delete; + //- Add/remove patch names to/from the view + void updatePatchNamesView(const bool show); + //- Add/remove point numbers to/from the view void updatePointNumbersView(const bool show); + //- Show Patch Names + bool ShowPatchNames; + //- Show Point Numbers bool ShowPointNumbers; vtkDataArraySelection* BlockSelection; - vtkDataArraySelection* CurvedEdgesSelection; //- Backend portion of the reader diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtkPVblockMesh/vtkPVblockMesh.C b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtkPVblockMesh/vtkPVblockMesh.C index 4dee4f8953b72e3734925fc108c0e176d8c4e149..e64f031dec7ac2e5d126f93c8e2403f1db7f6520 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtkPVblockMesh/vtkPVblockMesh.C +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtkPVblockMesh/vtkPVblockMesh.C @@ -28,6 +28,7 @@ License // OpenFOAM includes #include "blockMesh.H" +#include "blockMeshTools.H" #include "Time.H" #include "patchZones.H" #include "OStringStream.H" @@ -47,6 +48,34 @@ namespace Foam } +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +vtkTextActor* Foam::vtkPVblockMesh::createTextActor +( + const string& s, + const point& pt +) +{ + vtkTextActor* txt = vtkTextActor::New(); + txt->SetInput(s.c_str()); + + // Set text properties + vtkTextProperty* tprop = txt->GetTextProperty(); + tprop->SetFontFamilyToArial(); + tprop->BoldOn(); + tprop->ShadowOff(); + tprop->SetLineSpacing(1.0); + tprop->SetFontSize(14); + tprop->SetColor(1.0, 0.0, 1.0); + tprop->SetJustificationToCentered(); + + txt->GetPositionCoordinate()->SetCoordinateSystemToWorld(); + txt->GetPositionCoordinate()->SetValue(pt.x(), pt.y(), pt.z()); + + return txt; +} + + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::vtkPVblockMesh::resetCounters() @@ -60,7 +89,7 @@ void Foam::vtkPVblockMesh::resetCounters() void Foam::vtkPVblockMesh::updateInfoBlocks ( - vtkDataArraySelection* arraySelection + vtkDataArraySelection* select ) { arrayRange& range = arrayRangeBlocks_; @@ -71,7 +100,7 @@ void Foam::vtkPVblockMesh::updateInfoBlocks << " [meshPtr=" << (meshPtr_ ? "set" : "null") << "]" << endl; } - range.reset(arraySelection->GetNumberOfArrays()); + range.reset(select->GetNumberOfArrays()); const blockMesh& blkMesh = *meshPtr_; @@ -92,7 +121,7 @@ void Foam::vtkPVblockMesh::updateInfoBlocks } // Add "blockId" or "blockId - zoneName" to GUI list - arraySelection->AddArray(ostr.str().c_str()); + select->AddArray(ostr.str().c_str()); } range += nBlocks; @@ -106,7 +135,7 @@ void Foam::vtkPVblockMesh::updateInfoBlocks void Foam::vtkPVblockMesh::updateInfoEdges ( - vtkDataArraySelection* arraySelection + vtkDataArraySelection* select ) { arrayRange& range = arrayRangeEdges_; @@ -117,7 +146,7 @@ void Foam::vtkPVblockMesh::updateInfoEdges << " [meshPtr=" << (meshPtr_ ? "set" : "null") << "]" << endl; } - range.reset(arraySelection->GetNumberOfArrays()); + range.reset(select->GetNumberOfArrays()); const blockMesh& blkMesh = *meshPtr_; const blockEdgeList& edges = blkMesh.edges(); @@ -131,7 +160,7 @@ void Foam::vtkPVblockMesh::updateInfoEdges ostr << " - " << edges[edgeI].type(); // Add "beg:end - type" to GUI list - arraySelection->AddArray(ostr.str().c_str()); + select->AddArray(ostr.str().c_str()); } range += edges.size(); @@ -251,14 +280,6 @@ Foam::vtkPVblockMesh::~vtkPVblockMesh() Info<< "~vtkPVblockMesh" << endl; } - // Hmm. pointNumberTextActors are not getting removed - // - forAll(pointNumberTextActorsPtrs_, pointi) - { - pointNumberTextActorsPtrs_[pointi]->Delete(); - } - pointNumberTextActorsPtrs_.clear(); - delete meshPtr_; } @@ -411,71 +432,148 @@ void Foam::vtkPVblockMesh::CleanUp() } -void Foam::vtkPVblockMesh::renderPointNumbers +void Foam::vtkPVblockMesh::renderPatchNames ( vtkRenderer* renderer, const bool show ) { // always remove old actors first - - forAll(pointNumberTextActorsPtrs_, pointi) + forAll(patchTextActorsPtrs_, actori) { - renderer->RemoveViewProp(pointNumberTextActorsPtrs_[pointi]); - pointNumberTextActorsPtrs_[pointi]->Delete(); + renderer->RemoveViewProp(patchTextActorsPtrs_[actori]); + patchTextActorsPtrs_[actori]->Delete(); } - pointNumberTextActorsPtrs_.clear(); + patchTextActorsPtrs_.clear(); + + // the number of text actors + label nActors = 0; if (show && meshPtr_) { const blockMesh& blkMesh = *meshPtr_; + const dictionary& meshDescription = blkMesh.meshDict(); const pointField& cornerPts = blkMesh.vertices(); const scalar scaleFactor = blkMesh.scaleFactor(); - pointNumberTextActorsPtrs_.setSize(cornerPts.size()); - forAll(cornerPts, pointi) + if (!meshDescription.found("boundary")) { - vtkTextActor* txt = vtkTextActor::New(); + return; + } - // Display either pointi as a number or with its name - // (looked up from blockMeshDict) + // 8 sides per block is plenty + patchTextActorsPtrs_.setSize(8*blkMesh.size()); + + // Collect all variables + dictionary varDict(meshDescription.subOrEmptyDict("namedVertices")); + varDict.merge(meshDescription.subOrEmptyDict("namedBlocks")); + + // Read like boundary file + const PtrList<entry> patchesInfo(meshDescription.lookup("boundary")); + + forAll(patchesInfo, patchi) + { + const entry& patchInfo = patchesInfo[patchi]; + + if (!patchInfo.isDict()) { - OStringStream os; - blockVertex::write(os, pointi, blkMesh.meshDict()); - txt->SetInput(os.str().c_str()); + IOWarningInFunction(meshDescription) + << "Entry " << patchInfo << " in boundary section is not a" + << " valid dictionary." + << endl; + break; } - // Set text properties - vtkTextProperty* tprop = txt->GetTextProperty(); - tprop->SetFontFamilyToArial(); - tprop->BoldOn(); - tprop->ShadowOff(); - tprop->SetLineSpacing(1.0); - tprop->SetFontSize(14); - tprop->SetColor(1.0, 0.0, 1.0); - tprop->SetJustificationToCentered(); + const word& patchName = patchInfo.keyword(); - // Set text to use 3-D world co-ordinates - txt->GetPositionCoordinate()->SetCoordinateSystemToWorld(); - - txt->GetPositionCoordinate()->SetValue + // Read block faces + faceList patchFaces = blockMeshTools::read<face> ( - cornerPts[pointi].x()*scaleFactor, - cornerPts[pointi].y()*scaleFactor, - cornerPts[pointi].z()*scaleFactor + patchInfo.dict().lookup("faces"), + varDict ); - // Add text to each renderer - renderer->AddViewProp(txt); + forAll(patchFaces, facei) + { + const face& f = patchFaces[facei]; + + // Into a list for later removal + patchTextActorsPtrs_[nActors++] = createTextActor + ( + patchName, + f.centre(cornerPts) * scaleFactor + ); + + if (nActors == patchTextActorsPtrs_.size()) + { + // hit max allocated space - bail out + break; + } + } - // Maintain a list of text labels added so that they can be - // removed later - pointNumberTextActorsPtrs_[pointi] = txt; + if (nActors == patchTextActorsPtrs_.size()) + { + // hit max allocated space - bail out + break; + } } + + patchTextActorsPtrs_.setSize(nActors); + } + + // Add text to each renderer + forAll(patchTextActorsPtrs_, actori) + { + renderer->AddViewProp(patchTextActorsPtrs_[actori]); } } +void Foam::vtkPVblockMesh::renderPointNumbers +( + vtkRenderer* renderer, + const bool show +) +{ + // always remove old actors first + + forAll(pointTextActorsPtrs_, actori) + { + renderer->RemoveViewProp(pointTextActorsPtrs_[actori]); + pointTextActorsPtrs_[actori]->Delete(); + } + pointTextActorsPtrs_.clear(); + + if (show && meshPtr_) + { + const blockMesh& blkMesh = *meshPtr_; + const pointField& cornerPts = blkMesh.vertices(); + const scalar scaleFactor = blkMesh.scaleFactor(); + + pointTextActorsPtrs_.setSize(cornerPts.size()); + forAll(cornerPts, pointi) + { + // Display either pointi as a number or with its name + // (looked up from blockMeshDict) + OStringStream os; + blockVertex::write(os, pointi, blkMesh.meshDict()); + + // Into a list for later removal + pointTextActorsPtrs_[pointi] = createTextActor + ( + os.str(), + cornerPts[pointi]*scaleFactor + ); + } + } + + // Add text to each renderer + forAll(pointTextActorsPtrs_, actori) + { + renderer->AddViewProp(pointTextActorsPtrs_[actori]); + } +} + void Foam::vtkPVblockMesh::PrintSelf(ostream& os, vtkIndent indent) const { diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtkPVblockMesh/vtkPVblockMesh.H b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtkPVblockMesh/vtkPVblockMesh.H index e4e8c56c2cc87156f23d4c9a39da0d1a45075114..a22316c84afce69d88d71c5559185a980c524ae9 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtkPVblockMesh/vtkPVblockMesh.H +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtkPVblockMesh/vtkPVblockMesh.H @@ -109,38 +109,38 @@ class vtkPVblockMesh //- First instance and size of block corners (only partially used) arrayRange arrayRangeCorners_; + //- List of patch names for rendering to window + List<vtkTextActor*> patchTextActorsPtrs_; + //- List of point numbers for rendering to window - List<vtkTextActor*> pointNumberTextActorsPtrs_; + List<vtkTextActor*> pointTextActorsPtrs_; // Private Member Functions + //- Create a text actor + static vtkTextActor* createTextActor(const string& s, const point& pt); + //- Reset data counters void resetCounters(); - // Update information helper functions - - //- Internal block info - void updateInfoBlocks(vtkDataArraySelection*); - - //- Block curved edges info - void updateInfoEdges(vtkDataArraySelection*); - - // Update helper functions + //- OpenFOAM mesh + void updateFoamMesh(); - //- OpenFOAM mesh - void updateFoamMesh(); + //- Internal block info + void updateInfoBlocks(vtkDataArraySelection* select); - // Mesh conversion functions + //- Block curved edges info + void updateInfoEdges(vtkDataArraySelection* select); - //- Mesh blocks - void convertMeshBlocks(vtkMultiBlockDataSet*, int& blockNo); + //- Mesh blocks + void convertMeshBlocks(vtkMultiBlockDataSet*, int& blockNo); - //- Mesh curved edges - void convertMeshEdges(vtkMultiBlockDataSet*, int& blockNo); + //- Mesh curved edges + void convertMeshEdges(vtkMultiBlockDataSet*, int& blockNo); - //- Mesh corners - void convertMeshCorners(vtkMultiBlockDataSet*, int& blockNo); + //- Mesh corners + void convertMeshCorners(vtkMultiBlockDataSet*, int& blockNo); //- Disallow default bitwise copy construct @@ -181,6 +181,9 @@ public: //- Clean any storage void CleanUp(); + //- Add/remove patch names to/from the view + void renderPatchNames(vtkRenderer*, const bool show); + //- Add/remove point numbers to/from the view void renderPointNumbers(vtkRenderer*, const bool show);