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

Update egs_view layout #427

Merged
merged 14 commits into from
Aug 23, 2018
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ class EGS_DOSE_SCORING_EXPORT EGS_DoseScoring : public EGS_AusgabObject {
dose_geom= dgeom;
file_type = ftype;
};
bool getOutputFile(EGS_BaseGeometry *&dgeom, int &ftype) {
dgeom = dose_geom;
ftype = file_type;
return output_dose_file;
};
void setUserNorm(const EGS_Float &normi) {
norm_u=normi;
};
Expand Down
41 changes: 33 additions & 8 deletions HEN_HOUSE/egs++/egs_base_geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,27 @@ class EGS_LOCAL EGS_GeometryPrivate {
int j = 0, iloop = 0;
while (nnow > 0) {
if (geoms[j]->deref() == -1) {
delete geoms[j];
removeGeometry(geoms[j]);
}
else {
geoms[j++]->ref();
}
if (j >= nnow && nnow) {
j = 0;
++iloop;
if (iloop > 20) egsWarning("~EGS_GeometryPrivate(): failed "
"to delete all geometries after 20 loops!\n");
break;

for (int i=0; i<nnow; ++i) {
if (!geoms[i]->deref()) {
removeGeometry(geoms[i]);
}
}

if (iloop > 20) {
// egsWarning("~EGS_GeometryPrivate(): failed "
// "to delete all geometries after 20 loops!\n");

break;
}
}
}
};
Expand Down Expand Up @@ -178,12 +188,19 @@ class EGS_LOCAL EGS_GeometryPrivate {
};

void removeGeometry(EGS_BaseGeometry *g) {
ntot--;
EGS_BaseGeometry **tmp = new EGS_BaseGeometry* [ntot];
int i=0;
for (int j=0; j<nnow; j++) {
if (geoms[j] == g) {
geoms[j] = geoms[--nnow];
break;
if (geoms[j] != g) {
tmp[i++] = geoms[j];
}
}
if (geoms) {
delete [] geoms;
}
nnow--;
geoms = tmp;
};

EGS_BaseGeometry *getGeometry(const string &name) {
Expand Down Expand Up @@ -422,7 +439,7 @@ EGS_BaseGeometry::EGS_BaseGeometry(const string &Name) : nreg(0), name(Name),
}
if (egs_geometries[active_glist].addGeometry(this) < 0)
egsFatal("EGS_BaseGeometry::EGS_BaseGeometry:\n"
" a geometry with name %s alread exists\n",name.c_str());
" a geometry with name %s already exists\n",name.c_str());
}

EGS_BaseGeometry::~EGS_BaseGeometry() {
Expand Down Expand Up @@ -450,6 +467,14 @@ EGS_BaseGeometry *EGS_BaseGeometry::getGeometry(const string &Name) {
return egs_geometries[active_glist].getGeometry(Name);
}

EGS_BaseGeometry **EGS_BaseGeometry::getGeometries() {
return egs_geometries[active_glist].geoms;
}

int EGS_BaseGeometry::getNGeometries() {
return egs_geometries[active_glist].nnow;
}

void EGS_BaseGeometry::setMedium(const string &Name) {
med = egs_geometries[active_glist].addMedium(Name);
if (region_media)
Expand Down
4 changes: 4 additions & 0 deletions HEN_HOUSE/egs++/egs_base_geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,10 @@ class EGS_EXPORT EGS_BaseGeometry {
*/
static EGS_BaseGeometry *getGeometry(const string &Name);

static EGS_BaseGeometry **getGeometries();

static int getNGeometries();

/*! \brief Get a unique geometry name

This function is used to create a unique name for a nameless
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class EGS_FANO_SOURCE_EXPORT EGS_FanoSource :
while (!okfano);
u.z = buf_1 - rndm->getUniform()*(buf_1 - buf_2);
EGS_Float sinz = 1-u.z*u.z;
if ( sinz > epsilon ) {
if (sinz > epsilon) {
sinz = sqrt(sinz);
EGS_Float cphi, sphi;
EGS_Float phi = min_phi + (max_phi - min_phi)*rndm->getUniform();
Expand Down
67 changes: 50 additions & 17 deletions HEN_HOUSE/egs++/view/clippingplanes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,44 +44,48 @@ ClippingPlanesWidget::ClippingPlanesWidget(QWidget *parent, const char *name)
: QWidget(parent) {
setObjectName(name);
setupUi(this);
#if QT_VERSION >= 0x050000
planeTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
#else
planeTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
#endif

planeTable->setColumnWidth(0,60);
planeTable->setColumnWidth(1,60);
planeTable->setColumnWidth(2,60);
planeTable->setColumnWidth(3,60);
planeTable->setColumnWidth(4,28);
}

ClippingPlanesWidget::~ClippingPlanesWidget() {
}

void ClippingPlanesWidget::applyClicked() {
void ClippingPlanesWidget::applyClipping() {
emit clippingPlanesChanged();
}


void ClippingPlanesWidget::helpClicked() {
#ifdef VIEW_DEBUG
egsWarning("In ClippingPlanesWidget::helpClicked()\n");
#endif
}


int ClippingPlanesWidget::numPlanes() {
return planeTable->rowCount();
}

QTableWidgetItem *ClippingPlanesWidget::getItem(int i, int j) {
QTableWidgetItem *item = planeTable->item(i,j);
return item;
}


bool ClippingPlanesWidget::getPlane(int j, EGS_Vector &a, EGS_Float &d) {
// check if all row items exist and are selected.
QTableWidgetItem *itemAx = planeTable->item(j,0),
*itemAy = planeTable->item(j,1),
*itemAz = planeTable->item(j,2),
*itemD = planeTable->item(j,3);
if (!itemAx || !itemAy || !itemAz || !itemD) {
*itemD = planeTable->item(j,3),
*itemApplied = planeTable->item(j,4);

// Make sure all parameters for a plane exist
if (!itemAx || !itemAy || !itemAz || !itemD || !itemApplied) {
return false;
}
if (!itemAx->isSelected() || !itemAy->isSelected() ||
!itemAz->isSelected() || !itemD->isSelected()) {

// See if the checkbox in the 4th column is checked
// Only use the plane if it is checked
if (itemApplied->checkState() == Qt::Unchecked) {
return false;
}

Expand Down Expand Up @@ -112,3 +116,32 @@ bool ClippingPlanesWidget::getPlane(int j, EGS_Vector &a, EGS_Float &d) {
return true;
}

void ClippingPlanesWidget::setCell(int i, int j, EGS_Float val) {
QTableWidgetItem *item = planeTable->item(i,j);

if (!item) {
item = new QTableWidgetItem();
planeTable->setItem(i,j,item);
}

item->setText(QString::number(val));
}

void ClippingPlanesWidget::setCell(int i, int j, Qt::CheckState checked) {
QTableWidgetItem *item = planeTable->item(i,j);

if (!item) {
item = new QTableWidgetItem();
planeTable->setItem(i,j,item);
}

item->setCheckState(checked);
}

void ClippingPlanesWidget::clearCell(int i, int j) {
QTableWidgetItem *item = planeTable->item(i,j);

if (item) {
delete item;
}
}
12 changes: 6 additions & 6 deletions HEN_HOUSE/egs++/view/clippingplanes.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ class ClippingPlanesWidget : public QWidget, public Ui::ClippingPlanesWidget {

virtual int numPlanes();
virtual bool getPlane(int j, EGS_Vector &a, EGS_Float &d);

public slots:

virtual void helpClicked();
virtual void setCell(int i, int j, EGS_Float val);
virtual void setCell(int i, int j, Qt::CheckState checked);
virtual void clearCell(int i, int j);
virtual QTableWidgetItem *getItem(int i, int j);

signals:

Expand All @@ -59,8 +59,8 @@ protected slots:
virtual void languageChange() {
retranslateUi(this);
}
virtual void applyClicked();
virtual void applyClipping();

};

#endif // CLIPPINGPLANESWIDGET_H
#endif // CLIPPINGPLANESWIDGET_H
Loading