GUI: Switch DAGModel to use qreal instead of float

This commit is contained in:
Chris Hennes
2025-07-24 17:59:09 -05:00
parent 2aa659f2b3
commit 0142861774
2 changed files with 25 additions and 25 deletions

View File

@@ -563,7 +563,7 @@ void Model::updateSlot()
int currentRow = 0;
int currentColumn = -1; //we know first column is going to be root so will be kicked up to 0.
int maxColumn = currentColumn; //used for determining offset of icons and text.
float maxTextLength = 0;
qreal maxTextLength = 0;
for (const auto &currentVertex : sorted)
{
if (!(*theGraph)[currentVertex].dagVisible)
@@ -647,7 +647,7 @@ void Model::updateSlot()
auto rectangle = (*theGraph)[currentVertex].rectangle.get();
rectangle->setRect(-rowPadding, 0.0, rowPadding, rowHeight); //calculate actual length later.
rectangle->setTransform(QTransform::fromTranslate(0, rowHeight * static_cast<qreal>(currentRow)));
rectangle->setTransform(QTransform::fromTranslate(0, rowHeight * currentRow));
rectangle->setBackgroundBrush(backgroundBrushes[currentRow % backgroundBrushes.size()]);
auto point = (*theGraph)[currentVertex].point.get();
@@ -656,7 +656,7 @@ void Model::updateSlot()
rowHeight * currentRow + rowHeight / 2.0 - pointSize / 2.0));
point->setBrush(currentBrush);
float cheat = 0.0;
qreal cheat = 0.0;
if (direction == -1)
cheat = rowHeight;
@@ -672,7 +672,7 @@ void Model::updateSlot()
auto text = (*theGraph)[currentVertex].text.get();
text->setPlainText(QString::fromUtf8(findRecord(currentVertex, *graphLink).DObject->Label.getValue()));
text->setDefaultTextColor(currentBrush.color());
maxTextLength = std::max(maxTextLength, static_cast<float>(text->boundingRect().width()));
maxTextLength = std::max(maxTextLength, text->boundingRect().width());
text->setTransform(QTransform::fromTranslate
(0.0, rowHeight * currentRow - verticalSpacing * 2.0 + cheat)); //calculate x location later.
(*theGraph)[currentVertex].lastVisibleState = VisibilityState::None; //force visual update for color.
@@ -683,8 +683,8 @@ void Model::updateSlot()
//our list is topo sorted so all dependents should be located, so we can build the connectors.
//will have some more logic for connector path, simple for now.
float currentX = pointSpacing * currentColumn + pointSize / 2.0;
float currentY = rowHeight * currentRow + rowHeight / 2.0;
qreal currentX = pointSpacing * currentColumn + pointSize / 2.0;
qreal currentY = rowHeight * currentRow + rowHeight / 2.0;
OutEdgeIterator it, itEnd;
boost::tie(it, itEnd) = boost::out_edges(currentVertex, *theGraph);
for (; it != itEnd; ++it)
@@ -692,9 +692,9 @@ 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>(columnFromMask((*theGraph)[target].column)) + pointSize / 2.0; //on center.
qreal 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;
qreal dependentY = rowHeight * (*theGraph)[target].row + rowHeight / 2.0;
QGraphicsPathItem *pathItem = (*theGraph)[*it].connector.get();
pathItem->setBrush(Qt::NoBrush);
@@ -705,17 +705,17 @@ void Model::updateSlot()
else
{
//connector with bend.
float radius = pointSpacing / 1.9; //no zero length line.
qreal radius = pointSpacing / 1.9; //no zero length line.
path.lineTo(currentX, dependentY + radius * direction);
float yPosition;
qreal yPosition;
if (direction == -1.0)
yPosition = dependentY - 2.0 * radius;
else
yPosition = dependentY;
float width = 2.0 * radius;
float height = width;
qreal width = 2.0 * radius;
qreal height = width;
if (dependentX > currentX) //radius to the right.
{
QRectF arcRect(currentX, yPosition, width, height);
@@ -735,10 +735,10 @@ void Model::updateSlot()
}
//now that we have the graph drawn we know where to place icons and text.
float columnSpacing = (maxColumn * pointSpacing);
qreal columnSpacing = (maxColumn * pointSpacing);
for (const auto &currentVertex : sorted)
{
float localCurrentX = columnSpacing;
qreal localCurrentX = columnSpacing;
localCurrentX += pointToIcon;
auto visiblePixmap = (*theGraph)[currentVertex].visibleIcon.get();
QTransform visibleIconTransform = QTransform::fromTranslate(localCurrentX, 0.0);

View File

@@ -118,17 +118,17 @@ namespace Gui
//! @name View Constants for spacing
//@{
float fontHeight; //!< height of the current qApp default font.
float direction; //!< controls top to bottom or bottom to top direction.
float verticalSpacing; //!< pixels between top and bottom of text to background rectangle.
float rowHeight; //!< height of background rectangle.
float iconSize; //!< size of icon to match font.
float pointSize; //!< size of the connection point.
float pointSpacing; //!< spacing between pofloat columns.
float pointToIcon; //!< spacing from last column points to first icon.
float iconToIcon; //!< spacing between icons.
float iconToText; //!< spacing between last icon and text.
float rowPadding; //!< spaces added to rectangle background width ends.
qreal fontHeight; //!< height of the current qApp default font.
qreal direction; //!< controls top to bottom or bottom to top direction.
qreal verticalSpacing; //!< pixels between top and bottom of text to background rectangle.
qreal rowHeight; //!< height of background rectangle.
qreal iconSize; //!< size of icon to match font.
qreal pointSize; //!< size of the connection point.
qreal pointSpacing; //!< spacing between pofloat columns.
qreal pointToIcon; //!< spacing from last column points to first icon.
qreal iconToIcon; //!< spacing between icons.
qreal iconToText; //!< spacing between last icon and text.
qreal rowPadding; //!< spaces added to rectangle background width ends.
std::vector<QBrush> backgroundBrushes; //!< brushes to paint background rectangles.
std::vector<QBrush> forgroundBrushes; //!< brushes to paint points, connectors, text.
void setupViewConstants();