void MelodyNoteGlyphItem::setLedgerLinesItems(int count) { if (m_ledgerLines.count() == count) return; if (m_ledgerLines.count() < count) { QPen linePen = ledgerLinePen(); while (m_ledgerLines.count() < count) { QGraphicsLineItem *newLedgerLine = new QGraphicsLineItem(this); newLedgerLine->setPen(linePen); newLedgerLine->setVisible(false); m_ledgerLines.append(newLedgerLine); } } if (m_ledgerLines.count() > count) { while (m_ledgerLines.count() > count) { QGraphicsLineItem *ledgerLine = m_ledgerLines.takeLast(); if (ledgerLine != 0) { ledgerLine->setParentItem(0); delete ledgerLine; } } } }
void MeshDrawer::setMesh(const cv::Mat &mesh) { current_mesh = mesh; int number_of_points = (int)point_items.size(); int number_of_lines = (int)line_items.size(); bool hide_mesh = ((mesh.rows == 0) || (mesh.cols == 0)); // update lines for (int line_index = 0; line_index < number_of_lines; line_index++) { QGraphicsLineItem *line = line_items[line_index]; if (hide_mesh) { line->setVisible(false); } else { QPointF from_point(mesh.at<double>(current_connections.at<int>(0,line_index),0), mesh.at<double>(current_connections.at<int>(0,line_index)+number_of_points,0)); QPointF to_point(mesh.at<double>(current_connections.at<int>(1,line_index),0), mesh.at<double>(current_connections.at<int>(1,line_index)+number_of_points,0)); QLineF line_position(from_point,to_point); line->setLine(line_position); line->setVisible(true); } } // update points for (int point_index = 0; point_index < number_of_points; point_index++) { QGraphicsEllipseItem *point = point_items[point_index]; if (hide_mesh) { point->setVisible(false); } else { QPointF position(mesh.at<double>(point_index,0), mesh.at<double>(point_index+number_of_points,0)); QRectF ellipse_rect(position.x() - point_radius, position.y() - point_radius, 2*point_radius, 2*point_radius); point->setRect(ellipse_rect); point->setVisible(true); } } }
void MelodyNoteGlyphItem::layoutLedgerLineItems() { if (!m_ledgerLines.count()) return; qreal halfStaffSpace = musicFont()->halfStaffSpace(); qreal noteHeadWidth = m_notehead->boundingRect().width(); qreal ledgerLineWidth = noteHeadWidth + 2 * ledgerLineExtensionWidth(); for (int i = 0; i < m_ledgerLines.count(); ++i) { qreal yPos = i * halfStaffSpace; if (m_ledgerPosition == LedgerLinePosition::Above) { yPos *= -1; } QGraphicsLineItem *ledgerLineItem = m_ledgerLines.at(i); ledgerLineItem->setLine(0, yPos, ledgerLineWidth, yPos); ledgerLineItem->setVisible(true); } }
void AnimatorScene::setShowInterfaceTexts (bool showIp, bool showMac) { resetInterfaceTexts (); m_showIpInterfaceTexts = showIp; m_showMacInterfaceTexts = showMac; if (!m_showIpInterfaceTexts && !m_showMacInterfaceTexts) { return; } if (!m_interfaceATexts.size ()) { for (LinkManager::NodeIdAnimLinkVectorMap_t::const_iterator i = LinkManager::getInstance ()->getLinks ()->begin (); i != LinkManager::getInstance ()->getLinks ()->end (); ++i) { LinkManager::AnimLinkVector_t linkVector = i->second; for (LinkManager::AnimLinkVector_t::const_iterator j = linkVector.begin (); j != linkVector.end (); ++j) { AnimLink * animLink = *j; QString pointADescription = animLink->getInterfaceADescription (); QPointF pointApos = animLink->getInterfacePosA (); AnimInterfaceText * interfaceAText = new AnimInterfaceText (pointADescription); interfaceAText->setPos (pointApos); addItem (interfaceAText); m_interfaceATexts.push_back (interfaceAText); interfaceAText->setMode (m_showIpInterfaceTexts, m_showMacInterfaceTexts); QString pointBDescription = animLink->getInterfaceBDescription (); if (pointBDescription == "") { continue; } QPointF pointBpos = animLink->getInterfacePosB (); AnimInterfaceText * interfaceBText = new AnimInterfaceText (pointBDescription, true); interfaceBText->setMode (m_showIpInterfaceTexts, m_showMacInterfaceTexts); addItem (interfaceBText); interfaceBText->setPos (pointBpos); m_interfaceBTexts.push_back (interfaceBText); } } update (); removeInterfaceTextCollision (); return; } for (AnimInterfaceTextVector_t::const_iterator i = m_interfaceATexts.begin (); i != m_interfaceATexts.end (); ++i) { AnimInterfaceText * interfaceText = *i; interfaceText->setMode (m_showIpInterfaceTexts, m_showMacInterfaceTexts); QGraphicsLineItem * l = interfaceText->getLine (); if (l) { l->setVisible (showIp || showMac); } interfaceText->setVisible (showIp || showMac); } for (AnimInterfaceTextVector_t::const_iterator i = m_interfaceBTexts.begin (); i != m_interfaceBTexts.end (); ++i) { AnimInterfaceText * interfaceText = *i; interfaceText->setMode (m_showIpInterfaceTexts, m_showMacInterfaceTexts); QGraphicsLineItem * l = interfaceText->getLine (); if (l) { l->setVisible (showIp || showMac); } interfaceText->setVisible (showIp || showMac); } removeInterfaceTextCollision (); update (); }