|
5 | 5 |
|
6 | 6 | #include "dialog/mainwindowsupport.h" |
7 | 7 | #include "dialog/plotdata.h" |
| 8 | +#include <QMessageBox> |
8 | 9 |
|
9 | 10 | MainWindowSupport::MainWindowSupport(void) |
10 | 11 | { |
@@ -485,204 +486,3 @@ void MainWindowSupport::ReadCustomData(parameters *para, QString fileName, bool |
485 | 486 | para->stdDev = 1.0; |
486 | 487 | } |
487 | 488 | } |
488 | | - |
489 | | -/************************* Sanity check *********************************************/ |
490 | | -//Input parameter check |
491 | | -bool MainWindowSupport::CheckInputParameters(Ui_MainWindow *ui, parameters *para) |
492 | | -{ |
493 | | - QMessageBox msgBox, msgBoxWarn; |
494 | | - msgBox.setWindowTitle("Error"); |
495 | | - msgBox.setIcon(QMessageBox::Critical); |
496 | | - msgBoxWarn.setWindowTitle("Warning"); |
497 | | - msgBoxWarn.setIcon(QMessageBox::Warning); |
498 | | - |
499 | | - if ((para->scatRefReal <= 0.0) || (para->medRef <= 0.0)) |
500 | | - { |
501 | | - msgBox.setText("Refractive index cannot be zero"); |
502 | | - msgBox.exec(); |
503 | | - return 1; |
504 | | - } |
505 | | - if ((para->scatRefReal/para->medRef == 1.0)) |
506 | | - { |
507 | | - msgBox.setText("Relative refractive index cannot be 1.0"); |
508 | | - msgBox.exec(); |
509 | | - return 1; |
510 | | - } |
511 | | - double m = para->scatRefReal / para->medRef; |
512 | | - if ((m < 0.05) || (m > 5.0)) |
513 | | - { |
514 | | - msgBoxWarn.setText("Unrealistic relative refractive index."); |
515 | | - msgBoxWarn.setInformativeText("Check sphere and medium refractive index values"); |
516 | | - msgBoxWarn.exec(); |
517 | | - return 1; |
518 | | - } |
519 | | - if (para->scatRefImag >= 5.0) |
520 | | - { |
521 | | - msgBox.setText("Imaginary refractive index must be negative or less than 5.0."); |
522 | | - msgBox.exec(); |
523 | | - return 1; |
524 | | - } |
525 | | - //Avoid zeros |
526 | | - if ((para->startWavel <= 0.0) || (para->endWavel <= 0.0)) |
527 | | - { |
528 | | - msgBox.setText("The starting or ending wavelength cannot be zero"); |
529 | | - msgBox.exec(); |
530 | | - return 1; |
531 | | - } |
532 | | - //Avoid zeros |
533 | | - if (para->stepWavel <= 0.0) |
534 | | - { |
535 | | - msgBox.setText("Wavelength step cannot be zero"); |
536 | | - msgBox.exec(); |
537 | | - return 1; |
538 | | - } |
539 | | - if (para->startWavel < 50.0) |
540 | | - { |
541 | | - msgBox.setText("Minimum wavlength is 50nm"); |
542 | | - msgBox.exec(); |
543 | | - return 1; |
544 | | - } |
545 | | - if (para->endWavel > 3000.0) |
546 | | - { |
547 | | - msgBox.setText("Maximum wavlength is 3000nm"); |
548 | | - msgBox.exec(); |
549 | | - return 1; |
550 | | - } |
551 | | - if (para->endWavel - para->startWavel < 0.0) |
552 | | - { |
553 | | - msgBox.setText("The starting wavelength is greater than the ending wavelength"); |
554 | | - msgBox.exec(); |
555 | | - return 1; |
556 | | - } |
557 | | - if (ui->radioButton_NumDen->isChecked()) |
558 | | - { |
559 | | - if (para->sphNumDensity <= 0.0) |
560 | | - { |
561 | | - msgBox.setText("Sphere concentration cannot be zero"); |
562 | | - msgBox.exec(); |
563 | | - return 1; |
564 | | - } |
565 | | - } |
566 | | - if (ui->radioButton_VolFrac->isChecked()) |
567 | | - { |
568 | | - if (para->volFraction <= 0.0) |
569 | | - { |
570 | | - msgBox.setText("Volume Fraction cannot be zero"); |
571 | | - msgBox.exec(); |
572 | | - return 1; |
573 | | - } |
574 | | - |
575 | | - if (para->volFraction >= 1.0) |
576 | | - { |
577 | | - msgBox.setText("Volume Fraction cannot exceed 1.0"); |
578 | | - msgBox.exec(); |
579 | | - return 1; |
580 | | - } |
581 | | - } |
582 | | - if ((para->meanRadius < 0.00005) ||(para->meanRadius >150)) |
583 | | - { |
584 | | - msgBox.setText("Diameter is out of range!"); |
585 | | - msgBox.setInformativeText("Enter a value between 0.0001μm and 300μm"); |
586 | | - msgBox.exec(); |
587 | | - return 1; |
588 | | - } |
589 | | - if (ui->radioButton_MonoDisperse->isChecked()) |
590 | | - { |
591 | | - if (ui->radioButton_NumDen->isChecked()) |
592 | | - { |
593 | | - double volume = 4.0 * M_PI *para->meanRadius * para->meanRadius * para->meanRadius / 3.0; |
594 | | - if (para->sphNumDensity*volume >= 1e9) |
595 | | - { |
596 | | - msgBoxWarn.setText("Concentration x Sphere Volume exceeds 1mm³."); |
597 | | - msgBoxWarn.setInformativeText("Reduce Concentration."); |
598 | | - msgBoxWarn.exec(); |
599 | | - return 1; |
600 | | - } |
601 | | - } |
602 | | - } |
603 | | - return 0; |
604 | | -} |
605 | | - |
606 | | -//Poly disperse distribution parameter check |
607 | | -bool MainWindowSupport::CheckDistribution(Ui_MainWindow *ui, parameters *para) |
608 | | -{ |
609 | | - QMessageBox msgBox; |
610 | | - msgBox.setWindowTitle("Error"); |
611 | | - |
612 | | - if (para->stdDev == 0.0) |
613 | | - { |
614 | | - msgBox.setText("Standard Deviation is zero."); |
615 | | - msgBox.setInformativeText("Use 'Mono Disperse'."); |
616 | | - msgBox.exec(); |
617 | | - return 1; |
618 | | - } |
619 | | - if(ui->comboBox_Distribution->currentIndex() == 0) |
620 | | - { |
621 | | - if (para->stdDev > 3.0) |
622 | | - { |
623 | | - msgBox.setIcon(QMessageBox::Critical); |
624 | | - msgBox.setText("Large standard deviation provides an abnormal Log Normal distribution."); |
625 | | - msgBox.setInformativeText("The limit was set to 3.0μm."); |
626 | | - msgBox.exec(); |
627 | | - return 1; |
628 | | - } |
629 | | - if (para->stdDev < 1e-5) |
630 | | - { |
631 | | - msgBox.setIcon(QMessageBox::Critical); |
632 | | - msgBox.setText("The standard deviation is too small."); |
633 | | - msgBox.setInformativeText("Use 'Mono Disperse'."); |
634 | | - msgBox.exec(); |
635 | | - return 1; |
636 | | - } |
637 | | - } |
638 | | - |
639 | | - if(ui->comboBox_Distribution->currentIndex() == 1) |
640 | | - { |
641 | | - if (para->stdDev > 50.0) |
642 | | - { |
643 | | - msgBox.setIcon(QMessageBox::Critical); |
644 | | - msgBox.setText("The standard deviation is too large."); |
645 | | - msgBox.setInformativeText("The limit was set to 50.0μm."); |
646 | | - msgBox.exec(); |
647 | | - return 1; |
648 | | - } |
649 | | - if (para->stdDev < 1e-8) |
650 | | - { |
651 | | - msgBox.setIcon(QMessageBox::Critical); |
652 | | - msgBox.setText("The standard deviation is too small."); |
653 | | - msgBox.setInformativeText("Use 'Mono Disperse'."); |
654 | | - msgBox.exec(); |
655 | | - return 1; |
656 | | - } |
657 | | - } |
658 | | - if (para->nRadius == 1) |
659 | | - { |
660 | | - msgBox.setText("Discrete sphere size is 1. "); |
661 | | - msgBox.setInformativeText("Use 'Mono Disperse'."); |
662 | | - msgBox.exec(); |
663 | | - return 1; |
664 | | - } |
665 | | - if ((para->nRadius < 2.0) ||(para->nRadius >101.0)) |
666 | | - { |
667 | | - msgBox.setText("Number of sphere sizes is out of range."); |
668 | | - msgBox.setInformativeText("Enter a value between 2 and 101."); |
669 | | - msgBox.exec(); |
670 | | - return 1; |
671 | | - } |
672 | | - if ((para->meanRadius < 0.0005) ||(para->meanRadius >25)) |
673 | | - { |
674 | | - msgBox.setText("Diameter is out of range."); |
675 | | - msgBox.setInformativeText("Enter a value between 0.001μm and 50μm."); |
676 | | - msgBox.exec(); |
677 | | - return 1; |
678 | | - } |
679 | | - if (para->stdDev/para->meanRadius < 1.999e-5) |
680 | | - { |
681 | | - msgBox.setIcon(QMessageBox::Critical); |
682 | | - msgBox.setText("Standard deviation to mean diameter ratio is smaller than 1e-5."); |
683 | | - msgBox.setInformativeText("Use 'Mono Disperse'"); |
684 | | - msgBox.exec(); |
685 | | - return 1; |
686 | | - } |
687 | | - return 0; |
688 | | -} |
0 commit comments