23 #include <QHBoxLayout>
25 #include <QVBoxLayout>
26 #include <QResizeEvent>
27 #include <QIntValidator>
35 emit
resizeSignal(event->size().width(),
event->size().height());
39 : _curve(new
T_CURVE), _width(320), _height(170), _curvePoly(0), _baseRect(0), _gridRect(0) {
49 setSceneRect(-9, -7, width, height);
86 QString flowDirection = val.remove(0, 1);
87 flowDirection = flowDirection.remove(flowDirection.size() - 1, 1);
88 QStringList
components = flowDirection.split(
",");
138 _curvePoly = addPolygon(QPolygonF(), QPen(Qt::black, 1.0), QBrush(Qt::darkGray));
142 poly.append(QPointF(
_width, 0));
143 poly.append(QPointF(0, 0));
144 for (
int i = 0; i < 1000; i++) {
145 double x = i / 1000.0;
148 poly.append(QPointF(
_width, 0));
166 : QWidget(parent), _scene(0), _resolutionEdit(0), _tileSizeEdit(0), _lengthCutoffEdit(0), _amplitudeEdit(0),
167 _windAngleEdit(0), _windSpeedEdit(0), _flowDirectionEdit(0), _directionalFactorExponentEdit(0),
168 _directionalReflectionDampingEdit(0), _sharpenEdit(0) {
169 QHBoxLayout *mainLayout =
new QHBoxLayout();
170 mainLayout->setSpacing(2);
171 mainLayout->setMargin(4);
173 QWidget *edits =
new QWidget;
174 QVBoxLayout *editsLayout =
new QVBoxLayout;
175 editsLayout->setAlignment(Qt::AlignTop);
176 editsLayout->setSpacing(0);
177 editsLayout->setMargin(0);
178 edits->setLayout(editsLayout);
180 int editWidth = QFontMetrics(font()).width(
"[0,0,0]") + 8;
182 QWidget *resolution =
new QWidget;
183 QHBoxLayout *resolutionLayout =
new QHBoxLayout;
184 resolutionLayout->setSpacing(1);
185 resolutionLayout->setMargin(1);
186 resolution->setLayout(resolutionLayout);
189 QIntValidator *resolutionValidator =
new QIntValidator(
_resolutionEdit);
190 resolutionValidator->setBottom(1);
193 resolutionLayout->addStretch(50);
194 QLabel *resolutionLabel =
new QLabel(
"R");
195 resolutionLabel->setToolTip(
"Resolution");
196 resolutionLayout->addWidget(resolutionLabel);
199 QWidget *tileSize =
new QWidget;
200 QHBoxLayout *tileSizeLayout =
new QHBoxLayout;
201 tileSizeLayout->setSpacing(1);
202 tileSizeLayout->setMargin(1);
203 tileSize->setLayout(tileSizeLayout);
207 tileSizeLayout->addStretch(50);
208 QLabel *tileSizeLabel =
new QLabel(
"TS");
209 tileSizeLabel->setToolTip(
"Tile Size");
210 tileSizeLayout->addWidget(tileSizeLabel);
213 QWidget *lengthCutoff =
new QWidget;
214 QHBoxLayout *lengthCutoffLayout =
new QHBoxLayout;
215 lengthCutoffLayout->setSpacing(1);
216 lengthCutoffLayout->setMargin(1);
217 lengthCutoff->setLayout(lengthCutoffLayout);
221 lengthCutoffLayout->addStretch(50);
222 QLabel *lengthCutoffLabel =
new QLabel(
"LC");
223 lengthCutoffLabel->setToolTip(
"Length Cutoff");
224 lengthCutoffLayout->addWidget(lengthCutoffLabel);
227 QWidget *amplitude =
new QWidget;
228 QHBoxLayout *amplitudeLayout =
new QHBoxLayout;
229 amplitudeLayout->setSpacing(1);
230 amplitudeLayout->setMargin(1);
231 amplitude->setLayout(amplitudeLayout);
235 amplitudeLayout->addStretch(50);
236 QLabel *amplitudeLabel =
new QLabel(
"A");
237 amplitudeLabel->setToolTip(
"Amplitude");
238 amplitudeLayout->addWidget(amplitudeLabel);
241 QWidget *windAngle =
new QWidget;
242 QHBoxLayout *windAngleLayout =
new QHBoxLayout;
243 windAngleLayout->setSpacing(1);
244 windAngleLayout->setMargin(1);
245 windAngle->setLayout(windAngleLayout);
249 windAngleLayout->addStretch(50);
250 QLabel *windAngleLabel =
new QLabel(
"WA");
251 windAngleLabel->setToolTip(
"Wind Angle");
252 windAngleLayout->addWidget(windAngleLabel);
255 QWidget *windSpeed =
new QWidget;
256 QHBoxLayout *windSpeedLayout =
new QHBoxLayout;
257 windSpeedLayout->setSpacing(1);
258 windSpeedLayout->setMargin(1);
259 windSpeed->setLayout(windSpeedLayout);
263 windSpeedLayout->addStretch(50);
264 QLabel *windSpeedLabel =
new QLabel(
"WS");
265 windSpeedLabel->setToolTip(
"Wind Speed");
266 windSpeedLayout->addWidget(windSpeedLabel);
269 QWidget *directionalFactorExponent =
new QWidget;
270 QHBoxLayout *directionalFactorExponentLayout =
new QHBoxLayout;
271 directionalFactorExponentLayout->setSpacing(1);
272 directionalFactorExponentLayout->setMargin(1);
273 directionalFactorExponent->setLayout(directionalFactorExponentLayout);
277 directionalFactorExponentLayout->addStretch(50);
278 QLabel *directionalFactorExponentLabel =
new QLabel(
"DFE");
279 directionalFactorExponentLabel->setToolTip(
"Directional Factor Exponent");
280 directionalFactorExponentLayout->addWidget(directionalFactorExponentLabel);
283 QWidget *directionalReflectionDamping =
new QWidget;
284 QHBoxLayout *directionalReflectionDampingLayout =
new QHBoxLayout;
285 directionalReflectionDampingLayout->setSpacing(1);
286 directionalReflectionDampingLayout->setMargin(1);
287 directionalReflectionDamping->setLayout(directionalReflectionDampingLayout);
291 directionalReflectionDampingLayout->addStretch(50);
292 QLabel *directionalReflectionDampingLabel =
new QLabel(
"DRD");
293 directionalReflectionDampingLabel->setToolTip(
"Directional Reflection Damping");
294 directionalReflectionDampingLayout->addWidget(directionalReflectionDampingLabel);
297 QWidget *flowDirection =
new QWidget;
298 QHBoxLayout *flowDirectionLayout =
new QHBoxLayout;
299 flowDirectionLayout->setSpacing(1);
300 flowDirectionLayout->setMargin(1);
301 flowDirection->setLayout(flowDirectionLayout);
305 flowDirectionLayout->addStretch(50);
306 QLabel *flowDirectionLabel =
new QLabel(
"FD");
307 flowDirectionLabel->setToolTip(
"Flow Direction");
308 flowDirectionLayout->addWidget(flowDirectionLabel);
311 QWidget *sharpen =
new QWidget;
312 QHBoxLayout *sharpenLayout =
new QHBoxLayout;
313 sharpenLayout->setSpacing(1);
314 sharpenLayout->setMargin(1);
315 sharpen->setLayout(sharpenLayout);
319 sharpenLayout->addStretch(50);
320 QLabel *sharpenLabel =
new QLabel(
"S");
321 sharpenLabel->setToolTip(
"Sharpen");
322 sharpenLayout->addWidget(sharpenLabel);
325 QFrame *curveFrame =
new QFrame;
326 curveFrame->setFrameShape(QFrame::Panel);
327 curveFrame->setFrameShadow(QFrame::Sunken);
328 curveFrame->setLineWidth(1);
329 QHBoxLayout *curveFrameLayout =
new QHBoxLayout;
330 curveFrameLayout->setMargin(0);
332 curveView->setFrameShape(QFrame::Panel);
333 curveView->setFrameShadow(QFrame::Sunken);
334 curveView->setLineWidth(1);
335 curveView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
336 curveView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
338 curveView->setScene(
_scene);
339 curveView->setTransform(QTransform().scale(1, -1));
340 curveView->setRenderHints(QPainter::Antialiasing);
341 curveFrameLayout->addWidget(curveView);
342 curveFrame->setLayout(curveFrameLayout);
344 editsLayout->addWidget(resolution);
345 editsLayout->addWidget(tileSize);
346 editsLayout->addWidget(lengthCutoff);
347 editsLayout->addWidget(amplitude);
348 editsLayout->addWidget(windSpeed);
349 editsLayout->addWidget(directionalFactorExponent);
350 QFrame *line =
new QFrame();
351 line->setToolTip(
"Parameters below this do not affect spectrum");
352 line->setFrameShape(QFrame::HLine);
353 line->setFrameShadow(QFrame::Sunken);
354 editsLayout->addWidget(line);
355 editsLayout->addWidget(windAngle);
356 editsLayout->addWidget(flowDirection);
357 editsLayout->addWidget(directionalReflectionDamping);
358 editsLayout->addWidget(sharpen);
360 mainLayout->addWidget(edits);
361 mainLayout->addWidget(curveFrame);
362 mainLayout->setStretchFactor(curveFrame, 100);
363 setLayout(mainLayout);
406 connect(curveView, SIGNAL(resizeSignal(
int,
int)),
_scene, SLOT(resize(
int,
int)));
464 QString flowDirection =
"[";