Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions src/iv/imageviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,22 @@ ImageViewer::createActions()
closeupAvgPixelsBox->setToolTip(closeupAvgPixelsTooltip);
closeupAvgPixelsLabel->setToolTip(closeupAvgPixelsTooltip);


rotateLeftAct = new QAction(tr("&Rotate Left"), this);
rotateLeftAct->setShortcut(tr("Ctrl+Shift+L"));
connect(rotateLeftAct, SIGNAL(triggered()), this, SLOT(rotateLeft()));

rotateRightAct = new QAction(tr("&Rotate Right"), this);
rotateRightAct->setShortcut(tr("Ctrl+Shift+R"));
connect(rotateRightAct, SIGNAL(triggered()), this, SLOT(rotateRight()));

flipHorizontalAct = new QAction(tr("&Flip Horizontal"), this);
connect(flipHorizontalAct, SIGNAL(triggered()), this,
SLOT(flipHorizontal()));

flipVerticalAct = new QAction(tr("&Flip Vertical"), this);
connect(flipVerticalAct, SIGNAL(triggered()), this, SLOT(flipVertical()));

// Connect signals to ensure closeupAvgPixelsBox value is always <= closeupPixelsBox value
connect(closeupPixelsBox, QOverload<int>::of(&QSpinBox::valueChanged),
[this](int value) {
Expand Down Expand Up @@ -780,6 +796,11 @@ ImageViewer::createMenus()
toolsMenu->addAction(toggleAreaSampleAct);
toolsMenu->addMenu(slideMenu);
toolsMenu->addMenu(sortMenu);
toolsMenu->addSeparator();
toolsMenu->addAction(rotateLeftAct);
toolsMenu->addAction(rotateRightAct);
toolsMenu->addAction(flipHorizontalAct);
toolsMenu->addAction(flipVerticalAct);

// Menus, toolbars, & status
// Annotate
Expand Down Expand Up @@ -2455,3 +2476,82 @@ ImageViewer::areaSampleMode() const
{
return m_areaSampleMode;
}


void
ImageViewer::rotateLeft()
{
IvImage* img = cur();
if (!img)
return;

ImageSpec* spec = curspecmod();

int curr_orientation = spec->get_int_attribute("Orientation", 1);

if (curr_orientation >= 1 && curr_orientation <= 8) {
static int next_orientation[] = { 0, 8, 5, 6, 7, 4, 1, 2, 3 };
curr_orientation = next_orientation[curr_orientation];
spec->attribute("Orientation", curr_orientation);
}
displayCurrentImage();
}


void
ImageViewer::rotateRight()
{
IvImage* img = cur();
if (!img)
return;

ImageSpec* spec = curspecmod();
int curr_orientation = spec->get_int_attribute("Orientation", 1);

if (curr_orientation >= 1 && curr_orientation <= 8) {
static int next_orientation[] = { 0, 6, 7, 8, 5, 2, 3, 4, 1 };
curr_orientation = next_orientation[curr_orientation];
spec->attribute("Orientation", curr_orientation);
}
displayCurrentImage();
}


void
ImageViewer::flipHorizontal()
{
IvImage* img = cur();
if (!img)
return;

ImageSpec* spec = curspecmod();

int curr_orientation = spec->get_int_attribute("Orientation", 1);

if (curr_orientation >= 1 && curr_orientation <= 8) {
static int next_orientation[] = { 0, 2, 1, 4, 3, 6, 5, 8, 7 };
curr_orientation = next_orientation[curr_orientation];
spec->attribute("Orientation", curr_orientation);
}
displayCurrentImage();
}


void
ImageViewer::flipVertical()
{
IvImage* img = cur();
if (!img)
return;

ImageSpec* spec = curspecmod();

int curr_orientation = spec->get_int_attribute("Orientation", 1);

if (curr_orientation >= 1 && curr_orientation <= 8) {
static int next_orientation[] = { 0, 4, 3, 2, 1, 8, 7, 6, 5 };
curr_orientation = next_orientation[curr_orientation];
spec->attribute("Orientation", curr_orientation);
}
displayCurrentImage();
}
15 changes: 15 additions & 0 deletions src/iv/imageviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ class ImageViewer final : public QMainWindow {
return img ? &img->spec() : NULL;
}

/// Return a modifiable ref to the current image spec, or NULL if there is no
/// current image.
ImageSpec* curspecmod(void) const
{
IvImage* img = cur();
return img ? &img->specmod() : NULL;
}

bool pixelviewOn(void) const
{
return showPixelviewWindowAct && showPixelviewWindowAct->isChecked();
Expand Down Expand Up @@ -334,6 +342,11 @@ private slots:
void editPreferences(); ///< Edit viewer preferences
void toggleAreaSample(); ///< Use area probe

void rotateLeft();
void rotateRight();
void flipHorizontal();
void flipVertical();

void useOCIOAction(bool checked);
void ocioColorSpaceAction();
void ocioDisplayViewAction();
Expand Down Expand Up @@ -404,6 +417,8 @@ private slots:
QAction* showPixelviewWindowAct;
QAction* toggleAreaSampleAct;
QAction* toggleWindowGuidesAct;
QAction *rotateLeftAct, *rotateRightAct, *flipHorizontalAct,
*flipVerticalAct;
QMenu *fileMenu, *editMenu, /**imageMenu,*/ *viewMenu, *toolsMenu,
*helpMenu;
QMenu* openRecentMenu;
Expand Down
Loading