Skip to content

Commit 4e56aa7

Browse files
authored
feat(iv): area probe (#4767)
Fixes #4714 This PR adds support for selecting a rectangular region within an image to compute and display per-channel minimum, maximum, and average values. The feature can be activated through the Tools menu or by using a keyboard shortcut (Ctrl-A / Cmd-A) . Once active, the user can click and drag with the left mouse button to define a rectangular area, which is visually indicated by a blue outline. Upon releasing the mouse button, the tool calculates statistics for all pixels within the selected area and displays the results in the status bar. --------- Signed-off-by: Danielle Imogu <dannieim689@gmail.com>
1 parent 4bb092e commit 4e56aa7

4 files changed

Lines changed: 314 additions & 4 deletions

File tree

src/iv/imageviewer.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,12 @@ ImageViewer::createActions()
491491
slideShowDuration->setAccelerated(true);
492492
connect(slideShowDuration, SIGNAL(valueChanged(int)), this,
493493
SLOT(setSlideShowDuration(int)));
494+
495+
toggleAreaSampleAct = new QAction(tr("&Toggle Area Sample"), this);
496+
toggleAreaSampleAct->setCheckable(true);
497+
toggleAreaSampleAct->setShortcut(tr("Ctrl+A"));
498+
connect(toggleAreaSampleAct, SIGNAL(triggered()), this,
499+
SLOT(toggleAreaSample()));
494500
}
495501

496502

@@ -737,6 +743,7 @@ ImageViewer::createMenus()
737743
// Mode: select, zoom, pan, wipe
738744
toolsMenu->addAction(showInfoWindowAct);
739745
toolsMenu->addAction(showPixelviewWindowAct);
746+
toolsMenu->addAction(toggleAreaSampleAct);
740747
toolsMenu->addMenu(slideMenu);
741748
toolsMenu->addMenu(sortMenu);
742749

@@ -2387,3 +2394,28 @@ ImageViewer::editPreferences()
23872394
}
23882395
preferenceWindow->show();
23892396
}
2397+
2398+
2399+
2400+
void
2401+
ImageViewer::toggleAreaSample()
2402+
{
2403+
m_areaSampleMode = !m_areaSampleMode;
2404+
if (m_areaSampleMode) {
2405+
setCursor(Qt::CrossCursor);
2406+
} else {
2407+
unsetCursor();
2408+
}
2409+
// if (m_areaSampleMode == false){
2410+
// updateStatusBar();
2411+
// }
2412+
((QOpenGLWidget*)(glwin))->update();
2413+
}
2414+
2415+
2416+
2417+
bool
2418+
ImageViewer::areaSampleMode() const
2419+
{
2420+
return m_areaSampleMode;
2421+
}

src/iv/imageviewer.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ class ImageViewer final : public QMainWindow {
224224
return showPixelviewWindowAct && showPixelviewWindowAct->isChecked();
225225
}
226226

227+
bool probeviewOn(void) const
228+
{
229+
return toggleAreaSampleAct && toggleAreaSampleAct->isChecked();
230+
}
231+
227232
bool windowguidesOn(void) const
228233
{
229234
return toggleWindowGuidesAct && toggleWindowGuidesAct->isChecked();
@@ -249,6 +254,7 @@ class ImageViewer final : public QMainWindow {
249254

250255
void rawcolor(bool val) { m_rawcolor = val; }
251256
bool rawcolor() const { return m_rawcolor; }
257+
bool areaSampleMode() const;
252258

253259
bool useOCIO() { return m_useOCIO; }
254260
const std::string& ocioColorSpace() { return m_ocioColourSpace; }
@@ -316,6 +322,7 @@ private slots:
316322
void showInfoWindow(); ///< View extended info on image
317323
void showPixelviewWindow(); ///< View closeup pixel view
318324
void editPreferences(); ///< Edit viewer preferences
325+
void toggleAreaSample(); ///< Use area probe
319326

320327
void useOCIOAction(bool checked);
321328
void ocioColorSpaceAction();
@@ -385,6 +392,7 @@ private slots:
385392
QAction* showInfoWindowAct;
386393
QAction* editPreferencesAct;
387394
QAction* showPixelviewWindowAct;
395+
QAction* toggleAreaSampleAct;
388396
QAction* toggleWindowGuidesAct;
389397
QMenu *fileMenu, *editMenu, /**imageMenu,*/ *viewMenu, *toolsMenu,
390398
*helpMenu;
@@ -420,7 +428,8 @@ private slots:
420428
float m_default_gamma; // Default gamma of the display
421429
QPalette m_palette; // Custom palette
422430
bool m_darkPalette; // Use dark palette?
423-
bool m_rawcolor = false; // Use raw color mode
431+
bool m_rawcolor = false; // Use raw color mode
432+
bool m_areaSampleMode = false; // Use area sample mode
424433

425434
// The default width and height of the window:
426435
static const int m_default_width = 640;

0 commit comments

Comments
 (0)