pqPV3FoamReaderPanel.cxx 8.19 KB
Newer Older
1
2
3
4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
5
    \\  /    A nd           | Copyright (C) 2010-2010 OpenCFD Ltd.
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
     \\/     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 <QGridLayout>
#include <QCheckBox>
#include <QLabel>
#include <QLayout>
#include <QString>
35
#include <QPushButton>
36
37
#include <QtDebug>

38
// Paraview <-> QT UI
39
40
41
42
#include "pqAnimationScene.h"
#include "pqApplicationCore.h"
#include "pqPipelineRepresentation.h"
#include "pqServerManagerModel.h"
43
#include "pqView.h"
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

// Paraview Server Manager
#include "vtkSMDoubleVectorProperty.h"
#include "vtkSMIntVectorProperty.h"
#include "vtkSMProperty.h"
#include "vtkSMSourceProxy.h"


// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

pqPV3FoamReaderPanel::pqPV3FoamReaderPanel
(
    pqProxy *proxy,
    QWidget *p
)
:
60
    pqAutoGeneratedObjectPanel(proxy, p)
61
62
{
    // create first sublayout (at top of the panel)
63
64
    QGridLayout *form = new QGridLayout();
    this->PanelLayout->addLayout(form, 0, 0, 1, -1);
65

66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
    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())
        );
    }
110
111
112


    // checkbox for caching mesh
113
114
115
116
    if ((prop = this->proxy()->GetProperty("UiCacheMesh")) != 0)
    {
        // immediate update on the Server Manager side
        prop->SetImmediateUpdate(true);
117

118
119
120
121
122
123
124
125
126
        CacheMesh_ = new QCheckBox("Cache Mesh");
        CacheMesh_->setChecked
        (
            vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0)
        );
        CacheMesh_->setToolTip
        (
            "Cache the fvMesh in memory."
        );
127

128
129
130
131
132
133
134
135
136
        form->addWidget(CacheMesh_, 1, 0, Qt::AlignLeft);
        connect
        (
            CacheMesh_,
            SIGNAL(stateChanged(int)),
            this,
            SLOT(CacheMeshToggled())
        );
    }
137
138


139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
    // 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())
        );
    }
222
223
224
225
226
227
228
229
230
231

}


// * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //

void pqPV3FoamReaderPanel::CacheMeshToggled()
{
    vtkSMIntVectorProperty::SafeDownCast
    (
232
        this->proxy()->GetProperty("UiCacheMesh")
233
234
235
236
    )->SetElement(0, CacheMesh_->isChecked());
}


237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
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();
}


264
265
266
267
void pqPV3FoamReaderPanel::ShowPatchNamesToggled()
{
    vtkSMIntVectorProperty::SafeDownCast
    (
268
        this->proxy()->GetProperty("UiShowPatchNames")
269
    )->SetElement(0, ShowPatchNames_->isChecked());
270
271
272
273
274
275
276
277

    // update the active view
    if (this->view())
    {
        this->view()->render();
    }
    // OR: update all views
    // pqApplicationCore::instance()->render();
278
279
280
}


281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
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);
    }

}


314
// ************************************************************************* //