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
Improve egs_view editor input checking
  • Loading branch information
rtownson committed Sep 17, 2024
commit 19922d9f6ce4403f34fb2a0f6da793f22d919f05
11 changes: 7 additions & 4 deletions HEN_HOUSE/egs++/egs_base_geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,14 @@ class label {
};

static shared_ptr<EGS_BlockInput> blockInput = make_shared<EGS_BlockInput>("geometry");
static void setBaseGeometryInputs() {
static void setBaseGeometryInputs(bool includeMediaBlock = true) {
blockInput->addSingleInput("name", true, "The user-declared unique name of this geometry. This is the name you may refer to elsewhere in the input file");
shared_ptr<EGS_BlockInput> mediaBlock = blockInput->addBlockInput("media input");
mediaBlock->addSingleInput("media", true, "A list of media that are used in this geometry");
mediaBlock->addSingleInput("set medium", false, "TODO");

if(includeMediaBlock) {
shared_ptr<EGS_BlockInput> mediaBlock = blockInput->addBlockInput("media input");
mediaBlock->addSingleInput("media", true, "A list of media that are used in this geometry");
mediaBlock->addSingleInput("set medium", false, "TODO");
}
}

/*! \brief Base geometry class. Every geometry class must be derived from
Expand Down
106 changes: 87 additions & 19 deletions HEN_HOUSE/egs++/egs_input_struct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ void EGS_InputStruct::addBlockInput(shared_ptr<EGS_BlockInput> block) {
}

void EGS_InputStruct::addBlockInputs(vector<shared_ptr<EGS_BlockInput>> blocks) {
egsInformation("testA EGS_InputStruct::addBlockInputs\n");
blockInputs.insert(blockInputs.end(), blocks.begin(), blocks.end());
}

Expand Down Expand Up @@ -102,12 +101,12 @@ string EGS_BlockInput::getTitle() {
return blockTitle;
}

void EGS_BlockInput::addSingleInput(string attr, bool isReq, const string desc, const vector<string> vals) {
singleInputs.push_back(make_shared<EGS_SingleInput>(attr, isReq, desc, vals));
shared_ptr<EGS_SingleInput> EGS_BlockInput::addSingleInput(string inputTag, bool isReq, const string desc, const vector<string> vals) {
singleInputs.push_back(make_shared<EGS_SingleInput>(inputTag, isReq, desc, vals));
return singleInputs.back();
}

shared_ptr<EGS_BlockInput> EGS_BlockInput::addBlockInput(string blockTit, bool isReq) {
egsInformation("addBlockInput\n");
blockInputs.push_back(make_shared<EGS_BlockInput>(blockTit, isReq, shared_from_this()));

return blockInputs.back();
Expand All @@ -117,21 +116,72 @@ vector<shared_ptr<EGS_SingleInput>> EGS_BlockInput::getSingleInputs() {
return singleInputs;
}

vector<shared_ptr<EGS_SingleInput>> EGS_BlockInput::getSingleInputs(string title) {
if(egsEquivStr(blockTitle, title)) {
return singleInputs;
} else {
for(auto &block: blockInputs) {
auto inp = block->getSingleInputs(title);
if(inp.size() > 0) {
return inp;
}
}
}

return {};
}

vector<shared_ptr<EGS_BlockInput>> EGS_BlockInput::getBlockInputs() {
return blockInputs;
}

shared_ptr<EGS_SingleInput> EGS_BlockInput::getSingleInput(string attr) {
shared_ptr<EGS_SingleInput> EGS_BlockInput::getSingleInput(string inputTag) {
for(auto& inp : singleInputs) {
// TODO: this assumes unique attr
if(inp && inp->getAttribute() == attr) {
// TODO: this assumes unique inputTag
if(inp && egsEquivStr(inp->getTag(), inputTag)) {
return inp;
}
}

return nullptr;
}

shared_ptr<EGS_SingleInput> EGS_BlockInput::getSingleInput(string inputTag, string title) {
// First search the top-level input block
if(egsEquivStr(blockTitle, title)) {
for(auto &inp: singleInputs) {
// TODO: this assumes unique inputTag
if(inp && egsEquivStr(inp->getTag(), inputTag)) {
return inp;
}
}
}

// If not found, go through input lower level blocks
for(auto &block: blockInputs) {
auto inp = block->getSingleInput(inputTag, title);
if(inp) {
return inp;
}
}

return nullptr;
}

shared_ptr<EGS_BlockInput> EGS_BlockInput::getBlockInput(string title) {
if(egsEquivStr(blockTitle, title)) {
return shared_from_this();
} else {
for(auto &block: blockInputs) {
if(egsEquivStr(block->getTitle(), title)) {
return block;
}
}
}

return nullptr;
}

void EGS_BlockInput::setParent(shared_ptr<EGS_BlockInput> par) {
parent = par;
}
Expand All @@ -141,23 +191,23 @@ shared_ptr<EGS_BlockInput> EGS_BlockInput::getParent() {
}

shared_ptr<EGS_BlockInput> EGS_BlockInput::getLibraryBlock(string blockTitle, string libraryName) {

// First search the singleInputs for the library name
// only if the block title matches (e.g. it's a geometry, or a source)
if(this->getTitle() == blockTitle) {
// TODO: remove blockTitle from input params??
//if(this->getTitle() == blockTitle) {
for(auto &inp: singleInputs) {
if(!inp) {
continue;
}
if(egsEquivStr(inp->getAttribute(), "library")) {
if(egsEquivStr(inp->getTag(), "library")) {
if(inp->getValues().size() && egsEquivStr(inp->getValues().front(), libraryName)) {
return shared_from_this();
} else {
break;
}
}
}
}
//}

// If not found, go through input blocks
for(auto &block: blockInputs) {
Expand All @@ -174,34 +224,52 @@ bool EGS_BlockInput::contains(string inputTag) {
if(!inp) {
continue;
}
if(egsEquivStr(inp->getAttribute(), inputTag)) {
if(egsEquivStr(inp->getTag(), inputTag)) {
return true;
}
}
return false;
}

void EGS_BlockInput::addDependency(shared_ptr<EGS_SingleInput> inp, string val) {
dependencyInp = inp;
dependencyVal = val;
}

shared_ptr<EGS_SingleInput> EGS_BlockInput::getDependencyInp() {
return dependencyInp;
}

string EGS_BlockInput::getDependencyVal() {
return dependencyVal;
}

EGS_SingleInput::EGS_SingleInput() {}

EGS_SingleInput::EGS_SingleInput(string attr, bool isReq, const string desc, const vector<string> vals) {
attribute = attr;
EGS_SingleInput::EGS_SingleInput(string inputTag, bool isReq, const string desc, const vector<string> vals) {
tag = inputTag;
isRequired = isReq;
description = desc;
values = vals;
}

EGS_SingleInput::~EGS_SingleInput() {}

void EGS_SingleInput::addRequirement(string attr, string val) {

void EGS_SingleInput::addDependency(shared_ptr<EGS_SingleInput> inp, string val) {
dependencyInp.push_back(inp);
dependencyVal.push_back(val);
}

vector<EGS_SingleInput> EGS_SingleInput::getDependents() {
vector<shared_ptr<EGS_SingleInput>> EGS_SingleInput::getDependencyInp() {
return dependencyInp;
}

vector<string> EGS_SingleInput::getDependencyVal() {
return dependencyVal;
}

string EGS_SingleInput::getAttribute() {
return attribute;
string EGS_SingleInput::getTag() {
return tag;
}

bool EGS_SingleInput::getRequired() {
Expand Down
32 changes: 20 additions & 12 deletions HEN_HOUSE/egs++/egs_input_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,26 @@ class EGS_EXPORT EGS_SingleInput {

public:
EGS_SingleInput();
EGS_SingleInput(string attr, bool isReq, const string desc, const vector<string> vals);
string getAttribute();
bool getRequired();
EGS_SingleInput(string inputTag, bool isReq, const string desc, const vector<string> vals);
~EGS_SingleInput();

string getTag();
bool getRequired();
const vector<string> getValues();
string getDescription();

protected:

void addRequirement(string attr, string value="");
vector<EGS_SingleInput> getDependents();
void addDependency(shared_ptr<EGS_SingleInput> inp, string val="");
vector<shared_ptr<EGS_SingleInput>> getDependencyInp();
vector<string> getDependencyVal();

private:

vector<EGS_SingleInput> dependents;
vector<string> requirements;
string attribute;
string tag;
bool isRequired;
string description;
vector<string> values;
vector<shared_ptr<EGS_SingleInput>> dependencyInp;
vector<string> dependencyVal;
};

class EGS_EXPORT EGS_BlockInput
Expand All @@ -84,15 +84,21 @@ class EGS_EXPORT EGS_BlockInput

void setTitle(string blockTit);
string getTitle();
void addSingleInput(string attr, bool isReq, const string desc, const vector<string> vals = vector<string>());
shared_ptr<EGS_SingleInput> addSingleInput(string inputTag, bool isReq, const string desc, const vector<string> vals = vector<string>());
shared_ptr<EGS_BlockInput> addBlockInput(string blockTit, bool isReq = false);
vector<shared_ptr<EGS_SingleInput>> getSingleInputs();
vector<shared_ptr<EGS_SingleInput>> getSingleInputs(string title);
vector<shared_ptr<EGS_BlockInput>> getBlockInputs();
shared_ptr<EGS_SingleInput> getSingleInput(string attr);
shared_ptr<EGS_SingleInput> getSingleInput(string inputTag);
shared_ptr<EGS_SingleInput> getSingleInput(string inputTag, string title);
shared_ptr<EGS_BlockInput> getBlockInput(string title);
void setParent(shared_ptr<EGS_BlockInput> par);
shared_ptr<EGS_BlockInput> getParent();
shared_ptr<EGS_BlockInput> getLibraryBlock(string blockTitle, string libraryName);
bool contains(string inputTag);
void addDependency(shared_ptr<EGS_SingleInput> inp, string val="");
shared_ptr<EGS_SingleInput> getDependencyInp();
string getDependencyVal();


private:
Expand All @@ -103,6 +109,8 @@ class EGS_EXPORT EGS_BlockInput
string blockTitle;
bool isRequired;
const string desc;
shared_ptr<EGS_SingleInput> dependencyInp;
string dependencyVal;
};

class EGS_EXPORT EGS_InputStruct {
Expand Down
1 change: 1 addition & 0 deletions HEN_HOUSE/egs++/geometry/egs_box/egs_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#
# Contributors: Frederic Tessier
# Marc Chamberland
# Reid Townson
#
###############################################################################
*/
Expand Down
32 changes: 8 additions & 24 deletions HEN_HOUSE/egs++/geometry/egs_cd_geometry/egs_cd_geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# Contributors: Frederic Tessier
# Ernesto Mainegra-Hing
# Marc Chamberland
# Reid Townson
#
###############################################################################
*/
Expand All @@ -52,22 +53,6 @@ string EGS_CDGeometry::type(typeStr);

static bool EGS_CDGEOMETRY_LOCAL inputSet = false;

struct EGS_CDGEOMETRY_LOCAL InputOptions {
string bg_name;
};
InputOptions inp;

// Process inputs from the egsinp file
EGS_CDGEOMETRY_LOCAL int processInputs(EGS_Input *input) {
// int err = input->getInput(ebox_key1,inp.boxSize);
// if(err && blockInput->getSingleInput(ebox_key1)->getRequired()) {
// egsWarning(ebox_message1,ebox_message3);
// return 0;
// }

return 1;
}

void EGS_CDGeometry::setMedia(EGS_Input *,int,const int *) {
egsWarning("EGS_CDGeometry::setMedia: don't use this method. Use the\n"
" setMedia() methods of the geometry objects that make up this geometry\n");
Expand Down Expand Up @@ -133,11 +118,14 @@ extern "C" {
static void setInputs() {
inputSet = true;

setBaseGeometryInputs(false);

// Format: name, isRequired, description, vector string of allowed values
blockInput->addSingleInput("library", true, "The type of geometry, loaded by shared library in egs++/dso", vector<string>(1, typeStr));

blockInput->addSingleInput("base geometry", true, "The name of the geometry that defines regions for this 'cutting device'. It is within these regions that other geometries will be placed to create a composite geometry");
blockInput->addSingleInput("set geometry", true, "The region number in the base geometry, followed by the name of the geometry to place in that region. If this geometry extends beyond the region boundaries, it will be cut to size");
blockInput->addSingleInput("new indexing style", false, "Set to 1 to use a new region numbering algorithm. Defaults to 0, to use the original indexing style");
}

EGS_CDGEOMETRY_EXPORT string getExample() {
Expand Down Expand Up @@ -174,20 +162,16 @@ extern "C" {
delete ij;
}

if(!processInputs(input)) {
egsWarning("Failed to process the inputs for %s.\n", typeStr.c_str());
return 0;
}

int err = input->getInput("base geometry",inp.bg_name);
string bg_name;
int err = input->getInput("base geometry", bg_name);
if (err) {
egsWarning("createGeometry(CD_Geometry): no 'base geometry' input\n");
return 0;
}
EGS_BaseGeometry *g = EGS_BaseGeometry::getGeometry(inp.bg_name);
EGS_BaseGeometry *g = EGS_BaseGeometry::getGeometry(bg_name);
if (!g) {
egsWarning("createGeometry(CD_Geometry): no geometry named %s is"
" defined\n",inp.bg_name.c_str());
" defined\n",bg_name.c_str());
return 0;
}
int nreg = g->regions();
Expand Down
Loading