void Elevator::incrementOccupancy() { ++mOccupancy; if ( !textItem()->isVisible() ) textItem()->show(); textItem()->setPlainText( QString::number(mOccupancy) ); if ( !ellipseItem()->isVisible() ) ellipseItem()->show(); centerTextItem(); }
void Elevator::zeroOccupancy() { mOccupancy = 0; textItem()->hide(); textItem()->setPlainText("0"); centerTextItem(); ellipseItem()->hide(); }
void Checker::finishActiveSegment (const DocumentModelCoords &modelCoords, const QPointF &posStartScreen, const QPointF &posEndScreen, double yFrom, double yTo, const Transformation &transformation, SideSegments &sideSegments) const { LOG4CPP_INFO_S ((*mainCat)) << "Checker::finishActiveSegment" << " posStartScreen=" << QPointFToString (posStartScreen).toLatin1().data() << " posEndScreen=" << QPointFToString (posEndScreen).toLatin1().data() << " yFrom=" << yFrom << " yTo=" << yTo; QGraphicsItem *item; if ((modelCoords.coordsType() == COORDS_TYPE_POLAR) && (yFrom == yTo)) { // Linear cartesian radius double radiusLinearCartesian = yFrom; if (modelCoords.coordScaleYRadius() == COORD_SCALE_LOG) { radiusLinearCartesian = transformation.logToLinearRadius(yFrom, modelCoords.originRadius()); } else { radiusLinearCartesian -= modelCoords.originRadius(); } // Draw along an arc since this is a side of constant radius, and we have polar coordinates item = ellipseItem (transformation, radiusLinearCartesian, posStartScreen, posEndScreen); } else { // Draw straight line item = lineItem (posStartScreen, posEndScreen); } sideSegments.push_back (item); bindItemToScene (item); }
void GridLineFactory::finishActiveGridLine (const QPointF &posStartScreen, const QPointF &posEndScreen, double yFrom, double yTo, const Transformation &transformation, GridLine &gridLine) const { LOG4CPP_DEBUG_S ((*mainCat)) << "GridLineFactory::finishActiveGridLine" << " posStartScreen=" << QPointFToString (posStartScreen).toLatin1().data() << " posEndScreen=" << QPointFToString (posEndScreen).toLatin1().data() << " yFrom=" << yFrom << " yTo=" << yTo; QGraphicsItem *item; if ((m_modelCoords.coordsType() == COORDS_TYPE_POLAR) && (yFrom == yTo)) { // Linear cartesian radius double radiusLinearCartesian = yFrom; if (m_modelCoords.coordScaleYRadius() == COORD_SCALE_LOG) { radiusLinearCartesian = transformation.logToLinearRadius(yFrom, m_modelCoords.originRadius()); } else { radiusLinearCartesian -= m_modelCoords.originRadius(); } // Draw along an arc since this is a side of constant radius, and we have polar coordinates item = ellipseItem (transformation, radiusLinearCartesian, posStartScreen, posEndScreen); } else { // Draw straight line item = lineItem (posStartScreen, posEndScreen); } gridLine.add (item); bindItemToScene (item); }
bool Plugin::render(QGraphicsView *graphicsView, QGraphicsItem *parent) { qDebug() << "Painting the Scenario"; m_itemGroup = new QGraphicsItemGroup(); while (!m_drawStack.isEmpty()) { const Plugin::Command *cmd = m_drawStack.front(); m_drawStack.pop_front(); QStringList tokList = cmd->values().split(':', QString::SkipEmptyParts); bool ret = true; // return value switch (cmd->drawCommand()) { case Plugin::Command::Pen: ret = setCurPen(tokList); break; // added brackets to delimit the variables scope // thats not necessary on case Pen. case Plugin::Command::Rect: { QGraphicsRectItem *rect = rectItem(tokList); if (rect) m_itemGroup->addToGroup(rect); else ret = false; } break; case Plugin::Command::Line: { QGraphicsLineItem *line = lineItem(tokList); if (line) m_itemGroup->addToGroup(line); else ret = false; } break; case Plugin::Command::Ellipse: { QGraphicsEllipseItem *ellipse = ellipseItem(tokList); if (ellipse) m_itemGroup->addToGroup(ellipse); else ret = false; } break; } if (!ret) { delete m_itemGroup; // force to delete the group return false; } } if (parent) m_itemGroup->setParentItem(parent); m_itemGroup->setPos(m_point); graphicsView->scene()->addItem(m_itemGroup); return true; }