Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add egs_view egsinp editor with autocompletion for all egs++ apps #1164

Draft
wants to merge 40 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
5cf74da
Add a text editor to egs_view
rtownson Aug 3, 2019
439a0dc
Non-working temporary commit
rtownson Dec 13, 2019
1caf68c
Add a text editor to egs_view
rtownson Aug 3, 2019
0d03724
Non-working temporary commit
rtownson Dec 13, 2019
5642956
Add editor autocomplete and input checking
rtownson Feb 4, 2020
19922d9
Improve egs_view editor input checking
rtownson Feb 22, 2020
212a9f2
Add egs_view editor input dependency checking
rtownson Mar 13, 2020
b7da362
Start adding egs_view editor definition blocks
rtownson Mar 13, 2020
618c6f0
Add egs_view editor source and shape support
rtownson Mar 31, 2020
406f174
Add egs_editor input example menu bar
rtownson Apr 3, 2020
31d2374
Temp
rtownson May 13, 2020
d6fca07
Add egs_editor support for transformations
rtownson Jul 7, 2020
916f1f0
Start adding egs_editor run control support
rtownson Jul 20, 2020
e320166
Finish adding run control inputs to egs_editor
rtownson Jul 23, 2020
85326e6
Improve egs_editor undo history
rtownson Jul 30, 2020
4d2895c
Add Geometry Input Validation
Feb 2, 2021
1d65c15
Add sources, ausgab, other egs_view editor support
hcgallop Feb 10, 2021
0f59cd3
Add support for shapes in egs_view editor
hcgallop Feb 15, 2021
790ed98
Add keystroke seletion to egs_editor
hcgallop Feb 26, 2021
dbcec3a
Add support for applications in egs_view editor
hcgallop Apr 26, 2021
ea05f21
Add support for red line comments
hcgallop Apr 30, 2021
ecd69e2
Fix the recent egs_view ui changes
May 19, 2021
81a28e4
Fix the egs_view dso link to be a relative path
rtownson May 20, 2021
99b8ef4
Add iaea_phsp_source editor inputs
rtownson Apr 6, 2022
2a2e604
Remove old egs_view debug messages
rtownson Apr 7, 2022
70be98a
Improve egs_editor support for shapes
rtownson May 2, 2022
c8c35a9
Run astyle to fix formatting
rtownson May 10, 2022
c78965f
Fix a few typos in the egs_editor additions
rtownson Jun 28, 2022
868f84c
Update egs_input_struct documentation
rtownson Jul 4, 2022
85a78cf
Tidy up egs_view debug output
rtownson Jul 5, 2022
9549983
Fix egs_view image scaling when reloading or saving
rtownson Nov 9, 2023
be3fe92
Add the library auto complete for ausgab objects
rtownson Nov 9, 2023
d251483
Add more egs_editor completion and examples
Xuan-Zheng05 Jul 26, 2024
a45213c
Fixed hardcoded path to density correction files with system dependen…
Xuan-Zheng05 Aug 10, 2024
56e1cce
Fix pegless material autocompletion to work with any name
Xuan-Zheng05 Aug 14, 2024
d2b97b9
Fix incorrect example for media definition
Xuan-Zheng05 Aug 22, 2024
a509ab2
Fix autocomplete error from pegless material addition
Xuan-Zheng05 Aug 30, 2024
efcfc4d
Fix egs_editor medium autocomplete
rtownson Aug 8, 2024
59ea112
Fix make clean of application library objects
rtownson Aug 8, 2024
99e2cbb
Tidy up merge with branch from Xuan
rtownson Sep 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed hardcoded path to density correction files with system dependen…
…t path
  • Loading branch information
Xuan-Zheng05 authored and rtownson committed Sep 17, 2024
commit a45213c221cd157e8e8fc5920137e5900e100c69
52 changes: 0 additions & 52 deletions HEN_HOUSE/egs++/egs_application.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,54 +65,6 @@ class EGS_AusgabObject;
class EGS_Interpolator;
//template <class T> class EGS_SimpleContainer;

// Looks into \EGSnrc\HEN_HOUSE\pegs4\density_corrections\compounds for the density correction files
// returns a string vector of the file names
static vector<string> findDensityCorrectionInputs() {
vector<string> fileList;
#ifdef WIN32
const char fs = '\\';
#else
const char fs = '/';
#endif

string compound_dir = "C:";
compound_dir += fs;
compound_dir += "EGSnrc";
compound_dir += fs;
compound_dir += "HEN_HOUSE";
compound_dir += fs;
compound_dir += "pegs4";
compound_dir += fs;
compound_dir += "density_corrections";
compound_dir += fs;
compound_dir += "compounds";

DIR *dir;
struct dirent *ent;

if ((dir = opendir(compound_dir.c_str())) != NULL) {
while ((ent = readdir(dir)) != NULL) {
string filename = ent->d_name;

// removes the .density at the end of the file
if (filename.find(".density") != string::npos) {
filename = filename.substr(0, filename.find(".density"));
fileList.push_back(filename);
}
}
closedir(dir);
} else {
egsInformation("Failed to open density correction files directory\n");
}

// egsInformation("Printing file titles \n");
// for (const auto& file : fileList) {
// egsInformation("%s\n", file.c_str());
// }

return fileList;
}

static void addmcBlock(shared_ptr<EGS_InputStruct> blockPtr) {
shared_ptr<EGS_BlockInput> mcBlock = blockPtr->addBlockInput("MC transport parameter");
mcBlock->addSingleInput("Global ECUT", false, "Global electron transport cutoff");
Expand Down Expand Up @@ -170,10 +122,6 @@ static void addMediaDefBlock(shared_ptr<EGS_InputStruct> blockPtr) {
mediumBlock->addSingleInput("stopping powers", false, "{restricted total, unrestricted collision, unrestricted collision and radiative, unrestricted collision and restricted radiative, restricted collision and unrestricted radiative, unrestricted radiative}");
mediumBlock->addSingleInput("bremsstrahlung correction", false, "");
mediumBlock->addSingleInput("gas pressure", false, "");

vector<string> densityCorrectionFiles = findDensityCorrectionInputs();
mediumBlock->addSingleInput("density correction file", false, "", densityCorrectionFiles);

mediumBlock->addSingleInput("e- stopping power output file", false, "");
}

Expand Down
54 changes: 53 additions & 1 deletion HEN_HOUSE/egs++/view/viewcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <dirent.h>
using namespace std;

#ifndef M_PI
Expand Down Expand Up @@ -110,6 +111,10 @@ static unsigned char standard_blue[] = {
0, 0, 191, 80, 127, 127, 192, 128
};

// Looks into \EGSnrc\HEN_HOUSE\pegs4\density_corrections\compounds for the density correction files
// returns a string vector of the file names
vector<string> findDensityCorrectionInputs(string compound_dir);

GeometryViewControl::GeometryViewControl(QWidget *parent, const char *name)
: QMainWindow(parent) {
setObjectName(name);
Expand Down Expand Up @@ -314,7 +319,7 @@ GeometryViewControl::GeometryViewControl(QWidget *parent, const char *name)

// before this was a BlockInput, now it is a InputStruct
shared_ptr<EGS_InputStruct> app = getAppInputs();

if (app) {
inputStruct->addBlockInputs(app->getBlockInputs());

Expand Down Expand Up @@ -387,6 +392,16 @@ GeometryViewControl::GeometryViewControl(QWidget *parent, const char *name)
action->setData(QString::fromStdString(getExample()));
connect(action, &QAction::triggered, this, [this] { insertInputExample(); });
}

// Add the denstiy correction files
shared_ptr<EGS_BlockInput> mediaBlockInput = inputStruct->getBlockInput("media definition");
shared_ptr<EGS_BlockInput> mediumBlock = mediaBlockInput->getBlockInput("pegsless");

string compound_dir;
EGS_Application::checkEnvironmentVar(appc,appv,"-H","--hen-house","HEN_HOUSE", compound_dir);
vector<string> densityCorrectionFiles = findDensityCorrectionInputs(compound_dir);

mediumBlock->addSingleInput("density correction file", false, "", densityCorrectionFiles);
}

// Geometry definition block
Expand Down Expand Up @@ -3550,4 +3565,41 @@ void GeometryViewControl::setApplication() {

selectedApplication = newlySelectedApp;
egsinpEdit->setInputStruct(inputStruct);
}

vector<string> findDensityCorrectionInputs(string compound_dir) {
vector<string> fileList;

compound_dir += fs;
compound_dir += "pegs4";
compound_dir += fs;
compound_dir += "density_corrections";
compound_dir += fs;
compound_dir += "compounds";
egsInformation("density file path: %s\n", compound_dir.c_str());

DIR *dir;
struct dirent *ent;

if ((dir = opendir(compound_dir.c_str())) != NULL) {
while ((ent = readdir(dir)) != NULL) {
string filename = ent->d_name;

// removes the .density at the end of the file
if (filename.find(".density") != string::npos) {
filename = filename.substr(0, filename.find(".density"));
fileList.push_back(filename);
}
}
closedir(dir);
} else {
egsInformation("Failed to open density correction files directory\n");
}

// egsInformation("Printing file titles \n");
// for (const auto& file : fileList) {
// egsInformation("%s\n", file.c_str());
// }

return fileList;
}