void QSvgIconEngine::addFile(const QString &fileName, const QSize &, QIcon::Mode mode, QIcon::State state) { if (!fileName.isEmpty()) { QString abs = fileName; if (fileName.at(0) != QLatin1Char(':')) abs = QFileInfo(fileName).absoluteFilePath(); if (abs.endsWith(QLatin1String(".svg"), Qt::CaseInsensitive) #ifndef QT_NO_COMPRESS || abs.endsWith(QLatin1String(".svgz"), Qt::CaseInsensitive) || abs.endsWith(QLatin1String(".svg.gz"), Qt::CaseInsensitive)) #endif { QSvgRenderer renderer(abs); if (renderer.isValid()) { d->stepSerialNum(); d->svgFiles.insert(d->hashKey(mode, state), abs); } } else { QPixmap pm(abs); if (!pm.isNull()) addPixmap(pm, mode, state); } } }
void ImageEditorScene::setBackgroundImage(QString path) { clearBackgroundImage(); QPixmap pixmap(path); m_background_path = path; m_background_image = addPixmap(pixmap); m_background_image->setZValue(1); }
void CropScene::setImage(QImage img){ image= img; qDebug()<<"SETimage"<<image; addPixmap(QPixmap::fromImage(image)); selectionRect = new QGraphicsRectItem(0,0,0,0); }
bool QPixmapIconEngine::read(QDataStream &in) { int num_entries; QPixmap pm; QString fileName; QSize sz; uint mode; uint state; in >> num_entries; for (int i=0; i < num_entries; ++i) { if (in.atEnd()) { pixmaps.clear(); return false; } in >> pm; in >> fileName; in >> sz; in >> mode; in >> state; if (pm.isNull()) addFile(fileName, sz, QIcon::Mode(mode), QIcon::State(state)); else addPixmap(pm, QIcon::Mode(mode), QIcon::State(state)); } return true; }
ColorPickerScene::ColorPickerScene(QObject *parent) : QGraphicsScene(parent) { pm.load(":/other/gfx/colorpicker.png"); gradient = addPixmap(pm); gradient->setPos(0, 0); gradient->show(); }
PacientScene::PacientScene(QObject *parent) : QGraphicsScene(parent) { addPixmap(QPixmap(":/images/corps.jpg")); _menu = new QMenu(); _menu->addAction("New bubble...", this, SLOT(createBubble())); }
void StaffScene::makeTrebleClef() { QPixmap image(":/notation/treble"); m_treble = addPixmap(image); m_treble->setPos(trebleClef::offsetX, line(6)->pos().y() - trebleClef::offsetY); m_treble->setScale(1); m_treble->setData(propertyKeys::type, propertyTypes::trebleType); }
void GameScene::showGameOverText(quint32 score) { m_gameOverItem = addPixmap(PixmapCache::gameOverText()); const auto center = m_gameOverItem->boundingRect().center(); m_gameOverItem->setPos(width() / 2 - center.x(), height() / 2 - center.y()); m_paused = true; emit gameFinished(score); }
void ezQtImageScene::SetImage(QPixmap pixmap) { if (m_pImageItem) delete m_pImageItem; m_pixmap = pixmap; m_pImageItem = addPixmap(m_pixmap); setSceneRect(0, 0, m_pixmap.width(), m_pixmap.height()); }
void MapScene::tileUploaded(const QPixmap &pixmap, const TilePoint & point) { if(m_tiles.contains(point)) return; QGraphicsPixmapItem * pm = addPixmap( pixmap ); pm->setData(0, point.second); m_tiles.insert(point, pm); m_tiles.value(point)->setPos(point.first.x()*256.0, point.first.y()*256.0); m_tiles.value(point)->setVisible(point.second == m_zoom); }
void Scene::addCar(Car *car) { Point<double> coordinates = car->getCoordinates(); double x = coordinates.getX(); double y = coordinates.getY(); QPixmap pixmap = Settings::getInstance().getCarPixmap(car->getColor()); QGraphicsPixmapItem *pixmapItem = addPixmap(pixmap); pixmapItem->setOffset(-0.5 * QPointF(pixmap.width(), pixmap.height())); pixmapItem->setPos(x, y); pixmapItem->setRotation(qRadiansToDegrees(car->getDirection())); carsItems[car] = pixmapItem; }
void ImageScene::set_image(const QImage &_image) { if (image) { removeItem(image); delete image; image = NULL; } QPixmap pixmap = QPixmap::fromImage(_image); image = addPixmap(pixmap); }
//размещаем смайл на карте. для того, чтобы карта была сеткой, положение мыши округляем до ближайщего квадрата размером 50х50 void MvScene::placeSmile(float x, float y) { QGraphicsItem * smile = addPixmap(QPixmap("Smile.png")); div_t x1 = div(x,50); div_t y1 = div(y,50); smile->translate(x1.quot*50, y1.quot*50); if (itemCollidesWith(smile)->data(0)=="Map") smile->setData(0, "Smile"); else{ removeItem(smile); } }
void WldScene::resetCursor() { if(cursor) {delete cursor; cursor=NULL;} DrawMode=false; QPixmap cur(QSize(1,1)); cur.fill(Qt::black); cursor = addPixmap(QPixmap(cur)); cursor->setZValue(1000); cursor->hide(); }
void LvlScene::resetCursor() { if(cursor) {delete cursor; cursor=NULL;} DrawMode=false; QPixmap cur(QSize(5,5)); cur.fill(Qt::transparent); cursor = addPixmap(QPixmap(cur)); ((QGraphicsPixmapItem*)cursor)->setShapeMode(QGraphicsPixmapItem::BoundingRectShape); cursor->setZValue(1000); cursor->hide(); }
void MapView::mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent) { if(palette_->hasSelectedObject()) { if(!itemToBeAdded_) { itemToBeAdded_ = addPixmap(palette_->getSelectedObject()); } else { itemToBeAdded_->setPixmap(palette_->getSelectedObject()); } itemToBeAdded_->setOffset(0, -50); // it is the toplapping QPoint eventPoint = mouseEvent->scenePos().toPoint(); // set position to rounded point itemToBeAdded_->setPos( ( (eventPoint - QPoint(25, 25) )/50)*50 ); itemToBeAdded_->setZValue(itemToBeAdded_->y()); } }
MyScene::MyScene() : QGraphicsScene() { QString fichier = QFileDialog::getOpenFileName(0, "Ouvrir un fichier", QString(), "Images (*.png *.gif *.jpg *.jpeg)"); QPixmap image = QPixmap(fichier); size = image.size(); impix=addPixmap(image); point1 = QPointF(); point2 = QPointF(); numero=true; MyRectItem=new QGraphicsRectItem; rect = QRectF(); }
MyScene::MyScene(QString fileName) : QGraphicsScene() { QPixmap image = QPixmap(fileName); size=image.size(); impix=addPixmap(image); point1 = QPointF(); point2 = QPointF(); numero=true; MyRectItem=new QGraphicsRectItem; rect = QRectF(); SceneSelection = new QGraphicsScene; Selection = SceneSelection->addPixmap(image); }
void Scene::dropEvent(QDropEvent *e) { /* //dragEnterEventの後にくるイベント //ドロップの際の動作を記述する startPos = e->pos(); posx=startPos.x()-64; posy=startPos.y()-64; update(); */ QGraphicsPixmapItem *a = addPixmap(QPixmap(":pictgrams/picts/kasa_06.png")); a->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);//画像オブジェクトを動作、選択できるようにする }
// TODO: redesign in Qt way ;) // i.e. crop as opacity mask not a copy AvatarEditScene::AvatarEditScene(QObject *parent) : QGraphicsScene(parent) { setSceneRect(0, 0, 480, 360); isSizing = false; isDragged = false; crop = QRect(0, 0, 100, 100); // background setBackgroundBrush(QPixmap(":/images/transparent.png")); // scaled photo photoItem = addPixmap(QPixmap()); // gray it down photoBlurItem = addRect(QRect(), Qt::NoPen, QBrush(QColor(255, 255, 255, 127))); // crop cropItem = addPixmap(QPixmap()); // cropper QPixmap pixmap = getCropper(); cropper = pixmap.rect(); cropperItem = addPixmap(pixmap); cropperItem->setOpacity(0.5); }
void GameScene::showPauseText(bool show) { if(show) { m_pauseItem = addPixmap(PixmapCache::pauseText()); const auto center = m_pauseItem->boundingRect().center(); m_pauseItem->setPos(width() / 2 - center.x(), height() / 2 - center.y()); } else { delete m_pauseItem; m_pauseItem = nullptr; } }
SpriteScene::SpriteScene(QObject *parent) : QGraphicsScene(parent) { QGraphicsItem * dragon; QGraphicsItem * Frame; QGraphicsItem * Square; QList<QString > tmp; QFileInfo ourFile(currentFile); QString imgFileM; QPixmap sprite, mask; croc = new QGraphicsPixmapItem; sizer = new QGraphicsRectItem; mCurrentFrameX = 0; mCurrentFrameY = 0; x=0; y=0, dir=1; mPos = QPoint(0,0); sprite = QPixmap(currentFile); tmp = ourFile.fileName().split(".", QString::SkipEmptyParts); if(tmp.size()==2) imgFileM = tmp[0] + "m." + tmp[1]; else imgFileM = ""; mask = QPixmap( ourFile.absoluteDir().path() + "/" + imgFileM ); sprite.setMask(mask); mSpriteImage = QPixmap(sprite); draw(); Frame = addRect(0,0,100,100, QPen(Qt::gray, 1), Qt::transparent); Frame->setZValue(-10); croc->setPixmap(QPixmap(currentImage)); dragon = addPixmap(QPixmap(currentImage)); croc->setParentItem(dragon); dragon->setZValue(0); Square = addRect(0,0,0,0, QPen(Qt::NoPen), Qt::transparent); sizer->setRect(0,0,100,100); sizer->setPen(QPen(Qt::green)); sizer->setParentItem(Square); sizer->setZValue(3); //qDebug() << "Scene created"; }
SimulatorScene::SimulatorScene() : QGraphicsScene() { // Set Defaults _showGrid = true; _gridScale = DEFAULT_GRID_SCALE; setSceneRect(-500, -500, 1000, 1000); _img = QImage(320, 320, QImage::Format_RGB888); _pixmap = addPixmap(QPixmap::fromImage(_img)); _pixmap->setPos(-320, -320); _pixmap->setScale(2.0); // FixtureItem *fix = new FixtureItem; // addItem(fix); }
void GameScene::resized() { qDebug() << "GameScene::resized(): called"; //menuBackgroundRect->setRect(toFp(0), toFp(0), toFp(100), toFp(100)); mainMenu->setProperty("width", width()); mainMenu->setProperty("height", height()); QPixmap backgroundPixmap(":/images/background.png"); QPixmap scaledBackgroundPixmap; // check the ratio of the pixmap against the ratio of our scene if((qreal)backgroundPixmap.width() / (qreal)backgroundPixmap.height() > (qreal)width() / (qreal)height()) { scaledBackgroundPixmap = backgroundPixmap.scaledToHeight(height()); } else { scaledBackgroundPixmap = backgroundPixmap.scaledToWidth(width()); } this->removeItem(backgroundImage); delete backgroundImage; backgroundImage = addPixmap(scaledBackgroundPixmap); backgroundImage->setZValue(-1000); }
void ImageEditorScene::setImage(QString path) { QPixmap pixmap(path); if (m_pixmap) { removeItem(m_pixmap); DELETE(m_pixmap); } if (pixmap.isNull()) { hideEditingControls(); return; } m_pixmap = addPixmap(pixmap); m_pixmap->setZValue(2); m_image_path = path; emit newImageLoaded(); updateImageScale(); updateCropView(); updateSceneSize(); }
/*! \brief Constructor. Creates a new ProjectScene instance. \param pro the project pointer, not null. \param parent parent widget of this dialog, default value is 0. */ Ui::ProjectScene::ProjectScene(Core::Project *pro, QObject *parent /* = 0 */) : QGraphicsScene(parent), project(pro), currElement(0), gridVisible(false), currElementAdded(true), currElementAntialiasing(true), layerIndex(1) { // entry conditions Q_CHECK_PTR(pro); setBackgroundBrush(QBrush(appRes->grayGridImage())); if(project->backgroundImage().isNull()) { // from new addRect(0, 0, project->width(), project->height(), QPen(Qt::NoPen), QBrush(project->backgroundColor())); } else { // from open addPixmap(project->backgroundImage()); } setSceneRect(0, 0, project->width(), project->height()); }
void Scene::dropEvent(QGraphicsSceneDragDropEvent *event) { if(event->mimeData()->hasFormat("Picture")) { QByteArray buffer; QDataStream stream(&buffer, QIODevice::ReadOnly); QPixmap picture; buffer = event->mimeData()->data("Picture"); stream >> picture; QGraphicsPixmapItem *item = addPixmap(picture); item->setFlags(QGraphicsItem::ItemIsMovable); if (!internalMoving) { item->setPos(QPointF(event->scenePos().x() - picture.width()/2, event->scenePos().y() - picture.height()/2)); } else { item->setPos(event->scenePos()); item->moveBy(-relativePoint.x(), -relativePoint.y()); } internalMoving = false; event->accept(); } else
//! //! Constructor of the ParameterTypeIcon class. //! //! \param color The color for the parameter type icon. //! ParameterTypeIcon::ParameterTypeIcon ( const QColor &color ) { m_color = color; const QRect pinRect (0, 4, 15, 8); const QColor penColor (109, 109, 109); QPixmap normalPixmap (16, 16); QPainter painter; if (painter.begin(&normalPixmap)) { // get the background color from the application style's standard palette QColor backgroundColor = QApplication::style()->standardPalette().color(QPalette::Base); // fill the pixmap with the background color painter.fillRect(normalPixmap.rect(), QBrush(backgroundColor)); // draw the pin rect into the pixmap painter.setPen(QPen(penColor)); painter.setBrush(QBrush(m_color)); painter.drawRoundRect(pinRect); // end painting the pixmap if (painter.end()) { // create a bitmap for masking the pixmap QBitmap maskBitmap (normalPixmap.size()); if (painter.begin(&maskBitmap)) { // fill the bitmap with white (meaning transparent) painter.fillRect(maskBitmap.rect(), QBrush(QColor(Qt::white))); // draw the pin rect as black (meaning opaque) painter.setPen(QPen(QColor(Qt::black))); painter.setBrush(QBrush(QColor(Qt::black))); painter.drawRoundRect(pinRect); // end painting the bitmap and set it as mask for the pixmap if (painter.end()) normalPixmap.setMask(maskBitmap); } } } // add the pixmap to the icon addPixmap(normalPixmap); }
/*! Constructs an icon from a \a pixmap. */ QIcon::QIcon(const QPixmap &pixmap) :d(0) { addPixmap(pixmap); }
void WldScene::setItemPlacer(int itemType, unsigned long itemID) { if(cursor) {delete cursor; cursor=NULL;} WriteToLog(QtDebugMsg, QString("ItemPlacer -> set to type-%1 for ID-%2").arg(itemType).arg(itemID)); switch(itemType) { case 0: //Tiles { int j; bool noimage=true, found=false; bool isUser=false; noimage=true; isUser=false; //Check Index exists if(itemID < (unsigned int)index_tiles.size()) { j = index_tiles[itemID].i; if(j<pConfigs->main_wtiles.size()) { if(pConfigs->main_wtiles[j].id == itemID) found=true; } } //if Index found if(found) { //get neccesary element directly isUser=true; noimage=false; tImg = animates_Tiles[index_tiles[itemID].ai]->wholeImage(); } else { //fetching arrays for(j=0;j<uTiles.size();j++) { if(uTiles[j].id==itemID) { isUser=true; noimage=false; tImg = uTiles[j].image; break; } } j=pConfigs->getTileI(itemID); if(j>=0) { noimage=false; if(!isUser) tImg = pConfigs->main_wtiles[j].image; } } if((noimage)||(tImg.isNull())) { tImg=uTileImg; } WldPlacingItems::gridSz=pConfigs->default_grid; WldPlacingItems::gridOffset = QPoint(0, 0); WldPlacingItems::TileSet.id = itemID; long w = tImg.width(); long h = tImg.height()/( (pConfigs->main_wtiles[j].animated)?pConfigs->main_wtiles[j].frames:1); WldPlacingItems::itemW = w; WldPlacingItems::itemH = h; WldPlacingItems::flags.clear(); QPair<int, QVariant > flag; flag.first=0; flag.second="TILE"; WldPlacingItems::flags.push_back(flag); flag.first=1; flag.second=QString::number(itemID); WldPlacingItems::flags.push_back(flag); flag.first = 9; flag.second = QString::number(w); WldPlacingItems::flags.push_back(flag); flag.first = 10; flag.second = QString::number(h); WldPlacingItems::flags.push_back(flag); flag.first = 25; flag.second = "CURSOR"; WldPlacingItems::flags.push_back(flag); if(WldPlacingItems::placingMode==WldPlacingItems::PMODE_Square) { setSquareDrawer(); return; } WldPlacingItems::c_offset_x= qRound(qreal(w) / 2); WldPlacingItems::c_offset_y= qRound(qreal(h) / 2); if(WldPlacingItems::placingMode==WldPlacingItems::PMODE_Line) { setLineDrawer(); return; } cursor = addPixmap(tImg.copy(0,h*pConfigs->main_wtiles[j].display_frame,w,h)); //set data flags foreach(dataFlag_w flag, WldPlacingItems::flags) cursor->setData(flag.first, flag.second); cursor->setZValue(7000); cursor->setOpacity( 0.8 ); cursor->setVisible(false); cursor->setEnabled(true); placingItem=PLC_Tile; WldPlacingItems::TileSet.id = itemID; //flood fill uses 'item' cursor if(WldPlacingItems::placingMode==WldPlacingItems::PMODE_FloodFill) { setFloodFiller(); return; } SwitchEditingMode(MODE_PlacingNew); break; } case 1: //Sceneries { int j; bool noimage=true, found=false; bool isUser=false; noimage=true; isUser=false; //Check Index exists if(itemID < (unsigned int)index_scenes.size()) { j = index_scenes[itemID].i; if(j<pConfigs->main_wscene.size()) { if(pConfigs->main_wscene[j].id == itemID) found=true; } } //if Index found if(found) { //get neccesary element directly isUser=true; noimage=false; tImg = animates_Scenery[index_scenes[itemID].ai]->wholeImage(); } else { //fetching arrays for(j=0;j<uScenes.size();j++) { if(uScenes[j].id==itemID) { isUser=true; noimage=false; tImg = uScenes[j].image; break; } } j=pConfigs->getSceneI(itemID); if(j>=0) { noimage=false; if(!isUser) tImg = pConfigs->main_wscene[j].image; } } if((noimage)||(tImg.isNull())) { tImg=uSceneImg; } WldPlacingItems::gridSz=qRound(qreal(pConfigs->default_grid)/2); WldPlacingItems::gridOffset = QPoint(0, 0); WldPlacingItems::SceneSet.id = itemID; long w = WldPlacingItems::gridSz; long h = WldPlacingItems::gridSz; WldPlacingItems::itemW = w; WldPlacingItems::itemH = h; long iw = tImg.width(); long ih = tImg.height()/( (pConfigs->main_wscene[j].animated)?pConfigs->main_wscene[j].frames:1); WldPlacingItems::flags.clear(); QPair<int, QVariant > flag; flag.first=0; flag.second="SCENERY"; WldPlacingItems::flags.push_back(flag); flag.first=1; flag.second=QString::number(itemID); WldPlacingItems::flags.push_back(flag); flag.first = 9; flag.second = QString::number(w); WldPlacingItems::flags.push_back(flag); flag.first = 10; flag.second = QString::number(h); WldPlacingItems::flags.push_back(flag); flag.first = 25; flag.second = "CURSOR"; WldPlacingItems::flags.push_back(flag); if(WldPlacingItems::placingMode==WldPlacingItems::PMODE_Square) { setSquareDrawer(); return; } WldPlacingItems::c_offset_x= qRound(qreal(w) / 2); WldPlacingItems::c_offset_y= qRound(qreal(h) / 2); if(WldPlacingItems::placingMode==WldPlacingItems::PMODE_Line) { setLineDrawer(); return; } cursor = addPixmap(tImg.copy(0,ih * pConfigs->main_wscene[j].display_frame ,iw,ih)); //set data flags foreach(dataFlag_w flag, WldPlacingItems::flags) cursor->setData(flag.first, flag.second); cursor->setData(25, "CURSOR"); cursor->setZValue(7000); cursor->setOpacity( 0.8 ); cursor->setVisible(false); cursor->setEnabled(true); placingItem=PLC_Scene; WldPlacingItems::SceneSet.id = itemID; //flood fill uses 'item' cursor if(WldPlacingItems::placingMode==WldPlacingItems::PMODE_FloodFill) { setFloodFiller(); return; } SwitchEditingMode(MODE_PlacingNew); break; } case 2: //Path { int j; bool noimage=true, found=false; bool isUser=false; noimage=true; isUser=false; //Check Index exists if(itemID < (unsigned int)index_paths.size()) { j = index_paths[itemID].i; if(j<pConfigs->main_wpaths.size()) { if(pConfigs->main_wpaths[j].id == itemID) found=true; } } //if Index found if(found) { //get neccesary element directly isUser=true; noimage=false; tImg = animates_Paths[index_paths[itemID].ai]->wholeImage(); } else { //fetching arrays for(j=0;j<uPaths.size();j++) { if(uPaths[j].id==itemID) { isUser=true; noimage=false; tImg = uPaths[j].image; break; } } j=pConfigs->getBgoI(itemID); if(j>=0) { noimage=false; if(!isUser) tImg = pConfigs->main_wpaths[j].image; } } if((noimage)||(tImg.isNull())) { tImg=uPathImg; } WldPlacingItems::gridSz=pConfigs->default_grid; WldPlacingItems::gridOffset = QPoint(0, 0); WldPlacingItems::PathSet.id = itemID; long w = tImg.width(); long h = tImg.height()/( (pConfigs->main_wpaths[j].animated)?pConfigs->main_wpaths[j].frames:1); WldPlacingItems::itemW = w; WldPlacingItems::itemH = h; WldPlacingItems::flags.clear(); QPair<int, QVariant > flag; flag.first=0; flag.second="PATH"; WldPlacingItems::flags.push_back(flag); flag.first=1; flag.second=QString::number(itemID); WldPlacingItems::flags.push_back(flag); flag.first = 9; flag.second = QString::number(w); WldPlacingItems::flags.push_back(flag); flag.first = 10; flag.second = QString::number(h); WldPlacingItems::flags.push_back(flag); flag.first = 25; flag.second = "CURSOR"; WldPlacingItems::flags.push_back(flag); if(WldPlacingItems::placingMode==WldPlacingItems::PMODE_Square) { setSquareDrawer(); return; } WldPlacingItems::c_offset_x= qRound(qreal(w) / 2); WldPlacingItems::c_offset_y= qRound(qreal(h) / 2); if(WldPlacingItems::placingMode==WldPlacingItems::PMODE_Line) { setLineDrawer(); return; } cursor = addPixmap(tImg.copy(0,h * pConfigs->main_wpaths[j].display_frame, w ,h)); //set data flags foreach(dataFlag_w flag, WldPlacingItems::flags) cursor->setData(flag.first, flag.second); cursor->setData(25, "CURSOR"); cursor->setZValue(7000); cursor->setOpacity( 0.8 ); cursor->setVisible(false); cursor->setEnabled(true); placingItem=PLC_Path; WldPlacingItems::PathSet.id = itemID; //flood fill uses 'item' cursor if(WldPlacingItems::placingMode==WldPlacingItems::PMODE_FloodFill) { setFloodFiller(); return; } SwitchEditingMode(MODE_PlacingNew); break; } case 3: //Level { int j; bool noimage=true, found=false; bool isUser=false; noimage=true; isUser=false; //Check Index exists if(itemID < (unsigned int)index_levels.size()) { j = index_levels[itemID].i; if(j<pConfigs->main_wlevels.size()) { if(pConfigs->main_wlevels[j].id == itemID) found=true; } } //if Index found if(found) { //get neccesary element directly isUser=true; noimage=false; tImg = animates_Levels[index_levels[itemID].ai]->wholeImage(); } else { //fetching arrays for(j=0;j<uLevels.size();j++) { if(uLevels[j].id==itemID) { isUser=true; noimage=false; tImg = uLevels[j].image; break; } } j=pConfigs->getWLevelI(itemID); if(j>=0) { noimage=false; if(!isUser) tImg = pConfigs->main_wlevels[j].image; } } if((noimage)||(tImg.isNull())) { tImg=uLevelImg; } WldPlacingItems::gridSz=pConfigs->default_grid; WldPlacingItems::gridOffset = QPoint(0, 0); WldPlacingItems::LevelSet.id = itemID; long w = WldPlacingItems::gridSz; long h = WldPlacingItems::gridSz; long iw = tImg.width(); long ih = tImg.height()/( (pConfigs->main_wlevels[j].animated)?pConfigs->main_wlevels[j].frames:1); WldPlacingItems::itemW = w; WldPlacingItems::itemH = h; WldPlacingItems::flags.clear(); QPair<int, QVariant > flag; flag.first=0; flag.second="LEVEL"; WldPlacingItems::flags.push_back(flag); flag.first=1; flag.second=QString::number(itemID); WldPlacingItems::flags.push_back(flag); flag.first = 9; flag.second = QString::number(w); WldPlacingItems::flags.push_back(flag); flag.first = 10; flag.second = QString::number(h); WldPlacingItems::flags.push_back(flag); flag.first = 25; flag.second = "CURSOR"; WldPlacingItems::flags.push_back(flag); if(WldPlacingItems::placingMode==WldPlacingItems::PMODE_Square) { setSquareDrawer(); return; } WldPlacingItems::c_offset_x= qRound(qreal(w) / 2); WldPlacingItems::c_offset_y= qRound(qreal(h) / 2); if(WldPlacingItems::placingMode==WldPlacingItems::PMODE_Line) { setLineDrawer(); return; } cursor = addPixmap(tImg.copy(0, ih * pConfigs->main_wlevels[j].display_frame ,iw,ih)); int imgOffsetX = (int)qRound( -( qreal(tImg.width()) - qreal(WldPlacingItems::gridSz)) / 2 ); int imgOffsetY = (int)qRound( -qreal( tImg.height()/( (pConfigs->main_wlevels[j].animated)?pConfigs->main_wlevels[j].frames:1)) + WldPlacingItems::gridSz); ((QGraphicsPixmapItem*)cursor)->setOffset(imgOffsetX, imgOffsetY ); //set data flags foreach(dataFlag_w flag, WldPlacingItems::flags) cursor->setData(flag.first, flag.second); cursor->setData(25, "CURSOR"); cursor->setZValue(7000); cursor->setOpacity( 0.8 ); cursor->setVisible(false); cursor->setEnabled(true); placingItem=PLC_Level; WldPlacingItems::LevelSet.id = itemID; //flood fill uses 'item' cursor if(WldPlacingItems::placingMode==WldPlacingItems::PMODE_FloodFill) { setFloodFiller(); return; } SwitchEditingMode(MODE_PlacingNew); break; } case 4: //MusicBox placingItem=PLC_Musicbox; WldPlacingItems::MusicSet.id = itemID; WldPlacingItems::gridSz=32; WldPlacingItems::gridOffset = QPoint(0,0); WldPlacingItems::c_offset_x = 16; WldPlacingItems::c_offset_y = 16; cursor = addRect(0,0, 32, 32); cursor->setData(0, "MUSICBOX"); cursor->setData(1, QString::number(itemID)); cursor->setData(9, QString::number(32)); cursor->setData(10, QString::number(32)); ((QGraphicsRectItem *)cursor)->setBrush(QBrush(Qt::yellow)); ((QGraphicsRectItem *)cursor)->setPen(QPen(Qt::yellow, 2,Qt::SolidLine)); cursor->setData(25, "CURSOR"); cursor->setZValue(7000); cursor->setOpacity( 0.8 ); cursor->setVisible(false); cursor->setEnabled(true); SwitchEditingMode(MODE_PlacingNew); break; case 5: //Get point from a world map placingItem=MODE_SetPoint; WldPlacingItems::MusicSet.id = itemID; WldPlacingItems::gridSz=32; WldPlacingItems::gridOffset = QPoint(0,0); WldPlacingItems::c_offset_x = 16; WldPlacingItems::c_offset_y = 16; cursor = addRect(0,0, 32, 32); cursor->setData(0, "WorldMapPoint"); cursor->setData(1, QString::number(itemID)); cursor->setData(9, QString::number(32)); cursor->setData(10, QString::number(32)); ((QGraphicsRectItem *)cursor)->setBrush(QBrush(Qt::yellow)); ((QGraphicsRectItem *)cursor)->setPen(QPen(Qt::yellow, 2,Qt::SolidLine)); cursor->setData(25, "CURSOR"); cursor->setZValue(7000); cursor->setOpacity( 0.8 ); cursor->setVisible(false); cursor->setEnabled(true); SwitchEditingMode(MODE_SetPoint); // restore last point if(!selectedPointNotUsed) setPoint(selectedPoint); break; default: break; } if(itemType!=5) SwitchEditingMode(MODE_PlacingNew); contextMenuOpened=false; }