Skip to content

Commit

Permalink
use bitset to_string for column retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
blobfish authored and wwmayer committed May 13, 2016
1 parent dd3f85d commit 81ee548
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Gui/DAGView/DAGModel.cpp
Expand Up @@ -619,7 +619,7 @@ void Model::updateSlot()
//go with first visible parent for now.
if (!(*theGraph)[currentParent].dagVisible)
continue;
destinationColumn = static_cast<int>(std::log2((*theGraph)[currentParent].column.to_ulong()));
destinationColumn = static_cast<int>(columnFromMask((*theGraph)[currentParent].column));
break;
}
}
Expand Down Expand Up @@ -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<int>(std::log2((*theGraph)[target].column.to_ulong())) + pointSize / 2.0; //on center.
float dependentX = pointSpacing * static_cast<int>(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<int>(std::log2((*theGraph)[target].column.to_ulong())))
if (currentColumn == static_cast<int>(columnFromMask((*theGraph)[target].column)))
path.lineTo(currentX, dependentY); //straight connector in y.
else
{
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/Gui/DAGView/DAGModel.h
Expand Up @@ -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

Expand Down

0 comments on commit 81ee548

Please sign in to comment.