special case for the "open" icon. It will open a file selector and map the return file to the given command.
3828{
3829 if (aLabel == nullptr) return;
3830
3831 if (aCommand == nullptr) {
3832 if (std::string(aIconFile) == "user_icon") {
3833 return;
3834 }
3835 }
3836 QPixmap* pix;
3837 G4bool userToolBar =
false;
3838
3839 if (! fDefaultIcons) {
3840 userToolBar = true;
3841 }
3842 if (std::string(aIconFile) == "user_icon") {
3843
3845 pix =
new QPixmap(UImanager->
FindMacroPath(aFileName).data());
3846 if (pix->isNull()) {
3848
3849 if (verbose >= 2) {
3850 G4cout <<
"Warning: file '" << aFileName
3851 <<
"' is incorrect or does not exist, this command will not be build" <<
G4endl;
3852 }
3853 return;
3854 }
3855 }
3856 else if (std::string(aIconFile) == "open") {
3857 pix = fOpenIcon;
3858 }
3859 else if (std::string(aIconFile) == "save") {
3860 pix = fSaveIcon;
3861 }
3862 else if (std::string(aIconFile) == "move") {
3863 pix = fMoveIcon;
3864 }
3865 else if (std::string(aIconFile) == "rotate") {
3866 pix = fRotateIcon;
3867 }
3868 else if (std::string(aIconFile) == "pick") {
3869 pix = fPickIcon;
3870 }
3871 else if (std::string(aIconFile) == "zoom_in") {
3872 pix = fZoomInIcon;
3873 }
3874 else if (std::string(aIconFile) == "zoom_out") {
3875 pix = fZoomOutIcon;
3876 }
3877 else if (std::string(aIconFile) == "wireframe") {
3878 pix = fWireframeIcon;
3879 }
3880 else if (std::string(aIconFile) == "solid") {
3881 pix = fSolidIcon;
3882 }
3883 else if (std::string(aIconFile) == "point_cloud") {
3884 pix = fPointCloudIcon;
3885 }
3886 else if (std::string(aIconFile) == "hidden_line_removal") {
3887 pix = fHiddenLineRemovalIcon;
3888 }
3889 else if (std::string(aIconFile) == "hidden_line_and_surface_removal") {
3890 pix = fHiddenLineAndSurfaceRemovalIcon;
3891 }
3892 else if (std::string(aIconFile) == "perspective") {
3893 pix = fPerspectiveIcon;
3894 }
3895 else if (std::string(aIconFile) == "ortho") {
3896 pix = fOrthoIcon;
3897 }
3898 else if (std::string(aIconFile) == "runBeamOn") {
3899 pix = fRunIcon;
3900 }
3901 else if (std::string(aIconFile) == "exit") {
3902 pix = fExitIcon;
3903 }
3904 else if (std::string(aIconFile) == "reset_camera") {
3905 pix = fResetCameraIcon;
3906 }
3907 else if (std::string(aIconFile) == "resetTargetPoint") {
3908 pix = fResetTargetPointIcon;
3909 }
3910 else {
3913
3914 if (verbose >= 2) {
3915 G4cout <<
"Parameter" << aIconFile <<
" not defined" <<
G4endl;
3916 }
3917 return;
3918 }
3919 QToolBar* currentToolbar = nullptr;
3920 if (userToolBar) {
3921 if (fToolbarUser == nullptr) {
3922 fToolbarUser = new QToolBar();
3923 fToolbarUser->setIconSize(QSize(20, 20));
3924 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarUser);
3925 }
3926 currentToolbar = fToolbarUser;
3927 }
3928 else {
3929 if (fToolbarApp == nullptr) {
3930 fToolbarApp = new QToolBar();
3931 fToolbarApp->setIconSize(QSize(20, 20));
3932 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
3933 }
3934 currentToolbar = fToolbarApp;
3935 }
3936
3937
3938
3939 QList<QAction*> list = currentToolbar->actions();
3940
3941 for (auto i : list) {
3942 if (i->text() == QString(aLabel)) {
3944 if (UI == nullptr) return;
3946 if (verbose >= 2) {
3947 G4cout <<
"Warning: A toolBar icon \"" << aLabel <<
"\" already exists with the same name!"
3949 }
3950 }
3951 }
3952
3953
3954 if (std::string(aIconFile) == "open") {
3955 QString txt = aCommand + fStringSeparator + aLabel;
3956 currentToolbar->addAction(
3957 QIcon(*pix), aIconFile, this, [this, txt]() { this->OpenIconCallback(txt); });
3958
3959
3960 }
3961 else if (std::string(aIconFile) == "save") {
3962 QString txt = aCommand + fStringSeparator + aLabel;
3963 currentToolbar->addAction(
3964 QIcon(*pix), aIconFile, this, [this, txt]() { this->SaveIconCallback(txt); });
3965
3966 }
3967 else if ((std::string(aIconFile) == "move") || (std::string(aIconFile) == "rotate") ||
3968 (std::string(aIconFile) == "pick") || (std::string(aIconFile) == "zoom_out") ||
3969 (std::string(aIconFile) == "zoom_in"))
3970 {
3971 QString txt = QString(aIconFile);
3972 QAction* action = currentToolbar->addAction(
3973 QIcon(*pix), aIconFile, this, [this, txt]() { this->ChangeCursorAction(txt); });
3974 action->setCheckable(true);
3975 action->setChecked(false);
3976 action->setData(aIconFile);
3977
3978 if (std::string(aIconFile) == "rotate") {
3980 }
3981
3982
3983 }
3984 else if ((std::string(aIconFile) == "hidden_line_removal") ||
3985 (std::string(aIconFile) == "hidden_line_and_surface_removal") ||
3986 (std::string(aIconFile) == "solid") ||
3987 (std::string(aIconFile) == "wireframe") ||
3988 (std::string(aIconFile) == "point_cloud"))
3989 {
3990 QString txt = QString(aIconFile);
3991 QAction* action = currentToolbar->addAction(
3992 QIcon(*pix), aIconFile, this, [this, txt]() { this->ChangeSurfaceStyle(txt); });
3993 action->setCheckable(true);
3994 action->setChecked(true);
3995 action->setData(aIconFile);
3996
3997
3998
3999
4000
4001
4002
4003 if (std::string(aIconFile) == "solid") {
4005 }
4006
4007
4008
4009
4010
4011
4012
4013
4014 }
4015 else if ((std::string(aIconFile) == "perspective") || (std::string(aIconFile) == "ortho")) {
4016 QString txt = QString(aIconFile);
4017 QAction* action = currentToolbar->addAction(
4018 QIcon(*pix), aIconFile, this, [this, txt]() { this->ChangePerspectiveOrtho(txt); });
4019 action->setCheckable(true);
4020 action->setChecked(true);
4021 action->setData(aIconFile);
4022
4023 if (std::string(aIconFile) == "perspective") {
4025 }
4026 if (std::string(aIconFile) == "ortho") {
4028 }
4029
4030 }
4031 else if (std::string(aIconFile) == "reset_camera") {
4032 currentToolbar->addAction(QIcon(*pix), aIconFile, this, [this]() { this->ResetCameraCallback(); });
4033 }
4034 else {
4035
4037 if (UI == nullptr) return;
4038 G4UIcommandTree* treeTop = UI->
GetTree();
4039 if (aCommand != nullptr) {
4040 std::string str = aCommand;
4041 std::string::size_type
pos = str.find(
' ');
4042 if (pos != std::string::npos) {
4043 str = str.substr(0, pos).c_str();
4044 }
4045 if (treeTop->
FindPath(str.c_str()) ==
nullptr) {
4048
4049 if (verbose >= 2) {
4050 G4cout <<
"Warning: command '" << aCommand
4051 <<
"' does not exist, please define it before using it." <<
G4endl;
4052 }
4053 }
4054 }
4055 QString txt = QString(aCommand);
4056 currentToolbar->addAction(QIcon(*pix), aCommand, this,
4057 [this, txt]() { this->ButtonCallback(txt); });
4058 }
4059}
void SetIconOrthoSelected()
void SetIconPerspectiveSelected()
void SetIconSolidSelected()
void SetIconRotateSelected()
G4String FindMacroPath(const G4String &fname) const