Skip to content

Commit

Permalink
Make the initial marker colour an inverse of the average pixels in th…
Browse files Browse the repository at this point in the history
…e top left, change the selected pixel to be blue in keeping with the theme.
  • Loading branch information
RussellGarwood committed Mar 22, 2022
1 parent 3634356 commit 56ce94c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
45 changes: 26 additions & 19 deletions SPIERSalign/src/mainwindowimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ MainWindowImpl::MainWindowImpl(QWidget *parent, Qt::WindowFlags f)
horizontalLayout3->addWidget(infoLabel);
QScrollArea *infoScrollArea = new QScrollArea;
infoScrollArea->setLayout(horizontalLayout3);
//infoScrollArea->setMinimumHeight(50);
infoScrollArea->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum));
infoLayout->addWidget(infoScrollArea);

Expand All @@ -328,8 +327,6 @@ MainWindowImpl::MainWindowImpl(QWidget *parent, Qt::WindowFlags f)

layoutWidgetTwo = new QWidget;
layoutWidgetTwo->setLayout(infoLayout);
//layoutWidgetTwo->setMaximumWidth(500);
//layoutWidgetTwo->setMaximumHeight(500);
info->setWidget(layoutWidgetTwo);

addDockWidget(Qt::RightDockWidgetArea, info);
Expand Down Expand Up @@ -492,7 +489,7 @@ MainWindowImpl::~MainWindowImpl()
int i = 0;

//Write to settings file
on_actionSave_triggered();
savetriggered();

qDeleteAll(imageList.begin(), imageList.end());
imageList.clear();
Expand Down Expand Up @@ -1820,7 +1817,7 @@ void MainWindowImpl::on_actionOpen_triggered()
amRectPointer = nullptr;

//Write to settings file
on_actionSave_triggered();
savetriggered();

qDeleteAll(imageList.begin(), imageList.end());
imageList.clear();
Expand Down Expand Up @@ -2074,20 +2071,30 @@ void MainWindowImpl::on_actionOpen_triggered()
markerList->addItem(output);
}

int widthOverSixteen = width / 16;
int widthOverFifty = width / 50;
int newSize = 0;
if (widthOverSixteen > 99) newSize = 99;
else if (widthOverSixteen < 10) newSize = 10;
else newSize = widthOverSixteen;
if (widthOverFifty > 99) newSize = 99;
else if (widthOverFifty < 10) newSize = 10;
else newSize = widthOverFifty;

mSize->setValue(newSize);
mThickness->setValue(5);

//Make sure markers are visible, at least in top left
QColor colour = Dimensions.pixelColor(widthOverEight, heightOverEight);
red->setValue(255 - colour.red());
blue->setValue(255 - colour.blue());
green->setValue(255 - colour.blue());
int R = 0, G = 0, B = 0, pixelCount = 0;
for (int i = 0; i < widthOverEight; i++)
for (int j = 0; j < heightOverEight; j++)
{
QColor colour = Dimensions.pixelColor(widthOverEight, heightOverEight);
R += colour.red();
B += colour.blue();
G += colour.green();
pixelCount++;
}

red->setValue(255 - (R / pixelCount));
blue->setValue(255 - (B / pixelCount));
green->setValue(255 - (G / pixelCount));
}

for (i = 0; i < imageList.count(); i++)
Expand Down Expand Up @@ -2218,7 +2225,7 @@ void MainWindowImpl::redrawImage()
pixMapPointer->setZValue(0);
LogText("*11\t");
showInfo(-1, -1);
if (actionConstant_autosave->isChecked()) on_actionSave_triggered();
if (actionConstant_autosave->isChecked()) savetriggered();
LogText("*12\t");
redrawDecorations();
LogText("...Done\n");
Expand Down Expand Up @@ -2329,7 +2336,7 @@ void MainWindowImpl::redrawDecorations()

QPen marker;

QColor icolour((255 - redValue), (255 - greenValue), (255 - blueValue));
QColor icolour(0, 0, 200);
marker.setWidth(mThickness->value());
marker.setStyle(Qt::SolidLine);
marker.setCosmetic(true);
Expand Down Expand Up @@ -2364,7 +2371,7 @@ void MainWindowImpl::redrawJustDecorations()
QPen marker;
marker.setCosmetic(true);
QColor colour(redValue, greenValue, blueValue);
QColor icolour((255 - redValue), (255 - greenValue), (255 - blueValue));
QColor icolour(0, 0, 200);
marker.setWidth(mThickness->value());
marker.setStyle(Qt::SolidLine);

Expand Down Expand Up @@ -3956,10 +3963,10 @@ void MainWindowImpl::on_horizontalSlider_valueChanged(int value)
}

/**
* @brief MainWindowImpl::on_actionSave_triggered
* @brief MainWindowImpl::savetriggered
* Save settings file
*/
void MainWindowImpl::on_actionSave_triggered(QString filename)
void MainWindowImpl::savetriggered(QString filename)
{
int i;

Expand Down Expand Up @@ -4006,7 +4013,7 @@ void MainWindowImpl::on_actionSave_Backup_triggered()
date = QDateTime::currentDateTime ();
//Write to settings file
QString filename = filesDirectory.absolutePath() + "/settings backup - " + date.toString("dd MMM yyyy - hh.mm.ss") + ".txt";
on_actionSave_triggered(filename);
savetriggered(filename);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion SPIERSalign/src/mainwindowimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private slots:
void on_actionAdvance_To_Hidden_triggered();
void on_actionRetreat_To_Hidden_triggered();
void on_actionSave_Backup_triggered();
void on_actionSave_triggered(QString filename = "");
void savetriggered(QString filename = "");
void on_actionLock_Forward_triggered(bool checked);
void on_actionLock_Back_triggered(bool checked);
void on_actionMove_Forward_Back_triggered();
Expand Down

0 comments on commit 56ce94c

Please sign in to comment.