From 81ee548f7fae4a591d9b0190dfdfdb2ec084ad3a Mon Sep 17 00:00:00 2001 From: blobfish Date: Fri, 13 May 2016 08:42:29 -0400 Subject: [PATCH] use bitset to_string for column retrieval --- src/Gui/DAGView/DAGModel.cpp | 13 ++++++++++--- src/Gui/DAGView/DAGModel.h | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Gui/DAGView/DAGModel.cpp b/src/Gui/DAGView/DAGModel.cpp index c696cbde162e..b7efe1070d66 100644 --- a/src/Gui/DAGView/DAGModel.cpp +++ b/src/Gui/DAGView/DAGModel.cpp @@ -619,7 +619,7 @@ void Model::updateSlot() //go with first visible parent for now. if (!(*theGraph)[currentParent].dagVisible) continue; - destinationColumn = static_cast(std::log2((*theGraph)[currentParent].column.to_ulong())); + destinationColumn = static_cast(columnFromMask((*theGraph)[currentParent].column)); break; } } @@ -691,14 +691,15 @@ void Model::updateSlot() Vertex target = boost::target(*it, *theGraph); if (!(*theGraph)[target].dagVisible) continue; //we don't make it here if source isn't visible. So don't have to worry about that. - float dependentX = pointSpacing * static_cast(std::log2((*theGraph)[target].column.to_ulong())) + pointSize / 2.0; //on center. + float dependentX = pointSpacing * static_cast(columnFromMask((*theGraph)[target].column)) + pointSize / 2.0; //on center. + columnFromMask((*theGraph)[target].column); float dependentY = rowHeight * (*theGraph)[target].row + rowHeight / 2.0; QGraphicsPathItem *pathItem = (*theGraph)[*it].connector.get(); pathItem->setBrush(Qt::NoBrush); QPainterPath path; path.moveTo(currentX, currentY); - if (currentColumn == static_cast(std::log2((*theGraph)[target].column.to_ulong()))) + if (currentColumn == static_cast(columnFromMask((*theGraph)[target].column))) path.lineTo(currentX, dependentY); //straight connector in y. else { @@ -882,6 +883,12 @@ void Model::updateStates() } } +std::size_t Model::columnFromMask(const ColumnMask &maskIn) +{ + std::string maskString = maskIn.to_string(); + return maskString.size() - maskString.find("1") - 1; +} + RectItem* Model::getRectFromPosition(const QPointF& position) { RectItem *rect = nullptr; diff --git a/src/Gui/DAGView/DAGModel.h b/src/Gui/DAGView/DAGModel.h index ae9e5f84133e..f317500fe5bc 100644 --- a/src/Gui/DAGView/DAGModel.h +++ b/src/Gui/DAGView/DAGModel.h @@ -111,6 +111,7 @@ namespace Gui void addVertexItemsToScene(const Vertex &vertexIn); void removeVertexItemsFromScene(const Vertex &vertexIn); void updateStates(); + std::size_t columnFromMask(const ColumnMask&); RectItem* getRectFromPosition(const QPointF &position); //!< can be nullptr