/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2010-2010 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 2 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, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA \*---------------------------------------------------------------------------*/ #include "pqPV3FoamReaderPanel.h" // QT #include #include #include #include #include #include #include // 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 * * * * * * * * * * * * * * // pqPV3FoamReaderPanel::pqPV3FoamReaderPanel ( 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 times/fields if ((prop = this->proxy()->GetProperty("UiRefresh")) != 0) { prop->SetImmediateUpdate(1); QPushButton *refresh = new QPushButton("Refresh Times"); refresh->setToolTip("Rescan for updated times/fields."); form->addWidget(refresh, 0, 0, Qt::AlignLeft); QObject::connect ( refresh, SIGNAL(clicked()), this, SLOT(RefreshPressed()) ); } // checkbox for skip zeroTime if ((prop = this->proxy()->GetProperty("UiZeroTime")) != 0) { // immediate update on the Server Manager side prop->SetImmediateUpdate(true); ZeroTime_ = new QCheckBox("Skip Zero Time"); ZeroTime_->setChecked ( vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0) ); ZeroTime_->setToolTip ( "Skip including the 0/ time directory." ); form->addWidget(ZeroTime_, 0, 1, Qt::AlignLeft); connect ( ZeroTime_, SIGNAL(stateChanged(int)), this, SLOT(ZeroTimeToggled()) ); } // checkbox for caching mesh if ((prop = this->proxy()->GetProperty("UiCacheMesh")) != 0) { // immediate update on the Server Manager side prop->SetImmediateUpdate(true); CacheMesh_ = new QCheckBox("Cache Mesh"); CacheMesh_->setChecked ( vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0) ); CacheMesh_->setToolTip ( "Cache the fvMesh in memory." ); form->addWidget(CacheMesh_, 1, 0, Qt::AlignLeft); connect ( CacheMesh_, SIGNAL(stateChanged(int)), this, SLOT(CacheMeshToggled()) ); } // checkbox for patch names if ((prop = this->proxy()->GetProperty("UiShowPatchNames")) != 0) { // immediate update on the Server Manager side prop->SetImmediateUpdate(true); ShowPatchNames_ = new QCheckBox("Patch Names"); ShowPatchNames_->setChecked ( vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0) ); ShowPatchNames_->setToolTip ( "Show patch names in render window." ); // row/col 0,1 form->addWidget(ShowPatchNames_, 1, 1, Qt::AlignLeft); connect ( ShowPatchNames_, SIGNAL(stateChanged(int)), this, SLOT(ShowPatchNamesToggled()) ); } // checkbox for include sets if ((prop = this->proxy()->GetProperty("UiIncludeSets")) != 0) { // immediate update on the Server Manager side prop->SetImmediateUpdate(true); IncludeSets_ = new QCheckBox("Include Sets"); IncludeSets_->setChecked ( vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0) ); IncludeSets_->setToolTip ( "Search the polyMesh/sets/ directory." ); // row/col 1,0 form->addWidget(IncludeSets_, 2, 0, Qt::AlignLeft); connect ( IncludeSets_, SIGNAL(stateChanged(int)), this, SLOT(IncludeSetsToggled()) ); } // checkbox for include zones if ((prop = this->proxy()->GetProperty("UiIncludeZones")) != 0) { // immediate update on the Server Manager side prop->SetImmediateUpdate(true); IncludeZones_ = new QCheckBox("Include Zones"); IncludeZones_->setChecked ( vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0) ); IncludeZones_->setToolTip ( "ZoneMesh information is used to find {cell,face,point}Zones. " "The polyMesh/ directory is only checked on startup." ); // row/col 1,1 form->addWidget(IncludeZones_, 2, 1, Qt::AlignLeft); connect ( IncludeZones_, SIGNAL(stateChanged(int)), this, SLOT(IncludeZonesToggled()) ); } } // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // void pqPV3FoamReaderPanel::CacheMeshToggled() { vtkSMIntVectorProperty::SafeDownCast ( this->proxy()->GetProperty("UiCacheMesh") )->SetElement(0, CacheMesh_->isChecked()); } void pqPV3FoamReaderPanel::RefreshPressed() { // update everything vtkSMIntVectorProperty::SafeDownCast ( this->proxy()->GetProperty("UiRefresh") )->Modified(); vtkSMSourceProxy::SafeDownCast(this->proxy())->UpdatePipeline(); // render all views pqApplicationCore::instance()->render(); } void pqPV3FoamReaderPanel::ZeroTimeToggled() { vtkSMIntVectorProperty::SafeDownCast ( this->proxy()->GetProperty("UiZeroTime") )->SetElement(0, ZeroTime_->isChecked()); // update everything RefreshPressed(); } void pqPV3FoamReaderPanel::ShowPatchNamesToggled() { vtkSMIntVectorProperty::SafeDownCast ( this->proxy()->GetProperty("UiShowPatchNames") )->SetElement(0, ShowPatchNames_->isChecked()); // update the active view if (this->view()) { this->view()->render(); } // OR: update all views // pqApplicationCore::instance()->render(); } void pqPV3FoamReaderPanel::IncludeSetsToggled() { vtkSMProperty* prop; vtkSMIntVectorProperty::SafeDownCast ( this->proxy()->GetProperty("UiIncludeSets") )->SetElement(0, IncludeSets_->isChecked()); if ((prop = this->proxy()->GetProperty("PartArrayStatus")) != 0) { this->proxy()->UpdatePropertyInformation(prop); } } void pqPV3FoamReaderPanel::IncludeZonesToggled() { vtkSMProperty* prop; vtkSMIntVectorProperty::SafeDownCast ( this->proxy()->GetProperty("UiIncludeZones") )->SetElement(0, IncludeZones_->isChecked()); if ((prop = this->proxy()->GetProperty("PartArrayStatus")) != 0) { this->proxy()->UpdatePropertyInformation(prop); } } // ************************************************************************* //