@@ -444,6 +444,10 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, Lammps
444444 dodepth->setCheckable (true );
445445 dodepth->setToolTip (" Toggle depth cueing" );
446446 dodepth->setObjectName (" depthcue" );
447+ auto *dodefocus = new QPushButton (QIcon (" :/icons/defocus.svg" ), " " );
448+ dodefocus->setCheckable (true );
449+ dodefocus->setToolTip (" Toggle defocusing of distant objects" );
450+ dodefocus->setObjectName (" defocus" );
447451 auto *doshiny = new QPushButton (QIcon (" :/icons/image-shiny.svg" ), " " );
448452 doshiny->setCheckable (true );
449453 doshiny->setToolTip (" Toggle shininess" );
@@ -502,8 +506,8 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, Lammps
502506
503507 // square toolbar buttons with a snug, uniform icon (shared policy)
504508 styleToolButtons (buttonhint,
505- {dossao, doanti, dodepth, doshiny, dovdw, dobond, dobox, doaxes, zoomin ,
506- zoomout, rotleft, rotright, rotup, rotdown, recenter, reset, fitwin});
509+ {dossao, doanti, dodepth, dodefocus, doshiny, dovdw, dobond, dobox, doaxes,
510+ zoomin, zoomout, rotleft, rotright, rotup, rotdown, recenter, reset, fitwin});
507511
508512 // match the first-row controls (menu bar and size fields) to the toolbar
509513 // button height so both rows line up and the layout looks balanced
@@ -580,6 +584,7 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, Lammps
580584 buttonLayout->addWidget (dossao);
581585 buttonLayout->addWidget (doanti);
582586 buttonLayout->addWidget (dodepth);
587+ buttonLayout->addWidget (dodefocus);
583588 buttonLayout->addWidget (doshiny);
584589 buttonLayout->addWidget (dovdw);
585590 buttonLayout->addWidget (dobond);
@@ -621,6 +626,7 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, Lammps
621626 connect (dossao, &QPushButton::released, this , &ImageViewer::toggleSsao);
622627 connect (doanti, &QPushButton::released, this , &ImageViewer::toggleAnti);
623628 connect (dodepth, &QPushButton::released, this , &ImageViewer::toggleDepthcue);
629+ connect (dodefocus, &QPushButton::released, this , &ImageViewer::toggleDefocus);
624630 connect (doshiny, &QPushButton::released, this , &ImageViewer::toggleShiny);
625631 connect (dovdw, &QPushButton::released, this , &ImageViewer::toggleVdw);
626632 connect (dobond, &QPushButton::released, this , &ImageViewer::toggleBond);
@@ -670,6 +676,7 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, Lammps
670676 dossao->setChecked (usessao);
671677 doanti->setChecked (antialias);
672678 dodepth->setChecked (usedepthcue);
679+ dodefocus->setChecked (usedefocus);
673680
674681 scrollArea->setVisible (true );
675682 updateActions ();
@@ -743,6 +750,9 @@ void ImageViewer::readImageSettings()
743750 depthcuefactor = 0.5 ;
744751 depthcuecolor = " auto" ;
745752 depthcuestart = " auto" ;
753+ usedefocus = false ;
754+ defocusfactor = 0.5 ;
755+ defocusstart = " auto" ;
746756 useoutline = false ;
747757 outlinewidth = 2 ;
748758 outlinecolor = " black" ;
@@ -818,6 +828,8 @@ void ImageViewer::resetView()
818828 if (button) button->setChecked (antialias);
819829 button = findChild<QPushButton *>(" depthcue" );
820830 if (button) button->setChecked (usedepthcue);
831+ button = findChild<QPushButton *>(" defocus" );
832+ if (button) button->setChecked (usedefocus);
821833 button = findChild<QPushButton *>(" shiny" );
822834 if (button) button->setChecked (shinyfactor > SHINY_CUT );
823835 button = findChild<QPushButton *>(" vdw" );
@@ -898,6 +910,15 @@ void ImageViewer::toggleDepthcue()
898910 createImage ();
899911}
900912
913+ void ImageViewer::toggleDefocus ()
914+ {
915+ auto *button = qobject_cast<QPushButton *>(sender ());
916+ if (!button) return ;
917+ usedefocus = !usedefocus;
918+ button->setChecked (usedefocus);
919+ createImage ();
920+ }
921+
901922void ImageViewer::toggleShiny ()
902923{
903924 auto *button = qobject_cast<QPushButton *>(sender ());
@@ -1495,6 +1516,9 @@ DumpImageParams ImageViewer::gatherDumpImageParams(const QString &dumpfilename)
14951516 p.depthcuefactor = depthcuefactor;
14961517 p.depthcuecolor = depthcuecolor;
14971518 p.depthcuestart = depthcuestart;
1519+ p.usedefocus = usedefocus;
1520+ p.defocusfactor = defocusfactor;
1521+ p.defocusstart = defocusstart;
14981522 p.useoutline = useoutline;
14991523 p.outlinewidth = outlinewidth;
15001524 p.outlinecolor = outlinecolor;
0 commit comments