Skip to content

Commit

Permalink
unify data and display window overlay
Browse files Browse the repository at this point in the history
Signed-off-by: tkchanat <[email protected]>
  • Loading branch information
tkchanat committed Sep 28, 2024
1 parent e708a04 commit bb01cd4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 65 deletions.
26 changes: 6 additions & 20 deletions src/iv/imageviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,15 +386,10 @@ ImageViewer::createActions()
// toggleImageAct->setEnabled(true);
connect(toggleImageAct, SIGNAL(triggered()), this, SLOT(toggleImage()));

showDataWindowAct = new QAction(tr("Show Data Window (solid line)"), this);
showDataWindowAct->setCheckable(true);
connect(showDataWindowAct, SIGNAL(triggered()), this,
SLOT(toggleDataWindow()));

showDisplayWindowAct = new QAction(tr("Show Display Window (dotted line)"), this);
showDisplayWindowAct->setCheckable(true);
connect(showDisplayWindowAct, SIGNAL(triggered()), this,
SLOT(toggleDisplayWindow()));
toggleWindowGuidesAct = new QAction(tr("Show display and data window borders"), this);
toggleWindowGuidesAct->setCheckable(true);
connect(toggleWindowGuidesAct, SIGNAL(triggered()), this,
SLOT(toggleWindowGuides()));

slideShowAct = new QAction(tr("Start Slide Show"), this);
connect(slideShowAct, SIGNAL(triggered()), this, SLOT(slideShow()));
Expand Down Expand Up @@ -684,8 +679,7 @@ ImageViewer::createMenus()
viewMenu->addAction(prevImageAct);
viewMenu->addAction(nextImageAct);
viewMenu->addAction(toggleImageAct);
viewMenu->addAction(showDataWindowAct);
viewMenu->addAction(showDisplayWindowAct);
viewMenu->addAction(toggleWindowGuidesAct);
viewMenu->addSeparator();
viewMenu->addAction(zoomInAct);
viewMenu->addAction(zoomOutAct);
Expand Down Expand Up @@ -1362,15 +1356,7 @@ ImageViewer::toggleImage()


void
ImageViewer::toggleDataWindow()
{
((QOpenGLWidget*)(glwin))->update();
}



void
ImageViewer::toggleDisplayWindow()
ImageViewer::toggleWindowGuides()
{
((QOpenGLWidget*)(glwin))->update();
}
Expand Down
15 changes: 4 additions & 11 deletions src/iv/imageviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,9 @@ class ImageViewer final : public QMainWindow {
return showPixelviewWindowAct && showPixelviewWindowAct->isChecked();
}

bool datawindowOn(void) const
bool windowguidesOn(void) const
{
return showDataWindowAct && showDataWindowAct->isChecked();
}

bool displaywindowOn(void) const
{
return showDisplayWindowAct && showDisplayWindowAct->isChecked();
return toggleWindowGuidesAct && toggleWindowGuidesAct->isChecked();
}

bool pixelviewFollowsMouse(void) const
Expand Down Expand Up @@ -283,8 +278,7 @@ private slots:
void prevImage(); ///< View previous image in sequence
void nextImage(); ///< View next image in sequence
void toggleImage(); ///< View most recently viewed image
void toggleDataWindow(); ///< Toggle data window overlay
void toggleDisplayWindow(); ///< Toggle display window overlay
void toggleWindowGuides(); ///< Toggle data and display window overlay
void exposureMinusOneTenthStop(); ///< Decrease exposure 1/10 stop
void exposureMinusOneHalfStop(); ///< Decrease exposure 1/2 stop
void exposurePlusOneTenthStop(); ///< Increase exposure 1/10 stop
Expand Down Expand Up @@ -386,8 +380,7 @@ private slots:
QAction* showInfoWindowAct;
QAction* editPreferencesAct;
QAction* showPixelviewWindowAct;
QAction* showDataWindowAct;
QAction* showDisplayWindowAct;
QAction* toggleWindowGuidesAct;
QMenu *fileMenu, *editMenu, /**imageMenu,*/ *viewMenu, *toolsMenu,
*helpMenu;
QMenu* openRecentMenu;
Expand Down
51 changes: 19 additions & 32 deletions src/iv/ivgl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,12 +655,8 @@ IvGL::paintGL()
}
}

if (m_viewer.datawindowOn()) {
paint_datawindow();
}

if (m_viewer.displaywindowOn()) {
paint_displaywindow();
if (m_viewer.windowguidesOn()) {
paint_windowguides();
}

glPopMatrix();
Expand Down Expand Up @@ -938,44 +934,35 @@ IvGL::paint_pixelview()


void
IvGL::paint_datawindow()
IvGL::paint_windowguides()
{
IvImage* img = m_current_image;
const ImageSpec& spec(img->spec());

glDisable(GL_TEXTURE_2D);
glUseProgram(0);

const float xmin = spec.x;
const float xmax = spec.x + spec.width;
const float ymin = spec.y;
const float ymax = spec.y + spec.height;
glPushAttrib(GL_ENABLE_BIT);
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_XOR);
gl_rect_border(xmin, ymin, xmax, ymax);
glPopAttrib();
}

// Data window
{
const float xmin = spec.x;
const float xmax = spec.x + spec.width;
const float ymin = spec.y;
const float ymax = spec.y + spec.height;
gl_rect_border(xmin, ymin, xmax, ymax);
}

// Display window
{
const float xmin = spec.full_x;
const float xmax = spec.full_x + spec.full_width;
const float ymin = spec.full_y;
const float ymax = spec.full_y + spec.full_height;
gl_rect_dotted_border(xmin, ymin, xmax, ymax);
}

void
IvGL::paint_displaywindow()
{
IvImage* img = m_current_image;
const ImageSpec& spec(img->spec());

glDisable(GL_TEXTURE_2D);
glUseProgram(0);

const float xmin = spec.full_x;
const float xmax = spec.full_x + spec.full_width;
const float ymin = spec.full_y;
const float ymax = spec.full_y + spec.full_height;
glPushAttrib(GL_ENABLE_BIT);
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_XOR);
gl_rect_dotted_border(xmin, ymin, xmax, ymax);
glPopAttrib();
}

Expand Down
3 changes: 1 addition & 2 deletions src/iv/ivgl.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ class IvGL : public QOpenGLWidget, protected QOpenGLExtraFunctions {
void focusOutEvent(QFocusEvent* event) override;

void paint_pixelview();
void paint_datawindow();
void paint_displaywindow();
void paint_windowguides();
void glSquare(float xmin, float ymin, float xmax, float ymax, float z = 0);

virtual void create_shaders(void);
Expand Down

0 comments on commit bb01cd4

Please sign in to comment.