/* ******************************************************************************** * * * Class LocalScene * * -> dashboard method * ******************************************************************************** */ void LocalScene::populateDashBoardScene() { //Debug::debug() << " [LocalScene] populateDashBoardScene"; //! content populateMostPlayedAlbum(itemsBoundingRect().height() + 40); populateTopRatedAlbum(itemsBoundingRect().height() + 80); populateMostPlayedArtist(itemsBoundingRect().height() + 80); populateTopRatedArtist(itemsBoundingRect().height() + 80); }
/** * Updates the scene at the start and everytime new data points * are added. Specifically, objects on the scene are assigned * their position in the new coordinate system and are resized * if necessary. */ void DiagramScene::update() { _xAxis->setPos(_bounds.left(),getXAxisOffset()); _yAxis->setPos(getYAxisOffset(),_bounds.bottom()); _xAxis->setLength(_bounds.width()); _yAxis->setLength(_bounds.height()); _xLabel->setPos( _bounds.left() + _bounds.width() / 2, _bounds.bottom() + 1.5 * MARGIN ); _yLabel->setPos( _bounds.left() - 1.5 * MARGIN, _bounds.top() + _bounds.height() / 2 ); _xUnit->setPos( _bounds.right(), _bounds.bottom() + 1.2 * MARGIN); _yUnit->setPos( _bounds.left(), _bounds.top() - 0.5 * MARGIN); /* update graphs and their captions */ QRectF rect; for (int i = 0; i < _graphs.size(); i++) { rect = _graphs[i]->boundingRect(); int offset = static_cast<int>(fabs(rect.bottom() - _bounds.bottom()) - fabs(rect.top() - _bounds.top())); _graphs[i]->setPos(0, offset); rect = itemsBoundingRect(); _graphCaptions[i]->setPos(_bounds.left(),rect.bottom() + 10); } }
void MindMap::dumpMapInBipmap(QString file) { clearSelection(); setSceneRect(itemsBoundingRect()); QImage image(sceneRect().size().toSize(), QImage::Format_ARGB32); image.fill(Qt::transparent); QPainter painter(&image); render(&painter); image.save(file); }
void ResultScene::setWidth(int width) { const bool resizeItems = width != sceneRect().width(); m_selectionBar->resize(width, m_selectionBar->size().height()); if (resizeItems) { foreach (ResultItem *item, m_items) { item->calculateSize(width); } setSceneRect(itemsBoundingRect()); }
/******************************************************************************* populateScene *******************************************************************************/ void SettingsScene::populateScene() { Debug::debug() << " [SettingsScene] populateScene"; /* header item */ int Ypos = 0; m_header->setPos(0, 5); Ypos = Ypos + 40; /* SETTINGS::GENERAL */ m_pages.value(SETTINGS::GENERAL)->setPos(0,Ypos); static_cast<PageGeneral*>(m_pages[SETTINGS::GENERAL])->doLayout(); Ypos += static_cast<PageGeneral*>(m_pages[SETTINGS::GENERAL])->size().height(); /* SETTINGS::PLAYER */ m_pages.value(SETTINGS::PLAYER)->setPos(0,Ypos); static_cast<PagePlayer*>(m_pages[SETTINGS::PLAYER])->doLayout(); Ypos += static_cast<PagePlayer*>(m_pages[SETTINGS::PLAYER])->size().height(); /* SETTINGS::LIBRARY */ m_pages.value(SETTINGS::LIBRARY)->setPos(0,Ypos); static_cast<PageLibrary*>(m_pages[SETTINGS::LIBRARY])->doLayout(); Ypos += static_cast<PageLibrary*>(m_pages[SETTINGS::LIBRARY])->size().height(); /* SETTINGS::SHORTCUT */ m_pages.value(SETTINGS::SHORTCUT)->setPos(0,Ypos); static_cast<PageShortcut*>(m_pages[SETTINGS::SHORTCUT])->doLayout(); Ypos += static_cast<PageShortcut*>(m_pages[SETTINGS::SHORTCUT])->size().height(); /* SETTINGS::SONGINFO */ m_pages.value(SETTINGS::SONGINFO)->setPos(0,Ypos); static_cast<PageSongInfo*>(m_pages[SETTINGS::SONGINFO])->doLayout(); Ypos += static_cast<PageSongInfo*>(m_pages[SETTINGS::SONGINFO])->size().height(); /* SETTINGS::SCROBBLER */ m_pages.value(SETTINGS::SCROBBLER)->setPos(0,Ypos); static_cast<PageScrobbler*>(m_pages[SETTINGS::SCROBBLER])->doLayout(); /* ajust SceneRect */ setSceneRect ( itemsBoundingRect().adjusted(0, -10, 0, 40) ); }
void VibesScene2D::updateDims() { QList<QGraphicsItem*> children = this->items(); foreach(QGraphicsItem *item, children) { if (VibesGraphicsItem * vibesItem = qgraphicsitem_cast<VibesGraphicsItem*>(item)) { if ( vibesItem->setProj(dimX(),dimY()) ) item->setVisible(true); else item->setVisible(false); } } setSceneRect(itemsBoundingRect()); }
/** Permet de connaitre les dimensions qu'aura l'image generee par la methode toImage() @return La taille de l'image generee par toImage() */ QSize Diagram::imageSize() const { // determine la zone source = contenu du schema + marges qreal image_width, image_height; if (!use_border_) { QRectF items_rect = itemsBoundingRect(); image_width = items_rect.width(); image_height = items_rect.height(); } else { image_width = border_and_titleblock.borderWidth(); image_height = border_and_titleblock.borderHeight(); } image_width += 2.0 * margin; image_height += 2.0 * margin; // renvoie la taille de la zone source return(QSizeF(image_width, image_height).toSize()); }
/******************************************************************************* populateScene *******************************************************************************/ void SettingsScene::populateScene() { Debug::debug() << " [SettingsScene] populateScene"; //Debug::debug() << " [ContextScene] slot_update_draw "; m_layout->invalidate(); static_cast<PageGeneral*>(m_pages[SETTINGS::GENERAL])->doLayout(); static_cast<PagePlayer*>(m_pages[SETTINGS::PLAYER])->doLayout(); static_cast<PageLibrary*>(m_pages[SETTINGS::LIBRARY])->doLayout(); static_cast<PageShortcut*>(m_pages[SETTINGS::SHORTCUT])->doLayout(); static_cast<PageSongInfo*>(m_pages[SETTINGS::SONGINFO])->doLayout(); static_cast<PageScrobbler*>(m_pages[SETTINGS::SCROBBLER])->doLayout(); m_container->update(); /* we need to ajust SceneRect */ setSceneRect ( itemsBoundingRect().adjusted(0, -10, 0, 0) ); }
/** Exporte le schema vers une image @return Une QImage representant le schema */ bool Diagram::toPaintDevice(QPaintDevice &pix, int width, int height, Qt::AspectRatioMode aspectRatioMode) { // determine la zone source = contenu du schema + marges QRectF source_area; if (!use_border_) { source_area = itemsBoundingRect(); source_area.translate(-margin, -margin); source_area.setWidth (source_area.width () + 2.0 * margin); source_area.setHeight(source_area.height() + 2.0 * margin); } else { source_area = QRectF( 0.0, 0.0, border_and_titleblock.borderWidth () + 2.0 * margin, border_and_titleblock.borderHeight() + 2.0 * margin ); } // si les dimensions ne sont pas precisees, l'image est exportee a l'echelle 1:1 QSize image_size = (width == -1 && height == -1) ? source_area.size().toSize() : QSize(width, height); // prepare le rendu QPainter p; if (!p.begin(&pix)) return(false); // rendu antialiase p.setRenderHint(QPainter::Antialiasing, true); p.setRenderHint(QPainter::TextAntialiasing, true); p.setRenderHint(QPainter::SmoothPixmapTransform, true); // deselectionne tous les elements QList<QGraphicsItem *> selected_elmts = selectedItems(); foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(false); // effectue le rendu lui-meme render(&p, QRect(QPoint(0, 0), image_size), source_area, aspectRatioMode); p.end(); // restaure les elements selectionnes foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(true); return(true); }
void ModelScene::refresh() { // clear existing scene // clear model items for (ModelItemGraphics* MItemG : m_GraphicsItems) { removeItem(MItemG); delete MItemG; } m_GraphicsItems.clear(); // clear connections for (ConnectorGraphics* ConnG : m_GraphicsConnections) { removeItem(ConnG); delete ConnG; } m_GraphicsConnections.clear(); clear(); const std::list<openfluid::fluidx::ModelItemDescriptor*>& Items = m_Model.items(); std::list<openfluid::fluidx::ModelItemDescriptor*>::const_iterator itb = Items.begin(); std::list<openfluid::fluidx::ModelItemDescriptor*>::const_iterator ite = Items.end(); std::list<openfluid::fluidx::ModelItemDescriptor*>::const_iterator it; unsigned int SimCount = 0; unsigned int GenCount = 0; // add model items for (it = itb; it!= ite; ++it) { if ((*it)->isEnabled()) { QString ID = QString::fromStdString(m_Model.getID(*it)); QVariant ConfigPos = openfluid::base::RunContextManager::instance()->getProjectConfigValue("builder.model.graphicalview",ID); QPoint Position(0,0); if (ConfigPos.type() == QVariant::Point) Position = ConfigPos.toPoint(); else { QRectF CurrentRect = itemsBoundingRect(); Position.setX(int(CurrentRect.x()+CurrentRect.width()/2)); Position.setY(int(CurrentRect.y()+CurrentRect.height()/2)); } if ((*it)->getType() == openfluid::ware::WareType::SIMULATOR && openfluid::machine::SimulatorSignatureRegistry::instance()->isSimulatorAvailable(ID.toStdString())) { SimCount++; SimulatorGraphics* SimG = new SimulatorGraphics(QPoint(0,0), ID, SimCount+GenCount, openfluid::machine::SimulatorSignatureRegistry::instance() ->signature(ID.toStdString())); addItem(SimG); SimG->moveBy(Position.x(),Position.y()); SimG->initialize(); m_GraphicsItems.append(SimG); connect(SimG,SIGNAL(srcEditAsked(const QString&,bool)),this,SLOT(notifySrcEditAsked(const QString&,bool))); } else if ((*it)->getType() == openfluid::ware::WareType::GENERATOR)