use bitset to_string for column retrieval

This commit is contained in:
blobfish 2016-05-13 08:42:29 -04:00 committed by wmayer
parent dd3f85d1a1
commit 81ee548f7f
2 changed files with 11 additions and 3 deletions

View File

@ -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;
}
}
@ -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
{
@ -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;

View File

@ -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