Skip to content

Commit

Permalink
Fix regression in egs_view where unchecking Show Regions failed
Browse files Browse the repository at this point in the history
  • Loading branch information
M committed Feb 13, 2016
1 parent 1f98861 commit 3b5d808
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
19 changes: 18 additions & 1 deletion HEN_HOUSE/egs++/view/image_window.cpp
Expand Up @@ -78,6 +78,7 @@ ImageWindow::ImageWindow(QWidget *parent, const char *name) :
regionsDisplayed = true;

isSaving = false;
regionsWanted = false;

vis = new EGS_GeometryVisualizer;

Expand Down Expand Up @@ -185,6 +186,7 @@ void ImageWindow::rerender(EGS_BaseGeometry *geo) {
#endif

renderState = WorkerCalculating;
pars.requestType = ForScreen;
emit requestRender(lastRequestGeo, pars);
}

Expand Down Expand Up @@ -262,6 +264,14 @@ void ImageWindow::endTransformation() {
}
}

void ImageWindow::showRegions(bool show) {
regionsWanted = show;
if (regionsWanted) {
rerenderRequested = true;
}
update();
}

void ImageWindow::resizeEvent(QResizeEvent *e) {
#ifdef VIEW_DEBUG
egsWarning("In resizeEvent(): size is %d %d old size is: %d %d" " shown: %d\n",width(),height(),e->oldSize().width(), e->oldSize().height(),isVisible());
Expand Down Expand Up @@ -295,7 +305,14 @@ void ImageWindow::paintEvent(QPaintEvent *) {
p.end();
}

if (!navigating) {
if (regionsDisplayed && !regionsWanted) {
QPainter p(this);
// repaint just the eclipsed region (painter has clip)
p.drawImage(QPoint(0,0),r.img);
p.end();
}

if (!navigating && regionsWanted) {
// Don't recalculate an identical point, unless
// the rerender wiped everything.
if (!wasRerenderRequested && xyMouse == lastMouse) {
Expand Down
3 changes: 3 additions & 0 deletions HEN_HOUSE/egs++/view/image_window.h
Expand Up @@ -72,6 +72,8 @@ public slots:
void startTransformation();
void endTransformation();

void showRegions(bool show);

protected:

void rerender(EGS_BaseGeometry *geo);
Expand Down Expand Up @@ -117,6 +119,7 @@ protected slots:
// regionPicking synchronized with image on screen
EGS_GeometryVisualizer *vis;
bool regionsDisplayed;
bool regionsWanted;
QPoint xyMouse;
QPoint lastMouse;
int lastRegions[N_REG_MAX];
Expand Down
4 changes: 2 additions & 2 deletions HEN_HOUSE/egs++/view/renderworker.h
Expand Up @@ -40,7 +40,7 @@
using std::vector;

typedef enum {
Transformation, FullDetail, SavedImage
ForScreen, SavedImage
} RenderRequestType;

// This struct is designed to be passed by value.
Expand Down Expand Up @@ -77,7 +77,7 @@ struct RenderParameters {
bool draw_axeslabels;
EGS_Vector axesmax;
EGS_Float size;
// passthrough: request type. Does this belong in the struct?
// Purpose of request
RenderRequestType requestType;
};

Expand Down
4 changes: 2 additions & 2 deletions HEN_HOUSE/egs++/view/viewcontrol.cpp
Expand Up @@ -141,7 +141,6 @@ GeometryViewControl::GeometryViewControl(QWidget *parent, const char *name)
// various state variables
showAxes = this->showAxesCheckbox->isChecked();
showAxesLabels = this->showAxesLabelsCheckbox->isChecked();
showRegions = this->showRegionsCheckbox->isChecked();
showTracks = this->showTracksCheckbox->isChecked();
showPhotonTracks = this->showPhotonsCheckbox->isChecked();
showElectronTracks = this->showElectronsCheckbox->isChecked();
Expand All @@ -163,6 +162,7 @@ GeometryViewControl::GeometryViewControl(QWidget *parent, const char *name)

gview = new ImageWindow(this,"gview");
gview->resize(512,512);
gview->showRegions(this->showRegionsCheckbox->isChecked());

// connect signals and slots for mouse navigation
connect(gview, SIGNAL(cameraRotation(int, int)), this, SLOT(cameraRotate(int, int)));
Expand Down Expand Up @@ -308,7 +308,7 @@ void GeometryViewControl::checkboxAxesLabels(bool toggle) {
}

void GeometryViewControl::checkboxShowRegions(bool toggle) {
showRegions = toggle;
gview->showRegions(toggle);
}

void GeometryViewControl::checkboxShowTracks(bool toggle) {
Expand Down
1 change: 0 additions & 1 deletion HEN_HOUSE/egs++/view/viewcontrol.h
Expand Up @@ -157,7 +157,6 @@ public slots:
EGS_BaseGeometry *g;
bool showAxes;
bool showAxesLabels;
bool showRegions;
bool showTracks;
bool showPhotonTracks;
bool showElectronTracks;
Expand Down

0 comments on commit 3b5d808

Please sign in to comment.