Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure proper colorer range for depth range #172

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ jobs:
working-directory: ${{github.workspace}}/tests
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get install imagemagick
./bandage_command_line_tests.sh ${{github.workspace}}/build/BandageNG
elif [ "$RUNNER_OS" == "macOS" ]; then
brew install imagemagick
Expand Down
14 changes: 12 additions & 2 deletions graph/nodecolorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,25 @@ QColor DepthNodeColorer::get(const GraphicsItemNode *node) {
double depth = deBruijnNode->getDepth();

double lowValue = g_settings->lowDepthValue, highValue = g_settings->highDepthValue;

if (g_settings->autoDepthValue) {
lowValue = m_graph->m_firstQuartileDepth;
highValue = m_graph->m_thirdQuartileDepth;
if (m_scope.graphScope() == DEPTH_RANGE) {
lowValue = m_scope.minDepth();
highValue = m_scope.maxDepth();
} else {
lowValue = m_graph->m_firstQuartileDepth;
highValue = m_graph->m_thirdQuartileDepth;
}
}

float fraction = (depth - lowValue) / (highValue - lowValue);
return tinycolormap::GetColor(fraction, colorMap(g_settings->colorMap)).ConvertToQColor();
}

void DepthNodeColorer::saveScopeReference(graph::Scope& scope) {
m_scope = scope;
}

QColor UniformNodeColorer::get(const GraphicsItemNode *node) {
const DeBruijnNode *deBruijnNode = node->m_deBruijnNode;

Expand Down
3 changes: 3 additions & 0 deletions graph/nodecolorer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#pragma once

#include "graphscope.h"

#include <QColor>
#include <QSharedPointer>

Expand Down Expand Up @@ -51,6 +53,7 @@ class INodeColorer {
static std::unique_ptr<INodeColorer> create(NodeColorScheme scheme);

[[nodiscard]] NodeColorScheme scheme() const { return m_scheme; }

protected:
NodeColorScheme m_scheme;
QSharedPointer<AssemblyGraph> &m_graph;
Expand Down
12 changes: 10 additions & 2 deletions graph/nodecolorers.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,18 @@

class DepthNodeColorer : public INodeColorer {
public:
using INodeColorer::INodeColorer;

explicit DepthNodeColorer(NodeColorScheme scheme)
: INodeColorer(scheme),
m_scope(graph::Scope::wholeGraph())
{
}
QColor get(const GraphicsItemNode *node) override;
[[nodiscard]] const char* name() const override { return "Color by depth"; };

void saveScopeReference(graph::Scope& scope);

private:
graph::Scope m_scope;
};

class UniformNodeColorer : public INodeColorer {
Expand Down
12 changes: 8 additions & 4 deletions ui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ MainWindow::MainWindow(QString fileToLoadOnStartup, bool drawGraphAfterLoad) :
QMainWindow(nullptr),
ui(new Ui::MainWindow), m_imageFilter("PNG (*.png)"),
m_fileToLoadOnStartup(fileToLoadOnStartup), m_drawGraphAfterLoad(drawGraphAfterLoad),
m_uiState(NO_GRAPH_LOADED), m_blastSearchDialog(nullptr), m_alreadyShown(false)
m_uiState(NO_GRAPH_LOADED), m_blastSearchDialog(nullptr), m_alreadyShown(false),
m_scope(graph::Scope::wholeGraph())
{
ui->setupUi(this);

Expand Down Expand Up @@ -1004,7 +1005,7 @@ void MainWindow::drawGraph() {
QString errorMessage;
g_settings->doubleMode = ui->doubleNodesRadioButton->isChecked();

auto scope =
m_scope =
graph::scope(g_settings->graphScope,
ui->startingNodesLineEdit->text(),
ui->minDepthSpinBox->value(), ui->maxDepthSpinBox->value(),
Expand All @@ -1015,7 +1016,7 @@ void MainWindow::drawGraph() {
ui->nodeDistanceSpinBox->value());

auto startingNodes = graph::getStartingNodes(&errorTitle, &errorMessage,
*g_assemblyGraph, scope);
*g_assemblyGraph, m_scope);

if (!errorMessage.isEmpty()) {
QMessageBox::information(this, errorTitle, errorMessage);
Expand All @@ -1024,7 +1025,7 @@ void MainWindow::drawGraph() {

resetScene();
g_assemblyGraph->resetNodes();
g_assemblyGraph->markNodesToDraw(scope, startingNodes);
g_assemblyGraph->markNodesToDraw(m_scope, startingNodes);
layoutGraph();
}

Expand Down Expand Up @@ -1381,6 +1382,9 @@ void MainWindow::switchColourScheme(int idx) {
if (!g_assemblyGraph->m_csvHeaders.empty())
colorer->setColumnIdx(0);
ui->tagsComboBox->setVisible(true);
} else if (scheme == DEPTH_COLOUR) {
dynamic_cast<DepthNodeColorer*>(&*g_settings->nodeColorer)->saveScopeReference(m_scope);
ui->tagsComboBox->setVisible(false);
} else {
ui->tagsComboBox->setVisible(false);
}
Expand Down
1 change: 1 addition & 0 deletions ui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class MainWindow : public QMainWindow
bool m_drawGraphAfterLoad;
UiState m_uiState;
GraphSearchDialog * m_blastSearchDialog;
graph::Scope m_scope;

bool m_alreadyShown;

Expand Down
Loading