Skip to content

Commit 609999e

Browse files
authored
feat(iv): add iv data and display windows overlay (#4443)
Adding data and display window overlay in iv. Dashed line: Display window Solid line: Data window Off by default, select "Show display and data window borders" from the View menu. --------- Signed-off-by: tkchanat <andychancse@gmail.com>
1 parent a5dd2c3 commit 609999e

File tree

4 files changed

+93
-5
lines changed

4 files changed

+93
-5
lines changed

src/iv/imageviewer.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,12 @@ ImageViewer::createActions()
386386
// toggleImageAct->setEnabled(true);
387387
connect(toggleImageAct, SIGNAL(triggered()), this, SLOT(toggleImage()));
388388

389+
toggleWindowGuidesAct
390+
= new QAction(tr("Show display and data window borders"), this);
391+
toggleWindowGuidesAct->setCheckable(true);
392+
connect(toggleWindowGuidesAct, SIGNAL(triggered()), this,
393+
SLOT(toggleWindowGuides()));
394+
389395
slideShowAct = new QAction(tr("Start Slide Show"), this);
390396
connect(slideShowAct, SIGNAL(triggered()), this, SLOT(slideShow()));
391397

@@ -674,6 +680,7 @@ ImageViewer::createMenus()
674680
viewMenu->addAction(prevImageAct);
675681
viewMenu->addAction(nextImageAct);
676682
viewMenu->addAction(toggleImageAct);
683+
viewMenu->addAction(toggleWindowGuidesAct);
677684
viewMenu->addSeparator();
678685
viewMenu->addAction(zoomInAct);
679686
viewMenu->addAction(zoomOutAct);
@@ -1349,6 +1356,14 @@ ImageViewer::toggleImage()
13491356

13501357

13511358

1359+
void
1360+
ImageViewer::toggleWindowGuides()
1361+
{
1362+
((QOpenGLWidget*)(glwin))->update();
1363+
}
1364+
1365+
1366+
13521367
void
13531368
ImageViewer::exposureMinusOneTenthStop()
13541369
{

src/iv/imageviewer.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ class ImageViewer final : public QMainWindow {
223223
return showPixelviewWindowAct && showPixelviewWindowAct->isChecked();
224224
}
225225

226+
bool windowguidesOn(void) const
227+
{
228+
return toggleWindowGuidesAct && toggleWindowGuidesAct->isChecked();
229+
}
230+
226231
bool pixelviewFollowsMouse(void) const
227232
{
228233
return pixelviewFollowsMouseBox
@@ -268,11 +273,12 @@ private slots:
268273
/// change the zoom, even to fit on screen. If minsize is true, do not
269274
/// resize smaller than default_width x default_height.
270275
void fitWindowToImage(bool zoomok = true, bool minsize = false);
271-
void fullScreenToggle(); ///< Toggle full screen mode
272-
void about(); ///< Show "about iv" dialog
273-
void prevImage(); ///< View previous image in sequence
274-
void nextImage(); ///< View next image in sequence
275-
void toggleImage(); ///< View most recently viewed image
276+
void fullScreenToggle(); ///< Toggle full screen mode
277+
void about(); ///< Show "about iv" dialog
278+
void prevImage(); ///< View previous image in sequence
279+
void nextImage(); ///< View next image in sequence
280+
void toggleImage(); ///< View most recently viewed image
281+
void toggleWindowGuides(); ///< Toggle data and display window overlay
276282
void exposureMinusOneTenthStop(); ///< Decrease exposure 1/10 stop
277283
void exposureMinusOneHalfStop(); ///< Decrease exposure 1/2 stop
278284
void exposurePlusOneTenthStop(); ///< Increase exposure 1/10 stop
@@ -374,6 +380,7 @@ private slots:
374380
QAction* showInfoWindowAct;
375381
QAction* editPreferencesAct;
376382
QAction* showPixelviewWindowAct;
383+
QAction* toggleWindowGuidesAct;
377384
QMenu *fileMenu, *editMenu, /**imageMenu,*/ *viewMenu, *toolsMenu,
378385
*helpMenu;
379386
QMenu* openRecentMenu;

src/iv/ivgl.cpp

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,32 @@ gl_rect(float xmin, float ymin, float xmax, float ymax, float z = 0,
472472

473473

474474

475+
static void
476+
gl_rect_border(float xmin, float ymin, float xmax, float ymax, float z = 0)
477+
{
478+
glBegin(GL_LINE_LOOP);
479+
glVertex3f(xmin, ymin, z);
480+
glVertex3f(xmax, ymin, z);
481+
glVertex3f(xmax, ymax, z);
482+
glVertex3f(xmin, ymax, z);
483+
glEnd();
484+
}
485+
486+
487+
488+
static void
489+
gl_rect_dotted_border(float xmin, float ymin, float xmax, float ymax,
490+
float z = 0)
491+
{
492+
glPushAttrib(GL_ENABLE_BIT);
493+
glLineStipple(1, 0xF0F0);
494+
glEnable(GL_LINE_STIPPLE);
495+
gl_rect_border(xmin, ymin, xmax, ymax, z);
496+
glPopAttrib();
497+
}
498+
499+
500+
475501
static void
476502
handle_orientation(int orientation, int width, int height, float& scale_x,
477503
float& scale_y, float& rotate_z, float& point_x,
@@ -634,6 +660,10 @@ IvGL::paintGL()
634660
}
635661
}
636662

663+
if (m_viewer.windowguidesOn()) {
664+
paint_windowguides();
665+
}
666+
637667
glPopMatrix();
638668

639669
if (m_viewer.pixelviewOn()) {
@@ -908,6 +938,41 @@ IvGL::paint_pixelview()
908938

909939

910940

941+
void
942+
IvGL::paint_windowguides()
943+
{
944+
IvImage* img = m_current_image;
945+
const ImageSpec& spec(img->spec());
946+
947+
glDisable(GL_TEXTURE_2D);
948+
glUseProgram(0);
949+
glPushAttrib(GL_ENABLE_BIT);
950+
glEnable(GL_COLOR_LOGIC_OP);
951+
glLogicOp(GL_XOR);
952+
953+
// Data window
954+
{
955+
const float xmin = spec.x;
956+
const float xmax = spec.x + spec.width;
957+
const float ymin = spec.y;
958+
const float ymax = spec.y + spec.height;
959+
gl_rect_border(xmin, ymin, xmax, ymax);
960+
}
961+
962+
// Display window
963+
{
964+
const float xmin = spec.full_x;
965+
const float xmax = spec.full_x + spec.full_width;
966+
const float ymin = spec.full_y;
967+
const float ymax = spec.full_y + spec.full_height;
968+
gl_rect_dotted_border(xmin, ymin, xmax, ymax);
969+
}
970+
971+
glPopAttrib();
972+
}
973+
974+
975+
911976
void
912977
IvGL::useshader(int tex_width, int tex_height, bool pixelview)
913978
{

src/iv/ivgl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ class IvGL : public QOpenGLWidget, protected QOpenGLExtraFunctions {
151151
void focusOutEvent(QFocusEvent* event) override;
152152

153153
void paint_pixelview();
154+
void paint_windowguides();
154155
void glSquare(float xmin, float ymin, float xmax, float ymax, float z = 0);
155156

156157
virtual void create_shaders(void);

0 commit comments

Comments
 (0)